Skip to contentSkip to conversation

improve rte_tm APIs

PATCH Superseded Bruce Richardson 4 participants 20 messages Aug 6, 2024 – Oct 8, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

cover improve rte_tm APIs

This patchset makes some small updates to the traffic manager (TM) APIs in ethdev.

* 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.
* Add a function to allow the user to query the previously provided parameters used to create a TM node. This saves applications from having to provide a "shadow" hierarchy in the app mirroring that in the library.

Bruce Richardson (4):
ethdev: make parameters to TM node add fn constant
ethdev: make parameters to TM profile add fn constant
ethdev: make TM shaper parameters constant
ethdev: add traffic manager query function

 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/ethdev_trace.h        | 16 ++++++++++
 lib/ethdev/ethdev_trace_points.c |  3 ++
 lib/ethdev/rte_tm.c              | 31 +++++++++++++++++--
 lib/ethdev/rte_tm.h              | 52 ++++++++++++++++++++++++++++++--
 lib/ethdev/rte_tm_driver.h       | 18 +++++++++--
 16 files changed, 171 insertions(+), 67 deletions(-)

--
2.43.0

#1 lore raw

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.

---
 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(-)
drivers/net/cnxk/cnxk_tm.c +1 -1
index c799193cb8..9293b3e8f2 100644
@@ -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);
drivers/net/dpaa2/dpaa2_tm.c +2 -2
index cb854964b4..22337097e5 100644
@@ -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;
drivers/net/hns3/hns3_tm.c +8 -8
index 92a668538f..06df32bbcd 100644
@@ -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);
drivers/net/i40e/i40e_tm.c +3 -3
index cab296e1a4..c7d4680fb4 100644
@@ -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);
drivers/net/iavf/iavf_tm.c +3 -3
index 32bb3be45e..f9883927be 100644
@@ -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);
drivers/net/ice/ice_dcf_sched.c +3 -3
index b08bc5f1de..b93e001806 100644
@@ -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;
drivers/net/ice/ice_tm.c +3 -3
index 7239ab53f1..c977e6b177 100644
@@ -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);
drivers/net/ipn3ke/ipn3ke_tm.c +2 -2
index 0260227900..cffe1fdaa4 100644
@@ -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);
drivers/net/ixgbe/ixgbe_tm.c +3 -3
index ac8976062f..75cd707109 100644
@@ -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 =
drivers/net/txgbe/txgbe_tm.c +3 -3
index 3171be73d0..8ed4d24459 100644
@@ -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);
lib/ethdev/rte_tm.c +1 -1
index d594fe0049..74e6f4d610 100644
@@ -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];
lib/ethdev/rte_tm.h +1 -1
index 07028c9b36..c52acd1b4f 100644
@@ -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);
 
 /**
lib/ethdev/rte_tm_driver.h +1 -1
index 45290fb3fd..25d688516b 100644
@@ -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 */
Signature · 1 line
2.43.0
Reviewed-by on v1 1/4
#2 lore raw

RE: [PATCH 1/4] ethdev: make parameters to TM node add fn constant

Hi,

Quoted 54 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Tuesday, August 6, 2024 11:24 PM
To: [email protected]
Cc: Richardson, Bruce <[email protected]>; Nithin Dabilpuram <[email protected]>; Kiran Kumar K <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Rao <[email protected]>; Harman Kalra <[email protected]>; Hemant Agrawal <[email protected]>; Sachin Saxena <[email protected]>; Jie Hai <[email protected]>; Yisen Zhuang <[email protected]>; Wu, Jingjing <[email protected]>; Xu, Rosen <[email protected]>; Jiawen Wu <[email protected]>; Jian Wang <[email protected]>; Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
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.

---
 drivers/net/ipn3ke/ipn3ke_tm.c  |  4 ++--
(quoted diff) +0 -0

b/drivers/net/ipn3ke/ipn3ke_tm.c index 0260227900..cffe1fdaa4 100644

drivers/net/ipn3ke/ipn3ke_tm.c +0 -0
@@ -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,

drivers/net/ipn3ke/ipn3ke_tm.c +0 -1
 	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,

drivers/net/ipn3ke/ipn3ke_tm.c +4 -2
+	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 */
--
Quoted 1 line

2.43.0

Acked-by
#3 lore raw

Re: [PATCH 1/4] ethdev: make parameters to TM node add fn constant

Quoted 3 lines · Rosen

Hi,

Quoted 1 line

-----Original Message-----

<...>

Quoted 33 lines
Quoted 33 lines

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.

---
 drivers/net/ipn3ke/ipn3ke_tm.c  |  4 ++--
