forked from cisco-system-traffic-generator/trex-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dpdk_port_map.cpp
54 lines (38 loc) · 1.1 KB
/
dpdk_port_map.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdint.h>
#include "trex_defs.h"
#include "dpdk_port_map.h"
#include <assert.h>
/* default MAP == direct */
CTRexPortMapper::CTRexPortMapper(){
m_max_trex_vports = TREX_MAX_PORTS;
m_max_rte_eth_ports = TREX_MAX_PORTS;
int i;
for (i=0; i<TREX_MAX_PORTS; i++) {
m_map[i]=i;
m_rmap[i]=i;
}
}
void CTRexPortMapper::set(uint8_t rte_ports,dpdk_map_args_t & pmap){
m_max_trex_vports = pmap.size();
m_max_rte_eth_ports =rte_ports;
int i;
for (i=0; i<pmap.size(); i++) {
set_map(i, pmap[i]);
set_rmap(pmap[i], i); /* set reverse */
}
}
CTRexPortMapper * CTRexPortMapper::m_ins;
CTRexPortMapper * CTRexPortMapper::Ins(){
if (!m_ins) {
m_ins = new CTRexPortMapper();
}
return (m_ins);
}
void CTRexPortMapper::Dump(FILE *fd){
int i;
fprintf(fd," TRex port mapping \n");
fprintf(fd," ----------------- \n");
for (i=0; i<(int)m_max_trex_vports; i++) {
fprintf(fd," TRex vport: %d dpdk_rte_eth: %d \n",i,(int)m_map[i]);
}
}