Commit 82564f6c authored by Leon Romanovsky's avatar Leon Romanovsky Committed by David S. Miller
Browse files

devlink: Simplify devlink port API calls



Devlink port already has pointer to the devlink instance and all API
calls that forward these devlink ports to the drivers perform same
"devlink_port->devlink" assignment before actual call.

This patch removes useless parameter and allows us in the future
to create specific devlink_port_ops to manage user space access with
reliable ops assignment.

Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 39f32101
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -1889,8 +1889,7 @@ is_port_function_supported(struct mlx5_eswitch *esw, u16 vport_num)
	       mlx5_esw_is_sf_vport(esw, vport_num);
}

int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
					   struct devlink_port *port,
int mlx5_devlink_port_function_hw_addr_get(struct devlink_port *port,
					   u8 *hw_addr, int *hw_addr_len,
					   struct netlink_ext_ack *extack)
{
@@ -1899,7 +1898,7 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
	int err = -EOPNOTSUPP;
	u16 vport_num;

	esw = mlx5_devlink_eswitch_get(devlink);
	esw = mlx5_devlink_eswitch_get(port->devlink);
	if (IS_ERR(esw))
		return PTR_ERR(esw);

@@ -1923,8 +1922,7 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
	return err;
}

int mlx5_devlink_port_function_hw_addr_set(struct devlink *devlink,
					   struct devlink_port *port,
int mlx5_devlink_port_function_hw_addr_set(struct devlink_port *port,
					   const u8 *hw_addr, int hw_addr_len,
					   struct netlink_ext_ack *extack)
{
@@ -1933,7 +1931,7 @@ int mlx5_devlink_port_function_hw_addr_set(struct devlink *devlink,
	int err = -EOPNOTSUPP;
	u16 vport_num;

	esw = mlx5_devlink_eswitch_get(devlink);
	esw = mlx5_devlink_eswitch_get(port->devlink);
	if (IS_ERR(esw)) {
		NL_SET_ERR_MSG_MOD(extack, "Eswitch doesn't support set hw_addr");
		return PTR_ERR(esw);
+2 −4
Original line number Diff line number Diff line
@@ -475,12 +475,10 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
					struct netlink_ext_ack *extack);
int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
					enum devlink_eswitch_encap_mode *encap);
int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
					   struct devlink_port *port,
int mlx5_devlink_port_function_hw_addr_get(struct devlink_port *port,
					   u8 *hw_addr, int *hw_addr_len,
					   struct netlink_ext_ack *extack);
int mlx5_devlink_port_function_hw_addr_set(struct devlink *devlink,
					   struct devlink_port *port,
int mlx5_devlink_port_function_hw_addr_set(struct devlink_port *port,
					   const u8 *hw_addr, int hw_addr_len,
					   struct netlink_ext_ack *extack);

+4 −4
Original line number Diff line number Diff line
@@ -164,12 +164,12 @@ static bool mlx5_sf_is_active(const struct mlx5_sf *sf)
	return sf->hw_state == MLX5_VHCA_STATE_ACTIVE || sf->hw_state == MLX5_VHCA_STATE_IN_USE;
}

int mlx5_devlink_sf_port_fn_state_get(struct devlink *devlink, struct devlink_port *dl_port,
int mlx5_devlink_sf_port_fn_state_get(struct devlink_port *dl_port,
				      enum devlink_port_fn_state *state,
				      enum devlink_port_fn_opstate *opstate,
				      struct netlink_ext_ack *extack)
{
	struct mlx5_core_dev *dev = devlink_priv(devlink);
	struct mlx5_core_dev *dev = devlink_priv(dl_port->devlink);
	struct mlx5_sf_table *table;
	struct mlx5_sf *sf;
	int err = 0;
@@ -248,11 +248,11 @@ static int mlx5_sf_state_set(struct mlx5_core_dev *dev, struct mlx5_sf_table *ta
	return err;
}

int mlx5_devlink_sf_port_fn_state_set(struct devlink *devlink, struct devlink_port *dl_port,
int mlx5_devlink_sf_port_fn_state_set(struct devlink_port *dl_port,
				      enum devlink_port_fn_state state,
				      struct netlink_ext_ack *extack)
{
	struct mlx5_core_dev *dev = devlink_priv(devlink);
	struct mlx5_core_dev *dev = devlink_priv(dl_port->devlink);
	struct mlx5_sf_table *table;
	struct mlx5_sf *sf;
	int err;
+2 −2
Original line number Diff line number Diff line
@@ -24,11 +24,11 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink,
			     unsigned int *new_port_index);
int mlx5_devlink_sf_port_del(struct devlink *devlink, unsigned int port_index,
			     struct netlink_ext_ack *extack);
int mlx5_devlink_sf_port_fn_state_get(struct devlink *devlink, struct devlink_port *dl_port,
int mlx5_devlink_sf_port_fn_state_get(struct devlink_port *dl_port,
				      enum devlink_port_fn_state *state,
				      enum devlink_port_fn_opstate *opstate,
				      struct netlink_ext_ack *extack);
int mlx5_devlink_sf_port_fn_state_set(struct devlink *devlink, struct devlink_port *dl_port,
int mlx5_devlink_sf_port_fn_state_set(struct devlink_port *dl_port,
				      enum devlink_port_fn_state state,
				      struct netlink_ext_ack *extack);
#else
+5 −7
Original line number Diff line number Diff line
@@ -1396,8 +1396,8 @@ struct devlink_ops {
	 *
	 * Note: @extack can be NULL when port notifier queries the port function.
	 */
	int (*port_function_hw_addr_get)(struct devlink *devlink, struct devlink_port *port,
					 u8 *hw_addr, int *hw_addr_len,
	int (*port_function_hw_addr_get)(struct devlink_port *port, u8 *hw_addr,
					 int *hw_addr_len,
					 struct netlink_ext_ack *extack);
	/**
	 * @port_function_hw_addr_set: Port function's hardware address set function.
@@ -1406,7 +1406,7 @@ struct devlink_ops {
	 * by the devlink port. Driver should return -EOPNOTSUPP if it doesn't support port
	 * function handling for a particular port.
	 */
	int (*port_function_hw_addr_set)(struct devlink *devlink, struct devlink_port *port,
	int (*port_function_hw_addr_set)(struct devlink_port *port,
					 const u8 *hw_addr, int hw_addr_len,
					 struct netlink_ext_ack *extack);
	/**
@@ -1462,8 +1462,7 @@ struct devlink_ops {
	 *
	 * Return: 0 on success, negative value otherwise.
	 */
	int (*port_fn_state_get)(struct devlink *devlink,
				 struct devlink_port *port,
	int (*port_fn_state_get)(struct devlink_port *port,
				 enum devlink_port_fn_state *state,
				 enum devlink_port_fn_opstate *opstate,
				 struct netlink_ext_ack *extack);
@@ -1478,8 +1477,7 @@ struct devlink_ops {
	 *
	 * Return: 0 on success, negative value otherwise.
	 */
	int (*port_fn_state_set)(struct devlink *devlink,
				 struct devlink_port *port,
	int (*port_fn_state_set)(struct devlink_port *port,
				 enum devlink_port_fn_state state,
				 struct netlink_ext_ack *extack);

Loading