From patchwork Tue May 25 18:13:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 102252 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 o4PICrIO032114 for ; Tue, 25 May 2010 18:12:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758831Ab0EYSMw (ORCPT ); Tue, 25 May 2010 14:12:52 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:40268 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756378Ab0EYSMw (ORCPT ); Tue, 25 May 2010 14:12:52 -0400 Received: by fxm5 with SMTP id 5so3558802fxm.19 for ; Tue, 25 May 2010 11:12:50 -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=McLIXb5aaPylSUtqyaCGK4NsydhYZrY5R/gvv5dL/3Y=; b=JEaCzyG093oGz1hLI0FZtHbg64QXRK7S4cFSan8WcRuYky/NsTF57bH7GKlwSfdKso ZcxlE7u3HSS6Q5c098uSFDuUCpSNBzRNW8yePCiufTCzaRBghJVwD8zAXcBX8V+yocFi UAwcg8okOALXGRpO9eckncnApHL3+XM449QaU= 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=hE2kYZB6F7IBV08CObB63ONfdJWDVMxdGWzpUoTdUqfuRNjJWdTV23fVMWBWhR17UB /EaFMz4m27+D35q6q6n7UxjGMs6w7/8Iz+7xwq+QFDcZrL9DWmSrj+7b2iHMELiZOMtd lecrT0a6fWnIJjTkeXE88RIv2DlCmHfTkr+5I= Received: by 10.223.18.154 with SMTP id w26mr6608591faa.39.1274811170126; Tue, 25 May 2010 11:12:50 -0700 (PDT) Received: from me.localdomain (bzq-79-177-10-237.red.bezeqint.net [79.177.10.237]) by mx.google.com with ESMTPS id u12sm25897354fah.16.2010.05.25.11.12.47 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 25 May 2010 11:12:49 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id BE65411DF7; Tue, 25 May 2010 21:13:30 +0300 (IDT) Date: Tue, 25 May 2010 21:13:30 +0300 From: Sasha Khapyorsky To: linux-rdma Cc: Eli Dorfman , Yevgeny Kliteynik Subject: [PATCH] infiniband-diags/vendstat: allow multiple config space records Message-ID: <20100525181330.GU28549@me> References: <20100524205611.GJ28549@me> <20100524210735.GK28549@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100524210735.GK28549@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]); Tue, 25 May 2010 18:12:54 +0000 (UTC) diff --git a/infiniband-diags/src/vendstat.c b/infiniband-diags/src/vendstat.c index 0add06c..92a90c8 100644 --- a/infiniband-diags/src/vendstat.c +++ b/infiniband-diags/src/vendstat.c @@ -144,25 +144,30 @@ 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) +static void do_config_space_records(ib_portid_t *portid, unsigned set, + is3_config_space_t *cs, unsigned records) { - 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); + unsigned i; + + if (records > 18) + records = 18; + for (i = 0; i < records; i++) { + cs->record[i].address = htonl(cs->record[i].address); + cs->record[i].data = htonl(cs->record[i].data); + cs->record[i].mask = htonl(cs->record[i].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)); + IB_MLX_IS3_CONFIG_SPACE_ACCESS, 2 << 22 | records << 16, + cs)) + IBERROR("cannot %s config space records", set ? "set" : "get"); + + for (i = 0; i < records; i++) { + printf("Config space record at 0x%x: 0x%x\n", + ntohl(cs->record[i].address), + ntohl(cs->record[i].data & cs->record[i].mask)); + } } static void counter_groups_info(ib_portid_t * portid, int port) @@ -224,7 +229,9 @@ 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 is3_config_space_t write_cs, read_cs; +static unsigned write_cs_records, read_cs_records; + static int process_opt(void *context, int ch, char *optarg) { @@ -246,20 +253,29 @@ static int process_opt(void *context, int ch, char *optarg) return -1; break; case 'R': - config_space_read = 1; - ret = sscanf(optarg, "%x,%x", &conf_addr, &conf_mask); + if (read_cs_records >= 18) + break; + ret = sscanf(optarg, "%x,%x", + &read_cs.record[read_cs_records].address, + &read_cs.record[read_cs_records].mask); if (ret < 1) return -1; else if (ret == 1) - conf_mask = 0xffffffff; + read_cs.record[read_cs_records].mask = 0xffffffff; + read_cs_records++; break; case 'W': - config_space_write = 1; - ret = sscanf(optarg, "%x,%x,%x", &conf_addr, &conf_val, &conf_mask); + if (write_cs_records >= 18) + break; + ret = sscanf(optarg, "%x,%x,%x", + &write_cs.record[write_cs_records].address, + &write_cs.record[write_cs_records].data, + &write_cs.record[write_cs_records].mask); if (ret < 2) return -1; else if (ret == 2) - conf_mask = 0xffffffff; + write_cs.record[write_cs_records].mask = 0xffffffff; + write_cs_records++; break; default: return -1; @@ -329,8 +345,13 @@ int main(int argc, char **argv) exit(0); } - if (config_space_read || config_space_write) { - do_config_space_record(&portid, config_space_write); + if (read_cs_records || write_cs_records) { + if (read_cs_records) + do_config_space_records(&portid, 0, &read_cs, + read_cs_records); + if (write_cs_records) + do_config_space_records(&portid, 1, &write_cs, + write_cs_records); exit(0); }