mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net: mana: Add support for Multi Vports on Bare metal
@ 2025-05-16 19:51 Haiyang Zhang
  2025-05-16 20:57 ` ALOK TIWARI
  0 siblings, 1 reply; 3+ messages in thread
From: Haiyang Zhang @ 2025-05-16 19:51 UTC (permalink / raw)
  To: linux-hyperv, netdev
  Cc: haiyangz, decui, stephen, kys, paulros, olaf, vkuznets, davem,
	wei.liu, edumazet, kuba, pabeni, leon, longli, ssengar,
	linux-rdma, daniel, john.fastabend, bpf, ast, hawk, tglx,
	shradhagupta, andrew+netdev, kotaranov, horms, linux-kernel

To support Multi Vports on Bare metal, increase the device config response
version. And, skip the register HW vport, and register filter steps, when
the Bare metal hostmode is set.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/ethernet/microsoft/mana/mana_en.c | 22 +++++++++++++------
 include/net/mana/mana.h                       |  4 +++-
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 2bac6be8f6a0..0273696d254b 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -921,7 +921,7 @@ static void mana_pf_deregister_filter(struct mana_port_context *apc)
 
 static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,
 				 u32 proto_minor_ver, u32 proto_micro_ver,
-				 u16 *max_num_vports)
+				 u16 *max_num_vports, u8 *bm_hostmode)
 {
 	struct gdma_context *gc = ac->gdma_dev->gdma_context;
 	struct mana_query_device_cfg_resp resp = {};
@@ -932,7 +932,7 @@ static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,
 	mana_gd_init_req_hdr(&req.hdr, MANA_QUERY_DEV_CONFIG,
 			     sizeof(req), sizeof(resp));
 
-	req.hdr.resp.msg_version = GDMA_MESSAGE_V2;
+	req.hdr.resp.msg_version = GDMA_MESSAGE_V3;
 
 	req.proto_major_ver = proto_major_ver;
 	req.proto_minor_ver = proto_minor_ver;
@@ -961,6 +961,11 @@ static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,
 	else
 		gc->adapter_mtu = ETH_FRAME_LEN;
 
+	if (resp.hdr.response.msg_version == GDMA_MESSAGE_V3)
+		*bm_hostmode = resp.bm_hostmode;
+	else
+		*bm_hostmode = 0;
+
 	debugfs_create_u16("adapter-MTU", 0400, gc->mana_pci_debugfs, &gc->adapter_mtu);
 
 	return 0;
@@ -2441,7 +2446,7 @@ static void mana_destroy_vport(struct mana_port_context *apc)
 	mana_destroy_txq(apc);
 	mana_uncfg_vport(apc);
 
-	if (gd->gdma_context->is_pf)
+	if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode)
 		mana_pf_deregister_hw_vport(apc);
 }
 
@@ -2453,7 +2458,7 @@ static int mana_create_vport(struct mana_port_context *apc,
 
 	apc->default_rxobj = INVALID_MANA_HANDLE;
 
-	if (gd->gdma_context->is_pf) {
+	if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode) {
 		err = mana_pf_register_hw_vport(apc);
 		if (err)
 			return err;
@@ -2689,7 +2694,7 @@ int mana_alloc_queues(struct net_device *ndev)
 		goto destroy_vport;
 	}
 
-	if (gd->gdma_context->is_pf) {
+	if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode) {
 		err = mana_pf_register_filter(apc);
 		if (err)
 			goto destroy_vport;
@@ -2751,7 +2756,7 @@ static int mana_dealloc_queues(struct net_device *ndev)
 
 	mana_chn_setxdp(apc, NULL);
 
-	if (gd->gdma_context->is_pf)
+	if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode)
 		mana_pf_deregister_filter(apc);
 
 	/* No packet can be transmitted now since apc->port_is_up is false.
@@ -2998,6 +3003,7 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
 	struct gdma_context *gc = gd->gdma_context;
 	struct mana_context *ac = gd->driver_data;
 	struct device *dev = gc->dev;
+	u8 bm_hostmode = 0;
 	u16 num_ports = 0;
 	int err;
 	int i;
@@ -3026,10 +3032,12 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
 	}
 
 	err = mana_query_device_cfg(ac, MANA_MAJOR_VERSION, MANA_MINOR_VERSION,
-				    MANA_MICRO_VERSION, &num_ports);
+				    MANA_MICRO_VERSION, &num_ports, &bm_hostmode);
 	if (err)
 		goto out;
 
+	ac->bm_hostmode = bm_hostmode;
+
 	if (!resuming) {
 		ac->num_ports = num_ports;
 	} else {
diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index 0f78065de8fe..b352d2a7118e 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -408,6 +408,7 @@ struct mana_context {
 	struct gdma_dev *gdma_dev;
 
 	u16 num_ports;
+	u8 bm_hostmode; /* Bare Metal Host Mode Enabled */
 
 	struct mana_eq *eqs;
 	struct dentry *mana_eqs_debugfs;
@@ -557,7 +558,8 @@ struct mana_query_device_cfg_resp {
 	u64 pf_cap_flags4;
 
 	u16 max_num_vports;
-	u16 reserved;
+	u8 bm_hostmode; /* response v3: Bare Metal Host Mode Enabled */
+	u8 reserved;
 	u32 max_num_eqs;
 
 	/* response v2: */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: mana: Add support for Multi Vports on Bare metal
  2025-05-16 19:51 [PATCH net-next] net: mana: Add support for Multi Vports on Bare metal Haiyang Zhang
@ 2025-05-16 20:57 ` ALOK TIWARI
  2025-05-16 21:45   ` [EXTERNAL] " Haiyang Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: ALOK TIWARI @ 2025-05-16 20:57 UTC (permalink / raw)
  To: Haiyang Zhang, linux-hyperv, netdev
  Cc: decui, stephen, kys, paulros, olaf, vkuznets, davem, wei.liu,
	edumazet, kuba, pabeni, leon, longli, ssengar, linux-rdma,
	daniel, john.fastabend, bpf, ast, hawk, tglx, shradhagupta,
	andrew+netdev, kotaranov, horms, linux-kernel



On 17-05-2025 01:21, Haiyang Zhang wrote:
> To support Multi Vports on Bare metal, increase the device config response
> version. And, skip the register HW vport, and register filter steps, when
> the Bare metal hostmode is set.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>   drivers/net/ethernet/microsoft/mana/mana_en.c | 22 +++++++++++++------
>   include/net/mana/mana.h                       |  4 +++-
>   2 files changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 2bac6be8f6a0..0273696d254b 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -921,7 +921,7 @@ static void mana_pf_deregister_filter(struct mana_port_context *apc)
>   
[snip]
> +	u8 bm_hostmode = 0;
>   	u16 num_ports = 0;
>   	int err;
>   	int i;
> @@ -3026,10 +3032,12 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
>   	}
>   
>   	err = mana_query_device_cfg(ac, MANA_MAJOR_VERSION, MANA_MINOR_VERSION,
> -				    MANA_MICRO_VERSION, &num_ports);
> +				    MANA_MICRO_VERSION, &num_ports, &bm_hostmode);
>   	if (err)
>   		goto out;
>   
> +	ac->bm_hostmode = bm_hostmode;
> +
>   	if (!resuming) {
>   		ac->num_ports = num_ports;
>   	} else {
> diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
> index 0f78065de8fe..b352d2a7118e 100644
> --- a/include/net/mana/mana.h
> +++ b/include/net/mana/mana.h
> @@ -408,6 +408,7 @@ struct mana_context {
>   	struct gdma_dev *gdma_dev;
>   
>   	u16 num_ports;
> +	u8 bm_hostmode; /* Bare Metal Host Mode Enabled */

what about maintaining natural alignment, +u8 reserved0 ?

/* +response v3: Bare Metal Host Mode Enabled */ for consistency.
Even though this comment is optional here.
>   
>   	struct mana_eq *eqs;
>   	struct dentry *mana_eqs_debugfs;
> @@ -557,7 +558,8 @@ struct mana_query_device_cfg_resp {
>   	u64 pf_cap_flags4;
>   
>   	u16 max_num_vports;
> -	u16 reserved;
> +	u8 bm_hostmode; /* response v3: Bare Metal Host Mode Enabled */
> +	u8 reserved;
>   	u32 max_num_eqs;
>   
>   	/* response v2: */


Thanks,
Alok

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [EXTERNAL] Re: [PATCH net-next] net: mana: Add support for Multi Vports on Bare metal
  2025-05-16 20:57 ` ALOK TIWARI
