diff options
author | Moni Shoua <monis@mellanox.com> | 2013-12-12 18:03:12 +0200 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-01-18 14:12:35 -0800 |
commit | 7b85627b9f02f9b0fb2ef5f021807f4251135857 (patch) | |
tree | 46c6c152799067cd4c8a1813a76de58c45c389e9 /include/rdma | |
parent | dd5f03beb4f76ae65d76d8c22a8815e424fc607c (diff) |
IB/cma: IBoE (RoCE) IP-based GID addressing
Currently, the IB core and specifically the RDMA-CM assumes that IBoE
(RoCE) gids encode related Ethernet netdevice interface MAC address
and possibly VLAN id.
Change GIDs to be treated as they encode interface IP address.
Since Ethernet layer 2 address parameters are not longer encoded
within gids, we have to extend the Infiniband address structures (e.g.
ib_ah_attr) with layer 2 address parameters, namely mac and vlan.
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'include/rdma')
-rw-r--r-- | include/rdma/ib_addr.h | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index a0715606ebb..ce55906b54a 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h @@ -38,8 +38,12 @@ #include <linux/in6.h> #include <linux/if_arp.h> #include <linux/netdevice.h> +#include <linux/inetdevice.h> #include <linux/socket.h> #include <linux/if_vlan.h> +#include <net/ipv6.h> +#include <net/if_inet6.h> +#include <net/ip.h> #include <rdma/ib_verbs.h> #include <rdma/ib_pack.h> #include <net/ipv6.h> @@ -132,20 +136,10 @@ static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr) return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0; } -static inline void iboe_mac_vlan_to_ll(union ib_gid *gid, u8 *mac, u16 vid) +static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev) { - memset(gid->raw, 0, 16); - *((__be32 *) gid->raw) = cpu_to_be32(0xfe800000); - if (vid < 0x1000) { - gid->raw[12] = vid & 0xff; - gid->raw[11] = vid >> 8; - } else { - gid->raw[12] = 0xfe; - gid->raw[11] = 0xff; - } - memcpy(gid->raw + 13, mac + 3, 3); - memcpy(gid->raw + 8, mac, 3); - gid->raw[8] ^= 2; + return dev->priv_flags & IFF_802_1Q_VLAN ? + vlan_dev_vlan_id(dev) : 0xffff; } static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid) @@ -182,25 +176,20 @@ static inline int rdma_gid2ip(struct sockaddr *out, union ib_gid *gid) return 0; } -static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev) -{ - return dev->priv_flags & IFF_802_1Q_VLAN ? - vlan_dev_vlan_id(dev) : 0xffff; -} - static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) { struct net_device *dev; - u16 vid = 0xffff; + struct in_device *ip4; dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if); if (dev) { - vid = rdma_vlan_dev_vlan_id(dev); + ip4 = (struct in_device *)dev->ip_ptr; + if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address) + ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address, + (struct in6_addr *)gid); dev_put(dev); } - - iboe_mac_vlan_to_ll(gid, dev_addr->src_dev_addr, vid); } static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) |