Skip to content

Commit 2b8b093

Browse files
committed
Add vlan_filter argument in config.ini for RSS with vlan.
Set Rx VLAN filter, and then the dirvier(such as MLX5) will set FLOW RSS to enable L3/L4 RSS below vlan hdr. This action won't need after DPDK-20.11.
1 parent 49a21bc commit 2b8b093

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

config.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ tso=0
2424
# HW vlan strip, default: enabled.
2525
vlan_strip=1
2626

27+
# Set vlan filter id, to enable L3/L4 RSS below vlan hdr.
28+
# the format is same as port_list
29+
#vlan_filter=1,2,4-6
30+
2731
# sleep when no pkts incomming
2832
# unit: microseconds
2933
idle_sleep=0

lib/ff_config.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,14 @@ parse_port_slave_list(struct ff_port_cfg *cfg, const char *v_str)
367367
return res;
368368
}
369369

370+
static int
371+
parse_vlan_filter_list(struct ff_config *cfg, const char *v_str)
372+
{
373+
cfg->dpdk.nb_vlan_filter = DPDK_MAX_VLAN_FILTER;
374+
uint16_t *vlan_filter = cfg->dpdk.vlan_filter_id;
375+
return __parse_config_list(vlan_filter, &cfg->dpdk.nb_vlan_filter, v_str);
376+
}
377+
370378
static int
371379
vip_cfg_handler(struct ff_port_cfg *cur)
372380
{
@@ -689,6 +697,8 @@ ini_parse_handler(void* user, const char* section, const char* name,
689697
pconfig->dpdk.tx_csum_offoad_skip = atoi(value);
690698
} else if (MATCH("dpdk", "vlan_strip")) {
691699
pconfig->dpdk.vlan_strip = atoi(value);
700+
} else if (MATCH("dpdk", "vlan_filter")) {
701+
return parse_vlan_filter_list(pconfig, value);
692702
} else if (MATCH("dpdk", "idle_sleep")) {
693703
pconfig->dpdk.idle_sleep = atoi(value);
694704
} else if (MATCH("dpdk", "pkt_tx_delay")) {

lib/ff_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extern "C" {
3535
#define DPDK_CONFIG_NUM 16
3636
#define DPDK_CONFIG_MAXLEN 256
3737
#define DPDK_MAX_LCORE 128
38+
#define DPDK_MAX_VLAN_FILTER 128
3839
#define PCAP_SNAP_MINLEN 94
3940
#define PCAP_SAVE_MINLEN (2<<22)
4041

@@ -150,6 +151,8 @@ struct ff_config {
150151
int tso;
151152
int tx_csum_offoad_skip;
152153
int vlan_strip;
154+
int nb_vlan_filter;
155+
uint16_t vlan_filter_id[DPDK_MAX_VLAN_FILTER];
153156
int symmetric_rss;
154157

155158
/* sleep x microseconds when no pkts incomming */

lib/ff_dpdk_if.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,21 @@ init_port_start(void)
658658
if (ff_global_cfg.dpdk.vlan_strip) {
659659
if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_VLAN_STRIP) {
660660
port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
661+
printf("RX vlan strip offload supported\n");
662+
}
663+
}
664+
665+
/*
666+
* Set Rx VLAN filter, and then the dirvier(such as MLX5) will set
667+
* FLOW RSS to enable L3/L4 RSS below vlan hdr.
668+
* This action won't need after DPDK-20.11.
669+
*/
670+
if (ff_global_cfg.dpdk.nb_vlan_filter) {
671+
if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_VLAN_FILTER) {
672+
port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
673+
printf("RX vlan filter offload supported\n");
674+
} else {
675+
printf("RX vlan filter offload not supported\n");
661676
}
662677
}
663678

@@ -730,6 +745,24 @@ init_port_start(void)
730745
return ret;
731746
}
732747

748+
/* Enable vlan filter for RSS */
749+
if (ff_global_cfg.dpdk.nb_vlan_filter) {
750+
uint16_t vlan_id ;
751+
int on = 1, vlan_idx;
752+
753+
for (vlan_idx = 0; vlan_idx < ff_global_cfg.dpdk.nb_vlan_filter; vlan_idx++) {
754+
vlan_id = ff_global_cfg.dpdk.vlan_filter_id[vlan_idx];
755+
756+
if (rte_eth_dev_vlan_filter(port_id, vlan_id, on)) {
757+
printf("Port %u set vlan %u on %d failed.\n",
758+
port_id, vlan_id, on);
759+
} else {
760+
printf("Port %u set vlan %u on %d success.\n",
761+
port_id, vlan_id, on);
762+
}
763+
}
764+
}
765+
733766
static uint16_t nb_rxd = RX_QUEUE_SIZE;
734767
static uint16_t nb_txd = TX_QUEUE_SIZE;
735768
ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_id, &nb_rxd, &nb_txd);

0 commit comments

Comments
 (0)