From: Thomas Monjalon <thomas@monjalon.net> To: dev@dpdk.org Cc: ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru Subject: [dpdk-dev] [PATCH v6 3/3] devtools: check flow API doc tables Date: Tue, 18 May 2021 15:28:44 +0200 Message-ID: <20210518132844.3779728-4-thomas@monjalon.net> (raw) In-Reply-To: <20210518132844.3779728-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> --- v6 changes: - fix redundant drivers - ignore indirect action - prefix misses with a category (item or action) --- devtools/check-doc-vs-code.sh | 84 ++++++++++++++++++++++++++++++++++ devtools/parse-flow-support.sh | 78 +++++++++++++++++++++++++++++++ 2 files changed, 162 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..c58c239c87 --- /dev/null +++ b/devtools/check-doc-vs-code.sh @@ -0,0 +1,84 @@ +#! /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/..) + +# speed up by ignoring Unicode details +export LC_COLLATE=C + +result=0 +error() # <message> +{ + echo "$*" + result=$(($result + 1)) +} + +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" | + sort -u) + 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 + error "rte_flow doc out of sync for $1" + echo "$report" | sed 's,^,\t,' + 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..aeed76e55f --- /dev/null +++ b/devtools/parse-flow-support.sh @@ -0,0 +1,78 @@ +#! /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|indirect|end' +} + +if [ -z "$ref" ]; then # generate full tables + rte_flow_support item + echo + rte_flow_support action + exit 0 +fi + +# compare with reference input +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 + sed "s,^,$1 ," # prefix with category name +} + +rte_flow_compare item +rte_flow_compare action -- 2.31.1
next prev parent reply other threads:[~2021-05-18 13:29 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 ` [dpdk-dev] [PATCH v5 3/3] devtools: check flow API doc tables Thomas Monjalon 2021-05-13 18:40 ` 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 ` Thomas Monjalon [this message] 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=20210518132844.3779728-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
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://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/ https://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