Skip to content

Commit 3a481cc

Browse files
committed
eth: fbnic: support ring channel get and set while down
Trivial implementation of ethtool channel get and set. Set is only supported when device is closed, next patch will add code for live reconfig. Asymmetric configurations are supported (combined + extra Tx or Rx), so are configurations with independent IRQs for Rx and Tx. Having all 3 NAPI types (combined, Tx, Rx) is not supported. We used to only call fbnic_reset_indir_tbl() during init. Now that we call it after device had been register must be careful not to override user config. Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 557d022 commit 3a481cc

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,68 @@ fbnic_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
304304
return 0;
305305
}
306306

307+
static void fbnic_get_channels(struct net_device *netdev,
308+
struct ethtool_channels *ch)
309+
{
310+
struct fbnic_net *fbn = netdev_priv(netdev);
311+
struct fbnic_dev *fbd = fbn->fbd;
312+
313+
ch->max_rx = fbd->max_num_queues;
314+
ch->max_tx = fbd->max_num_queues;
315+
ch->max_combined = min(ch->max_rx, ch->max_tx);
316+
ch->max_other = FBNIC_NON_NAPI_VECTORS;
317+
318+
if (fbn->num_rx_queues > fbn->num_napi ||
319+
fbn->num_tx_queues > fbn->num_napi)
320+
ch->combined_count = min(fbn->num_rx_queues,
321+
fbn->num_tx_queues);
322+
else
323+
ch->combined_count =
324+
fbn->num_rx_queues + fbn->num_tx_queues - fbn->num_napi;
325+
ch->rx_count = fbn->num_rx_queues - ch->combined_count;
326+
ch->tx_count = fbn->num_tx_queues - ch->combined_count;
327+
ch->other_count = FBNIC_NON_NAPI_VECTORS;
328+
}
329+
330+
static void fbnic_set_queues(struct fbnic_net *fbn, struct ethtool_channels *ch,
331+
unsigned int max_napis)
332+
{
333+
fbn->num_rx_queues = ch->rx_count + ch->combined_count;
334+
fbn->num_tx_queues = ch->tx_count + ch->combined_count;
335+
fbn->num_napi = min(ch->rx_count + ch->tx_count + ch->combined_count,
336+
max_napis);
337+
}
338+
339+
static int fbnic_set_channels(struct net_device *netdev,
340+
struct ethtool_channels *ch)
341+
{
342+
struct fbnic_net *fbn = netdev_priv(netdev);
343+
unsigned int max_napis, standalone;
344+
struct fbnic_dev *fbd = fbn->fbd;
345+
346+
max_napis = fbd->num_irqs - FBNIC_NON_NAPI_VECTORS;
347+
standalone = ch->rx_count + ch->tx_count;
348+
349+
/* Limits for standalone queues:
350+
* - each queue has it's own NAPI (num_napi >= rx + tx + combined)
351+
* - combining queues (combined not 0, rx or tx must be 0)
352+
*/
353+
if ((ch->rx_count && ch->tx_count && ch->combined_count) ||
354+
(standalone && standalone + ch->combined_count > max_napis) ||
355+
ch->rx_count + ch->combined_count > fbd->max_num_queues ||
356+
ch->tx_count + ch->combined_count > fbd->max_num_queues ||
357+
ch->other_count != FBNIC_NON_NAPI_VECTORS)
358+
return -EINVAL;
359+
360+
if (!netif_running(netdev)) {
361+
fbnic_set_queues(fbn, ch, max_napis);
362+
fbnic_reset_indir_tbl(fbn);
363+
return 0;
364+
}
365+
366+
return -EBUSY;
367+
}
368+
307369
static int
308370
fbnic_get_ts_info(struct net_device *netdev,
309371
struct kernel_ethtool_ts_info *tsinfo)
@@ -417,6 +479,8 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
417479
.get_rxfh_indir_size = fbnic_get_rxfh_indir_size,
418480
.get_rxfh = fbnic_get_rxfh,
419481
.set_rxfh = fbnic_set_rxfh,
482+
.get_channels = fbnic_get_channels,
483+
.set_channels = fbnic_set_channels,
420484
.get_ts_info = fbnic_get_ts_info,
421485
.get_ts_stats = fbnic_get_ts_stats,
422486
.get_eth_mac_stats = fbnic_get_eth_mac_stats,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ void fbnic_reset_indir_tbl(struct fbnic_net *fbn)
1313
unsigned int num_rx = fbn->num_rx_queues;
1414
unsigned int i;
1515

16+
if (netif_is_rxfh_configured(fbn->netdev))
17+
return;
18+
1619
for (i = 0; i < FBNIC_RPC_RSS_TBL_SIZE; i++)
1720
fbn->indir_tbl[0][i] = ethtool_rxfh_indir_default(i, num_rx);
1821
}

0 commit comments

Comments
 (0)