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>
This commit is contained in:

committed by
Roland Dreier

parent
dd5f03beb4
commit
7b85627b9f
@@ -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)
|
||||
|
Reference in New Issue
Block a user