diff mbox series

[iwl-next,v4,5/8] ice: allocate devlink for subfunction

Message ID 20240417142028.2171-6-michal.swiatkowski@linux.intel.com
State Changes Requested
Headers show
Series ice: support devlink subfunction | expand

Commit Message

Michal Swiatkowski April 17, 2024, 2:20 p.m. UTC
From: Piotr Raczynski <piotr.raczynski@intel.com>

Make devlink allocation function generic to use it for PF and for SF.

Add function for SF devlink port creation. It will be used in next
patch.

Create header file for subfunction device. Define subfunction device
structure there as it is needed for devlink allocation and port
creation.

Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
 .../net/ethernet/intel/ice/devlink/devlink.c  | 47 ++++++++++++++---
 .../net/ethernet/intel/ice/devlink/devlink.h  |  1 +
 .../ethernet/intel/ice/devlink/devlink_port.c | 50 +++++++++++++++++++
 .../ethernet/intel/ice/devlink/devlink_port.h |  3 ++
 drivers/net/ethernet/intel/ice/ice_sf_eth.h   | 21 ++++++++
 5 files changed, 116 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_eth.h

Comments

Jiri Pirko April 18, 2024, 12:04 p.m. UTC | #1
Wed, Apr 17, 2024 at 04:20:25PM CEST, michal.swiatkowski@linux.intel.com wrote:
>From: Piotr Raczynski <piotr.raczynski@intel.com>

[...]

>+/**
>+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
>+ * @dev: the device to allocate for
>+ *
>+ * Allocate a devlink instance for SF.
>+ *
>+ * Return: void pointer to allocated memory
>+ */
>+struct ice_sf_priv *ice_allocate_sf(struct device *dev)

This is devlink instance for SF auxdev. Please make sure it is properly
linked with the devlink port instance using devl_port_fn_devlink_set()
See mlx5 implementation for inspiration.


>+{
>+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
>+				 &ice_sf_devlink_ops);
>+}
>+

[...]
Michal Swiatkowski April 18, 2024, 12:48 p.m. UTC | #2
On Thu, Apr 18, 2024 at 02:04:21PM +0200, Jiri Pirko wrote:
> Wed, Apr 17, 2024 at 04:20:25PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >From: Piotr Raczynski <piotr.raczynski@intel.com>
> 
> [...]
> 
> >+/**
> >+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
> >+ * @dev: the device to allocate for
> >+ *
> >+ * Allocate a devlink instance for SF.
> >+ *
> >+ * Return: void pointer to allocated memory
> >+ */
> >+struct ice_sf_priv *ice_allocate_sf(struct device *dev)
> 
> This is devlink instance for SF auxdev. Please make sure it is properly
> linked with the devlink port instance using devl_port_fn_devlink_set()
> See mlx5 implementation for inspiration.
> 
> 

I am going to do it in the last patchset. I know that it isn't the best
option to split patchesets like that, but it was hard to do it differently.

Thanks,
Michal

> >+{
> >+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
> >+				 &ice_sf_devlink_ops);
> >+}
> >+
> 
> [...]
Jiri Pirko April 18, 2024, 1:02 p.m. UTC | #3
Thu, Apr 18, 2024 at 02:48:53PM CEST, michal.swiatkowski@linux.intel.com wrote:
>On Thu, Apr 18, 2024 at 02:04:21PM +0200, Jiri Pirko wrote:
>> Wed, Apr 17, 2024 at 04:20:25PM CEST, michal.swiatkowski@linux.intel.com wrote:
>> >From: Piotr Raczynski <piotr.raczynski@intel.com>
>> 
>> [...]
>> 
>> >+/**
>> >+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
>> >+ * @dev: the device to allocate for
>> >+ *
>> >+ * Allocate a devlink instance for SF.
>> >+ *
>> >+ * Return: void pointer to allocated memory
>> >+ */
>> >+struct ice_sf_priv *ice_allocate_sf(struct device *dev)
>> 
>> This is devlink instance for SF auxdev. Please make sure it is properly
>> linked with the devlink port instance using devl_port_fn_devlink_set()
>> See mlx5 implementation for inspiration.
>> 
>> 
>
>I am going to do it in the last patchset. I know that it isn't the best

Where? Either I'm blind or you don't do it.


