Skip to content

Commit 2faf63b

Browse files
mfijalkoanguy11
authored andcommitted
ice: make use of ice_for_each_* macros
Go through the code base and use ice_for_each_* macros. While at it, introduce ice_for_each_xdp_txq() macro that can be used for looping over xdp_rings array. Commit is not introducing any new functionality. Signed-off-by: Maciej Fijalkowski <[email protected]> Tested-by: Gurucharan G <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 22bf877 commit 2faf63b

File tree

6 files changed

+30
-27
lines changed

6 files changed

+30
-27
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,13 @@
125125
#define ice_for_each_vsi(pf, i) \
126126
for ((i) = 0; (i) < (pf)->num_alloc_vsi; (i)++)
127127

128-
/* Macros for each Tx/Rx ring in a VSI */
128+
/* Macros for each Tx/Xdp/Rx ring in a VSI */
129129
#define ice_for_each_txq(vsi, i) \
130130
for ((i) = 0; (i) < (vsi)->num_txq; (i)++)
131131

132+
#define ice_for_each_xdp_txq(vsi, i) \
133+
for ((i) = 0; (i) < (vsi)->num_xdp_txq; (i)++)
134+
132135
#define ice_for_each_rxq(vsi, i) \
133136
for ((i) = 0; (i) < (vsi)->num_rxq; (i)++)
134137

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ int ice_set_cpu_rx_rmap(struct ice_vsi *vsi)
614614
return -EINVAL;
615615

616616
base_idx = vsi->base_vector;
617-
for (i = 0; i < vsi->num_q_vectors; i++)
617+
ice_for_each_q_vector(vsi, i)
618618
if (irq_cpu_rmap_add(netdev->rx_cpu_rmap,
619619
pf->msix_entries[base_idx + i].vector)) {
620620
ice_free_cpu_rx_rmap(vsi);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi)
201201

