Add support for VLAN insert and stripping 67/64467/2
authorXavier Simonart <xavier.simonart@intel.com>
Sun, 4 Nov 2018 16:29:43 +0000 (17:29 +0100)
committerXavier Simonart <xavier.simonart@intel.com>
Wed, 5 Dec 2018 11:46:00 +0000 (12:46 +0100)
JIRA: SAMPLEVNF-149

VLAN can be enabled on a port by adding "vlan=yes" in the port section.
When VLAN is enabled on a port, then DEV_RX_OFFLOAD_VLAN_STRIP
and DEV_TX_OFFLOAD_VLAN_INSERT are enabled (if device supports it).
This will cause VLAN to be stripped from any packets received with
the proper tag, and VLAN to be added for any packets being transmitted.
The VLAN ID themselves are configured through the physical function
using something like (where ens801f1 isthe PF):
ip link set ens801f1 vf 0 vlan 1111

Change-Id: I945c87b0c18565da479ecaa08e5ffce91232a7ce
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
VNFs/DPPD-PROX/prox_args.c
VNFs/DPPD-PROX/prox_port_cfg.c

index c09c563..59c514f 100644 (file)
@@ -559,6 +559,23 @@ static int get_port_cfg(unsigned sindex, char *str, void *data)
                else
                        cfg->requested_rx_offload &= ~DEV_RX_OFFLOAD_CRC_STRIP;
        }
+       else if (STR_EQ(str, "vlan")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(18,8,0,1)
+               uint32_t val;
+               if (parse_bool(&val, pkey)) {
+                       return -1;
+               }
+               if (val) {
+                       cfg->requested_rx_offload |= DEV_RX_OFFLOAD_VLAN_STRIP;
+                       cfg->requested_tx_offload |= DEV_TX_OFFLOAD_VLAN_INSERT;
+               } else {
+                       cfg->requested_rx_offload &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
+                       cfg->requested_tx_offload &= ~DEV_TX_OFFLOAD_VLAN_INSERT;
+               }
+#else
+               plog_warn("vlan option not supported : update DPDK at least to 18.08 to support this option\n");
+#endif
+       }
        else if (STR_EQ(str, "mtu size")) {
                uint32_t val;
                if (parse_int(&val, pkey)) {
index a71d0cc..661b671 100644 (file)
@@ -460,6 +460,7 @@ static void init_port(struct prox_port_cfg *port_cfg)
 #if RTE_VERSION >= RTE_VERSION_NUM(18,8,0,1)
        CONFIGURE_RX_OFFLOAD(DEV_RX_OFFLOAD_CRC_STRIP);
        CONFIGURE_RX_OFFLOAD(DEV_RX_OFFLOAD_JUMBO_FRAME);
+       CONFIGURE_RX_OFFLOAD(DEV_RX_OFFLOAD_VLAN_STRIP);
 #else
        if (port_cfg->requested_rx_offload & DEV_RX_OFFLOAD_CRC_STRIP) {
                port_cfg->port_conf.rxmode.hw_strip_crc = 1;
@@ -473,6 +474,7 @@ static void init_port(struct prox_port_cfg *port_cfg)
 #if RTE_VERSION >= RTE_VERSION_NUM(18,8,0,1)
        CONFIGURE_TX_OFFLOAD(DEV_TX_OFFLOAD_IPV4_CKSUM);
        CONFIGURE_TX_OFFLOAD(DEV_TX_OFFLOAD_UDP_CKSUM);
+       CONFIGURE_TX_OFFLOAD(DEV_TX_OFFLOAD_VLAN_INSERT);
 #else
        if ((port_cfg->dev_info.tx_offload_capa & (DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM)) == 0) {
                port_cfg->tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOOFFLOADS;