DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] common/cnxk: check MACsec HW capability
@ 2025-01-24 18:21 Akhil Goyal
  0 siblings, 0 replies; only message in thread
From: Akhil Goyal @ 2025-01-24 18:21 UTC (permalink / raw)
  To: dev; +Cc: jerinj, Akhil Goyal

Added ROC API to check if hardware has capability
to perform MACsec operations.
Skipped MACsec initialization if not supported by hardware

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 drivers/common/cnxk/roc_mbox.h  |  2 ++
 drivers/common/cnxk/roc_mcs.c   | 21 +++++++++++++++++++++
 drivers/common/cnxk/roc_mcs.h   |  2 ++
 drivers/common/cnxk/version.map |  1 +
 drivers/net/cnxk/cnxk_ethdev.c  |  4 ++--
 5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index f362d55bc2..989f33b0d2 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -2869,6 +2869,8 @@ struct get_hw_cap_rsp {
 	uint8_t __io nix_fixed_txschq_mapping;
 	uint8_t __io nix_shaping;      /* Is shaping and coloring supported */
 	uint8_t __io npc_hash_extract; /* Is hash extract supported */
+#define HW_CAP_MACSEC BIT_ULL(1)
+	uint64_t hw_caps;
 };
 
 struct ndc_sync_op {
diff --git a/drivers/common/cnxk/roc_mcs.c b/drivers/common/cnxk/roc_mcs.c
index f823f7f478..0ae5618c09 100644
--- a/drivers/common/cnxk/roc_mcs.c
+++ b/drivers/common/cnxk/roc_mcs.c
@@ -18,6 +18,27 @@ TAILQ_HEAD(mcs_event_cb_list, mcs_event_cb);
 
 PLT_STATIC_ASSERT(ROC_MCS_MEM_SZ >= (sizeof(struct mcs_priv) + sizeof(struct mcs_event_cb_list)));
 
+bool
+roc_mcs_is_supported(void)
+{
+	struct get_hw_cap_rsp *hw_cap_rsp;
+	struct npa_lf *npa;
+
+	/* Use mbox handler of first probed pci_func for initial mcs mbox communication. */
+	npa = idev_npa_obj_get();
+	if (!npa)
+		return false;
+
+	mbox_alloc_msg_get_hw_cap(npa->mbox);
+	if (mbox_process_msg(npa->mbox, (void *)&hw_cap_rsp))
+		return false;
+
+	if (hw_cap_rsp->hw_caps & HW_CAP_MACSEC)
+		return true;
+
+	return false;
+}
+
 int
 roc_mcs_hw_info_get(struct roc_mcs_hw_info *hw_info)
 {
diff --git a/drivers/common/cnxk/roc_mcs.h b/drivers/common/cnxk/roc_mcs.h
index 0627865a4d..3ac82f6f8c 100644
--- a/drivers/common/cnxk/roc_mcs.h
+++ b/drivers/common/cnxk/roc_mcs.h
@@ -498,6 +498,8 @@ struct roc_mcs {
 
 TAILQ_HEAD(roc_mcs_head, roc_mcs);
 
+/* Check HW capability for MACsec */
+__roc_api bool roc_mcs_is_supported(void);
 /* Initialization */
 __roc_api struct roc_mcs *roc_mcs_dev_init(uint8_t mcs_idx);
 __roc_api void roc_mcs_dev_fini(struct roc_mcs *mcs);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 37b76c020e..97562b1663 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -171,6 +171,7 @@ INTERNAL {
 	roc_mcs_flowid_stats_get;
 	roc_mcs_hw_info_get;
 	roc_mcs_intr_configure;
+	roc_mcs_is_supported;
 	roc_mcs_lmac_mode_set;
 	roc_mcs_pn_table_write;
 	roc_mcs_pn_table_read;
diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index ea980a6d5e..3efce5c634 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -2002,7 +2002,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (rc)
 		goto free_mac_addrs;
 
-	if (roc_feature_nix_has_macsec()) {
+	if (roc_feature_nix_has_macsec() && roc_mcs_is_supported()) {
 		rc = cnxk_mcs_dev_init(dev, 0);
 		if (rc) {
 			plt_err("Failed to init MCS");
@@ -2132,7 +2132,7 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset)
 	}
 	eth_dev->data->nb_rx_queues = 0;
 
-	if (roc_feature_nix_has_macsec())
+	if (roc_feature_nix_has_macsec() && roc_mcs_is_supported())
 		cnxk_mcs_dev_fini(dev);
 
 	/* Free security resources */
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-24 18:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-24 18:21 [PATCH] common/cnxk: check MACsec HW capability Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).