Skip to content

Commit

Permalink
net: thunderx: take into account xdp_features setting tx/rx queues
Browse files Browse the repository at this point in the history
thunderx nic allows xdp just if enough hw queues are available for XDP.
Take into account queues configuration setting xdp_features.

Fixes: 66c0e13 ("drivers: net: turn on XDP features")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Lorenzo Bianconi authored and Jakub Kicinski committed Mar 11, 2023
1 parent f85949f commit 3c249fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 11 additions & 6 deletions drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,17 @@ static int nicvf_set_channels(struct net_device *dev,
if (channel->tx_count > nic->max_queues)
return -EINVAL;

if (nic->xdp_prog &&
((channel->tx_count + channel->rx_count) > nic->max_queues)) {
netdev_err(nic->netdev,
"XDP mode, RXQs + TXQs > Max %d\n",
nic->max_queues);
return -EINVAL;
if (channel->tx_count + channel->rx_count > nic->max_queues) {
if (nic->xdp_prog) {
netdev_err(nic->netdev,
"XDP mode, RXQs + TXQs > Max %d\n",
nic->max_queues);
return -EINVAL;
}

xdp_clear_features_flag(nic->netdev);
} else if (!pass1_silicon(nic->pdev)) {
xdp_set_features_flag(dev, NETDEV_XDP_ACT_BASIC);
}

if (if_up)
Expand Down
4 changes: 3 additions & 1 deletion drivers/net/ethernet/cavium/thunder/nicvf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,9 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev->netdev_ops = &nicvf_netdev_ops;
netdev->watchdog_timeo = NICVF_TX_TIMEOUT;

netdev->xdp_features = NETDEV_XDP_ACT_BASIC;
if (!pass1_silicon(nic->pdev) &&
nic->rx_queues + nic->tx_queues <= nic->max_queues)
netdev->xdp_features = NETDEV_XDP_ACT_BASIC;

/* MTU range: 64 - 9200 */
netdev->min_mtu = NIC_HW_MIN_FRS;
Expand Down

0 comments on commit 3c249fe

Please sign in to comment.