(quoted diff) +0 -0

b/drivers/net/ipn3ke/ipn3ke_tm.c index 0260227900..cffe1fdaa4 100644

drivers/net/ipn3ke/ipn3ke_tm.c +0 -0
@@ -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,

drivers/net/ipn3ke/ipn3ke_tm.c +0 -1
 	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,

drivers/net/ipn3ke/ipn3ke_tm.c +4 -1
+	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,
Quoted 9 lines
Quoted 6 lines
drivers/net/ipn3ke/ipn3ke_tm.c +0 -1
 	struct rte_tm_error *error)
 {
 	struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev); diff --
 /** @internal Traffic manager node delete */
--

2.43.0

#4 lore raw

PATCH 2/4 ethdev: make parameters to TM profile add fn constant

In reply to Bruce Richardson

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.

---
 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(-)
drivers/net/ipn3ke/ipn3ke_tm.c +2 -2
index cffe1fdaa4..20a0ed0467 100644
@@ -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);
lib/ethdev/rte_tm.c +1 -1
index 74e6f4d610..d221b1e553 100644
@@ -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];
lib/ethdev/rte_tm.h +1 -1
index c52acd1b4f..f6f3f6a8d4 100644
@@ -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);
 
 /**
lib/ethdev/rte_tm_driver.h +1 -1
index 25d688516b..b6ecf1bd4d 100644
@@ -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 on v1 2/4
#5 lore raw

RE: [PATCH 2/4] ethdev: make parameters to TM profile add fn constant

Hi,

Quoted 86 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Tuesday, August 6, 2024 11:24 PM
To: [email protected]
Cc: Richardson, Bruce <[email protected]>; Xu, Rosen <[email protected]>; Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
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.

---
 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(-)
(quoted diff) +0 -0

b/drivers/net/ipn3ke/ipn3ke_tm.c index cffe1fdaa4..20a0ed0467 100644

drivers/net/ipn3ke/ipn3ke_tm.c +1 -1
@@ -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)

{

drivers/net/ipn3ke/ipn3ke_tm.c +1 -1
 	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

lib/ethdev/rte_tm.c +1 -1
@@ -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

lib/ethdev/rte_tm.h +1 -1
@@ -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);
 
 /**
lib/ethdev/rte_tm_driver.h index renamed from lib/ethdev/rte_tm_driver.h +0 -0

25d688516b..b6ecf1bd4d 100644

lib/ethdev/rte_tm_driver.h +1 -1
@@ -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);
 
Quoted 3 lines

/** @internal Traffic manager WRED profile delete */
--
2.43.0

Acked-by
#6 lore raw

Re: [PATCH 2/4] ethdev: make parameters to TM profile add fn constant

Quoted 3 lines · Rosen

Hi,

Quoted 1 line

-----Original Message-----

<...>

Quoted 11 lines
Quoted 8 lines

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.

#7 lore raw

PATCH 3/4 ethdev: make TM shaper parameters constant

In reply to Bruce Richardson

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.

---
 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(-)
drivers/net/cnxk/cnxk_tm.c +1 -1
index 9293b3e8f2..0ed6732dda 100644
@@ -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);
drivers/net/dpaa2/dpaa2_tm.c +1 -1
index 22337097e5..115397ce47 100644
@@ -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;
drivers/net/hns3/hns3_tm.c +3 -3
index 06df32bbcd..1c2ad71133 100644
@@ -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);
drivers/net/i40e/i40e_tm.c +3 -3
index c7d4680fb4..4c0940f355 100644
@@ -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);
drivers/net/iavf/iavf_tm.c +3 -3
index f9883927be..1d12196ba6 100644
@@ -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);
drivers/net/ice/ice_dcf_sched.c +3 -3
index b93e001806..7967c35533 100644
@@ -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;
drivers/net/ice/ice_tm.c +3 -3
index c977e6b177..8a29a9e744 100644
@@ -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);
drivers/net/ipn3ke/ipn3ke_tm.c +2 -2
index 20a0ed0467..eec01bb037 100644
@@ -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);
drivers/net/ixgbe/ixgbe_tm.c +3 -3
index 75cd707109..27a821285d 100644
@@ -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 =
drivers/net/mvpp2/mrvl_tm.c +1 -1
index 9fac80b867..3c7cf481a5 100644
@@ -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;
drivers/net/txgbe/txgbe_tm.c +3 -3
index 8ed4d24459..b62bcf54aa 100644
@@ -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);
lib/ethdev/rte_tm.c +1 -1
index d221b1e553..3eb98e618a 100644
@@ -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];
lib/ethdev/rte_tm.h +1 -1
index f6f3f6a8d4..e5da9b8323 100644
@@ -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);
 
 /**
lib/ethdev/rte_tm_driver.h +1 -1
index b6ecf1bd4d..6c2618c0d8 100644
@@ -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

Reviewed-by on v1 3/4
#8 lore raw

RE: [PATCH 3/4] ethdev: make TM shaper parameters constant

Hi,

Quoted 53 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Tuesday, August 6, 2024 11:24 PM
To: [email protected]
Cc: Richardson, Bruce <[email protected]>; Nithin Dabilpuram <[email protected]>; Kiran Kumar K <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Rao <[email protected]>; Harman Kalra <[email protected]>; Hemant Agrawal <[email protected]>; Sachin Saxena <[email protected]>; Jie Hai <[email protected]>; Yisen Zhuang <[email protected]>; Wu, Jingjing <[email protected]>; Xu, Rosen <[email protected]>; Liron Himi <[email protected]>; Jiawen Wu <[email protected]>; Jian Wang <[email protected]>; Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
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.

---
 drivers/net/ipn3ke/ipn3ke_tm.c  | 4 ++--
(quoted diff) +0 -0

b/drivers/net/ipn3ke/ipn3ke_tm.c index 20a0ed0467..eec01bb037 100644

drivers/net/ipn3ke/ipn3ke_tm.c +2 -1
@@ -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,

drivers/net/ipn3ke/ipn3ke_tm.c +2 -2
-	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 */
--
Quoted 1 line

2.43.0

Acked-by
#9 lore raw

Re: [PATCH 3/4] ethdev: make TM shaper parameters constant

Quoted 3 lines · Rosen

Hi,

Quoted 1 line

-----Original Message-----

<...>

Quoted 8 lines
Quoted 8 lines

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.

Quoted 4 lines
Quoted 1 line
#10 lore raw

PATCH 4/4 ethdev: add traffic manager query function

In reply to Bruce Richardson

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.

---
 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(+)
lib/ethdev/ethdev_trace.h +16 -0
index 3bec87bfdb..dee2819531 100644
@@ -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),
lib/ethdev/ethdev_trace_points.c +3 -0
index 99e04f5893..f5ed7ca637 100644
@@ -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)
 
lib/ethdev/rte_tm.c +25 -0
index 3eb98e618a..8000b66af9 100644
@@ -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,
lib/ethdev/rte_tm.h +48 -0

54 lines not on this page · raw message

lib/ethdev/rte_tm_driver.h +12 -0
index 6c2618c0d8..fc67f1cb4b 100644
@@ -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;
 
Signature · 1 line
2.43.0
#11 lore raw

Re: [PATCH 4/4] ethdev: add traffic manager query function

Quoted 39 lines · Bruce Richardson
lib/ethdev/rte_tm.h +38 -0
+/**
+ * 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
+ */

