Skip to content

Commit e32d4e6

Browse files
venkatkumarduvvurudavem330
authored andcommitted
bnxt_en: Fix the vlan_tci exact match check.
It is possible that OVS may set don’t care for DEI/CFI bit in vlan_tci mask. Hence, checking for vlan_tci exact match will endup in a vlan flow rejection. This patch fixes the problem by checking for vlan_pcp and vid separately, instead of checking for the entire vlan_tci. Fixes: e85a9be (bnxt_en: do not allow wildcard matches for L2 flows) Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 26420d9 commit e32d4e6

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
#define BNXT_FID_INVALID 0xffff
2828
#define VLAN_TCI(vid, prio) ((vid) | ((prio) << VLAN_PRIO_SHIFT))
2929

30+
#define is_vlan_pcp_wildcarded(vlan_tci_mask) \
31+
((ntohs(vlan_tci_mask) & VLAN_PRIO_MASK) == 0x0000)
32+
#define is_vlan_pcp_exactmatch(vlan_tci_mask) \
33+
((ntohs(vlan_tci_mask) & VLAN_PRIO_MASK) == VLAN_PRIO_MASK)
34+
#define is_vlan_pcp_zero(vlan_tci) \
35+
((ntohs(vlan_tci) & VLAN_PRIO_MASK) == 0x0000)
36+
#define is_vid_exactmatch(vlan_tci_mask) \
37+
((ntohs(vlan_tci_mask) & VLAN_VID_MASK) == VLAN_VID_MASK)
38+
3039
/* Return the dst fid of the func for flow forwarding
3140
* For PFs: src_fid is the fid of the PF
3241
* For VF-reps: src_fid the fid of the VF
@@ -389,6 +398,21 @@ static bool is_exactmatch(void *mask, int len)
389398
return true;
390399
}
391400

401+
static bool is_vlan_tci_allowed(__be16 vlan_tci_mask,
402+
__be16 vlan_tci)
403+
{
404+
/* VLAN priority must be either exactly zero or fully wildcarded and
405+
* VLAN id must be exact match.
406+
*/
407+
if (is_vid_exactmatch(vlan_tci_mask) &&
408+
((is_vlan_pcp_exactmatch(vlan_tci_mask) &&
409+
is_vlan_pcp_zero(vlan_tci)) ||
410+
is_vlan_pcp_wildcarded(vlan_tci_mask)))
411+
return true;
412+
413+
return false;
414+
}
415+
392416
static bool bits_set(void *key, int len)
393417
{
394418
const u8 *p = key;
@@ -803,9 +827,9 @@ static bool bnxt_tc_can_offload(struct bnxt *bp, struct bnxt_tc_flow *flow)
803827
/* Currently VLAN fields cannot be partial wildcard */
804828
if (bits_set(&flow->l2_key.inner_vlan_tci,
805829
sizeof(flow->l2_key.inner_vlan_tci)) &&
806-
!is_exactmatch(&flow->l2_mask.inner_vlan_tci,
807-
sizeof(flow->l2_mask.inner_vlan_tci))) {
808-
netdev_info(bp->dev, "Wildcard match unsupported for VLAN TCI\n");
830+
!is_vlan_tci_allowed(flow->l2_mask.inner_vlan_tci,
831+
flow->l2_key.inner_vlan_tci)) {
832+
netdev_info(bp->dev, "Unsupported VLAN TCI\n");
809833
return false;
810834
}
811835
if (bits_set(&flow->l2_key.inner_vlan_tpid,

0 commit comments

Comments
 (0)