diff mbox series

[net-next,3/8] devlink: Extend devlink rate API with traffic classes bandwidth management

Message ID 20241113180034.714102-4-tariqt@nvidia.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net/mlx5: ConnectX-8 SW Steering + Rate management on traffic classes | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl fail Tree is dirty after regen; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success Errors and warnings before: 0 (+0) this patch: 0 (+0)
netdev/cc_maintainers warning 3 maintainers not CCed: donald.hunter@gmail.com horms@kernel.org swarupkotikalapudi@gmail.com
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 528 this patch: 528
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 82 exceeds 80 columns WARNING: line length of 86 exceeds 80 columns WARNING: line length of 87 exceeds 80 columns WARNING: line length of 88 exceeds 80 columns WARNING: line length of 90 exceeds 80 columns WARNING: line length of 94 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

Tariq Toukan Nov. 13, 2024, 6 p.m. UTC
From: Carolina Jubran <cjubran@nvidia.com>

Introduce support for specifying bandwidth proportions between traffic
classes (TC) in the devlink-rate API. This new option allows users to
allocate bandwidth across multiple traffic classes in a single command.

This feature provides a more granular control over traffic management,
especially for scenarios requiring Enhanced Transmission Selection.

Users can now define a specific bandwidth share for each traffic class,
such as allocating 20% for TC0 (TCP/UDP) and 80% for TC5 (RoCE).

Example:
DEV=pci/0000:08:00.0

$ devlink port function rate add $DEV/vfs_group tx_share 10Gbit \
  tx_max 50Gbit tc-bw 0:20 1:0 2:0 3:0 4:0 5:80 6:0 7:0

$ devlink port function rate set $DEV/vfs_group \
  tc-bw 0:20 1:0 2:0 3:0 4:0 5:10 6:60 7:0

Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 Documentation/netlink/specs/devlink.yaml | 50 ++++++++++++++++++++
 include/net/devlink.h                    |  6 +++
 include/uapi/linux/devlink.h             | 10 ++++
 net/devlink/netlink_gen.c                | 21 +++++++--
 net/devlink/netlink_gen.h                |  1 +
 net/devlink/rate.c                       | 60 ++++++++++++++++++++++--
 6 files changed, 141 insertions(+), 7 deletions(-)

Comments

kernel test robot Nov. 13, 2024, 11:22 p.m. UTC | #1
Hi Tariq,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Tariq-Toukan/net-mlx5-DR-expand-SWS-STE-callbacks-and-consolidate-common-structs/20241114-022031
base:   net-next/main
patch link:    https://lore.kernel.org/r/20241113180034.714102-4-tariqt%40nvidia.com
patch subject: [PATCH net-next 3/8] devlink: Extend devlink rate API with traffic classes bandwidth management
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20241114/202411140730.KCvy3X1m-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241114/202411140730.KCvy3X1m-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411140730.KCvy3X1m-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from net/devlink/core.c:7:
   In file included from include/net/genetlink.h:5:
   In file included from include/linux/net.h:24:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from net/devlink/core.c:9:
   In file included from include/trace/events/devlink.h:11:
>> include/net/devlink.h:121:12: error: use of undeclared identifier 'IEEE_8021QAZ_MAX_TCS'
     121 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |                   ^
   In file included from net/devlink/core.c:11:
   net/devlink/devl_internal.h:29:19: warning: arithmetic between different enumeration types ('enum devlink_reload_limit' and 'enum devlink_reload_action') [-Wenum-enum-conversion]
      29 |         u32 reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE];
         |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:26:30: note: expanded from macro 'DEVLINK_RELOAD_STATS_ARRAY_SIZE'
      26 |         (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX)
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:30:26: warning: arithmetic between different enumeration types ('enum devlink_reload_limit' and 'enum devlink_reload_action') [-Wenum-enum-conversion]
      30 |         u32 remote_reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE];
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:26:30: note: expanded from macro 'DEVLINK_RELOAD_STATS_ARRAY_SIZE'
      26 |         (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX)
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   6 warnings and 1 error generated.
--
   In file included from net/devlink/dev.c:8:
   In file included from include/net/genetlink.h:5:
   In file included from include/linux/net.h:24:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from net/devlink/dev.c:10:
   In file included from net/devlink/devl_internal.h:14:
