Skip to content

Commit

Permalink
ethdev: make TM shaper parameters constant
Browse files Browse the repository at this point in the history
The function to add a new shaper profile in rte_tm should not (and does
not) modify the profile parameters passed in via struct pointer. We
should guarantee this by marking the parameter pointer as const. This
allows SW to create multiple profiles using the same parameter
struct without having to reset it each time.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  • Loading branch information
bruce-richardson authored and ferruhy committed Oct 7, 2024
1 parent bbe8345 commit 4f24ef0
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion drivers/net/cnxk/cnxk_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/dpaa2/dpaa2_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/hns3/hns3_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/i40e/i40e_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/iavf/iavf_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ice/ice_dcf_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ice/ice_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ipn3ke/ipn3ke_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ixgbe/ixgbe_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/mvpp2/mrvl_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/txgbe/txgbe_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/ethdev/rte_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion lib/ethdev/rte_tm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/ethdev/rte_tm_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 4f24ef0

Please sign in to comment.