IXP4xx: move common debugging from network drivers to QMGR module.
authorKrzysztof Hałasa <khc@pm.waw.pl>
Sun, 21 Dec 2008 23:26:38 +0000 (00:26 +0100)
committerKrzysztof Hałasa <khc@pm.waw.pl>
Sun, 21 Dec 2008 23:48:00 +0000 (00:48 +0100)
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
arch/arm/mach-ixp4xx/include/mach/qmgr.h
arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
drivers/net/arm/ixp4xx_eth.c
drivers/net/wan/ixp4xx_hss.c

index 1e52b95cede5518db0b73630cf65d2bc46f82315..0cbe6ceb67c5a012837221f8e9a95509689dea94 100644 (file)
@@ -12,6 +12,8 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 
+#define DEBUG_QMGR     0
+
 #define HALF_QUEUES    32
 #define QUEUES         64      /* only 32 lower queues currently supported */
 #define MAX_QUEUE_LENGTH 4     /* in dwords */
@@ -61,22 +63,51 @@ void qmgr_enable_irq(unsigned int queue);
 void qmgr_disable_irq(unsigned int queue);
 
 /* request_ and release_queue() must be called from non-IRQ context */
+
+#if DEBUG_QMGR
+extern char qmgr_queue_descs[QUEUES][32];
+
 int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
                       unsigned int nearly_empty_watermark,
-                      unsigned int nearly_full_watermark);
+                      unsigned int nearly_full_watermark,
+                      const char *desc_format, const char* name);
+#else
+int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
+                        unsigned int nearly_empty_watermark,
+                        unsigned int nearly_full_watermark);
+#define qmgr_request_queue(queue, len, nearly_empty_watermark,         \
+                          nearly_full_watermark, desc_format, name)    \
+       __qmgr_request_queue(queue, len, nearly_empty_watermark,        \
+                            nearly_full_watermark)
+#endif
+
 void qmgr_release_queue(unsigned int queue);
 
 
 static inline void qmgr_put_entry(unsigned int queue, u32 val)
 {
        extern struct qmgr_regs __iomem *qmgr_regs;
+#if DEBUG_QMGR
+       BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */
+
+       printk(KERN_DEBUG "Queue %s(%i) put %X\n",
+              qmgr_queue_descs[queue], queue, val);
+#endif
        __raw_writel(val, &qmgr_regs->acc[queue][0]);
 }
 
 static inline u32 qmgr_get_entry(unsigned int queue)
 {
+       u32 val;
        extern struct qmgr_regs __iomem *qmgr_regs;
-       return __raw_readl(&qmgr_regs->acc[queue][0]);
+       val = __raw_readl(&qmgr_regs->acc[queue][0]);
+#if DEBUG_QMGR
+       BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */
+
+       printk(KERN_DEBUG "Queue %s(%i) get %X\n",
+              qmgr_queue_descs[queue], queue, val);
+#endif
+       return val;
 }
 
 static inline int qmgr_get_stat1(unsigned int queue)
index 444c2ae21db4a910026dd5013ffce8f9213e679c..bfddc73d0a200b358b80761891106e5237b22799 100644 (file)
@@ -14,8 +14,6 @@
 #include <linux/module.h>
 #include <mach/qmgr.h>
 
-#define DEBUG          0
-
 struct qmgr_regs __iomem *qmgr_regs;
 static struct resource *mem_res;
 static spinlock_t qmgr_lock;
@@ -23,6 +21,10 @@ static u32 used_sram_bitmap[4]; /* 128 16-dword pages */
 static void (*irq_handlers[HALF_QUEUES])(void *pdev);
 static void *irq_pdevs[HALF_QUEUES];
 
+#if DEBUG_QMGR
+char qmgr_queue_descs[QUEUES][32];
+#endif
+
 void qmgr_set_irq(unsigned int queue, int src,
                  void (*handler)(void *pdev), void *pdev)
 {
@@ -82,9 +84,16 @@ static inline void shift_mask(u32 *mask)
        mask[0] <<= 1;
 }
 
+#if DEBUG_QMGR
 int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
                       unsigned int nearly_empty_watermark,
