raw/cnxk_bphy: support telemetry
[dpdk.git] / devtools / parse-flow-support.sh
1 #! /bin/sh -e
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2021 Mellanox Technologies, Ltd
4
5 # Parse rte_flow support of a driver directory,
6 # and optionally show difference with a doc file in .ini format.
7
8 dir=$1 # drivers/net/foo
9 ref=$2 # doc/guides/nics/features/foo.ini
10
11 if [ -z "$dir" ]; then
12         echo "directory argument is required" >&2
13         exit 1
14 fi
15
16 # sorting order
17 export LC_COLLATE=C
18
19 # exclude exceptions
20 exclude() # <pattern>
21 {
22         case $(basename $dir) in
23                 bnxt)
24                         filter=$(sed -n "/$1/{N;/TYPE_NOT_SUPPORTED/P;}" \
25                                 $dir/tf_ulp/ulp_rte_handler_tbl.c |
26                                 grep -wo "$1[[:alnum:]_]*" | sort -u |
27                                 tr '\n' '|' | sed 's,.$,\n,')
28                         exceptions='RTE_FLOW_ACTION_TYPE_SHARED'
29                         grep -vE "$filter" | grep -vE $exceptions;;
30                 *) cat
31         esac
32 }
33
34 # include exceptions
35 include() # <pattern>
36 {
37         case $(basename $dir) in
38         esac
39 }
40
41 # generate INI section
42 list() # <title> <pattern>
43 {
44         echo "[$1]"
45         git grep -who "$2[[:alnum:]_]*" $dir |
46         (exclude $2; include $2) | sort -u |
47         awk 'sub(/'$2'/, "") {printf "%-20s = Y\n", tolower($0)}'
48 }
49
50 rte_flow_support() # <category>
51 {
52         title="rte_flow $1s"
53         pattern=$(echo "RTE_FLOW_$1_TYPE_" | awk '{print toupper($0)}')
54         list "$title" "$pattern" | grep -vwE 'void|indirect|end'
55 }
56
57 if [ -z "$ref" ]; then # generate full tables
58         rte_flow_support item
59         echo
60         rte_flow_support action
61         exit 0
62 fi
63
64 # compare with reference input
65 rte_flow_compare() # <category>
66 {
67         section="rte_flow $1s]"
68         {
69                 rte_flow_support $1
70                 sed -n "/$section/,/]/p" "$ref" | sed '/^$/d'
71         } |
72         sed '/]/d' | # ignore section title
73         sed 's, *=.*,,' | # ignore value (better in doc than generated one)
74         sort | uniq -u | # show differences
75         sed "s,^,$1 ," # prefix with category name
76 }
77
78 rte_flow_compare item
79 rte_flow_compare action