diff mbox series

[net-next,v3,3/9] octeontx2-pf: Create representor netdev

Message ID 20240428105312.9731-4-gakula@marvell.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Introduce RVU representors | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang fail Errors and warnings before: 937 this patch: 943
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 950 this patch: 956
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 83 exceeds 80 columns WARNING: line length of 90 exceeds 80 columns WARNING: line length of 93 exceeds 80 columns WARNING: line length of 95 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Geetha sowjanya April 28, 2024, 10:53 a.m. UTC
Adds initial devlink support to set/get the switchdev mode.
Representor netdevs are created for each rvu devices when
the switch mode is set to 'switchdev'. These netdevs are
be used to control and configure VFs.

Signed-off-by: Geetha sowjanya <gakula@marvell.com>
---
 .../marvell/octeontx2/nic/otx2_devlink.c      |  51 ++++++
 .../net/ethernet/marvell/octeontx2/nic/rep.c  | 156 ++++++++++++++++++
 .../net/ethernet/marvell/octeontx2/nic/rep.h  |   2 +
 3 files changed, 209 insertions(+)

Comments

Jiri Pirko April 29, 2024, 11:33 a.m. UTC | #1
Sun, Apr 28, 2024 at 12:53:06PM CEST, gakula@marvell.com wrote:
>Adds initial devlink support to set/get the switchdev mode.
>Representor netdevs are created for each rvu devices when
>the switch mode is set to 'switchdev'. These netdevs are
>be used to control and configure VFs.
>
>Signed-off-by: Geetha sowjanya <gakula@marvell.com>


Are you still missing creating of devlink port as I requested? Why?
Geetha sowjanya April 29, 2024, 4:13 p.m. UTC | #2
> -----Original Message-----
> From: Jiri Pirko <jiri@resnulli.us>
> Sent: Monday, April 29, 2024 5:03 PM
> To: Geethasowjanya Akula <gakula@marvell.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kuba@kernel.org;
> davem@davemloft.net; pabeni@redhat.com; edumazet@google.com; Sunil
> Kovvuri Goutham <sgoutham@marvell.com>; Subbaraya Sundeep Bhatta
> <sbhatta@marvell.com>; Hariprasad Kelam <hkelam@marvell.com>
> Subject: [EXTERNAL] Re: [net-next PATCH v3 3/9] octeontx2-pf: Create
> representor netdev
> 
> Prioritize security for external emails: Confirm sender and content safety
> before clicking links or opening attachments
> 
> ----------------------------------------------------------------------
> Sun, Apr 28, 2024 at 12:53:06PM CEST, gakula@marvell.com wrote:
> >Adds initial devlink support to set/get the switchdev mode.
> >Representor netdevs are created for each rvu devices when the switch
> >mode is set to 'switchdev'. These netdevs are be used to control and
> >configure VFs.
> >
> >Signed-off-by: Geetha sowjanya <gakula@marvell.com>
> 
> 
> Are you still missing creating of devlink port as I requested? Why?
Sorry I missed your comment on earlier patchset.
Wrt adding devlink port support, our plan is to get the initial patchset reviewed and then add 'devlink port' support.
Will submit 'devlink port' support as a follow-up patch series.
Jiri Pirko April 30, 2024, 6:57 a.m. UTC | #3
Mon, Apr 29, 2024 at 06:13:56PM CEST, gakula@marvell.com wrote:
>
>
>> -----Original Message-----
>> From: Jiri Pirko <jiri@resnulli.us>
>> Sent: Monday, April 29, 2024 5:03 PM
>> To: Geethasowjanya Akula <gakula@marvell.com>
>> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kuba@kernel.org;
>> davem@davemloft.net; pabeni@redhat.com; edumazet@google.com; Sunil
>> Kovvuri Goutham <sgoutham@marvell.com>; Subbaraya Sundeep Bhatta
>> <sbhatta@marvell.com>; Hariprasad Kelam <hkelam@marvell.com>
>> Subject: [EXTERNAL] Re: [net-next PATCH v3 3/9] octeontx2-pf: Create
>> representor netdev
>> 
>> Prioritize security for external emails: Confirm sender and content safety
>> before clicking links or opening attachments
>> 
>> ----------------------------------------------------------------------
>> Sun, Apr 28, 2024 at 12:53:06PM CEST, gakula@marvell.com wrote:
>> >Adds initial devlink support to set/get the switchdev mode.
>> >Representor netdevs are created for each rvu devices when the switch
>> >mode is set to 'switchdev'. These netdevs are be used to control and
>> >configure VFs.
>> >
>> >Signed-off-by: Geetha sowjanya <gakula@marvell.com>
>> 
>> 
>> Are you still missing creating of devlink port as I requested? Why?
>Sorry I missed your comment on earlier patchset.
>Wrt adding devlink port support, our plan is to get the initial patchset reviewed and then add 'devlink port' support.

You need to do it in this patchset. Rep netdev without devlink port is
unacceptable from my perspective. Thanks!


>Will submit 'devlink port' support as a follow-up patch series.
Geetha sowjanya April 30, 2024, 3:17 p.m. UTC | #4
> -----Original Message-----
> From: Jiri Pirko <jiri@resnulli.us>
> Sent: Tuesday, April 30, 2024 12:27 PM
> To: Geethasowjanya Akula <gakula@marvell.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kuba@kernel.org;
> davem@davemloft.net; pabeni@redhat.com; edumazet@google.com; Sunil
> Kovvuri Goutham <sgoutham@marvell.com>; Subbaraya Sundeep Bhatta
> <sbhatta@marvell.com>; Hariprasad Kelam <hkelam@marvell.com>
> Subject: Re: [EXTERNAL] Re: [net-next PATCH v3 3/9] octeontx2-pf: Create
> representor netdev
> 
> Mon, Apr 29, 2024 at 06:13:56PM CEST, gakula@marvell.com wrote:
> >
> >
> >> -----Original Message-----
> >> From: Jiri Pirko <jiri@resnulli.us>
> >> Sent: Monday, April 29, 2024 5:03 PM
> >> To: Geethasowjanya Akula <gakula@marvell.com>
> >> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
> >> kuba@kernel.org; davem@davemloft.net; pabeni@redhat.com;
> >> edumazet@google.com; Sunil Kovvuri Goutham
> <sgoutham@marvell.com>;
> >> Subbaraya Sundeep Bhatta <sbhatta@marvell.com>; Hariprasad Kelam
> >> <hkelam@marvell.com>
> >> Subject: [EXTERNAL] Re: [net-next PATCH v3 3/9] octeontx2-pf: Create
> >> representor netdev
> >>
> >> Prioritize security for external emails: Confirm sender and content
> >> safety before clicking links or opening attachments
> >>
> >> ---------------------------------------------------------------------
> >> - Sun, Apr 28, 2024 at 12:53:06PM CEST, gakula@marvell.com wrote:
> >> >Adds initial devlink support to set/get the switchdev mode.
> >> >Representor netdevs are created for each rvu devices when the switch
> >> >mode is set to 'switchdev'. These netdevs are be used to control and
> >> >configure VFs.
> >> >
> >> >Signed-off-by: Geetha sowjanya <gakula@marvell.com>
> >>
> >>
> >> Are you still missing creating of devlink port as I requested? Why?
> >Sorry I missed your comment on earlier patchset.
> >Wrt adding devlink port support, our plan is to get the initial patchset
> reviewed and then add 'devlink port' support.
> 
> You need to do it in this patchset. Rep netdev without devlink port is
> unacceptable from my perspective. Thanks!
Ok. Will add devlink port support and submit next version.
> 
> 
> >Will submit 'devlink port' support as a follow-up patch series.
Simon Horman May 1, 2024, 6:06 p.m. UTC | #5
+ Dan Carpenter

On Sun, Apr 28, 2024 at 04:23:06PM +0530, Geetha sowjanya wrote:
> Adds initial devlink support to set/get the switchdev mode.
> Representor netdevs are created for each rvu devices when
> the switch mode is set to 'switchdev'. These netdevs are
> be used to control and configure VFs.
> 
> Signed-off-by: Geetha sowjanya <gakula@marvell.com>

Hi Geetha,

