ag71xx: Switch from driver to kernel macro for NAPI_WEIGHT.
[openwrt/staging/chunkeey.git] / target / linux / ar71xx / files / drivers / net / ethernet / atheros / ag71xx / ag71xx_debugfs.c
index 757a572b0096ac8342e0b7c30925c3ca29c0eea1..89cea0c0f5ae97c9917cd13e1ee89bd31fe45e58 100644 (file)
@@ -78,7 +78,7 @@ void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag, int rx, int tx)
        if (rx) {
                stats->rx_count++;
                stats->rx_packets += rx;
-               if (rx <= AG71XX_NAPI_WEIGHT)
+               if (rx <= NAPI_POLL_WEIGHT)
                        stats->rx[rx]++;
                if (rx > stats->rx_packets_max)
                        stats->rx_packets_max = rx;
@@ -87,7 +87,7 @@ void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag, int rx, int tx)
        if (tx) {
                stats->tx_count++;
                stats->tx_packets += tx;
-               if (tx <= AG71XX_NAPI_WEIGHT)
+               if (tx <= NAPI_POLL_WEIGHT)
                        stats->tx[tx]++;
                if (tx > stats->tx_packets_max)
                        stats->tx_packets_max = tx;
@@ -121,7 +121,7 @@ static ssize_t read_file_napi_stats(struct file *file, char __user *user_buf,
        len += snprintf(buf + len, buflen - len, "%3s  %10s %10s\n",
                        "len", "rx", "tx");
 
-       for (i = 1; i <= AG71XX_NAPI_WEIGHT; i++)
+       for (i = 1; i <= NAPI_POLL_WEIGHT; i++)
                len += snprintf(buf + len, buflen - len,
                                "%3d: %10lu %10lu\n",
                                i, stats->rx[i], stats->tx[i]);
@@ -157,6 +157,8 @@ static ssize_t read_file_ring(struct file *file, char __user *user_buf,
                              struct ag71xx_ring *ring,
                              unsigned desc_reg)
 {
+       int ring_size = BIT(ring->order);
+       int ring_mask = ring_size - 1;
        char *buf;
        unsigned int buflen;
        unsigned int len = 0;
@@ -167,7 +169,7 @@ static ssize_t read_file_ring(struct file *file, char __user *user_buf,
        u32 desc_hw;
        int i;
 
-       buflen = (ring->size * DESC_PRINT_LEN);
+       buflen = (ring_size * DESC_PRINT_LEN);
        buf = kmalloc(buflen, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
@@ -178,12 +180,13 @@ static ssize_t read_file_ring(struct file *file, char __user *user_buf,
 
        spin_lock_irqsave(&ag->lock, flags);
 
-       curr = (ring->curr % ring->size);
-       dirty = (ring->dirty % ring->size);
+       curr = (ring->curr & ring_mask);
+       dirty = (ring->dirty & ring_mask);
        desc_hw = ag71xx_rr(ag, desc_reg);
-       for (i = 0; i < ring->size; i++) {
+       for (i = 0; i < ring_size; i++) {
                struct ag71xx_buf *ab = &ring->buf[i];
-               u32 desc_dma = ((u32) ring->descs_dma) + i * ring->desc_size;
+               struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
+               u32 desc_dma = ((u32) ring->descs_dma) + i * AG71XX_DESC_SIZE;
 
                len += snprintf(buf + len, buflen - len,
                        "%3d %c%c%c %08x %08x %08x %08x %c %10lu\n",
@@ -192,10 +195,10 @@ static ssize_t read_file_ring(struct file *file, char __user *user_buf,
                        (i == dirty) ? 'D' : ' ',
                        (desc_hw == desc_dma) ? 'H' : ' ',
                        desc_dma,
-                       ab->desc->next,
-                       ab->desc->data,
-                       ab->desc->ctrl,
-                       (ab->desc->ctrl & DESC_EMPTY) ? 'E' : '*',
+                       desc->next,
+                       desc->data,
+                       desc->ctrl,
+                       (desc->ctrl & DESC_EMPTY) ? 'E' : '*',
                        ab->timestamp);
        }