From patchwork Thu Jan 31 06:43:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 2071321 X-Patchwork-Delegate: ira.weiny@intel.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A1B8FDFB79 for ; Thu, 31 Jan 2013 06:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753882Ab3AaGnt (ORCPT ); Thu, 31 Jan 2013 01:43:49 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:50783 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750917Ab3AaGnt (ORCPT ); Thu, 31 Jan 2013 01:43:49 -0500 Received: by mail-wi0-f174.google.com with SMTP id hj13so3706273wib.13 for ; Wed, 30 Jan 2013 22:43:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:content-type:content-transfer-encoding:x-gm-message-state; bh=3+99xsk7/06+9h+kMdoh0/Yd1FJMaLH9KYOghcatkaM=; b=dDhOAMYVqTrHbL7kmuJyi/kwaTDoBrNTJ8PZ1iIGtf4yzko4SMw5KVYk4ACm6tXrZ0 yymw3Bj1laTsn9mqN/gKG/WQw5rcAS7O2JXQc17z+u2oWGSiN9nxI+cws/n9hTh7MS5v pW2PGQfke8xntS+O5ovPs7tZCDiZg4UxXftBrvxFLVn7jNdaBaIQ/ozwueH7duHDNyUt oYqXY6P5N08a8OjOIXAlQ3FHwnMruN3cvCloTxXG4BxKgAkL3e+AOyi5sSZdDimdD1lL fQAbuJ2u5tjMWhUTXDAyVrLcoMzRjtro/WzJ+BPW0KbES0GYt2d2WhSpiQ7wyi49C2Pe TXAg== X-Received: by 10.180.77.35 with SMTP id p3mr12948123wiw.18.1359614627534; Wed, 30 Jan 2013 22:43:47 -0800 (PST) Received: from [10.220.10.138] (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPS id fa15sm12991828wid.7.2013.01.30.22.43.45 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jan 2013 22:43:46 -0800 (PST) Message-ID: <510A129E.4000600@dev.mellanox.co.il> Date: Thu, 31 Jan 2013 01:43:42 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: Ira Weiny CC: "linux-rdma (linux-rdma@vger.kernel.org)" , Sarat Kakarla Subject: [PATCH] libibmad: Add NodeRecord query API X-Gm-Message-State: ALoCoQniUNJzt6v0dQeTZEG4Pd3JeUSNyzaop51shZw+Y9hAYMshmhsA9jjNOQ4VVRHOXiOL8f7A Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Add ib_node_query_via routine similar to ib_path_query_via Signed-off-by: Hal Rosenstock --- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/infiniband/mad.h b/include/infiniband/mad.h index 0694dc4..02b2353 100644 --- a/include/infiniband/mad.h +++ b/include/infiniband/mad.h @@ -65,6 +65,7 @@ BEGIN_C_DECLS #define IB_PC_DATA_SZ (IB_MAD_SIZE - IB_PC_DATA_OFFS) #define IB_SA_MCM_RECSZ 53 #define IB_SA_PR_RECSZ 64 +#define IB_SA_NR_RECSZ 108 #define IB_SA_GIR_RECSZ 72 #define IB_BM_DATA_OFFS 64 #define IB_BM_DATA_SZ (IB_MAD_SIZE - IB_BM_DATA_OFFS) @@ -1519,6 +1542,9 @@ MAD_EXPORT int ib_path_query_via(const struct ibmad_port *srcport, ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf); /* returns lid */ +MAD_EXPORT int ib_node_query_via(const struct ibmad_port *srcport, + uint64_t guid, ib_portid_t * sm_id, + void *buf); /* resolve.c */ MAD_EXPORT int ib_resolve_smlid(ib_portid_t * sm_id, int timeout) DEPRECATED; diff --git a/src/libibmad.map b/src/libibmad.map index a4d4418..3f92885 100644 --- a/src/libibmad.map +++ b/src/libibmad.map @@ -148,5 +148,6 @@ IBMAD_1.3 { cc_config_status_via; smp_mkey_get; smp_mkey_set; + ib_node_query_via; local: *; }; diff --git a/src/sa.c b/src/sa.c index a9a93cc..352ed9f 100644 --- a/src/sa.c +++ b/src/sa.c @@ -145,3 +145,47 @@ int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id, { return ib_path_query_via(ibmp, srcgid, destgid, sm_id, buf); } + +/* NodeRecord */ +#define IB_NR_COMPMASK_LID (1ull<<0) +#define IB_NR_COMPMASK_RESERVED1 (1ull<<1) +#define IB_NR_COMPMASK_BASEVERSION (1ull<<2) +#define IB_NR_COMPMASK_CLASSVERSION (1ull<<3) +#define IB_NR_COMPMASK_NODETYPE (1ull<<4) +#define IB_NR_COMPMASK_NUMPORTS (1ull<<5) +#define IB_NR_COMPMASK_SYSIMAGEGUID (1ull<<6) +#define IB_NR_COMPMASK_NODEGUID (1ull<<7) +#define IB_NR_COMPMASK_PORTGUID (1ull<<8) +#define IB_NR_COMPMASK_PARTCAP (1ull<<9) +#define IB_NR_COMPMASK_DEVID (1ull<<10) +#define IB_NR_COMPMASK_REV (1ull<<11) +#define IB_NR_COMPMASK_PORTNUM (1ull<<12) +#define IB_NR_COMPMASK_VENDID (1ull<<13) +#define IB_NR_COMPMASK_NODEDESC (1ull<<14) + +#define IB_NR_DEF_MASK IB_NR_COMPMASK_PORTGUID + +int ib_node_query_via(const struct ibmad_port *srcport, uint64_t guid, + ib_portid_t * sm_id, void *buf) +{ + ib_sa_call_t sa = { 0 }; + uint8_t *p; + + memset(&sa, 0, sizeof sa); + sa.method = IB_MAD_METHOD_GET; + sa.attrid = IB_SA_ATTR_NODERECORD; + sa.mask = IB_NR_DEF_MASK; + sa.trid = mad_trid(); + + memset(buf, 0, IB_SA_NR_RECSZ); + + mad_encode_field(buf, IB_SA_NR_PORT_GUID_F, &guid); + + p = sa_rpc_call(srcport, buf, sm_id, &sa, 0); + if (!p) { + IBWARN("sa call node_query failed"); + return -1; + } + + return 0; +}