Commit 933c1327 authored by Jiri Pirko's avatar Jiri Pirko Committed by Jakub Kicinski

devlink: move port_fn_roce_get/set() to devlink_port_ops

Move port_fn_roce_get/set() from devlink_ops into newly introduced
devlink_port_ops.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 71c93e37
...@@ -317,8 +317,6 @@ static const struct devlink_ops mlx5_devlink_ops = { ...@@ -317,8 +317,6 @@ static const struct devlink_ops mlx5_devlink_ops = {
.rate_node_new = mlx5_esw_devlink_rate_node_new, .rate_node_new = mlx5_esw_devlink_rate_node_new,
.rate_node_del = mlx5_esw_devlink_rate_node_del, .rate_node_del = mlx5_esw_devlink_rate_node_del,
.rate_leaf_parent_set = mlx5_esw_devlink_rate_parent_set, .rate_leaf_parent_set = mlx5_esw_devlink_rate_parent_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_get = mlx5_devlink_port_fn_migratable_get,
.port_fn_migratable_set = mlx5_devlink_port_fn_migratable_set, .port_fn_migratable_set = mlx5_devlink_port_fn_migratable_set,
#endif #endif
......
...@@ -68,6 +68,8 @@ static void mlx5_esw_dl_port_free(struct devlink_port *dl_port) ...@@ -68,6 +68,8 @@ static void mlx5_esw_dl_port_free(struct devlink_port *dl_port)
static const struct devlink_port_ops mlx5_esw_dl_port_ops = { static const struct devlink_port_ops mlx5_esw_dl_port_ops = {
.port_fn_hw_addr_get = mlx5_devlink_port_fn_hw_addr_get, .port_fn_hw_addr_get = mlx5_devlink_port_fn_hw_addr_get,
.port_fn_hw_addr_set = mlx5_devlink_port_fn_hw_addr_set, .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,
}; };
int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_num) int mlx5_esw_offloads_devlink_port_register(struct mlx5_eswitch *esw, u16 vport_num)
...@@ -143,6 +145,8 @@ struct devlink_port *mlx5_esw_offloads_devlink_port(struct mlx5_eswitch *esw, u1 ...@@ -143,6 +145,8 @@ struct devlink_port *mlx5_esw_offloads_devlink_port(struct mlx5_eswitch *esw, u1
static const struct devlink_port_ops mlx5_esw_dl_sf_port_ops = { static const struct devlink_port_ops mlx5_esw_dl_sf_port_ops = {
.port_fn_hw_addr_get = mlx5_devlink_port_fn_hw_addr_get, .port_fn_hw_addr_get = mlx5_devlink_port_fn_hw_addr_get,
.port_fn_hw_addr_set = mlx5_devlink_port_fn_hw_addr_set, .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,
}; };
int mlx5_esw_devlink_sf_port_register(struct mlx5_eswitch *esw, struct devlink_port *dl_port, int mlx5_esw_devlink_sf_port_register(struct mlx5_eswitch *esw, struct devlink_port *dl_port,
......
...@@ -1429,24 +1429,6 @@ struct devlink_ops { ...@@ -1429,24 +1429,6 @@ struct devlink_ops {
int (*trap_policer_counter_get)(struct devlink *devlink, int (*trap_policer_counter_get)(struct devlink *devlink,
const struct devlink_trap_policer *policer, const struct devlink_trap_policer *policer,
u64 *p_drops); u64 *p_drops);
/**
* @port_fn_roce_get: Port function's roce get function.
*
* Query RoCE state of a function managed by the devlink port.
* Return -EOPNOTSUPP if port function RoCE handling is not supported.
*/
int (*port_fn_roce_get)(struct devlink_port *devlink_port,
bool *is_enable,
struct netlink_ext_ack *extack);
/**
* @port_fn_roce_set: Port function's roce set function.
*
* Enable/Disable the RoCE state of a function managed by the devlink
* port.
* Return -EOPNOTSUPP if port function RoCE handling is not supported.
*/
int (*port_fn_roce_set)(struct devlink_port *devlink_port,
bool enable, struct netlink_ext_ack *extack);
/** /**
* @port_fn_migratable_get: Port function's migratable get function. * @port_fn_migratable_get: Port function's migratable get function.
* *
...@@ -1636,6 +1618,14 @@ void devlink_free(struct devlink *devlink); ...@@ -1636,6 +1618,14 @@ void devlink_free(struct devlink *devlink);
* @port_fn_hw_addr_set: Callback used to set port function's hardware address. * @port_fn_hw_addr_set: Callback used to set port function's hardware address.
* Should be used by device drivers to set the hardware * Should be used by device drivers to set the hardware
* address of a function managed by the devlink port. * address of a function managed by the devlink port.
* @port_fn_roce_get: Callback used to get port function's RoCE capability.
* Should be used by device drivers to report
* the current state of RoCE capability of a function
* managed by the devlink port.
* @port_fn_roce_set: Callback used to set port function's RoCE capability.
* Should be used by device drivers to enable/disable
* RoCE capability of a function managed
* by the devlink port.
* *
* Note: Driver should return -EOPNOTSUPP if it doesn't support * Note: Driver should return -EOPNOTSUPP if it doesn't support
* port function (@port_fn_*) handling for a particular port. * port function (@port_fn_*) handling for a particular port.
...@@ -1653,6 +1643,11 @@ struct devlink_port_ops { ...@@ -1653,6 +1643,11 @@ struct devlink_port_ops {
int (*port_fn_hw_addr_set)(struct devlink_port *port, int (*port_fn_hw_addr_set)(struct devlink_port *port,
const u8 *hw_addr, int hw_addr_len, const u8 *hw_addr, int hw_addr_len,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
int (*port_fn_roce_get)(struct devlink_port *devlink_port,
bool *is_enable,
struct netlink_ext_ack *extack);
int (*port_fn_roce_set)(struct devlink_port *devlink_port,
bool enable, struct netlink_ext_ack *extack);
}; };
void devlink_port_init(struct devlink *devlink, void devlink_port_init(struct devlink *devlink,
......
...@@ -447,18 +447,18 @@ static void devlink_port_fn_cap_fill(struct nla_bitfield32 *caps, ...@@ -447,18 +447,18 @@ static void devlink_port_fn_cap_fill(struct nla_bitfield32 *caps,
caps->value |= cap; caps->value |= cap;
} }
static int devlink_port_fn_roce_fill(const struct devlink_ops *ops, static int devlink_port_fn_roce_fill(struct devlink_port *devlink_port,
struct devlink_port *devlink_port,
struct nla_bitfield32 *caps, struct nla_bitfield32 *caps,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
bool is_enable; bool is_enable;
int err; int err;
if (!ops->port_fn_roce_get) if (!devlink_port->ops->port_fn_roce_get)
return 0; return 0;
err = ops->port_fn_roce_get(devlink_port, &is_enable, extack); err = devlink_port->ops->port_fn_roce_get(devlink_port, &is_enable,
extack);
if (err) { if (err) {
if (err == -EOPNOTSUPP) if (err == -EOPNOTSUPP)
return 0; return 0;
...@@ -501,7 +501,7 @@ static int devlink_port_fn_caps_fill(const struct devlink_ops *ops, ...@@ -501,7 +501,7 @@ static int devlink_port_fn_caps_fill(const struct devlink_ops *ops,
struct nla_bitfield32 caps = {}; struct nla_bitfield32 caps = {};
int err; int err;
err = devlink_port_fn_roce_fill(ops, devlink_port, &caps, extack); err = devlink_port_fn_roce_fill(devlink_port, &caps, extack);
if (err) if (err)
return err; return err;
...@@ -837,9 +837,8 @@ static int ...@@ -837,9 +837,8 @@ static int
devlink_port_fn_roce_set(struct devlink_port *devlink_port, bool enable, devlink_port_fn_roce_set(struct devlink_port *devlink_port, bool enable,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
const struct devlink_ops *ops = devlink_port->devlink->ops; return devlink_port->ops->port_fn_roce_set(devlink_port, enable,
extack);
return ops->port_fn_roce_set(devlink_port, enable, extack);
} }
static int devlink_port_fn_caps_set(struct devlink_port *devlink_port, static int devlink_port_fn_caps_set(struct devlink_port *devlink_port,
...@@ -1214,7 +1213,7 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port, ...@@ -1214,7 +1213,7 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port,
caps = nla_get_bitfield32(attr); caps = nla_get_bitfield32(attr);
if (caps.selector & DEVLINK_PORT_FN_CAP_ROCE && if (caps.selector & DEVLINK_PORT_FN_CAP_ROCE &&
!ops->port_fn_roce_set) { !devlink_port->ops->port_fn_roce_set) {
NL_SET_ERR_MSG_ATTR(extack, attr, NL_SET_ERR_MSG_ATTR(extack, attr,
"Port doesn't support RoCE function attribute"); "Port doesn't support RoCE function attribute");
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment