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 2D789A0A0F; Thu, 8 Apr 2021 00:33:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 86BD7141068; Thu, 8 Apr 2021 00:33:38 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by mails.dpdk.org (Postfix) with ESMTP id 9E800141057 for ; Thu, 8 Apr 2021 00:33:35 +0200 (CEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 45D795C00E0; Wed, 7 Apr 2021 18:33:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 07 Apr 2021 18:33:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=bulYtPN0wUsJk a0jMjlQQ8Aj58Io5p0cStbiSplA/To=; b=j+CfzjaUT+9ARvEUqof+/H7UwVXLo f+W/g/JMesqy3ebkkG9/rPmfJx0FWCBtQThs+DI5W6ietw5MxIYaUNV73lp2IHjq wRN3R25M5EwGZUiY4760CmGZJiCouo5Zg6KuCo8mc/OdcLya290ZK6esUl24olXd XRUuVrIsA9PPzm/gq15k7M3D8nHOeKZwXL3iKv8Btyfe7xMSbfvrPTrvIq908gTG 6kNj1jtZuyob9lmZySS0zkh0aThPQmB67v9a9/ddLfPhSgGkQusMW0ZNh7wZfa2T IZekCt/grePFVfYJoH5WnOLNPvyGEIWmpfYJWZyrpbIeOPf97MB8cMpGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=bulYtPN0wUsJka0jMjlQQ8Aj58Io5p0cStbiSplA/To=; b=F/VyUETs a242DNNtk884yscYHgqxrS12WTpWf1kmlWOPnp2Cgw4XCgWc+ayl4HyhMgfNeUGC Mri8Z6U3jP7RFfnBhrFywyeD8kSyiDQmquDV0E+YqD4Aj3BKBJi0cVEqO0Ax/tWl IEtvkIkC4bIk70SarzCXxx1gPJAZIUz8DahcG3d2e/rrtXphdtMgKI1gwoi5NAUA dXoAZ/PfPKt802Wzqk3iVNcSbVvDuyo9JqBcIovDIkKkG9llnYA94jjhOn/X7ckS FJKs7WmgLdK5WFhPZ1pVUqgZ99ZGYBWfy48H3ClzpN14xRUapGOIhY7uSSnYGI+P KF+doVk/lYUASg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejkedguddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes mhhonhhjrghlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpedvhefgiedvjeegtdevhe efhfetleefgfeivefgffevfeejgedtgfeutdehtdegveenucfkphepjeejrddufeegrddv tdefrddukeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 439451080067; Wed, 7 Apr 2021 18:33:34 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru Date: Thu, 8 Apr 2021 00:33:20 +0200 Message-Id: <20210407223320.2952469-4-thomas@monjalon.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210407223320.2952469-1-thomas@monjalon.net> References: <1612458325-13508-1-git-send-email-asafp@nvidia.com> <20210407223320.2952469-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 3/3] devtools: check flow API doc tables 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 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 --- 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() # +{ + test -n "$(git log --format='%h' -S"$1" $trusted_commit..)" +} + +has_file_change() # +{ + 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() # +{ + 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() # +{ + 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() # +{ + case $(basename $dir) in + esac +} + +# generate INI section +list() # <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