From patchwork Fri Oct 8 10:29:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Singh, Aman Deep" X-Patchwork-Id: 100767 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 09EAAA034F; Fri, 8 Oct 2021 12:39:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6DEB40DF7; Fri, 8 Oct 2021 12:39:30 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id B5CA24003C for ; Fri, 8 Oct 2021 12:39:28 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="289978464" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="289978464" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 03:39:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="715474857" Received: from npg-npf-wlpr-srv02.iind.intel.com ([10.190.213.104]) by fmsmga005.fm.intel.com with ESMTP; 08 Oct 2021 03:39:26 -0700 From: Aman Singh To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 8 Oct 2021 15:59:49 +0530 Message-Id: <20211008102949.70716-1-aman.deep.singh@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] devtools/cocci: added script for ethdev namespace 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" The cocci script is to help add prefix 'RTE_ETH' namespace to all enum & macro of ethdev library in a backward compatible way. After the script makes the changes few manual changes are required in rte_ethdev.h for enum name changes. Signed-off-by: Aman Singh --- devtools/cocci/namespace_ethdev.cocci | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 devtools/cocci/namespace_ethdev.cocci diff --git a/devtools/cocci/namespace_ethdev.cocci b/devtools/cocci/namespace_ethdev.cocci new file mode 100644 index 0000000000..383db454f0 --- /dev/null +++ b/devtools/cocci/namespace_ethdev.cocci @@ -0,0 +1,50 @@ +@rule1@ +identifier I =~ "^(RTE_FC_|ETH_MQ_|ETH_RSS_|DEV_RX_|DEV_TX_|ETH_LINK_|RTE_RETA| +ETH_SPEED|RTE_TUNNEL|ETH_VLAN|ETH_4|ETH_8|ETH_16|ETH_32|ETH_64|RTE_FDIR|RTE_L2| +ETH_DCB|ETH_MIRROR|ETH_VMDQ|ETH_NUM|ETH_QINQ|rte_fdir)"; +@@ +I + +@ script : python p@ +I << rule1.I; +J; +@@ +coccinelle .J="RTE_ETH_" + I[4:]; +if I.isupper() == False: + coccinelle .J="rte_eth_" + I[4:]; + +exception_matches = ["ETH_RSS_MODE","ETH_VLAN_FILTER_ANY","ETH_VLAN_FILTER_SPEC", +"ETH_VLAN_FILTER_CLASSIFY","ETH_RSS_UPDATE","RTE_FDIR_MODE"] + +if any(x in I for x in exception_matches): + coccinelle .J= I; + +@ identifier@ +identifier rule1.I; +identifier p.J; +@@ +- I ++ J + +@rule2@ +identifier A =~ "^(RTE_FC_|ETH_MQ_|ETH_RSS_|DEV_RX_|DEV_TX_|ETH_LINK_|RTE_RETA| +ETH_SPEED|RTE_TUNNEL|ETH_VLAN|ETH_4|ETH_8|ETH_16|ETH_32|ETH_64|RTE_FDIR|RTE_L2| +ETH_DCB|ETH_MIRROR|ETH_VMDQ|ETH_NUM|ETH_QINQ)"; +expression B ; +@@ +#define A B + +@ script : python p2@ +A << rule2.A; +K; +@@ +coccinelle .K="RTE_ETH_" + A[4:]; + +@ identifier2@ +identifier rule2.A; +expression rule2.B; +identifier p2.K; +@@ +- #define A B ++ #define K B ++ #define A K