diff mbox series

[RFC,v4,18/27] qedn: Add qedn_claim_dev API support

Message ID 20210429190926.5086-19-smalin@marvell.com
State Superseded
Headers show
Series NVMeTCP Offload ULP and QEDN Device Driver | expand

Commit Message

Shai Malin April 29, 2021, 7:09 p.m. UTC
From: Nikolay Assa <nassa@marvell.com>

This patch introduces the qedn_claim_dev() network service which the
offload device (qedn) is using through the paired net-device (qede).
qedn_claim_dev() returns true if the IP addr(IPv4 or IPv6) of the target
server is reachable via the net-device which is paired with the
offloaded device.

Acked-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: Nikolay Assa <nassa@marvell.com>
Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
Signed-off-by: Omkar Kulkarni <okulkarni@marvell.com>
Signed-off-by: Michal Kalderon <mkalderon@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
Signed-off-by: Shai Malin <smalin@marvell.com>
---
 drivers/nvme/hw/qedn/qedn.h      |  4 +++
 drivers/nvme/hw/qedn/qedn_main.c | 42 ++++++++++++++++++++++++++++++--
 2 files changed, 44 insertions(+), 2 deletions(-)

Comments

Hannes Reinecke May 2, 2021, 11:29 a.m. UTC | #1
On 4/29/21 9:09 PM, Shai Malin wrote:
> From: Nikolay Assa <nassa@marvell.com>

> 

> This patch introduces the qedn_claim_dev() network service which the

> offload device (qedn) is using through the paired net-device (qede).

> qedn_claim_dev() returns true if the IP addr(IPv4 or IPv6) of the target

> server is reachable via the net-device which is paired with the

> offloaded device.

> 

> Acked-by: Igor Russkikh <irusskikh@marvell.com>

> Signed-off-by: Nikolay Assa <nassa@marvell.com>

> Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>

> Signed-off-by: Omkar Kulkarni <okulkarni@marvell.com>

> Signed-off-by: Michal Kalderon <mkalderon@marvell.com>

> Signed-off-by: Ariel Elior <aelior@marvell.com>

> Signed-off-by: Shai Malin <smalin@marvell.com>

> ---

>   drivers/nvme/hw/qedn/qedn.h      |  4 +++

>   drivers/nvme/hw/qedn/qedn_main.c | 42 ++++++++++++++++++++++++++++++--

>   2 files changed, 44 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/nvme/hw/qedn/qedn.h b/drivers/nvme/hw/qedn/qedn.h

> index c1ac17eabcb7..7efe2366eb7c 100644

> --- a/drivers/nvme/hw/qedn/qedn.h

> +++ b/drivers/nvme/hw/qedn/qedn.h

> @@ -8,6 +8,10 @@

>   

>   #include <linux/qed/qed_if.h>

>   #include <linux/qed/qed_nvmetcp_if.h>

> +#include <linux/qed/qed_nvmetcp_ip_services_if.h>

> +#include <linux/qed/qed_chain.h>

> +#include <linux/qed/storage_common.h>

> +#include <linux/qed/nvmetcp_common.h>

>   

>   /* Driver includes */

>   #include "../../host/tcp-offload.h"

> diff --git a/drivers/nvme/hw/qedn/qedn_main.c b/drivers/nvme/hw/qedn/qedn_main.c

> index e3e8e3676b79..52007d35622d 100644

> --- a/drivers/nvme/hw/qedn/qedn_main.c

> +++ b/drivers/nvme/hw/qedn/qedn_main.c

> @@ -27,9 +27,47 @@ static int

>   qedn_claim_dev(struct nvme_tcp_ofld_dev *dev,

>   	       struct nvme_tcp_ofld_ctrl_con_params *conn_params)

