Linux CXL
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: linux-cxl@vger.kernel.org
Cc: nvdimm@lists.linux.dev,
	Alison Schofield <alison.schofield@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>
Subject: [PATCH ndctl 1/5] cxl/memdev.c: allow filtering memdevs by bus
Date: Fri, 21 Apr 2023 21:09:59 -0600	[thread overview]
Message-ID: <20230405-vv-fw_update-v1-1-722a7a5baea3@intel.com> (raw)
In-Reply-To: <20230405-vv-fw_update-v1-0-722a7a5baea3@intel.com>

The family of memdev based commands implemented in memdev.c lacked an
option to filter the operation by bus. Add a helper to filter memdevs by
the bus they're under, and use it in memdev_action() which loops through
the requested memdevs. Update the man pages for all the affected
commands as well to include the bus filter option.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 Documentation/cxl/cxl-disable-memdev.txt |  2 ++
 Documentation/cxl/cxl-enable-memdev.txt  |  2 ++
 Documentation/cxl/cxl-free-dpa.txt       |  2 ++
 Documentation/cxl/cxl-read-labels.txt    |  2 ++
 Documentation/cxl/cxl-reserve-dpa.txt    |  2 ++
 Documentation/cxl/cxl-set-partition.txt  |  2 ++
 Documentation/cxl/cxl-write-labels.txt   |  3 +++
 cxl/filter.h                             |  2 ++
 cxl/filter.c                             | 19 +++++++++++++++++++
 cxl/memdev.c                             |  4 ++++
 10 files changed, 40 insertions(+)

diff --git a/Documentation/cxl/cxl-disable-memdev.txt b/Documentation/cxl/cxl-disable-memdev.txt
index edd5385..d397802 100644
--- a/Documentation/cxl/cxl-disable-memdev.txt
+++ b/Documentation/cxl/cxl-disable-memdev.txt
@@ -18,6 +18,8 @@ OPTIONS
 <memory device(s)>::
 include::memdev-option.txt[]
 
+include::bus-option.txt[]
+
 -f::
 --force::
 	DANGEROUS: Override the safety measure that blocks attempts to disable
diff --git a/Documentation/cxl/cxl-enable-memdev.txt b/Documentation/cxl/cxl-enable-memdev.txt
index 088d5e0..5b5ed66 100644
--- a/Documentation/cxl/cxl-enable-memdev.txt
+++ b/Documentation/cxl/cxl-enable-memdev.txt
@@ -23,6 +23,8 @@ OPTIONS
 <memory device(s)>::
 include::memdev-option.txt[]
 
+include::bus-option.txt[]
+
 -v::
 	Turn on verbose debug messages in the library (if libcxl was built with
 	logging and debug enabled).
diff --git a/Documentation/cxl/cxl-free-dpa.txt b/Documentation/cxl/cxl-free-dpa.txt
index 73fb048..506fafd 100644
--- a/Documentation/cxl/cxl-free-dpa.txt
+++ b/Documentation/cxl/cxl-free-dpa.txt
@@ -24,6 +24,8 @@ OPTIONS
 <memory device(s)>::
 include::memdev-option.txt[]
 
+include::bus-option.txt[]
+
 -d::
 --decoder::
 	Specify the decoder to free. The CXL specification
diff --git a/Documentation/cxl/cxl-read-labels.txt b/Documentation/cxl/cxl-read-labels.txt
index 143f296..a96e7a4 100644
--- a/Documentation/cxl/cxl-read-labels.txt
+++ b/Documentation/cxl/cxl-read-labels.txt
@@ -20,6 +20,8 @@ OPTIONS
 -------
 include::labels-options.txt[]
 
+include::bus-option.txt[]
+
 -o::
 --output::
 	output file
diff --git a/Documentation/cxl/cxl-reserve-dpa.txt b/Documentation/cxl/cxl-reserve-dpa.txt
index 5e79ef2..58cc93e 100644
--- a/Documentation/cxl/cxl-reserve-dpa.txt
+++ b/Documentation/cxl/cxl-reserve-dpa.txt
@@ -24,6 +24,8 @@ OPTIONS
 <memory device(s)>::
 include::memdev-option.txt[]
 
+include::bus-option.txt[]
+
 -d::
 --decoder::
 	Specify the decoder to attempt the allocation. The CXL specification
diff --git a/Documentation/cxl/cxl-set-partition.txt b/Documentation/cxl/cxl-set-partition.txt
index f0126da..bed7f76 100644
--- a/Documentation/cxl/cxl-set-partition.txt
+++ b/Documentation/cxl/cxl-set-partition.txt
@@ -35,6 +35,8 @@ OPTIONS
 <memory device(s)>::
 include::memdev-option.txt[]
 
