• Dmytro Linkin's avatar
    devlink: Allow setting parent node of rate objects · d7555984
    Dmytro Linkin authored
    Refactor DEVLINK_CMD_RATE_{GET|SET} command handlers to support setting
    a node as a parent for another rate object (leaf or node) by means of
    new attribute DEVLINK_ATTR_RATE_PARENT_NODE_NAME. Extend devlink ops
    with new callbacks rate_{leaf|node}_parent_set() to set node as a parent
    for rate object to allow supporting drivers to implement rate grouping
    through devlink. Driver implementations are allowed to support leafs
    or node children only. Invoking callback with NULL as parent should be
    threated by the driver as unset parent action.
    Extend rate object struct with reference counter to disallow deleting a
    node with any child pointing to it. User should unset parent for the
    child explicitly.
    
    Example:
    
    $ devlink port function rate add netdevsim/netdevsim10/group1
    
    $ devlink port function rate add netdevsim/netdevsim10/group2
    
    $ devlink port function rate set netdevsim/netdevsim10/group1 parent group2
    
    $ devlink port function rate show netdevsim/netdevsim10/group1
    netdevsim/netdevsim10/group1: type node parent group2
    
    $ devlink port function rate set netdevsim/netdevsim10/group1 noparent
    Co-developed-by: default avatarVlad Buslov <vladbu@nvidia.com>
    Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
    Signed-off-by: default avatarDmytro Linkin <dlinkin@nvidia.com>
    Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    d7555984
devlink.c 291 KB