]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ixgbe: Add FCoE DDP allocation failure counters to ethtool stats.
authorAmir Hanania <amir.hanania@intel.com>
Wed, 31 Aug 2011 02:07:55 +0000 (02:07 +0000)
committerJoe Jin <joe.jin@oracle.com>
Thu, 17 May 2012 14:19:10 +0000 (22:19 +0800)
Add 2 new counters to ethtool:
1. Count DDP allocation failure since we max the number of buffers
allowed in one DDP context.
2. Count DDP allocation failure since we max the number of buffers
allowed in one DDP context when we alloc an extra buffer.

(cherry picked from commit 7b859ebc0a69a7d142f705bd4a8e5720b810f718)
Signed-off-by: Amir Hanania <amir.hanania@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
drivers/net/ixgbe/ixgbe_ethtool.c
drivers/net/ixgbe/ixgbe_fcoe.c
drivers/net/ixgbe/ixgbe_fcoe.h
drivers/net/ixgbe/ixgbe_main.c
drivers/net/ixgbe/ixgbe_type.h

index 15a2146ad672796259f0d6c1d2209c9a349f98cb..76e645b902cec07aca3abfb1cd0d1d387b2321e7 100644 (file)
@@ -112,6 +112,8 @@ static struct ixgbe_stats ixgbe_gstrings_stats[] = {
        {"rx_fcoe_dropped", IXGBE_STAT(stats.fcoerpdc)},
        {"rx_fcoe_packets", IXGBE_STAT(stats.fcoeprc)},
        {"rx_fcoe_dwords", IXGBE_STAT(stats.fcoedwrc)},
+       {"fcoe_noddp", IXGBE_STAT(stats.fcoe_noddp)},
+       {"fcoe_noddp_ext_buff", IXGBE_STAT(stats.fcoe_noddp_ext_buff)},
        {"tx_fcoe_packets", IXGBE_STAT(stats.fcoeptc)},
        {"tx_fcoe_dwords", IXGBE_STAT(stats.fcoedwtc)},
 #endif /* IXGBE_FCOE */
index 323f4529992d072365c9f92294e1b6c9a873b020..df3b1be69d83c9106b2794b1b316d4fc7078cbb0 100644 (file)
@@ -145,6 +145,7 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,
        u32 fcbuff, fcdmarw, fcfltrw, fcrxctl;
        dma_addr_t addr = 0;
        struct pci_pool *pool;
+       unsigned int cpu;
 
        if (!netdev || !sgl)
                return 0;
@@ -182,7 +183,8 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,
        }
 
        /* alloc the udl from per cpu ddp pool */
-       pool = *per_cpu_ptr(fcoe->pool, get_cpu());
+       cpu = get_cpu();
+       pool = *per_cpu_ptr(fcoe->pool, cpu);
        ddp->udl = pci_pool_alloc(pool, GFP_ATOMIC, &ddp->udp);
        if (!ddp->udl) {
                e_err(drv, "failed allocated ddp context\n");
@@ -199,9 +201,7 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,
                while (len) {
                        /* max number of buffers allowed in one DDP context */
                        if (j >= IXGBE_BUFFCNT_MAX) {
-                               e_err(drv, "xid=%x:%d,%d,%d:addr=%llx "
-                                     "not enough descriptors\n",
-                                     xid, i, j, dmacount, (u64)addr);
+                               *per_cpu_ptr(fcoe->pcpu_noddp, cpu) += 1;
                                goto out_noddp_free;
                        }
 
@@ -241,12 +241,7 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,
         */
        if (lastsize == bufflen) {
                if (j >= IXGBE_BUFFCNT_MAX) {
-                       printk_once("Will NOT use DDP since there are not "
-                                   "enough user buffers. We need an  extra "
-                                   "buffer because lastsize is bufflen. "
-                                   "xid=%x:%d,%d,%d:addr=%llx\n",
-                                   xid, i, j, dmacount, (u64)addr);
-
+                       *per_cpu_ptr(fcoe->pcpu_noddp_ext_buff, cpu) += 1;
                        goto out_noddp_free;
                }
 
@@ -600,6 +595,7 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
        struct ixgbe_hw *hw = &adapter->hw;
        struct ixgbe_fcoe *fcoe = &adapter->fcoe;
        struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE];
+       unsigned int cpu;
 
        if (!fcoe->pool) {
                spin_lock_init(&fcoe->lock);
@@ -627,6 +623,24 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
                        e_err(drv, "failed to map extra DDP buffer\n");
                        goto out_extra_ddp_buffer;
                }
+
+               /* Alloc per cpu mem to count the ddp alloc failure number */
+               fcoe->pcpu_noddp = alloc_percpu(u64);
+               if (!fcoe->pcpu_noddp) {
+                       e_err(drv, "failed to alloc noddp counter\n");
+                       goto out_pcpu_noddp_alloc_fail;
+               }
+
+               fcoe->pcpu_noddp_ext_buff = alloc_percpu(u64);
+               if (!fcoe->pcpu_noddp_ext_buff) {
+                       e_err(drv, "failed to alloc noddp extra buff cnt\n");
+                       goto out_pcpu_noddp_extra_buff_alloc_fail;
+               }
+
+               for_each_possible_cpu(cpu) {
+                       *per_cpu_ptr(fcoe->pcpu_noddp, cpu) = 0;
+                       *per_cpu_ptr(fcoe->pcpu_noddp_ext_buff, cpu) = 0;
+               }
        }
 
        /* Enable L2 eth type filter for FCoE */
@@ -664,7 +678,13 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
        IXGBE_WRITE_REG(hw, IXGBE_FCRXCTRL, IXGBE_FCRXCTRL_FCCRCBO |
                        (FC_FCOE_VER << IXGBE_FCRXCTRL_FCOEVER_SHIFT));
        return;
-
+out_pcpu_noddp_extra_buff_alloc_fail:
+       free_percpu(fcoe->pcpu_noddp);
+out_pcpu_noddp_alloc_fail:
+       dma_unmap_single(&adapter->pdev->dev,
+                        fcoe->extra_ddp_buffer_dma,
+                        IXGBE_FCBUFF_MIN,
+                        DMA_FROM_DEVICE);
 out_extra_ddp_buffer:
        kfree(fcoe->extra_ddp_buffer);
 out_ddp_pools:
@@ -693,6 +713,8 @@ void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter)
                         fcoe->extra_ddp_buffer_dma,
                         IXGBE_FCBUFF_MIN,
                         DMA_FROM_DEVICE);
