Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3323891rwb; Mon, 19 Sep 2022 19:50:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4tqzktFI0VhU99/b/h9jc8OFY6KQVlsueC2IjznlbZHEEkasRHxA/gD/8j9TA4JLyxlltb X-Received: by 2002:a63:df50:0:b0:439:286e:b9f4 with SMTP id h16-20020a63df50000000b00439286eb9f4mr18686512pgj.416.1663642220056; Mon, 19 Sep 2022 19:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663642220; cv=none; d=google.com; s=arc-20160816; b=Mker4TksT4TaDPoVJWPcYoyLtGyyvHFihhIJf1qG7/ZsYYEo+GXsVwD8U/lq8nBjWD JvYfxDAbRerF8OgAxDgU71CTkYncAVdfrRW7pbVvJfI7oKswHp+3qGlbxXIXoQfs+IR7 VS9Fj6SDxJV6jB9IQ8RUHKTpqfpRXVCXSBx8/KwJ/Bo6XYtTujUiXxKQW2NO/K3fpQIK O/nAB70Su7EPQVp39Ox+FsFqxhaJS42mIf/8X60dlZBZh+YdLVN4khIol9wsKDwtCPUe Ta7M+bZ9fZ2SATdZtvfl5OjxTmGN94WsLQ9+Nul0kq2cdporgSpzV4pwJPUputJVU5pl 7TrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dNim4t6D3u1EwkeGcilMNCdWN9K4ooOqRZJUBMK5sfw=; b=Vi15bEEz/FfkG+nx4mRA7D7vOP1xRCW3pc+zF1M5AV4CfNk2l4HddrVIe25qbPwBto qz0y8FQU/zHzyPUP5Rh9JhrHacUxKj2IfEnGP4a4qT8KDB3qiIerrNBu7wyxKwg0ekYG oLOEsLxAgmmzCFxzP6iAAq2XGes1mBMlRA1v2S5FQHZCRbZYsO+eC7pzC+kGzl23hKhL ShNHBED3P4aZTOeCUPDhJyza7ysKQTAcxs+GB+x6gADlBtZmf4tCr69hnJ8NwXmUEMcd C03CsskstUmEkkbLwvU/lhX8vUO24ZO2yzLL5Nx/wzL3echpfdAKQFAOQJlfuPnIIrQm pLvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TmBfDkzB; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f22-20020a056a00229600b00535fa14ffaasi396435pfe.116.2022.09.19.19.50.08; Mon, 19 Sep 2022 19:50:20 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=TmBfDkzB; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbiITBqb (ORCPT + 99 others); Mon, 19 Sep 2022 21:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbiITBq1 (ORCPT ); Mon, 19 Sep 2022 21:46:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5506651406 for ; Mon, 19 Sep 2022 18:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663638382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dNim4t6D3u1EwkeGcilMNCdWN9K4ooOqRZJUBMK5sfw=; b=TmBfDkzB5jRkoaINqRZNoDDmbVwhO0iv9nAWlazNrE9wY+45UvXZ+ZX7FHZlE1/a5bSu5o ErhjoahlM9g5VdLRlR6jGGJ36bl6ZOBec1iVwt9P2wPKYf2uxfxfiLDdpr88EEgY6oIN9f QoHqMvdZeeLkbA6p0ehPhU8wKJ6nyGI= Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-221-HX0dBLVgNAC_wmdqdPSfWQ-1; Mon, 19 Sep 2022 21:46:20 -0400 X-MC-Unique: HX0dBLVgNAC_wmdqdPSfWQ-1 Received: by mail-vs1-f69.google.com with SMTP id i29-20020a05610220dd00b00398c850a99eso313366vsr.6 for ; Mon, 19 Sep 2022 18:46:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=dNim4t6D3u1EwkeGcilMNCdWN9K4ooOqRZJUBMK5sfw=; b=QhqFIak5XqvGsolLhXPQqzb2DdpOnorMjk4q90JZM9y2qQtd6SoKHrNFAZSfEMr7KC V50doT7Na7x8Lf1HlDOm5bYYCftl6j+YnPiI6nt32Ea45YGg/HWPGpZESj3wBzeH66yH wA+4K7kbi5VkERWzEpoADNEJ2OUEHk760zQlmdk4Lky7G5XNmgl5nMH0EDXbHdmBJGiI 7MTSRph+QD02+LfE48lQ3uI1lpZHlACu/WG22etePP578C0YTOEkJe+ZpG/VFxwlo8kL j5exFLlDI+cN7aJEk/ea8lo/LkhNPw6QAigKlLPkpkMvckE0WgN7qdw8TvwulRXzMyah 6g3Q== X-Gm-Message-State: ACrzQf3Qgv43VMKTRdxm2kJ0zrzqbTp850BaD1Kp8DAXS/V3ezrcxVWn bc2HLywAp+9PiA2DQ+vog8gD9qFs3bevtnjfLgJh8XfAE2IIH49c/L+9qI6YitRDYksnZWydT0F iLAEGz89NlIMOX6kwnuHGXz7YxP66wu5XmlbCvyiX X-Received: by 2002:a05:6102:1341:b0:398:889e:7f28 with SMTP id j1-20020a056102134100b00398889e7f28mr7895721vsl.21.1663638378561; Mon, 19 Sep 2022 18:46:18 -0700 (PDT) X-Received: by 2002:a05:6102:1341:b0:398:889e:7f28 with SMTP id j1-20020a056102134100b00398889e7f28mr7895714vsl.21.1663638378361; Mon, 19 Sep 2022 18:46:18 -0700 (PDT) MIME-Version: 1.0 References: <20220915085048.12840-1-jasowang@redhat.com> <20220915085048.12840-4-jasowang@redhat.com> In-Reply-To: From: Jason Wang Date: Tue, 20 Sep 2022 09:46:07 +0800 Message-ID: Subject: Re: [PATCH 3/3] vp_vdpa: support feature provisioning To: Eli Cohen Cc: "mst@redhat.com" , "si-wei.liu@oracle.com" , Parav Pandit , "wuzongyong@linux.alibaba.com" , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "eperezma@redhat.com" , "lingshan.zhu@intel.com" , "gdawar@xilinx.com" , "lulu@redhat.com" , "xieyongji@bytedance.com" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 On Mon, Sep 19, 2022 at 3:05 PM Eli Cohen wrote: > > > From: Jason Wang > > Sent: Thursday, 15 September 2022 11:51 > > To: mst@redhat.com; jasowang@redhat.com > > Cc: Eli Cohen ; si-wei.liu@oracle.com; Parav Pandit > > ; wuzongyong@linux.alibaba.com; > > virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org; > > eperezma@redhat.com; lingshan.zhu@intel.com; gdawar@xilinx.com; > > lulu@redhat.com; xieyongji@bytedance.com > > Subject: [PATCH 3/3] vp_vdpa: support feature provisioning > > > > This patch allows the device features to be provisioned via > > netlink. This is done by: > > > > 1) validating the provisioned features to be a subset of the parent > > features. > > 2) clearing the features that is not wanted by the userspace > > > > Signed-off-by: Jason Wang > > --- > > drivers/vdpa/virtio_pci/vp_vdpa.c | 16 ++++++++++++++-- > > 1 file changed, 14 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c > > b/drivers/vdpa/virtio_pci/vp_vdpa.c > > index 04522077735b..4b28e0c95ba2 100644 > > --- a/drivers/vdpa/virtio_pci/vp_vdpa.c > > +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > > > #define VP_VDPA_QUEUE_MAX 256 > > #define VP_VDPA_DRIVER_NAME "vp_vdpa" > > @@ -35,6 +36,7 @@ struct vp_vdpa { > > struct virtio_pci_modern_device *mdev; > > struct vp_vring *vring; > > struct vdpa_callback config_cb; > > + u64 device_features; > > char msix_name[VP_VDPA_NAME_SIZE]; > > int config_irq; > > int queues; > > @@ -66,9 +68,9 @@ static struct virtio_pci_modern_device > > *vp_vdpa_to_mdev(struct vp_vdpa *vp_vdpa) > > > > static u64 vp_vdpa_get_device_features(struct vdpa_device *vdpa) > > { > > - struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa); > > + struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa); > > > > - return vp_modern_get_features(mdev); > > + return vp_vdpa->device_features; > > } > > Unrelated to this patch. Maybe put in another patch? Actually not, since we don't want to report the features that are supported by the device, but the features that are provisioned via netlink: > > + if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) { > > + if (add_config->device_features & ~device_features) > > + return -EINVAL; > > + device_features &= add_config->device_features; > > + } > > + vp_vdpa->device_features = device_features; Thanks > > > > > static int vp_vdpa_set_driver_features(struct vdpa_device *vdpa, u64 > > features) > > @@ -475,6 +477,7 @@ static int vp_vdpa_dev_add(struct vdpa_mgmt_dev > > *v_mdev, const char *name, > > struct pci_dev *pdev = mdev->pci_dev; > > struct device *dev = &pdev->dev; > > struct vp_vdpa *vp_vdpa = NULL; > > + u64 device_features; > > int ret, i; > > > > vp_vdpa = vdpa_alloc_device(struct vp_vdpa, vdpa, > > @@ -491,6 +494,14 @@ static int vp_vdpa_dev_add(struct vdpa_mgmt_dev > > *v_mdev, const char *name, > > vp_vdpa->queues = vp_modern_get_num_queues(mdev); > > vp_vdpa->mdev = mdev; > > > > + device_features = vp_modern_get_features(mdev); > > + if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) { > > + if (add_config->device_features & ~device_features) > > + return -EINVAL; > > + device_features &= add_config->device_features; > > + } > > + vp_vdpa->device_features = device_features; > > + > > ret = devm_add_action_or_reset(dev, vp_vdpa_free_irq_vectors, > > pdev); > > if (ret) { > > dev_err(&pdev->dev, > > @@ -599,6 +610,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const > > struct pci_device_id *id) > > mgtdev->id_table = mdev_id; > > mgtdev->max_supported_vqs = > > vp_modern_get_num_queues(mdev); > > mgtdev->supported_features = vp_modern_get_features(mdev); > > + mgtdev->config_attr_mask = (1 << VDPA_ATTR_DEV_FEATURES); > > pci_set_master(pdev); > > pci_set_drvdata(pdev, vp_vdpa_mgtdev); > > > > -- > > 2.25.1 >