Some minor feedback from my side.

...

> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c

...

> +int rvu_rep_create(struct otx2_nic *priv, struct netlink_ext_ack *extack)
> +{
> +	int rep_cnt = priv->rep_cnt;
> +	struct net_device *ndev;
> +	struct rep_dev *rep;
> +	int rep_id, err;
> +	u16 pcifunc;
> +
> +	priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);

It looks like the size argument should be sizeof(struct rep_dev *)
or sizeof(*priv->reps).

Flagged by Coccinelle.

Please consider limiting lines in Networking code to 80 columns wide
where it can be achieved without too much bother.

> +	if (!priv->reps)
> +		return -ENOMEM;
> +
> +	for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
> +		ndev = alloc_etherdev(sizeof(*rep));
> +		if (!ndev) {
> +			NL_SET_ERR_MSG_FMT_MOD(extack, "PFVF representor:%d creation failed\n",
> +					       rep_id);
> +			err = -ENOMEM;
> +			goto exit;
> +		}
> +
> +		rep = netdev_priv(ndev);
> +		priv->reps[rep_id] = rep;
> +		rep->mdev = priv;
> +		rep->netdev = ndev;
> +		rep->rep_id = rep_id;
> +
> +		ndev->min_mtu = OTX2_MIN_MTU;
> +		ndev->max_mtu = priv->hw.max_mtu;
> +		pcifunc = priv->rep_pf_map[rep_id];
> +		rep->pcifunc = pcifunc;
> +
> +		snprintf(ndev->name, sizeof(ndev->name), "r%dp%d", rep_id,
> +			 rvu_get_pf(pcifunc));
> +
> +		eth_hw_addr_random(ndev);
> +		err = register_netdev(ndev);
> +		if (err) {
> +			NL_SET_ERR_MSG_MOD(extack, "PFVF reprentator registration failed\n");

I don't think the string passed to NL_SET_ERR_MSG_MOD needs a trailing '\n'.
I'm unsure if this also applies to NL_SET_ERR_MSG_FMT_MOD or not.

Flagged by Coccinelle.


The current ndev appears to be leaked here,
as it does not appear to be covered by the unwind loop below.

I think this can be resolved using:

			free_netdev(ndev);

> +			goto exit;
> +		}
> +	}
> +	err = rvu_rep_napi_init(priv, extack);
> +	if (err)
> +		goto exit;

Even with the above fixed, Smatch complains that:

.../rep.c:180 rvu_rep_create() warn: 'ndev' from alloc_etherdev_mqs() not released on lines: 180.
.../rep.c:180 rvu_rep_create() warn: 'ndev' from register_netdev() not released on lines: 180.

Where line 180 is the very last line of the funciton: return err;

I think this is triggered by the error handling above.
However, I also think it is a false positive.
I've CCed Dan Carpenter as I'd value a second opinion on this one.

> +
> +	return 0;
> +exit:
> +	while (--rep_id >= 0) {
> +		rep = priv->reps[rep_id];
> +		unregister_netdev(rep->netdev);
> +		free_netdev(rep->netdev);
> +	}
> +	return err;
> +}

...
Simon Horman May 1, 2024, 6:18 p.m. UTC | #6
On Sun, Apr 28, 2024 at 04:23:06PM +0530, Geetha sowjanya wrote:
> Adds initial devlink support to set/get the switchdev mode.
> Representor netdevs are created for each rvu devices when
> the switch mode is set to 'switchdev'. These netdevs are
> be used to control and configure VFs.
> 
> Signed-off-by: Geetha sowjanya <gakula@marvell.com>

Hi again,

I missed the following when preparing my previous email.

...

> @@ -113,6 +162,7 @@ int otx2_register_dl(struct otx2_nic *pfvf)
>  	devlink_free(dl);
>  	return err;
>  }
> +EXPORT_SYMBOL(otx2_register_dl);
>  
>  void otx2_unregister_dl(struct otx2_nic *pfvf)
>  {
> @@ -124,3 +174,4 @@ void otx2_unregister_dl(struct otx2_nic *pfvf)
>  				  ARRAY_SIZE(otx2_dl_params));
>  	devlink_free(dl);
>  }
> +EXPORT_SYMBOL(otx2_unregister_dl);