>> include/net/devlink.h:121:12: error: use of undeclared identifier 'IEEE_8021QAZ_MAX_TCS'
     121 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |                   ^
   In file included from net/devlink/dev.c:10:
   net/devlink/devl_internal.h:29:19: warning: arithmetic between different enumeration types ('enum devlink_reload_limit' and 'enum devlink_reload_action') [-Wenum-enum-conversion]
      29 |         u32 reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE];
         |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:26:30: note: expanded from macro 'DEVLINK_RELOAD_STATS_ARRAY_SIZE'
      26 |         (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX)
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:30:26: warning: arithmetic between different enumeration types ('enum devlink_reload_limit' and 'enum devlink_reload_action') [-Wenum-enum-conversion]
      30 |         u32 remote_reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE];
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:26:30: note: expanded from macro 'DEVLINK_RELOAD_STATS_ARRAY_SIZE'
      26 |         (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX)
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/dev.c:335:20: warning: arithmetic between different enumeration types ('enum devlink_reload_limit' and 'enum devlink_reload_action') [-Wenum-enum-conversion]
     335 |                 stat_idx = limit * __DEVLINK_RELOAD_ACTION_MAX + action;
         |                            ~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/dev.c:447:26: warning: arithmetic between different enumeration types ('enum devlink_reload_limit' and 'enum devlink_reload_action') [-Wenum-enum-conversion]
     447 |         u32 remote_reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE];
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:26:30: note: expanded from macro 'DEVLINK_RELOAD_STATS_ARRAY_SIZE'
      26 |         (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX)
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   8 warnings and 1 error generated.
--
   In file included from net/devlink/rate.c:7:
   In file included from net/devlink/devl_internal.h:7:
   In file included from include/linux/etherdevice.h:20:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:8:
   In file included from include/linux/cacheflush.h:5:
   In file included from arch/x86/include/asm/cacheflush.h:5:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from net/devlink/rate.c:7:
   In file included from net/devlink/devl_internal.h:14:
>> include/net/devlink.h:121:12: error: use of undeclared identifier 'IEEE_8021QAZ_MAX_TCS'
     121 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |                   ^
   In file included from net/devlink/rate.c:7:
   net/devlink/devl_internal.h:29:19: warning: arithmetic between different enumeration types ('enum devlink_reload_limit' and 'enum devlink_reload_action') [-Wenum-enum-conversion]
      29 |         u32 reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE];
         |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:26:30: note: expanded from macro 'DEVLINK_RELOAD_STATS_ARRAY_SIZE'
      26 |         (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX)
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:30:26: warning: arithmetic between different enumeration types ('enum devlink_reload_limit' and 'enum devlink_reload_action') [-Wenum-enum-conversion]
      30 |         u32 remote_reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE];
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/devlink/devl_internal.h:26:30: note: expanded from macro 'DEVLINK_RELOAD_STATS_ARRAY_SIZE'
      26 |         (__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX)
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> net/devlink/rate.c:133:18: error: use of undeclared identifier 'IEEE_8021QAZ_MAX_TCS'
     133 |         for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
         |                         ^
   net/devlink/rate.c:335:12: error: use of undeclared identifier 'IEEE_8021QAZ_MAX_TCS'
     335 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |                   ^
   net/devlink/rate.c:405:19: error: use of undeclared identifier 'IEEE_8021QAZ_MAX_TCS'
     405 |                 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
         |                                 ^
   6 warnings and 4 errors generated.
--
   In file included from drivers/net/ethernet/intel/i40e/i40e_main.c:5:
   In file included from include/linux/crash_dump.h:5:
   In file included from include/linux/kexec.h:18:
   In file included from include/linux/vmcore_info.h:6:
   In file included from include/linux/elfcore.h:11:
   In file included from include/linux/ptrace.h:10:
   In file included from include/linux/pid_namespace.h:7:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/ethernet/intel/i40e/i40e_main.c:13:
   In file included from drivers/net/ethernet/intel/i40e/i40e.h:13:
>> include/net/devlink.h:121:12: error: use of undeclared identifier 'IEEE_8021QAZ_MAX_TCS'
     121 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |                   ^
   drivers/net/ethernet/intel/i40e/i40e_main.c:15639:46: warning: shift count >= width of type [-Wshift-count-overflow]
    15639 |         err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
          |                                                     ^~~~~~~~~~~~~~~~
   include/linux/dma-mapping.h:77:54: note: expanded from macro 'DMA_BIT_MASK'
      77 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
         |                                                      ^ ~~~
   5 warnings and 1 error generated.
