Skip to content

Commit 086c18f

Browse files
emuslndavem330
authored andcommitted
ionic: centralize queue reset code
The queue reset pattern is used in a couple different places, only slightly different from each other, and could cause issues if one gets changed and the other didn't. This puts them together so that only one version is needed, yet each can have slighty different effects by passing in a pointer to a work function to do whatever configuration twiddling is needed in the middle of the reset. This specifically addresses issues seen where under loops of changing ring size or queue count parameters we could occasionally bump into the netdev watchdog. v2: added more commit message commentary Fixes: 4d03e00 ("ionic: Add initial ethtool support") Signed-off-by: Shannon Nelson <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 469aced commit 086c18f

File tree

3 files changed

+32
-41
lines changed

3 files changed

+32
-41
lines changed

drivers/net/ethernet/pensando/ionic/ionic_ethtool.c

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,18 @@ static void ionic_get_ringparam(struct net_device *netdev,
468468
ring->rx_pending = lif->nrxq_descs;
469469
}
470470

471+
static void ionic_set_ringsize(struct ionic_lif *lif, void *arg)
472+
{
473+
struct ethtool_ringparam *ring = arg;
474+
475+
lif->ntxq_descs = ring->tx_pending;
476+
lif->nrxq_descs = ring->rx_pending;
477+
}
478+
471479
static int ionic_set_ringparam(struct net_device *netdev,
472480
struct ethtool_ringparam *ring)
473481
{
474482
struct ionic_lif *lif = netdev_priv(netdev);
475-
bool running;
476-
int err;
477483

478484
if (ring->rx_mini_pending || ring->rx_jumbo_pending) {
479485
netdev_info(netdev, "Changing jumbo or mini descriptors not supported\n");
@@ -491,22 +497,7 @@ static int ionic_set_ringparam(struct net_device *netdev,
491497
ring->rx_pending == lif->nrxq_descs)
492498
return 0;
493499

494-
err = ionic_wait_for_bit(lif, IONIC_LIF_F_QUEUE_RESET);
495-
if (err)
496-
return err;
497-
498-
running = test_bit(IONIC_LIF_F_UP, lif->state);
499-
if (running)
500-
ionic_stop(netdev);
501-
502-
lif->ntxq_descs = ring->tx_pending;
503-
lif->nrxq_descs = ring->rx_pending;
504-
505-
if (running)
506-
ionic_open(netdev);
507-
clear_bit(IONIC_LIF_F_QUEUE_RESET, lif->state);
508-
509-
return 0;
500+
return ionic_reset_queues(lif, ionic_set_ringsize, ring);
510501
}
511502

512503
static void ionic_get_channels(struct net_device *netdev,
@@ -521,12 +512,17 @@ static void ionic_get_channels(struct net_device *netdev,
521512
ch->combined_count = lif->nxqs;
522513
}
523514

515+
static void ionic_set_queuecount(struct ionic_lif *lif, void *arg)
516+
{
517+
struct ethtool_channels *ch = arg;
518+
519+
lif->nxqs = ch->combined_count;
520+
}
521+
524522
static int ionic_set_channels(struct net_device *netdev,
525523
struct ethtool_channels *ch)
526524
{
527525
struct ionic_lif *lif = netdev_priv(netdev);
528-
bool running;
529-
int err;
530526

531527
if (!ch->combined_count || ch->other_count ||
532528
ch->rx_count || ch->tx_count)
@@ -535,21 +531,7 @@ static int ionic_set_channels(struct net_device *netdev,
535531
if (ch->combined_count == lif->nxqs)
536532
return 0;
537533

538-
err = ionic_wait_for_bit(lif, IONIC_LIF_F_QUEUE_RESET);
539-
if (err)
540-
return err;
541-
542-
running = test_bit(IONIC_LIF_F_UP, lif->state);
543-
if (running)
544-
ionic_stop(netdev);
545-
546-
lif->nxqs = ch->combined_count;
547-
548-
if (running)
549-
ionic_open(netdev);
550-
clear_bit(IONIC_LIF_F_QUEUE_RESET, lif->state);
551-
552-
return 0;
534+
return ionic_reset_queues(lif, ionic_set_queuecount, ch);
553535
}
554536

555537
static u32 ionic_get_priv_flags(struct net_device *netdev)

drivers/net/ethernet/pensando/ionic/ionic_lif.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ static int ionic_change_mtu(struct net_device *netdev, int new_mtu)
13131313
return err;
13141314

13151315
netdev->mtu = new_mtu;
1316-
err = ionic_reset_queues(lif);
1316+
err = ionic_reset_queues(lif, NULL, NULL);
13171317

13181318
return err;
13191319
}
@@ -1325,7 +1325,7 @@ static void ionic_tx_timeout_work(struct work_struct *ws)
13251325
netdev_info(lif->netdev, "Tx Timeout recovery\n");
13261326

13271327
rtnl_lock();
1328-
ionic_reset_queues(lif);
1328+
ionic_reset_queues(lif, NULL, NULL);
13291329
rtnl_unlock();
13301330
}
13311331

@@ -1988,7 +1988,7 @@ static const struct net_device_ops ionic_netdev_ops = {
19881988
.ndo_get_vf_stats = ionic_get_vf_stats,
19891989
};
19901990

1991-
int ionic_reset_queues(struct ionic_lif *lif)
1991+
int ionic_reset_queues(struct ionic_lif *lif, ionic_reset_cb cb, void *arg)
19921992
{
19931993
bool running;
19941994
int err = 0;
@@ -2001,12 +2001,19 @@ int ionic_reset_queues(struct ionic_lif *lif)
20012001
if (running) {
20022002
netif_device_detach(lif->netdev);
20032003
err = ionic_stop(lif->netdev);
2004+
if (err)
2005+
goto reset_out;
20042006
}
2005-
if (!err && running) {
2006-
ionic_open(lif->netdev);
2007+
2008+
if (cb)
2009+
cb(lif, arg);
2010+
2011+
if (running) {
2012+
err = ionic_open(lif->netdev);
20072013
netif_device_attach(lif->netdev);
20082014
}
20092015

2016+
reset_out:
20102017
clear_bit(IONIC_LIF_F_QUEUE_RESET, lif->state);
20112018

20122019
return err;

drivers/net/ethernet/pensando/ionic/ionic_lif.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ static inline u32 ionic_coal_hw_to_usec(struct ionic *ionic, u32 units)
248248
return (units * div) / mult;
249249
}
250250

251+
typedef void (*ionic_reset_cb)(struct ionic_lif *lif, void *arg);
252+
251253
void ionic_link_status_check_request(struct ionic_lif *lif);
252254
void ionic_get_stats64(struct net_device *netdev,
253255
struct rtnl_link_stats64 *ns);
@@ -267,7 +269,7 @@ int ionic_lif_rss_config(struct ionic_lif *lif, u16 types,
267269

268270
int ionic_open(struct net_device *netdev);
269271
int ionic_stop(struct net_device *netdev);
270-
int ionic_reset_queues(struct ionic_lif *lif);
272+
int ionic_reset_queues(struct ionic_lif *lif, ionic_reset_cb cb, void *arg);
271273

272274
static inline void debug_stats_txq_post(struct ionic_qcq *qcq,
273275
struct ionic_txq_desc *desc, bool dbell)

0 commit comments

Comments
 (0)