@@ -888,6 +888,8 @@ static const struct devlink_ops nsim_dev_devlink_ops = {
.port_del = nsim_dev_devlink_port_del,
.port_function_hw_addr_get = nsim_dev_port_function_hw_addr_get,
.port_function_hw_addr_set = nsim_dev_port_function_hw_addr_set,
+ .port_function_state_get = nsim_dev_port_function_state_get,
+ .port_function_state_set = nsim_dev_port_function_state_set,
};
#define NSIM_DEV_MAX_MACS_DEFAULT 32
@@ -308,3 +308,9 @@ int nsim_dev_port_function_hw_addr_get(struct devlink *devlink, struct devlink_p
int nsim_dev_port_function_hw_addr_set(struct devlink *devlink, struct devlink_port *port,
const u8 *hw_addr, int hw_addr_len,
struct netlink_ext_ack *extack);
+int nsim_dev_port_function_state_get(struct devlink *devlink, struct devlink_port *port,
+ enum devlink_port_function_state *state,
+ struct netlink_ext_ack *extack);
+int nsim_dev_port_function_state_set(struct devlink *devlink, struct devlink_port *port,
+ enum devlink_port_function_state state,
+ struct netlink_ext_ack *extack);
@@ -16,6 +16,7 @@ struct nsim_port_function {
u16 pfnum;
struct nsim_port_function *pf_port; /* Valid only for SF port */
u8 hw_addr[ETH_ALEN];
+ u8 state; /* enum devlink_port_function_state */
};
void nsim_dev_port_function_init(struct nsim_dev *nsim_dev)
@@ -196,6 +197,7 @@ static int nsim_devlink_port_function_add(struct devlink *devlink, struct nsim_d
list_add(&port->list, &nsim_dev->port_functions.head);
+ port->state = DEVLINK_PORT_FUNCTION_STATE_INACTIVE;
err = devlink_port_register(devlink, &port->dl_port, port->port_index);
if (err)
goto reg_err;
@@ -379,3 +381,31 @@ int nsim_dev_port_function_hw_addr_set(struct devlink *devlink, struct devlink_p
memcpy(port->hw_addr, hw_addr, ETH_ALEN);
return 0;
}
+
+int nsim_dev_port_function_state_get(struct devlink *devlink, struct devlink_port *dl_port,
+ enum devlink_port_function_state *state,
+ struct netlink_ext_ack *extack)
+{
+ struct nsim_dev *nsim_dev = devlink_priv(devlink);
+ struct nsim_port_function *port;
+
+ port = nsim_dev_to_port_function(nsim_dev, dl_port);
+ if (IS_ERR(port))
+ return PTR_ERR(port);
+ *state = port->state;
+ return 0;
+}
+
+int nsim_dev_port_function_state_set(struct devlink *devlink, struct devlink_port *dl_port,
+ enum devlink_port_function_state state,
+ struct netlink_ext_ack *extack)
+{
+ struct nsim_dev *nsim_dev = devlink_priv(devlink);
+ struct nsim_port_function *port;
+
+ port = nsim_dev_to_port_function(nsim_dev, dl_port);
+ if (IS_ERR(port))
+ return PTR_ERR(port);
+ port->state = state;
+ return 0;
+}