From: Kurt Kanzenbach <kurt@linutronix.de>
To: Song Yoong Siang <yoong.siang.song@intel.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Richard Cochran <richardcochran@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Shinas Rasheed <srasheed@marvell.com>,
Kevin Tian <kevin.tian@intel.com>,
Brett Creeley <brett.creeley@amd.com>,
Blanco Alcaine Hector <hector.blanco.alcaine@intel.com>,
Joshua Hay <joshua.a.hay@intel.com>,
Sasha Neftin <sasha.neftin@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH iwl-next,v1 2/3] igc: Add default Rx queue configuration via sysfs
Date: Tue, 30 Jul 2024 11:58:34 +0200 [thread overview]
Message-ID: <87plqvjj5h.fsf@kurt.kurt.home> (raw)
In-Reply-To: <20240730012312.775893-1-yoong.siang.song@intel.com>
[-- Attachment #1: Type: text/plain, Size: 4937 bytes --]
On Tue Jul 30 2024, Song Yoong Siang wrote:
> From: Blanco Alcaine Hector <hector.blanco.alcaine@intel.com>
>
> This commit introduces the support to configure default Rx queue during
> runtime. A new sysfs attribute "default_rx_queue" has been added, allowing
> users to check and modify the default Rx queue.
>
> 1. Command to check the currently configured default Rx queue:
> cat /sys/devices/pci0000:00/.../default_rx_queue
>
> 2. Command to set the default Rx queue to a desired value, for example 3:
> echo 3 > /sys/devices/pci0000:00/.../default_rx_queue
>
> Signed-off-by: Blanco Alcaine Hector <hector.blanco.alcaine@intel.com>
> Signed-off-by: Song Yoong Siang <yoong.siang.song@intel.com>
[...]
> index e5b893fc5b66..df96800f6e3b 100644
> --- a/drivers/net/ethernet/intel/igc/igc_regs.h
> +++ b/drivers/net/ethernet/intel/igc/igc_regs.h
> @@ -63,6 +63,12 @@
> /* RSS registers */
> #define IGC_MRQC 0x05818 /* Multiple Receive Control - RW */
>
> +/* MRQC register bit definitions */
Nit: Now, the MRQC register definitions are scattered over two files:
igc_regs.h and igc.h. igc.h has
#define IGC_MRQC_ENABLE_RSS_MQ 0x00000002
#define IGC_MRQC_RSS_FIELD_IPV4_UDP 0x00400000
#define IGC_MRQC_RSS_FIELD_IPV6_UDP 0x00800000
Maybe combine them into a single location?
> +#define IGC_MRQC_ENABLE_MQ 0x00000000
> +#define IGC_MRQC_ENABLE_MASK GENMASK(2, 0)
> +#define IGC_MRQC_DEFAULT_QUEUE_MASK GENMASK(5, 3)
> +#define IGC_MRQC_DEFAULT_QUEUE_SHIFT 3
Nit: FIELD_GET() and FIELD_PREP() can help to get rid of the manual
shifting. See below.
> +
> /* Filtering Registers */
> #define IGC_ETQF(_n) (0x05CB0 + (4 * (_n))) /* EType Queue Fltr */
> #define IGC_FHFT(_n) (0x09000 + (256 * (_n))) /* Flexible Host Filter */
> diff --git a/drivers/net/ethernet/intel/igc/igc_sysfs.c b/drivers/net/ethernet/intel/igc/igc_sysfs.c
> new file mode 100644
> index 000000000000..34d838e6a019
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/igc/igc_sysfs.c
> @@ -0,0 +1,156 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2024 Intel Corporation */
> +
> +#include <linux/device.h>
> +#include <linux/kobject.h>
> +#include <linux/module.h>
> +#include <linux/netdevice.h>
> +#include <linux/sysfs.h>
> +#include <linux/types.h>
> +
> +#include "igc.h"
> +#include "igc_regs.h"
> +#include "igc_sysfs.h"
> +
> +/**
> + * igc_is_default_queue_supported - Checks if default Rx queue can be configured
> + * @mrqc: MRQC register content
> + *
> + * Checks if the current configuration of the device supports changing the
> + * default Rx queue configuration.
> + *
> + * Return: true if the default Rx queue can be configured, false otherwise.
> + */
> +static bool igc_is_default_queue_supported(u32 mrqc)
> +{
> + u32 mrqe = mrqc & IGC_MRQC_ENABLE_MASK;
> +
> + /* The default Rx queue setting is applied only if Multiple Receive
> + * Queues (MRQ) as defined by filters (2-tuple filters, L2 Ether-type
> + * filters, SYN filter and flex filters) is enabled.
> + */
> + if (mrqe != IGC_MRQC_ENABLE_MQ && mrqe != IGC_MRQC_ENABLE_RSS_MQ)
> + return false;
> +
> + return true;
> +}
> +
> +/**
> + * igc_get_default_rx_queue - Returns the index of default Rx queue
> + * @adapter: address of board private structure
> + *
> + * Return: index of the default Rx queue.
> + */
> +static u32 igc_get_default_rx_queue(struct igc_adapter *adapter)
> +{
> + struct igc_hw *hw = &adapter->hw;
> + u32 mrqc = rd32(IGC_MRQC);
> +
> + if (!igc_is_default_queue_supported(mrqc)) {
> + netdev_warn(adapter->netdev,
> + "MRQ disabled: default RxQ is ignored.\n");
> + }
> +
> + return (mrqc & IGC_MRQC_DEFAULT_QUEUE_MASK) >>
> + IGC_MRQC_DEFAULT_QUEUE_SHIFT;
Nit: return FIELD_GET(IGC_MRQC_DEFAULT_QUEUE_MASK, mrqc);
> +}
> +
> +/**
> + * igc_set_default_rx_queue - Sets the default Rx queue
> + * @adapter: address of board private structure
> + * @queue: index of the queue to be set as default Rx queue
> + *
> + * Return: 0 on success, negative error code on failure.
> + */
> +static int igc_set_default_rx_queue(struct igc_adapter *adapter, u32 queue)
> +{
> + struct igc_hw *hw = &adapter->hw;
> + u32 mrqc = rd32(IGC_MRQC);
> +
> + if (!igc_is_default_queue_supported(mrqc)) {
> + netdev_err(adapter->netdev,
> + "Default RxQ not supported. Please enable MRQ.\n");
> + return -EOPNOTSUPP;
> + }
> +
> + if (queue > adapter->rss_queues - 1) {
> + netdev_err(adapter->netdev,
> + "Invalid default RxQ index %d. Valid range: 0-%u.\n",
> + queue, adapter->rss_queues - 1);
> + return -EINVAL;
> + }
> +
> + /* Set the default Rx queue */
> + mrqc = rd32(IGC_MRQC);
> + mrqc &= ~IGC_MRQC_DEFAULT_QUEUE_MASK;
> + mrqc |= queue << IGC_MRQC_DEFAULT_QUEUE_SHIFT;
Nit: mrqc |= FIELD_PREP(IGC_MRQC_DEFAULT_QUEUE_MASK, queue);
Thanks,
Kurt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
next prev parent reply other threads:[~2024-07-30 9:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 1:23 [PATCH iwl-next,v1 2/3] igc: Add default Rx queue configuration via sysfs Song Yoong Siang
2024-07-30 9:58 ` Kurt Kanzenbach [this message]
2024-08-01 7:20 ` Song, Yoong Siang
2024-07-30 10:08 ` Wojciech Drewek
2024-08-01 7:45 ` Song, Yoong Siang
2024-07-30 13:19 ` [Intel-wired-lan] [PATCH iwl-next, v1 " Marcin Szycik
2024-08-01 7:56 ` Song, Yoong Siang
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=87plqvjj5h.fsf@kurt.kurt.home \
--to=kurt@linutronix.de \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brett.creeley@amd.com \
--cc=corbet@lwn.net \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=hector.blanco.alcaine@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=joshua.a.hay@intel.com \
--cc=kevin.tian@intel.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=richardcochran@gmail.com \
--cc=sasha.neftin@intel.com \
--cc=srasheed@marvell.com \
--cc=vinicius.gomes@intel.com \
--cc=yoong.siang.song@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).