>option to split patchesets like that, but it was hard to do it differently.
>
>Thanks,
>Michal
>
>> >+{
>> >+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
>> >+				 &ice_sf_devlink_ops);
>> >+}
>> >+
>> 
>> [...]
Michal Swiatkowski April 18, 2024, 2:46 p.m. UTC | #4
On Thu, Apr 18, 2024 at 03:02:49PM +0200, Jiri Pirko wrote:
> Thu, Apr 18, 2024 at 02:48:53PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >On Thu, Apr 18, 2024 at 02:04:21PM +0200, Jiri Pirko wrote:
> >> Wed, Apr 17, 2024 at 04:20:25PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >> >From: Piotr Raczynski <piotr.raczynski@intel.com>
> >> 
> >> [...]
> >> 
> >> >+/**
> >> >+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
> >> >+ * @dev: the device to allocate for
> >> >+ *
> >> >+ * Allocate a devlink instance for SF.
> >> >+ *
> >> >+ * Return: void pointer to allocated memory
> >> >+ */
> >> >+struct ice_sf_priv *ice_allocate_sf(struct device *dev)
> >> 
> >> This is devlink instance for SF auxdev. Please make sure it is properly
> >> linked with the devlink port instance using devl_port_fn_devlink_set()
> >> See mlx5 implementation for inspiration.
> >> 
> >> 
> >
> >I am going to do it in the last patchset. I know that it isn't the best
> 
> Where? Either I'm blind or you don't do it.
> 
> 

You told me to split few patches from first patchset [1]. We agree that
there will be too many patches for one submission, so I split it into
3:
- 1/3 devlink prework (already accepted)
- 2/3 base subfunction (this patchset)
- 3/3 port representor refactor to support subfunction (I am going to
  include it there)

[1] https://lore.kernel.org/netdev/20240301115414.502097-1-michal.swiatkowski@linux.intel.com/

Thanks,
Michal

> >option to split patchesets like that, but it was hard to do it differently.
> >
> >Thanks,
> >Michal
> >
> >> >+{
> >> >+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
> >> >+				 &ice_sf_devlink_ops);
> >> >+}
> >> >+
> >> 
> >> [...]
Jiri Pirko April 18, 2024, 3:43 p.m. UTC | #5
Thu, Apr 18, 2024 at 04:46:23PM CEST, michal.swiatkowski@linux.intel.com wrote:
>On Thu, Apr 18, 2024 at 03:02:49PM +0200, Jiri Pirko wrote:
>> Thu, Apr 18, 2024 at 02:48:53PM CEST, michal.swiatkowski@linux.intel.com wrote:
>> >On Thu, Apr 18, 2024 at 02:04:21PM +0200, Jiri Pirko wrote:
>> >> Wed, Apr 17, 2024 at 04:20:25PM CEST, michal.swiatkowski@linux.intel.com wrote:
>> >> >From: Piotr Raczynski <piotr.raczynski@intel.com>
>> >> 
>> >> [...]
>> >> 
>> >> >+/**
>> >> >+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
>> >> >+ * @dev: the device to allocate for
>> >> >+ *
>> >> >+ * Allocate a devlink instance for SF.
>> >> >+ *
>> >> >+ * Return: void pointer to allocated memory
>> >> >+ */
>> >> >+struct ice_sf_priv *ice_allocate_sf(struct device *dev)
>> >> 
>> >> This is devlink instance for SF auxdev. Please make sure it is properly
>> >> linked with the devlink port instance using devl_port_fn_devlink_set()
>> >> See mlx5 implementation for inspiration.
>> >> 
>> >> 
>> >
>> >I am going to do it in the last patchset. I know that it isn't the best
>> 
>> Where? Either I'm blind or you don't do it.
>> 
>> 
>
>You told me to split few patches from first patchset [1]. We agree that
>there will be too many patches for one submission, so I split it into
>3:
>- 1/3 devlink prework (already accepted)
>- 2/3 base subfunction (this patchset)
>- 3/3 port representor refactor to support subfunction (I am going to
>  include it there)

Sorry, but how is this relevant to my suggestion to use
devl_port_fn_devlink_set() which you apparently don't?


