devlink: move port_fn_migratable_get/set() to devlink_port_ops
Move port_fn_migratable_get/set() from devlink_ops into newly introduced devlink_port_ops. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
933c13275c
commit
4a490d7154
@ -317,8 +317,6 @@ static const struct devlink_ops mlx5_devlink_ops = {
|
||||
.rate_node_new = mlx5_esw_devlink_rate_node_new,
|
||||
.rate_node_del = mlx5_esw_devlink_rate_node_del,
|
||||
.rate_leaf_parent_set = mlx5_esw_devlink_rate_parent_set,
|
||||
.port_fn_migratable_get = mlx5_devlink_port_fn_migratable_get,
|
||||
.port_fn_migratable_set = mlx5_devlink_port_fn_migratable_set,
|
||||
#endif
|
||||
#ifdef CONFIG_MLX5_SF_MANAGER
|
||||
.port_new = mlx5_devlink_sf_port_new,
|
||||
|
@ -70,6 +70,8 @@ static const struct devlink_port_ops mlx5_esw_dl_port_ops = {
|
||||
.port_fn_hw_addr_set = mlx5_devlink_port_fn_hw_addr_set,
|
||||
.port_fn_roce_get = mlx5_devlink_port_fn_roce_get,
|
||||
.port_fn_roce_set = mlx5_devlink_port_fn_roce_set,
|
||||
.port_fn_migratable_get = mlx5_devlink_port_fn_migratable_get,
|
||||
.port_fn_migratable_set = mlx5_devlink_port_fn_migratable_set,
|
||||
};
|
||||
|
||||
int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_num)
|
||||
|
@ -1429,27 +1429,6 @@ struct devlink_ops {
|
||||
int (*trap_policer_counter_get)(struct devlink *devlink,
|
||||
const struct devlink_trap_policer *policer,
|
||||
u64 *p_drops);
|
||||
/**
|
||||
* @port_fn_migratable_get: Port function's migratable get function.
|
||||
*
|
||||
* Query migratable state of a function managed by the devlink port.
|
||||
* Return -EOPNOTSUPP if port function migratable handling is not
|
||||
* supported.
|
||||
*/
|
||||
int (*port_fn_migratable_get)(struct devlink_port *devlink_port,
|
||||
bool *is_enable,
|
||||
struct netlink_ext_ack *extack);
|
||||
/**
|
||||
* @port_fn_migratable_set: Port function's migratable set function.
|
||||
*
|
||||
* Enable/Disable migratable state of a function managed by the devlink
|
||||
* port.
|
||||
* Return -EOPNOTSUPP if port function migratable handling is not
|
||||
* supported.
|
||||
*/
|
||||
int (*port_fn_migratable_set)(struct devlink_port *devlink_port,
|
||||
bool enable,
|
||||
struct netlink_ext_ack *extack);
|
||||
/**
|
||||
* port_new() - Add a new port function of a specified flavor
|
||||
* @devlink: Devlink instance
|
||||
@ -1626,6 +1605,14 @@ void devlink_free(struct devlink *devlink);
|
||||
* Should be used by device drivers to enable/disable
|
||||
* RoCE capability of a function managed
|
||||
* by the devlink port.
|
||||
* @port_fn_migratable_get: Callback used to get port function's migratable
|
||||
* capability. Should be used by device drivers
|
||||
* to report the current state of migratable capability
|
||||
* of a function managed by the devlink port.
|
||||
* @port_fn_migratable_set: Callback used to set port function's migratable
|
||||
* capability. Should be used by device drivers
|
||||
* to enable/disable migratable capability of
|
||||
* a function managed by the devlink port.
|
||||
*
|
||||
* Note: Driver should return -EOPNOTSUPP if it doesn't support
|
||||
* port function (@port_fn_*) handling for a particular port.
|
||||
@ -1648,6 +1635,12 @@ struct devlink_port_ops {
|
||||
struct netlink_ext_ack *extack);
|
||||
int (*port_fn_roce_set)(struct devlink_port *devlink_port,
|
||||
bool enable, struct netlink_ext_ack *extack);
|
||||
int (*port_fn_migratable_get)(struct devlink_port *devlink_port,
|
||||
bool *is_enable,
|
||||
struct netlink_ext_ack *extack);
|
||||
int (*port_fn_migratable_set)(struct devlink_port *devlink_port,
|
||||
bool enable,
|
||||
struct netlink_ext_ack *extack);
|
||||
};
|
||||
|
||||
void devlink_port_init(struct devlink *devlink,
|
||||
|
@ -469,19 +469,19 @@ static int devlink_port_fn_roce_fill(struct devlink_port *devlink_port,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int devlink_port_fn_migratable_fill(const struct devlink_ops *ops,
|
||||
struct devlink_port *devlink_port,
|
||||
static int devlink_port_fn_migratable_fill(struct devlink_port *devlink_port,
|
||||
struct nla_bitfield32 *caps,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
bool is_enable;
|
||||
int err;
|
||||
|
||||
if (!ops->port_fn_migratable_get ||
|
||||
if (!devlink_port->ops->port_fn_migratable_get ||
|
||||
devlink_port->attrs.flavour != DEVLINK_PORT_FLAVOUR_PCI_VF)
|
||||
return 0;
|
||||
|
||||
err = ops->port_fn_migratable_get(devlink_port, &is_enable, extack);
|
||||
err = devlink_port->ops->port_fn_migratable_get(devlink_port,
|
||||
&is_enable, extack);
|
||||
if (err) {
|
||||
if (err == -EOPNOTSUPP)
|
||||
return 0;
|
||||
@ -492,8 +492,7 @@ static int devlink_port_fn_migratable_fill(const struct devlink_ops *ops,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int devlink_port_fn_caps_fill(const struct devlink_ops *ops,
|
||||
struct devlink_port *devlink_port,
|
||||
static int devlink_port_fn_caps_fill(struct devlink_port *devlink_port,
|
||||
struct sk_buff *msg,
|
||||
struct netlink_ext_ack *extack,
|
||||
bool *msg_updated)
|
||||
@ -505,7 +504,7 @@ static int devlink_port_fn_caps_fill(const struct devlink_ops *ops,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = devlink_port_fn_migratable_fill(ops, devlink_port, &caps, extack);
|
||||
err = devlink_port_fn_migratable_fill(devlink_port, &caps, extack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -828,9 +827,8 @@ static int
|
||||
devlink_port_fn_mig_set(struct devlink_port *devlink_port, bool enable,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
const struct devlink_ops *ops = devlink_port->devlink->ops;
|
||||
|
||||
return ops->port_fn_migratable_set(devlink_port, enable, extack);
|
||||
return devlink_port->ops->port_fn_migratable_set(devlink_port, enable,
|
||||
extack);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -885,8 +883,7 @@ devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por
|
||||
err = devlink_port_fn_hw_addr_fill(port, msg, extack, &msg_updated);
|
||||
if (err)
|
||||
goto out;
|
||||
err = devlink_port_fn_caps_fill(ops, port, msg, extack,
|
||||
&msg_updated);
|
||||
err = devlink_port_fn_caps_fill(port, msg, extack, &msg_updated);
|
||||
if (err)
|
||||
goto out;
|
||||
err = devlink_port_fn_state_fill(ops, port, msg, extack, &msg_updated);
|
||||
@ -1219,7 +1216,7 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port,
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
if (caps.selector & DEVLINK_PORT_FN_CAP_MIGRATABLE) {
|
||||
if (!ops->port_fn_migratable_set) {
|
||||
if (!devlink_port->ops->port_fn_migratable_set) {
|
||||
NL_SET_ERR_MSG_ATTR(extack, attr,
|
||||
"Port doesn't support migratable function attribute");
|
||||
return -EOPNOTSUPP;
|
||||
|
Loading…
Reference in New Issue
Block a user