[dpdk-dev] [PATCH 3/3] drivers: align log names
David Marchand
david.marchand at redhat.com
Fri Mar 19 17:29:25 CET 2021
On Wed, Mar 10, 2021 at 3:02 PM Thomas Monjalon <thomas at monjalon.net> wrote:
>
> The log levels are configured by using the name of the logs.
> Some drivers are aligned to follow a common log name standard:
> pmd.class.driver[.sub]
> Some "common" drivers skip the "class" part:
> pmd.driver.sub
Without a check, this is likely to happen again.
I cooked this:
diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 78a408ef98..dc52569792 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -199,6 +199,41 @@ check_internal_tags() { # <patch>
return $res
}
+check_log_levels() { # <patch>
+ res=0
+
+ cat "$1" |awk '
+ BEGIN {
+ pattern = "";
+ ret = 0;
+ }
+ /^+++ b\// {
+ count = split($2, path, "/")
+ if (count >= 4 && path[2] == "lib") {
+ pattern = "lib\\." gensub(/librte_(.*)/,
"\\1", "", path[3])
+ } else if (count >= 5 && path[2] == "drivers") {
+ pattern = "pmd\\." path[3] "\\." path[4]
+ } else {
+ pattern = "";
+ }
+ }
+ /^+.*RTE_LOG_REGISTER\([^,]+,[^,]+,/ {
+ if (pattern == "") {
+ next;
+ }
+ if (! ($0 ~ "RTE_LOG_REGISTER\\([^,]+, " pattern
"(|\\.[^,]+),")) {
+ print $0
+ print "Added logtype does not comply with
pattern: " gensub(/\\/, "", "g", pattern)
+ ret = 1;
+ }
+ }
+ END {
+ exit ret;
+ }' || res=1
+
+ return $res
+}
+
number=0
range='origin/main..'
quiet=false
@@ -290,6 +325,14 @@ check () { # <patch> <commit> <title>
ret=1
fi
+ ! $verbose || printf '\nChecking RTE_LOG_REGISTER:\n'
+ report=$(check_log_levels "$tmpinput")
+ if [ $? -ne 0 ] ; then
+ $headline_printed || print_headline "$3"
+ printf '%s\n' "$report"
+ ret=1
+ fi
+
if [ "$tmpinput" != "$1" ]; then
rm -f "$tmpinput"
trap - INT
Which for following patch:
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 761a0f26bb..ef6e3b2d0c 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -8452,7 +8452,8 @@ RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "*
igb_uio | vfio-pci");
RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe_vf,
IXGBEVF_DEVARG_PFLINK_FULLCHK "=<0|1>");
-RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgbe.init, NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgb.init, NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgbe.plop, NOTICE);
RTE_LOG_REGISTER(ixgbe_logtype_driver, pmd.net.ixgbe.driver, NOTICE);
#ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
diff --git a/lib/librte_compressdev/rte_compressdev.c
b/lib/librte_compressdev/rte_compressdev.c
index 49a342f400..d444685053 100644
--- a/lib/librte_compressdev/rte_compressdev.c
+++ b/lib/librte_compressdev/rte_compressdev.c
@@ -764,3 +764,5 @@ rte_compressdev_name_get(uint8_t dev_id)
}
RTE_LOG_REGISTER(compressdev_logtype, lib.compressdev, NOTICE);
+RTE_LOG_REGISTER(compressdev_logtype, lib.compressdev, NOTICE);
+RTE_LOG_REGISTER(compressdev_logtype, lib.compressde, NOTICE);
Triggers:
$ ./devtools/checkpatches.sh -n1
...
+RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgb.init, NOTICE);
Added logtype does not comply with pattern: pmd.net.ixgbe
+RTE_LOG_REGISTER(compressdev_logtype, lib.compressde, NOTICE);
Added logtype does not comply with pattern: lib.compressdev
WDYT?
--
David Marchand
More information about the dev
mailing list