Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Aug 2018 08:12:52 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r337076 - in stable/11/sys/ofed: drivers/infiniband/core include/rdma
Message-ID:  <201808020812.w728Cq44039215@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Thu Aug  2 08:12:52 2018
New Revision: 337076
URL: https://svnweb.freebsd.org/changeset/base/337076

Log:
  MFC r336370:
  Set RoCEv2 MGID according to spec in ibcore.
  
  RoCEv2 Annex states that for RoCEv2 over IPv4, the corresponding
  IPv4 address is encoded into the GID according to the following rule:
  GID= :ffff:<IPv4 address>
  
  Remove the 0xff0e prefix for RoCEv2 packets with IPv4 and leave it
  zeroed and change rdma_is_multicast_addr() to consider the new logic.
  
  Linux commit:
  be1d325a335840a86c133a56c6a911c368bac0fd
  1c3aea2bc8f0b2e5b57375ead40457ff75a3a2ec
  
  Sponsored by:		Mellanox Technologies

Modified:
  stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c
  stable/11/sys/ofed/drivers/infiniband/core/ib_verbs.c
  stable/11/sys/ofed/include/rdma/ib_addr.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c
==============================================================================
--- stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c	Thu Aug  2 08:12:01 2018	(r337075)
+++ stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c	Thu Aug  2 08:12:52 2018	(r337076)
@@ -3947,7 +3947,8 @@ static void iboe_mcast_work_handler(struct work_struct
 	kfree(mw);
 }
 
-static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid)
+static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid,
+			      enum ib_gid_type gid_type)
 {
 	struct sockaddr_in *sin = (struct sockaddr_in *)addr;
 	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
@@ -3957,8 +3958,8 @@ static void cma_iboe_set_mgid(struct sockaddr *addr, u
 	} else if (addr->sa_family == AF_INET6) {
 		memcpy(mgid, &sin6->sin6_addr, sizeof *mgid);
 	} else {
-		mgid->raw[0] = 0xff;
-		mgid->raw[1] = 0x0e;
+		mgid->raw[0] = (gid_type == IB_GID_TYPE_IB) ? 0xff : 0;
+		mgid->raw[1] = (gid_type == IB_GID_TYPE_IB) ? 0x0e : 0;
 		mgid->raw[2] = 0;
 		mgid->raw[3] = 0;
 		mgid->raw[4] = 0;
@@ -3999,7 +4000,9 @@ static int cma_iboe_join_multicast(struct rdma_id_priv
 		goto out1;
 	}
 
-	cma_iboe_set_mgid(addr, &mc->multicast.ib->rec.mgid);
+	gid_type = id_priv->cma_dev->default_gid_type[id_priv->id.port_num -
+		   rdma_start_port(id_priv->cma_dev->device)];
+	cma_iboe_set_mgid(addr, &mc->multicast.ib->rec.mgid, gid_type);
 
 	mc->multicast.ib->rec.pkey = cpu_to_be16(0xffff);
 	if (id_priv->id.ps == RDMA_PS_UDP)
@@ -4015,8 +4018,6 @@ static int cma_iboe_join_multicast(struct rdma_id_priv
 	mc->multicast.ib->rec.hop_limit = 1;
 	mc->multicast.ib->rec.mtu = iboe_get_mtu(ndev->if_mtu);
 
-	gid_type = id_priv->cma_dev->default_gid_type[id_priv->id.port_num -
-		   rdma_start_port(id_priv->cma_dev->device)];
 	if (addr->sa_family == AF_INET) {
 		if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) {
 			mc->multicast.ib->rec.hop_limit = IPV6_DEFAULT_HOPLIMIT;

Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_verbs.c
==============================================================================
--- stable/11/sys/ofed/drivers/infiniband/core/ib_verbs.c	Thu Aug  2 08:12:01 2018	(r337075)
+++ stable/11/sys/ofed/drivers/infiniband/core/ib_verbs.c	Thu Aug  2 08:12:52 2018	(r337076)
@@ -1511,8 +1511,9 @@ int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gi
 
 	if (!qp->device->attach_mcast)
 		return -ENOSYS;
-	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
-	    !is_valid_mcast_lid(qp, lid))
+
+	if (!rdma_is_multicast_addr((struct in6_addr *)gid->raw) ||
+	    qp->qp_type != IB_QPT_UD || !is_valid_mcast_lid(qp, lid))
 		return -EINVAL;
 
 	ret = qp->device->attach_mcast(qp, gid, lid);
@@ -1528,8 +1529,9 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gi
 
 	if (!qp->device->detach_mcast)
 		return -ENOSYS;
-	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
-	    !is_valid_mcast_lid(qp, lid))
+
+	if (!rdma_is_multicast_addr((struct in6_addr *)gid->raw) ||
+	    qp->qp_type != IB_QPT_UD || !is_valid_mcast_lid(qp, lid))
 		return -EINVAL;
 
 	ret = qp->device->detach_mcast(qp, gid, lid);

Modified: stable/11/sys/ofed/include/rdma/ib_addr.h
==============================================================================
--- stable/11/sys/ofed/include/rdma/ib_addr.h	Thu Aug  2 08:12:01 2018	(r337075)
+++ stable/11/sys/ofed/include/rdma/ib_addr.h	Thu Aug  2 08:12:52 2018	(r337076)
@@ -315,7 +315,13 @@ static inline void rdma_get_ll_mac(struct in6_addr *ad
 
 static inline int rdma_is_multicast_addr(struct in6_addr *addr)
 {
-	return addr->s6_addr[0] == 0xff;
+	__be32 ipv4_addr;
+
+	if (addr->s6_addr[0] == 0xff)
+		return 1;
+
+	ipv4_addr = addr->s6_addr32[3];
+	return (ipv6_addr_v4mapped(addr) && ipv4_is_multicast(ipv4_addr));
 }
 
 static inline void rdma_get_mcast_mac(struct in6_addr *addr, u8 *mac)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808020812.w728Cq44039215>