mbox series

[net-next,v12,00/11] Implement devlink-rate API and extend it

Message ID 20221115104825.172668-1-michal.wilczynski@intel.com (mailing list archive)
Headers show
Series Implement devlink-rate API and extend it | expand

Message

Wilczynski, Michal Nov. 15, 2022, 10:48 a.m. UTC
This patch series implements devlink-rate for ice driver. Unfortunately
current API isn't flexible enough for our use case, so there is a need to
extend it. Some functions have been introduced to enable the driver to
export current Tx scheduling configuration.

Pasting justification for this series from commit implementing devlink-rate
in ice driver(that is a part of this series):

There is a need to support modification of Tx scheduler tree, in the
ice driver. This will allow user to control Tx settings of each node in
the internal hierarchy of nodes. As a result user will be able to use
Hierarchy QoS implemented entirely in the hardware.

This patch implemenents devlink-rate API. It also exports initial
default hierarchy. It's mostly dictated by the fact that the tree
can't be removed entirely, all we can do is enable the user to modify
it. For example root node shouldn't ever be removed, also nodes that
have children are off-limits.

Example initial tree with 2 VF's:

[root@fedora ~]# devlink port function rate show
pci/0000:4b:00.0/node_27: type node parent node_26
pci/0000:4b:00.0/node_26: type node parent node_0
pci/0000:4b:00.0/node_34: type node parent node_33
pci/0000:4b:00.0/node_33: type node parent node_32
pci/0000:4b:00.0/node_32: type node parent node_16
pci/0000:4b:00.0/node_19: type node parent node_18
pci/0000:4b:00.0/node_18: type node parent node_17
pci/0000:4b:00.0/node_17: type node parent node_16
pci/0000:4b:00.0/node_21: type node parent node_20
pci/0000:4b:00.0/node_20: type node parent node_3
pci/0000:4b:00.0/node_14: type node parent node_5
pci/0000:4b:00.0/node_5: type node parent node_3
pci/0000:4b:00.0/node_13: type node parent node_4
pci/0000:4b:00.0/node_12: type node parent node_4
pci/0000:4b:00.0/node_11: type node parent node_4
pci/0000:4b:00.0/node_10: type node parent node_4
pci/0000:4b:00.0/node_9: type node parent node_4
pci/0000:4b:00.0/node_8: type node parent node_4
pci/0000:4b:00.0/node_7: type node parent node_4
pci/0000:4b:00.0/node_6: type node parent node_4
pci/0000:4b:00.0/node_4: type node parent node_3
pci/0000:4b:00.0/node_3: type node parent node_16
pci/0000:4b:00.0/node_16: type node parent node_15
pci/0000:4b:00.0/node_15: type node parent node_0
pci/0000:4b:00.0/node_2: type node parent node_1
pci/0000:4b:00.0/node_1: type node parent node_0
pci/0000:4b:00.0/node_0: type node
pci/0000:4b:00.0/1: type leaf parent node_27
pci/0000:4b:00.0/2: type leaf parent node_27

Let me visualize part of the tree:

                        +---------+
                        |  node_0 |
                        +---------+
                             |
                        +----v----+
                        | node_26 |
                        +----+----+
                             |
                        +----v----+
                        | node_27 |
                        +----+----+
                             |
                    |-----------------|
               +----v----+       +----v----+
               |   VF 1  |       |   VF 2  |
               +----+----+       +----+----+

So at this point there is a couple things that can be done.
For example we could only assign parameters to VF's.

[root@fedora ~]# devlink port function rate set pci/0000:4b:00.0/1 \
                 tx_max 5Gbps

This would cap the VF 1 BW to 5Gbps.

But let's say you would like to create a completely new branch.
This can be done like this:

[root@fedora ~]# devlink port function rate add \
                 pci/0000:4b:00.0/node_custom parent node_0
[root@fedora ~]# devlink port function rate add \
                 pci/0000:4b:00.0/node_custom_1 parent node_custom
[root@fedora ~]# devlink port function rate set \
                 pci/0000:4b:00.0/1 parent node_custom_1

This creates a completely new branch and reassigns VF 1 to it.

A number of parameters is supported per each node: tx_max, tx_share,
tx_priority and tx_weight.

V12:
 - fixed warnings
 - added comment about conversion from bytes/s to kilobits/s

V11:
 - updated documentation in ice.rst to clarify how new parameters
   are used, and describe in more detail how and when the hierarchy
   is exported/deleted, and how mutual exclusivity with DCB/ADQ
   works
 - added documentation of new parameters in devlink-port.rst
 - refactored ice_set_object_tx_priority, ice_set_object_tx_max,
   ice_set_object_tx_weight, ice_set_object_tx_share to avoid
   code duplication

V10:
 - changed attributes type from u16 to u32 as they are padded to u32
   anyway
 - changed NL_SET_ERR_MSG_MOD to NL_SET_ERR_MSG_ATTR as it points to
   a problem with specific attribute
 - fixed function parameter not described
 - added documentation in ice.rst

V9:
 - changed misleading name from 'parameter' to 'attribute'
 - removed mechanism referring for kernel object by string,
   now it's referring to them as pointers
 - removed limiting name size in devl_rate_node_create()
 - removed commit that allowed for change of priv in set_parent
   callback
 - added commit that allows for pre-allocation of ice_sched
   elements

