diff mbox series

[RFC,net-next,v1,5/6] tools: ynl: ethtool.py: Make tool invokable from any CWD

Message ID 20240223192658.45893-6-rrameshbabu@nvidia.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series ethtool HW timestamping statistics | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Rahul Rameshbabu Feb. 23, 2024, 7:24 p.m. UTC
ethtool.py depends on yml files in a specific location of the linux kernel
tree. Using relative lookup for those files means that ethtool.py would
need to be run under tools/net/ynl/. Lookup needed yml files without
depending on the current working directory that ethtool.py is invoked from.

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
---
 tools/net/ynl/ethtool.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Jacob Keller Feb. 23, 2024, 9:08 p.m. UTC | #1
On 2/23/2024 11:24 AM, Rahul Rameshbabu wrote:
> ethtool.py depends on yml files in a specific location of the linux kernel
> tree. Using relative lookup for those files means that ethtool.py would
> need to be run under tools/net/ynl/. Lookup needed yml files without
> depending on the current working directory that ethtool.py is invoked from.
> 
> Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> ---
>  tools/net/ynl/ethtool.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/net/ynl/ethtool.py b/tools/net/ynl/ethtool.py
> index 6c9f7e31250c..44ba3ba58ed9 100755
> --- a/tools/net/ynl/ethtool.py
> +++ b/tools/net/ynl/ethtool.py
> @@ -6,6 +6,7 @@ import json
>  import pprint
>  import sys
>  import re
> +import os
>  
>  from lib import YnlFamily
>  
> @@ -152,8 +153,11 @@ def main():
>      global args
>      args = parser.parse_args()
>  
> -    spec = '../../../Documentation/netlink/specs/ethtool.yaml'
> -    schema = '../../../Documentation/netlink/genetlink-legacy.yaml'
> +    script_abs_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
> +    spec = os.path.join(script_abs_dir,
> +                        '../../../Documentation/netlink/specs/ethtool.yaml')
> +    schema = os.path.join(script_abs_dir,
> +                          '../../../Documentation/netlink/genetlink-legacy.yaml')
>  

This seems like a worthwhile improvement to make the tool more usable.

Thanks,
Jake

>      ynl = YnlFamily(spec, schema)
>
Rahul Rameshbabu Feb. 23, 2024, 10:39 p.m. UTC | #2
On Fri, 23 Feb, 2024 13:08:34 -0800 Jacob Keller <jacob.e.keller@intel.com> wrote:
> On 2/23/2024 11:24 AM, Rahul Rameshbabu wrote:
>> ethtool.py depends on yml files in a specific location of the linux kernel
>> tree. Using relative lookup for those files means that ethtool.py would
>> need to be run under tools/net/ynl/. Lookup needed yml files without
>> depending on the current working directory that ethtool.py is invoked from.
>> 
>> Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
>> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
>> ---
>>  tools/net/ynl/ethtool.py | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>> 
>> diff --git a/tools/net/ynl/ethtool.py b/tools/net/ynl/ethtool.py
>> index 6c9f7e31250c..44ba3ba58ed9 100755
>> --- a/tools/net/ynl/ethtool.py
>> +++ b/tools/net/ynl/ethtool.py
>> @@ -6,6 +6,7 @@ import json
>>  import pprint
>>  import sys
>>  import re
>> +import os
>>  
>>  from lib import YnlFamily
>>  
>> @@ -152,8 +153,11 @@ def main():
>>      global args
>>      args = parser.parse_args()
>>  
>> -    spec = '../../../Documentation/netlink/specs/ethtool.yaml'
>> -    schema = '../../../Documentation/netlink/genetlink-legacy.yaml'
>> +    script_abs_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
>> +    spec = os.path.join(script_abs_dir,
>> +                        '../../../Documentation/netlink/specs/ethtool.yaml')
>> +    schema = os.path.join(script_abs_dir,
>> +                          '../../../Documentation/netlink/genetlink-legacy.yaml')
>>  
>
> This seems like a worthwhile improvement to make the tool more usable.
>

Unfortunately, even though in the next patch after this one where I add
the ts stats group as a comment, the tool seems to fail at rendering the
actual counters of the stats group, so I had to use the ethtool tree to
test. I should look into that, so that way other contributors such as
Intel can simply use this script to test that they hooked into the
ethtool ts stats interface correctly.

--
Thanks,

Rahul Rameshbabu
Jakub Kicinski Feb. 29, 2024, 2:08 a.m. UTC | #3
On Fri, 23 Feb 2024 14:39:07 -0800 Rahul Rameshbabu wrote:
> Unfortunately, even though in the next patch after this one where I add
> the ts stats group as a comment, the tool seems to fail at rendering the
> actual counters of the stats group, so I had to use the ethtool tree to
> test. I should look into that, so that way other contributors such as
> Intel can simply use this script to test that they hooked into the
> ethtool ts stats interface correctly.

IIRC some attribute nesting in ETHTOOL_MSG_STATS_GET is too "creative"
for the YAML specs. Using the ETHTOOL_FLAG_STATS path should avoid this
problem.
diff mbox series

Patch

diff --git a/tools/net/ynl/ethtool.py b/tools/net/ynl/ethtool.py
index 6c9f7e31250c..44ba3ba58ed9 100755
--- a/tools/net/ynl/ethtool.py
+++ b/tools/net/ynl/ethtool.py
@@ -6,6 +6,7 @@  import json
 import pprint
 import sys
 import re
+import os
 
 from lib import YnlFamily
 
@@ -152,8 +153,11 @@  def main():
     global args
     args = parser.parse_args()
 
-    spec = '../../../Documentation/netlink/specs/ethtool.yaml'
-    schema = '../../../Documentation/netlink/genetlink-legacy.yaml'
+    script_abs_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
+    spec = os.path.join(script_abs_dir,
+                        '../../../Documentation/netlink/specs/ethtool.yaml')
+    schema = os.path.join(script_abs_dir,
+                          '../../../Documentation/netlink/genetlink-legacy.yaml')
 
     ynl = YnlFamily(spec, schema)