1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/intel/idpf
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
..
idpf.h idpf: prevent deinit uninitialized virtchnl core 2024-03-04 09:47:33 -08:00
idpf_controlq.c idpf: fix minor controlq issues 2024-03-04 09:48:33 -08:00
idpf_controlq.h idpf: add controlq init and reset checks 2023-09-13 14:59:23 -07:00
idpf_controlq_api.h idpf: implement virtchnl transaction manager 2024-03-04 09:32:41 -08:00
idpf_controlq_setup.c idpf: add controlq init and reset checks 2023-09-13 14:59:23 -07:00
idpf_dev.c idpf: add idpf_virtchnl.h 2024-03-04 09:28:27 -08:00
idpf_devids.h idpf: add module register and probe functionality 2023-09-13 14:59:23 -07:00
idpf_ethtool.c idpf: Interpret .set_channels() input differently 2024-05-23 13:02:26 +02:00
idpf_lan_pf_regs.h idpf: initialize interrupts and enable vport 2023-09-13 14:59:24 -07:00
idpf_lan_txrx.h idpf: add singleq start_xmit and napi poll 2023-09-13 14:59:24 -07:00
idpf_lan_vf_regs.h idpf: initialize interrupts and enable vport 2023-09-13 14:59:24 -07:00
idpf_lib.c net: annotate writes on dev->mtu from ndo_change_mtu() 2024-05-07 16:19:14 -07:00
idpf_main.c idpf: cleanup virtchnl cruft 2024-03-04 09:42:56 -08:00
idpf_mem.h idpf: add controlq init and reset checks 2023-09-13 14:59:23 -07:00
idpf_singleq_txrx.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-01-04 18:06:46 -08:00
idpf_txrx.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-04-04 18:01:07 -07:00
idpf_txrx.h idpf: make virtchnl2.h self-contained 2024-03-28 18:50:47 -07:00
idpf_vf_dev.c idpf: implement virtchnl transaction manager 2024-03-04 09:32:41 -08:00
idpf_virtchnl.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-03-07 10:29:36 -08:00
idpf_virtchnl.h idpf: refactor idpf_recv_mb_msg 2024-03-04 09:39:30 -08:00
Makefile idpf: add ethtool callbacks 2023-09-13 14:59:24 -07:00
virtchnl2.h idpf: sprinkle __counted_by{,_le}() in the virtchnl2 header 2024-03-28 18:50:47 -07:00
virtchnl2_lan_desc.h