@ 2025-05-16 21:45   ` Haiyang Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Haiyang Zhang @ 2025-05-16 21:45 UTC (permalink / raw)
  To: ALOK TIWARI, linux-hyperv, netdev
  Cc: Dexuan Cui, stephen, KY Srinivasan, Paul Rosswurm, olaf,
	vkuznets, davem, wei.liu, edumazet, kuba, pabeni, leon, Long Li,
	ssengar, linux-rdma, daniel, john.fastabend, bpf, ast, hawk,
	tglx, shradhagupta, andrew+netdev, Konstantin Taranov, horms,
	linux-kernel



> -----Original Message-----
> From: ALOK TIWARI <alok.a.tiwari@oracle.com>
> Sent: Friday, May 16, 2025 4:57 PM
> To: Haiyang Zhang <haiyangz@microsoft.com>; linux-hyperv@vger.kernel.org;
> netdev@vger.kernel.org
> Cc: Dexuan Cui <decui@microsoft.com>; stephen@networkplumber.org; KY
> Srinivasan <kys@microsoft.com>; Paul Rosswurm <paulros@microsoft.com>;
> olaf@aepfle.de; vkuznets@redhat.com; davem@davemloft.net;
> wei.liu@kernel.org; edumazet@google.com; kuba@kernel.org;
> pabeni@redhat.com; leon@kernel.org; Long Li <longli@microsoft.com>;
> ssengar@linux.microsoft.com; linux-rdma@vger.kernel.org;
> daniel@iogearbox.net; john.fastabend@gmail.com; bpf@vger.kernel.org;
> ast@kernel.org; hawk@kernel.org; tglx@linutronix.de;
> shradhagupta@linux.microsoft.com; andrew+netdev@lunn.ch; Konstantin
> Taranov <kotaranov@microsoft.com>; horms@kernel.org; linux-
> kernel@vger.kernel.org
> Subject: [EXTERNAL] Re: [PATCH net-next] net: mana: Add support for Multi
> Vports on Bare metal
> 
> 
> 
> On 17-05-2025 01:21, Haiyang Zhang wrote:
> > To support Multi Vports on Bare metal, increase the device config
> response
> > version. And, skip the register HW vport, and register filter steps,
> when
> > the Bare metal hostmode is set.
> >
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >   drivers/net/ethernet/microsoft/mana/mana_en.c | 22 +++++++++++++------
> >   include/net/mana/mana.h                       |  4 +++-
> >   2 files changed, 18 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c
> b/drivers/net/ethernet/microsoft/mana/mana_en.c
> > index 2bac6be8f6a0..0273696d254b 100644
> > --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> > +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> > @@ -921,7 +921,7 @@ static void mana_pf_deregister_filter(struct
> mana_port_context *apc)
> >
> [snip]
> > +	u8 bm_hostmode = 0;
> >   	u16 num_ports = 0;
> >   	int err;
> >   	int i;
> > @@ -3026,10 +3032,12 @@ int mana_probe(struct gdma_dev *gd, bool
> resuming)
> >   	}
> >
> >   	err = mana_query_device_cfg(ac, MANA_MAJOR_VERSION,
> MANA_MINOR_VERSION,
> > -				    MANA_MICRO_VERSION, &num_ports);
> > +				    MANA_MICRO_VERSION, &num_ports, &bm_hostmode);
> >   	if (err)
> >   		goto out;
> >
> > +	ac->bm_hostmode = bm_hostmode;
> > +
> >   	if (!resuming) {
> >   		ac->num_ports = num_ports;
> >   	} else {
> > diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
> > index 0f78065de8fe..b352d2a7118e 100644
> > --- a/include/net/mana/mana.h
> > +++ b/include/net/mana/mana.h
> > @@ -408,6 +408,7 @@ struct mana_context {
> >   	struct gdma_dev *gdma_dev;
> >
> >   	u16 num_ports;
> > +	u8 bm_hostmode; /* Bare Metal Host Mode Enabled */
> 
> what about maintaining natural alignment, +u8 reserved0 ?

This is not structure going across the "wire". Compiler will
add holes when necessary. So we don't normally add "reserved"
for alignment in these structs, right?

> /* +response v3: Bare Metal Host Mode Enabled */ for consistency.
> Even though this comment is optional here.

I will just remove this optional comment.

Thanks,
- Haiyang



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-16 21:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-16 19:51 [PATCH net-next] net: mana: Add support for Multi Vports on Bare metal Haiyang Zhang
2025-05-16 20:57 ` ALOK TIWARI
2025-05-16 21:45   ` [EXTERNAL] " Haiyang Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®