diff options
author | LEROY Christophe <christophe.leroy@c-s.fr> | 2014-10-07 09:04:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-08 16:01:41 -0400 |
commit | 583d4a6885cfa75a3d189f6bb69b5c545e961c75 (patch) | |
tree | f91db118ccfb64a9b0dbc596aacb451b3e577f5a | |
parent | 935e2218d5a0fade1645982fb034eee37f100f11 (diff) |
net: fs_enet: Remove non NAPI RX
In the probe function, use_napi is inconditionnaly set to 1. This patch removes
all the code which is conditional to !use_napi, and removes use_napi which has
then become useless.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 164 | ||||
-rw-r--r-- | include/linux/fs_enet_pd.h | 1 |
2 files changed, 15 insertions, 150 deletions
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c index 748fd24d3d9e..71a25b4e2d5a 100644 --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | |||
@@ -215,128 +215,6 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget) | |||
215 | return received; | 215 | return received; |
216 | } | 216 | } |
217 | 217 | ||
218 | /* non NAPI receive function */ | ||
219 | static int fs_enet_rx_non_napi(struct net_device *dev) | ||
220 | { | ||
221 | struct fs_enet_private *fep = netdev_priv(dev); | ||
222 | const struct fs_platform_info *fpi = fep->fpi; | ||
223 | cbd_t __iomem *bdp; | ||
224 | struct sk_buff *skb, *skbn, *skbt; | ||
225 | int received = 0; | ||
226 | u16 pkt_len, sc; | ||
227 | int curidx; | ||
228 | /* | ||
229 | * First, grab all of the stats for the incoming packet. | ||
230 | * These get messed up if we get called due to a busy condition. | ||
231 | */ | ||
232 | bdp = fep->cur_rx; | ||
233 | |||
234 | while (((sc = CBDR_SC(bdp)) & BD_ENET_RX_EMPTY) == 0) { | ||
235 | |||
236 | curidx = bdp - fep->rx_bd_base; | ||
237 | |||
238 | /* | ||
239 | * Since we have allocated space to hold a complete frame, | ||
240 | * the last indicator should be set. | ||
241 | */ | ||
242 | if ((sc & BD_ENET_RX_LAST) == 0) | ||
243 | dev_warn(fep->dev, "rcv is not +last\n"); | ||
244 | |||
245 | /* | ||
246 | * Check for errors. | ||
247 | */ | ||
248 | if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL | | ||
249 | BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) { | ||
250 | fep->stats.rx_errors++; | ||
251 | /* Frame too long or too short. */ | ||
252 | if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH)) | ||
253 | fep->stats.rx_length_errors++; | ||
254 | /* Frame alignment */ | ||
255 | if (sc & (BD_ENET_RX_NO | BD_ENET_RX_CL)) | ||
256 | fep->stats.rx_frame_errors++; | ||
257 | /* CRC Error */ | ||
258 | if (sc & BD_ENET_RX_CR) | ||
259 | fep->stats.rx_crc_errors++; | ||
260 | /* FIFO overrun */ | ||
261 | if (sc & BD_ENET_RX_OV) | ||
262 | fep->stats.rx_crc_errors++; | ||
263 | |||
264 | skb = fep->rx_skbuff[curidx]; | ||
265 | |||
266 | dma_unmap_single(fep->dev, CBDR_BUFADDR(bdp), | ||
267 | L1_CACHE_ALIGN(PKT_MAXBUF_SIZE), | ||
268 | DMA_FROM_DEVICE); | ||
269 | |||
270 | skbn = skb; | ||
271 | |||
272 | } else { | ||
273 | |||
274 | skb = fep->rx_skbuff[curidx]; | ||
275 | |||
276 | dma_unmap_single(fep->dev, CBDR_BUFADDR(bdp), | ||
277 | L1_CACHE_ALIGN(PKT_MAXBUF_SIZE), | ||
278 | DMA_FROM_DEVICE); | ||
279 | |||
280 | /* | ||
281 | * Process the incoming frame. | ||
282 | */ | ||
283 | fep->stats.rx_packets++; | ||
284 | pkt_len = CBDR_DATLEN(bdp) - 4; /* remove CRC */ | ||
285 | fep->stats.rx_bytes += pkt_len + 4; | ||
286 | |||
287 | if (pkt_len <= fpi->rx_copybreak) { | ||
288 | /* +2 to make IP header L1 cache aligned */ | ||
289 | skbn = netdev_alloc_skb(dev, pkt_len + 2); | ||
290 | if (skbn != NULL) { | ||
291 | skb_reserve(skbn, 2); /* align IP header */ | ||
292 | skb_copy_from_linear_data(skb, | ||
293 | skbn->data, pkt_len); | ||
294 | /* swap */ | ||
295 | skbt = skb; | ||
296 | skb = skbn; | ||
297 | skbn = skbt; | ||
298 | } | ||
299 | } else { | ||
300 | skbn = netdev_alloc_skb(dev, ENET_RX_FRSIZE); | ||
301 | |||
302 | if (skbn) | ||
303 | skb_align(skbn, ENET_RX_ALIGN); | ||
304 | } | ||
305 | |||
306 | if (skbn != NULL) { | ||
307 | skb_put(skb, pkt_len); /* Make room */ | ||
308 | skb->protocol = eth_type_trans(skb, dev); | ||
309 | received++; | ||
310 | netif_rx(skb); | ||
311 | } else { | ||
312 | fep->stats.rx_dropped++; | ||
313 | skbn = skb; | ||
314 | } | ||
315 | } | ||
316 | |||
317 | fep->rx_skbuff[curidx] = skbn; | ||
318 | CBDW_BUFADDR(bdp, dma_map_single(fep->dev, skbn->data, | ||
319 | L1_CACHE_ALIGN(PKT_MAXBUF_SIZE), | ||
320 | DMA_FROM_DEVICE)); | ||
321 | CBDW_DATLEN(bdp, 0); | ||
322 | CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY); | ||
323 | |||
324 | /* | ||
325 | * Update BD pointer to next entry. | ||
326 | */ | ||
327 | if ((sc & BD_ENET_RX_WRAP) == 0) | ||
328 | bdp++; | ||
329 | else | ||
330 | bdp = fep->rx_bd_base; | ||
331 | |||
332 | (*fep->ops->rx_bd_done)(dev); | ||
333 | } | ||
334 | |||
335 | fep->cur_rx = bdp; | ||
336 | |||
337 | return 0; | ||
338 | } | ||
339 | |||
340 | static void fs_enet_tx(struct net_device *dev) | 218 | static void fs_enet_tx(struct net_device *dev) |
341 | { | 219 | { |
342 | struct fs_enet_private *fep = netdev_priv(dev); | 220 | struct fs_enet_private *fep = netdev_priv(dev); |
@@ -453,8 +331,7 @@ fs_enet_interrupt(int irq, void *dev_id) | |||
453 | nr++; | 331 | nr++; |
454 | 332 | ||
455 | int_clr_events = int_events; | 333 | int_clr_events = int_events; |
456 | if (fpi->use_napi) | 334 | int_clr_events &= ~fep->ev_napi_rx; |
457 | int_clr_events &= ~fep->ev_napi_rx; | ||
458 | 335 | ||
459 | (*fep->ops->clear_int_events)(dev, int_clr_events); | 336 | (*fep->ops->clear_int_events)(dev, int_clr_events); |
460 | 337 | ||
@@ -462,19 +339,15 @@ fs_enet_interrupt(int irq, void *dev_id) | |||
462 | (*fep->ops->ev_error)(dev, int_events); | 339 | (*fep->ops->ev_error)(dev, int_events); |
463 | 340 | ||
464 | if (int_events & fep->ev_rx) { | 341 | if (int_events & fep->ev_rx) { |
465 | if (!fpi->use_napi) | 342 | napi_ok = napi_schedule_prep(&fep->napi); |
466 | fs_enet_rx_non_napi(dev); | 343 | |
467 | else { | 344 | (*fep->ops->napi_disable_rx)(dev); |
468 | napi_ok = napi_schedule_prep(&fep->napi); | 345 | (*fep->ops->clear_int_events)(dev, fep->ev_napi_rx); |
469 | 346 | ||
470 | (*fep->ops->napi_disable_rx)(dev); | 347 | /* NOTE: it is possible for FCCs in NAPI mode */ |
471 | (*fep->ops->clear_int_events)(dev, fep->ev_napi_rx); | 348 | /* to submit a spurious interrupt while in poll */ |
472 | 349 | if (napi_ok) | |
473 | /* NOTE: it is possible for FCCs in NAPI mode */ | 350 | __napi_schedule(&fep->napi); |
474 | /* to submit a spurious interrupt while in poll */ | ||
475 | if (napi_ok) | ||
476 | __napi_schedule(&fep->napi); | ||
477 | } | ||
478 | } | 351 | } |
479 | 352 | ||
480 | if (int_events & fep->ev_tx) | 353 | if (int_events & fep->ev_tx) |
@@ -811,24 +684,21 @@ static int fs_enet_open(struct net_device *dev) | |||
811 | /* not doing this, will cause a crash in fs_enet_rx_napi */ | 684 | /* not doing this, will cause a crash in fs_enet_rx_napi */ |
812 | fs_init_bds(fep->ndev); | 685 | fs_init_bds(fep->ndev); |
813 | 686 | ||
814 | if (fep->fpi->use_napi) | 687 | napi_enable(&fep->napi); |
815 | napi_enable(&fep->napi); | ||
816 | 688 | ||
817 | /* Install our interrupt handler. */ | 689 | /* Install our interrupt handler. */ |
818 | r = request_irq(fep->interrupt, fs_enet_interrupt, IRQF_SHARED, | 690 | r = request_irq(fep->interrupt, fs_enet_interrupt, IRQF_SHARED, |
819 | "fs_enet-mac", dev); | 691 | "fs_enet-mac", dev); |
820 | if (r != 0) { | 692 | if (r != 0) { |
821 | dev_err(fep->dev, "Could not allocate FS_ENET IRQ!"); | 693 | dev_err(fep->dev, "Could not allocate FS_ENET IRQ!"); |
822 | if (fep->fpi->use_napi) | 694 | napi_disable(&fep->napi); |
823 | napi_disable(&fep->napi); | ||
824 | return -EINVAL; | 695 | return -EINVAL; |
825 | } | 696 | } |
826 | 697 | ||
827 | err = fs_init_phy(dev); | 698 | err = fs_init_phy(dev); |
828 | if (err) { | 699 | if (err) { |
829 | free_irq(fep->interrupt, dev); | 700 | free_irq(fep->interrupt, dev); |
830 | if (fep->fpi->use_napi) | 701 | napi_disable(&fep->napi); |
831 | napi_disable(&fep->napi); | ||
832 | return err; | 702 | return err; |
833 | } | 703 | } |
834 | phy_start(fep->phydev); | 704 | phy_start(fep->phydev); |
@@ -845,8 +715,7 @@ static int fs_enet_close(struct net_device *dev) | |||
845 | 715 | ||
846 | netif_stop_queue(dev); | 716 | netif_stop_queue(dev); |
847 | netif_carrier_off(dev); | 717 | netif_carrier_off(dev); |
848 | if (fep->fpi->use_napi) | 718 | napi_disable(&fep->napi); |
849 | napi_disable(&fep->napi); | ||
850 | phy_stop(fep->phydev); | 719 | phy_stop(fep->phydev); |
851 | 720 | ||
852 | spin_lock_irqsave(&fep->lock, flags); | 721 | spin_lock_irqsave(&fep->lock, flags); |
@@ -1022,7 +891,6 @@ static int fs_enet_probe(struct platform_device *ofdev) | |||
1022 | fpi->rx_ring = 32; | 891 | fpi->rx_ring = 32; |
1023 | fpi->tx_ring = 32; | 892 | fpi->tx_ring = 32; |
1024 | fpi->rx_copybreak = 240; | 893 | fpi->rx_copybreak = 240; |
1025 | fpi->use_napi = 1; | ||
1026 | fpi->napi_weight = 17; | 894 | fpi->napi_weight = 17; |
1027 | fpi->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0); | 895 | fpi->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0); |
1028 | if (!fpi->phy_node && of_phy_is_fixed_link(ofdev->dev.of_node)) { | 896 | if (!fpi->phy_node && of_phy_is_fixed_link(ofdev->dev.of_node)) { |
@@ -1102,9 +970,7 @@ static int fs_enet_probe(struct platform_device *ofdev) | |||
1102 | 970 | ||
1103 | ndev->netdev_ops = &fs_enet_netdev_ops; | 971 | ndev->netdev_ops = &fs_enet_netdev_ops; |
1104 | ndev->watchdog_timeo = 2 * HZ; | 972 | ndev->watchdog_timeo = 2 * HZ; |
1105 | if (fpi->use_napi) | 973 | netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi, fpi->napi_weight); |
1106 | netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi, | ||
1107 | fpi->napi_weight); | ||
1108 | 974 | ||
1109 | ndev->ethtool_ops = &fs_ethtool_ops; | 975 | ndev->ethtool_ops = &fs_ethtool_ops; |
1110 | 976 | ||
diff --git a/include/linux/fs_enet_pd.h b/include/linux/fs_enet_pd.h index efb05961bdd8..77d783f71527 100644 --- a/include/linux/fs_enet_pd.h +++ b/include/linux/fs_enet_pd.h | |||
@@ -139,7 +139,6 @@ struct fs_platform_info { | |||
139 | int rx_ring, tx_ring; /* number of buffers on rx */ | 139 | int rx_ring, tx_ring; /* number of buffers on rx */ |
140 | __u8 macaddr[ETH_ALEN]; /* mac address */ | 140 | __u8 macaddr[ETH_ALEN]; /* mac address */ |
141 | int rx_copybreak; /* limit we copy small frames */ | 141 | int rx_copybreak; /* limit we copy small frames */ |
142 | int use_napi; /* use NAPI */ | ||
143 | int napi_weight; /* NAPI weight */ | 142 | int napi_weight; /* NAPI weight */ |
144 | 143 | ||
145 | int use_rmii; /* use RMII mode */ | 144 | int use_rmii; /* use RMII mode */ |