* [PATCH] infiniband-diags/vendstat: code simplifications
@ 2010-05-24 20:56 Sasha Khapyorsky
2010-05-24 21:07 ` [PATCH] infiniband-diags/vendstat: add config space access options Sasha Khapyorsky
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Khapyorsky @ 2010-05-24 20:56 UTC (permalink / raw)
To: linux-rdma; +Cc: Eli Dorfman
Simplify and consolidate the code by using helper function do_vendor().
Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
infiniband-diags/src/vendstat.c | 94 ++++++++++++++++++--------------------
1 files changed, 45 insertions(+), 49 deletions(-)
diff --git a/infiniband-diags/src/vendstat.c b/infiniband-diags/src/vendstat.c
index abff83a..0de5722 100644
--- a/infiniband-diags/src/vendstat.c
+++ b/infiniband-diags/src/vendstat.c
@@ -97,14 +97,12 @@ typedef struct {
} is3_general_info_t;
typedef struct {
- uint32_t address;
- uint32_t data;
- uint32_t mask;
-} is3_record_t;
-
-typedef struct {
uint8_t reserved[8];
- is3_record_t record[18];
+ struct is3_record {
+ uint32_t address;
+ uint32_t data;
+ uint32_t mask;
+ } record[18];
} is3_config_space_t;
#define COUNTER_GROUPS_NUM 2
@@ -127,23 +125,35 @@ typedef struct {
is4_group_select_t group_selects[COUNTER_GROUPS_NUM];
} is4_config_counter_groups_t;
-void counter_groups_info(ib_portid_t * portid, int port)
+static int do_vendor(ib_portid_t *portid, struct ibmad_port *srcport,
+ uint8_t class, uint8_t method, uint16_t attr_id,
+ uint32_t attr_mod, void *data)
{
- char buf[1024];
ib_vendor_call_t call;
- is4_counter_group_info_t *cg_info;
- int i, num_cg;
memset(&call, 0, sizeof(call));
- call.mgmt_class = IB_MLX_VENDOR_CLASS;
- call.method = IB_MAD_METHOD_GET;
+ call.mgmt_class = class;
+ call.method = method;
call.timeout = ibd_timeout;
- call.attrid = IB_MLX_IS4_COUNTER_GROUP_INFO;
- call.mod = port;
+ call.attrid = attr_id;
+ call.mod = attr_mod;
+
+ if (!ib_vendor_call_via(data, portid, &call, srcport))
+ IBERROR("vendstat: method %u, attribute %u", method, attr_id);
+
+ return 0;
+}
+
+static void counter_groups_info(ib_portid_t * portid, int port)
+{
+ char buf[1024];
+ is4_counter_group_info_t *cg_info;
+ int i, num_cg;
/* Counter Group Info */
memset(&buf, 0, sizeof(buf));
- if (!ib_vendor_call_via(&buf, portid, &call, srcport))
+ if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
+ IB_MLX_IS4_COUNTER_GROUP_INFO, port, buf))
IBERROR("counter group info query");
cg_info = (is4_counter_group_info_t *) & buf;
@@ -166,20 +176,12 @@ void counter_groups_info(ib_portid_t * portid, int port)
static int cg0, cg1;
-void config_counter_groups(ib_portid_t * portid, int port)
+static void config_counter_groups(ib_portid_t * portid, int port)
{
char buf[1024];
- ib_vendor_call_t call;
is4_config_counter_groups_t *cg_config;
- memset(&call, 0, sizeof(call));
- call.mgmt_class = IB_MLX_VENDOR_CLASS;
- call.attrid = IB_MLX_IS4_CONFIG_COUNTER_GROUP;
- call.timeout = ibd_timeout;
- call.mod = port;
/* configure counter groups for groups 0 and 1 */
- call.method = IB_MAD_METHOD_SET;
-
memset(&buf, 0, sizeof(buf));
cg_config = (is4_config_counter_groups_t *) & buf;
@@ -188,14 +190,15 @@ void config_counter_groups(ib_portid_t * portid, int port)
cg_config->group_selects[0].group_select = (uint8_t) cg0;
cg_config->group_selects[1].group_select = (uint8_t) cg1;
- if (!ib_vendor_call_via(&buf, portid, &call, srcport))
+ if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_SET,
+ IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf))
IBERROR("config counter group set");
/* get config counter groups */
memset(&buf, 0, sizeof(buf));
- call.method = IB_MAD_METHOD_GET;
- if (!ib_vendor_call_via(&buf, portid, &call, srcport))
+ if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
+ IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf))
IBERROR("config counter group query");
}
@@ -234,10 +237,7 @@ int main(int argc, char **argv)
ib_portid_t portid = { 0 };
int port = 0;
char buf[1024];
- ib_vendor_call_t call;
is3_general_info_t *gi;
- is3_config_space_t *cs;
- int i;
const struct ibdiag_opt opts[] = {
{"N", 'N', 0, NULL, "show IS3 or IS4 general information"},
@@ -299,22 +299,16 @@ int main(int argc, char **argv)
/* Would need a list of these and it might not be complete */
/* so for right now, punt on this */
- memset(&call, 0, sizeof(call));
- call.mgmt_class = IB_MLX_VENDOR_CLASS;
- call.method = IB_MAD_METHOD_GET;
- call.timeout = ibd_timeout;
-
- memset(&buf, 0, sizeof(buf));
/* vendor ClassPortInfo is required attribute if class supported */
- call.attrid = CLASS_PORT_INFO;
- if (!ib_vendor_call_via(&buf, &portid, &call, srcport))
+ memset(&buf, 0, sizeof(buf));
+ if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
+ CLASS_PORT_INFO, 0, buf))
IBERROR("classportinfo query");
memset(&buf, 0, sizeof(buf));
- call.attrid = IB_MLX_IS3_GENERAL_INFO;
- if (!ib_vendor_call_via(&buf, &portid, &call, srcport))
- IBERROR("vendstat");
gi = (is3_general_info_t *) & buf;
+ if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
+ IB_MLX_IS3_GENERAL_INFO, 0, gi))
if (general_info) {
/* dump IS3 or IS4 general info here */
@@ -336,20 +330,22 @@ int main(int argc, char **argv)
}
if (xmit_wait) {
+ is3_config_space_t *cs;
+ unsigned i;
+
if (ntohs(gi->hw_info.device_id) != IS3_DEVICE_ID)
IBERROR("Unsupported device ID 0x%x",
ntohs(gi->hw_info.device_id));
memset(&buf, 0, sizeof(buf));
- call.attrid = IB_MLX_IS3_CONFIG_SPACE_ACCESS;
- /* Limit of 18 accesses per MAD ? */
- call.mod = 2 << 22 | 16 << 16; /* 16 records */
/* Set record addresses for each port */
cs = (is3_config_space_t *) & buf;
for (i = 0; i < 16; i++)
cs->record[i].address =
htonl(IB_MLX_IS3_PORT_XMIT_WAIT + ((i + 1) << 12));
- if (!ib_vendor_call_via(&buf, &portid, &call, srcport))
+ if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS,
+ IB_MAD_METHOD_GET, IB_MLX_IS3_CONFIG_SPACE_ACCESS,
+ 2 << 22 | 16 << 16, cs))
IBERROR("vendstat");
for (i = 0; i < 16; i++)
@@ -358,14 +354,14 @@ int main(int argc, char **argv)
/* Last 8 ports is another query */
memset(&buf, 0, sizeof(buf));
- call.attrid = IB_MLX_IS3_CONFIG_SPACE_ACCESS;
- call.mod = 2 << 22 | 8 << 16; /* 8 records */
/* Set record addresses for each port */
cs = (is3_config_space_t *) & buf;
for (i = 0; i < 8; i++)
cs->record[i].address =
htonl(IB_MLX_IS3_PORT_XMIT_WAIT + ((i + 17) << 12));
- if (!ib_vendor_call_via(&buf, &portid, &call, srcport))
+ if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS,
+ IB_MAD_METHOD_GET, IB_MLX_IS3_CONFIG_SPACE_ACCESS,
+ 2 << 22 | 8 << 16, cs))
IBERROR("vendstat");
for (i = 0; i < 8; i++)
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] infiniband-diags/vendstat: add config space access options
2010-05-24 20:56 [PATCH] infiniband-diags/vendstat: code simplifications Sasha Khapyorsky
@ 2010-05-24 21:07 ` Sasha Khapyorsky
2010-05-25 18:13 ` [PATCH] infiniband-diags/vendstat: allow multiple config space records Sasha Khapyorsky
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Khapyorsky @ 2010-05-24 21:07 UTC (permalink / raw)
To: linux-rdma; +Cc: Eli Dorfman, Yevgeny Kliteynik
Add Mellanox vendor class config space records access options (-R for
read and -W for write). Example of usage:
vendstat -R 0x12345,0xffff <lid> - will read low 16 bits of config
space record at address 0x12345
vendstat -W 0x12345,0,0xfff <lid> - will zero low 12 bits of config
space record at address 0x12345
Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
infiniband-diags/src/vendstat.c | 45 +++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
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, "<num,num>", "configure IS4 counter groups"},
+ {"Read", 'R', 1, "<addr,mask>", "Read configuration space record at addr"},
+ {"Write", 'W', 1, "<addr,val,mask>", "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 */
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] infiniband-diags/vendstat: allow multiple config space records
2010-05-24 21:07 ` [PATCH] infiniband-diags/vendstat: add config space access options Sasha Khapyorsky
@ 2010-05-25 18:13 ` Sasha Khapyorsky
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Khapyorsky @ 2010-05-25 18:13 UTC (permalink / raw)
To: linux-rdma; +Cc: Eli Dorfman, Yevgeny Kliteynik
Allow to use -R and -W options (config space record access) multiple
number of times, so that multiple config space records will be reading
and/or writing. Using both -R and -W is allowed as well. Example:
vendstat -R 0x12345,0xffff -R 0x12346 -W 0x12347,0,0xfff <lid>
Note that now number of records is effectively limited by 18 (so that it
fit single MAD), this could be increased with using multiple MADs.
Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
infiniband-diags/src/vendstat.c | 69 +++++++++++++++++++++++++-------------
1 files changed, 45 insertions(+), 24 deletions(-)
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);
}
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-25 18:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-24 20:56 [PATCH] infiniband-diags/vendstat: code simplifications Sasha Khapyorsky
2010-05-24 21:07 ` [PATCH] infiniband-diags/vendstat: add config space access options Sasha Khapyorsky
2010-05-25 18:13 ` [PATCH] infiniband-diags/vendstat: allow multiple config space records Sasha Khapyorsky
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.