From patchwork Wed Aug 20 06:52:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Barak X-Patchwork-Id: 4747741 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7FD339F375 for ; Wed, 20 Aug 2014 06:52:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF094200CF for ; Wed, 20 Aug 2014 06:52:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 820CC20179 for ; Wed, 20 Aug 2014 06:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750916AbaHTGwS (ORCPT ); Wed, 20 Aug 2014 02:52:18 -0400 Received: from mailp.voltaire.com ([193.47.165.129]:56160 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751460AbaHTGwS (ORCPT ); Wed, 20 Aug 2014 02:52:18 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from matanb@mellanox.com) with SMTP; 20 Aug 2014 09:52:11 +0300 Received: from r-vnc06.mtr.labs.mlnx (r-vnc06.mtr.labs.mlnx [10.208.0.117]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id s7K6qB1f014122; Wed, 20 Aug 2014 09:52:11 +0300 From: Matan Barak To: Yishai Hadas , Jason Gunthorpe Cc: Roland Dreier , linux-rdma@vger.kernel.org, dledford@redhat.com, Or Gerlitz , Matan Barak Subject: [PATCH libmlx4 V4 2/2] Add RoCE IP based addressing support for UD QPs Date: Wed, 20 Aug 2014 09:52:09 +0300 Message-Id: <1408517529-20631-3-git-send-email-matanb@mellanox.com> X-Mailer: git-send-email 1.7.6.4 In-Reply-To: <1408517529-20631-1-git-send-email-matanb@mellanox.com> References: <1408517529-20631-1-git-send-email-matanb@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to implement IP based addressing for UD QPs, we need a way to resolve the addresses internally. When the provider detects an Ethernet link layer with IP based gids, it calls a helper function in libibverbs in order to resolve the Ethernet L2 params. Signed-off-by: Matan Barak Signed-off-by: Or Gerlitz --- src/verbs.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/verbs.c b/src/verbs.c index 5c069ea..831e934 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -856,11 +856,29 @@ struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) memcpy(ah->av.dgid, attr->grh.dgid.raw, 16); } - if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) - if (mlx4_resolve_grh_to_l2(pd, ah, attr)) { - free(ah); - return NULL; + if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) { + if (port_attr.port_cap_flags & IBV_PORT_IP_BASED_GIDS) { + uint16_t vid; + + if (ibv_resolve_eth_l2_from_gid(pd->context, attr, + ah->mac, &vid)) { + free(ah); + return NULL; + } + + if (vid <= 0xfff) { + ah->av.port_pd |= htonl(1 << 29); + ah->vlan = vid | + ((attr->sl & 7) << 13); + } + + } else { + if (mlx4_resolve_grh_to_l2(pd, ah, attr)) { + free(ah); + return NULL; + } } + } return &ah->ibv_ah; }