netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shay Drory <shayd@nvidia.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: jiri@nvidia.com, saeedm@nvidia.com, parav@nvidia.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shay Drory <shayd@nvidia.com>
Subject: [PATCH net-next 3/4] devlink: Add new cpu_affinity generic device param
Date: Tue, 22 Feb 2022 12:58:11 +0200	[thread overview]
Message-ID: <20220222105812.18668-4-shayd@nvidia.com> (raw)
In-Reply-To: <20220222105812.18668-1-shayd@nvidia.com>

Add new device generic parameter to configure device affinity.

A user who wishes to customize the affinity of the device can do it
using below example.

$ devlink dev param set auxiliary/mlx5_core.sf.4 name cpu_affinity \
              value [cpu_bitmask] cmode driverinit
$ devlink dev reload pci/0000:06:00.0

At this point devlink instance will use the customize affinity.

Signed-off-by: Shay Drory <shayd@nvidia.com>
---
 Documentation/networking/devlink/devlink-params.rst | 5 +++++
 include/net/devlink.h                               | 4 ++++
 net/core/devlink.c                                  | 5 +++++
 3 files changed, 14 insertions(+)

diff --git a/Documentation/networking/devlink/devlink-params.rst b/Documentation/networking/devlink/devlink-params.rst
index 4e01dc32bc08..2f9f5baf4373 100644
--- a/Documentation/networking/devlink/devlink-params.rst
+++ b/Documentation/networking/devlink/devlink-params.rst
@@ -137,3 +137,8 @@ own name.
    * - ``event_eq_size``
      - u32
      - Control the size of asynchronous control events EQ.
+   * - ``cpu_affinity``
+     - Bitfield
+     - control the cpu affinity of the device. user is able to change cpu
+       affinity also via procfs interface (/proc/irq/\*/smp_affinity). This will
+       overwrite the devlink setting.
diff --git a/include/net/devlink.h b/include/net/devlink.h
index f411482f716d..595a4d54a2bd 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -466,6 +466,7 @@ enum devlink_param_generic_id {
 	DEVLINK_PARAM_GENERIC_ID_ENABLE_IWARP,
 	DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE,
 	DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE,
+	DEVLINK_PARAM_GENERIC_ID_CPU_AFFINITY,
 
 	/* add new param generic ids above here*/
 	__DEVLINK_PARAM_GENERIC_ID_MAX,
@@ -524,6 +525,9 @@ enum devlink_param_generic_id {
 #define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME "event_eq_size"
 #define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE DEVLINK_PARAM_TYPE_U32
 
+#define DEVLINK_PARAM_GENERIC_CPU_AFFINITY_NAME "cpu_affinity"
+#define DEVLINK_PARAM_GENERIC_CPU_AFFINITY_TYPE DEVLINK_PARAM_TYPE_BITFIELD
+
 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate)	\
 {									\
 	.id = DEVLINK_PARAM_GENERIC_ID_##_id,				\
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 3d7e27abc487..d2dfd9a88eb1 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4477,6 +4477,11 @@ static const struct devlink_param devlink_param_generic[] = {
 		.name = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME,
 		.type = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE,
 	},
+	{
+		.id = DEVLINK_PARAM_GENERIC_ID_CPU_AFFINITY,
+		.name = DEVLINK_PARAM_GENERIC_CPU_AFFINITY_NAME,
+		.type = DEVLINK_PARAM_GENERIC_CPU_AFFINITY_TYPE,
+	},
 };
 
 static int devlink_param_generic_verify(const struct devlink_param *param)
-- 
2.21.3


  parent reply	other threads:[~2022-02-22 11:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 10:58 [PATCH net-next 0/4] devlink: Introduce cpu_affinity command Shay Drory
2022-02-22 10:58 ` [PATCH net-next 1/4] net netlink: Introduce NLA_BITFIELD type Shay Drory
2022-02-22 10:58 ` [PATCH net-next 2/4] devlink: Add support for NLA_BITFIELD for devlink param Shay Drory
2022-02-22 10:58 ` Shay Drory [this message]
2022-02-22 10:58 ` [PATCH net-next 4/4] net/mlx5: Support cpu_affinity devlink dev param Shay Drory

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=20220222105812.18668-4-shayd@nvidia.com \
    --to=shayd@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=parav@nvidia.com \
    --cc=saeedm@nvidia.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).