[ofa-general] [PATCH RFC] RDMA/cxgb3: Add protocol statistics to iw_cxgb3.
Steve Wise
swise at opengridcomputing.com
Thu Jun 12 14:13:02 PDT 2008
- Add a new rdma ctl command called RDMA_GET_MIB to the low level driver
to obtain the protocol mib from the hardware.
- Add a sysfs entry to allow dumping these stats.
Signed-off-by: Steve Wise <swise at opengridcomputing.com>
---
drivers/infiniband/hw/cxgb3/iwch_provider.c | 56 +++++++++++++++++++++++++++
drivers/net/cxgb3/cxgb3_ctl_defs.h | 48 +++++++++++++++++++++++
drivers/net/cxgb3/cxgb3_offload.c | 7 +++
3 files changed, 110 insertions(+), 1 deletions(-)
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index 480a2da..f71a103 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -1192,17 +1192,71 @@ static ssize_t show_board(struct device *dev, struct device_attribute *attr,
return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor,
iwch_dev->rdev.rnic_info.pdev->device);
}
+static ssize_t show_stats(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+ ibdev.dev);
+ struct rdma_mib_stats m;
+ int ret;
+ ssize_t len = 0;
+
+ PDBG("%s dev 0x%p\n", __func__, dev);
+ ret = iwch_dev->rdev.t3cdev_p->ctl(iwch_dev->rdev.t3cdev_p,
+ RDMA_GET_MIB, &m);
+ if (ret)
+ return sprintf(buf, "Not Available\n");
+
+#define MIB32(s, field) len += sprintf(buf + len, "%-18s %u\n", s, m.field)
+#define MIB64(s, hi, lo) \
+ len += sprintf(buf + len, "%-18s %llu\n", s, \
+ (unsigned long long)m.hi + m.lo)
+
+ MIB64("IPInReceives:", ipInReceive_hi, ipInReceive_lo);
+ MIB64("IPInHdrErrors:", ipInHdrErrors_hi, ipInHdrErrors_lo);
+ MIB64("IPInAddrErrors:", ipInAddrErrors_hi, ipInAddrErrors_lo);
+ MIB64("IPInUnknownProtos:", ipInUnknownProtos_hi,
+ ipInUnknownProtos_lo);
+ MIB64("IPInDiscards:", ipInDiscards_hi, ipInDiscards_lo);
+ MIB64("IPInDelivers:", ipInDelivers_hi, ipInDelivers_lo);
+ MIB64("IPOutRequests:", ipOutRequests_hi, ipOutRequests_lo);
+ MIB64("IPOutDiscards:", ipOutDiscards_hi, ipOutDiscards_lo);
+ MIB64("IPOutNoRoutes:", ipOutNoRoutes_hi, ipOutNoRoutes_lo);
+ MIB32("IPReasmTimeout:", ipReasmTimeout);
+ MIB32("IPReasmReqds:", ipReasmReqds);
+ MIB32("IPReasmOKs:", ipReasmOKs);
+ MIB32("IPReasmFails:", ipReasmFails);
+ MIB32("TCPActiveOpens:", tcpActiveOpens);
+ MIB32("TCPPassiveOpens:", tcpPassiveOpens);
+ MIB32("TCPAttemptFails:", tcpAttemptFails);
+ MIB32("TCPEstabResets:", tcpEstabResets);
+ MIB32("TCPOutRsts:", tcpOutRsts);
+ MIB32("TCPCurrEstab:", tcpCurrEstab);
+ MIB64("TCPInSegs:", tcpInSegs_hi, tcpInSegs_lo);
+ MIB64("TCPOutSegs:", tcpOutSegs_hi, tcpOutSegs_lo);
+ MIB64("TCPRetransSeg:", tcpRetransSeg_hi, tcpRetransSeg_lo);
+ MIB64("TCPInErrs:", tcpInErrs_hi, tcpInErrs_lo);
+ MIB32("TCPRtoMin:", tcpRtoMin);
+ MIB32("TCPRtoMax:", tcpRtoMax);
+
+#undef MIB32
+#undef MIB64
+
+ return len;
+}
static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
+static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
static struct device_attribute *iwch_class_attributes[] = {
&dev_attr_hw_rev,
&dev_attr_fw_ver,
&dev_attr_hca_type,
- &dev_attr_board_id
+ &dev_attr_board_id,
+ &dev_attr_stats
};
int iwch_register_device(struct iwch_dev *dev)
diff --git a/drivers/net/cxgb3/cxgb3_ctl_defs.h b/drivers/net/cxgb3/cxgb3_ctl_defs.h
index 6c4f320..2dffc2e 100644
--- a/drivers/net/cxgb3/cxgb3_ctl_defs.h
+++ b/drivers/net/cxgb3/cxgb3_ctl_defs.h
@@ -54,6 +54,7 @@ enum {
RDMA_CQ_DISABLE = 16,
RDMA_CTRL_QP_SETUP = 17,
RDMA_GET_MEM = 18,
+ RDMA_GET_MIB = 19,
GET_RX_PAGE_INFO = 50,
};
@@ -171,4 +172,51 @@ struct ofld_page_info {
unsigned int page_size; /* Page size, should be a power of 2 */
unsigned int num; /* Number of pages */
};
+
+/*
+ * Offload RDMA protocol stats.
+ */
+struct rdma_mib_stats {
+ u32 ipInReceive_hi;
+ u32 ipInReceive_lo;
+ u32 ipInHdrErrors_hi;
+ u32 ipInHdrErrors_lo;
+ u32 ipInAddrErrors_hi;
+ u32 ipInAddrErrors_lo;
+ u32 ipInUnknownProtos_hi;
+ u32 ipInUnknownProtos_lo;
+ u32 ipInDiscards_hi;
+ u32 ipInDiscards_lo;
+ u32 ipInDelivers_hi;
+ u32 ipInDelivers_lo;
+ u32 ipOutRequests_hi;
+ u32 ipOutRequests_lo;
+ u32 ipOutDiscards_hi;
+ u32 ipOutDiscards_lo;
+ u32 ipOutNoRoutes_hi;
+ u32 ipOutNoRoutes_lo;
+ u32 ipReasmTimeout;
+ u32 ipReasmReqds;
+ u32 ipReasmOKs;
+ u32 ipReasmFails;
+
+ u32 reserved[8];
+
+ u32 tcpActiveOpens;
+ u32 tcpPassiveOpens;
+ u32 tcpAttemptFails;
+ u32 tcpEstabResets;
+ u32 tcpOutRsts;
+ u32 tcpCurrEstab;
+ u32 tcpInSegs_hi;
+ u32 tcpInSegs_lo;
+ u32 tcpOutSegs_hi;
+ u32 tcpOutSegs_lo;
+ u32 tcpRetransSeg_hi;
+ u32 tcpRetransSeg_lo;
+ u32 tcpInErrs_hi;
+ u32 tcpInErrs_lo;
+ u32 tcpRtoMin;
+ u32 tcpRtoMax;
+};
#endif /* _CXGB3_OFFLOAD_CTL_DEFS_H */
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index ff9c013..1884238 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -303,6 +303,12 @@ static int cxgb_rdma_ctl(struct adapter *adapter, unsigned int req, void *data)
spin_unlock_irq(&adapter->sge.reg_lock);
break;
}
+ case RDMA_GET_MIB: {
+ spin_lock(&adapter->stats_lock);
+ t3_tp_get_mib_stats(adapter, (struct rdma_mib_stats *)data);
+ spin_unlock(&adapter->stats_lock);
+ break;
+ }
default:
ret = -EOPNOTSUPP;
}
@@ -381,6 +387,7 @@ static int cxgb_offload_ctl(struct t3cdev *tdev, unsigned int req, void *data)
case RDMA_CQ_DISABLE:
case RDMA_CTRL_QP_SETUP:
case RDMA_GET_MEM:
+ case RDMA_GET_MIB:
if (!offload_running(adapter))
return -EAGAIN;
return cxgb_rdma_ctl(adapter, req, data);
More information about the general
mailing list