From patchwork Fri Oct 21 22:43:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 7027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp956002wrr; Fri, 21 Oct 2022 16:50:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4UaSftV2lHuGykwxq6Z5Ahc14YiSoB+QG8pnC+kLmO+zDrM4nvAE7DG7o2Ziht39mv/V8/ X-Received: by 2002:a05:6402:5ca:b0:43b:6e01:482c with SMTP id n10-20020a05640205ca00b0043b6e01482cmr20205639edx.189.1666396256612; Fri, 21 Oct 2022 16:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666396256; cv=none; d=google.com; s=arc-20160816; b=Gn00nMBY13mDdi7vRabxsOTW39SQ/8ko/yNxpl+/wCg9oNkA1ZhjWKqmlWW7LJ1M1h kHS6FnQTJBFtgT57aJqnG08IPaGkjp4FlNqYQqz2sGHLHW8pxuGZ9QLQZ1mpRri4kzAb /aUzo+XgwOTG9P3E9LVpcMn3TDVVTLgHgILReWqLIRq0N1Xknu4pYb954K04cbeXOBos Xwgv9VjcxNDtdtmO6C3kNzqhG1RXd61HmmQ8Ci85/79P7s1AJ3yYm3m09dilKpFA1h7Q pR2S65H4/OxmHoTYnOVftlmYxFfhuRkj7VXqSgvW8B/b4qgbxlIJ4LOXbU624Uv7vb2T 3WUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=V7U93o+Lc8e/VViolr2K02LD3zVGat6a0bv7jBQ/DuE=; b=TpqaCwVy+mE9uTisZ2CEmR8dZ4AhfzgAhaHrQZtEkiCsEao9XO+ShjZjdpNkkHcZCZ sOA1DLIYCwjmwoiFKHCCodk1GDblnt+TY09ZvVsI3Hr1cATEc6/0EkBdCjGnvGDMVyfY XviYR6AouDLOnrYfJ4H5uFwMymNmNCMm6XdC7uBuPHrd1jZlFyTZHDhB6bv2FlXhIOwK xUeGZsuLy9Og6lp91acvH8vWDwxqdZR9y/jI8w8iAVF1d9WAxMvnTd3UoI//YfQwLoEY hC/cl0Chl0ynkt1G/5J50HlxNd1NuvUkBfp01AGqk8/74nVJe6ff64IkmvI5f2N03a4L ZmMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=o2H9wvmq; 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=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz2-20020a1709072ce200b0079ca59305a6si2584428ejc.354.2022.10.21.16.50.33; Fri, 21 Oct 2022 16:50:56 -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=@oracle.com header.s=corp-2022-7-12 header.b=o2H9wvmq; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbiJUXty (ORCPT + 99 others); Fri, 21 Oct 2022 19:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbiJUXtp (ORCPT ); Fri, 21 Oct 2022 19:49:45 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2E6A36BC6 for ; Fri, 21 Oct 2022 16:49:44 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29LLDlEp001545; Fri, 21 Oct 2022 23:49:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=V7U93o+Lc8e/VViolr2K02LD3zVGat6a0bv7jBQ/DuE=; b=o2H9wvmqrC/aVP5g+9PScLnhdqDsbhELElCpUQnUsrLFlUrzy0QZcnzFGY+1w+ElVLwC E1ZAtrJ8WG8oM254DY59E9TPrrp5gfnzF8NlPx0/z2jNzT6kuH91nlUnYOOZgSGYIWcl jdwLE1rhXXq9Q4Lh6+GDWm/YBVvYzqZP9ueZLnHmtzlY8xnloONdeFWzN4EDiBw73CWM v+hUXK4aph45cKwpHulKMEl4cCoq79cYCnKfanPJ5ikEFhIO5ZidZOLA4o6AkzNmylqE YvOeX8VLdW+F/ZRVpWEYq2yXDaG7gp/IzVxqgndlMQrYt2/GXTvCAXNW6TYcEJ3t9a1m zw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k9awwdmr4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Oct 2022 23:49:40 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29LMgIQS007144; Fri, 21 Oct 2022 23:49:38 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8hre9a3b-2; Fri, 21 Oct 2022 23:49:38 +0000 From: Si-Wei Liu To: mst@redhat.com, jasowang@redhat.com, parav@nvidia.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/4] vdpa: save vdpa_dev_set_config in struct vdpa_device Date: Fri, 21 Oct 2022 15:43:54 -0700 Message-Id: <1666392237-4042-2-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666392237-4042-1-git-send-email-si-wei.liu@oracle.com> References: <1666392237-4042-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-21_04,2022-10-21_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210139 X-Proofpoint-GUID: lS0vrvi2FmUheEorsn-MXjEvqAy3rb5y X-Proofpoint-ORIG-GUID: lS0vrvi2FmUheEorsn-MXjEvqAy3rb5y X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747343121061307020?= X-GMAIL-MSGID: =?utf-8?q?1747343121061307020?= In order to allow live migration orchestration software to export the initial set of vdpa attributes with which the device was created, it will be useful if the vdpa tool can report the config on demand with simple query. This will ease the orchestration software implementation so that it doesn't have to keep track of vdpa config change, or have to persist vdpa attributes across failure and recovery, in fear of being killed due to accidental software error. This commit attempts to make struct vdpa_device contain the struct vdpa_dev_set_config, where all config attributes upon vdpa creation are carried over. Which will be used in subsequent commits. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- include/linux/vdpa.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 6d0f5e4..9f519a3 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -58,6 +58,16 @@ struct vdpa_vq_state { }; }; +struct vdpa_dev_set_config { + u64 device_features; + struct { + u8 mac[ETH_ALEN]; + u16 mtu; + u16 max_vq_pairs; + } net; + u64 mask; +}; + struct vdpa_mgmt_dev; /** @@ -77,6 +87,8 @@ struct vdpa_vq_state { * @nvqs: maximum number of supported virtqueues * @mdev: management device pointer; caller must setup when registering device as part * of dev_add() mgmtdev ops callback before invoking _vdpa_register_device(). + * @init_cfg: initial device config on vdpa creation; useful when instantiating + * device with identical config is needed, e.g. migration. */ struct vdpa_device { struct device dev; @@ -91,6 +103,7 @@ struct vdpa_device { struct vdpa_mgmt_dev *mdev; unsigned int ngroups; unsigned int nas; + struct vdpa_dev_set_config init_cfg; }; /** @@ -103,16 +116,6 @@ struct vdpa_iova_range { u64 last; }; -struct vdpa_dev_set_config { - u64 device_features; - struct { - u8 mac[ETH_ALEN]; - u16 mtu; - u16 max_vq_pairs; - } net; - u64 mask; -}; - /** * Corresponding file area for device memory mapping * @file: vma->vm_file for the mapping From patchwork Fri Oct 21 22:43:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 7029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp956287wrr; Fri, 21 Oct 2022 16:52:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6G/ZYvrMu6L1rCcZOtdBmYhYf3E36RNTUUlmttEQ884315Ijyoq3xWGfcD6jOip/Jg4kbQ X-Received: by 2002:a05:6402:2552:b0:45d:ecf:b23 with SMTP id l18-20020a056402255200b0045d0ecf0b23mr19823939edb.255.1666396323577; Fri, 21 Oct 2022 16:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666396323; cv=none; d=google.com; s=arc-20160816; b=u2/FUR6Nn8bUHK5FGe7hw3APAuBGsYkV09kphEARNl36XnrQ1fP5+5Fj8FT4KY34E4 NHnesFeKAsYMADkFHNc4ryI36JpEdcqdga6U4bwga16lM0FikF9OQ8Td9RokgP8Xti1d MOtkLf/fhG0HLw0QlBNxrEd2bD3pcrFYG46g4ovrsUt5+Qau3EKWJzgoyEnNVHfSK8/7 waVYd+9jwgCTwJxZWhXi0saLmtO3mTgFYllbPzHWVJa2fqnN41ie6e7qzFY0cXCo3ORe 40a9+YhVH9LelBrcVSS56aix0RkvbkDR8XU4oMcKpJWgj2mIXWcFzuVCbYpc2szXbl2q OWdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=P1b5Vz6uMAabNAwiX7q1M23FaXF98wy0/Q0czLGx1dk=; b=KM2APBj4tvAtBBOKuOdpQm+gWvLCeaa7Oz4t8zRUCN5L3KL3XnPDoJeTlmYcqDJK4k 5qaIASdjjgdfwwSsbUV0rW/1fhki+4vnMXBI5hWy26n0mzdH5eKkwEiXlDunxTV+4+KI im6Jjq8W8+9RTYo+BhfrZw2eHRZWpt7tUsXAtRjYz0ArbpEO0kJhURBgBFVJcBMO5X2S flMOhrReUFP7i0jHw9j/Afgl6XOz/12UaI3jxdTXTJXFE1mduEhYq2ou0XASjee2VvPg RfxaH/Y8Ym72SF1v7O9ZQzlH2rUXCSlrWutXE0JVtw6R5k1Rr28NzSFt2X6FrgCqDM6p /mCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=HQC4zNyS; 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=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm21-20020a170907949500b007417e9a2c71si21519340ejc.352.2022.10.21.16.51.39; Fri, 21 Oct 2022 16:52:03 -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=@oracle.com header.s=corp-2022-7-12 header.b=HQC4zNyS; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229902AbiJUXuC (ORCPT + 99 others); Fri, 21 Oct 2022 19:50:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbiJUXtq (ORCPT ); Fri, 21 Oct 2022 19:49:46 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1780F36BCE for ; Fri, 21 Oct 2022 16:49:44 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29LLDuC6019522; Fri, 21 Oct 2022 23:49:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=P1b5Vz6uMAabNAwiX7q1M23FaXF98wy0/Q0czLGx1dk=; b=HQC4zNySVtL/KEYvUZ85OSTvYHcVKBX63F7oyv7cbPqa8g3E6CHuf7d/7SEOha2d/jYr IGIiZk8M0TDYoevcmoZiU4rUUfxBB0x7eO9sg6aURyJ/4z/eVQfbS7FdKCpDzfVzBg/Z rWieJ71iJC+1lOaCJ8QO9ofn4V7PbvFE26eYCPCwTQ+PfRGEZFYatK3LH7mIahxdMEm3 89X4hjWeQJLnLbew0D6g2IV+m+6MH1OAd+MwFguvevngIE/+BFwXAk+iR7ixQ8MmIYGD HA6QcQSNIboNDObvqWFqAl+TLyFVP6cEBFb6Lqwje1rpUcrkls1oM6uwGsbjplNWPpbT Rg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k9b7swc7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Oct 2022 23:49:39 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29LMgIQT007144; Fri, 21 Oct 2022 23:49:39 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8hre9a3b-3; Fri, 21 Oct 2022 23:49:39 +0000 From: Si-Wei Liu To: mst@redhat.com, jasowang@redhat.com, parav@nvidia.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/4] vdpa: pass initial config to _vdpa_register_device() Date: Fri, 21 Oct 2022 15:43:55 -0700 Message-Id: <1666392237-4042-3-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666392237-4042-1-git-send-email-si-wei.liu@oracle.com> References: <1666392237-4042-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-21_04,2022-10-21_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210139 X-Proofpoint-GUID: i-UeKb6RIh-aSPzyS2heCENj2RNPyc5M X-Proofpoint-ORIG-GUID: i-UeKb6RIh-aSPzyS2heCENj2RNPyc5M X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747343191308493051?= X-GMAIL-MSGID: =?utf-8?q?1747343191308493051?= Just as _vdpa_register_device taking @nvqs as the number of queues to feed userspace inquery via vdpa_dev_fill(), we can follow the same to stash config attributes in struct vdpa_device at the time of vdpa registration. Signed-off-by: Si-Wei Liu --- drivers/vdpa/ifcvf/ifcvf_main.c | 2 +- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- drivers/vdpa/vdpa.c | 15 +++++++++++---- drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 2 +- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 2 +- drivers/vdpa/vdpa_user/vduse_dev.c | 2 +- drivers/vdpa/virtio_pci/vp_vdpa.c | 3 ++- include/linux/vdpa.h | 3 ++- 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index f9c0044..c54ab2c 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -771,7 +771,7 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, else ret = dev_set_name(&vdpa_dev->dev, "vdpa%u", vdpa_dev->index); - ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring); + ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring, config); if (ret) { put_device(&adapter->vdpa.dev); IFCVF_ERR(pdev, "Failed to register to vDPA bus"); diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 9091336..376082e 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -3206,7 +3206,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, mlx5_notifier_register(mdev, &ndev->nb); ndev->nb_registered = true; mvdev->vdev.mdev = &mgtdev->mgtdev; - err = _vdpa_register_device(&mvdev->vdev, max_vqs + 1); + err = _vdpa_register_device(&mvdev->vdev, max_vqs + 1, add_config); if (err) goto err_reg; diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index febdc99..bebded6 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -215,11 +215,16 @@ static int vdpa_name_match(struct device *dev, const void *data) return (strcmp(dev_name(&vdev->dev), data) == 0); } -static int __vdpa_register_device(struct vdpa_device *vdev, u32 nvqs) +static int __vdpa_register_device(struct vdpa_device *vdev, u32 nvqs, + const struct vdpa_dev_set_config *cfg) { struct device *dev; vdev->nvqs = nvqs; + if (cfg) + vdev->init_cfg = *cfg; + else + vdev->init_cfg.mask = 0ULL; lockdep_assert_held(&vdpa_dev_lock); dev = bus_find_device(&vdpa_bus, NULL, dev_name(&vdev->dev), vdpa_name_match); @@ -237,15 +242,17 @@ static int __vdpa_register_device(struct vdpa_device *vdev, u32 nvqs) * callback after setting up valid mgmtdev for this vdpa device. * @vdev: the vdpa device to be registered to vDPA bus * @nvqs: number of virtqueues supported by this device + * @cfg: initial config on vdpa device creation * * Return: Returns an error when fail to add device to vDPA bus */ -int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs) +int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs, + const struct vdpa_dev_set_config *cfg) { if (!vdev->mdev) return -EINVAL; - return __vdpa_register_device(vdev, nvqs); + return __vdpa_register_device(vdev, nvqs, cfg); } EXPORT_SYMBOL_GPL(_vdpa_register_device); @@ -262,7 +269,7 @@ int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs) int err; down_write(&vdpa_dev_lock); - err = __vdpa_register_device(vdev, nvqs); + err = __vdpa_register_device(vdev, nvqs, NULL); up_write(&vdpa_dev_lock); return err; } diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c index c6db1a1..5e1cebc 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c @@ -387,7 +387,7 @@ static int vdpasim_blk_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, if (IS_ERR(simdev)) return PTR_ERR(simdev); - ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_BLK_VQ_NUM); + ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_BLK_VQ_NUM, config); if (ret) goto put_dev; diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c index c3cb225..06ef5a0 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c @@ -260,7 +260,7 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, vdpasim_net_setup_config(simdev, config); - ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM); + ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM, config); if (ret) goto reg_err; diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 35dceee..6530fd2 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1713,7 +1713,7 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, if (ret) return ret; - ret = _vdpa_register_device(&dev->vdev->vdpa, dev->vq_num); + ret = _vdpa_register_device(&dev->vdev->vdpa, dev->vq_num, config); if (ret) { put_device(&dev->vdev->vdpa.dev); return ret; diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c index d448db0..ffdc90e 100644 --- a/drivers/vdpa/virtio_pci/vp_vdpa.c +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c @@ -538,7 +538,8 @@ static int vp_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, vp_vdpa->config_irq = VIRTIO_MSI_NO_VECTOR; vp_vdpa->vdpa.mdev = &vp_vdpa_mgtdev->mgtdev; - ret = _vdpa_register_device(&vp_vdpa->vdpa, vp_vdpa->queues); + ret = _vdpa_register_device(&vp_vdpa->vdpa, vp_vdpa->queues, + add_config); if (ret) { dev_err(&pdev->dev, "Failed to register to vdpa bus\n"); goto err; diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 9f519a3..e68ab65 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -381,7 +381,8 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent, int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs); void vdpa_unregister_device(struct vdpa_device *vdev); -int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs); +int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs, + const struct vdpa_dev_set_config *cfg); void _vdpa_unregister_device(struct vdpa_device *vdev); /** From patchwork Fri Oct 21 22:43:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 7030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp956292wrr; Fri, 21 Oct 2022 16:52:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6YRAPFRspkyXm+5Z0dZALkkSYG+Td1lz2TdD+uOR8bQ/P8z7FMXp7/mm7WzMRiuMqT2nq1 X-Received: by 2002:a17:907:c27:b0:791:81f2:f2b1 with SMTP id ga39-20020a1709070c2700b0079181f2f2b1mr18055863ejc.436.1666396324899; Fri, 21 Oct 2022 16:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666396324; cv=none; d=google.com; s=arc-20160816; b=jzJGpVjgSAt1Hff5HVk/Y1HgXT7fNgiY77h6BfSY3OBNYdK+fGTDq4xIMrWVg4Deal 5LdKltaiJoBxfDYJTmPZAoJrcIwQzPbC26bqcFi1I+pbYA1+Sj133zoX0zGS1FY9vbrQ az8qiTLmVnxJ8IfUjrgTrqyohffYX/SO2XHIa15wvNdTzyNfV9h3lTG6V+v9pabuqxl9 ibq8wp3wlfvzBC2071XqjOvYnVeJAU8JxqH1sggHXqppTZqfkQgQDY4Wyzl6gsUmXcPm Mpd9kPWtR89Asp5Ucc1aIUTDlKhM6vOv6opQOcifjqQHYwhZUg+MkfbbmJnpoY0OLlU+ 9QBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=+ERFyiHXEdvrz8E3RvSkJniqhhPRKAx1foTvxjTTKEA=; b=xbFwlWRHcf02+4yVABBC1Jjmj12uSp3TRaAiXTE8u9hRmRebcr5h0/wU5svQ2op8yE YFWoc4syfjaentkT8RfvcbyIzFpZ70BQDLCHMokHEYBX9Jepso+3kh/t1TC5R1dq4XCs Y17iFWttMPiLy6frCCY14JT4DLjlR/Y7YHdN0VZyvxlAqeT3VRYI3Tik9ubm5+2+wbkn /XB3/DTYE63qgYrKhSFN5ZVS1VsfYFlb3nSnNAkhLj0X80NfKnsl7sUForaI0YFWpebj 22T8LJqOE9e7NbaLaTWZgKWk2zEQXvKXKdADMTU3D2j4lVTcrw0Le5ZSYGMvNeRJUoWU O2QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=MS8hwiEw; 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=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a1709062a9300b0078d9b5792a0si19477591eje.319.2022.10.21.16.51.41; Fri, 21 Oct 2022 16:52:04 -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=@oracle.com header.s=corp-2022-7-12 header.b=MS8hwiEw; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbiJUXuH (ORCPT + 99 others); Fri, 21 Oct 2022 19:50:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbiJUXtq (ORCPT ); Fri, 21 Oct 2022 19:49:46 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1785936DDB for ; Fri, 21 Oct 2022 16:49:44 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29LLDn3t005590; Fri, 21 Oct 2022 23:49:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=+ERFyiHXEdvrz8E3RvSkJniqhhPRKAx1foTvxjTTKEA=; b=MS8hwiEwSILu/wE4cyRrnc49kdnE+NWUoQEPiZtWVekdU5e+KsUJO/YJ3lWavVEM9DEq li9O/2C/GpwDfJ0sje0lTpIsSmtcXWcOPpPhSsBPXhbrnutl/m7chrmFbOLE+oc+aWf6 Mmf81i7h9dw7WjxLyHzk5GhaCj/0hfE7fS/i4cBvD+/B4cgZ0/Ggw/tMrKwY6k2nxA8g 6f6Vs89ZMwUTvWvPcSkLyuE7uB+DwNFFsq/YzQRbquHmqcc+G/KFG9b/vec8CWlBHOEA VhgQFwW/eKVjb+ZvM6vGOWK+pkp2nLxN4aTisSjtOAxVkZVJQE5qGvbOpibEc+jN/9FA xA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7ndtucb5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Oct 2022 23:49:41 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29LMgIQU007144; Fri, 21 Oct 2022 23:49:39 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8hre9a3b-4; Fri, 21 Oct 2022 23:49:39 +0000 From: Si-Wei Liu To: mst@redhat.com, jasowang@redhat.com, parav@nvidia.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/4] vdpa: show dev config as-is in "vdpa dev show" output Date: Fri, 21 Oct 2022 15:43:56 -0700 Message-Id: <1666392237-4042-4-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666392237-4042-1-git-send-email-si-wei.liu@oracle.com> References: <1666392237-4042-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-21_04,2022-10-21_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210139 X-Proofpoint-ORIG-GUID: qjwBfrKXvfL1eemarairM2QD3NRCWguZ X-Proofpoint-GUID: qjwBfrKXvfL1eemarairM2QD3NRCWguZ X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747343193257523732?= X-GMAIL-MSGID: =?utf-8?q?1747343193257523732?= Live migration of vdpa would typically require re-instate vdpa device with an idential set of configs on the destination node, same way as how source node created the device in the first place. In order to save orchestration software from memorizing and keeping track of vdpa config, it will be helpful if the vdpa tool provides the aids for exporting the initial configs as-is, the way how vdpa device was created. The "vdpa dev show" command seems to be the right vehicle for that. It is unlike the "vdpa dev config show" command output which usually goes with the live value in the device config space, and is not quite reliable subject to the dynamics of feature negotiation or possible change by the driver to the config space. Examples: 1) Create vDPA by default without any config attribute $ vdpa dev add mgmtdev pci/0000:41:04.2 name vdpa0 $ vdpa dev show vdpa0 vdpa0: type network mgmtdev pci/0000:41:04.2 vendor_id 5555 max_vqs 9 max_vq_size 256 $ vdpa dev -jp show vdpa0 { "dev": { "vdpa0": { "type": "network", "mgmtdev": "pci/0000:41:04.2", "vendor_id": 5555, "max_vqs": 9, "max_vq_size": 256, } } } 2) Create vDPA with config attribute(s) specified $ vdpa dev add mgmtdev pci/0000:41:04.2 name vdpa0 \ mac e4:11:c6:d3:45:f0 max_vq_pairs 4 $ vdpa dev show vdpa0: type network mgmtdev pci/0000:41:04.2 vendor_id 5555 max_vqs 9 max_vq_size 256 initial_config: mac e4:11:c6:d3:45:f0 max_vq_pairs 4 $ vdpa dev -jp show { "dev": { "vdpa0": { "type": "network", "mgmtdev": "pci/0000:41:04.2", "vendor_id": 5555, "max_vqs": 9, "max_vq_size": 256, "initial_config": { "mac": "e4:11:c6:d3:45:f0", "max_vq_pairs": 4 } } } } Signed-off-by: Si-Wei Liu --- drivers/vdpa/vdpa.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index bebded6..bfb8f54 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -677,6 +677,41 @@ static int vdpa_nl_cmd_dev_del_set_doit(struct sk_buff *skb, struct genl_info *i } static int +vdpa_dev_initcfg_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 device_id) +{ + struct vdpa_dev_set_config *cfg = &vdev->init_cfg; + int err = -EMSGSIZE; + + if (!cfg->mask) + return 0; + + switch (device_id) { + case VIRTIO_ID_NET: + if ((cfg->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR)) != 0 && + nla_put(msg, VDPA_ATTR_DEV_NET_CFG_MACADDR, + sizeof(cfg->net.mac), cfg->net.mac)) + return err; + if ((cfg->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)) != 0 && + nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, cfg->net.mtu)) + return err; + if ((cfg->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP)) != 0 && + nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, + cfg->net.max_vq_pairs)) + return err; + break; + default: + break; + } + + if ((cfg->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) != 0 && + nla_put_u64_64bit(msg, VDPA_ATTR_DEV_FEATURES, + cfg->device_features, VDPA_ATTR_PAD)) + return err; + + return 0; +} + +static int vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq, int flags, struct netlink_ext_ack *extack) { @@ -715,6 +750,10 @@ static int vdpa_nl_cmd_dev_del_set_doit(struct sk_buff *skb, struct genl_info *i if (nla_put_u16(msg, VDPA_ATTR_DEV_MIN_VQ_SIZE, min_vq_size)) goto msg_err; + err = vdpa_dev_initcfg_fill(vdev, msg, device_id); + if (err) + goto msg_err; + genlmsg_end(msg, hdr); return 0; From patchwork Fri Oct 21 22:43:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 7031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp956368wrr; Fri, 21 Oct 2022 16:52:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Jru2FUU9HMUGo0R6IqX4A3jDA1aLTE8MDEa5Qt82qiaxkwwGOg8Tf5ahHY7Lt5X4AWsYv X-Received: by 2002:a17:907:7d8b:b0:78e:2534:4fd3 with SMTP id oz11-20020a1709077d8b00b0078e25344fd3mr18212360ejc.141.1666396339150; Fri, 21 Oct 2022 16:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666396339; cv=none; d=google.com; s=arc-20160816; b=e80iP84FEBeoGJ34DEHhKM87Q8DAA0QDttypUsDOcCYXxUVL383l2BwOImPgd3SYA1 DOLB8bkQM5mtaUsJUJlbQpz/Jwu7D4S1NimDPudzcMFAxxtDCOCPf+c4j8bTEH8ISOLU HxtAsVwAfoIT8WJ7AmuWBxn1P8ASN5DZFvBFsXhnEjzyz8CjnWQ7ysNWNzTT3YUn+GaL bxQs3G4Ob89rQkpZir8EUdQgG9yXvZBlWm1UVI3tGf9HIFzp1w9UyKvij3rF1YzYzsV8 OK/vEj9V45VIJMbsoVZGNkhBRsOluAbuW0Qm/dYmdcGP4nka+QoOiXIcNkwhBbDZZAa3 /j6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=FRx2Fg0cajst6kpPs94hDo0ddOOvTCD3LCs/N6K2pbQ=; b=o0O/StOE1YJEmt044CCrntfdn6ZaPUepksA/dyqDoDjqWFvbwZWSbUSGYoEQZJ4vw2 01oXHhurrsG9gxhs/hPxxzKMsKDxMoU/la2+USnF82p0MPIBiUuoU4YsWA0siYJ3dZVq TRr7PSlE7ilVW3TjCVc85QpZzdPh2UpVVGneBDbuy3LdUB2MDzPFGxIukvoWxWJEdkD+ HTUjGZuiT6FW6jBwA1xPaIrPdOnnQXbB+b0xgyIO9LAkw3xlvo0LmTMZea3Z8YGxAWqB PJooOh9WzNYrNuyyq0eKQ55uXWyCOQ1TKlEa/t1CYkYiSbkF+zIojTjJ6Cj4xlIp9JnF LAMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=zF7iufL3; 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=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp19-20020a170906c15300b0078c47b4478esi19886098ejc.106.2022.10.21.16.51.55; Fri, 21 Oct 2022 16:52:19 -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=@oracle.com header.s=corp-2022-7-12 header.b=zF7iufL3; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbiJUXuL (ORCPT + 99 others); Fri, 21 Oct 2022 19:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbiJUXtr (ORCPT ); Fri, 21 Oct 2022 19:49:47 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECF5732051 for ; Fri, 21 Oct 2022 16:49:45 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29LLDxSH010167; Fri, 21 Oct 2022 23:49:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=FRx2Fg0cajst6kpPs94hDo0ddOOvTCD3LCs/N6K2pbQ=; b=zF7iufL38/zGRCwoYPbt/hbLIZw7k3PD028Na914f3vBi+UzjQ7LbC1y/Oj/mxLwLXQa ZPME/xePngSQtu0WyW+6dSkCcpiPOyGhHY39l/5TRiiW+k5XYBEwgiUaYKiUsWWHB6uC 44xHe4x+FUqH8wgr98T+QlpAWeMq1DsE3dn12waMgwsG1cFkc+L5Wayu40vmOQW8WNnm uD754CBwvUmI51XLhOiuF7fb3rEVyLjzsrImu70FqvxgFJ+rZwX1lPIeyuzoHy9dwg4W 6JBgxrbVoSdhsKsLvtoFVAIZ8t9pyWRWpReohcgvwgPTnLchUWcy3b6DpizAriCR+pAI SQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k99ntpp4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Oct 2022 23:49:41 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29LMgIQV007144; Fri, 21 Oct 2022 23:49:39 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8hre9a3b-5; Fri, 21 Oct 2022 23:49:39 +0000 From: Si-Wei Liu To: mst@redhat.com, jasowang@redhat.com, parav@nvidia.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] vdpa: fix improper error message when adding vdpa dev Date: Fri, 21 Oct 2022 15:43:57 -0700 Message-Id: <1666392237-4042-5-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666392237-4042-1-git-send-email-si-wei.liu@oracle.com> References: <1666392237-4042-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-21_04,2022-10-21_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210139 X-Proofpoint-ORIG-GUID: RGN-ubRw9X1BKW1wArzcdeu-jrC-i3g3 X-Proofpoint-GUID: RGN-ubRw9X1BKW1wArzcdeu-jrC-i3g3 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747343207733907628?= X-GMAIL-MSGID: =?utf-8?q?1747343207733907628?= In below example, before the fix, mtu attribute is supported by the parent mgmtdev, but the error message showing "All provided are not supported" is just misleading. $ vdpa mgmtdev show vdpasim_net: supported_classes net max_supported_vqs 3 dev_features MTU MAC CTRL_VQ CTRL_MAC_ADDR ANY_LAYOUT VERSION_1 ACCESS_PLATFORM $ vdpa dev add mgmtdev vdpasim_net name vdpasim0 mtu 5000 max_vqp 2 Error: vdpa: All provided attributes are not supported. kernel answers: Operation not supported After fix, the relevant error message will be like: $ vdpa dev add mgmtdev vdpasim_net name vdpasim0 mtu 5000 max_vqp 2 Error: vdpa: Some provided attributes are not supported. kernel answers: Operation not supported $ vdpa dev add mgmtdev vdpasim_net name vdpasim0 max_vqp 2 Error: vdpa: All provided attributes are not supported. kernel answers: Operation not supported Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index bfb8f54..2638565 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -629,13 +629,20 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i err = PTR_ERR(mdev); goto err; } - if ((config.mask & mdev->config_attr_mask) != config.mask) { + if (config.mask && (config.mask & mdev->config_attr_mask) == 0) { NL_SET_ERR_MSG_MOD(info->extack, "All provided attributes are not supported"); err = -EOPNOTSUPP; goto err; } + if ((config.mask & mdev->config_attr_mask) != config.mask) { + NL_SET_ERR_MSG_MOD(info->extack, + "Some provided attributes are not supported"); + err = -EOPNOTSUPP; + goto err; + } + err = mdev->ops->dev_add(mdev, name, &config); err: up_write(&vdpa_dev_lock);