aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/qmgr.h35
-rw-r--r--arch/arm/mach-ixp4xx/ixp4xx_qmgr.c41
-rw-r--r--drivers/net/arm/ixp4xx_eth.c55
-rw-r--r--drivers/net/wan/ixp4xx_hss.c54
4 files changed, 85 insertions, 100 deletions
diff --git a/arch/arm/mach-ixp4xx/include/mach/qmgr.h b/arch/arm/mach-ixp4xx/include/mach/qmgr.h
index 1e52b95cede5..0cbe6ceb67c5 100644
--- a/arch/arm/mach-ixp4xx/include/mach/qmgr.h
+++ b/arch/arm/mach-ixp4xx/include/mach/qmgr.h
@@ -12,6 +12,8 @@
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14 14
15#define DEBUG_QMGR 0
16
15#define HALF_QUEUES 32 17#define HALF_QUEUES 32
16#define QUEUES 64 /* only 32 lower queues currently supported */ 18#define QUEUES 64 /* only 32 lower queues currently supported */
17#define MAX_QUEUE_LENGTH 4 /* in dwords */ 19#define MAX_QUEUE_LENGTH 4 /* in dwords */
@@ -61,22 +63,51 @@ void qmgr_enable_irq(unsigned int queue);
61void qmgr_disable_irq(unsigned int queue); 63void qmgr_disable_irq(unsigned int queue);
62 64
63/* request_ and release_queue() must be called from non-IRQ context */ 65/* request_ and release_queue() must be called from non-IRQ context */
66
67#if DEBUG_QMGR
68extern char qmgr_queue_descs[QUEUES][32];
69
64int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, 70int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
65 unsigned int nearly_empty_watermark, 71 unsigned int nearly_empty_watermark,
66 unsigned int nearly_full_watermark); 72 unsigned int nearly_full_watermark,
73 const char *desc_format, const char* name);
74#else
75int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
76 unsigned int nearly_empty_watermark,
77 unsigned int nearly_full_watermark);
78#define qmgr_request_queue(queue, len, nearly_empty_watermark, \
79 nearly_full_watermark, desc_format, name) \
80 __qmgr_request_queue(queue, len, nearly_empty_watermark, \
81 nearly_full_watermark)
82#endif
83
67void qmgr_release_queue(unsigned int queue); 84void qmgr_release_queue(unsigned int queue);
68 85
69 86
70static inline void qmgr_put_entry(unsigned int queue, u32 val) 87static inline void qmgr_put_entry(unsigned int queue, u32 val)
71{ 88{
72 extern struct qmgr_regs __iomem *qmgr_regs; 89 extern struct qmgr_regs __iomem *qmgr_regs;
90#if DEBUG_QMGR
91 BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */
92
93 printk(KERN_DEBUG "Queue %s(%i) put %X\n",
94 qmgr_queue_descs[queue], queue, val);
95#endif
73 __raw_writel(val, &qmgr_regs->acc[queue][0]); 96 __raw_writel(val, &qmgr_regs->acc[queue][0]);
74} 97}
75 98
76static inline u32 qmgr_get_entry(unsigned int queue) 99static inline u32 qmgr_get_entry(unsigned int queue)
77{ 100{
101 u32 val;
78 extern struct qmgr_regs __iomem *qmgr_regs; 102 extern struct qmgr_regs __iomem *qmgr_regs;
79 return __raw_readl(&qmgr_regs->acc[queue][0]); 103 val = __raw_readl(&qmgr_regs->acc[queue][0]);
104#if DEBUG_QMGR
105 BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */
106
107 printk(KERN_DEBUG "Queue %s(%i) get %X\n",
108 qmgr_queue_descs[queue], queue, val);
109#endif
110 return val;
80} 111}
81 112
82static inline int qmgr_get_stat1(unsigned int queue) 113static inline int qmgr_get_stat1(unsigned int queue)
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
index 444c2ae21db4..bfddc73d0a20 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
@@ -14,8 +14,6 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <mach/qmgr.h> 15#include <mach/qmgr.h>
16 16
17#define DEBUG 0
18
19struct qmgr_regs __iomem *qmgr_regs; 17struct qmgr_regs __iomem *qmgr_regs;
20static struct resource *mem_res; 18static struct resource *mem_res;
21static spinlock_t qmgr_lock; 19static spinlock_t qmgr_lock;
@@ -23,6 +21,10 @@ static u32 used_sram_bitmap[4]; /* 128 16-dword pages */
23static void (*irq_handlers[HALF_QUEUES])(void *pdev); 21static void (*irq_handlers[HALF_QUEUES])(void *pdev);
24static void *irq_pdevs[HALF_QUEUES]; 22static void *irq_pdevs[HALF_QUEUES];
25 23
24#if DEBUG_QMGR
25char qmgr_queue_descs[QUEUES][32];
26#endif
27
26void qmgr_set_irq(unsigned int queue, int src, 28void qmgr_set_irq(unsigned int queue, int src,
27 void (*handler)(void *pdev), void *pdev) 29 void (*handler)(void *pdev), void *pdev)
28{ 30{
@@ -82,9 +84,16 @@ static inline void shift_mask(u32 *mask)
82 mask[0] <<= 1; 84 mask[0] <<= 1;
83} 85}
84 86
87#if DEBUG_QMGR
85int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, 88int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
86 unsigned int nearly_empty_watermark, 89 unsigned int nearly_empty_watermark,
87 unsigned int nearly_full_watermark) 90 unsigned int nearly_full_watermark,
91 const char *desc_format, const char* name)
92#else
93int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
94 unsigned int nearly_empty_watermark,
95 unsigned int nearly_full_watermark)
96#endif
88{ 97{
89 u32 cfg, addr = 0, mask[4]; /* in 16-dwords */ 98 u32 cfg, addr = 0, mask[4]; /* in 16-dwords */
90 int err; 99 int err;
@@ -152,12 +161,13 @@ int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
152 used_sram_bitmap[2] |= mask[2]; 161 used_sram_bitmap[2] |= mask[2];
153 used_sram_bitmap[3] |= mask[3]; 162 used_sram_bitmap[3] |= mask[3];
154 __raw_writel(cfg | (addr << 14), &qmgr_regs->sram[queue]); 163 __raw_writel(cfg | (addr << 14), &qmgr_regs->sram[queue]);
155 spin_unlock_irq(&qmgr_lock); 164#if DEBUG_QMGR
156 165 snprintf(qmgr_queue_descs[queue], sizeof(qmgr_queue_descs[0]),
157#if DEBUG 166 desc_format, name);
158 printk(KERN_DEBUG "qmgr: requested queue %i, addr = 0x%02X\n", 167 printk(KERN_DEBUG "qmgr: requested queue %s(%i) addr = 0x%02X\n",
159 queue, addr); 168 qmgr_queue_descs[queue], queue, addr);
160#endif 169#endif
170 spin_unlock_irq(&qmgr_lock);
161 return 0; 171 return 0;
162 172
163err: 173err:
@@ -190,6 +200,11 @@ void qmgr_release_queue(unsigned int queue)
190 while (addr--) 200 while (addr--)
191 shift_mask(mask); 201 shift_mask(mask);
192 202
203#if DEBUG_QMGR
204 printk(KERN_DEBUG "qmgr: releasing queue %s(%i)\n",
205 qmgr_queue_descs[queue], queue);
206 qmgr_queue_descs[queue][0] = '\x0';
207#endif
193 __raw_writel(0, &qmgr_regs->sram[queue]); 208 __raw_writel(0, &qmgr_regs->sram[queue]);
194 209
195 used_sram_bitmap[0] &= ~mask[0]; 210 used_sram_bitmap[0] &= ~mask[0];
@@ -202,11 +217,8 @@ void qmgr_release_queue(unsigned int queue)
202 module_put(THIS_MODULE); 217 module_put(THIS_MODULE);
203 218
204 while ((addr = qmgr_get_entry(queue))) 219 while ((addr = qmgr_get_entry(queue)))
205 printk(KERN_ERR "qmgr: released queue %d not empty: 0x%08X\n", 220 printk(KERN_ERR "qmgr: released queue %i not empty: 0x%08X\n",
206 queue, addr); 221 queue, addr);
207#if DEBUG
208 printk(KERN_DEBUG "qmgr: released queue %i\n", queue);
209#endif
210} 222}
211 223
212static int qmgr_init(void) 224static int qmgr_init(void)
@@ -277,5 +289,10 @@ EXPORT_SYMBOL(qmgr_regs);
277EXPORT_SYMBOL(qmgr_set_irq); 289EXPORT_SYMBOL(qmgr_set_irq);
278EXPORT_SYMBOL(qmgr_enable_irq); 290EXPORT_SYMBOL(qmgr_enable_irq);
279EXPORT_SYMBOL(qmgr_disable_irq); 291EXPORT_SYMBOL(qmgr_disable_irq);
292#if DEBUG_QMGR
293EXPORT_SYMBOL(qmgr_queue_descs);
280EXPORT_SYMBOL(qmgr_request_queue); 294EXPORT_SYMBOL(qmgr_request_queue);
295#else
296EXPORT_SYMBOL(__qmgr_request_queue);
297#endif
281EXPORT_SYMBOL(qmgr_release_queue); 298EXPORT_SYMBOL(qmgr_release_queue);
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
index 3f72eb66e7f1..64adf6cc1221 100644
--- a/drivers/net/arm/ixp4xx_eth.c
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -35,7 +35,6 @@
35#include <mach/npe.h> 35#include <mach/npe.h>
36#include <mach/qmgr.h> 36#include <mach/qmgr.h>
37 37
38#define DEBUG_QUEUES 0
39#define DEBUG_DESC 0 38#define DEBUG_DESC 0
40#define DEBUG_RX 0 39#define DEBUG_RX 0
41#define DEBUG_TX 0 40#define DEBUG_TX 0
@@ -423,47 +422,13 @@ static inline void debug_desc(u32 phys, struct desc *desc)
423#endif 422#endif
424} 423}
425 424
426static inline void debug_queue(unsigned int queue, int is_get, u32 phys)
427{
428#if DEBUG_QUEUES
429 static struct {
430 int queue;
431 char *name;
432 } names[] = {
433 { TX_QUEUE(0x10), "TX#0 " },
434 { TX_QUEUE(0x20), "TX#1 " },
435 { TX_QUEUE(0x00), "TX#2 " },
436 { RXFREE_QUEUE(0x10), "RX-free#0 " },
437 { RXFREE_QUEUE(0x20), "RX-free#1 " },
438 { RXFREE_QUEUE(0x00), "RX-free#2 " },
439 { TXDONE_QUEUE, "TX-done " },
440 };
441 int i;
442
443 for (i = 0; i < ARRAY_SIZE(names); i++)
444 if (names[i].queue == queue)
445 break;
446
447 printk(KERN_DEBUG "Queue %i %s%s %X\n", queue,
448 i < ARRAY_SIZE(names) ? names[i].name : "",
449 is_get ? "->" : "<-", phys);
450#endif
451}
452
453static inline u32 queue_get_entry(unsigned int queue)
454{
455 u32 phys = qmgr_get_entry(queue);
456 debug_queue(queue, 1, phys);
457 return phys;
458}
459
460static inline int queue_get_desc(unsigned int queue, struct port *port, 425static inline int queue_get_desc(unsigned int queue, struct port *port,
461 int is_tx) 426 int is_tx)
462{ 427{
463 u32 phys, tab_phys, n_desc; 428 u32 phys, tab_phys, n_desc;
464 struct desc *tab; 429 struct desc *tab;
465 430
466 if (!(phys = queue_get_entry(queue))) 431 if (!(phys = qmgr_get_entry(queue)))
467 return -1; 432 return -1;
468 433
469 phys &= ~0x1F; /* mask out non-address bits */ 434 phys &= ~0x1F; /* mask out non-address bits */
@@ -479,7 +444,6 @@ static inline int queue_get_desc(unsigned int queue, struct port *port,
479static inline void queue_put_desc(unsigned int queue, u32 phys, 444static inline void queue_put_desc(unsigned int queue, u32 phys,
480 struct desc *desc) 445 struct desc *desc)
481{ 446{
482 debug_queue(queue, 0, phys);
483 debug_desc(phys, desc); 447 debug_desc(phys, desc);
484 BUG_ON(phys & 0x1F); 448 BUG_ON(phys & 0x1F);
485 qmgr_put_entry(queue, phys); 449 qmgr_put_entry(queue, phys);
@@ -628,7 +592,7 @@ static void eth_txdone_irq(void *unused)
628#if DEBUG_TX 592#if DEBUG_TX
629 printk(KERN_DEBUG DRV_NAME ": eth_txdone_irq\n"); 593 printk(KERN_DEBUG DRV_NAME ": eth_txdone_irq\n");
630#endif 594#endif
631 while ((phys = queue_get_entry(TXDONE_QUEUE)) != 0) { 595 while ((phys = qmgr_get_entry(TXDONE_QUEUE)) != 0) {
632 u32 npe_id, n_desc; 596 u32 npe_id, n_desc;
633 struct port *port; 597 struct port *port;
634 struct desc *desc; 598 struct desc *desc;
@@ -840,25 +804,30 @@ static int request_queues(struct port *port)
840{ 804{
841 int err; 805 int err;
842 806
843 err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0); 807 err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0,
808 "%s:RX-free", port->netdev->name);
844 if (err) 809 if (err)
845 return err; 810 return err;
846 811
847 err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0); 812 err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0,
813 "%s:RX", port->netdev->name);
848 if (err) 814 if (err)
849 goto rel_rxfree; 815 goto rel_rxfree;
850 816
851 err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0); 817 err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0,
818 "%s:TX", port->netdev->name);
852 if (err) 819 if (err)
853 goto rel_rx; 820 goto rel_rx;
854 821
855 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0); 822 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0,
823 "%s:TX-ready", port->netdev->name);
856 if (err) 824 if (err)
857 goto rel_tx; 825 goto rel_tx;
858 826
859 /* TX-done queue handles skbs sent out by the NPEs */ 827 /* TX-done queue handles skbs sent out by the NPEs */
860 if (!ports_open) { 828 if (!ports_open) {
861 err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0); 829 err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0,
830 "%s:TX-done", DRV_NAME);
862 if (err) 831 if (err)
863 goto rel_txready; 832 goto rel_txready;
864 } 833 }
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index fa3ce81f4cfc..0c6802507a79 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -21,7 +21,6 @@
21#include <mach/npe.h> 21#include <mach/npe.h>
22#include <mach/qmgr.h> 22#include <mach/qmgr.h>
23 23
24#define DEBUG_QUEUES 0
25#define DEBUG_DESC 0 24#define DEBUG_DESC 0
26#define DEBUG_RX 0 25#define DEBUG_RX 0
27#define DEBUG_TX 0 26#define DEBUG_TX 0
@@ -555,48 +554,13 @@ static inline void debug_desc(u32 phys, struct desc *desc)
555#endif 554#endif
556} 555}
557 556
558static inline void debug_queue(unsigned int queue, int is_get, u32 phys)
559{
560#if DEBUG_QUEUES
561 static struct {
562 int queue;
563 char *name;
564 } names[] = {
565 { HSS0_PKT_TX0_QUEUE, "TX#0 " },
566 { HSS0_PKT_TXDONE_QUEUE, "TX-done#0 " },
567 { HSS0_PKT_RX_QUEUE, "RX#0 " },
568 { HSS0_PKT_RXFREE0_QUEUE, "RX-free#0 " },
569 { HSS1_PKT_TX0_QUEUE, "TX#1 " },
570 { HSS1_PKT_TXDONE_QUEUE, "TX-done#1 " },
571 { HSS1_PKT_RX_QUEUE, "RX#1 " },
572 { HSS1_PKT_RXFREE0_QUEUE, "RX-free#1 " },
573 };
574 int i;
575
576 for (i = 0; i < ARRAY_SIZE(names); i++)
577 if (names[i].queue == queue)
578 break;
579
580 printk(KERN_DEBUG "Queue %i %s%s %X\n", queue,
581 i < ARRAY_SIZE(names) ? names[i].name : "",
582 is_get ? "->" : "<-", phys);
583#endif
584}
585
586static inline u32 queue_get_entry(unsigned int queue)
587{
588 u32 phys = qmgr_get_entry(queue);
589 debug_queue(queue, 1, phys);
590 return phys;
591}
592
593static inline int queue_get_desc(unsigned int queue, struct port *port, 557static inline int queue_get_desc(unsigned int queue, struct port *port,
594 int is_tx) 558 int is_tx)
595{ 559{
596 u32 phys, tab_phys, n_desc; 560 u32 phys, tab_phys, n_desc;
597 struct desc *tab; 561 struct desc *tab;
598 562
599 if (!(phys = queue_get_entry(queue))) 563 if (!(phys = qmgr_get_entry(queue)))
600 return -1; 564 return -1;
601 565
602 BUG_ON(phys & 0x1F); 566 BUG_ON(phys & 0x1F);
@@ -612,7 +576,6 @@ static inline int queue_get_desc(unsigned int queue, struct port *port,
612static inline void queue_put_desc(unsigned int queue, u32 phys, 576static inline void queue_put_desc(unsigned int queue, u32 phys,
613 struct desc *desc) 577 struct desc *desc)
614{ 578{
615 debug_queue(queue, 0, phys);
616 debug_desc(phys, desc); 579 debug_desc(phys, desc);
617 BUG_ON(phys & 0x1F); 580 BUG_ON(phys & 0x1F);
618 qmgr_put_entry(queue, phys); 581 qmgr_put_entry(queue, phys);
@@ -930,23 +893,28 @@ static int request_hdlc_queues(struct port *port)
930{ 893{
931 int err; 894 int err;
932 895
933 err = qmgr_request_queue(queue_ids[port->id].rxfree, RX_DESCS, 0, 0); 896 err = qmgr_request_queue(queue_ids[port->id].rxfree, RX_DESCS, 0, 0,
897 "%s:RX-free", port->netdev->name);
934 if (err) 898 if (err)
935 return err; 899 return err;
936 900
937 err = qmgr_request_queue(queue_ids[port->id].rx, RX_DESCS, 0, 0); 901 err = qmgr_request_queue(queue_ids[port->id].rx, RX_DESCS, 0, 0,
902 "%s:RX", port->netdev->name);
938 if (err) 903 if (err)
939 goto rel_rxfree; 904 goto rel_rxfree;
940 905
941 err = qmgr_request_queue(queue_ids[port->id].tx, TX_DESCS, 0, 0); 906 err = qmgr_request_queue(queue_ids[port->id].tx, TX_DESCS, 0, 0,
907 "%s:TX", port->netdev->name);
942 if (err) 908 if (err)
943 goto rel_rx; 909 goto rel_rx;
944 910
945 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0); 911 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0,
912 "%s:TX-ready", port->netdev->name);
946 if (err) 913 if (err)
947 goto rel_tx; 914 goto rel_tx;
948 915
949 err = qmgr_request_queue(queue_ids[port->id].txdone, TX_DESCS, 0, 0); 916 err = qmgr_request_queue(queue_ids[port->id].txdone, TX_DESCS, 0, 0,
917 "%s:TX-done", port->netdev->name);
950 if (err) 918 if (err)
951 goto rel_txready; 919 goto rel_txready;
952 return 0; 920 return 0;