Skip to content

Commit 557d022

Browse files
ahduyckkuba-moo
authored andcommitted
eth: fbnic: centralize the queue count and NAPI<>queue setting
To simplify dealing with RTNL_ASSERT() requirements further down the line, move setting queue count and NAPI<>queue association to their own helpers. Signed-off-by: Alexander Duyck <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3a856ab commit 557d022

File tree

3 files changed

+70
-33
lines changed

3 files changed

+70
-33
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_netdev.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ int __fbnic_open(struct fbnic_net *fbn)
2323
if (err)
2424
goto free_napi_vectors;
2525

26-
err = netif_set_real_num_tx_queues(fbn->netdev,
27-
fbn->num_tx_queues);
28-
if (err)
29-
goto free_resources;
30-
31-
err = netif_set_real_num_rx_queues(fbn->netdev,
32-
fbn->num_rx_queues);
26+
err = fbnic_set_netif_queues(fbn);
3327
if (err)
3428
goto free_resources;
3529

@@ -93,6 +87,7 @@ static int fbnic_stop(struct net_device *netdev)
9387
fbnic_time_stop(fbn);
9488
fbnic_fw_xmit_ownership_msg(fbn->fbd, false);
9589

90+
fbnic_reset_netif_queues(fbn);
9691
fbnic_free_resources(fbn);
9792
fbnic_free_napi_vectors(fbn);
9893

drivers/net/ethernet/meta/fbnic/fbnic_txrx.c

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,71 @@ int fbnic_alloc_resources(struct fbnic_net *fbn)
16211621
return err;
16221622
}
16231623

1624+
static void fbnic_set_netif_napi(struct fbnic_napi_vector *nv)
1625+
{
1626+
int i, j;
1627+
1628+
/* Associate Tx queue with NAPI */
1629+
for (i = 0; i < nv->txt_count; i++) {
1630+
struct fbnic_q_triad *qt = &nv->qt[i];
1631+
1632+
netif_queue_set_napi(nv->napi.dev, qt->sub0.q_idx,
1633+
NETDEV_QUEUE_TYPE_TX, &nv->napi);
1634+
}
1635+
1636+
/* Associate Rx queue with NAPI */
1637+
for (j = 0; j < nv->rxt_count; j++, i++) {
1638+
struct fbnic_q_triad *qt = &nv->qt[i];
1639+
1640+
netif_queue_set_napi(nv->napi.dev, qt->cmpl.q_idx,
1641+
NETDEV_QUEUE_TYPE_RX, &nv->napi);
1642+
}
1643+
}
1644+
1645+
static void fbnic_reset_netif_napi(struct fbnic_napi_vector *nv)
1646+
{
1647+
int i, j;
1648+
1649+
/* Disassociate Tx queue from NAPI */
1650+
for (i = 0; i < nv->txt_count; i++) {
1651+
struct fbnic_q_triad *qt = &nv->qt[i];
1652+
1653+
netif_queue_set_napi(nv->napi.dev, qt->sub0.q_idx,
1654+
NETDEV_QUEUE_TYPE_TX, NULL);
1655+
}
1656+
1657+
/* Disassociate Rx queue from NAPI */
1658+
for (j = 0; j < nv->rxt_count; j++, i++) {
1659+
struct fbnic_q_triad *qt = &nv->qt[i];
1660+
1661+
netif_queue_set_napi(nv->napi.dev, qt->cmpl.q_idx,
1662+
NETDEV_QUEUE_TYPE_RX, NULL);
1663+
}
1664+
}
1665+
1666+
int fbnic_set_netif_queues(struct fbnic_net *fbn)
1667+
{
1668+
int i, err;
1669+
1670+
err = netif_set_real_num_queues(fbn->netdev, fbn->num_tx_queues,
1671+
fbn->num_rx_queues);
1672+
if (err)
1673+
return err;
1674+
1675+
for (i = 0; i < fbn->num_napi; i++)
1676+
fbnic_set_netif_napi(fbn->napi[i]);
1677+
1678+
return 0;
1679+
}
1680+
1681+
void fbnic_reset_netif_queues(struct fbnic_net *fbn)
1682+
{
1683+
int i;
1684+
1685+
for (i = 0; i < fbn->num_napi; i++)
1686+
fbnic_reset_netif_napi(fbn->napi[i]);
1687+
}
1688+
16241689
static void fbnic_disable_twq0(struct fbnic_ring *txr)
16251690
{
16261691
u32 twq_ctl = fbnic_ring_rd32(txr, FBNIC_QUEUE_TWQ0_CTL);
@@ -1801,10 +1866,6 @@ void fbnic_flush(struct fbnic_net *fbn)
18011866
tx_queue = netdev_get_tx_queue(nv->napi.dev,
18021867
qt->sub0.q_idx);
18031868
netdev_tx_reset_queue(tx_queue);
1804-
1805-
/* Disassociate Tx queue from NAPI */
1806-
netif_queue_set_napi(nv->napi.dev, qt->sub0.q_idx,
1807-
NETDEV_QUEUE_TYPE_TX, NULL);
18081869
}
18091870

