From patchwork Mon Oct 5 17:45:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 51763 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n95HnPCT006816 for ; Mon, 5 Oct 2009 17:49:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754073AbZJERpx (ORCPT ); Mon, 5 Oct 2009 13:45:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754152AbZJERpx (ORCPT ); Mon, 5 Oct 2009 13:45:53 -0400 Received: from mga01.intel.com ([192.55.52.88]:19642 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754073AbZJERpw (ORCPT ); Mon, 5 Oct 2009 13:45:52 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 05 Oct 2009 10:39:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.44,507,1249282800"; d="scan'208";a="500017587" Received: from mshefty-mobl2.amr.corp.intel.com (HELO msheftyMOBL2) ([10.24.90.80]) by fmsmga002.fm.intel.com with ESMTP; 05 Oct 2009 10:37:07 -0700 From: "Sean Hefty" To: "linux-rdma" , "Roland Dreier" Cc: "Hefty, Sean" References: Subject: [PATCH 2/2] rdma/cm: allow user to specify IP to DGID mapping Date: Mon, 5 Oct 2009 10:45:15 -0700 Message-ID: MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcpF42ImUM6vKmP1QmaJuGQm512aeAAAAiLg In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 0753178..9adf8fb 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1919,6 +1919,21 @@ err: } EXPORT_SYMBOL(rdma_resolve_addr); +int rdma_set_ib_dest(struct rdma_cm_id *id, struct sockaddr *dst_addr, + union ib_gid *dgid) +{ + struct rdma_id_private *id_priv; + + id_priv = container_of(id, struct rdma_id_private, id); + if (!cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_ADDR_RESOLVED)) + return -EINVAL; + + memcpy(&id->route.addr.dst_addr, dst_addr, ip_addr_size(dst_addr)); + ib_addr_set_dgid(&id->route.addr.dev_addr, dgid); + return 0; +} +EXPORT_SYMBOL(rdma_set_ib_dest); + static void cma_bind_port(struct rdma_bind_list *bind_list, struct rdma_id_private *id_priv) { diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 1359727..3a252e6 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -832,12 +832,35 @@ static int ucma_set_ib_path(struct ucma_context *ctx, return ucma_event_handler(ctx->cm_id, &event); } +static int ucma_set_ib_dest(struct ucma_context *ctx, + struct rdma_ucm_ib_dest *ib_dest, size_t optlen) +{ + union ib_gid dgid; + struct rdma_cm_event event; + int ret; + + if (optlen < sizeof(*ib_dest)) + return -EINVAL; + + memcpy(&dgid, ib_dest->dgid, sizeof dgid); + ret = rdma_set_ib_dest(ctx->cm_id, (struct sockaddr *) &ib_dest->dst_addr, &dgid); + if (ret) + return ret; + + memset(&event, 0, sizeof event); + event.event = RDMA_CM_EVENT_ADDR_RESOLVED; + return ucma_event_handler(ctx->cm_id, &event); +} + static int ucma_set_option_ib(struct ucma_context *ctx, int optname, void *optval, size_t optlen) { int ret; switch (optname) { + case RDMA_OPTION_IB_DEST: + ret = ucma_set_ib_dest(ctx, optval, optlen); + break; case RDMA_OPTION_IB_PATH: ret = ucma_set_ib_path(ctx, optval, optlen); break; diff --git a/include/rdma/rdma_cm_ib.h b/include/rdma/rdma_cm_ib.h index 2389c3b..7326d35 100644 --- a/include/rdma/rdma_cm_ib.h +++ b/include/rdma/rdma_cm_ib.h @@ -48,6 +48,20 @@ int rdma_set_ib_paths(struct rdma_cm_id *id, struct ib_sa_path_rec *path_rec, int num_paths); +/** + * rdma_set_ib_dest - Manually set the destination address + * @id: Connection identifier associated with the request. + * @dst_addr: Destination address information. + * @dgid: Destination device address information. + * + * This call allows the user to specify address mappings for rdma_cm_id's + * bound to an Infiniband device. It is called on the client side of a + * connection and combined with rdma_bind_addr, replaces the call to + * rdma_resolve_addr. + */ +int rdma_set_ib_dest(struct rdma_cm_id *id, struct sockaddr *dst_addr, + union ib_gid *dgid); + /* Global qkey for UDP QPs and multicast groups. */ #define RDMA_UDP_QKEY 0x01234567 diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h index d7829f4..a908b89 100644 --- a/include/rdma/rdma_user_cm.h +++ b/include/rdma/rdma_user_cm.h @@ -223,6 +223,7 @@ enum { enum { RDMA_OPTION_ID_TOS = 0, + RDMA_OPTION_IB_DEST = 0, RDMA_OPTION_IB_PATH = 1 }; @@ -234,6 +235,11 @@ struct rdma_ucm_set_option { __u32 optlen; }; +struct rdma_ucm_ib_dest { + __u8 dgid[16]; + struct sockaddr_in6 dst_addr; +}; + struct rdma_ucm_migrate_id { __u64 response; __u32 id;