Message ID | 20230301180213.1828060-1-shayagr@amazon.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Add tx push buf len param to ethtool | expand |
On Wed, 1 Mar 2023 20:02:13 +0200 Shay Agroskin wrote: > -static const struct ethtool_ops ena_ethtool_ops = { > +static struct ethtool_ops ena_ethtool_ops = { > .supported_coalesce_params = ETHTOOL_COALESCE_USECS | > ETHTOOL_COALESCE_USE_ADAPTIVE_RX, > .get_link_ksettings = ena_get_link_ksettings, > @@ -967,8 +967,18 @@ static const struct ethtool_ops ena_ethtool_ops = { > .get_ts_info = ethtool_op_get_ts_info, > }; > > -void ena_set_ethtool_ops(struct net_device *netdev) > +void ena_set_ethtool_ops(struct ena_adapter *adapter) > { > + struct net_device *netdev = adapter->netdev; > + > + ena_ethtool_ops.supported_ring_params = 0; > + if (adapter->ena_dev->tx_mem_queue_type == > + ENA_ADMIN_PLACEMENT_POLICY_HOST) > + goto no_llq_supported; > + > + ena_ethtool_ops.supported_ring_params |= ETHTOOL_RING_USE_TX_PUSH_BUF_LEN; > + > +no_llq_supported: > netdev->ethtool_ops = &ena_ethtool_ops; > } Don't update the global structures based on caps of a single device. The opt-in is to declare that the driver will act on the value, doesn't necessarily mean that given device can support the feature. Leave ETHTOOL_RING_USE_TX_PUSH_BUF_LEN always set and error out appropriately in ena_set_ringparam(). Option #2 is to refactor the supported features into a struct and add a callback for driver to "fix up" the caps at request time. But that'd touch a lot of drivers.
diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c index 5e13fbc7b0ab..27fe0e6a5b6e 100644 --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c @@ -939,7 +939,7 @@ static int ena_set_tunable(struct net_device *netdev, return ret; } -static const struct ethtool_ops ena_ethtool_ops = { +static struct ethtool_ops ena_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_USE_ADAPTIVE_RX, .get_link_ksettings = ena_get_link_ksettings, @@ -967,8 +967,18 @@ static const struct ethtool_ops ena_ethtool_ops = { .get_ts_info = ethtool_op_get_ts_info, }; -void ena_set_ethtool_ops(struct net_device *netdev) +void ena_set_ethtool_ops(struct ena_adapter *adapter) { + struct net_device *netdev = adapter->netdev; + + ena_ethtool_ops.supported_ring_params = 0; + if (adapter->ena_dev->tx_mem_queue_type == + ENA_ADMIN_PLACEMENT_POLICY_HOST) + goto no_llq_supported; + + ena_ethtool_ops.supported_ring_params |= ETHTOOL_RING_USE_TX_PUSH_BUF_LEN; + +no_llq_supported: netdev->ethtool_ops = &ena_ethtool_ops; } diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 0625be4619a8..22f9786a91e2 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -3719,6 +3719,11 @@ int ena_restore_device(struct ena_adapter *adapter) } } + /* Some ethtool advertised capabilities might change after + * destroy/restore calls + */ + ena_set_ethtool_ops(adapter); + set_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags); clear_bit(ENA_FLAG_ONGOING_RESET, &adapter->flags); @@ -4450,7 +4455,7 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->netdev_ops = &ena_netdev_ops; netdev->watchdog_timeo = TX_TIMEOUT; - ena_set_ethtool_ops(netdev); + ena_set_ethtool_ops(adapter); netdev->priv_flags |= IFF_UNICAST_FLT; diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h index 5a0d4ee76172..f1dedf24cd11 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.h +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h @@ -388,7 +388,7 @@ struct ena_adapter { u32 xdp_num_queues; }; -void ena_set_ethtool_ops(struct net_device *netdev); +void ena_set_ethtool_ops(struct ena_adapter *adapter); void ena_dump_stats_to_dmesg(struct ena_adapter *adapter);
Advertise support for modifying TX push buffer len using ethtool. This capability requires the driver to support Low Latency Queue which might not be the case for some scenarios. Signed-off-by: Shay Agroskin <shayagr@amazon.com> --- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 14 ++++++++++++-- drivers/net/ethernet/amazon/ena/ena_netdev.c | 7 ++++++- drivers/net/ethernet/amazon/ena/ena_netdev.h | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-)