linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] New RAW_PACKET QP type
@ 2010-12-06  7:32 Aleksey Senin
       [not found] ` <4CFC918D.1090708-smomgflXvOZWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksey Senin @ 2010-12-06  7:32 UTC (permalink / raw)
  To: Roland Dreier
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Moni Shoua, Nir Muchtar,
	Or Gerlitz

The following patches add a new QP type named RAW_PACKET.

This type of QP is used in Ethernet environment and intended for
creation of a whole packet, including L2 headers, from userspace.
QP of thie type does not generate header in hardware but sending
gathered payloads to the wire.
This QP type must be used only by privileged software.

Differences from V2

This series doesn't contain patch for protocol distinction.
RAW_PACKET QP added to qp_state_table while preforming QP init.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/4] RAW_PACKET QP type definition
       [not found] ` <4CFC918D.1090708-smomgflXvOZWk0Htik3J/w@public.gmane.org>
@ 2010-12-06  7:34   ` Aleksey Senin
       [not found]     ` <4CFC921D.3000907-smomgflXvOZWk0Htik3J/w@public.gmane.org>
  2011-03-08 21:13   ` [PATCH v3 0/4] New RAW_PACKET QP type Or Gerlitz
  1 sibling, 1 reply; 6+ messages in thread
From: Aleksey Senin @ 2010-12-06  7:34 UTC (permalink / raw)
  To: Roland Dreier
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Moni Shoua, Nir Muchtar,
	Or Gerlitz

Reserve a place for future XRC patch in order to be sure that
OFED kernel ABI will not broken when XRC and RAW patches will be
accepted to upstream kernel.

Signed-off-by: Aleksey Senin <alekseys-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/core/verbs.c |    5 +++--
 include/rdma/ib_verbs.h         |    3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index af7a8b0..611c13c 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -326,8 +326,8 @@ EXPORT_SYMBOL(ib_create_qp);
 
 static const struct {
 	int			valid;
-	enum ib_qp_attr_mask	req_param[IB_QPT_RAW_ETHERTYPE + 1];
-	enum ib_qp_attr_mask	opt_param[IB_QPT_RAW_ETHERTYPE + 1];
+	enum ib_qp_attr_mask	req_param[IB_QPT_RAW_PACKET + 1];
+	enum ib_qp_attr_mask	opt_param[IB_QPT_RAW_PACKET + 1];
 } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
 	[IB_QPS_RESET] = {
 		[IB_QPS_RESET] = { .valid = 1 },
@@ -337,6 +337,7 @@ static const struct {
 				[IB_QPT_UD]  = (IB_QP_PKEY_INDEX		|
 						IB_QP_PORT			|
 						IB_QP_QKEY),
+				[IB_QPT_RAW_PACKET] = IB_QP_PORT,
 				[IB_QPT_UC]  = (IB_QP_PKEY_INDEX		|
 						IB_QP_PORT			|
 						IB_QP_ACCESS_FLAGS),
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e04c488..e14e3f8 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -561,7 +561,8 @@ enum ib_qp_type {
 	IB_QPT_UC,
 	IB_QPT_UD,
 	IB_QPT_RAW_IPV6,
-	IB_QPT_RAW_ETHERTYPE
+	IB_QPT_RAW_ETHERTYPE = 7,
+	IB_QPT_RAW_PACKET = 8
 };
 
 enum ib_qp_create_flags {
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/4] RAW_PACKET QP capabilities check
       [not found]     ` <4CFC921D.3000907-smomgflXvOZWk0Htik3J/w@public.gmane.org>
@ 2010-12-06  7:36       ` Aleksey Senin
       [not found]         ` <4CFC926B.8060305-smomgflXvOZWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksey Senin @ 2010-12-06  7:36 UTC (permalink / raw)
  To: Roland Dreier
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Moni Shoua, Nir Muchtar,
	Or Gerlitz

In order to prevent regular user from creating malicious packets, at the
time of QP creation, kernel will check if the process has necessary
permissions. This examination areis done in uverbs layer and is general
for all low level drivers.