202202
if (!test_bit(ICE_FLAG_DCB_ENA, vsi->back->flags)) {
203203
/* Reset the TC information */
204-
for (i = 0; i < vsi->num_txq; i++) {
204+
ice_for_each_txq(vsi, i) {
205205
tx_ring = vsi->tx_rings[i];
206206
tx_ring->dcb_tc = 0;
207207
}
208-
for (i = 0; i < vsi->num_rxq; i++) {
208+
ice_for_each_rxq(vsi, i) {
209209
rx_ring = vsi->rx_rings[i];
210210
rx_ring->dcb_tc = 0;
211211
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,12 +2756,12 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
27562756

27572757
/* set for the next time the netdev is started */
27582758
if (!netif_running(vsi->netdev)) {
2759-
for (i = 0; i < vsi->alloc_txq; i++)
2759+
ice_for_each_alloc_txq(vsi, i)
27602760
vsi->tx_rings[i]->count = new_tx_cnt;
2761-
for (i = 0; i < vsi->alloc_rxq; i++)
2761+
ice_for_each_alloc_rxq(vsi, i)
27622762
vsi->rx_rings[i]->count = new_rx_cnt;
27632763
if (ice_is_xdp_ena_vsi(vsi))
2764-
for (i = 0; i < vsi->num_xdp_txq; i++)
2764+
ice_for_each_xdp_txq(vsi, i)
27652765
vsi->xdp_rings[i]->count = new_tx_cnt;
27662766
vsi->num_tx_desc = (u16)new_tx_cnt;
27672767
vsi->num_rx_desc = (u16)new_rx_cnt;
@@ -2810,7 +2810,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
28102810
goto free_tx;
28112811
}
28122812

2813-
for (i = 0; i < vsi->num_xdp_txq; i++) {
2813+
ice_for_each_xdp_txq(vsi, i) {
28142814
/* clone ring and setup updated count */
28152815
xdp_rings[i] = *vsi->xdp_rings[i];
28162816
xdp_rings[i].count = new_tx_cnt;
@@ -2904,7 +2904,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
29042904
}
29052905

29062906
if (xdp_rings) {
2907-
for (i = 0; i < vsi->num_xdp_txq; i++) {
2907+
ice_for_each_xdp_txq(vsi, i) {
29082908
ice_free_tx_ring(vsi->xdp_rings[i]);
29092909
*vsi->xdp_rings[i] = xdp_rings[i];
29102910
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ static int ice_vsi_ctrl_all_rx_rings(struct ice_vsi *vsi, bool ena)
4646
int ret = 0;
4747
u16 i;
4848

49-
for (i = 0; i < vsi->num_rxq; i++)
49+
ice_for_each_rxq(vsi, i)
5050
ice_vsi_ctrl_one_rx_ring(vsi, ena, i, false);
5151

5252
ice_flush(&vsi->back->hw);
5353

54-
for (i = 0; i < vsi->num_rxq; i++) {
54+
ice_for_each_rxq(vsi, i) {
5555
ret = ice_vsi_wait_one_rx_ring(vsi, ena, i);
5656
if (ret)
5757
break;
@@ -639,12 +639,12 @@ static void ice_vsi_put_qs(struct ice_vsi *vsi)
639639

640640
mutex_lock(&pf->avail_q_mutex);
641641

642-
for (i = 0; i < vsi->alloc_txq; i++) {
642+
ice_for_each_alloc_txq(vsi, i) {
643643
clear_bit(vsi->txq_map[i], pf->avail_txqs);
644644
vsi->txq_map[i] = ICE_INVAL_Q_INDEX;
645645
}
646646

647-
for (i = 0; i < vsi->alloc_rxq; i++) {
647+
ice_for_each_alloc_rxq(vsi, i) {
648648
clear_bit(vsi->rxq_map[i], pf->avail_rxqs);
649649
vsi->rxq_map[i] = ICE_INVAL_Q_INDEX;
650650
}
@@ -1298,15 +1298,15 @@ static void ice_vsi_clear_rings(struct ice_vsi *vsi)
12981298
}
12991299

13001300
if (vsi->tx_rings) {
1301-
for (i = 0; i < vsi->alloc_txq; i++) {
1301+
ice_for_each_alloc_txq(vsi, i) {
13021302
if (vsi->tx_rings[i]) {
13031303
kfree_rcu(vsi->tx_rings[i], rcu);
13041304
WRITE_ONCE(vsi->tx_rings[i], NULL);
13051305
}
13061306
}
13071307
}
13081308
if (vsi->rx_rings) {
1309-
for (i = 0; i < vsi->alloc_rxq; i++) {
1309+
ice_for_each_alloc_rxq(vsi, i) {
13101310
if (vsi->rx_rings[i]) {
13111311
kfree_rcu(vsi->rx_rings[i], rcu);
13121312
WRITE_ONCE(vsi->rx_rings[i], NULL);
@@ -1327,7 +1327,7 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi)
13271327

13281328
dev = ice_pf_to_dev(pf);
13291329
/* Allocate Tx rings */
1330-
for (i = 0; i < vsi->alloc_txq; i++) {
1330+
ice_for_each_alloc_txq(vsi, i) {
13311331
struct ice_tx_ring *ring;
13321332

13331333
/* allocate with kzalloc(), free with kfree_rcu() */
@@ -1346,7 +1346,7 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi)
13461346
}
13471347

13481348
/* Allocate Rx rings */
1349-
for (i = 0; i < vsi->alloc_rxq; i++) {
1349+
ice_for_each_alloc_rxq(vsi, i) {
13501350
struct ice_rx_ring *ring;
13511351

13521352
/* allocate with kzalloc(), free with kfree_rcu() */
@@ -1857,7 +1857,7 @@ int ice_vsi_cfg_xdp_txqs(struct ice_vsi *vsi)
18571857
if (ret)
18581858
return ret;
18591859

1860-
for (i = 0; i < vsi->num_xdp_txq; i++)
1860+
ice_for_each_xdp_txq(vsi, i)
18611861
vsi->xdp_rings[i]->xsk_pool = ice_tx_xsk_pool(vsi->xdp_rings[i]);
18621862

18631863
return ret;
@@ -1955,7 +1955,7 @@ void ice_vsi_cfg_msix(struct ice_vsi *vsi)
19551955
u16 txq = 0, rxq = 0;
19561956
int i, q;
19571957

1958-
for (i = 0; i < vsi->num_q_vectors; i++) {
1958+
ice_for_each_q_vector(vsi, i) {
19591959
struct ice_q_vector *q_vector = vsi->q_vectors[i];
19601960
u16 reg_idx = q_vector->reg_idx;
19611961

@@ -2649,7 +2649,7 @@ static void ice_vsi_release_msix(struct ice_vsi *vsi)
26492649
u32 rxq = 0;
26502650
int i, q;
26512651

2652-
for (i = 0; i < vsi->num_q_vectors; i++) {
2652+
ice_for_each_q_vector(vsi, i) {
26532653
struct ice_q_vector *q_vector = vsi->q_vectors[i];
26542654

26552655
ice_write_intrl(q_vector, 0);

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void ice_check_for_hang_subtask(struct ice_pf *pf)
103103

104104
hw = &vsi->back->hw;
105105

106-
for (i = 0; i < vsi->num_txq; i++) {
106+
ice_for_each_txq(vsi, i) {
107107
struct ice_tx_ring *tx_ring = vsi->tx_rings[i];
108108

109109
if (tx_ring && tx_ring->desc) {
@@ -2377,7 +2377,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)
23772377
struct ice_tx_desc *tx_desc;
23782378
int i, j;
23792379

2380-
for (i = 0; i < vsi->num_xdp_txq; i++) {
2380+
ice_for_each_xdp_txq(vsi, i) {
23812381
u16 xdp_q_idx = vsi->alloc_txq + i;
23822382
struct ice_tx_ring *xdp_ring;
23832383

@@ -2526,15 +2526,15 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog)
25262526

25272527
return 0;
25282528
clear_xdp_rings:
2529-
for (i = 0; i < vsi->num_xdp_txq; i++)
2529+
ice_for_each_xdp_txq(vsi, i)
25302530
if (vsi->xdp_rings[i]) {
25312531
kfree_rcu(vsi->xdp_rings[i], rcu);
25322532
vsi->xdp_rings[i] = NULL;
25332533
}
25342534

25352535
err_map_xdp:
25362536
mutex_lock(&pf->avail_q_mutex);
2537-
for (i = 0; i < vsi->num_xdp_txq; i++) {
2537+
ice_for_each_xdp_txq(vsi, i) {
25382538
clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs);
25392539
vsi->txq_map[i + vsi->alloc_txq] = ICE_INVAL_Q_INDEX;
25402540
}
@@ -2579,13 +2579,13 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi)
25792579

25802580
free_qmap:
25812581
mutex_lock(&pf->avail_q_mutex);
2582-
for (i = 0; i < vsi->num_xdp_txq; i++) {
2582+
ice_for_each_xdp_txq(vsi, i) {
25832583
clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs);
25842584
vsi->txq_map[i + vsi->alloc_txq] = ICE_INVAL_Q_INDEX;
25852585
}
25862586
mutex_unlock(&pf->avail_q_mutex);
25872587

2588-
for (i = 0; i < vsi->num_xdp_txq; i++)
2588+
ice_for_each_xdp_txq(vsi, i)
25892589
if (vsi->xdp_rings[i]) {
25902590
if (vsi->xdp_rings[i]->desc)
25912591
ice_free_tx_ring(vsi->xdp_rings[i]);
@@ -7066,7 +7066,7 @@ static void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue)
70667066
}
70677067

70687068
/* now that we have an index, find the tx_ring struct */
7069-
for (i = 0; i < vsi->num_txq; i++)
7069+
ice_for_each_txq(vsi, i)
70707070
if (vsi->tx_rings[i] && vsi->tx_rings[i]->desc)
70717071
if (txqueue == vsi->tx_rings[i]->q_index) {
70727072
tx_ring = vsi->tx_rings[i];

0 commit comments

Comments
 (0)