1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/intel
Larysa Zaremba 5e7695e021 idpf: Interpret .set_channels() input differently
Unlike ice, idpf does not check, if user has requested at least 1 combined
channel. Instead, it relies on a check in the core code. Unfortunately, the
check does not trigger for us because of the hacky .set_channels()
interpretation logic that is not consistent with the core code.

This naturally leads to user being able to trigger a crash with an invalid
input. This is how:

1. ethtool -l <IFNAME> -> combined: 40
2. ethtool -L <IFNAME> rx 0 tx 0
   combined number is not specified, so command becomes {rx_count = 0,
   tx_count = 0, combined_count = 40}.
3. ethnl_set_channels checks, if there is at least 1 RX and 1 TX channel,
   comparing (combined_count + rx_count) and (combined_count + tx_count)
   to zero. Obviously, (40 + 0) is greater than zero, so the core code
   deems the input OK.
4. idpf interprets `rx 0 tx 0` as 0 channels and tries to proceed with such
   configuration.

The issue has to be solved fundamentally, as current logic is also known to
cause AF_XDP problems in ice [0].

Interpret the command in a way that is more consistent with ethtool
manual [1] (--show-channels and --set-channels) and new ice logic.

Considering that in the idpf driver only the difference between RX and TX
queues forms dedicated channels, change the correct way to set number of
channels to:

ethtool -L <IFNAME> combined 10 /* For symmetric queues */
ethtool -L <IFNAME> combined 8 tx 2 rx 0 /* For asymmetric queues */

[0] https://lore.kernel.org/netdev/20240418095857.2827-1-larysa.zaremba@intel.com/
[1] https://man7.org/linux/man-pages/man8/ethtool.8.html

Fixes: 02cbfba1ad ("idpf: add ethtool callbacks")
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Igor Bagnucki <igor.bagnucki@intel.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
Tested-by: Krishneil Singh <krishneil.k.singh@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2024-05-23 13:02:26 +02:00
..
e1000 net: annotate writes on dev->mtu from ndo_change_mtu() 2024-05-07 16:19:14 -07:00
e1000e net: e1000e & ixgbe: Remove PCI_HEADER_TYPE_MFD duplicates 2024-05-08 09:26:46 -07:00
fm10k net: intel: implement modern PM ops declarations 2024-03-29 08:58:43 -07:00
i40e i40e: flower: validate control flags 2024-05-08 09:12:09 -07:00
iavf iavf: flower: validate control flags 2024-05-08 09:20:33 -07:00
ice ice: Interpret .set_channels() input differently 2024-05-23 13:02:26 +02:00
idpf idpf: Interpret .set_channels() input differently 2024-05-23 13:02:26 +02:00
igb igb: flower: validate control flags 2024-05-08 09:22:33 -07:00
igbvf net: annotate writes on dev->mtu from ndo_change_mtu() 2024-05-07 16:19:14 -07:00
igc igc: fix a log entry using uninitialized netdev 2024-05-08 09:25:44 -07:00
ixgbe Revert "ixgbe: Manual AN-37 for troublesome link partners for X550 SFI" 2024-05-23 10:48:35 +02:00
ixgbevf net: annotate writes on dev->mtu from ndo_change_mtu() 2024-05-07 16:19:14 -07:00
libeth libeth: add Rx buffer management 2024-04-24 11:06:25 -07:00
libie net: intel: introduce {, Intel} Ethernet common library 2024-04-24 11:06:25 -07:00
e100.c net: intel: implement modern PM ops declarations 2024-03-29 08:58:43 -07:00
Kconfig net: intel: introduce {, Intel} Ethernet common library 2024-04-24 11:06:25 -07:00
Makefile net: intel: introduce {, Intel} Ethernet common library 2024-04-24 11:06:25 -07:00