1. 01 Feb, 2023 13 commits
    • Jakub Kicinski's avatar
      docs: netlink: add a starting guide for working with specs · 01e47a37
      Jakub Kicinski authored
      We have a bit of documentation about the internals of Netlink
      and the specs, but really the goal is for most people to not
      worry about those. Add a practical guide for beginners who
      want to poke at the specs.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      01e47a37
    • Jakub Kicinski's avatar
      netlink: specs: add partial specification for ethtool · b784db7a
      Jakub Kicinski authored
      Ethtool is one of the most actively developed families.
      With the changes to the CLI it should be possible to use
      the YNL based code for easy prototyping and development.
      Add a partial family definition. I've tested the string
      set and rings. I don't have any MAC Merge implementation
      to test with, but I added the definition for it, anyway,
      because it's last. New commands can simply be added at
      the end without having to worry about manually providing
      IDs / values.
      
      Set (with notification support - None is the response,
      the data is from the notification):
      
      $ sudo ./tools/net/ynl/cli.py \
          --spec Documentation/netlink/specs/ethtool.yaml \
          --do rings-set \
          --json '{"header":{"dev-name":"enp0s31f6"}, "rx":129}' \
          --subscribe monitor
      None
      [{'msg': {'header': {'dev-index': 2, 'dev-name': 'enp0s31f6'},
                'rx': 136,
                'rx-max': 4096,
                'tx': 256,
                'tx-max': 4096,
                'tx-push': 0},
        'name': 'rings-ntf'}]
      
      Do / dump (yes, the kernel requires that even for dump and even
      if empty - the "header" nest must be there):
      
      $ ./tools/net/ynl/cli.py \
          --spec Documentation/netlink/specs/ethtool.yaml \
          --do rings-get \
          --json '{"header":{"dev-index": 2}}'
      {'header': {'dev-index': 2, 'dev-name': 'enp0s31f6'},
       'rx': 136,
       'rx-max': 4096,
       'tx': 256,
       'tx-max': 4096,
       'tx-push': 0}
      
      $ ./tools/net/ynl/cli.py \
          --spec Documentation/netlink/specs/ethtool.yaml \
          --dump rings-get \
          --json '{"header":{}}'
      [{'header': {'dev-index': 2, 'dev-name': 'enp0s31f6'},
        'rx': 136,
        'rx-max': 4096,
        'tx': 256,
        'tx-max': 4096,
        'tx-push': 0},
       {'header': {'dev-index': 3, 'dev-name': 'wlp0s20f3'}, 'tx-push': 0},
       {'header': {'dev-index': 19, 'dev-name': 'enp58s0u1u1'},
        'rx': 100,
        'rx-max': 4096,
        'tx-push': 0}]
      
      And error reporting:
      
      $ ./tools/net/ynl/cli.py \
          --spec Documentation/netlink/specs/ethtool.yaml \
          --dump rings-get \
          --json '{"header":{"flags":5}}'
      Netlink error: Invalid argument
      nl_len = 68 (52) nl_flags = 0x300 nl_type = 2
      	error: -22	extack: {'msg': 'reserved bit set',
      	                         'bad-attr-offs': 24,
      				 'bad-attr': '.header.flags'}
      None
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b784db7a
    • Jakub Kicinski's avatar
      netlink: specs: finish up operation enum-models · 8403bf04
      Jakub Kicinski authored
      I had a (bright?) idea of introducing the concept of enum-models
      to account for all the weird ways families enumerate their messages.
      I've never finished it because generating C code for each of them
      is pretty daunting. But for languages which can use ID values directly
      the support is simple enough, so clean this up a bit.
      
      "unified" model is what I recommend going forward.
      "directional" model is what ethtool uses.
      "notify-split" is used by the proposed DPLL code, but we can just
      make them use "unified", it hasn't been merged :)
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8403bf04
    • Jakub Kicinski's avatar
      tools: ynl: load jsonschema on demand · 5c6674f6
      Jakub Kicinski authored
      The CLI script tries to validate jsonschema by default.
      It's seems better to validate too many times than too few.
      However, when copying the scripts to random servers having
      to install jsonschema is tedious. Load jsonschema via
      importlib, and let the user opt out.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      5c6674f6
    • Jakub Kicinski's avatar
      tools: ynl: use operation names from spec on the CLI · 8dfec0a8
      Jakub Kicinski authored
      When I wrote the first version of the Python code I was quite
      excited that we can generate class methods directly from the
      spec. Unfortunately we need to use valid identifiers for method
      names (specifically no dashes are allowed). Don't reuse those
      names on the CLI, it's much more natural to use the operation
      names exactly as listed in the spec.
      
      Instead of:
        ./cli --do rings_get
      use:
        ./cli --do rings-get
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8dfec0a8
    • Jakub Kicinski's avatar
      tools: ynl: support pretty printing bad attribute names · 4cd2796f
      Jakub Kicinski authored
      One of my favorite features of the Netlink specs is that they
      make decoding structured extack a ton easier.
      Implement pretty printing bad attribute names in YNL.
      
      For example it will now say:
      
        'bad-attr': '.header.flags'
      
      rather than the useless:
      
        'bad-attr-offs': 32
      
      Proof:
      
        $ ./cli.py --spec ethtool.yaml --do rings_get \
           --json '{"header":{"dev-index":1, "flags":4}}'
        Netlink error: Invalid argument
        nl_len = 68 (52) nl_flags = 0x300 nl_type = 2
      	error: -22	extack: {'msg': 'reserved bit set',
      				 'bad-attr': '.header.flags'}
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4cd2796f
    • Jakub Kicinski's avatar
      tools: ynl: support multi-attr · 90256f3f
      Jakub Kicinski authored
      Ethtool uses mutli-attr, add the support to YNL.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      90256f3f
    • Jakub Kicinski's avatar
      tools: ynl: support directional enum-model in CLI · fd0616d3
      Jakub Kicinski authored
      Support families which use different IDs for messages
      to and from the kernel.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      fd0616d3
    • Jakub Kicinski's avatar
      tools: ynl: add support for types needed by ethtool · 19b64b48
      Jakub Kicinski authored
      Ethtool needs support for handful of extra types.
      It doesn't have the definitions section yet.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      19b64b48
    • Jakub Kicinski's avatar
      tools: ynl: use the common YAML loading and validation code · 30a5c6c8
      Jakub Kicinski authored
      Adapt the common object hierarchy in code gen and CLI.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      30a5c6c8
    • Jakub Kicinski's avatar
      tools: ynl: add an object hierarchy to represent parsed spec · 3aacf828
      Jakub Kicinski authored
      There's a lot of copy and pasting going on between the "cli"
      and code gen when it comes to representing the parsed spec.
      Create a library which both can use.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      3aacf828
    • Jakub Kicinski's avatar
      tools: ynl: move the cli and netlink code around · 4e4480e8
      Jakub Kicinski authored
      Move the CLI code out of samples/ and the library part
      of it into tools/net/ynl/lib/. This way we can start
      sharing some code with the code gen.
      
      Initially I thought that code gen is too C-specific to
      share anything but basic stuff like calculating values
      for enums can easily be shared.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4e4480e8
    • Jakub Kicinski's avatar
      tools: ynl-gen: prevent do / dump reordering · eaf317e7
      Jakub Kicinski authored
      An earlier fix tried to address generated code jumping around
      one code-gen run to another. Turns out dict()s are already
      ordered since Python 3.7, the problem is that we iterate over
      operation modes using a set(). Sets are unordered in Python.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      eaf317e7
  2. 31 Jan, 2023 22 commits
  3. 30 Jan, 2023 5 commits
    • David S. Miller's avatar
      Merge branch 'devlink-next' · 90e8ca0a
      David S. Miller authored
      Jakub Kicinski says:
      
      ====================
      devlink: fix reload notifications and remove features
      
      First two patches adjust notifications during devlink reload.
      The last patch removes no longer needed devlink features.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      90e8ca0a
    • Jiri Pirko's avatar
      devlink: remove devlink features · fb8421a9
      Jiri Pirko authored
      Devlink features were introduced to disallow devlink reload calls of
      userspace before the devlink was fully initialized. The reason for this
      workaround was the fact that devlink reload was originally called
      without devlink instance lock held.
      
      However, with recent changes that converted devlink reload to be
      performed under devlink instance lock, this is redundant so remove
      devlink features entirely.
      
      Note that mlx5 used this to enable devlink reload conditionally only
      when device didn't act as multi port slave. Move the multi port check
      into mlx5_devlink_reload_down() callback alongside with the other
      checks preventing the device from reload in certain states.
      Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fb8421a9
    • Jiri Pirko's avatar
      devlink: send objects notifications during devlink reload · a131315a
      Jiri Pirko authored
      Currently, the notifications are only sent for params. People who
      introduced other objects forgot to add the reload notifications here.
      
      To make sure all notifications happen according to existing comment,
      benefit from existence of devlink_notify_register/unregister() helpers
      and use them in reload code.
      Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a131315a
    • Jiri Pirko's avatar
      devlink: move devlink reload notifications back in between _down() and _up() calls · 7d7e9169
      Jiri Pirko authored
      This effectively reverts commit 05a7f4a8 ("devlink: Break parameter
      notification sequence to be before/after unload/load driver").
      
      Cited commit resolved a problem in mlx5 params implementation,
      when param notification code accessed memory previously freed
      during reload.
      
      Now, when the params can be registered and unregistered when devlink
      instance is registered, mlx5 code unregisters the problematic param
      during devlink reload. The fix is therefore no longer needed.
      
      Current behavior is a it problematic, as it sends DEL notifications even
      in potential case when reload_down() call fails which might confuse
      userspace notifications listener.
      
      So move the reload notifications back where they were originally in
      between reload_down() and reload_up() calls.
      Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7d7e9169
    • David S. Miller's avatar
      Merge branch 'sparx5-ES2-VCAP-support' · 166a1a5a
      David S. Miller authored
      Steen Hegelund says:
      
      ====================
      Adding Sparx5 ES2 VCAP support
      
      This provides the Egress Stage 2 (ES2) VCAP (Versatile Content-Aware
      Processor) support for the Sparx5 platform.
      
      The ES2 VCAP is an Egress Access Control VCAP that uses frame keyfields and
      previously classified keyfields to apply e.g. policing, trapping or
      mirroring to frames.
      
      The ES2 VCAP has 2 lookups and they are accessible with a TC chain id:
      
      - chain 20000000: ES2 Lookup 0
      - chain 20100000: ES2 Lookup 1
      
      As the other Sparx5 VCAPs the ES2 VCAP has its own lookup/port keyset
      configuration that decides which keys will be used for matching on which
      traffic type.
      
      The ES2 VCAP has these traffic classifications:
      
      - IPv4 frames
      - IPv6 frames
      - Other frames
      
      The ES2 VCAP can match on an ISDX key (Ingress Service Index) as one of the
      frame metadata keyfields.  The IS0 VCAP can update this key using its
      actions, and this allows a IS0 VCAP rule to be linked to an ES2 rule.
      
      This is similar to how the IS0 VCAP and the IS2 VCAP use the PAG
      (Policy Association Group) keyfield to link rules.
      
      From user space this is exposed via "chain offsets", so an IS0 rule with a
      "goto chain 20000015" action will use an ISDX key value of 15 to link to a
      rule in the ES2 VCAP attached to the same chain id.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      166a1a5a