>
>[1] https://lore.kernel.org/netdev/20240301115414.502097-1-michal.swiatkowski@linux.intel.com/
>
>Thanks,
>Michal
>
>> >option to split patchesets like that, but it was hard to do it differently.
>> >
>> >Thanks,
>> >Michal
>> >
>> >> >+{
>> >> >+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
>> >> >+				 &ice_sf_devlink_ops);
>> >> >+}
>> >> >+
>> >> 
>> >> [...]
Michal Swiatkowski April 18, 2024, 4:11 p.m. UTC | #6
On Thu, Apr 18, 2024 at 05:43:25PM +0200, Jiri Pirko wrote:
> Thu, Apr 18, 2024 at 04:46:23PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >On Thu, Apr 18, 2024 at 03:02:49PM +0200, Jiri Pirko wrote:
> >> Thu, Apr 18, 2024 at 02:48:53PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >> >On Thu, Apr 18, 2024 at 02:04:21PM +0200, Jiri Pirko wrote:
> >> >> Wed, Apr 17, 2024 at 04:20:25PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >> >> >From: Piotr Raczynski <piotr.raczynski@intel.com>
> >> >> 
> >> >> [...]
> >> >> 
> >> >> >+/**
> >> >> >+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
> >> >> >+ * @dev: the device to allocate for
> >> >> >+ *
> >> >> >+ * Allocate a devlink instance for SF.
> >> >> >+ *
> >> >> >+ * Return: void pointer to allocated memory
> >> >> >+ */
> >> >> >+struct ice_sf_priv *ice_allocate_sf(struct device *dev)
> >> >> 
> >> >> This is devlink instance for SF auxdev. Please make sure it is properly
> >> >> linked with the devlink port instance using devl_port_fn_devlink_set()
> >> >> See mlx5 implementation for inspiration.
> >> >> 
> >> >> 
> >> >
> >> >I am going to do it in the last patchset. I know that it isn't the best
> >> 
> >> Where? Either I'm blind or you don't do it.
> >> 
> >> 
> >
> >You told me to split few patches from first patchset [1]. We agree that
> >there will be too many patches for one submission, so I split it into
> >3:
> >- 1/3 devlink prework (already accepted)
> >- 2/3 base subfunction (this patchset)
> >- 3/3 port representor refactor to support subfunction (I am going to
> >  include it there)
> 
> Sorry, but how is this relevant to my suggestion to use
> devl_port_fn_devlink_set() which you apparently don't?
> 

Devlink port to link with is introduced in the port representor part.
Strange, but it fitted to my splitting. I can move
activation/deactivation part also to this patchset (as there is no
devlink port to call it on) if you want.

> 
> >
> >[1] https://lore.kernel.org/netdev/20240301115414.502097-1-michal.swiatkowski@linux.intel.com/
> >
> >Thanks,
> >Michal
> >
> >> >option to split patchesets like that, but it was hard to do it differently.
> >> >
> >> >Thanks,
> >> >Michal
> >> >
> >> >> >+{
> >> >> >+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
> >> >> >+				 &ice_sf_devlink_ops);
> >> >> >+}
> >> >> >+
> >> >> 
> >> >> [...]
Jiri Pirko April 18, 2024, 5:25 p.m. UTC | #7
Thu, Apr 18, 2024 at 06:11:38PM CEST, michal.swiatkowski@linux.intel.com wrote:
>On Thu, Apr 18, 2024 at 05:43:25PM +0200, Jiri Pirko wrote:
>> Thu, Apr 18, 2024 at 04:46:23PM CEST, michal.swiatkowski@linux.intel.com wrote:
>> >On Thu, Apr 18, 2024 at 03:02:49PM +0200, Jiri Pirko wrote:
>> >> Thu, Apr 18, 2024 at 02:48:53PM CEST, michal.swiatkowski@linux.intel.com wrote:
>> >> >On Thu, Apr 18, 2024 at 02:04:21PM +0200, Jiri Pirko wrote:
>> >> >> Wed, Apr 17, 2024 at 04:20:25PM CEST, michal.swiatkowski@linux.intel.com wrote:
>> >> >> >From: Piotr Raczynski <piotr.raczynski@intel.com>
>> >> >> 
>> >> >> [...]
>> >> >> 
>> >> >> >+/**
>> >> >> >+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
>> >> >> >+ * @dev: the device to allocate for
>> >> >> >+ *
>> >> >> >+ * Allocate a devlink instance for SF.
>> >> >> >+ *
>> >> >> >+ * Return: void pointer to allocated memory
>> >> >> >+ */
>> >> >> >+struct ice_sf_priv *ice_allocate_sf(struct device *dev)
>> >> >> 
>> >> >> This is devlink instance for SF auxdev. Please make sure it is properly
>> >> >> linked with the devlink port instance using devl_port_fn_devlink_set()
>> >> >> See mlx5 implementation for inspiration.
>> >> >> 
>> >> >> 
>> >> >
>> >> >I am going to do it in the last patchset. I know that it isn't the best
>> >> 
>> >> Where? Either I'm blind or you don't do it.
>> >> 
>> >> 
>> >
>> >You told me to split few patches from first patchset [1]. We agree that
>> >there will be too many patches for one submission, so I split it into
>> >3:
>> >- 1/3 devlink prework (already accepted)
>> >- 2/3 base subfunction (this patchset)
>> >- 3/3 port representor refactor to support subfunction (I am going to
>> >  include it there)
>> 
>> Sorry, but how is this relevant to my suggestion to use
>> devl_port_fn_devlink_set() which you apparently don't?
>> 
>
>Devlink port to link with is introduced in the port representor part.
>Strange, but it fitted to my splitting. I can move
>activation/deactivation part also to this patchset (as there is no
>devlink port to call it on) if you want.