>   {

> -	/* Placeholder - qedn_claim_dev */

> +	struct pci_dev *qede_pdev = NULL;

> +	struct net_device *ndev = NULL;

> +	u16 vlan_id = 0;

> +	int rc = 0;

>   

> -	return 0;

> +	/* qedn utilizes host network stack through paired qede device for

> +	 * non-offload traffic. First we verify there is valid route to remote

> +	 * peer.

> +	 */

> +	if (conn_params->remote_ip_addr.ss_family == AF_INET) {

> +		rc = qed_route_ipv4(&conn_params->local_ip_addr,

> +				    &conn_params->remote_ip_addr,

> +				    &conn_params->remote_mac_addr,

> +				    &ndev);

> +	} else if (conn_params->remote_ip_addr.ss_family == AF_INET6) {

> +		rc = qed_route_ipv6(&conn_params->local_ip_addr,

> +				    &conn_params->remote_ip_addr,

> +				    &conn_params->remote_mac_addr,

> +				    &ndev);

> +	} else {

> +		pr_err("address family %d not supported\n",

> +		       conn_params->remote_ip_addr.ss_family);

> +

> +		return false;

> +	}

> +

> +	if (rc)

> +		return false;

> +

> +	qed_vlan_get_ndev(&ndev, &vlan_id);

> +	conn_params->vlan_id = vlan_id;

> +

> +	/* route found through ndev - validate this is qede*/

> +	qede_pdev = qed_validate_ndev(ndev);

> +	if (!qede_pdev)

> +		return false;

> +

> +	dev->qede_pdev = qede_pdev;

> +	dev->ndev = ndev;

> +

> +	return true;

>   }

>   

