[PATCH v3 11/20] qedn: Add qedn_claim_dev API support
Shai Malin
smalin at marvell.com
Thu Jun 24 10:24:01 PDT 2021
From: Nikolay Assa <nassa at 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 at marvell.com>
Signed-off-by: Nikolay Assa <nassa at marvell.com>
Signed-off-by: Prabhakar Kushwaha <pkushwaha at marvell.com>
Signed-off-by: Omkar Kulkarni <okulkarni at marvell.com>
Signed-off-by: Michal Kalderon <mkalderon at marvell.com>
Signed-off-by: Ariel Elior <aelior at marvell.com>
Signed-off-by: Shai Malin <smalin at marvell.com>
Reviewed-by: Hannes Reinecke <hare at suse.de>
---
drivers/nvme/hw/qedn/qedn.h | 4 +++
drivers/nvme/hw/qedn/qedn_main.c | 55 ++++++++++++++++++++++++++++++--
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/hw/qedn/qedn.h b/drivers/nvme/hw/qedn/qedn.h
index 931efc3afbaa..0ce1e19d1ba8 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 97591797605e..78bc9fe17e7b 100644
--- a/drivers/nvme/hw/qedn/qedn_main.c
+++ b/drivers/nvme/hw/qedn/qedn_main.c
@@ -22,13 +22,62 @@ static struct pci_device_id qedn_pci_tbl[] = {
{0, 0},
};
+static int
+qedn_find_dev(struct nvme_tcp_ofld_dev *dev,
+ struct nvme_tcp_ofld_ctrl *ctrl)
+{
+ struct nvme_tcp_ofld_ctrl_con_params *conn_params;
+ struct pci_dev *qede_pdev = NULL;
+ struct sockaddr remote_mac_addr;
+ struct net_device *ndev = NULL;
+ u16 vlan_id = 0;
+ int rc = 0;
+
+ conn_params = &ctrl->conn_params;
+
+ /* 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,
+ &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,
+ &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;
+
+ if (!ctrl->private_data && ctrl->ndev &&
+ strcmp(ctrl->ndev->name, ndev->name))
+ return false;
+
+ ctrl->ndev = ndev;
+
+ qed_vlan_get_ndev(&ctrl->ndev, &vlan_id);
+
+ /* route found through ndev - validate this is qede*/
+ qede_pdev = qed_validate_ndev(ctrl->ndev);
+ if (!qede_pdev)
+ return false;
+
+ return true;
+}
+
static int
qedn_claim_dev(struct nvme_tcp_ofld_dev *dev,
struct nvme_tcp_ofld_ctrl *ctrl)
{
- /* Placeholder - qedn_claim_dev */
-
- return 0;
+ return qedn_find_dev(dev, ctrl);
}
static int qedn_setup_ctrl(struct nvme_tcp_ofld_ctrl *ctrl)
--
2.22.0
More information about the Linux-nvme
mailing list