You have 7 more patches to use in this set. No problem. Please do it all
at once.


>
>> 
>> >
>> >[1] https://lore.kernel.org/netdev/20240301115414.502097-1-michal.swiatkowski@linux.intel.com/
>> >
>> >Thanks,
>> >Michal
>> >
>> >> >option to split patchesets like that, but it was hard to do it differently.
>> >> >
>> >> >Thanks,
>> >> >Michal
>> >> >
>> >> >> >+{
>> >> >> >+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
>> >> >> >+				 &ice_sf_devlink_ops);
>> >> >> >+}
>> >> >> >+
>> >> >> 
>> >> >> [...]
Michal Swiatkowski April 19, 2024, 5:22 p.m. UTC | #8
On Thu, Apr 18, 2024 at 07:25:35PM +0200, Jiri Pirko wrote:
> Thu, Apr 18, 2024 at 06:11:38PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >On Thu, Apr 18, 2024 at 05:43:25PM +0200, Jiri Pirko wrote:
> >> Thu, Apr 18, 2024 at 04:46:23PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >> >On Thu, Apr 18, 2024 at 03:02:49PM +0200, Jiri Pirko wrote:
> >> >> Thu, Apr 18, 2024 at 02:48:53PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >> >> >On Thu, Apr 18, 2024 at 02:04:21PM +0200, Jiri Pirko wrote:
> >> >> >> Wed, Apr 17, 2024 at 04:20:25PM CEST, michal.swiatkowski@linux.intel.com wrote:
> >> >> >> >From: Piotr Raczynski <piotr.raczynski@intel.com>
> >> >> >> 
> >> >> >> [...]
> >> >> >> 
> >> >> >> >+/**
> >> >> >> >+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
> >> >> >> >+ * @dev: the device to allocate for
> >> >> >> >+ *
> >> >> >> >+ * Allocate a devlink instance for SF.
> >> >> >> >+ *
> >> >> >> >+ * Return: void pointer to allocated memory
> >> >> >> >+ */
> >> >> >> >+struct ice_sf_priv *ice_allocate_sf(struct device *dev)
> >> >> >> 
> >> >> >> This is devlink instance for SF auxdev. Please make sure it is properly
> >> >> >> linked with the devlink port instance using devl_port_fn_devlink_set()
> >> >> >> See mlx5 implementation for inspiration.
> >> >> >> 
> >> >> >> 
> >> >> >
> >> >> >I am going to do it in the last patchset. I know that it isn't the best
> >> >> 
> >> >> Where? Either I'm blind or you don't do it.
> >> >> 
> >> >> 
> >> >
> >> >You told me to split few patches from first patchset [1]. We agree that
> >> >there will be too many patches for one submission, so I split it into
> >> >3:
> >> >- 1/3 devlink prework (already accepted)
> >> >- 2/3 base subfunction (this patchset)
> >> >- 3/3 port representor refactor to support subfunction (I am going to
> >> >  include it there)
> >> 
> >> Sorry, but how is this relevant to my suggestion to use
> >> devl_port_fn_devlink_set() which you apparently don't?
> >> 
> >
> >Devlink port to link with is introduced in the port representor part.
> >Strange, but it fitted to my splitting. I can move
> >activation/deactivation part also to this patchset (as there is no
> >devlink port to call it on) if you want.
> 
> You have 7 more patches to use in this set. No problem. Please do it all
> at once.
> 

