mbox series

[iproute2-next,0/5] Support devlink port add delete

Message ID 20210129165608.134965-1-parav@nvidia.com
Headers show
Series Support devlink port add delete | expand

Message

Parav Pandit Jan. 29, 2021, 4:56 p.m. UTC
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 shows PCI SF port attributes
Patch-3 adds devlink commands to add and delete a port along with man
page
Patch-4 shows function state and operational state
Patch-5 enables user to set function state and adds man page
documentation

Parav Pandit (5):
  devlink: Update kernel headers
  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            | 249 ++++++++++++++++++++++++++++++++---
 include/uapi/linux/devlink.h |  25 ++++
 man/man8/devlink-port.8      | 127 ++++++++++++++++++
 3 files changed, 384 insertions(+), 17 deletions(-)

Comments

David Ahern Feb. 2, 2021, 3:20 a.m. UTC | #1
On 2/1/21 2:35 PM, Parav Pandit wrote:
> 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

> 


applied to iproute2-next.

In the future, please split additions and changes to utility functions
into a separate standalone patch.
Parav Pandit Feb. 2, 2021, 4:01 a.m. UTC | #2
> From: David Ahern <dsahern@gmail.com>

> Sent: Tuesday, February 2, 2021 8:50 AM

> 

> On 2/1/21 2:35 PM, Parav Pandit wrote:

> > 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

> >

> 

> applied to iproute2-next.

> 

> In the future, please split additions and changes to utility functions into a

> separate standalone patch.

Ok. Will do. I rebase and send v3 with the split utils functions addition into a standalone patch for vdpa tool series [1].
Thanks.
[1] https://lore.kernel.org/netdev/20210128184319.29174-1-parav@nvidia.com/