Signed-off-by: Aleksey Senin <alekseys-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/core/uverbs_cmd.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index b342248..df149ed 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1052,6 +1052,9 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
+	if (cmd.qp_type == IB_QPT_RAW_PACKET && !capable(CAP_NET_RAW))
+		return -EPERM;
+
 	INIT_UDATA(&udata, buf + sizeof cmd,
 		   (unsigned long) cmd.response + sizeof resp,
 		   in_len - sizeof cmd, out_len - sizeof resp);
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 3/4] Add RAW_PACKET to verbs attach/detach multicast
       [not found]         ` <4CFC926B.8060305-smomgflXvOZWk0Htik3J/w@public.gmane.org>
@ 2010-12-06  7:37           ` Aleksey Senin
       [not found]             ` <4CFC92AF.8070009-smomgflXvOZWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksey Senin @ 2010-12-06  7:37 UTC (permalink / raw)
  To: Roland Dreier
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Moni Shoua, Nir Muchtar,
	Or Gerlitz

Sanity check - validate that the subnet_prefix bits set to zero'es.

Signed-off-by: Aleksey Senin <alekseys-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/core/verbs.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 611c13c..9e4998c 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -904,7 +904,10 @@ int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 {
 	if (!qp->device->attach_mcast)
 		return -ENOSYS;
-	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
+	if (qp->qp_type == IB_QPT_RAW_PACKET) {
+		if (gid->global.subnet_prefix & cpu_to_be64(~1ULL))
+			return -EINVAL;
+	} else if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
 		return -EINVAL;
 
 	return qp->device->attach_mcast(qp, gid, lid);
@@ -915,7 +918,10 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 {
 	if (!qp->device->detach_mcast)
 		return -ENOSYS;
-	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
+	if (qp->qp_type == IB_QPT_RAW_PACKET) {
+		if (gid->global.subnet_prefix & cpu_to_be64(~1ULL))
+			return -EINVAL;
+	} else if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
 		return -EINVAL;
 
 	return qp->device->detach_mcast(qp, gid, lid);
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 4/4] mlx4: RAW PACKET QP support
       [not found]             ` <4CFC92AF.8070009-smomgflXvOZWk0Htik3J/w@public.gmane.org>