18101871
/* Flush any processed Rx Queue Triads and drop the rest */
@@ -1820,10 +1881,6 @@ void fbnic_flush(struct fbnic_net *fbn)
18201881

18211882
fbnic_put_pkt_buff(nv, qt->cmpl.pkt, 0);
18221883
qt->cmpl.pkt->buff.data_hard_start = NULL;
1823-
1824-
/* Disassociate Rx queue from NAPI */
1825-
netif_queue_set_napi(nv->napi.dev, qt->cmpl.q_idx,
1826-
NETDEV_QUEUE_TYPE_RX, NULL);
18271884
}
18281885
}
18291886
}
@@ -1836,29 +1893,12 @@ void fbnic_fill(struct fbnic_net *fbn)
18361893
struct fbnic_napi_vector *nv = fbn->napi[i];
18371894
int j, t;
18381895

1839-
/* Configure NAPI mapping for Tx */
1840-
for (t = 0; t < nv->txt_count; t++) {
1841-
struct fbnic_q_triad *qt = &nv->qt[t];
1842-
1843-
/* Nothing to do if Tx queue is disabled */
1844-
if (qt->sub0.flags & FBNIC_RING_F_DISABLED)
1845-
continue;
1846-
1847-
/* Associate Tx queue with NAPI */
1848-
netif_queue_set_napi(nv->napi.dev, qt->sub0.q_idx,
1849-
NETDEV_QUEUE_TYPE_TX, &nv->napi);
1850-
}
1851-
18521896
/* Configure NAPI mapping and populate pages
18531897
* in the BDQ rings to use for Rx
18541898
*/
1855-
for (j = 0; j < nv->rxt_count; j++, t++) {
1899+
for (j = 0, t = nv->txt_count; j < nv->rxt_count; j++, t++) {
18561900
struct fbnic_q_triad *qt = &nv->qt[t];
18571901

1858-
/* Associate Rx queue with NAPI */
1859-
netif_queue_set_napi(nv->napi.dev, qt->cmpl.q_idx,
1860-
NETDEV_QUEUE_TYPE_RX, &nv->napi);
1861-
18621902
/* Populate the header and payload BDQs */
18631903
fbnic_fill_bdq(nv, &qt->sub0);
18641904
fbnic_fill_bdq(nv, &qt->sub1);

drivers/net/ethernet/meta/fbnic/fbnic_txrx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ int fbnic_alloc_napi_vectors(struct fbnic_net *fbn);
124124
void fbnic_free_napi_vectors(struct fbnic_net *fbn);
125125
int fbnic_alloc_resources(struct fbnic_net *fbn);
126126
void fbnic_free_resources(struct fbnic_net *fbn);
127+
int fbnic_set_netif_queues(struct fbnic_net *fbn);
128+
void fbnic_reset_netif_queues(struct fbnic_net *fbn);
127129
irqreturn_t fbnic_msix_clean_rings(int irq, void *data);
128130
void fbnic_napi_enable(struct fbnic_net *fbn);
129131
void fbnic_napi_disable(struct fbnic_net *fbn);

0 commit comments

Comments
 (0)