--
   In file included from drivers/net/ethernet/intel/i40e/i40e_ethtool.c:8:
   In file included from drivers/net/ethernet/intel/i40e/i40e_txrx_common.h:7:
   In file included from drivers/net/ethernet/intel/i40e/i40e.h:7:
   In file included from include/linux/linkmode.h:5:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:8:
   In file included from include/linux/cacheflush.h:5:
   In file included from arch/x86/include/asm/cacheflush.h:5:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/ethernet/intel/i40e/i40e_ethtool.c:8:
   In file included from drivers/net/ethernet/intel/i40e/i40e_txrx_common.h:7:
   In file included from drivers/net/ethernet/intel/i40e/i40e.h:13:
>> include/net/devlink.h:121:12: error: use of undeclared identifier 'IEEE_8021QAZ_MAX_TCS'
     121 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |                   ^
   4 warnings and 1 error generated.


vim +/IEEE_8021QAZ_MAX_TCS +121 include/net/devlink.h

   100	
   101	struct devlink_rate {
   102		struct list_head list;
   103		enum devlink_rate_type type;
   104		struct devlink *devlink;
   105		void *priv;
   106		u64 tx_share;
   107		u64 tx_max;
   108	
   109		struct devlink_rate *parent;
   110		union {
   111			struct devlink_port *devlink_port;
   112			struct {
   113				char *name;
   114				refcount_t refcnt;
   115			};
   116		};
   117	
   118		u32 tx_priority;
   119		u32 tx_weight;
   120	
 > 121		u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
   122	};
   123
kernel test robot Nov. 14, 2024, 12:05 a.m. UTC | #2
Hi Tariq,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Tariq-Toukan/net-mlx5-DR-expand-SWS-STE-callbacks-and-consolidate-common-structs/20241114-022031
base:   net-next/main
patch link:    https://lore.kernel.org/r/20241113180034.714102-4-tariqt%40nvidia.com
patch subject: [PATCH net-next 3/8] devlink: Extend devlink rate API with traffic classes bandwidth management
config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20241114/202411140704.LBU1Zf9c-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241114/202411140704.LBU1Zf9c-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411140704.LBU1Zf9c-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/net/dsa.h:22,
                    from net/core/flow_dissector.c:9:
>> include/net/devlink.h:121:19: error: 'IEEE_8021QAZ_MAX_TCS' undeclared here (not in a function)
     121 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |                   ^~~~~~~~~~~~~~~~~~~~


vim +/IEEE_8021QAZ_MAX_TCS +121 include/net/devlink.h

   100	
   101	struct devlink_rate {
   102		struct list_head list;
   103		enum devlink_rate_type type;
   104		struct devlink *devlink;
   105		void *priv;
   106		u64 tx_share;
   107		u64 tx_max;
   108	
   109		struct devlink_rate *parent;
   110		union {
   111			struct devlink_port *devlink_port;
   112			struct {
   113				char *name;
   114				refcount_t refcnt;
   115			};
   116		};
   117	
   118		u32 tx_priority;
   119		u32 tx_weight;
   120	
 > 121		u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
   122	};
   123
kernel test robot Nov. 14, 2024, 12:46 a.m. UTC | #3
Hi Tariq,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Tariq-Toukan/net-mlx5-DR-expand-SWS-STE-callbacks-and-consolidate-common-structs/20241114-022031
base:   net-next/main
patch link:    https://lore.kernel.org/r/20241113180034.714102-4-tariqt%40nvidia.com
patch subject: [PATCH net-next 3/8] devlink: Extend devlink rate API with traffic classes bandwidth management
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20241114/202411140820.ybeyWmcE-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241114/202411140820.ybeyWmcE-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411140820.ybeyWmcE-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from net/devlink/devl_internal.h:14,
                    from net/devlink/rate.c:7:
   include/net/devlink.h:121:19: error: 'IEEE_8021QAZ_MAX_TCS' undeclared here (not in a function)
     121 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |                   ^~~~~~~~~~~~~~~~~~~~
   net/devlink/rate.c: In function 'devlink_nl_rate_set':
>> net/devlink/rate.c:335:13: warning: unused variable 'tc_bw' [-Wunused-variable]
     335 |         u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
         |             ^~~~~


