Eli,<div><br></div><div>I'm getting build failure of our kernel module with OFED-1.5.2-rc1.</div><div><br></div><div><div>/usr/src/ofa_kernel/include/rdma/ib_addr.h: In function ‘iboe_addr_get_sgid’:</div><div>/usr/src/ofa_kernel/include/rdma/ib_addr.h:160: error: implicit declaration of function ‘vlan_dev_vlan_id’</div>
</div><div><br></div><div>I'm using a standard Redhat EL 5.3 setup.</div><div>kernel is <span class="Apple-style-span" style="font-family: arial, sans-serif; border-collapse: collapse; ">2.6.18-128.7.1.el5</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; border-collapse: collapse; "><br></span></div><div>include/linux/autoconf.h has the following defined but the function doesn't seem to be defined in the kernel.</div>
<div><br></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; ">CONFIG_VLAN_8021Q_MODULE 1</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">I can work around the problem by hacking </span></font><span class="Apple-style-span" style="font-family: arial, sans-serif; border-collapse: collapse; ">/usr/src/ofa_kernel/include/rdma/ib_addr.h with undefining the VLAN stuff.</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">
<br>
#undef CONFIG_VLAN_8021Q
<br>
#undef CONFIG_VLAN_8021Q_MODULE</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">Any ideas to fix this in a graceful way?</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><br></span></font></div><div><div class="gmail_quote">On Thu, Feb 18, 2010 at 10:24 AM, Eli Cohen <span dir="ltr"><<a href="mailto:eli@mellanox.co.il">eli@mellanox.co.il</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Add 802.1q vlan support to IBoE. The vlan tag is encoded within the GID<br>
derived from a link local address in the following way:<br>
<br>
GID[11] GID[12] contain the vlan ID.<br>
The 3 bit user priority field is identical to the 3 bits of the SL.<br>
<br>
In case rdma_cm apps, the TOS field is used to generate the SL field by doing a<br>
shift right of 5 bits effectively taking to 3 MS bits of the TOS field. In<br>
order to support userspace verbs consumers, ib_uverbs_get_mac has changed into<br>
ib_uverbs_get_eth_l2_addr and now returns both MAC and VLAN information.<br>
<br>
Signed-off-by: Eli Cohen <<a href="mailto:eli@mellanox.co.il">eli@mellanox.co.il</a>><br>
---<br>
drivers/infiniband/core/cma.c | 20 ++++++++-----<br>
drivers/infiniband/core/ucma.c | 13 ++++++++-<br>
drivers/infiniband/core/ud_header.c | 31 ++++++++++++++++++++-<br>
include/rdma/ib_addr.h | 49 ++++++++++++++++++++++++++++++++---<br>
include/rdma/ib_pack.h | 19 ++++++-------<br>
5 files changed, 106 insertions(+), 26 deletions(-)<br>
<br>
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c<br>
index df5f636..108d1bb 100644<br>
--- a/drivers/infiniband/core/cma.c<br>
+++ b/drivers/infiniband/core/cma.c<br>
@@ -1763,6 +1763,7 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)<br>
struct sockaddr_in *src_addr = (struct sockaddr_in *)&route->addr.src_addr;<br>
struct sockaddr_in *dst_addr = (struct sockaddr_in *)&route->addr.dst_addr;<br>
struct net_device *ndev = NULL;<br>
+ u16 vid;<br>
<br>
if (src_addr->sin_family != dst_addr->sin_family)<br>
return -EINVAL;<br>
@@ -1782,14 +1783,6 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)<br>
<br>
route->num_paths = 1;<br>
<br>
- iboe_mac_to_ll(&route->path_rec->sgid, addr->dev_addr.src_dev_addr);<br>
- iboe_mac_to_ll(&route->path_rec->dgid, addr->dev_addr.dst_dev_addr);<br>
-<br>
- route->path_rec->hop_limit = 1;<br>
- route->path_rec->reversible = 1;<br>
- route->path_rec->pkey = cpu_to_be16(0xffff);<br>
- route->path_rec->mtu_selector = IB_SA_EQ;<br>
-<br>
if (addr->dev_addr.bound_dev_if)<br>
ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if);<br>
if (!ndev) {<br>
@@ -1797,6 +1790,17 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)<br>
goto err2;<br>
}<br>
<br>
+ vid = rdma_vlan_dev_vlan_id(ndev);<br>
+<br>
+ iboe_mac_vlan_to_ll(&route->path_rec->sgid, addr->dev_addr.src_dev_addr, vid);<br>
+ iboe_mac_vlan_to_ll(&route->path_rec->dgid, addr->dev_addr.dst_dev_addr, vid);<br>
+<br>
+ route->path_rec->hop_limit = 1;<br>
+ route->path_rec->reversible = 1;<br>
+ route->path_rec->pkey = cpu_to_be16(0xffff);<br>
+ route->path_rec->mtu_selector = IB_SA_EQ;<br>
+ route->path_rec->sl = id_priv->tos >> 5;<br>
+<br>
route->path_rec->mtu = iboe_get_mtu(ndev->mtu);<br>
route->path_rec->rate_selector = IB_SA_EQ;<br>
route->path_rec->rate = iboe_get_rate(ndev);<br>
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c<br>
index fcc27bc..ed670f5 100644<br>
--- a/drivers/infiniband/core/ucma.c<br>
+++ b/drivers/infiniband/core/ucma.c<br>
@@ -586,13 +586,22 @@ static void ucma_copy_iboe_route(struct rdma_ucm_query_route_resp *resp,<br>
struct rdma_route *route)<br>
{<br>
struct rdma_dev_addr *dev_addr;<br>
+ struct net_device *dev;<br>
+ u16 vid = 0;<br>
<br>
resp->num_paths = route->num_paths;<br>
switch (route->num_paths) {<br>
case 0:<br>
dev_addr = &route->addr.dev_addr;<br>
- iboe_mac_to_ll((union ib_gid *) &resp->ib_route[0].dgid,<br>
- dev_addr->dst_dev_addr);<br>
+ dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);<br>
+ if (dev) {<br>
+ vid = rdma_vlan_dev_vlan_id(dev);<br>
+ dev_put(dev);<br>
+ }<br>
+<br>
+<br>
+ iboe_mac_vlan_to_ll((union ib_gid *) &resp->ib_route[0].dgid,<br>
+ dev_addr->dst_dev_addr, vid);<br>
iboe_addr_get_sgid(dev_addr,<br>
(union ib_gid *) &resp->ib_route[0].sgid);<br>
resp->ib_route[0].pkey = cpu_to_be16(0xffff);<br>
diff --git a/drivers/infiniband/core/ud_header.c b/drivers/infiniband/core/ud_header.c<br>
index 7650313..7d03cf1 100644<br>
--- a/drivers/infiniband/core/ud_header.c<br>
+++ b/drivers/infiniband/core/ud_header.c<br>
@@ -33,6 +33,7 @@<br>
<br>
#include <linux/errno.h><br>
#include <linux/string.h><br>
+#include <linux/if_ether.h><br>
<br>
#include <rdma/ib_pack.h><br>
<br>
@@ -103,6 +104,17 @@ static const struct ib_field eth_table[] = {<br>
.size_bits = 16 }<br>
};<br>
<br>
+static const struct ib_field vlan_table[] = {<br>
+ { STRUCT_FIELD(vlan, tag),<br>
+ .offset_words = 0,<br>
+ .offset_bits = 0,<br>
+ .size_bits = 16 },<br>
+ { STRUCT_FIELD(vlan, type),<br>
+ .offset_words = 0,<br>
+ .offset_bits = 16,<br>
+ .size_bits = 16 }<br>
+};<br>
+<br>
static const struct ib_field grh_table[] = {<br>
{ STRUCT_FIELD(grh, ip_version),<br>
.offset_words = 0,<br>
@@ -205,6 +217,7 @@ static const struct ib_field deth_table[] = {<br>
* @payload_bytes:Length of packet payload<br>
* @lrh_present: specify if LRH is present<br>
* @eth_present: specify if Eth header is present<br>
+ * @vlan_present: packet is tagged vlan<br>
* @grh_present:GRH flag (if non-zero, GRH will be included)<br>
* @immediate_present: specify if immediate data is present<br>
* @header:Structure to initialize<br>
@@ -212,6 +225,7 @@ static const struct ib_field deth_table[] = {<br>
void ib_ud_header_init(int payload_bytes,<br>
int lrh_present,<br>
int eth_present,<br>
+ int vlan_present,<br>
int grh_present,<br>
int immediate_present,<br>
struct ib_ud_header *header)<br>
@@ -227,8 +241,14 @@ void ib_ud_header_init(int payload_bytes,<br>
packet_length = IB_LRH_BYTES;<br>
}<br>
<br>
- if (eth_present)<br>
- packet_length = IB_ETH_BYTES;<br>
+ if (eth_present) {<br>
+ if (vlan_present) {<br>
+ header->eth.type = cpu_to_be16(ETH_P_8021Q);<br>
+ packet_length += IB_VLAN_BYTES;<br>
+<br>
+ }<br>
+ packet_length += IB_ETH_BYTES;<br>
+ }<br>
<br>
packet_length += IB_BTH_BYTES + IB_DETH_BYTES + payload_bytes +<br>
4 + /* ICRC */<br>
@@ -258,6 +278,7 @@ void ib_ud_header_init(int payload_bytes,<br>
<br>
header->lrh_present = lrh_present;<br>
header->eth_present = eth_present;<br>
+ header->vlan_present = vlan_present;<br>
header->grh_present = grh_present;<br>
header->immediate_present = immediate_present;<br>
}<br>
@@ -287,6 +308,12 @@ int ib_ud_header_pack(struct ib_ud_header *header,<br>
len += IB_ETH_BYTES;<br>
}<br>
<br>
+ if (header->vlan_present) {<br>
+ ib_pack(vlan_table, ARRAY_SIZE(vlan_table),<br>
+ &header->vlan, buf + len);<br>
+ len += IB_VLAN_BYTES;<br>
+ }<br>
+<br>
if (header->grh_present) {<br>
ib_pack(grh_table, ARRAY_SIZE(grh_table),<br>
&header->grh, buf + len);<br>
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h<br>
index 23b184e..7e75bfa 100644<br>
--- a/include/rdma/ib_addr.h<br>
+++ b/include/rdma/ib_addr.h<br>
@@ -41,6 +41,7 @@<br>
#include <linux/socket.h><br>
#include <rdma/ib_verbs.h><br>
#include <rdma/ib_pack.h><br>
+#include <linux/if_vlan.h><br>
<br>
struct rdma_addr_client {<br>
atomic_t refcount;<br>
@@ -129,12 +130,17 @@ static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr)<br>
return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0;<br>
}<br>
<br>
-static inline void iboe_mac_to_ll(union ib_gid *gid, u8 *mac)<br>
+static inline void iboe_mac_vlan_to_ll(union ib_gid *gid, u8 *mac, u16 vid)<br>
{<br>
memset(gid->raw, 0, 16);<br>
*((u32 *)gid->raw) = cpu_to_be32(0xfe800000);<br>
- gid->raw[12] = 0xfe;<br>
- gid->raw[11] = 0xff;<br>
+ if (vid) {<br>
+ gid->raw[12] = vid & 0xff;<br>
+ gid->raw[11] = vid >> 8;<br>
+ } else {<br>
+ gid->raw[12] = 0xfe;<br>
+ gid->raw[11] = 0xff;<br>
+ }<br>
memcpy(gid->raw + 13, mac + 3, 3);<br>
memcpy(gid->raw + 8, mac, 3);<br>
gid->raw[8] ^= 2;<br>
@@ -143,7 +149,16 @@ static inline void iboe_mac_to_ll(union ib_gid *gid, u8 *mac)<br>
static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,<br>
union ib_gid *gid)<br>
{<br>
- iboe_mac_to_ll(gid, dev_addr->src_dev_addr);<br>
+ struct net_device *dev;<br>
+ u16 vid = 0;<br>
+<br>
+ dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);<br>
+ if (dev) {<br>
+ vid = vlan_dev_vlan_id(dev);<br>
+ dev_put(dev);<br>
+ }<br>
+<br>
+ iboe_mac_vlan_to_ll(gid, dev_addr->src_dev_addr, vid);<br>
}<br>
<br>
static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)<br>
@@ -243,4 +258,30 @@ static inline void rdma_get_mcast_mac(struct in6_addr *addr, u8 *mac)<br>
for (i = 2; i < 6; ++i)<br>
mac[i] = addr->s6_addr[i + 10];<br>
}<br>
+<br>
+static inline u16 rdma_get_vlan_id(union ib_gid *dgid)<br>
+{<br>
+ u16 vid;<br>
+<br>
+ vid = dgid->raw[11] << 8 | dgid->raw[12];<br>
+ return vid == 0xfffe ? 0 : vid & 0xfff;<br>
+}<br>
+<br>
+static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev) {<br>
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)<br>
+ return vlan_dev_vlan_id(dev);<br>
+#else<br>
+ return 0;<br>
+#endif<br>
+}<br>
+<br>
+static inline struct net_device *rdma_vlan_dev_real_dev(const struct net_device *dev)<br>
+{<br>
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)<br>
+ return vlan_dev_real_dev(dev);<br>
+#else<br>
+ return 0;<br>
+#endif<br>
+}<br>
+<br>
#endif /* IB_ADDR_H */<br>
diff --git a/include/rdma/ib_pack.h b/include/rdma/ib_pack.h<br>
index 67a85f3..1678be7 100644<br>
--- a/include/rdma/ib_pack.h<br>
+++ b/include/rdma/ib_pack.h<br>
@@ -38,6 +38,7 @@<br>
enum {<br>
IB_LRH_BYTES = 8,<br>
IB_ETH_BYTES = 14,<br>
+ IB_VLAN_BYTES = 4,<br>
IB_GRH_BYTES = 40,<br>
IB_BTH_BYTES = 12,<br>
IB_DETH_BYTES = 8<br>
@@ -219,21 +220,18 @@ struct ib_unpacked_eth {<br>
__be16 type;<br>
};<br>
<br>
+struct ib_unpacked_vlan {<br>
+ __be16 tag;<br>
+ __be16 type;<br>
+};<br>
+<br>
struct ib_ud_header {<br>
int lrh_present;<br>
struct ib_unpacked_lrh lrh;<br>
int eth_present;<br>
struct ib_unpacked_eth eth;<br>
- int grh_present;<br>
- struct ib_unpacked_grh grh;<br>
- struct ib_unpacked_bth bth;<br>
- struct ib_unpacked_deth deth;<br>
- int immediate_present;<br>
- __be32 immediate_data;<br>
-};<br>
-<br>
-struct eth_ud_header {<br>
- struct ib_unpacked_eth eth;<br>
+ int vlan_present;<br>
+ struct ib_unpacked_vlan vlan;<br>
int grh_present;<br>
struct ib_unpacked_grh grh;<br>
struct ib_unpacked_bth bth;<br>
@@ -255,6 +253,7 @@ void ib_unpack(const struct ib_field *desc,<br>
void ib_ud_header_init(int payload_bytes,<br>
int lrh_present,<br>
int eth_present,<br>
+ int vlan_present,<br>
int grh_present,<br>
int immediate_present,<br>
struct ib_ud_header *header);<br>
<font color="#888888">--<br>
1.7.0<br>
<br>
_______________________________________________<br>
ewg mailing list<br>
<a href="mailto:ewg@lists.openfabrics.org">ewg@lists.openfabrics.org</a><br>
<a href="http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ewg" target="_blank">http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ewg</a><br>
</font></blockquote></div><br></div>