Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/3] libibumad: Support arbitrary number of IB devices
@ 2019-08-06 14:38 Haim Boozaglo
  2019-08-06 14:38 ` [PATCH 2/3] libibumad: Redesign resolve_ca_name to support " Haim Boozaglo
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Haim Boozaglo @ 2019-08-06 14:38 UTC (permalink / raw)
  To: linux-rdma; +Cc: Vladimir Koushnir, Haim Boozaglo

From: Vladimir Koushnir <vladimirk@mellanox.com>

Added new function returning a list of available InfiniBand device names.
The returned list is not limited to 32 devices.

Signed-off-by: Vladimir Koushnir <vladimirk@mellanox.com>
Signed-off-by: Haim Boozaglo <haimbo@mellanox.com>
---
 libibumad/CMakeLists.txt              |  2 +-
 libibumad/libibumad.map               |  6 +++++
 libibumad/man/umad_free_ca_namelist.3 | 28 ++++++++++++++++++++++++
 libibumad/man/umad_get_ca_namelist.3  | 34 +++++++++++++++++++++++++++++
 libibumad/umad.c                      | 41 +++++++++++++++++++++++++++++++++++
 libibumad/umad.h                      |  2 ++
 6 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 libibumad/man/umad_free_ca_namelist.3
 create mode 100644 libibumad/man/umad_get_ca_namelist.3

diff --git a/libibumad/CMakeLists.txt b/libibumad/CMakeLists.txt
index 1f600a0..9d0a425 100644
--- a/libibumad/CMakeLists.txt
+++ b/libibumad/CMakeLists.txt
@@ -10,7 +10,7 @@ publish_headers(infiniband
 
 rdma_library(ibumad libibumad.map
   # See Documentation/versioning.md
-  3 3.0.${PACKAGE_VERSION}
+  3 3.1.${PACKAGE_VERSION}
   sysfs.c
   umad.c
   umad_str.c
diff --git a/libibumad/libibumad.map b/libibumad/libibumad.map
index 8bf474e..1b8e7e1 100644
--- a/libibumad/libibumad.map
+++ b/libibumad/libibumad.map
@@ -39,3 +39,9 @@ IBUMAD_1.0 {
 		umad_attribute_str;
 	local: *;
 };
+
+IBUMAD_1.1 {
+	global:
+		umad_get_ca_namelist;
+		umad_free_ca_namelist;
+} IBUMAD_1.0;
diff --git a/libibumad/man/umad_free_ca_namelist.3 b/libibumad/man/umad_free_ca_namelist.3
new file mode 100644
index 0000000..f15958b
--- /dev/null
+++ b/libibumad/man/umad_free_ca_namelist.3
@@ -0,0 +1,28 @@
+.\" -*- nroff -*-
+.\"
+.TH UMAD_FREE_CA_NAMELIST 3  "May 1, 2018" "OpenIB" "OpenIB Programmer\'s Manual"
+.SH "NAME"
+umad_free_ca_namelist \- free InfiniBand devices name list
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/umad.h>
+.sp
+.BI "void umad_free_ca_namelist(char " "*cas" );
+.fi
+.SH "DESCRIPTION"
+.B umad_get_free_namelist()
+frees the InfiniBand devices name list previously allocated with
+.B umad_get_ca_namelist()\fR.
+The argument
+.I cas
+is a character array of InfiniBand devices names
+.SH "RETURN VALUE"
+.B umad_free_ca_namelist()
+returns no value.
+.SH "SEE ALSO"
+.BR umad_get_ca_namelist(3)
+.SH "AUTHORS"
+.TP
+Vladimir Koushnir <vladimirk@mellanox.com>
+.TP
+Hal Rosenstock <hal@mellanox.com>
diff --git a/libibumad/man/umad_get_ca_namelist.3 b/libibumad/man/umad_get_ca_namelist.3
new file mode 100644
index 0000000..5b30209
--- /dev/null
+++ b/libibumad/man/umad_get_ca_namelist.3
@@ -0,0 +1,34 @@
+.\" -*- nroff -*-
+.\"
+.TH UMAD_GET_CA_NAMELIST 3  "May 1, 2018" "OpenIB" "OpenIB Programmer\'s Manual"
+.SH "NAME"
+umad_get_ca_namelist \- get list of available InfiniBand device names
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/umad.h>
+.sp
+.BI "int umad_get_ca_namelist(char " "**cas" );
+.fi
+.SH "DESCRIPTION"
+.B umad_get_ca_namelist()
+fills the
+.I cas
+array with arbitrary number of local IB devices (CAs) names.
+The argument
+.I cas
+is a character array that will be allocated by the function to include number of entries, each with
+.B UMAD_CA_NAME_LEN
+characters.
+.SH "RETURN VALUE"
+.B umad_get_ca_namelist()
+returns a non-negative value equal to the number of entries filled,
+or \-1 on errors.
+.SH "SEE ALSO"
+.BR umad_get_ca_portguids (3),
+.BR umad_open_port (3)
+.BR umad_free_ca_namelist(3)
+.SH "AUTHORS"
+.TP
+Vladimir Koushnir <vladimirk@mellanox.com>
+.TP
+Hal Rosenstock <hal@mellanox.com>
diff --git a/libibumad/umad.c b/libibumad/umad.c
index 5f8656e..9d0303b 100644
--- a/libibumad/umad.c
+++ b/libibumad/umad.c
@@ -1123,3 +1123,44 @@ void umad_dump(void *umad)
 	       mad->agent_id, mad->status, mad->timeout_ms);
 	umad_addr_dump(&mad->addr);
 }
+
+int umad_get_ca_namelist(char **cas)
+{
+	struct dirent **namelist;
+	int n, i, j = 0;
+
+	n = scandir(SYS_INFINIBAND, &namelist, NULL, alphasort);
+
+	if (n > 0) {
+		*cas = (char *) calloc(1, n * sizeof(char) * UMAD_CA_NAME_LEN);
+		for (i = 0; i < n; i++) {
+			if (*cas && strcmp(namelist[i]->d_name, ".") &&
+			    strcmp(namelist[i]->d_name, "..")) {
+				if (is_ib_type(namelist[i]->d_name)) {
+					strncpy(*cas + j * UMAD_CA_NAME_LEN,
+						namelist[i]->d_name,
+						UMAD_CA_NAME_LEN);
+					j++;
+				}
+			}
+			free(namelist[i]);
+		}
+		DEBUG("return %d cas", j);
+	} else {
+		/* Is this still needed ? */
+		if ((*cas = calloc(1, UMAD_CA_NAME_LEN * sizeof(char)))) {
+			strncpy(*cas, def_ca_name, UMAD_CA_NAME_LEN);
+			DEBUG("return 1 ca");
+			j = 1;
+		}
+	}
+	if (n >= 0)
+		free(namelist);
+
+	return j;
+}
+
+void umad_free_ca_namelist(char *cas)
+{
+	free(cas);
+}
diff --git a/libibumad/umad.h b/libibumad/umad.h
index 3cc551f..70bc213 100644
--- a/libibumad/umad.h
+++ b/libibumad/umad.h
@@ -208,6 +208,8 @@ int umad_register(int portid, int mgmt_class, int mgmt_version,
 int umad_register_oui(int portid, int mgmt_class, uint8_t rmpp_version,
 		      uint8_t oui[3], long method_mask[16 / sizeof(long)]);
 int umad_unregister(int portid, int agentid);
+int umad_get_ca_namelist(char **cas);
+void umad_free_ca_namelist(char *cas);
 
 enum {
 	UMAD_USER_RMPP = (1 << 0)
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH rdma-core 0/3] get more than 32 available InfiniBand device names
@ 2019-08-11 16:29 Haim Boozaglo
  2019-08-11 16:29 ` [PATCH 3/3] ibdiags: Support arbitrary number of IB devices in ibstat Haim Boozaglo
  0 siblings, 1 reply; 8+ messages in thread
