Skip to contentSkip to conversation

iboe - address resolution in userspace

PATCH Eli Cohen 2 participants 4 messages Jul 29, 2010 – Aug 4, 2010 2 messages not in the archive InfiniBand

lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

Roland,

This is the userspace patch implementing the outcome of the email discussions about address resolution conducted over the last couple of weeks.
We are planning to submit the full patch series based on your iboe branch within the next few days with the hope that this can be pushed upstream for 2.6.36.

Quoted 1 line

From ff1c4c562f91082126d53297e316437026fb8ac0 Mon Sep 17 00:00:00 2001

From: Eli Cohen <eli-VPRAkNaXOzVS1MOuV/[email protected]>
Date: Wed, 28 Jul 2010 18:07:45 +0300
Subject: [PATCH] libibverbs: Add API to resolve GID to L2 address

Add a new API, resolve_eth_ll_gid(), which resolves a GID to layer 2 address information. The 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.

---
 include/infiniband/driver.h |    7 ++++
 src/verbs.c                 |   78 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 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 +78 -0

87 lines not on this page · raw message

Signature · 8 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
Quoted 6 lines · Eli Cohen

Add a new API, resolve_eth_ll_gid(), which resolves a GID to layer 2 address information. The 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.

Is it reasonable for the receiver to have an sgid table entry for every vlan supported?

resolve_eth_gid should probably fail if dgid vlan != sgid vlan..

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

Quoted 4 lines
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);

union ibv_gid * should be const (and const flowed down)

src/verbs.c int __ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid · line 566

Quoted 4 lines
src/verbs.c +4 -0
+static int is_multicast_gid(union ibv_gid *gid)
+{
+	return gid->raw[0] == 0xff ? 1 : 0;
+}

This ternary if is kinda redundant?

Review

Quoted 2 lines
(quoted diff) +2 -0
+static int resolve_grh(union ibv_gid *dgid, uint8_t *mac, uint8_t *is_mcast)
+{

Funny name for the function? It does not touch GRHs?

src/verbs.c int __ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid · line 618

Quoted 2 lines
src/verbs.c +2 -0
+	*vlan = get_vlan_id(&sgid);
+	*tagged = *vlan;

It is hard to see what you are trying to do here, can you document this GID address format you invented? vlan 0 is not special, you shouldn't use it to mean untagged packets. I'm guessing the scheme is if the GID has the 0xFFFE bit then it should be untagged otherwise it should be tagged with the VID in bytes 11/12? If so then this computation if *tagged is wrong, it prevents someone creating tagged vlan id 0 packets, which is a valid thing to do.

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

author
#4 lore raw
In reply to a message not in the archive

Hi,

I am attaching a new patch which addresses the comments raised. --

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

---
 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 · 7 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
#5 lore raw
Quoted 21 lines · Eli Cohen

Hi,

I am attaching a new patch which addresses the comments raised. --

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

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

Quoted 4 lines
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);

Forgot to make the dgid const here.

src/verbs.c int __ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid · line 573

Quoted 11 lines
src/verbs.c +9 -0
+static void get_mcast_mac(const union ibv_gid *gid, uint8_t *mac)
+{
+	int i;
+
+	mac[0] = 0x33;
+	mac[1] = 0x33;
+	for (i = 2; i < 6; ++i)
+		mac[i] = gid->raw[i + 10];
+}

So how does vlan and multicast work? This is copying byte 12 into the MAC address.. Not too thrilled about using the IPv6 prefix unconditionally either?

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