From patchwork Mon May 24 21:07:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 101950 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4OL6u9W023324 for ; Mon, 24 May 2010 21:06:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757130Ab0EXVGy (ORCPT ); Mon, 24 May 2010 17:06:54 -0400 Received: from fg-out-1718.google.com ([72.14.220.155]:17009 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756767Ab0EXVGx (ORCPT ); Mon, 24 May 2010 17:06:53 -0400 Received: by fg-out-1718.google.com with SMTP id e12so5467fga.1 for ; Mon, 24 May 2010 14:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=9c851NLOJ3lDcKx2Zuy0+cxFqlQcnNMcigxN2mp0+A8=; b=jsjPNpL772Jq5ri4zUvek4l5IU6zoTNQDjlK63swJZwYQs0vUZyyJSVYfyc0XyevE2 hTzB9huJMstXGQ2fWYNo7cKiR8r9LxPBAkEt6p3oExN1bSwUKLWkSi5PfeluKJgiUg+5 pk2sc/uBTVOr9reTFbPh4zwz71/86M5rTEsn0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=LSjIzYCT/zHOB1ZLlVuf25oDY0glgdv+ud0k1Jk6Zcw8h/BwvCVGTgvlURhsQ5bDML 1i3YSYme7ghDQXs1jBnUGkMOPT8UAKH8Dl3XMCsFhqwILlQZJe7yuJdb2unRcqGagpw2 /uM7HDSLrG6KvFaoHZjf9/FM+BRmD3mgLcBkI= Received: by 10.87.74.15 with SMTP id b15mr9121833fgl.11.1274735209430; Mon, 24 May 2010 14:06:49 -0700 (PDT) Received: from me.localdomain (87.69.36.170.cable.012.net.il [87.69.36.170]) by mx.google.com with ESMTPS id 3sm4434036fge.10.2010.05.24.14.06.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 24 May 2010 14:06:48 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id CD17711DF7; Tue, 25 May 2010 00:07:35 +0300 (IDT) Date: Tue, 25 May 2010 00:07:35 +0300 From: Sasha Khapyorsky To: linux-rdma Cc: Eli Dorfman , Yevgeny Kliteynik Subject: [PATCH] infiniband-diags/vendstat: add config space access options Message-ID: <20100524210735.GK28549@me> References: <20100524205611.GJ28549@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100524205611.GJ28549@me> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 24 May 2010 21:06:56 +0000 (UTC) diff --git a/infiniband-diags/src/vendstat.c b/infiniband-diags/src/vendstat.c index 0de5722..0add06c 100644 --- a/infiniband-diags/src/vendstat.c +++ b/infiniband-diags/src/vendstat.c @@ -144,6 +144,27 @@ static int do_vendor(ib_portid_t *portid, struct ibmad_port *srcport, return 0; } +static unsigned int conf_addr, conf_val, conf_mask; + +static void do_config_space_record(ib_portid_t *portid, unsigned set) +{ + is3_config_space_t cs; + + memset(&cs, 0, sizeof(cs)); + cs.record[0].address = htonl(conf_addr); + cs.record[0].data = htonl(conf_val); + cs.record[0].mask = htonl(conf_mask); + + if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, + set ? IB_MAD_METHOD_SET : IB_MAD_METHOD_GET, + IB_MLX_IS3_CONFIG_SPACE_ACCESS, 2 << 22 | 1 << 16, &cs)) + IBERROR("cannot %s config space record", set ? "set" : "get"); + + printf("Config space record at 0x%x: 0x%x\n", + ntohl(cs.record[0].address), + ntohl(cs.record[0].data & cs.record[0].mask)); +} + static void counter_groups_info(ib_portid_t * portid, int port) { char buf[1024]; @@ -203,6 +224,7 @@ static void config_counter_groups(ib_portid_t * portid, int port) } static int general_info, xmit_wait, counter_group_info, config_counter_group; +static unsigned int config_space_read, config_space_write; static int process_opt(void *context, int ch, char *optarg) { @@ -223,6 +245,22 @@ static int process_opt(void *context, int ch, char *optarg) if (ret != 2) return -1; break; + case 'R': + config_space_read = 1; + ret = sscanf(optarg, "%x,%x", &conf_addr, &conf_mask); + if (ret < 1) + return -1; + else if (ret == 1) + conf_mask = 0xffffffff; + break; + case 'W': + config_space_write = 1; + ret = sscanf(optarg, "%x,%x,%x", &conf_addr, &conf_val, &conf_mask); + if (ret < 2) + return -1; + else if (ret == 2) + conf_mask = 0xffffffff; + break; default: return -1; } @@ -244,6 +282,8 @@ int main(int argc, char **argv) {"w", 'w', 0, NULL, "show IS3 port xmit wait counters"}, {"i", 'i', 0, NULL, "show IS4 counter group info"}, {"c", 'c', 1, "", "configure IS4 counter groups"}, + {"Read", 'R', 1, "", "Read configuration space record at addr"}, + {"Write", 'W', 1, "", "Write configuration space record at addr"}, {0} }; @@ -289,6 +329,11 @@ int main(int argc, char **argv) exit(0); } + if (config_space_read || config_space_write) { + do_config_space_record(&portid, config_space_write); + exit(0); + } + /* These are Mellanox specific vendor MADs */ /* but vendors change the VendorId so how know for sure ? */ /* Only General Info and Port Xmit Wait Counters */