761-8139cp-fixes-from-4.4.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. commit 8b7a7048220f86547db31de0abe1ea6dd2cfa892
  2. Author: David Woodhouse <dwmw2@infradead.org>
  3. Date: Thu Sep 24 11:38:22 2015 +0100
  4. 8139cp: Fix GSO MSS handling
  5. When fixing the TSO support I noticed we just mask ->gso_size with the
  6. MSSMask value and don't care about the consequences.
  7. Provide a .ndo_features_check() method which drops the NETIF_F_TSO
  8. feature for any skb which would exceed the maximum, and thus forces it
  9. to be segmented by software.
  10. Then we can stop the masking in cp_start_xmit(), and just WARN if the
  11. maximum is exceeded, which should now never happen.
  12. Finally, Francois Romieu noticed that we didn't even have the right
  13. value for MSSMask anyway; it should be 0x7ff (11 bits) not 0xfff.
  14. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  15. Signed-off-by: David S. Miller <davem@davemloft.net>
  16. commit 5a58f227790faded5a3ef6075f3ddd65093e0f86
  17. Author: David Woodhouse <David.Woodhouse@intel.com>
  18. Date: Wed Sep 23 09:46:09 2015 +0100
  19. 8139cp: Enable offload features by default
  20. I fixed TSO. Hardware checksum and scatter/gather also appear to be
  21. working correctly both on real hardware and in QEMU's emulation.
  22. Let's enable them by default and see if anyone screams...
  23. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  24. Signed-off-by: David S. Miller <davem@davemloft.net>
  25. --- a/drivers/net/ethernet/realtek/8139cp.c
  26. +++ b/drivers/net/ethernet/realtek/8139cp.c
  27. @@ -175,7 +175,7 @@ enum {
  28. LastFrag = (1 << 28), /* Final segment of a packet */
  29. LargeSend = (1 << 27), /* TCP Large Send Offload (TSO) */
  30. MSSShift = 16, /* MSS value position */
  31. - MSSMask = 0xfff, /* MSS value: 11 bits */
  32. + MSSMask = 0x7ff, /* MSS value: 11 bits */
  33. TxError = (1 << 23), /* Tx error summary */
  34. RxError = (1 << 20), /* Rx error summary */
  35. IPCS = (1 << 18), /* Calculate IP checksum */
  36. @@ -754,10 +754,16 @@ static netdev_tx_t cp_start_xmit (struct
  37. eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
  38. mss = skb_shinfo(skb)->gso_size;
  39. + if (mss > MSSMask) {
  40. + WARN_ONCE(1, "Net bug: GSO size %d too large for 8139CP\n",
  41. + mss);
  42. + goto out_dma_error;
  43. + }
  44. +
  45. opts2 = cpu_to_le32(cp_tx_vlan_tag(skb));
  46. opts1 = DescOwn;
  47. if (mss)
  48. - opts1 |= LargeSend | ((mss & MSSMask) << MSSShift);
  49. + opts1 |= LargeSend | (mss << MSSShift);
  50. else if (skb->ip_summed == CHECKSUM_PARTIAL) {
  51. const struct iphdr *ip = ip_hdr(skb);
  52. if (ip->protocol == IPPROTO_TCP)
  53. @@ -1852,6 +1858,15 @@ static void cp_set_d3_state (struct cp_p
  54. pci_set_power_state (cp->pdev, PCI_D3hot);
  55. }
  56. +static netdev_features_t cp_features_check(struct sk_buff *skb,
  57. + struct net_device *dev,
  58. + netdev_features_t features)
  59. +{
  60. + if (skb_shinfo(skb)->gso_size > MSSMask)
  61. + features &= ~NETIF_F_TSO;
  62. +
  63. + return vlan_features_check(skb, features);
  64. +}
  65. static const struct net_device_ops cp_netdev_ops = {
  66. .ndo_open = cp_open,
  67. .ndo_stop = cp_close,
  68. @@ -1864,6 +1879,7 @@ static const struct net_device_ops cp_ne
  69. .ndo_tx_timeout = cp_tx_timeout,
  70. .ndo_set_features = cp_set_features,
  71. .ndo_change_mtu = cp_change_mtu,
  72. + .ndo_features_check = cp_features_check,
  73. #ifdef CONFIG_NET_POLL_CONTROLLER
  74. .ndo_poll_controller = cp_poll_controller,
  75. @@ -1983,12 +1999,12 @@ static int cp_init_one (struct pci_dev *
  76. dev->ethtool_ops = &cp_ethtool_ops;
  77. dev->watchdog_timeo = TX_TIMEOUT;
  78. - dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
  79. + dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
  80. + NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
  81. if (pci_using_dac)
  82. dev->features |= NETIF_F_HIGHDMA;
  83. - /* disabled by default until verified */
  84. dev->hw_features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
  85. NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
  86. dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |