[ofw] [Patch 30/62] Reference implementation of NDv2
Fab Tillier
ftillier at microsoft.com
Wed Feb 20 18:00:58 PST 2013
Don't redefine IPv6 address structure, reuse system defined structure and associated macros. Also get rid of weird "extern inline" function and put the inline function in a header.
Signed-off-by: Fab Tillier <ftillier at microsoft.com>
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\ib\ah.c .\hw\mlx4\kernel\bus\ib\ah.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\ib\ah.c Thu Mar 29 00:15:28 2012
+++ .\hw\mlx4\kernel\bus\ib\ah.c Wed May 23 15:14:37 2012
@@ -40,60 +40,33 @@
#include "ah.tmh"
#endif
-
-static inline int rdma_link_local_addr(struct ib_in6_addr *addr)
-{
- if (addr->s6_addr32[0] == cpu_to_be32(0xfe800000) &&
- addr->s6_addr32[1] == 0)
- return 1;
- else
- return 0;
-}
-
-inline void rdma_get_ll_mac(struct ib_in6_addr *addr, u8 *mac)
-{
- memcpy(mac, &addr->s6_addr[8], 3);
- memcpy(mac + 3, &addr->s6_addr[13], 3);
- mac[0] ^= 2;
-}
-
-static inline int rdma_is_multicast_addr(struct ib_in6_addr *addr)
-{
- return addr->s6_addr[0] == 0xff ? 1 : 0;
-}
-
-static inline void rdma_get_mcast_mac(struct ib_in6_addr *addr, u8 *mac)
+static inline void rdma_get_mcast_mac(const union ib_gid *gid, u8 *mac)
{
int i;
mac[0] = 0x33;
mac[1] = 0x33;
for (i = 2; i < 6; ++i)
- mac[i] = addr->s6_addr[i + 10];
+ mac[i] = gid->raw[i + 10];
}
int mlx4_ib_resolve_grh(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah_attr,
u8 *mac, int *is_mcast)
{
- int err = 0;
- struct ib_sockaddr_in6 dst;
-
UNREFERENCED_PARAMETER(dev);
+ if (IN6_IS_ADDR_LINKLOCAL((IN6_ADDR*)ah_attr->grh.dgid.raw)) {
+ rdma_get_ll_mac(&ah_attr->grh.dgid, mac);
*is_mcast = 0;
- memcpy(dst.sin6_addr.s6_addr, ah_attr->grh.dgid.raw, sizeof(ah_attr->grh.dgid.raw));
-
- if (rdma_link_local_addr(&dst.sin6_addr))
- rdma_get_ll_mac(&dst.sin6_addr, mac);
- else if (rdma_is_multicast_addr(&dst.sin6_addr)) {
- rdma_get_mcast_mac(&dst.sin6_addr, mac);
+ } else if (IN6_IS_ADDR_MULTICAST((IN6_ADDR*)ah_attr->grh.dgid.raw)) {
+ rdma_get_mcast_mac(&ah_attr->grh.dgid, mac);
*is_mcast = 1;
} else {
- err = -EINVAL; //jyang:todo
ASSERT(FALSE);
+ return -EINVAL; //jyang:todo
}
- return err;
+ return 0;
}
static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\ib\mlx4_ib.h .\hw\mlx4\kernel\bus\ib\mlx4_ib.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\ib\mlx4_ib.h Thu Aug 02 13:58:26 2012
+++ .\hw\mlx4\kernel\bus\ib\mlx4_ib.h Thu Jul 26 15:31:14 2012
@@ -43,6 +43,15 @@
#include "doorbell.h"
#include "ib_pack.h"
+
+inline void rdma_get_ll_mac(const union ib_gid *gid, u8 *mac)
+{
+ memcpy(mac, &gid->raw[8], 3);
+ memcpy(mac + 3, &gid->raw[13], 3);
+ mac[0] ^= 2;
+}
+
+
enum {
MLX4_IB_DB_PER_PAGE = PAGE_SIZE / 4
};
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\ib\qp.c .\hw\mlx4\kernel\bus\ib\qp.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\ib\qp.c Thu Aug 02 13:08:44 2012
+++ .\hw\mlx4\kernel\bus\ib\qp.c Thu Jul 26 15:31:14 2012
@@ -93,8 +93,6 @@ static const __be32 mlx4_ib_opcode[] = {
//????????????????? IB_WR_RDMA_READ_WITH_INV, //???????????????
-extern inline void rdma_get_ll_mac(struct ib_in6_addr *addr, u8 *mac);
-
static struct mlx4_ib_sqp *to_msqp(struct mlx4_ib_qp *mqp)
{
return container_of(mqp, struct mlx4_ib_sqp, qp);
@@ -1735,7 +1733,7 @@ static int build_mlx_header(struct mlx4_
memcpy(eth->eth.dmac_h, ah->av.eth.mac_0_1, 2);
memcpy(eth->eth.dmac_h + 2, ah->av.eth.mac_2_5, 2);
memcpy(eth->eth.dmac_l, ah->av.eth.mac_2_5 + 2, 2);
- rdma_get_ll_mac((struct ib_in6_addr *)&grh->source_gid, mac);
+ rdma_get_ll_mac(&grh->source_gid, mac);
tmp = mac;
memcpy(eth->eth.smac_h, tmp, 2);
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\inc\ib_verbs.h .\hw\mlx4\kernel\bus\inc\ib_verbs.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\inc\ib_verbs.h Thu Aug 02 13:58:26 2012
+++ .\hw\mlx4\kernel\bus\inc\ib_verbs.h Thu Jul 26 15:31:14 2012
@@ -50,38 +50,8 @@ union ib_gid {
};
#include "ib_verbs_ex.h"
-
-/*
- * IPv6 address structure
- */
-
-struct ib_in6_addr
-{
- union
- {
- __u8 u6_addr8[16];
- __be16 u6_addr16[8];
- __be32 u6_addr32[4];
- } in6_u;
-#ifndef s6_addr
-#define s6_addr in6_u.u6_addr8
-#endif
-#define s6_addr16 in6_u.u6_addr16
-#define s6_addr32 in6_u.u6_addr32
-};
-
-
-struct ib_sockaddr_in6 {
- unsigned short int sin6_family; /* AF_INET6 */
- __be16 sin6_port; /* Transport layer port # */
- __be32 sin6_flowinfo; /* IPv6 flow information */
- struct ib_in6_addr sin6_addr; /* IPv6 address */
- __u32 sin6_scope_id; /* scope id (new in RFC2553) */
-};
-
-#ifndef AF_INET6
-#define AF_INET6 10 /* IP version 6 */
-#endif
+#include <ws2def.h>
+#include <ws2ipdef.h>
enum rdma_node_type {
/* IB values map to NodeInfo:NodeType. */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ndv2.30.patch
Type: application/octet-stream
Size: 4960 bytes
Desc: ndv2.30.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20130221/445a3c91/attachment.obj>
More information about the ofw
mailing list