ice: Refactor spoofcheck configuration functions
Subsystems (3)
Tony Nguyen
maintainerPATCH v3 1/14 ice: Refactor spoofcheck configuration functions
From: Brett Creeley <[email protected]>
Add functions to configure Tx VLAN antispoof based on iproute configuration and/or VLAN mode and VF driver support. This is needed later so the driver can control when it can be configured. Also, add functions that can be used to enable and disable MAC and VLAN spoofcheck. Move spoofchk configuration during VSI setup into the SR-IOV initialization path and into the post VSI rebuild flow for VF VSIs.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 19 --- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 159 ++++++++++++++---- 2 files changed, 128 insertions(+), 50 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +0 -19
@@ -1125,25 +1125,6 @@ static int ice_vsi_init(struct ice_vsi *vsi, bool init_vsi)cpu_to_le16 (ICE_AQ_VSI_PROP_RXQ_MAP_VALID ); } -/* enable/disable MAC and VLAN anti-spoof when spoofchk is on/off -* respectively -*/ -if (vsi->type ==ICE_VSI_VF ) { - ctxt->info.valid_sections |= -cpu_to_le16 (ICE_AQ_VSI_PROP_SECURITY_VALID ); -if (pf->vf[vsi->vf_id].spoofchk) { - ctxt->info.sec_flags |= -ICE_AQ_VSI_SEC_FLAG_ENA_MAC_ANTI_SPOOF | - (ICE_AQ_VSI_SEC_TX_VLAN_PRUNE_ENA << -ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S ); - }else { - ctxt->info.sec_flags &= - ~(ICE_AQ_VSI_SEC_FLAG_ENA_MAC_ANTI_SPOOF | - (ICE_AQ_VSI_SEC_TX_VLAN_PRUNE_ENA << -ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S )); - } - } -/* Allow control frames out of main VSI */ if (vsi->type ==ICE_VSI_PF ) { ctxt->info.sec_flags |=ICE_AQ_VSI_SEC_FLAG_ALLOW_DEST_OVRD ;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +128 -31
190 lines not on this page · raw message
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH v3 2/14 ice: Add helper function for adding VLAN 0
From: Brett Creeley <[email protected]>
There are multiple places where VLAN 0 is being added. Create a function to be called in order to minimize changes as the implementation is expanded to support double VLAN and avoid duplicated code.
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_lib.c | 11 ++++++++++- drivers/net/ethernet/intel/ice/ice_lib.h | 2 +- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +2 -2
@@ -127,7 +127,7 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)__dev_mc_unsync (uplink_netdev,NULL );netif_addr_unlock_bh (uplink_netdev); -if (ice_vsi_add_vlan (uplink_vsi,0 ,ICE_FWD_TO_VSI )) +if (ice_vsi_add_vlan_zero (uplink_vsi)) goto err_def_rx;if (!ice_is_dflt_vsi_in_use (uplink_vsi->vsw)) {
@@ -231,7 +231,7 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf) goto err; } -if (ice_vsi_add_vlan (vsi,0 ,ICE_FWD_TO_VSI )) { +if (ice_vsi_add_vlan_zero (vsi)) {ice_fltr_add_mac_and_broadcast (vsi, vf->hw_lan_addr.addr,ICE_FWD_TO_VSI );
drivers/net/ethernet/intel/ice/ice_lib.c +10 -1
@@ -2621,7 +2621,7 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,* so this handles those cases (i.e. adding the PF to a bridge * without the 8021q module loaded). */ - ret =ice_vsi_add_vlan (vsi,0 ,ICE_FWD_TO_VSI ); + ret =ice_vsi_add_vlan_zero (vsi);if (ret) goto unroll_clear_rings;
@@ -4069,6 +4069,15 @@ int ice_set_link(struct ice_vsi *vsi, bool ena)return 0 ; } +/** +* ice_vsi_add_vlan_zero - add VLAN 0 filter(s) for this VSI +* @vsi: VSI used to add VLAN filters +*/ +int ice_vsi_add_vlan_zero (struct ice_vsi *vsi) +{ +return ice_vsi_add_vlan (vsi,0 ,ICE_FWD_TO_VSI ); +} +/** * ice_is_feature_supported * @pf: pointer to the struct ice_pf instance
drivers/net/ethernet/intel/ice/ice_lib.h +1 -1
@@ -133,7 +133,7 @@ void ice_vsi_ctx_clear_antispoof(struct ice_vsi_ctx *ctx);void ice_vsi_ctx_set_allow_override (struct ice_vsi_ctx *ctx);void ice_vsi_ctx_clear_allow_override (struct ice_vsi_ctx *ctx); - +int ice_vsi_add_vlan_zero (struct ice_vsi *vsi);bool ice_is_feature_supported (struct ice_pf *pf,enum ice_feature f);void ice_clear_feature_support (struct ice_pf *pf,enum ice_feature f);void ice_init_feature_support (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +1 -1
@@ -1855,7 +1855,7 @@ static int ice_init_vf_vsi_res(struct ice_vf *vf)if (!vsi)return -ENOMEM ; - err =ice_vsi_add_vlan (vsi,0 ,ICE_FWD_TO_VSI ); + err =ice_vsi_add_vlan_zero (vsi);if (err) {dev_warn (dev,"Failed to add VLAN 0 filter for VF %d\n" , vf->vf_id);
Signature · 1 line
2.20.1
G
PATCH v3 2/14 ice: Add helper function for adding VLAN 0
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 02/14] ice: Add helper function for adding VLAN 0From: Brett Creeley <[email protected]>
There are multiple places where VLAN 0 is being added. Create a function to be called in order to minimize changes as the implementation is expanded to support double VLAN and avoid duplicated code.
Quoted 9 lines
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_lib.c | 11 ++++++++++- drivers/net/ethernet/intel/ice/ice_lib.h | 2 +- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-)
Tony Nguyen
maintainerPATCH v3 3/14 ice: Add new VSI VLAN ops
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Incoming changes to support 802.1Q and/or 802.1ad VLAN filtering and offloads require more flexibility when configuring VLANs. The VSI VLAN interface will allow flexibility for configuring VLANs for all VSI types. Add new files to separate the VSI VLAN ops and move functions to make the code more organized.
--- drivers/net/ethernet/intel/ice/Makefile | 2 + drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- drivers/net/ethernet/intel/ice/ice_lib.c | 207 +---------- drivers/net/ethernet/intel/ice/ice_lib.h | 11 - drivers/net/ethernet/intel/ice/ice_main.c | 30 +- drivers/net/ethernet/intel/ice/ice_osdep.h | 1 + drivers/net/ethernet/intel/ice/ice_switch.h | 9 - drivers/net/ethernet/intel/ice/ice_type.h | 9 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 111 +----- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 326 ++++++++++++++++++ .../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 27 ++ .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 20 ++ .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 28 ++ 14 files changed, 450 insertions(+), 335 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.h create mode 100644 drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.h
drivers/net/ethernet/intel/ice/Makefile +2 -0
@@ -18,6 +18,8 @@ ice-y := ice_main.o \ ice_txrx_lib.o \ ice_txrx.o \ ice_fltr.o \ + ice_vsi_vlan_ops.o \ + ice_vsi_vlan_lib.o \ ice_fdir.o \ ice_ethtool_fdir.o \ ice_flex_pipe.o \
drivers/net/ethernet/intel/ice/ice.h +2 -0
@@ -73,6 +73,7 @@#include "ice_eswitch.h" #include "ice_lag.h" #include "ice_gnss.h" +#include "ice_vsi_vlan_ops.h" #define ICE_BAR0 0#define ICE_REQ_DESC_MULTIPLE 32
@@ -370,6 +371,7 @@ struct ice_vsi { u8 irqs_ready:1; u8 current_isup:1; /* Sync 'link up' logging */ u8 stat_offsets_loaded:1; +struct ice_vsi_vlan_ops vlan_ops;u16 num_vlan;/* queue information */
drivers/net/ethernet/intel/ice/ice_eswitch.c +1 -1
@@ -118,7 +118,7 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)struct ice_vsi *ctrl_vsi = pf->switchdev.control_vsi;bool rule_added = false; -ice_vsi_manage_vlan_stripping (ctrl_vsi, false); + ctrl_vsi->vlan_ops.dis_stripping (ctrl_vsi);ice_remove_vsi_fltr (&pf->hw, uplink_vsi->idx);
drivers/net/ethernet/intel/ice/ice_lib.c +5 -202
243 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.h +0 -11
@@ -22,15 +22,6 @@ int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi);void ice_vsi_cfg_msix (struct ice_vsi *vsi); -int -ice_vsi_add_vlan (struct ice_vsi *vsi,u16 vid,enum ice_sw_fwd_act_type action); - -int ice_vsi_kill_vlan (struct ice_vsi *vsi,u16 vid); - -int ice_vsi_manage_vlan_insertion (struct ice_vsi *vsi); - -int ice_vsi_manage_vlan_stripping (struct ice_vsi *vsi,bool ena); -int ice_vsi_start_all_rx_rings (struct ice_vsi *vsi);int ice_vsi_stop_all_rx_rings (struct ice_vsi *vsi);
@@ -45,8 +36,6 @@ int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi);bool ice_vsi_is_vlan_pruning_ena (struct ice_vsi *vsi); -int ice_cfg_vlan_pruning (struct ice_vsi *vsi,bool ena); -void ice_cfg_sw_lldp (struct ice_vsi *vsi,bool tx,bool create);int ice_set_link (struct ice_vsi *vsi,bool ena);
drivers/net/ethernet/intel/ice/ice_main.c +15 -15
@@ -401,7 +401,7 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) ~IFF_PROMISC ; goto out_promisc; } -ice_cfg_vlan_pruning (vsi, false); + vsi->vlan_ops.dis_rx_filtering (vsi); } }else {/* Clear Rx filter to remove traffic from wire */
@@ -415,7 +415,7 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) goto out_promisc; }if (vsi->num_vlan >1 ) -ice_cfg_vlan_pruning (vsi, true); + vsi->vlan_ops.ena_rx_filtering (vsi); } } }
@@ -3429,7 +3429,7 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto,/* Enable VLAN pruning when a VLAN other than 0 is added */ if (!ice_vsi_is_vlan_pruning_ena (vsi)) { - ret =ice_cfg_vlan_pruning (vsi, true); + ret = vsi->vlan_ops.ena_rx_filtering (vsi);if (ret)return ret; }
@@ -3437,7 +3437,7 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto,/* Add a switch rule for this VLAN ID so its corresponding VLAN tagged * packets aren't pruned by the device's internal switch on Rx */ - ret =ice_vsi_add_vlan (vsi, vid,ICE_FWD_TO_VSI ); + ret = vsi->vlan_ops.add_vlan (vsi, vid,ICE_FWD_TO_VSI );if (!ret)set_bit (ICE_VSI_VLAN_FLTR_CHANGED , vsi->state);
@@ -3464,16 +3464,16 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,if (!vid)return 0 ; -/* Make sure ice_vsi_kill_vlan is successful before updating VLAN +/* Make sure VLAN delete is successful before updating VLAN * information */ - ret =ice_vsi_kill_vlan (vsi, vid); + ret = vsi->vlan_ops.del_vlan (vsi, vid);if (ret)return ret;/* Disable pruning when VLAN 0 is the only VLAN rule */ if (vsi->num_vlan ==1 &&ice_vsi_is_vlan_pruning_ena (vsi)) - ret =ice_cfg_vlan_pruning (vsi, false); + vsi->vlan_ops.dis_rx_filtering (vsi);set_bit (ICE_VSI_VLAN_FLTR_CHANGED , vsi->state);return ret;
@@ -5617,24 +5617,24 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)if ((features &NETIF_F_HW_VLAN_CTAG_RX ) && !(netdev->features &NETIF_F_HW_VLAN_CTAG_RX )) - ret =ice_vsi_manage_vlan_stripping (vsi, true); + ret = vsi->vlan_ops.ena_stripping (vsi);else if (!(features &NETIF_F_HW_VLAN_CTAG_RX ) && (netdev->features &NETIF_F_HW_VLAN_CTAG_RX )) - ret =ice_vsi_manage_vlan_stripping (vsi, false); + ret = vsi->vlan_ops.dis_stripping (vsi);if ((features &NETIF_F_HW_VLAN_CTAG_TX ) && !(netdev->features &NETIF_F_HW_VLAN_CTAG_TX )) - ret =ice_vsi_manage_vlan_insertion (vsi); + ret = vsi->vlan_ops.ena_insertion (vsi);else if (!(features &NETIF_F_HW_VLAN_CTAG_TX ) && (netdev->features &NETIF_F_HW_VLAN_CTAG_TX )) - ret =ice_vsi_manage_vlan_insertion (vsi); + ret = vsi->vlan_ops.dis_insertion (vsi);if ((features &NETIF_F_HW_VLAN_CTAG_FILTER ) && !(netdev->features &NETIF_F_HW_VLAN_CTAG_FILTER )) - ret =ice_cfg_vlan_pruning (vsi, true); + ret = vsi->vlan_ops.ena_rx_filtering (vsi);else if (!(features &NETIF_F_HW_VLAN_CTAG_FILTER ) && (netdev->features &NETIF_F_HW_VLAN_CTAG_FILTER )) - ret =ice_cfg_vlan_pruning (vsi, false); + ret = vsi->vlan_ops.dis_rx_filtering (vsi);if ((features &NETIF_F_NTUPLE ) && !(netdev->features &NETIF_F_NTUPLE )) {
@@ -5670,9 +5670,9 @@ static int ice_vsi_vlan_setup(struct ice_vsi *vsi)int ret =0 ;if (vsi->netdev->features &NETIF_F_HW_VLAN_CTAG_RX ) - ret =ice_vsi_manage_vlan_stripping (vsi, true); + ret = vsi->vlan_ops.ena_stripping (vsi);if (vsi->netdev->features &NETIF_F_HW_VLAN_CTAG_TX ) - ret =ice_vsi_manage_vlan_insertion (vsi); + ret = vsi->vlan_ops.ena_insertion (vsi);return ret; }
drivers/net/ethernet/intel/ice/ice_osdep.h +1 -0
@@ -9,6 +9,7 @@#ifndef CONFIG_64BIT #include <linux/io-64-nonatomic-lo-hi.h> #endif +#include <net/udp_tunnel.h> #define wr32 (a, reg, value) writel((value), ((a)->hw_addr + (reg)))#define rd32 (a, reg) readl((a)->hw_addr + (reg))
drivers/net/ethernet/intel/ice/ice_switch.h +0 -9
@@ -33,15 +33,6 @@ struct ice_vsi_ctx {struct ice_q_ctx *rdma_q_ctx[ICE_MAX_TRAFFIC_CLASS ]; }; -enum ice_sw_fwd_act_type { -ICE_FWD_TO_VSI =0 , -ICE_FWD_TO_VSI_LIST ,/* Do not use this when adding filter */ -ICE_FWD_TO_Q , -ICE_FWD_TO_QGRP , -ICE_DROP_PACKET , -ICE_INVAL_ACT -}; -/* Switch recipe ID enum values are specific to hardware */ enum ice_sw_lkup_type {ICE_SW_LKUP_ETHERTYPE =0 ,
drivers/net/ethernet/intel/ice/ice_type.h +9 -0
@@ -1007,6 +1007,15 @@ struct ice_hw_port_stats {u64 fd_sb_match; }; +enum ice_sw_fwd_act_type { +ICE_FWD_TO_VSI =0 , +ICE_FWD_TO_VSI_LIST ,/* Do not use this when adding filter */ +ICE_FWD_TO_Q , +ICE_FWD_TO_QGRP , +ICE_DROP_PACKET , +ICE_INVAL_ACT +}; +struct ice_aq_get_set_rss_lut_params {u16 vsi_handle;/* software VSI handle */ u16 lut_size;/* size of the LUT buffer */
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +14 -97
197 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c new file +326 -0
326 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#ifndef _ICE_VSI_VLAN_LIB_H_ +#define _ICE_VSI_VLAN_LIB_H_ + +#include <linux/types.h> +#include "ice_type.h" + +struct ice_vsi ; + +int +ice_vsi_add_vlan (struct ice_vsi *vsi,u16 vid,enum ice_sw_fwd_act_type action); +int ice_vsi_del_vlan (struct ice_vsi *vsi,u16 vid); + +int ice_vsi_ena_stripping (struct ice_vsi *vsi); +int ice_vsi_dis_stripping (struct ice_vsi *vsi); +int ice_vsi_ena_insertion (struct ice_vsi *vsi); +int ice_vsi_dis_insertion (struct ice_vsi *vsi); +int ice_vsi_set_port_vlan (struct ice_vsi *vsi,u16 pvid_info); + +int ice_vsi_ena_rx_vlan_filtering (struct ice_vsi *vsi); +int ice_vsi_dis_rx_vlan_filtering (struct ice_vsi *vsi); +int ice_vsi_ena_tx_vlan_filtering (struct ice_vsi *vsi); +int ice_vsi_dis_tx_vlan_filtering (struct ice_vsi *vsi); + +#endif /* _ICE_VSI_VLAN_LIB_H_ */
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#include "ice_vsi_vlan_ops.h" +#include "ice.h" + +void ice_vsi_init_vlan_ops (struct ice_vsi *vsi) +{ + vsi->vlan_ops.add_vlan = ice_vsi_add_vlan; + vsi->vlan_ops.del_vlan = ice_vsi_del_vlan; + vsi->vlan_ops.ena_stripping = ice_vsi_ena_stripping; + vsi->vlan_ops.dis_stripping = ice_vsi_dis_stripping; + vsi->vlan_ops.ena_insertion = ice_vsi_ena_insertion; + vsi->vlan_ops.dis_insertion = ice_vsi_dis_insertion; + vsi->vlan_ops.ena_rx_filtering = ice_vsi_ena_rx_vlan_filtering; + vsi->vlan_ops.dis_rx_filtering = ice_vsi_dis_rx_vlan_filtering; + vsi->vlan_ops.ena_tx_filtering = ice_vsi_ena_tx_vlan_filtering; + vsi->vlan_ops.dis_tx_filtering = ice_vsi_dis_tx_vlan_filtering; + vsi->vlan_ops.set_port_vlan = ice_vsi_set_port_vlan; +}
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#ifndef _ICE_VSI_VLAN_OPS_H_ +#define _ICE_VSI_VLAN_OPS_H_ + +#include "ice_type.h" +#include "ice_vsi_vlan_lib.h" + +struct ice_vsi ; + +struct ice_vsi_vlan_ops { +int (*add_vlan)(struct ice_vsi *vsi,u16 vid,enum ice_sw_fwd_act_type action); +int (*del_vlan)(struct ice_vsi *vsi,u16 vid); +int (*ena_stripping)(struct ice_vsi *vsi); +int (*dis_stripping)(struct ice_vsi *vsi); +int (*ena_insertion)(struct ice_vsi *vsi); +int (*dis_insertion)(struct ice_vsi *vsi); +int (*ena_rx_filtering)(struct ice_vsi *vsi); +int (*dis_rx_filtering)(struct ice_vsi *vsi); +int (*ena_tx_filtering)(struct ice_vsi *vsi); +int (*dis_tx_filtering)(struct ice_vsi *vsi); +int (*set_port_vlan)(struct ice_vsi *vsi,u16 pvid_info); +}; + +void ice_vsi_init_vlan_ops (struct ice_vsi *vsi); + +#endif /* _ICE_VSI_VLAN_OPS_H_ */
Signature · 1 line
2.20.1
G
PATCH v3 3/14 ice: Add new VSI VLAN ops
Quoted 31 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 03/14] ice: Add new VSI VLAN opsFrom: Brett Creeley <[email protected]>
Incoming changes to support 802.1Q and/or 802.1ad VLAN filtering and offloads require more flexibility when configuring VLANs. The VSI VLAN interface will allow flexibility for configuring VLANs for all VSI types. Add new files to separate the VSI VLAN ops and move functions to make the code more organized.
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/Makefile | 2 + drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- drivers/net/ethernet/intel/ice/ice_lib.c | 207 +---------- drivers/net/ethernet/intel/ice/ice_lib.h | 11 - drivers/net/ethernet/intel/ice/ice_main.c | 30 +- drivers/net/ethernet/intel/ice/ice_osdep.h | 1 + drivers/net/ethernet/intel/ice/ice_switch.h | 9 - drivers/net/ethernet/intel/ice/ice_type.h | 9 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 111 +----- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 326 ++++++++++++++++++
Quoted 9 lines
.../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 27 ++ .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 20 ++ .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 28 ++ 14 files changed, 450 insertions(+), 335 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.h create mode 100644 drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.h
Tony Nguyen
maintainerPATCH v3 4/14 ice: Introduce ice_vlan struct
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Add a new struct for VLAN related information. Currently this holds VLAN ID and priority values, but will be expanded to hold TPID value. This reduces the changes necessary if any other values are added in future. Remove the action argument from these calls as it's always ICE_FWD_VSI.
--- drivers/net/ethernet/intel/ice/ice_fltr.c | 35 +++++++------------ drivers/net/ethernet/intel/ice/ice_fltr.h | 10 +++--- drivers/net/ethernet/intel/ice/ice_lib.c | 5 ++- drivers/net/ethernet/intel/ice/ice_lib.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 8 +++-- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 19 ++++++---- drivers/net/ethernet/intel/ice/ice_vlan.h | 17 +++++++++ .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 31 +++++++++------- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 9 +++-- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 6 ++-- 10 files changed, 82 insertions(+), 59 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_vlan.h
drivers/net/ethernet/intel/ice/ice_fltr.c +13 -22
@@ -206,21 +206,20 @@ ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list,* ice_fltr_add_vlan_to_list - add VLAN filter info to exsisting list * @vsi: pointer to VSI struct * @list: list to add filter info to -* @vlan_id: VLAN ID to add -* @action: filter action +* @vlan: VLAN filter details */ static int ice_fltr_add_vlan_to_list (struct ice_vsi *vsi,struct list_head *list, -u16 vlan_id,enum ice_sw_fwd_act_type action) +struct ice_vlan *vlan) {struct ice_fltr_info info = {0 }; info.flag =ICE_FLTR_TX ; info.src_id =ICE_SRC_ID_VSI ; info.lkup_type =ICE_SW_LKUP_VLAN ; - info.fltr_act = action; + info.fltr_act =ICE_FWD_TO_VSI ; info.vsi_handle = vsi->idx; - info.l_data.vlan.vlan_id = vlan_id; + info.l_data.vlan.vlan_id = vlan->vid;return ice_fltr_add_entry_to_list (ice_pf_to_dev (vsi->back), &info, list);
@@ -313,19 +312,17 @@ ice_fltr_prepare_mac_and_broadcast(struct ice_vsi *vsi, const u8 *mac,/** * ice_fltr_prepare_vlan - add or remove VLAN filter * @vsi: pointer to VSI struct -* @vlan_id: VLAN ID to add -* @action: action to be performed on filter match +* @vlan: VLAN filter details * @vlan_action: pointer to add or remove VLAN function */ static int -ice_fltr_prepare_vlan (struct ice_vsi *vsi,u16 vlan_id, -enum ice_sw_fwd_act_type action, +ice_fltr_prepare_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan,int (*vlan_action)(struct ice_vsi *,struct list_head *)) {LIST_HEAD (tmp_list);int result; -if (ice_fltr_add_vlan_to_list (vsi, &tmp_list, vlan_id, action)) +if (ice_fltr_add_vlan_to_list (vsi, &tmp_list, vlan))return -ENOMEM ; result =vlan_action (vsi, &tmp_list);
@@ -398,27 +395,21 @@ int ice_fltr_remove_mac(struct ice_vsi *vsi, const u8 *mac,/** * ice_fltr_add_vlan - add single VLAN filter * @vsi: pointer to VSI struct -* @vlan_id: VLAN ID to add -* @action: action to be performed on filter match +* @vlan: VLAN filter details */ -int ice_fltr_add_vlan (struct ice_vsi *vsi,u16 vlan_id, -enum ice_sw_fwd_act_type action) +int ice_fltr_add_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan) { -return ice_fltr_prepare_vlan (vsi, vlan_id, action, - ice_fltr_add_vlan_list); +return ice_fltr_prepare_vlan (vsi, vlan, ice_fltr_add_vlan_list); }/** * ice_fltr_remove_vlan - remove VLAN filter * @vsi: pointer to VSI struct -* @vlan_id: filter VLAN to remove -* @action: action to remove +* @vlan: VLAN filter details */ -int ice_fltr_remove_vlan (struct ice_vsi *vsi,u16 vlan_id, -enum ice_sw_fwd_act_type action) +int ice_fltr_remove_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan) { -return ice_fltr_prepare_vlan (vsi, vlan_id, action, - ice_fltr_remove_vlan_list); +return ice_fltr_prepare_vlan (vsi, vlan, ice_fltr_remove_vlan_list); }/**
drivers/net/ethernet/intel/ice/ice_fltr.h +4 -6
@@ -4,6 +4,8 @@#ifndef _ICE_FLTR_H_#define _ICE_FLTR_H_ +#include "ice_vlan.h" +void ice_fltr_free_list (struct device *dev,struct list_head *h);int ice_fltr_set_vlan_vsi_promisc (struct ice_hw *hw,struct ice_vsi *vsi,u8 promisc_mask);
@@ -32,12 +34,8 @@ ice_fltr_remove_mac(struct ice_vsi *vsi, const u8 *mac,int ice_fltr_remove_mac_list (struct ice_vsi *vsi,struct list_head *list); -int -ice_fltr_add_vlan (struct ice_vsi *vsi,u16 vid, -enum ice_sw_fwd_act_type action); -int -ice_fltr_remove_vlan (struct ice_vsi *vsi,u16 vid, -enum ice_sw_fwd_act_type action); +int ice_fltr_add_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan); +int ice_fltr_remove_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan); int ice_fltr_add_eth(struct ice_vsi *vsi, u16 ethertype, u16 flag,
drivers/net/ethernet/intel/ice/ice_lib.c +4 -1
@@ -3878,7 +3878,10 @@ int ice_set_link(struct ice_vsi *vsi, bool ena)*/ int ice_vsi_add_vlan_zero (struct ice_vsi *vsi) { -return vsi->vlan_ops.add_vlan (vsi,0 ,ICE_FWD_TO_VSI ); +struct ice_vlan vlan; + + vlan =ICE_VLAN (0 ,0 ); +return vsi->vlan_ops.add_vlan (vsi, &vlan); }/**
drivers/net/ethernet/intel/ice/ice_lib.h +1 -0
@@ -5,6 +5,7 @@#define _ICE_LIB_H_#include "ice.h" +#include "ice_vlan.h" const char *ice_vsi_type_str (enum ice_vsi_type vsi_type);
drivers/net/ethernet/intel/ice/ice_main.c +6 -2
@@ -3421,6 +3421,7 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto, {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_vsi *vsi = np->vsi; +struct ice_vlan vlan;int ret;/* VLAN 0 is added by default during load/reset */
@@ -3437,7 +3438,8 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto,/* Add a switch rule for this VLAN ID so its corresponding VLAN tagged * packets aren't pruned by the device's internal switch on Rx */ - ret = vsi->vlan_ops.add_vlan (vsi, vid,ICE_FWD_TO_VSI ); + vlan =ICE_VLAN (vid,0 ); + ret = vsi->vlan_ops.add_vlan (vsi, &vlan);if (!ret)set_bit (ICE_VSI_VLAN_FLTR_CHANGED , vsi->state);
@@ -3458,6 +3460,7 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto, {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_vsi *vsi = np->vsi; +struct ice_vlan vlan;int ret;/* don't allow removal of VLAN 0 */
@@ -3467,7 +3470,8 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,/* Make sure VLAN delete is successful before updating VLAN * information */ - ret = vsi->vlan_ops.del_vlan (vsi, vid); + vlan =ICE_VLAN (vid,0 ); + ret = vsi->vlan_ops.del_vlan (vsi, &vlan);if (ret)return ret;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +12 -7
@@ -760,24 +760,25 @@ static int ice_vf_rebuild_host_tx_rate_cfg(struct ice_vf *vf)*/ static int ice_vf_rebuild_host_vlan_cfg (struct ice_vf *vf) { +u8 vlan_prio = (vf->port_vlan_info &VLAN_PRIO_MASK ) >>VLAN_PRIO_SHIFT ; +u16 vlan_id = vf->port_vlan_info &VLAN_VID_MASK ;struct device *dev =ice_pf_to_dev (vf->pf);struct ice_vsi *vsi =ice_get_vf_vsi (vf); -u16 vlan_id =0 ; +struct ice_vlan vlan;int err; + vlan =ICE_VLAN (vlan_id, vlan_prio);if (vf->port_vlan_info) { - err = vsi->vlan_ops.set_port_vlan (vsi, vf->port_vlan_info); + err = vsi->vlan_ops.set_port_vlan (vsi, &vlan);if (err) {dev_err (dev,"failed to configure port VLAN via VSI parameters for VF %u, error %d\n" , vf->vf_id, err);return err; } - - vlan_id = vf->port_vlan_info &VLAN_VID_MASK ; }/* vlan_id will either be 0 or the port VLAN number */ - err = vsi->vlan_ops.add_vlan (vsi, vlan_id,ICE_FWD_TO_VSI ); + err = vsi->vlan_ops.add_vlan (vsi, &vlan);if (err) { dev_err(dev, "failed to add %s VLAN %u filter for VF %u, error %d\n", vf->port_vlan_info ? "port" : "", vlan_id, vf->vf_id,
@@ -4231,6 +4232,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)if (add_v) {for (i =0 ; i < vfl->num_elements; i++) {u16 vid = vfl->vlan_id[i]; +struct ice_vlan vlan;if (!ice_is_vf_trusted (vf) && vsi->num_vlan >=ICE_MAX_VLAN_PER_VF ) {
@@ -4250,7 +4252,8 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)if (!vid)continue ; - status = vsi->vlan_ops.add_vlan (vsi, vid,ICE_FWD_TO_VSI ); + vlan =ICE_VLAN (vid,0 ); + status = vsi->vlan_ops.add_vlan (vsi, &vlan);if (status) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ; goto error_param;
@@ -4293,6 +4296,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v) num_vf_vlan = vsi->num_vlan;for (i =0 ; i < vfl->num_elements && i < num_vf_vlan; i++) {u16 vid = vfl->vlan_id[i]; +struct ice_vlan vlan;/* we add VLAN 0 by default for each VF so we can enable * Tx VLAN anti-spoof without triggering MDD events so
@@ -4301,7 +4305,8 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)if (!vid)continue ; - status = vsi->vlan_ops.del_vlan (vsi, vid); + vlan =ICE_VLAN (vid,0 ); + status = vsi->vlan_ops.del_vlan (vsi, &vlan);if (status) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ; goto error_param;
drivers/net/ethernet/intel/ice/ice_vlan.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#ifndef _ICE_VLAN_H_ +#define _ICE_VLAN_H_ + +#include <linux/types.h> +#include "ice_type.h" + +struct ice_vlan { +u16 vid; +u8 prio; +}; + +#define ICE_VLAN (vid, prio) ((struct ice_vlan){ vid, prio }) + +#endif /* _ICE_VLAN_H_ */
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c +18 -13
@@ -9,20 +9,18 @@/** * ice_vsi_add_vlan - default add VLAN implementation for all VSI types * @vsi: VSI being configured -* @vid: VLAN ID to be added -* @action: filter action to be performed on match +* @vlan: VLAN filter to add */ -int -ice_vsi_add_vlan (struct ice_vsi *vsi,u16 vid,enum ice_sw_fwd_act_type action) +int ice_vsi_add_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan) {int err =0 ; -if (!ice_fltr_add_vlan (vsi, vid, action)) { +if (!ice_fltr_add_vlan (vsi, vlan)) { vsi->num_vlan++; }else { err = -ENODEV ;dev_err (ice_pf_to_dev (vsi->back),"Failure Adding VLAN %d on VSI %i\n" , - vid, vsi->vsi_num); + vlan->vid, vsi->vsi_num); }return err;
@@ -31,9 +29,9 @@ ice_vsi_add_vlan(struct ice_vsi *vsi, u16 vid, enum ice_sw_fwd_act_type action)/** * ice_vsi_del_vlan - default del VLAN implementation for all VSI types * @vsi: VSI being configured -* @vid: VLAN ID to be removed +* @vlan: VLAN filter to delete */ -int ice_vsi_del_vlan (struct ice_vsi *vsi,u16 vid) +int ice_vsi_del_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan) {struct ice_pf *pf = vsi->back;struct device *dev;
@@ -41,16 +39,16 @@ int ice_vsi_del_vlan(struct ice_vsi *vsi, u16 vid) dev =ice_pf_to_dev (pf); - err =ice_fltr_remove_vlan (vsi, vid,ICE_FWD_TO_VSI ); + err =ice_fltr_remove_vlan (vsi, vlan);if (!err) { vsi->num_vlan--; }else if (err == -ENOENT ) {dev_dbg (dev,"Failed to remove VLAN %d on VSI %i, it does not exist\n" , - vid, vsi->vsi_num); + vlan->vid, vsi->vsi_num); err =0 ; }else {dev_err (dev,"Error removing VLAN %d on VSI %i error: %d\n" , - vid, vsi->vsi_num, err); + vlan->vid, vsi->vsi_num, err); }return err;
@@ -214,9 +212,16 @@ static int ice_vsi_manage_pvid(struct ice_vsi *vsi, u16 pvid_info, bool enable)return ret; } -int ice_vsi_set_port_vlan (struct ice_vsi *vsi,u16 pvid_info) +int ice_vsi_set_port_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan) { -return ice_vsi_manage_pvid (vsi, pvid_info, true); +u16 port_vlan_info; + +if (vlan->prio >7 ) +return -EINVAL ; + + port_vlan_info = vlan->vid | (vlan->prio <<VLAN_PRIO_SHIFT ); + +return ice_vsi_manage_pvid (vsi, port_vlan_info, true); }/**
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.h +4 -5
@@ -5,19 +5,18 @@#define _ICE_VSI_VLAN_LIB_H_#include <linux/types.h> -#include "ice_type.h" +#include "ice_vlan.h" struct ice_vsi ; -int -ice_vsi_add_vlan (struct ice_vsi *vsi,u16 vid,enum ice_sw_fwd_act_type action); -int ice_vsi_del_vlan (struct ice_vsi *vsi,u16 vid); +int ice_vsi_add_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan); +int ice_vsi_del_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan);int ice_vsi_ena_stripping (struct ice_vsi *vsi);int ice_vsi_dis_stripping (struct ice_vsi *vsi);int ice_vsi_ena_insertion (struct ice_vsi *vsi);int ice_vsi_dis_insertion (struct ice_vsi *vsi); -int ice_vsi_set_port_vlan (struct ice_vsi *vsi,u16 pvid_info); +int ice_vsi_set_port_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan);int ice_vsi_ena_rx_vlan_filtering (struct ice_vsi *vsi);int ice_vsi_dis_rx_vlan_filtering (struct ice_vsi *vsi);
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.h +3 -3
@@ -10,8 +10,8 @@struct ice_vsi ;struct ice_vsi_vlan_ops { -int (*add_vlan)(struct ice_vsi *vsi,u16 vid,enum ice_sw_fwd_act_type action); -int (*del_vlan)(struct ice_vsi *vsi,u16 vid); +int (*add_vlan)(struct ice_vsi *vsi,struct ice_vlan *vlan); +int (*del_vlan)(struct ice_vsi *vsi,struct ice_vlan *vlan);int (*ena_stripping)(struct ice_vsi *vsi);int (*dis_stripping)(struct ice_vsi *vsi);int (*ena_insertion)(struct ice_vsi *vsi);
@@ -20,7 +20,7 @@ struct ice_vsi_vlan_ops {int (*dis_rx_filtering)(struct ice_vsi *vsi);int (*ena_tx_filtering)(struct ice_vsi *vsi);int (*dis_tx_filtering)(struct ice_vsi *vsi); -int (*set_port_vlan)(struct ice_vsi *vsi,u16 pvid_info); +int (*set_port_vlan)(struct ice_vsi *vsi,struct ice_vlan *vlan); };void ice_vsi_init_vlan_ops (struct ice_vsi *vsi);
Signature · 1 line
2.20.1
G
PATCH v3 4/14 ice: Introduce ice_vlan struct
Quoted 31 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 04/14] ice: Introduceice_vlanstructFrom: Brett Creeley <[email protected]>
Add a new struct for VLAN related information. Currently this holds VLAN ID and priority values, but will be expanded to hold TPID value. This reduces the changes necessary if any other values are added in future. Remove the action argument from these calls as it's always
ICE_FWD_VSI.Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_fltr.c | 35 +++++++------------ drivers/net/ethernet/intel/ice/ice_fltr.h | 10 +++--- drivers/net/ethernet/intel/ice/ice_lib.c | 5 ++- drivers/net/ethernet/intel/ice/ice_lib.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 8 +++-- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 19 ++++++---- drivers/net/ethernet/intel/ice/ice_vlan.h | 17 +++++++++ .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 31 +++++++++------- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 9 +++-- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 6 ++-- 10 files changed, 82 insertions(+), 59 deletions(-) create mode 100644
Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_vlan.h
Tony Nguyen
maintainerPATCH v3 5/14 ice: Refactor vf->port_vlan_info to use ice_vlan
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
The current vf->port_vlan_info variable is a packed u16 that contains the port VLAN ID and QoS/prio value. This is fine, but changes are incoming that allow for an 802.1ad port VLAN. Add flexibility by changing the vf->port_vlan_info member to be an ice_vlan structure.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 76 ++++++++++--------- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 3 +- 2 files changed, 44 insertions(+), 35 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +42 -34
@@ -751,6 +751,21 @@ static int ice_vf_rebuild_host_tx_rate_cfg(struct ice_vf *vf)return 0 ; } +static u16 ice_vf_get_port_vlan_id (struct ice_vf *vf) +{ +return vf->port_vlan_info.vid; +} + +static u8 ice_vf_get_port_vlan_prio (struct ice_vf *vf) +{ +return vf->port_vlan_info.prio; +} + +static bool ice_vf_is_port_vlan_ena (struct ice_vf *vf) +{ +return (ice_vf_get_port_vlan_id (vf) ||ice_vf_get_port_vlan_prio (vf)); +} +/** * ice_vf_rebuild_host_vlan_cfg - add VLAN 0 filter or rebuild the Port VLAN * @vf: VF to add MAC filters for
@@ -760,16 +775,12 @@ static int ice_vf_rebuild_host_tx_rate_cfg(struct ice_vf *vf)*/ static int ice_vf_rebuild_host_vlan_cfg (struct ice_vf *vf) { -u8 vlan_prio = (vf->port_vlan_info &VLAN_PRIO_MASK ) >>VLAN_PRIO_SHIFT ; -u16 vlan_id = vf->port_vlan_info &VLAN_VID_MASK ;struct device *dev =ice_pf_to_dev (vf->pf);struct ice_vsi *vsi =ice_get_vf_vsi (vf); -struct ice_vlan vlan;int err; - vlan =ICE_VLAN (vlan_id, vlan_prio); -if (vf->port_vlan_info) { - err = vsi->vlan_ops.set_port_vlan (vsi, &vlan); +if (ice_vf_is_port_vlan_ena (vf)) { + err = vsi->vlan_ops.set_port_vlan (vsi, &vf->port_vlan_info);if (err) {dev_err (dev,"failed to configure port VLAN via VSI parameters for VF %u, error %d\n" , vf->vf_id, err);
@@ -777,12 +788,11 @@ static int ice_vf_rebuild_host_vlan_cfg(struct ice_vf *vf) } } -/* vlan_id will either be 0 or the port VLAN number */ - err = vsi->vlan_ops.add_vlan (vsi, &vlan); + err = vsi->vlan_ops.add_vlan (vsi, &vf->port_vlan_info);if (err) { -dev_err (dev,"failed to add %s VLAN %u filter for VF %u, error %d\n" , - vf->port_vlan_info ?"port" :"" , vlan_id, vf->vf_id, - err); +dev_err (dev,"failed to add VLAN %u filter for VF %u during VF rebuild, error %d\n" , +ice_vf_is_port_vlan_ena (vf) ? +ice_vf_get_port_vlan_id (vf) :0 , vf->vf_id, err);return err; }
@@ -1255,9 +1265,9 @@ static int ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 prostruct ice_hw *hw = &vsi->back->hw;int status; -if (vf->port_vlan_info) +if (ice_vf_is_port_vlan_ena (vf)) status =ice_fltr_set_vsi_promisc (hw, vsi->idx, promisc_m, - vf->port_vlan_info &VLAN_VID_MASK ); +ice_vf_get_port_vlan_id (vf));else if (vsi->num_vlan >1 ) status =ice_fltr_set_vlan_vsi_promisc (hw, vsi, promisc_m);else
@@ -1277,9 +1287,9 @@ static int ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 pstruct ice_hw *hw = &vsi->back->hw;int status; -if (vf->port_vlan_info) +if (ice_vf_is_port_vlan_ena (vf)) status =ice_fltr_clear_vsi_promisc (hw, vsi->idx, promisc_m, - vf->port_vlan_info &VLAN_VID_MASK ); +ice_vf_get_port_vlan_id (vf));else if (vsi->num_vlan >1 ) status =ice_fltr_clear_vlan_vsi_promisc (hw, vsi, promisc_m);else
@@ -1654,7 +1664,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)*/ if (test_bit (ICE_VF_STATE_UC_PROMISC , vf->vf_states) ||test_bit (ICE_VF_STATE_MC_PROMISC , vf->vf_states)) { -if (vf->port_vlan_info || vsi->num_vlan) +if (ice_vf_is_port_vlan_ena (vf) || vsi->num_vlan) promisc_m =ICE_UCAST_VLAN_PROMISC_BITS ;else promisc_m =ICE_UCAST_PROMISC_BITS ;
@@ -2277,7 +2287,7 @@ static u16 ice_vc_get_max_frame_size(struct ice_vf *vf) max_frame_size = pi->phy.link_info.max_frame_size; -if (vf->port_vlan_info) +if (ice_vf_is_port_vlan_ena (vf)) max_frame_size -=VLAN_HLEN ;return max_frame_size;
@@ -2326,7 +2336,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg) goto err; } -if (!vsi->info.pvid) +if (!ice_vf_is_port_vlan_ena (vf)) vfres->vf_cap_flags |=VIRTCHNL_VF_OFFLOAD_VLAN ;if (vf->driver_caps &VIRTCHNL_VF_OFFLOAD_RSS_PF ) {
@@ -3050,7 +3060,7 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) rm_promisc = !allmulti && !alluni; -if (vsi->num_vlan || vf->port_vlan_info) { +if (vsi->num_vlan ||ice_vf_is_port_vlan_ena (vf)) {if (rm_promisc) ret = vsi->vlan_ops.ena_rx_filtering (vsi);else
@@ -3086,7 +3096,7 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) }else {u8 mcast_m, ucast_m; -if (vf->port_vlan_info || vsi->num_vlan >1 ) { +if (ice_vf_is_port_vlan_ena (vf) || vsi->num_vlan >1 ) { mcast_m =ICE_MCAST_VLAN_PROMISC_BITS ; ucast_m =ICE_UCAST_VLAN_PROMISC_BITS ; }else {
@@ -3669,7 +3679,7 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)/* add space for the port VLAN since the VF driver is not * expected to account for it in the MTU calculation */ -if (vf->port_vlan_info) +if (ice_vf_is_port_vlan_ena (vf)) vsi->max_frame +=VLAN_HLEN ;if (ice_vsi_cfg_single_rxq (vsi, q_idx)) {
@@ -4097,7 +4107,6 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,struct ice_pf *pf =ice_netdev_to_pf (netdev);struct device *dev;struct ice_vf *vf; -u16 vlanprio;int ret; dev =ice_pf_to_dev (pf);
@@ -4120,20 +4129,19 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,if (ret)return ret; - vlanprio = vlan_id | (qos <<VLAN_PRIO_SHIFT ); - -if (vf->port_vlan_info == vlanprio) { +if (ice_vf_get_port_vlan_prio (vf) == qos && +ice_vf_get_port_vlan_id (vf) == vlan_id) {/* duplicate request, so just return success */ -dev_dbg (dev,"Duplicate pvid %d request\n" , vlanprio); +dev_dbg (dev,"Duplicate port VLAN %u, QoS %u request\n" , + vlan_id, qos);return 0 ; }mutex_lock (&vf->cfg_lock); - vf->port_vlan_info = vlanprio; - -if (vf->port_vlan_info) -dev_info (dev,"Setting VLAN %d, QoS 0x%x on VF %d\n" , + vf->port_vlan_info =ICE_VLAN (vlan_id, qos); +if (ice_vf_is_port_vlan_ena (vf)) +dev_info (dev,"Setting VLAN %u, QoS %u on VF %d\n" , vlan_id, qos, vf_id);else dev_info (dev,"Clearing port VLAN on VF %d\n" , vf_id);
@@ -4219,7 +4227,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v) goto error_param; } -if (vsi->info.pvid) { +if (ice_vf_is_port_vlan_ena (vf)) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ; goto error_param; }
@@ -4445,7 +4453,7 @@ static int ice_vf_init_vlan_stripping(struct ice_vf *vf)return -EINVAL ;/* don't modify stripping if port VLAN is configured */ -if (vsi->info.pvid) +if (ice_vf_is_port_vlan_ena (vf))return 0 ;if (ice_vf_vlan_offload_ena (vf->driver_caps))
@@ -4815,8 +4823,8 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi)ether_addr_copy (ivi->mac, vf->hw_lan_addr.addr);/* VF configuration for VLAN and applicable QoS */ - ivi->vlan = vf->port_vlan_info &VLAN_VID_MASK ; - ivi->qos = (vf->port_vlan_info &VLAN_PRIO_MASK ) >>VLAN_PRIO_SHIFT ; + ivi->vlan =ice_vf_get_port_vlan_id (vf); + ivi->qos =ice_vf_get_port_vlan_prio (vf); ivi->trusted = vf->trusted; ivi->spoofchk = vf->spoofchk;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +2 -1
@@ -5,6 +5,7 @@#define _ICE_VIRTCHNL_PF_H_#include "ice.h" #include "ice_virtchnl_fdir.h" +#include "ice_vsi_vlan_ops.h" /* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */ #define ICE_MAX_VLAN_PER_VF 8
@@ -119,7 +120,7 @@ struct ice_vf {struct ice_time_mac legacy_last_added_umac;DECLARE_BITMAP (txq_ena,ICE_MAX_RSS_QS_PER_VF );DECLARE_BITMAP (rxq_ena,ICE_MAX_RSS_QS_PER_VF ); -u16 port_vlan_info;/* Port VLAN ID and QoS */ +struct ice_vlan port_vlan_info;/* Port VLAN ID and QoS */ u8 pf_set_mac:1; /* VF MAC address set by VMM admin */ u8 trusted:1; u8 spoofchk:1;
Signature · 1 line
2.20.1
G
PATCH v3 5/14 ice: Refactor vf->port_vlan_info to use ice_vlan
Quoted 17 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 05/14] ice: Refactor vf-Quoted 1 line
port_vlan_infoto useice_vlanFrom: Brett Creeley <[email protected]>
The current
vf->port_vlan_infovariable is a packed u16 that contains the port VLAN ID and QoS/prio value. This is fine, but changes are incoming that allow for an 802.1ad port VLAN. Add flexibility by changing thevf->port_vlan_infomember to be anice_vlanstructure.
Quoted 7 lines
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 76 ++++++++++--------- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 3 +- 2 files changed, 44 insertions(+), 35 deletions(-)
Tony Nguyen
maintainerPATCH v3 6/14 ice: Use the proto argument for VLAN ops
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently the proto argument is unused. This is because the driver only supports 802.1Q VLAN filtering. This policy is enforced via netdev features that the driver sets up when configuring the netdev, so the proto argument won't ever be anything other than 802.1Q. However, this will allow for future iterations of the driver to seemlessly support 802.1ad filtering. Begin using the proto argument and extend the related structures to support its use.
--- drivers/net/ethernet/intel/ice/ice_fltr.c | 2 + drivers/net/ethernet/intel/ice/ice_lib.c | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 22 ++++----- drivers/net/ethernet/intel/ice/ice_switch.c | 5 ++ drivers/net/ethernet/intel/ice/ice_switch.h | 2 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 10 ++-- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 2 +- drivers/net/ethernet/intel/ice/ice_vlan.h | 3 +- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 48 ++++++++++++++++++- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 4 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 4 +- 11 files changed, 78 insertions(+), 26 deletions(-)
drivers/net/ethernet/intel/ice/ice_fltr.c +2 -0
@@ -220,6 +220,8 @@ ice_fltr_add_vlan_to_list(struct ice_vsi *vsi, struct list_head *list, info.fltr_act =ICE_FWD_TO_VSI ; info.vsi_handle = vsi->idx; info.l_data.vlan.vlan_id = vlan->vid; + info.l_data.vlan.tpid = vlan->tpid; + info.l_data.vlan.tpid_valid = true;return ice_fltr_add_entry_to_list (ice_pf_to_dev (vsi->back), &info, list);
drivers/net/ethernet/intel/ice/ice_lib.c +1 -1
@@ -3880,7 +3880,7 @@ int ice_vsi_add_vlan_zero(struct ice_vsi *vsi) {struct ice_vlan vlan; - vlan =ICE_VLAN (0 ,0 ); + vlan =ICE_VLAN (0 ,0 ,0 );return vsi->vlan_ops.add_vlan (vsi, &vlan); }
drivers/net/ethernet/intel/ice/ice_main.c +10 -12
@@ -3410,14 +3410,13 @@ ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)/** * ice_vlan_rx_add_vid - Add a VLAN ID filter to HW offload * @netdev: network interface to be adjusted -* @proto: unused protocol +* @proto: VLAN TPID * @vid: VLAN ID to be added * * net_device_ops implementation for adding VLAN IDs */ static int -ice_vlan_rx_add_vid (struct net_device *netdev,__always_unused __be16 proto, -u16 vid) +ice_vlan_rx_add_vid (struct net_device *netdev,__be16 proto,u16 vid) {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_vsi *vsi = np->vsi;
@@ -3438,7 +3437,7 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto,/* Add a switch rule for this VLAN ID so its corresponding VLAN tagged * packets aren't pruned by the device's internal switch on Rx */ - vlan =ICE_VLAN (vid,0 ); + vlan =ICE_VLAN (be16_to_cpu (proto), vid,0 ); ret = vsi->vlan_ops.add_vlan (vsi, &vlan);if (!ret)set_bit (ICE_VSI_VLAN_FLTR_CHANGED , vsi->state);
@@ -3449,14 +3448,13 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto,/** * ice_vlan_rx_kill_vid - Remove a VLAN ID filter from HW offload * @netdev: network interface to be adjusted -* @proto: unused protocol +* @proto: VLAN TPID * @vid: VLAN ID to be removed * * net_device_ops implementation for removing VLAN IDs */ static int -ice_vlan_rx_kill_vid (struct net_device *netdev,__always_unused __be16 proto, -u16 vid) +ice_vlan_rx_kill_vid (struct net_device *netdev,__be16 proto,u16 vid) {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_vsi *vsi = np->vsi;
@@ -3470,7 +3468,7 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,/* Make sure VLAN delete is successful before updating VLAN * information */ - vlan =ICE_VLAN (vid,0 ); + vlan =ICE_VLAN (be16_to_cpu (proto), vid,0 ); ret = vsi->vlan_ops.del_vlan (vsi, &vlan);if (ret)return ret;
@@ -5621,14 +5619,14 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)if ((features &NETIF_F_HW_VLAN_CTAG_RX ) && !(netdev->features &NETIF_F_HW_VLAN_CTAG_RX )) - ret = vsi->vlan_ops.ena_stripping (vsi); + ret = vsi->vlan_ops.ena_stripping (vsi,ETH_P_8021Q );else if (!(features &NETIF_F_HW_VLAN_CTAG_RX ) && (netdev->features &NETIF_F_HW_VLAN_CTAG_RX )) ret = vsi->vlan_ops.dis_stripping (vsi);if ((features &NETIF_F_HW_VLAN_CTAG_TX ) && !(netdev->features &NETIF_F_HW_VLAN_CTAG_TX )) - ret = vsi->vlan_ops.ena_insertion (vsi); + ret = vsi->vlan_ops.ena_insertion (vsi,ETH_P_8021Q );else if (!(features &NETIF_F_HW_VLAN_CTAG_TX ) && (netdev->features &NETIF_F_HW_VLAN_CTAG_TX )) ret = vsi->vlan_ops.dis_insertion (vsi);
@@ -5674,9 +5672,9 @@ static int ice_vsi_vlan_setup(struct ice_vsi *vsi)int ret =0 ;if (vsi->netdev->features &NETIF_F_HW_VLAN_CTAG_RX ) - ret = vsi->vlan_ops.ena_stripping (vsi); + ret = vsi->vlan_ops.ena_stripping (vsi,ETH_P_8021Q );if (vsi->netdev->features &NETIF_F_HW_VLAN_CTAG_TX ) - ret = vsi->vlan_ops.ena_insertion (vsi); + ret = vsi->vlan_ops.ena_insertion (vsi,ETH_P_8021Q );return ret; }
drivers/net/ethernet/intel/ice/ice_switch.c +5 -0
@@ -1539,6 +1539,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 =ETH_P_8021Q ;void *daddr =NULL ;u16 eth_hdr_sz;u8 *eth_hdr;
@@ -1611,6 +1612,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 ;
@@ -1653,6 +1656,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 */
drivers/net/ethernet/intel/ice/ice_switch.h +2 -0
@@ -77,6 +77,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
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +5 -5
@@ -4139,7 +4139,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,mutex_lock (&vf->cfg_lock); - vf->port_vlan_info =ICE_VLAN (vlan_id, qos); + vf->port_vlan_info =ICE_VLAN (ETH_P_8021Q , vlan_id, qos);if (ice_vf_is_port_vlan_ena (vf))dev_info (dev,"Setting VLAN %u, QoS %u on VF %d\n" , vlan_id, qos, vf_id);
@@ -4260,7 +4260,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)if (!vid)continue ; - vlan =ICE_VLAN (vid,0 ); + vlan =ICE_VLAN (ETH_P_8021Q , vid,0 ); status = vsi->vlan_ops.add_vlan (vsi, &vlan);if (status) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ;
@@ -4313,7 +4313,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)if (!vid)continue ; - vlan =ICE_VLAN (vid,0 ); + vlan =ICE_VLAN (ETH_P_8021Q , vid,0 ); status = vsi->vlan_ops.del_vlan (vsi, &vlan);if (status) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ;
@@ -4392,7 +4392,7 @@ static int ice_vc_ena_vlan_stripping(struct ice_vf *vf) } vsi =ice_get_vf_vsi (vf); -if (vsi->vlan_ops.ena_stripping (vsi)) +if (vsi->vlan_ops.ena_stripping (vsi,ETH_P_8021Q )) v_ret =VIRTCHNL_STATUS_ERR_PARAM ; error_param:
@@ -4457,7 +4457,7 @@ static int ice_vf_init_vlan_stripping(struct ice_vf *vf)return 0 ;if (ice_vf_vlan_offload_ena (vf->driver_caps)) -return vsi->vlan_ops.ena_stripping (vsi); +return vsi->vlan_ops.ena_stripping (vsi,ETH_P_8021Q );else return vsi->vlan_ops.dis_stripping (vsi); }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +1 -1
@@ -120,7 +120,7 @@ struct ice_vf {struct ice_time_mac legacy_last_added_umac;DECLARE_BITMAP (txq_ena,ICE_MAX_RSS_QS_PER_VF );DECLARE_BITMAP (rxq_ena,ICE_MAX_RSS_QS_PER_VF ); -struct ice_vlan port_vlan_info;/* Port VLAN ID and QoS */ +struct ice_vlan port_vlan_info;/* Port VLAN ID, QoS, and TPID */ u8 pf_set_mac:1; /* VF MAC address set by VMM admin */ u8 trusted:1; u8 spoofchk:1;
drivers/net/ethernet/intel/ice/ice_vlan.h +2 -1
@@ -8,10 +8,11 @@#include "ice_type.h" struct ice_vlan { +u16 tpid;u16 vid;u8 prio; }; -#define ICE_VLAN (vid, prio) ((struct ice_vlan){ vid, prio }) +#define ICE_VLAN (tpid, vid, prio) ((struct ice_vlan){ tpid, vid, prio })#endif /* _ICE_VLAN_H_ */
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c +46 -2
86 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.h +2 -2
@@ -12,9 +12,9 @@ struct ice_vsi;int ice_vsi_add_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan);int ice_vsi_del_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan); -int ice_vsi_ena_stripping (struct ice_vsi *vsi); +int ice_vsi_ena_stripping (struct ice_vsi *vsi,u16 tpid);int ice_vsi_dis_stripping (struct ice_vsi *vsi); -int ice_vsi_ena_insertion (struct ice_vsi *vsi); +int ice_vsi_ena_insertion (struct ice_vsi *vsi,u16 tpid);int ice_vsi_dis_insertion (struct ice_vsi *vsi);int ice_vsi_set_port_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan);
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.h +2 -2
@@ -12,9 +12,9 @@ struct ice_vsi;struct ice_vsi_vlan_ops {int (*add_vlan)(struct ice_vsi *vsi,struct ice_vlan *vlan);int (*del_vlan)(struct ice_vsi *vsi,struct ice_vlan *vlan); -int (*ena_stripping)(struct ice_vsi *vsi); +int (*ena_stripping)(struct ice_vsi *vsi,const u16 tpid);int (*dis_stripping)(struct ice_vsi *vsi); -int (*ena_insertion)(struct ice_vsi *vsi); +int (*ena_insertion)(struct ice_vsi *vsi,const u16 tpid);int (*dis_insertion)(struct ice_vsi *vsi);int (*ena_rx_filtering)(struct ice_vsi *vsi);int (*dis_rx_filtering)(struct ice_vsi *vsi);
Signature · 1 line
2.20.1
G
PATCH v3 6/14 ice: Use the proto argument for VLAN ops
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 06/14] ice: Use the proto argument for VLAN opsFrom: Brett Creeley <[email protected]>
Currently the proto argument is unused. This is because the driver only supports 802.1Q VLAN filtering. This policy is enforced via netdev features that the driver sets up when configuring the netdev, so the proto argument won't ever be anything other than 802.1Q. However, this will allow for future iterations of the driver to seemlessly support 802.1ad filtering. Begin using the proto argument and extend the related structures to support its use.
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 14 lines
--- drivers/net/ethernet/intel/ice/ice_fltr.c | 2 + drivers/net/ethernet/intel/ice/ice_lib.c | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 22 ++++----- drivers/net/ethernet/intel/ice/ice_switch.c | 5 ++ drivers/net/ethernet/intel/ice/ice_switch.h | 2 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 10 ++-- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 2 +- drivers/net/ethernet/intel/ice/ice_vlan.h | 3 +- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 48 ++++++++++++++++++- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 4 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 4 +- 11 files changed, 78 insertions(+), 26 deletions(-)
Tony Nguyen
maintainerPATCH v3 7/14 ice: Adjust naming for inner VLAN operations
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Current operations act on inner VLAN fields. To support double VLAN, outer VLAN operations and functions will be implemented. Add the "inner" naming to existing VLAN operations to distinguish them from the upcoming outer values and functions. Some spacing adjustments are made to align values.
Note that the inner is not talking about a tunneled VLAN, but the second VLAN in the packet. For SVM the driver uses inner or single VLAN filtering and offloads and in Double VLAN Mode the driver uses the inner filtering and offloads for SR-IOV VFs in port VLANs in order to support offloading the guest VLAN while a port VLAN is configured.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 191 +++++++++--------- drivers/net/ethernet/intel/ice/ice_lib.c | 8 +- drivers/net/ethernet/intel/ice/ice_main.c | 6 +- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 57 +++--- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 10 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 10 +- 6 files changed, 140 insertions(+), 142 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +98 -93
@@ -343,108 +343,113 @@ struct ice_aqc_vsi_props {#define ICE_AQ_VSI_SW_FLAG_SRC_PRUNE BIT(7)u8 sw_flags2;#define ICE_AQ_VSI_SW_FLAG_RX_PRUNE_EN_S 0 -#define ICE_AQ_VSI_SW_FLAG_RX_PRUNE_EN_M \ - (0xF << ICE_AQ_VSI_SW_FLAG_RX_PRUNE_EN_S) +#define ICE_AQ_VSI_SW_FLAG_RX_PRUNE_EN_M (0xF << ICE_AQ_VSI_SW_FLAG_RX_PRUNE_EN_S)#define ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA BIT(0)#define ICE_AQ_VSI_SW_FLAG_LAN_ENA BIT(4)u8 veb_stat_id;#define ICE_AQ_VSI_SW_VEB_STAT_ID_S 0 -#define ICE_AQ_VSI_SW_VEB_STAT_ID_M (0x1F << ICE_AQ_VSI_SW_VEB_STAT_ID_S) +#define ICE_AQ_VSI_SW_VEB_STAT_ID_M (0x1F << ICE_AQ_VSI_SW_VEB_STAT_ID_S)#define ICE_AQ_VSI_SW_VEB_STAT_ID_VALID BIT(5)/* security section */ u8 sec_flags;#define ICE_AQ_VSI_SEC_FLAG_ALLOW_DEST_OVRD BIT(0)#define ICE_AQ_VSI_SEC_FLAG_ENA_MAC_ANTI_SPOOF BIT(2) -#define ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S 4 -#define ICE_AQ_VSI_SEC_TX_PRUNE_ENA_M (0xF << ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S) +#define ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S 4 +#define ICE_AQ_VSI_SEC_TX_PRUNE_ENA_M (0xF << ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S)#define ICE_AQ_VSI_SEC_TX_VLAN_PRUNE_ENA BIT(0)u8 sec_reserved;/* VLAN section */ -__le16 pvid;/* VLANS include priority bits */ -u8 pvlan_reserved[2 ]; -u8 vlan_flags; -#define ICE_AQ_VSI_VLAN_MODE_S 0 -#define ICE_AQ_VSI_VLAN_MODE_M (0x3 << ICE_AQ_VSI_VLAN_MODE_S) -#define ICE_AQ_VSI_VLAN_MODE_UNTAGGED 0x1 -#define ICE_AQ_VSI_VLAN_MODE_TAGGED 0x2 -#define ICE_AQ_VSI_VLAN_MODE_ALL 0x3 -#define ICE_AQ_VSI_PVLAN_INSERT_PVID BIT(2) -#define ICE_AQ_VSI_VLAN_EMOD_S 3 -#define ICE_AQ_VSI_VLAN_EMOD_M (0x3 << ICE_AQ_VSI_VLAN_EMOD_S) -#define ICE_AQ_VSI_VLAN_EMOD_STR_BOTH (0x0 << ICE_AQ_VSI_VLAN_EMOD_S) -#define ICE_AQ_VSI_VLAN_EMOD_STR_UP (0x1 << ICE_AQ_VSI_VLAN_EMOD_S) -#define ICE_AQ_VSI_VLAN_EMOD_STR (0x2 << ICE_AQ_VSI_VLAN_EMOD_S) -#define ICE_AQ_VSI_VLAN_EMOD_NOTHING (0x3 << ICE_AQ_VSI_VLAN_EMOD_S) -u8 pvlan_reserved2[3 ]; +__le16 port_based_inner_vlan;/* VLANS include priority bits */ +u8 inner_vlan_reserved[2 ]; +u8 inner_vlan_flags; +#define ICE_AQ_VSI_INNER_VLAN_TX_MODE_S 0 +#define ICE_AQ_VSI_INNER_VLAN_TX_MODE_M (0x3 << ICE_AQ_VSI_INNER_VLAN_TX_MODE_S) +#define ICE_AQ_VSI_INNER_VLAN_TX_MODE_ACCEPTUNTAGGED 0x1 +#define ICE_AQ_VSI_INNER_VLAN_TX_MODE_ACCEPTTAGGED 0x2 +#define ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL 0x3 +#define ICE_AQ_VSI_INNER_VLAN_INSERT_PVID BIT(2) +#define ICE_AQ_VSI_INNER_VLAN_EMODE_S 3 +#define ICE_AQ_VSI_INNER_VLAN_EMODE_M (0x3 << ICE_AQ_VSI_INNER_VLAN_EMODE_S) +#define ICE_AQ_VSI_INNER_VLAN_EMODE_STR_BOTH (0x0 << ICE_AQ_VSI_INNER_VLAN_EMODE_S) +#define ICE_AQ_VSI_INNER_VLAN_EMODE_STR_UP (0x1 << ICE_AQ_VSI_INNER_VLAN_EMODE_S) +#define ICE_AQ_VSI_INNER_VLAN_EMODE_STR (0x2 << ICE_AQ_VSI_INNER_VLAN_EMODE_S) +#define ICE_AQ_VSI_INNER_VLAN_EMODE_NOTHING (0x3 << ICE_AQ_VSI_INNER_VLAN_EMODE_S) +u8 inner_vlan_reserved2[3 ];/* ingress egress up sections */ __le32 ingress_table;/* bitmap, 3 bits per up */ -#define ICE_AQ_VSI_UP_TABLE_UP0_S 0 -#define ICE_AQ_VSI_UP_TABLE_UP0_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP0_S) -#define ICE_AQ_VSI_UP_TABLE_UP1_S 3 -#define ICE_AQ_VSI_UP_TABLE_UP1_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP1_S) -#define ICE_AQ_VSI_UP_TABLE_UP2_S 6 -#define ICE_AQ_VSI_UP_TABLE_UP2_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP2_S) -#define ICE_AQ_VSI_UP_TABLE_UP3_S 9 -#define ICE_AQ_VSI_UP_TABLE_UP3_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP3_S) -#define ICE_AQ_VSI_UP_TABLE_UP4_S 12 -#define ICE_AQ_VSI_UP_TABLE_UP4_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP4_S) -#define ICE_AQ_VSI_UP_TABLE_UP5_S 15 -#define ICE_AQ_VSI_UP_TABLE_UP5_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP5_S) -#define ICE_AQ_VSI_UP_TABLE_UP6_S 18 -#define ICE_AQ_VSI_UP_TABLE_UP6_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP6_S) -#define ICE_AQ_VSI_UP_TABLE_UP7_S 21 -#define ICE_AQ_VSI_UP_TABLE_UP7_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP7_S) +#define ICE_AQ_VSI_UP_TABLE_UP0_S 0 +#define ICE_AQ_VSI_UP_TABLE_UP0_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP0_S) +#define ICE_AQ_VSI_UP_TABLE_UP1_S 3 +#define ICE_AQ_VSI_UP_TABLE_UP1_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP1_S) +#define ICE_AQ_VSI_UP_TABLE_UP2_S 6 +#define ICE_AQ_VSI_UP_TABLE_UP2_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP2_S) +#define ICE_AQ_VSI_UP_TABLE_UP3_S 9 +#define ICE_AQ_VSI_UP_TABLE_UP3_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP3_S) +#define ICE_AQ_VSI_UP_TABLE_UP4_S 12 +#define ICE_AQ_VSI_UP_TABLE_UP4_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP4_S) +#define ICE_AQ_VSI_UP_TABLE_UP5_S 15 +#define ICE_AQ_VSI_UP_TABLE_UP5_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP5_S) +#define ICE_AQ_VSI_UP_TABLE_UP6_S 18 +#define ICE_AQ_VSI_UP_TABLE_UP6_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP6_S) +#define ICE_AQ_VSI_UP_TABLE_UP7_S 21 +#define ICE_AQ_VSI_UP_TABLE_UP7_M (0x7 << ICE_AQ_VSI_UP_TABLE_UP7_S)__le32 egress_table;/* same defines as for ingress table */ /* outer tags section */ -__le16 outer_tag; -u8 outer_tag_flags; -#define ICE_AQ_VSI_OUTER_TAG_MODE_S 0 -#define ICE_AQ_VSI_OUTER_TAG_MODE_M (0x3 << ICE_AQ_VSI_OUTER_TAG_MODE_S) -#define ICE_AQ_VSI_OUTER_TAG_NOTHING 0x0 -#define ICE_AQ_VSI_OUTER_TAG_REMOVE 0x1 -#define ICE_AQ_VSI_OUTER_TAG_COPY 0x2 -#define ICE_AQ_VSI_OUTER_TAG_TYPE_S 2 -#define ICE_AQ_VSI_OUTER_TAG_TYPE_M (0x3 << ICE_AQ_VSI_OUTER_TAG_TYPE_S) -#define ICE_AQ_VSI_OUTER_TAG_NONE 0x0 -#define ICE_AQ_VSI_OUTER_TAG_STAG 0x1 -#define ICE_AQ_VSI_OUTER_TAG_VLAN_8100 0x2 -#define ICE_AQ_VSI_OUTER_TAG_VLAN_9100 0x3 -#define ICE_AQ_VSI_OUTER_TAG_INSERT BIT(4) -#define ICE_AQ_VSI_OUTER_TAG_ACCEPT_HOST BIT(6) -u8 outer_tag_reserved; +__le16 port_based_outer_vlan; +u8 outer_vlan_flags; +#define ICE_AQ_VSI_OUTER_VLAN_EMODE_S 0 +#define ICE_AQ_VSI_OUTER_VLAN_EMODE_M (0x3 << ICE_AQ_VSI_OUTER_VLAN_EMODE_S) +#define ICE_AQ_VSI_OUTER_VLAN_EMODE_SHOW_BOTH 0x0 +#define ICE_AQ_VSI_OUTER_VLAN_EMODE_SHOW_UP 0x1 +#define ICE_AQ_VSI_OUTER_VLAN_EMODE_SHOW 0x2 +#define ICE_AQ_VSI_OUTER_VLAN_EMODE_NOTHING 0x3 +#define ICE_AQ_VSI_OUTER_TAG_TYPE_S 2 +#define ICE_AQ_VSI_OUTER_TAG_TYPE_M (0x3 << ICE_AQ_VSI_OUTER_TAG_TYPE_S) +#define ICE_AQ_VSI_OUTER_TAG_NONE 0x0 +#define ICE_AQ_VSI_OUTER_TAG_STAG 0x1 +#define ICE_AQ_VSI_OUTER_TAG_VLAN_8100 0x2 +#define ICE_AQ_VSI_OUTER_TAG_VLAN_9100 0x3 +#define ICE_AQ_VSI_OUTER_VLAN_PORT_BASED_INSERT BIT(4) +#define ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S 5 +#define ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M (0x3 << ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S) +#define ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ACCEPTUNTAGGED 0x1 +#define ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ACCEPTTAGGED 0x2 +#define ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ALL 0x3 +#define ICE_AQ_VSI_OUTER_VLAN_BLOCK_TX_DESC BIT(7) +u8 outer_vlan_reserved;/* queue mapping section */ __le16 mapping_flags; -#define ICE_AQ_VSI_Q_MAP_CONTIG 0x0 -#define ICE_AQ_VSI_Q_MAP_NONCONTIG BIT(0) +#define ICE_AQ_VSI_Q_MAP_CONTIG 0x0 +#define ICE_AQ_VSI_Q_MAP_NONCONTIG BIT(0)__le16 q_mapping[16 ]; -#define ICE_AQ_VSI_Q_S 0 -#define ICE_AQ_VSI_Q_M (0x7FF << ICE_AQ_VSI_Q_S) +#define ICE_AQ_VSI_Q_S 0 +#define ICE_AQ_VSI_Q_M (0x7FF << ICE_AQ_VSI_Q_S)__le16 tc_mapping[8 ]; -#define ICE_AQ_VSI_TC_Q_OFFSET_S 0 -#define ICE_AQ_VSI_TC_Q_OFFSET_M (0x7FF << ICE_AQ_VSI_TC_Q_OFFSET_S) -#define ICE_AQ_VSI_TC_Q_NUM_S 11 -#define ICE_AQ_VSI_TC_Q_NUM_M (0xF << ICE_AQ_VSI_TC_Q_NUM_S) +#define ICE_AQ_VSI_TC_Q_OFFSET_S 0 +#define ICE_AQ_VSI_TC_Q_OFFSET_M (0x7FF << ICE_AQ_VSI_TC_Q_OFFSET_S) +#define ICE_AQ_VSI_TC_Q_NUM_S 11 +#define ICE_AQ_VSI_TC_Q_NUM_M (0xF << ICE_AQ_VSI_TC_Q_NUM_S)/* queueing option section */ u8 q_opt_rss; -#define ICE_AQ_VSI_Q_OPT_RSS_LUT_S 0 -#define ICE_AQ_VSI_Q_OPT_RSS_LUT_M (0x3 << ICE_AQ_VSI_Q_OPT_RSS_LUT_S) -#define ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI 0x0 -#define ICE_AQ_VSI_Q_OPT_RSS_LUT_PF 0x2 -#define ICE_AQ_VSI_Q_OPT_RSS_LUT_GBL 0x3 -#define ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_S 2 -#define ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M (0xF << ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_S) -#define ICE_AQ_VSI_Q_OPT_RSS_HASH_S 6 -#define ICE_AQ_VSI_Q_OPT_RSS_HASH_M (0x3 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) -#define ICE_AQ_VSI_Q_OPT_RSS_TPLZ (0x0 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) -#define ICE_AQ_VSI_Q_OPT_RSS_SYM_TPLZ (0x1 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) -#define ICE_AQ_VSI_Q_OPT_RSS_XOR (0x2 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) -#define ICE_AQ_VSI_Q_OPT_RSS_JHASH (0x3 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) +#define ICE_AQ_VSI_Q_OPT_RSS_LUT_S 0 +#define ICE_AQ_VSI_Q_OPT_RSS_LUT_M (0x3 << ICE_AQ_VSI_Q_OPT_RSS_LUT_S) +#define ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI 0x0 +#define ICE_AQ_VSI_Q_OPT_RSS_LUT_PF 0x2 +#define ICE_AQ_VSI_Q_OPT_RSS_LUT_GBL 0x3 +#define ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_S 2 +#define ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M (0xF << ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_S) +#define ICE_AQ_VSI_Q_OPT_RSS_HASH_S 6 +#define ICE_AQ_VSI_Q_OPT_RSS_HASH_M (0x3 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) +#define ICE_AQ_VSI_Q_OPT_RSS_TPLZ (0x0 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) +#define ICE_AQ_VSI_Q_OPT_RSS_SYM_TPLZ (0x1 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) +#define ICE_AQ_VSI_Q_OPT_RSS_XOR (0x2 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S) +#define ICE_AQ_VSI_Q_OPT_RSS_JHASH (0x3 << ICE_AQ_VSI_Q_OPT_RSS_HASH_S)u8 q_opt_tc; -#define ICE_AQ_VSI_Q_OPT_TC_OVR_S 0 -#define ICE_AQ_VSI_Q_OPT_TC_OVR_M (0x1F << ICE_AQ_VSI_Q_OPT_TC_OVR_S) -#define ICE_AQ_VSI_Q_OPT_PROF_TC_OVR BIT(7) +#define ICE_AQ_VSI_Q_OPT_TC_OVR_S 0 +#define ICE_AQ_VSI_Q_OPT_TC_OVR_M (0x1F << ICE_AQ_VSI_Q_OPT_TC_OVR_S) +#define ICE_AQ_VSI_Q_OPT_PROF_TC_OVR BIT(7)u8 q_opt_flags; -#define ICE_AQ_VSI_Q_OPT_PE_FLTR_EN BIT(0) +#define ICE_AQ_VSI_Q_OPT_PE_FLTR_EN BIT(0)u8 q_opt_reserved[3 ];/* outer up section */ __le32 outer_up_table;/* same structure and defines as ingress tbl */
@@ -452,27 +457,27 @@ struct ice_aqc_vsi_props {__le16 sect_10_reserved;/* flow director section */ __le16 fd_options; -#define ICE_AQ_VSI_FD_ENABLE BIT(0) -#define ICE_AQ_VSI_FD_TX_AUTO_ENABLE BIT(1) -#define ICE_AQ_VSI_FD_PROG_ENABLE BIT(3) +#define ICE_AQ_VSI_FD_ENABLE BIT(0) +#define ICE_AQ_VSI_FD_TX_AUTO_ENABLE BIT(1) +#define ICE_AQ_VSI_FD_PROG_ENABLE BIT(3)__le16 max_fd_fltr_dedicated;__le16 max_fd_fltr_shared;__le16 fd_def_q; -#define ICE_AQ_VSI_FD_DEF_Q_S 0 -#define ICE_AQ_VSI_FD_DEF_Q_M (0x7FF << ICE_AQ_VSI_FD_DEF_Q_S) -#define ICE_AQ_VSI_FD_DEF_GRP_S 12 -#define ICE_AQ_VSI_FD_DEF_GRP_M (0x7 << ICE_AQ_VSI_FD_DEF_GRP_S) +#define ICE_AQ_VSI_FD_DEF_Q_S 0 +#define ICE_AQ_VSI_FD_DEF_Q_M (0x7FF << ICE_AQ_VSI_FD_DEF_Q_S) +#define ICE_AQ_VSI_FD_DEF_GRP_S 12 +#define ICE_AQ_VSI_FD_DEF_GRP_M (0x7 << ICE_AQ_VSI_FD_DEF_GRP_S)__le16 fd_report_opt; -#define ICE_AQ_VSI_FD_REPORT_Q_S 0 -#define ICE_AQ_VSI_FD_REPORT_Q_M (0x7FF << ICE_AQ_VSI_FD_REPORT_Q_S) -#define ICE_AQ_VSI_FD_DEF_PRIORITY_S 12 -#define ICE_AQ_VSI_FD_DEF_PRIORITY_M (0x7 << ICE_AQ_VSI_FD_DEF_PRIORITY_S) -#define ICE_AQ_VSI_FD_DEF_DROP BIT(15) +#define ICE_AQ_VSI_FD_REPORT_Q_S 0 +#define ICE_AQ_VSI_FD_REPORT_Q_M (0x7FF << ICE_AQ_VSI_FD_REPORT_Q_S) +#define ICE_AQ_VSI_FD_DEF_PRIORITY_S 12 +#define ICE_AQ_VSI_FD_DEF_PRIORITY_M (0x7 << ICE_AQ_VSI_FD_DEF_PRIORITY_S) +#define ICE_AQ_VSI_FD_DEF_DROP BIT(15)/* PASID section */ __le32 pasid_id; -#define ICE_AQ_VSI_PASID_ID_S 0 -#define ICE_AQ_VSI_PASID_ID_M (0xFFFFF << ICE_AQ_VSI_PASID_ID_S) -#define ICE_AQ_VSI_PASID_ID_VALID BIT(31) +#define ICE_AQ_VSI_PASID_ID_S 0 +#define ICE_AQ_VSI_PASID_ID_M (0xFFFFF << ICE_AQ_VSI_PASID_ID_S) +#define ICE_AQ_VSI_PASID_ID_VALID BIT(31)u8 reserved[24 ]; };
drivers/net/ethernet/intel/ice/ice_lib.c +4 -4
@@ -810,13 +810,13 @@ static void ice_set_dflt_vsi_ctx(struct ice_vsi_ctx *ctxt) ctxt->info.sw_flags =ICE_AQ_VSI_SW_FLAG_SRC_PRUNE ;/* Traffic from VSI can be sent to LAN */ ctxt->info.sw_flags2 =ICE_AQ_VSI_SW_FLAG_LAN_ENA ; -/* By default bits 3 and 4 in vlan_flags are 0's which results in legacy +/* By default bits 3 and 4 in inner_vlan_flags are 0's which results in legacy * behavior (show VLAN, DEI, and UP) in descriptor. Also, allow all * packets untagged/tagged. */ - ctxt->info.vlan_flags = ((ICE_AQ_VSI_VLAN_MODE_ALL & -ICE_AQ_VSI_VLAN_MODE_M ) >> -ICE_AQ_VSI_VLAN_MODE_S ); + ctxt->info.inner_vlan_flags = ((ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL & +ICE_AQ_VSI_INNER_VLAN_TX_MODE_M ) >> +ICE_AQ_VSI_INNER_VLAN_TX_MODE_S );/* Have 1:1 UP mapping for both ingress/egress tables */ table |=ICE_UP_TABLE_TRANSLATE (0 ,0 ); table |=ICE_UP_TABLE_TRANSLATE (1 ,1 );
drivers/net/ethernet/intel/ice/ice_main.c +3 -3
@@ -4071,8 +4071,8 @@ static void ice_set_safe_mode_vlan_cfg(struct ice_pf *pf) ctxt->info.sw_flags2 &= ~ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA ;/* allow all VLANs on Tx and don't strip on Rx */ - ctxt->info.vlan_flags =ICE_AQ_VSI_VLAN_MODE_ALL | -ICE_AQ_VSI_VLAN_EMOD_NOTHING ; + ctxt->info.inner_vlan_flags =ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL | +ICE_AQ_VSI_INNER_VLAN_EMODE_NOTHING ; status =ice_update_vsi (hw, vsi->idx, ctxt,NULL );if (status) {
@@ -4081,7 +4081,7 @@ static void ice_set_safe_mode_vlan_cfg(struct ice_pf *pf) }else { vsi->info.sec_flags = ctxt->info.sec_flags; vsi->info.sw_flags2 = ctxt->info.sw_flags2; - vsi->info.vlan_flags = ctxt->info.vlan_flags; + vsi->info.inner_vlan_flags = ctxt->info.inner_vlan_flags; }kfree (ctxt);
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c +25 -32
149 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.h +5 -5
@@ -12,11 +12,11 @@ struct ice_vsi;int ice_vsi_add_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan);int ice_vsi_del_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan); -int ice_vsi_ena_stripping (struct ice_vsi *vsi,u16 tpid); -int ice_vsi_dis_stripping (struct ice_vsi *vsi); -int ice_vsi_ena_insertion (struct ice_vsi *vsi,u16 tpid); -int ice_vsi_dis_insertion (struct ice_vsi *vsi); -int ice_vsi_set_port_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan); +int ice_vsi_ena_inner_stripping (struct ice_vsi *vsi,u16 tpid); +int ice_vsi_dis_inner_stripping (struct ice_vsi *vsi); +int ice_vsi_ena_inner_insertion (struct ice_vsi *vsi,u16 tpid); +int ice_vsi_dis_inner_insertion (struct ice_vsi *vsi); +int ice_vsi_set_inner_port_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan);int ice_vsi_ena_rx_vlan_filtering (struct ice_vsi *vsi);int ice_vsi_dis_rx_vlan_filtering (struct ice_vsi *vsi);
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c +5 -5
@@ -8,13 +8,13 @@ void ice_vsi_init_vlan_ops(struct ice_vsi *vsi) { vsi->vlan_ops.add_vlan = ice_vsi_add_vlan; vsi->vlan_ops.del_vlan = ice_vsi_del_vlan; - vsi->vlan_ops.ena_stripping = ice_vsi_ena_stripping; - vsi->vlan_ops.dis_stripping = ice_vsi_dis_stripping; - vsi->vlan_ops.ena_insertion = ice_vsi_ena_insertion; - vsi->vlan_ops.dis_insertion = ice_vsi_dis_insertion; + vsi->vlan_ops.ena_stripping = ice_vsi_ena_inner_stripping; + vsi->vlan_ops.dis_stripping = ice_vsi_dis_inner_stripping; + vsi->vlan_ops.ena_insertion = ice_vsi_ena_inner_insertion; + vsi->vlan_ops.dis_insertion = ice_vsi_dis_inner_insertion; vsi->vlan_ops.ena_rx_filtering = ice_vsi_ena_rx_vlan_filtering; vsi->vlan_ops.dis_rx_filtering = ice_vsi_dis_rx_vlan_filtering; vsi->vlan_ops.ena_tx_filtering = ice_vsi_ena_tx_vlan_filtering; vsi->vlan_ops.dis_tx_filtering = ice_vsi_dis_tx_vlan_filtering; - vsi->vlan_ops.set_port_vlan = ice_vsi_set_port_vlan; + vsi->vlan_ops.set_port_vlan = ice_vsi_set_inner_port_vlan; }
Signature · 1 line
2.20.1
G
PATCH v3 7/14 ice: Adjust naming for inner VLAN operations
Quoted 25 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 07/14] ice: Adjust naming for inner VLAN operationsFrom: Brett Creeley <[email protected]>
Current operations act on inner VLAN fields. To support double VLAN, outer VLAN operations and functions will be implemented. Add the "inner" naming to existing VLAN operations to distinguish them from the upcoming outer values and functions. Some spacing adjustments are made to align values.
Note that the inner is not talking about a tunneled VLAN, but the second VLAN in the packet. For SVM the driver uses inner or single VLAN filtering and offloads and in Double VLAN Mode the driver uses the inner filtering and offloads for SR-IOV VFs in port VLANs in order to support offloading the guest VLAN while a port VLAN is configured.
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 9 lines
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 191 +++++++++--------- drivers/net/ethernet/intel/ice/ice_lib.c | 8 +- drivers/net/ethernet/intel/ice/ice_main.c | 6 +- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 57 +++--- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 10 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 10 +- 6 files changed, 140 insertions(+), 142 deletions(-)
Tony Nguyen
maintainerPATCH v3 8/14 ice: Add outer_vlan_ops and VSI specific VLAN ops implementations
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Add a new outer_vlan_ops member to the ice_vsi structure as outer VLAN ops are only available when the device is in Double VLAN Mode (DVM). Depending on the VSI type, the requirements for what operations to use/allow differ.
By default all VSI's have unsupported inner and outer VSI VLAN ops. This implementation was chosen to prevent unexpected crashes due to null pointer dereferences. Instead, if a VSI calls an unsupported op, it will just return -EOPNOTSUPP.
Add implementations to support modifying outer VLAN fields for VSI context. This includes the ability to modify VLAN stripping, insertion, and the port VLAN based on the outer VLAN handling fields of the VSI context.
These functions should only ever be used if DVM is enabled because that means the firmware supports the outer VLAN fields in the VSI context. If the device is in DVM, then always use the outer_vlan_ops, else use the vlan_ops since the device is in Single VLAN Mode (SVM).
Also, move adding the untagged VLAN 0 filter from ice_vsi_setup() to ice_vsi_vlan_setup() as the latter function is specific to the PF and all other VSI types that need an untagged VLAN 0 filter already do this in their specific flows. Without this change, Flow Director is failing to initialize because it does not implement any VSI VLAN ops.
--- drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 3 +- drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +- drivers/net/ethernet/intel/ice/ice_lib.c | 111 +++++- drivers/net/ethernet/intel/ice/ice_lib.h | 3 + drivers/net/ethernet/intel/ice/ice_main.c | 60 +-- .../ethernet/intel/ice/ice_pf_vsi_vlan_ops.c | 37 ++ .../ethernet/intel/ice/ice_pf_vsi_vlan_ops.h | 13 + .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 72 ++++ .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.h | 16 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 101 +++-- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 6 + .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 344 +++++++++++++++++- .../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 6 + .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 107 +++++- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 6 + 16 files changed, 808 insertions(+), 85 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_pf_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_pf_vsi_vlan_ops.h create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.h
drivers/net/ethernet/intel/ice/Makefile +2 -1
@@ -18,6 +18,7 @@ ice-y := ice_main.o \ ice_txrx_lib.o \ ice_txrx.o \ ice_fltr.o \ + ice_pf_vsi_vlan_ops.o \ ice_vsi_vlan_ops.o \ ice_vsi_vlan_lib.o \ ice_fdir.o \
@@ -32,7 +33,7 @@ ice-y := ice_main.o \ ice_repr.o \ ice_tc_lib.o ice-$(CONFIG_PCI_IOV) += ice_virtchnl_allowlist.o -ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice_virtchnl_fdir.o +ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice_virtchnl_fdir.o ice_vf_vsi_vlan_ops.o ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o ice_gnss.o ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
drivers/net/ethernet/intel/ice/ice.h +2 -1
@@ -371,7 +371,8 @@ struct ice_vsi { u8 irqs_ready:1; u8 current_isup:1; /* Sync 'link up' logging */ u8 stat_offsets_loaded:1; -struct ice_vsi_vlan_ops vlan_ops; +struct ice_vsi_vlan_ops inner_vlan_ops; +struct ice_vsi_vlan_ops outer_vlan_ops;u16 num_vlan;/* queue information */
drivers/net/ethernet/intel/ice/ice_eswitch.c +4 -1
@@ -116,9 +116,12 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)struct ice_vsi *uplink_vsi = pf->switchdev.uplink_vsi;struct net_device *uplink_netdev = uplink_vsi->netdev;struct ice_vsi *ctrl_vsi = pf->switchdev.control_vsi; +struct ice_vsi_vlan_ops *vlan_ops;bool rule_added = false; - ctrl_vsi->vlan_ops.dis_stripping (ctrl_vsi); + vlan_ops =ice_get_compat_vsi_vlan_ops (ctrl_vsi); +if (vlan_ops->dis_stripping (ctrl_vsi)) +return -ENODEV ;ice_remove_vsi_fltr (&pf->hw, uplink_vsi->idx);
drivers/net/ethernet/intel/ice/ice_lib.c +99 -12
135 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.h +3 -0
@@ -124,6 +124,9 @@ void ice_vsi_ctx_set_allow_override(struct ice_vsi_ctx *ctx);void ice_vsi_ctx_clear_allow_override (struct ice_vsi_ctx *ctx);int ice_vsi_add_vlan_zero (struct ice_vsi *vsi); +int ice_vsi_del_vlan_zero (struct ice_vsi *vsi); +bool ice_vsi_has_non_zero_vlans (struct ice_vsi *vsi); +u16 ice_vsi_num_non_zero_vlans (struct ice_vsi *vsi);bool ice_is_feature_supported (struct ice_pf *pf,enum ice_feature f);void ice_clear_feature_support (struct ice_pf *pf,enum ice_feature f);void ice_init_feature_support (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_main.c +37 -23
209 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_pf_vsi_vlan_ops.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#include "ice_vsi_vlan_ops.h" +#include "ice_vsi_vlan_lib.h" +#include "ice.h" +#include "ice_pf_vsi_vlan_ops.h" + +void ice_pf_vsi_init_vlan_ops (struct ice_vsi *vsi) +{ +struct ice_vsi_vlan_ops *vlan_ops; + +if (ice_is_dvm_ena (&vsi->back->hw)) { + vlan_ops = &vsi->outer_vlan_ops; + + vlan_ops->add_vlan = ice_vsi_add_vlan; + vlan_ops->del_vlan = ice_vsi_del_vlan; + vlan_ops->ena_stripping = ice_vsi_ena_outer_stripping; + vlan_ops->dis_stripping = ice_vsi_dis_outer_stripping; + vlan_ops->ena_insertion = ice_vsi_ena_outer_insertion; + vlan_ops->dis_insertion = ice_vsi_dis_outer_insertion; + vlan_ops->ena_rx_filtering = ice_vsi_ena_rx_vlan_filtering; + vlan_ops->dis_rx_filtering = ice_vsi_dis_rx_vlan_filtering; + }else { + vlan_ops = &vsi->inner_vlan_ops; + + vlan_ops->add_vlan = ice_vsi_add_vlan; + vlan_ops->del_vlan = ice_vsi_del_vlan; + vlan_ops->ena_stripping = ice_vsi_ena_inner_stripping; + vlan_ops->dis_stripping = ice_vsi_dis_inner_stripping; + vlan_ops->ena_insertion = ice_vsi_ena_inner_insertion; + vlan_ops->dis_insertion = ice_vsi_dis_inner_insertion; + vlan_ops->ena_rx_filtering = ice_vsi_ena_rx_vlan_filtering; + vlan_ops->dis_rx_filtering = ice_vsi_dis_rx_vlan_filtering; + } +} +
drivers/net/ethernet/intel/ice/ice_pf_vsi_vlan_ops.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#ifndef _ICE_PF_VSI_VLAN_OPS_H_ +#define _ICE_PF_VSI_VLAN_OPS_H_ + +#include "ice_vsi_vlan_ops.h" + +struct ice_vsi ; + +void ice_pf_vsi_init_vlan_ops (struct ice_vsi *vsi); + +#endif /* _ICE_PF_VSI_VLAN_OPS_H_ */
drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c new file +72 -0
72 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#ifndef _ICE_VF_VSI_VLAN_OPS_H_ +#define _ICE_VF_VSI_VLAN_OPS_H_ + +#include "ice_vsi_vlan_ops.h" + +struct ice_vsi ; + +#ifdef CONFIG_PCI_IOV +void ice_vf_vsi_init_vlan_ops (struct ice_vsi *vsi); +#else +static inline void ice_vf_vsi_init_vlan_ops (struct ice_vsi *vsi) { } +#endif /* CONFIG_PCI_IOV */ +#endif /* _ICE_PF_VSI_VLAN_OPS_H_ */
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +67 -34
260 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +6 -0
@@ -211,6 +211,7 @@ int ice_vc_send_msg_to_vf(struct ice_vf *vf, u32 v_opcode, enum virtchnl_status_code v_retval, u8 *msg, u16 msglen);bool ice_vc_isvalid_vsi_id (struct ice_vf *vf,u16 vsi_id); +bool ice_vf_is_port_vlan_ena (struct ice_vf *vf);#else /* CONFIG_PCI_IOV */ static inline void ice_process_vflr_event (struct ice_pf *pf) { }static inline void ice_free_vfs (struct ice_pf *pf) { }
@@ -343,5 +344,10 @@ static inline bool ice_is_any_vf_in_promisc(struct ice_pf __always_unused *pf) {return false; } + +static inline bool ice_vf_is_port_vlan_ena (struct ice_vf __always_unused *vf) +{ +return false; +}#endif /* CONFIG_PCI_IOV */ #endif /* _ICE_VIRTCHNL_PF_H_ */
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c +343 -1
353 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.h +6 -0
@@ -23,4 +23,10 @@ int ice_vsi_dis_rx_vlan_filtering(struct ice_vsi *vsi);int ice_vsi_ena_tx_vlan_filtering (struct ice_vsi *vsi);int ice_vsi_dis_tx_vlan_filtering (struct ice_vsi *vsi); +int ice_vsi_ena_outer_stripping (struct ice_vsi *vsi,u16 tpid); +int ice_vsi_dis_outer_stripping (struct ice_vsi *vsi); +int ice_vsi_ena_outer_insertion (struct ice_vsi *vsi,u16 tpid); +int ice_vsi_dis_outer_insertion (struct ice_vsi *vsi); +int ice_vsi_set_outer_port_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan); +#endif /* _ICE_VSI_VLAN_LIB_H_ */
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c +95 -12
115 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.h +6 -0
@@ -23,6 +23,12 @@ struct ice_vsi_vlan_ops { int (*set_port_vlan)(struct ice_vsi *vsi, struct ice_vlan *vlan); }; +static inline bool ice_is_dvm_ena (struct ice_hw __always_unused *hw) +{ +return false; +} +void ice_vsi_init_vlan_ops (struct ice_vsi *vsi); +struct ice_vsi_vlan_ops *ice_get_compat_vsi_vlan_ops (struct ice_vsi *vsi);#endif /* _ICE_VSI_VLAN_OPS_H_ */
Signature · 1 line
2.20.1
G
PATCH v3 8/14 ice: Add outer_vlan_ops and VSI specific VLAN ops implementations
Quoted 54 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 08/14] ice: Addouter_vlan_opsand VSI specific VLAN ops implementationsFrom: Brett Creeley <[email protected]>
Add a new
outer_vlan_opsmember to theice_vsistructure as outer VLAN ops are only available when the device is in Double VLAN Mode (DVM). Depending on the VSI type, the requirements for what operations to use/allow differ.By default all VSI's have unsupported inner and outer VSI VLAN ops. This implementation was chosen to prevent unexpected crashes due to null pointer dereferences. Instead, if a VSI calls an unsupported op, it will just return
-EOPNOTSUPP.Add implementations to support modifying outer VLAN fields for VSI context. This includes the ability to modify VLAN stripping, insertion, and the port VLAN based on the outer VLAN handling fields of the VSI context.
These functions should only ever be used if DVM is enabled because that means the firmware supports the outer VLAN fields in the VSI context. If the device is in DVM, then always use the
outer_vlan_ops, else use thevlan_opssince the device is in Single VLAN Mode (SVM).Also, move adding the untagged VLAN 0 filter from
ice_vsi_setup()toice_vsi_vlan_setup()as the latter function is specific to the PF and all other VSI types that need an untagged VLAN 0 filter already do this in their specific flows. Without this change, Flow Director is failing to initialize because it does not implement any VSI VLAN ops.Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 3 +- drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +- drivers/net/ethernet/intel/ice/ice_lib.c | 111 +++++- drivers/net/ethernet/intel/ice/ice_lib.h | 3 + drivers/net/ethernet/intel/ice/ice_main.c | 60 +-- .../ethernet/intel/ice/ice_pf_vsi_vlan_ops.c | 37 ++ .../ethernet/intel/ice/ice_pf_vsi_vlan_ops.h | 13 + .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 72 ++++ .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.h | 16 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 101 +++-- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 6 + .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 344 +++++++++++++++++-
Quoted 9 lines
.../net/ethernet/intel/ice/ice_vsi_vlan_lib.h | 6 + .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 107 +++++- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 6 + 16 files changed, 808 insertions(+), 85 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_pf_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_pf_vsi_vlan_ops.h create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.h
Tony Nguyen
maintainerPATCH v3 9/14 ice: Add hot path support for 802.1Q and 802.1ad VLAN offloads
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently the driver only supports 802.1Q VLAN insertion and stripping. However, once Double VLAN Mode (DVM) is fully supported, then both 802.1Q and 802.1ad VLAN insertion and stripping will be supported. Unfortunately the VSI context parameters only allow for one VLAN ethertype at a time for VLAN offloads so only one or the other VLAN ethertype offload can be supported at once.
To support this, multiple changes are needed.
Rx path changes:
[1] In DVM, the Rx queue context l2tagsel field needs to be cleared so the outermost tag shows up in the l2tag2_2nd field of the Rx flex descriptor. In Single VLAN Mode (SVM), the l2tagsel field should remain 1 to support SVM configurations.
[2] Modify the ice_test_staterr() function to take a __le16 instead of the ice_32b_rx_flex_desc union pointer so this function can be used for both rx_desc->wb.status_error0 and rx_desc->wb.status_error1.
[3] Add the new inline function ice_get_vlan_tag_from_rx_desc() that checks if there is a VLAN tag in l2tag1 or l2tag2_2nd.
[4] In ice_receive_skb(), add a check to see if NETIF_F_HW_VLAN_STAG_RX is enabled in netdev->features. If it is, then this is the VLAN ethertype that needs to be added to the stripping VLAN tag. Since ice_fix_features() prevents CTAG_RX and STAG_RX from being enabled simultaneously, the VLAN ethertype will only ever be 802.1Q or 802.1ad.
Tx path changes:
[1] In DVM, the VLAN tag needs to be placed in the l2tag2 field of the Tx context descriptor. The new define ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN was added to the list of tx_flags to handle this case.
[2] When the stack requests the VLAN tag to be offloaded on Tx, the driver needs to set either ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN or ICE_TX_FLAGS_HW_VLAN, so the tag is inserted in l2tag2 or l2tag1 respectively. To determine which location to use, set a bit in the Tx ring flags field during ring allocation that can be used to determine which field to use in the Tx descriptor. In DVM, always use l2tag2, and in SVM, always use l2tag1.
---
v2: Fix kdoc issue
drivers/net/ethernet/intel/ice/ice_base.c | 18 +++++++++-- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 8 +++-- .../net/ethernet/intel/ice/ice_lan_tx_rx.h | 2 ++ drivers/net/ethernet/intel/ice/ice_lib.c | 5 ++++ drivers/net/ethernet/intel/ice/ice_txrx.c | 28 +++++++++++------ drivers/net/ethernet/intel/ice/ice_txrx.h | 3 ++ drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 9 ++++-- drivers/net/ethernet/intel/ice/ice_txrx_lib.h | 30 +++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_xsk.c | 6 ++-- 9 files changed, 87 insertions(+), 22 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +16 -2
@@ -406,8 +406,22 @@ static int ice_setup_rx_ctx(struct ice_rx_ring *ring)*/ rlan_ctx.crcstrip =1 ; -/* L2TSEL flag defines the reported L2 Tags in the receive descriptor */ - rlan_ctx.l2tsel =1 ; +/* L2TSEL flag defines the reported L2 Tags in the receive descriptor +* and it needs to remain 1 for non-DVM capable configurations to not +* break backward compatibility for VF drivers. Setting this field to 0 +* will cause the single/outer VLAN tag to be stripped to the L2TAG2_2ND +* field in the Rx descriptor. Setting it to 1 allows the VLAN tag to +* be stripped in L2TAG1 of the Rx descriptor, which is where VFs will +* check for the tag +*/ +if (ice_is_dvm_ena (hw)) +if (vsi->type ==ICE_VSI_VF && +ice_vf_is_port_vlan_ena (&vsi->back->vf[vsi->vf_id])) + rlan_ctx.l2tsel =1 ; +else + rlan_ctx.l2tsel =0 ; +else + rlan_ctx.l2tsel =1 ; rlan_ctx.dtype =ICE_RX_DTYPE_NO_SPLIT ; rlan_ctx.hsplit_0 =ICE_RLAN_RX_HSPLIT_0_NO_SPLIT ;
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +6 -2
@@ -916,7 +916,8 @@ ice_tx_prepare_vlan_flags_dcb(struct ice_tx_ring *tx_ring,return ;/* Insert 802.1p priority into VLAN header */ -if ((first->tx_flags &ICE_TX_FLAGS_HW_VLAN ) || +if ((first->tx_flags &ICE_TX_FLAGS_HW_VLAN || + first->tx_flags &ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN ) || skb->priority !=TC_PRIO_CONTROL ) { first->tx_flags &= ~ICE_TX_FLAGS_VLAN_PR_M ;/* Mask the lower 3 bits to set the 802.1p priority */
@@ -925,7 +926,10 @@ ice_tx_prepare_vlan_flags_dcb(struct ice_tx_ring *tx_ring,/* if this is not already set it means a VLAN 0 + priority needs * to be offloaded */ - first->tx_flags |=ICE_TX_FLAGS_HW_VLAN ; +if (tx_ring->flags &ICE_TX_FLAGS_RING_VLAN_L2TAG2 ) + first->tx_flags |=ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN ; +else + first->tx_flags |=ICE_TX_FLAGS_HW_VLAN ; } }
drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h +2 -0
@@ -424,6 +424,8 @@ enum ice_rx_flex_desc_status_error_0_bits {enum ice_rx_flex_desc_status_error_1_bits {/* Note: These are predefined bit offsets */ ICE_RX_FLEX_DESC_STATUS1_NAT_S =4 , +/* [10:5] reserved */ +ICE_RX_FLEX_DESC_STATUS1_L2TAG2P_S =11 ,ICE_RX_FLEX_DESC_STATUS1_LAST /* this entry must be last!!! */ };
drivers/net/ethernet/intel/ice/ice_lib.c +5 -0
@@ -1370,6 +1370,7 @@ static void ice_vsi_clear_rings(struct ice_vsi *vsi)*/ static int ice_vsi_alloc_rings (struct ice_vsi *vsi) { +bool dvm_ena =ice_is_dvm_ena (&vsi->back->hw);struct ice_pf *pf = vsi->back;struct device *dev;u16 i;
@@ -1391,6 +1392,10 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi) ring->tx_tstamps = &pf->ptp.port.tx; ring->dev = dev; ring->count = vsi->num_tx_desc; +if (dvm_ena) + ring->flags |=ICE_TX_FLAGS_RING_VLAN_L2TAG2 ; +else + ring->flags |=ICE_TX_FLAGS_RING_VLAN_L2TAG1 ;WRITE_ONCE (vsi->tx_rings[i], ring); }
drivers/net/ethernet/intel/ice/ice_txrx.c +19 -9
@@ -1073,7 +1073,7 @@ ice_is_non_eop(struct ice_rx_ring *rx_ring, union ice_32b_rx_flex_desc *rx_desc) {/* if we are the last buffer then there is nothing else to do */ #define ICE_RXD_EOF BIT(ICE_RX_FLEX_DESC_STATUS0_EOF_S) -if (likely (ice_test_staterr (rx_desc,ICE_RXD_EOF ))) +if (likely (ice_test_staterr (rx_desc->wb.status_error0,ICE_RXD_EOF )))return false; rx_ring->rx_stats.non_eop_descs++;
@@ -1135,7 +1135,7 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)* hardware wrote DD then it will be non-zero */ stat_err_bits =BIT (ICE_RX_FLEX_DESC_STATUS0_DD_S ); -if (!ice_test_staterr (rx_desc, stat_err_bits)) +if (!ice_test_staterr (rx_desc->wb.status_error0, stat_err_bits))break ;/* This memory barrier is needed to keep us from reading
@@ -1221,14 +1221,13 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)continue ; stat_err_bits =BIT (ICE_RX_FLEX_DESC_STATUS0_RXE_S ); -if (unlikely (ice_test_staterr (rx_desc, stat_err_bits))) { +if (unlikely (ice_test_staterr (rx_desc->wb.status_error0, + stat_err_bits))) {dev_kfree_skb_any (skb);continue ; } - stat_err_bits =BIT (ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S ); -if (ice_test_staterr (rx_desc, stat_err_bits)) - vlan_tag =le16_to_cpu (rx_desc->wb.l2tag1); + vlan_tag =ice_get_vlan_tag_from_rx_desc (rx_desc);/* pad the skb if needed, to make a valid ethernet frame */ if (eth_skb_pad (skb)) {
@@ -1910,12 +1909,16 @@ ice_tx_prepare_vlan_flags(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first)if (!skb_vlan_tag_present (skb) &ð_type_vlan (skb->protocol))return ; -/* currently, we always assume 802.1Q for VLAN insertion as VLAN -* insertion for 802.1AD is not supported +/* the VLAN ethertype/tpid is determined by VSI configuration and netdev +* feature flags, which the driver only allows either 802.1Q or 802.1ad +* VLAN offloads exclusively so we only care about the VLAN ID here */ if (skb_vlan_tag_present (skb)) { first->tx_flags |=skb_vlan_tag_get (skb) <<ICE_TX_FLAGS_VLAN_S ; - first->tx_flags |=ICE_TX_FLAGS_HW_VLAN ; +if (tx_ring->flags &ICE_TX_FLAGS_RING_VLAN_L2TAG2 ) + first->tx_flags |=ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN ; +else + first->tx_flags |=ICE_TX_FLAGS_HW_VLAN ; }ice_tx_prepare_vlan_flags_dcb (tx_ring, first);
@@ -2288,6 +2291,13 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_tx_ring *tx_ring)/* prepare the VLAN tagging flags for Tx */ ice_tx_prepare_vlan_flags (tx_ring, first); +if (first->tx_flags &ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN ) { + offload.cd_qw1 |= (u64)(ICE_TX_DESC_DTYPE_CTX | + (ICE_TX_CTX_DESC_IL2TAG2 << +ICE_TXD_CTX_QW1_CMD_S )); + offload.cd_l2tag2 = (first->tx_flags &ICE_TX_FLAGS_VLAN_M ) >> +ICE_TX_FLAGS_VLAN_S ; + }/* set up TSO offload */ tso =ice_tso (first, &offload);
drivers/net/ethernet/intel/ice/ice_txrx.h +3 -0
@@ -123,6 +123,7 @@ static inline int ice_skb_pad(void)#define ICE_TX_FLAGS_IPV4 BIT(5)#define ICE_TX_FLAGS_IPV6 BIT(6)#define ICE_TX_FLAGS_TUNNEL BIT(7) +#define ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN BIT(8)#define ICE_TX_FLAGS_VLAN_M 0xffff0000#define ICE_TX_FLAGS_VLAN_PR_M 0xe0000000#define ICE_TX_FLAGS_VLAN_PR_S 29
@@ -334,6 +335,8 @@ struct ice_tx_ring {spinlock_t tx_lock;u32 txq_teid;/* Added Tx queue TEID */ #define ICE_TX_FLAGS_RING_XDP BIT(0) +#define ICE_TX_FLAGS_RING_VLAN_L2TAG1 BIT(1) +#define ICE_TX_FLAGS_RING_VLAN_L2TAG2 BIT(2)u8 flags;u8 dcb_tc;/* Traffic class of ring */ u8 ptp_tx;
drivers/net/ethernet/intel/ice/ice_txrx_lib.c +7 -2
@@ -207,9 +207,14 @@ ice_process_skb_fields(struct ice_rx_ring *rx_ring,void ice_receive_skb (struct ice_rx_ring *rx_ring,struct sk_buff *skb,u16 vlan_tag) { -if ((rx_ring->netdev->features &NETIF_F_HW_VLAN_CTAG_RX ) && - (vlan_tag &VLAN_VID_MASK )) +netdev_features_t features = rx_ring->netdev->features; +bool non_zero_vlan = !!(vlan_tag &VLAN_VID_MASK ); + +if ((features &NETIF_F_HW_VLAN_CTAG_RX ) && non_zero_vlan)__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021Q ), vlan_tag); +else if ((features &NETIF_F_HW_VLAN_STAG_RX ) && non_zero_vlan) +__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021AD ), vlan_tag); +napi_gro_receive (&rx_ring->q_vector->napi, skb); }
drivers/net/ethernet/intel/ice/ice_txrx_lib.h +27 -3
@@ -7,7 +7,7 @@/** * ice_test_staterr - tests bits in Rx descriptor status and error fields -* @rx_desc: pointer to receive descriptor (in le64 format) +* @status_err_n: Rx descriptor status_error0 or status_error1 bits * @stat_err_bits: value to mask * * This function does some fast chicanery in order to return the
@@ -16,9 +16,9 @@* at offset zero. */ static inline bool -ice_test_staterr (union ice_32b_rx_flex_desc *rx_desc,const u16 stat_err_bits) +ice_test_staterr (__le16 status_err_n,const u16 stat_err_bits) { -return !!(rx_desc->wb.status_error0 &cpu_to_le16 (stat_err_bits)); +return !!(status_err_n &cpu_to_le16 (stat_err_bits)); } static inline __le64
@@ -31,6 +31,30 @@ ice_build_ctob(u64 td_cmd, u64 td_offset, unsigned int size, u64 td_tag) (td_tag << ICE_TXD_QW1_L2TAG1_S)); } +/** +* ice_get_vlan_tag_from_rx_desc - get VLAN from Rx flex descriptor +* @rx_desc: Rx 32b flex descriptor with RXDID=2 +* +* The OS and current PF implementation only support stripping a single VLAN tag +*@a time, so there should only ever be 0 or 1 tags in the l2tag* fields. If +* one is found return the tag, else return 0 to mean no VLAN tag was found. +*/ +static inline u16 +ice_get_vlan_tag_from_rx_desc (union ice_32b_rx_flex_desc *rx_desc) +{ +u16 stat_err_bits; + + stat_err_bits =BIT (ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S ); +if (ice_test_staterr (rx_desc->wb.status_error0, stat_err_bits)) +return le16_to_cpu (rx_desc->wb.l2tag1); + + stat_err_bits =BIT (ICE_RX_FLEX_DESC_STATUS1_L2TAG2P_S ); +if (ice_test_staterr (rx_desc->wb.status_error1, stat_err_bits)) +return le16_to_cpu (rx_desc->wb.l2tag2_2nd); + +return 0 ; +} +/** * ice_xdp_ring_update_tail - Updates the XDP Tx ring tail register * @xdp_ring: XDP Tx ring
drivers/net/ethernet/intel/ice/ice_xsk.c +2 -4
@@ -530,7 +530,7 @@ int ice_clean_rx_irq_zc(struct ice_rx_ring *rx_ring, int budget) rx_desc =ICE_RX_DESC (rx_ring, rx_ring->next_to_clean); stat_err_bits =BIT (ICE_RX_FLEX_DESC_STATUS0_DD_S ); -if (!ice_test_staterr (rx_desc, stat_err_bits)) +if (!ice_test_staterr (rx_desc->wb.status_error0, stat_err_bits))break ;/* This memory barrier is needed to keep us from reading
@@ -582,9 +582,7 @@ int ice_clean_rx_irq_zc(struct ice_rx_ring *rx_ring, int budget) total_rx_bytes += skb->len; total_rx_packets++; - stat_err_bits =BIT (ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S ); -if (ice_test_staterr (rx_desc, stat_err_bits)) - vlan_tag =le16_to_cpu (rx_desc->wb.l2tag1); + vlan_tag =ice_get_vlan_tag_from_rx_desc (rx_desc); rx_ptype =le16_to_cpu (rx_desc->wb.ptype_flex_flags0) &ICE_RX_FLEX_DESC_PTYPE_M ;
Signature · 1 line
2.20.1
G
PATCH v3 9/14 ice: Add hot path support for 802.1Q and 802.1ad VLAN offloads
Quoted 59 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 09/14] ice: Add hot path support for 802.1Q and 802.1ad VLAN offloadsFrom: Brett Creeley <[email protected]>
Currently the driver only supports 802.1Q VLAN insertion and stripping. However, once Double VLAN Mode (DVM) is fully supported, then both 802.1Q and 802.1ad VLAN insertion and stripping will be supported. Unfortunately the VSI context parameters only allow for one VLAN ethertype at a time for VLAN offloads so only one or the other VLAN ethertype offload can be supported at once.
To support this, multiple changes are needed.
Rx path changes:
[1] In DVM, the Rx queue context l2tagsel field needs to be cleared so the outermost tag shows up in the
l2tag2_2ndfield of the Rx flex descriptor. In Single VLAN Mode (SVM), the l2tagsel field should remain
1 to support SVM configurations.[2] Modify the
ice_test_staterr()function to take a__le16instead of theice_32b_rx_flex_descunion pointer so this function can be used for bothrx_desc->wb.status_error0andrx_desc->wb.status_error1.[3] Add the new inline function
ice_get_vlan_tag_from_rx_desc()that checks if there is a VLAN tag in l2tag1 orl2tag2_2nd.[4] In
ice_receive_skb(), add a check to see ifNETIF_F_HW_VLAN_STAG_RXis enabled innetdev->features. If it is, then this is the VLAN ethertype that needs to be added to the stripping VLAN tag. Sinceice_fix_features()preventsCTAG_RXandSTAG_RXfrom being enabled simultaneously, the VLAN ethertype will only ever be 802.1Q or 802.1ad.Tx path changes:
[1] In DVM, the VLAN tag needs to be placed in the l2tag2 field of the Tx context descriptor. The new define
ICE_TX_FLAGS_HW_OUTER_SINGLE_VLANwas added to the list oftx_flagsto handle this case.[2] When the stack requests the VLAN tag to be offloaded on Tx, the driver needs to set either
ICE_TX_FLAGS_HW_OUTER_SINGLE_VLANorICE_TX_FLAGS_HW_VLAN, so the tag is inserted in l2tag2 or l2tag1 respectively. To determine which location to use, set a bit in the Tx ring flags field during ring allocation that can be used to determine which field to use in the Tx descriptor. In DVM, always use l2tag2, and in SVM, always use l2tag1.Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>---
v2: Fix kdoc issue
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_base.c | 18 +++++++++-- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 8 +++-- .../net/ethernet/intel/ice/ice_lan_tx_rx.h | 2 ++ drivers/net/ethernet/intel/ice/ice_lib.c | 5 ++++ drivers/net/ethernet/intel/ice/ice_txrx.c | 28 +++++++++++------ drivers/net/ethernet/intel/ice/ice_txrx.h | 3 ++ drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 9 ++++-- drivers/net/ethernet/intel/ice/ice_txrx_lib.h | 30 +++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_xsk.c | 6 ++-- 9 files changed, 87 insertions(+), 22 deletions(-)
Tony Nguyen
maintainerPATCH v3 10/14 ice: Add support for VIRTCHNL_VF_OFFLOAD_VLAN_V2
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Add support for the VF driver to be able to request VIRTCHNL_VF_OFFLOAD_VLAN_V2, negotiate its VLAN capabilities via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS, add/delete VLAN filters, and enable/disable VLAN offloads.
VFs supporting VIRTCHNL_OFFLOAD_VLAN_V2 will be able to use the following virtchnl opcodes:
VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPSVIRTCHNL_OP_ADD_VLAN_V2VIRTCHNL_OP_DEL_VLAN_V2VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
Legacy VF drivers may expect the initial VLAN stripping settings to be configured by the PF, so the PF initializes VLAN stripping based on the VIRTCHNL_OP_GET_VF_RESOURCES opcode. However, with VLAN support via VIRTCHNL_VF_OFFLOAD_VLAN_V2, this function is only expected to be used for VFs that only support VIRTCHNL_VF_OFFLOAD_VLAN, which will only be supported when a port VLAN is configured. Update the function based on the new expectations. Also, change the message when the PF can't enable/disable VLAN stripping to a dev_dbg() as this isn't fatal.
When a VF isn't in a port VLAN and it only supports VIRTCHNL_VF_OFFLOAD_VLAN when Double VLAN Mode (DVM) is enabled, then the PF needs to reject the VIRTCHNL_VF_OFFLOAD_VLAN capability and configure the VF in software only VLAN mode. To do this add the new function ice_vf_vsi_cfg_legacy_vlan_mode(), which updates the VF's inner and outer ice_vsi_vlan_ops functions and sets up software only VLAN mode.
--- drivers/net/ethernet/intel/ice/ice_base.c | 1 + .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 115 ++ .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.h | 3 + .../intel/ice/ice_virtchnl_allowlist.c | 10 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 1132 ++++++++++++++++- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 8 + 6 files changed, 1226 insertions(+), 43 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +1 -0
@@ -5,6 +5,7 @@#include "ice_base.h" #include "ice_lib.h" #include "ice_dcb_lib.h" +#include "ice_virtchnl_pf.h" /** * __ice_vsi_get_qs_contig - Assign a contiguous chunk of queues to VSI
drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c +115 -0
133 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.h +3 -0
@@ -8,6 +8,9 @@struct ice_vsi ; +void ice_vf_vsi_cfg_dvm_legacy_vlan_mode (struct ice_vsi *vsi); +void ice_vf_vsi_cfg_svm_legacy_vlan_mode (struct ice_vsi *vsi); +#ifdef CONFIG_PCI_IOV void ice_vf_vsi_init_vlan_ops (struct ice_vsi *vsi);#else
drivers/net/ethernet/intel/ice/ice_virtchnl_allowlist.c +10 -0
@@ -55,6 +55,15 @@ static const u32 vlan_allowlist_opcodes[] = { VIRTCHNL_OP_ENABLE_VLAN_STRIPPING, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING, }; +/* VIRTCHNL_VF_OFFLOAD_VLAN_V2 */ +static const u32 vlan_v2_allowlist_opcodes[] = { +VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS ,VIRTCHNL_OP_ADD_VLAN_V2 , +VIRTCHNL_OP_DEL_VLAN_V2 ,VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 , +VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 , +VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 , +VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 , +}; +/* VIRTCHNL_VF_OFFLOAD_RSS_PF */ static const u32 rss_pf_allowlist_opcodes[] = {VIRTCHNL_OP_CONFIG_RSS_KEY ,VIRTCHNL_OP_CONFIG_RSS_LUT ,
@@ -89,6 +98,7 @@ static const struct allowlist_opcode_info allowlist_opcodes[] = {ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_RSS_PF , rss_pf_allowlist_opcodes),ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF , adv_rss_pf_allowlist_opcodes),ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_FDIR_PF , fdir_pf_allowlist_opcodes), + ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_VLAN_V2, vlan_v2_allowlist_opcodes), };/**
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +1089 -43
1,239 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +8 -0
@@ -95,6 +95,13 @@ struct ice_vc_vf_ops {int (*handle_rss_cfg_msg)(struct ice_vf *vf,u8 *msg,bool add);int (*add_fdir_fltr_msg)(struct ice_vf *vf,u8 *msg);int (*del_fdir_fltr_msg)(struct ice_vf *vf,u8 *msg); +int (*get_offload_vlan_v2_caps)(struct ice_vf *vf); +int (*add_vlan_v2_msg)(struct ice_vf *vf,u8 *msg); +int (*remove_vlan_v2_msg)(struct ice_vf *vf,u8 *msg); +int (*ena_vlan_stripping_v2_msg)(struct ice_vf *vf,u8 *msg); +int (*dis_vlan_stripping_v2_msg)(struct ice_vf *vf,u8 *msg); +int (*ena_vlan_insertion_v2_msg)(struct ice_vf *vf,u8 *msg); +int (*dis_vlan_insertion_v2_msg)(struct ice_vf *vf,u8 *msg); };/* VF information structure */
@@ -121,6 +128,7 @@ struct ice_vf {DECLARE_BITMAP (txq_ena,ICE_MAX_RSS_QS_PER_VF );DECLARE_BITMAP (rxq_ena,ICE_MAX_RSS_QS_PER_VF );struct ice_vlan port_vlan_info;/* Port VLAN ID, QoS, and TPID */ +struct virtchnl_vlan_caps vlan_v2_caps; u8 pf_set_mac:1; /* VF MAC address set by VMM admin */ u8 trusted:1; u8 spoofchk:1;
Signature · 1 line
2.20.1
Jankowski
PATCH v3 10/14 ice: Add support for VIRTCHNL_VF_OFFLOAD_VLAN_V2
drivers/net/ethernet/intel/ice/ice_base.c
Quoted 65 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: czwartek, 2 grudnia 2021 17:39
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 10/14] ice: Add support forVIRTCHNL_VF_OFFLOAD_VLAN_V2From: Brett Creeley <[email protected]>
Add support for the VF driver to be able to request
VIRTCHNL_VF_OFFLOAD_VLAN_V2, negotiate its VLAN capabilities viaVIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS, add/delete VLAN filters, and
enable/disable VLAN offloads.VFs supporting
VIRTCHNL_OFFLOAD_VLAN_V2will be able to use the following virtchnl opcodes:
VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPSVIRTCHNL_OP_ADD_VLAN_V2VIRTCHNL_OP_DEL_VLAN_V2VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2Legacy VF drivers may expect the initial VLAN stripping settings to be configured by the PF, so the PF initializes VLAN stripping based on the
VIRTCHNL_OP_GET_VF_RESOURCESopcode. However, with VLAN support viaVIRTCHNL_VF_OFFLOAD_VLAN_V2, this function is only expected to be used for VFs that only supportVIRTCHNL_VF_OFFLOAD_VLAN, which will only be supported when a port VLAN is configured. Update the function based on the new expectations. Also, change the message when the PF can't enable/disable VLAN stripping to adev_dbg()as this isn't fatal.When a VF isn't in a port VLAN and it only supports
VIRTCHNL_VF_OFFLOAD_VLANwhen Double VLAN Mode (DVM) is enabled, then
the PF needs to reject theVIRTCHNL_VF_OFFLOAD_VLANcapability and configure the VF in software only VLAN mode. To do this add the new functionice_vf_vsi_cfg_legacy_vlan_mode(), which updates the VF's inner and outerice_vsi_vlan_opsfunctions and sets up software only VLAN mode.Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_base.c | 1 + .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 115 ++ .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.h | 3 + .../intel/ice/ice_virtchnl_allowlist.c | 10 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 1132 ++++++++++++++++- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 8 + 6 files changed, 1226 insertions(+), 43 deletions(-)drivers/net/ethernet/intel/ice/ice_base.c +0
-0@@ -5,6 +5,7 @@
Tony Nguyen
maintainerPATCH v3 11/14 ice: Support configuring the device to Double VLAN Mode
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
In order to support configuring the device in Double VLAN Mode (DVM), the DDP and FW have to support DVM. If both support DVM, the PF that downloads the package needs to update the default recipes, set the VLAN mode, and update boost TCAM entries.
To support updating the default recipes in DVM, add support for updating an existing switch recipe's lkup_idx and mask. This is done by first calling the get recipe AQ (0x0292) with the desired recipe ID. Then, if that is successful update one of the lookup indices (lkup_idx) and its associated mask if the mask is valid otherwise the already existing mask will be used.
The VLAN mode of the device has to be configured while the global configuration lock is held while downloading the DDP, specifically after the DDP has been downloaded. If supported, the device will default to DVM.
---
v3: Add ICE_DBQ_AQ define
drivers/net/ethernet/intel/ice/Makefile | 1 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 64 ++- drivers/net/ethernet/intel/ice/ice_common.c | 49 +- drivers/net/ethernet/intel/ice/ice_common.h | 3 + .../net/ethernet/intel/ice/ice_flex_pipe.c | 290 ++++++++++-- .../net/ethernet/intel/ice/ice_flex_pipe.h | 13 + .../net/ethernet/intel/ice/ice_flex_type.h | 40 ++ drivers/net/ethernet/intel/ice/ice_main.c | 12 + .../ethernet/intel/ice/ice_pf_vsi_vlan_ops.c | 1 + drivers/net/ethernet/intel/ice/ice_switch.c | 75 +++ drivers/net/ethernet/intel/ice/ice_switch.h | 13 + drivers/net/ethernet/intel/ice/ice_type.h | 10 + .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 1 + .../net/ethernet/intel/ice/ice_vlan_mode.c | 439 ++++++++++++++++++ .../net/ethernet/intel/ice/ice_vlan_mode.h | 13 + .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 25 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 5 - 17 files changed, 995 insertions(+), 59 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_vlan_mode.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vlan_mode.h
drivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -23,6 +23,7 @@ ice-y := ice_main.o \ ice_vsi_vlan_lib.o \ ice_fdir.o \ ice_ethtool_fdir.o \ + ice_vlan_mode.o \ ice_flex_pipe.o \ ice_flow.o \ ice_idc.o \
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +63 -1
128 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_common.c +44 -5
66 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_common.h +3 -0
@@ -85,6 +85,9 @@ int ice_aq_send_driver_ver(struct ice_hw *hw, struct ice_driver_ver *dv, struct ice_sq_cd *cd);int +ice_aq_set_port_params (struct ice_port_info *pi,bool double_vlan, +struct ice_sq_cd *cd); +int ice_aq_get_phy_caps (struct ice_port_info *pi,bool qual_mods,u8 report_mode,struct ice_aqc_get_phy_caps_data *caps,struct ice_sq_cd *cd);
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +256 -34
393 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_flex_pipe.h +13 -0
@@ -89,6 +89,12 @@ ice_init_prof_result_bm(struct ice_hw *hw);int ice_get_sw_fv_list (struct ice_hw *hw,u8 *prot_ids,u16 ids_cnt,unsigned long *bm,struct list_head *fv_list); +int +ice_pkg_buf_unreserve_section (struct ice_buf_build *bld,u16 count); +u16 ice_pkg_buf_get_free_space (struct ice_buf_build *bld); +int +ice_aq_upload_section (struct ice_hw *hw,struct ice_buf_hdr *pkg_buf, +u16 buf_size,struct ice_sq_cd *cd);bool ice_get_open_tunnel_port (struct ice_hw *hw,u16 *port,enum ice_tunnel_type type);
@@ -96,6 +102,7 @@ int ice_udp_tunnel_set_port(struct net_device *netdev, unsigned int table, unsigned int idx, struct udp_tunnel_info *ti);int ice_udp_tunnel_unset_port (struct net_device *netdev,unsigned int table,unsigned int idx,struct udp_tunnel_info *ti); +int ice_set_dvm_boost_entries (struct ice_hw *hw);/* Rx parser PTYPE functions */ bool ice_hw_ptype_ena (struct ice_hw *hw,u16 ptype);
@@ -120,4 +127,10 @@ void ice_clear_hw_tbls(struct ice_hw *hw);void ice_free_hw_tbls (struct ice_hw *hw);int ice_rem_prof (struct ice_hw *hw,enum ice_block blk,u64 id); +struct ice_buf_build * +ice_pkg_buf_alloc_single_section (struct ice_hw *hw,u32 type,u16 size, +void **section); +struct ice_buf *ice_pkg_buf (struct ice_buf_build *bld); +void ice_pkg_buf_free (struct ice_hw *hw,struct ice_buf_build *bld); +#endif /* _ICE_FLEX_PIPE_H_ */
drivers/net/ethernet/intel/ice/ice_flex_type.h +40 -0
@@ -162,6 +162,7 @@ struct ice_meta_sect {#define ICE_SID_RXPARSER_MARKER_PTYPE 55#define ICE_SID_RXPARSER_BOOST_TCAM 56 +#define ICE_SID_RXPARSER_METADATA_INIT 58#define ICE_SID_TXPARSER_BOOST_TCAM 66#define ICE_SID_XLT0_PE 80
@@ -442,6 +443,19 @@ struct ice_tunnel_table {u16 valid_count[__TNL_TYPE_CNT]; }; +struct ice_dvm_entry { +u16 boost_addr; +u16 enable; +struct ice_boost_tcam_entry *boost_entry; +}; + +#define ICE_DVM_MAX_ENTRIES 48 + +struct ice_dvm_table { +struct ice_dvm_entry tbl[ICE_DVM_MAX_ENTRIES ]; +u16 count; +}; +struct ice_pkg_es {__le16 count;__le16 offset;
@@ -662,4 +676,30 @@ enum ice_prof_type {ICE_PROF_TUN_ALL =0x6 , ICE_PROF_ALL = 0xFF, }; + +/* Number of bits/bytes contained in meta init entry. Note, this should be a +* multiple of 32 bits. +*/ +#define ICE_META_INIT_BITS 192 +#define ICE_META_INIT_DW_CNT (ICE_META_INIT_BITS / (sizeof(__le32) * \ + BITS_PER_BYTE)) + +/* The meta init Flag field starts at this bit */ +#define ICE_META_FLAGS_ST 123 + +/* The entry and bit to check for Double VLAN Mode (DVM) support */ +#define ICE_META_VLAN_MODE_ENTRY 0 +#define ICE_META_FLAG_VLAN_MODE 60 +#define ICE_META_VLAN_MODE_BIT (ICE_META_FLAGS_ST + \ + ICE_META_FLAG_VLAN_MODE) + +struct ice_meta_init_entry { +__le32 bm[ICE_META_INIT_DW_CNT ]; +}; + +struct ice_meta_init_section { +__le16 count; +__le16 offset; +struct ice_meta_init_entry entry; +};#endif /* _ICE_FLEX_TYPE_H_ */
drivers/net/ethernet/intel/ice/ice_main.c +12 -0
@@ -3555,12 +3555,17 @@ static int ice_tc_indir_block_register(struct ice_vsi *vsi)static int ice_setup_pf_sw (struct ice_pf *pf) {struct device *dev =ice_pf_to_dev (pf); +bool dvm =ice_is_dvm_ena (&pf->hw);struct ice_vsi *vsi;int status;if (ice_is_reset_in_progress (pf->state))return -EBUSY ; + status =ice_aq_set_port_params (pf->hw.port_info, dvm,NULL ); +if (status) +return -EIO ; + vsi =ice_pf_vsi_setup (pf, pf->hw.port_info);if (!vsi)return -ENOMEM ;
@@ -6649,6 +6654,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) {struct device *dev =ice_pf_to_dev (pf);struct ice_hw *hw = &pf->hw; +bool dvm;int err;if (test_bit (ICE_DOWN , pf->state))
@@ -6712,6 +6718,12 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) goto err_init_ctrlq; } + dvm =ice_is_dvm_ena (hw); + + err =ice_aq_set_port_params (pf->hw.port_info, dvm,NULL ); +if (err) + goto err_init_ctrlq; + err =ice_sched_init_port (hw->port_info);if (err) goto err_sched_init_port;
drivers/net/ethernet/intel/ice/ice_pf_vsi_vlan_ops.c +1 -0
@@ -3,6 +3,7 @@#include "ice_vsi_vlan_ops.h" #include "ice_vsi_vlan_lib.h" +#include "ice_vlan_mode.h" #include "ice.h" #include "ice_pf_vsi_vlan_ops.h"
drivers/net/ethernet/intel/ice/ice_switch.c +75 -0
87 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_switch.h +13 -0
@@ -118,6 +118,15 @@ struct ice_fltr_info {u8 lan_en;/* Indicate if packet can be forwarded to the uplink */ }; +struct ice_update_recipe_lkup_idx_params { +u16 rid; +u16 fv_idx; +bool ignore_valid; +u16 mask; +bool mask_valid; +u8 lkup_idx; +}; +struct ice_adv_lkup_elem {enum ice_protocol_type type;union ice_prot_hdr h_u;/* Header values */
@@ -360,4 +369,8 @@ void ice_rm_all_sw_replay_rule_info(struct ice_hw *hw);int ice_aq_sw_rules (struct ice_hw *hw,void *rule_list,u16 rule_list_sz,u8 num_rules,enum ice_adminq_opc opc,struct ice_sq_cd *cd); +int +ice_update_recipe_lkup_idx (struct ice_hw *hw, +struct ice_update_recipe_lkup_idx_params *params); +void ice_change_proto_id_to_dvm (void );#endif /* _ICE_SWITCH_H_ */
drivers/net/ethernet/intel/ice/ice_type.h +10 -0
@@ -14,6 +14,7 @@#include "ice_flex_type.h" #include "ice_protocol_type.h" #include "ice_sbq_cmd.h" +#include "ice_vlan_mode.h" static inline bool ice_is_tc_ena (unsigned long bitmap,u8 tc) {
@@ -53,6 +54,11 @@ static inline u32 ice_round_to_num(u32 N, u32 R)#define ICE_DBG_AQ_DESC BIT_ULL(25)#define ICE_DBG_AQ_DESC_BUF BIT_ULL(26)#define ICE_DBG_AQ_CMD BIT_ULL(27) +#define ICE_DBG_AQ (ICE_DBG_AQ_MSG | \ + ICE_DBG_AQ_DESC | \ + ICE_DBG_AQ_DESC_BUF | \ + ICE_DBG_AQ_CMD) +#define ICE_DBG_USER BIT_ULL(31)enum ice_aq_res_ids {
@@ -919,6 +925,9 @@ struct ice_hw {struct udp_tunnel_nic_shared udp_tunnel_shared;struct udp_tunnel_nic_info udp_tunnel_nic; +/* dvm boost update information */ +struct ice_dvm_table dvm_upd; +/* HW block tables */ struct ice_blk_info blk[ICE_BLK_COUNT ];struct mutex fl_profs_locks[ICE_BLK_COUNT ];/* lock fltr profiles */
@@ -942,6 +951,7 @@ struct ice_hw {struct list_head rss_list_head;struct ice_mbx_snapshot mbx_snapshot;DECLARE_BITMAP (hw_ptype,ICE_FLOW_PTYPE_MAX ); +u8 dvm_ena;u16 io_expander_handle; };
drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c +1 -0
@@ -3,6 +3,7 @@#include "ice_vsi_vlan_ops.h" #include "ice_vsi_vlan_lib.h" +#include "ice_vlan_mode.h" #include "ice.h" #include "ice_vf_vsi_vlan_ops.h" #include "ice_virtchnl_pf.h"
drivers/net/ethernet/intel/ice/ice_vlan_mode.c new file +439 -0
439 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vlan_mode.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#ifndef _ICE_VLAN_MODE_H_ +#define _ICE_VLAN_MODE_H_ + +struct ice_hw ; + +bool ice_is_dvm_ena (struct ice_hw *hw); +int ice_set_vlan_mode (struct ice_hw *hw); +void ice_post_pkg_dwnld_vlan_mode_cfg (struct ice_hw *hw); + +#endif /* _ICE_VLAN_MODE_H */
drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c +11 -14
@@ -39,20 +39,20 @@ static bool validate_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan)*/ int ice_vsi_add_vlan (struct ice_vsi *vsi,struct ice_vlan *vlan) { -int err =0 ; +int err;if (!validate_vlan (vsi, vlan))return -EINVAL ; -if (!ice_fltr_add_vlan (vsi, vlan)) { - vsi->num_vlan++; - }else { - err = -ENODEV ; -dev_err (ice_pf_to_dev (vsi->back),"Failure Adding VLAN %d on VSI %i\n" , - vlan->vid, vsi->vsi_num); + err =ice_fltr_add_vlan (vsi, vlan); +if (err && err != -EEXIST ) { +dev_err (ice_pf_to_dev (vsi->back),"Failure Adding VLAN %d on VSI %i, status %d\n" , + vlan->vid, vsi->vsi_num, err); +return err; } -return err; + vsi->num_vlan++; +return 0 ; }/**
@@ -72,16 +72,13 @@ int ice_vsi_del_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan) dev =ice_pf_to_dev (pf); err =ice_fltr_remove_vlan (vsi, vlan); -if (!err) { +if (!err) vsi->num_vlan--; - }else if (err == -ENOENT ) { -dev_dbg (dev,"Failed to remove VLAN %d on VSI %i, it does not exist\n" , - vlan->vid, vsi->vsi_num); +else if (err == -ENOENT || err == -EBUSY ) err =0 ; - }else { +else dev_err (dev,"Error removing VLAN %d on VSI %i error: %d\n" , vlan->vid, vsi->vsi_num, err); - }return err; }
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.h +0 -5
@@ -23,11 +23,6 @@ struct ice_vsi_vlan_ops {int (*set_port_vlan)(struct ice_vsi *vsi,struct ice_vlan *vlan); }; -static inline bool ice_is_dvm_ena (struct ice_hw __always_unused *hw) -{ -return false; -} -void ice_vsi_init_vlan_ops (struct ice_vsi *vsi);struct ice_vsi_vlan_ops *ice_get_compat_vsi_vlan_ops (struct ice_vsi *vsi);
Signature · 1 line
2.20.1
G
PATCH v3 11/14 ice: Support configuring the device to Double VLAN Mode
Quoted 48 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 11/14] ice: Support configuring the device to Double VLAN ModeFrom: Brett Creeley <[email protected]>
In order to support configuring the device in Double VLAN Mode (DVM), the DDP and FW have to support DVM. If both support DVM, the PF that downloads the package needs to update the default recipes, set the VLAN mode, and update boost TCAM entries.
To support updating the default recipes in DVM, add support for updating an existing switch recipe's
lkup_idxand mask. This is done by first calling the get recipe AQ (0x0292) with the desired recipe ID. Then, if that is successful update one of the lookup indices (lkup_idx) and its associated mask if the mask is valid otherwise the already existing mask will be used.The VLAN mode of the device has to be configured while the global configuration lock is held while downloading the DDP, specifically after the DDP has been downloaded. If supported, the device will default to DVM.
Co-developed-by Dan Nowlin <[email protected]>Signed-off-by Dan Nowlin <[email protected]>Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>---
v3: AddICE_DBQ_AQdefinedrivers/net/ethernet/intel/ice/Makefile | 1 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 64 ++- drivers/net/ethernet/intel/ice/ice_common.c | 49 +- drivers/net/ethernet/intel/ice/ice_common.h | 3 + .../net/ethernet/intel/ice/ice_flex_pipe.c | 290 ++++++++++-- .../net/ethernet/intel/ice/ice_flex_pipe.h | 13 + .../net/ethernet/intel/ice/ice_flex_type.h | 40 ++ drivers/net/ethernet/intel/ice/ice_main.c | 12 + .../ethernet/intel/ice/ice_pf_vsi_vlan_ops.c | 1 + drivers/net/ethernet/intel/ice/ice_switch.c | 75 +++ drivers/net/ethernet/intel/ice/ice_switch.h | 13 + drivers/net/ethernet/intel/ice/ice_type.h | 10 +
Quoted 9 lines
.../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 1 + .../net/ethernet/intel/ice/ice_vlan_mode.c | 439 ++++++++++++++++++ .../net/ethernet/intel/ice/ice_vlan_mode.h | 13 + .../net/ethernet/intel/ice/ice_vsi_vlan_lib.c | 25 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.h | 5 - 17 files changed, 995 insertions(+), 59 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_vlan_mode.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vlan_mode.h
Tony Nguyen
maintainerPATCH v3 12/14 ice: Advertise 802.1ad VLAN filtering and offloads for PF netdev
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
In order for the driver to support 802.1ad VLAN filtering and offloads, it needs to advertise those VLAN features and also support modifying those VLAN features, so make the necessary changes to ice_set_netdev_features(). By default, enable CTAG insertion/stripping and CTAG filtering for both Single and Double VLAN Modes (SVM/DVM). Also, in DVM, enable STAG filtering by default. This is done by setting the feature bits in netdev->features. Also, in DVM, support toggling of STAG insertion/stripping, but don't enable them by default. This is done by setting the feature bits in netdev->hw_features.
Since 802.1ad VLAN filtering and offloads are only supported in DVM, make sure they are not enabled by default and that they cannot be enabled during runtime, when the device is in SVM.
Add an implementation for the ndo_fix_features() callback. This is needed since the hardware cannot support multiple VLAN ethertypes for VLAN insertion/stripping simultaneously and all supported VLAN filtering must either be enabled or disabled together.
Disable inner VLAN stripping by default when DVM is enabled. If a VSI supports stripping the inner VLAN in DVM, then it will have to configure that during runtime. For example if a VF is configured in a port VLAN while DVM is enabled it will be allowed to offload inner VLANs.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 27 ++- drivers/net/ethernet/intel/ice/ice_main.c | 260 ++++++++++++++++++---- 2 files changed, 238 insertions(+), 49 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +21 -6
@@ -796,11 +796,12 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi)/** * ice_set_dflt_vsi_ctx - Set default VSI context before adding a VSI +* @hw: HW structure used to determine the VLAN mode of the device * @ctxt: the VSI context being set * * This initializes a default VSI context for all sections except the Queues. */ -static void ice_set_dflt_vsi_ctx (struct ice_vsi_ctx *ctxt) +static void ice_set_dflt_vsi_ctx (struct ice_hw *hw,struct ice_vsi_ctx *ctxt) {u32 table =0 ;
@@ -811,13 +812,27 @@ static void ice_set_dflt_vsi_ctx(struct ice_vsi_ctx *ctxt) ctxt->info.sw_flags =ICE_AQ_VSI_SW_FLAG_SRC_PRUNE ;/* Traffic from VSI can be sent to LAN */ ctxt->info.sw_flags2 =ICE_AQ_VSI_SW_FLAG_LAN_ENA ; -/* By default bits 3 and 4 in inner_vlan_flags are 0's which results in legacy -* behavior (show VLAN, DEI, and UP) in descriptor. Also, allow all -* packets untagged/tagged. -*/ +/* allow all untagged/tagged packets by default on Tx */ ctxt->info.inner_vlan_flags = ((ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL &ICE_AQ_VSI_INNER_VLAN_TX_MODE_M ) >>ICE_AQ_VSI_INNER_VLAN_TX_MODE_S ); +/* SVM - by default bits 3 and 4 in inner_vlan_flags are 0's which +* results in legacy behavior (show VLAN, DEI, and UP) in descriptor. +* +* DVM - leave inner VLAN in packet by default +*/ +if (ice_is_dvm_ena (hw)) { + ctxt->info.inner_vlan_flags |= +ICE_AQ_VSI_INNER_VLAN_EMODE_NOTHING ; + ctxt->info.outer_vlan_flags = + (ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ALL << +ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S ) & +ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M ; + ctxt->info.outer_vlan_flags |= + (ICE_AQ_VSI_OUTER_TAG_VLAN_8100 << +ICE_AQ_VSI_OUTER_TAG_TYPE_S ) & +ICE_AQ_VSI_OUTER_TAG_TYPE_M ; + }/* Have 1:1 UP mapping for both ingress/egress tables */ table |=ICE_UP_TABLE_TRANSLATE (0 ,0 ); table |=ICE_UP_TABLE_TRANSLATE (1 ,1 );
@@ -1094,7 +1109,7 @@ static int ice_vsi_init(struct ice_vsi *vsi, bool init_vsi) ~ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA ; } -ice_set_dflt_vsi_ctx (ctxt); +ice_set_dflt_vsi_ctx (hw, ctxt);if (test_bit (ICE_FLAG_FD_ENA , pf->flags))ice_set_fd_vsi_ctx (ctxt, vsi);/* if the switch is in VEB mode, allow VSI loopback */
drivers/net/ethernet/intel/ice/ice_main.c +217 -43
341 lines not on this page · raw message
Signature · 1 line
2.20.1
G
PATCH v3 12/14 ice: Advertise 802.1ad VLAN filtering and offloads for PF netdev
Quoted 37 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 12/14] ice: Advertise 802.1ad VLAN filtering and offloads for PF netdevFrom: Brett Creeley <[email protected]>
In order for the driver to support 802.1ad VLAN filtering and offloads, it needs to advertise those VLAN features and also support modifying those VLAN features, so make the necessary changes to
ice_set_netdev_features(). By default, enable CTAG insertion/stripping and CTAG filtering for both Single and Double VLAN Modes (SVM/DVM).
Also, in DVM, enable STAG filtering by default. This is done by setting the feature bits innetdev->features. Also, in DVM, support toggling of STAG insertion/stripping, but don't enable them by default. This is done by setting the feature bits innetdev->hw_features.Since 802.1ad VLAN filtering and offloads are only supported in DVM, make sure they are not enabled by default and that they cannot be enabled during runtime, when the device is in SVM.
Add an implementation for the
ndo_fix_features()callback. This is needed since the hardware cannot support multiple VLAN ethertypes for VLAN insertion/stripping simultaneously and all supported VLAN filtering must either be enabled or disabled together.Disable inner VLAN stripping by default when DVM is enabled. If a VSI supports stripping the inner VLAN in DVM, then it will have to configure that during runtime. For example if a VF is configured in a port VLAN while DVM is enabled it will be allowed to offload inner VLANs.
Quoted 7 lines
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_lib.c | 27 ++- drivers/net/ethernet/intel/ice/ice_main.c | 260 ++++++++++++++++++---- 2 files changed, 238 insertions(+), 49 deletions(-)
Tony Nguyen
maintainerPATCH v3 13/14 ice: Add support for 802.1ad port VLANs VF
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently there is only support for 802.1Q port VLANs on SR-IOV VFs. Add support to also allow 802.1ad port VLANs when double VLAN mode is enabled.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +44 -7
@@ -768,6 +768,11 @@ bool ice_vf_is_port_vlan_ena(struct ice_vf *vf)return (ice_vf_get_port_vlan_id (vf) ||ice_vf_get_port_vlan_prio (vf)); } +static u16 ice_vf_get_port_vlan_tpid (struct ice_vf *vf) +{ +return vf->port_vlan_info.tpid; +} +/** * ice_vf_rebuild_host_vlan_cfg - add VLAN 0 filter or rebuild the Port VLAN * @vf: VF to add MAC filters for
@@ -4129,6 +4134,33 @@ static int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg) v_ret, (u8 *)vfres, sizeof(*vfres)); } +/** +* ice_is_supported_port_vlan_proto - make sure the vlan_proto is supported +* @hw: hardware structure used to check the VLAN mode +* @vlan_proto: VLAN TPID being checked +* +* If the device is configured in Double VLAN Mode (DVM), then both ETH_P_8021Q +* and ETH_P_8021AD are supported. If the device is configured in Single VLAN +* Mode (SVM), then only ETH_P_8021Q is supported. +*/ +static bool +ice_is_supported_port_vlan_proto (struct ice_hw *hw,u16 vlan_proto) +{ +bool is_supported = false; + +switch (vlan_proto) { +case ETH_P_8021Q : + is_supported = true; +break ; +case ETH_P_8021AD : +if (ice_is_dvm_ena (hw)) + is_supported = true; +break ; + } + +return is_supported; +} +/** * ice_set_vf_port_vlan * @netdev: network interface device structure
@@ -4144,6 +4176,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, __be16 vlan_proto) {struct ice_pf *pf =ice_netdev_to_pf (netdev); +u16 local_vlan_proto =ntohs (vlan_proto);struct device *dev;struct ice_vf *vf;int ret;
@@ -4158,8 +4191,9 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,return -EINVAL ; } -if (vlan_proto !=htons (ETH_P_8021Q )) { -dev_err (dev,"VF VLAN protocol is not supported\n" ); +if (!ice_is_supported_port_vlan_proto (&pf->hw, local_vlan_proto)) { +dev_err (dev,"VF VLAN protocol 0x%04x is not supported\n" , + local_vlan_proto);return -EPROTONOSUPPORT ; }
@@ -4169,19 +4203,20 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,return ret;if (ice_vf_get_port_vlan_prio (vf) == qos && +ice_vf_get_port_vlan_tpid (vf) == local_vlan_proto &&ice_vf_get_port_vlan_id (vf) == vlan_id) {/* duplicate request, so just return success */ -dev_dbg (dev,"Duplicate port VLAN %u, QoS %u request\n" , - vlan_id, qos); +dev_dbg (dev,"Duplicate port VLAN %u, QoS %u, TPID 0x%04x request\n" , + vlan_id, qos, local_vlan_proto);return 0 ; }mutex_lock (&vf->cfg_lock); - vf->port_vlan_info =ICE_VLAN (ETH_P_8021Q , vlan_id, qos); + vf->port_vlan_info =ICE_VLAN (local_vlan_proto, vlan_id, qos);if (ice_vf_is_port_vlan_ena (vf)) -dev_info (dev,"Setting VLAN %u, QoS %u on VF %d\n" , - vlan_id, qos, vf_id); +dev_info (dev,"Setting VLAN %u, QoS %u, TPID 0x%04x on VF %d\n" , + vlan_id, qos, local_vlan_proto, vf_id);else dev_info (dev,"Clearing port VLAN on VF %d\n" , vf_id);
@@ -5904,6 +5939,8 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi)/* VF configuration for VLAN and applicable QoS */ ivi->vlan =ice_vf_get_port_vlan_id (vf); ivi->qos =ice_vf_get_port_vlan_prio (vf); +if (ice_vf_is_port_vlan_ena (vf)) + ivi->vlan_proto =cpu_to_be16 (ice_vf_get_port_vlan_tpid (vf)); ivi->trusted = vf->trusted; ivi->spoofchk = vf->spoofchk;
Signature · 1 line
2.20.1
Jankowski
PATCH v3 13/14 ice: Add support for 802.1ad port VLANs VF
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c bool ice_vf_is_port_vlan_ena(struct ice_vf *vf)
Quoted 28 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: czwartek, 2 grudnia 2021 17:39
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 13/14] ice: Add support for 802.1ad port VLANs VFFrom: Brett Creeley <[email protected]>
Currently there is only support for 802.1Q port VLANs on SR-IOV VFs. Add support to also allow 802.1ad port VLANs when double VLAN mode is enabled.
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-)drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +0
-0@@ -768,6 +768,11 @@ bool ice_vf_is_port_vlan_ena(struct ice_vf *vf)
Tony Nguyen
maintainerPATCH v3 14/14 ice: Add ability for PF admin to enable VF VLAN pruning
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
VFs by default are able to see all tagged traffic regardless of trust and VLAN filters. Based on legacy devices (i.e. ixgbe, i40e), customers expect VFs to receive all VLAN tagged traffic with a matching destination MAC.
Add an ethtool private flag 'vf-vlan-pruning' and set the default to off so VFs will receive all VLAN traffic directed towards them. When the flag is turned on, VF will only be able to receive untagged traffic or traffic with VLAN tags it has created interfaces for.
Also, the flag cannot be changed while any VFs are allocated. This was done to simplify the implementation. So, if this flag is needed, then the PF admin must enable it. If the user tries to enable the flag while VFs are active, then print an unsupported message with the vf-vlan-pruning flag included. In case multiple flags were specified, this makes it clear to the user which flag failed.
--- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 9 +++++++++ .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 18 ++++++++++++++++-- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -486,6 +486,7 @@ enum ice_pf_flags {ICE_FLAG_LEGACY_RX ,ICE_FLAG_VF_TRUE_PROMISC_ENA ,ICE_FLAG_MDD_AUTO_RESET_VF , +ICE_FLAG_VF_VLAN_PRUNING ,ICE_FLAG_LINK_LENIENT_MODE_ENA ,ICE_FLAG_GNSS ,/* GNSS successfully initialized */ ICE_PF_FLAGS_NBITS /* must be last */
drivers/net/ethernet/intel/ice/ice_ethtool.c +9 -0
@@ -164,6 +164,7 @@ static const struct ice_priv_flag ice_gstrings_priv_flags[] = {ICE_PRIV_FLAG ("vf-true-promisc-support" ,ICE_FLAG_VF_TRUE_PROMISC_ENA ),ICE_PRIV_FLAG ("mdd-auto-reset-vf" ,ICE_FLAG_MDD_AUTO_RESET_VF ), +ICE_PRIV_FLAG ("vf-vlan-pruning" ,ICE_FLAG_VF_VLAN_PRUNING ), ICE_PRIV_FLAG("legacy-rx", ICE_FLAG_LEGACY_RX), };
@@ -1295,6 +1296,14 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)change_bit (ICE_FLAG_VF_TRUE_PROMISC_ENA , pf->flags); ret = -EAGAIN ; } + +if (test_bit (ICE_FLAG_VF_VLAN_PRUNING , change_flags) && + pf->num_alloc_vfs) { +dev_err (dev,"vf-vlan-pruning: VLAN pruning cannot be changed while VFs are active.\n" ); +/* toggle bit back to previous state */ +change_bit (ICE_FLAG_VF_VLAN_PRUNING , pf->flags); + ret = -EOPNOTSUPP ; + } ethtool_exit:clear_bit (ICE_FLAG_ETHTOOL_CTXT , pf->flags);return ret;
drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c +16 -2
@@ -43,7 +43,6 @@ void ice_vf_vsi_init_vlan_ops(struct ice_vsi *vsi)/* outer VLAN ops regardless of port VLAN config */ vlan_ops->add_vlan = ice_vsi_add_vlan; - vlan_ops->ena_rx_filtering = ice_vsi_ena_rx_vlan_filtering; vlan_ops->dis_rx_filtering = ice_vsi_dis_rx_vlan_filtering; vlan_ops->ena_tx_filtering = ice_vsi_ena_tx_vlan_filtering; vlan_ops->dis_tx_filtering = ice_vsi_dis_tx_vlan_filtering;
@@ -51,6 +50,8 @@ void ice_vf_vsi_init_vlan_ops(struct ice_vsi *vsi)if (ice_vf_is_port_vlan_ena (vf)) {/* setup outer VLAN ops */ vlan_ops->set_port_vlan = ice_vsi_set_outer_port_vlan; + vlan_ops->ena_rx_filtering = + ice_vsi_ena_rx_vlan_filtering;/* setup inner VLAN ops */ vlan_ops = &vsi->inner_vlan_ops;
@@ -61,6 +62,12 @@ void ice_vf_vsi_init_vlan_ops(struct ice_vsi *vsi) vlan_ops->ena_insertion = ice_vsi_ena_inner_insertion; vlan_ops->dis_insertion = ice_vsi_dis_inner_insertion; }else { +if (!test_bit (ICE_FLAG_VF_VLAN_PRUNING , pf->flags)) + vlan_ops->ena_rx_filtering = noop_vlan; +else + vlan_ops->ena_rx_filtering = + ice_vsi_ena_rx_vlan_filtering; + vlan_ops->del_vlan = ice_vsi_del_vlan; vlan_ops->ena_stripping = ice_vsi_ena_outer_stripping; vlan_ops->dis_stripping = ice_vsi_dis_outer_stripping;
@@ -80,14 +87,21 @@ void ice_vf_vsi_init_vlan_ops(struct ice_vsi *vsi)/* inner VLAN ops regardless of port VLAN config */ vlan_ops->add_vlan = ice_vsi_add_vlan; - vlan_ops->ena_rx_filtering = ice_vsi_ena_rx_vlan_filtering; vlan_ops->dis_rx_filtering = ice_vsi_dis_rx_vlan_filtering; vlan_ops->ena_tx_filtering = ice_vsi_ena_tx_vlan_filtering; vlan_ops->dis_tx_filtering = ice_vsi_dis_tx_vlan_filtering;if (ice_vf_is_port_vlan_ena (vf)) { vlan_ops->set_port_vlan = ice_vsi_set_inner_port_vlan; + vlan_ops->ena_rx_filtering = + ice_vsi_ena_rx_vlan_filtering; }else { +if (!test_bit (ICE_FLAG_VF_VLAN_PRUNING , pf->flags)) + vlan_ops->ena_rx_filtering = noop_vlan; +else + vlan_ops->ena_rx_filtering = + ice_vsi_ena_rx_vlan_filtering; + vlan_ops->del_vlan = ice_vsi_del_vlan; vlan_ops->ena_stripping = ice_vsi_ena_inner_stripping; vlan_ops->dis_stripping = ice_vsi_dis_inner_stripping;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +14 -0
@@ -807,6 +807,11 @@ static int ice_vf_rebuild_host_vlan_cfg(struct ice_vf *vf, struct ice_vsi *vsi)return err; } + err = vlan_ops->ena_rx_filtering (vsi); +if (err) +dev_warn (dev,"failed to enable Rx VLAN filtering for VF %d VSI %d during VF rebuild, error %d\n" , + vf->vf_id, vsi->idx, err); +return 0 ; }
@@ -1791,6 +1796,7 @@ static void ice_vc_notify_vf_reset(struct ice_vf *vf)*/ static int ice_init_vf_vsi_res (struct ice_vf *vf) { +struct ice_vsi_vlan_ops *vlan_ops;struct ice_pf *pf = vf->pf;u8 broadcast[ETH_ALEN ];struct ice_vsi *vsi;
@@ -1811,6 +1817,14 @@ static int ice_init_vf_vsi_res(struct ice_vf *vf) goto release_vsi; } + vlan_ops =ice_get_compat_vsi_vlan_ops (vsi); + err = vlan_ops->ena_rx_filtering (vsi); +if (err) { +dev_warn (dev,"Failed to enable Rx VLAN filtering for VF %d\n" , + vf->vf_id); + goto release_vsi; + } +eth_broadcast_addr (broadcast); err =ice_fltr_add_mac (vsi, broadcast,ICE_FWD_TO_VSI );if (err) {
Signature · 1 line
2.20.1
G
PATCH v3 14/14 ice: Add ability for PF admin to enable VF VLAN pruning
Quoted 27 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 14/14] ice: Add ability for PF admin to enable VF VLAN pruningFrom: Brett Creeley <[email protected]>
VFs by default are able to see all tagged traffic regardless of trust and VLAN filters. Based on legacy devices (i.e. ixgbe, i40e), customers expect VFs to receive all VLAN tagged traffic with a matching destination MAC.
Add an ethtool private flag 'vf-vlan-pruning' and set the default to off so VFs will receive all VLAN traffic directed towards them. When the flag is turned on, VF will only be able to receive untagged traffic or traffic with VLAN tags it has created interfaces for.
Also, the flag cannot be changed while any VFs are allocated. This was done to simplify the implementation. So, if this flag is needed, then the PF admin must enable it. If the user tries to enable the flag while VFs are active, then print an unsupported message with the vf-vlan-pruning flag included. In case multiple flags were specified, this makes it clear to the user which flag failed.
Quoted 9 lines
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 9 +++++++++ .../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 18 ++++++++++++++++-- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-)
G
PATCH v3 1/14 ice: Refactor spoofcheck configuration functions
In reply to Tony NguyenQuoted 19 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, December 2, 2021 10:09 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v3 01/14] ice: Refactor spoofcheck configuration functionsFrom: Brett Creeley <[email protected]>
Add functions to configure Tx VLAN antispoof based on iproute configuration and/or VLAN mode and VF driver support. This is needed later so the driver can control when it can be configured. Also, add functions that can be used to enable and disable MAC and VLAN spoofcheck. Move spoofchk configuration during VSI setup into the SR-IOV initialization path and into the post VSI rebuild flow for VF VSIs.
Quoted 7 lines
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_lib.c | 19 --- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 159 ++++++++++++++---- 2 files changed, 128 insertions(+), 50 deletions(-)