vim +/tc_bw +335 net/devlink/rate.c

   329	
   330	static int devlink_nl_rate_set(struct devlink_rate *devlink_rate,
   331				       const struct devlink_ops *ops,
   332				       struct genl_info *info)
   333	{
   334		struct nlattr *nla_parent, **attrs = info->attrs;
 > 335		u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
   336		int err = -EOPNOTSUPP;
   337		u32 priority;
   338		u32 weight;
   339		u64 rate;
   340	
   341		if (attrs[DEVLINK_ATTR_RATE_TX_SHARE]) {
   342			rate = nla_get_u64(attrs[DEVLINK_ATTR_RATE_TX_SHARE]);
   343			if (devlink_rate_is_leaf(devlink_rate))
   344				err = ops->rate_leaf_tx_share_set(devlink_rate, devlink_rate->priv,
   345								  rate, info->extack);
   346			else if (devlink_rate_is_node(devlink_rate))
   347				err = ops->rate_node_tx_share_set(devlink_rate, devlink_rate->priv,
   348								  rate, info->extack);
   349			if (err)
   350				return err;
   351			devlink_rate->tx_share = rate;
   352		}
   353	
   354		if (attrs[DEVLINK_ATTR_RATE_TX_MAX]) {
   355			rate = nla_get_u64(attrs[DEVLINK_ATTR_RATE_TX_MAX]);
   356			if (devlink_rate_is_leaf(devlink_rate))
   357				err = ops->rate_leaf_tx_max_set(devlink_rate, devlink_rate->priv,
   358								rate, info->extack);
   359			else if (devlink_rate_is_node(devlink_rate))
   360				err = ops->rate_node_tx_max_set(devlink_rate, devlink_rate->priv,
   361								rate, info->extack);
   362			if (err)
   363				return err;
   364			devlink_rate->tx_max = rate;
   365		}
   366	
   367		if (attrs[DEVLINK_ATTR_RATE_TX_PRIORITY]) {
   368			priority = nla_get_u32(attrs[DEVLINK_ATTR_RATE_TX_PRIORITY]);
   369			if (devlink_rate_is_leaf(devlink_rate))
   370				err = ops->rate_leaf_tx_priority_set(devlink_rate, devlink_rate->priv,
   371								     priority, info->extack);
   372			else if (devlink_rate_is_node(devlink_rate))
   373				err = ops->rate_node_tx_priority_set(devlink_rate, devlink_rate->priv,
   374								     priority, info->extack);
   375	
   376			if (err)
   377				return err;
   378			devlink_rate->tx_priority = priority;
   379		}
   380	
   381		if (attrs[DEVLINK_ATTR_RATE_TX_WEIGHT]) {
   382			weight = nla_get_u32(attrs[DEVLINK_ATTR_RATE_TX_WEIGHT]);
   383			if (devlink_rate_is_leaf(devlink_rate))
   384				err = ops->rate_leaf_tx_weight_set(devlink_rate, devlink_rate->priv,
   385								   weight, info->extack);
   386			else if (devlink_rate_is_node(devlink_rate))
   387				err = ops->rate_node_tx_weight_set(devlink_rate, devlink_rate->priv,
   388								   weight, info->extack);
   389	
   390			if (err)
   391				return err;
   392			devlink_rate->tx_weight = weight;
   393		}
   394	
   395		if (attrs[DEVLINK_ATTR_RATE_TC_BW]) {
   396			struct nlattr *nla_tc_bw = attrs[DEVLINK_ATTR_RATE_TC_BW];
   397			struct nlattr *tb[DEVLINK_ATTR_RATE_TC_7_BW + 1];
   398			int i;
   399	
   400			err = nla_parse_nested(tb, DEVLINK_ATTR_RATE_TC_7_BW, nla_tc_bw,
   401					       devlink_dl_rate_tc_bw_nl_policy, info->extack);
   402			if (err)
   403				return err;
   404	
   405			for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
   406				if (tb[DEVLINK_ATTR_RATE_TC_0_BW + i])
   407					tc_bw[i] = nla_get_u32(tb[DEVLINK_ATTR_RATE_TC_0_BW + i]);
   408				else
   409					tc_bw[i] = 0;
   410			}
   411	
   412			if (devlink_rate_is_leaf(devlink_rate))
   413				err = ops->rate_leaf_tc_bw_set(devlink_rate, devlink_rate->priv,
   414							       tc_bw, info->extack);
   415			else if (devlink_rate_is_node(devlink_rate))
   416				err = ops->rate_node_tc_bw_set(devlink_rate, devlink_rate->priv,
   417							       tc_bw, info->extack);
   418	
   419			if (err)
   420				return err;
   421	
   422			memcpy(devlink_rate->tc_bw, tc_bw, sizeof(tc_bw));
   423		}
   424	
   425		nla_parent = attrs[DEVLINK_ATTR_RATE_PARENT_NODE_NAME];
   426		if (nla_parent) {
   427			err = devlink_nl_rate_parent_node_set(devlink_rate, info,
   428							      nla_parent);
   429			if (err)
   430				return err;
   431		}
   432	
   433		return 0;
   434	}
   435