Ok, as whole will still not fit into 15 I sent preparation patchset for
representor [1].

Now the patchset based on this preparation have 14 patches, so I hope it
is fine (including linking that you mentioned). I will send it right
after the preparation patchset is applied.

I am going on the 2 weeks vacation, so my replies will be delayed.

[1] https://lore.kernel.org/netdev/20240419171336.11617-1-michal.swiatkowski@linux.intel.com/T/#t

Thanks,
Michal

> 
> >
> >> 
> >> >
> >> >[1] https://lore.kernel.org/netdev/20240301115414.502097-1-michal.swiatkowski@linux.intel.com/
> >> >
> >> >Thanks,
> >> >Michal
> >> >
> >> >> >option to split patchesets like that, but it was hard to do it differently.
> >> >> >
> >> >> >Thanks,
> >> >> >Michal
> >> >> >
> >> >> >> >+{
> >> >> >> >+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
> >> >> >> >+				 &ice_sf_devlink_ops);
> >> >> >> >+}
> >> >> >> >+
> >> >> >> 
> >> >> >> [...]
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c
index 661af04c8eef..5a78bf08e731 100644
--- a/drivers/net/ethernet/intel/ice/devlink/devlink.c
+++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c
@@ -10,6 +10,7 @@ 
 #include "ice_eswitch.h"
 #include "ice_fw_update.h"
 #include "ice_dcb_lib.h"
+#include "ice_sf_eth.h"
 
 /* context for devlink info version reporting */
 struct ice_info_ctx {
@@ -1286,6 +1287,8 @@  static const struct devlink_ops ice_devlink_ops = {
 	.port_new = ice_devlink_port_new,
 };
 
+static const struct devlink_ops ice_sf_devlink_ops;
+
 static int
 ice_devlink_enable_roce_get(struct devlink *devlink, u32 id,
 			    struct devlink_param_gset_ctx *ctx)
@@ -1417,18 +1420,23 @@  static void ice_devlink_free(void *devlink_ptr)
 }
 
 /**
- * ice_allocate_pf - Allocate devlink and return PF structure pointer
+ * ice_devlink_alloc - Allocate devlink and return devlink priv pointer
  * @dev: the device to allocate for
+ * @priv_size: size of the priv memory
+ * @ops: pointer to devlink ops for this device
+ *
+ * Allocate a devlink instance for this device and return the private pointer
+ * The devlink memory is kept track of through devres by adding an action to
+ * remove it when unwinding.
  *
- * Allocate a devlink instance for this device and return the private area as
- * the PF structure. The devlink memory is kept track of through devres by
- * adding an action to remove it when unwinding.
+ * Return: void pointer to allocated memory
  */
-struct ice_pf *ice_allocate_pf(struct device *dev)
+static void *ice_devlink_alloc(struct device *dev, size_t priv_size,
+			       const struct devlink_ops *ops)
 {
 	struct devlink *devlink;
 
-	devlink = devlink_alloc(&ice_devlink_ops, sizeof(struct ice_pf), dev);
+	devlink = devlink_alloc(ops, priv_size, dev);
 	if (!devlink)
 		return NULL;
 
@@ -1439,6 +1447,33 @@  struct ice_pf *ice_allocate_pf(struct device *dev)
 	return devlink_priv(devlink);
 }
 
