]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: mvpp2: prs: Fix parser range for VID filtering
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Tue, 11 Jun 2019 09:51:42 +0000 (11:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Jun 2019 06:15:14 +0000 (08:15 +0200)
[ Upstream commit 46b0090a6636cf34c0e856f15dd03e15ba4cdda6 ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c

index 392fd895f27826e81153f230603fa37b8e921fcc..e0da4db3bf564149aa7636f68f92ee56b97c40df 100644 (file)
@@ -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)