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
6 /* ------------------------------------------------------------------------ */
8 struct adm5120_if_priv {
9 + struct net_device *dev;
12 unsigned int port_mask;
14 +#ifdef CONFIG_ADM5120_SWITCH_NAPI
15 + struct napi_struct napi;
20 @@ -333,7 +339,6 @@ static void sw_dump_regs(void)
21 SW_DBG("rlda: %08X\n", t);
25 /* ------------------------------------------------------------------------ */
27 static inline void adm5120_rx_dma_update(struct dma_desc *desc,
28 @@ -495,9 +500,11 @@ static void adm5120_switch_tx(void)
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)
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;
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);
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);
57 @@ -541,10 +545,12 @@ static irqreturn_t adm5120_switch_irq(in
59 if (status & SWITCH_INTS_POLL) {
60 struct net_device *dev = dev_id;
61 + struct adm5120_if_priv *priv = netdev_priv(dev);
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);
71 @@ -779,12 +785,31 @@ static void adm5120_switch_set_vlan_port
73 /* ------------------------------------------------------------------------ */
75 +#ifdef CONFIG_ADM5120_SWITCH_NAPI
76 +static inline void adm5120_if_napi_enable(struct net_device *dev)
78 + struct adm5120_if_priv *priv = netdev_priv(dev);
79 + napi_enable(&priv->napi);
82 +static inline void adm5120_if_napi_disable(struct net_device *dev)
84 + struct adm5120_if_priv *priv = netdev_priv(dev);
85 + napi_disable(&priv->napi);
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 */
92 static int adm5120_if_open(struct net_device *dev)
98 + adm5120_if_napi_enable(dev);
100 err = request_irq(dev->irq, adm5120_switch_irq,
101 (IRQF_SHARED | IRQF_DISABLED), dev->name, dev);
103 @@ -809,6 +834,7 @@ static int adm5120_if_open(struct net_de
107 + adm5120_if_napi_disable(dev);
111 @@ -818,6 +844,7 @@ static int adm5120_if_stop(struct net_de
114 netif_stop_queue(dev);
115 + adm5120_if_napi_disable(dev);
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
123 + priv = netdev_priv(dev);
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;
134 #ifdef CONFIG_ADM5120_SWITCH_NAPI
135 - dev->poll = adm5120_if_poll;
137 + netif_napi_add(dev, &priv->napi, adm5120_if_poll, 64);
140 - SET_MODULE_OWNER(dev);