From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru
Subject: [dpdk-dev] [PATCH v5 3/3] devtools: check flow API doc tables
Date: Thu, 8 Apr 2021 00:33:20 +0200 [thread overview]
Message-ID: <20210407223320.2952469-4-thomas@monjalon.net> (raw)
In-Reply-To: <20210407223320.2952469-1-thomas@monjalon.net>
The script check-doc-vs-code.sh may be used to add
some automatic checks of the doc.
If run without any argument, a complete check is done.
The optional argument is a git history reference point
to check faster only what has changed since this commit.
In this commit, the only check is for rte_flow tables,
achieved through the script parse-flow-support.sh.
If run without a .ini reference, it prints rte_flow tables.
Note: detected features are marked with the value Y,
while the real .ini file could have special values like I.
The script allow parsing exceptions (exclude or include),
like for bnxt code which lists unsupported items and actions.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
devtools/check-doc-vs-code.sh | 79 ++++++++++++++++++++++++++++++++++
devtools/parse-flow-support.sh | 76 ++++++++++++++++++++++++++++++++
2 files changed, 155 insertions(+)
create mode 100755 devtools/check-doc-vs-code.sh
create mode 100755 devtools/parse-flow-support.sh
diff --git a/devtools/check-doc-vs-code.sh b/devtools/check-doc-vs-code.sh
new file mode 100755
index 0000000000..6e53d66899
--- /dev/null
+++ b/devtools/check-doc-vs-code.sh
@@ -0,0 +1,79 @@
+#! /bin/sh -e
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2021 Mellanox Technologies, Ltd
+
+# Check whether doc & code are in sync.
+# Optional argument: check only what changed since a commit.
+trusted_commit=$1 # example: origin/main
+
+selfdir=$(dirname $(readlink -f $0))
+rootdir=$(readlink -f $selfdir/..)
+
+result=0
+
+# speed up by ignoring Unicode details
+export LC_COLLATE=C
+
+changed_files()
+{
+ [ -n "$files" ] ||
+ files=$(git diff-tree --name-only -r $trusted_commit..)
+ echo "$files"
+}
+
+has_code_change() # <pattern>
+{
+ test -n "$(git log --format='%h' -S"$1" $trusted_commit..)"
+}
+
+has_file_change() # <pattern>
+{
+ changed_files | grep -q "$1"
+}
+
+changed_net_drivers()
+{
+ net_paths='drivers/net/|doc/guides/nics/features/'
+ [ -n "$drivers" ] ||
+ drivers=$(changed_files |
+ sed -rn "s,^($net_paths)([^./]*).*,\2,p")
+ echo "$drivers"
+}
+
+all_net_drivers()
+{
+ find $rootdir/drivers/net -mindepth 1 -maxdepth 1 -type d |
+ sed 's,.*/,,' |
+ sort
+}
+
+check_rte_flow() # <driver>
+{
+ code=$rootdir/drivers/net/$1
+ doc=$rootdir/doc/guides/nics/features/$1.ini
+ [ -d $code ] || return 0
+ [ -f $doc ] || return 0
+ report=$($selfdir/parse-flow-support.sh $code $doc)
+ if [ -n "$report" ]; then
+ echo "rte_flow doc out of sync for $1"
+ echo "$report" | sed 's,^,\t,'
+ result=$(($result + 1))
+ fi
+}
+
+if [ -z "$trusted_commit" ]; then
+ # check all
+ for driver in $(all_net_drivers); do
+ check_rte_flow $driver
+ done
+ exit $result
+fi
+
+# find what changed and check
+if has_code_change 'RTE_FLOW_.*_TYPE_' ||
+ has_file_change 'doc/guides/nics/features'; then
+ for driver in $(changed_net_drivers); do
+ check_rte_flow $driver
+ done
+fi
+exit $result
diff --git a/devtools/parse-flow-support.sh b/devtools/parse-flow-support.sh
new file mode 100755
index 0000000000..b397e81b62
--- /dev/null
+++ b/devtools/parse-flow-support.sh
@@ -0,0 +1,76 @@
+#! /bin/sh -e
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2021 Mellanox Technologies, Ltd
+
+# Parse rte_flow support of a driver directory,
+# and optionally show difference with a doc file in .ini format.
+
+dir=$1 # drivers/net/foo
+ref=$2 # doc/guides/nics/features/foo.ini
+
+if [ -z "$dir" ]; then
+ echo "directory argument is required" >&2
+ exit 1
+fi
+
+# sorting order
+export LC_COLLATE=C
+
+# exclude exceptions
+exclude() # <pattern>
+{
+ case $(basename $dir) in
+ bnxt)
+ filter=$(sed -n "/$1/{N;/TYPE_NOT_SUPPORTED/P;}" \
+ $dir/tf_ulp/ulp_template_db{,_tbl}.c |
+ grep -wo "$1[[:alnum:]_]*" | sort -u |
+ tr '\n' '|' | sed 's,.$,\n,')
+ grep -vE "$filter";;
+ *) cat
+ esac
+}
+
+# include exceptions
+include() # <pattern>
+{
+ case $(basename $dir) in
+ esac
+}
+
+# generate INI section
+list() # <title> <pattern>
+{
+ echo "[$1]"
+ git grep -who "$2[[:alnum:]_]*" $dir |
+ (exclude $2; include $2) | sort -u |
+ awk 'sub(/'$2'/, "") {printf "%-20s = Y\n", tolower($0)}'
+}
+
+rte_flow_support() # <category>
+{
+ title="rte_flow $1s"
+ pattern=$(echo "RTE_FLOW_$1_TYPE_" | awk '{print toupper($0)}')
+ list "$title" "$pattern" | grep -vwE 'void|end'
+}
+
+if [ -z "$ref" ]; then
+ rte_flow_support item
+ echo
+ rte_flow_support action
+ exit 0
+fi
+
+rte_flow_compare() # <category>
+{
+ section="rte_flow $1s]"
+ {
+ rte_flow_support $1
+ sed -n "/$section/,/]/p" "$ref" | sed '/^$/d'
+ } |
+ sed '/]/d' | # ignore section title
+ sed 's, *=.*,,' | # ignore value (better in doc than generated one)
+ sort | uniq -u # show differences
+}
+
+rte_flow_compare item
+rte_flow_compare action
--
2.31.1
next prev parent reply other threads:[~2021-04-07 22:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-04 17:05 [dpdk-dev] [PATCH] doc: add new tables for rte flow items and actions support Asaf Penso
2021-02-04 22:09 ` Thomas Monjalon
2021-02-07 8:46 ` Asaf Penso
2021-02-07 9:44 ` Thomas Monjalon
2021-02-07 9:27 ` [dpdk-dev] [PATCH v2] " Asaf Penso
2021-02-07 10:46 ` [dpdk-dev] [PATCH v3] " Asaf Penso
2021-02-07 10:52 ` [dpdk-dev] [PATCH v4] " Asaf Penso
2021-02-08 12:58 ` Thomas Monjalon
2021-02-16 13:13 ` Ferruh Yigit
2021-02-17 5:57 ` Asaf Penso
2021-02-17 10:37 ` Ferruh Yigit
2021-02-17 10:49 ` Thomas Monjalon
2021-02-18 16:12 ` Asaf Penso
2021-02-18 17:58 ` Ajit Khaparde
2021-02-18 18:45 ` Ferruh Yigit
2021-04-06 15:07 ` Thomas Monjalon
2021-04-07 22:33 ` [dpdk-dev] [PATCH v5 0/3] rte_flow doc matrix Thomas Monjalon
2021-04-07 22:33 ` [dpdk-dev] [PATCH v5 1/3] doc: rename sfc features file Thomas Monjalon
2021-04-07 22:33 ` [dpdk-dev] [PATCH v5 2/3] doc: add flow API features tables Thomas Monjalon
2021-04-08 8:45 ` [dpdk-dev] [EXT] " Kiran Kumar Kokkilagadda
2021-05-14 10:42 ` [dpdk-dev] " Ferruh Yigit
2021-05-14 11:52 ` Thomas Monjalon
2021-04-07 22:33 ` Thomas Monjalon [this message]
2021-05-13 18:40 ` [dpdk-dev] [PATCH v5 3/3] devtools: check flow API doc tables Ferruh Yigit
2021-05-18 12:46 ` Thomas Monjalon
2021-05-14 10:51 ` Ferruh Yigit
2021-05-18 10:33 ` Thomas Monjalon
2021-05-18 13:28 ` [dpdk-dev] [PATCH v6 0/3] rte_flow doc matrix Thomas Monjalon
2021-05-18 13:28 ` [dpdk-dev] [PATCH v6 1/3] doc: rename sfc features file Thomas Monjalon
2021-05-18 13:28 ` [dpdk-dev] [PATCH v6 2/3] doc: add flow API features tables Thomas Monjalon
2021-05-18 13:28 ` [dpdk-dev] [PATCH v6 3/3] devtools: check flow API doc tables Thomas Monjalon
2021-05-18 16:54 ` [dpdk-dev] [PATCH v6 0/3] rte_flow doc matrix Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210407223320.2952469-4-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).