Skip to contentSkip to conversation

libibverbs: Add API to resolve GID to L2 address

PATCH In review Eli Cohen 1 participant 1 message Aug 26, 2010 InfiniBand

lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

PATCH v10 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 v9:
1. Add missing const in declaration of resolve_eth_gid()
2. Change function name to ibv_resolve_eth_gid()
3. ibv_resolve_eth_gid() requires VLANs retrieved from SGID and DGID be indentical only for none multicast GIDs.

 include/infiniband/driver.h |    7 +++
 src/verbs.c                 |   97 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
include/infiniband/driver.h +7 -0
index 9a81416..dffb26d 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 ibv_resolve_eth_gid(const 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.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