Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp964143ybg; Wed, 10 Jun 2020 19:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/zKi4tY6mr7dZRf4MRvlw/pF2VxpjKK0lWdQTUtCkfFE9Xg83b8egs+B6dg3fgl1uS48I X-Received: by 2002:a05:6402:1ac1:: with SMTP id ba1mr4845123edb.91.1591842599920; Wed, 10 Jun 2020 19:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591842599; cv=none; d=google.com; s=arc-20160816; b=S/d3Os37xCpJTe1kXdy4PI385vcA9u6lpmeRjsiQXmgO+CXI1FzTDtGXqI4oNZZNIN 8c3NUCaYYEBVIxjYiSdwgfYv9k3dZheVs6qiUufI5p6oezMhiDljWjGLYbcG1lISSX4C eB8rEdVSh4cSSM+sPYj9luiR1E36714QTSDQmZdR7jQ1Id1vn5g3lzi7p0GT9P+cARS7 7W6VHALSiEyxqa6sUji3TX9OSH2RQwC79Z/ylTXu1HamSirWZUz4qWYog7TKLHBfuI9d j23q881gkrQ5vNJCWuFBydrKqC941XlOjQ1XegFr0GtPlZgrf1At2OfE+S3GNxAhRoz9 tvQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=SSIeLxdIXdYa0BfZUKu6b2wFGF0ZuOPOU+av2DPcqlE=; b=XNRg34iCRh6w9ZONoyA2YDykiw8oBOyk2GnwtKFDlEQ/ACg6Eevi+YLfKLJ/s2a4Xq +CPmgTMEzwdqMIGxB1cJuOX2PQyBV1F3xjij9ZJW55p5lFk4f9WPhdamj2UGdD3szgu4 M/ONsstoYp4cN2Da/Sy9QXpoY09CAR+9oJjgUyzRp1E0gmWXFbHvW2WrGUGNPygLKvgc CRL26vOxiN1saLtuzjtYTC7OvDsOMw6ECAgy9PE/3kkE7+emE/bbcRiPT29Zpjvptdqx kyWlQ40nGYJ5S7bA9Reecc/i3NewdDaYKyR/EwfiTzQe9LsWH6bpTuuzaZH9NnxGwmb/ Z9/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e2si836845edy.212.2020.06.10.19.29.37; Wed, 10 Jun 2020 19:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726352AbgFKC15 (ORCPT + 99 others); Wed, 10 Jun 2020 22:27:57 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:58980 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726279AbgFKC15 (ORCPT ); Wed, 10 Jun 2020 22:27:57 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7ABD42F40A3152786A0A; Thu, 11 Jun 2020 10:27:54 +0800 (CST) Received: from [127.0.0.1] (10.173.221.213) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Thu, 11 Jun 2020 10:27:45 +0800 Subject: Re: [RFC PATCH v4 08/10] i40e/vf_migration: VF live migration - pass-through VF first To: Yan Zhao CC: , , , , , , , , , , , "Wang Haibin" References: <20200518024202.13996-1-yan.y.zhao@intel.com> <20200518025316.14491-1-yan.y.zhao@intel.com> <20200611002319.GC13961@joy-OptiPlex-7040> From: Xiang Zheng Message-ID: Date: Thu, 11 Jun 2020 10:27:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20200611002319.GC13961@joy-OptiPlex-7040> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.221.213] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/6/11 8:23, Yan Zhao wrote: > On Wed, Jun 10, 2020 at 04:59:43PM +0800, Xiang Zheng wrote: >> Hi Yan, >> >> few nits below... >> >> On 2020/5/18 10:53, Yan Zhao wrote: >>> This driver intercepts all device operations as long as it's probed >>> successfully by vfio-pci driver. >>> >>> It will process regions and irqs of its interest and then forward >>> operations to default handlers exported from vfio pci if it wishes to. >>> >>> In this patch, this driver does nothing but pass through VFs to guest >>> by calling to exported handlers from driver vfio-pci. >>> >>> Cc: Shaopeng He >>> >>> Signed-off-by: Yan Zhao >>> --- >>> drivers/net/ethernet/intel/Kconfig | 10 ++ >>> drivers/net/ethernet/intel/i40e/Makefile | 2 + >>> .../ethernet/intel/i40e/i40e_vf_migration.c | 165 ++++++++++++++++++ >>> .../ethernet/intel/i40e/i40e_vf_migration.h | 59 +++++++ >>> 4 files changed, 236 insertions(+) >>> create mode 100644 drivers/net/ethernet/intel/i40e/i40e_vf_migration.c >>> create mode 100644 drivers/net/ethernet/intel/i40e/i40e_vf_migration.h >>> >>> diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig >>> index ad34e4335df2..31780d9a59f1 100644 >>> --- a/drivers/net/ethernet/intel/Kconfig >>> +++ b/drivers/net/ethernet/intel/Kconfig >>> @@ -264,6 +264,16 @@ config I40E_DCB >>> >>> If unsure, say N. >>> [...] >>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_vf_migration.h b/drivers/net/ethernet/intel/i40e/i40e_vf_migration.h >>> new file mode 100644 >>> index 000000000000..696d40601ec3 >>> --- /dev/null >>> +++ b/drivers/net/ethernet/intel/i40e/i40e_vf_migration.h >>> @@ -0,0 +1,59 @@ >>> +/* SPDX-License-Identifier: GPL-2.0 */ >>> +/* Copyright(c) 2013 - 2019 Intel Corporation. */ >>> + >>> +#ifndef I40E_MIG_H >>> +#define I40E_MIG_H >>> + >>> +#include >>> +#include >>> +#include >>> + >>> +#include "i40e.h" >>> +#include "i40e_txrx.h" >>> + >>> +/* helper macros copied from vfio-pci */ >>> +#define VFIO_PCI_OFFSET_SHIFT 40 >>> +#define VFIO_PCI_OFFSET_TO_INDEX(off) ((off) >> VFIO_PCI_OFFSET_SHIFT) >>> +#define VFIO_PCI_INDEX_TO_OFFSET(index) ((u64)(index) << VFIO_PCI_OFFSET_SHIFT) >>> +#define VFIO_PCI_OFFSET_MASK (((u64)(1) << VFIO_PCI_OFFSET_SHIFT) - 1) >>> + >>> +/* Single Root I/O Virtualization */ >>> +struct pci_sriov { >>> + int pos; /* Capability position */ >>> + int nres; /* Number of resources */ >>> + u32 cap; /* SR-IOV Capabilities */ >>> + u16 ctrl; /* SR-IOV Control */ >>> + u16 total_VFs; /* Total VFs associated with the PF */ >>> + u16 initial_VFs; /* Initial VFs associated with the PF */ >>> + u16 num_VFs; /* Number of VFs available */ >>> + u16 offset; /* First VF Routing ID offset */ >>> + u16 stride; /* Following VF stride */ >>> + u16 vf_device; /* VF device ID */ >>> + u32 pgsz; /* Page size for BAR alignment */ >>> + u8 link; /* Function Dependency Link */ >>> + u8 max_VF_buses; /* Max buses consumed by VFs */ >>> + u16 driver_max_VFs; /* Max num VFs driver supports */ >>> + struct pci_dev *dev; /* Lowest numbered PF */ >>> + struct pci_dev *self; /* This PF */ >>> + u32 cfg_size; /* VF config space size */ >>> + u32 class; /* VF device */ >>> + u8 hdr_type; /* VF header type */ >>> + u16 subsystem_vendor; /* VF subsystem vendor */ >>> + u16 subsystem_device; /* VF subsystem device */ >>> + resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ >>> + bool drivers_autoprobe; /* Auto probing of VFs by driver */ >>> +}; >>> + >> >> Can "struct pci_sriov" be extracted for common use? This should not be exclusive >> for "i40e_vf migration support". >> > the definition of this structure is actually in driver/pci/pci.h. > maybe removing the copy here and use below include is better? > #include "../../../../pci/pci.h" > How about moving the definition from driver/pci/pci.h into include/linux/pci.h? So we can just include "linux/pci.h" and removing the copy here. -- Thanks, Xiang