1 From: Divy Le Ray <divy@chelsio.com>
2 Date: Wed, 29 Oct 2008 05:40:32 +0000 (-0700)
3 Subject: cxgb3 - enable lro control through ethtool
4 Acked-by: Karsten Keil <kkeil@novell.com>
8 cxgb3 - enable lro control through ethtool
10 Implement ethtool's get_flags and set_flags methods.
11 It enables ethtool to control the LRO settings.
13 Signed-off-by: Divy Le Ray <divy@chelsio.com>
14 Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
17 Index: linux-2.6.27/drivers/net/cxgb3/cxgb3_main.c
18 ===================================================================
19 --- linux-2.6.27.orig/drivers/net/cxgb3/cxgb3_main.c
20 +++ linux-2.6.27/drivers/net/cxgb3/cxgb3_main.c
21 @@ -470,6 +470,36 @@ static void enable_all_napi(struct adapt
25 + * set_qset_lro - Turn a queue set's LRO capability on and off
26 + * @dev: the device the qset is attached to
27 + * @qset_idx: the queue set index
28 + * @val: the LRO switch
30 + * Sets LRO on or off for a particular queue set.
31 + * the device's features flag is updated to reflect the LRO
32 + * capability when all queues belonging to the device are
33 + * in the same state.
35 +static void set_qset_lro(struct net_device *dev, int qset_idx, int val)
37 + struct port_info *pi = netdev_priv(dev);
38 + struct adapter *adapter = pi->adapter;
41 + adapter->params.sge.qset[qset_idx].lro = !!val;
42 + adapter->sge.qs[qset_idx].lro_enabled = !!val;
44 + /* let ethtool report LRO on only if all queues are LRO enabled */
45 + for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; ++i)
46 + lro_on &= adapter->params.sge.qset[i].lro;
49 + dev->features |= NETIF_F_LRO;
51 + dev->features &= ~NETIF_F_LRO;
55 * setup_sge_qsets - configure SGE Tx/Rx/response queues
58 @@ -492,8 +522,7 @@ static int setup_sge_qsets(struct adapte
59 pi->qs = &adap->sge.qs[pi->first_qset];
60 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets;
62 - if (!pi->rx_csum_offload)
63 - adap->params.sge.qset[qset_idx].lro = 0;
64 + set_qset_lro(dev, qset_idx, pi->rx_csum_offload);
65 err = t3_sge_alloc_qset(adap, qset_idx, 1,
66 (adap->flags & USING_MSIX) ? qset_idx + 1 :
68 @@ -1637,13 +1666,10 @@ static int set_rx_csum(struct net_device
70 p->rx_csum_offload = data;
72 - struct adapter *adap = p->adapter;
75 - for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) {
76 - adap->params.sge.qset[i].lro = 0;
77 - adap->sge.qs[i].lro_enabled = 0;
79 + for (i = p->first_qset; i < p->first_qset + p->nqsets; i++)
80 + set_qset_lro(dev, i, 0);
84 @@ -1798,6 +1824,25 @@ static void get_wol(struct net_device *d
85 memset(&wol->sopass, 0, sizeof(wol->sopass));
88 +static int cxgb3_set_flags(struct net_device *dev, u32 data)
90 + struct port_info *pi = netdev_priv(dev);
93 + if (data & ETH_FLAG_LRO) {
94 + if (!pi->rx_csum_offload)
97 + for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
98 + set_qset_lro(dev, i, 1);
101 + for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
102 + set_qset_lro(dev, i, 0);
107 static const struct ethtool_ops cxgb_ethtool_ops = {
108 .get_settings = get_settings,
109 .set_settings = set_settings,
110 @@ -1827,6 +1872,8 @@ static const struct ethtool_ops cxgb_eth
111 .get_regs = get_regs,
113 .set_tso = ethtool_op_set_tso,
114 + .get_flags = ethtool_op_get_flags,
115 + .set_flags = cxgb3_set_flags,
118 static int in_range(int val, int lo, int hi)
119 @@ -1943,11 +1990,9 @@ static int cxgb_extension_ioctl(struct n
124 - struct sge_qset *qs = &adapter->sge.qs[t.qset_idx];
126 - qs->lro_enabled = t.lro;
129 + set_qset_lro(dev, t.qset_idx, t.lro);
133 case CHELSIO_GET_QSET_PARAMS:{