ice: Add support for VLAN priority filters in switchdev
Subsystems (2)
PATCH 1/1 ice: Add support for VLAN priority filters in switchdev
Enable support for adding TC rules that filter on the VLAN priority in switchdev mode.
VLAN priority are the first 3 bits of 16b switch field vector word which contain also vlan id value within its last 12 bits. When getting vlan priority value from tc match.key it
has to be shifted first to proper bits positions (by VLAN_PRIO_SHIFT) and then can be added to the joint 'vlan' field in ice_vlan_hdr in lookup element.
The mask of lookup changes accordingly. 0x0FFF - when only vlan id is added in filter 0xE000 - when only vlan priority is added in filter 0xEFFF - when both these values are specified
--- drivers/net/ethernet/intel/ice/ice_tc_lib.c | 73 ++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 4 +- 2 files changed, 60 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/ice/ice_tc_lib.c +57 -16
@@ -51,11 +51,11 @@ ice_tc_count_lkups(u32 flags, struct ice_tc_flower_lyr_2_4_hdrs *headers, lkups_cnt++;/* is VLAN specified? */ -if (flags &ICE_TC_FLWR_FIELD_VLAN ) +if (flags & (ICE_TC_FLWR_FIELD_VLAN |ICE_TC_FLWR_FIELD_VLAN_PRIO )) lkups_cnt++;/* is CVLAN specified? */ -if (flags &ICE_TC_FLWR_FIELD_CVLAN ) +if (flags & (ICE_TC_FLWR_FIELD_CVLAN |ICE_TC_FLWR_FIELD_CVLAN_PRIO )) lkups_cnt++;/* are PPPoE options specified? */
@@ -385,7 +385,7 @@ ice_tc_fill_rules(struct ice_hw *hw, u32 flags, }/* copy VLAN info */ -if (flags &ICE_TC_FLWR_FIELD_VLAN ) { +if (flags & (ICE_TC_FLWR_FIELD_VLAN |ICE_TC_FLWR_FIELD_VLAN_PRIO )) { vlan_tpid =be16_to_cpu (headers->vlan_hdr.vlan_tpid); rule_info->vlan_type =ice_check_supported_vlan_tpid (vlan_tpid);
@@ -394,15 +394,45 @@ ice_tc_fill_rules(struct ice_hw *hw, u32 flags, list[i].type =ICE_VLAN_EX ; else list[i].type = ICE_VLAN_OFOS; - list[i].h_u.vlan_hdr.vlan = headers->vlan_hdr.vlan_id; - list[i].m_u.vlan_hdr.vlan =cpu_to_be16 (0xFFFF ); + +if (flags &ICE_TC_FLWR_FIELD_VLAN ) { + list[i].h_u.vlan_hdr.vlan = headers->vlan_hdr.vlan_id; + list[i].m_u.vlan_hdr.vlan =cpu_to_be16 (0x0FFF ); + } + +if (flags &ICE_TC_FLWR_FIELD_VLAN_PRIO ) { +if (flags &ICE_TC_FLWR_FIELD_VLAN ) { + list[i].m_u.vlan_hdr.vlan =cpu_to_be16 (0xEFFF ); + }else { + list[i].m_u.vlan_hdr.vlan =cpu_to_be16 (0xE000 ); + list[i].h_u.vlan_hdr.vlan =0 ; + } + list[i].h_u.vlan_hdr.vlan |= + headers->vlan_hdr.vlan_prio; + } + i++; } -if (flags &ICE_TC_FLWR_FIELD_CVLAN ) { +if (flags & (ICE_TC_FLWR_FIELD_CVLAN |ICE_TC_FLWR_FIELD_CVLAN_PRIO )) { list[i].type =ICE_VLAN_IN ; - list[i].h_u.vlan_hdr.vlan = headers->cvlan_hdr.vlan_id; - list[i].m_u.vlan_hdr.vlan =cpu_to_be16 (0xFFFF ); + +if (flags &ICE_TC_FLWR_FIELD_CVLAN ) { + list[i].h_u.vlan_hdr.vlan = headers->cvlan_hdr.vlan_id; + list[i].m_u.vlan_hdr.vlan =cpu_to_be16 (0x0FFF ); + } + +if (flags &ICE_TC_FLWR_FIELD_CVLAN_PRIO ) { +if (flags &ICE_TC_FLWR_FIELD_CVLAN ) { + list[i].m_u.vlan_hdr.vlan =cpu_to_be16 (0xEFFF ); + }else { + list[i].m_u.vlan_hdr.vlan =cpu_to_be16 (0xE000 ); + list[i].h_u.vlan_hdr.vlan =0 ; + } + list[i].h_u.vlan_hdr.vlan |= + headers->cvlan_hdr.vlan_prio; + } + i++; }
@@ -1264,16 +1294,22 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,if (match.mask->vlan_id) {if (match.mask->vlan_id ==VLAN_VID_MASK ) { fltr->flags |=ICE_TC_FLWR_FIELD_VLAN ; + headers->vlan_hdr.vlan_id = +cpu_to_be16 (match.key->vlan_id & +VLAN_VID_MASK ); }else {NL_SET_ERR_MSG_MOD (fltr->extack,"Bad VLAN mask" );return -EINVAL ; } } - headers->vlan_hdr.vlan_id = -cpu_to_be16 (match.key->vlan_id &VLAN_VID_MASK ); -if (match.mask->vlan_priority) - headers->vlan_hdr.vlan_prio = match.key->vlan_priority; +if (match.mask->vlan_priority) { + fltr->flags |=ICE_TC_FLWR_FIELD_VLAN_PRIO ; + headers->vlan_hdr.vlan_prio = +cpu_to_be16 ((match.key->vlan_priority << +VLAN_PRIO_SHIFT ) &VLAN_PRIO_MASK ); + } +if (match.mask->vlan_tpid) headers->vlan_hdr.vlan_tpid = match.key->vlan_tpid; }
@@ -1291,6 +1327,9 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,if (match.mask->vlan_id) {if (match.mask->vlan_id ==VLAN_VID_MASK ) { fltr->flags |=ICE_TC_FLWR_FIELD_CVLAN ; + headers->cvlan_hdr.vlan_id = +cpu_to_be16 (match.key->vlan_id & +VLAN_VID_MASK ); }else {NL_SET_ERR_MSG_MOD (fltr->extack,"Bad CVLAN mask" );
@@ -1298,10 +1337,12 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi, } } - headers->cvlan_hdr.vlan_id = -cpu_to_be16 (match.key->vlan_id &VLAN_VID_MASK ); -if (match.mask->vlan_priority) - headers->cvlan_hdr.vlan_prio = match.key->vlan_priority; +if (match.mask->vlan_priority) { + fltr->flags |=ICE_TC_FLWR_FIELD_CVLAN_PRIO ; + headers->cvlan_hdr.vlan_prio = +cpu_to_be16 ((match.key->vlan_priority << +VLAN_PRIO_SHIFT ) &VLAN_PRIO_MASK ); + } }if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_PPPOE )) {
drivers/net/ethernet/intel/ice/ice_tc_lib.h +3 -1
@@ -30,6 +30,8 @@#define ICE_TC_FLWR_FIELD_IP_TTL BIT(23)#define ICE_TC_FLWR_FIELD_ENC_IP_TOS BIT(24)#define ICE_TC_FLWR_FIELD_ENC_IP_TTL BIT(25) +#define ICE_TC_FLWR_FIELD_VLAN_PRIO BIT(26) +#define ICE_TC_FLWR_FIELD_CVLAN_PRIO BIT(27)#define ICE_TC_FLOWER_MASK_32 0xFFFFFFFF
@@ -48,7 +50,7 @@ struct ice_tc_flower_action {struct ice_tc_vlan_hdr {__be16 vlan_id;/* Only last 12 bits valid */ -u16 vlan_prio;/* Only last 3 bits valid (valid values: 0..7) */ +__be16 vlan_prio;/* Only last 3 bits valid (valid values: 0..7) */ __be16 vlan_tpid; };
Signature · 6 lines
2.36.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 23 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Martyna Szapar-Mudlaw
Sent: Thursday, September 15, 2022 5:45 PM
To: [email protected]
Cc: Martyna Szapar-Mudlaw <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next] ice: Add support for VLAN priority filters in switchdevEnable support for adding TC rules that filter on the VLAN priority in switchdev mode.
VLAN priority are the first 3 bits of 16b switch field vector word which contain also vlan id value within its last 12 bits.
When getting vlan priority value from tc match.key it has to be shifted first to proper bits positions (byVLAN_PRIO_SHIFT) and then can be added to the joint 'vlan' field inice_vlan_hdrin lookup element.The mask of lookup changes accordingly.
0x0FFF- when only vlan id is added in filter0xE000- when only vlan priority is added in filter0xEFFF- when both these values are specified
Quoted 8 lines
Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar- [email protected]>
--- drivers/net/ethernet/intel/ice/ice_tc_lib.c | 73 ++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 4 +- 2 files changed, 60 insertions(+), 17 deletions(-)
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan