linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering
@ 2019-06-11  9:51 Maxime Chevallier
  2019-06-11  9:51 ` [PATCH net 1/2] net: mvpp2: prs: Fix parser range " Maxime Chevallier
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Maxime Chevallier @ 2019-06-11  9:51 UTC (permalink / raw)
  To: davem
  Cc: Maxime Chevallier, netdev, linux-kernel, Antoine Tenart,
	thomas.petazzoni, gregory.clement, miquel.raynal, nadavh,
	stefanc, mw

This series fixes some issues with VID filtering offload, mainly due to
the wrong ranges being used in the TCAM header parser.

The first patch fixes a bug where removing a VLAN from a port's
whitelist would also remove it from other port's, if they are on the
same PPv2 instance.

The second patch makes so that we don't invalidate the wrong TCAM
entries when clearing the whole whitelist.

Maxime Chevallier (2):
  net: mvpp2: prs: Fix parser range for VID filtering
  net: mvpp2: prs: Use the correct helpers when removing all VID filters

 .../net/ethernet/marvell/mvpp2/mvpp2_prs.c    | 23 ++++++++++---------
 1 file changed, 12 insertions(+), 11 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/2] net: mvpp2: prs: Fix parser range for VID filtering
  2019-06-11  9:51 [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering Maxime Chevallier
@ 2019-06-11  9:51 ` Maxime Chevallier
  2019-06-11  9:51 ` [PATCH net 2/2] net: mvpp2: prs: Use the correct helpers when removing all VID filters Maxime Chevallier
  2019-06-12 18:13 ` [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2019-06-11  9:51 UTC (permalink / raw)
  To: davem
  Cc: Maxime Chevallier, netdev, linux-kernel, Antoine Tenart,
	thomas.petazzoni, gregory.clement, miquel.raynal, nadavh,
	stefanc, mw, Yuri Chipchev

VID filtering is implemented in the Header Parser, with one range of 11
vids being assigned for each no-loopback port.

Make sure we use the per-port range when looking for existing entries in
the Parser.

Since we used a global range instead of a per-port one, this causes VIDs
to be removed from the whitelist from all ports of the same PPv2
instance.

Fixes: 56beda3db602 ("net: mvpp2: Add hardware offloading for VLAN filtering")
Suggested-by: Yuri Chipchev <yuric@marvell.com>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
index 392fd895f278..e0da4db3bf56 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
@@ -1905,8 +1905,7 @@ static int mvpp2_prs_ip6_init(struct mvpp2 *priv)
 }
 
 /* Find tcam entry with matched pair <vid,port> */
