From patchwork Mon Dec 6 07:38:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksey Senin X-Patchwork-Id: 377272 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB67aEaj026442 for ; Mon, 6 Dec 2010 07:38:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751260Ab0LFHiu (ORCPT ); Mon, 6 Dec 2010 02:38:50 -0500 Received: from fwil.voltaire.com ([193.47.165.2]:33680 "EHLO Exil2010.voltaire.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751101Ab0LFHiu (ORCPT ); Mon, 6 Dec 2010 02:38:50 -0500 Received: from exil.voltaire.com (172.25.0.55) by Exil2010.voltaire.com (172.25.0.11) with Microsoft SMTP Server id 14.1.255.0; Mon, 6 Dec 2010 09:38:44 +0200 Received: from [172.25.5.190] ([172.25.5.190]) by exil.voltaire.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 6 Dec 2010 09:38:43 +0200 Message-ID: <4CFC9303.101@voltaire.com> Date: Mon, 6 Dec 2010 09:38:43 +0200 From: Aleksey Senin User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6 MIME-Version: 1.0 To: Roland Dreier CC: , Moni Shoua , Nir Muchtar , Or Gerlitz Subject: [PATCH v3 4/4] mlx4: RAW PACKET QP support References: <4CFC918D.1090708@voltaire.com> <4CFC921D.3000907@voltaire.com> <4CFC926B.8060305@voltaire.com> <4CFC92AF.8070009@voltaire.com> In-Reply-To: <4CFC92AF.8070009@voltaire.com> X-OriginalArrivalTime: 06 Dec 2010 07:38:43.0743 (UTC) FILETIME=[9BE522F0:01CB9518] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 06 Dec 2010 07:38:51 +0000 (UTC) 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])