e1000e: fix IPMI traffic

Some users reported that they have machines with BMCs enabled that cannot
receive IPMI traffic after e1000e is loaded.
http://marc.info/?l=e1000-devel&m=121909039127414&w=2
http://marc.info/?l=e1000-devel&m=121365543823387&w=2

This fixes the issue if they load with the new parameter = 0 by disabling
crc stripping, but leaves the performance feature on for most users.
Based on work done by Hong Zhang.

Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Jeff Kirsher and committed by David S. Miller eb7c3adb e82f54ba

+51 -2
+5
drivers/net/e1000e/e1000.h
··· 299 299 unsigned long led_status; 300 300 301 301 unsigned int flags; 302 + unsigned int flags2; 302 303 struct work_struct downshift_task; 303 304 struct work_struct update_phy_task; 304 305 }; ··· 307 306 struct e1000_info { 308 307 enum e1000_mac_type mac; 309 308 unsigned int flags; 309 + unsigned int flags2; 310 310 u32 pba; 311 311 s32 (*get_variants)(struct e1000_adapter *); 312 312 struct e1000_mac_operations *mac_ops; ··· 348 346 #define FLAG_TSO_FORCE (1 << 29) 349 347 #define FLAG_RX_RESTART_NOW (1 << 30) 350 348 #define FLAG_MSI_TEST_FAILED (1 << 31) 349 + 350 + /* CRC Stripping defines */ 351 + #define FLAG2_CRC_STRIPPING (1 << 0) 351 352 352 353 #define E1000_RX_DESC_PS(R, i) \ 353 354 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
+21 -2
drivers/net/e1000e/netdev.c
··· 499 499 goto next_desc; 500 500 } 501 501 502 + /* adjust length to remove Ethernet CRC */ 503 + if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) 504 + length -= 4; 505 + 502 506 total_rx_bytes += length; 503 507 total_rx_packets++; 504 508 ··· 808 804 pci_dma_sync_single_for_device(pdev, ps_page->dma, 809 805 PAGE_SIZE, PCI_DMA_FROMDEVICE); 810 806 807 + /* remove the CRC */ 808 + if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) 809 + l1 -= 4; 810 + 811 811 skb_put(skb, l1); 812 812 goto copydone; 813 813 } /* if */ ··· 832 824 skb->data_len += length; 833 825 skb->truesize += length; 834 826 } 827 + 828 + /* strip the ethernet crc, problem is we're using pages now so 829 + * this whole operation can get a little cpu intensive 830 + */ 831 + if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) 832 + pskb_trim(skb, skb->len - 4); 835 833 836 834 copydone: 837 835 total_rx_bytes += skb->len; ··· 2315 2301 else 2316 2302 rctl |= E1000_RCTL_LPE; 2317 2303 2318 - /* Enable hardware CRC frame stripping */ 2319 - rctl |= E1000_RCTL_SECRC; 2304 + /* Some systems expect that the CRC is included in SMBUS traffic. The 2305 + * hardware strips the CRC before sending to both SMBUS (BMC) and to 2306 + * host memory when this is enabled 2307 + */ 2308 + if (adapter->flags2 & FLAG2_CRC_STRIPPING) 2309 + rctl |= E1000_RCTL_SECRC; 2320 2310 2321 2311 /* Setup buffer sizes */ 2322 2312 rctl &= ~E1000_RCTL_SZ_4096; ··· 4784 4766 adapter->ei = ei; 4785 4767 adapter->pba = ei->pba; 4786 4768 adapter->flags = ei->flags; 4769 + adapter->flags2 = ei->flags2; 4787 4770 adapter->hw.adapter = adapter; 4788 4771 adapter->hw.mac.type = ei->mac; 4789 4772 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
+25
drivers/net/e1000e/param.c
··· 151 151 */ 152 152 E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]"); 153 153 154 + /* 155 + * Enable CRC Stripping 156 + * 157 + * Valid Range: 0, 1 158 + * 159 + * Default Value: 1 (enabled) 160 + */ 161 + E1000_PARAM(CrcStripping, "Enable CRC Stripping, disable if your BMC needs " \ 162 + "the CRC"); 163 + 154 164 struct e1000_option { 155 165 enum { enable_option, range_option, list_option } type; 156 166 const char *name; ··· 412 402 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) 413 403 && spd) 414 404 adapter->flags |= FLAG_SMART_POWER_DOWN; 405 + } 406 + } 407 + { /* CRC Stripping */ 408 + const struct e1000_option opt = { 409 + .type = enable_option, 410 + .name = "CRC Stripping", 411 + .err = "defaulting to enabled", 412 + .def = OPTION_ENABLED 413 + }; 414 + 415 + if (num_CrcStripping > bd) { 416 + unsigned int crc_stripping = CrcStripping[bd]; 417 + e1000_validate_option(&crc_stripping, &opt, adapter); 418 + if (crc_stripping == OPTION_ENABLED) 419 + adapter->flags2 |= FLAG2_CRC_STRIPPING; 415 420 } 416 421 } 417 422 { /* Kumeran Lock Loss Workaround */