-static int mvpp2_prs_vid_range_find(struct mvpp2 *priv, int pmap, u16 vid,
-				    u16 mask)
+static int mvpp2_prs_vid_range_find(struct mvpp2_port *port, u16 vid, u16 mask)
 {
 	unsigned char byte[2], enable[2];
 	struct mvpp2_prs_entry pe;
@@ -1914,13 +1913,13 @@ static int mvpp2_prs_vid_range_find(struct mvpp2 *priv, int pmap, u16 vid,
 	int tid;
 
 	/* Go through the all entries with MVPP2_PRS_LU_VID */
-	for (tid = MVPP2_PE_VID_FILT_RANGE_START;
-	     tid <= MVPP2_PE_VID_FILT_RANGE_END; tid++) {
-		if (!priv->prs_shadow[tid].valid ||
-		    priv->prs_shadow[tid].lu != MVPP2_PRS_LU_VID)
+	for (tid = MVPP2_PRS_VID_PORT_FIRST(port->id);
+	     tid <= MVPP2_PRS_VID_PORT_LAST(port->id); tid++) {
+		if (!port->priv->prs_shadow[tid].valid ||
+		    port->priv->prs_shadow[tid].lu != MVPP2_PRS_LU_VID)
 			continue;
 
-		mvpp2_prs_init_from_hw(priv, &pe, tid);
+		mvpp2_prs_init_from_hw(port->priv, &pe, tid);
 
 		mvpp2_prs_tcam_data_byte_get(&pe, 2, &byte[0], &enable[0]);
 		mvpp2_prs_tcam_data_byte_get(&pe, 3, &byte[1], &enable[1]);
@@ -1950,7 +1949,7 @@ int mvpp2_prs_vid_entry_add(struct mvpp2_port *port, u16 vid)
 	memset(&pe, 0, sizeof(pe));
 
 	/* Scan TCAM and see if entry with this <vid,port> already exist */
-	tid = mvpp2_prs_vid_range_find(priv, (1 << port->id), vid, mask);
+	tid = mvpp2_prs_vid_range_find(port, vid, mask);
 
 	reg_val = mvpp2_read(priv, MVPP2_MH_REG(port->id));
 	if (reg_val & MVPP2_DSA_EXTENDED)
@@ -2008,7 +2007,7 @@ void mvpp2_prs_vid_entry_remove(struct mvpp2_port *port, u16 vid)
 	int tid;
 
 	/* Scan TCAM and see if entry with this <vid,port> already exist */
-	tid = mvpp2_prs_vid_range_find(priv, (1 << port->id), vid, 0xfff);
+	tid = mvpp2_prs_vid_range_find(port, vid, 0xfff);
 
 	/* No such entry */
 	if (tid < 0)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/2] net: mvpp2: prs: Use the correct helpers when removing all VID filters
  2019-06-11  9:51 [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering Maxime Chevallier
  2019-06-11  9:51 ` [PATCH net 1/2] net: mvpp2: prs: Fix parser range " Maxime Chevallier
@ 2019-06-11  9:51 ` Maxime Chevallier
  2019-06-12 18:13 ` [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2019-06-11  9:51 UTC (permalink / raw)
  To: davem
  Cc: Maxime Chevallier, netdev, linux-kernel, Antoine Tenart,
	thomas.petazzoni, gregory.clement, miquel.raynal, nadavh,
	stefanc, mw, Yuri Chipchev

When removing all VID filters, the mvpp2_prs_vid_entry_remove would be
called with the TCAM id incorrectly used as a VID, causing the wrong
TCAM entries to be invalidated.

Fix this by directly invalidating entries in the VID range.

Fixes: 56beda3db602 ("net: mvpp2: Add hardware offloading for VLAN filtering")
Suggested-by: Yuri Chipchev <yuric@marvell.com>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
index e0da4db3bf56..ae2240074d8e 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
@@ -2025,8 +2025,10 @@ void mvpp2_prs_vid_remove_all(struct mvpp2_port *port)
 
 	for (tid = MVPP2_PRS_VID_PORT_FIRST(port->id);
 	     tid <= MVPP2_PRS_VID_PORT_LAST(port->id); tid++) {
-		if (priv->prs_shadow[tid].valid)
-			mvpp2_prs_vid_entry_remove(port, tid);
+		if (priv->prs_shadow[tid].valid) {
+			mvpp2_prs_hw_inv(priv, tid);
+			priv->prs_shadow[tid].valid = false;
+		}
 	}
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering
  2019-06-11  9:51 [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering Maxime Chevallier
  2019-06-11  9:51 ` [PATCH net 1/2] net: mvpp2: prs: Fix parser range " Maxime Chevallier
  2019-06-11  9:51 ` [PATCH net 2/2] net: mvpp2: prs: Use the correct helpers when removing all VID filters Maxime Chevallier
@ 2019-06-12 18:13 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-06-12 18:13 UTC (permalink / raw)
  To: maxime.chevallier
  Cc: netdev, linux-kernel, antoine.tenart, thomas.petazzoni,
	gregory.clement, miquel.raynal, nadavh, stefanc, mw

From: Maxime Chevallier <maxime.chevallier@bootlin.com>
Date: Tue, 11 Jun 2019 11:51:41 +0200

> This series fixes some issues with VID filtering offload, mainly due to
> the wrong ranges being used in the TCAM header parser.
> 
> The first patch fixes a bug where removing a VLAN from a port's
> whitelist would also remove it from other port's, if they are on the
> same PPv2 instance.
> 
> The second patch makes so that we don't invalidate the wrong TCAM
> entries when clearing the whole whitelist.

Series applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 2/2] net: mvpp2: prs: Use the correct helpers when removing all VID filters
  2019-06-10 13:50 [PATCH net 1/2] net: mvpp2: prs: Fix parser range " Maxime Chevallier
@ 2019-06-10 13:50 ` Maxime Chevallier
  0 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2019-06-10 13:50 UTC (permalink / raw)
  To: davem
  Cc: Maxime Chevallier, netdev, linux-kernel, Antoine Tenart,
	thomas.petazzoni, gregory.clement, miquel.raynal, nadavh,
	stefanc, mw, Yuri Chipchev

When removing all VID filters, the mvpp2_prs_vid_entry_remove would be
called with the TCAM id incorrectly used as a VID, causing the wrong
TCAM entries to be invalidated.

Fix this by directly invalidating entries in the VID range.

Fixes: 56beda3db602 ("net: mvpp2: Add hardware offloading for VLAN filtering")
Suggested-by: Yuri Chipchev <yuric@marvell.com>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
index e0da4db3bf56..ae2240074d8e 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
@@ -2025,8 +2025,10 @@ void mvpp2_prs_vid_remove_all(struct mvpp2_port *port)
 
 	for (tid = MVPP2_PRS_VID_PORT_FIRST(port->id);
 	     tid <= MVPP2_PRS_VID_PORT_LAST(port->id); tid++) {
-		if (priv->prs_shadow[tid].valid)
-			mvpp2_prs_vid_entry_remove(port, tid);
+		if (priv->prs_shadow[tid].valid) {
+			mvpp2_prs_hw_inv(priv, tid);
+			priv->prs_shadow[tid].valid = false;
+		}
 	}
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-06-12 18:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-11  9:51 [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering Maxime Chevallier
2019-06-11  9:51 ` [PATCH net 1/2] net: mvpp2: prs: Fix parser range " Maxime Chevallier
2019-06-11  9:51 ` [PATCH net 2/2] net: mvpp2: prs: Use the correct helpers when removing all VID filters Maxime Chevallier
2019-06-12 18:13 ` [PATCH net 0/2] net: mvpp2: prs: Fixes for VID filtering David Miller
  -- strict thread matches above, loose matches on Subject: below --
2019-06-10 13:50 [PATCH net 1/2] net: mvpp2: prs: Fix parser range " Maxime Chevallier
2019-06-10 13:50 ` [PATCH net 2/2] net: mvpp2: prs: Use the correct helpers when removing all VID filters Maxime Chevallier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).