diff options
author | Michael S. Tsirkin <mst@mellanox.co.il> | 2005-08-14 00:19:38 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-08-26 23:37:35 -0400 |
commit | 2e8b981c5d5c6fe5479ad47c44e3e76ebb5408ef (patch) | |
tree | d01fc31cb120666633f92d0eaf48b82b6a22be46 /drivers/infiniband/hw/mthca/mthca_cmd.c | |
parent | 97f52eb438be7caebe026421545619d8a0c1398a (diff) |
[PATCH] IB/mthca: add HCA board ID to sysfs info
Add support for reporting HCA board ID returned from QUERY_ADAPTER
firmware command through sysfs.
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_cmd.c')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_cmd.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index 1e60487ecd7f..e15c1e2deab4 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c | |||
@@ -1085,6 +1085,34 @@ out: | |||
1085 | return err; | 1085 | return err; |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | static void get_board_id(void *vsd, char *board_id) | ||
1089 | { | ||
1090 | int i; | ||
1091 | |||
1092 | #define VSD_OFFSET_SIG1 0x00 | ||
1093 | #define VSD_OFFSET_SIG2 0xde | ||
1094 | #define VSD_OFFSET_MLX_BOARD_ID 0xd0 | ||
1095 | #define VSD_OFFSET_TS_BOARD_ID 0x20 | ||
1096 | |||
1097 | #define VSD_SIGNATURE_TOPSPIN 0x5ad | ||
1098 | |||
1099 | memset(board_id, 0, MTHCA_BOARD_ID_LEN); | ||
1100 | |||
1101 | if (be16_to_cpup(vsd + VSD_OFFSET_SIG1) == VSD_SIGNATURE_TOPSPIN && | ||
1102 | be16_to_cpup(vsd + VSD_OFFSET_SIG2) == VSD_SIGNATURE_TOPSPIN) { | ||
1103 | strlcpy(board_id, vsd + VSD_OFFSET_TS_BOARD_ID, MTHCA_BOARD_ID_LEN); | ||
1104 | } else { | ||
1105 | /* | ||
1106 | * The board ID is a string but the firmware byte | ||
1107 | * swaps each 4-byte word before passing it back to | ||
1108 | * us. Therefore we need to swab it before printing. | ||
1109 | */ | ||
1110 | for (i = 0; i < 4; ++i) | ||
1111 | ((u32 *) board_id)[i] = | ||
1112 | swab32(*(u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4)); | ||
1113 | } | ||
1114 | } | ||
1115 | |||
1088 | int mthca_QUERY_ADAPTER(struct mthca_dev *dev, | 1116 | int mthca_QUERY_ADAPTER(struct mthca_dev *dev, |
1089 | struct mthca_adapter *adapter, u8 *status) | 1117 | struct mthca_adapter *adapter, u8 *status) |
1090 | { | 1118 | { |
@@ -1097,6 +1125,7 @@ int mthca_QUERY_ADAPTER(struct mthca_dev *dev, | |||
1097 | #define QUERY_ADAPTER_DEVICE_ID_OFFSET 0x04 | 1125 | #define QUERY_ADAPTER_DEVICE_ID_OFFSET 0x04 |
1098 | #define QUERY_ADAPTER_REVISION_ID_OFFSET 0x08 | 1126 | #define QUERY_ADAPTER_REVISION_ID_OFFSET 0x08 |
1099 | #define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10 | 1127 | #define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10 |
1128 | #define QUERY_ADAPTER_VSD_OFFSET 0x20 | ||
1100 | 1129 | ||
1101 | mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); | 1130 | mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); |
1102 | if (IS_ERR(mailbox)) | 1131 | if (IS_ERR(mailbox)) |
@@ -1114,6 +1143,9 @@ int mthca_QUERY_ADAPTER(struct mthca_dev *dev, | |||
1114 | MTHCA_GET(adapter->revision_id, outbox, QUERY_ADAPTER_REVISION_ID_OFFSET); | 1143 | MTHCA_GET(adapter->revision_id, outbox, QUERY_ADAPTER_REVISION_ID_OFFSET); |
1115 | MTHCA_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET); | 1144 | MTHCA_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET); |
1116 | 1145 | ||
1146 | get_board_id(outbox + QUERY_ADAPTER_VSD_OFFSET / 4, | ||
1147 | adapter->board_id); | ||
1148 | |||
1117 | out: | 1149 | out: |
1118 | mthca_free_mailbox(dev, mailbox); | 1150 | mthca_free_mailbox(dev, mailbox); |
1119 | return err; | 1151 | return err; |