From patchwork Fri Aug 2 22:20:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 2838198 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 45875BF535 for ; Fri, 2 Aug 2013 22:20:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C35720355 for ; Fri, 2 Aug 2013 22:20:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41D0120364 for ; Fri, 2 Aug 2013 22:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754174Ab3HBWUa (ORCPT ); Fri, 2 Aug 2013 18:20:30 -0400 Received: from mga01.intel.com ([192.55.52.88]:20958 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753589Ab3HBWU3 (ORCPT ); Fri, 2 Aug 2013 18:20:29 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 02 Aug 2013 15:20:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,804,1367996400"; d="scan'208";a="375385369" Received: from cst-linux.jf.intel.com ([10.23.221.72]) by fmsmga001.fm.intel.com with ESMTP; 02 Aug 2013 15:20:28 -0700 From: sean.hefty@intel.com To: linux-rdma@vger.kernel.org Cc: Sean Hefty Subject: [PATCH librdmacm 1/5] rsockets: Support native IB addressing on connected rsockets Date: Fri, 2 Aug 2013 15:20:18 -0700 Message-Id: <1375482022-5953-2-git-send-email-sean.hefty@intel.com> X-Mailer: git-send-email 1.7.3 In-Reply-To: <1375482022-5953-1-git-send-email-sean.hefty@intel.com> References: <1375482022-5953-1-git-send-email-sean.hefty@intel.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=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Sean Hefty Update rsockets to support AF_IB addresses on connected rsockets. Support for datagram rsockets is more difficult as a result of using real UDP sockets for QP resolution, so that support is deferred. For connected sockets, we need to update internal checks to handle AF_IB. Signed-off-by: Sean Hefty --- src/acm.c | 12 ------------ src/cma.h | 12 ++++++++++++ src/rsocket.c | 39 +++++++++++++++++++++++++++++---------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/acm.c b/src/acm.c index 33379cf..45bcb81 100644 --- a/src/acm.c +++ b/src/acm.c @@ -116,18 +116,6 @@ static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER; static int sock = -1; static uint16_t server_port; -struct ib_connect_hdr { - uint8_t cma_version; - uint8_t ip_version; /* IP version: 7:4 */ - uint16_t port; - uint32_t src_addr[4]; - uint32_t dst_addr[4]; -#define cma_src_ip4 src_addr[3] -#define cma_src_ip6 src_addr[0] -#define cma_dst_ip4 dst_addr[3] -#define cma_dst_ip6 dst_addr[0] -}; - static int ucma_set_server_port(void) { FILE *f; diff --git a/src/cma.h b/src/cma.h index e6fba8b..e944a9a 100644 --- a/src/cma.h +++ b/src/cma.h @@ -206,6 +206,18 @@ struct ibv_path_data }; #endif +struct ib_connect_hdr { + uint8_t cma_version; + uint8_t ip_version; /* IP version: 7:4 */ + uint16_t port; + uint32_t src_addr[4]; + uint32_t dst_addr[4]; +#define cma_src_ip4 src_addr[3] +#define cma_src_ip6 src_addr[0] +#define cma_dst_ip4 dst_addr[3] +#define cma_dst_ip6 dst_addr[0] +}; + #ifndef SYSCONFDIR #define SYSCONFDIR "/etc" #endif diff --git a/src/rsocket.c b/src/rsocket.c index ef24dfb..e2b1cc7 100644 --- a/src/rsocket.c +++ b/src/rsocket.c @@ -187,6 +187,16 @@ struct rs_conn_data { struct rs_sge data_buf; }; +struct rs_conn_private_data { + union { + struct rs_conn_data conn_data; + struct { + struct ib_connect_hdr ib_hdr; + struct rs_conn_data conn_data; + } af_ib; + }; +}; + /* * rsocket states are ordered as passive, connecting, connected, disconnected. */ @@ -965,8 +975,13 @@ static void rs_free(struct rsocket *rs) free(rs); } -static void rs_set_conn_data(struct rsocket *rs, struct rdma_conn_param *param, - struct rs_conn_data *conn) +static size_t rs_conn_data_offset(struct rsocket *rs) +{ + return (rs->cm_id->route.addr.src_addr.sa_family == AF_IB) ? + sizeof(struct ib_connect_hdr) : 0; +} + +static void rs_format_conn_data(struct rsocket *rs, struct rs_conn_data *conn) { conn->version = 1; conn->flags = RS_CONN_FLAG_IOMAP | @@ -982,9 +997,6 @@ static void rs_set_conn_data(struct rsocket *rs, struct rdma_conn_param *param, conn->data_buf.addr = htonll((uintptr_t) rs->rbuf); conn->data_buf.length = htonl(rs->rbuf_size >> 1); conn->data_buf.key = htonl(rs->rmr->rkey); - - param->private_data = conn; - param->private_data_len = sizeof *conn; } static void rs_save_conn_data(struct rsocket *rs, struct rs_conn_data *conn) @@ -1063,7 +1075,7 @@ int rsocket(int domain, int type, int protocol) struct rsocket *rs; int index, ret; - if ((domain != PF_INET && domain != PF_INET6) || + if ((domain != AF_INET && domain != AF_INET6 && domain != AF_IB) || ((type != SOCK_STREAM) && (type != SOCK_DGRAM)) || (type == SOCK_STREAM && protocol && protocol != IPPROTO_TCP) || (type == SOCK_DGRAM && protocol && protocol != IPPROTO_UDP)) @@ -1165,7 +1177,8 @@ int raccept(int socket, struct sockaddr *addr, socklen_t *addrlen) if (ret < 0) goto err; - creq = (struct rs_conn_data *) new_rs->cm_id->event->param.conn.private_data; + creq = (struct rs_conn_data *) + (new_rs->cm_id->event->param.conn.private_data + rs_conn_data_offset(rs)); if (creq->version != 1) { ret = ERR(ENOTSUP); goto err; @@ -1180,7 +1193,9 @@ int raccept(int socket, struct sockaddr *addr, socklen_t *addrlen) rs_save_conn_data(new_rs, creq); param = new_rs->cm_id->event->param.conn; - rs_set_conn_data(new_rs, ¶m, &cresp); + rs_format_conn_data(new_rs, &cresp); + param.private_data = &cresp; + param.private_data_len = sizeof cresp; ret = rdma_accept(new_rs->cm_id, ¶m); if (!ret) new_rs->state = rs_connect_rdwr; @@ -1201,7 +1216,8 @@ err: static int rs_do_connect(struct rsocket *rs) { struct rdma_conn_param param; - struct rs_conn_data creq, *cresp; + struct rs_conn_private_data cdata; + struct rs_conn_data *creq, *cresp; int to, ret; switch (rs->state) { @@ -1246,7 +1262,10 @@ do_connect: break; memset(¶m, 0, sizeof param); - rs_set_conn_data(rs, ¶m, &creq); + creq = (void *) &cdata + rs_conn_data_offset(rs); + rs_format_conn_data(rs, creq); + param.private_data = (void *) creq - rs_conn_data_offset(rs); + param.private_data_len = sizeof(*creq) + rs_conn_data_offset(rs); param.flow_control = 1; param.retry_count = 7; param.rnr_retry_count = 7;