[1/3] net/netvsc: support receive without vlan strip

Message ID 20181214012621.15213-2-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/netvsc: misc fixes |

Checks

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

Commit Message

Stephen Hemminger Dec. 14, 2018, 1:26 a.m. UTC
  In some cases, VLAN stripping is not desireable. If necessary
re-insert stripped vlan tag.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/netvsc/hn_ethdev.c | 2 ++
 drivers/net/netvsc/hn_rxtx.c   | 8 ++++++++
 drivers/net/netvsc/hn_var.h    | 5 +++--
 3 files changed, 13 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit Dec. 14, 2018, 4:09 p.m. UTC | #1
On 12/14/2018 1:26 AM, Stephen Hemminger wrote:
> In some cases, VLAN stripping is not desireable. If necessary
> re-insert stripped vlan tag.
> 
> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>

<...>

> @@ -501,6 +501,14 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb,
>  	if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) {
>  		m->vlan_tci = info->vlan_info;
>  		m->ol_flags |= PKT_RX_VLAN_STRIPPED | PKT_RX_VLAN;
> +
> +		/* NDIS always strips tag, put it back if necessary */
> +		if (!hv->vlan_strip && rte_vlan_insert(&m)) {

Should 'PKT_RX_VLAN_STRIPPED' flag removed when vlan inserted back?
  
Stephen Hemminger Dec. 14, 2018, 4:28 p.m. UTC | #2
On Fri, 14 Dec 2018 16:09:33 +0000
Ferruh Yigit <ferruh.yigit@intel.com> wrote:

> On 12/14/2018 1:26 AM, Stephen Hemminger wrote:
> > In some cases, VLAN stripping is not desireable. If necessary
> > re-insert stripped vlan tag.
> > 
> > Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>  
> 
> <...>
> 
> > @@ -501,6 +501,14 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb,
> >  	if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) {
> >  		m->vlan_tci = info->vlan_info;
> >  		m->ol_flags |= PKT_RX_VLAN_STRIPPED | PKT_RX_VLAN;
> > +
> > +		/* NDIS always strips tag, put it back if necessary */
> > +		if (!hv->vlan_strip && rte_vlan_insert(&m)) {  
> 
> Should 'PKT_RX_VLAN_STRIPPED' flag removed when vlan inserted back?

This is already done by rte_vlan_insert()
  
Ferruh Yigit Dec. 17, 2018, 10:27 a.m. UTC | #3
On 12/14/2018 4:28 PM, Stephen Hemminger wrote:
> On Fri, 14 Dec 2018 16:09:33 +0000
> Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> 
>> On 12/14/2018 1:26 AM, Stephen Hemminger wrote:
>>> In some cases, VLAN stripping is not desireable. If necessary
>>> re-insert stripped vlan tag.
>>>
>>> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>  
>>
>> <...>
>>
>>> @@ -501,6 +501,14 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb,
>>>  	if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) {
>>>  		m->vlan_tci = info->vlan_info;
>>>  		m->ol_flags |= PKT_RX_VLAN_STRIPPED | PKT_RX_VLAN;
>>> +
>>> +		/* NDIS always strips tag, put it back if necessary */
>>> +		if (!hv->vlan_strip && rte_vlan_insert(&m)) {  
>>
>> Should 'PKT_RX_VLAN_STRIPPED' flag removed when vlan inserted back?
> 
> This is already done by rte_vlan_insert()

Yes it does, so it is OK.
  

Patch

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index b330bf3d7255..d7ac0c7320b0 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -378,6 +378,8 @@  static int hn_dev_configure(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 
+	hv->vlan_strip = !!(rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP);
+
 	err = hn_rndis_conf_offload(hv, txmode->offloads,
 				    rxmode->offloads);
 	if (err) {
diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index f4a36641b6c3..622a83983e10 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -501,6 +501,14 @@  static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb,
 	if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) {
 		m->vlan_tci = info->vlan_info;
 		m->ol_flags |= PKT_RX_VLAN_STRIPPED | PKT_RX_VLAN;
+
+		/* NDIS always strips tag, put it back if necessary */
+		if (!hv->vlan_strip && rte_vlan_insert(&m)) {
+			PMD_DRV_LOG(DEBUG, "vlan insert failed");
+			++rxq->stats.errors;
+			rte_pktmbuf_free(m);
+			return;
+		}
 	}
 
 	if (info->csum_info != HN_NDIS_RXCSUM_INFO_INVALID) {
diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h
index e1072c7cfa55..cd173f6af942 100644
--- a/drivers/net/netvsc/hn_var.h
+++ b/drivers/net/netvsc/hn_var.h
@@ -97,8 +97,9 @@  struct hn_data {
 	struct rte_eth_dev *vf_dev;		/* Subordinate device */
 	rte_spinlock_t  vf_lock;
 	uint16_t	port_id;
-	bool		closed;
-	bool		vf_present;
+	uint8_t		closed;
+	uint8_t		vf_present;
+	uint8_t		vlan_strip;
 	uint32_t	link_status;
 	uint32_t	link_speed;