ethdev: fix QinQ strip offload support

Message ID 1555240302-9771-1-git-send-email-viveksharma@marvell.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • ethdev: fix QinQ strip offload support
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Vivek Kumar Sharma April 14, 2019, 11:11 a.m.
From: Vivek Sharma <viveksharma@marvell.com>

Enable missing support for QinQ strip rx offload
in vlan offload set/get methods.

Fixes: cc9d0456b870 ("i40e: support double vlan stripping and insertion")
Cc: stable@dpdk.org

Signed-off-by: Vivek Sharma <viveksharma@marvell.com>
---
 lib/librte_ethdev/rte_ethdev.c | 17 +++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h |  5 ++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

Comments

Stephen Hemminger April 15, 2019, 3:54 p.m. | #1
On Sun, 14 Apr 2019 16:41:42 +0530
<viveksharma@marvell.com> wrote:

>  
> +	cur = !!(offload_mask & ETH_QINQ_STRIP_OFFLOAD);
> +	org = !!(dev->data->dev_conf.rxmode.offloads &
> +		 DEV_RX_OFFLOAD_QINQ_STRIP);
> +	if (cur != org) {
> +		if (cur)
> +			dev->data->dev_conf.rxmode.offloads |=
> +				DEV_RX_OFFLOAD_QINQ_STRIP;
> +		else
> +			dev->data->dev_conf.rxmode.offloads &=
> +				~DEV_RX_OFFLOAD_QINQ_STRIP;
> +		mask |= ETH_QINQ_STRIP_MASK;
> +	}
> +
>  	/*no change*/

Using a local (pointer) variable for dev->data->dev_conf.rxmode.offloads
would make the code more readable and lines shorter.
Rami Rosen April 15, 2019, 9:33 p.m. | #2
>Using a local (pointer) variable for dev->data->dev_conf.rxmode.offloads
>would make the code more readable and lines shorter.

+1

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 243beb4..222df4e 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -2770,6 +2770,19 @@  rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask)
 		mask |= ETH_VLAN_EXTEND_MASK;
 	}
 
+	cur = !!(offload_mask & ETH_QINQ_STRIP_OFFLOAD);
+	org = !!(dev->data->dev_conf.rxmode.offloads &
+		 DEV_RX_OFFLOAD_QINQ_STRIP);
+	if (cur != org) {
+		if (cur)
+			dev->data->dev_conf.rxmode.offloads |=
+				DEV_RX_OFFLOAD_QINQ_STRIP;
+		else
+			dev->data->dev_conf.rxmode.offloads &=
+				~DEV_RX_OFFLOAD_QINQ_STRIP;
+		mask |= ETH_QINQ_STRIP_MASK;
+	}
+
 	/*no change*/
 	if (mask == 0)
 		return ret;
@@ -2805,6 +2818,10 @@  rte_eth_dev_get_vlan_offload(uint16_t port_id)
 	    DEV_RX_OFFLOAD_VLAN_EXTEND)
 		ret |= ETH_VLAN_EXTEND_OFFLOAD;
 
+	if (dev->data->dev_conf.rxmode.offloads &
+	    DEV_RX_OFFLOAD_QINQ_STRIP)
+		ret |= DEV_RX_OFFLOAD_QINQ_STRIP;
+
 	return ret;
 }
 
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 40a068f..c1792f4 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -550,11 +550,13 @@  struct rte_eth_rss_conf {
 #define ETH_VLAN_STRIP_OFFLOAD   0x0001 /**< VLAN Strip  On/Off */
 #define ETH_VLAN_FILTER_OFFLOAD  0x0002 /**< VLAN Filter On/Off */
 #define ETH_VLAN_EXTEND_OFFLOAD  0x0004 /**< VLAN Extend On/Off */
+#define ETH_QINQ_STRIP_OFFLOAD   0x0008 /**< QINQ Strip On/Off */
 
 /* Definitions used for mask VLAN setting */
 #define ETH_VLAN_STRIP_MASK   0x0001 /**< VLAN Strip  setting mask */
 #define ETH_VLAN_FILTER_MASK  0x0002 /**< VLAN Filter  setting mask*/
 #define ETH_VLAN_EXTEND_MASK  0x0004 /**< VLAN Extend  setting mask*/
+#define ETH_QINQ_STRIP_MASK   0x0008 /**< QINQ Strip  setting mask */
 #define ETH_VLAN_ID_MAX       0x0FFF /**< VLAN ID is in lower 12 bits*/
 
 /* Definitions used for receive MAC address   */
@@ -965,7 +967,8 @@  struct rte_eth_conf {
 				 DEV_RX_OFFLOAD_TCP_CKSUM)
 #define DEV_RX_OFFLOAD_VLAN (DEV_RX_OFFLOAD_VLAN_STRIP | \
 			     DEV_RX_OFFLOAD_VLAN_FILTER | \
-			     DEV_RX_OFFLOAD_VLAN_EXTEND)
+			     DEV_RX_OFFLOAD_VLAN_EXTEND | \
+			     DEV_RX_OFFLOAD_QINQ_STRIP)
 
 /*
  * If new Rx offload capabilities are defined, they also must be