From patchwork Mon Nov 26 14:52:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haakon Bugge X-Patchwork-Id: 10698435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24DCC13BB for ; Mon, 26 Nov 2018 14:52:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1448629CF2 for ; Mon, 26 Nov 2018 14:52:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08A0429D05; Mon, 26 Nov 2018 14:52:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F19E29CF2 for ; Mon, 26 Nov 2018 14:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbeK0BrO (ORCPT ); Mon, 26 Nov 2018 20:47:14 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:58188 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeK0BrN (ORCPT ); Mon, 26 Nov 2018 20:47:13 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAQEiKUC008376; Mon, 26 Nov 2018 14:52:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=8T/BffS3Q/KzJjCva+kYq8vWKQh1L8PCBg91RoEARY8=; b=Eiu6cN+NqatzgO6HCdT6qhsTaeiZvaDSs9pqBjXbPa1ty/lY6E21bdmaWshppVLaZOE5 JJ4wSU5XMvfTaOKa9tUMp/jM8AMqv8cmUQjvHxn11OozRPIoMYnR5BFYFkfuVYS87FVg CRw/FmZeDDj5RWM6BAAXBGvkMvFH47kbGrDaJ6XHiDdN4aohOE+QRw4Ojhe98J9UUc6V 27LWvLA/oI2nLAz9rN8lO/BmQv2NjG0DfdgVXoa+EdrFcTdSqfF/G+K8QbqAqkmWot4g XF3NvbWuTmHsls1d+Y/YI4Df9rg2aKlY5g4IyVYy47mjQxC9JbAH09/cHKMZL/y71KRv 3Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2nxy9qx3xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Nov 2018 14:52:42 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAQEqZ8E016971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Nov 2018 14:52:36 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wAQEqZfS028926; Mon, 26 Nov 2018 14:52:35 GMT Received: from lab02.no.oracle.com (/10.172.144.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Nov 2018 06:52:34 -0800 From: =?utf-8?q?H=C3=A5kon_Bugge?= To: Sean Hefty , Hal Rosenstock Cc: Doug Ledford , Leon Romanovsky , Jason Gunthorpe , linux-rdma@vger.kernel.org, aron.silverton@oracle.com, mark.haywood@oracle.com Subject: [PATCH ibacm 2/2] ibacm: acme supports only one port Date: Mon, 26 Nov 2018 15:52:03 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9088 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811260133 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP acme can display end-point information. This is implemented in acm by iterating through all end-points and their ports, until the end-point indexes match. This implies, considering a mult-ported device, that the address information associated with the first port is the only one displayed. Before this commit: # ibstat | grep ports Number of ports: 2 # ib_acme -e svc,guid,port,pkey,ep_index,prov,addr_0,addresses /usr/local/var/run/ibacm-unix.sock,0x0021280001a17c96,1,0xffff,1,ibacmp,lab36,lab36-1,192.168.200.200 Fixed by adding port_num to the equation, and the above command will yield: # ib_acme -e svc,guid,port,pkey,ep_index,prov,addr_0,addresses /usr/local/var/run/ibacm-unix.sock,0x0021280001a17c96,1,0xffff,1,ibacmp,192.168.200.200,lab36,lab36-1 /usr/local/var/run/ibacm-unix.sock,0x0021280001a17c96,2,0xffff,1,ibacmp,192.168.200.201,lab36-2 Signed-off-by: HÃ¥kon Bugge --- ibacm/include/infiniband/acm.h | 6 ++++-- ibacm/src/acm.c | 11 ++++++++--- ibacm/src/acme.c | 29 +++++++++++++++++------------ ibacm/src/libacm.c | 12 +++++++----- ibacm/src/libacm.h | 2 +- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/ibacm/include/infiniband/acm.h b/ibacm/include/infiniband/acm.h index f6efee18..90f3d431 100644 --- a/ibacm/include/infiniband/acm.h +++ b/ibacm/include/infiniband/acm.h @@ -73,7 +73,8 @@ struct acm_hdr { uint8_t version; uint8_t opcode; uint8_t status; - uint8_t data[3]; + uint8_t port_num; + uint8_t data[2]; uint16_t length; uint64_t tid; }; @@ -135,7 +136,8 @@ struct acm_perf_msg { struct acm_ep_config_data { uint64_t dev_guid; uint8_t port_num; - uint8_t rsvd[3]; + uint8_t phys_port_cnt; + uint8_t rsvd[2]; uint16_t pkey; uint16_t addr_cnt; uint8_t prov_name[ACM_MAX_PROV_NAME]; diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c index 6a02f33d..0eaf0c89 100644 --- a/ibacm/src/acm.c +++ b/ibacm/src/acm.c @@ -876,7 +876,9 @@ static struct acmc_addr *acm_get_ep_address(struct acm_ep_addr_data *data) return NULL; } -static struct acmc_ep *acm_get_ep(int index) +/* If port_num is zero, iterate through all ports, otherwise consider + * only the specific port_num */ +static struct acmc_ep *acm_get_ep(int index, uint8_t port_num) { struct acmc_device *dev; struct acmc_ep *ep; @@ -885,6 +887,8 @@ static struct acmc_ep *acm_get_ep(int index) acm_log(2, "ep index %d\n", index); list_for_each(&dev_list, dev, entry) { for (i = 0; i < dev->port_cnt; i++) { + if (port_num && port_num != (i + 1)) + continue; if (dev->port[i].state != IBV_PORT_ACTIVE) continue; list_for_each(&dev->port[i].ep_list, ep, entry) { @@ -1161,7 +1165,7 @@ static int acm_svr_perf_query(struct acmc_client *client, struct acm_msg *msg) len = ACM_MSG_HDR_LENGTH + (ACM_MAX_COUNTER * sizeof(uint64_t)); } else { if (index >= 1) { - ep = acm_get_ep(index - 1); + ep = acm_get_ep(index - 1, msg->hdr.port_num); } else { addr = acm_get_ep_address(&msg->resolve_data[0]); if (addr) @@ -1231,11 +1235,12 @@ static int acm_svr_ep_query(struct acmc_client *client, struct acm_msg *msg) acm_log(2, "client %d\n", client->index); index = msg->hdr.data[0]; - ep = acm_get_ep(index - 1); + ep = acm_get_ep(index - 1, msg->hdr.port_num); if (ep) { msg->hdr.status = ACM_STATUS_SUCCESS; msg->ep_data[0].dev_guid = ep->port->dev->device.dev_guid; msg->ep_data[0].port_num = ep->port->port.port_num; + msg->ep_data[0].phys_port_cnt = ep->port->dev->port_cnt; msg->ep_data[0].pkey = htobe16(ep->endpoint.pkey); strncpy((char *)msg->ep_data[0].prov_name, ep->port->prov->name, ACM_MAX_PROV_NAME - 1); diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c index b592b977..7c4031e4 100644 --- a/ibacm/src/acme.c +++ b/ibacm/src/acme.c @@ -926,21 +926,26 @@ static int enumerate_ep(char *svc, int index) static int labels; int ret, i; struct acm_ep_config_data *ep_data; + uint8_t port = 0; - ret = ib_acm_enum_ep(index, &ep_data); - if (ret) - return ret; + do { + ret = ib_acm_enum_ep(index, &ep_data, port); + if (ret) + return ret; - if (!labels) { - printf("svc,guid,port,pkey,ep_index,prov,addr_0,addresses\n"); - labels = 1; - } + if (!labels) { + printf("svc,guid,port,pkey,ep_index,prov,addr_0,addresses\n"); + labels = 1; + } + + printf("%s,0x%016" PRIx64 ",%d,0x%04x,%d,%s", svc, ep_data->dev_guid, + ep_data->port_num, ep_data->pkey, index, ep_data->prov_name); + for (i = 0; i < ep_data->addr_cnt; i++) + printf(",%s", ep_data->addrs[i].name); + printf("\n"); + port = ep_data->port_num + 1; + } while (port <= ep_data->phys_port_cnt); - printf("%s,0x%016" PRIx64 ",%d,0x%04x,%d,%s", svc, ep_data->dev_guid, - ep_data->port_num, ep_data->pkey, index, ep_data->prov_name); - for (i = 0; i < ep_data->addr_cnt; i++) - printf(",%s", ep_data->addrs[i].name); - printf("\n"); ib_acm_free_ep_data(ep_data); return 0; diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c index 8f0bfc2a..62099393 100644 --- a/ibacm/src/libacm.c +++ b/ibacm/src/libacm.c @@ -382,7 +382,7 @@ out: return ret; } -int ib_acm_enum_ep(int index, struct acm_ep_config_data **data) +int ib_acm_enum_ep(int index, struct acm_ep_config_data **data, uint8_t port) { struct acm_ep_config_data *netw_edata = NULL; struct acm_ep_config_data *host_edata = NULL; @@ -396,6 +396,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data) memset(&msg, 0, sizeof msg); msg.hdr.version = ACM_VERSION; msg.hdr.opcode = ACM_OP_EP_QUERY; + msg.hdr.port_num = port; msg.hdr.data[0] = index; msg.hdr.length = htobe16(ACM_MSG_HDR_LENGTH); @@ -428,10 +429,11 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data) goto out; } - host_edata->dev_guid = be64toh(netw_edata->dev_guid); - host_edata->port_num = netw_edata->port_num; - host_edata->pkey = be16toh(netw_edata->pkey); - host_edata->addr_cnt = be16toh(netw_edata->addr_cnt); + host_edata->dev_guid = be64toh(netw_edata->dev_guid); + host_edata->port_num = netw_edata->port_num; + host_edata->phys_port_cnt = netw_edata->phys_port_cnt; + host_edata->pkey = be16toh(netw_edata->pkey); + host_edata->addr_cnt = be16toh(netw_edata->addr_cnt); memcpy(host_edata->prov_name, netw_edata->prov_name, sizeof(host_edata->prov_name)); diff --git a/ibacm/src/libacm.h b/ibacm/src/libacm.h index bf8cb79b..fb81b417 100644 --- a/ibacm/src/libacm.h +++ b/ibacm/src/libacm.h @@ -54,7 +54,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type, const char *ib_acm_cntr_name(int index); -int ib_acm_enum_ep(int index, struct acm_ep_config_data **data); +int ib_acm_enum_ep(int index, struct acm_ep_config_data **data, uint8_t port); #define ib_acm_free_ep_data(data) free(data) #endif /* LIBACM_H */