ethdev: separate driver APIs
[dpdk.git] / drivers / net / cxgbe / base / t4_hw.c
index 94abd5b..56f38c8 100644 (file)
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
-#include <rte_memzone.h>
 #include <rte_tailq.h>
 #include <rte_eal.h>
 #include <rte_alarm.h>
 #include <rte_ether.h>
-#include <rte_ethdev.h>
-#include <rte_atomic.h>
+#include <rte_ethdev_driver.h>
 #include <rte_malloc.h>
 #include <rte_random.h>
 #include <rte_dev.h>
@@ -404,6 +402,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox,
                        t4_os_atomic_list_del(&entry, &adap->mbox_list,
                                              &adap->mbox_lock);
                        t4_report_fw_error(adap);
+                       free(temp);
                        return (pcie_fw & F_PCIE_FW_ERR) ? -ENXIO : -EBUSY;
                }
 
@@ -447,6 +446,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox,
                                                         &adap->mbox_list,
                                                         &adap->mbox_lock));
                t4_report_fw_error(adap);
+               free(temp);
                return (v == X_MBOWNER_FW ? -EBUSY : -ETIMEDOUT);
        }
 
@@ -547,6 +547,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox,
                        T4_OS_MBOX_LOCKING(
                                t4_os_atomic_list_del(&entry, &adap->mbox_list,
                                                      &adap->mbox_lock));
+                       free(temp);
                        return -G_FW_CMD_RETVAL((int)res);
                }
        }
@@ -2941,6 +2942,7 @@ unsigned int t4_get_tp_ch_map(struct adapter *adapter, unsigned int pidx)
 void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
 {
        u32 bgmap = t4_get_mps_bg_map(adap, idx);
+       u32 stat_ctl = t4_read_reg(adap, A_MPS_STAT_CTL);
 
 #define GET_STAT(name) \
        t4_read_reg64(adap, \
@@ -2973,6 +2975,15 @@ void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
        p->tx_ppp6             = GET_STAT(TX_PORT_PPP6);
        p->tx_ppp7             = GET_STAT(TX_PORT_PPP7);
 
+       if (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T5) {
+               if (stat_ctl & F_COUNTPAUSESTATTX) {
+                       p->tx_frames -= p->tx_pause;
+                       p->tx_octets -= p->tx_pause * 64;
+               }
+               if (stat_ctl & F_COUNTPAUSEMCTX)
+                       p->tx_mcast_frames -= p->tx_pause;
+       }
+
        p->rx_octets           = GET_STAT(RX_PORT_BYTES);
        p->rx_frames           = GET_STAT(RX_PORT_FRAMES);
        p->rx_bcast_frames     = GET_STAT(RX_PORT_BCAST);
@@ -3000,6 +3011,16 @@ void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
        p->rx_ppp5             = GET_STAT(RX_PORT_PPP5);
        p->rx_ppp6             = GET_STAT(RX_PORT_PPP6);
        p->rx_ppp7             = GET_STAT(RX_PORT_PPP7);
+
+       if (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T5) {
+               if (stat_ctl & F_COUNTPAUSESTATRX) {
+                       p->rx_frames -= p->rx_pause;
+                       p->rx_octets -= p->rx_pause * 64;
+               }
+               if (stat_ctl & F_COUNTPAUSEMCRX)
+                       p->rx_mcast_frames -= p->rx_pause;
+       }
+
        p->rx_ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_MAC_DROP_FRAME) : 0;
        p->rx_ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_MAC_DROP_FRAME) : 0;
        p->rx_ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_MAC_DROP_FRAME) : 0;