backport acx100 2.6.24 fixes from SVN
[openwrt.git] / target / linux / adm5120 / patches-2.6.24 / 900-adm5120_switch_napi.patch
1 Index: linux-2.6.24/drivers/net/adm5120sw.c
2 ===================================================================
3 --- linux-2.6.24.orig/drivers/net/adm5120sw.c
4 +++ linux-2.6.24/drivers/net/adm5120sw.c
5 @@ -93,8 +93,14 @@
6 /* ------------------------------------------------------------------------ */
7
8 struct adm5120_if_priv {
9 + struct net_device *dev;
10 +
11 unsigned int vlan_no;
12 unsigned int port_mask;
13 +
14 +#ifdef CONFIG_ADM5120_SWITCH_NAPI
15 + struct napi_struct napi;
16 +#endif
17 };
18
19 struct dma_desc {
20 @@ -333,7 +339,6 @@ static void sw_dump_regs(void)
21 SW_DBG("rlda: %08X\n", t);
22 }
23
24 -
25 /* ------------------------------------------------------------------------ */
26
27 static inline void adm5120_rx_dma_update(struct dma_desc *desc,
28 @@ -495,9 +500,11 @@ static void adm5120_switch_tx(void)
29 }
30
31 #ifdef CONFIG_ADM5120_SWITCH_NAPI
32 -static int adm5120_if_poll(struct net_device *dev, int *budget)
33 +static int adm5120_if_poll(struct napi_struct *napi, int limit)
34 {
35 - int limit = min(dev->quota, *budget);
36 + struct adm5120_if_priv *priv = container_of(napi,
37 + struct adm5120_if_priv, napi);
38 + struct net_device *dev = priv->dev;
39 int done;
40 u32 status;
41
42 @@ -509,13 +516,10 @@ static int adm5120_if_poll(struct net_de
43 SW_DBG("%s: processing RX ring\n", dev->name);
44 done = adm5120_switch_rx(limit);
45
46 - *budget -= done;
47 - dev->quota -= done;
48 -
49 status = sw_int_status() & SWITCH_INTS_POLL;
50 if ((done < limit) && (!status)) {
51 SW_DBG("disable polling mode for %s\n", dev->name);
52 - netif_rx_complete(dev);
53 + netif_rx_complete(dev, napi);
54 sw_int_unmask(SWITCH_INTS_POLL);
55 return 0;
56 }
57 @@ -541,10 +545,12 @@ static irqreturn_t adm5120_switch_irq(in
58
59 if (status & SWITCH_INTS_POLL) {
60 struct net_device *dev = dev_id;
61 + struct adm5120_if_priv *priv = netdev_priv(dev);
62 +
63 sw_dump_intr_mask("poll ints", status);
64 SW_DBG("enable polling mode for %s\n", dev->name);
65 sw_int_mask(SWITCH_INTS_POLL);
66 - netif_rx_schedule(dev);
67 + netif_rx_schedule(dev, &priv->napi);
68 }
69 #else
70 sw_int_ack(status);
71 @@ -779,12 +785,31 @@ static void adm5120_switch_set_vlan_port
72
73 /* ------------------------------------------------------------------------ */
74
75 +#ifdef CONFIG_ADM5120_SWITCH_NAPI
76 +static inline void adm5120_if_napi_enable(struct net_device *dev)
77 +{
78 + struct adm5120_if_priv *priv = netdev_priv(dev);
79 + napi_enable(&priv->napi);
80 +}
81 +
82 +static inline void adm5120_if_napi_disable(struct net_device *dev)
83 +{
84 + struct adm5120_if_priv *priv = netdev_priv(dev);
85 + napi_disable(&priv->napi);
86 +}
87 +#else
88 +static inline void adm5120_if_napi_enable(struct net_device *dev) {}
89 +static inline void adm5120_if_napi_disable(struct net_device *dev) {}
90 +#endif /* CONFIG_ADM5120_SWITCH_NAPI */
91 +
92 static int adm5120_if_open(struct net_device *dev)
93 {
94 u32 t;
95 int err;
96 int i;
97
98 + adm5120_if_napi_enable(dev);
99 +
100 err = request_irq(dev->irq, adm5120_switch_irq,
101 (IRQF_SHARED | IRQF_DISABLED), dev->name, dev);
102 if (err) {
103 @@ -809,6 +834,7 @@ static int adm5120_if_open(struct net_de
104 return 0;
105
106 err:
107 + adm5120_if_napi_disable(dev);
108 return err;
109 }
110
111 @@ -818,6 +844,7 @@ static int adm5120_if_stop(struct net_de
112 int i;
113
114 netif_stop_queue(dev);
115 + adm5120_if_napi_disable(dev);
116
117 /* disable port if not assigned to other devices */
118 t = sw_read_reg(SWITCH_REG_PORT_CONF0);
119 @@ -1001,6 +1028,9 @@ static struct net_device *adm5120_if_all
120 if (!dev)
121 return NULL;
122
123 + priv = netdev_priv(dev);
124 + priv->dev = dev;
125 +
126 dev->irq = ADM5120_IRQ_SWITCH;
127 dev->open = adm5120_if_open;
128 dev->hard_start_xmit = adm5120_if_hard_start_xmit;
129 @@ -1010,13 +1040,11 @@ static struct net_device *adm5120_if_all
130 dev->tx_timeout = adm5120_if_tx_timeout;
131 dev->watchdog_timeo = TX_TIMEOUT;
132 dev->set_mac_address = adm5120_if_set_mac_address;
133 +
134 #ifdef CONFIG_ADM5120_SWITCH_NAPI
135 - dev->poll = adm5120_if_poll;
136 - dev->weight = 64;
137 + netif_napi_add(dev, &priv->napi, adm5120_if_poll, 64);
138 #endif
139
140 - SET_MODULE_OWNER(dev);
141 -
142 return dev;
143 }
144
This page took 0.04677 seconds and 5 git commands to generate.