Subject: Re: [iwl-next v4 8/8] ice: allow to activate and deactivate subfunction

From: Michal Swiatkowski <[email-masked]>
Date: Thu, 18 Apr 2024 13:55:03 +0200

On Thu, Apr 18, 2024 at 11:12:47AM +0300, Shay Drori wrote:
> resend as plain test
> 
> On 18/04/2024 10:53, Shay Drori wrote:
> > On 17/04/2024 17:20, Michal Swiatkowski wrote:
> > > +/**
> > > + * ice_devlink_port_fn_state_get - devlink handler for port state get
> > > + * @port: pointer to devlink port
> > > + * @state: admin configured state of the port
> > > + * @opstate: current port operational state
> > > + * @extack: extack for reporting error messages
> > > + *
> > > + * Gets port state.
> > > + *
> > > + * Return: zero on success or an error code on failure.
> > > + */
> > > +static int
> > > +ice_devlink_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)
> > > +{
> > > +	struct ice_dynamic_port *dyn_port;
> > > +
> > > +	dyn_port = ice_devlink_port_to_dyn(port);
> > > +
> > > +	if (dyn_port->active) {
> > > +		*state = DEVLINK_PORT_FN_STATE_ACTIVE;
> > > +		*opstate = DEVLINK_PORT_FN_OPSTATE_ATTACHED;
> > 
> > 
> > DEVLINK_PORT_FN_OPSTATE_ATTACHED means the SF is up/bind[1].
> > ice is using auxiliary bus for SFs, which means user can unbind it
> > via the auxiliary sysfs (/sys/bus/auxiliary/drivers/ice_sf/unbind).
> > In this case[2], you need to return:
> > *state = DEVLINK_PORT_FN_STATE_ACTIVE;
> > *opstate = DEVLINK_PORT_FN_OPSTATE_DETACHED;
> > 

Thanks, I didn't think about unbinding/binding the aux driver via sysfs.

To be sure:
- user create the subfunction:
INACTIVE, DETACHED
- user activate it:
ACTIVE, ATTACHED
- user unbind driver:
ACTIVE, DETACHED
- user can bind it again as long as subfunction port is ACTIVE
is it right?

I will fix the comment from previous patch and add state tracking for
ATTACHED/DETACHED.

Thanks,
Michal

> > 
> > [1]
> > Documentation from include/uapi/linux/devlink.h:
> > 
> > * @DEVLINK_PORT_FN_OPSTATE_ATTACHED: Driver is attached to the function.
> > <...>
> > * @DEVLINK_PORT_FN_OPSTATE_DETACHED: Driver is detached from the function.
> > 
> > > +	} else {
> > > +		*state = DEVLINK_PORT_FN_STATE_INACTIVE;
> > > +		*opstate = DEVLINK_PORT_FN_OPSTATE_DETACHED;
> > > +	}
> > > +
> > > +	return 0;
> > > +}
> > > +