Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C92BC49EA6 for ; Thu, 24 Jun 2021 17:30:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F23061075 for ; Thu, 24 Jun 2021 17:30:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F23061075 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=marvell.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xalzHt31IotKbEGQArhVv3w9T0Stqxf0BgUFmuhg0VA=; b=hljuc3NLn2AZXJ Qk5bd0di8tkEpJh0IJ5cy8eWdJHmR/o+d9ujzXQUZucqtvMJQDmIPrN7iLwCltLdUNa3lNqPDJSFQ hrFWpYvWWbhw8GMkOERLMhoSx86wr5VJBg28f25wmCZfOE+mNnBAzrHqTzR9LKkgLUgEmdADxy+UY FKGnei3uzAkMSV1XfAMEIK6VlFtFwt29CUWTJtKJ4XpnaYp9F1y/4eKqN9jamyA867gsloFT+u4Ww IjM0DEtPhU4701r4SNb0JOxu4gIogwPfZmF+uDR887lZla1Es1puPMeqjz50oghp8LOtyM25Z7HNb TAE4FBzNX1rj24cIgHcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwTBN-00FemY-7V; Thu, 24 Jun 2021 17:30:29 +0000 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174] helo=mx0b-0016f401.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwT6Q-00FdCN-OY for linux-nvme@lists.infradead.org; Thu, 24 Jun 2021 17:25:25 +0000 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15OH9rtg017573; Thu, 24 Jun 2021 10:25:18 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 39cgc8bm9v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 24 Jun 2021 10:25:18 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 24 Jun 2021 10:25:17 -0700 Received: from lbtlvb-pcie154.il.qlogic.org (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 24 Jun 2021 10:25:13 -0700 From: Shai Malin To: , , , , CC: , , , , , , , , , Nikolay Assa Subject: [PATCH v3 11/20] qedn: Add qedn_claim_dev API support Date: Thu, 24 Jun 2021 20:24:01 +0300 Message-ID: <20210624172410.14225-12-smalin@marvell.com> X-Mailer: git-send-email 2.16.6 In-Reply-To: <20210624172410.14225-1-smalin@marvell.com> References: <20210624172410.14225-1-smalin@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: hgVSV-A1p0rF8xo3BRlTrairhlZOdfKr X-Proofpoint-GUID: hgVSV-A1p0rF8xo3BRlTrairhlZOdfKr X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-24_12:2021-06-24, 2021-06-24 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_102522_849808_B5FE903D X-CRM114-Status: GOOD ( 15.31 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org From: Nikolay Assa 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 Signed-off-by: Nikolay Assa Signed-off-by: Prabhakar Kushwaha Signed-off-by: Omkar Kulkarni Signed-off-by: Michal Kalderon Signed-off-by: Ariel Elior Signed-off-by: Shai Malin Reviewed-by: Hannes Reinecke --- 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 #include +#include +#include +#include +#include /* 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 _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme