aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/gianfar.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/gianfar.c')
-rw-r--r--drivers/net/gianfar.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 6850dc0a7b91..8bd3c9f17532 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -143,7 +143,6 @@ void gfar_start(struct net_device *dev);
143static void gfar_clear_exact_match(struct net_device *dev); 143static void gfar_clear_exact_match(struct net_device *dev);
144static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr); 144static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr);
145static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 145static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
146u16 gfar_select_queue(struct net_device *dev, struct sk_buff *skb);
147 146
148MODULE_AUTHOR("Freescale Semiconductor, Inc"); 147MODULE_AUTHOR("Freescale Semiconductor, Inc");
149MODULE_DESCRIPTION("Gianfar Ethernet Driver"); 148MODULE_DESCRIPTION("Gianfar Ethernet Driver");
@@ -357,8 +356,11 @@ static void gfar_init_mac(struct net_device *ndev)
357 /* Configure the coalescing support */ 356 /* Configure the coalescing support */
358 gfar_configure_coalescing(priv, 0xFF, 0xFF); 357 gfar_configure_coalescing(priv, 0xFF, 0xFF);
359 358
360 if (priv->rx_filer_enable) 359 if (priv->rx_filer_enable) {
361 rctrl |= RCTRL_FILREN; 360 rctrl |= RCTRL_FILREN;
361 /* Program the RIR0 reg with the required distribution */
362 gfar_write(&regs->rir0, DEFAULT_RIR0);
363 }
362 364
363 if (priv->rx_csum_enable) 365 if (priv->rx_csum_enable)
364 rctrl |= RCTRL_CHECKSUMMING; 366 rctrl |= RCTRL_CHECKSUMMING;
@@ -414,6 +416,36 @@ static void gfar_init_mac(struct net_device *ndev)
414 gfar_write(&regs->fifo_tx_starve_shutoff, priv->fifo_starve_off); 416 gfar_write(&regs->fifo_tx_starve_shutoff, priv->fifo_starve_off);
415} 417}
416 418
419static struct net_device_stats *gfar_get_stats(struct net_device *dev)
420{
421 struct gfar_private *priv = netdev_priv(dev);
422 struct netdev_queue *txq;
423 unsigned long rx_packets = 0, rx_bytes = 0, rx_dropped = 0;
424 unsigned long tx_packets = 0, tx_bytes = 0;
425 int i = 0;
426
427 for (i = 0; i < priv->num_rx_queues; i++) {
428 rx_packets += priv->rx_queue[i]->stats.rx_packets;
429 rx_bytes += priv->rx_queue[i]->stats.rx_bytes;
430 rx_dropped += priv->rx_queue[i]->stats.rx_dropped;
431 }
432
433 dev->stats.rx_packets = rx_packets;
434 dev->stats.rx_bytes = rx_bytes;
435 dev->stats.rx_dropped = rx_dropped;
436
437 for (i = 0; i < priv->num_tx_queues; i++) {
438 txq = netdev_get_tx_queue(dev, i);
439 tx_bytes += txq->tx_bytes;
440 tx_packets += txq->tx_packets;
441 }
442
443 dev->stats.tx_bytes = tx_bytes;
444 dev->stats.tx_packets = tx_packets;
445
446 return &dev->stats;
447}
448
417static const struct net_device_ops gfar_netdev_ops = { 449static const struct net_device_ops gfar_netdev_ops = {
418 .ndo_open = gfar_enet_open, 450 .ndo_open = gfar_enet_open,
419 .ndo_start_xmit = gfar_start_xmit, 451 .ndo_start_xmit = gfar_start_xmit,
@@ -422,7 +454,7 @@ static const struct net_device_ops gfar_netdev_ops = {
422 .ndo_set_multicast_list = gfar_set_multi, 454 .ndo_set_multicast_list = gfar_set_multi,
423 .ndo_tx_timeout = gfar_timeout, 455 .ndo_tx_timeout = gfar_timeout,
424 .ndo_do_ioctl = gfar_ioctl, 456 .ndo_do_ioctl = gfar_ioctl,
425 .ndo_select_queue = gfar_select_queue, 457 .ndo_get_stats = gfar_get_stats,
426 .ndo_vlan_rx_register = gfar_vlan_rx_register, 458 .ndo_vlan_rx_register = gfar_vlan_rx_register,
427 .ndo_set_mac_address = eth_mac_addr, 459 .ndo_set_mac_address = eth_mac_addr,
428 .ndo_validate_addr = eth_validate_addr, 460 .ndo_validate_addr = eth_validate_addr,
@@ -472,10 +504,6 @@ static inline int gfar_uses_fcb(struct gfar_private *priv)
472 return priv->vlgrp || priv->rx_csum_enable; 504 return priv->vlgrp || priv->rx_csum_enable;
473} 505}
474 506
475u16 gfar_select_queue(struct net_device *dev, struct sk_buff *skb)
476{
477 return skb_get_queue_mapping(skb);
478}
479static void free_tx_pointers(struct gfar_private *priv) 507static void free_tx_pointers(struct gfar_private *priv)
480{ 508{
481 int i = 0; 509 int i = 0;
@@ -1022,6 +1050,9 @@ static int gfar_probe(struct of_device *ofdev,
1022 priv->rx_queue[i]->rxic = DEFAULT_RXIC; 1050 priv->rx_queue[i]->rxic = DEFAULT_RXIC;
1023 } 1051 }
1024 1052
1053 /* enable filer if using multiple RX queues*/
1054 if(priv->num_rx_queues > 1)
1055 priv->rx_filer_enable = 1;
1025 /* Enable most messages by default */ 1056 /* Enable most messages by default */
1026 priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1; 1057 priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1;
1027 1058
@@ -1937,7 +1968,8 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
1937 } 1968 }
1938 1969
1939 /* Update transmit stats */ 1970 /* Update transmit stats */
1940 dev->stats.tx_bytes += skb->len; 1971 txq->tx_bytes += skb->len;
1972 txq->tx_packets ++;
1941 1973
1942 txbdp = txbdp_start = tx_queue->cur_tx; 1974 txbdp = txbdp_start = tx_queue->cur_tx;
1943 1975
@@ -2295,8 +2327,6 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
2295 tx_queue->skb_dirtytx = skb_dirtytx; 2327 tx_queue->skb_dirtytx = skb_dirtytx;
2296 tx_queue->dirty_tx = bdp; 2328 tx_queue->dirty_tx = bdp;
2297 2329
2298 dev->stats.tx_packets += howmany;
2299
2300 return howmany; 2330 return howmany;
2301} 2331}
2302 2332
@@ -2434,10 +2464,11 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
2434 fcb = (struct rxfcb *)skb->data; 2464 fcb = (struct rxfcb *)skb->data;
2435 2465
2436 /* Remove the FCB from the skb */ 2466 /* Remove the FCB from the skb */
2437 skb_set_queue_mapping(skb, fcb->rq);
2438 /* Remove the padded bytes, if there are any */ 2467 /* Remove the padded bytes, if there are any */
2439 if (amount_pull) 2468 if (amount_pull) {
2469 skb_record_rx_queue(skb, fcb->rq);
2440 skb_pull(skb, amount_pull); 2470 skb_pull(skb, amount_pull);
2471 }
2441 2472
2442 if (priv->rx_csum_enable) 2473 if (priv->rx_csum_enable)
2443 gfar_rx_checksum(skb, fcb); 2474 gfar_rx_checksum(skb, fcb);
@@ -2510,22 +2541,22 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
2510 } 2541 }
2511 } else { 2542 } else {
2512 /* Increment the number of packets */ 2543 /* Increment the number of packets */
2513 dev->stats.rx_packets++; 2544 rx_queue->stats.rx_packets++;
2514 howmany++; 2545 howmany++;
2515 2546
2516 if (likely(skb)) { 2547 if (likely(skb)) {
2517 pkt_len = bdp->length - ETH_FCS_LEN; 2548 pkt_len = bdp->length - ETH_FCS_LEN;
2518 /* Remove the FCS from the packet length */ 2549 /* Remove the FCS from the packet length */
2519 skb_put(skb, pkt_len); 2550 skb_put(skb, pkt_len);
2520 dev->stats.rx_bytes += pkt_len; 2551 rx_queue->stats.rx_bytes += pkt_len;
2521 2552 skb_record_rx_queue(skb, rx_queue->qindex);
2522 gfar_process_frame(dev, skb, amount_pull); 2553 gfar_process_frame(dev, skb, amount_pull);
2523 2554
2524 } else { 2555 } else {
2525 if (netif_msg_rx_err(priv)) 2556 if (netif_msg_rx_err(priv))
2526 printk(KERN_WARNING 2557 printk(KERN_WARNING
2527 "%s: Missing skb!\n", dev->name); 2558 "%s: Missing skb!\n", dev->name);
2528 dev->stats.rx_dropped++; 2559 rx_queue->stats.rx_dropped++;
2529 priv->extra_stats.rx_skbmissing++; 2560 priv->extra_stats.rx_skbmissing++;
2530 } 2561 }
2531 2562