+include::bus-option.txt[]
+
 -t::
 --type=::
 	Type of partition, 'pmem' or 'ram' (volatile), to modify.
diff --git a/Documentation/cxl/cxl-write-labels.txt b/Documentation/cxl/cxl-write-labels.txt
index 75f42a5..8f2d139 100644
--- a/Documentation/cxl/cxl-write-labels.txt
+++ b/Documentation/cxl/cxl-write-labels.txt
@@ -21,6 +21,9 @@ not allow write access to the device's label data area.
 OPTIONS
 -------
 include::labels-options.txt[]
+
+include::bus-option.txt[]
+
 -i::
 --input::
 	input file
diff --git a/cxl/filter.h b/cxl/filter.h
index c486514..595cde7 100644
--- a/cxl/filter.h
+++ b/cxl/filter.h
@@ -36,6 +36,8 @@ struct cxl_filter_params {
 struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
 					  const char *__ident,
 					  const char *serials);
+struct cxl_memdev *util_cxl_memdev_filter_by_bus(struct cxl_memdev *memdev,
+						 const char *__ident);
 struct cxl_port *util_cxl_port_filter_by_memdev(struct cxl_port *port,
 						const char *ident,
 						const char *serial);
diff --git a/cxl/filter.c b/cxl/filter.c
index 90b13be..d2ab899 100644
--- a/cxl/filter.c
+++ b/cxl/filter.c
@@ -243,6 +243,25 @@ static struct cxl_port *util_cxl_port_filter_by_bus(struct cxl_port *port,
 	return NULL;
 }
 
+struct cxl_memdev *util_cxl_memdev_filter_by_bus(struct cxl_memdev *memdev,
+						 const char *__ident)
+{
+	struct cxl_ctx *ctx = cxl_memdev_get_ctx(memdev);
+	struct cxl_bus *bus;
+
+	if (!__ident)
+		return memdev;
+
+	cxl_bus_foreach(ctx, bus) {
+		if (!util_cxl_bus_filter(bus, __ident))
+			continue;
+		if (bus == cxl_memdev_get_bus(memdev))
+			return memdev;
+	}
+
+	return NULL;
+}
+
 static struct cxl_decoder *
 util_cxl_decoder_filter_by_bus(struct cxl_decoder *decoder, const char *__ident)
 {
diff --git a/cxl/memdev.c b/cxl/memdev.c
index 0b3ad02..807e859 100644
--- a/cxl/memdev.c
+++ b/cxl/memdev.c
@@ -44,6 +44,8 @@ enum cxl_setpart_type {
 };
 
 #define BASE_OPTIONS() \
+OPT_STRING('b', "bus", &param.bus, "bus name", \
+	   "Limit operation to the specified bus"), \
 OPT_BOOLEAN('v',"verbose", &param.verbose, "turn on debug"), \
 OPT_BOOLEAN('S', "serial", &param.serial, "use serial numbers to id memdevs")
 
@@ -753,6 +755,8 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx,
 			if (!util_cxl_memdev_filter(memdev, memdev_filter,
 						    serial_filter))
 				continue;
+			if (!util_cxl_memdev_filter_by_bus(memdev, param.bus))
+				continue;
 			found = true;
 
 			if (action == action_write) {

-- 
2.40.0


  reply	other threads:[~2023-04-22  3:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-22  3:09 [PATCH ndctl 0/5] cxl: firmware update support for libcxl and cxl-cli Vishal Verma
2023-04-22  3:09 ` Vishal Verma [this message]
2023-05-19 17:57   ` [PATCH ndctl 1/5] cxl/memdev.c: allow filtering memdevs by bus Dave Jiang
2023-04-22  3:10 ` [PATCH ndctl 2/5] cxl/list: print firmware info in memdev listings Vishal Verma
2023-05-19 18:21   ` Dave Jiang
2023-04-22  3:10 ` [PATCH ndctl 3/5] cxl/fw_loader: add APIs to get current state of the FW loader mechanism Vishal Verma
2023-05-19 18:49   ` Dave Jiang
2023-04-22  3:10 ` [PATCH ndctl 4/5] cxl: add an update-firmware command Vishal Verma
2023-04-24 23:14   ` Verma, Vishal L
2023-05-19 18:57   ` Dave Jiang
2023-04-22  3:10 ` [PATCH ndctl 5/5] test/cxl-update-firmware: add a unit test for firmware update Vishal Verma
2023-05-19 19:00   ` Dave Jiang

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=20230405-vv-fw_update-v1-1-722a7a5baea3@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    /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