Skip to content

Support devlink port add delete

Parav Pandit netdev 2 versions – Applied

Status from this message: applied to iproute2-next.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 2 repliesApplied
  2. v15 patches 4 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/6devlink: Update kernel headersinclude/uapi/linux/devlink.h+25 -00 replies
2/6devlink: Introduce and use string to number mapperdevlink/devlink.c include/utils.h lib/utils.c+50 -160 replies
3/6devlink: Introduce PCI SF port flavour and attributedevlink/devlink.c+8 -20 replies
4/6devlink: Supporting add and delete of devlink portdevlink/devlink.c man/man8/devlink-port.8+171 -00 replies
5/6devlink: Support get port function statedevlink/devlink.c include/utils.h lib/utils.c+67 -80 replies
6/6devlink: Support set of port function statedevlink/devlink.c man/man8/devlink-port.8+110 -90 replies

Reviews trailers per patch

4 of 6 patches have a Reviewed-by or Acked-by.

PatchJiri Pirko
1/6
2/6
3/6R-b
4/6R-b
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH iproute2-next v2 0/6] Support devlink port add delete

This patchset implements devlink port add, delete and function state management commands.

An example sequence for a PCI SF:

Set the device in switchdev mode:

$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev

View ports in switchdev mode:

$ devlink port show
pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false

Add a subfunction port for PCI PF 0 with sfnumber 88:

$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
pci/0000:08:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state inactive opstate detached

Show a newly added port:

$ devlink port show pci/0000:06:00.0/32768
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state inactive opstate detached

Set the function state to active:

$ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state active

Show the port in JSON format:

$ devlink port show pci/0000:06:00.0/32768 -jp
{
    "port": {
        "pci/0000:06:00.0/32768": {
            "type": "eth",
            "netdev": "ens2f0npf0sf88",
            "flavour": "pcisf",
            "controller": 0,
            "pfnum": 0,
            "sfnum": 88,
            "splittable": false,
            "function": {
                "hw_addr": "00:00:00:00:88:88",
                "state": "active",
                "opstate": "attached"
            }
        }
    }
}

Set the function state to active:

$ devlink port function set pci/0000:06:00.0/32768 state inactive

Delete the port after use:

$ devlink port del pci/0000:06:00.0/32768

Patch summary:
Patch-1 updates kernel headers
Patch-2 introduces string to number map helper and uses it for port flavour
Patch-3 shows PCI SF port attributes
Patch-4 adds devlink commands to add and delete a port along with man page
Patch-5 shows function state and operational state to user Patch-6 enables user to set function state and adds man page documentation

Parav Pandit (6):
devlink: Update kernel headers
devlink: Introduce and use string to number mapper
devlink: Introduce PCI SF port flavour and attribute
devlink: Supporting add and delete of devlink port
devlink: Support get port function state
devlink: Support set of port function state

 devlink/devlink.c            | 260 ++++++++++++++++++++++++++++++-----
 include/uapi/linux/devlink.h |  25 ++++
 include/utils.h              |   9 ++
 lib/utils.c                  |  41 ++++++
 man/man8/devlink-port.8      | 127 +++++++++++++++++
 5 files changed, 429 insertions(+), 33 deletions(-)
Signature · 1 line
2.26.2