lib/ethdev/rte_tm.h rte_tm_node_add(uint16_t port_id, · line 1649

Quoted 10 lines
lib/ethdev/rte_tm.h +10 -0
+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.

#12 lore raw

Re: [PATCH 4/4] ethdev: add traffic manager query function

Quoted 47 lines · Ferruh Yigit
Quoted 46 lines · Bruce Richardson
lib/ethdev/rte_tm.h +46 -0
+/**
+ * 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,
Quoted 9 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+	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.

Quoted 4 lines

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/[email protected]/

Quoted 3 lines

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

#13 lore raw

Re: [PATCH 4/4] ethdev: add traffic manager query function

Quoted 78 lines · Bruce Richardson
Quoted 47 lines · Ferruh Yigit
Quoted 46 lines · Bruce Richardson
lib/ethdev/rte_tm.h +46 -0
+/**
+ * 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,
Quoted 9 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+	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.

Quoted 4 lines

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/[email protected]/

Quoted 3 lines

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.

Quoted 7 lines

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

#14 lore raw

v2 cover make struct parameters constant in rte_tm APIs

In reply to 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

#15 lore raw

PATCH v2 1/3 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.

---
 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(-)
drivers/net/cnxk/cnxk_tm.c +1 -1
index c799193cb8..9293b3e8f2 100644
@@ -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);
drivers/net/dpaa2/dpaa2_tm.c +2 -2
index cb854964b4..22337097e5 100644
@@ -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;
drivers/net/hns3/hns3_tm.c +8 -8
index 92a668538f..06df32bbcd 100644
@@ -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);
drivers/net/i40e/i40e_tm.c +3 -3
index cab296e1a4..c7d4680fb4 100644
@@ -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);
drivers/net/iavf/iavf_tm.c +3 -3
index 32bb3be45e..f9883927be 100644
@@ -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);
drivers/net/ice/ice_dcf_sched.c +3 -3
index b08bc5f1de..b93e001806 100644
@@ -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;
drivers/net/ice/ice_tm.c +3 -3
index 7239ab53f1..c977e6b177 100644
@@ -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);
drivers/net/ipn3ke/ipn3ke_tm.c +2 -2
index 0260227900..cffe1fdaa4 100644
@@ -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);
drivers/net/ixgbe/ixgbe_tm.c +3 -3
index ac8976062f..75cd707109 100644
@@ -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 =
drivers/net/txgbe/txgbe_tm.c +3 -3
index 3171be73d0..8ed4d24459 100644
@@ -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);
lib/ethdev/rte_tm.c +1 -1
index d594fe0049..74e6f4d610 100644
@@ -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];
lib/ethdev/rte_tm.h +1 -1
index 07028c9b36..c52acd1b4f 100644
@@ -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);
 
 /**
lib/ethdev/rte_tm_driver.h +1 -1
index 45290fb3fd..25d688516b 100644
@@ -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 */
Signature · 1 line
2.43.0
#16 lore raw

PATCH v2 2/3 ethdev: make parameters to TM profile add fn constant

In reply to Bruce Richardson

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.

---
 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(-)
drivers/net/ipn3ke/ipn3ke_tm.c +2 -2
index cffe1fdaa4..20a0ed0467 100644
@@ -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);
lib/ethdev/rte_tm.c +1 -1
index 74e6f4d610..d221b1e553 100644
@@ -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];
lib/ethdev/rte_tm.h +1 -1
index c52acd1b4f..f6f3f6a8d4 100644
@@ -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);
 
 /**
lib/ethdev/rte_tm_driver.h +1 -1
index 25d688516b..b6ecf1bd4d 100644
@@ -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 */
Signature · 1 line
2.43.0
#17 lore raw

PATCH v2 3/3 ethdev: make TM shaper parameters constant

In reply to Bruce Richardson

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.

---
 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(-)
drivers/net/cnxk/cnxk_tm.c +1 -1
index 9293b3e8f2..0ed6732dda 100644
@@ -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);
drivers/net/dpaa2/dpaa2_tm.c +1 -1
index 22337097e5..115397ce47 100644
@@ -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;
drivers/net/hns3/hns3_tm.c +3 -3
index 06df32bbcd..1c2ad71133 100644
@@ -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);
drivers/net/i40e/i40e_tm.c +3 -3
index c7d4680fb4..4c0940f355 100644
@@ -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);
drivers/net/iavf/iavf_tm.c +3 -3
index f9883927be..1d12196ba6 100644
@@ -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);
drivers/net/ice/ice_dcf_sched.c +3 -3
index b93e001806..7967c35533 100644
@@ -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;
drivers/net/ice/ice_tm.c +3 -3
index c977e6b177..8a29a9e744 100644
@@ -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);
drivers/net/ipn3ke/ipn3ke_tm.c +2 -2
index 20a0ed0467..eec01bb037 100644
@@ -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);
drivers/net/ixgbe/ixgbe_tm.c +3 -3
index 75cd707109..27a821285d 100644
@@ -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 =
drivers/net/mvpp2/mrvl_tm.c +1 -1
index 9fac80b867..3c7cf481a5 100644
@@ -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;
drivers/net/txgbe/txgbe_tm.c +3 -3
index 8ed4d24459..b62bcf54aa 100644
@@ -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);
lib/ethdev/rte_tm.c +1 -1
index d221b1e553..3eb98e618a 100644
@@ -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];
lib/ethdev/rte_tm.h +1 -1
index f6f3f6a8d4..e5da9b8323 100644
@@ -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);
 
 /**
lib/ethdev/rte_tm_driver.h +1 -1
index b6ecf1bd4d..6c2618c0d8 100644
@@ -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 */
Signature · 1 line
2.43.0
#18 lore raw

Re: [PATCH v2 0/3] make struct parameters constant in rte_tm APIs

In reply to Bruce Richardson
Quoted 29 lines · On Mon, 7 Oct 2024 12:49:04 +0100 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(-)
Quoted 3 lines

--
2.43.0

#19 lore raw

Re: [PATCH v2 0/3] make struct parameters constant in rte_tm APIs

Quoted 32 lines · Stephen Hemminger
Quoted 29 lines · On Mon, 7 Oct 2024 12:49:04 +0100 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(-)
Quoted 6 lines
Quoted 3 lines

--
2.43.0

Series applied to dpdk-next-net/main, thanks.