From patchwork Tue Jul 19 09:34:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 988502 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6J9XEIi017063 for ; Tue, 19 Jul 2011 09:34:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750983Ab1GSJed (ORCPT ); Tue, 19 Jul 2011 05:34:33 -0400 Received: from mail.mellanox.co.il ([194.90.237.43]:48815 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750882Ab1GSJec (ORCPT ); Tue, 19 Jul 2011 05:34:32 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from ogerlitz@mellanox.com) with SMTP; 19 Jul 2011 12:34:30 +0300 Received: from MTRCASDAG01.mtl.com (172.25.0.174) by MTLCAS01.mtl.com (10.0.8.71) with Microsoft SMTP Server (TLS) id 14.1.289.1; Tue, 19 Jul 2011 12:34:30 +0300 Received: from host217 (172.25.5.217) by MTRCASDAG01.mtl.com (172.25.0.174) with Microsoft SMTP Server (TLS) id 14.1.289.1; Tue, 19 Jul 2011 12:34:30 +0300 Date: Tue, 19 Jul 2011 12:34:15 +0300 From: Or Gerlitz X-X-Sender: ogerlitz@ogerlitz.voltaire.com To: Roland Dreier CC: linux-rdma Subject: [PATCH 6/7] libmlx4: add IBoE UD/VLANs support In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (LRH 1167 2008-08-23) MIME-Version: 1.0 X-Originating-IP: [172.25.5.217] 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.6 (demeter2.kernel.org [140.211.167.43]); Tue, 19 Jul 2011 09:34:33 +0000 (UTC) Add VLANs support for the UD address handle creation flow, where the vlan id is taken from the destination GID and the and vlan priority from the IB SL specified by the application. Signed-off-by: Or Gerlitz --- src/mlx4.h | 1 + src/qp.c | 1 + src/verbs.c | 9 +++++++-- src/wqe.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mlx4.h b/src/mlx4.h index b277b06..0ad838d 100644 --- a/src/mlx4.h +++ b/src/mlx4.h @@ -241,6 +241,7 @@ struct mlx4_av { struct mlx4_ah { struct ibv_ah ibv_ah; struct mlx4_av av; + uint16_t vlan; uint8_t mac[6]; }; diff --git a/src/qp.c b/src/qp.c index 4d79e38..40a6689 100644 --- a/src/qp.c +++ b/src/qp.c @@ -144,6 +144,7 @@ static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg, memcpy(dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof (struct mlx4_av)); dseg->dqpn = htonl(wr->wr.ud.remote_qpn); dseg->qkey = htonl(wr->wr.ud.remote_qkey); + dseg->vlan = htons(to_mah(wr->wr.ud.ah)->vlan); memcpy(dseg->mac, to_mah(wr->wr.ud.ah)->mac, 6); } diff --git a/src/verbs.c b/src/verbs.c index 6620ac2..8aa9860 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -634,13 +634,18 @@ static uint16_t get_vlan_id(union ibv_gid *gid) static int mlx4_resolve_grh_to_l2(struct mlx4_ah *ah, struct ibv_ah_attr *attr) { - if (get_vlan_id(&attr->grh.dgid) != 0xffff) - return 1; + uint16_t vid; if (link_local_gid(&attr->grh.dgid)) { memcpy(ah->mac, &attr->grh.dgid.raw[8], 3); memcpy(ah->mac + 3, &attr->grh.dgid.raw[13], 3); ah->mac[0] ^= 2; + + vid = get_vlan_id(&attr->grh.dgid); + if (vid != 0xffff) { + ah->av.port_pd |= htonl(1 << 29); + ah->vlan = vid | ((attr->sl & 7) << 13); + } return 0; } else return 1; diff --git a/src/wqe.h b/src/wqe.h index 043f0da..bbd22ba 100644 --- a/src/wqe.h +++ b/src/wqe.h @@ -78,7 +78,7 @@ struct mlx4_wqe_datagram_seg { uint32_t av[8]; uint32_t dqpn; uint32_t qkey; - uint16_t reserved; + uint16_t vlan; uint8_t mac[6]; };