@ 2010-12-06  7:38               ` Aleksey Senin
  0 siblings, 0 replies; 6+ messages in thread
From: Aleksey Senin @ 2010-12-06  7:38 UTC (permalink / raw)
  To: Roland Dreier
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Moni Shoua, Nir Muchtar,
	Or Gerlitz

Make distinction when attaching/detaching multicast QP.
QP type  used for protocol determination.

When modifiying QP set mtu_msgmax to 0xff as it  required by from
Mellanox PRM. In the case of using raw ethernet first three bits (mtu)
should be set to 7 and the rest (maximum message size) to 31.

Signed-off-by: Aleksey Senin <alekseys-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/hw/mlx4/main.c |   14 +++++++++-----
 drivers/infiniband/hw/mlx4/qp.c   |   20 +++++++++++++++-----
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index bbe003f..0a19fcd 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -622,10 +622,12 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 	int err;
 	struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
 	struct mlx4_ib_qp *mqp = to_mqp(ibqp);
+	enum mlx4_protocol prot = (ibqp->qp_type == IB_QPT_RAW_PACKET ?
+			    MLX4_PROTOCOL_EN : MLX4_PROTOCOL_IB);
 
 	err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw, !!(mqp->flags &
-				    MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK),
-				    MLX4_PROTOCOL_IB);
+				    MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK), prot);
+
 	if (err)
 		return err;
 
@@ -636,8 +638,8 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 	return 0;
 
 err_add:
-	mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw,
-			MLX4_PROTOCOL_IB);
+	mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw, prot);
+
 	return err;
 }
 
@@ -665,9 +667,11 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 	u8 mac[6];
 	struct net_device *ndev;
 	struct mlx4_ib_gid_entry *ge;
+	enum mlx4_protocol prot = (ibqp->qp_type == IB_QPT_RAW_PACKET ?
+				    MLX4_PROTOCOL_EN : MLX4_PROTOCOL_IB);
 
 	err = mlx4_multicast_detach(mdev->dev,
-				    &mqp->mqp, gid->raw, MLX4_PROTOCOL_IB);
+				    &mqp->mqp, gid->raw, prot);
 	if (err)
 		return err;
 
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 9a7794a..0008b7a 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -746,6 +746,7 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
 	case IB_QPT_RC:
 	case IB_QPT_UC:
 	case IB_QPT_UD:
+	case IB_QPT_RAW_PACKET:
 	{
 		qp = kzalloc(sizeof *qp, GFP_KERNEL);
 		if (!qp)
@@ -822,7 +823,8 @@ static int to_mlx4_st(enum ib_qp_type type)
 	case IB_QPT_UC:		return MLX4_QP_ST_UC;
 	case IB_QPT_UD:		return MLX4_QP_ST_UD;
 	case IB_QPT_SMI:
-	case IB_QPT_GSI:	return MLX4_QP_ST_MLX;
+	case IB_QPT_GSI:
+	case IB_QPT_RAW_PACKET:	return MLX4_QP_ST_MLX;
 	default:		return -1;
 	}
 }
@@ -988,8 +990,9 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 			break;
 		}
 	}
-
-	if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_SMI)
+	if (ibqp->qp_type == IB_QPT_RAW_PACKET)
+		context->mtu_msgmax = 0xff;
+	else if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_SMI)
 		context->mtu_msgmax = (IB_MTU_4096 << 5) | 11;
 	else if (ibqp->qp_type == IB_QPT_UD) {
 		if (qp->flags & MLX4_IB_QP_LSO)
@@ -1138,7 +1141,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 	if (cur_state == IB_QPS_INIT &&
 	    new_state == IB_QPS_RTR  &&
 	    (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_SMI ||
-	     ibqp->qp_type == IB_QPT_UD)) {
+	     ibqp->qp_type == IB_QPT_UD ||
+	     ibqp->qp_type == IB_QPT_RAW_PACKET)) {
 		context->pri_path.sched_queue = (qp->port - 1) << 6;
 		if (is_qp0(dev, qp))
 			context->pri_path.sched_queue |= MLX4_IB_DEFAULT_QP0_SCHED_QUEUE;
@@ -1252,11 +1256,17 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 	if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask))
 		goto out;
 
-	if ((attr_mask & IB_QP_PORT) &&
+	if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type != IB_QPT_RAW_PACKET) &&
 	    (attr->port_num == 0 || attr->port_num > dev->dev->caps.num_ports)) {
 		goto out;
 	}
 
+	if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
+		(rdma_port_get_link_layer(&dev->ib_dev, attr->port_num)
+				!= IB_LINK_LAYER_ETHERNET)) {
+		goto out;
+	}
+
 	if (attr_mask & IB_QP_PKEY_INDEX) {
 		int p = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
 		if (attr->pkey_index >= dev->dev->caps.pkey_table_len[p])
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 0/4] New RAW_PACKET QP type
       [not found] ` <4CFC918D.1090708-smomgflXvOZWk0Htik3J/w@public.gmane.org>
  2010-12-06  7:34   ` [PATCH v3 1/4] RAW_PACKET QP type definition Aleksey Senin
@ 2011-03-08 21:13   ` Or Gerlitz
  1 sibling, 0 replies; 6+ messages in thread
From: Or Gerlitz @ 2011-03-08 21:13 UTC (permalink / raw)
  To: Roland Dreier
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Nir Muchtar, Aleksey Senin

On Mon, Dec 6, 2010 at 9:32 AM, Aleksey Senin <alekseys-smomgflXvOZWk0Htik3J/w@public.gmane.org> wrote:
> The following patches add a new QP type named RAW_PACKET.
> This type of QP is used in Ethernet environment and intended for
> creation of a whole packet, including L2 headers, from userspace.


Hi Roland, any chance you can look on these raw qp patches for the
coming merge window? as you can see, there's some dependencies and
inter-relations between the mlx4 streeing changes to the raw qp
support, and having the raw qp support stay behind / out of tree makes
things complex to track. Also, what's more on the plate for the coming
window?

Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-03-08 21:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-06  7:32 [PATCH v3 0/4] New RAW_PACKET QP type Aleksey Senin
     [not found] ` <4CFC918D.1090708-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-12-06  7:34   ` [PATCH v3 1/4] RAW_PACKET QP type definition Aleksey Senin
     [not found]     ` <4CFC921D.3000907-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-12-06  7:36       ` [PATCH v3 2/4] RAW_PACKET QP capabilities check Aleksey Senin
     [not found]         ` <4CFC926B.8060305-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-12-06  7:37           ` [PATCH v3 3/4] Add RAW_PACKET to verbs attach/detach multicast Aleksey Senin
     [not found]             ` <4CFC92AF.8070009-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-12-06  7:38               ` [PATCH v3 4/4] mlx4: RAW PACKET QP support Aleksey Senin
2011-03-08 21:13   ` [PATCH v3 0/4] New RAW_PACKET QP type Or Gerlitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).