+       free_percpu(fcoe->pcpu_noddp);
+       free_percpu(fcoe->pcpu_noddp_ext_buff);
        kfree(fcoe->extra_ddp_buffer);
        ixgbe_fcoe_ddp_pools_free(fcoe);
 }
index 99de145e290dc8813703f0eb06e14945e211a48b..261fd62dda1861950e5a43bbe41c68665d5f214e 100644 (file)
@@ -73,6 +73,8 @@ struct ixgbe_fcoe {
        unsigned char *extra_ddp_buffer;
        dma_addr_t extra_ddp_buffer_dma;
        unsigned long mode;
+       u64 __percpu *pcpu_noddp;
+       u64 __percpu *pcpu_noddp_ext_buff;
 #ifdef CONFIG_IXGBE_DCB
        u8 up;
 #endif
index 21c1aeb7f42301513bfaf39f6692c4a63f2e609f..a6d602e66feba392491bdcda46213200b19d9b20 100644 (file)
@@ -5551,6 +5551,11 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
        u64 non_eop_descs = 0, restart_queue = 0, tx_busy = 0;
        u64 alloc_rx_page_failed = 0, alloc_rx_buff_failed = 0;
        u64 bytes = 0, packets = 0;
+#ifdef IXGBE_FCOE
+       struct ixgbe_fcoe *fcoe = &adapter->fcoe;
+       unsigned int cpu;
+       u64 fcoe_noddp_counts_sum = 0, fcoe_noddp_ext_buff_counts_sum = 0;
+#endif /* IXGBE_FCOE */
 
        if (test_bit(__IXGBE_DOWN, &adapter->state) ||
            test_bit(__IXGBE_RESETTING, &adapter->state))
@@ -5678,6 +5683,18 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
                hwstats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
                hwstats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
                hwstats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
+               /* Add up per cpu counters for total ddp aloc fail */
+               if (fcoe->pcpu_noddp && fcoe->pcpu_noddp_ext_buff) {
+                       for_each_possible_cpu(cpu) {
+                               fcoe_noddp_counts_sum +=
+                                       *per_cpu_ptr(fcoe->pcpu_noddp, cpu);
+                               fcoe_noddp_ext_buff_counts_sum +=
+                                       *per_cpu_ptr(fcoe->
+                                               pcpu_noddp_ext_buff, cpu);
+                       }
+               }
+               hwstats->fcoe_noddp = fcoe_noddp_counts_sum;
+               hwstats->fcoe_noddp_ext_buff = fcoe_noddp_ext_buff_counts_sum;
 #endif /* IXGBE_FCOE */
                break;
        default:
index fbb5f1220f348c4a1172d94be328c53333d43130..242643a69b3f7cfc915373fce2ac47fe712ff1e7 100644 (file)
@@ -2680,6 +2680,8 @@ struct ixgbe_hw_stats {
        u64 fcoeptc;
        u64 fcoedwrc;
        u64 fcoedwtc;
+       u64 fcoe_noddp;
+       u64 fcoe_noddp_ext_buff;
        u64 b2ospc;
        u64 b2ogprc;
        u64 o2bgptc;