Skip to content

Commit 101b40a

Browse files
emuslndavem330
authored andcommitted
ionic: change queue count with no reset
Add to our new ionic_reconfigure_queues() to also be able to change the number of queues in use, and to change the queue interrupt layout between split and combined. Signed-off-by: Shannon Nelson <snelson@pensando.io> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a34e25a commit 101b40a

File tree

2 files changed

+213
-91
lines changed

2 files changed

+213
-91
lines changed

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

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -561,53 +561,79 @@ static void ionic_get_channels(struct net_device *netdev,
561561
}
562562
}
563563

564-
static void ionic_set_queuecount(struct ionic_lif *lif, void *arg)
565-
{
566-
struct ethtool_channels *ch = arg;
567-
568-
if (ch->combined_count) {
569-
lif->nxqs = ch->combined_count;
570-
if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) {
571-
clear_bit(IONIC_LIF_F_SPLIT_INTR, lif->state);
572-
lif->tx_coalesce_usecs = lif->rx_coalesce_usecs;
573-
lif->tx_coalesce_hw = lif->rx_coalesce_hw;
574-
netdev_info(lif->netdev, "Sharing queue interrupts\n");
575-
}
576-
} else {
577-
lif->nxqs = ch->rx_count;
578-
if (!test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) {
579-
set_bit(IONIC_LIF_F_SPLIT_INTR, lif->state);
580-
netdev_info(lif->netdev, "Splitting queue interrupts\n");
581-
}
582-
}
583-
}
584-
585564
static int ionic_set_channels(struct net_device *netdev,
586565
struct ethtool_channels *ch)
587566
{
588567
struct ionic_lif *lif = netdev_priv(netdev);
589-
int new_cnt;
568+
struct ionic_queue_params qparam;
569+
int max_cnt;
570+
int err;
571+
572+
ionic_init_queue_params(lif, &qparam);
590573

591574
if (ch->rx_count != ch->tx_count) {
592575
netdev_info(netdev, "The rx and tx count must be equal\n");
593576
return -EINVAL;
594577
}
595578

596579
if (ch->combined_count && ch->rx_count) {
597-
netdev_info(netdev, "Use either combined_count or rx/tx_count, not both\n");
580+
netdev_info(netdev, "Use either combined or rx and tx, not both\n");
598581
return -EINVAL;
599582
}
600583

601-
if (ch->combined_count)
602-
new_cnt = ch->combined_count;
603-
else
604-
new_cnt = ch->rx_count;
584+
max_cnt = lif->ionic->ntxqs_per_lif;
585+
if (ch->combined_count) {
586+
if (ch->combined_count > max_cnt)
587+
return -EINVAL;
588+
589+
if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state))
590+
netdev_info(lif->netdev, "Sharing queue interrupts\n");
591+
else if (ch->combined_count == lif->nxqs)
592+
return 0;
605593

606-
if (lif->nxqs != new_cnt)
607-
netdev_info(netdev, "Changing queue count from %d to %d\n",
608-
lif->nxqs, new_cnt);
594+
if (lif->nxqs != ch->combined_count)
595+
netdev_info(netdev, "Changing queue count from %d to %d\n",
596+
lif->nxqs, ch->combined_count);
609597

610-
return ionic_reset_queues(lif, ionic_set_queuecount, ch);
598+
qparam.nxqs = ch->combined_count;
599+
qparam.intr_split = 0;
600+
} else {
601+
max_cnt /= 2;
602+
if (ch->rx_count > max_cnt)
603+
return -EINVAL;
604+
605+
if (!test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state))
606+
netdev_info(lif->netdev, "Splitting queue interrupts\n");
607+
else if (ch->rx_count == lif->nxqs)
608+
return 0;
609+
610+
if (lif->nxqs != ch->rx_count)
611+
netdev_info(netdev, "Changing queue count from %d to %d\n",
612+
lif->nxqs, ch->rx_count);
613+
614+
qparam.nxqs = ch->rx_count;
615+
qparam.intr_split = 1;
616+
}
617+
618+
/* if we're not running, just set the values and return */
619+
if (!netif_running(lif->netdev)) {
620+
lif->nxqs = qparam.nxqs;
621+
622+
if (qparam.intr_split) {
623+
set_bit(IONIC_LIF_F_SPLIT_INTR, lif->state);
624+
} else {
625+
clear_bit(IONIC_LIF_F_SPLIT_INTR, lif->state);
626+
lif->tx_coalesce_usecs = lif->rx_coalesce_usecs;
627+
lif->tx_coalesce_hw = lif->rx_coalesce_hw;
628+
}
629+
return 0;
630+
}
631+
632+
err = ionic_reconfigure_queues(lif, &qparam);
633+
if (err)
634+
netdev_info(netdev, "Queue reconfiguration failed, changes canceled: %d\n", err);
635+
636+
return err;
611637
}
612638

613639
static u32 ionic_get_priv_flags(struct net_device *netdev)

0 commit comments

Comments
 (0)