From patchwork Fri Nov 11 14:27:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Longpeng(Mike)" X-Patchwork-Id: 1517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp781626wru; Fri, 11 Nov 2022 06:46:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf59bDogICSrmQOjGrxEU0bMPfpZDTZzyQroVA+xj5N6dJDEC7U7XmgCddHdoAOvq9pIsFtU X-Received: by 2002:a17:906:78e:b0:7a1:e52e:bddb with SMTP id l14-20020a170906078e00b007a1e52ebddbmr1948304ejc.685.1668178016489; Fri, 11 Nov 2022 06:46:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668178016; cv=none; d=google.com; s=arc-20160816; b=fH/5hFCfyF36L5SwxU/+c9Pt7+ODJriR6F9b366pdDbHvnA+L1kTknUBmS+aPK7ziF FSc4ZJrdFAyvXbfK+G9JYDxzmqj8iH5sky3RhfL14g+L6wSC3gWHBCzCM7QCtOy/ABKN ROiR9me0HwPfsg0JZgBdAtp4SsGJL5j10FY7Qivi3aSff2sZcuw1a+6whQ/30UPeFAGb icq0pvj1iHyByx0Gy0kcMWkc8RVNbyj0xjC41Qdy8rky0Dv9ukLkX2r/g8Ko7O6Hh/Np nqllqGi56wp0BPVdGkifAUhsvh+iFPhcBiQi98XyyydhM6+kMNUmeu7qNLFo106ubwow C+bQ== 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 :message-id:date:subject:cc:to:from; bh=tuppcrhBPe1EhMgwS3MP9nl2RWEBVsyluEKSPoJulHc=; b=sbNRUsbA8ynjtOittWbs1E+hP+kuCkbo7tyWQbTEA+DKUZBHM1rb6JDb2K6BUpSGXU 1zFhOnhrjrivqPb8cyqCVPot3A9Mc3ScOTwNfP7aZPEQ6/8cSrBGe7tgwck2Vb/6VlFR p7MS/ufkWVAiY2jgqGRhas4HZcBsH6BI+g0InwWyWq39BMn8lpl3wtrrNeSWH2WT/Zkj 8QODhmBvBnbJgej+wX0R/s0m0KucDT9iOrjr1YDlMDBLoURgqiePPjLbwkeuf4PzbYWW YqVvteuRZj3ol6gZm8GRxMzW9ncjYrPTL2BJE92F0Jp3WW8iSmbNKa9Xev7fydb8HWis 6nfQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx3-20020a170906af0300b007adacdfd08asi1682249ejb.295.2022.11.11.06.46.31; Fri, 11 Nov 2022 06:46:56 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234041AbiKKO1f (ORCPT + 99 others); Fri, 11 Nov 2022 09:27:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231840AbiKKO1a (ORCPT ); Fri, 11 Nov 2022 09:27:30 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1DA8C1; Fri, 11 Nov 2022 06:27:28 -0800 (PST) Received: from kwepemi100025.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N81Cg3gHNzbnfm; Fri, 11 Nov 2022 22:23:43 +0800 (CST) Received: from DESKTOP-27KDQMV.china.huawei.com (10.174.148.223) by kwepemi100025.china.huawei.com (7.221.188.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 11 Nov 2022 22:27:25 +0800 From: "Longpeng(Mike)" To: CC: , , , , , , , , Longpeng Subject: [RFC 0/4] pci/sriov: support VFs dynamic addition Date: Fri, 11 Nov 2022 22:27:18 +0800 Message-ID: <20221111142722.1172-1-longpeng2@huawei.com> X-Mailer: git-send-email 2.25.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.148.223] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi100025.china.huawei.com (7.221.188.158) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749211431870150433?= X-GMAIL-MSGID: =?utf-8?q?1749211431870150433?= From: Longpeng We can enable SRIOV and add VFs by /sys/bus/pci/devices/..../sriov_numvfs, but this operation needs to spend lots of time if there has a large amount of VFs. For example, if the machine has 10 PFs and 250 VFs per-PF, enable all the VFs concurrently would cost about 200-250ms. However most of them are not need to be used at the moment, so we can enable SRIOV first but add VFs on demand. This series introduces two interfaces: 1. sriov_numvfs_no_scan: enable SRIOV without add the VFs. 2. sriov_scan_vf_id: add a specific VF. Longpeng (4): pci/sriov: extract sriov_numvfs common helper pci/sriov: add vf_bitmap to mark the vf id allocation pci/sriov: add sriov_numfs_no_scan interface pci/sriov: add sriov_scan_vf_id interface drivers/pci/iov.c | 162 +++++++++++++++++++++++++++++++++++++++++----- drivers/pci/pci.h | 1 + 2 files changed, 148 insertions(+), 15 deletions(-)