E610 device does not support MACsec.

This commit will excluding MACsec stats from the xstats info
display for E610 device.

Fixes: b35d309710fe ("net/ixgbe: add MACsec offload")
Cc: sta...@dpdk.org

Signed-off-by: Kaiwen Deng <kaiwenx.d...@intel.com>
---
 drivers/net/intel/ixgbe/ixgbe_ethdev.c | 121 ++++++++++++++-----------
 1 file changed, 67 insertions(+), 54 deletions(-)

diff --git a/drivers/net/intel/ixgbe/ixgbe_ethdev.c 
b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
index 0fa4898aba..130a23cd9d 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
@@ -3354,38 +3354,40 @@ ixgbe_read_stats_registers(struct ixgbe_hw *hw,
                                        IXGBE_FDIRFSTAT) >> 16) & 0xFFFF;
        }
        /* MACsec Stats registers */
-       macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
-       macsec_stats->out_pkts_encrypted +=
-               IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
-       macsec_stats->out_pkts_protected +=
-               IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
-       macsec_stats->out_octets_encrypted +=
-               IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
-       macsec_stats->out_octets_protected +=
-               IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
-       macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
-       macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
-       macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
-       macsec_stats->in_pkts_unknownsci +=
-               IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
-       macsec_stats->in_octets_decrypted +=
-               IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
-       macsec_stats->in_octets_validated +=
-               IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
-       macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
-       macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
-       macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
-       for (i = 0; i < 2; i++) {
-               macsec_stats->in_pkts_ok +=
-                       IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
-               macsec_stats->in_pkts_invalid +=
-                       IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
-               macsec_stats->in_pkts_notvalid +=
-                       IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
-       }
-       macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
-       macsec_stats->in_pkts_notusingsa +=
-               IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
+       if (hw->mac.type != ixgbe_mac_E610) {
+               macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, 
IXGBE_LSECTXUT);
+               macsec_stats->out_pkts_encrypted +=
+                       IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
+               macsec_stats->out_pkts_protected +=
+                       IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
+               macsec_stats->out_octets_encrypted +=
+                       IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
+               macsec_stats->out_octets_protected +=
+                       IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
+               macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, 
IXGBE_LSECRXUT);
+               macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, 
IXGBE_LSECRXBAD);
+               macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, 
IXGBE_LSECRXNOSCI);
+               macsec_stats->in_pkts_unknownsci +=
+                       IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
+               macsec_stats->in_octets_decrypted +=
+                       IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
+               macsec_stats->in_octets_validated +=
+                       IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
+               macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, 
IXGBE_LSECRXUNCH);
+               macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, 
IXGBE_LSECRXDELAY);
+               macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, 
IXGBE_LSECRXLATE);
+               for (i = 0; i < 2; i++) {
+                       macsec_stats->in_pkts_ok +=
+                               IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
+                       macsec_stats->in_pkts_invalid +=
+                               IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
+                       macsec_stats->in_pkts_notvalid +=
+                               IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
+               }
+               macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, 
IXGBE_LSECRXUNSA);
+               macsec_stats->in_pkts_notusingsa +=
+                       IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
+       }
 }
 
 /*
@@ -3478,15 +3480,19 @@ ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
        (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES))
 
 static unsigned
-ixgbe_xstats_calc_num(void)
+ixgbe_xstats_calc_num(struct rte_eth_dev *dev)
 {
+       struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       if (hw->mac.type == ixgbe_mac_E610)
+               return IXGBE_XSTATS_CALC_NUM - IXGBE_NB_MACSEC_STATS;
        return IXGBE_XSTATS_CALC_NUM;
 }
 
-static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+static int ixgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
        struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int size)
 {
-       const unsigned cnt_stats = ixgbe_xstats_calc_num();
+       struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       const unsigned int cnt_stats = ixgbe_xstats_calc_num(dev);
        unsigned stat, i, count;
 
        if (xstats_names != NULL) {
@@ -3505,11 +3511,13 @@ static int ixgbe_dev_xstats_get_names(__rte_unused 
struct rte_eth_dev *dev,
                }
 
                /* MACsec Stats */
-               for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
-                       strlcpy(xstats_names[count].name,
-                               rte_ixgbe_macsec_strings[i].name,
-                               sizeof(xstats_names[count].name));
-                       count++;
+               if (hw->mac.type != ixgbe_mac_E610) {
+                       for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
+                               strlcpy(xstats_names[count].name,
+                                       rte_ixgbe_macsec_strings[i].name,
+                                       sizeof(xstats_names[count].name));
+                               count++;
+                       }
                }
 
                /* RX Priority Stats */
@@ -3544,7 +3552,8 @@ static int ixgbe_dev_xstats_get_names_by_id(
        unsigned int limit)
 {
        if (!ids) {
-               const unsigned int cnt_stats = ixgbe_xstats_calc_num();
+               struct ixgbe_hw *hw = 
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+               const unsigned int cnt_stats = ixgbe_xstats_calc_num(dev);
                unsigned int stat, i, count;
 
                if (xstats_names != NULL) {
@@ -3563,11 +3572,13 @@ static int ixgbe_dev_xstats_get_names_by_id(
                        }
 
                        /* MACsec Stats */
-                       for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
-                               strlcpy(xstats_names[count].name,
-                                       rte_ixgbe_macsec_strings[i].name,
-                                       sizeof(xstats_names[count].name));
-                               count++;
+                       if (hw->mac.type != ixgbe_mac_E610) {
+                               for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
+                                       strlcpy(xstats_names[count].name,
+                                               
rte_ixgbe_macsec_strings[i].name,
+                                               
sizeof(xstats_names[count].name));
+                                       count++;
+                               }
                        }
 
                        /* RX Priority Stats */
@@ -3643,7 +3654,7 @@ ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstat *xstats,
        uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
        unsigned i, stat, count = 0;
 
-       count = ixgbe_xstats_calc_num();
+       count = ixgbe_xstats_calc_num(dev);
 
        if (n < count)
                return count;
@@ -3672,11 +3683,13 @@ ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstat *xstats,
        }
 
        /* MACsec Stats */
-       for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
-               xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
-                               rte_ixgbe_macsec_strings[i].offset);
-               xstats[count].id = count;
-               count++;
+       if (hw->mac.type != ixgbe_mac_E610) {
+               for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
+                       xstats[count].value = *(uint64_t *)(((char 
*)macsec_stats) +
+                                       rte_ixgbe_macsec_strings[i].offset);
+                       xstats[count].id = count;
+                       count++;
+               }
        }
 
        /* RX Priority Stats */
@@ -3719,7 +3732,7 @@ ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const 
uint64_t *ids,
                uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
                unsigned int i, stat, count = 0;
 
-               count = ixgbe_xstats_calc_num();
+               count = ixgbe_xstats_calc_num(dev);
 
                if (!ids && n < count)
                        return count;
@@ -3803,7 +3816,7 @@ ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
                        IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
                                dev->data->dev_private);
 
-       unsigned count = ixgbe_xstats_calc_num();
+       unsigned int count = ixgbe_xstats_calc_num(dev);
 
        /* HW registers are cleared on read */
        ixgbe_dev_xstats_get(dev, NULL, count);
-- 
2.34.1

Reply via email to