Let's check that the code and the documentation are aligned for VMDq capability.
Some driver directory hosts multiple drivers that have multiple corresponding entry in doc/guides/features/. For this case, only try to detect a discrepancy if any doc announce a feature but no code can be found. Note: net/atlantic and net/cxgbe were forcibly setting some fields in dev_info to 0, which is unneeded since ethdev already clears the structure. Signed-off-by: David Marchand <[email protected]> --- Changes since v2: - inverted logic: Changes since v1: - added helper for checking mq capabilities, - added handling of multi drivers, - moved net/atlantic and net/cxgbe cleanups here, --- devtools/check-doc-vs-code.sh | 50 +++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_ethdev.c | 2 -- drivers/net/cxgbe/cxgbe_ethdev.c | 1 - 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/devtools/check-doc-vs-code.sh b/devtools/check-doc-vs-code.sh index 7afc18d153..e84b003a51 100755 --- a/devtools/check-doc-vs-code.sh +++ b/devtools/check-doc-vs-code.sh @@ -161,10 +161,54 @@ check_rte_flow() # <driver> fi } +has_doc_feature() # <ini_file> <feature> +{ + grep -q "^$2[[:space:]]*=[[:space:]]*[YP]" "$1" +} + +# check if any doc for a code directory has a feature +any_doc_has_feature() # <code_dir> <feature> +{ + for drv in $(docs_for_code $1); do + d=$rootdir/doc/guides/nics/features/$drv.ini + if has_doc_feature "$d" "$2"; then + return 0 + fi + done + return 1 +} + +check_mq_cap() # <driver> <feature> <indicator> <code_pattern> <mq_pattern> +{ + if has_doc_feature "$doc" "$2"; then + # doc claims feature, code must have it + git grep -qE "$4" -- "$code" || + error "$2 documented but $3 not set for $1" + elif ! any_doc_has_feature "$code" "$2"; then + # check code->doc only if no doc for the code directory has the feature + ! git grep -qE "$4" -- "$code" || + error "$3 set but $2 not documented for $1" + ! git grep -qE "$5" -- "$code" || + error "$2 mq_mode referenced but $2 not documented for $1" + fi +} + +check_mq_caps() # <driver> +{ + code=$(driver_code_dir $1) + doc=$rootdir/doc/guides/nics/features/$1.ini + [ -d $code ] || return 0 + [ -f $doc ] || return 0 + + check_mq_cap $1 "VMDq" "max_vmdq_pools" 'max_vmdq_pools[[:space:]]*=' \ + 'RTE_ETH_MQ_(RX|TX).*VMDQ' +} + if [ -z "$trusted_commit" ]; then # check all for driver in $(all_net_drivers); do check_rte_flow $driver + check_mq_caps $driver done exit $result fi @@ -176,4 +220,10 @@ if has_code_change 'RTE_FLOW_.*_TYPE_' || check_rte_flow $driver done fi +if has_code_change 'max_vmdq_pools|RTE_ETH_MQ_.*VMDQ' || + has_file_change 'doc/guides/nics/features'; then + for driver in $(changed_net_drivers); do + check_mq_caps $driver + done +fi exit $result diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 24184bdb18..44a65d7557 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -1106,8 +1106,6 @@ atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_vfs = pci_dev->max_vfs; dev_info->max_hash_mac_addrs = 0; - dev_info->max_vmdq_pools = 0; - dev_info->vmdq_queue_num = 0; dev_info->rx_offload_capa = ATL_RX_OFFLOADS; diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 82e67eeff1..93554f354c 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -129,7 +129,6 @@ int cxgbe_dev_info_get(struct rte_eth_dev *eth_dev, device_info->max_mac_addrs = 1; /* XXX: For now we support one MAC/port */ device_info->max_vfs = adapter->params.arch.vfcount; - device_info->max_vmdq_pools = 0; /* XXX: For now no support for VMDQ */ device_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP; -- 2.54.0