-                      unsigned int nearly_full_watermark)
+                      unsigned int nearly_full_watermark,
+                      const char *desc_format, const char* name)
+#else
+int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
+                        unsigned int nearly_empty_watermark,
+                        unsigned int nearly_full_watermark)
+#endif
 {
        u32 cfg, addr = 0, mask[4]; /* in 16-dwords */
        int err;
@@ -152,12 +161,13 @@ int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
        used_sram_bitmap[2] |= mask[2];
        used_sram_bitmap[3] |= mask[3];
        __raw_writel(cfg | (addr << 14), &qmgr_regs->sram[queue]);
-       spin_unlock_irq(&qmgr_lock);
-
-#if DEBUG
-       printk(KERN_DEBUG "qmgr: requested queue %i, addr = 0x%02X\n",
-              queue, addr);
+#if DEBUG_QMGR
+       snprintf(qmgr_queue_descs[queue], sizeof(qmgr_queue_descs[0]),
+                desc_format, name);
+       printk(KERN_DEBUG "qmgr: requested queue %s(%i) addr = 0x%02X\n",
+              qmgr_queue_descs[queue], queue, addr);
 #endif
+       spin_unlock_irq(&qmgr_lock);
        return 0;
 
 err:
@@ -190,6 +200,11 @@ void qmgr_release_queue(unsigned int queue)
        while (addr--)
                shift_mask(mask);
 
+#if DEBUG_QMGR
+       printk(KERN_DEBUG "qmgr: releasing queue %s(%i)\n",
+              qmgr_queue_descs[queue], queue);
+       qmgr_queue_descs[queue][0] = '\x0';
+#endif
        __raw_writel(0, &qmgr_regs->sram[queue]);
 
        used_sram_bitmap[0] &= ~mask[0];
@@ -202,11 +217,8 @@ void qmgr_release_queue(unsigned int queue)
        module_put(THIS_MODULE);
 
        while ((addr = qmgr_get_entry(queue)))
-               printk(KERN_ERR "qmgr: released queue %d not empty: 0x%08X\n",
+               printk(KERN_ERR "qmgr: released queue %i not empty: 0x%08X\n",
                       queue, addr);
-#if DEBUG
-       printk(KERN_DEBUG "qmgr: released queue %i\n", queue);
-#endif
 }
 
 static int qmgr_init(void)
@@ -277,5 +289,10 @@ EXPORT_SYMBOL(qmgr_regs);
 EXPORT_SYMBOL(qmgr_set_irq);
 EXPORT_SYMBOL(qmgr_enable_irq);
 EXPORT_SYMBOL(qmgr_disable_irq);
+#if DEBUG_QMGR
+EXPORT_SYMBOL(qmgr_queue_descs);
 EXPORT_SYMBOL(qmgr_request_queue);
+#else
+EXPORT_SYMBOL(__qmgr_request_queue);
+#endif
 EXPORT_SYMBOL(qmgr_release_queue);
index 3f72eb66e7f1652efd4a594ba942a5b8bcbf091c..64adf6cc1221bbb1093fba9f1839935e84723694 100644 (file)
@@ -35,7 +35,6 @@
 #include <mach/npe.h>
 #include <mach/qmgr.h>
 
-#define DEBUG_QUEUES           0
 #define DEBUG_DESC             0
 #define DEBUG_RX               0
 #define DEBUG_TX               0
@@ -423,47 +422,13 @@ static inline void debug_desc(u32 phys, struct desc *desc)
 #endif
 }
 
-static inline void debug_queue(unsigned int queue, int is_get, u32 phys)
-{
-#if DEBUG_QUEUES
-       static struct {
-               int queue;
-               char *name;
-       } names[] = {
-               { TX_QUEUE(0x10), "TX#0 " },
-               { TX_QUEUE(0x20), "TX#1 " },
-               { TX_QUEUE(0x00), "TX#2 " },
-               { RXFREE_QUEUE(0x10), "RX-free#0 " },
-               { RXFREE_QUEUE(0x20), "RX-free#1 " },
-               { RXFREE_QUEUE(0x00), "RX-free#2 " },
-               { TXDONE_QUEUE, "TX-done " },
-       };
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(names); i++)
-               if (names[i].queue == queue)
-                       break;
-
-       printk(KERN_DEBUG "Queue %i %s%s %X\n", queue,
-              i < ARRAY_SIZE(names) ? names[i].name : "",
-              is_get ? "->" : "<-", phys);
-#endif
-}
-
-static inline u32 queue_get_entry(unsigned int queue)
-{
-       u32 phys = qmgr_get_entry(queue);
-       debug_queue(queue, 1, phys);
-       return phys;
-}
-
 static inline int queue_get_desc(unsigned int queue, struct port *port,
                                 int is_tx)
 {
        u32 phys, tab_phys, n_desc;
        struct desc *tab;
 
-       if (!(phys = queue_get_entry(queue)))
+       if (!(phys = qmgr_get_entry(queue)))
                return -1;
 
        phys &= ~0x1F; /* mask out non-address bits */
@@ -479,7 +444,6 @@ static inline int queue_get_desc(unsigned int queue, struct port *port,
 static inline void queue_put_desc(unsigned int queue, u32 phys,
                                  struct desc *desc)
 {
-       debug_queue(queue, 0, phys);
        debug_desc(phys, desc);
        BUG_ON(phys & 0x1F);
        qmgr_put_entry(queue, phys);
@@ -628,7 +592,7 @@ static void eth_txdone_irq(void *unused)
 #if DEBUG_TX
        printk(KERN_DEBUG DRV_NAME ": eth_txdone_irq\n");
 #endif
-       while ((phys = queue_get_entry(TXDONE_QUEUE)) != 0) {
+       while ((phys = qmgr_get_entry(TXDONE_QUEUE)) != 0) {
                u32 npe_id, n_desc;
                struct port *port;
                struct desc *desc;
@@ -840,25 +804,30 @@ static int request_queues(struct port *port)
 {
        int err;
 
-       err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0);
+       err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0,
+                           "%s:RX-free", port->netdev->name);
        if (err)
                return err;
 
-       err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0);
+       err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0,
+                           "%s:RX", port->netdev->name);
        if (err)
                goto rel_rxfree;
 
-       err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0);
+       err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0,
+                           "%s:TX", port->netdev->name);
        if (err)
                goto rel_rx;
 
