diff options
-rw-r--r-- | drivers/net/ixgbe/ixgbe_common.c | 94 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_common.h | 3 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_main.c | 18 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_type.h | 6 |
4 files changed, 105 insertions, 16 deletions
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c index 56052570cac5..cc11e422ce9b 100644 --- a/drivers/net/ixgbe/ixgbe_common.c +++ b/drivers/net/ixgbe/ixgbe_common.c | |||
@@ -196,30 +196,110 @@ s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw) | |||
196 | } | 196 | } |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * ixgbe_read_pba_num_generic - Reads part number from EEPROM | 199 | * ixgbe_read_pba_string_generic - Reads part number string from EEPROM |
200 | * @hw: pointer to hardware structure | 200 | * @hw: pointer to hardware structure |
201 | * @pba_num: stores the part number from the EEPROM | 201 | * @pba_num: stores the part number string from the EEPROM |
202 | * @pba_num_size: part number string buffer length | ||
202 | * | 203 | * |
203 | * Reads the part number from the EEPROM. | 204 | * Reads the part number string from the EEPROM. |
204 | **/ | 205 | **/ |
205 | s32 ixgbe_read_pba_num_generic(struct ixgbe_hw *hw, u32 *pba_num) | 206 | s32 ixgbe_read_pba_string_generic(struct ixgbe_hw *hw, u8 *pba_num, |
207 | u32 pba_num_size) | ||
206 | { | 208 | { |
207 | s32 ret_val; | 209 | s32 ret_val; |
208 | u16 data; | 210 | u16 data; |
211 | u16 pba_ptr; | ||
212 | u16 offset; | ||
213 | u16 length; | ||
214 | |||
215 | if (pba_num == NULL) { | ||
216 | hw_dbg(hw, "PBA string buffer was null\n"); | ||
217 | return IXGBE_ERR_INVALID_ARGUMENT; | ||
218 | } | ||
209 | 219 | ||
210 | ret_val = hw->eeprom.ops.read(hw, IXGBE_PBANUM0_PTR, &data); | 220 | ret_val = hw->eeprom.ops.read(hw, IXGBE_PBANUM0_PTR, &data); |
211 | if (ret_val) { | 221 | if (ret_val) { |
212 | hw_dbg(hw, "NVM Read Error\n"); | 222 | hw_dbg(hw, "NVM Read Error\n"); |
213 | return ret_val; | 223 | return ret_val; |
214 | } | 224 | } |
215 | *pba_num = (u32)(data << 16); | ||
216 | 225 | ||
217 | ret_val = hw->eeprom.ops.read(hw, IXGBE_PBANUM1_PTR, &data); | 226 | ret_val = hw->eeprom.ops.read(hw, IXGBE_PBANUM1_PTR, &pba_ptr); |
218 | if (ret_val) { | 227 | if (ret_val) { |
219 | hw_dbg(hw, "NVM Read Error\n"); | 228 | hw_dbg(hw, "NVM Read Error\n"); |
220 | return ret_val; | 229 | return ret_val; |
221 | } | 230 | } |
222 | *pba_num |= data; | 231 | |
232 | /* | ||
233 | * if data is not ptr guard the PBA must be in legacy format which | ||
234 | * means pba_ptr is actually our second data word for the PBA number | ||
235 | * and we can decode it into an ascii string | ||
236 | */ | ||
237 | if (data != IXGBE_PBANUM_PTR_GUARD) { | ||
238 | hw_dbg(hw, "NVM PBA number is not stored as string\n"); | ||
239 | |||
240 | /* we will need 11 characters to store the PBA */ | ||
241 | if (pba_num_size < 11) { | ||
242 | hw_dbg(hw, "PBA string buffer too small\n"); | ||
243 | return IXGBE_ERR_NO_SPACE; | ||
244 | } | ||
245 | |||
246 | /* extract hex string from data and pba_ptr */ | ||
247 | pba_num[0] = (data >> 12) & 0xF; | ||
248 | pba_num[1] = (data >> 8) & 0xF; | ||
249 | pba_num[2] = (data >> 4) & 0xF; | ||
250 | pba_num[3] = data & 0xF; | ||
251 | pba_num[4] = (pba_ptr >> 12) & 0xF; | ||
252 | pba_num[5] = (pba_ptr >> 8) & 0xF; | ||
253 | pba_num[6] = '-'; | ||
254 | pba_num[7] = 0; | ||
255 | pba_num[8] = (pba_ptr >> 4) & 0xF; | ||
256 | pba_num[9] = pba_ptr & 0xF; | ||
257 | |||
258 | /* put a null character on the end of our string */ | ||
259 | pba_num[10] = '\0'; | ||
260 | |||
261 | /* switch all the data but the '-' to hex char */ | ||
262 | for (offset = 0; offset < 10; offset++) { | ||
263 | if (pba_num[offset] < 0xA) | ||
264 | pba_num[offset] += '0'; | ||
265 | else if (pba_num[offset] < 0x10) | ||
266 | pba_num[offset] += 'A' - 0xA; | ||
267 | } | ||
268 | |||
269 | return 0; | ||
270 | } | ||
271 | |||
272 | ret_val = hw->eeprom.ops.read(hw, pba_ptr, &length); | ||
273 | if (ret_val) { | ||
274 | hw_dbg(hw, "NVM Read Error\n"); | ||
275 | return ret_val; | ||
276 | } | ||
277 | |||
278 | if (length == 0xFFFF || length == 0) { | ||
279 | hw_dbg(hw, "NVM PBA number section invalid length\n"); | ||
280 | return IXGBE_ERR_PBA_SECTION; | ||
281 | } | ||
282 | |||
283 | /* check if pba_num buffer is big enough */ | ||
284 | if (pba_num_size < (((u32)length * 2) - 1)) { | ||
285 | hw_dbg(hw, "PBA string buffer too small\n"); | ||
286 | return IXGBE_ERR_NO_SPACE; | ||
287 | } | ||
288 | |||
289 | /* trim pba length from start of string */ | ||
290 | pba_ptr++; | ||
291 | length--; | ||
292 | |||
293 | for (offset = 0; offset < length; offset++) { | ||
294 | ret_val = hw->eeprom.ops.read(hw, pba_ptr + offset, &data); | ||
295 | if (ret_val) { | ||
296 | hw_dbg(hw, "NVM Read Error\n"); | ||
297 | return ret_val; | ||
298 | } | ||
299 | pba_num[offset * 2] = (u8)(data >> 8); | ||
300 | pba_num[(offset * 2) + 1] = (u8)(data & 0xFF); | ||
301 | } | ||
302 | pba_num[offset * 2] = '\0'; | ||
223 | 303 | ||
224 | return 0; | 304 | return 0; |
225 | } | 305 | } |
diff --git a/drivers/net/ixgbe/ixgbe_common.h b/drivers/net/ixgbe/ixgbe_common.h index 341ca514a281..e1f980a8a09d 100644 --- a/drivers/net/ixgbe/ixgbe_common.h +++ b/drivers/net/ixgbe/ixgbe_common.h | |||
@@ -35,7 +35,8 @@ s32 ixgbe_init_ops_generic(struct ixgbe_hw *hw); | |||
35 | s32 ixgbe_init_hw_generic(struct ixgbe_hw *hw); | 35 | s32 ixgbe_init_hw_generic(struct ixgbe_hw *hw); |
36 | s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw); | 36 | s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw); |
37 | s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw); | 37 | s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw); |
38 | s32 ixgbe_read_pba_num_generic(struct ixgbe_hw *hw, u32 *pba_num); | 38 | s32 ixgbe_read_pba_string_generic(struct ixgbe_hw *hw, u8 *pba_num, |
39 | u32 pba_num_size); | ||
39 | s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr); | 40 | s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr); |
40 | s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw); | 41 | s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw); |
41 | void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw); | 42 | void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw); |
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index c5c93408212d..f97353cdb607 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -6952,11 +6952,12 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, | |||
6952 | const struct ixgbe_info *ii = ixgbe_info_tbl[ent->driver_data]; | 6952 | const struct ixgbe_info *ii = ixgbe_info_tbl[ent->driver_data]; |
6953 | static int cards_found; | 6953 | static int cards_found; |
6954 | int i, err, pci_using_dac; | 6954 | int i, err, pci_using_dac; |
6955 | u8 part_str[IXGBE_PBANUM_LENGTH]; | ||
6955 | unsigned int indices = num_possible_cpus(); | 6956 | unsigned int indices = num_possible_cpus(); |
6956 | #ifdef IXGBE_FCOE | 6957 | #ifdef IXGBE_FCOE |
6957 | u16 device_caps; | 6958 | u16 device_caps; |
6958 | #endif | 6959 | #endif |
6959 | u32 part_num, eec; | 6960 | u32 eec; |
6960 | 6961 | ||
6961 | /* Catch broken hardware that put the wrong VF device ID in | 6962 | /* Catch broken hardware that put the wrong VF device ID in |
6962 | * the PCIe SR-IOV capability. | 6963 | * the PCIe SR-IOV capability. |
@@ -7262,16 +7263,17 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, | |||
7262 | hw->bus.width == ixgbe_bus_width_pcie_x1 ? "Width x1" : | 7263 | hw->bus.width == ixgbe_bus_width_pcie_x1 ? "Width x1" : |
7263 | "Unknown"), | 7264 | "Unknown"), |
7264 | netdev->dev_addr); | 7265 | netdev->dev_addr); |
7265 | ixgbe_read_pba_num_generic(hw, &part_num); | 7266 | |
7267 | err = ixgbe_read_pba_string_generic(hw, part_str, IXGBE_PBANUM_LENGTH); | ||
7268 | if (err) | ||
7269 | strcpy(part_str, "Unknown"); | ||
7266 | if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present) | 7270 | if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present) |
7267 | e_dev_info("MAC: %d, PHY: %d, SFP+: %d, " | 7271 | e_dev_info("MAC: %d, PHY: %d, SFP+: %d, PBA No: %s\n", |
7268 | "PBA No: %06x-%03x\n", | ||
7269 | hw->mac.type, hw->phy.type, hw->phy.sfp_type, | 7272 | hw->mac.type, hw->phy.type, hw->phy.sfp_type, |
7270 | (part_num >> 8), (part_num & 0xff)); | 7273 | part_str); |
7271 | else | 7274 | else |
7272 | e_dev_info("MAC: %d, PHY: %d, PBA No: %06x-%03x\n", | 7275 | e_dev_info("MAC: %d, PHY: %d, PBA No: %s\n", |
7273 | hw->mac.type, hw->phy.type, | 7276 | hw->mac.type, hw->phy.type, part_str); |
7274 | (part_num >> 8), (part_num & 0xff)); | ||
7275 | 7277 | ||
7276 | if (hw->bus.width <= ixgbe_bus_width_pcie_x4) { | 7278 | if (hw->bus.width <= ixgbe_bus_width_pcie_x4) { |
7277 | e_dev_warn("PCI-Express bandwidth available for this card is " | 7279 | e_dev_warn("PCI-Express bandwidth available for this card is " |
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h index 35b60db5e776..ef816dd5a8f0 100644 --- a/drivers/net/ixgbe/ixgbe_type.h +++ b/drivers/net/ixgbe/ixgbe_type.h | |||
@@ -1508,7 +1508,11 @@ | |||
1508 | #define IXGBE_EEPROM_WORD_SIZE_SHIFT 6 | 1508 | #define IXGBE_EEPROM_WORD_SIZE_SHIFT 6 |
1509 | #define IXGBE_EEPROM_OPCODE_BITS 8 | 1509 | #define IXGBE_EEPROM_OPCODE_BITS 8 |
1510 | 1510 | ||
1511 | /* Part Number String Length */ | ||
1512 | #define IXGBE_PBANUM_LENGTH 11 | ||
1513 | |||
1511 | /* Checksum and EEPROM pointers */ | 1514 | /* Checksum and EEPROM pointers */ |
1515 | #define IXGBE_PBANUM_PTR_GUARD 0xFAFA | ||
1512 | #define IXGBE_EEPROM_CHECKSUM 0x3F | 1516 | #define IXGBE_EEPROM_CHECKSUM 0x3F |
1513 | #define IXGBE_EEPROM_SUM 0xBABA | 1517 | #define IXGBE_EEPROM_SUM 0xBABA |
1514 | #define IXGBE_PCIE_ANALOG_PTR 0x03 | 1518 | #define IXGBE_PCIE_ANALOG_PTR 0x03 |
@@ -2637,6 +2641,8 @@ struct ixgbe_info { | |||
2637 | #define IXGBE_ERR_NO_SPACE -25 | 2641 | #define IXGBE_ERR_NO_SPACE -25 |
2638 | #define IXGBE_ERR_OVERTEMP -26 | 2642 | #define IXGBE_ERR_OVERTEMP -26 |
2639 | #define IXGBE_ERR_RAR_INDEX -27 | 2643 | #define IXGBE_ERR_RAR_INDEX -27 |
2644 | #define IXGBE_ERR_PBA_SECTION -31 | ||
2645 | #define IXGBE_ERR_INVALID_ARGUMENT -32 | ||
2640 | #define IXGBE_NOT_IMPLEMENTED 0x7FFFFFFF | 2646 | #define IXGBE_NOT_IMPLEMENTED 0x7FFFFFFF |
2641 | 2647 | ||
2642 | #endif /* _IXGBE_TYPE_H_ */ | 2648 | #endif /* _IXGBE_TYPE_H_ */ |