From patchwork Thu Jul 18 19:52:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 2829797 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 A41329F4D4 for ; Thu, 18 Jul 2013 19:52:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82E5E201E0 for ; Thu, 18 Jul 2013 19:52:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E0E9201DE for ; Thu, 18 Jul 2013 19:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759247Ab3GRTwv (ORCPT ); Thu, 18 Jul 2013 15:52:51 -0400 Received: from mga09.intel.com ([134.134.136.24]:30109 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759465Ab3GRTwt (ORCPT ); Thu, 18 Jul 2013 15:52:49 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 18 Jul 2013 12:50:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,696,1367996400"; d="scan'208";a="372729277" Received: from cst-linux.jf.intel.com ([10.23.221.72]) by orsmga002.jf.intel.com with ESMTP; 18 Jul 2013 12:52:39 -0700 From: sean.hefty@intel.com To: linux-rdma@vger.kernel.org Cc: Sean Hefty Subject: [PATCH librdmacm 2/3] acm: Define needed ACM protocol messages Date: Thu, 18 Jul 2013 12:52:12 -0700 Message-Id: <1374177133-802-2-git-send-email-sean.hefty@intel.com> X-Mailer: git-send-email 1.7.3 In-Reply-To: <1374177133-802-1-git-send-email-sean.hefty@intel.com> References: <1374177133-802-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=-7.2 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 The librdmacm needs message definitions used to communicate with the ibacm. It currently pulls these from infiniband/acm.h, which is installed by ibacm. This creates an install order dependency on ibacm. However, work on the scalable SA has the ibacm using the librdmacm (via rsockets) for communication between the different SSA components. To resolve this issue, have the librdmacm define the message structures that it needs to communicate with ibacm. The librdmacm already defines some ACM messages through configuration checks. We just expand that capability, which isolates the librdmacm package from the ibacm package. Signed-off-by: Sean Hefty --- configure.ac | 7 +----- src/acm.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 31b1a0e..b4303c6 100644 --- a/configure.ac +++ b/configure.ac @@ -71,12 +71,7 @@ fi fi AC_CHECK_HEADER(infiniband/acm.h, - AC_DEFINE([USE_IB_ACM], 1, [setting IBACM support]), []) - -AC_CHECK_HEADER(infiniband/acm.h, - AC_CHECK_MEMBER(struct acm_msg.resolve_data, [], - AC_DEFINE(DEFINE_ACM_MSG, 1, [adding ACM message definition]), - [#include ]), []) + AC_DEFINE([USE_IB_ACM], 1, [setting IBACM support]), []) dnl Checks close on exec support AC_CHECK_HEADERS([fcntl.h sys/socket.h]) diff --git a/src/acm.c b/src/acm.c index 6e8e173..09c5d4e 100644 --- a/src/acm.c +++ b/src/acm.c @@ -46,19 +46,71 @@ #include #ifdef USE_IB_ACM -#include +#define ACM_VERSION 1 + +#define ACM_OP_RESOLVE 0x01 +#define ACM_OP_ACK 0x80 + +#define ACM_STATUS_SUCCESS 0 +#define ACM_STATUS_ENOMEM 1 +#define ACM_STATUS_EINVAL 2 +#define ACM_STATUS_ENODATA 3 +#define ACM_STATUS_ENOTCONN 5 +#define ACM_STATUS_ETIMEDOUT 6 +#define ACM_STATUS_ESRCADDR 7 +#define ACM_STATUS_ESRCTYPE 8 +#define ACM_STATUS_EDESTADDR 9 +#define ACM_STATUS_EDESTTYPE 10 + +#define ACM_FLAGS_NODELAY (1<<30) + +#define ACM_MSG_HDR_LENGTH 16 +#define ACM_MAX_ADDRESS 64 +#define ACM_MSG_EP_LENGTH 72 +#define ACM_MSG_DATA_LENGTH (ACM_MSG_EP_LENGTH * 8) + +struct acm_hdr { + uint8_t version; + uint8_t opcode; + uint8_t status; + uint8_t data[3]; + uint16_t length; + uint64_t tid; +}; + +#define ACM_EP_INFO_NAME 0x0001 +#define ACM_EP_INFO_ADDRESS_IP 0x0002 +#define ACM_EP_INFO_ADDRESS_IP6 0x0003 +#define ACM_EP_INFO_PATH 0x0010 + +union acm_ep_info { + uint8_t addr[ACM_MAX_ADDRESS]; + uint8_t name[ACM_MAX_ADDRESS]; + struct ibv_path_record path; +}; + +#define ACM_EP_FLAG_SOURCE (1<<0) +#define ACM_EP_FLAG_DEST (1<<1) -#if DEFINE_ACM_MSG -typedef struct cma_acm_msg { +struct acm_ep_addr_data { + uint32_t flags; + uint16_t type; + uint16_t reserved; + union acm_ep_info info; +}; + +struct acm_resolve_msg { + struct acm_hdr hdr; + struct acm_ep_addr_data data[0]; +}; + +struct acm_msg { struct acm_hdr hdr; union{ uint8_t data[ACM_MSG_DATA_LENGTH]; struct acm_ep_addr_data resolve_data[0]; }; -} cma_acm_msg_t; -#else -typedef struct acm_msg cma_acm_msg_t; -#endif +}; static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER; static int sock = -1; @@ -242,7 +294,7 @@ err: rdma_freeaddrinfo(ib_rai); } -static void ucma_ib_save_resp(struct rdma_addrinfo *rai, cma_acm_msg_t *msg) +static void ucma_ib_save_resp(struct rdma_addrinfo *rai, struct acm_msg *msg) { struct acm_ep_addr_data *ep_data; struct ibv_path_data *path_data = NULL; @@ -326,7 +378,7 @@ static int ucma_ib_addr(struct sockaddr *addr, socklen_t len) void ucma_ib_resolve(struct rdma_addrinfo **rai, struct rdma_addrinfo *hints) { - cma_acm_msg_t msg; + struct acm_msg msg; struct acm_ep_addr_data *data; int ret;