Skip to contentSkip to conversation

libibverbs: Add API to resolve GID to L2 address

PATCH Superseded Eli Cohen 2 participants 3 messages Aug 6, 2010 – Aug 16, 2010 1 message not in the archive InfiniBand

v9 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

PATCH v9 3/4 libibverbs: Add API to resolve GID to L2 address

Add a new API, resolve_eth_gid(), which resolves a GID to layer 2 address information. A GID resembles an IPv6 link local address and encodes the MAC address and the VLAN tag within it. The function accepts the destination GID, port number and source GID index and returns the MAC, VLAN and indications whether the remote address is tagged VLAN and whether the address is multicast.

VLAN encoding is done as follows:
gid[11] is MS byte
gid[12] is LS byte

---

Changes from V8:
1. Move resolving of GID to MAC from kernel space to user space.

 include/infiniband/driver.h |    7 +++
 src/verbs.c                 |   97 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
include/infiniband/driver.h +7 -0
index 9a81416..be4ec98 100644
@@ -37,6 +37,8 @@
 
 #include <infiniband/verbs.h>
 #include <infiniband/kern-abi.h>
+#include <arpa/inet.h>
+#include <string.h>
 
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -143,4 +145,9 @@ const char *ibv_get_sysfs_path(void);
 int ibv_read_sysfs_file(const char *dir, const char *file,
 			char *buf, size_t size);
 
+int resolve_eth_gid(struct ibv_pd *pd, uint8_t port_num,
+		    union ibv_gid *dgid, uint8_t sgid_index,
+		    uint8_t mac[], uint16_t *vlan, uint8_t *tagged,
+		    uint8_t *is_mcast);
+
 #endif /* INFINIBAND_DRIVER_H */
src/verbs.c +97 -0

106 lines not on this page · raw message

Signature · 6 lines
1.7.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

include/infiniband/driver.h const char *ibv_get_sysfs_path(void); · line 151

Quoted 4 lines · Eli Cohen
include/infiniband/driver.h +4 -0
+int resolve_eth_gid(struct ibv_pd *pd, uint8_t port_num,
+		    union ibv_gid *dgid, uint8_t sgid_index,
+		    uint8_t mac[], uint16_t *vlan, uint8_t *tagged,
+		    uint8_t *is_mcast);

Still missing the const on dgid

It also just occured to me that this should be ibv_resolve_eth_gid to keep within the symbol namespace prefix used by libibverbs.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20100806164552.GK11306-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

author
#3 lore raw
Quoted 8 lines · Jason Gunthorpe

include/infiniband/driver.h const char *ibv_get_sysfs_path(void); · line 151

Quoted 4 lines · Eli Cohen
include/infiniband/driver.h +4 -0
+int resolve_eth_gid(struct ibv_pd *pd, uint8_t port_num,
+		    union ibv_gid *dgid, uint8_t sgid_index,
+		    uint8_t mac[], uint16_t *vlan, uint8_t *tagged,
+		    uint8_t *is_mcast);

Still missing the const on dgid

OK, I failed to use const in the prototype of the function. I am just curios why is it necessary at all? The are many places where you pass a pointer to struct that is not meant to be changed and you do not use const. For example, ibv_create_ah() passes as the first parameter a pointer to a struct ibv_pd and does not use const.

Quoted 4 lines

It also just occured to me that this should be ibv_resolve_eth_gid to keep within the symbol namespace prefix used by libibverbs.

That was deliberate. Since it is meant to be used by the hardware level libraries only I did not use the the ibv_ prefix but it I don't have a strong opinion about this so I will change it anyway. --
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html