From: Haim Boozaglo @ 2019-08-11 16:29 UTC (permalink / raw)
  To: linux-rdma; +Cc: Haim Boozaglo

Hi,

This series from Vladimir Koushnir adds the ability to get
list of InfiniBand device names greater than 32.

Thanks

Vladimir Koushnir (3):
  libibumad: Support arbitrary number of IB devices
  libibumad: Redesign resolve_ca_name to support arbitrary number of IB
    devices
  ibdiags: Support arbitrary number of IB devices in ibstat

 debian/libibumad3.symbols             |   2 +
 infiniband-diags/ibstat.c             |  47 +++++++-----
 libibumad/CMakeLists.txt              |   2 +-
 libibumad/libibumad.map               |   6 ++
 libibumad/man/umad_free_ca_namelist.3 |  28 +++++++
 libibumad/man/umad_get_ca_namelist.3  |  34 ++++++++
 libibumad/umad.c                      | 141 +++++++++++++++++++++++++---------
 libibumad/umad.h                      |   2 +
 8 files changed, 204 insertions(+), 58 deletions(-)
 create mode 100644 libibumad/man/umad_free_ca_namelist.3
 create mode 100644 libibumad/man/umad_get_ca_namelist.3

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-06 14:38 [PATCH 1/3] libibumad: Support arbitrary number of IB devices Haim Boozaglo
2019-08-06 14:38 ` [PATCH 2/3] libibumad: Redesign resolve_ca_name to support " Haim Boozaglo
2019-08-06 14:38 ` [PATCH 3/3] ibdiags: Support arbitrary number of IB devices in ibstat Haim Boozaglo
2019-08-06 15:52 ` [PATCH 1/3] libibumad: Support arbitrary number of IB devices Leon Romanovsky
2019-08-07  7:26   ` Vladimir Koushnir
2019-08-07  7:44     ` Leon Romanovsky
2019-08-07  8:09       ` Vladimir Koushnir
2019-08-11 16:29 [PATCH rdma-core 0/3] get more than 32 available InfiniBand device names Haim Boozaglo
2019-08-11 16:29 ` [PATCH 3/3] ibdiags: Support arbitrary number of IB devices in ibstat Haim Boozaglo

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git