net/ice/base: add VLAN TPID for VLAN filters
authorQi Zhang <qi.z.zhang@intel.com>
Thu, 21 Jan 2021 01:07:41 +0000 (09:07 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 29 Jan 2021 17:16:07 +0000 (18:16 +0100)
Currently VLAN filters via RID4 are only based on VLAN ID. However, with
incoming support for Double VLAN Mode (DVM), the driver needs to be able
to support filtering on VLAN ID + VLAN TPID (i.e. 0x8100, 0x88a8, etc.).
Add support for this by adding two fields to the ice_fltr_info
structure. First, add the tpid_valid field so the code can determine
whether or not to overwrite the default 0x8100 value for programming
packets or use the tpid field.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
drivers/net/ice/base/ice_switch.c
drivers/net/ice/base/ice_switch.h

index 692a147..277623d 100644 (file)
@@ -14,6 +14,7 @@
 #define ICE_PPP_IPV6_PROTO_ID          0x0057
 #define ICE_IPV6_ETHER_ID              0x86DD
 #define ICE_TCP_PROTO_ID               0x06
+#define ICE_ETH_P_8021Q                        0x8100
 
 /* Dummy ethernet header needed in the ice_aqc_sw_rules_elem
  * struct to configure any switch filter rules.
@@ -3441,6 +3442,7 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
                 struct ice_aqc_sw_rules_elem *s_rule, enum ice_adminq_opc opc)
 {
        u16 vlan_id = ICE_MAX_VLAN_ID + 1;
+       u16 vlan_tpid = ICE_ETH_P_8021Q;
        void *daddr = NULL;
        u16 eth_hdr_sz;
        u8 *eth_hdr;
@@ -3513,6 +3515,8 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
                break;
        case ICE_SW_LKUP_VLAN:
                vlan_id = f_info->l_data.vlan.vlan_id;
+               if (f_info->l_data.vlan.tpid_valid)
+                       vlan_tpid = f_info->l_data.vlan.tpid;
                if (f_info->fltr_act == ICE_FWD_TO_VSI ||
                    f_info->fltr_act == ICE_FWD_TO_VSI_LIST) {
                        act |= ICE_SINGLE_ACT_PRUNE;
@@ -3556,6 +3560,8 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
        if (!(vlan_id > ICE_MAX_VLAN_ID)) {
                off = (_FORCE_ __be16 *)(eth_hdr + ICE_ETH_VLAN_TCI_OFFSET);
                *off = CPU_TO_BE16(vlan_id);
+               off = (_FORCE_ __be16 *)(eth_hdr + ICE_ETH_ETHTYPE_OFFSET);
+               *off = CPU_TO_BE16(vlan_tpid);
        }
 
        /* Create the switch rule with the final dummy Ethernet header */
index c11c064..a0a7a2e 100644 (file)
@@ -160,6 +160,8 @@ struct ice_fltr_info {
                } mac_vlan;
                struct {
                        u16 vlan_id;
+                       u16 tpid;
+                       u8 tpid_valid;
                } vlan;
                /* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
                 * if just using ethertype as filter. Set lkup_type as