From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B8851A0547; Thu, 28 Oct 2021 18:11:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 191B7426FD; Thu, 28 Oct 2021 18:10:38 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 371AB426F7 for ; Thu, 28 Oct 2021 18:10:33 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10151"; a="211214639" X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="211214639" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 09:06:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="498462928" Received: from silpixa00400884.ir.intel.com ([10.243.22.82]) by orsmga008.jf.intel.com with ESMTP; 28 Oct 2021 09:06:40 -0700 From: Radu Nicolau To: Jingjing Wu , Beilei Xing Cc: dev@dpdk.org, declan.doherty@intel.com, abhijit.sinha@intel.com, qi.z.zhang@intel.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com, Radu Nicolau Date: Thu, 28 Oct 2021 16:52:21 +0100 Message-Id: <20211028155223.2769166-6-radu.nicolau@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211028155223.2769166-1-radu.nicolau@intel.com> References: <20210909142428.750634-1-radu.nicolau@intel.com> <20211028155223.2769166-1-radu.nicolau@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v13 5/7] net/iavf: add xstats support for inline IPsec crypto X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add per queue counters for maintaining statistics for inline IPsec crypto offload, which can be retrieved through the rte_security_session_stats_get() with more detailed errors through the rte_ethdev xstats. Signed-off-by: Declan Doherty Signed-off-by: Radu Nicolau Acked-by: Jingjing Wu --- drivers/net/iavf/iavf.h | 21 ++++++- drivers/net/iavf/iavf_ethdev.c | 84 +++++++++++++++++++++++----- drivers/net/iavf/iavf_ipsec_crypto.c | 2 +- drivers/net/iavf/iavf_rxtx.h | 12 ---- 4 files changed, 90 insertions(+), 29 deletions(-) diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index bac72590bc..53c99d0f0e 100644 --- a/drivers/net/iavf/iavf.h +++ b/drivers/net/iavf/iavf.h @@ -96,6 +96,25 @@ struct iavf_adapter; struct iavf_rx_queue; struct iavf_tx_queue; + +struct iavf_ipsec_crypto_stats { + uint64_t icount; + uint64_t ibytes; + struct { + uint64_t count; + uint64_t sad_miss; + uint64_t not_processed; + uint64_t icv_check; + uint64_t ipsec_length; + uint64_t misc; + } ierrors; +}; + +struct iavf_eth_xstats { + struct virtchnl_eth_stats eth_stats; + struct iavf_ipsec_crypto_stats ips_stats; +}; + /* Structure that defines a VSI, associated with a adapter. */ struct iavf_vsi { struct iavf_adapter *adapter; /* Backreference to associated adapter */ @@ -105,7 +124,7 @@ struct iavf_vsi { uint16_t max_macaddrs; /* Maximum number of MAC addresses */ uint16_t base_vector; uint16_t msix_intr; /* The MSIX interrupt binds to VSI */ - struct virtchnl_eth_stats eth_stats_offset; + struct iavf_eth_xstats eth_stats_offset; }; struct rte_flow; diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index dba505494f..783a10060c 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -90,6 +90,7 @@ static const uint32_t *iavf_dev_supported_ptypes_get(struct rte_eth_dev *dev); static int iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int iavf_dev_stats_reset(struct rte_eth_dev *dev); +static int iavf_dev_xstats_reset(struct rte_eth_dev *dev); static int iavf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned int n); static int iavf_dev_xstats_get_names(struct rte_eth_dev *dev, @@ -145,21 +146,37 @@ struct rte_iavf_xstats_name_off { unsigned int offset; }; +#define _OFF_OF(a) offsetof(struct iavf_eth_xstats, a) static const struct rte_iavf_xstats_name_off rte_iavf_stats_strings[] = { - {"rx_bytes", offsetof(struct iavf_eth_stats, rx_bytes)}, - {"rx_unicast_packets", offsetof(struct iavf_eth_stats, rx_unicast)}, - {"rx_multicast_packets", offsetof(struct iavf_eth_stats, rx_multicast)}, - {"rx_broadcast_packets", offsetof(struct iavf_eth_stats, rx_broadcast)}, - {"rx_dropped_packets", offsetof(struct iavf_eth_stats, rx_discards)}, + {"rx_bytes", _OFF_OF(eth_stats.rx_bytes)}, + {"rx_unicast_packets", _OFF_OF(eth_stats.rx_unicast)}, + {"rx_multicast_packets", _OFF_OF(eth_stats.rx_multicast)}, + {"rx_broadcast_packets", _OFF_OF(eth_stats.rx_broadcast)}, + {"rx_dropped_packets", _OFF_OF(eth_stats.rx_discards)}, {"rx_unknown_protocol_packets", offsetof(struct iavf_eth_stats, rx_unknown_protocol)}, - {"tx_bytes", offsetof(struct iavf_eth_stats, tx_bytes)}, - {"tx_unicast_packets", offsetof(struct iavf_eth_stats, tx_unicast)}, - {"tx_multicast_packets", offsetof(struct iavf_eth_stats, tx_multicast)}, - {"tx_broadcast_packets", offsetof(struct iavf_eth_stats, tx_broadcast)}, - {"tx_dropped_packets", offsetof(struct iavf_eth_stats, tx_discards)}, - {"tx_error_packets", offsetof(struct iavf_eth_stats, tx_errors)}, + {"tx_bytes", _OFF_OF(eth_stats.tx_bytes)}, + {"tx_unicast_packets", _OFF_OF(eth_stats.tx_unicast)}, + {"tx_multicast_packets", _OFF_OF(eth_stats.tx_multicast)}, + {"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)}, + {"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)}, + {"tx_error_packets", _OFF_OF(eth_stats.tx_errors)}, + + {"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)}, + {"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)}, + {"inline_ipsec_crypto_ierrors", _OFF_OF(ips_stats.ierrors.count)}, + {"inline_ipsec_crypto_ierrors_sad_lookup", + _OFF_OF(ips_stats.ierrors.sad_miss)}, + {"inline_ipsec_crypto_ierrors_not_processed", + _OFF_OF(ips_stats.ierrors.not_processed)}, + {"inline_ipsec_crypto_ierrors_icv_fail", + _OFF_OF(ips_stats.ierrors.icv_check)}, + {"inline_ipsec_crypto_ierrors_length", + _OFF_OF(ips_stats.ierrors.ipsec_length)}, + {"inline_ipsec_crypto_ierrors_misc", + _OFF_OF(ips_stats.ierrors.misc)}, }; +#undef _OFF_OF #define IAVF_NB_XSTATS (sizeof(rte_iavf_stats_strings) / \ sizeof(rte_iavf_stats_strings[0])) @@ -177,7 +194,7 @@ static const struct eth_dev_ops iavf_eth_dev_ops = { .stats_reset = iavf_dev_stats_reset, .xstats_get = iavf_dev_xstats_get, .xstats_get_names = iavf_dev_xstats_get_names, - .xstats_reset = iavf_dev_stats_reset, + .xstats_reset = iavf_dev_xstats_reset, .promiscuous_enable = iavf_dev_promiscuous_enable, .promiscuous_disable = iavf_dev_promiscuous_disable, .allmulticast_enable = iavf_dev_allmulticast_enable, @@ -1527,7 +1544,7 @@ iavf_stat_update_32(uint64_t *offset, uint64_t *stat) static void iavf_update_stats(struct iavf_vsi *vsi, struct virtchnl_eth_stats *nes) { - struct virtchnl_eth_stats *oes = &vsi->eth_stats_offset; + struct virtchnl_eth_stats *oes = &vsi->eth_stats_offset.eth_stats; iavf_stat_update_48(&oes->rx_bytes, &nes->rx_bytes); iavf_stat_update_48(&oes->rx_unicast, &nes->rx_unicast); @@ -1589,7 +1606,18 @@ iavf_dev_stats_reset(struct rte_eth_dev *dev) return ret; /* set stats offset base on current values */ - vsi->eth_stats_offset = *pstats; + vsi->eth_stats_offset.eth_stats = *pstats; + + return 0; +} + +static int +iavf_dev_xstats_reset(struct rte_eth_dev *dev) +{ + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + + iavf_dev_stats_reset(dev); + memset(&vf->vsi.eth_stats_offset, 0, sizeof(struct iavf_eth_xstats)); return 0; } @@ -1609,6 +1637,27 @@ static int iavf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return IAVF_NB_XSTATS; } +static void +iavf_dev_update_ipsec_xstats(struct rte_eth_dev *ethdev, + struct iavf_ipsec_crypto_stats *ips) +{ + uint16_t idx; + for (idx = 0; idx < ethdev->data->nb_rx_queues; idx++) { + struct iavf_rx_queue *rxq; + struct iavf_ipsec_crypto_stats *stats; + rxq = (struct iavf_rx_queue *)ethdev->data->rx_queues[idx]; + stats = &rxq->stats.ipsec_crypto; + ips->icount += stats->icount; + ips->ibytes += stats->ibytes; + ips->ierrors.count += stats->ierrors.count; + ips->ierrors.sad_miss += stats->ierrors.sad_miss; + ips->ierrors.not_processed += stats->ierrors.not_processed; + ips->ierrors.icv_check += stats->ierrors.icv_check; + ips->ierrors.ipsec_length += stats->ierrors.ipsec_length; + ips->ierrors.misc += stats->ierrors.misc; + } +} + static int iavf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned int n) { @@ -1619,6 +1668,7 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev, struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); struct iavf_vsi *vsi = &vf->vsi; struct virtchnl_eth_stats *pstats = NULL; + struct iavf_eth_xstats iavf_xtats = {0}; if (n < IAVF_NB_XSTATS) return IAVF_NB_XSTATS; @@ -1631,11 +1681,15 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev, return 0; iavf_update_stats(vsi, pstats); + iavf_xtats.eth_stats = *pstats; + + if (iavf_ipsec_crypto_supported(adapter)) + iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats); /* loop over xstats array and values from pstats */ for (i = 0; i < IAVF_NB_XSTATS; i++) { xstats[i].id = i; - xstats[i].value = *(uint64_t *)(((char *)pstats) + + xstats[i].value = *(uint64_t *)(((char *)&iavf_xtats) + rte_iavf_stats_strings[i].offset); } diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c index 633fedf860..eabc4be6bc 100644 --- a/drivers/net/iavf/iavf_ipsec_crypto.c +++ b/drivers/net/iavf/iavf_ipsec_crypto.c @@ -509,7 +509,7 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter, htonl(conf->ipsec.tunnel.ipv4.dst_ip.s_addr); } else { uint32_t *v6_dst_addr = - conf->ipsec.tunnel.ipv6.dst_addr.s6_addr32; + (uint32_t *)conf->ipsec.tunnel.ipv6.dst_addr.s6_addr; sa_cfg->virtchnl_ip_type = VIRTCHNL_IPV6; diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index b88c81f8f6..c7156d1daa 100644 --- a/drivers/net/iavf/iavf_rxtx.h +++ b/drivers/net/iavf/iavf_rxtx.h @@ -165,18 +165,6 @@ struct iavf_txq_ops { void (*release_mbufs)(struct iavf_tx_queue *txq); }; -struct iavf_ipsec_crypto_stats { - uint64_t icount; - uint64_t ibytes; - struct { - uint64_t count; - uint64_t sad_miss; - uint64_t not_processed; - uint64_t icv_check; - uint64_t ipsec_length; - uint64_t misc; - } ierrors; -}; struct iavf_rx_queue_stats { uint64_t reserved; -- 2.25.1