]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
qede: Add support for per-queue stats.
authorSudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Tue, 16 Aug 2016 14:51:02 +0000 (10:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 19 Aug 2016 04:11:45 +0000 (21:11 -0700)
Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qede/qede.h
drivers/net/ethernet/qlogic/qede/qede_ethtool.c
drivers/net/ethernet/qlogic/qede/qede_main.c

index 9060c2ad9d6220ea24a1699e9fcf4a21758f15a7..81a63cf0a9980a346b8181b7cab12e27e6627c4b 100644 (file)
@@ -237,6 +237,7 @@ struct qede_rx_queue {
        u16                     num_rx_buffers;
        u16                     rxq_id;
 
+       u64                     rcv_pkts;
        u64                     rx_hw_errors;
        u64                     rx_alloc_errors;
        u64                     rx_ip_frags;
@@ -265,6 +266,8 @@ struct qede_tx_queue {
        union db_prod           tx_db;
 
        u16                     num_tx_buffers;
+       u64                     xmit_pkts;
+       u64                     stopped_cnt;
 };
 
 #define BD_UNMAP_ADDR(bd)              HILO_U64(le32_to_cpu((bd)->addr.hi), \
index c035e3c2349d8ca98c8b9b859cf2fa8326cb9b96..6e17ee10e748e2ac1c425287e2738e698d962e55 100644 (file)
@@ -35,6 +35,7 @@ static const struct {
        u64 offset;
        char string[ETH_GSTRING_LEN];
 } qede_rqstats_arr[] = {
+       QEDE_RQSTAT(rcv_pkts),
        QEDE_RQSTAT(rx_hw_errors),
        QEDE_RQSTAT(rx_alloc_errors),
        QEDE_RQSTAT(rx_ip_frags),
@@ -44,6 +45,24 @@ static const struct {
 #define QEDE_RQSTATS_DATA(dev, sindex, rqindex) \
        (*((u64 *)(((char *)(dev->fp_array[(rqindex)].rxq)) +\
                    qede_rqstats_arr[(sindex)].offset)))
+#define QEDE_TQSTAT_OFFSET(stat_name) \
+       (offsetof(struct qede_tx_queue, stat_name))
+#define QEDE_TQSTAT_STRING(stat_name) (#stat_name)
+#define QEDE_TQSTAT(stat_name) \
+       {QEDE_TQSTAT_OFFSET(stat_name), QEDE_TQSTAT_STRING(stat_name)}
+#define QEDE_NUM_TQSTATS ARRAY_SIZE(qede_tqstats_arr)
+static const struct {
+       u64 offset;
+       char string[ETH_GSTRING_LEN];
+} qede_tqstats_arr[] = {
+       QEDE_TQSTAT(xmit_pkts),
+       QEDE_TQSTAT(stopped_cnt),
+};
+
+#define QEDE_TQSTATS_DATA(dev, sindex, tssid, tcid) \
+       (*((u64 *)(((u64)(&dev->fp_array[tssid].txqs[tcid])) +\
+                  qede_tqstats_arr[(sindex)].offset)))
+
 static const struct {
        u64 offset;
        char string[ETH_GSTRING_LEN];
@@ -153,17 +172,29 @@ static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
 {
        int i, j, k;
 
+       for (i = 0, k = 0; i < edev->num_rss; i++) {
+               int tc;
+
+               for (j = 0; j < QEDE_NUM_RQSTATS; j++)
+                       sprintf(buf + (k + j) * ETH_GSTRING_LEN,
+                               "%d:   %s", i, qede_rqstats_arr[j].string);
+               k += QEDE_NUM_RQSTATS;
+               for (tc = 0; tc < edev->num_tc; tc++) {
+                       for (j = 0; j < QEDE_NUM_TQSTATS; j++)
+                               sprintf(buf + (k + j) * ETH_GSTRING_LEN,
+                                       "%d.%d: %s", i, tc,
+                                       qede_tqstats_arr[j].string);
+                       k += QEDE_NUM_TQSTATS;
+               }
+       }
+
        for (i = 0, j = 0; i < QEDE_NUM_STATS; i++) {
                if (IS_VF(edev) && qede_stats_arr[i].pf_only)
                        continue;
-               strcpy(buf + j * ETH_GSTRING_LEN,
+               strcpy(buf + (k + j) * ETH_GSTRING_LEN,
                       qede_stats_arr[i].string);
                j++;
        }
-
-       for (k = 0; k < QEDE_NUM_RQSTATS; k++, j++)
-               strcpy(buf + j * ETH_GSTRING_LEN,
-                      qede_rqstats_arr[k].string);
 }
 
 static void qede_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
@@ -199,19 +230,24 @@ static void qede_get_ethtool_stats(struct net_device *dev,
 
        mutex_lock(&edev->qede_lock);
 
+       for (qid = 0; qid < edev->num_rss; qid++) {
+               int tc;
+
+               for (sidx = 0; sidx < QEDE_NUM_RQSTATS; sidx++)
+                       buf[cnt++] = QEDE_RQSTATS_DATA(edev, sidx, qid);
+               for (tc = 0; tc < edev->num_tc; tc++) {
+                       for (sidx = 0; sidx < QEDE_NUM_TQSTATS; sidx++)
+                               buf[cnt++] = QEDE_TQSTATS_DATA(edev, sidx, qid,
+                                                              tc);
+               }
+       }
+
        for (sidx = 0; sidx < QEDE_NUM_STATS; sidx++) {
                if (IS_VF(edev) && qede_stats_arr[sidx].pf_only)
                        continue;
                buf[cnt++] = QEDE_STATS_DATA(edev, sidx);
        }
 
-       for (sidx = 0; sidx < QEDE_NUM_RQSTATS; sidx++) {
-               buf[cnt] = 0;
-               for (qid = 0; qid < edev->num_rss; qid++)
-                       buf[cnt] += QEDE_RQSTATS_DATA(edev, sidx, qid);
-               cnt++;
-       }
-
        mutex_unlock(&edev->qede_lock);
 }
 
@@ -229,7 +265,8 @@ static int qede_get_sset_count(struct net_device *dev, int stringset)
                                if (qede_stats_arr[i].pf_only)
                                        num_stats--;
                }
-               return num_stats + QEDE_NUM_RQSTATS;
+               return num_stats +  edev->num_rss *
+                       (QEDE_NUM_RQSTATS + QEDE_NUM_TQSTATS * edev->num_tc);
        case ETH_SS_PRIV_FLAGS:
                return QEDE_PRI_FLAG_LEN;
        case ETH_SS_TEST:
index 467d0eb043dfbe2900a9356f34717ec94b6ac6d8..a05459f969620c2653650e2e2b44b2a70e0795c4 100644 (file)
@@ -720,6 +720,7 @@ static netdev_tx_t qede_start_xmit(struct sk_buff *skb,
        if (unlikely(qed_chain_get_elem_left(&txq->tx_pbl)
                      < (MAX_SKB_FRAGS + 1))) {
                netif_tx_stop_queue(netdev_txq);
+               txq->stopped_cnt++;
                DP_VERBOSE(edev, NETIF_MSG_TX_QUEUED,
                           "Stop queue was called\n");
                /* paired memory barrier is in qede_tx_int(), we have to keep
@@ -779,6 +780,7 @@ static int qede_tx_int(struct qede_dev *edev, struct qede_tx_queue *txq)
                bytes_compl += len;
                pkts_compl++;
                txq->sw_tx_cons++;
+               txq->xmit_pkts++;
        }
 
        netdev_tx_completed_queue(netdev_txq, pkts_compl, bytes_compl);
@@ -1587,6 +1589,8 @@ next_cqe: /* don't consume bd rx buffer */
        /* Update producers */
        qede_update_rx_prod(edev, rxq);
 
+       rxq->rcv_pkts += rx_pkt;
+
        return rx_pkt;
 }