[openib-general] [PATCH] madeye: Mainly add more SA decode
Hal Rosenstock
halr at voltaire.com
Mon Sep 19 09:04:46 PDT 2005
madeye: Mainly add more SA decode
Support SA attributes and add support for some missing SA methods
Also, display data for received RMPP messages (next step is to do this
on the send side)
Also, allow filtering of messages by attribute ID
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
Index: madeye.c
===================================================================
--- madeye.c (revision 3450)
+++ madeye.c (working copy)
@@ -1,5 +1,6 @@
/*
- * Copyright (c) 2004 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
+ * Copyright (c) 2005 Voltaire Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -60,16 +61,19 @@ struct madeye_port {
static int smp = 1;
static int gmp = 1;
static int mgmt_class = 0;
+static int attr_id = 0;
static int data = 0;
module_param(smp, int, 0444);
module_param(gmp, int, 0444);
module_param(mgmt_class, int, 0444);
+module_param(attr_id, int, 0444);
module_param(data, int, 0444);
MODULE_PARM_DESC(smp, "Display all SMPs (default=1)");
MODULE_PARM_DESC(gmp, "Display all GMPs (default=1)");
MODULE_PARM_DESC(mgmt_class, "Display all MADs of specified class (default=0)");
+MODULE_PARM_DESC(attr_id, "Display add MADs of specified attribute ID (default=0)");
MODULE_PARM_DESC(data, "Display data area of MADs (default=0)");
static char * get_class_name(u8 mgmt_class)
@@ -130,6 +134,14 @@ static char * get_method_name(u8 mgmt_cl
return "Get table response";
case IB_SA_METHOD_DELETE:
return "Delete";
+ case IB_SA_METHOD_DELETE_RESP:
+ return "Delete response";
+ case IB_SA_METHOD_GET_MULTI:
+ return "Get Multi";
+ case IB_SA_METHOD_GET_MULTI_RESP:
+ return "Get Multi response";
+ case IB_SA_METHOD_GET_TRACE_TBL:
+ return "Get Trace Table response";
default:
break;
}
@@ -162,6 +174,58 @@ static void print_status_details(u16 sta
}
}
+static char * get_sa_attr(__be16 attr)
+{
+ switch(attr) {
+ case IB_SA_ATTR_CLASS_PORTINFO:
+ return "Class Port Info";
+ case IB_SA_ATTR_NOTICE:
+ return "Notice";
+ case IB_SA_ATTR_INFORM_INFO:
+ return "Inform Info";
+ case IB_SA_ATTR_NODE_REC:
+ return "Node Record";
+ case IB_SA_ATTR_PORT_INFO_REC:
+ return "PortInfo Record";
+ case IB_SA_ATTR_SL2VL_REC:
+ return "SL to VL Record";
+ case IB_SA_ATTR_SWITCH_REC:
+ return "Switch Record";
+ case IB_SA_ATTR_LINEAR_FDB_REC:
+ return "Linear FDB Record";
+ case IB_SA_ATTR_RANDOM_FDB_REC:
+ return "Random FDB Record";
+ case IB_SA_ATTR_MCAST_FDB_REC:
+ return "Multicast FDB Record";
+ case IB_SA_ATTR_SM_INFO_REC:
+ return "SM Info Record";
+ case IB_SA_ATTR_LINK_REC:
+ return "Link Record";
+ case IB_SA_ATTR_GUID_INFO_REC:
+ return "Guid Info Record";
+ case IB_SA_ATTR_SERVICE_REC:
+ return "Service Record";
+ case IB_SA_ATTR_PARTITION_REC:
+ return "Partition Record";
+ case IB_SA_ATTR_PATH_REC:
+ return "Path Record";
+ case IB_SA_ATTR_VL_ARB_REC:
+ return "VL Arb Record";
+ case IB_SA_ATTR_MC_MEMBER_REC:
+ return "MC Member Record";
+ case IB_SA_ATTR_TRACE_REC:
+ return "Trace Record";
+ case IB_SA_ATTR_MULTI_PATH_REC:
+ return "Multi Path Record";
+ case IB_SA_ATTR_SERVICE_ASSOC_REC:
+ return "Service Assoc Record";
+ case IB_SA_ATTR_INFORM_INFO_REC:
+ return "Inform Info Record";
+ default:
+ return "";
+ }
+}
+
static void print_mad_hdr(struct ib_mad_hdr *mad_hdr)
{
printk("MAD version....0x%01x\n", mad_hdr->base_version);
@@ -175,7 +239,11 @@ static void print_mad_hdr(struct ib_mad_
print_status_details(be16_to_cpu(mad_hdr->status));
printk("Class specific.0x%02x\n", be16_to_cpu(mad_hdr->class_specific));
printk("Trans ID.......0x%llx\n", mad_hdr->tid);
- printk("Attr ID........0x%02x\n", be16_to_cpu(mad_hdr->attr_id));
+ if (mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_ADM)
+ printk("Attr ID........0x%02x (%s)\n", be16_to_cpu(mad_hdr->attr_id),
+ get_sa_attr(be16_to_cpu(mad_hdr->attr_id)));
+ else
+ printk("Attr ID........0x%02x\n", be16_to_cpu(mad_hdr->attr_id));
printk("Attr modifier..0x%04x\n", be32_to_cpu(mad_hdr->attr_mod));
}
@@ -326,6 +394,8 @@ static void snoop_smi_handler(struct ib_
{
if (!smp && send_wr->wr.ud.mad_hdr->mgmt_class != mgmt_class)
return;
+ if (attr_id && send_wr->wr.ud.mad_hdr->attr_id != attr_id)
+ return;
printk("Madeye:sent SMP\n");
if (send_wr->num_sge > 1) {
@@ -342,6 +412,8 @@ static void recv_smi_handler(struct ib_m
{
if (!smp && mad_recv_wc->recv_buf.mad->mad_hdr.mgmt_class != mgmt_class)
return;
+ if (attr_id && mad_recv_wc->recv_buf.mad->mad_hdr.attr_id != attr_id)
+ return;
printk("Madeye:recv SMP\n");
print_smp((struct ib_smp *)&mad_recv_wc->recv_buf.mad->mad_hdr);
@@ -353,6 +425,7 @@ static int is_rmpp_mad(struct ib_mad_hdr
switch (mad_hdr->method) {
case IB_SA_METHOD_GET_TABLE:
case IB_SA_METHOD_GET_TABLE_RESP:
+ case IB_SA_METHOD_GET_MULTI_RESP:
return 1;
default:
break;
@@ -373,6 +446,8 @@ static void snoop_gsi_handler(struct ib_
if (!gmp && send_wr->wr.ud.mad_hdr->mgmt_class != mgmt_class)
return;
+ if (attr_id && send_wr->wr.ud.mad_hdr->attr_id != attr_id)
+ return;
printk("Madeye:sent GMP\n");
print_mad_hdr(hdr);
@@ -381,16 +456,23 @@ static void snoop_gsi_handler(struct ib_
mad = (struct ib_rmpp_mad *) hdr;
print_rmpp_hdr(&mad->rmpp_hdr);
}
+
}
static void recv_gsi_handler(struct ib_mad_agent *mad_agent,
struct ib_mad_recv_wc *mad_recv_wc)
{
struct ib_mad_hdr *hdr = &mad_recv_wc->recv_buf.mad->mad_hdr;
- struct ib_rmpp_mad *mad;
+ struct ib_rmpp_mad *mad = NULL;
+ struct ib_sa_mad *sa_mad;
+ struct ib_vendor_mad *vendor_mad;
+ u8 *mad_data;
+ int i, j;
if (!gmp && hdr->mgmt_class != mgmt_class)
return;
+ if (attr_id && mad_recv_wc->recv_buf.mad->mad_hdr.attr_id != attr_id)
+ return;
printk("Madeye:recv GMP\n");
print_mad_hdr(hdr);
@@ -399,6 +481,40 @@ static void recv_gsi_handler(struct ib_m
mad = (struct ib_rmpp_mad *) hdr;
print_rmpp_hdr(&mad->rmpp_hdr);
}
+
+ if (data) {
+ if (hdr->mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
+ j = IB_MGMT_SA_DATA;
+ /* Display SA header */
+ sa_mad = (struct ib_sa_mad *) &mad_recv_wc->recv_buf.mad;
+
+ if (is_rmpp_mad(hdr)) {
+ if (mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_DATA)
+ return;
+ }
+ mad_data = sa_mad->data;
+ } else {
+ if (is_rmpp_mad(hdr)) {
+ j = IB_MGMT_VENDOR_DATA;
+ /* Display OUI */
+ vendor_mad = (struct ib_vendor_mad *) &mad_recv_wc->recv_buf.mad;
+ printk("Vendor OUI......%01x %01x %01x\n",
+ vendor_mad->oui[0],
+ vendor_mad->oui[1],
+ vendor_mad->oui[2]);
+ mad_data = vendor_mad->data;
+ } else {
+ j = IB_MGMT_MAD_DATA;
+ mad_data = mad_recv_wc->recv_buf.mad->data;
+ }
+ }
+ for (i = 0; i < j; i++) {
+ if (i % 16 == 0)
+ printk("\nData...........");
+ printk("%01x ", mad_data[i]);
+ }
+ printk("\n");
+ }
}
static void madeye_add_one(struct ib_device *device)
More information about the general
mailing list