diff options
author | Figo.zhang <figo1802@gmail.com> | 2009-10-29 23:05:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-02 02:55:07 -0500 |
commit | 68d8287ce1e1da3c99881385a93e74f68c454fc2 (patch) | |
tree | 40f327eb2c6f742f2208fa5b7afa55bbd6aa4644 /drivers/net/arm | |
parent | d521b63b27e3a397e0ef7ca86b6e813861083c83 (diff) |
NET:KS8695: add API for get rx interrupt bit
1. Add API Add k8695_get_rx_enable_bit() for get Rx interrupt
enable/status bit.
2. add some comment or document about some functions and variables.
3. update driver version to "1.02"
4. add napi_enable() and napi_disable() in open/close file method.
Signed-off-by: Figo.zhang <figo1802@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/arm')
-rw-r--r-- | drivers/net/arm/ks8695net.c | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c index ed0b0f3b7122..0073d198715b 100644 --- a/drivers/net/arm/ks8695net.c +++ b/drivers/net/arm/ks8695net.c | |||
@@ -41,8 +41,7 @@ | |||
41 | #include "ks8695net.h" | 41 | #include "ks8695net.h" |
42 | 42 | ||
43 | #define MODULENAME "ks8695_ether" | 43 | #define MODULENAME "ks8695_ether" |
44 | #define MODULEVERSION "1.01" | 44 | #define MODULEVERSION "1.02" |
45 | |||
46 | 45 | ||
47 | /* | 46 | /* |
48 | * Transmit and device reset timeout, default 5 seconds. | 47 | * Transmit and device reset timeout, default 5 seconds. |
@@ -98,6 +97,9 @@ struct ks8695_skbuff { | |||
98 | #define MAX_RX_DESC 16 | 97 | #define MAX_RX_DESC 16 |
99 | #define MAX_RX_DESC_MASK 0xf | 98 | #define MAX_RX_DESC_MASK 0xf |
100 | 99 | ||
100 | /*napi_weight have better more than rx DMA buffers*/ | ||
101 | #define NAPI_WEIGHT 64 | ||
102 | |||
101 | #define MAX_RXBUF_SIZE 0x700 | 103 | #define MAX_RXBUF_SIZE 0x700 |
102 | 104 | ||
103 | #define TX_RING_DMA_SIZE (sizeof(struct tx_ring_desc) * MAX_TX_DESC) | 105 | #define TX_RING_DMA_SIZE (sizeof(struct tx_ring_desc) * MAX_TX_DESC) |
@@ -123,6 +125,7 @@ enum ks8695_dtype { | |||
123 | * @dev: The platform device object for this interface | 125 | * @dev: The platform device object for this interface |
124 | * @dtype: The type of this device | 126 | * @dtype: The type of this device |
125 | * @io_regs: The ioremapped registers for this interface | 127 | * @io_regs: The ioremapped registers for this interface |
128 | * @napi : Add support NAPI for Rx | ||
126 | * @rx_irq_name: The textual name of the RX IRQ from the platform data | 129 | * @rx_irq_name: The textual name of the RX IRQ from the platform data |
127 | * @tx_irq_name: The textual name of the TX IRQ from the platform data | 130 | * @tx_irq_name: The textual name of the TX IRQ from the platform data |
128 | * @link_irq_name: The textual name of the link IRQ from the | 131 | * @link_irq_name: The textual name of the link IRQ from the |
@@ -146,6 +149,7 @@ enum ks8695_dtype { | |||
146 | * @rx_ring_dma: The DMA mapped equivalent of rx_ring | 149 | * @rx_ring_dma: The DMA mapped equivalent of rx_ring |
147 | * @rx_buffers: The sk_buff mappings for the RX ring | 150 | * @rx_buffers: The sk_buff mappings for the RX ring |
148 | * @next_rx_desc_read: The next RX descriptor to read from on IRQ | 151 | * @next_rx_desc_read: The next RX descriptor to read from on IRQ |
152 | * @rx_lock: A lock to protect Rx irq function | ||
149 | * @msg_enable: The flags for which messages to emit | 153 | * @msg_enable: The flags for which messages to emit |
150 | */ | 154 | */ |
151 | struct ks8695_priv { | 155 | struct ks8695_priv { |
@@ -398,11 +402,30 @@ ks8695_tx_irq(int irq, void *dev_id) | |||
398 | } | 402 | } |
399 | 403 | ||
400 | /** | 404 | /** |
405 | * ks8695_get_rx_enable_bit - Get rx interrupt enable/status bit | ||
406 | * @ksp: Private data for the KS8695 Ethernet | ||
407 | * | ||
408 | * For KS8695 document: | ||
409 | * Interrupt Enable Register (offset 0xE204) | ||
410 | * Bit29 : WAN MAC Receive Interrupt Enable | ||
411 | * Bit16 : LAN MAC Receive Interrupt Enable | ||
412 | * Interrupt Status Register (Offset 0xF208) | ||
413 | * Bit29: WAN MAC Receive Status | ||
414 | * Bit16: LAN MAC Receive Status | ||
415 | * So, this Rx interrrupt enable/status bit number is equal | ||
416 | * as Rx IRQ number. | ||
417 | */ | ||
418 | static inline u32 ks8695_get_rx_enable_bit(struct ks8695_priv *ksp) | ||
419 | { | ||
420 | return ksp->rx_irq; | ||
421 | } | ||
422 | |||
423 | /** | ||
401 | * ks8695_rx_irq - Receive IRQ handler | 424 | * ks8695_rx_irq - Receive IRQ handler |
402 | * @irq: The IRQ which went off (ignored) | 425 | * @irq: The IRQ which went off (ignored) |
403 | * @dev_id: The net_device for the interrupt | 426 | * @dev_id: The net_device for the interrupt |
404 | * | 427 | * |
405 | * Use NAPI to receive packets. | 428 | * Inform NAPI that packet reception needs to be scheduled |
406 | */ | 429 | */ |
407 | 430 | ||
408 | static irqreturn_t | 431 | static irqreturn_t |
@@ -412,7 +435,7 @@ ks8695_rx_irq(int irq, void *dev_id) | |||
412 | struct ks8695_priv *ksp = netdev_priv(ndev); | 435 | struct ks8695_priv *ksp = netdev_priv(ndev); |
413 | unsigned long status; | 436 | unsigned long status; |
414 | 437 | ||
415 | unsigned long mask_bit = 1 << ksp->rx_irq; | 438 | unsigned long mask_bit = 1 << ks8695_get_rx_enable_bit(ksp); |
416 | 439 | ||
417 | spin_lock(&ksp->rx_lock); | 440 | spin_lock(&ksp->rx_lock); |
418 | 441 | ||
@@ -434,9 +457,15 @@ ks8695_rx_irq(int irq, void *dev_id) | |||
434 | return IRQ_HANDLED; | 457 | return IRQ_HANDLED; |
435 | } | 458 | } |
436 | 459 | ||
437 | static int ks8695_rx(struct net_device *ndev, int budget) | 460 | /** |
461 | * ks8695_rx - Receive packets called by NAPI poll method | ||
462 | * @ksp: Private data for the KS8695 Ethernet | ||
463 | * @budget: The max packets would be receive | ||
464 | */ | ||
465 | |||
466 | static int ks8695_rx(struct ks8695_priv *ksp, int budget) | ||
438 | { | 467 | { |
439 | struct ks8695_priv *ksp = netdev_priv(ndev); | 468 | struct net_device *ndev = ksp->ndev; |
440 | struct sk_buff *skb; | 469 | struct sk_buff *skb; |
441 | int buff_n; | 470 | int buff_n; |
442 | u32 flags; | 471 | u32 flags; |
@@ -526,20 +555,32 @@ rx_finished: | |||
526 | 555 | ||
527 | /* And refill the buffers */ | 556 | /* And refill the buffers */ |
528 | ks8695_refill_rxbuffers(ksp); | 557 | ks8695_refill_rxbuffers(ksp); |
558 | |||
559 | /* Kick the RX DMA engine, in case it became | ||
560 | * suspended */ | ||
561 | ks8695_writereg(ksp, KS8695_DRSC, 0); | ||
529 | } | 562 | } |
530 | return received; | 563 | return received; |
531 | } | 564 | } |
532 | 565 | ||
566 | |||
567 | /** | ||
568 | * ks8695_poll - Receive packet by NAPI poll method | ||
569 | * @ksp: Private data for the KS8695 Ethernet | ||
570 | * @budget: The remaining number packets for network subsystem | ||
571 | * | ||
572 | * Invoked by the network core when it requests for new | ||
573 | * packets from the driver | ||
574 | */ | ||
533 | static int ks8695_poll(struct napi_struct *napi, int budget) | 575 | static int ks8695_poll(struct napi_struct *napi, int budget) |
534 | { | 576 | { |
535 | struct ks8695_priv *ksp = container_of(napi, struct ks8695_priv, napi); | 577 | struct ks8695_priv *ksp = container_of(napi, struct ks8695_priv, napi); |
536 | struct net_device *dev = ksp->ndev; | 578 | unsigned long work_done; |
537 | unsigned long mask_bit = 1 << ksp->rx_irq; | ||
538 | unsigned long isr = readl(KS8695_IRQ_VA + KS8695_INTEN); | ||
539 | 579 | ||
540 | unsigned long work_done ; | 580 | unsigned long isr = readl(KS8695_IRQ_VA + KS8695_INTEN); |
581 | unsigned long mask_bit = 1 << ks8695_get_rx_enable_bit(ksp); | ||
541 | 582 | ||
542 | work_done = ks8695_rx(dev, budget); | 583 | work_done = ks8695_rx(ksp, budget); |
543 | 584 | ||
544 | if (work_done < budget) { | 585 | if (work_done < budget) { |
545 | unsigned long flags; | 586 | unsigned long flags; |
@@ -1302,6 +1343,7 @@ ks8695_stop(struct net_device *ndev) | |||
1302 | struct ks8695_priv *ksp = netdev_priv(ndev); | 1343 | struct ks8695_priv *ksp = netdev_priv(ndev); |
1303 | 1344 | ||
1304 | netif_stop_queue(ndev); | 1345 | netif_stop_queue(ndev); |
1346 | napi_disable(&ksp->napi); | ||
1305 | netif_carrier_off(ndev); | 1347 | netif_carrier_off(ndev); |
1306 | 1348 | ||
1307 | ks8695_shutdown(ksp); | 1349 | ks8695_shutdown(ksp); |
@@ -1336,6 +1378,7 @@ ks8695_open(struct net_device *ndev) | |||
1336 | return ret; | 1378 | return ret; |
1337 | } | 1379 | } |
1338 | 1380 | ||
1381 | napi_enable(&ksp->napi); | ||
1339 | netif_start_queue(ndev); | 1382 | netif_start_queue(ndev); |
1340 | 1383 | ||
1341 | return 0; | 1384 | return 0; |
@@ -1521,7 +1564,7 @@ ks8695_probe(struct platform_device *pdev) | |||
1521 | SET_ETHTOOL_OPS(ndev, &ks8695_ethtool_ops); | 1564 | SET_ETHTOOL_OPS(ndev, &ks8695_ethtool_ops); |
1522 | ndev->watchdog_timeo = msecs_to_jiffies(watchdog); | 1565 | ndev->watchdog_timeo = msecs_to_jiffies(watchdog); |
1523 | 1566 | ||
1524 | netif_napi_add(ndev, &ksp->napi, ks8695_poll, 64); | 1567 | netif_napi_add(ndev, &ksp->napi, ks8695_poll, NAPI_WEIGHT); |
1525 | 1568 | ||
1526 | /* Retrieve the default MAC addr from the chip. */ | 1569 | /* Retrieve the default MAC addr from the chip. */ |
1527 | /* The bootloader should have left it in there for us. */ | 1570 | /* The bootloader should have left it in there for us. */ |