diff options
-rw-r--r-- | drivers/net/e1000e/defines.h | 8 | ||||
-rw-r--r-- | drivers/net/e1000e/e1000.h | 3 | ||||
-rw-r--r-- | drivers/net/e1000e/lib.c | 135 | ||||
-rw-r--r-- | drivers/net/e1000e/netdev.c | 12 |
4 files changed, 130 insertions, 28 deletions
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h index 016ea383145a..7245dc2e0b7c 100644 --- a/drivers/net/e1000e/defines.h +++ b/drivers/net/e1000e/defines.h | |||
@@ -488,6 +488,9 @@ | |||
488 | #define E1000_BLK_PHY_RESET 12 | 488 | #define E1000_BLK_PHY_RESET 12 |
489 | #define E1000_ERR_SWFW_SYNC 13 | 489 | #define E1000_ERR_SWFW_SYNC 13 |
490 | #define E1000_NOT_IMPLEMENTED 14 | 490 | #define E1000_NOT_IMPLEMENTED 14 |
491 | #define E1000_ERR_INVALID_ARGUMENT 16 | ||
492 | #define E1000_ERR_NO_SPACE 17 | ||
493 | #define E1000_ERR_NVM_PBA_SECTION 18 | ||
491 | 494 | ||
492 | /* Loop limit on how long we wait for auto-negotiation to complete */ | 495 | /* Loop limit on how long we wait for auto-negotiation to complete */ |
493 | #define FIBER_LINK_UP_LIMIT 50 | 496 | #define FIBER_LINK_UP_LIMIT 50 |
@@ -650,13 +653,16 @@ | |||
650 | /* Mask bits for fields in Word 0x03 of the EEPROM */ | 653 | /* Mask bits for fields in Word 0x03 of the EEPROM */ |
651 | #define NVM_COMPAT_LOM 0x0800 | 654 | #define NVM_COMPAT_LOM 0x0800 |
652 | 655 | ||
656 | /* length of string needed to store PBA number */ | ||
657 | #define E1000_PBANUM_LENGTH 11 | ||
658 | |||
653 | /* For checksumming, the sum of all words in the NVM should equal 0xBABA. */ | 659 | /* For checksumming, the sum of all words in the NVM should equal 0xBABA. */ |
654 | #define NVM_SUM 0xBABA | 660 | #define NVM_SUM 0xBABA |
655 | 661 | ||
656 | /* PBA (printed board assembly) number words */ | 662 | /* PBA (printed board assembly) number words */ |
657 | #define NVM_PBA_OFFSET_0 8 | 663 | #define NVM_PBA_OFFSET_0 8 |
658 | #define NVM_PBA_OFFSET_1 9 | 664 | #define NVM_PBA_OFFSET_1 9 |
659 | 665 | #define NVM_PBA_PTR_GUARD 0xFAFA | |
660 | #define NVM_WORD_SIZE_BASE_SHIFT 6 | 666 | #define NVM_WORD_SIZE_BASE_SHIFT 6 |
661 | 667 | ||
662 | /* NVM Commands - SPI */ | 668 | /* NVM Commands - SPI */ |
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index 3d9366ffd16e..2c913b8e9116 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h | |||
@@ -514,7 +514,8 @@ extern struct e1000_info e1000_pch_info; | |||
514 | extern struct e1000_info e1000_pch2_info; | 514 | extern struct e1000_info e1000_pch2_info; |
515 | extern struct e1000_info e1000_es2_info; | 515 | extern struct e1000_info e1000_es2_info; |
516 | 516 | ||
517 | extern s32 e1000e_read_pba_num(struct e1000_hw *hw, u32 *pba_num); | 517 | extern s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, |
518 | u32 pba_num_size); | ||
518 | 519 | ||
519 | extern s32 e1000e_commit_phy(struct e1000_hw *hw); | 520 | extern s32 e1000e_commit_phy(struct e1000_hw *hw); |
520 | 521 | ||
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c index 0fd4eb5ac5fb..8377523c054a 100644 --- a/drivers/net/e1000e/lib.c +++ b/drivers/net/e1000e/lib.c | |||
@@ -2139,6 +2139,119 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) | |||
2139 | } | 2139 | } |
2140 | 2140 | ||
2141 | /** | 2141 | /** |
2142 | * e1000_read_pba_string_generic - Read device part number | ||
2143 | * @hw: pointer to the HW structure | ||
2144 | * @pba_num: pointer to device part number | ||
2145 | * @pba_num_size: size of part number buffer | ||
2146 | * | ||
2147 | * Reads the product board assembly (PBA) number from the EEPROM and stores | ||
2148 | * the value in pba_num. | ||
2149 | **/ | ||
2150 | s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, | ||
2151 | u32 pba_num_size) | ||
2152 | { | ||
2153 | s32 ret_val; | ||
2154 | u16 nvm_data; | ||
2155 | u16 pba_ptr; | ||
2156 | u16 offset; | ||
2157 | u16 length; | ||
2158 | |||
2159 | if (pba_num == NULL) { | ||
2160 | e_dbg("PBA string buffer was null\n"); | ||
2161 | ret_val = E1000_ERR_INVALID_ARGUMENT; | ||
2162 | goto out; | ||
2163 | } | ||
2164 | |||
2165 | ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); | ||
2166 | if (ret_val) { | ||
2167 | e_dbg("NVM Read Error\n"); | ||
2168 | goto out; | ||
2169 | } | ||
2170 | |||
2171 | ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr); | ||
2172 | if (ret_val) { | ||
2173 | e_dbg("NVM Read Error\n"); | ||
2174 | goto out; | ||
2175 | } | ||
2176 | |||
2177 | /* | ||
2178 | * if nvm_data is not ptr guard the PBA must be in legacy format which | ||
2179 | * means pba_ptr is actually our second data word for the PBA number | ||
2180 | * and we can decode it into an ascii string | ||
2181 | */ | ||
2182 | if (nvm_data != NVM_PBA_PTR_GUARD) { | ||
2183 | e_dbg("NVM PBA number is not stored as string\n"); | ||
2184 | |||
2185 | /* we will need 11 characters to store the PBA */ | ||
2186 | if (pba_num_size < 11) { | ||
2187 | e_dbg("PBA string buffer too small\n"); | ||
2188 | return E1000_ERR_NO_SPACE; | ||
2189 | } | ||
2190 | |||
2191 | /* extract hex string from data and pba_ptr */ | ||
2192 | pba_num[0] = (nvm_data >> 12) & 0xF; | ||
2193 | pba_num[1] = (nvm_data >> 8) & 0xF; | ||
2194 | pba_num[2] = (nvm_data >> 4) & 0xF; | ||
2195 | pba_num[3] = nvm_data & 0xF; | ||
2196 | pba_num[4] = (pba_ptr >> 12) & 0xF; | ||
2197 | pba_num[5] = (pba_ptr >> 8) & 0xF; | ||
2198 | pba_num[6] = '-'; | ||
2199 | pba_num[7] = 0; | ||
2200 | pba_num[8] = (pba_ptr >> 4) & 0xF; | ||
2201 | pba_num[9] = pba_ptr & 0xF; | ||
2202 | |||
2203 | /* put a null character on the end of our string */ | ||
2204 | pba_num[10] = '\0'; | ||
2205 | |||
2206 | /* switch all the data but the '-' to hex char */ | ||
2207 | for (offset = 0; offset < 10; offset++) { | ||
2208 | if (pba_num[offset] < 0xA) | ||
2209 | pba_num[offset] += '0'; | ||
2210 | else if (pba_num[offset] < 0x10) | ||
2211 | pba_num[offset] += 'A' - 0xA; | ||
2212 | } | ||
2213 | |||
2214 | goto out; | ||
2215 | } | ||
2216 | |||
2217 | ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length); | ||
2218 | if (ret_val) { | ||
2219 | e_dbg("NVM Read Error\n"); | ||
2220 | goto out; | ||
2221 | } | ||
2222 | |||
2223 | if (length == 0xFFFF || length == 0) { | ||
2224 | e_dbg("NVM PBA number section invalid length\n"); | ||
2225 | ret_val = E1000_ERR_NVM_PBA_SECTION; | ||
2226 | goto out; | ||
2227 | } | ||
2228 | /* check if pba_num buffer is big enough */ | ||
2229 | if (pba_num_size < (((u32)length * 2) - 1)) { | ||
2230 | e_dbg("PBA string buffer too small\n"); | ||
2231 | ret_val = E1000_ERR_NO_SPACE; | ||
2232 | goto out; | ||
2233 | } | ||
2234 | |||
2235 | /* trim pba length from start of string */ | ||
2236 | pba_ptr++; | ||
2237 | length--; | ||
2238 | |||
2239 | for (offset = 0; offset < length; offset++) { | ||
2240 | ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data); | ||
2241 | if (ret_val) { | ||
2242 | e_dbg("NVM Read Error\n"); | ||
2243 | goto out; | ||
2244 | } | ||
2245 | pba_num[offset * 2] = (u8)(nvm_data >> 8); | ||
2246 | pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF); | ||
2247 | } | ||
2248 | pba_num[offset * 2] = '\0'; | ||
2249 | |||
2250 | out: | ||
2251 | return ret_val; | ||
2252 | } | ||
2253 | |||
2254 | /** | ||
2142 | * e1000_read_mac_addr_generic - Read device MAC address | 2255 | * e1000_read_mac_addr_generic - Read device MAC address |
2143 | * @hw: pointer to the HW structure | 2256 | * @hw: pointer to the HW structure |
2144 | * | 2257 | * |
@@ -2579,25 +2692,3 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) | |||
2579 | out: | 2692 | out: |
2580 | return ret_val; | 2693 | return ret_val; |
2581 | } | 2694 | } |
2582 | |||
2583 | s32 e1000e_read_pba_num(struct e1000_hw *hw, u32 *pba_num) | ||
2584 | { | ||
2585 | s32 ret_val; | ||
2586 | u16 nvm_data; | ||
2587 | |||
2588 | ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); | ||
2589 | if (ret_val) { | ||
2590 | e_dbg("NVM Read Error\n"); | ||
2591 | return ret_val; | ||
2592 | } | ||
2593 | *pba_num = (u32)(nvm_data << 16); | ||
2594 | |||
2595 | ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data); | ||
2596 | if (ret_val) { | ||
2597 | e_dbg("NVM Read Error\n"); | ||
2598 | return ret_val; | ||
2599 | } | ||
2600 | *pba_num |= nvm_data; | ||
2601 | |||
2602 | return 0; | ||
2603 | } | ||
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index f8efbbbfddfb..393b76d27536 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -5626,7 +5626,8 @@ static void e1000_print_device_info(struct e1000_adapter *adapter) | |||
5626 | { | 5626 | { |
5627 | struct e1000_hw *hw = &adapter->hw; | 5627 | struct e1000_hw *hw = &adapter->hw; |
5628 | struct net_device *netdev = adapter->netdev; | 5628 | struct net_device *netdev = adapter->netdev; |
5629 | u32 pba_num; | 5629 | u32 ret_val; |
5630 | u8 pba_str[E1000_PBANUM_LENGTH]; | ||
5630 | 5631 | ||
5631 | /* print bus type/speed/width info */ | 5632 | /* print bus type/speed/width info */ |
5632 | e_info("(PCI Express:2.5GB/s:%s) %pM\n", | 5633 | e_info("(PCI Express:2.5GB/s:%s) %pM\n", |
@@ -5637,9 +5638,12 @@ static void e1000_print_device_info(struct e1000_adapter *adapter) | |||
5637 | netdev->dev_addr); | 5638 | netdev->dev_addr); |
5638 | e_info("Intel(R) PRO/%s Network Connection\n", | 5639 | e_info("Intel(R) PRO/%s Network Connection\n", |
5639 | (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000"); | 5640 | (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000"); |
5640 | e1000e_read_pba_num(hw, &pba_num); | 5641 | ret_val = e1000_read_pba_string_generic(hw, pba_str, |
5641 | e_info("MAC: %d, PHY: %d, PBA No: %06x-%03x\n", | 5642 | E1000_PBANUM_LENGTH); |
5642 | hw->mac.type, hw->phy.type, (pba_num >> 8), (pba_num & 0xff)); | 5643 | if (ret_val) |
5644 | strcpy(pba_str, "Unknown"); | ||
5645 | e_info("MAC: %d, PHY: %d, PBA No: %s\n", | ||
5646 | hw->mac.type, hw->phy.type, pba_str); | ||
5643 | } | 5647 | } |
5644 | 5648 | ||
5645 | static void e1000_eeprom_checks(struct e1000_adapter *adapter) | 5649 | static void e1000_eeprom_checks(struct e1000_adapter *adapter) |