DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] devtools/cocci: add script for ethdev namespace
@ 2021-11-23  8:47 Aman Singh
  2021-11-25 18:41 ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Aman Singh @ 2021-11-23  8:47 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit

The cocci script is to help add prefix 'RTE_ETH' namespace to enum
& macro of ethdev library. It helps in automating these changes for
applications. The script won't make changes in the code comment part.
Usage: spatch <script path> <app path>

Signed-off-by: Aman Singh <aman.deep.singh@intel.com>
---
 devtools/cocci/namespace_ethdev.cocci | 48 +++++++++++++++++++++++++++
 1 file changed, 48 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..d5de41e117
--- /dev/null
+++ b/devtools/cocci/namespace_ethdev.cocci
@@ -0,0 +1,48 @@
+@rule1@
+identifier I =~  "^(RTE_FC_|ETH_MQ_|ETH_RSS|DEV_RX_|DEV_TX_|ETH_LINK|RTE_RETA|
+|ETH_DCB|RTE_TUNNEL|ETH_VLAN|ETH_4|ETH_8|ETH_16|ETH_32|ETH_64|RTE_FDIR|RTE_L2|
+|ETH_SPEED|ETH_MIRROR|ETH_VMDQ|ETH_NUM|ETH_QINQ|ETH_MAX_)";
+@@
+I
+
+@ script : python p@
+I << rule1.I;
+J;
+@@
+coccinelle .J="RTE_ETH_" + I[4:];
+
+exception_matches = ["ETH_VLAN_FILTER_CLASSIFY","ETH_VLAN_FILTER_ANY",
+"ETH_VLAN_FILTER_SPEC","ETH_RSS_MODE","ETH_RSS_UPDATE","RTE_FDIR_MODE",
+"RTE_FDIR_NO","RTE_FDIR_REPORT","ETH_MAX_RX_CLIENTS_E1H",
+"ETH_MAX_AGGREGATION_QUEUES_E1","ETH_RSS_ENGINE_NUM","ETH_NUM_MAC_FILTERS",
+"ETH_MAX_NUM_RX_QUEUES_PER_VF_QUAD","ETH_RSS_IND_TABLE_ENTRIES_NUM",
+"ETH_RSS_KEY_SIZE_REGS","ETH_NUM_STATISTIC_COUNTERS","ETH_SPEED_"]
+
+if any(x in I for x in exception_matches):
+        coccinelle .J= I;
+
+@ identifier@
+identifier rule1.I;
+identifier p.J;
+@@
+- I
++ J
+
+// Below rule for structures only
+@rule2@
+identifier A  =~  "rte_fdir_conf|rte_intr_conf";
+@@
+struct A
+
+@ script : python p2@
+A << rule2.A;
+B;
+@@
+coccinelle .B="rte_eth_" + A[4:];
+
+@ identifier2@
+identifier rule2.A;
+identifier p2.B;
+@@
+- struct A
++ struct B
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] devtools/cocci: add script for ethdev namespace
  2021-11-23  8:47 [PATCH] devtools/cocci: add script for ethdev namespace Aman Singh
@ 2021-11-25 18:41 ` Ferruh Yigit
  2021-11-26 16:37   ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Ferruh Yigit @ 2021-11-25 18:41 UTC (permalink / raw)
  To: Aman Singh; +Cc: dev

On 11/23/2021 8:47 AM, Aman Singh wrote:
> The cocci script is to help add prefix 'RTE_ETH' namespace to enum
> & macro of ethdev library. It helps in automating these changes for
> applications. The script won't make changes in the code comment part.
> Usage: spatch <script path> <app path>
> 

Hi Aman,

I am trying to test the script, I thought an easy way can be to run
the script in an old version of the DPDK release and expecting it
build successfully after script run.
For that I am using 'spatch --include-headers --in-place' option on p
the repo.

Getting build error for the OFFLOAD macros, header files seems not
updated for the offloads, but .c files are updated.
Like:
DEV_TX_OFFLOAD_TCP_CKSUM --> RTE_ETH_TX_OFFLOAD_TCP_CKSUM
DEV_RX_OFFLOAD_UDP_CKSUM --> RTE_ETH_RX_OFFLOAD_UDP_CKSUM
...

Am I missing something, or .h left out intentionally?
Is there a way to update all?

> Signed-off-by: Aman Singh <aman.deep.singh@intel.com>
> ---
>   devtools/cocci/namespace_ethdev.cocci | 48 +++++++++++++++++++++++++++
>   1 file changed, 48 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..d5de41e117
> --- /dev/null
> +++ b/devtools/cocci/namespace_ethdev.cocci
> @@ -0,0 +1,48 @@
> +@rule1@
> +identifier I =~  "^(RTE_FC_|ETH_MQ_|ETH_RSS|DEV_RX_|DEV_TX_|ETH_LINK|RTE_RETA|
> +|ETH_DCB|RTE_TUNNEL|ETH_VLAN|ETH_4|ETH_8|ETH_16|ETH_32|ETH_64|RTE_FDIR|RTE_L2|
> +|ETH_SPEED|ETH_MIRROR|ETH_VMDQ|ETH_NUM|ETH_QINQ|ETH_MAX_)";
> +@@
> +I
> +
> +@ script : python p@
> +I << rule1.I;
> +J;
> +@@
> +coccinelle .J="RTE_ETH_" + I[4:];
> +
> +exception_matches = ["ETH_VLAN_FILTER_CLASSIFY","ETH_VLAN_FILTER_ANY",
> +"ETH_VLAN_FILTER_SPEC","ETH_RSS_MODE","ETH_RSS_UPDATE","RTE_FDIR_MODE",
> +"RTE_FDIR_NO","RTE_FDIR_REPORT","ETH_MAX_RX_CLIENTS_E1H",
> +"ETH_MAX_AGGREGATION_QUEUES_E1","ETH_RSS_ENGINE_NUM","ETH_NUM_MAC_FILTERS",
> +"ETH_MAX_NUM_RX_QUEUES_PER_VF_QUAD","ETH_RSS_IND_TABLE_ENTRIES_NUM",
> +"ETH_RSS_KEY_SIZE_REGS","ETH_NUM_STATISTIC_COUNTERS","ETH_SPEED_"]
> +
> +if any(x in I for x in exception_matches):
> +        coccinelle .J= I;
> +
> +@ identifier@
> +identifier rule1.I;
> +identifier p.J;
> +@@
> +- I
> ++ J
> +
> +// Below rule for structures only
> +@rule2@
> +identifier A  =~  "rte_fdir_conf|rte_intr_conf";
> +@@
> +struct A
> +
> +@ script : python p2@
> +A << rule2.A;
> +B;
> +@@
> +coccinelle .B="rte_eth_" + A[4:];
> +
> +@ identifier2@
> +identifier rule2.A;
> +identifier p2.B;
> +@@
> +- struct A
> ++ struct B
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] devtools/cocci: add script for ethdev namespace
  2021-11-25 18:41 ` Ferruh Yigit
