Skip to content

Commit 7aa6dc3

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: ena: take into account xdp_features setting tx/rx queues
ena 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") Reviewed-by: Shay Agroskin <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3c249fe commit 7aa6dc3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

drivers/net/ethernet/amazon/ena/ena_ethtool.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,11 +850,20 @@ static int ena_set_channels(struct net_device *netdev,
850850
struct ena_adapter *adapter = netdev_priv(netdev);
851851
u32 count = channels->combined_count;
852852
/* The check for max value is already done in ethtool */
853-
if (count < ENA_MIN_NUM_IO_QUEUES ||
854-
(ena_xdp_present(adapter) &&
855-
!ena_xdp_legal_queue_count(adapter, count)))
853+
if (count < ENA_MIN_NUM_IO_QUEUES)
856854
return -EINVAL;
857855

856+
if (!ena_xdp_legal_queue_count(adapter, count)) {
857+
if (ena_xdp_present(adapter))
858+
return -EINVAL;
859+
860+
xdp_clear_features_flag(netdev);
861+
} else {
862+
xdp_set_features_flag(netdev,
863+
NETDEV_XDP_ACT_BASIC |
864+
NETDEV_XDP_ACT_REDIRECT);
865+
}
866+
858867
return ena_update_queue_count(adapter, count);
859868
}
860869

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,8 +4105,6 @@ static void ena_set_conf_feat_params(struct ena_adapter *adapter,
41054105
/* Set offload features */
41064106
ena_set_dev_offloads(feat, netdev);
41074107

4108-
netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT;
4109-
41104108
adapter->max_mtu = feat->dev_attr.max_mtu;
41114109
netdev->max_mtu = adapter->max_mtu;
41124110
netdev->min_mtu = ENA_MIN_MTU;
@@ -4393,6 +4391,10 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
43934391

43944392
ena_config_debug_area(adapter);
43954393

4394+
if (ena_xdp_legal_queue_count(adapter, adapter->num_io_queues))
4395+
netdev->xdp_features = NETDEV_XDP_ACT_BASIC |
4396+
NETDEV_XDP_ACT_REDIRECT;
4397+
43964398
memcpy(adapter->netdev->perm_addr, adapter->mac_addr, netdev->addr_len);
43974399

43984400
netif_carrier_off(netdev);

0 commit comments

Comments
 (0)