V8:
- address minor formatting issues
- fix memory leak
- address warnings

V7:
- split into smaller commits
- paste justification for this series to cover letter

V6:
- replaced strncpy with strscpy
- renamed rate_vport -> rate_leaf

V5:
- removed queue support per community request
- fix division of 64bit variable with 32bit divisor by using div_u64()
- remove RDMA, ADQ exlusion as it's not necessary anymore
- changed how driver exports configuration, as queues are not supported
  anymore
- changed IDA to Xarray for unique node identification

V4:
- changed static variable counter to per port IDA to
  uniquely identify nodes

V3:
- removed shift macros, since FIELD_PREP is used
- added static_assert for struct
- removed unnecessary functions
- used tab instead of space in define

V2:
- fixed Alexandr comments
- refactored code to fix checkpatch issues
- added mutual exclusion for RDMA, DCB

Michal Wilczynski (11):
  devlink: Introduce new attribute 'tx_priority' to devlink-rate
  devlink: Introduce new attribute 'tx_weight' to devlink-rate
  devlink: Enable creation of the devlink-rate nodes from the driver
  devlink: Allow for devlink-rate nodes parent reassignment
  devlink: Allow to set up parent in devl_rate_leaf_create()
  ice: Introduce new parameters in ice_sched_node
  ice: Add an option to pre-allocate memory for ice_sched_node
  ice: Implement devlink-rate API
  ice: Prevent ADQ, DCB coexistence with Custom Tx scheduler
  ice: Add documentation for devlink-rate implementation
  Documentation: Add documentation for new devlink-rate attributes

 .../networking/devlink/devlink-port.rst       |  33 +-
 Documentation/networking/devlink/ice.rst      | 115 ++++
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   4 +-
 drivers/net/ethernet/intel/ice/ice_common.c   |   7 +-
 drivers/net/ethernet/intel/ice/ice_dcb.c      |   2 +-
 drivers/net/ethernet/intel/ice/ice_dcb_lib.c  |   7 +
 drivers/net/ethernet/intel/ice/ice_devlink.c  | 502 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_devlink.h  |   3 +
 drivers/net/ethernet/intel/ice/ice_main.c     |   6 +
 drivers/net/ethernet/intel/ice/ice_repr.c     |  18 +
 drivers/net/ethernet/intel/ice/ice_sched.c    | 104 +++-
 drivers/net/ethernet/intel/ice/ice_sched.h    |  31 +-
 drivers/net/ethernet/intel/ice/ice_type.h     |   9 +
 .../mellanox/mlx5/core/esw/devlink_port.c     |   4 +-
 drivers/net/netdevsim/dev.c                   |   2 +-
 include/net/devlink.h                         |  18 +-
 include/uapi/linux/devlink.h                  |   3 +
 net/core/devlink.c                            | 130 ++++-
 18 files changed, 970 insertions(+), 28 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Nov. 18, 2022, 6:30 a.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 15 Nov 2022 11:48:14 +0100 you wrote:
> This patch series implements devlink-rate for ice driver. Unfortunately
> current API isn't flexible enough for our use case, so there is a need to
> extend it. Some functions have been introduced to enable the driver to
> export current Tx scheduling configuration.
> 
> Pasting justification for this series from commit implementing devlink-rate
> in ice driver(that is a part of this series):
> 
> [...]

Here is the summary with links:
  - [net-next,v12,01/11] devlink: Introduce new attribute 'tx_priority' to devlink-rate
    https://git.kernel.org/netdev/net-next/c/cd502236835b
  - [net-next,v12,02/11] devlink: Introduce new attribute 'tx_weight' to devlink-rate
    https://git.kernel.org/netdev/net-next/c/6e2d7e84fcfe
  - [net-next,v12,03/11] devlink: Enable creation of the devlink-rate nodes from the driver
    https://git.kernel.org/netdev/net-next/c/caba177d7f4d
  - [net-next,v12,04/11] devlink: Allow for devlink-rate nodes parent reassignment
    https://git.kernel.org/netdev/net-next/c/04d674f04e32
  - [net-next,v12,05/11] devlink: Allow to set up parent in devl_rate_leaf_create()
    https://git.kernel.org/netdev/net-next/c/f2fc15e271f2
  - [net-next,v12,06/11] ice: Introduce new parameters in ice_sched_node
    https://git.kernel.org/netdev/net-next/c/16dfa49406bc
  - [net-next,v12,07/11] ice: Add an option to pre-allocate memory for ice_sched_node
    https://git.kernel.org/netdev/net-next/c/bdf96d965a20
  - [net-next,v12,08/11] ice: Implement devlink-rate API
    https://git.kernel.org/netdev/net-next/c/42c2eb6b1f43
  - [net-next,v12,09/11] ice: Prevent ADQ, DCB coexistence with Custom Tx scheduler
    https://git.kernel.org/netdev/net-next/c/80fe30a8c1f4
  - [net-next,v12,10/11] ice: Add documentation for devlink-rate implementation
    (no matching commit)
  - [net-next,v12,11/11] Documentation: Add documentation for new devlink-rate attributes
    https://git.kernel.org/netdev/net-next/c/242dd64375b8

You are awesome, thank you!