From: Haim Boozaglo <haimbo@mellanox.com>
To: linux-rdma@vger.kernel.org
Cc: Vladimir Koushnir <vladimirk@mellanox.com>,
Haim Boozaglo <haimbo@mellanox.com>
Subject: [PATCH 1/3] libibumad: Support arbitrary number of IB devices
Date: Sun, 11 Aug 2019 16:29:20 +0000 [thread overview]
Message-ID: <1565540962-20188-2-git-send-email-haimbo@mellanox.com> (raw)
In-Reply-To: <1565540962-20188-1-git-send-email-haimbo@mellanox.com>
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>
---
debian/libibumad3.symbols | 2 ++
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 ++
7 files changed, 114 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/debian/libibumad3.symbols b/debian/libibumad3.symbols
index 31a749f..d4b9bde 100644
--- a/debian/libibumad3.symbols
+++ b/debian/libibumad3.symbols
@@ -9,7 +9,9 @@ libibumad.so.3 libibumad3 #MINVER#
umad_debug@IBUMAD_1.0 1.3.9
umad_done@IBUMAD_1.0 1.3.9
umad_dump@IBUMAD_1.0 1.3.9
+ umad_free_ca_namelist@IBUMAD_1.1 3.1.26
umad_get_ca@IBUMAD_1.0 1.3.9
+ umad_get_ca_namelist@IBUMAD_1.1 3.1.26
umad_get_ca_portguids@IBUMAD_1.0 1.3.9
umad_get_cas_names@IBUMAD_1.0 1.3.9
umad_get_fd@IBUMAD_1.0 1.3.9
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..1f66cc3 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_free_ca_namelist;
+ umad_get_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
next prev parent reply other threads:[~2019-08-11 16:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Haim Boozaglo [this message]
2019-08-13 16:39 ` [PATCH 1/3] libibumad: Support arbitrary number of IB devices Ira Weiny
2019-08-18 7:31 ` Haim Boozaglo
2019-08-11 16:29 ` [PATCH 2/3] libibumad: Redesign resolve_ca_name to support " Haim Boozaglo
2019-08-11 16:29 ` [PATCH 3/3] ibdiags: Support arbitrary number of IB devices in ibstat Haim Boozaglo
2019-08-12 15:13 ` [PATCH rdma-core 0/3] get more than 32 available InfiniBand device names Doug Ledford
-- strict thread matches above, loose matches on Subject: below --
2019-08-06 14:38 [PATCH 1/3] libibumad: Support arbitrary number of IB devices Haim Boozaglo
2019-08-06 15:52 ` Leon Romanovsky
2019-08-07 7:26 ` Vladimir Koushnir
2019-08-07 7:44 ` Leon Romanovsky
2019-08-07 8:09 ` Vladimir Koushnir
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=1565540962-20188-2-git-send-email-haimbo@mellanox.com \
--to=haimbo@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=vladimirk@mellanox.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).