>   static int qedn_create_queue(struct nvme_tcp_ofld_queue *queue, int qid,

> 

Reviewed-by: Hannes Reinecke <hare@suse.de>


Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Shai Malin May 7, 2021, 1:57 p.m. UTC | #2
On 5/2/21 2:29 PM, Hannes Reinecke wrote:
> On 4/29/21 9:09 PM, Shai Malin wrote:

> > From: Nikolay Assa <nassa@marvell.com>

> >

> > This patch introduces the qedn_claim_dev() network service which the

> > offload device (qedn) is using through the paired net-device (qede).

> > qedn_claim_dev() returns true if the IP addr(IPv4 or IPv6) of the target

> > server is reachable via the net-device which is paired with the

> > offloaded device.

> >

> > Acked-by: Igor Russkikh <irusskikh@marvell.com>

> > Signed-off-by: Nikolay Assa <nassa@marvell.com>

> > Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>

> > Signed-off-by: Omkar Kulkarni <okulkarni@marvell.com>

> > Signed-off-by: Michal Kalderon <mkalderon@marvell.com>

> > Signed-off-by: Ariel Elior <aelior@marvell.com>

> > Signed-off-by: Shai Malin <smalin@marvell.com>

> > ---

> >   drivers/nvme/hw/qedn/qedn.h      |  4 +++

> >   drivers/nvme/hw/qedn/qedn_main.c | 42 ++++++++++++++++++++++++++++++--

> >   2 files changed, 44 insertions(+), 2 deletions(-)

> >

> > diff --git a/drivers/nvme/hw/qedn/qedn.h b/drivers/nvme/hw/qedn/qedn.h

> > index c1ac17eabcb7..7efe2366eb7c 100644

> > --- a/drivers/nvme/hw/qedn/qedn.h

> > +++ b/drivers/nvme/hw/qedn/qedn.h

> > @@ -8,6 +8,10 @@

> >

> >   #include <linux/qed/qed_if.h>

> >   #include <linux/qed/qed_nvmetcp_if.h>

> > +#include <linux/qed/qed_nvmetcp_ip_services_if.h>

> > +#include <linux/qed/qed_chain.h>

> > +#include <linux/qed/storage_common.h>

> > +#include <linux/qed/nvmetcp_common.h>

> >

> >   /* Driver includes */

> >   #include "../../host/tcp-offload.h"

> > diff --git a/drivers/nvme/hw/qedn/qedn_main.c b/drivers/nvme/hw/qedn/qedn_main.c

> > index e3e8e3676b79..52007d35622d 100644

> > --- a/drivers/nvme/hw/qedn/qedn_main.c

> > +++ b/drivers/nvme/hw/qedn/qedn_main.c

> > @@ -27,9 +27,47 @@ static int

> >   qedn_claim_dev(struct nvme_tcp_ofld_dev *dev,

> >              struct nvme_tcp_ofld_ctrl_con_params *conn_params)

> >   {

> > -     /* Placeholder - qedn_claim_dev */

> > +     struct pci_dev *qede_pdev = NULL;

> > +     struct net_device *ndev = NULL;

> > +     u16 vlan_id = 0;

> > +     int rc = 0;

> >

> > -     return 0;

> > +     /* qedn utilizes host network stack through paired qede device for

> > +      * non-offload traffic. First we verify there is valid route to remote

> > +      * peer.

> > +      */

> > +     if (conn_params->remote_ip_addr.ss_family == AF_INET) {

> > +             rc = qed_route_ipv4(&conn_params->local_ip_addr,

> > +                                 &conn_params->remote_ip_addr,

> > +                                 &conn_params->remote_mac_addr,

> > +                                 &ndev);

> > +     } else if (conn_params->remote_ip_addr.ss_family == AF_INET6) {

> > +             rc = qed_route_ipv6(&conn_params->local_ip_addr,

> > +                                 &conn_params->remote_ip_addr,

> > +                                 &conn_params->remote_mac_addr,

> > +                                 &ndev);

> > +     } else {

> > +             pr_err("address family %d not supported\n",

> > +                    conn_params->remote_ip_addr.ss_family);

> > +

> > +             return false;

> > +     }

> > +

> > +     if (rc)

> > +             return false;

> > +

> > +     qed_vlan_get_ndev(&ndev, &vlan_id);

> > +     conn_params->vlan_id = vlan_id;

> > +

> > +     /* route found through ndev - validate this is qede*/

> > +     qede_pdev = qed_validate_ndev(ndev);

> > +     if (!qede_pdev)

> > +             return false;

> > +

> > +     dev->qede_pdev = qede_pdev;

> > +     dev->ndev = ndev;

> > +

> > +     return true;

> >   }

> >

> >   static int qedn_create_queue(struct nvme_tcp_ofld_queue *queue, int qid,

> >

> Reviewed-by: Hannes Reinecke <hare@suse.de>


Thanks.

>

> Cheers,

>

> Hannes

> --

> Dr. Hannes Reinecke                Kernel Storage Architect

> hare@suse.de                              +49 911 74053 688

> SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg

> HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
diff mbox series

Patch

diff --git a/drivers/nvme/hw/qedn/qedn.h b/drivers/nvme/hw/qedn/qedn.h
index c1ac17eabcb7..7efe2366eb7c 100644
--- a/drivers/nvme/hw/qedn/qedn.h
+++ b/drivers/nvme/hw/qedn/qedn.h
@@ -8,6 +8,10 @@ 
 
 #include <linux/qed/qed_if.h>
 #include <linux/qed/qed_nvmetcp_if.h>
+#include <linux/qed/qed_nvmetcp_ip_services_if.h>
+#include <linux/qed/qed_chain.h>
+#include <linux/qed/storage_common.h>
+#include <linux/qed/nvmetcp_common.h>
 
 /* Driver includes */
 #include "../../host/tcp-offload.h"
diff --git a/drivers/nvme/hw/qedn/qedn_main.c b/drivers/nvme/hw/qedn/qedn_main.c
index e3e8e3676b79..52007d35622d 100644
--- a/drivers/nvme/hw/qedn/qedn_main.c
+++ b/drivers/nvme/hw/qedn/qedn_main.c
@@ -27,9 +27,47 @@  static int
 qedn_claim_dev(struct nvme_tcp_ofld_dev *dev,
 	       struct nvme_tcp_ofld_ctrl_con_params *conn_params)
 {
-	/* Placeholder - qedn_claim_dev */
+	struct pci_dev *qede_pdev = NULL;
+	struct net_device *ndev = NULL;
+	u16 vlan_id = 0;
+	int rc = 0;
 
-	return 0;
+	/* qedn utilizes host network stack through paired qede device for
+	 * non-offload traffic. First we verify there is valid route to remote
+	 * peer.
+	 */
+	if (conn_params->remote_ip_addr.ss_family == AF_INET) {
+		rc = qed_route_ipv4(&conn_params->local_ip_addr,
+				    &conn_params->remote_ip_addr,
+				    &conn_params->remote_mac_addr,
+				    &ndev);
+	} else if (conn_params->remote_ip_addr.ss_family == AF_INET6) {
+		rc = qed_route_ipv6(&conn_params->local_ip_addr,
+				    &conn_params->remote_ip_addr,
+				    &conn_params->remote_mac_addr,
+				    &ndev);
+	} else {
+		pr_err("address family %d not supported\n",
+		       conn_params->remote_ip_addr.ss_family);
+
+		return false;
+	}
+
+	if (rc)
+		return false;
+
+	qed_vlan_get_ndev(&ndev, &vlan_id);
+	conn_params->vlan_id = vlan_id;
+
+	/* route found through ndev - validate this is qede*/
+	qede_pdev = qed_validate_ndev(ndev);
+	if (!qede_pdev)
+		return false;
+
+	dev->qede_pdev = qede_pdev;
+	dev->ndev = ndev;
+
+	return true;
 }
 
 static int qedn_create_queue(struct nvme_tcp_ofld_queue *queue, int qid,