diff mbox series

[RFC,v1,net-next,5/5] net: ena: Advertise ETHTOOL_RING_USE_TX_PUSH_BUF_LEN support

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

Checks

Context Check Description
netdev/series_format warning Series does not have a cover letter
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 11 this patch: 11
netdev/cc_maintainers warning 2 maintainers not CCed: pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 82 exceeds 80 columns WARNING: struct ethtool_ops should normally be const
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Shay Agroskin March 1, 2023, 6:02 p.m. UTC
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(-)

Comments

Jakub Kicinski March 2, 2023, 4:11 a.m. UTC | #1
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 mbox series

Patch

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);