+/**
+ * ice_allocate_pf - Allocate devlink and return PF structure pointer
+ * @dev: the device to allocate for
+ *
+ * Allocate a devlink instance for PF.
+ *
+ * Return: void pointer to allocated memory
+ */
+struct ice_pf *ice_allocate_pf(struct device *dev)
+{
+	return ice_devlink_alloc(dev, sizeof(struct ice_pf), &ice_devlink_ops);
+}
+
+/**
+ * ice_allocate_sf - Allocate devlink and return SF structure pointer
+ * @dev: the device to allocate for
+ *
+ * Allocate a devlink instance for SF.
+ *
+ * Return: void pointer to allocated memory
+ */
+struct ice_sf_priv *ice_allocate_sf(struct device *dev)
+{
+	return ice_devlink_alloc(dev, sizeof(struct ice_sf_priv),
+				 &ice_sf_devlink_ops);
+}
+
 /**
  * ice_devlink_register - Register devlink interface for this PF
  * @pf: the PF to register the devlink for.
diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.h b/drivers/net/ethernet/intel/ice/devlink/devlink.h
index d291c0e2e17b..1b2a5980d5e8 100644
--- a/drivers/net/ethernet/intel/ice/devlink/devlink.h
+++ b/drivers/net/ethernet/intel/ice/devlink/devlink.h
@@ -5,6 +5,7 @@ 
 #define _ICE_DEVLINK_H_
 
 struct ice_pf *ice_allocate_pf(struct device *dev);
+struct ice_sf_priv *ice_allocate_sf(struct device *dev);
 
 void ice_devlink_register(struct ice_pf *pf);
 void ice_devlink_unregister(struct ice_pf *pf);
diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
index d80637f945b6..0ab4d687e311 100644
--- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
+++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c
@@ -432,6 +432,56 @@  void ice_devlink_destroy_vf_port(struct ice_vf *vf)
 	devlink_port_unregister(&vf->devlink_port);
 }
 
+/**
+ * ice_devlink_create_sf_dev_port - Register virtual port for a subfunction
+ * @sf_dev: the subfunction device to create a devlink port for
+ *
+ * Register virtual flavour devlink port for the subfunction auxiliary device
+ * created after activating a dynamically added devlink port.
+ *
+ * Return: zero on success or an error code on failure.
+ */
+int ice_devlink_create_sf_dev_port(struct ice_sf_dev *sf_dev)
+{
+	struct devlink_port_attrs attrs = {};
+	struct devlink_port *devlink_port;
+	struct ice_dynamic_port *dyn_port;
+	struct devlink *devlink;
+	struct ice_vsi *vsi;
+	struct device *dev;
+	struct ice_pf *pf;
+	int err;
+
+	dyn_port = sf_dev->dyn_port;
+	vsi = dyn_port->vsi;
+	pf = dyn_port->pf;
+	dev = ice_pf_to_dev(pf);
+
+	devlink_port = &sf_dev->priv->devlink_port;
+
+	attrs.flavour = DEVLINK_PORT_FLAVOUR_VIRTUAL;
+
+	devlink_port_attrs_set(devlink_port, &attrs);
+	devlink = priv_to_devlink(sf_dev->priv);
+
+	err = devl_port_register(devlink, devlink_port, vsi->idx);
+	if (err)
+		dev_err(dev, "Failed to create virtual devlink port for auxiliary subfunction device");
+
+	return err;
+}
+
+/**
+ * ice_devlink_destroy_sf_dev_port - Destroy virtual port for a subfunction
+ * @sf_dev: the subfunction device to create a devlink port for
+ *
+ * Unregisters the virtual port associated with this subfunction.
+ */
+void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev)
+{
+	devl_port_unregister(&sf_dev->priv->devlink_port);
+}
+
 /**
  * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port
  * @dyn_port: dynamic port instance to deallocate
diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
index 196db6806019..33f07cec6bd6 100644
--- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
+++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h
@@ -5,6 +5,7 @@ 
 #define _DEVLINK_PORT_H_
 
 #include "../ice.h"
+#include "ice_sf_eth.h"
 
 /**
  * struct ice_dynamic_port - Track dynamically added devlink port instance
@@ -30,6 +31,8 @@  int ice_devlink_create_pf_port(struct ice_pf *pf);
 void ice_devlink_destroy_pf_port(struct ice_pf *pf);
 int ice_devlink_create_vf_port(struct ice_vf *vf);
 void ice_devlink_destroy_vf_port(struct ice_vf *vf);
+int ice_devlink_create_sf_dev_port(struct ice_sf_dev *sf_dev);
+void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev);
 
 #define ice_devlink_port_to_dyn(p) \
 	container_of(port, struct ice_dynamic_port, devlink_port)
diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.h b/drivers/net/ethernet/intel/ice/ice_sf_eth.h
new file mode 100644
index 000000000000..a08f8b2bceef
--- /dev/null
+++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.h
@@ -0,0 +1,21 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2024, Intel Corporation. */
+
+#ifndef _ICE_SF_ETH_H_
+#define _ICE_SF_ETH_H_
+
+#include <linux/auxiliary_bus.h>
+#include "ice.h"
+
+struct ice_sf_dev {
+	struct auxiliary_device adev;
+	struct ice_dynamic_port *dyn_port;
+	struct ice_sf_priv *priv;
+};
+
+struct ice_sf_priv {
+	struct ice_sf_dev *dev;
+	struct devlink_port devlink_port;
+};
+
+#endif /* _ICE_SF_ETH_H_ */