Skip to content

Commit e75d1b2

Browse files
mfijalkoJeff Kirsher
authored andcommitted
ice: get rid of per-tc flow in Tx queue configuration routines
There's no reason for treating DCB as first class citizen when configuring the Tx queues and going through TCs. Reverse the logic and base the configuration logic on rings, which is the object of interest anyway. Signed-off-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent eff380a commit e75d1b2

File tree

3 files changed

+47
-49
lines changed

3 files changed

+47
-49
lines changed

drivers/net/ethernet/intel/ice/ice_base.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,21 @@ static void ice_cfg_itr_gran(struct ice_hw *hw)
190190
wr32(hw, GLINT_CTL, regval);
191191
}
192192

193+
/**
194+
* ice_calc_q_handle - calculate the queue handle
195+
* @vsi: VSI that ring belongs to
196+
* @ring: ring to get the absolute queue index
197+
* @tc: traffic class number
198+
*/
199+
static u16 ice_calc_q_handle(struct ice_vsi *vsi, struct ice_ring *ring, u8 tc)
200+
{
201+
/* Idea here for calculation is that we subtract the number of queue
202+
* count from TC that ring belongs to from it's absolute queue index
203+
* and as a result we get the queue's index within TC.
204+
*/
205+
return ring->q_index - vsi->tc_cfg.tc_info[tc].qoffset;
206+
}
207+
193208
/**
194209
* ice_setup_tx_ctx - setup a struct ice_tlan_ctx instance
195210
* @ring: The Tx ring to configure
@@ -522,20 +537,19 @@ void ice_vsi_free_q_vectors(struct ice_vsi *vsi)
522537
* ice_vsi_cfg_txq - Configure single Tx queue
523538
* @vsi: the VSI that queue belongs to
524539
* @ring: Tx ring to be configured
525-
* @tc_q_idx: queue index within given TC
526540
* @qg_buf: queue group buffer
527-
* @tc: TC that Tx ring belongs to
528541
*/
529542
int
530-
ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring, u16 tc_q_idx,
531-
struct ice_aqc_add_tx_qgrp *qg_buf, u8 tc)
543+
ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring,
544+
struct ice_aqc_add_tx_qgrp *qg_buf)
532545
{
533546
struct ice_tlan_ctx tlan_ctx = { 0 };
534547
struct ice_aqc_add_txqs_perq *txq;
535548
struct ice_pf *pf = vsi->back;
536549
u8 buf_len = sizeof(*qg_buf);
537550
enum ice_status status;
538551
u16 pf_q;
552+
u8 tc;
539553

540554
pf_q = ring->reg_idx;
541555
ice_setup_tx_ctx(ring, &tlan_ctx, pf_q);
@@ -549,10 +563,15 @@ ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring, u16 tc_q_idx,
549563
*/
550564
ring->tail = pf->hw.hw_addr + QTX_COMM_DBELL(pf_q);
551565

566+
if (IS_ENABLED(CONFIG_DCB))
567+
tc = ring->dcb_tc;
568+
else
569+
tc = 0;
570+
552571
/* Add unique software queue handle of the Tx queue per
553572
* TC into the VSI Tx ring
554573
*/
555-
ring->q_handle = tc_q_idx;
574+
ring->q_handle = ice_calc_q_handle(vsi, ring, tc);
556575

557576
status = ice_ena_vsi_txq(vsi->port_info, vsi->idx, tc, ring->q_handle,
558577
1, qg_buf, buf_len, NULL);

drivers/net/ethernet/intel/ice/ice_base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ int ice_vsi_alloc_q_vectors(struct ice_vsi *vsi);
1313
void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi);
1414
void ice_vsi_free_q_vectors(struct ice_vsi *vsi);
1515
int
16-
ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring, u16 tc_q_idx,
17-
struct ice_aqc_add_tx_qgrp *qg_buf, u8 tc);
16+
ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring,
17+
struct ice_aqc_add_tx_qgrp *qg_buf);
1818
void ice_cfg_itr(struct ice_hw *hw, struct ice_q_vector *q_vector);
1919
void
2020
ice_cfg_txq_interrupt(struct ice_vsi *vsi, u16 txq, u16 msix_idx, u16 itr_idx);

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,42 +1225,31 @@ int ice_vsi_cfg_rxqs(struct ice_vsi *vsi)
12251225
* ice_vsi_cfg_txqs - Configure the VSI for Tx
12261226
* @vsi: the VSI being configured
12271227
* @rings: Tx ring array to be configured
1228-
* @offset: offset within vsi->txq_map
12291228
*
12301229
* Return 0 on success and a negative value on error
12311230
* Configure the Tx VSI for operation.
12321231
*/
12331232
static int
1234-
ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings, int offset)
1233+
ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings)
12351234
{
12361235
struct ice_aqc_add_tx_qgrp *qg_buf;
1237-
struct ice_pf *pf = vsi->back;
1238-
u16 q_idx = 0, i;
1236+
u16 q_idx = 0;
12391237
int err = 0;
1240-
u8 tc;
12411238

1242-
qg_buf = devm_kzalloc(&pf->pdev->dev, sizeof(*qg_buf), GFP_KERNEL);
1239+
qg_buf = kzalloc(sizeof(*qg_buf), GFP_KERNEL);
12431240
if (!qg_buf)
12441241
return -ENOMEM;
12451242

12461243
qg_buf->num_txqs = 1;
12471244

1248-
/* set up and configure the Tx queues for each enabled TC */
1249-
ice_for_each_traffic_class(tc) {
1250-
if (!(vsi->tc_cfg.ena_tc & BIT(tc)))
1251-
break;
1252-
1253-
for (i = 0; i < vsi->tc_cfg.tc_info[tc].qcount_tx; i++) {
1254-
err = ice_vsi_cfg_txq(vsi, rings[q_idx], i + offset,
1255-
qg_buf, tc);
1256-
if (err)
1257-
goto err_cfg_txqs;
1258-
1259-
q_idx++;
1260-
}
1245+
for (q_idx = 0; q_idx < vsi->num_txq; q_idx++) {
1246+
err = ice_vsi_cfg_txq(vsi, rings[q_idx], qg_buf);
1247+
if (err)
1248+
goto err_cfg_txqs;
12611249
}
1250+
12621251
err_cfg_txqs:
1263-
devm_kfree(&pf->pdev->dev, qg_buf);
1252+
kfree(qg_buf);
12641253
return err;
12651254
}
12661255

@@ -1273,7 +1262,7 @@ ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings, int offset)
12731262
*/
12741263
int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi)
12751264
{
1276-
return ice_vsi_cfg_txqs(vsi, vsi->tx_rings, 0);
1265+
return ice_vsi_cfg_txqs(vsi, vsi->tx_rings);
12771266
}
12781267

