ice: add support for enabling/disabling single queues
Subsystems (2)
Tony Nguyen
maintainerPATCH 1/15 ice: add support for enabling/disabling single queues
From: Maciej Fijalkowski <[email protected]>
Refactor the queue handling functions that are going through queue arrays in a way that the logic done for a single queue is pulled out and it will be called for each ring when traversing ring array. This implies that when disabling Tx rings we won't fill up q_ids, q_teids and q_handles arrays. Drop also 'offset' parameter; the value from vsi's txq_map is stored in ring->reg_idx and that drops the need for mentioned parameter. Introduce the ice_vsi_cfg_txq, ice_vsi_stop_tx_ring and ice_vsi_ctrl_rx_ring that are the functions with pulled out logic.
There's several Tx queue meta data (q_id, q_handle, q_teid and other) that need to be set up during Tx queue disablement, so let's as well add a helper structure that wraps it up and a function that will be filling it up.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 340 +++++++++++++---------- drivers/net/ethernet/intel/ice/ice_lib.h | 18 +- 2 files changed, 213 insertions(+), 145 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +197 -143
@@ -191,41 +191,55 @@ static int ice_pf_rxq_wait(struct ice_pf *pf, int pf_q, bool ena) }/** -* ice_vsi_ctrl_rx_rings - Start or stop a VSI's Rx rings +* ice_vsi_ctrl_rx_ring - Start or stop a VSI's Rx ring * @vsi: the VSI being configured * @ena: start or stop the Rx rings +* @rxq_idx: Rx queue index */ -static int ice_vsi_ctrl_rx_rings (struct ice_vsi *vsi,bool ena) +static int ice_vsi_ctrl_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;struct ice_hw *hw = &pf->hw; -int i, ret =0 ; +int ret =0 ; +u32 rx_reg; -for (i =0 ; i < vsi->num_rxq; i++) { -int pf_q = vsi->rxq_map[i]; -u32 rx_reg; + rx_reg =rd32 (hw,QRX_CTRL (pf_q)); - rx_reg =rd32 (hw,QRX_CTRL (pf_q)); +/* Skip if the queue is already in the requested state */ +if (ena == !!(rx_reg &QRX_CTRL_QENA_STAT_M )) +return 0 ; -/* Skip if the queue is already in the requested state */ -if (ena == !!(rx_reg &QRX_CTRL_QENA_STAT_M )) -continue ; +/* turn on/off the queue */ +if (ena) + rx_reg |=QRX_CTRL_QENA_REQ_M ; +else + rx_reg &= ~QRX_CTRL_QENA_REQ_M ; +wr32 (hw,QRX_CTRL (pf_q), rx_reg); -/* turn on/off the queue */ -if (ena) - rx_reg |=QRX_CTRL_QENA_REQ_M ; -else - 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 (&pf->pdev->dev, +"VSI idx %d Rx ring %d %sable timeout\n" , + vsi->idx, pf_q, (ena ?"en" :"dis" )); -/* wait for the change to finish */ - ret =ice_pf_rxq_wait (pf, pf_q, ena); -if (ret) { -dev_err (&pf->pdev->dev, -"VSI idx %d Rx ring %d %sable timeout\n" , - vsi->idx, pf_q, (ena ?"en" :"dis" )); +return ret; +} + +/** +* ice_vsi_ctrl_rx_rings - Start or stop a VSI's Rx rings +* @vsi: the VSI being configured +* @ena: start or stop the Rx rings +*/ +static int ice_vsi_ctrl_rx_rings (struct ice_vsi *vsi,bool ena) +{ +int i, ret =0 ; + +for (i =0 ; i < vsi->num_rxq; i++) { + ret =ice_vsi_ctrl_rx_ring (vsi, ena, i); +if (ret)break ; - } }return ret;
@@ -1668,6 +1682,62 @@ int ice_vsi_cfg_rxqs(struct ice_vsi *vsi)return 0 ; } +/** +* ice_vsi_cfg_txq - Configure single Tx queue +* @vsi: the VSI that queue belongs to +* @ring: Tx ring to be configured +* @tc_q_idx: queue index within given TC +* @qg_buf: queue group buffer +* @tc: TC that Tx ring belongs to +*/ +static int +ice_vsi_cfg_txq (struct ice_vsi *vsi,struct ice_ring *ring,u16 tc_q_idx, +struct ice_aqc_add_tx_qgrp *qg_buf,u8 tc) +{ +struct ice_tlan_ctx tlan_ctx = {0 }; +struct ice_aqc_add_txqs_perq *txq; +struct ice_pf *pf = vsi->back; +u8 buf_len =sizeof (*qg_buf); +enum ice_status status; +u16 pf_q; + + pf_q = ring->reg_idx; +ice_setup_tx_ctx (ring, &tlan_ctx, pf_q); +/* copy context contents into the qg_buf */ + qg_buf->txqs[0 ].txq_id =cpu_to_le16 (pf_q); +ice_set_ctx ((u8 *)&tlan_ctx, qg_buf->txqs[0 ].txq_ctx, + ice_tlan_ctx_info); + +/* init queue specific tail reg. It is referred as +* transmit comm scheduler queue doorbell. +*/ + ring->tail = pf->hw.hw_addr +QTX_COMM_DBELL (pf_q); + +/* Add unique software queue handle of the Tx queue per +* TC into the VSI Tx ring +*/ + ring->q_handle = tc_q_idx; + + status =ice_ena_vsi_txq (vsi->port_info, vsi->idx, tc, ring->q_handle, +1 , qg_buf, buf_len,NULL ); +if (status) { +dev_err (&pf->pdev->dev, +"Failed to set LAN Tx queue context, error: %d\n" , + status); +return -ENODEV ; + } + +/* Add Tx Queue TEID into the VSI Tx ring from the +* response. This will complete configuring and +* enabling the queue. +*/ + txq = &qg_buf->txqs[0 ]; +if (pf_q ==le16_to_cpu (txq->txq_id)) + ring->txq_teid =le32_to_cpu (txq->q_teid); + +return 0 ; +} +/** * ice_vsi_cfg_txqs - Configure the VSI for Tx * @vsi: the VSI being configured
@@ -1681,20 +1751,16 @@ static int ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings, int offset) { struct ice_aqc_add_tx_qgrp *qg_buf; -struct ice_aqc_add_txqs_perq *txq;struct ice_pf *pf = vsi->back; -u8 num_q_grps, q_idx =0 ; -enum ice_status status; -u16 buf_len, i, pf_q; -int err =0 , tc; +u16 q_idx =0 , i; +int err =0 ; +u8 tc; - buf_len =sizeof (*qg_buf); - qg_buf =devm_kzalloc (&pf->pdev->dev, buf_len,GFP_KERNEL ); + qg_buf =devm_kzalloc (&pf->pdev->dev,sizeof (*qg_buf),GFP_KERNEL );if (!qg_buf)return -ENOMEM ; qg_buf->num_txqs =1 ; - num_q_grps =1 ;/* set up and configure the Tx queues for each enabled TC */ ice_for_each_traffic_class (tc) {
@@ -1702,39 +1768,10 @@ ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings, int offset)break ;for (i =0 ; i < vsi->tc_cfg.tc_info[tc].qcount_tx; i++) { -struct ice_tlan_ctx tlan_ctx = {0 }; - - pf_q = vsi->txq_map[q_idx + offset]; -ice_setup_tx_ctx (rings[q_idx], &tlan_ctx, pf_q); -/* copy context contents into the qg_buf */ - qg_buf->txqs[0 ].txq_id =cpu_to_le16 (pf_q); -ice_set_ctx ((u8 *)&tlan_ctx, qg_buf->txqs[0 ].txq_ctx, - ice_tlan_ctx_info); - -/* init queue specific tail reg. It is referred as -* transmit comm scheduler queue doorbell. -*/ - rings[q_idx]->tail = - pf->hw.hw_addr +QTX_COMM_DBELL (pf_q); - status =ice_ena_vsi_txq (vsi->port_info, vsi->idx, tc, - i, num_q_grps, qg_buf, - buf_len,NULL ); -if (status) { -dev_err (&pf->pdev->dev, -"Failed to set LAN Tx queue context, error: %d\n" , - status); - err = -ENODEV ; + err =ice_vsi_cfg_txq (vsi, rings[q_idx], i + offset, + qg_buf, tc); +if (err) goto err_cfg_txqs; - } - -/* Add Tx Queue TEID into the VSI Tx ring from the -* response. This will complete configuring and -* enabling the queue. -*/ - txq = &qg_buf->txqs[0 ]; -if (pf_q ==le16_to_cpu (txq->txq_id)) - rings[q_idx]->txq_teid = -le32_to_cpu (txq->q_teid); q_idx++; }
@@ -2081,45 +2118,106 @@ void ice_trigger_sw_intr(struct ice_hw *hw, struct ice_q_vector *q_vector) }/** -* ice_vsi_stop_tx_rings - Disable Tx rings +* ice_vsi_stop_tx_ring - Disable single Tx ring * @vsi: the VSI being configured * @rst_src: reset source * @rel_vmvf_num: Relative ID of VF/VM -* @rings: Tx ring array to be stopped -* @offset: offset within vsi->txq_map +* @ring: Tx ring to be stopped +* @txq_meta: Meta data of Tx ring to be stopped */ static int -ice_vsi_stop_tx_rings (struct ice_vsi *vsi,enum ice_disq_rst_src rst_src, -u16 rel_vmvf_num,struct ice_ring **rings,int offset) +ice_vsi_stop_tx_ring (struct ice_vsi *vsi,enum ice_disq_rst_src rst_src, +u16 rel_vmvf_num,struct ice_ring *ring, +struct ice_txq_meta *txq_meta) {struct ice_pf *pf = vsi->back; +struct ice_q_vector *q_vector;struct ice_hw *hw = &pf->hw; -int tc, q_idx =0 , err =0 ; -u16 *q_ids, *q_handles, i;enum ice_status status; -u32 *q_teids, val; +u32 val; -if (vsi->num_txq >ICE_LAN_TXQ_MAX_QDIS ) -return -EINVAL ; +/* clear cause_ena bit for disabled queues */ + val =rd32 (hw,QINT_TQCTL (ring->reg_idx)); + val &= ~QINT_TQCTL_CAUSE_ENA_M ; +wr32 (hw,QINT_TQCTL (ring->reg_idx), val); - q_teids =devm_kcalloc (&pf->pdev->dev, vsi->num_txq,sizeof (*q_teids), -GFP_KERNEL ); -if (!q_teids) -return -ENOMEM ; +/* software is expected to wait for 100 ns */ +ndelay (100 ); - q_ids =devm_kcalloc (&pf->pdev->dev, vsi->num_txq,sizeof (*q_ids), -GFP_KERNEL ); -if (!q_ids) { - err = -ENOMEM ; - goto err_alloc_q_ids; +/* trigger a software interrupt for the vector +* associated to the queue to schedule NAPI handler +*/ + q_vector = ring->q_vector; +if (q_vector) +ice_trigger_sw_intr (hw, q_vector); + + status =ice_dis_vsi_txq (vsi->port_info, txq_meta->vsi_idx, + txq_meta->tc,1 , &txq_meta->q_handle, + &txq_meta->q_id, &txq_meta->q_teid, rst_src, + rel_vmvf_num,NULL ); + +/* if the disable queue command was exercised during an +* active reset flow, ICE_ERR_RESET_ONGOING is returned. +* This is not an error as the reset operation disables +* queues at the hardware level anyway. +*/ +if (status ==ICE_ERR_RESET_ONGOING ) { +dev_dbg (&vsi->back->pdev->dev, +"Reset in progress. LAN Tx queues already disabled\n" ); + }else if (status ==ICE_ERR_DOES_NOT_EXIST ) { +dev_dbg (&vsi->back->pdev->dev, +"LAN Tx queues do not exist, nothing to disable\n" ); + }else if (status) { +dev_err (&vsi->back->pdev->dev, +"Failed to disable LAN Tx queues, error: %d\n" , status); +return -ENODEV ; } - q_handles =devm_kcalloc (&pf->pdev->dev, vsi->num_txq, -sizeof (*q_handles),GFP_KERNEL ); -if (!q_handles) { - err = -ENOMEM ; - goto err_alloc_q_handles; - } +return 0 ; +} + +/** +* ice_fill_txq_meta - Prepare the Tx queue's meta data +* @vsi: VSI that ring belongs to +* @ring: ring that txq_meta will be based on +* @txq_meta: a helper struct that wraps Tx queue's information +* +* Set up a helper struct that will contain all the necessary fields that +* are needed for stopping Tx queue +*/ +static void +ice_fill_txq_meta (struct ice_vsi *vsi,struct ice_ring *ring, +struct ice_txq_meta *txq_meta) +{ +u8 tc =0 ; + +#ifdef CONFIG_DCB + tc = ring->dcb_tc; +#endif /* CONFIG_DCB */ + txq_meta->q_id = ring->reg_idx; + txq_meta->q_teid = ring->txq_teid; + txq_meta->q_handle = ring->q_handle; + txq_meta->vsi_idx = vsi->idx; + txq_meta->tc = tc; +} + +/** +* ice_vsi_stop_tx_rings - Disable Tx rings +* @vsi: the VSI being configured +* @rst_src: reset source +* @rel_vmvf_num: Relative ID of VF/VM +* @rings: Tx ring array to be stopped +*/ +static int +ice_vsi_stop_tx_rings (struct ice_vsi *vsi,enum ice_disq_rst_src rst_src, +u16 rel_vmvf_num,struct ice_ring **rings) +{ +u16 i, q_idx =0 ; +int status; +u8 tc; + +if (vsi->num_txq >ICE_LAN_TXQ_MAX_QDIS ) +return -EINVAL ;/* set up the Tx queue list to be disabled for each enabled TC */ ice_for_each_traffic_class (tc) {
@@ -2127,67 +2225,24 @@ ice_vsi_stop_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src,break ;for (i =0 ; i < vsi->tc_cfg.tc_info[tc].qcount_tx; i++) { -struct ice_q_vector *q_vector; - -if (!rings || !rings[q_idx]) { - err = -EINVAL ; - goto err_out; - } +struct ice_txq_meta txq_meta = { }; - q_ids[i] = vsi->txq_map[q_idx + offset]; - q_teids[i] = rings[q_idx]->txq_teid; - q_handles[i] = i; +if (!rings || !rings[q_idx]) +return -EINVAL ; -/* clear cause_ena bit for disabled queues */ - val =rd32 (hw,QINT_TQCTL (rings[i]->reg_idx)); - val &= ~QINT_TQCTL_CAUSE_ENA_M ; -wr32 (hw,QINT_TQCTL (rings[i]->reg_idx), val); +ice_fill_txq_meta (vsi, rings[q_idx], &txq_meta); + status =ice_vsi_stop_tx_ring (vsi, rst_src, + rel_vmvf_num, + rings[q_idx], &txq_meta); -/* software is expected to wait for 100 ns */ -ndelay (100 ); - -/* trigger a software interrupt for the vector -* associated to the queue to schedule NAPI handler -*/ - q_vector = rings[i]->q_vector; -if (q_vector) -ice_trigger_sw_intr (hw, q_vector); +if (status) +return status; q_idx++; } - status =ice_dis_vsi_txq (vsi->port_info, vsi->idx, tc, - vsi->num_txq, q_handles, q_ids, - q_teids, rst_src, rel_vmvf_num,NULL ); - -/* if the disable queue command was exercised during an active -* reset flow, ICE_ERR_RESET_ONGOING is returned. This is not -* an error as the reset operation disables queues at the -* hardware level anyway. -*/ -if (status ==ICE_ERR_RESET_ONGOING ) { -dev_dbg (&pf->pdev->dev, -"Reset in progress. LAN Tx queues already disabled\n" ); - }else if (status ==ICE_ERR_DOES_NOT_EXIST ) { -dev_dbg (&pf->pdev->dev, -"LAN Tx queues does not exist, nothing to disabled\n" ); - }else if (status) { -dev_err (&pf->pdev->dev, -"Failed to disable LAN Tx queues, error: %d\n" , - status); - err = -ENODEV ; - } } -err_out: -devm_kfree (&pf->pdev->dev, q_handles); - -err_alloc_q_handles: -devm_kfree (&pf->pdev->dev, q_ids); - -err_alloc_q_ids: -devm_kfree (&pf->pdev->dev, q_teids); - -return err; +return 0 ; }/**
@@ -2200,8 +2255,7 @@ int ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, u16 rel_vmvf_num) { - return ice_vsi_stop_tx_rings(vsi, rst_src, rel_vmvf_num, vsi->tx_rings, - 0); + return ice_vsi_stop_tx_rings(vsi, rst_src, rel_vmvf_num, vsi->tx_rings); }/**
drivers/net/ethernet/intel/ice/ice_lib.h +16 -2
@@ -6,8 +6,22 @@#include "ice.h" -int ice_add_mac_to_list (struct ice_vsi *vsi,struct list_head *add_list, -const u8 *macaddr); +struct ice_txq_meta { +/* Tx-scheduler element identifier */ +u32 q_teid; +/* Entry in VSI's txq_map bitmap */ +u16 q_id; +/* Relative index of Tx queue within TC */ +u16 q_handle; +/* VSI index that Tx queue belongs to */ +u16 vsi_idx; +/* TC number that Tx queue belongs to */ +u8 tc; +}; + +int +ice_add_mac_to_list (struct ice_vsi *vsi,struct list_head *add_list, +const u8 *macaddr);void ice_free_fltr_list (struct device *dev,struct list_head *h);
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH 2/15 ice: add support for virtchnl_queue_select.[tx|rx]_queues bitmap
From: Paul Greenwalt <[email protected]>
The VF driver can call VIRTCHNL_OP_[ENABLE|DISABLE]_QUEUES separately for each queue. Add support for virtchnl_queue_select.[tx|rx]_queues bitmap which is used to indicate which queues to enable and disable.
Add tracing of VF Tx/Rx per queue enable state to avoid enabling enabled queues and disabling disabled queues. Add total queues enabled count and clear ICE_VF_STATE_QS_ENA when count is zero.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 15 +- drivers/net/ethernet/intel/ice/ice_lib.h | 10 + drivers/net/ethernet/intel/ice/ice_main.c | 2 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 243 +++++++++++++----- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 12 +- 5 files changed, 207 insertions(+), 75 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +12 -3
@@ -196,7 +196,10 @@ static int ice_pf_rxq_wait(struct ice_pf *pf, int pf_q, bool ena)* @ena: start or stop the Rx rings * @rxq_idx: Rx queue index */ -static int ice_vsi_ctrl_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx) +#ifndef CONFIG_PCI_IOV +static +#endif /* !CONFIG_PCI_IOV */ +int ice_vsi_ctrl_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;
@@ -2125,7 +2128,10 @@ void ice_trigger_sw_intr(struct ice_hw *hw, struct ice_q_vector *q_vector)* @ring: Tx ring to be stopped * @txq_meta: Meta data of Tx ring to be stopped */ -static int +#ifndef CONFIG_PCI_IOV +static +#endif /* !CONFIG_PCI_IOV */ +int ice_vsi_stop_tx_ring (struct ice_vsi *vsi,enum ice_disq_rst_src rst_src,u16 rel_vmvf_num,struct ice_ring *ring,struct ice_txq_meta *txq_meta)
@@ -2185,7 +2191,10 @@ ice_vsi_stop_tx_ring(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src,* Set up a helper struct that will contain all the necessary fields that * are needed for stopping Tx queue */ -static void +#ifndef CONFIG_PCI_IOV +static +#endif /* !CONFIG_PCI_IOV */ +void ice_fill_txq_meta (struct ice_vsi *vsi,struct ice_ring *ring,struct ice_txq_meta *txq_meta) {
drivers/net/ethernet/intel/ice/ice_lib.h +10 -0
@@ -39,6 +39,16 @@ ice_cfg_txq_interrupt(struct ice_vsi *vsi, u16 txq, u16 msix_idx, u16 itr_idx);void ice_cfg_rxq_interrupt (struct ice_vsi *vsi,u16 rxq,u16 msix_idx,u16 itr_idx); + +int +ice_vsi_stop_tx_ring (struct ice_vsi *vsi,enum ice_disq_rst_src rst_src, +u16 rel_vmvf_num,struct ice_ring *ring, +struct ice_txq_meta *txq_meta); + +void ice_fill_txq_meta (struct ice_vsi *vsi,struct ice_ring *ring, +struct ice_txq_meta *txq_meta); + +int ice_vsi_ctrl_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx);#endif /* CONFIG_PCI_IOV */ int ice_vsi_add_vlan (struct ice_vsi *vsi,u16 vid);
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -489,7 +489,7 @@ ice_prepare_for_reset(struct ice_pf *pf)/* Disable VFs until reset is completed */ for (i =0 ; i < pf->num_alloc_vfs; i++) -clear_bit (ICE_VF_STATE_ENA , pf->vf[i].vf_states); +ice_set_vf_state_qs_dis (&pf->vf[i]);/* disable the VSIs and their queues that are not already DOWN */ ice_pf_dis_all_vsi (pf, false);
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +175 -68
347 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +9 -3
@@ -41,9 +41,9 @@/* Specific VF states */ enum ice_vf_states { -ICE_VF_STATE_INIT =0 , -ICE_VF_STATE_ACTIVE , -ICE_VF_STATE_ENA , +ICE_VF_STATE_INIT =0 ,/* PF is initializing VF */ +ICE_VF_STATE_ACTIVE ,/* VF resources are allocated for use */ +ICE_VF_STATE_QS_ENA ,/* VF queue(s) enabled */ ICE_VF_STATE_DIS ,ICE_VF_STATE_MC_PROMISC ,ICE_VF_STATE_UC_PROMISC ,
@@ -68,6 +68,8 @@ struct ice_vf {struct virtchnl_version_info vf_ver;u32 driver_caps;/* reported by VF driver */ 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; u8 pf_set_mac:1; /* VF MAC address set by VMM admin */ u8 trusted:1;
@@ -90,6 +92,7 @@ struct ice_vf {u16 num_mac;u16 num_vlan;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
@@ -116,12 +119,15 @@ int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);int ice_set_vf_spoofchk (struct net_device *netdev,int vf_id,bool ena);int ice_calc_vf_reg_idx (struct ice_vf *vf,struct ice_q_vector *q_vector); + +void ice_set_vf_state_qs_dis (struct ice_vf *vf);#else /* CONFIG_PCI_IOV */ #define ice_process_vflr_event (pf) do {} while (0)#define ice_free_vfs (pf) do {} while (0)#define ice_vc_process_vf_msg (pf, event) do {} while (0)#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) static inline bool ice_reset_all_vfs(struct ice_pf __always_unused *pf,
Signature · 1 line
2.20.1
Bowers
PATCH 2/15 ice: add support for virtchnl_queue_select.[tx|rx]_queues bitmap
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 02/15] ice: add support for virtchnl_queue_select.[tx|rx]_queues bitmapFrom: Paul Greenwalt <[email protected]>
The VF driver can call VIRTCHNL_OP_[ENABLE|DISABLE]_QUEUES separately for each queue. Add support for virtchnl_queue_select.[tx|rx]_queues bitmap which is used to indicate which queues to enable and disable.
Add tracing of VF Tx/Rx per queue enable state to avoid enabling enabled queues and disabling disabled queues. Add total queues enabled count and clear
ICE_VF_STATE_QS_ENAwhen count is zero.Signed-off-by Paul Greenwalt <[email protected]>Signed-off-by Peng Huang <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 7 lines
--- drivers/net/ethernet/intel/ice/ice_lib.c | 15 +- drivers/net/ethernet/intel/ice/ice_lib.h | 10 + drivers/net/ethernet/intel/ice/ice_main.c | 2 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 243 +++++++++++++----- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 12 +- 5 files changed, 207 insertions(+), 75 deletions(-)
Tony Nguyen
maintainerPATCH 3/15 ice: Alloc queue management bitmaps and arrays dynamically
In reply to Tony NguyenFrom: Anirudh Venkataramanan <[email protected]>
The total number of queues available on the device is divided between multiple physical functions (PF) in the firmware and provided to the driver when it gets function capabilities from the firmware. Thus each PF knows how many Tx/Rx queues it has. These queues are then doled out to different VSIs (for LAN traffic, SR-IOV VF traffic, etc.)
To track usage of these queues at the PF level, the driver uses two bitmaps avail_txqs and avail_rxqs. At the VSI level (i.e. struct ice_vsi instances) the driver uses two arrays txq_map and rxq_map, to track ownership of VSIs' queues in avail_txqs and avail_rxqs respectively.
The aforementioned bitmaps and arrays should be allocated dynamically, because the number of queues supported by a PF is only available once function capabilities have been queried. The current static allocation consumes way more memory than required.
This patch removes the DECLARE_BITMAP for avail_txqs and avail_rxqs and instead uses bitmap_zalloc to allocate the bitmaps during init. Similarly txq_map and rxq_map are now allocated in ice_vsi_alloc_arrays. As a result ICE_MAX_TXQS and ICE_MAX_RXQS defines are no longer needed. Also as txq_map and rxq_map are now allocated and freed, some code reordering was required in ice_vsi_rebuild for correct functioning.
--- drivers/net/ethernet/intel/ice/ice.h | 12 +++--- drivers/net/ethernet/intel/ice/ice_lib.c | 49 +++++++++++++++++------ drivers/net/ethernet/intel/ice/ice_main.c | 40 ++++++++++++++---- 3 files changed, 74 insertions(+), 27 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +6 -6
@@ -73,8 +73,6 @@ extern const char ice_drv_ver[];#define ICE_MBXRQ_LEN 512#define ICE_MIN_MSIX 2#define ICE_NO_VSI 0xffff -#define ICE_MAX_TXQS 2048 -#define ICE_MAX_RXQS 2048#define ICE_VSI_MAP_CONTIG 0#define ICE_VSI_MAP_SCATTER 1#define ICE_MAX_SCATTER_TXQS 16
@@ -284,8 +282,8 @@ struct ice_vsi {/* queue information */ u8 tx_mapping_mode;/* ICE_MAP_MODE_[CONTIG|SCATTER] */ u8 rx_mapping_mode;/* ICE_MAP_MODE_[CONTIG|SCATTER] */ -u16 txq_map[ICE_MAX_TXQS ];/* index in pf->avail_txqs */ -u16 rxq_map[ICE_MAX_RXQS ];/* index in pf->avail_rxqs */ +u16 *txq_map;/* index in pf->avail_txqs */ +u16 *rxq_map;/* index in pf->avail_rxqs */ u16 alloc_txq;/* Allocated Tx queues */ u16 num_txq;/* Used Tx queues */ u16 alloc_rxq;/* Allocated Rx queues */
@@ -357,9 +355,9 @@ struct ice_pf {u16 num_vf_qps;/* num queue pairs per VF */ u16 num_vf_msix;/* num vectors per VF */ DECLARE_BITMAP (state, __ICE_STATE_NBITS); -DECLARE_BITMAP (avail_txqs,ICE_MAX_TXQS ); -DECLARE_BITMAP (avail_rxqs,ICE_MAX_RXQS );DECLARE_BITMAP (flags,ICE_PF_FLAGS_NBITS ); +unsigned long *avail_txqs;/* bitmap to track PF Tx queue usage */ +unsigned long *avail_rxqs;/* bitmap to track PF Rx queue usage */ unsigned long serv_tmr_period;unsigned long serv_tmr_prev;struct timer_list serv_tmr;
@@ -370,6 +368,8 @@ struct ice_pf {u32 hw_csum_rx_error;u32 oicr_idx;/* Other interrupt cause MSIX vector index */ u32 num_avail_sw_msix;/* remaining MSIX SW vectors left unclaimed */ +u16 max_pf_txqs;/* Total Tx queues PF wide */ +u16 max_pf_rxqs;/* Total Rx queues PF wide */ u32 num_lan_msix;/* Total MSIX vectors for base driver */ u16 num_lan_tx;/* num LAN Tx queues setup */ u16 num_lan_rx;/* num LAN Rx queues setup */
drivers/net/ethernet/intel/ice/ice_lib.c +36 -13
103 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +32 -8
@@ -2243,13 +2243,23 @@ static void ice_deinit_pf(struct ice_pf *pf)ice_service_task_stop (pf);mutex_destroy (&pf->sw_mutex);mutex_destroy (&pf->avail_q_mutex); + +if (pf->avail_txqs) { +bitmap_free (pf->avail_txqs); + pf->avail_txqs =NULL ; + } + +if (pf->avail_rxqs) { +bitmap_free (pf->avail_rxqs); + pf->avail_rxqs =NULL ; + } }/** * ice_init_pf - Initialize general software structures (struct ice_pf) * @pf: board private structure to initialize */ -static void ice_init_pf (struct ice_pf *pf) +static int ice_init_pf (struct ice_pf *pf) {bitmap_zero (pf->flags,ICE_PF_FLAGS_NBITS );#ifdef CONFIG_PCI_IOV
@@ -2265,12 +2275,6 @@ static void ice_init_pf(struct ice_pf *pf)mutex_init (&pf->sw_mutex);mutex_init (&pf->avail_q_mutex); -/* Clear avail_[t|r]x_qs bitmaps (set all to avail) */ -mutex_lock (&pf->avail_q_mutex); -bitmap_zero (pf->avail_txqs,ICE_MAX_TXQS ); -bitmap_zero (pf->avail_rxqs,ICE_MAX_RXQS ); -mutex_unlock (&pf->avail_q_mutex); -if (pf->hw.func_caps.common_cap.rss_table_size)set_bit (ICE_FLAG_RSS_ENA , pf->flags);
@@ -2279,6 +2283,22 @@ static void ice_init_pf(struct ice_pf *pf) pf->serv_tmr_period =HZ ;INIT_WORK (&pf->serv_task, ice_service_task);clear_bit (__ICE_SERVICE_SCHED, pf->state); + + pf->max_pf_txqs = pf->hw.func_caps.common_cap.num_txq; + pf->max_pf_rxqs = pf->hw.func_caps.common_cap.num_rxq; + + pf->avail_txqs =bitmap_zalloc (pf->max_pf_txqs,GFP_KERNEL ); +if (!pf->avail_txqs) +return -ENOMEM ; + + pf->avail_rxqs =bitmap_zalloc (pf->max_pf_rxqs,GFP_KERNEL ); +if (!pf->avail_rxqs) { +devm_kfree (&pf->pdev->dev, pf->avail_txqs); + pf->avail_txqs =NULL ; +return -ENOMEM ; + } + +return 0 ; }/**
@@ -2503,7 +2523,11 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) hw->fw_maj_ver, hw->fw_min_ver, hw->fw_build, hw->api_maj_ver, hw->api_min_ver); -ice_init_pf (pf); + err =ice_init_pf (pf); +if (err) { +dev_err (dev,"ice_init_pf failed: %d\n" , err); + goto err_init_pf_unroll; + } err =ice_init_pf_dcb (pf, false);if (err) {
Signature · 1 line
2.20.1
Bowers
PATCH 3/15 ice: Alloc queue management bitmaps and arrays dynamically
Quoted 34 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 03/15] ice: Alloc queue management bitmaps and arrays dynamicallyFrom: Anirudh Venkataramanan <[email protected]>
The total number of queues available on the device is divided between multiple physical functions (PF) in the firmware and provided to the driver when it gets function capabilities from the firmware. Thus each PF knows how many Tx/Rx queues it has. These queues are then doled out to different VSIs (for LAN traffic, SR-IOV VF traffic, etc.)
To track usage of these queues at the PF level, the driver uses two bitmaps
avail_txqsandavail_rxqs. At the VSI level (i.e. structice_vsiinstances) the driver uses two arraystxq_mapandrxq_map, to track ownership of VSIs' queues inavail_txqsandavail_rxqsrespectively.The aforementioned bitmaps and arrays should be allocated dynamically, because the number of queues supported by a PF is only available once function capabilities have been queried. The current static allocation consumes way more memory than required.
This patch removes the
DECLARE_BITMAPforavail_txqsandavail_rxqsand instead usesbitmap_zallocto allocate the bitmaps during init. Similarlytxq_mapandrxq_mapare now allocated inice_vsi_alloc_arrays. As a resultICE_MAX_TXQSandICE_MAX_RXQSdefines are no longer needed.
Also astxq_mapandrxq_mapare now allocated and freed, some code reordering was required inice_vsi_rebuildfor correct functioning.
Quoted 7 lines
Signed-off-by: Anirudh Venkataramanan
<[email protected]>--- drivers/net/ethernet/intel/ice/ice.h | 12 +++--- drivers/net/ethernet/intel/ice/ice_lib.c | 49 +++++++++++++++++------ drivers/net/ethernet/intel/ice/ice_main.c | 40 ++++++++++++++---- 3 files changed, 74 insertions(+), 27 deletions(-)
Tony Nguyen
maintainerPATCH 4/15 ice: Fix VF configuration issues due to reset
In reply to Tony NguyenFrom: Akeem G Abodunrin <[email protected]>
This patch fixes a critical reset issue that resulting to the server reboot when an Admin changes VF configuration on the host, for example changing VF to Trusted/non_Trusted mode, the PF driver send reset notification to AVF driver while also continue with reset flow. However, AVF driver schedule another reset due to notification, which causes two concurrent reset going on, and trigger lock up in the FW, with AQ call to delete VSI.
--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +9 -2
@@ -1152,12 +1152,19 @@ static bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)u32 reg;int i; -/* If the VFs have been disabled, this means something else is -* resetting the VF, so we shouldn't continue. +/* If the PF has been disabled, there is no need resetting VF until +* PF is active again. */ if (test_bit (__ICE_VF_DIS, pf->state))return false; +/* If the VF has been disabled, this means something else is +* resetting the VF, so we shouldn't continue. Otherwise, set +* disable VF state bit for actual reset, and continue. +*/ +if (test_and_set_bit (ICE_VF_STATE_DIS , vf->vf_states)) +return false; +ice_trigger_vf_reset (vf, is_vflr); vsi = pf->vsi[vf->lan_vsi_idx];
Signature · 1 line
2.20.1
Bowers
PATCH 4/15 ice: Fix VF configuration issues due to reset
Quoted 17 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 04/15] ice: Fix VF configuration issues due to resetFrom: Akeem G Abodunrin <[email protected]>
This patch fixes a critical reset issue that resulting to the server reboot when an Admin changes VF configuration on the host, for example changing VF to Trusted/non_Trusted mode, the PF driver send reset notification to AVF driver while also continue with reset flow. However, AVF driver schedule another reset due to notification, which causes two concurrent reset going on, and trigger lock up in the FW, with AQ call to delete VSI.
Quoted 4 lines
Signed-off-by Akeem G Abodunrin <[email protected]>--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
Tony Nguyen
maintainerPATCH 5/15 ice: Rework ice_ena_msix_range
In reply to Tony NguyenFrom: Anirudh Venkataramanan <[email protected]>
The current implementation of ice_ena_msix_range is difficult to read and has subtle issues. This patch reworks the said function for clarity and correctness.
More specifically,
1. Add more checks to bail out of 'needed' is greater than 'v_left'.
2. Simplify fallback logic
3. Do not set pf->num_avail_sw_msix in ice_ena_msix_range as it gets overwritten by ice_init_interrupt_scheme.
--- drivers/net/ethernet/intel/ice/ice_main.c | 32 +++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +21 -11
@@ -2317,13 +2317,18 @@ static int ice_ena_msix_range(struct ice_pf *pf)/* reserve one vector for miscellaneous handler */ needed =1 ; +if (v_left < needed) + goto no_hw_vecs_left_err; v_budget += needed; v_left -= needed;/* reserve vectors for LAN traffic */ - pf->num_lan_msix =min_t (int,num_online_cpus (), v_left); - v_budget += pf->num_lan_msix; - v_left -= pf->num_lan_msix; + needed =min_t (int,num_online_cpus (), v_left); +if (v_left < needed) + goto no_hw_vecs_left_err; + pf->num_lan_msix = needed; + v_budget += needed; + v_left -= needed; pf->msix_entries =devm_kcalloc (&pf->pdev->dev, v_budget,sizeof (*pf->msix_entries),GFP_KERNEL );
@@ -2348,18 +2353,18 @@ static int ice_ena_msix_range(struct ice_pf *pf)if (v_actual < v_budget) {dev_warn (&pf->pdev->dev, -"not enough vectors. requested = %d, obtained = %d\n" , +"not enough OS MSI-X vectors. requested = %d, obtained = %d\n" , v_budget, v_actual); -if (v_actual >= (pf->num_lan_msix +1 )) { - pf->num_avail_sw_msix = v_actual - - (pf->num_lan_msix +1 ); - }else if (v_actual >=2 ) { - pf->num_lan_msix =1 ; - pf->num_avail_sw_msix = v_actual -2 ; - }else { +/* 2 vectors for LAN (traffic + OICR) */ +#define ICE_MIN_LAN_VECS 2 + +if (v_actual <ICE_MIN_LAN_VECS ) { +/* error if we can't get minimum vectors */ pci_disable_msix (pf->pdev); err = -ERANGE ; goto msix_err; + }else { + pf->num_lan_msix =ICE_MIN_LAN_VECS ; } }
@@ -2369,6 +2374,11 @@ static int ice_ena_msix_range(struct ice_pf *pf)devm_kfree (&pf->pdev->dev, pf->msix_entries); goto exit_err; +no_hw_vecs_left_err: +dev_err (&pf->pdev->dev, +"not enough device MSI-X vectors. requested = %d, available = %d\n" , + needed, v_left); + err = -ERANGE ; exit_err: pf->num_lan_msix =0 ;return err;
Signature · 1 line
2.20.1
Bowers
PATCH 5/15 ice: Rework ice_ena_msix_range
Quoted 23 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 05/15] ice: Reworkice_ena_msix_rangeFrom: Anirudh Venkataramanan <[email protected]>
The current implementation of
ice_ena_msix_rangeis difficult to read and has subtle issues. This patch reworks the said function for clarity and correctness.More specifically,
1. Add more checks to bail out of 'needed' is greater than '
v_left'.2. Simplify fallback logic
3. Do not set
pf->num_avail_sw_msixinice_ena_msix_rangeas it gets overwritten byice_init_interrupt_scheme.
Quoted 6 lines
Signed-off-by: Anirudh Venkataramanan
<[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 32 +++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-)
Tony Nguyen
maintainerPATCH 6/15 ice: fix adminq calls during remove
In reply to Tony NguyenFrom: Henry Tieman <[email protected]>
The order of operations was incorrect in ice_remove(). The code would try to use adminq operations after the adminq was disabled. This caused all adminq calls to fail and possibly timeout waiting.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -2669,9 +2669,9 @@ static void ice_remove(struct pci_dev *pdev)continue ;ice_vsi_free_q_vectors (pf->vsi[i]); } -ice_clear_interrupt_scheme (pf);ice_deinit_pf (pf);ice_deinit_hw (&pf->hw); +ice_clear_interrupt_scheme (pf);pci_disable_pcie_error_reporting (pdev); }
Signature · 1 line
2.20.1
Bowers
PATCH 6/15 ice: fix adminq calls during remove
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 06/15] ice: fix adminq calls during removeFrom: Henry Tieman <[email protected]>
The order of operations was incorrect in
ice_remove(). The code would try to use adminq operations after the adminq was disabled. This caused all adminq calls to fail and possibly timeout waiting.
Quoted 5 lines
Signed-off-by Henry Tieman <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH 7/15 ice: Fix EMP reset handling
In reply to Tony NguyenFrom: Anirudh Venkataramanan <[email protected]>
ice_reset_subtask needs to handle EMP resets as well, as EMP resets can be triggered by the firmware. This patch adds the logic to do this.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +2 -0
@@ -567,6 +567,8 @@ static void ice_reset_subtask(struct ice_pf *pf) reset_type =ICE_RESET_CORER ;if (test_and_clear_bit (__ICE_GLOBR_RECV, pf->state)) reset_type =ICE_RESET_GLOBR ; +if (test_and_clear_bit (__ICE_EMPR_RECV, pf->state)) + reset_type =ICE_RESET_EMPR ;/* return if no valid reset type requested */ if (reset_type ==ICE_RESET_INVAL )return ;
Signature · 1 line
2.20.1
Bowers
PATCH 7/15 ice: Fix EMP reset handling
Quoted 9 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 07/15] ice: Fix EMP reset handlingFrom: Anirudh Venkataramanan <[email protected]>
Quoted 8 lines
ice_reset_subtaskneeds to handle EMP resets as well, as EMP resets can be triggered by the firmware. This patch adds the logic to do this.Signed-off-by: Anirudh Venkataramanan
<[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 1 file changed, 2 insertions(+)
Tony Nguyen
maintainerPATCH 8/15 ice: Fix resource leak in ice_remove_rule_internal()
In reply to Tony NguyenFrom: Jeb Cramer <[email protected]>
We don't free s_rule if ice_aq_sw_rules() returns a non-zero status. If it returned a zero status, s_rule would be freed right after, so this implies it should be freed within the scope of the function regardless.
--- drivers/net/ethernet/intel/ice/ice_switch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_switch.c +3 -2
@@ -1623,12 +1623,13 @@ ice_remove_rule_internal(struct ice_hw *hw, u8 recp_id, status =ice_aq_sw_rules (hw, s_rule,ICE_SW_RULE_RX_TX_NO_HDR_SIZE ,1 , ice_aqc_opc_remove_sw_rules,NULL ); -if (status) - goto exit;/* Remove a book keeping from the list */ devm_kfree (ice_hw_to_dev (hw), s_rule); +if (status) + goto exit; +list_del (&list_elem->list_entry);devm_kfree (ice_hw_to_dev (hw), list_elem); }
Signature · 1 line
2.20.1
Bowers
PATCH 8/15 ice: Fix resource leak in ice_remove_rule_internal()
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 08/15] ice: Fix resource leak inice_remove_rule_internal()From: Jeb Cramer <[email protected]>
Quoted 8 lines
We don't free
s_ruleifice_aq_sw_rules()returns a non-zero status. If it returned a zero status,s_rulewould be freed right after, so this implies it should be freed within the scope of the function regardless.Signed-off-by Jeb Cramer <[email protected]>--- drivers/net/ethernet/intel/ice/ice_switch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Tony Nguyen
maintainerPATCH 9/15 ice: Report what the user set for coalesce [tx|rx]-usecs
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently if the user sets an odd value for [tx|rx]-usecs we align the value because the hardware only understands ITR values in multiples of
2. This seems misleading because we are essentially telling the user that the ITR value is odd, when in fact we have changed it internally. Fix this by reporting that setting odd ITR values is not allowed.
Also, while making changes to ice_set_rc_coalesce() I noticed a bit of code/error duplication. Make the necessary changes to remove the duplication.
--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 88 ++++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +44 -44
@@ -3400,25 +3400,25 @@ static int ice_set_rc_coalesce(enum ice_container_type c_type, struct ethtool_coalesce *ec, struct ice_ring_container *rc, struct ice_vsi *vsi) { + const char *c_type_str = (c_type == ICE_RX_CONTAINER) ? "rx" : "tx"; +u32 use_adaptive_coalesce, coalesce_usecs;struct ice_pf *pf = vsi->back;u16 itr_setting;if (!rc->ring)return -EINVAL ; - itr_setting = rc->itr_setting & ~ICE_ITR_DYNAMIC ; -switch (c_type) {case ICE_RX_CONTAINER :if (ec->rx_coalesce_usecs_high >ICE_MAX_INTRL || (ec->rx_coalesce_usecs_high && ec->rx_coalesce_usecs_high < pf->hw.intrl_gran)) {netdev_info (vsi->netdev, -"Invalid value, rx-usecs-high valid values are 0 (disabled), %d-%d\n" , - pf->hw.intrl_gran,ICE_MAX_INTRL ); +"Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n" , + c_type_str, pf->hw.intrl_gran, +ICE_MAX_INTRL );return -EINVAL ; } -if (ec->rx_coalesce_usecs_high != rc->ring->q_vector->intrl) { rc->ring->q_vector->intrl = ec->rx_coalesce_usecs_high; wr32(&pf->hw, GLINT_RATE(rc->ring->q_vector->reg_idx),
@@ -3426,60 +3426,60 @@ ice_set_rc_coalesce(enum ice_container_type c_type, struct ethtool_coalesce *ec, pf->hw.intrl_gran)); } -if (ec->rx_coalesce_usecs != itr_setting && - ec->use_adaptive_rx_coalesce) { -netdev_info (vsi->netdev, -"Rx interrupt throttling cannot be changed if adaptive-rx is enabled\n" ); -return -EINVAL ; - } - -if (ec->rx_coalesce_usecs >ICE_ITR_MAX ) { -netdev_info (vsi->netdev, -"Invalid value, rx-usecs range is 0-%d\n" , -ICE_ITR_MAX ); -return -EINVAL ; - } + use_adaptive_coalesce = ec->use_adaptive_rx_coalesce; + coalesce_usecs = ec->rx_coalesce_usecs; -if (ec->use_adaptive_rx_coalesce) { - rc->itr_setting |=ICE_ITR_DYNAMIC ; - }else { - rc->itr_setting =ITR_REG_ALIGN (ec->rx_coalesce_usecs); - rc->target_itr =ITR_TO_REG (rc->itr_setting); - }break ;case ICE_TX_CONTAINER :if (ec->tx_coalesce_usecs_high) {netdev_info (vsi->netdev, -"setting tx-usecs-high is not supported\n" ); +"setting %s-usecs-high is not supported\n" , + c_type_str);return -EINVAL ; } -if (ec->tx_coalesce_usecs != itr_setting && - ec->use_adaptive_tx_coalesce) { -netdev_info (vsi->netdev, -"Tx interrupt throttling cannot be changed if adaptive-tx is enabled\n" ); -return -EINVAL ; - } - -if (ec->tx_coalesce_usecs >ICE_ITR_MAX ) { -netdev_info (vsi->netdev, -"Invalid value, tx-usecs range is 0-%d\n" , -ICE_ITR_MAX ); -return -EINVAL ; - } + use_adaptive_coalesce = ec->use_adaptive_tx_coalesce; + coalesce_usecs = ec->tx_coalesce_usecs; -if (ec->use_adaptive_tx_coalesce) { - rc->itr_setting |=ICE_ITR_DYNAMIC ; - }else { - rc->itr_setting =ITR_REG_ALIGN (ec->tx_coalesce_usecs); - rc->target_itr =ITR_TO_REG (rc->itr_setting); - }break ;default :dev_dbg (&pf->pdev->dev,"Invalid container type %d\n" , c_type);return -EINVAL ; } + itr_setting = rc->itr_setting & ~ICE_ITR_DYNAMIC ; +if (coalesce_usecs != itr_setting && use_adaptive_coalesce) { +netdev_info (vsi->netdev, +"%s interrupt throttling cannot be changed if adaptive-%s is enabled\n" , + c_type_str, c_type_str); +return -EINVAL ; + } + +if (coalesce_usecs >ICE_ITR_MAX ) { +netdev_info (vsi->netdev, +"Invalid value, %s-usecs range is 0-%d\n" , + c_type_str,ICE_ITR_MAX ); +return -EINVAL ; + } + +/* hardware only supports an ITR granularity of 2us */ +if (coalesce_usecs %2 !=0 ) { +netdev_info (vsi->netdev, +"Invalid value, %s-usecs must be even\n" , + c_type_str); +return -EINVAL ; + } + +if (use_adaptive_coalesce) { + rc->itr_setting |=ICE_ITR_DYNAMIC ; + }else { +/* store user facing value how it was set */ + rc->itr_setting = coalesce_usecs; +/* set to static and convert to value HW understands */ + rc->target_itr = +ITR_TO_REG (ITR_REG_ALIGN (rc->itr_setting)); + } +return 0 ; }
Signature · 1 line
2.20.1
Bowers
PATCH 9/15 ice: Report what the user set for coalesce [tx|rx]-usecs
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 09/15] ice: Report what the user set for coalesce [tx|rx]-usecsFrom: Brett Creeley <[email protected]>
Currently if the user sets an odd value for [tx|rx]-usecs we align the value because the hardware only understands ITR values in multiples of 2. This seems misleading because we are essentially telling the user that the ITR value is odd, when in fact we have changed it internally.
Fix this by reporting that setting odd ITR values is not allowed.
Quoted 8 lines
Also, while making changes to
ice_set_rc_coalesce()I noticed a bit of code/error duplication. Make the necessary changes to remove the duplication.Signed-off-by Brett Creeley <[email protected]>--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 88 ++++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-)
Tony Nguyen
maintainerPATCH 10/15 ice: Deduce TSA value from the priority value in the CEE mode
In reply to Tony NguyenFrom: Chinh T Cao <[email protected]>
In CEE mode, the TSA information can be derived from the reported priority value.
--- drivers/net/ethernet/intel/ice/ice_dcb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_dcb.c +7 -1
@@ -444,9 +444,15 @@ ice_parse_cee_pgcfg_tlv(struct ice_cee_feat_tlv *tlv,* |pg0|pg1|pg2|pg3|pg4|pg5|pg6|pg7| * --------------------------------- */ -ice_for_each_traffic_class (i) +ice_for_each_traffic_class (i) { etscfg->tcbwtable[i] = buf[offset++]; +if (etscfg->prio_table[i] ==ICE_CEE_PGID_STRICT ) + dcbcfg->etscfg.tsatable[i] =ICE_IEEE_TSA_STRICT ; +else + dcbcfg->etscfg.tsatable[i] =ICE_IEEE_TSA_ETS ; + } +/* Number of TCs supported (1 octet) */ etscfg->maxtcs = buf[offset]; }
Signature · 1 line
2.20.1
Bowers
PATCH 10/15 ice: Deduce TSA value from the priority value in the CEE mode
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 10/15] ice: Deduce TSA value from the priority value in the CEE modeFrom: Chinh T Cao <[email protected]>
Quoted 7 lines
In CEE mode, the TSA information can be derived from the reported priority value.
Signed-off-by Chinh T Cao <[email protected]>--- drivers/net/ethernet/intel/ice/ice_dcb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH 11/15 ice: add needed PFR during driver unload
In reply to Tony NguyenFrom: Bruce Allan <[email protected]>
According to the specification, a PF Reset must be done as part of the driver unload flow.
--- drivers/net/ethernet/intel/ice/ice_main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +5 -0
@@ -2674,6 +2674,11 @@ static void ice_remove(struct pci_dev *pdev)ice_deinit_pf (pf);ice_deinit_hw (&pf->hw);ice_clear_interrupt_scheme (pf); +/* Issue a PFR as part of the prescribed driver unload flow. Do not +* do it via ice_schedule_reset() since there is no need to rebuild +* and the service task is already stopped. +*/ +ice_reset (&pf->hw,ICE_RESET_PFR );pci_disable_pcie_error_reporting (pdev); }
Signature · 1 line
2.20.1
Bowers
PATCH 11/15 ice: add needed PFR during driver unload
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 11/15] ice: add needed PFR during driver unloadFrom: Bruce Allan <[email protected]>
Quoted 7 lines
According to the specification, a PF Reset must be done as part of the driver unload flow.
Signed-off-by Bruce Allan <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 5 +++++ 1 file changed, 5 insertions(+)
Tony Nguyen
maintainerPATCH 12/15 ice: update driver unloading field for Queue Shutdown AQ command
In reply to Tony NguyenFrom: Bruce Allan <[email protected]>
According to recent specification versions, the field in the Queue Shutdown AdminQ command consisting of the "driver unloading" indication is not a 4 byte field (it is byte.bit 16.0). Change it to a byte and remove the unnecessary endian conversion.
--- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 4 ++-- drivers/net/ethernet/intel/ice/ice_common.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +2 -2
@@ -35,9 +35,9 @@ struct ice_aqc_get_ver {/* Queue Shutdown (direct 0x0003) */ struct ice_aqc_q_shutdown { -__le32 driver_unloading; +u8 driver_unloading;#define ICE_AQC_DRIVER_UNLOADING BIT(0) -u8 reserved[12 ]; +u8 reserved[15 ]; };/* Request resource ownership (direct 0x0008)
drivers/net/ethernet/intel/ice/ice_common.c +1 -1
@@ -1259,7 +1259,7 @@ enum ice_status ice_aq_q_shutdown(struct ice_hw *hw, bool unloading)ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_q_shutdown);if (unloading) - cmd->driver_unloading =cpu_to_le32 (ICE_AQC_DRIVER_UNLOADING ); + cmd->driver_unloading =ICE_AQC_DRIVER_UNLOADING ;return ice_aq_send_cmd (hw, &desc,NULL ,0 ,NULL ); }
Signature · 1 line
2.20.1
Bowers
PATCH 12/15 ice: update driver unloading field for Queue Shutdown AQ command
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:26 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 12/15] ice: update driver unloading field for Queue Shutdown AQ commandFrom: Bruce Allan <[email protected]>
According to recent specification versions, the field in the Queue Shutdown AdminQ command consisting of the "driver unloading" indication is not a 4 byte field (it is byte.bit 16.0). Change it to a byte and remove the unnecessary endian conversion.
Quoted 5 lines
Signed-off-by Bruce Allan <[email protected]>--- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 4 ++-- drivers/net/ethernet/intel/ice/ice_common.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Tony Nguyen
maintainerPATCH 13/15 ice: add print of autoneg state to link message
In reply to Tony NguyenFrom: Jesse Brandeburg <[email protected]>
Print the state of autonegotiation when printing the Link up message. Adds new text to the "NIC Link is up" line like
Autoneg: <True | False>
--- drivers/net/ethernet/intel/ice/ice_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +9 -2
@@ -626,6 +626,7 @@ void ice_print_link_msg(struct ice_vsi *vsi, bool isup)const char *speed;const char *fec;const char *fc; +const char *an;if (!vsi)return ;
@@ -709,6 +710,12 @@ void ice_print_link_msg(struct ice_vsi *vsi, bool isup)break ; } +/* check if autoneg completed, might be false due to not supported */ +if (vsi->port_info->phy.link_info.an_info &ICE_AQ_AN_COMPLETED ) + an ="True" ; +else + an ="False" ; +/* Get FEC mode requested based on PHY caps last SW configuration */ caps =devm_kzalloc (&vsi->back->pdev->dev,sizeof (*caps),GFP_KERNEL );if (!caps) {
@@ -733,8 +740,8 @@ void ice_print_link_msg(struct ice_vsi *vsi, bool isup)devm_kfree (&vsi->back->pdev->dev, caps); done: -netdev_info (vsi->netdev,"NIC Link is up %sbps, Requested FEC: %s, FEC: %s, Flow Control: %s\n" , - speed, fec_req, fec, fc); +netdev_info (vsi->netdev,"NIC Link is up %sbps, Requested FEC: %s, FEC: %s, Autoneg: %s, Flow Control: %s\n" , + speed, fec_req, fec, an, fc); }/**
Signature · 1 line
2.20.1
Bowers
PATCH 13/15 ice: add print of autoneg state to link message
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:26 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 13/15] ice: add print of autoneg state to link messageFrom: Jesse Brandeburg <[email protected]>
Quoted 8 lines
Print the state of autonegotiation when printing the Link up message. Adds new text to the "NIC Link is up" line like
Autoneg: <True | False>Signed-off-by Jesse Brandeburg <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
Tony Nguyen
maintainerPATCH 14/15 ice: print extra message if topology issue
In reply to Tony NguyenFrom: Jesse Brandeburg <[email protected]>
The driver needs to inform the user if there is an issue with the topology / configuration of the link.
--- drivers/net/ethernet/intel/ice/ice_main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +17 -0
@@ -613,6 +613,22 @@ static void ice_reset_subtask(struct ice_pf *pf) } } +/** +* ice_print_topo_conflict - print topology conflict message +* @vsi: the VSI whose topology status is being checked +*/ +static void ice_print_topo_conflict (struct ice_vsi *vsi) +{ +switch (vsi->port_info->phy.link_info.topo_media_conflict) { +case ICE_AQ_LINK_TOPO_CONFLICT : +case ICE_AQ_LINK_MEDIA_CONFLICT : +netdev_info (vsi->netdev,"Possible mis-configuration of the Ethernet port detected, please use the Intel(R) Ethernet Port Configuration Tool application to address the issue.\n" ); +break ; +default : +break ; + } +} +/** * ice_print_link_msg - print link up or down message * @vsi: the VSI whose link status is being queried
@@ -742,6 +758,7 @@ void ice_print_link_msg(struct ice_vsi *vsi, bool isup) done:netdev_info (vsi->netdev,"NIC Link is up %sbps, Requested FEC: %s, FEC: %s, Autoneg: %s, Flow Control: %s\n" , speed, fec_req, fec, an, fc); +ice_print_topo_conflict (vsi); }/**
Signature · 1 line
2.20.1
Bowers
PATCH 14/15 ice: print extra message if topology issue
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:26 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 14/15] ice: print extra message if topology issueFrom: Jesse Brandeburg <[email protected]>
Quoted 7 lines
The driver needs to inform the user if there is an issue with the topology / configuration of the link.
Signed-off-by Jesse Brandeburg <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Tony Nguyen
maintainerPATCH 15/15 ice: Cleanup defines in ice_type.h
In reply to Tony NguyenConventionally, if the #defines/other are not needed by other header files being included, #includes are done first followed by #defines and other stuff. Move the #defines before the #includes to follow this convention.
Suggested by: Bruce Allan <[email protected]>
--- drivers/net/ethernet/intel/ice/ice_type.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_type.h +3 -3
@@ -4,15 +4,15 @@#ifndef _ICE_TYPE_H_#define _ICE_TYPE_H_ +#define ICE_BYTES_PER_WORD 2 +#define ICE_BYTES_PER_DWORD 4 +#include "ice_status.h" #include "ice_hw_autogen.h" #include "ice_osdep.h" #include "ice_controlq.h" #include "ice_lan_tx_rx.h" -#define ICE_BYTES_PER_WORD 2 -#define ICE_BYTES_PER_DWORD 4 -static inline bool ice_is_tc_ena (unsigned long bitmap,u8 tc) {return test_bit (tc, &bitmap);
Signature · 1 line
2.20.1
Bowers
PATCH 15/15 ice: Cleanup defines in ice_type.h
Quoted 12 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:26 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 15/15] ice: Cleanup defines inice_type.hConventionally, if the #defines/other are not needed by other header files being included, #includes are done first followed by #defines and other stuff. Move the #defines before the #includes to follow this convention.
Quoted 5 lines
Suggested by: Bruce Allan <[email protected]>
Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_type.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Bowers
PATCH 1/15 ice: add support for enabling/disabling single queues
In reply to Tony NguyenQuoted 23 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Friday, August 2, 2019 1:25 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S26 01/15] ice: add support for enabling/disabling single queuesFrom: Maciej Fijalkowski <[email protected]>
Refactor the queue handling functions that are going through queue arrays in a way that the logic done for a single queue is pulled out and it will be called for each ring when traversing ring array. This implies that when disabling Tx rings we won't fill up
q_ids,q_teidsandq_handlesarrays. Drop also 'offset' parameter; the value from vsi'stxq_mapis stored inring->reg_idxand that drops the need for mentioned parameter. Introduce theice_vsi_cfg_txq,ice_vsi_stop_tx_ringandice_vsi_ctrl_rx_ringthat are the functions with pulled out logic.There's several Tx queue meta data (
q_id,q_handle,q_teidand other) that need to be set up during Tx queue disablement, so let's as well add a helper structure that wraps it up and a function that will be filling it up.
Quoted 6 lines
Signed-off-by Maciej Fijalkowski <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_lib.c | 340 +++++++++++++---------- drivers/net/ethernet/intel/ice/ice_lib.h | 18 +- 2 files changed, 213 insertions(+), 145 deletions(-)