Jiri Pirko Nov. 14, 2024, 9:48 a.m. UTC | #4
Wed, Nov 13, 2024 at 07:00:28PM CET, tariqt@nvidia.com wrote:
>From: Carolina Jubran <cjubran@nvidia.com>
>
>Introduce support for specifying bandwidth proportions between traffic
>classes (TC) in the devlink-rate API. This new option allows users to
>allocate bandwidth across multiple traffic classes in a single command.
>
>This feature provides a more granular control over traffic management,
>especially for scenarios requiring Enhanced Transmission Selection.
>
>Users can now define a specific bandwidth share for each traffic class,
>such as allocating 20% for TC0 (TCP/UDP) and 80% for TC5 (RoCE).
>
>Example:
>DEV=pci/0000:08:00.0
>
>$ devlink port function rate add $DEV/vfs_group tx_share 10Gbit \
>  tx_max 50Gbit tc-bw 0:20 1:0 2:0 3:0 4:0 5:80 6:0 7:0
>
>$ devlink port function rate set $DEV/vfs_group \
>  tc-bw 0:20 1:0 2:0 3:0 4:0 5:10 6:60 7:0
>
>Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
>Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
>Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
>---
> Documentation/netlink/specs/devlink.yaml | 50 ++++++++++++++++++++
> include/net/devlink.h                    |  6 +++
> include/uapi/linux/devlink.h             | 10 ++++
> net/devlink/netlink_gen.c                | 21 +++++++--
> net/devlink/netlink_gen.h                |  1 +
> net/devlink/rate.c                       | 60 ++++++++++++++++++++++--
> 6 files changed, 141 insertions(+), 7 deletions(-)
>
>diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml
>index 09fbb4c03fc8..41fdc2514f69 100644
>--- a/Documentation/netlink/specs/devlink.yaml
>+++ b/Documentation/netlink/specs/devlink.yaml
>@@ -817,6 +817,34 @@ attribute-sets:
>       -
>         name: rate-tx-weight
>         type: u32
>+      -
>+        name: rate-tc-0-bw
>+        type: u32
>+      -
>+        name: rate-tc-1-bw
>+        type: u32
>+      -
>+        name: rate-tc-2-bw
>+        type: u32
>+      -
>+        name: rate-tc-3-bw
>+        type: u32
>+      -
>+        name: rate-tc-4-bw
>+        type: u32
>+      -
>+        name: rate-tc-5-bw
>+        type: u32
>+      -
>+        name: rate-tc-6-bw
>+        type: u32
>+      -
>+        name: rate-tc-7-bw
>+        type: u32

This is very odd to embed index into name of attribute. Please don't do
that. Could you please separate that and have rate-tc-index as a separate
attr?


>+      -
>+        name: rate-tc-bw
>+        type: nest
>+        nested-attributes: dl-rate-tc-bw-values

[...]
diff mbox series

Patch

diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml
index 09fbb4c03fc8..41fdc2514f69 100644
--- a/Documentation/netlink/specs/devlink.yaml
+++ b/Documentation/netlink/specs/devlink.yaml
@@ -817,6 +817,34 @@  attribute-sets:
       -
         name: rate-tx-weight
         type: u32
+      -
+        name: rate-tc-0-bw
+        type: u32
+      -
+        name: rate-tc-1-bw
+        type: u32
+      -
+        name: rate-tc-2-bw
+        type: u32
+      -
+        name: rate-tc-3-bw
+        type: u32
+      -
+        name: rate-tc-4-bw
+        type: u32
+      -
+        name: rate-tc-5-bw
+        type: u32
+      -
+        name: rate-tc-6-bw
+        type: u32
+      -
+        name: rate-tc-7-bw
+        type: u32
+      -
+        name: rate-tc-bw
+        type: nest
+        nested-attributes: dl-rate-tc-bw-values
       -
         name: region-direct
         type: flag
@@ -1225,6 +1253,26 @@  attribute-sets:
       -
         name: flash
         type: flag
+  -
+    name: dl-rate-tc-bw-values
+    subset-of: devlink
+    attributes:
+      -
+        name: rate-tc-0-bw
+      -
+        name: rate-tc-1-bw
+      -
+        name: rate-tc-2-bw
+      -
+        name: rate-tc-3-bw
+      -
+        name: rate-tc-4-bw
+      -
+        name: rate-tc-5-bw
+      -
+        name: rate-tc-6-bw
+      -
+        name: rate-tc-7-bw
 
 operations:
   enum-model: directional
