Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp781937rwb; Tue, 29 Nov 2022 05:25:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf4OWDYEV/BNRruGy3XpI3RH1iRwOGEVpU+saIbd+HVuN0iLwwzmAsW+HktDFv17IBe2XXJL X-Received: by 2002:aa7:92c7:0:b0:574:39dd:f162 with SMTP id k7-20020aa792c7000000b0057439ddf162mr33016528pfa.44.1669728312210; Tue, 29 Nov 2022 05:25:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669728312; cv=none; d=google.com; s=arc-20160816; b=zFyJnyfWVfH/LyGpYGE45ZLPWSJ5TXvJ/f81lDyDdM/HNQcCE3eUZwqw/IHK6D48Sx 6dQNbE+hiGeS2GZTrTqAvI7IbDjwQw2/QMHlqbufa4MXtycOqKsAhqcjwNkcBFXbyFo+ YJ8FP4ngbfRcJhJEhnBoVPydcDwEj9fb5wjWca41sc4aqKitqm3bCRQINaRobvBQqNdk QwEZGjD45b+7kjCQ1c9n/kfZJYb04D2eNv/FIv7aIlSoZnkajWKn4xkYuwFUvH+UimSg ZuZqlpFgToLpZByL8bj9C3rmWhljPLq5VlEriFLLJGoxIM6+AhT79m0LC8RxeCirQcmV C4Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+cXlLxmV1H8HUaAl4N1/GqA5b1HOv85DnD4OjH+gw1g=; b=Ntx5K+deZAQX2NtJ8T94kYEwyiYRUeNRWY4sdSPe3GSwi2tvI83knqRGZi1bdFypmM lemT4WazQq5/dwpdsSuPVnN5YLez6IybufnKWEAVh1xdXBqRQGhrcr260IAfJwDn1XuV p7KW54EnEcBvijGdJHLK4UfRgq8JPw1UXHN7KF9txO8ZwgjmwexLOYLDjF8ud3GMnhA1 B80iw9rkdcYFj8By2iaionVRzr0jlmU9WL0yE1SfLAhlwZ7Qdi80tGgE6Jx4eNnpAoAn ZWbkuqlEGBbTPDK+isUzyvg10PYarIk73d9RReDiShjkjmJD3maAu8sG52MIpkfXlbu3 oC9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Z5jb0ThT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a63d74e000000b004701d95bcf8si13953722pgi.564.2022.11.29.05.24.45; Tue, 29 Nov 2022 05:25:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Z5jb0ThT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233657AbiK2NKa (ORCPT + 85 others); Tue, 29 Nov 2022 08:10:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232981AbiK2NKC (ORCPT ); Tue, 29 Nov 2022 08:10:02 -0500 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2871761506; Tue, 29 Nov 2022 05:10:01 -0800 (PST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ATBxjX3029859; Tue, 29 Nov 2022 05:09:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=+cXlLxmV1H8HUaAl4N1/GqA5b1HOv85DnD4OjH+gw1g=; b=Z5jb0ThTm57WYoIGa5TcBdnL6ojY1TTJWDWRhCR0WwpsevOoQAR9OWk3RY9uPFEDAVGr Bi/hJdrV99XfwfqbTH+/xZ4OZuojZcxE5AVuwJYx2Mk4afB5FpWckGZVTexGUSsOOOtF 7GSw2rR0AoZK8yYBXgTDNeRyaA4m/vJE5+QzSnuDbi4FpMlsjnIWTPpkbqHRvzHLEBnv hoRJlUB5sYMExDkOLoMm3foSJFMQgR3v8nIRBbGvTR/CIC7KW4vb8iYkoqAec9F/X6AZ ojMdViV8ggryecZkIh5v598lwmfo4bQX9NxtwGFCoC/7UA3MKfjeXccC1lkLN5DjX4/l mg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3m5a509ysx-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 29 Nov 2022 05:09:52 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 29 Nov 2022 05:09:45 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 29 Nov 2022 05:09:45 -0800 Received: from sburla-PowerEdge-T630.caveonetworks.com (unknown [10.106.27.217]) by maili.marvell.com (Postfix) with ESMTP id 36C753F7084; Tue, 29 Nov 2022 05:09:45 -0800 (PST) From: Veerasenareddy Burru To: , , , , , CC: , Veerasenareddy Burru , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net-next v2 7/9] octeon_ep: add SRIOV VF creation Date: Tue, 29 Nov 2022 05:09:30 -0800 Message-ID: <20221129130933.25231-8-vburru@marvell.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20221129130933.25231-1-vburru@marvell.com> References: <20221129130933.25231-1-vburru@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: vFt53_GzrBgDTHRpF9yMtStT-niUG7h_ X-Proofpoint-GUID: vFt53_GzrBgDTHRpF9yMtStT-niUG7h_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-29_08,2022-11-29_01,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support to create SRIOV VFs. Signed-off-by: Veerasenareddy Burru Signed-off-by: Sathesh Edara --- v1 -> v2: * no change .../ethernet/marvell/octeon_ep/octep_main.c | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 069c4d18cf37..d43161d1e38a 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -1177,11 +1177,61 @@ static void octep_remove(struct pci_dev *pdev) pci_disable_device(pdev); } +static int octep_sriov_disable(struct octep_device *oct) +{ + struct pci_dev *pdev = oct->pdev; + + if (pci_vfs_assigned(oct->pdev)) { + dev_warn(&pdev->dev, "Can't disable SRIOV while VFs are assigned\n"); + return -EPERM; + } + + pci_disable_sriov(pdev); + CFG_GET_ACTIVE_VFS(oct->conf) = 0; + + return 0; +} + +static int octep_sriov_enable(struct octep_device *oct, int num_vfs) +{ + struct pci_dev *pdev = oct->pdev; + int err; + + err = pci_enable_sriov(pdev, num_vfs); + if (err) { + dev_warn(&pdev->dev, "Failed to enable SRIOV err=%d\n", err); + return err; + } + CFG_GET_ACTIVE_VFS(oct->conf) = num_vfs; + + return num_vfs; +} + +static int octep_sriov_configure(struct pci_dev *pdev, int num_vfs) +{ + struct octep_device *oct = pci_get_drvdata(pdev); + int max_nvfs; + + if (num_vfs == 0) + return octep_sriov_disable(oct); + + max_nvfs = CFG_GET_MAX_VFS(oct->conf); + + if (num_vfs > max_nvfs) { + dev_err(&pdev->dev, "Invalid VF count Max supported VFs = %d\n", + max_nvfs); + return -EINVAL; + } + + return octep_sriov_enable(oct, num_vfs); +} + static struct pci_driver octep_driver = { .name = OCTEP_DRV_NAME, .id_table = octep_pci_id_tbl, .probe = octep_probe, .remove = octep_remove, + .sriov_configure = octep_sriov_configure, }; /** -- 2.36.0