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 9530D46128; Fri, 24 Jan 2025 19:22:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DF74402CE; Fri, 24 Jan 2025 19:22:00 +0100 (CET) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5C9454028A for ; Fri, 24 Jan 2025 19:21:58 +0100 (CET) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50OH4jah032166 for ; Fri, 24 Jan 2025 10:21:57 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pfpt0220; bh=vqsRy49RNBu00FzsYtCsdxf /N1n7YQpgXpXdr1Z8FVg=; b=Z7yhstXGoXWT8mxf+neMDFWz1mMckINbR64aril rtp7eqaEA3bKyyVUkCy/+4t9WSbFgx8j1p9yUIGYX8H/K42JOnaHaJAlhVUibtEJ Y1LZjbQc+C7Uwe3NjSRYkD3I2tr27P0hex9glEhs7gKSf62Z60VJy/AOoIashJDK KMU1n55yf/uzWeSqKUFct/X8dPVYLTbkbjjt6yyl4sRtYr4heDTv/bWl8RVebX6o i0Gp/KYrfKNpmMpe49tzkO/VIDBHQLgRBrZ4KD6/xH1ayl/dsZ4Z5V+4vMSt9mep xnc2FzLmRb/SERskml10jHZukt0zjp64wekK42U0R9lQjOg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 44cexrg54h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 24 Jan 2025 10:21:57 -0800 (PST) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 24 Jan 2025 10:21:56 -0800 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 24 Jan 2025 10:21:56 -0800 Received: from cavium-SR1-T640.marvell.com (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id BE2B43F7058; Fri, 24 Jan 2025 10:21:54 -0800 (PST) From: Akhil Goyal To: CC: , Akhil Goyal Subject: [PATCH] common/cnxk: check MACsec HW capability Date: Fri, 24 Jan 2025 23:51:51 +0530 Message-ID: <20250124182151.3587238-1-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: bBLCpY4tXfLf05t_1XLu_JkQrTgRuKKb X-Proofpoint-ORIG-GUID: bBLCpY4tXfLf05t_1XLu_JkQrTgRuKKb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-24_08,2025-01-23_01,2024-11-22_01 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 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 --- 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