2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2021 Mellanox Technologies, Ltd
5 # Parse rte_flow support of a driver directory,
6 # and optionally show difference with a doc file in .ini format.
8 dir=$1 # drivers/net/foo
9 ref=$2 # doc/guides/nics/features/foo.ini
11 if [ -z "$dir" ]; then
12 echo "directory argument is required" >&2
22 case $(basename $dir) in
24 filter=$(sed -n "/$1/{N;/TYPE_NOT_SUPPORTED/P;}" \
25 $dir/tf_ulp/ulp_template_db{,_tbl}.c |
26 grep -wo "$1[[:alnum:]_]*" | sort -u |
27 tr '\n' '|' | sed 's,.$,\n,')
36 case $(basename $dir) in
40 # generate INI section
41 list() # <title> <pattern>
44 git grep -who "$2[[:alnum:]_]*" $dir |
45 (exclude $2; include $2) | sort -u |
46 awk 'sub(/'$2'/, "") {printf "%-20s = Y\n", tolower($0)}'
49 rte_flow_support() # <category>
52 pattern=$(echo "RTE_FLOW_$1_TYPE_" | awk '{print toupper($0)}')
53 list "$title" "$pattern" | grep -vwE 'void|indirect|end'
56 if [ -z "$ref" ]; then # generate full tables
59 rte_flow_support action
63 # compare with reference input
64 rte_flow_compare() # <category>
66 section="rte_flow $1s]"
69 sed -n "/$section/,/]/p" "$ref" | sed '/^$/d'
71 sed '/]/d' | # ignore section title
72 sed 's, *=.*,,' | # ignore value (better in doc than generated one)
73 sort | uniq -u | # show differences
74 sed "s,^,$1 ," # prefix with category name
78 rte_flow_compare action