From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Larysa Zaremba <larysa.zaremba@intel.com>
Cc: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
Emil Tantilov <emil.s.tantilov@intel.com>,
Lukasz Czapnik <lukasz.czapnik@intel.com>,
linux-kernel@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
intel-wired-lan@lists.osuosl.org, alan.brady@intel.com,
Jakub Kicinski <kuba@kernel.org>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [Intel-wired-lan] [PATCH iwl-net] ice: Interpret .set_channels() input differently
Date: Wed, 17 Apr 2024 13:42:13 +0200 [thread overview]
Message-ID: <Zh+1laRuDhNf21Lm@boxer> (raw)
In-Reply-To: <20240416125856.1263314-1-larysa.zaremba@intel.com>
On Tue, Apr 16, 2024 at 02:58:54PM +0200, Larysa Zaremba wrote:
> A bug occurs because a safety check guarding AF_XDP-related queues in
> ethnl_set_channels(), does not trigger. This happens, because kernel and
> ice driver interpret the ethtool command differently.
>
> How the bug occurs:
> 1. ethtool -l <IFNAME> -> combined: 40
> 2. Attach AF_XDP to queue 30
> 3. ethtool -L <IFNAME> rx 15 tx 15
> combined number is not specified, so command becomes {rx_count = 15,
> tx_count = 15, combined_count = 40}.
> 4. ethnl_set_channels checks, if there are any AF_XDP of queues from the
> new (combined_count + rx_count) to the old one, so from 55 to 40, check
> does not trigger.
> 5. ice interprets `rx 15 tx 15` as 15 combined channels and deletes the
> queue that AF_XDP is attached to.
>
> Interpret the command in a way that is more consistent with ethtool
> manual [0] (--show-channels and --set-channels).
>
> Considering that in the ice 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 */
Makes sense for usage above:
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Nonetheless I still think core should not allow user to shoot himself to
foot, but let's keep it as a separate thing.
Thanks!
>
> [0] https://man7.org/linux/man-pages/man8/ethtool.8.html
>
> Fixes: 87324e747fde ("ice: Implement ethtool ops for channels")
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_ethtool.c | 22 ++++++--------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> index 78b833b3e1d7..d91f41f61bce 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> @@ -3593,7 +3593,6 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
> struct ice_pf *pf = vsi->back;
> int new_rx = 0, new_tx = 0;
> bool locked = false;
> - u32 curr_combined;
> int ret = 0;
>
> /* do not support changing channels in Safe Mode */
> @@ -3615,22 +3614,13 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
> return -EOPNOTSUPP;
> }
>
> - curr_combined = ice_get_combined_cnt(vsi);
> + if (!ch->combined_count) {
> + netdev_err(dev, "Please specify at least 1 combined channel\n");
> + return -EINVAL;
> + }
>
> - /* these checks are for cases where user didn't specify a particular
> - * value on cmd line but we get non-zero value anyway via
> - * get_channels(); look at ethtool.c in ethtool repository (the user
> - * space part), particularly, do_schannels() routine
> - */
> - if (ch->rx_count == vsi->num_rxq - curr_combined)
> - ch->rx_count = 0;
> - if (ch->tx_count == vsi->num_txq - curr_combined)
> - ch->tx_count = 0;
> - if (ch->combined_count == curr_combined)
> - ch->combined_count = 0;
> -
> - if (!(ch->combined_count || (ch->rx_count && ch->tx_count))) {
> - netdev_err(dev, "Please specify at least 1 Rx and 1 Tx channel\n");
> + if (ch->rx_count && ch->tx_count) {
> + netdev_err(dev, "Dedicated RX or TX channels cannot be used simultaneously\n");
> return -EINVAL;
> }
>
> --
> 2.43.0
>
WARNING: multiple messages have this Message-ID (diff)
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Larysa Zaremba <larysa.zaremba@intel.com>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
<intel-wired-lan@lists.osuosl.org>,
<linux-kernel@vger.kernel.org>, <alan.brady@intel.com>,
<jesse.brandeburg@intel.com>,
Emil Tantilov <emil.s.tantilov@intel.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Lukasz Czapnik <lukasz.czapnik@intel.com>,
"Michal Swiatkowski" <michal.swiatkowski@linux.intel.com>
Subject: Re: [PATCH iwl-net] ice: Interpret .set_channels() input differently
Date: Wed, 17 Apr 2024 13:42:13 +0200 [thread overview]
Message-ID: <Zh+1laRuDhNf21Lm@boxer> (raw)
In-Reply-To: <20240416125856.1263314-1-larysa.zaremba@intel.com>
On Tue, Apr 16, 2024 at 02:58:54PM +0200, Larysa Zaremba wrote:
> A bug occurs because a safety check guarding AF_XDP-related queues in
> ethnl_set_channels(), does not trigger. This happens, because kernel and
> ice driver interpret the ethtool command differently.
>
> How the bug occurs:
> 1. ethtool -l <IFNAME> -> combined: 40
> 2. Attach AF_XDP to queue 30
> 3. ethtool -L <IFNAME> rx 15 tx 15
> combined number is not specified, so command becomes {rx_count = 15,
> tx_count = 15, combined_count = 40}.
> 4. ethnl_set_channels checks, if there are any AF_XDP of queues from the
> new (combined_count + rx_count) to the old one, so from 55 to 40, check
> does not trigger.
> 5. ice interprets `rx 15 tx 15` as 15 combined channels and deletes the
> queue that AF_XDP is attached to.
>
> Interpret the command in a way that is more consistent with ethtool
> manual [0] (--show-channels and --set-channels).
>
> Considering that in the ice 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 */
Makes sense for usage above:
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Nonetheless I still think core should not allow user to shoot himself to
foot, but let's keep it as a separate thing.
Thanks!
>
> [0] https://man7.org/linux/man-pages/man8/ethtool.8.html
>
> Fixes: 87324e747fde ("ice: Implement ethtool ops for channels")
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_ethtool.c | 22 ++++++--------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> index 78b833b3e1d7..d91f41f61bce 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> @@ -3593,7 +3593,6 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
> struct ice_pf *pf = vsi->back;
> int new_rx = 0, new_tx = 0;
> bool locked = false;
> - u32 curr_combined;
> int ret = 0;
>
> /* do not support changing channels in Safe Mode */
> @@ -3615,22 +3614,13 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
> return -EOPNOTSUPP;
> }
>
> - curr_combined = ice_get_combined_cnt(vsi);
> + if (!ch->combined_count) {
> + netdev_err(dev, "Please specify at least 1 combined channel\n");
> + return -EINVAL;
> + }
>
> - /* these checks are for cases where user didn't specify a particular
> - * value on cmd line but we get non-zero value anyway via
> - * get_channels(); look at ethtool.c in ethtool repository (the user
> - * space part), particularly, do_schannels() routine
> - */
> - if (ch->rx_count == vsi->num_rxq - curr_combined)
> - ch->rx_count = 0;
> - if (ch->tx_count == vsi->num_txq - curr_combined)
> - ch->tx_count = 0;
> - if (ch->combined_count == curr_combined)
> - ch->combined_count = 0;
> -
> - if (!(ch->combined_count || (ch->rx_count && ch->tx_count))) {
> - netdev_err(dev, "Please specify at least 1 Rx and 1 Tx channel\n");
> + if (ch->rx_count && ch->tx_count) {
> + netdev_err(dev, "Dedicated RX or TX channels cannot be used simultaneously\n");
> return -EINVAL;
> }
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-04-17 11:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 12:58 [Intel-wired-lan] [PATCH iwl-net] ice: Interpret .set_channels() input differently Larysa Zaremba
2024-04-16 12:58 ` Larysa Zaremba
2024-04-17 11:42 ` Maciej Fijalkowski [this message]
2024-04-17 11:42 ` Maciej Fijalkowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zh+1laRuDhNf21Lm@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=alan.brady@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=emil.s.tantilov@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=larysa.zaremba@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.czapnik@intel.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.