All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com,
	mateusz.polchlopek@intel.com, netdev@vger.kernel.org,
	jiri@nvidia.com, michal.kubiak@intel.com,
	intel-wired-lan@lists.osuosl.org, pio.raczynski@gmail.com,
	sridhar.samudrala@intel.com, jacob.e.keller@intel.com,
	wojciech.drewek@intel.com, przemyslaw.kitszel@intel.com
Subject: Re: [Intel-wired-lan] [iwl-next v1 14/14] ice: allow to activate and deactivate subfunction
Date: Fri, 10 May 2024 09:33:54 +0200	[thread overview]
Message-ID: <Zj3N4idfTGZUYlNc@mev-dev> (raw)
In-Reply-To: <Zjy1LXn4Vj0PX_xs@nanopsycho.orion>

On Thu, May 09, 2024 at 01:36:13PM +0200, Jiri Pirko wrote:
> Tue, May 07, 2024 at 01:45:15PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >From: Piotr Raczynski <piotr.raczynski@intel.com>
> >
> >Use previously implemented SF aux driver. It is probe during SF
> >activation and remove after deactivation.
> >
> >Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
> >Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> >---
> > .../ethernet/intel/ice/devlink/devlink_port.c | 108 ++++++++++++++++++
> > .../ethernet/intel/ice/devlink/devlink_port.h |   6 +
> > drivers/net/ethernet/intel/ice/ice_sf_eth.c   | 107 +++++++++++++++++
> > drivers/net/ethernet/intel/ice/ice_sf_eth.h   |   3 +
> > 4 files changed, 224 insertions(+)
> >
> >diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
> >index e8929e91aff2..43ed05e5c883 100644
> >--- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
> >+++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
> >@@ -482,6 +482,42 @@ void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev)
> > 	devl_port_unregister(&sf_dev->priv->devlink_port);
> > }
> > 
> >+/**
> >+ * ice_activate_dynamic_port - Activate a dynamic port
> >+ * @dyn_port: dynamic port instance to activate
> >+ * @extack: extack for reporting error messages
> >+ *
> >+ * Activate the dynamic port based on its flavour.
> >+ *
> >+ * Return: zero on success or an error code on failure.
> >+ */
> >+static int
> >+ice_activate_dynamic_port(struct ice_dynamic_port *dyn_port,
> >+			  struct netlink_ext_ack *extack)
> >+{
> >+	int err;
> >+
> >+	err = ice_sf_eth_activate(dyn_port, extack);
> >+	if (err)
> >+		return err;
> >+
> >+	dyn_port->active = true;
> >+
> >+	return 0;
> >+}
> >+
> >+/**
> >+ * ice_deactivate_dynamic_port - Deactivate a dynamic port
> >+ * @dyn_port: dynamic port instance to deactivate
> >+ *
> >+ * Undo activation of a dynamic port.
> >+ */
> >+static void ice_deactivate_dynamic_port(struct ice_dynamic_port *dyn_port)
> >+{
> >+	ice_sf_eth_deactivate(dyn_port);
> >+	dyn_port->active = false;
> >+}
> >+
> > /**
> >  * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port
> >  * @dyn_port: dynamic port instance to deallocate
> >@@ -494,6 +530,9 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port)
> > 	struct devlink_port *devlink_port = &dyn_port->devlink_port;
> > 	struct ice_pf *pf = dyn_port->pf;
> > 
> >+	if (dyn_port->active)
> >+		ice_deactivate_dynamic_port(dyn_port);
> >+
> > 	xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf);
> > 	ice_eswitch_detach_sf(pf, dyn_port);
> > 	ice_vsi_free(dyn_port->vsi);
> >@@ -638,10 +677,79 @@ ice_devlink_port_fn_hw_addr_get(struct devlink_port *port, u8 *hw_addr,
> > 	return 0;
> > }
> > 
> >+/**
> >+ * ice_devlink_port_fn_state_set - devlink handler for port state set
> >+ * @port: pointer to devlink port
> >+ * @state: state to set
> >+ * @extack: extack for reporting error messages
> >+ *
> >+ * Activates or deactivates the port.
> >+ *
> >+ * Return: zero on success or an error code on failure.
> >+ */
> >+static int
> >+ice_devlink_port_fn_state_set(struct devlink_port *port,
> >+			      enum devlink_port_fn_state state,
> >+			      struct netlink_ext_ack *extack)
> >+{
> >+	struct ice_dynamic_port *dyn_port;
> >+
> >+	dyn_port = ice_devlink_port_to_dyn(port);
> >+
> >+	switch (state) {
> >+	case DEVLINK_PORT_FN_STATE_ACTIVE:
> >+		if (!dyn_port->active)
> >+			return ice_activate_dynamic_port(dyn_port, extack);
> >+		break;
> >+	case DEVLINK_PORT_FN_STATE_INACTIVE:
> >+		if (dyn_port->active)
> >+			ice_deactivate_dynamic_port(dyn_port);
> >+		break;
> >+	}
> >+
> >+	return 0;
> >+}
> >+
> >+/**
> >+ * 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;
> >+	else
> >+		*state = DEVLINK_PORT_FN_STATE_INACTIVE;
> >+
> >+	if (dyn_port->attached)
> >+		*opstate = DEVLINK_PORT_FN_OPSTATE_ATTACHED;
> >+	else
> >+		*opstate = DEVLINK_PORT_FN_OPSTATE_DETACHED;
> >+
> >+	return 0;
> >+}
> >+
> > static const struct devlink_port_ops ice_devlink_port_sf_ops = {
> > 	.port_del = ice_devlink_port_del,
> > 	.port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get,
> > 	.port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set,
> >+	.port_fn_state_get = ice_devlink_port_fn_state_get,
> >+	.port_fn_state_set = ice_devlink_port_fn_state_set,
> > };
> > 
> > /**
> >diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
> >index 6e14b9e4d621..28574e585341 100644
> >--- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
> >+++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
> >@@ -14,17 +14,23 @@
> >  * @devlink_port: the associated devlink port structure
> >  * @pf: pointer to the PF private structure
> >  * @vsi: the VSI associated with this port
> >+ * @sf_dev: pointer to the subfunction device
> >  *
> >  * An instance of a dynamically added devlink port. Each port flavour
> >  */
> > struct ice_dynamic_port {
> > 	u8 hw_addr[ETH_ALEN];
> > 	u8 active: 1;
> >+	u8 attached: 1;
> > 	struct devlink_port devlink_port;
> > 	struct ice_pf *pf;
> > 	struct ice_vsi *vsi;
> > 	unsigned long repr_id;
> > 	u32 sfnum;
> >+	/* Flavour-specific implementation data */
> >+	union {
> >+		struct ice_sf_dev *sf_dev;
> >+	};
> > };
> > 
> > void ice_dealloc_all_dynamic_ports(struct ice_pf *pf);
> >diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> >index 3a540a2638d1..c01190c9403f 100644
> >--- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> >+++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> >@@ -147,6 +147,7 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev,
> > 	devl_unlock(devlink);
> > 
> > 	devlink_register(devlink);
> >+	dyn_port->attached = true;
> > 
> > 	return 0;
> > 
> >@@ -186,6 +187,8 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev)
> > 	devl_unlock(devlink);
> > 	devlink_free(devlink);
> > 	ice_vsi_decfg(vsi);
> >+
> >+	dyn_port->attached = false;
> > }
> > 
> > static const struct auxiliary_device_id ice_sf_dev_id_table[] = {
> >@@ -202,6 +205,8 @@ static struct auxiliary_driver ice_sf_driver = {
> > 	.id_table = ice_sf_dev_id_table
> > };
> > 
> >+static DEFINE_XARRAY_ALLOC1(ice_sf_aux_id);
> >+
> > /**
> >  * ice_sf_driver_register - Register new auxiliary subfunction driver
> >  *
> >@@ -220,3 +225,105 @@ void ice_sf_driver_unregister(void)
> > {
> > 	auxiliary_driver_unregister(&ice_sf_driver);
> > }
> >+
> >+/**
> >+ * ice_sf_dev_release - Release device associated with auxiliary device
> >+ * @device: pointer to the device
> >+ *
> >+ * Since most of the code for subfunction deactivation is handled in
> >+ * the remove handler, here just free tracking resources.
> >+ */
> >+static void ice_sf_dev_release(struct device *device)
> >+{
> >+	struct auxiliary_device *adev = to_auxiliary_dev(device);
> >+	struct ice_sf_dev *sf_dev = ice_adev_to_sf_dev(adev);
> >+
> >+	xa_erase(&ice_sf_aux_id, adev->id);
> >+	kfree(sf_dev);
> >+}
> >+
> >+/**
> >+ * ice_sf_eth_activate - Activate Ethernet subfunction port
> >+ * @dyn_port: the dynamic port instance for this subfunction
> >+ * @extack: extack for reporting error messages
> >+ *
> >+ * Activate the dynamic port as an Ethernet subfunction. Setup the netdev
> >+ * resources associated and initialize the auxiliary device.
> >+ *
> >+ * Return: zero on success or an error code on failure.
> >+ */
> >+int
> >+ice_sf_eth_activate(struct ice_dynamic_port *dyn_port,
> >+		    struct netlink_ext_ack *extack)
> >+{
> >+	struct ice_pf *pf = dyn_port->pf;
> >+	struct ice_sf_dev *sf_dev;
> >+	struct pci_dev *pdev;
> >+	int err;
> >+	u32 id;
> >+
> >+	err  = xa_alloc(&ice_sf_aux_id, &id, NULL, xa_limit_32b,
> 
> Double space.
> 

Thanks, will fix.

> 
> >+			GFP_KERNEL);
> >+	if (err) {
> >+		NL_SET_ERR_MSG_MOD(extack, "Could not allocate subfunction ID");
> >+		return err;
> >+	}
> >+
> >+	sf_dev = kzalloc(sizeof(*sf_dev), GFP_KERNEL);
> >+	if (!sf_dev) {
> >+		err = -ENOMEM;
> >+		NL_SET_ERR_MSG_MOD(extack, "Could not allocate sf_dev memory");
> >+		goto xa_erase;
> >+	}
> >+	pdev = pf->pdev;
> >+
> >+	sf_dev->dyn_port = dyn_port;
> >+	sf_dev->adev.id = id;
> >+	sf_dev->adev.name = "sf";
> >+	sf_dev->adev.dev.release = ice_sf_dev_release;
> >+	sf_dev->adev.dev.parent = &pdev->dev;
> >+
> >+	err = auxiliary_device_init(&sf_dev->adev);
> >+	if (err) {
> >+		NL_SET_ERR_MSG_MOD(extack, "Failed to initialize auxiliary device");
> >+		goto sf_dev_free;
> >+	}
> >+
> >+	err = auxiliary_device_add(&sf_dev->adev);
> >+	if (err) {
> >+		NL_SET_ERR_MSG_MOD(extack, "Auxiliary device failed to probe");
> 
> How do you know? Probe may happen async.
> 

"Failed to add SF aux device" will be fine?

> 
> >+		goto aux_dev_uninit;
> >+	}
> >+
> >+	dyn_port->sf_dev = sf_dev;
> >+
> >+	return 0;
> >+
> >+aux_dev_uninit:
> >+	auxiliary_device_uninit(&sf_dev->adev);
> >+sf_dev_free:
> >+	kfree(sf_dev);
> >+xa_erase:
> >+	xa_erase(&ice_sf_aux_id, id);
> >+
> >+	return err;
> >+}
> >+
> >+/**
> >+ * ice_sf_eth_deactivate - Deactivate Ethernet subfunction port
> >+ * @dyn_port: the dynamic port instance for this subfunction
> >+ *
> >+ * Deactivate the Ethernet subfunction, removing its auxiliary device and the
> >+ * associated resources.
> >+ */
> >+void ice_sf_eth_deactivate(struct ice_dynamic_port *dyn_port)
> >+{
> >+	struct ice_sf_dev *sf_dev = dyn_port->sf_dev;
> >+
> >+	if (sf_dev) {
> >+		auxiliary_device_delete(&sf_dev->adev);
> >+		auxiliary_device_uninit(&sf_dev->adev);
> >+	}
> >+
> >+	dyn_port->sf_dev = NULL;
> >+}
> >diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.h b/drivers/net/ethernet/intel/ice/ice_sf_eth.h
> >index e972c50f96c9..c558cad0a183 100644
> >--- a/drivers/net/ethernet/intel/ice/ice_sf_eth.h
> >+++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.h
> >@@ -27,4 +27,7 @@ ice_sf_dev *ice_adev_to_sf_dev(struct auxiliary_device *adev)
> > int ice_sf_driver_register(void);
> > void ice_sf_driver_unregister(void);
> > 
> >+int ice_sf_eth_activate(struct ice_dynamic_port *dyn_port,
> >+			struct netlink_ext_ack *extack);
> >+void ice_sf_eth_deactivate(struct ice_dynamic_port *dyn_port);
> > #endif /* _ICE_SF_ETH_H_ */
> >-- 
> >2.42.0
> >
> >

WARNING: multiple messages have this Message-ID (diff)
From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	jacob.e.keller@intel.com, michal.kubiak@intel.com,
	maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com,
	przemyslaw.kitszel@intel.com, wojciech.drewek@intel.com,
	pio.raczynski@gmail.com, jiri@nvidia.com,
	mateusz.polchlopek@intel.com, shayd@nvidia.com
Subject: Re: [iwl-next v1 14/14] ice: allow to activate and deactivate subfunction
Date: Fri, 10 May 2024 09:33:54 +0200	[thread overview]
Message-ID: <Zj3N4idfTGZUYlNc@mev-dev> (raw)
In-Reply-To: <Zjy1LXn4Vj0PX_xs@nanopsycho.orion>

On Thu, May 09, 2024 at 01:36:13PM +0200, Jiri Pirko wrote:
> Tue, May 07, 2024 at 01:45:15PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >From: Piotr Raczynski <piotr.raczynski@intel.com>
> >
> >Use previously implemented SF aux driver. It is probe during SF
> >activation and remove after deactivation.
> >
> >Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
> >Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> >---
> > .../ethernet/intel/ice/devlink/devlink_port.c | 108 ++++++++++++++++++
> > .../ethernet/intel/ice/devlink/devlink_port.h |   6 +
> > drivers/net/ethernet/intel/ice/ice_sf_eth.c   | 107 +++++++++++++++++
> > drivers/net/ethernet/intel/ice/ice_sf_eth.h   |   3 +
> > 4 files changed, 224 insertions(+)
> >
> >diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
> >index e8929e91aff2..43ed05e5c883 100644
> >--- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
> >+++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
> >@@ -482,6 +482,42 @@ void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev)
> > 	devl_port_unregister(&sf_dev->priv->devlink_port);
> > }
> > 
> >+/**
> >+ * ice_activate_dynamic_port - Activate a dynamic port
> >+ * @dyn_port: dynamic port instance to activate
> >+ * @extack: extack for reporting error messages
> >+ *
> >+ * Activate the dynamic port based on its flavour.
> >+ *
> >+ * Return: zero on success or an error code on failure.
> >+ */
> >+static int
> >+ice_activate_dynamic_port(struct ice_dynamic_port *dyn_port,
> >+			  struct netlink_ext_ack *extack)
> >+{
> >+	int err;
> >+
> >+	err = ice_sf_eth_activate(dyn_port, extack);
> >+	if (err)
> >+		return err;
> >+
> >+	dyn_port->active = true;
> >+
> >+	return 0;
> >+}
> >+
> >+/**
> >+ * ice_deactivate_dynamic_port - Deactivate a dynamic port
> >+ * @dyn_port: dynamic port instance to deactivate
> >+ *
> >+ * Undo activation of a dynamic port.
> >+ */
> >+static void ice_deactivate_dynamic_port(struct ice_dynamic_port *dyn_port)
> >+{
> >+	ice_sf_eth_deactivate(dyn_port);
> >+	dyn_port->active = false;
> >+}
> >+
> > /**
> >  * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port
> >  * @dyn_port: dynamic port instance to deallocate
> >@@ -494,6 +530,9 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port)
> > 	struct devlink_port *devlink_port = &dyn_port->devlink_port;
> > 	struct ice_pf *pf = dyn_port->pf;
> > 
> >+	if (dyn_port->active)
> >+		ice_deactivate_dynamic_port(dyn_port);
> >+
> > 	xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf);
> > 	ice_eswitch_detach_sf(pf, dyn_port);
> > 	ice_vsi_free(dyn_port->vsi);
> >@@ -638,10 +677,79 @@ ice_devlink_port_fn_hw_addr_get(struct devlink_port *port, u8 *hw_addr,
> > 	return 0;
> > }
> > 
> >+/**
> >+ * ice_devlink_port_fn_state_set - devlink handler for port state set
> >+ * @port: pointer to devlink port
> >+ * @state: state to set
> >+ * @extack: extack for reporting error messages
> >+ *
> >+ * Activates or deactivates the port.
> >+ *
> >+ * Return: zero on success or an error code on failure.
> >+ */
> >+static int
> >+ice_devlink_port_fn_state_set(struct devlink_port *port,
> >+			      enum devlink_port_fn_state state,
> >+			      struct netlink_ext_ack *extack)
> >+{
> >+	struct ice_dynamic_port *dyn_port;
> >+
> >+	dyn_port = ice_devlink_port_to_dyn(port);
> >+
> >+	switch (state) {
> >+	case DEVLINK_PORT_FN_STATE_ACTIVE:
> >+		if (!dyn_port->active)
> >+			return ice_activate_dynamic_port(dyn_port, extack);
> >+		break;
> >+	case DEVLINK_PORT_FN_STATE_INACTIVE:
> >+		if (dyn_port->active)
> >+			ice_deactivate_dynamic_port(dyn_port);
> >+		break;
> >+	}
> >+
> >+	return 0;
> >+}
> >+
> >+/**
> >+ * 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;
> >+	else
> >+		*state = DEVLINK_PORT_FN_STATE_INACTIVE;
> >+
> >+	if (dyn_port->attached)
> >+		*opstate = DEVLINK_PORT_FN_OPSTATE_ATTACHED;
> >+	else
> >+		*opstate = DEVLINK_PORT_FN_OPSTATE_DETACHED;
> >+
> >+	return 0;
> >+}
> >+
> > static const struct devlink_port_ops ice_devlink_port_sf_ops = {
> > 	.port_del = ice_devlink_port_del,
> > 	.port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get,
> > 	.port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set,
> >+	.port_fn_state_get = ice_devlink_port_fn_state_get,
> >+	.port_fn_state_set = ice_devlink_port_fn_state_set,
> > };
> > 
> > /**
> >diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
> >index 6e14b9e4d621..28574e585341 100644
> >--- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
> >+++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
> >@@ -14,17 +14,23 @@
> >  * @devlink_port: the associated devlink port structure
> >  * @pf: pointer to the PF private structure
> >  * @vsi: the VSI associated with this port
> >+ * @sf_dev: pointer to the subfunction device
> >  *
> >  * An instance of a dynamically added devlink port. Each port flavour
> >  */
> > struct ice_dynamic_port {
> > 	u8 hw_addr[ETH_ALEN];
> > 	u8 active: 1;
> >+	u8 attached: 1;
> > 	struct devlink_port devlink_port;
> > 	struct ice_pf *pf;
> > 	struct ice_vsi *vsi;
> > 	unsigned long repr_id;
> > 	u32 sfnum;
> >+	/* Flavour-specific implementation data */
> >+	union {
> >+		struct ice_sf_dev *sf_dev;
> >+	};
> > };
> > 
> > void ice_dealloc_all_dynamic_ports(struct ice_pf *pf);
> >diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> >index 3a540a2638d1..c01190c9403f 100644
> >--- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> >+++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> >@@ -147,6 +147,7 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev,
> > 	devl_unlock(devlink);
> > 
> > 	devlink_register(devlink);
> >+	dyn_port->attached = true;
> > 
> > 	return 0;
> > 
> >@@ -186,6 +187,8 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev)
> > 	devl_unlock(devlink);
> > 	devlink_free(devlink);
> > 	ice_vsi_decfg(vsi);
> >+
> >+	dyn_port->attached = false;
> > }
> > 
> > static const struct auxiliary_device_id ice_sf_dev_id_table[] = {
> >@@ -202,6 +205,8 @@ static struct auxiliary_driver ice_sf_driver = {
> > 	.id_table = ice_sf_dev_id_table
> > };
> > 
> >+static DEFINE_XARRAY_ALLOC1(ice_sf_aux_id);
> >+
> > /**
> >  * ice_sf_driver_register - Register new auxiliary subfunction driver
> >  *
> >@@ -220,3 +225,105 @@ void ice_sf_driver_unregister(void)
> > {
> > 	auxiliary_driver_unregister(&ice_sf_driver);
> > }
> >+
> >+/**
> >+ * ice_sf_dev_release - Release device associated with auxiliary device
> >+ * @device: pointer to the device
> >+ *
> >+ * Since most of the code for subfunction deactivation is handled in
> >+ * the remove handler, here just free tracking resources.
> >+ */
> >+static void ice_sf_dev_release(struct device *device)
> >+{
> >+	struct auxiliary_device *adev = to_auxiliary_dev(device);
> >+	struct ice_sf_dev *sf_dev = ice_adev_to_sf_dev(adev);
> >+
> >+	xa_erase(&ice_sf_aux_id, adev->id);
> >+	kfree(sf_dev);
> >+}
> >+
> >+/**
> >+ * ice_sf_eth_activate - Activate Ethernet subfunction port
> >+ * @dyn_port: the dynamic port instance for this subfunction
> >+ * @extack: extack for reporting error messages
> >+ *
> >+ * Activate the dynamic port as an Ethernet subfunction. Setup the netdev
> >+ * resources associated and initialize the auxiliary device.
> >+ *
> >+ * Return: zero on success or an error code on failure.
> >+ */
> >+int
> >+ice_sf_eth_activate(struct ice_dynamic_port *dyn_port,
> >+		    struct netlink_ext_ack *extack)
> >+{
> >+	struct ice_pf *pf = dyn_port->pf;
> >+	struct ice_sf_dev *sf_dev;
> >+	struct pci_dev *pdev;
> >+	int err;
> >+	u32 id;
> >+
> >+	err  = xa_alloc(&ice_sf_aux_id, &id, NULL, xa_limit_32b,
> 
> Double space.
> 

Thanks, will fix.

> 
> >+			GFP_KERNEL);
> >+	if (err) {
> >+		NL_SET_ERR_MSG_MOD(extack, "Could not allocate subfunction ID");
> >+		return err;
> >+	}
> >+
> >+	sf_dev = kzalloc(sizeof(*sf_dev), GFP_KERNEL);
> >+	if (!sf_dev) {
> >+		err = -ENOMEM;
> >+		NL_SET_ERR_MSG_MOD(extack, "Could not allocate sf_dev memory");
> >+		goto xa_erase;
> >+	}
> >+	pdev = pf->pdev;
> >+
> >+	sf_dev->dyn_port = dyn_port;
> >+	sf_dev->adev.id = id;
> >+	sf_dev->adev.name = "sf";
> >+	sf_dev->adev.dev.release = ice_sf_dev_release;
> >+	sf_dev->adev.dev.parent = &pdev->dev;
> >+
> >+	err = auxiliary_device_init(&sf_dev->adev);
> >+	if (err) {
> >+		NL_SET_ERR_MSG_MOD(extack, "Failed to initialize auxiliary device");
> >+		goto sf_dev_free;
> >+	}
> >+
> >+	err = auxiliary_device_add(&sf_dev->adev);
> >+	if (err) {
> >+		NL_SET_ERR_MSG_MOD(extack, "Auxiliary device failed to probe");
> 
> How do you know? Probe may happen async.
> 

"Failed to add SF aux device" will be fine?

> 
> >+		goto aux_dev_uninit;
> >+	}
> >+
> >+	dyn_port->sf_dev = sf_dev;
> >+
> >+	return 0;
> >+
> >+aux_dev_uninit:
> >+	auxiliary_device_uninit(&sf_dev->adev);
> >+sf_dev_free:
> >+	kfree(sf_dev);
> >+xa_erase:
> >+	xa_erase(&ice_sf_aux_id, id);
> >+
> >+	return err;
> >+}
> >+
> >+/**
> >+ * ice_sf_eth_deactivate - Deactivate Ethernet subfunction port
> >+ * @dyn_port: the dynamic port instance for this subfunction
> >+ *
> >+ * Deactivate the Ethernet subfunction, removing its auxiliary device and the
> >+ * associated resources.
> >+ */
> >+void ice_sf_eth_deactivate(struct ice_dynamic_port *dyn_port)
> >+{
> >+	struct ice_sf_dev *sf_dev = dyn_port->sf_dev;
> >+
> >+	if (sf_dev) {
> >+		auxiliary_device_delete(&sf_dev->adev);
> >+		auxiliary_device_uninit(&sf_dev->adev);
> >+	}
> >+
> >+	dyn_port->sf_dev = NULL;
> >+}
> >diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.h b/drivers/net/ethernet/intel/ice/ice_sf_eth.h
> >index e972c50f96c9..c558cad0a183 100644
> >--- a/drivers/net/ethernet/intel/ice/ice_sf_eth.h
> >+++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.h
> >@@ -27,4 +27,7 @@ ice_sf_dev *ice_adev_to_sf_dev(struct auxiliary_device *adev)
> > int ice_sf_driver_register(void);
> > void ice_sf_driver_unregister(void);
> > 
> >+int ice_sf_eth_activate(struct ice_dynamic_port *dyn_port,
> >+			struct netlink_ext_ack *extack);
> >+void ice_sf_eth_deactivate(struct ice_dynamic_port *dyn_port);
> > #endif /* _ICE_SF_ETH_H_ */
> >-- 
> >2.42.0
> >
> >

  reply	other threads:[~2024-05-10  7:34 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07 11:45 [Intel-wired-lan] [iwl-next v1 00/14] ice: support devlink subfunction Michal Swiatkowski
2024-05-07 11:45 ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 01/14] ice: add new VSI type for subfunctions Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 02/14] ice: export ice ndo_ops functions Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 03/14] ice: add basic devlink subfunctions support Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-09 11:06   ` [Intel-wired-lan] " Jiri Pirko
2024-05-09 11:06     ` Jiri Pirko
2024-05-10  7:13     ` [Intel-wired-lan] " Michal Swiatkowski
2024-05-10  7:13       ` Michal Swiatkowski
2024-05-10 11:05       ` [Intel-wired-lan] " Jiri Pirko
2024-05-10 11:05         ` Jiri Pirko
2024-05-10 12:25         ` [Intel-wired-lan] " Michal Swiatkowski
2024-05-10 12:25           ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 04/14] ice: treat subfunction VSI the same as PF VSI Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 05/14] ice: allocate devlink for subfunction Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 06/14] ice: base subfunction aux driver Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-09 11:13   ` [Intel-wired-lan] " Jiri Pirko
2024-05-09 11:13     ` Jiri Pirko
2024-05-10  7:20     ` [Intel-wired-lan] " Michal Swiatkowski
2024-05-10  7:20       ` Michal Swiatkowski
2024-05-10 11:06       ` [Intel-wired-lan] " Jiri Pirko
2024-05-10 11:06         ` Jiri Pirko
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 07/14] ice: implement netdev for subfunction Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 08/14] ice: create port representor for SF Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-09 11:16   ` [Intel-wired-lan] " Jiri Pirko
2024-05-09 11:16     ` Jiri Pirko
2024-05-10  7:31     ` [Intel-wired-lan] " Michal Swiatkowski
2024-05-10  7:31       ` Michal Swiatkowski
2024-05-10 11:07       ` [Intel-wired-lan] " Jiri Pirko
2024-05-10 11:07         ` Jiri Pirko
2024-05-10 12:25         ` [Intel-wired-lan] " Michal Swiatkowski
2024-05-10 12:25           ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 09/14] ice: don't set target VSI for subfunction Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 10/14] ice: check if SF is ready in ethtool ops Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 11/14] ice: netdevice ops for SF representor Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-09 11:17   ` [Intel-wired-lan] " Jiri Pirko
2024-05-09 11:17     ` Jiri Pirko
2024-05-10  7:25     ` [Intel-wired-lan] " Michal Swiatkowski
2024-05-10  7:25       ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 12/14] ice: support subfunction devlink Tx topology Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 13/14] ice: basic support for VLAN in subfunctions Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-07 11:45 ` [Intel-wired-lan] [iwl-next v1 14/14] ice: allow to activate and deactivate subfunction Michal Swiatkowski
2024-05-07 11:45   ` Michal Swiatkowski
2024-05-09 11:36   ` [Intel-wired-lan] " Jiri Pirko
2024-05-09 11:36     ` Jiri Pirko
2024-05-10  7:33     ` Michal Swiatkowski [this message]
2024-05-10  7:33       ` Michal Swiatkowski
2024-05-10 11:08       ` [Intel-wired-lan] " Jiri Pirko
2024-05-10 11:08         ` Jiri Pirko
2024-05-09 11:18 ` [Intel-wired-lan] [iwl-next v1 00/14] ice: support devlink subfunction Jiri Pirko
2024-05-09 11:18   ` Jiri Pirko
2024-05-10  7:24   ` [Intel-wired-lan] " Michal Swiatkowski
2024-05-10  7:24     ` Michal Swiatkowski
2024-05-10 11:09     ` [Intel-wired-lan] " Jiri Pirko
2024-05-10 11:09       ` Jiri Pirko
2024-05-10 12:26       ` [Intel-wired-lan] " Michal Swiatkowski
2024-05-10 12:26         ` Michal Swiatkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zj3N4idfTGZUYlNc@mev-dev \
    --to=michal.swiatkowski@linux.intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jiri@nvidia.com \
    --cc=jiri@resnulli.us \
    --cc=maciej.fijalkowski@intel.com \
    --cc=mateusz.polchlopek@intel.com \
    --cc=michal.kubiak@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pio.raczynski@gmail.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=shayd@nvidia.com \
    --cc=sridhar.samudrala@intel.com \
    --cc=wojciech.drewek@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.