Subject: Re: [PATCH net-next v2 5/6] tools: ynl: Add fixed-header support to ynl

From: Jakub Kicinski <[email-masked]>
Date: Tue, 21 Mar 2023 22:34:40 -0700

On Sun, 19 Mar 2023 19:38:02 +0000 Donald Hunter wrote:
> -    def __init__(self, family, yaml, req_value, rsp_value):
> +    def __init__(self, family, yaml, req_value, rsp_value, default_fixed_header):
>          super().__init__(family, yaml)
>  
>          self.value = req_value if req_value == rsp_value else None
> @@ -278,6 +279,7 @@ class SpecOperation(SpecElement):
>          self.is_call = 'do' in yaml or 'dump' in yaml
>          self.is_async = 'notify' in yaml or 'event' in yaml
>          self.is_resv = not self.is_async and not self.is_call
> +        self.fixed_header = self.yaml.get('fixed-header', default_fixed_header)
>  
>          # Added by resolve:
>          self.attr_set = None
> @@ -384,24 +386,26 @@ class SpecFamily(SpecElement):
>      def new_struct(self, elem):
>          return SpecStruct(self, elem)
>  
> -    def new_operation(self, elem, req_val, rsp_val):
> -        return SpecOperation(self, elem, req_val, rsp_val)
> +    def new_operation(self, elem, req_val, rsp_val, default_fixed_header):
> +        return SpecOperation(self, elem, req_val, rsp_val, default_fixed_header)
>  
>      def add_unresolved(self, elem):
>          self._resolution_list.append(elem)
>  
>      def _dictify_ops_unified(self):
> +        default_fixed_header = self.yaml['operations'].get('fixed-header')
>          val = 1
>          for elem in self.yaml['operations']['list']:
>              if 'value' in elem:
>                  val = elem['value']
>  
> -            op = self.new_operation(elem, val, val)
> +            op = self.new_operation(elem, val, val, default_fixed_header)
>              val += 1
>  
>              self.msgs[op.name] = op
>  
>      def _dictify_ops_directional(self):
> +        default_fixed_header = self.yaml['operations'].get('fixed-header')
>          req_val = rsp_val = 1
>          for elem in self.yaml['operations']['list']:
>              if 'notify' in elem:
> @@ -426,7 +430,7 @@ class SpecFamily(SpecElement):
>              else:
>                  raise Exception("Can't parse directional ops")
>  
> -            op = self.new_operation(elem, req_val, rsp_val)
> +            op = self.new_operation(elem, req_val, rsp_val, default_fixed_header)

Can we record the "family-default" fixed header in the family and read
from there rather than passing the arg around?

Also - doc - to be clear - by documentation I mean in the right places
under Documentation/user-api/netlink/