otx2_devlink.o is linked into both rvu_nicpf.ko and rvu_nicpf.ko.
The two exports above result in the following errors when building
with allmodconfig on x86_64

 ERROR: modpost: drivers/net/ethernet/marvell/octeontx2/nic/rvu_nicvf: 'otx2_register_dl' exported twice. Previous export was in drivers/net/ethernet/marvell/octeontx2/nic/rvu_nicpf.ko
 ERROR: modpost: drivers/net/ethernet/marvell/octeontx2/nic/rvu_nicvf: 'otx2_unregister_dl' exported twice. Previous export was in drivers/net/ethernet/marvell/octeontx2/nic/rvu_nicpf.ko

...
Dan Carpenter May 2, 2024, 7:01 a.m. UTC | #7
On Wed, May 01, 2024 at 07:06:56PM +0100, Simon Horman wrote:
> > +			goto exit;
> > +		}
> > +	}
> > +	err = rvu_rep_napi_init(priv, extack);
> > +	if (err)
> > +		goto exit;
> 
> Even with the above fixed, Smatch complains that:
> 
> .../rep.c:180 rvu_rep_create() warn: 'ndev' from alloc_etherdev_mqs() not released on lines: 180.
> .../rep.c:180 rvu_rep_create() warn: 'ndev' from register_netdev() not released on lines: 180.
> 
> Where line 180 is the very last line of the funciton: return err;
> 
> I think this is triggered by the error handling above.
> However, I also think it is a false positive.
> I've CCed Dan Carpenter as I'd value a second opinion on this one.
> 

Yeah.  It's a false positive.