@@ -2148,6 +2196,7 @@  operations:
             - rate-tx-max
             - rate-tx-priority
             - rate-tx-weight
+            - rate-tc-bw
             - rate-parent-node-name
 
     -
@@ -2168,6 +2217,7 @@  operations:
             - rate-tx-max
             - rate-tx-priority
             - rate-tx-weight
+            - rate-tc-bw
             - rate-parent-node-name
 
     -
diff --git a/include/net/devlink.h b/include/net/devlink.h
index fbb9a2668e24..917bc006a5a4 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -117,6 +117,8 @@  struct devlink_rate {
 
 	u32 tx_priority;
 	u32 tx_weight;
+
+	u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
 };
 
 struct devlink_port {
@@ -1469,6 +1471,8 @@  struct devlink_ops {
 					 u32 tx_priority, struct netlink_ext_ack *extack);
 	int (*rate_leaf_tx_weight_set)(struct devlink_rate *devlink_rate, void *priv,
 				       u32 tx_weight, struct netlink_ext_ack *extack);
+	int (*rate_leaf_tc_bw_set)(struct devlink_rate *devlink_rate, void *priv,
+				   u32 *tc_bw, struct netlink_ext_ack *extack);
 	int (*rate_node_tx_share_set)(struct devlink_rate *devlink_rate, void *priv,
 				      u64 tx_share, struct netlink_ext_ack *extack);
 	int (*rate_node_tx_max_set)(struct devlink_rate *devlink_rate, void *priv,
@@ -1477,6 +1481,8 @@  struct devlink_ops {
 					 u32 tx_priority, struct netlink_ext_ack *extack);
 	int (*rate_node_tx_weight_set)(struct devlink_rate *devlink_rate, void *priv,
 				       u32 tx_weight, struct netlink_ext_ack *extack);
+	int (*rate_node_tc_bw_set)(struct devlink_rate *devlink_rate, void *priv,
+				   u32 *tc_bw, struct netlink_ext_ack *extack);
 	int (*rate_node_new)(struct devlink_rate *rate_node, void **priv,
 			     struct netlink_ext_ack *extack);
 	int (*rate_node_del)(struct devlink_rate *rate_node, void *priv,
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 9401aa343673..c369726a262a 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -614,6 +614,16 @@  enum devlink_attr {
 
 	DEVLINK_ATTR_REGION_DIRECT,		/* flag */
 
+	DEVLINK_ATTR_RATE_TC_0_BW,		/* u32 */
+	DEVLINK_ATTR_RATE_TC_1_BW,		/* u32 */
+	DEVLINK_ATTR_RATE_TC_2_BW,		/* u32 */
+	DEVLINK_ATTR_RATE_TC_3_BW,		/* u32 */
+	DEVLINK_ATTR_RATE_TC_4_BW,		/* u32 */
+	DEVLINK_ATTR_RATE_TC_5_BW,		/* u32 */
+	DEVLINK_ATTR_RATE_TC_6_BW,		/* u32 */
+	DEVLINK_ATTR_RATE_TC_7_BW,		/* u32 */
+	DEVLINK_ATTR_RATE_TC_BW,		/* nested */
+
 	/* Add new attributes above here, update the spec in
 	 * Documentation/netlink/specs/devlink.yaml and re-generate
 	 * net/devlink/netlink_gen.c.
diff --git a/net/devlink/netlink_gen.c b/net/devlink/netlink_gen.c
index f9786d51f68f..546766bdd836 100644
--- a/net/devlink/netlink_gen.c
+++ b/net/devlink/netlink_gen.c
@@ -18,6 +18,17 @@  const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_
 	[DEVLINK_PORT_FN_ATTR_CAPS] = NLA_POLICY_BITFIELD32(15),
 };
 
+const struct nla_policy devlink_dl_rate_tc_bw_nl_policy[DEVLINK_ATTR_RATE_TC_7_BW + 1] = {
+	[DEVLINK_ATTR_RATE_TC_0_BW] = { .type = NLA_U32, },
+	[DEVLINK_ATTR_RATE_TC_1_BW] = { .type = NLA_U32, },
+	[DEVLINK_ATTR_RATE_TC_2_BW] = { .type = NLA_U32, },
+	[DEVLINK_ATTR_RATE_TC_3_BW] = { .type = NLA_U32, },
+	[DEVLINK_ATTR_RATE_TC_4_BW] = { .type = NLA_U32, },
+	[DEVLINK_ATTR_RATE_TC_5_BW] = { .type = NLA_U32, },
+	[DEVLINK_ATTR_RATE_TC_6_BW] = { .type = NLA_U32, },
+	[DEVLINK_ATTR_RATE_TC_7_BW] = { .type = NLA_U32, },
+};
+
 const struct nla_policy devlink_dl_selftest_id_nl_policy[DEVLINK_ATTR_SELFTEST_ID_FLASH + 1] = {
 	[DEVLINK_ATTR_SELFTEST_ID_FLASH] = { .type = NLA_FLAG, },
 };
@@ -496,7 +507,7 @@  static const struct nla_policy devlink_rate_get_dump_nl_policy[DEVLINK_ATTR_DEV_
 };
 
 /* DEVLINK_CMD_RATE_SET - do */
-static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_RATE_TX_WEIGHT + 1] = {
+static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_RATE_TC_BW + 1] = {
 	[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, },
@@ -505,10 +516,11 @@  static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_RATE_TX_W
 	[DEVLINK_ATTR_RATE_TX_PRIORITY] = { .type = NLA_U32, },
 	[DEVLINK_ATTR_RATE_TX_WEIGHT] = { .type = NLA_U32, },
 	[DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING, },
+	[DEVLINK_ATTR_RATE_TC_BW] = NLA_POLICY_NESTED(devlink_dl_rate_tc_bw_nl_policy),
 };
 
 /* DEVLINK_CMD_RATE_NEW - do */
-static const struct nla_policy devlink_rate_new_nl_policy[DEVLINK_ATTR_RATE_TX_WEIGHT + 1] = {
+static const struct nla_policy devlink_rate_new_nl_policy[DEVLINK_ATTR_RATE_TC_BW + 1] = {
 	[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, },
@@ -517,6 +529,7 @@  static const struct nla_policy devlink_rate_new_nl_policy[DEVLINK_ATTR_RATE_TX_W
 	[DEVLINK_ATTR_RATE_TX_PRIORITY] = { .type = NLA_U32, },
 	[DEVLINK_ATTR_RATE_TX_WEIGHT] = { .type = NLA_U32, },
 	[DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING, },
+	[DEVLINK_ATTR_RATE_TC_BW] = NLA_POLICY_NESTED(devlink_dl_rate_tc_bw_nl_policy),
 };
 
 /* DEVLINK_CMD_RATE_DEL - do */
@@ -1164,7 +1177,7 @@  const struct genl_split_ops devlink_nl_ops[74] = {
 		.doit		= devlink_nl_rate_set_doit,
 		.post_doit	= devlink_nl_post_doit,
 		.policy		= devlink_rate_set_nl_policy,
-		.maxattr	= DEVLINK_ATTR_RATE_TX_WEIGHT,
+		.maxattr	= DEVLINK_ATTR_RATE_TC_BW,
 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
@@ -1174,7 +1187,7 @@  const struct genl_split_ops devlink_nl_ops[74] = {
 		.doit		= devlink_nl_rate_new_doit,
 		.post_doit	= devlink_nl_post_doit,
 		.policy		= devlink_rate_new_nl_policy,
-		.maxattr	= DEVLINK_ATTR_RATE_TX_WEIGHT,
+		.maxattr	= DEVLINK_ATTR_RATE_TC_BW,
 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
diff --git a/net/devlink/netlink_gen.h b/net/devlink/netlink_gen.h
index 8f2bd50ddf5e..084ad5026d4f 100644
--- a/net/devlink/netlink_gen.h
+++ b/net/devlink/netlink_gen.h
@@ -14,6 +14,7 @@ 
 /* Common nested types */
 extern const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_CAPS + 1];
 extern const struct nla_policy devlink_dl_selftest_id_nl_policy[DEVLINK_ATTR_SELFTEST_ID_FLASH + 1];
+extern const struct nla_policy devlink_dl_rate_tc_bw_nl_policy[DEVLINK_ATTR_RATE_TC_7_BW + 1];
 
 /* Ops table for devlink */
 extern const struct genl_split_ops devlink_nl_ops[74];
diff --git a/net/devlink/rate.c b/net/devlink/rate.c
index 8828ffaf6cbc..9bffda6783f9 100644
--- a/net/devlink/rate.c
+++ b/net/devlink/rate.c
@@ -86,7 +86,9 @@  static int devlink_nl_rate_fill(struct sk_buff *msg,
 				int flags, struct netlink_ext_ack *extack)
 {
 	struct devlink *devlink = devlink_rate->devlink;
+	struct nlattr *nla_tc_bw;
 	void *hdr;
+	int i;
 
 	hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
 	if (!hdr)
@@ -124,10 +126,19 @@  static int devlink_nl_rate_fill(struct sk_buff *msg,
 			devlink_rate->tx_weight))
 		goto nla_put_failure;
 
-	if (devlink_rate->parent)
-		if (nla_put_string(msg, DEVLINK_ATTR_RATE_PARENT_NODE_NAME,
-				   devlink_rate->parent->name))
+	nla_tc_bw = nla_nest_start(msg, DEVLINK_ATTR_RATE_TC_BW);
+	if (!nla_tc_bw)
+		goto nla_put_failure;
+
+	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
+		if (nla_put_u32(msg, DEVLINK_ATTR_RATE_TC_0_BW + i,
+				devlink_rate->tc_bw[i])) {
+			nla_nest_cancel(msg, nla_tc_bw);
 			goto nla_put_failure;
+		}
+	}
+
+	nla_nest_end(msg, nla_tc_bw);
 
 	genlmsg_end(msg, hdr);
 	return 0;
@@ -321,6 +332,7 @@  static int devlink_nl_rate_set(struct devlink_rate *devlink_rate,
 			       struct genl_info *info)
 {
 	struct nlattr *nla_parent, **attrs = info->attrs;
+	u32 tc_bw[IEEE_8021QAZ_MAX_TCS];
 	int err = -EOPNOTSUPP;
 	u32 priority;
 	u32 weight;
@@ -380,6 +392,36 @@  static int devlink_nl_rate_set(struct devlink_rate *devlink_rate,
 		devlink_rate->tx_weight = weight;
 	}
 
+	if (attrs[DEVLINK_ATTR_RATE_TC_BW]) {
+		struct nlattr *nla_tc_bw = attrs[DEVLINK_ATTR_RATE_TC_BW];
+		struct nlattr *tb[DEVLINK_ATTR_RATE_TC_7_BW + 1];
+		int i;
+
+		err = nla_parse_nested(tb, DEVLINK_ATTR_RATE_TC_7_BW, nla_tc_bw,
+				       devlink_dl_rate_tc_bw_nl_policy, info->extack);
+		if (err)
+			return err;
+
+		for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
+			if (tb[DEVLINK_ATTR_RATE_TC_0_BW + i])
+				tc_bw[i] = nla_get_u32(tb[DEVLINK_ATTR_RATE_TC_0_BW + i]);
+			else
+				tc_bw[i] = 0;
+		}
+
+		if (devlink_rate_is_leaf(devlink_rate))
+			err = ops->rate_leaf_tc_bw_set(devlink_rate, devlink_rate->priv,
+						       tc_bw, info->extack);
+		else if (devlink_rate_is_node(devlink_rate))
+			err = ops->rate_node_tc_bw_set(devlink_rate, devlink_rate->priv,
+						       tc_bw, info->extack);
+
+		if (err)
+			return err;
+
+		memcpy(devlink_rate->tc_bw, tc_bw, sizeof(tc_bw));
+	}
+
 	nla_parent = attrs[DEVLINK_ATTR_RATE_PARENT_NODE_NAME];
 	if (nla_parent) {
 		err = devlink_nl_rate_parent_node_set(devlink_rate, info,
@@ -423,6 +465,12 @@  static bool devlink_rate_set_ops_supported(const struct devlink_ops *ops,
 					    "TX weight set isn't supported for the leafs");
 			return false;
 		}
+		if (attrs[DEVLINK_ATTR_RATE_TC_BW] && !ops->rate_leaf_tc_bw_set) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    attrs[DEVLINK_ATTR_RATE_TC_BW],
+					    "TC bandwidth set isn't supported for the leafs");
+			return false;
+		}
 	} else if (type == DEVLINK_RATE_TYPE_NODE) {
 		if (attrs[DEVLINK_ATTR_RATE_TX_SHARE] && !ops->rate_node_tx_share_set) {
 			NL_SET_ERR_MSG(info->extack, "TX share set isn't supported for the nodes");
@@ -449,6 +497,12 @@  static bool devlink_rate_set_ops_supported(const struct devlink_ops *ops,
 					    "TX weight set isn't supported for the nodes");
 			return false;
 		}
+		if (attrs[DEVLINK_ATTR_RATE_TC_BW] && !ops->rate_node_tc_bw_set) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    attrs[DEVLINK_ATTR_RATE_TC_BW],
+					    "TC bandwidth set isn't supported for the nodes");
+			return false;
+		}
 	} else {
 		WARN(1, "Unknown type of rate object");
 		return false;