aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorHariprasad Shenai <hariprasad@chelsio.com>2014-12-03 01:19:50 -0500
committerDavid S. Miller <davem@davemloft.net>2014-12-09 13:21:08 -0500
commit79af221d67e7e7502d740d57eebd93ddd66cffc4 (patch)
tree68cf7356ca09ec325c14ffed52ce00ebec9c00c4 /drivers/net
parent6000df00fd440b38cf41d435c3790e9cc12b447f (diff)
cxgb4: Add a check for flashing FW using ethtool
Don't let T4 firmware flash on a T5 adapter and vice-versa using ethtool Based on original work by Casey Leedom <leedom@chelsio.com> Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 163a2a14948c..c623f1fc2e3d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -1131,6 +1131,27 @@ unsigned int t4_flash_cfg_addr(struct adapter *adapter)
1131 return FLASH_CFG_START; 1131 return FLASH_CFG_START;
1132} 1132}
1133 1133
1134/* Return TRUE if the specified firmware matches the adapter. I.e. T4
1135 * firmware for T4 adapters, T5 firmware for T5 adapters, etc. We go ahead
1136 * and emit an error message for mismatched firmware to save our caller the
1137 * effort ...
1138 */
1139static bool t4_fw_matches_chip(const struct adapter *adap,
1140 const struct fw_hdr *hdr)
1141{
1142 /* The expression below will return FALSE for any unsupported adapter
1143 * which will keep us "honest" in the future ...
1144 */
1145 if ((is_t4(adap->params.chip) && hdr->chip == FW_HDR_CHIP_T4) ||
1146 (is_t5(adap->params.chip) && hdr->chip == FW_HDR_CHIP_T5))
1147 return true;
1148
1149 dev_err(adap->pdev_dev,
1150 "FW image (%d) is not suitable for this adapter (%d)\n",
1151 hdr->chip, CHELSIO_CHIP_VERSION(adap->params.chip));
1152 return false;
1153}
1154
1134/** 1155/**
1135 * t4_load_fw - download firmware 1156 * t4_load_fw - download firmware
1136 * @adap: the adapter 1157 * @adap: the adapter
@@ -1170,6 +1191,8 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size)
1170 FW_MAX_SIZE); 1191 FW_MAX_SIZE);
1171 return -EFBIG; 1192 return -EFBIG;
1172 } 1193 }
1194 if (!t4_fw_matches_chip(adap, hdr))
1195 return -EINVAL;
1173 1196
1174 for (csum = 0, i = 0; i < size / sizeof(csum); i++) 1197 for (csum = 0, i = 0; i < size / sizeof(csum); i++)
1175 csum += ntohl(p[i]); 1198 csum += ntohl(p[i]);
@@ -3080,6 +3103,9 @@ int t4_fw_upgrade(struct adapter *adap, unsigned int mbox,
3080 const struct fw_hdr *fw_hdr = (const struct fw_hdr *)fw_data; 3103 const struct fw_hdr *fw_hdr = (const struct fw_hdr *)fw_data;
3081 int reset, ret; 3104 int reset, ret;
3082 3105
3106 if (!t4_fw_matches_chip(adap, fw_hdr))
3107 return -EINVAL;
3108
3083 ret = t4_fw_halt(adap, mbox, force); 3109 ret = t4_fw_halt(adap, mbox, force);
3084 if (ret < 0 && !force) 3110 if (ret < 0 && !force)
3085 return ret; 3111 return ret;