regards,
dan carpenter
Geetha sowjanya May 3, 2024, 6:27 a.m. UTC | #8
> -----Original Message-----
> From: Simon Horman <horms@kernel.org>
> Sent: Wednesday, May 1, 2024 11:37 PM
> To: Geethasowjanya Akula <gakula@marvell.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kuba@kernel.org;
> davem@davemloft.net; pabeni@redhat.com; edumazet@google.com; Sunil
> Kovvuri Goutham <sgoutham@marvell.com>; Subbaraya Sundeep Bhatta
> <sbhatta@marvell.com>; Hariprasad Kelam <hkelam@marvell.com>; Dan
> Carpenter <dan.carpenter@linaro.org>
> Subject: [EXTERNAL] Re: [net-next PATCH v3 3/9] octeontx2-pf: Create
> representor netdev
> 
> ----------------------------------------------------------------------
> + Dan Carpenter
> 
> On Sun, Apr 28, 2024 at 04:23:06PM +0530, Geetha sowjanya wrote:
> > Adds initial devlink support to set/get the switchdev mode.
> > Representor netdevs are created for each rvu devices when the switch
> > mode is set to 'switchdev'. These netdevs are be used to control and
> > configure VFs.
> >
> > Signed-off-by: Geetha sowjanya <gakula@marvell.com>
> 
> Hi Geetha,
> 
> Some minor feedback from my side.
> 
> ...
> 
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> > b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> 
> ...
> 
> > +int rvu_rep_create(struct otx2_nic *priv, struct netlink_ext_ack
> > +*extack) {
> > +	int rep_cnt = priv->rep_cnt;
> > +	struct net_device *ndev;
> > +	struct rep_dev *rep;
> > +	int rep_id, err;
> > +	u16 pcifunc;
> > +
> > +	priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct
> > +rep_dev), GFP_KERNEL);
> 
> It looks like the size argument should be sizeof(struct rep_dev *) or
> sizeof(*priv->reps).
> 
> Flagged by Coccinelle.
> 
> Please consider limiting lines in Networking code to 80 columns wide where it
> can be achieved without too much bother.
Ack. Will fix it in next version.
> 
> > +	if (!priv->reps)
> > +		return -ENOMEM;
> > +
> > +	for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
> > +		ndev = alloc_etherdev(sizeof(*rep));
> > +		if (!ndev) {
> > +			NL_SET_ERR_MSG_FMT_MOD(extack, "PFVF
> representor:%d creation failed\n",
> > +					       rep_id);
> > +			err = -ENOMEM;
> > +			goto exit;
> > +		}
> > +
> > +		rep = netdev_priv(ndev);
> > +		priv->reps[rep_id] = rep;
> > +		rep->mdev = priv;
> > +		rep->netdev = ndev;
> > +		rep->rep_id = rep_id;
> > +
> > +		ndev->min_mtu = OTX2_MIN_MTU;
> > +		ndev->max_mtu = priv->hw.max_mtu;
> > +		pcifunc = priv->rep_pf_map[rep_id];
> > +		rep->pcifunc = pcifunc;
> > +
> > +		snprintf(ndev->name, sizeof(ndev->name), "r%dp%d", rep_id,
> > +			 rvu_get_pf(pcifunc));
> > +
> > +		eth_hw_addr_random(ndev);
> > +		err = register_netdev(ndev);
> > +		if (err) {
> > +			NL_SET_ERR_MSG_MOD(extack, "PFVF reprentator
> registration
> > +failed\n");
> 
> I don't think the string passed to NL_SET_ERR_MSG_MOD needs a trailing
> '\n'.
> I'm unsure if this also applies to NL_SET_ERR_MSG_FMT_MOD or not.
Ack.
> 
> Flagged by Coccinelle.
> 
> 
> The current ndev appears to be leaked here, as it does not appear to be
> covered by the unwind loop below.
> 
> I think this can be resolved using:
> 
> 			free_netdev(ndev);
> 
> > +			goto exit;
> > +		}
> > +	}
> > +	err = rvu_rep_napi_init(priv, extack);
> > +	if (err)
> > +		goto exit;
> 
> Even with the above fixed, Smatch complains that:
> 
> .../rep.c:180 rvu_rep_create() warn: 'ndev' from alloc_etherdev_mqs() not
> released on lines: 180.
> .../rep.c:180 rvu_rep_create() warn: 'ndev' from register_netdev() not
> released on lines: 180.
> 
> Where line 180 is the very last line of the funciton: return err;
> 
> I think this is triggered by the error handling above.
> However, I also think it is a false positive.
> I've CCed Dan Carpenter as I'd value a second opinion on this one.
> 
> > +
> > +	return 0;
> > +exit:
> > +	while (--rep_id >= 0) {
> > +		rep = priv->reps[rep_id];
> > +		unregister_netdev(rep->netdev);
> > +		free_netdev(rep->netdev);
> > +	}
> > +	return err;
> > +}
> 
> ...
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
index 99ddf31269d9..79ad824fd185 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
@@ -77,7 +77,56 @@  static const struct devlink_param otx2_dl_params[] = {
 			     otx2_dl_mcam_count_validate),
 };
 
+#ifdef CONFIG_RVU_ESWITCH
+static int otx2_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
+{
+	struct otx2_devlink *otx2_dl = devlink_priv(devlink);
+	struct otx2_nic *pfvf = otx2_dl->pfvf;
+
+	if (!otx2_rep_dev(pfvf->pdev))
+		return -EOPNOTSUPP;
+
+	*mode = pfvf->esw_mode;
+
+	return 0;
+}
+
+static int otx2_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
+					 struct netlink_ext_ack *extack)
+{
+	struct otx2_devlink *otx2_dl = devlink_priv(devlink);
+	struct otx2_nic *pfvf = otx2_dl->pfvf;
+	int ret = 0;
+
+	if (!otx2_rep_dev(pfvf->pdev))
+		return -EOPNOTSUPP;
+
+	if (pfvf->esw_mode == mode)
+		return 0;
+
+	switch (mode) {
+	case DEVLINK_ESWITCH_MODE_LEGACY:
+		rvu_rep_destroy(pfvf);
+		break;
+	case DEVLINK_ESWITCH_MODE_SWITCHDEV:
+		ret = rvu_rep_create(pfvf, extack);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (!ret)
+		pfvf->esw_mode = mode;
+
+	return ret;
+}
+#endif
+
 static const struct devlink_ops otx2_devlink_ops = {
+#ifdef CONFIG_RVU_ESWITCH
+	.eswitch_mode_get = otx2_devlink_eswitch_mode_get,
+	.eswitch_mode_set = otx2_devlink_eswitch_mode_set,
+#endif
 };
 
 int otx2_register_dl(struct otx2_nic *pfvf)
@@ -113,6 +162,7 @@  int otx2_register_dl(struct otx2_nic *pfvf)
 	devlink_free(dl);
 	return err;
 }