12791268
/**
@@ -1463,34 +1452,24 @@ static int
14631452
ice_vsi_stop_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src,
14641453
u16 rel_vmvf_num, struct ice_ring **rings)
14651454
{
1466-
u16 i, q_idx = 0;
1467-
int status;
1468-
u8 tc;
1455+
u16 q_idx;
14691456

14701457
if (vsi->num_txq > ICE_LAN_TXQ_MAX_QDIS)
14711458
return -EINVAL;
14721459

1473-
/* set up the Tx queue list to be disabled for each enabled TC */
1474-
ice_for_each_traffic_class(tc) {
1475-
if (!(vsi->tc_cfg.ena_tc & BIT(tc)))
1476-
break;
1477-
1478-
for (i = 0; i < vsi->tc_cfg.tc_info[tc].qcount_tx; i++) {
1479-
struct ice_txq_meta txq_meta = { };
1460+
for (q_idx = 0; q_idx < vsi->num_txq; q_idx++) {
1461+
struct ice_txq_meta txq_meta = { };
1462+
int status;
14801463

1481-
if (!rings || !rings[q_idx])
1482-
return -EINVAL;
1464+
if (!rings || !rings[q_idx])
1465+
return -EINVAL;
14831466

1484-
ice_fill_txq_meta(vsi, rings[q_idx], &txq_meta);
1485-
status = ice_vsi_stop_tx_ring(vsi, rst_src,
1486-
rel_vmvf_num,
1487-
rings[q_idx], &txq_meta);
1467+
ice_fill_txq_meta(vsi, rings[q_idx], &txq_meta);
1468+
status = ice_vsi_stop_tx_ring(vsi, rst_src, rel_vmvf_num,
1469+
rings[q_idx], &txq_meta);
14881470

1489-
if (status)
1490-
return status;
1491-
1492-
q_idx++;
1493-
}
1471+
if (status)
1472+
return status;
14941473
}
14951474

14961475
return 0;

0 commit comments

Comments
 (0)