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