aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2009-01-11 03:19:36 -0500
committerDavid S. Miller <davem@davemloft.net>2009-01-11 03:19:36 -0500
commit47fd23fe8efeea3af4593a8424419df48724eb25 (patch)
tree110a3c9d39322c356d43090b1431d66711ec47dd /drivers
parent2a7e637de51ded7b0b56b927f45915eadb6734bb (diff)
cxgb3: Keep LRO off if disabled when interface is down
I have a system with a Chelsio adapter (driven by cxgb3) whose ports are part of a Linux bridge. Recently I updated the kernel and discovered that things stopped working because cxgb3 was doing LRO on packets that were passed into the bridge code for forwarding. (Incidentally, this problem manifested itself in a strange way that made debugging a bit interesting -- for some reason, the skb_warn_if_lro() check in bridge didn't trigger and these LROed packets were forwarded out a forcedeth interface, and caused the forcedeth transmit path to get stuck) This is because cxgb3 has no way of keeping state for the LRO flag until the interface is brought up, so if the bridging code disables LRO while the interface is down, then cxgb3_up() will just reenable LRO, and on my Debian system at least, the init scripts add interfaces to a bridge before bringing the interfaces up. Fix this by keeping track of each interface's LRO state in cxgb3 so that when bridge disables LRO, it stays disabled in cxgb3_up() when the interface is brought up. I did this by changing the rx_csum_offload flag into a pair of bit flags; the effect of this on the rx_eth() fast path is miniscule enough that it should be fine (eg on x86, a cmpb instruction becomes a testb instruction). Signed-off-by: Roland Dreier <rolandd@cisco.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/cxgb3/adapter.h7
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c22
-rw-r--r--drivers/net/cxgb3/sge.c2
3 files changed, 21 insertions, 10 deletions
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index 5b346f9eaa8b..a89d8cc51205 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -50,12 +50,17 @@ struct vlan_group;
50struct adapter; 50struct adapter;
51struct sge_qset; 51struct sge_qset;
52 52
53enum { /* rx_offload flags */
54 T3_RX_CSUM = 1 << 0,
55 T3_LRO = 1 << 1,
56};
57
53struct port_info { 58struct port_info {
54 struct adapter *adapter; 59 struct adapter *adapter;
55 struct vlan_group *vlan_grp; 60 struct vlan_group *vlan_grp;
56 struct sge_qset *qs; 61 struct sge_qset *qs;
57 u8 port_id; 62 u8 port_id;
58 u8 rx_csum_offload; 63 u8 rx_offload;
59 u8 nqsets; 64 u8 nqsets;
60 u8 first_qset; 65 u8 first_qset;
61 struct cphy phy; 66 struct cphy phy;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 2847f947499d..0089746b8d02 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -546,7 +546,7 @@ static int setup_sge_qsets(struct adapter *adap)
546 pi->qs = &adap->sge.qs[pi->first_qset]; 546 pi->qs = &adap->sge.qs[pi->first_qset];
547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets; 547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets;
548 ++j, ++qset_idx) { 548 ++j, ++qset_idx) {
549 set_qset_lro(dev, qset_idx, pi->rx_csum_offload); 549 set_qset_lro(dev, qset_idx, pi->rx_offload & T3_LRO);
550 err = t3_sge_alloc_qset(adap, qset_idx, 1, 550 err = t3_sge_alloc_qset(adap, qset_idx, 1,
551 (adap->flags & USING_MSIX) ? qset_idx + 1 : 551 (adap->flags & USING_MSIX) ? qset_idx + 1 :
552 irq_idx, 552 irq_idx,
@@ -1657,17 +1657,19 @@ static u32 get_rx_csum(struct net_device *dev)
1657{ 1657{
1658 struct port_info *p = netdev_priv(dev); 1658 struct port_info *p = netdev_priv(dev);
1659 1659
1660 return p->rx_csum_offload; 1660 return p->rx_offload & T3_RX_CSUM;
1661} 1661}
1662 1662
1663static int set_rx_csum(struct net_device *dev, u32 data) 1663static int set_rx_csum(struct net_device *dev, u32 data)
1664{ 1664{
1665 struct port_info *p = netdev_priv(dev); 1665 struct port_info *p = netdev_priv(dev);
1666 1666
1667 p->rx_csum_offload = data; 1667 if (data) {
1668 if (!data) { 1668 p->rx_offload |= T3_RX_CSUM;
1669 } else {
1669 int i; 1670 int i;
1670 1671
1672 p->rx_offload &= ~(T3_RX_CSUM | T3_LRO);
1671 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) 1673 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++)
1672 set_qset_lro(dev, i, 0); 1674 set_qset_lro(dev, i, 0);
1673 } 1675 }
@@ -1830,15 +1832,18 @@ static int cxgb3_set_flags(struct net_device *dev, u32 data)
1830 int i; 1832 int i;
1831 1833
1832 if (data & ETH_FLAG_LRO) { 1834 if (data & ETH_FLAG_LRO) {
1833 if (!pi->rx_csum_offload) 1835 if (!(pi->rx_offload & T3_RX_CSUM))
1834 return -EINVAL; 1836 return -EINVAL;
1835 1837
1838 pi->rx_offload |= T3_LRO;
1836 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) 1839 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1837 set_qset_lro(dev, i, 1); 1840 set_qset_lro(dev, i, 1);
1838 1841
1839 } else 1842 } else {
1843 pi->rx_offload &= ~T3_LRO;
1840 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) 1844 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1841 set_qset_lro(dev, i, 0); 1845 set_qset_lro(dev, i, 0);
1846 }
1842 1847
1843 return 0; 1848 return 0;
1844} 1849}
@@ -1926,7 +1931,7 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1926 pi = adap2pinfo(adapter, i); 1931 pi = adap2pinfo(adapter, i);
1927 if (t.qset_idx >= pi->first_qset && 1932 if (t.qset_idx >= pi->first_qset &&
1928 t.qset_idx < pi->first_qset + pi->nqsets && 1933 t.qset_idx < pi->first_qset + pi->nqsets &&
1929 !pi->rx_csum_offload) 1934 !(pi->rx_offload & T3_RX_CSUM))
1930 return -EINVAL; 1935 return -EINVAL;
1931 } 1936 }
1932 1937
@@ -2946,7 +2951,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2946 adapter->port[i] = netdev; 2951 adapter->port[i] = netdev;
2947 pi = netdev_priv(netdev); 2952 pi = netdev_priv(netdev);
2948 pi->adapter = adapter; 2953 pi->adapter = adapter;
2949 pi->rx_csum_offload = 1; 2954 pi->rx_offload = T3_RX_CSUM | T3_LRO;
2950 pi->port_id = i; 2955 pi->port_id = i;
2951 netif_carrier_off(netdev); 2956 netif_carrier_off(netdev);
2952 netif_tx_stop_all_queues(netdev); 2957 netif_tx_stop_all_queues(netdev);
@@ -2955,6 +2960,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2955 netdev->mem_end = mmio_start + mmio_len - 1; 2960 netdev->mem_end = mmio_start + mmio_len - 1;
2956 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; 2961 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
2957 netdev->features |= NETIF_F_LLTX; 2962 netdev->features |= NETIF_F_LLTX;
2963 netdev->features |= NETIF_F_LRO;
2958 if (pci_using_dac) 2964 if (pci_using_dac)
2959 netdev->features |= NETIF_F_HIGHDMA; 2965 netdev->features |= NETIF_F_HIGHDMA;
2960 2966
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 6c641a889471..14f9fb3e8795 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -1932,7 +1932,7 @@ static void rx_eth(struct adapter *adap, struct sge_rspq *rq,
1932 skb_pull(skb, sizeof(*p) + pad); 1932 skb_pull(skb, sizeof(*p) + pad);
1933 skb->protocol = eth_type_trans(skb, adap->port[p->iff]); 1933 skb->protocol = eth_type_trans(skb, adap->port[p->iff]);
1934 pi = netdev_priv(skb->dev); 1934 pi = netdev_priv(skb->dev);
1935 if (pi->rx_csum_offload && p->csum_valid && p->csum == htons(0xffff) && 1935 if ((pi->rx_offload & T3_RX_CSUM) && p->csum_valid && p->csum == htons(0xffff) &&
1936 !p->fragment) { 1936 !p->fragment) {
1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++; 1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++;
1938 skb->ip_summed = CHECKSUM_UNNECESSARY; 1938 skb->ip_summed = CHECKSUM_UNNECESSARY;