[openib-general] [PATCH] mthca: report board id in sysfs
Michael S. Tsirkin
mst at mellanox.co.il
Mon Jun 27 08:03:08 PDT 2005
4 last words in query adapter include the board id (byte-swapped).
Show this board id in sysfs.
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>
Index: hw/mthca/mthca_dev.h
===================================================================
--- hw/mthca/mthca_dev.h (revision 2719)
+++ hw/mthca/mthca_dev.h (working copy)
@@ -66,6 +66,10 @@ enum {
};
enum {
+ MTHCA_BOARD_ID_LEN = 0x10
+};
+
+enum {
MTHCA_EQ_CONTEXT_SIZE = 0x40,
MTHCA_CQ_CONTEXT_SIZE = 0x40,
MTHCA_QP_CONTEXT_SIZE = 0x200,
@@ -245,6 +249,7 @@ struct mthca_dev {
unsigned long device_cap_flags;
u32 rev_id;
+ u8 board_id[MTHCA_BOARD_ID_LEN];
/* firmware info */
u64 fw_ver;
Index: hw/mthca/mthca_main.c
===================================================================
--- hw/mthca/mthca_main.c (revision 2719)
+++ hw/mthca/mthca_main.c (working copy)
@@ -284,6 +284,7 @@ static int __devinit mthca_init_tavor(st
mdev->eq_table.inta_pin = adapter.inta_pin;
mdev->rev_id = adapter.revision_id;
+ memcpy(mdev->board_id, adapter.board_id, sizeof mdev->board_id);
return 0;
Index: hw/mthca/mthca_provider.c
===================================================================
--- hw/mthca/mthca_provider.c (revision 2719)
+++ hw/mthca/mthca_provider.c (working copy)
@@ -955,14 +955,23 @@ static ssize_t show_hca(struct class_dev
}
}
+static ssize_t show_board(struct class_device *cdev, char *buf)
+{
+ struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev);
+ return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
+}
+
+
static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
static struct class_device_attribute *mthca_class_attributes[] = {
&class_device_attr_hw_rev,
&class_device_attr_fw_ver,
- &class_device_attr_hca_type
+ &class_device_attr_hca_type,
+ &class_device_attr_board_id
};
int mthca_register_device(struct mthca_dev *dev)
Index: hw/mthca/mthca_cmd.c
===================================================================
--- hw/mthca/mthca_cmd.c (revision 2719)
+++ hw/mthca/mthca_cmd.c (working copy)
@@ -1087,13 +1087,14 @@ int mthca_QUERY_ADAPTER(struct mthca_dev
{
struct mthca_mailbox *mailbox;
u32 *outbox;
- int err;
+ int i, err;
#define QUERY_ADAPTER_OUT_SIZE 0x100
#define QUERY_ADAPTER_VENDOR_ID_OFFSET 0x00
#define QUERY_ADAPTER_DEVICE_ID_OFFSET 0x04
#define QUERY_ADAPTER_REVISION_ID_OFFSET 0x08
#define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10
+#define QUERY_ADAPTER_BOARD_ID_OFFSET 0xF0
mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
if (IS_ERR(mailbox))
@@ -1111,6 +1112,9 @@ int mthca_QUERY_ADAPTER(struct mthca_dev
MTHCA_GET(adapter->revision_id, outbox, QUERY_ADAPTER_REVISION_ID_OFFSET);
MTHCA_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET);
+ for (i = 0; i < sizeof adapter->board_id / 4; ++i)
+ adapter->board_id[i] = __swab32p(outbox + i + QUERY_ADAPTER_BOARD_ID_OFFSET / 4);
+
out:
mthca_free_mailbox(dev, mailbox);
return err;
Index: hw/mthca/mthca_cmd.h
===================================================================
--- hw/mthca/mthca_cmd.h (revision 2719)
+++ hw/mthca/mthca_cmd.h (working copy)
@@ -187,6 +187,7 @@ struct mthca_adapter {
u32 device_id;
u32 revision_id;
u8 inta_pin;
+ u32 board_id[MTHCA_BOARD_ID_LEN / 4];
};
struct mthca_init_hca_param {
--
MST
More information about the general
mailing list