@ 2021-11-26 16:37   ` Ferruh Yigit
  2021-11-26 16:58     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Ferruh Yigit @ 2021-11-26 16:37 UTC (permalink / raw)
  To: Aman Singh, Thomas Monjalon, David Marchand; +Cc: dev

On 11/25/2021 6:41 PM, Ferruh Yigit wrote:
> On 11/23/2021 8:47 AM, Aman Singh wrote:
>> The cocci script is to help add prefix 'RTE_ETH' namespace to enum
>> & macro of ethdev library. It helps in automating these changes for
>> applications. The script won't make changes in the code comment part.
>> Usage: spatch <script path> <app path>
>>
> 
> Hi Aman,
> 
> I am trying to test the script, I thought an easy way can be to run
> the script in an old version of the DPDK release and expecting it
> build successfully after script run.
> For that I am using 'spatch --include-headers --in-place' option on p
> the repo.
> 
> Getting build error for the OFFLOAD macros, header files seems not
> updated for the offloads, but .c files are updated.
> Like:
> DEV_TX_OFFLOAD_TCP_CKSUM --> RTE_ETH_TX_OFFLOAD_TCP_CKSUM
> DEV_RX_OFFLOAD_UDP_CKSUM --> RTE_ETH_RX_OFFLOAD_UDP_CKSUM
> ...
> 
> Am I missing something, or .h left out intentionally?
> Is there a way to update all?
> 

What I missed was script is not updating "#define ..." usage,
this make sense since target is for applications to update their code,
so script should update usage, not defines.

And as I tested with v21.08 with latest ethdev.h defines, some macros
seems not updated:
ETH_TUNNEL_FILTER_*
ETH_SPEED_NUM_*

Deprecated and removed macros are not updated, like:
RTE_ETH_DCB_NONE

And for some cases, like a new PMD specific macro is defined using
old existing macros, old macros are not updated.


Except from above issues, script updates majority of the macros,
and can be useful for application developers, also script can be
improved more later.

With above notes:
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>


>> Signed-off-by: Aman Singh <aman.deep.singh@intel.com>

<...>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] devtools/cocci: add script for ethdev namespace
  2021-11-26 16:37   ` Ferruh Yigit
@ 2021-11-26 16:58     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2021-11-26 16:58 UTC (permalink / raw)
  To: Aman Singh; +Cc: David Marchand, dev, Ferruh Yigit

26/11/2021 17:37, Ferruh Yigit:
> On 11/25/2021 6:41 PM, Ferruh Yigit wrote:
> > On 11/23/2021 8:47 AM, Aman Singh wrote:
> >> The cocci script is to help add prefix 'RTE_ETH' namespace to enum
> >> & macro of ethdev library. It helps in automating these changes for
> >> applications. The script won't make changes in the code comment part.
> >> Usage: spatch <script path> <app path>
[...]
> Except from above issues, script updates majority of the macros,
> and can be useful for application developers, also script can be
> improved more later.
> 
> With above notes:
> Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-26 16:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23  8:47 [PATCH] devtools/cocci: add script for ethdev namespace Aman Singh
2021-11-25 18:41 ` Ferruh Yigit
2021-11-26 16:37   ` Ferruh Yigit
2021-11-26 16:58     ` Thomas Monjalon

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git