+EXPORT_SYMBOL(otx2_register_dl);
 
 void otx2_unregister_dl(struct otx2_nic *pfvf)
 {
@@ -124,3 +174,4 @@  void otx2_unregister_dl(struct otx2_nic *pfvf)
 				  ARRAY_SIZE(otx2_dl_params));
 	devlink_free(dl);
 }
+EXPORT_SYMBOL(otx2_unregister_dl);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
index e570c2bd4ab2..c66ae39e4e23 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
@@ -28,6 +28,156 @@  MODULE_DESCRIPTION(DRV_STRING);
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);
 
+static int rvu_rep_napi_init(struct otx2_nic *priv, struct netlink_ext_ack *extack)
+{
+	struct otx2_cq_poll *cq_poll = NULL;
+	struct otx2_qset *qset = &priv->qset;
+	struct otx2_hw *hw = &priv->hw;
+	int err = 0, qidx, vec;
+	char *irq_name;
+
+	qset->napi = kcalloc(hw->cint_cnt, sizeof(*cq_poll), GFP_KERNEL);
+	if (!qset->napi)
+		return -ENOMEM;
+
+	/* Register NAPI handler */
+	for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
+		cq_poll = &qset->napi[qidx];
+		cq_poll->cint_idx = qidx;
+		cq_poll->cq_ids[CQ_RX] =
+			(qidx <  hw->rx_queues) ? qidx : CINT_INVALID_CQ;
+		cq_poll->cq_ids[CQ_TX] = (qidx < hw->tx_queues) ?
+					  qidx + hw->rx_queues : CINT_INVALID_CQ;
+		cq_poll->cq_ids[CQ_XDP] = CINT_INVALID_CQ;
+		cq_poll->cq_ids[CQ_QOS] = CINT_INVALID_CQ;
+
+		cq_poll->dev = (void *)priv;
+		netif_napi_add(priv->reps[qidx]->netdev, &cq_poll->napi,
+			       otx2_napi_handler);
+		napi_enable(&cq_poll->napi);
+	}
+	/* Register CQ IRQ handlers */
+	vec = hw->nix_msixoff + NIX_LF_CINT_VEC_START;
+	for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
+		irq_name = &hw->irq_name[vec * NAME_SIZE];
+
+		snprintf(irq_name, NAME_SIZE, "rep%d-rxtx-%d", qidx, qidx);
+
+		err = request_irq(pci_irq_vector(priv->pdev, vec),
+				  otx2_cq_intr_handler, 0, irq_name,
+				  &qset->napi[qidx]);
+		if (err) {
+			NL_SET_ERR_MSG_FMT_MOD(extack,
+					       "RVU REP IRQ registration failed for CQ%d\n",
+						qidx);
+			goto err_free_cints;
+		}
+		vec++;
+
+		/* Enable CQ IRQ */
+		otx2_write64(priv, NIX_LF_CINTX_INT(qidx), BIT_ULL(0));
+		otx2_write64(priv, NIX_LF_CINTX_ENA_W1S(qidx), BIT_ULL(0));
+	}
+	priv->flags &= ~OTX2_FLAG_INTF_DOWN;
+	return 0;
+
+err_free_cints:
+	otx2_free_cints(priv, qidx);
+	otx2_disable_napi(priv);
+	return err;
+}
+
+static void rvu_rep_free_cq_rsrc(struct otx2_nic *priv)
+{
+	struct otx2_cq_poll *cq_poll = NULL;
+	struct otx2_qset *qset = &priv->qset;
+	int qidx, vec;
+
+	/* Cleanup CQ NAPI and IRQ */
+	vec = priv->hw.nix_msixoff + NIX_LF_CINT_VEC_START;
+	for (qidx = 0; qidx < priv->hw.cint_cnt; qidx++) {
+		/* Disable interrupt */
+		otx2_write64(priv, NIX_LF_CINTX_ENA_W1C(qidx), BIT_ULL(0));
+
+		synchronize_irq(pci_irq_vector(priv->pdev, vec));
+
+		cq_poll = &qset->napi[qidx];
+		napi_synchronize(&cq_poll->napi);
+		vec++;
+	}
+	otx2_free_cints(priv, priv->hw.cint_cnt);
+	otx2_disable_napi(priv);
+}
+
+void rvu_rep_destroy(struct otx2_nic *priv)
+{
+	struct rep_dev *rep;
+	int rep_id;
+
+	rvu_rep_free_cq_rsrc(priv);
+	for (rep_id = 0; rep_id < priv->rep_cnt; rep_id++) {
+		rep = priv->reps[rep_id];
+		unregister_netdev(rep->netdev);
+		free_netdev(rep->netdev);
+	}
+}
+
+int rvu_rep_create(struct otx2_nic *priv, struct netlink_ext_ack *extack)
+{
+	int rep_cnt = priv->rep_cnt;
+	struct net_device *ndev;
+	struct rep_dev *rep;
+	int rep_id, err;
+	u16 pcifunc;
+
+	priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);
+	if (!priv->reps)
+		return -ENOMEM;
+
+	for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
+		ndev = alloc_etherdev(sizeof(*rep));
+		if (!ndev) {
+			NL_SET_ERR_MSG_FMT_MOD(extack, "PFVF representor:%d creation failed\n",
+					       rep_id);
+			err = -ENOMEM;
+			goto exit;
+		}
+
+		rep = netdev_priv(ndev);
+		priv->reps[rep_id] = rep;
+		rep->mdev = priv;
+		rep->netdev = ndev;
+		rep->rep_id = rep_id;
+
+		ndev->min_mtu = OTX2_MIN_MTU;
+		ndev->max_mtu = priv->hw.max_mtu;
+		pcifunc = priv->rep_pf_map[rep_id];
+		rep->pcifunc = pcifunc;
+
+		snprintf(ndev->name, sizeof(ndev->name), "r%dp%d", rep_id,
+			 rvu_get_pf(pcifunc));
+
+		eth_hw_addr_random(ndev);
+		err = register_netdev(ndev);
+		if (err) {
+			NL_SET_ERR_MSG_MOD(extack, "PFVF reprentator registration failed\n");
+			goto exit;
+		}
+	}
+	err = rvu_rep_napi_init(priv, extack);
+	if (err)
+		goto exit;
+
+	return 0;
+exit:
+	while (--rep_id >= 0) {
+		rep = priv->reps[rep_id];
+		unregister_netdev(rep->netdev);
+		free_netdev(rep->netdev);
+	}
+	return err;
+}
+
 static int rvu_rep_rsrc_free(struct otx2_nic *priv)
 {
 	struct otx2_qset *qset = &priv->qset;
@@ -163,6 +313,10 @@  static int rvu_rep_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (err)
 		goto err_detach_rsrc;
 
+	err = otx2_register_dl(priv);
+	if (err)
+		goto err_detach_rsrc;
+
 	return 0;
 
 err_detach_rsrc:
@@ -184,6 +338,8 @@  static void rvu_rep_remove(struct pci_dev *pdev)
 {
 	struct otx2_nic *priv = pci_get_drvdata(pdev);
 
+	otx2_unregister_dl(priv);
+	rvu_rep_destroy(priv);
 	rvu_rep_rsrc_free(priv);
 	otx2_detach_resources(&priv->mbox);
 	if (priv->hw.lmt_info)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
index 9b3734146dd1..c04874c4d4c6 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.h
@@ -29,4 +29,6 @@  static inline bool otx2_rep_dev(struct pci_dev *pdev)
 	return pdev->device == PCI_DEVID_RVU_REP;
 }
 
+int rvu_rep_create(struct otx2_nic *priv, struct netlink_ext_ack *extack);
+void rvu_rep_destroy(struct otx2_nic *priv);
 #endif /* REP_H */