-       err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0);
+       err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0,
+                           "%s:TX-ready", port->netdev->name);
        if (err)
                goto rel_tx;
 
        /* TX-done queue handles skbs sent out by the NPEs */
        if (!ports_open) {
-               err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0);
+               err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0,
+                                   "%s:TX-done", DRV_NAME);
                if (err)
                        goto rel_txready;
        }
index fa3ce81f4cfc608d57d819eb7d2b6544a6864ee0..0c6802507a79817840e36194a0ec49b0993adb73 100644 (file)
@@ -21,7 +21,6 @@
 #include <mach/npe.h>
 #include <mach/qmgr.h>
 
-#define DEBUG_QUEUES           0
 #define DEBUG_DESC             0
 #define DEBUG_RX               0
 #define DEBUG_TX               0
@@ -555,48 +554,13 @@ static inline void debug_desc(u32 phys, struct desc *desc)
 #endif
 }
 
-static inline void debug_queue(unsigned int queue, int is_get, u32 phys)
-{
-#if DEBUG_QUEUES
-       static struct {
-               int queue;
-               char *name;
-       } names[] = {
-               { HSS0_PKT_TX0_QUEUE, "TX#0 " },
-               { HSS0_PKT_TXDONE_QUEUE, "TX-done#0 " },
-               { HSS0_PKT_RX_QUEUE, "RX#0 " },
-               { HSS0_PKT_RXFREE0_QUEUE, "RX-free#0 " },
-               { HSS1_PKT_TX0_QUEUE, "TX#1 " },
-               { HSS1_PKT_TXDONE_QUEUE, "TX-done#1 " },
-               { HSS1_PKT_RX_QUEUE, "RX#1 " },
-               { HSS1_PKT_RXFREE0_QUEUE, "RX-free#1 " },
-       };
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(names); i++)
-               if (names[i].queue == queue)
-                       break;
-
-       printk(KERN_DEBUG "Queue %i %s%s %X\n", queue,
-              i < ARRAY_SIZE(names) ? names[i].name : "",
-              is_get ? "->" : "<-", phys);
-#endif
-}
-
-static inline u32 queue_get_entry(unsigned int queue)
-{
-       u32 phys = qmgr_get_entry(queue);
-       debug_queue(queue, 1, phys);
-       return phys;
-}
-
 static inline int queue_get_desc(unsigned int queue, struct port *port,
                                 int is_tx)
 {
        u32 phys, tab_phys, n_desc;
        struct desc *tab;
 
-       if (!(phys = queue_get_entry(queue)))
+       if (!(phys = qmgr_get_entry(queue)))
                return -1;
 
        BUG_ON(phys & 0x1F);
@@ -612,7 +576,6 @@ static inline int queue_get_desc(unsigned int queue, struct port *port,
 static inline void queue_put_desc(unsigned int queue, u32 phys,
                                  struct desc *desc)
 {
-       debug_queue(queue, 0, phys);
        debug_desc(phys, desc);
        BUG_ON(phys & 0x1F);
        qmgr_put_entry(queue, phys);
@@ -930,23 +893,28 @@ static int request_hdlc_queues(struct port *port)
 {
        int err;
 
-       err = qmgr_request_queue(queue_ids[port->id].rxfree, RX_DESCS, 0, 0);
+       err = qmgr_request_queue(queue_ids[port->id].rxfree, RX_DESCS, 0, 0,
+                                "%s:RX-free", port->netdev->name);
        if (err)
                return err;
 
-       err = qmgr_request_queue(queue_ids[port->id].rx, RX_DESCS, 0, 0);
+       err = qmgr_request_queue(queue_ids[port->id].rx, RX_DESCS, 0, 0,
+                                "%s:RX", port->netdev->name);
        if (err)
                goto rel_rxfree;
 
-       err = qmgr_request_queue(queue_ids[port->id].tx, TX_DESCS, 0, 0);
+       err = qmgr_request_queue(queue_ids[port->id].tx, TX_DESCS, 0, 0,
+                                "%s:TX", port->netdev->name);
        if (err)
                goto rel_rx;
 
-       err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0);
+       err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0,
+                                "%s:TX-ready", port->netdev->name);
        if (err)
                goto rel_tx;
 
-       err = qmgr_request_queue(queue_ids[port->id].txdone, TX_DESCS, 0, 0);
+       err = qmgr_request_queue(queue_ids[port->id].txdone, TX_DESCS, 0, 0,
+                                "%s:TX-done", port->netdev->name);
        if (err)
                goto rel_txready;
        return 0;