ice: Add initial support for QinQ
Subsystems (2)
Tony Nguyen
maintainerPATCH 1/15 ice: Add initial support for QinQ
From: Brett Creeley <[email protected]>
Allow support for S-Tag + C-Tag VLAN traffic by disabling pruning when there are no 0x8100 VLAN interfaces currently created on top of the PF. When an 0x8100 VLAN interface is configured, enable pruning and only support single and double C-Tag VLAN traffic. If all of the 0x8100 interfaces that were created on top of the PF are removed via ethtool -K <iface> rx-vlan-filter off or via ip tools, then disable pruning and allow S-Tag + C-Tag traffic again.
Add VLAN 0 filter by default for the PF. This is because a bridge sets the default_pvid to 1, sends the request down to ice_vlan_rx_add_vid(), and we never get the request to add VLAN 0 via the 8021q module which causes all untagged traffic to be dropped.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 43 +++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_lib.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 21 ++++++--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 14 +++--- 4 files changed, 63 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +40 -3
@@ -1383,7 +1383,9 @@ int ice_vsi_add_vlan(struct ice_vsi *vsi, u16 vid)list_add (&tmp->list_entry, &tmp_add_list); status =ice_add_vlan (&pf->hw, &tmp_add_list); -if (status) { +if (!status) { + vsi->num_vlan++; + }else { err = -ENODEV ;dev_err (dev,"Failure Adding VLAN %d on VSI %i\n" , vid, vsi->vsi_num);
@@ -1425,10 +1427,12 @@ int ice_vsi_kill_vlan(struct ice_vsi *vsi, u16 vid)list_add (&list->list_entry, &tmp_add_list); status =ice_remove_vlan (&pf->hw, &tmp_add_list); -if (status ==ICE_ERR_DOES_NOT_EXIST ) { +if (!status) { + vsi->num_vlan--; + }else if (status ==ICE_ERR_DOES_NOT_EXIST ) {dev_dbg (dev,"Failed to remove VLAN %d on VSI %i, it does not exist, status: %d\n" , vid, vsi->vsi_num, status); - }else if (status) { + }else {dev_err (dev,"Error removing VLAN %d on vsi %i error: %d\n" , vid, vsi->vsi_num, status); err = -EIO ;
@@ -1790,6 +1794,26 @@ int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi)return ice_vsi_stop_tx_rings (vsi,ICE_NO_RESET ,0 , vsi->xdp_rings); } +/** +* ice_vsi_is_vlan_pruning_ena - check if VLAN pruning is enabled or not +* @vsi: VSI to check whether or not VLAN pruning is enabled. +* +* returns true if Rx VLAN pruning and Tx VLAN anti-spoof is enabled and false +* otherwise. +*/ +bool ice_vsi_is_vlan_pruning_ena (struct ice_vsi *vsi) +{ +u8 rx_pruning =ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA ; +u8 tx_pruning =ICE_AQ_VSI_SEC_TX_VLAN_PRUNE_ENA << +ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S ; + +if (!vsi) +return false; + +return ((vsi->info.sw_flags2 & rx_pruning) && + (vsi->info.sec_flags & tx_pruning)); +} +/** * ice_cfg_vlan_pruning - enable or disable VLAN pruning on the VSI * @vsi: VSI to enable or disable VLAN pruning on
@@ -2060,6 +2084,17 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,if (ret) goto unroll_vector_base; +/* Always add VLAN ID 0 switch rule by default. This is needed +* in order to allow all untagged and 0 tagged priority traffic +* if Rx VLAN pruning is enabled. Also there are cases where we +* don't get the call to add VLAN 0 via ice_vlan_rx_add_vid() +* 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 ); +if (ret) + goto unroll_clear_rings; +ice_vsi_map_rings_to_vectors (vsi);/* Do not exit if configuring RSS had an issue, at least
@@ -2139,6 +2174,8 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,return vsi; +unroll_clear_rings: +ice_vsi_clear_rings (vsi); unroll_vector_base:/* reclaim SW interrupts back to the common pool */ ice_free_res (pf->irq_tracker, vsi->base_vector, vsi->idx);
drivers/net/ethernet/intel/ice/ice_lib.h +2 -0
@@ -44,6 +44,8 @@ int ice_vsi_cfg_xdp_txqs(struct ice_vsi *vsi);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,bool vlan_promisc);void ice_cfg_sw_lldp (struct ice_vsi *vsi,bool tx,bool create);
drivers/net/ethernet/intel/ice/ice_main.c +14 -7
@@ -2467,16 +2467,19 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto,if (vsi->info.pvid)return -EINVAL ; -/* Enable VLAN pruning when VLAN 0 is added */ -if (unlikely (!vid)) { +/* VLAN 0 is added by default during load/reset */ +if (!vid) +return 0 ; + +/* 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, false);if (ret)return ret; } -/* Add all VLAN IDs including 0 to the switch filter. VLAN ID 0 is -* needed to continue allowing all untagged packets since VLAN prune -* list is applied to all packets by the switch +/* 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);if (!ret) {
@@ -2506,6 +2509,10 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,if (vsi->info.pvid)return -EINVAL ; +/* don't allow removal of VLAN 0 */ +if (!vid) +return 0 ; +/* Make sure ice_vsi_kill_vlan is successful before updating VLAN * information */
@@ -2513,8 +2520,8 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,if (ret)return ret; -/* Disable VLAN pruning when VLAN 0 is removed */ -if (unlikely (!vid)) +/* 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, false); vsi->vlan_ena = false;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +7 -7
@@ -2843,9 +2843,9 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v) goto error_param; } - vsi->num_vlan++; -/* Enable VLAN pruning when VLAN is added */ -if (!vlan_promisc) { +/* Enable VLAN pruning when non-zero VLAN is added */ +if (!vlan_promisc && vid && + !ice_vsi_is_vlan_pruning_ena (vsi)) { status =ice_cfg_vlan_pruning (vsi, true, false);if (status) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ;
@@ -2853,7 +2853,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v) vid, status); goto error_param; } - }else { + }else if (vlan_promisc) {/* Enable Ucast/Mcast VLAN promiscuous mode */ promisc_m =ICE_PROMISC_VLAN_TX |ICE_PROMISC_VLAN_RX ;
@@ -2897,9 +2897,9 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v) goto error_param; } - vsi->num_vlan--; -/* Disable VLAN pruning when the last VLAN is removed */ -if (!vsi->num_vlan) +/* Disable VLAN pruning when only VLAN 0 is left */ +if (vsi->num_vlan ==1 && +ice_vsi_is_vlan_pruning_ena (vsi))ice_cfg_vlan_pruning (vsi, false, false);/* Disable Unicast/Multicast VLAN promiscuous mode */
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH 2/15 ice: Refactor port vlan configuration for the VF
From: Brett Creeley <[email protected]>
Currently ice_vsi_manage_pvid() calls ice_vsi_[set|kill]_pvid_fill_ctxt() when enabling/disabling a port VLAN on a VSI respectively. These two functions have some duplication so just move their unique pieces inline in ice_vsi_manage_pvid() and then the duplicate code can be reused for both the enabling/disabling paths.
Before this patch the info.pvid field was not being written correctly via ice_vsi_kill_pvid_fill_ctxt() so it was being hardcoded to 0 in ice_set_vf_port_vlan(). Fix this by setting the info.pvid field to 0 before calling ice_vsi_update() in ice_vsi_manage_pvid().
We currently use vf->port_vlan_id to keep track of the port VLAN ID and QoS, which is a bit misleading. Fix this by renaming it to vf->port_vlan_info. Also change the name of the argument for ice_vsi_manage_pvid() from vid to pvid_info.
In ice_vsi_manage_pvid() only save the fields that were modified in the VSI properties structure on success instead of the entire thing.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 86 ++++++++----------- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 2 +- 2 files changed, 37 insertions(+), 51 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +36 -50
@@ -406,44 +406,16 @@ static void ice_trigger_vf_reset(struct ice_vf *vf, bool is_vflr, bool is_pfr) } } -/** -* ice_vsi_set_pvid_fill_ctxt - Set VSI ctxt for add PVID -* @ctxt: the VSI ctxt to fill -* @vid: the VLAN ID to set as a PVID -*/ -static void ice_vsi_set_pvid_fill_ctxt (struct ice_vsi_ctx *ctxt,u16 vid) -{ - ctxt->info.vlan_flags = (ICE_AQ_VSI_VLAN_MODE_UNTAGGED | -ICE_AQ_VSI_PVLAN_INSERT_PVID | -ICE_AQ_VSI_VLAN_EMOD_STR ); - ctxt->info.pvid =cpu_to_le16 (vid); - ctxt->info.sw_flags2 |=ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA ; - ctxt->info.valid_sections =cpu_to_le16 (ICE_AQ_VSI_PROP_VLAN_VALID | -ICE_AQ_VSI_PROP_SW_VALID ); -} - -/** -* ice_vsi_kill_pvid_fill_ctxt - Set VSI ctx for remove PVID -* @ctxt: the VSI ctxt to fill -*/ -static void ice_vsi_kill_pvid_fill_ctxt (struct ice_vsi_ctx *ctxt) -{ - ctxt->info.vlan_flags =ICE_AQ_VSI_VLAN_EMOD_NOTHING ; - ctxt->info.vlan_flags |=ICE_AQ_VSI_VLAN_MODE_ALL ; - ctxt->info.sw_flags2 &= ~ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA ; - ctxt->info.valid_sections =cpu_to_le16 (ICE_AQ_VSI_PROP_VLAN_VALID | -ICE_AQ_VSI_PROP_SW_VALID ); -} -/** * ice_vsi_manage_pvid - Enable or disable port VLAN for VSI * @vsi: the VSI to update -* @vid: the VLAN ID to set as a PVID +* @pvid_info: VLAN ID and QoS used to set the PVID VSI context field * @enable: true for enable PVID false for disable */ -static int ice_vsi_manage_pvid (struct ice_vsi *vsi,u16 vid,bool enable) +static int ice_vsi_manage_pvid (struct ice_vsi *vsi,u16 pvid_info,bool enable) {struct ice_hw *hw = &vsi->back->hw; +struct ice_aqc_vsi_props *info;struct ice_vsi_ctx *ctxt;enum ice_status status;int ret =0 ;
@@ -453,20 +425,33 @@ static int ice_vsi_manage_pvid(struct ice_vsi *vsi, u16 vid, bool enable)return -ENOMEM ; ctxt->info = vsi->info; -if (enable) -ice_vsi_set_pvid_fill_ctxt (ctxt, vid); -else -ice_vsi_kill_pvid_fill_ctxt (ctxt); + info = &ctxt->info; +if (enable) { + info->vlan_flags =ICE_AQ_VSI_VLAN_MODE_UNTAGGED | +ICE_AQ_VSI_PVLAN_INSERT_PVID | +ICE_AQ_VSI_VLAN_EMOD_STR ; + info->sw_flags2 |=ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA ; + }else { + info->vlan_flags =ICE_AQ_VSI_VLAN_EMOD_NOTHING | +ICE_AQ_VSI_VLAN_MODE_ALL ; + info->sw_flags2 &= ~ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA ; + } + + info->pvid =cpu_to_le16 (pvid_info); + info->valid_sections =cpu_to_le16 (ICE_AQ_VSI_PROP_VLAN_VALID | +ICE_AQ_VSI_PROP_SW_VALID ); status =ice_update_vsi (hw, vsi->idx, ctxt,NULL );if (status) { -dev_info (ice_pf_to_dev (vsi->back),"update VSI for port VLAN failed, err %d aq_err %d\n" , +dev_info (ice_hw_to_dev (hw),"update VSI for port VLAN failed, err %d aq_err %d\n" , status, hw->adminq.sq_last_status); ret = -EIO ; goto out; } - vsi->info = ctxt->info; + vsi->info.vlan_flags = info->vlan_flags; + vsi->info.sw_flags2 = info->sw_flags2; + vsi->info.pvid = info->pvid; out:kfree (ctxt);return ret;
@@ -533,9 +518,9 @@ static int ice_alloc_vsi_res(struct ice_vf *vf) vf->lan_vsi_num = vsi->vsi_num;/* Check if port VLAN exist before, and restore it accordingly */ -if (vf->port_vlan_id) { -ice_vsi_manage_pvid (vsi, vf->port_vlan_id, true); -ice_vsi_add_vlan (vsi, vf->port_vlan_id &ICE_VLAN_M ); +if (vf->port_vlan_info) { +ice_vsi_manage_pvid (vsi, vf->port_vlan_info, true); +ice_vsi_add_vlan (vsi, vf->port_vlan_info &ICE_VLAN_M ); }eth_broadcast_addr (broadcast);
@@ -985,13 +970,13 @@ ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m,if (vsi->num_vlan) { status =ice_set_vlan_vsi_promisc (hw, vsi->idx, promisc_m, rm_promisc); - }else if (vf->port_vlan_id) { + }else if (vf->port_vlan_info) {if (rm_promisc) status =ice_clear_vsi_promisc (hw, vsi->idx, promisc_m, - vf->port_vlan_id); + vf->port_vlan_info);else status =ice_set_vsi_promisc (hw, vsi->idx, promisc_m, - vf->port_vlan_id); + vf->port_vlan_info); }else {if (rm_promisc) status = ice_clear_vsi_promisc(hw, vsi->idx, promisc_m,
@@ -1231,7 +1216,7 @@ static 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_id || vsi->num_vlan) +if (vf->port_vlan_info || vsi->num_vlan) promisc_m =ICE_UCAST_VLAN_PROMISC_BITS ;else promisc_m =ICE_UCAST_PROMISC_BITS ;
@@ -2706,10 +2691,11 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,if (vlan_id || qos) { ret =ice_vsi_manage_pvid (vsi, vlanprio, true);if (ret) - goto error_set_pvid; + goto error_manage_pvid; }else { -ice_vsi_manage_pvid (vsi,0 , false); - vsi->info.pvid =0 ; + ret =ice_vsi_manage_pvid (vsi,0 , false); +if (ret) + goto error_manage_pvid; }if (vlan_id) {
@@ -2719,15 +2705,15 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,/* add new VLAN filter for each MAC */ ret =ice_vsi_add_vlan (vsi, vlan_id);if (ret) - goto error_set_pvid; + goto error_manage_pvid; }/* The Port VLAN needs to be saved across resets the same as the * default LAN MAC address. */ - vf->port_vlan_id =le16_to_cpu (vsi->info.pvid); + vf->port_vlan_info =le16_to_cpu (vsi->info.pvid); -error_set_pvid: +error_manage_pvid:return ret; }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +1 -1
@@ -74,7 +74,7 @@ struct ice_vf {struct virtchnl_ether_addr dflt_lan_addr;DECLARE_BITMAP (txq_ena,ICE_MAX_BASE_QS_PER_VF );DECLARE_BITMAP (rxq_ena,ICE_MAX_BASE_QS_PER_VF ); -u16 port_vlan_id; +u16 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
Bowers
PATCH 2/15 ice: Refactor port vlan configuration for the VF
Quoted 26 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:21 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 02/15] ice: Refactor port vlan configuration for the VFFrom: Brett Creeley <[email protected]>
Currently
ice_vsi_manage_pvid()calls ice_vsi_[set|kill]_pvid_fill_ctxt() when enabling/disabling a port VLAN on a VSI respectively. These two functions have some duplication so just move their unique pieces inline inice_vsi_manage_pvid()and then the duplicate code can be reused for both the enabling/disabling paths.Before this patch the info.pvid field was not being written correctly via
ice_vsi_kill_pvid_fill_ctxt()so it was being hardcoded to 0 inice_set_vf_port_vlan(). Fix this by setting the info.pvid field to 0 before callingice_vsi_update()inice_vsi_manage_pvid().We currently use
vf->port_vlan_idto keep track of the port VLAN ID and QoS, which is a bit misleading. Fix this by renaming it tovf->port_vlan_info. Also change the name of the argument forice_vsi_manage_pvid()from vid topvid_info.
Quoted 8 lines
In
ice_vsi_manage_pvid()only save the fields that were modified in the VSI properties structure on success instead of the entire thing.Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 86 ++++++++----------- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 2 +- 2 files changed, 37 insertions(+), 51 deletions(-)
Tony Nguyen
maintainerPATCH 3/15 ice: Add helper to determine if VF link is up
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
The check for vf->link_up is incorrect because this field is only valid if vf->link_forced is true. Fix this by adding the helper ice_is_vf_link_up() to determine if the VF's link is up.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +25 -17
@@ -90,6 +90,26 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe, } } +/** +* ice_is_vf_link_up - check if the VF's link is up +* @vf: VF to check if link is up +*/ +static bool ice_is_vf_link_up (struct ice_vf *vf) +{ +struct ice_pf *pf = vf->pf; + +if (ice_check_vf_init (pf, vf)) +return false; + +if (!vf->num_qs_ena) +return false; +else if (vf->link_forced) +return vf->link_up; +else +return pf->hw.port_info->phy.link_info.link_info & +ICE_AQ_LINK_UP ; +} +/** * ice_vc_notify_vf_link_state - Inform a VF of link status * @vf: pointer to the VF structure
@@ -99,28 +119,16 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe,static void ice_vc_notify_vf_link_state (struct ice_vf *vf) {struct virtchnl_pf_event pfe = {0 }; -struct ice_link_status *ls; -struct ice_pf *pf = vf->pf; -struct ice_hw *hw; - - hw = &pf->hw; - ls = &hw->port_info->phy.link_info; +struct ice_hw *hw = &vf->pf->hw; pfe.event =VIRTCHNL_EVENT_LINK_CHANGE ; pfe.severity =PF_EVENT_SEVERITY_INFO ; -/* Always report link is down if the VF queues aren't enabled */ -if (!vf->num_qs_ena) { +if (ice_is_vf_link_up (vf)) +ice_set_pfe_link (vf, &pfe, + hw->port_info->phy.link_info.link_speed, true); +else ice_set_pfe_link (vf, &pfe,ICE_AQ_LINK_SPEED_UNKNOWN , false); - }else if (vf->link_forced) { -u16 link_speed = vf->link_up ? - ls->link_speed :ICE_AQ_LINK_SPEED_UNKNOWN ; - -ice_set_pfe_link (vf, &pfe, link_speed, vf->link_up); - }else { -ice_set_pfe_link (vf, &pfe, ls->link_speed, - ls->link_info &ICE_AQ_LINK_UP ); - } ice_aq_send_msg_to_vf(hw, vf->vf_id, VIRTCHNL_OP_EVENT, VIRTCHNL_STATUS_SUCCESS, (u8 *)&pfe,
Signature · 1 line
2.20.1
Bowers
PATCH 3/15 ice: Add helper to determine if VF link is up
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:21 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 03/15] ice: Add helper to determine if VF link is upFrom: Brett Creeley <[email protected]>
The check for
vf->link_upis incorrect because this field is only valid ifvf->link_forcedis true. Fix this by adding the helpervf->ice_is_vf_link_up()
to determine if the VF's link is up.
Quoted 5 lines
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-)
Tony Nguyen
maintainerPATCH 4/15 ice: Fix Port VLAN priority bits
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently when configuring a port VLAN for a VF we are only shifting the QoS bits by 12. This is incorrect. Fix this by getting rid of the ICE specific VLAN defines and use the kernel VLAN defines instead.
Also, don't assign a value to vlanprio until the VLAN ID and QoS parameters have been validated.
Also, there are many places we do (le16_to_cpu(vsi->info.pvid) & VLAN_VID_MASK). Instead do (vf->port_vlan_info & VLAN_VID_MASK) because we always save what's stored in vsi->info.pvid to vf->port_vlan_info in the CPU's endianness.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 27 +++++++++---------- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 5 ---- 2 files changed, 13 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +13 -14
@@ -528,7 +528,7 @@ static int ice_alloc_vsi_res(struct ice_vf *vf)/* Check if port VLAN exist before, and restore it accordingly */ if (vf->port_vlan_info) {ice_vsi_manage_pvid (vsi, vf->port_vlan_info, true); -ice_vsi_add_vlan (vsi, vf->port_vlan_info &ICE_VLAN_M ); +ice_vsi_add_vlan (vsi, vf->port_vlan_info &VLAN_VID_MASK ); }eth_broadcast_addr (broadcast);
@@ -2659,19 +2659,20 @@ int ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, __be16 vlan_proto) { - u16 vlanprio = vlan_id | (qos << ICE_VLAN_PRIORITY_S); struct ice_pf *pf = ice_netdev_to_pf(netdev);struct ice_vsi *vsi;struct device *dev;struct ice_vf *vf; +u16 vlanprio;int ret =0 ; dev =ice_pf_to_dev (pf);if (ice_validate_vf_id (pf, vf_id))return -EINVAL ; -if (vlan_id >ICE_MAX_VLANID || qos >7 ) { -dev_err (dev,"Invalid VF Parameters\n" ); +if (vlan_id >=VLAN_N_VID || qos >7 ) { +dev_err (dev,"Invalid Port VLAN parameters for VF %d, ID %d, QoS %d\n" , + vf_id, vlan_id, qos);return -EINVAL ; }
@@ -2685,16 +2686,17 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,if (ice_check_vf_init (pf, vf))return -EBUSY ; -if (le16_to_cpu (vsi->info.pvid) == vlanprio) { + vlanprio = vlan_id | (qos <<VLAN_PRIO_SHIFT ); + +if (vf->port_vlan_info == vlanprio) {/* duplicate request, so just return success */ dev_dbg (dev,"Duplicate pvid %d request\n" , vlanprio);return ret; }/* If PVID, then remove all filters on the old VLAN */ -if (vsi->info.pvid) -ice_vsi_kill_vlan (vsi, (le16_to_cpu (vsi->info.pvid) & -VLAN_VID_MASK )); +if (vf->port_vlan_info) +ice_vsi_kill_vlan (vsi, vf->port_vlan_info &VLAN_VID_MASK );if (vlan_id || qos) { ret =ice_vsi_manage_pvid (vsi, vlanprio, true);
@@ -2775,7 +2777,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v) }for (i =0 ; i < vfl->num_elements; i++) { -if (vfl->vlan_id[i] >ICE_MAX_VLANID ) { +if (vfl->vlan_id[i] >=VLAN_N_VID ) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ;dev_err (dev,"invalid VF VLAN id %d\n" , vfl->vlan_id[i]);
@@ -3206,14 +3208,12 @@ int ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi) { struct ice_pf *pf = ice_netdev_to_pf(netdev); -struct ice_vsi *vsi;struct ice_vf *vf;if (ice_validate_vf_id (pf, vf_id))return -EINVAL ; vf = &pf->vf[vf_id]; - vsi = pf->vsi[vf->lan_vsi_idx];if (ice_check_vf_init (pf, vf))return -EBUSY ;
@@ -3222,9 +3222,8 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi)ether_addr_copy (ivi->mac, vf->dflt_lan_addr.addr);/* VF configuration for VLAN and applicable QoS */ - ivi->vlan =le16_to_cpu (vsi->info.pvid) &ICE_VLAN_M ; - ivi->qos = (le16_to_cpu (vsi->info.pvid) &ICE_PRIORITY_M ) >> -ICE_VLAN_PRIORITY_S ; + ivi->vlan = vf->port_vlan_info &VLAN_VID_MASK ; + ivi->qos = (vf->port_vlan_info &VLAN_PRIO_MASK ) >>VLAN_PRIO_SHIFT ; ivi->trusted = vf->trusted; ivi->spoofchk = vf->spoofchk;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +0 -5
@@ -5,11 +5,6 @@#define _ICE_VIRTCHNL_PF_H_#include "ice.h" -#define ICE_MAX_VLANID 4095 -#define ICE_VLAN_PRIORITY_S 12 -#define ICE_VLAN_M 0xFFF -#define ICE_PRIORITY_M 0x7000 -/* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */ #define ICE_MAX_VLAN_PER_VF 8#define ICE_MAX_MACADDR_PER_VF 12
Signature · 1 line
2.20.1
Bowers
PATCH 4/15 ice: Fix Port VLAN priority bits
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:21 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 04/15] ice: Fix Port VLAN priority bitsFrom: Brett Creeley <[email protected]>
Currently when configuring a port VLAN for a VF we are only shifting the QoS bits by 12. This is incorrect. Fix this by getting rid of the ICE specific VLAN defines and use the kernel VLAN defines instead.
Also, don't assign a value to vlanprio until the VLAN ID and QoS parameters have been validated.
Also, there are many places we do (
le16_to_cpu(vsi->info.pvid)&VLAN_VID_MASK). Instead do (vf->port_vlan_info&VLAN_VID_MASK) because we always save what's stored invsi->info.pvidtovf->port_vlan_infoin the CPU's endianness.
Quoted 5 lines
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 27 +++++++++---------- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 5 ---- 2 files changed, 13 insertions(+), 19 deletions(-)
Tony Nguyen
maintainerPATCH 5/15 ice: Only allow tagged bcast/mcast traffic for VF in port VLAN
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently the VF can see other's broadcast and multicast traffic because it always has a VLAN filter for VLAN 0. Fix this by removing/adding the VF's VLAN 0 filter when a port VLAN is added/removed respectively.
This required a few changes.
1. Move where we add VLAN 0 by default for the VF into ice_alloc_vsi_res() because this is when we determine if a port VLAN is present for load and reset.
2. Moved where we kill the old port VLAN filter in ice_set_vf_port_vlan() to the very end of the function because it allows us to save the old port VLAN configuration upon any failure case.
3. During adding/removing of a port VLAN via ice_set_vf_port_vlan() we also need to remove/add the VLAN 0 filter rule respectively.
4. Improve log messages.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 49 ++++++++++++------- 1 file changed, 31 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +31 -18
@@ -528,7 +528,18 @@ static int ice_alloc_vsi_res(struct ice_vf *vf)/* Check if port VLAN exist before, and restore it accordingly */ if (vf->port_vlan_info) {ice_vsi_manage_pvid (vsi, vf->port_vlan_info, true); -ice_vsi_add_vlan (vsi, vf->port_vlan_info &VLAN_VID_MASK ); +if (ice_vsi_add_vlan (vsi, vf->port_vlan_info &VLAN_VID_MASK )) +dev_warn (ice_pf_to_dev (pf),"Failed to add Port VLAN %d filter for VF %d\n" , + vf->port_vlan_info &VLAN_VID_MASK , vf->vf_id); + }else { +/* set VLAN 0 filter by default when no port VLAN is +* enabled. If a port VLAN is enabled we don't want +* untagged broadcast/multicast traffic seen on the VF +* interface. +*/ +if (ice_vsi_add_vlan (vsi,0 )) +dev_warn (ice_pf_to_dev (pf),"Failed to add VLAN 0 filter for VF %d, MDD events will trigger. Reset the VF, disable spoofchk, or enable 8021q module on the guest\n" , + vf->vf_id); }eth_broadcast_addr (broadcast);
@@ -936,17 +947,9 @@ static void ice_cleanup_and_realloc_vf(struct ice_vf *vf)/* reallocate VF resources to finish resetting the VSI state */ if (!ice_alloc_vf_res (vf)) { -struct ice_vsi *vsi; -ice_ena_vf_mappings (vf);set_bit (ICE_VF_STATE_ACTIVE , vf->vf_states);clear_bit (ICE_VF_STATE_DIS , vf->vf_states); - - vsi = pf->vsi[vf->lan_vsi_idx]; -if (ice_vsi_add_vlan (vsi,0 )) -dev_warn (ice_pf_to_dev (pf), -"Failed to add VLAN 0 filter for VF %d, MDD events will trigger. Reset the VF, disable spoofchk, or enable 8021q module on the guest" , - vf->vf_id); }/* Tell the VF driver the reset is done. This needs to be done only
@@ -2694,15 +2697,24 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,return ret; } -/* If PVID, then remove all filters on the old VLAN */ -if (vf->port_vlan_info) -ice_vsi_kill_vlan (vsi, vf->port_vlan_info &VLAN_VID_MASK ); -if (vlan_id || qos) { +/* remove VLAN 0 filter set by default when transitioning from +* no port VLAN to a port VLAN. No change to old port VLAN on +* failure. +*/ + ret =ice_vsi_kill_vlan (vsi,0 ); +if (ret) +return ret; ret =ice_vsi_manage_pvid (vsi, vlanprio, true);if (ret) - goto error_manage_pvid; +return ret; }else { +/* add VLAN 0 filter back when transitioning from port VLAN to +* no port VLAN. No change to old port VLAN on failure. +*/ + ret =ice_vsi_add_vlan (vsi,0 ); +if (ret) +return ret; ret =ice_vsi_manage_pvid (vsi,0 , false);if (ret) goto error_manage_pvid;
@@ -2712,15 +2724,16 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,dev_info (dev,"Setting VLAN %d, QoS 0x%x on VF %d\n" , vlan_id, qos, vf_id); -/* add new VLAN filter for each MAC */ +/* add VLAN filter for the port VLAN */ ret =ice_vsi_add_vlan (vsi, vlan_id);if (ret) goto error_manage_pvid; } +/* remove old port VLAN filter with valid VLAN ID or QoS fields */ +if (vf->port_vlan_info) +ice_vsi_kill_vlan (vsi, vf->port_vlan_info &VLAN_VID_MASK ); -/* The Port VLAN needs to be saved across resets the same as the -* default LAN MAC address. -*/ +/* keep port VLAN information persistent on resets */ vf->port_vlan_info =le16_to_cpu (vsi->info.pvid); error_manage_pvid:
Signature · 1 line
2.20.1
Bowers
PATCH 5/15 ice: Only allow tagged bcast/mcast traffic for VF in port VLAN
Quoted 27 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:21 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 05/15] ice: Only allow tagged bcast/mcast traffic for VF in port VLANFrom: Brett Creeley <[email protected]>
Currently the VF can see other's broadcast and multicast traffic because it always has a VLAN filter for VLAN 0. Fix this by removing/adding the VF's VLAN 0 filter when a port VLAN is added/removed respectively.
This required a few changes.
1. Move where we add VLAN 0 by default for the VF into
ice_alloc_vsi_res()because this is when we determine if a port VLAN is present for load and reset.2. Moved where we kill the old port VLAN filter in
ice_set_vf_port_vlan()to the very end of the function because it allows us to save the old port VLAN configuration upon any failure case.3. During adding/removing of a port VLAN via
ice_set_vf_port_vlan()we also need to remove/add the VLAN 0 filter rule respectively.
Quoted 6 lines
4. Improve log messages.
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 49 ++++++++++++------- 1 file changed, 31 insertions(+), 18 deletions(-)
Tony Nguyen
maintainerPATCH 6/15 ice: Add support to enable/disable all Rx queues before waiting
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently when we enable/disable all Rx queues we do the following sequence for each Rx queue and then move to the next queue.
1. Enable/Disable the Rx queue via register write.
2. Read the configuration register to determine if the Rx queue was enabled/disabled successfully.
In some cases enabling/disabling queue 0 fails because of step 2 above. Fix this by doing step 1 for all of the Rx queues and then step 2 for all of the Rx queues.
Also, there are cases where we enable/disable a single queue (i.e. SR-IOV and XDP) so add a new function that does step 1 and 2 above with a read flush in between.
This change also required a single Rx queue to be enabled/disabled with and without waiting for the change to propagate through hardware. Fix this by adding a boolean wait flag to the necessary functions.
Also, add the keywords "one" and "all" to distinguish between enabling/disabling a single Rx queue and all Rx queues respectively.
--- drivers/net/ethernet/intel/ice/ice_base.c | 42 ++++++++++++++----- drivers/net/ethernet/intel/ice/ice_base.h | 4 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 4 +- drivers/net/ethernet/intel/ice/ice_lib.c | 32 +++++++++----- drivers/net/ethernet/intel/ice/ice_lib.h | 4 +- drivers/net/ethernet/intel/ice/ice_main.c | 4 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 7 ++-- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +- 8 files changed, 67 insertions(+), 34 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +31 -11
@@ -459,17 +459,20 @@ int __ice_vsi_get_qs(struct ice_qs_cfg *qs_cfg) }/** -* ice_vsi_ctrl_rx_ring - Start or stop a VSI's Rx ring +* ice_vsi_ctrl_one_rx_ring - start/stop VSI's Rx ring with no busy wait * @vsi: the VSI being configured -* @ena: start or stop the Rx rings -* @rxq_idx: Rx queue index +* @ena: start or stop the Rx ring +* @rxq_idx: 0-based Rx queue index for the VSI passed in +* @wait: wait or don't wait for configuration to finish in hardware +* +* Return 0 on success and negative on error. */ -int ice_vsi_ctrl_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx) +int +ice_vsi_ctrl_one_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx,bool wait) {int pf_q = vsi->rxq_map[rxq_idx];struct ice_pf *pf = vsi->back;struct ice_hw *hw = &pf->hw; -int ret =0 ;u32 rx_reg; rx_reg =rd32 (hw,QRX_CTRL (pf_q));
@@ -485,13 +488,30 @@ int ice_vsi_ctrl_rx_ring(struct ice_vsi *vsi, bool ena, u16 rxq_idx) rx_reg &= ~QRX_CTRL_QENA_REQ_M ;wr32 (hw,QRX_CTRL (pf_q), rx_reg); -/* wait for the change to finish */ - ret =ice_pf_rxq_wait (pf, pf_q, ena); -if (ret) -dev_err (ice_pf_to_dev (pf),"VSI idx %d Rx ring %d %sable timeout\n" , - vsi->idx, pf_q, (ena ?"en" :"dis" )); +if (!wait) +return 0 ; + +ice_flush (hw); +return ice_pf_rxq_wait (pf, pf_q, ena); +} -return ret; +/** +* ice_vsi_wait_one_rx_ring - wait for a VSI's Rx ring to be stopped/started +* @vsi: the VSI being configured +* @ena: true/false to verify Rx ring has been enabled/disabled respectively +* @rxq_idx: 0-based Rx queue index for the VSI passed in +* +* This routine will wait for the given Rx queue of the VSI to reach the +* enabled or disabled state. Returns -ETIMEDOUT in case of failing to reach +* the requested state after multiple retries; else will return 0 in case of +* success. +*/ +int ice_vsi_wait_one_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx) +{ +int pf_q = vsi->rxq_map[rxq_idx]; +struct ice_pf *pf = vsi->back; + +return ice_pf_rxq_wait (pf, pf_q, ena); }/**
drivers/net/ethernet/intel/ice/ice_base.h +3 -1
@@ -8,7 +8,9 @@int ice_setup_rx_ctx (struct ice_ring *ring);int __ice_vsi_get_qs (struct ice_qs_cfg *qs_cfg); -int ice_vsi_ctrl_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx); +int +ice_vsi_ctrl_one_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx,bool wait); +int ice_vsi_wait_one_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx);int ice_vsi_alloc_q_vectors (struct ice_vsi *vsi);void ice_vsi_map_rings_to_vectors (struct ice_vsi *vsi);void ice_vsi_free_q_vectors (struct ice_vsi *vsi);
drivers/net/ethernet/intel/ice/ice_ethtool.c +2 -2
@@ -462,7 +462,7 @@ static int ice_lbtest_prepare_rings(struct ice_vsi *vsi)if (status) goto err_setup_rx_ring; - status =ice_vsi_start_rx_rings (vsi); + status =ice_vsi_start_all_rx_rings (vsi);if (status) goto err_start_rx_ring;
@@ -494,7 +494,7 @@ static int ice_lbtest_disable_rings(struct ice_vsi *vsi)netdev_err (vsi->netdev,"Failed to stop Tx rings, VSI %d error %d\n" , vsi->vsi_num, status); - status =ice_vsi_stop_rx_rings (vsi); + status =ice_vsi_stop_all_rx_rings (vsi);if (status)netdev_err (vsi->netdev,"Failed to stop Rx rings, VSI %d error %d\n" , vsi->vsi_num, status);
drivers/net/ethernet/intel/ice/ice_lib.c +21 -11
@@ -26,16 +26,26 @@ const char *ice_vsi_type_str(enum ice_vsi_type type) }/** -* ice_vsi_ctrl_rx_rings - Start or stop a VSI's Rx rings +* ice_vsi_ctrl_all_rx_rings - Start or stop a VSI's Rx rings * @vsi: the VSI being configured * @ena: start or stop the Rx rings +* +* First enable/disable all of the Rx rings, flush any remaining writes, and +* then verify that they have all been enabled/disabled successfully. This will +* let all of the register writes complete when enabling/disabling the Rx rings +* before waiting for the change in hardware to complete. */ -static int ice_vsi_ctrl_rx_rings (struct ice_vsi *vsi,bool ena) +static int ice_vsi_ctrl_all_rx_rings (struct ice_vsi *vsi,bool ena) {int i, ret =0 ; +for (i =0 ; i < vsi->num_rxq; i++) +ice_vsi_ctrl_one_rx_ring (vsi, ena, i, false); + +ice_flush (&vsi->back->hw); +for (i =0 ; i < vsi->num_rxq; i++) { - ret =ice_vsi_ctrl_rx_ring (vsi, ena, i); + ret =ice_vsi_wait_one_rx_ring (vsi, ena, i);if (ret)break ; }
@@ -1717,25 +1727,25 @@ int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena) }/** -* ice_vsi_start_rx_rings - start VSI's Rx rings -* @vsi: the VSI whose rings are to be started +* ice_vsi_start_all_rx_rings - start/enable all of a VSI's Rx rings +* @vsi: the VSI whose rings are to be enabled * * Returns 0 on success and a negative value on error */ -int ice_vsi_start_rx_rings (struct ice_vsi *vsi) +int ice_vsi_start_all_rx_rings (struct ice_vsi *vsi) { -return ice_vsi_ctrl_rx_rings (vsi, true); +return ice_vsi_ctrl_all_rx_rings (vsi, true); }/** -* ice_vsi_stop_rx_rings - stop VSI's Rx rings -* @vsi: the VSI +* ice_vsi_stop_all_rx_rings - stop/disable all of a VSI's Rx rings +* @vsi: the VSI whose rings are to be disabled * * Returns 0 on success and a negative value on error */ -int ice_vsi_stop_rx_rings (struct ice_vsi *vsi) +int ice_vsi_stop_all_rx_rings (struct ice_vsi *vsi) { -return ice_vsi_ctrl_rx_rings (vsi, false); +return ice_vsi_ctrl_all_rx_rings (vsi, false); }/**
drivers/net/ethernet/intel/ice/ice_lib.h +2 -2
@@ -32,9 +32,9 @@ 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_rx_rings (struct ice_vsi *vsi); +int ice_vsi_start_all_rx_rings (struct ice_vsi *vsi); -int ice_vsi_stop_rx_rings (struct ice_vsi *vsi); +int ice_vsi_stop_all_rx_rings (struct ice_vsi *vsi); int ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src,
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -4031,7 +4031,7 @@ static int ice_up_complete(struct ice_vsi *vsi)* Tx queue group list was configured and the context bits were * programmed using ice_vsi_cfg_txqs */ - err =ice_vsi_start_rx_rings (vsi); + err =ice_vsi_start_all_rx_rings (vsi);if (err)return err;
@@ -4410,7 +4410,7 @@ int ice_down(struct ice_vsi *vsi) vsi->vsi_num, tx_err); } - rx_err =ice_vsi_stop_rx_rings (vsi); + rx_err =ice_vsi_stop_all_rx_rings (vsi);if (rx_err)netdev_err (vsi->netdev,"Failed stop Rx rings, VSI %d error %d\n" , vsi->vsi_num, rx_err);
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +4 -3
@@ -271,7 +271,7 @@ static void ice_dis_vf_qs(struct ice_vf *vf) vsi = pf->vsi[vf->lan_vsi_idx];ice_vsi_stop_lan_tx_rings (vsi,ICE_NO_RESET , vf->vf_id); -ice_vsi_stop_rx_rings (vsi); +ice_vsi_stop_all_rx_rings (vsi);ice_set_vf_state_qs_dis (vf); }
@@ -2026,7 +2026,7 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)if (test_bit (vf_q_id, vf->rxq_ena))continue ; -if (ice_vsi_ctrl_rx_ring (vsi, true, vf_q_id)) { +if (ice_vsi_ctrl_one_rx_ring (vsi, true, vf_q_id, true)) {dev_err (ice_pf_to_dev (vsi->back),"Failed to enable Rx ring %d on VSI %d\n" , vf_q_id, vsi->vsi_num); v_ret =VIRTCHNL_STATUS_ERR_PARAM ;
@@ -2154,7 +2154,8 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)if (!test_bit (vf_q_id, vf->rxq_ena))continue ; -if (ice_vsi_ctrl_rx_ring (vsi, false, vf_q_id)) { +if (ice_vsi_ctrl_one_rx_ring (vsi, false, vf_q_id, + true)) {dev_err (ice_pf_to_dev (vsi->back),"Failed to stop Rx ring %d on VSI %d\n" , vf_q_id, vsi->vsi_num); v_ret =VIRTCHNL_STATUS_ERR_PARAM ;
drivers/net/ethernet/intel/ice/ice_xsk.c +2 -2
@@ -183,7 +183,7 @@ static int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx)if (err)return err; } - err =ice_vsi_ctrl_rx_ring (vsi, false, q_idx); + err =ice_vsi_ctrl_one_rx_ring (vsi, false, q_idx, true);if (err)return err;
@@ -243,7 +243,7 @@ static int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx)ice_qvec_cfg_msix (vsi, q_vector); - err =ice_vsi_ctrl_rx_ring (vsi, true, q_idx); + err =ice_vsi_ctrl_one_rx_ring (vsi, true, q_idx, true);if (err) goto free_buf;
Signature · 1 line
2.20.1
Bowers
PATCH 6/15 ice: Add support to enable/disable all Rx queues before waiting
Quoted 33 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:21 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 06/15] ice: Add support to enable/disable all Rx queues before waitingFrom: Brett Creeley <[email protected]>
Currently when we enable/disable all Rx queues we do the following sequence for each Rx queue and then move to the next queue.
1. Enable/Disable the Rx queue via register write.
2. Read the configuration register to determine if the Rx queue was enabled/disabled successfully.In some cases enabling/disabling queue 0 fails because of step 2 above. Fix this by doing step 1 for all of the Rx queues and then step 2 for all of the Rx queues.
Also, there are cases where we enable/disable a single queue (i.e. SR-IOV and XDP) so add a new function that does step 1 and 2 above with a read flush in between.
This change also required a single Rx queue to be enabled/disabled with and without waiting for the change to propagate through hardware. Fix this by adding a boolean wait flag to the necessary functions.
Also, add the keywords "one" and "all" to distinguish between enabling/disabling a single Rx queue and all Rx queues respectively.
Signed-off-by Brett Creeley <[email protected]>
Quoted 10 lines
--- drivers/net/ethernet/intel/ice/ice_base.c | 42 ++++++++++++++----- drivers/net/ethernet/intel/ice/ice_base.h | 4 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 4 +- drivers/net/ethernet/intel/ice/ice_lib.c | 32 +++++++++----- drivers/net/ethernet/intel/ice/ice_lib.h | 4 +- drivers/net/ethernet/intel/ice/ice_main.c | 4 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 7 ++-- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +- 8 files changed, 67 insertions(+), 34 deletions(-)
Tony Nguyen
maintainerPATCH 7/15 ice: Fix implicit queue mapping mode in ice_vsi_get_qs
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently in ice_vsi_get_qs() we set the mapping_mode for Tx and Rx to vsi->[tx|rx]_mapping_mode, but the problem is vsi->[tx|rx]_mapping_mode have not been set yet. This was working because ICE_VSI_MAP_CONTIG is defined to 0. Fix this by being explicit with our mapping mode by initializing the Tx and Rx structure's mapping_mode to ICE_VSI_MAP_CONTIG and then setting the vsi->[tx|rx]_mapping_mode to the [tx|rx]_qs_cfg.mapping_mode values.
Also, only assign the vsi->[tx|rx]_mapping_mode when the queues are successfully mapped to the VSI. With this change there was no longer a need to initialize the ret variable to 0 so remove that.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +12 -9
@@ -443,7 +443,7 @@ static int ice_vsi_get_qs(struct ice_vsi *vsi) .scatter_count = ICE_MAX_SCATTER_TXQS, .vsi_map = vsi->txq_map, .vsi_map_offset = 0, - .mapping_mode = vsi->tx_mapping_mode + .mapping_mode = ICE_VSI_MAP_CONTIG };struct ice_qs_cfg rx_qs_cfg = { .qs_mutex = &pf->avail_q_mutex,
@@ -453,18 +453,21 @@ static int ice_vsi_get_qs(struct ice_vsi *vsi) .scatter_count = ICE_MAX_SCATTER_RXQS, .vsi_map = vsi->rxq_map, .vsi_map_offset = 0, - .mapping_mode = vsi->rx_mapping_mode + .mapping_mode = ICE_VSI_MAP_CONTIG }; -int ret =0 ; - - vsi->tx_mapping_mode =ICE_VSI_MAP_CONTIG ; - vsi->rx_mapping_mode =ICE_VSI_MAP_CONTIG ; +int ret; ret =__ice_vsi_get_qs (&tx_qs_cfg); -if (!ret) - ret =__ice_vsi_get_qs (&rx_qs_cfg); +if (ret) +return ret; + vsi->tx_mapping_mode = tx_qs_cfg.mapping_mode; -return ret; + ret =__ice_vsi_get_qs (&rx_qs_cfg); +if (ret) +return ret; + vsi->rx_mapping_mode = rx_qs_cfg.mapping_mode; + +return 0 ; }/**
Signature · 1 line
2.20.1
Bowers
PATCH 7/15 ice: Fix implicit queue mapping mode in ice_vsi_get_qs
Quoted 19 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 07/15] ice: Fix implicit queue mapping mode inice_vsi_get_qsFrom: Brett Creeley <[email protected]>
Currently in
ice_vsi_get_qs()we set themapping_modefor Tx and Rx to vsi->[tx|rx]_mapping_mode, but the problem is vsi-Quoted 1 line
[tx|rx]_mapping_mode
have not been set yet. This was working because
ICE_VSI_MAP_CONTIGis defined to 0. Fix this by being explicit with our mapping mode by initializing the Tx and Rx structure'smapping_modetoICE_VSI_MAP_CONTIGand then setting the vsi->[tx|rx]_mapping_mode to the [tx|rx]_qs_cfg.mapping_mode values.
Quoted 8 lines
Also, only assign the vsi->[tx|rx]_mapping_mode when the queues are successfully mapped to the VSI. With this change there was no longer a need to initialize the ret variable to 0 so remove that.
Signed-off-by Brett Creeley <[email protected]>--- drivers/net/ethernet/intel/ice/ice_lib.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
Tony Nguyen
maintainerPATCH 8/15 ice: Handle LAN overflow event for VF queues
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently we are not handling LAN overflow events. There can be cases where LAN overflow events occur on VF queues, especially with Link Flow Control (LFC) enabled on the controlling PF. In order to recover from the LAN overflow event caused by a VF we need to determine if the queue belongs to a VF and reset that VF accordingly.
The struct ice_aqc_event_lan_overflow returns a copy of the GLDCB_RTCTQ register, which tells us what the queue index is in the global/device space. The global queue index needs to first be converted to a PF space queue index and then it can be used to find if a VF owns it.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 11 ++++ .../net/ethernet/intel/ice/ice_hw_autogen.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 3 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 66 +++++++++++++++++++ .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 4 ++ 5 files changed, 86 insertions(+)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +11 -0
@@ -1692,6 +1692,13 @@ struct ice_aqc_get_pkg_info_resp {struct ice_aqc_get_pkg_info pkg_info[1 ]; }; +/* Lan Queue Overflow Event (direct, 0x1001) */ +struct ice_aqc_event_lan_overflow { +__le32 prtdcb_ruptq; +__le32 qtx_ctl; +u8 reserved[8 ]; +}; +/** * struct ice_aq_desc - Admin Queue (AQ) descriptor * @flags: ICE_AQ_FLAG_* flags
@@ -1762,6 +1769,7 @@ struct ice_aq_desc {struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;struct ice_aqc_set_event_mask set_event_mask;struct ice_aqc_get_link_status get_link_status; +struct ice_aqc_event_lan_overflow lan_overflow; } params; };
@@ -1893,6 +1901,9 @@ enum ice_adminq_opc { ice_aqc_opc_update_pkg =0x0C42 , ice_aqc_opc_get_pkg_info_list =0x0C43 , +/* Standalone Commands/Events */ + ice_aqc_opc_event_lan_overflow =0x1001 , +/* debug commands */ ice_aqc_opc_fw_logging =0xFF09 , ice_aqc_opc_fw_logging_info = 0xFF10,
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +2 -0
@@ -287,6 +287,8 @@#define GL_PWR_MODE_CTL 0x000B820C#define GL_PWR_MODE_CTL_CAR_MAX_BW_S 30#define GL_PWR_MODE_CTL_CAR_MAX_BW_M ICE_M(0x3, 30) +#define GLDCB_RTCTQ_RXQNUM_S 0 +#define GLDCB_RTCTQ_RXQNUM_M ICE_M(0x7FF, 0)#define GLPRT_BPRCL (_i) (0x00381380 + ((_i) * 8))#define GLPRT_BPTCL (_i) (0x00381240 + ((_i) * 8))#define GLPRT_CRCERRS (_i) (0x00380100 + ((_i) * 8))
drivers/net/ethernet/intel/ice/ice_main.c +3 -0
@@ -1032,6 +1032,9 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)if (ice_handle_link_event (pf, &event))dev_err (dev,"Could not handle link event\n" );break ; +case ice_aqc_opc_event_lan_overflow: +ice_vf_lan_overflow_event (pf, &event); +break ;case ice_mbx_opc_send_msg_to_pf:ice_vc_process_vf_msg (pf, &event);break ;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +66 -0
72 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +4 -0
@@ -122,6 +122,9 @@ void ice_set_vf_state_qs_dis(struct ice_vf *vf);int ice_get_vf_stats (struct net_device *netdev,int vf_id,struct ifla_vf_stats *vf_stats); +void +ice_vf_lan_overflow_event (struct ice_pf *pf,struct ice_rq_event_info *event); +#else /* CONFIG_PCI_IOV */ #define ice_process_vflr_event (pf) do {} while (0)#define ice_free_vfs (pf) do {} while (0)
@@ -129,6 +132,7 @@ ice_get_vf_stats(struct net_device *netdev, int vf_id,#define ice_vc_notify_link_state (pf) do {} while (0)#define ice_vc_notify_reset (pf) do {} while (0)#define ice_set_vf_state_qs_dis (vf) do {} while (0) +#define ice_vf_lan_overflow_event (pf, event) do {} while (0) static inline bool ice_reset_all_vfs(struct ice_pf __always_unused *pf,
Signature · 1 line
2.20.1
Bowers
PATCH 8/15 ice: Handle LAN overflow event for VF queues
Quoted 23 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 08/15] ice: Handle LAN overflow event for VF queuesFrom: Brett Creeley <[email protected]>
Currently we are not handling LAN overflow events. There can be cases where LAN overflow events occur on VF queues, especially with Link Flow Control (LFC) enabled on the controlling PF. In order to recover from the LAN overflow event caused by a VF we need to determine if the queue belongs to a VF and reset that VF accordingly.
The struct
ice_aqc_event_lan_overflowreturns a copy of theGLDCB_RTCTQregister, which tells us what the queue index is in the global/device space. The global queue index needs to first be converted to a PF space queue index and then it can be used to find if a VF owns it.Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 7 lines
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 11 ++++ .../net/ethernet/intel/ice/ice_hw_autogen.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 3 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 66 +++++++++++++++++++ .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 4 ++ 5 files changed, 86 insertions(+)
Tony Nguyen
maintainerPATCH 9/15 ice: Fix and refactor Rx queue disable for VFs
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently when a VF driver sends the PF a request to disable Rx queues we will disable them one at a time, even if the VF driver sent us a batch of queues to disable. This is causing issues where the Rx queue disable times out with LFC enabled. This can be improved by detecting when the VF is trying to disable all of its queues.
Also remove the variable num_qs_ena from the ice_vf structure as it was only used to see if there were no Rx and no Tx queues active. Instead add a function that checks if both the vf->rxq_ena and vf->txq_ena bitmaps are empty.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 36 ++++++++++++++----- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 1 - 2 files changed, 27 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +27 -9
@@ -90,6 +90,19 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe, } } +/** +* ice_vf_has_no_qs_ena - check if the VF has any Rx or Tx queues enabled +* @vf: the VF to check +* +* Returns true if the VF has no Rx and no Tx queues enabled and returns false +* otherwise +*/ +static bool ice_vf_has_no_qs_ena (struct ice_vf *vf) +{ +return (!bitmap_weight (vf->rxq_ena,ICE_MAX_BASE_QS_PER_VF ) && + !bitmap_weight (vf->txq_ena,ICE_MAX_BASE_QS_PER_VF )); +} +/** * ice_is_vf_link_up - check if the VF's link is up * @vf: VF to check if link is up
@@ -101,7 +114,7 @@ static bool ice_is_vf_link_up(struct ice_vf *vf)if (ice_check_vf_init (pf, vf))return false; -if (!vf->num_qs_ena) +if (ice_vf_has_no_qs_ena (vf))return false;else if (vf->link_forced)return vf->link_up;
@@ -255,7 +268,6 @@ void ice_set_vf_state_qs_dis(struct ice_vf *vf)/* Clear Rx/Tx enabled queues flag */ bitmap_zero (vf->txq_ena,ICE_MAX_BASE_QS_PER_VF );bitmap_zero (vf->rxq_ena,ICE_MAX_BASE_QS_PER_VF ); - vf->num_qs_ena =0 ;clear_bit (ICE_VF_STATE_QS_ENA , vf->vf_states); }
@@ -2100,7 +2112,6 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg) }set_bit (vf_q_id, vf->rxq_ena); - vf->num_qs_ena++; } vsi = pf->vsi[vf->lan_vsi_idx];
@@ -2116,7 +2127,6 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)continue ;set_bit (vf_q_id, vf->txq_ena); - vf->num_qs_ena++; }/* Set flag to indicate that queues are enabled */
@@ -2203,13 +2213,22 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)/* Clear enabled queues flag */ clear_bit (vf_q_id, vf->txq_ena); - vf->num_qs_ena--; } } -if (vqs->rx_queues) { - q_map = vqs->rx_queues; + q_map = vqs->rx_queues; +/* speed up Rx queue disable by batching them if possible */ +if (q_map && +bitmap_equal (&q_map, vf->rxq_ena,ICE_MAX_BASE_QS_PER_VF )) { +if (ice_vsi_stop_all_rx_rings (vsi)) { +dev_err (ice_pf_to_dev (vsi->back),"Failed to stop all Rx rings on VSI %d\n" , + vsi->vsi_num); + v_ret =VIRTCHNL_STATUS_ERR_PARAM ; + goto error_param; + } +bitmap_zero (vf->rxq_ena,ICE_MAX_BASE_QS_PER_VF ); + }else if (q_map) {for_each_set_bit (vf_q_id, &q_map,ICE_MAX_BASE_QS_PER_VF ) {if (!ice_vc_isvalid_q_id (vf, vqs->vsi_id, vf_q_id)) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ;
@@ -2230,12 +2249,11 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)/* Clear enabled queues flag */ clear_bit (vf_q_id, vf->rxq_ena); - vf->num_qs_ena--; } }/* Clear enabled queues flag */ -if (v_ret ==VIRTCHNL_STATUS_SUCCESS && !vf->num_qs_ena) +if (v_ret ==VIRTCHNL_STATUS_SUCCESS &&ice_vf_has_no_qs_ena (vf))clear_bit (ICE_VF_STATE_QS_ENA , vf->vf_states); error_param:
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +0 -1
@@ -90,7 +90,6 @@ struct ice_vf {u8 num_req_qs;/* num of queue pairs requested by VF */ u16 num_mac;u16 num_vf_qs;/* num of queue configured per VF */ -u16 num_qs_ena;/* total num of Tx/Rx queue enabled */ };#ifdef CONFIG_PCI_IOV
Signature · 1 line
2.20.1
Bowers
PATCH 9/15 ice: Fix and refactor Rx queue disable for VFs
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 09/15] ice: Fix and refactor Rx queue disable for VFsFrom: Brett Creeley <[email protected]>
Currently when a VF driver sends the PF a request to disable Rx queues we will disable them one at a time, even if the VF driver sent us a batch of queues to disable. This is causing issues where the Rx queue disable times out with LFC enabled. This can be improved by detecting when the VF is trying to disable all of its queues.
Also remove the variable
num_qs_enafrom theice_vfstructure as it was only used to see if there were no Rx and no Tx queues active. Instead add a function that checks if both thevf->rxq_enaandvf->txq_enabitmaps are empty.
Quoted 5 lines
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 36 ++++++++++++++----- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 1 - 2 files changed, 27 insertions(+), 10 deletions(-)
Tony Nguyen
maintainerPATCH 10/15 ice: Fix virtchnl_queue_select bitmap validation
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently in ice_vc_ena_qs_msg() we are incorrectly validating the virtchnl queue select bitmaps. The virtchnl_queue_select rx_queues and tx_queue bitmap is being compared against ICE_MAX_BASE_QS_PER_VF, but the problem is that these bitmaps can have a value greater than ICE_MAX_BASE_QS_PER_VF. Fix this by comparing the bitmaps against BIT(ICE_MAX_BASE_QS_PER_VF).
Also, add the function ice_vc_validate_vqs_bitmaps() that checks to see if both virtchnl_queue_select bitmaps are empty along with checking that the bitmaps only have valid bits set. This function can then be used in both the queue enable and disable flows.
Arkady Gilinksky's patch on the intel-wired-lan mailing list ("i40e/iavf: Fix msg interface between VF and PF") made me aware of this issue.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +18 -8
@@ -2045,6 +2045,22 @@ static int ice_vc_get_stats_msg(struct ice_vf *vf, u8 *msg) (u8 *)&stats, sizeof(stats)); } +/** +* ice_vc_validate_vqs_bitmaps - validate Rx/Tx queue bitmaps from VIRTCHNL +* @vqs: virtchnl_queue_select structure containing bitmaps to validate +* +* Return true on successful validation, else false +*/ +static bool ice_vc_validate_vqs_bitmaps (struct virtchnl_queue_select *vqs) +{ +if ((!vqs->rx_queues && !vqs->tx_queues) || + vqs->rx_queues >=BIT (ICE_MAX_BASE_QS_PER_VF ) || + vqs->tx_queues >=BIT (ICE_MAX_BASE_QS_PER_VF )) +return false; + +return true; +} +/** * ice_vc_ena_qs_msg * @vf: pointer to the VF info
@@ -2072,13 +2088,7 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg) goto error_param; } -if (!vqs->rx_queues && !vqs->tx_queues) { - v_ret =VIRTCHNL_STATUS_ERR_PARAM ; - goto error_param; - } - -if (vqs->rx_queues >ICE_MAX_BASE_QS_PER_VF || - vqs->tx_queues >ICE_MAX_BASE_QS_PER_VF ) { +if (!ice_vc_validate_vqs_bitmaps (vqs)) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ; goto error_param; }
@@ -2168,7 +2178,7 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg) goto error_param; } -if (!vqs->rx_queues && !vqs->tx_queues) { +if (!ice_vc_validate_vqs_bitmaps (vqs)) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ; goto error_param; }
Signature · 1 line
2.20.1
Bowers
PATCH 10/15 ice: Fix virtchnl_queue_select bitmap validation
Quoted 22 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 10/15] ice: Fixvirtchnl_queue_selectbitmap validationFrom: Brett Creeley <[email protected]>
Currently in
ice_vc_ena_qs_msg()we are incorrectly validating the virtchnl queue select bitmaps. Thevirtchnl_queue_selectrx_queuesandtx_queuebitmap is being compared againstICE_MAX_BASE_QS_PER_VF, but the problem is that these bitmaps can have a value greater thanICE_MAX_BASE_QS_PER_VF. Fix this by comparing the bitmaps againstBIT(ICE_MAX_BASE_QS_PER_VF).Also, add the function
ice_vc_validate_vqs_bitmaps()that checks to see if bothvirtchnl_queue_selectbitmaps are empty along with checking that the bitmaps only have valid bits set. This function can then be used in both the queue enable and disable flows.
Quoted 8 lines
Arkady Gilinksky's patch on the intel-wired-lan mailing list ("i40e/iavf: Fix msg interface between VF and PF") made me aware of this issue.
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-)
Tony Nguyen
maintainerPATCH 11/15 ice: remove unnecessary fallthrough comments
In reply to Tony NguyenFrom: Bruce Allan <[email protected]>
Fallthrough comments are used to explicitly indicate the code is intended to flow from one case statement to the next in a switch statement rather than break out of the switch statement. They are only needed when a case has one or more statements to execute before falling through to the next case, not when there is a list of cases for which the same statement(s) should be executed.
--- drivers/net/ethernet/intel/ice/ice_base.c | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 -- drivers/net/ethernet/intel/ice/ice_lib.c | 2 -- drivers/net/ethernet/intel/ice/ice_main.c | 2 -- drivers/net/ethernet/intel/ice/ice_sriov.c | 2 -- drivers/net/ethernet/intel/ice/ice_txrx.c | 1 - 6 files changed, 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +0 -1
@@ -247,7 +247,6 @@ ice_setup_tx_ctx(struct ice_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf_q)*/ switch (vsi->type) {case ICE_VSI_LB : -/* fall through */ case ICE_VSI_PF : tlan_ctx->vmvf_type =ICE_TLAN_CTX_VMVF_TYPE_PF ;break ;
drivers/net/ethernet/intel/ice/ice_ethtool.c +0 -2
@@ -1091,7 +1091,6 @@ ice_get_fecparam(struct net_device *netdev, struct ethtool_fecparam *fecparam) fecparam->active_fec =ETHTOOL_FEC_BASER ;break ;case ICE_AQ_LINK_25G_RS_528_FEC_EN : -/* fall through */ case ICE_AQ_LINK_25G_RS_544_FEC_EN : fecparam->active_fec =ETHTOOL_FEC_RS ;break ;
@@ -1781,7 +1780,6 @@ ice_get_settings_link_up(struct ethtool_link_ksettings *ks, Asym_Pause);break ;case ICE_FC_PFC : -/* fall through */ default :ethtool_link_ksettings_del_link_mode (ks, lp_advertising, Pause); ethtool_link_ksettings_del_link_mode(ks, lp_advertising,
drivers/net/ethernet/intel/ice/ice_lib.c +0 -2
@@ -121,7 +121,6 @@ static void ice_vsi_set_num_desc(struct ice_vsi *vsi) {switch (vsi->type) {case ICE_VSI_PF : -/* fall through */ case ICE_VSI_LB : vsi->num_rx_desc =ICE_DFLT_NUM_RX_DESC ; vsi->num_tx_desc =ICE_DFLT_NUM_TX_DESC ;
@@ -828,7 +827,6 @@ static int ice_vsi_init(struct ice_vsi *vsi, bool init_vsi) ctxt->info = vsi->info;switch (vsi->type) {case ICE_VSI_LB : -/* fall through */ case ICE_VSI_PF : ctxt->flags =ICE_AQ_VSI_TYPE_PF ;break ;
drivers/net/ethernet/intel/ice/ice_main.c +0 -2
@@ -709,7 +709,6 @@ void ice_print_link_msg(struct ice_vsi *vsi, bool isup)/* Get FEC mode based on negotiated link info */ switch (vsi->port_info->phy.link_info.fec_info) {case ICE_AQ_LINK_25G_RS_528_FEC_EN : -/* fall through */ case ICE_AQ_LINK_25G_RS_544_FEC_EN : fec ="RS-FEC" ;break ;
@@ -2981,7 +2980,6 @@ ice_log_pkg_init(struct ice_hw *hw, enum ice_status *status) }break ;case ICE_ERR_BUF_TOO_SHORT : -/* fall-through */ case ICE_ERR_CFG :dev_err (dev,"The DDP package file is invalid. Entering Safe Mode.\n" );break ;
drivers/net/ethernet/intel/ice/ice_sriov.c +0 -2
@@ -121,9 +121,7 @@ u32 ice_conv_link_speed_to_virtchnl(bool adv_link_support, u16 link_speed) speed = (u32 )VIRTCHNL_LINK_SPEED_25GB ;break ;case ICE_AQ_LINK_SPEED_40GB : -/* fall through */ case ICE_AQ_LINK_SPEED_50GB : -/* fall through */ case ICE_AQ_LINK_SPEED_100GB : speed = (u32 )VIRTCHNL_LINK_SPEED_40GB ;break ;
drivers/net/ethernet/intel/ice/ice_txrx.c +0 -1
@@ -1188,7 +1188,6 @@ ice_adjust_itr_by_size_and_speed(struct ice_port_info *port_info, avg_pkt_size + 640);break ;case ICE_AQ_LINK_SPEED_10GB : -/* fall through */ default : itr +=DIV_ROUND_UP (170 * (avg_pkt_size +24 ), avg_pkt_size +640 );
Signature · 1 line
2.20.1
Bowers
PATCH 11/15 ice: remove unnecessary fallthrough comments
Quoted 19 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 11/15] ice: remove unnecessary fallthrough commentsFrom: Bruce Allan <[email protected]>
Fallthrough comments are used to explicitly indicate the code is intended to flow from one case statement to the next in a switch statement rather than break out of the switch statement. They are only needed when a case has one or more statements to execute before falling through to the next case, not when there is a list of cases for which the same statement(s) should be executed.
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 8 lines
--- drivers/net/ethernet/intel/ice/ice_base.c | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 -- drivers/net/ethernet/intel/ice/ice_lib.c | 2 -- drivers/net/ethernet/intel/ice/ice_main.c | 2 -- drivers/net/ethernet/intel/ice/ice_sriov.c | 2 -- drivers/net/ethernet/intel/ice/ice_txrx.c | 1 - 6 files changed, 10 deletions(-)
Tony Nguyen
maintainerPATCH 12/15 ice: replace "fallthrough" comments with fallthrough reserved word
In reply to Tony NguyenFrom: Bruce Allan <[email protected]>
"fallthrough" comments are used in switch case statements to explicitly indicate the code is intended to fall through to the following statement. Different variants of "fallthough" are acceptable, e.g. "fall through", "fallthrough", "Fall-through". The GCC compiler has an optional warning (-Wimplicit-fallthrough[=n]) to warn when such a comment is not present; the default version of which is enabled when compiling the Linux kernel.
There have been recent discussions in kernel mailing lists regarding replacing non-standardized "fallthrough" comments with the pseudo-reserved word 'fallthrough' which will be defined as __attribute__ ((fallthrough)) for versions of gcc that support it (i.e. gcc 7 and newer) or as a nop for versions that do not. Replace "fallthrough" comments with fallthrough reserved word.
--- drivers/net/ethernet/intel/ice/ice_common.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_switch.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_txrx.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +2 -2
@@ -1182,7 +1182,7 @@ ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf,case ice_aqc_opc_release_res:if (le16_to_cpu (cmd->res_id) ==ICE_AQC_RES_ID_GLBL_LOCK )break ; -/* fall-through */ + fallthrough;default :mutex_lock (&ice_global_cfg_lock_sw); lock_acquired = true;
@@ -2719,7 +2719,7 @@ __ice_aq_get_set_rss_lut(struct ice_hw *hw, u16 vsi_id, u8 lut_type, u8 *lut,ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M ;break ; } -/* fall-through */ + fallthrough;default : status =ICE_ERR_PARAM ; goto ice_aq_get_set_rss_lut_exit;
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -3011,7 +3011,7 @@ ice_log_pkg_init(struct ice_hw *hw, enum ice_status *status)default :break ; } -/* fall-through */ + fallthrough;default :dev_err (dev,"An unknown error (%d) occurred when loading the DDP package. Entering Safe Mode.\n" , *status);
drivers/net/ethernet/intel/ice/ice_switch.c +2 -2
@@ -787,7 +787,7 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,break ;case ICE_SW_LKUP_ETHERTYPE_MAC : daddr = f_info->l_data.ethertype_mac.mac_addr; -/* fall-through */ + fallthrough;case ICE_SW_LKUP_ETHERTYPE : off = (__force __be16 *)(eth_hdr +ICE_ETH_ETHTYPE_OFFSET ); *off =cpu_to_be16 (f_info->l_data.ethertype_mac.ethertype);
@@ -798,7 +798,7 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,break ;case ICE_SW_LKUP_PROMISC_VLAN : vlan_id = f_info->l_data.mac_vlan.vlan_id; -/* fall-through */ + fallthrough;case ICE_SW_LKUP_PROMISC : daddr = f_info->l_data.mac_vlan.mac_addr;break ;
drivers/net/ethernet/intel/ice/ice_txrx.c +2 -2
@@ -453,10 +453,10 @@ ice_run_xdp(struct ice_ring *rx_ring, struct xdp_buff *xdp,break ;default :bpf_warn_invalid_xdp_action (act); -/* fallthrough -- not supported action */ + fallthrough;case XDP_ABORTED :trace_xdp_exception (rx_ring->netdev, xdp_prog, act); -/* fallthrough -- handle aborts by dropping frame */ + fallthrough;case XDP_DROP : result =ICE_XDP_CONSUMED ;break ;
drivers/net/ethernet/intel/ice/ice_xsk.c +2 -2
@@ -816,10 +816,10 @@ ice_run_xdp_zc(struct ice_ring *rx_ring, struct xdp_buff *xdp)break ;default :bpf_warn_invalid_xdp_action (act); -/* fallthrough -- not supported action */ + fallthrough;case XDP_ABORTED :trace_xdp_exception (rx_ring->netdev, xdp_prog, act); -/* fallthrough -- handle aborts by dropping frame */ + fallthrough;case XDP_DROP : result =ICE_XDP_CONSUMED ;break ;
Signature · 1 line
2.20.1
Bowers
PATCH 12/15 ice: replace "fallthrough" comments with fallthrough reserved word
Quoted 26 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 12/15] ice: replace "fallthrough" comments with fallthrough reserved wordFrom: Bruce Allan <[email protected]>
"fallthrough" comments are used in switch case statements to explicitly indicate the code is intended to fall through to the following statement. Different variants of "fallthough" are acceptable, e.g. "fall through", "fallthrough", "Fall-through". The GCC compiler has an optional warning (-Wimplicit-fallthrough[=n]) to warn when such a comment is not present; the default version of which is enabled when compiling the Linux kernel.
There have been recent discussions in kernel mailing lists regarding replacing non-standardized "fallthrough" comments with the pseudo-reserved word 'fallthrough' which will be defined as
__attribute__((fallthrough)) for versions of gcc that support it (i.e. gcc 7 and newer) or as a nop for versions that do not. Replace "fallthrough" comments with fallthrough reserved word.Signed-off-by Bruce Allan <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 7 lines
--- drivers/net/ethernet/intel/ice/ice_common.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_switch.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_txrx.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-)
Tony Nguyen
maintainerPATCH 13/15 ice: use proper format for function pointer as a function parameter
In reply to Tony NguyenFrom: Bruce Allan <[email protected]>
Compiling with gcc-9.2.1 with W=1 points out warnings about the improper function parameter list. Fix it.
--- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_xsk.c +1 -1
@@ -609,7 +609,7 @@ ice_alloc_buf_slow_zc(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf)*/ static bool ice_alloc_rx_bufs_zc (struct ice_ring *rx_ring,int count, -bool alloc (struct ice_ring *,struct ice_rx_buf *)) +bool (*alloc)(struct ice_ring *,struct ice_rx_buf *)) {union ice_32b_rx_flex_desc *rx_desc;u16 ntu = rx_ring->next_to_use;
Signature · 1 line
2.20.1
Bowers
PATCH 13/15 ice: use proper format for function pointer as a function parameter
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 13/15] ice: use proper format for function pointer as a function parameterFrom: Bruce Allan <[email protected]>
Quoted 7 lines
Compiling with gcc-9.2.1 with W=1 points out warnings about the improper function parameter list. Fix it.
Signed-off-by Bruce Allan <[email protected]>--- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH 14/15 ice: add function argument description to function header comment
In reply to Tony NguyenFrom: Bruce Allan <[email protected]>
Commit 0290bd291cc0 ("netdev: pass the stuck queue to the timeout handler") introduced a new argument to the function but missed adding the description of the argument to the function header comment. Add it now.
--- drivers/net/ethernet/intel/ice/ice_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
@@ -5121,6 +5121,7 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,/** * ice_tx_timeout - Respond to a Tx Hang * @netdev: network interface device structure +* @txqueue: Tx queue */ static void ice_tx_timeout (struct net_device *netdev,unsigned int txqueue) {
Signature · 1 line
2.20.1
Bowers
PATCH 14/15 ice: add function argument description to function header comment
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 14/15] ice: add function argument description to function header commentFrom: Bruce Allan <[email protected]>
Quoted 8 lines
Commit
0290bd291cc0("netdev: pass the stuck queue to the timeout handler") introduced a new argument to the function but missed adding the description of the argument to the function header comment. Add it now.Signed-off-by Bruce Allan <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 1 + 1 file changed, 1 insertion(+)
Tony Nguyen
maintainerPATCH 15/15 ice: use true/false for bool types
In reply to Tony NguyenFrom: Bruce Allan <[email protected]>
Subject says it all.
--- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_xsk.c +1 -1
@@ -841,8 +841,8 @@ int ice_clean_rx_irq_zc(struct ice_ring *rx_ring, int budget)unsigned int total_rx_bytes =0 , total_rx_packets =0 ;u16 cleaned_count =ICE_DESC_UNUSED (rx_ring);unsigned int xdp_xmit =0 ; +bool failure = false;struct xdp_buff xdp; -bool failure =0 ; xdp.rxq = &rx_ring->xdp_rxq;
Signature · 1 line
2.20.1
Bowers
PATCH 15/15 ice: use true/false for bool types
Quoted 7 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:22 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 15/15] ice: use true/false for bool types
Quoted 8 lines
From: Bruce Allan <[email protected]>
Subject says it all.
Signed-off-by Bruce Allan <[email protected]>--- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Bowers
PATCH 1/15 ice: Add initial support for QinQ
In reply to Tony NguyenQuoted 22 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Wednesday, January 22, 2020 7:21 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S38 01/15] ice: Add initial support for QinQFrom: Brett Creeley <[email protected]>
Allow support for S-Tag + C-Tag VLAN traffic by disabling pruning when there are no
0x8100VLAN interfaces currently created on top of the PF. When an0x8100VLAN interface is configured, enable pruning and only support single and double C-Tag VLAN traffic. If all of the0x8100interfaces that were created on top of the PF are removed via ethtool -K <iface> rx- vlan-filter off or via ip tools, then disable pruning and allow S-Tag + C-Tag traffic again.Add VLAN 0 filter by default for the PF. This is because a bridge sets the
default_pvidto 1, sends the request down toice_vlan_rx_add_vid(), and we never get the request to add VLAN 0 via the 8021q module which causes all untagged traffic to be dropped.
Quoted 8 lines
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_lib.c | 43 +++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_lib.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 21 ++++++--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 14 +++--- 4 files changed, 63 insertions(+), 17 deletions(-)