* [PATCH 1/4] ethdev: make parameters to TM node add fn constant
2024-08-06 15:24 [PATCH 0/4] improve rte_tm APIs Bruce Richardson
@ 2024-08-06 15:24 ` Bruce Richardson
2024-08-07 7:27 ` Xu, Rosen
2024-08-06 15:24 ` [PATCH 2/4] ethdev: make parameters to TM profile " Bruce Richardson
` (3 subsequent siblings)
4 siblings, 1 reply; 20+ messages in thread
From: Bruce Richardson @ 2024-08-06 15:24 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, Nithin Dabilpuram, Kiran Kumar K,
Sunil Kumar Kori, Satha Rao, Harman Kalra, Hemant Agrawal,
Sachin Saxena, Jie Hai, Yisen Zhuang, Jingjing Wu, Rosen Xu,
Jiawen Wu, Jian Wang, Cristian Dumitrescu, Thomas Monjalon,
Ferruh Yigit, Andrew Rybchenko
The function to add a new scheduling node in rte_tm should not (and
does not) modify the actual node parameters passed in via struct
pointer. We should guarantee this by marking the parameter pointer as
const. This allows SW to create multiple scheduling nodes using the same
parameter struct without having to reset it each time.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/cnxk/cnxk_tm.c | 2 +-
drivers/net/dpaa2/dpaa2_tm.c | 4 ++--
drivers/net/hns3/hns3_tm.c | 16 ++++++++--------
drivers/net/i40e/i40e_tm.c | 6 +++---
drivers/net/iavf/iavf_tm.c | 6 +++---
drivers/net/ice/ice_dcf_sched.c | 6 +++---
drivers/net/ice/ice_tm.c | 6 +++---
drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
drivers/net/ixgbe/ixgbe_tm.c | 6 +++---
drivers/net/txgbe/txgbe_tm.c | 6 +++---
lib/ethdev/rte_tm.c | 2 +-
lib/ethdev/rte_tm.h | 2 +-
lib/ethdev/rte_tm_driver.h | 2 +-
13 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_tm.c b/drivers/net/cnxk/cnxk_tm.c
index c799193cb8..9293b3e8f2 100644
--- a/drivers/net/cnxk/cnxk_tm.c
+++ b/drivers/net/cnxk/cnxk_tm.c
@@ -336,7 +336,7 @@ static int
cnxk_nix_tm_node_add(struct rte_eth_dev *eth_dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t lvl,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
diff --git a/drivers/net/dpaa2/dpaa2_tm.c b/drivers/net/dpaa2/dpaa2_tm.c
index cb854964b4..22337097e5 100644
--- a/drivers/net/dpaa2/dpaa2_tm.c
+++ b/drivers/net/dpaa2/dpaa2_tm.c
@@ -359,7 +359,7 @@ static int
dpaa2_node_check_params(struct rte_eth_dev *dev, uint32_t node_id,
__rte_unused uint32_t priority, uint32_t weight,
uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
if (node_id == RTE_TM_NODE_ID_NULL)
@@ -431,7 +431,7 @@ dpaa2_node_check_params(struct rte_eth_dev *dev, uint32_t node_id,
static int
dpaa2_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority, uint32_t weight,
- uint32_t level_id, struct rte_tm_node_params *params,
+ uint32_t level_id, const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct dpaa2_dev_priv *priv = dev->data->dev_private;
diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c
index 92a668538f..06df32bbcd 100644
--- a/drivers/net/hns3/hns3_tm.c
+++ b/drivers/net/hns3/hns3_tm.c
@@ -329,7 +329,7 @@ hns3_tm_node_search(struct rte_eth_dev *dev,
static int
hns3_tm_nonleaf_node_param_check(struct rte_eth_dev *dev,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_tm_shaper_profile *shaper_profile;
@@ -364,7 +364,7 @@ hns3_tm_nonleaf_node_param_check(struct rte_eth_dev *dev,
static int
hns3_tm_leaf_node_param_check(struct rte_eth_dev *dev __rte_unused,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
@@ -408,7 +408,7 @@ hns3_tm_leaf_node_param_check(struct rte_eth_dev *dev __rte_unused,
static int
hns3_tm_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -457,7 +457,7 @@ hns3_tm_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
static int
hns3_tm_port_node_add(struct rte_eth_dev *dev, uint32_t node_id,
- uint32_t level_id, struct rte_tm_node_params *params,
+ uint32_t level_id, const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -503,7 +503,7 @@ hns3_tm_port_node_add(struct rte_eth_dev *dev, uint32_t node_id,
static int
hns3_tm_tc_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t level_id, struct hns3_tm_node *parent_node,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -554,7 +554,7 @@ hns3_tm_tc_node_add(struct rte_eth_dev *dev, uint32_t node_id,
static int
hns3_tm_queue_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t level_id, struct hns3_tm_node *parent_node,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -601,7 +601,7 @@ static int
hns3_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -1230,7 +1230,7 @@ static int
hns3_tm_node_add_wrap(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/i40e/i40e_tm.c b/drivers/net/i40e/i40e_tm.c
index cab296e1a4..c7d4680fb4 100644
--- a/drivers/net/i40e/i40e_tm.c
+++ b/drivers/net/i40e/i40e_tm.c
@@ -20,7 +20,7 @@ static int i40e_shaper_profile_del(struct rte_eth_dev *dev,
static int i40e_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int i40e_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -353,7 +353,7 @@ i40e_tm_node_search(struct rte_eth_dev *dev,
static int
i40e_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -450,7 +450,7 @@ static int
i40e_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/iavf/iavf_tm.c b/drivers/net/iavf/iavf_tm.c
index 32bb3be45e..f9883927be 100644
--- a/drivers/net/iavf/iavf_tm.c
+++ b/drivers/net/iavf/iavf_tm.c
@@ -18,7 +18,7 @@ static int iavf_shaper_profile_del(struct rte_eth_dev *dev,
static int iavf_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int iavf_tm_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -131,7 +131,7 @@ iavf_tm_node_search(struct rte_eth_dev *dev,
static int
iavf_node_param_check(struct iavf_info *vf, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
/* checked all the unsupported parameter */
@@ -271,7 +271,7 @@ static int
iavf_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
diff --git a/drivers/net/ice/ice_dcf_sched.c b/drivers/net/ice/ice_dcf_sched.c
index b08bc5f1de..b93e001806 100644
--- a/drivers/net/ice/ice_dcf_sched.c
+++ b/drivers/net/ice/ice_dcf_sched.c
@@ -12,7 +12,7 @@ static int ice_dcf_hierarchy_commit(struct rte_eth_dev *dev,
static int ice_dcf_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int ice_dcf_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -139,7 +139,7 @@ ice_dcf_shaper_profile_search(struct rte_eth_dev *dev,
static int
ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
/* checked all the unsupported parameter */
@@ -230,7 +230,7 @@ static int
ice_dcf_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
enum ice_dcf_tm_node_type parent_node_type = ICE_DCF_TM_NODE_TYPE_MAX;
diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c
index 7239ab53f1..c977e6b177 100644
--- a/drivers/net/ice/ice_tm.c
+++ b/drivers/net/ice/ice_tm.c
@@ -15,7 +15,7 @@ static int ice_hierarchy_commit(struct rte_eth_dev *dev,
static int ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int ice_tm_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -82,7 +82,7 @@ ice_tm_conf_uninit(struct rte_eth_dev *dev)
static int
ice_node_param_check(struct ice_pf *pf, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
/* checked all the unsupported parameter */
@@ -337,7 +337,7 @@ static int
ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c b/drivers/net/ipn3ke/ipn3ke_tm.c
index 0260227900..cffe1fdaa4 100644
--- a/drivers/net/ipn3ke/ipn3ke_tm.c
+++ b/drivers/net/ipn3ke/ipn3ke_tm.c
@@ -1010,7 +1010,7 @@ ipn3ke_tm_tdrop_profile_delete(struct rte_eth_dev *dev,
static int
ipn3ke_tm_node_add_check_parameter(uint32_t tm_id,
uint32_t node_id, uint32_t parent_node_id, uint32_t priority,
- uint32_t weight, uint32_t level_id, struct rte_tm_node_params *params,
+ uint32_t weight, uint32_t level_id, const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
uint32_t level_of_node_id;
@@ -1168,7 +1168,7 @@ ipn3ke_tm_node_add_check_mount(uint32_t tm_id,
static int
ipn3ke_tm_node_add(struct rte_eth_dev *dev,
uint32_t node_id, uint32_t parent_node_id, uint32_t priority,
- uint32_t weight, uint32_t level_id, struct rte_tm_node_params *params,
+ uint32_t weight, uint32_t level_id, const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
diff --git a/drivers/net/ixgbe/ixgbe_tm.c b/drivers/net/ixgbe/ixgbe_tm.c
index ac8976062f..75cd707109 100644
--- a/drivers/net/ixgbe/ixgbe_tm.c
+++ b/drivers/net/ixgbe/ixgbe_tm.c
@@ -19,7 +19,7 @@ static int ixgbe_shaper_profile_del(struct rte_eth_dev *dev,
static int ixgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int ixgbe_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -461,7 +461,7 @@ ixgbe_queue_base_nb_get(struct rte_eth_dev *dev, uint16_t tc_node_no,
static int
ixgbe_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
if (node_id == RTE_TM_NODE_ID_NULL) {
@@ -558,7 +558,7 @@ static int
ixgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct ixgbe_tm_conf *tm_conf =
diff --git a/drivers/net/txgbe/txgbe_tm.c b/drivers/net/txgbe/txgbe_tm.c
index 3171be73d0..8ed4d24459 100644
--- a/drivers/net/txgbe/txgbe_tm.c
+++ b/drivers/net/txgbe/txgbe_tm.c
@@ -20,7 +20,7 @@ static int txgbe_shaper_profile_del(struct rte_eth_dev *dev,
static int txgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int txgbe_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -450,7 +450,7 @@ txgbe_queue_base_nb_get(struct rte_eth_dev *dev, uint16_t tc_node_no,
static int
txgbe_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
if (node_id == RTE_TM_NODE_ID_NULL) {
@@ -547,7 +547,7 @@ static int
txgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct txgbe_tm_conf *tm_conf = TXGBE_DEV_TM_CONF(dev);
diff --git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c
index d594fe0049..74e6f4d610 100644
--- a/lib/ethdev/rte_tm.c
+++ b/lib/ethdev/rte_tm.c
@@ -286,7 +286,7 @@ int rte_tm_node_add(uint16_t port_id,
uint32_t priority,
uint32_t weight,
uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
diff --git a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h
index 07028c9b36..c52acd1b4f 100644
--- a/lib/ethdev/rte_tm.h
+++ b/lib/ethdev/rte_tm.h
@@ -1596,7 +1596,7 @@ rte_tm_node_add(uint16_t port_id,
uint32_t priority,
uint32_t weight,
uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
/**
diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h
index 45290fb3fd..25d688516b 100644
--- a/lib/ethdev/rte_tm_driver.h
+++ b/lib/ethdev/rte_tm_driver.h
@@ -101,7 +101,7 @@ typedef int (*rte_tm_node_add_t)(struct rte_eth_dev *dev,
uint32_t priority,
uint32_t weight,
uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
/** @internal Traffic manager node delete */
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH 1/4] ethdev: make parameters to TM node add fn constant
2024-08-06 15:24 ` [PATCH 1/4] ethdev: make parameters to TM node add fn constant Bruce Richardson
@ 2024-08-07 7:27 ` Xu, Rosen
2024-09-22 16:10 ` Ferruh Yigit
0 siblings, 1 reply; 20+ messages in thread
From: Xu, Rosen @ 2024-08-07 7:27 UTC (permalink / raw)
To: Richardson, Bruce, dev
Cc: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
Harman Kalra, Hemant Agrawal, Sachin Saxena, Jie Hai,
Yisen Zhuang, Wu, Jingjing, Jiawen Wu, Jian Wang, Dumitrescu,
Cristian, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko
Hi,
> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Tuesday, August 6, 2024 11:24 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Nithin Dabilpuram
> <ndabilpuram@marvell.com>; Kiran Kumar K <kirankumark@marvell.com>;
> Sunil Kumar Kori <skori@marvell.com>; Satha Rao
> <skoteshwar@marvell.com>; Harman Kalra <hkalra@marvell.com>; Hemant
> Agrawal <hemant.agrawal@nxp.com>; Sachin Saxena
> <sachin.saxena@nxp.com>; Jie Hai <haijie1@huawei.com>; Yisen Zhuang
> <yisen.zhuang@huawei.com>; Wu, Jingjing <jingjing.wu@intel.com>; Xu,
> Rosen <rosen.xu@intel.com>; Jiawen Wu <jiawenwu@trustnetic.com>; Jian
> Wang <jianwang@trustnetic.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>; Thomas Monjalon
> <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@amd.com>; Andrew
> Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Subject: [PATCH 1/4] ethdev: make parameters to TM node add fn constant
>
> The function to add a new scheduling node in rte_tm should not (and does
> not) modify the actual node parameters passed in via struct pointer. We
> should guarantee this by marking the parameter pointer as const. This allows
> SW to create multiple scheduling nodes using the same parameter struct
> without having to reset it each time.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
> diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c
> b/drivers/net/ipn3ke/ipn3ke_tm.c index 0260227900..cffe1fdaa4 100644
> --- a/drivers/net/ipn3ke/ipn3ke_tm.c
> +++ b/drivers/net/ipn3ke/ipn3ke_tm.c
> @@ -1010,7 +1010,7 @@ ipn3ke_tm_tdrop_profile_delete(struct
> rte_eth_dev *dev, static int
> ipn3ke_tm_node_add_check_parameter(uint32_t tm_id,
> uint32_t node_id, uint32_t parent_node_id, uint32_t priority,
> - uint32_t weight, uint32_t level_id, struct rte_tm_node_params
> *params,
> + uint32_t weight, uint32_t level_id, const struct rte_tm_node_params
> +*params,
> struct rte_tm_error *error)
> {
> uint32_t level_of_node_id;
> @@ -1168,7 +1168,7 @@ ipn3ke_tm_node_add_check_mount(uint32_t
> tm_id, static int ipn3ke_tm_node_add(struct rte_eth_dev *dev,
> uint32_t node_id, uint32_t parent_node_id, uint32_t priority,
> - uint32_t weight, uint32_t level_id, struct rte_tm_node_params
> *params,
> + uint32_t weight, uint32_t level_id, const struct rte_tm_node_params
> +*params,
> struct rte_tm_error *error)
> {
> struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev); diff --
> /** @internal Traffic manager node delete */
> --
> 2.43.0
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/4] ethdev: make parameters to TM node add fn constant
2024-08-07 7:27 ` Xu, Rosen
@ 2024-09-22 16:10 ` Ferruh Yigit
0 siblings, 0 replies; 20+ messages in thread
From: Ferruh Yigit @ 2024-09-22 16:10 UTC (permalink / raw)
To: Xu, Rosen, Richardson, Bruce, dev
Cc: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
Harman Kalra, Hemant Agrawal, Sachin Saxena, Jie Hai,
Yisen Zhuang, Wu, Jingjing, Jiawen Wu, Jian Wang, Dumitrescu,
Cristian, Thomas Monjalon, Andrew Rybchenko
On 8/7/2024 8:27 AM, Xu, Rosen wrote:
> Hi,
>
>> -----Original Message-----
<...>
>> Subject: [PATCH 1/4] ethdev: make parameters to TM node add fn constant
>>
>> The function to add a new scheduling node in rte_tm should not (and does
>> not) modify the actual node parameters passed in via struct pointer. We
>> should guarantee this by marking the parameter pointer as const. This allows
>> SW to create multiple scheduling nodes using the same parameter struct
>> without having to reset it each time.
>>
>> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>> ---
>> drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
>> diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c
>> b/drivers/net/ipn3ke/ipn3ke_tm.c index 0260227900..cffe1fdaa4 100644
>> --- a/drivers/net/ipn3ke/ipn3ke_tm.c
>> +++ b/drivers/net/ipn3ke/ipn3ke_tm.c
>> @@ -1010,7 +1010,7 @@ ipn3ke_tm_tdrop_profile_delete(struct
>> rte_eth_dev *dev, static int
>> ipn3ke_tm_node_add_check_parameter(uint32_t tm_id,
>> uint32_t node_id, uint32_t parent_node_id, uint32_t priority,
>> - uint32_t weight, uint32_t level_id, struct rte_tm_node_params
>> *params,
>> + uint32_t weight, uint32_t level_id, const struct rte_tm_node_params
>> +*params,
>> struct rte_tm_error *error)
>> {
>> uint32_t level_of_node_id;
>> @@ -1168,7 +1168,7 @@ ipn3ke_tm_node_add_check_mount(uint32_t
>> tm_id, static int ipn3ke_tm_node_add(struct rte_eth_dev *dev,
>> uint32_t node_id, uint32_t parent_node_id, uint32_t priority,
>> - uint32_t weight, uint32_t level_id, struct rte_tm_node_params
>> *params,
>> + uint32_t weight, uint32_t level_id, const struct rte_tm_node_params
>> +*params,
>> struct rte_tm_error *error)
>> {
>> struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev); diff --
>> /** @internal Traffic manager node delete */
>> --
>> 2.43.0
>
> Reviewed-by: Rosen Xu <rosen.xu@intel.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 2/4] ethdev: make parameters to TM profile add fn constant
2024-08-06 15:24 [PATCH 0/4] improve rte_tm APIs Bruce Richardson
2024-08-06 15:24 ` [PATCH 1/4] ethdev: make parameters to TM node add fn constant Bruce Richardson
@ 2024-08-06 15:24 ` Bruce Richardson
2024-08-07 7:27 ` Xu, Rosen
2024-08-06 15:24 ` [PATCH 3/4] ethdev: make TM shaper parameters constant Bruce Richardson
` (2 subsequent siblings)
4 siblings, 1 reply; 20+ messages in thread
From: Bruce Richardson @ 2024-08-06 15:24 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, Rosen Xu, Cristian Dumitrescu, Thomas Monjalon,
Ferruh Yigit, Andrew Rybchenko
The function to add a new profile in rte_tm should not (and does not)
modify the profile parameters passed in via struct pointer. We should
guarantee this by marking the parameter pointer as const. This allows
SW to create multiple profiles using the same parameter struct without
having to reset it each time.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
lib/ethdev/rte_tm.c | 2 +-
lib/ethdev/rte_tm.h | 2 +-
lib/ethdev/rte_tm_driver.h | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c b/drivers/net/ipn3ke/ipn3ke_tm.c
index cffe1fdaa4..20a0ed0467 100644
--- a/drivers/net/ipn3ke/ipn3ke_tm.c
+++ b/drivers/net/ipn3ke/ipn3ke_tm.c
@@ -848,7 +848,7 @@ ipn3ke_tm_shaper_profile_delete(struct rte_eth_dev *dev,
static int
ipn3ke_tm_tdrop_profile_check(__rte_unused struct rte_eth_dev *dev,
- uint32_t tdrop_profile_id, struct rte_tm_wred_params *profile,
+ uint32_t tdrop_profile_id, const struct rte_tm_wred_params *profile,
struct rte_tm_error *error)
{
enum rte_color color;
@@ -931,7 +931,7 @@ ipn3ke_hw_tm_tdrop_wr(struct ipn3ke_hw *hw,
/* Traffic manager TDROP profile add */
static int
ipn3ke_tm_tdrop_profile_add(struct rte_eth_dev *dev,
- uint32_t tdrop_profile_id, struct rte_tm_wred_params *profile,
+ uint32_t tdrop_profile_id, const struct rte_tm_wred_params *profile,
struct rte_tm_error *error)
{
struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
diff --git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c
index 74e6f4d610..d221b1e553 100644
--- a/lib/ethdev/rte_tm.c
+++ b/lib/ethdev/rte_tm.c
@@ -153,7 +153,7 @@ int rte_tm_node_capabilities_get(uint16_t port_id,
/* Add WRED profile */
int rte_tm_wred_profile_add(uint16_t port_id,
uint32_t wred_profile_id,
- struct rte_tm_wred_params *profile,
+ const struct rte_tm_wred_params *profile,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
diff --git a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h
index c52acd1b4f..f6f3f6a8d4 100644
--- a/lib/ethdev/rte_tm.h
+++ b/lib/ethdev/rte_tm.h
@@ -1347,7 +1347,7 @@ rte_tm_node_capabilities_get(uint16_t port_id,
int
rte_tm_wred_profile_add(uint16_t port_id,
uint32_t wred_profile_id,
- struct rte_tm_wred_params *profile,
+ const struct rte_tm_wred_params *profile,
struct rte_tm_error *error);
/**
diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h
index 25d688516b..b6ecf1bd4d 100644
--- a/lib/ethdev/rte_tm_driver.h
+++ b/lib/ethdev/rte_tm_driver.h
@@ -51,7 +51,7 @@ typedef int (*rte_tm_node_capabilities_get_t)(struct rte_eth_dev *dev,
/** @internal Traffic manager WRED profile add */
typedef int (*rte_tm_wred_profile_add_t)(struct rte_eth_dev *dev,
uint32_t wred_profile_id,
- struct rte_tm_wred_params *profile,
+ const struct rte_tm_wred_params *profile,
struct rte_tm_error *error);
/** @internal Traffic manager WRED profile delete */
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH 2/4] ethdev: make parameters to TM profile add fn constant
2024-08-06 15:24 ` [PATCH 2/4] ethdev: make parameters to TM profile " Bruce Richardson
@ 2024-08-07 7:27 ` Xu, Rosen
2024-09-22 16:11 ` Ferruh Yigit
0 siblings, 1 reply; 20+ messages in thread
From: Xu, Rosen @ 2024-08-07 7:27 UTC (permalink / raw)
To: Richardson, Bruce, dev
Cc: Dumitrescu, Cristian, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko
Hi,
> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Tuesday, August 6, 2024 11:24 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Xu, Rosen
> <rosen.xu@intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>; Thomas Monjalon
> <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@amd.com>; Andrew
> Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Subject: [PATCH 2/4] ethdev: make parameters to TM profile add fn constant
>
> The function to add a new profile in rte_tm should not (and does not) modify
> the profile parameters passed in via struct pointer. We should guarantee this
> by marking the parameter pointer as const. This allows SW to create multiple
> profiles using the same parameter struct without having to reset it each time.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
> lib/ethdev/rte_tm.c | 2 +-
> lib/ethdev/rte_tm.h | 2 +-
> lib/ethdev/rte_tm_driver.h | 2 +-
> 4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c
> b/drivers/net/ipn3ke/ipn3ke_tm.c index cffe1fdaa4..20a0ed0467 100644
> --- a/drivers/net/ipn3ke/ipn3ke_tm.c
> +++ b/drivers/net/ipn3ke/ipn3ke_tm.c
> @@ -848,7 +848,7 @@ ipn3ke_tm_shaper_profile_delete(struct
> rte_eth_dev *dev,
>
> static int
> ipn3ke_tm_tdrop_profile_check(__rte_unused struct rte_eth_dev *dev,
> - uint32_t tdrop_profile_id, struct rte_tm_wred_params *profile,
> + uint32_t tdrop_profile_id, const struct rte_tm_wred_params
> *profile,
> struct rte_tm_error *error)
> {
> enum rte_color color;
> @@ -931,7 +931,7 @@ ipn3ke_hw_tm_tdrop_wr(struct ipn3ke_hw *hw,
> /* Traffic manager TDROP profile add */ static int
> ipn3ke_tm_tdrop_profile_add(struct rte_eth_dev *dev,
> - uint32_t tdrop_profile_id, struct rte_tm_wred_params *profile,
> + uint32_t tdrop_profile_id, const struct rte_tm_wred_params
> *profile,
> struct rte_tm_error *error)
> {
> struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev); diff --
> git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c index
> 74e6f4d610..d221b1e553 100644
> --- a/lib/ethdev/rte_tm.c
> +++ b/lib/ethdev/rte_tm.c
> @@ -153,7 +153,7 @@ int rte_tm_node_capabilities_get(uint16_t port_id,
> /* Add WRED profile */
> int rte_tm_wred_profile_add(uint16_t port_id,
> uint32_t wred_profile_id,
> - struct rte_tm_wred_params *profile,
> + const struct rte_tm_wred_params *profile,
> struct rte_tm_error *error)
> {
> struct rte_eth_dev *dev = &rte_eth_devices[port_id]; diff --git
> a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h index c52acd1b4f..f6f3f6a8d4
> 100644
> --- a/lib/ethdev/rte_tm.h
> +++ b/lib/ethdev/rte_tm.h
> @@ -1347,7 +1347,7 @@ rte_tm_node_capabilities_get(uint16_t port_id,
> int rte_tm_wred_profile_add(uint16_t port_id,
> uint32_t wred_profile_id,
> - struct rte_tm_wred_params *profile,
> + const struct rte_tm_wred_params *profile,
> struct rte_tm_error *error);
>
> /**
> diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h index
> 25d688516b..b6ecf1bd4d 100644
> --- a/lib/ethdev/rte_tm_driver.h
> +++ b/lib/ethdev/rte_tm_driver.h
> @@ -51,7 +51,7 @@ typedef int (*rte_tm_node_capabilities_get_t)(struct
> rte_eth_dev *dev,
> /** @internal Traffic manager WRED profile add */ typedef int
> (*rte_tm_wred_profile_add_t)(struct rte_eth_dev *dev,
> uint32_t wred_profile_id,
> - struct rte_tm_wred_params *profile,
> + const struct rte_tm_wred_params *profile,
> struct rte_tm_error *error);
>
> /** @internal Traffic manager WRED profile delete */
> --
> 2.43.0
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/4] ethdev: make parameters to TM profile add fn constant
2024-08-07 7:27 ` Xu, Rosen
@ 2024-09-22 16:11 ` Ferruh Yigit
0 siblings, 0 replies; 20+ messages in thread
From: Ferruh Yigit @ 2024-09-22 16:11 UTC (permalink / raw)
To: Xu, Rosen, Richardson, Bruce, dev
Cc: Dumitrescu, Cristian, Thomas Monjalon, Andrew Rybchenko
On 8/7/2024 8:27 AM, Xu, Rosen wrote:
> Hi,
>
>> -----Original Message-----
<...>
>> Subject: [PATCH 2/4] ethdev: make parameters to TM profile add fn constant
>>
>> The function to add a new profile in rte_tm should not (and does not) modify
>> the profile parameters passed in via struct pointer. We should guarantee this
>> by marking the parameter pointer as const. This allows SW to create multiple
>> profiles using the same parameter struct without having to reset it each time.
>>
>> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>
> Reviewed-by: Rosen Xu <rosen.xu@intel.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 3/4] ethdev: make TM shaper parameters constant
2024-08-06 15:24 [PATCH 0/4] improve rte_tm APIs Bruce Richardson
2024-08-06 15:24 ` [PATCH 1/4] ethdev: make parameters to TM node add fn constant Bruce Richardson
2024-08-06 15:24 ` [PATCH 2/4] ethdev: make parameters to TM profile " Bruce Richardson
@ 2024-08-06 15:24 ` Bruce Richardson
2024-08-07 7:29 ` Xu, Rosen
2024-08-06 15:24 ` [PATCH 4/4] ethdev: add traffic manager query function Bruce Richardson
2024-10-07 11:49 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Bruce Richardson
4 siblings, 1 reply; 20+ messages in thread
From: Bruce Richardson @ 2024-08-06 15:24 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, Nithin Dabilpuram, Kiran Kumar K,
Sunil Kumar Kori, Satha Rao, Harman Kalra, Hemant Agrawal,
Sachin Saxena, Jie Hai, Yisen Zhuang, Jingjing Wu, Rosen Xu,
Liron Himi, Jiawen Wu, Jian Wang, Cristian Dumitrescu,
Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko
The function to add a new shaper profile in rte_tm should not (and does
not) modify the profile parameters passed in via struct pointer. We
should guarantee this by marking the parameter pointer as const. This
allows SW to create multiple profiles using the same parameter
struct without having to reset it each time.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/cnxk/cnxk_tm.c | 2 +-
drivers/net/dpaa2/dpaa2_tm.c | 2 +-
drivers/net/hns3/hns3_tm.c | 6 +++---
drivers/net/i40e/i40e_tm.c | 6 +++---
drivers/net/iavf/iavf_tm.c | 6 +++---
drivers/net/ice/ice_dcf_sched.c | 6 +++---
drivers/net/ice/ice_tm.c | 6 +++---
drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
drivers/net/ixgbe/ixgbe_tm.c | 6 +++---
drivers/net/mvpp2/mrvl_tm.c | 2 +-
drivers/net/txgbe/txgbe_tm.c | 6 +++---
lib/ethdev/rte_tm.c | 2 +-
lib/ethdev/rte_tm.h | 2 +-
lib/ethdev/rte_tm_driver.h | 2 +-
14 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_tm.c b/drivers/net/cnxk/cnxk_tm.c
index 9293b3e8f2..0ed6732dda 100644
--- a/drivers/net/cnxk/cnxk_tm.c
+++ b/drivers/net/cnxk/cnxk_tm.c
@@ -267,7 +267,7 @@ cnxk_nix_tm_node_capa_get(struct rte_eth_dev *eth_dev, uint32_t node_id,
static int
cnxk_nix_tm_shaper_profile_add(struct rte_eth_dev *eth_dev, uint32_t id,
- struct rte_tm_shaper_params *params,
+ const struct rte_tm_shaper_params *params,
struct rte_tm_error *error)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
diff --git a/drivers/net/dpaa2/dpaa2_tm.c b/drivers/net/dpaa2/dpaa2_tm.c
index 22337097e5..115397ce47 100644
--- a/drivers/net/dpaa2/dpaa2_tm.c
+++ b/drivers/net/dpaa2/dpaa2_tm.c
@@ -268,7 +268,7 @@ dpaa2_shaper_profile_from_id(struct dpaa2_dev_priv *priv,
static int
dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *params,
+ const struct rte_tm_shaper_params *params,
struct rte_tm_error *error)
{
struct dpaa2_dev_priv *priv = dev->data->dev_private;
diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c
index 06df32bbcd..1c2ad71133 100644
--- a/drivers/net/hns3/hns3_tm.c
+++ b/drivers/net/hns3/hns3_tm.c
@@ -166,7 +166,7 @@ hns3_tm_shaper_profile_search(struct rte_eth_dev *dev,
static int
hns3_tm_shaper_profile_param_check(struct rte_eth_dev *dev,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -220,7 +220,7 @@ hns3_tm_shaper_profile_param_check(struct rte_eth_dev *dev,
static int
hns3_tm_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -1198,7 +1198,7 @@ hns3_tm_capabilities_get_wrap(struct rte_eth_dev *dev,
static int
hns3_tm_shaper_profile_add_wrap(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/i40e/i40e_tm.c b/drivers/net/i40e/i40e_tm.c
index c7d4680fb4..4c0940f355 100644
--- a/drivers/net/i40e/i40e_tm.c
+++ b/drivers/net/i40e/i40e_tm.c
@@ -12,7 +12,7 @@ static int i40e_tm_capabilities_get(struct rte_eth_dev *dev,
struct rte_tm_error *error);
static int i40e_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int i40e_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -217,7 +217,7 @@ i40e_shaper_profile_search(struct rte_eth_dev *dev,
}
static int
-i40e_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+i40e_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min rate not supported */
@@ -251,7 +251,7 @@ i40e_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
i40e_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
diff --git a/drivers/net/iavf/iavf_tm.c b/drivers/net/iavf/iavf_tm.c
index f9883927be..1d12196ba6 100644
--- a/drivers/net/iavf/iavf_tm.c
+++ b/drivers/net/iavf/iavf_tm.c
@@ -10,7 +10,7 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
__rte_unused struct rte_tm_error *error);
static int iavf_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int iavf_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -487,7 +487,7 @@ iavf_tm_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
}
static int
-iavf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+iavf_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min bucket size not supported */
@@ -515,7 +515,7 @@ iavf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
iavf_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
diff --git a/drivers/net/ice/ice_dcf_sched.c b/drivers/net/ice/ice_dcf_sched.c
index b93e001806..7967c35533 100644
--- a/drivers/net/ice/ice_dcf_sched.c
+++ b/drivers/net/ice/ice_dcf_sched.c
@@ -18,7 +18,7 @@ static int ice_dcf_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
static int ice_dcf_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int ice_dcf_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -463,7 +463,7 @@ ice_dcf_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
}
static int
-ice_dcf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+ice_dcf_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min bucket size not supported */
@@ -491,7 +491,7 @@ ice_dcf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
ice_dcf_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct ice_dcf_adapter *adapter = dev->data->dev_private;
diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c
index c977e6b177..8a29a9e744 100644
--- a/drivers/net/ice/ice_tm.c
+++ b/drivers/net/ice/ice_tm.c
@@ -23,7 +23,7 @@ static int ice_node_type_get(struct rte_eth_dev *dev, uint32_t node_id,
int *is_leaf, struct rte_tm_error *error);
static int ice_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int ice_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -237,7 +237,7 @@ ice_shaper_profile_search(struct rte_eth_dev *dev,
}
static int
-ice_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+ice_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min bucket size not supported */
@@ -265,7 +265,7 @@ ice_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
ice_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c b/drivers/net/ipn3ke/ipn3ke_tm.c
index 20a0ed0467..eec01bb037 100644
--- a/drivers/net/ipn3ke/ipn3ke_tm.c
+++ b/drivers/net/ipn3ke/ipn3ke_tm.c
@@ -722,7 +722,7 @@ ipn3ke_tm_node_capabilities_get(struct rte_eth_dev *dev,
}
static int
-ipn3ke_tm_shaper_parame_trans(struct rte_tm_shaper_params *profile,
+ipn3ke_tm_shaper_parame_trans(const struct rte_tm_shaper_params *profile,
struct ipn3ke_tm_shaper_profile *local_profile,
const struct ipn3ke_tm_shaper_params_range_type *ref_data)
{
@@ -747,7 +747,7 @@ ipn3ke_tm_shaper_parame_trans(struct rte_tm_shaper_params *profile,
static int
ipn3ke_tm_shaper_profile_add(struct rte_eth_dev *dev,
- uint32_t shaper_profile_id, struct rte_tm_shaper_params *profile,
+ uint32_t shaper_profile_id, const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
diff --git a/drivers/net/ixgbe/ixgbe_tm.c b/drivers/net/ixgbe/ixgbe_tm.c
index 75cd707109..27a821285d 100644
--- a/drivers/net/ixgbe/ixgbe_tm.c
+++ b/drivers/net/ixgbe/ixgbe_tm.c
@@ -11,7 +11,7 @@ static int ixgbe_tm_capabilities_get(struct rte_eth_dev *dev,
struct rte_tm_error *error);
static int ixgbe_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int ixgbe_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -226,7 +226,7 @@ ixgbe_shaper_profile_search(struct rte_eth_dev *dev,
}
static int
-ixgbe_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+ixgbe_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min rate not supported */
@@ -260,7 +260,7 @@ ixgbe_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
ixgbe_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct ixgbe_tm_conf *tm_conf =
diff --git a/drivers/net/mvpp2/mrvl_tm.c b/drivers/net/mvpp2/mrvl_tm.c
index 9fac80b867..3c7cf481a5 100644
--- a/drivers/net/mvpp2/mrvl_tm.c
+++ b/drivers/net/mvpp2/mrvl_tm.c
@@ -380,7 +380,7 @@ mrvl_shaper_profile_from_id(struct mrvl_priv *priv, uint32_t shaper_profile_id)
*/
static int
mrvl_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *params,
+ const struct rte_tm_shaper_params *params,
struct rte_tm_error *error)
{
struct mrvl_priv *priv = dev->data->dev_private;
diff --git a/drivers/net/txgbe/txgbe_tm.c b/drivers/net/txgbe/txgbe_tm.c
index 8ed4d24459..b62bcf54aa 100644
--- a/drivers/net/txgbe/txgbe_tm.c
+++ b/drivers/net/txgbe/txgbe_tm.c
@@ -12,7 +12,7 @@ static int txgbe_tm_capabilities_get(struct rte_eth_dev *dev,
struct rte_tm_error *error);
static int txgbe_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int txgbe_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -218,7 +218,7 @@ txgbe_shaper_profile_search(struct rte_eth_dev *dev,
}
static int
-txgbe_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+txgbe_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min rate not supported */
@@ -252,7 +252,7 @@ txgbe_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
txgbe_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct txgbe_tm_conf *tm_conf = TXGBE_DEV_TM_CONF(dev);
diff --git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c
index d221b1e553..3eb98e618a 100644
--- a/lib/ethdev/rte_tm.c
+++ b/lib/ethdev/rte_tm.c
@@ -218,7 +218,7 @@ int rte_tm_shared_wred_context_delete(uint16_t port_id,
/* Add shaper profile */
int rte_tm_shaper_profile_add(uint16_t port_id,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
diff --git a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h
index f6f3f6a8d4..e5da9b8323 100644
--- a/lib/ethdev/rte_tm.h
+++ b/lib/ethdev/rte_tm.h
@@ -1449,7 +1449,7 @@ rte_tm_shared_wred_context_delete(uint16_t port_id,
int
rte_tm_shaper_profile_add(uint16_t port_id,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
/**
diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h
index b6ecf1bd4d..6c2618c0d8 100644
--- a/lib/ethdev/rte_tm_driver.h
+++ b/lib/ethdev/rte_tm_driver.h
@@ -75,7 +75,7 @@ typedef int (*rte_tm_shared_wred_context_delete_t)(
/** @internal Traffic manager shaper profile add */
typedef int (*rte_tm_shaper_profile_add_t)(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
/** @internal Traffic manager shaper profile delete */
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH 3/4] ethdev: make TM shaper parameters constant
2024-08-06 15:24 ` [PATCH 3/4] ethdev: make TM shaper parameters constant Bruce Richardson
@ 2024-08-07 7:29 ` Xu, Rosen
2024-09-22 16:11 ` Ferruh Yigit
0 siblings, 1 reply; 20+ messages in thread
From: Xu, Rosen @ 2024-08-07 7:29 UTC (permalink / raw)
To: Richardson, Bruce, dev
Cc: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
Harman Kalra, Hemant Agrawal, Sachin Saxena, Jie Hai,
Yisen Zhuang, Wu, Jingjing, Liron Himi, Jiawen Wu, Jian Wang,
Dumitrescu, Cristian, Thomas Monjalon, Ferruh Yigit,
Andrew Rybchenko
Hi,
> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Tuesday, August 6, 2024 11:24 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Nithin Dabilpuram
> <ndabilpuram@marvell.com>; Kiran Kumar K <kirankumark@marvell.com>;
> Sunil Kumar Kori <skori@marvell.com>; Satha Rao
> <skoteshwar@marvell.com>; Harman Kalra <hkalra@marvell.com>; Hemant
> Agrawal <hemant.agrawal@nxp.com>; Sachin Saxena
> <sachin.saxena@nxp.com>; Jie Hai <haijie1@huawei.com>; Yisen Zhuang
> <yisen.zhuang@huawei.com>; Wu, Jingjing <jingjing.wu@intel.com>; Xu,
> Rosen <rosen.xu@intel.com>; Liron Himi <lironh@marvell.com>; Jiawen Wu
> <jiawenwu@trustnetic.com>; Jian Wang <jianwang@trustnetic.com>;
> Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Thomas Monjalon
> <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@amd.com>; Andrew
> Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Subject: [PATCH 3/4] ethdev: make TM shaper parameters constant
>
> The function to add a new shaper profile in rte_tm should not (and does
> not) modify the profile parameters passed in via struct pointer. We should
> guarantee this by marking the parameter pointer as const. This allows SW to
> create multiple profiles using the same parameter struct without having to
> reset it each time.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
> diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c
> b/drivers/net/ipn3ke/ipn3ke_tm.c index 20a0ed0467..eec01bb037 100644
> --- a/drivers/net/ipn3ke/ipn3ke_tm.c
> +++ b/drivers/net/ipn3ke/ipn3ke_tm.c
> @@ -722,7 +722,7 @@ ipn3ke_tm_node_capabilities_get(struct
> rte_eth_dev *dev, }
>
> static int
> -ipn3ke_tm_shaper_parame_trans(struct rte_tm_shaper_params *profile,
> +ipn3ke_tm_shaper_parame_trans(const struct rte_tm_shaper_params
> +*profile,
> struct ipn3ke_tm_shaper_profile *local_profile,
> const struct ipn3ke_tm_shaper_params_range_type *ref_data)
> { @@ -747,7 +747,7 @@ ipn3ke_tm_shaper_parame_trans(struct
> rte_tm_shaper_params *profile,
>
> static int
> ipn3ke_tm_shaper_profile_add(struct rte_eth_dev *dev,
> - uint32_t shaper_profile_id, struct rte_tm_shaper_params *profile,
> + uint32_t shaper_profile_id, const struct rte_tm_shaper_params
> +*profile,
> struct rte_tm_error *error)
> {
> struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev); diff --
> /** @internal Traffic manager shaper profile delete */
> --
> 2.43.0
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/4] ethdev: make TM shaper parameters constant
2024-08-07 7:29 ` Xu, Rosen
@ 2024-09-22 16:11 ` Ferruh Yigit
0 siblings, 0 replies; 20+ messages in thread
From: Ferruh Yigit @ 2024-09-22 16:11 UTC (permalink / raw)
To: Xu, Rosen, Richardson, Bruce, dev
Cc: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
Harman Kalra, Hemant Agrawal, Sachin Saxena, Jie Hai,
Yisen Zhuang, Wu, Jingjing, Liron Himi, Jiawen Wu, Jian Wang,
Dumitrescu, Cristian, Thomas Monjalon, Andrew Rybchenko
On 8/7/2024 8:29 AM, Xu, Rosen wrote:
> Hi,
>
>> -----Original Message-----
<...>
>> Subject: [PATCH 3/4] ethdev: make TM shaper parameters constant
>>
>> The function to add a new shaper profile in rte_tm should not (and does
>> not) modify the profile parameters passed in via struct pointer. We should
>> guarantee this by marking the parameter pointer as const. This allows SW to
>> create multiple profiles using the same parameter struct without having to
>> reset it each time.
>>
>> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>
> Reviewed-by: Rosen Xu <rosen.xu@intel.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 4/4] ethdev: add traffic manager query function
2024-08-06 15:24 [PATCH 0/4] improve rte_tm APIs Bruce Richardson
` (2 preceding siblings ...)
2024-08-06 15:24 ` [PATCH 3/4] ethdev: make TM shaper parameters constant Bruce Richardson
@ 2024-08-06 15:24 ` Bruce Richardson
2024-09-22 16:26 ` Ferruh Yigit
2024-10-07 11:49 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Bruce Richardson
4 siblings, 1 reply; 20+ messages in thread
From: Bruce Richardson @ 2024-08-06 15:24 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, Thomas Monjalon, Ferruh Yigit,
Andrew Rybchenko, Cristian Dumitrescu
Add function to allow querying a node in the scheduler tree. Returns
the parameters as were given to the add function. Adding this function
allows apps to just query the hierarchy rather than having to maintain
their own copies of it internally.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/ethdev/ethdev_trace.h | 16 +++++++++++
lib/ethdev/ethdev_trace_points.c | 3 ++
lib/ethdev/rte_tm.c | 25 +++++++++++++++++
lib/ethdev/rte_tm.h | 48 ++++++++++++++++++++++++++++++++
lib/ethdev/rte_tm_driver.h | 12 ++++++++
5 files changed, 104 insertions(+)
diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h
index 3bec87bfdb..dee2819531 100644
--- a/lib/ethdev/ethdev_trace.h
+++ b/lib/ethdev/ethdev_trace.h
@@ -1903,6 +1903,22 @@ RTE_TRACE_POINT(
rte_trace_point_emit_int(ret);
)
+RTE_TRACE_POINT(
+ rte_tm_trace_node_query,
+ RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t node_id,
+ uint32_t *parent_node_id, uint32_t *priority,
+ uint32_t *weight, uint32_t *level_id,
+ struct rte_tm_node_params *params, int ret),
+ rte_trace_point_emit_u16(port_id);
+ rte_trace_point_emit_u32(node_id);
+ rte_trace_point_emit_ptr(parent_node_id);
+ rte_trace_point_emit_ptr(priority);
+ rte_trace_point_emit_ptr(weight);
+ rte_trace_point_emit_ptr(level_id);
+ rte_trace_point_emit_ptr(params);
+ rte_trace_point_emit_int(ret);
+)
+
RTE_TRACE_POINT(
rte_tm_trace_node_delete,
RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t node_id, int ret),
diff --git a/lib/ethdev/ethdev_trace_points.c b/lib/ethdev/ethdev_trace_points.c
index 99e04f5893..f5ed7ca637 100644
--- a/lib/ethdev/ethdev_trace_points.c
+++ b/lib/ethdev/ethdev_trace_points.c
@@ -694,6 +694,9 @@ RTE_TRACE_POINT_REGISTER(rte_tm_trace_mark_vlan_dei,
RTE_TRACE_POINT_REGISTER(rte_tm_trace_node_add,
lib.ethdev.tm.node_add)
+RTE_TRACE_POINT_REGISTER(rte_tm_trace_node_query,
+ lib.ethdev.tm.node_query)
+
RTE_TRACE_POINT_REGISTER(rte_tm_trace_node_capabilities_get,
lib.ethdev.tm.node_capabilities_get)
diff --git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c
index 3eb98e618a..8000b66af9 100644
--- a/lib/ethdev/rte_tm.c
+++ b/lib/ethdev/rte_tm.c
@@ -301,6 +301,31 @@ int rte_tm_node_add(uint16_t port_id,
return ret;
}
+int rte_tm_node_query(uint16_t port_id,
+ uint32_t node_id,
+ uint32_t *parent_node_id,
+ uint32_t *priority,
+ uint32_t *weight,
+ uint32_t *level_id,
+ struct rte_tm_node_params *params,
+ struct rte_tm_error *error)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+ int ret;
+
+ if (dev == NULL)
+ return -EINVAL;
+
+ ret = RTE_TM_FUNC(port_id, node_query)(dev,
+ node_id, parent_node_id, priority, weight, level_id,
+ params, error);
+
+ rte_tm_trace_node_query(port_id, node_id, parent_node_id, priority,
+ weight, level_id, params, ret);
+
+ return ret;
+}
+
/* Delete node from traffic manager hierarchy */
int rte_tm_node_delete(uint16_t port_id,
uint32_t node_id,
diff --git a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h
index e5da9b8323..419e491043 100644
--- a/lib/ethdev/rte_tm.h
+++ b/lib/ethdev/rte_tm.h
@@ -1599,6 +1599,54 @@ rte_tm_node_add(uint16_t port_id,
const struct rte_tm_node_params *params,
struct rte_tm_error *error);
+/**
+ * Return information about a traffic management node
+ *
+ * Return information about a hierarchy node, using the same format of parameters
+ * as was passed to the rte_rm_node_add() function.
+ * Each of the "out" parameters pointers (except error) may be passed as NULL if the
+ * information is not needed by the caller. For example, to one may check if a node id
+ * is in use by:
+ *
+ * struct rte_tm_error error;
+ * int ret = rte_tm_node_query(port, node_id, NULL, NULL, NULL, NULL, NULL, &error);
+ * if (ret == ENOENT) ...
+ *
+ * @param[in] port_id
+ * The port identifier of the Ethernet device.
+ * @param[in] node_id
+ * Node ID. Should be a valid node id.
+ * @param[out] parent_node_id
+ * Parent node ID.
+ * @param[out] priority
+ * Node priority. The highest node priority is zero. Used by the SP algorithm
+ * running on the parent of the current node for scheduling this child node.
+ * @param[out] weight
+ * Node weight. The node weight is relative to the weight sum of all siblings
+ * that have the same priority. The lowest weight is one. Used by the WFQ
+ * algorithm running on the parent of the current node for scheduling this
+ * child node.
+ * @param[out] level_id
+ * The node level in the scheduler hierarchy.
+ * @param[out] params
+ * Node parameters, as would be used when creating the node.
+ * @param[out] error
+ * Error details. Filled in only on error, when not NULL.
+ * @return
+ * 0 on success, non-zero error code otherwise.
+ * -EINVAL - port or node id value is invalid
+ * -ENOENT - no node exists with the provided id
+ */
+int
+rte_tm_node_query(uint16_t port_id,
+ uint32_t node_id,
+ uint32_t *parent_node_id,
+ uint32_t *priority,
+ uint32_t *weight,
+ uint32_t *level_id,
+ struct rte_tm_node_params *params,
+ struct rte_tm_error *error);
+
/**
* Traffic manager node delete
*
diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h
index 6c2618c0d8..fc67f1cb4b 100644
--- a/lib/ethdev/rte_tm_driver.h
+++ b/lib/ethdev/rte_tm_driver.h
@@ -119,6 +119,16 @@ typedef int (*rte_tm_node_resume_t)(struct rte_eth_dev *dev,
uint32_t node_id,
struct rte_tm_error *error);
+/** @internal Traffic manager node query */
+typedef int (*rte_tm_node_query_t)(const struct rte_eth_dev *dev,
+ uint32_t node_id,
+ uint32_t *parent_node_id,
+ uint32_t *priority,
+ uint32_t *weight,
+ uint32_t *level_id,
+ struct rte_tm_node_params *params,
+ struct rte_tm_error *error);
+
/** @internal Traffic manager hierarchy commit */
typedef int (*rte_tm_hierarchy_commit_t)(struct rte_eth_dev *dev,
int clear_on_fail,
@@ -248,6 +258,8 @@ struct rte_tm_ops {
rte_tm_node_suspend_t node_suspend;
/** Traffic manager node resume */
rte_tm_node_resume_t node_resume;
+ /** Traffic manager node resume */
+ rte_tm_node_query_t node_query;
/** Traffic manager hierarchy commit */
rte_tm_hierarchy_commit_t hierarchy_commit;
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/4] ethdev: add traffic manager query function
2024-08-06 15:24 ` [PATCH 4/4] ethdev: add traffic manager query function Bruce Richardson
@ 2024-09-22 16:26 ` Ferruh Yigit
2024-10-07 11:04 ` Bruce Richardson
0 siblings, 1 reply; 20+ messages in thread
From: Ferruh Yigit @ 2024-09-22 16:26 UTC (permalink / raw)
To: Bruce Richardson, dev
Cc: Thomas Monjalon, Andrew Rybchenko, Cristian Dumitrescu
On 8/6/2024 4:24 PM, Bruce Richardson wrote:
> +/**
> + * Return information about a traffic management node
> + *
> + * Return information about a hierarchy node, using the same format of parameters
> + * as was passed to the rte_rm_node_add() function.
> + * Each of the "out" parameters pointers (except error) may be passed as NULL if the
> + * information is not needed by the caller. For example, to one may check if a node id
> + * is in use by:
> + *
> + * struct rte_tm_error error;
> + * int ret = rte_tm_node_query(port, node_id, NULL, NULL, NULL, NULL, NULL, &error);
> + * if (ret == ENOENT) ...
> + *
> + * @param[in] port_id
> + * The port identifier of the Ethernet device.
> + * @param[in] node_id
> + * Node ID. Should be a valid node id.
> + * @param[out] parent_node_id
> + * Parent node ID.
> + * @param[out] priority
> + * Node priority. The highest node priority is zero. Used by the SP algorithm
> + * running on the parent of the current node for scheduling this child node.
> + * @param[out] weight
> + * Node weight. The node weight is relative to the weight sum of all siblings
> + * that have the same priority. The lowest weight is one. Used by the WFQ
> + * algorithm running on the parent of the current node for scheduling this
> + * child node.
> + * @param[out] level_id
> + * The node level in the scheduler hierarchy.
> + * @param[out] params
> + * Node parameters, as would be used when creating the node.
> + * @param[out] error
> + * Error details. Filled in only on error, when not NULL.
> + * @return
> + * 0 on success, non-zero error code otherwise.
> + * -EINVAL - port or node id value is invalid
> + * -ENOENT - no node exists with the provided id
> + */
> +int
> +rte_tm_node_query(uint16_t port_id,
> + uint32_t node_id,
> + uint32_t *parent_node_id,
> + uint32_t *priority,
> + uint32_t *weight,
> + uint32_t *level_id,
> + struct rte_tm_node_params *params,
> + struct rte_tm_error *error);
> +
>
No objection to get an TM node query API overall, but it would be good
to get more comment on the what correct API should be, we are missing it.
Both because it is not discussed much, and it is first release, better
to add this API as experimental.
Also we should have an implementation in driver and a sample application
usage (testpmd?) with new API. Are these planned separately for this
release, or can it be available part of next version of this patch?
Finally, does it worth documenting this in release notes, as just a
query API I am not sure if this a notable feature, but just a reminder.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/4] ethdev: add traffic manager query function
2024-09-22 16:26 ` Ferruh Yigit
@ 2024-10-07 11:04 ` Bruce Richardson
2024-10-08 10:56 ` Bruce Richardson
0 siblings, 1 reply; 20+ messages in thread
From: Bruce Richardson @ 2024-10-07 11:04 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, Thomas Monjalon, Andrew Rybchenko, Cristian Dumitrescu
On Sun, Sep 22, 2024 at 05:26:30PM +0100, Ferruh Yigit wrote:
> On 8/6/2024 4:24 PM, Bruce Richardson wrote:
> > +/**
> > + * Return information about a traffic management node
> > + *
> > + * Return information about a hierarchy node, using the same format of parameters
> > + * as was passed to the rte_rm_node_add() function.
> > + * Each of the "out" parameters pointers (except error) may be passed as NULL if the
> > + * information is not needed by the caller. For example, to one may check if a node id
> > + * is in use by:
> > + *
> > + * struct rte_tm_error error;
> > + * int ret = rte_tm_node_query(port, node_id, NULL, NULL, NULL, NULL, NULL, &error);
> > + * if (ret == ENOENT) ...
> > + *
> > + * @param[in] port_id
> > + * The port identifier of the Ethernet device.
> > + * @param[in] node_id
> > + * Node ID. Should be a valid node id.
> > + * @param[out] parent_node_id
> > + * Parent node ID.
> > + * @param[out] priority
> > + * Node priority. The highest node priority is zero. Used by the SP algorithm
> > + * running on the parent of the current node for scheduling this child node.
> > + * @param[out] weight
> > + * Node weight. The node weight is relative to the weight sum of all siblings
> > + * that have the same priority. The lowest weight is one. Used by the WFQ
> > + * algorithm running on the parent of the current node for scheduling this
> > + * child node.
> > + * @param[out] level_id
> > + * The node level in the scheduler hierarchy.
> > + * @param[out] params
> > + * Node parameters, as would be used when creating the node.
> > + * @param[out] error
> > + * Error details. Filled in only on error, when not NULL.
> > + * @return
> > + * 0 on success, non-zero error code otherwise.
> > + * -EINVAL - port or node id value is invalid
> > + * -ENOENT - no node exists with the provided id
> > + */
> > +int
> > +rte_tm_node_query(uint16_t port_id,
> > + uint32_t node_id,
> > + uint32_t *parent_node_id,
> > + uint32_t *priority,
> > + uint32_t *weight,
> > + uint32_t *level_id,
> > + struct rte_tm_node_params *params,
> > + struct rte_tm_error *error);
> > +
> >
>
> No objection to get an TM node query API overall, but it would be good
> to get more comment on the what correct API should be, we are missing it.
> Both because it is not discussed much, and it is first release, better
> to add this API as experimental.
>
Yes, good point, it should be added to version.map file and marked as
experimental. Happy to take any feedback on what the API should be.
> Also we should have an implementation in driver and a sample application
> usage (testpmd?) with new API. Are these planned separately for this
> release, or can it be available part of next version of this patch?
>
I have an implemented for ice driver in [1]. On testpmd side, I never
thought to do so, because it was more for me when writing test code around
the APIs than for actual end-users. [As I explain, this API should save app
developers the work of storing a copy of the TM hierarchy in the app code
too]. However, I think it may be no harm to do a testpmd call for it, it
may be useful for debugging.
[1] https://patches.dpdk.org/project/dpdk/patch/20240812152815.1132697-2-bruce.richardson@intel.com/
> Finally, does it worth documenting this in release notes, as just a
> query API I am not sure if this a notable feature, but just a reminder.
>
Don't think it requires an RN item.
Will perhaps do a new revision of this patchset without this final patch,
and then submit this patch as a separate one for tracking. I don't think
the other patches to mark things const should be blocked by discussion on
this.
Regards,
/Bruce
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/4] ethdev: add traffic manager query function
2024-10-07 11:04 ` Bruce Richardson
@ 2024-10-08 10:56 ` Bruce Richardson
0 siblings, 0 replies; 20+ messages in thread
From: Bruce Richardson @ 2024-10-08 10:56 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, Thomas Monjalon, Andrew Rybchenko, Cristian Dumitrescu
On Mon, Oct 07, 2024 at 12:04:37PM +0100, Bruce Richardson wrote:
> On Sun, Sep 22, 2024 at 05:26:30PM +0100, Ferruh Yigit wrote:
> > On 8/6/2024 4:24 PM, Bruce Richardson wrote:
> > > +/**
> > > + * Return information about a traffic management node
> > > + *
> > > + * Return information about a hierarchy node, using the same format of parameters
> > > + * as was passed to the rte_rm_node_add() function.
> > > + * Each of the "out" parameters pointers (except error) may be passed as NULL if the
> > > + * information is not needed by the caller. For example, to one may check if a node id
> > > + * is in use by:
> > > + *
> > > + * struct rte_tm_error error;
> > > + * int ret = rte_tm_node_query(port, node_id, NULL, NULL, NULL, NULL, NULL, &error);
> > > + * if (ret == ENOENT) ...
> > > + *
> > > + * @param[in] port_id
> > > + * The port identifier of the Ethernet device.
> > > + * @param[in] node_id
> > > + * Node ID. Should be a valid node id.
> > > + * @param[out] parent_node_id
> > > + * Parent node ID.
> > > + * @param[out] priority
> > > + * Node priority. The highest node priority is zero. Used by the SP algorithm
> > > + * running on the parent of the current node for scheduling this child node.
> > > + * @param[out] weight
> > > + * Node weight. The node weight is relative to the weight sum of all siblings
> > > + * that have the same priority. The lowest weight is one. Used by the WFQ
> > > + * algorithm running on the parent of the current node for scheduling this
> > > + * child node.
> > > + * @param[out] level_id
> > > + * The node level in the scheduler hierarchy.
> > > + * @param[out] params
> > > + * Node parameters, as would be used when creating the node.
> > > + * @param[out] error
> > > + * Error details. Filled in only on error, when not NULL.
> > > + * @return
> > > + * 0 on success, non-zero error code otherwise.
> > > + * -EINVAL - port or node id value is invalid
> > > + * -ENOENT - no node exists with the provided id
> > > + */
> > > +int
> > > +rte_tm_node_query(uint16_t port_id,
> > > + uint32_t node_id,
> > > + uint32_t *parent_node_id,
> > > + uint32_t *priority,
> > > + uint32_t *weight,
> > > + uint32_t *level_id,
> > > + struct rte_tm_node_params *params,
> > > + struct rte_tm_error *error);
> > > +
> > >
> >
> > No objection to get an TM node query API overall, but it would be good
> > to get more comment on the what correct API should be, we are missing it.
> > Both because it is not discussed much, and it is first release, better
> > to add this API as experimental.
> >
>
> Yes, good point, it should be added to version.map file and marked as
> experimental. Happy to take any feedback on what the API should be.
>
> > Also we should have an implementation in driver and a sample application
> > usage (testpmd?) with new API. Are these planned separately for this
> > release, or can it be available part of next version of this patch?
> >
> I have an implemented for ice driver in [1]. On testpmd side, I never
> thought to do so, because it was more for me when writing test code around
> the APIs than for actual end-users. [As I explain, this API should save app
> developers the work of storing a copy of the TM hierarchy in the app code
> too]. However, I think it may be no harm to do a testpmd call for it, it
> may be useful for debugging.
>
> [1] https://patches.dpdk.org/project/dpdk/patch/20240812152815.1132697-2-bruce.richardson@intel.com/
>
> > Finally, does it worth documenting this in release notes, as just a
> > query API I am not sure if this a notable feature, but just a reminder.
> >
>
> Don't think it requires an RN item.
>
> Will perhaps do a new revision of this patchset without this final patch,
> and then submit this patch as a separate one for tracking. I don't think
> the other patches to mark things const should be blocked by discussion on
> this.
>
This patch is now split off into separate series including driver update
and testpmd command:
https://patches.dpdk.org/project/dpdk/list/?series=33342
Regards,
/Bruce
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 0/3] make struct parameters constant in rte_tm APIs
2024-08-06 15:24 [PATCH 0/4] improve rte_tm APIs Bruce Richardson
` (3 preceding siblings ...)
2024-08-06 15:24 ` [PATCH 4/4] ethdev: add traffic manager query function Bruce Richardson
@ 2024-10-07 11:49 ` Bruce Richardson
2024-10-07 11:49 ` [PATCH v2 1/3] ethdev: make parameters to TM node add fn constant Bruce Richardson
` (3 more replies)
4 siblings, 4 replies; 20+ messages in thread
From: Bruce Richardson @ 2024-10-07 11:49 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
For functions for creating profiles, shapers and hierarchy nodes, make
the parameter structure pointer a pointer to a const object. This
guarantees to the user that the struct won't be modified by the
function, which allows the user to re-use the same parameters multiple
times without having to constantly reinitialize it.
V2: drop final patch with new node query function, simplifying patchset
Bruce Richardson (3):
ethdev: make parameters to TM node add fn constant
ethdev: make parameters to TM profile add fn constant
ethdev: make TM shaper parameters constant
drivers/net/cnxk/cnxk_tm.c | 4 ++--
drivers/net/dpaa2/dpaa2_tm.c | 6 +++---
drivers/net/hns3/hns3_tm.c | 22 +++++++++++-----------
drivers/net/i40e/i40e_tm.c | 12 ++++++------
drivers/net/iavf/iavf_tm.c | 12 ++++++------
drivers/net/ice/ice_dcf_sched.c | 12 ++++++------
drivers/net/ice/ice_tm.c | 12 ++++++------
drivers/net/ipn3ke/ipn3ke_tm.c | 12 ++++++------
drivers/net/ixgbe/ixgbe_tm.c | 12 ++++++------
drivers/net/mvpp2/mrvl_tm.c | 2 +-
drivers/net/txgbe/txgbe_tm.c | 12 ++++++------
lib/ethdev/rte_tm.c | 6 +++---
lib/ethdev/rte_tm.h | 6 +++---
lib/ethdev/rte_tm_driver.h | 6 +++---
14 files changed, 68 insertions(+), 68 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 1/3] ethdev: make parameters to TM node add fn constant
2024-10-07 11:49 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Bruce Richardson
@ 2024-10-07 11:49 ` Bruce Richardson
2024-10-07 11:49 ` [PATCH v2 2/3] ethdev: make parameters to TM profile " Bruce Richardson
` (2 subsequent siblings)
3 siblings, 0 replies; 20+ messages in thread
From: Bruce Richardson @ 2024-10-07 11:49 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, Rosen Xu, Ferruh Yigit
The function to add a new scheduling node in rte_tm should not (and
does not) modify the actual node parameters passed in via struct
pointer. We should guarantee this by marking the parameter pointer as
const. This allows SW to create multiple scheduling nodes using the same
parameter struct without having to reset it each time.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
drivers/net/cnxk/cnxk_tm.c | 2 +-
drivers/net/dpaa2/dpaa2_tm.c | 4 ++--
drivers/net/hns3/hns3_tm.c | 16 ++++++++--------
drivers/net/i40e/i40e_tm.c | 6 +++---
drivers/net/iavf/iavf_tm.c | 6 +++---
drivers/net/ice/ice_dcf_sched.c | 6 +++---
drivers/net/ice/ice_tm.c | 6 +++---
drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
drivers/net/ixgbe/ixgbe_tm.c | 6 +++---
drivers/net/txgbe/txgbe_tm.c | 6 +++---
lib/ethdev/rte_tm.c | 2 +-
lib/ethdev/rte_tm.h | 2 +-
lib/ethdev/rte_tm_driver.h | 2 +-
13 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_tm.c b/drivers/net/cnxk/cnxk_tm.c
index c799193cb8..9293b3e8f2 100644
--- a/drivers/net/cnxk/cnxk_tm.c
+++ b/drivers/net/cnxk/cnxk_tm.c
@@ -336,7 +336,7 @@ static int
cnxk_nix_tm_node_add(struct rte_eth_dev *eth_dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t lvl,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
diff --git a/drivers/net/dpaa2/dpaa2_tm.c b/drivers/net/dpaa2/dpaa2_tm.c
index cb854964b4..22337097e5 100644
--- a/drivers/net/dpaa2/dpaa2_tm.c
+++ b/drivers/net/dpaa2/dpaa2_tm.c
@@ -359,7 +359,7 @@ static int
dpaa2_node_check_params(struct rte_eth_dev *dev, uint32_t node_id,
__rte_unused uint32_t priority, uint32_t weight,
uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
if (node_id == RTE_TM_NODE_ID_NULL)
@@ -431,7 +431,7 @@ dpaa2_node_check_params(struct rte_eth_dev *dev, uint32_t node_id,
static int
dpaa2_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority, uint32_t weight,
- uint32_t level_id, struct rte_tm_node_params *params,
+ uint32_t level_id, const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct dpaa2_dev_priv *priv = dev->data->dev_private;
diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c
index 92a668538f..06df32bbcd 100644
--- a/drivers/net/hns3/hns3_tm.c
+++ b/drivers/net/hns3/hns3_tm.c
@@ -329,7 +329,7 @@ hns3_tm_node_search(struct rte_eth_dev *dev,
static int
hns3_tm_nonleaf_node_param_check(struct rte_eth_dev *dev,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_tm_shaper_profile *shaper_profile;
@@ -364,7 +364,7 @@ hns3_tm_nonleaf_node_param_check(struct rte_eth_dev *dev,
static int
hns3_tm_leaf_node_param_check(struct rte_eth_dev *dev __rte_unused,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
@@ -408,7 +408,7 @@ hns3_tm_leaf_node_param_check(struct rte_eth_dev *dev __rte_unused,
static int
hns3_tm_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -457,7 +457,7 @@ hns3_tm_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
static int
hns3_tm_port_node_add(struct rte_eth_dev *dev, uint32_t node_id,
- uint32_t level_id, struct rte_tm_node_params *params,
+ uint32_t level_id, const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -503,7 +503,7 @@ hns3_tm_port_node_add(struct rte_eth_dev *dev, uint32_t node_id,
static int
hns3_tm_tc_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t level_id, struct hns3_tm_node *parent_node,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -554,7 +554,7 @@ hns3_tm_tc_node_add(struct rte_eth_dev *dev, uint32_t node_id,
static int
hns3_tm_queue_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t level_id, struct hns3_tm_node *parent_node,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -601,7 +601,7 @@ static int
hns3_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -1230,7 +1230,7 @@ static int
hns3_tm_node_add_wrap(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/i40e/i40e_tm.c b/drivers/net/i40e/i40e_tm.c
index cab296e1a4..c7d4680fb4 100644
--- a/drivers/net/i40e/i40e_tm.c
+++ b/drivers/net/i40e/i40e_tm.c
@@ -20,7 +20,7 @@ static int i40e_shaper_profile_del(struct rte_eth_dev *dev,
static int i40e_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int i40e_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -353,7 +353,7 @@ i40e_tm_node_search(struct rte_eth_dev *dev,
static int
i40e_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -450,7 +450,7 @@ static int
i40e_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/iavf/iavf_tm.c b/drivers/net/iavf/iavf_tm.c
index 32bb3be45e..f9883927be 100644
--- a/drivers/net/iavf/iavf_tm.c
+++ b/drivers/net/iavf/iavf_tm.c
@@ -18,7 +18,7 @@ static int iavf_shaper_profile_del(struct rte_eth_dev *dev,
static int iavf_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int iavf_tm_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -131,7 +131,7 @@ iavf_tm_node_search(struct rte_eth_dev *dev,
static int
iavf_node_param_check(struct iavf_info *vf, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
/* checked all the unsupported parameter */
@@ -271,7 +271,7 @@ static int
iavf_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
diff --git a/drivers/net/ice/ice_dcf_sched.c b/drivers/net/ice/ice_dcf_sched.c
index b08bc5f1de..b93e001806 100644
--- a/drivers/net/ice/ice_dcf_sched.c
+++ b/drivers/net/ice/ice_dcf_sched.c
@@ -12,7 +12,7 @@ static int ice_dcf_hierarchy_commit(struct rte_eth_dev *dev,
static int ice_dcf_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int ice_dcf_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -139,7 +139,7 @@ ice_dcf_shaper_profile_search(struct rte_eth_dev *dev,
static int
ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
/* checked all the unsupported parameter */
@@ -230,7 +230,7 @@ static int
ice_dcf_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
enum ice_dcf_tm_node_type parent_node_type = ICE_DCF_TM_NODE_TYPE_MAX;
diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c
index 7239ab53f1..c977e6b177 100644
--- a/drivers/net/ice/ice_tm.c
+++ b/drivers/net/ice/ice_tm.c
@@ -15,7 +15,7 @@ static int ice_hierarchy_commit(struct rte_eth_dev *dev,
static int ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int ice_tm_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -82,7 +82,7 @@ ice_tm_conf_uninit(struct rte_eth_dev *dev)
static int
ice_node_param_check(struct ice_pf *pf, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
/* checked all the unsupported parameter */
@@ -337,7 +337,7 @@ static int
ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c b/drivers/net/ipn3ke/ipn3ke_tm.c
index 0260227900..cffe1fdaa4 100644
--- a/drivers/net/ipn3ke/ipn3ke_tm.c
+++ b/drivers/net/ipn3ke/ipn3ke_tm.c
@@ -1010,7 +1010,7 @@ ipn3ke_tm_tdrop_profile_delete(struct rte_eth_dev *dev,
static int
ipn3ke_tm_node_add_check_parameter(uint32_t tm_id,
uint32_t node_id, uint32_t parent_node_id, uint32_t priority,
- uint32_t weight, uint32_t level_id, struct rte_tm_node_params *params,
+ uint32_t weight, uint32_t level_id, const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
uint32_t level_of_node_id;
@@ -1168,7 +1168,7 @@ ipn3ke_tm_node_add_check_mount(uint32_t tm_id,
static int
ipn3ke_tm_node_add(struct rte_eth_dev *dev,
uint32_t node_id, uint32_t parent_node_id, uint32_t priority,
- uint32_t weight, uint32_t level_id, struct rte_tm_node_params *params,
+ uint32_t weight, uint32_t level_id, const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
diff --git a/drivers/net/ixgbe/ixgbe_tm.c b/drivers/net/ixgbe/ixgbe_tm.c
index ac8976062f..75cd707109 100644
--- a/drivers/net/ixgbe/ixgbe_tm.c
+++ b/drivers/net/ixgbe/ixgbe_tm.c
@@ -19,7 +19,7 @@ static int ixgbe_shaper_profile_del(struct rte_eth_dev *dev,
static int ixgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int ixgbe_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -461,7 +461,7 @@ ixgbe_queue_base_nb_get(struct rte_eth_dev *dev, uint16_t tc_node_no,
static int
ixgbe_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
if (node_id == RTE_TM_NODE_ID_NULL) {
@@ -558,7 +558,7 @@ static int
ixgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct ixgbe_tm_conf *tm_conf =
diff --git a/drivers/net/txgbe/txgbe_tm.c b/drivers/net/txgbe/txgbe_tm.c
index 3171be73d0..8ed4d24459 100644
--- a/drivers/net/txgbe/txgbe_tm.c
+++ b/drivers/net/txgbe/txgbe_tm.c
@@ -20,7 +20,7 @@ static int txgbe_shaper_profile_del(struct rte_eth_dev *dev,
static int txgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
static int txgbe_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
@@ -450,7 +450,7 @@ txgbe_queue_base_nb_get(struct rte_eth_dev *dev, uint16_t tc_node_no,
static int
txgbe_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t priority, uint32_t weight,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
if (node_id == RTE_TM_NODE_ID_NULL) {
@@ -547,7 +547,7 @@ static int
txgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
uint32_t parent_node_id, uint32_t priority,
uint32_t weight, uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct txgbe_tm_conf *tm_conf = TXGBE_DEV_TM_CONF(dev);
diff --git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c
index d594fe0049..74e6f4d610 100644
--- a/lib/ethdev/rte_tm.c
+++ b/lib/ethdev/rte_tm.c
@@ -286,7 +286,7 @@ int rte_tm_node_add(uint16_t port_id,
uint32_t priority,
uint32_t weight,
uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
diff --git a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h
index 07028c9b36..c52acd1b4f 100644
--- a/lib/ethdev/rte_tm.h
+++ b/lib/ethdev/rte_tm.h
@@ -1596,7 +1596,7 @@ rte_tm_node_add(uint16_t port_id,
uint32_t priority,
uint32_t weight,
uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
/**
diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h
index 45290fb3fd..25d688516b 100644
--- a/lib/ethdev/rte_tm_driver.h
+++ b/lib/ethdev/rte_tm_driver.h
@@ -101,7 +101,7 @@ typedef int (*rte_tm_node_add_t)(struct rte_eth_dev *dev,
uint32_t priority,
uint32_t weight,
uint32_t level_id,
- struct rte_tm_node_params *params,
+ const struct rte_tm_node_params *params,
struct rte_tm_error *error);
/** @internal Traffic manager node delete */
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 2/3] ethdev: make parameters to TM profile add fn constant
2024-10-07 11:49 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Bruce Richardson
2024-10-07 11:49 ` [PATCH v2 1/3] ethdev: make parameters to TM node add fn constant Bruce Richardson
@ 2024-10-07 11:49 ` Bruce Richardson
2024-10-07 11:49 ` [PATCH v2 3/3] ethdev: make TM shaper parameters constant Bruce Richardson
2024-10-07 15:22 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Stephen Hemminger
3 siblings, 0 replies; 20+ messages in thread
From: Bruce Richardson @ 2024-10-07 11:49 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, Rosen Xu, Ferruh Yigit
The function to add a new profile in rte_tm should not (and does not)
modify the profile parameters passed in via struct pointer. We should
guarantee this by marking the parameter pointer as const. This allows
SW to create multiple profiles using the same parameter struct without
having to reset it each time.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
lib/ethdev/rte_tm.c | 2 +-
lib/ethdev/rte_tm.h | 2 +-
lib/ethdev/rte_tm_driver.h | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c b/drivers/net/ipn3ke/ipn3ke_tm.c
index cffe1fdaa4..20a0ed0467 100644
--- a/drivers/net/ipn3ke/ipn3ke_tm.c
+++ b/drivers/net/ipn3ke/ipn3ke_tm.c
@@ -848,7 +848,7 @@ ipn3ke_tm_shaper_profile_delete(struct rte_eth_dev *dev,
static int
ipn3ke_tm_tdrop_profile_check(__rte_unused struct rte_eth_dev *dev,
- uint32_t tdrop_profile_id, struct rte_tm_wred_params *profile,
+ uint32_t tdrop_profile_id, const struct rte_tm_wred_params *profile,
struct rte_tm_error *error)
{
enum rte_color color;
@@ -931,7 +931,7 @@ ipn3ke_hw_tm_tdrop_wr(struct ipn3ke_hw *hw,
/* Traffic manager TDROP profile add */
static int
ipn3ke_tm_tdrop_profile_add(struct rte_eth_dev *dev,
- uint32_t tdrop_profile_id, struct rte_tm_wred_params *profile,
+ uint32_t tdrop_profile_id, const struct rte_tm_wred_params *profile,
struct rte_tm_error *error)
{
struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
diff --git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c
index 74e6f4d610..d221b1e553 100644
--- a/lib/ethdev/rte_tm.c
+++ b/lib/ethdev/rte_tm.c
@@ -153,7 +153,7 @@ int rte_tm_node_capabilities_get(uint16_t port_id,
/* Add WRED profile */
int rte_tm_wred_profile_add(uint16_t port_id,
uint32_t wred_profile_id,
- struct rte_tm_wred_params *profile,
+ const struct rte_tm_wred_params *profile,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
diff --git a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h
index c52acd1b4f..f6f3f6a8d4 100644
--- a/lib/ethdev/rte_tm.h
+++ b/lib/ethdev/rte_tm.h
@@ -1347,7 +1347,7 @@ rte_tm_node_capabilities_get(uint16_t port_id,
int
rte_tm_wred_profile_add(uint16_t port_id,
uint32_t wred_profile_id,
- struct rte_tm_wred_params *profile,
+ const struct rte_tm_wred_params *profile,
struct rte_tm_error *error);
/**
diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h
index 25d688516b..b6ecf1bd4d 100644
--- a/lib/ethdev/rte_tm_driver.h
+++ b/lib/ethdev/rte_tm_driver.h
@@ -51,7 +51,7 @@ typedef int (*rte_tm_node_capabilities_get_t)(struct rte_eth_dev *dev,
/** @internal Traffic manager WRED profile add */
typedef int (*rte_tm_wred_profile_add_t)(struct rte_eth_dev *dev,
uint32_t wred_profile_id,
- struct rte_tm_wred_params *profile,
+ const struct rte_tm_wred_params *profile,
struct rte_tm_error *error);
/** @internal Traffic manager WRED profile delete */
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 3/3] ethdev: make TM shaper parameters constant
2024-10-07 11:49 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Bruce Richardson
2024-10-07 11:49 ` [PATCH v2 1/3] ethdev: make parameters to TM node add fn constant Bruce Richardson
2024-10-07 11:49 ` [PATCH v2 2/3] ethdev: make parameters to TM profile " Bruce Richardson
@ 2024-10-07 11:49 ` Bruce Richardson
2024-10-07 15:22 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Stephen Hemminger
3 siblings, 0 replies; 20+ messages in thread
From: Bruce Richardson @ 2024-10-07 11:49 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, Rosen Xu, Ferruh Yigit
The function to add a new shaper profile in rte_tm should not (and does
not) modify the profile parameters passed in via struct pointer. We
should guarantee this by marking the parameter pointer as const. This
allows SW to create multiple profiles using the same parameter
struct without having to reset it each time.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
drivers/net/cnxk/cnxk_tm.c | 2 +-
drivers/net/dpaa2/dpaa2_tm.c | 2 +-
drivers/net/hns3/hns3_tm.c | 6 +++---
drivers/net/i40e/i40e_tm.c | 6 +++---
drivers/net/iavf/iavf_tm.c | 6 +++---
drivers/net/ice/ice_dcf_sched.c | 6 +++---
drivers/net/ice/ice_tm.c | 6 +++---
drivers/net/ipn3ke/ipn3ke_tm.c | 4 ++--
drivers/net/ixgbe/ixgbe_tm.c | 6 +++---
drivers/net/mvpp2/mrvl_tm.c | 2 +-
drivers/net/txgbe/txgbe_tm.c | 6 +++---
lib/ethdev/rte_tm.c | 2 +-
lib/ethdev/rte_tm.h | 2 +-
lib/ethdev/rte_tm_driver.h | 2 +-
14 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_tm.c b/drivers/net/cnxk/cnxk_tm.c
index 9293b3e8f2..0ed6732dda 100644
--- a/drivers/net/cnxk/cnxk_tm.c
+++ b/drivers/net/cnxk/cnxk_tm.c
@@ -267,7 +267,7 @@ cnxk_nix_tm_node_capa_get(struct rte_eth_dev *eth_dev, uint32_t node_id,
static int
cnxk_nix_tm_shaper_profile_add(struct rte_eth_dev *eth_dev, uint32_t id,
- struct rte_tm_shaper_params *params,
+ const struct rte_tm_shaper_params *params,
struct rte_tm_error *error)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
diff --git a/drivers/net/dpaa2/dpaa2_tm.c b/drivers/net/dpaa2/dpaa2_tm.c
index 22337097e5..115397ce47 100644
--- a/drivers/net/dpaa2/dpaa2_tm.c
+++ b/drivers/net/dpaa2/dpaa2_tm.c
@@ -268,7 +268,7 @@ dpaa2_shaper_profile_from_id(struct dpaa2_dev_priv *priv,
static int
dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *params,
+ const struct rte_tm_shaper_params *params,
struct rte_tm_error *error)
{
struct dpaa2_dev_priv *priv = dev->data->dev_private;
diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c
index 06df32bbcd..1c2ad71133 100644
--- a/drivers/net/hns3/hns3_tm.c
+++ b/drivers/net/hns3/hns3_tm.c
@@ -166,7 +166,7 @@ hns3_tm_shaper_profile_search(struct rte_eth_dev *dev,
static int
hns3_tm_shaper_profile_param_check(struct rte_eth_dev *dev,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -220,7 +220,7 @@ hns3_tm_shaper_profile_param_check(struct rte_eth_dev *dev,
static int
hns3_tm_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -1198,7 +1198,7 @@ hns3_tm_capabilities_get_wrap(struct rte_eth_dev *dev,
static int
hns3_tm_shaper_profile_add_wrap(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/i40e/i40e_tm.c b/drivers/net/i40e/i40e_tm.c
index c7d4680fb4..4c0940f355 100644
--- a/drivers/net/i40e/i40e_tm.c
+++ b/drivers/net/i40e/i40e_tm.c
@@ -12,7 +12,7 @@ static int i40e_tm_capabilities_get(struct rte_eth_dev *dev,
struct rte_tm_error *error);
static int i40e_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int i40e_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -217,7 +217,7 @@ i40e_shaper_profile_search(struct rte_eth_dev *dev,
}
static int
-i40e_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+i40e_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min rate not supported */
@@ -251,7 +251,7 @@ i40e_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
i40e_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
diff --git a/drivers/net/iavf/iavf_tm.c b/drivers/net/iavf/iavf_tm.c
index f9883927be..1d12196ba6 100644
--- a/drivers/net/iavf/iavf_tm.c
+++ b/drivers/net/iavf/iavf_tm.c
@@ -10,7 +10,7 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
__rte_unused struct rte_tm_error *error);
static int iavf_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int iavf_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -487,7 +487,7 @@ iavf_tm_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
}
static int
-iavf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+iavf_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min bucket size not supported */
@@ -515,7 +515,7 @@ iavf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
iavf_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
diff --git a/drivers/net/ice/ice_dcf_sched.c b/drivers/net/ice/ice_dcf_sched.c
index b93e001806..7967c35533 100644
--- a/drivers/net/ice/ice_dcf_sched.c
+++ b/drivers/net/ice/ice_dcf_sched.c
@@ -18,7 +18,7 @@ static int ice_dcf_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
struct rte_tm_error *error);
static int ice_dcf_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int ice_dcf_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -463,7 +463,7 @@ ice_dcf_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
}
static int
-ice_dcf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+ice_dcf_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min bucket size not supported */
@@ -491,7 +491,7 @@ ice_dcf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
ice_dcf_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct ice_dcf_adapter *adapter = dev->data->dev_private;
diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c
index c977e6b177..8a29a9e744 100644
--- a/drivers/net/ice/ice_tm.c
+++ b/drivers/net/ice/ice_tm.c
@@ -23,7 +23,7 @@ static int ice_node_type_get(struct rte_eth_dev *dev, uint32_t node_id,
int *is_leaf, struct rte_tm_error *error);
static int ice_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int ice_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -237,7 +237,7 @@ ice_shaper_profile_search(struct rte_eth_dev *dev,
}
static int
-ice_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+ice_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min bucket size not supported */
@@ -265,7 +265,7 @@ ice_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
ice_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c b/drivers/net/ipn3ke/ipn3ke_tm.c
index 20a0ed0467..eec01bb037 100644
--- a/drivers/net/ipn3ke/ipn3ke_tm.c
+++ b/drivers/net/ipn3ke/ipn3ke_tm.c
@@ -722,7 +722,7 @@ ipn3ke_tm_node_capabilities_get(struct rte_eth_dev *dev,
}
static int
-ipn3ke_tm_shaper_parame_trans(struct rte_tm_shaper_params *profile,
+ipn3ke_tm_shaper_parame_trans(const struct rte_tm_shaper_params *profile,
struct ipn3ke_tm_shaper_profile *local_profile,
const struct ipn3ke_tm_shaper_params_range_type *ref_data)
{
@@ -747,7 +747,7 @@ ipn3ke_tm_shaper_parame_trans(struct rte_tm_shaper_params *profile,
static int
ipn3ke_tm_shaper_profile_add(struct rte_eth_dev *dev,
- uint32_t shaper_profile_id, struct rte_tm_shaper_params *profile,
+ uint32_t shaper_profile_id, const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
diff --git a/drivers/net/ixgbe/ixgbe_tm.c b/drivers/net/ixgbe/ixgbe_tm.c
index 75cd707109..27a821285d 100644
--- a/drivers/net/ixgbe/ixgbe_tm.c
+++ b/drivers/net/ixgbe/ixgbe_tm.c
@@ -11,7 +11,7 @@ static int ixgbe_tm_capabilities_get(struct rte_eth_dev *dev,
struct rte_tm_error *error);
static int ixgbe_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int ixgbe_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -226,7 +226,7 @@ ixgbe_shaper_profile_search(struct rte_eth_dev *dev,
}
static int
-ixgbe_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+ixgbe_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min rate not supported */
@@ -260,7 +260,7 @@ ixgbe_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
ixgbe_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct ixgbe_tm_conf *tm_conf =
diff --git a/drivers/net/mvpp2/mrvl_tm.c b/drivers/net/mvpp2/mrvl_tm.c
index 9fac80b867..3c7cf481a5 100644
--- a/drivers/net/mvpp2/mrvl_tm.c
+++ b/drivers/net/mvpp2/mrvl_tm.c
@@ -380,7 +380,7 @@ mrvl_shaper_profile_from_id(struct mrvl_priv *priv, uint32_t shaper_profile_id)
*/
static int
mrvl_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *params,
+ const struct rte_tm_shaper_params *params,
struct rte_tm_error *error)
{
struct mrvl_priv *priv = dev->data->dev_private;
diff --git a/drivers/net/txgbe/txgbe_tm.c b/drivers/net/txgbe/txgbe_tm.c
index 8ed4d24459..b62bcf54aa 100644
--- a/drivers/net/txgbe/txgbe_tm.c
+++ b/drivers/net/txgbe/txgbe_tm.c
@@ -12,7 +12,7 @@ static int txgbe_tm_capabilities_get(struct rte_eth_dev *dev,
struct rte_tm_error *error);
static int txgbe_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
static int txgbe_shaper_profile_del(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
@@ -218,7 +218,7 @@ txgbe_shaper_profile_search(struct rte_eth_dev *dev,
}
static int
-txgbe_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
+txgbe_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
/* min rate not supported */
@@ -252,7 +252,7 @@ txgbe_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
static int
txgbe_shaper_profile_add(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct txgbe_tm_conf *tm_conf = TXGBE_DEV_TM_CONF(dev);
diff --git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c
index d221b1e553..3eb98e618a 100644
--- a/lib/ethdev/rte_tm.c
+++ b/lib/ethdev/rte_tm.c
@@ -218,7 +218,7 @@ int rte_tm_shared_wred_context_delete(uint16_t port_id,
/* Add shaper profile */
int rte_tm_shaper_profile_add(uint16_t port_id,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
diff --git a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h
index f6f3f6a8d4..e5da9b8323 100644
--- a/lib/ethdev/rte_tm.h
+++ b/lib/ethdev/rte_tm.h
@@ -1449,7 +1449,7 @@ rte_tm_shared_wred_context_delete(uint16_t port_id,
int
rte_tm_shaper_profile_add(uint16_t port_id,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
/**
diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h
index b6ecf1bd4d..6c2618c0d8 100644
--- a/lib/ethdev/rte_tm_driver.h
+++ b/lib/ethdev/rte_tm_driver.h
@@ -75,7 +75,7 @@ typedef int (*rte_tm_shared_wred_context_delete_t)(
/** @internal Traffic manager shaper profile add */
typedef int (*rte_tm_shaper_profile_add_t)(struct rte_eth_dev *dev,
uint32_t shaper_profile_id,
- struct rte_tm_shaper_params *profile,
+ const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error);
/** @internal Traffic manager shaper profile delete */
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 0/3] make struct parameters constant in rte_tm APIs
2024-10-07 11:49 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Bruce Richardson
` (2 preceding siblings ...)
2024-10-07 11:49 ` [PATCH v2 3/3] ethdev: make TM shaper parameters constant Bruce Richardson
@ 2024-10-07 15:22 ` Stephen Hemminger
2024-10-08 0:38 ` Ferruh Yigit
3 siblings, 1 reply; 20+ messages in thread
From: Stephen Hemminger @ 2024-10-07 15:22 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
On Mon, 7 Oct 2024 12:49:04 +0100
Bruce Richardson <bruce.richardson@intel.com> wrote:
> For functions for creating profiles, shapers and hierarchy nodes, make
> the parameter structure pointer a pointer to a const object. This
> guarantees to the user that the struct won't be modified by the
> function, which allows the user to re-use the same parameters multiple
> times without having to constantly reinitialize it.
>
> V2: drop final patch with new node query function, simplifying patchset
>
> Bruce Richardson (3):
> ethdev: make parameters to TM node add fn constant
> ethdev: make parameters to TM profile add fn constant
> ethdev: make TM shaper parameters constant
>
> drivers/net/cnxk/cnxk_tm.c | 4 ++--
> drivers/net/dpaa2/dpaa2_tm.c | 6 +++---
> drivers/net/hns3/hns3_tm.c | 22 +++++++++++-----------
> drivers/net/i40e/i40e_tm.c | 12 ++++++------
> drivers/net/iavf/iavf_tm.c | 12 ++++++------
> drivers/net/ice/ice_dcf_sched.c | 12 ++++++------
> drivers/net/ice/ice_tm.c | 12 ++++++------
> drivers/net/ipn3ke/ipn3ke_tm.c | 12 ++++++------
> drivers/net/ixgbe/ixgbe_tm.c | 12 ++++++------
> drivers/net/mvpp2/mrvl_tm.c | 2 +-
> drivers/net/txgbe/txgbe_tm.c | 12 ++++++------
> lib/ethdev/rte_tm.c | 6 +++---
> lib/ethdev/rte_tm.h | 6 +++---
> lib/ethdev/rte_tm_driver.h | 6 +++---
> 14 files changed, 68 insertions(+), 68 deletions(-)
>
> --
> 2.43.0
>
Series-Acked-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 0/3] make struct parameters constant in rte_tm APIs
2024-10-07 15:22 ` [PATCH v2 0/3] make struct parameters constant in rte_tm APIs Stephen Hemminger
@ 2024-10-08 0:38 ` Ferruh Yigit
0 siblings, 0 replies; 20+ messages in thread
From: Ferruh Yigit @ 2024-10-08 0:38 UTC (permalink / raw)
To: Stephen Hemminger, Bruce Richardson; +Cc: dev
On 10/7/2024 4:22 PM, Stephen Hemminger wrote:
> On Mon, 7 Oct 2024 12:49:04 +0100
> Bruce Richardson <bruce.richardson@intel.com> wrote:
>
>> For functions for creating profiles, shapers and hierarchy nodes, make
>> the parameter structure pointer a pointer to a const object. This
>> guarantees to the user that the struct won't be modified by the
>> function, which allows the user to re-use the same parameters multiple
>> times without having to constantly reinitialize it.
>>
>> V2: drop final patch with new node query function, simplifying patchset
>>
>> Bruce Richardson (3):
>> ethdev: make parameters to TM node add fn constant
>> ethdev: make parameters to TM profile add fn constant
>> ethdev: make TM shaper parameters constant
>>
>> drivers/net/cnxk/cnxk_tm.c | 4 ++--
>> drivers/net/dpaa2/dpaa2_tm.c | 6 +++---
>> drivers/net/hns3/hns3_tm.c | 22 +++++++++++-----------
>> drivers/net/i40e/i40e_tm.c | 12 ++++++------
>> drivers/net/iavf/iavf_tm.c | 12 ++++++------
>> drivers/net/ice/ice_dcf_sched.c | 12 ++++++------
>> drivers/net/ice/ice_tm.c | 12 ++++++------
>> drivers/net/ipn3ke/ipn3ke_tm.c | 12 ++++++------
>> drivers/net/ixgbe/ixgbe_tm.c | 12 ++++++------
>> drivers/net/mvpp2/mrvl_tm.c | 2 +-
>> drivers/net/txgbe/txgbe_tm.c | 12 ++++++------
>> lib/ethdev/rte_tm.c | 6 +++---
>> lib/ethdev/rte_tm.h | 6 +++---
>> lib/ethdev/rte_tm_driver.h | 6 +++---
>> 14 files changed, 68 insertions(+), 68 deletions(-)
>>
>> --
>> 2.43.0
>>
>
> Series-Acked-by: Stephen Hemminger <stephen@networkplumber.org>
>
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 20+ messages in thread