diff options
author | Hariprasad Shenai <hariprasad@chelsio.com> | 2015-02-09 01:37:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-09 17:07:54 -0500 |
commit | ba3f8cd55f2aaa734ba44d8dd8cfaa6503c83d63 (patch) | |
tree | 6bf2ff90bfabc67fc37716e89d5ebc3d7df1ec00 | |
parent | a4505152044c31f7b8e108a87ab2009901d96d0e (diff) |
cxgb4: Add support in cxgb4 to get expansion rom version via ethtool
Add support to get option/expansion rom version flashed in the adapter via
ethtool getdrvinfo function.
Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 37 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 8 |
4 files changed, 55 insertions, 0 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index 0fe3a52fb0b8..d6cda17efe6e 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | |||
@@ -1121,6 +1121,7 @@ int t4_fw_upgrade(struct adapter *adap, unsigned int mbox, | |||
1121 | unsigned int t4_flash_cfg_addr(struct adapter *adapter); | 1121 | unsigned int t4_flash_cfg_addr(struct adapter *adapter); |
1122 | int t4_get_fw_version(struct adapter *adapter, u32 *vers); | 1122 | int t4_get_fw_version(struct adapter *adapter, u32 *vers); |
1123 | int t4_get_tp_version(struct adapter *adapter, u32 *vers); | 1123 | int t4_get_tp_version(struct adapter *adapter, u32 *vers); |
1124 | int t4_get_exprom_version(struct adapter *adapter, u32 *vers); | ||
1124 | int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info, | 1125 | int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info, |
1125 | const u8 *fw_data, unsigned int fw_size, | 1126 | const u8 *fw_data, unsigned int fw_size, |
1126 | struct fw_hdr *card_fw, enum dev_state state, int *reset); | 1127 | struct fw_hdr *card_fw, enum dev_state state, int *reset); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 5db5b4f7b94d..a22cf932ca35 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | |||
@@ -1419,6 +1419,7 @@ static int get_eeprom_len(struct net_device *dev) | |||
1419 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1419 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1420 | { | 1420 | { |
1421 | struct adapter *adapter = netdev2adap(dev); | 1421 | struct adapter *adapter = netdev2adap(dev); |
1422 | u32 exprom_vers; | ||
1422 | 1423 | ||
1423 | strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); | 1424 | strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); |
1424 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); | 1425 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
@@ -1436,6 +1437,14 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
1436 | FW_HDR_FW_VER_MINOR_G(adapter->params.tp_vers), | 1437 | FW_HDR_FW_VER_MINOR_G(adapter->params.tp_vers), |
1437 | FW_HDR_FW_VER_MICRO_G(adapter->params.tp_vers), | 1438 | FW_HDR_FW_VER_MICRO_G(adapter->params.tp_vers), |
1438 | FW_HDR_FW_VER_BUILD_G(adapter->params.tp_vers)); | 1439 | FW_HDR_FW_VER_BUILD_G(adapter->params.tp_vers)); |
1440 | |||
1441 | if (!t4_get_exprom_version(adapter, &exprom_vers)) | ||
1442 | snprintf(info->erom_version, sizeof(info->erom_version), | ||
1443 | "%u.%u.%u.%u", | ||
1444 | FW_HDR_FW_VER_MAJOR_G(exprom_vers), | ||
1445 | FW_HDR_FW_VER_MINOR_G(exprom_vers), | ||
1446 | FW_HDR_FW_VER_MICRO_G(exprom_vers), | ||
1447 | FW_HDR_FW_VER_BUILD_G(exprom_vers)); | ||
1439 | } | 1448 | } |
1440 | 1449 | ||
1441 | static void get_strings(struct net_device *dev, u32 stringset, u8 *data) | 1450 | static void get_strings(struct net_device *dev, u32 stringset, u8 *data) |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 2c13e8005319..4d643b65265e 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | |||
@@ -948,6 +948,43 @@ int t4_get_tp_version(struct adapter *adapter, u32 *vers) | |||
948 | 1, vers, 0); | 948 | 1, vers, 0); |
949 | } | 949 | } |
950 | 950 | ||
951 | /** | ||
952 | * t4_get_exprom_version - return the Expansion ROM version (if any) | ||
953 | * @adapter: the adapter | ||
954 | * @vers: where to place the version | ||
955 | * | ||
956 | * Reads the Expansion ROM header from FLASH and returns the version | ||
957 | * number (if present) through the @vers return value pointer. We return | ||
958 | * this in the Firmware Version Format since it's convenient. Return | ||
959 | * 0 on success, -ENOENT if no Expansion ROM is present. | ||
960 | */ | ||
961 | int t4_get_exprom_version(struct adapter *adap, u32 *vers) | ||
962 | { | ||
963 | struct exprom_header { | ||
964 | unsigned char hdr_arr[16]; /* must start with 0x55aa */ | ||
965 | unsigned char hdr_ver[4]; /* Expansion ROM version */ | ||
966 | } *hdr; | ||
967 | u32 exprom_header_buf[DIV_ROUND_UP(sizeof(struct exprom_header), | ||
968 | sizeof(u32))]; | ||
969 | int ret; | ||
970 | |||
971 | ret = t4_read_flash(adap, FLASH_EXP_ROM_START, | ||
972 | ARRAY_SIZE(exprom_header_buf), exprom_header_buf, | ||
973 | 0); | ||
974 | if (ret) | ||
975 | return ret; | ||
976 | |||
977 | hdr = (struct exprom_header *)exprom_header_buf; | ||
978 | if (hdr->hdr_arr[0] != 0x55 || hdr->hdr_arr[1] != 0xaa) | ||
979 | return -ENOENT; | ||
980 | |||
981 | *vers = (FW_HDR_FW_VER_MAJOR_V(hdr->hdr_ver[0]) | | ||
982 | FW_HDR_FW_VER_MINOR_V(hdr->hdr_ver[1]) | | ||
983 | FW_HDR_FW_VER_MICRO_V(hdr->hdr_ver[2]) | | ||
984 | FW_HDR_FW_VER_BUILD_V(hdr->hdr_ver[3])); | ||
985 | return 0; | ||
986 | } | ||
987 | |||
951 | /* Is the given firmware API compatible with the one the driver was compiled | 988 | /* Is the given firmware API compatible with the one the driver was compiled |
952 | * with? | 989 | * with? |
953 | */ | 990 | */ |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h index 95fc425375c4..9b353a88cbda 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | |||
@@ -3018,21 +3018,29 @@ enum fw_hdr_chip { | |||
3018 | 3018 | ||
3019 | #define FW_HDR_FW_VER_MAJOR_S 24 | 3019 | #define FW_HDR_FW_VER_MAJOR_S 24 |
3020 | #define FW_HDR_FW_VER_MAJOR_M 0xff | 3020 | #define FW_HDR_FW_VER_MAJOR_M 0xff |
3021 | #define FW_HDR_FW_VER_MAJOR_V(x) \ | ||
3022 | ((x) << FW_HDR_FW_VER_MAJOR_S) | ||
3021 | #define FW_HDR_FW_VER_MAJOR_G(x) \ | 3023 | #define FW_HDR_FW_VER_MAJOR_G(x) \ |
3022 | (((x) >> FW_HDR_FW_VER_MAJOR_S) & FW_HDR_FW_VER_MAJOR_M) | 3024 | (((x) >> FW_HDR_FW_VER_MAJOR_S) & FW_HDR_FW_VER_MAJOR_M) |
3023 | 3025 | ||
3024 | #define FW_HDR_FW_VER_MINOR_S 16 | 3026 | #define FW_HDR_FW_VER_MINOR_S 16 |
3025 | #define FW_HDR_FW_VER_MINOR_M 0xff | 3027 | #define FW_HDR_FW_VER_MINOR_M 0xff |
3028 | #define FW_HDR_FW_VER_MINOR_V(x) \ | ||
3029 | ((x) << FW_HDR_FW_VER_MINOR_S) | ||
3026 | #define FW_HDR_FW_VER_MINOR_G(x) \ | 3030 | #define FW_HDR_FW_VER_MINOR_G(x) \ |
3027 | (((x) >> FW_HDR_FW_VER_MINOR_S) & FW_HDR_FW_VER_MINOR_M) | 3031 | (((x) >> FW_HDR_FW_VER_MINOR_S) & FW_HDR_FW_VER_MINOR_M) |
3028 | 3032 | ||
3029 | #define FW_HDR_FW_VER_MICRO_S 8 | 3033 | #define FW_HDR_FW_VER_MICRO_S 8 |
3030 | #define FW_HDR_FW_VER_MICRO_M 0xff | 3034 | #define FW_HDR_FW_VER_MICRO_M 0xff |
3035 | #define FW_HDR_FW_VER_MICRO_V(x) \ | ||
3036 | ((x) << FW_HDR_FW_VER_MICRO_S) | ||
3031 | #define FW_HDR_FW_VER_MICRO_G(x) \ | 3037 | #define FW_HDR_FW_VER_MICRO_G(x) \ |
3032 | (((x) >> FW_HDR_FW_VER_MICRO_S) & FW_HDR_FW_VER_MICRO_M) | 3038 | (((x) >> FW_HDR_FW_VER_MICRO_S) & FW_HDR_FW_VER_MICRO_M) |
3033 | 3039 | ||
3034 | #define FW_HDR_FW_VER_BUILD_S 0 | 3040 | #define FW_HDR_FW_VER_BUILD_S 0 |
3035 | #define FW_HDR_FW_VER_BUILD_M 0xff | 3041 | #define FW_HDR_FW_VER_BUILD_M 0xff |
3042 | #define FW_HDR_FW_VER_BUILD_V(x) \ | ||
3043 | ((x) << FW_HDR_FW_VER_BUILD_S) | ||
3036 | #define FW_HDR_FW_VER_BUILD_G(x) \ | 3044 | #define FW_HDR_FW_VER_BUILD_G(x) \ |
3037 | (((x) >> FW_HDR_FW_VER_BUILD_S) & FW_HDR_FW_VER_BUILD_M) | 3045 | (((x) >> FW_HDR_FW_VER_BUILD_S) & FW_HDR_FW_VER_BUILD_M) |
3038 | 3046 | ||