Received: by 2002:a19:651b:0:0:0:0:0 with SMTP id z27csp3615925lfb; Mon, 9 May 2022 00:06:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVRJ98cvPmeI4ZC73ajsCRRuCz5Z41wOARXo6nS7+R6RlL5n0M27xUbPcS772qGL83PyLy X-Received: by 2002:a63:6bca:0:b0:3c2:13bc:2706 with SMTP id g193-20020a636bca000000b003c213bc2706mr12159448pgc.464.1652080015361; Mon, 09 May 2022 00:06:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652080015; cv=pass; d=google.com; s=arc-20160816; b=cHGPH2g+Kwjk8aaIZah/k8bzeR50LENuJay8aaZHt01w7xrODEaKZhHjObaeTs2inx fskN30aAyAP9rnwyTI6nfM+A0wLFKhbebN8mDNzgB87bNnuqq3oekaziTRruJ0oJ0uUb sZtUnaVu8pIv0V4jrm/C+WZOhR+duQS0dDi707w5QrabEm1i0lZUMKPpYVAa54Rd4U5v wkBgWRw+CZhQ8fn8da3LTlLi88/Csf2OeVAxGKoDy9Hzx6itq8f/w/PByPNcJAWAe7iM yvlusotWnnQ/RZNFEjSwsNY1zp5WyaDPYree7SEoEdcWrVvbE2+8MN4d1FOBxgSyoMmU zmtg== ARC-Message-Signature: i=2; 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=RQuTHzasEqSzs5tPz7rDY5DcNEuN5dY/MdYtSZGR+4Q=; b=qqC9kd7JvXeiN0+/NLtaB6dGALaiYMCTbc0NUP0ae5ph18yCgXMxtyzlZgeH6resc3 iPlMI38yeg+LPcU0kzqB0QasPs/L64xftsMD/XZDAC/j3LoXM3xxzKUxMEAYT+aNj95N RDZZjuUNZiBYTU8tSZlrub55L/EFOApN8I7bHEUIz7XaxrHxi+eJdwM71kG0PMA+S2eN umq/mnzRCGrvfElxyJUenWgmJM3hYqYF5GUKzY4qLqanH1FF3qDoOgupTH2Vsext3tG9 3lhwge1O/gFkw+wlJ1o+AIXPRwUWQve3EO0xgVpx12KID6vqWY83nsqJ4B0PVD/pHeZG WJqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ltVpW96K; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t10-20020a654b8a000000b003c6086f7cb8si14024785pgq.431.2022.05.09.00.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 00:06:55 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ltVpW96K; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2853F1A8DFB; Mon, 9 May 2022 00:04:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235871AbiEHQhc (ORCPT + 99 others); Sun, 8 May 2022 12:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235861AbiEHQh3 (ORCPT ); Sun, 8 May 2022 12:37:29 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2059.outbound.protection.outlook.com [40.107.220.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB480BE1F for ; Sun, 8 May 2022 09:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gmZqQaY1zRmCVw0EY/51gHu2g84ZAMKdkbNkslCITYOmJOAfIJDIwsHj/18/MWbAQWiWasVxtt4xifEPwmlu8yANby6KHslZH5AYA5zGnJTdGjKX4uhOjn84sZKiCJiUMLH3yipSh7VYemoV+7o1/avzDhbuzV3xh69y5Y7h4P12UrA8fc99nQj8/iUTsumU8VbrxU5TH4nDt4bz33DziNZyAb6IO9S6plIJBFrtUVn/8kx261Jgv8ofEg/Y6yhxoNmW3CDcbR6I5UiMKkJxzldBDUKxtLa1wYXVbth3AtDRBmP38r6avz++eUfhLUZHWDbgkdlAqLVfXtduirrTqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RQuTHzasEqSzs5tPz7rDY5DcNEuN5dY/MdYtSZGR+4Q=; b=YbtTBqP3HyxO1wnQXveMHbbYOPd+K4EIRBvgtpR8pvWwy2MEKy7F6Qrrp+pE1YORlIAKzNRAAPFuXFoUMFhtgjrS995n1a5IBaoMwPb+uEOtdJxc+5BU2i3WTP7tNI6WHIbq0UQ6qEpAJYLF2itJzcA7cl6BoY1hMBVLdsqNaCDXNcuHRhC3QDdXF8lAakYLHhW4J2KwoC78P9CYon/TXVHGaOHM98VT2ituQGIbWijptHrBPociyRJgtT6XyL6f+vkF/WqhCnD44o4hM0i17x3FlsjXDEmK5Tyvl7R+S9fG5glmhnZFm6h2Dlly4Aq/QyFWjB9xPtvBOHBCY6v8OA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RQuTHzasEqSzs5tPz7rDY5DcNEuN5dY/MdYtSZGR+4Q=; b=ltVpW96KV36j8w0Nl7uF5Y9FTAv9U9v0yOunXmAZdkJl0Ls4iWROGlxXDs6tNzR6h9LVxVXv6CiJUzFYaFXULl4l+v52bJU4U1O66p64MBaIy5to05jrrOu00rS4n7gocyR3J6zTnJpM9uP/6AFRW36i2nud2ei/CHeZ2pJ3G1kEhSAkivNO3/SdkGLo4bHIYTFPyF+U0I5Dow+hiIow0GytOcnS6D+eeiYkAVNDlVizgzMsYwnv84Mac7Ca738qehrpq5dNpad672I4Cq2poWjJ8c88P75JZ4EJB713LPlnVuMDpnkcJ5ArXZKEH+IUqUz/lFZiCM1aSpb7EZwN3w== Received: from DS7P222CA0017.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::26) by DM6PR12MB3995.namprd12.prod.outlook.com (2603:10b6:5:1c6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.20; Sun, 8 May 2022 16:33:33 +0000 Received: from DM6NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::f6) by DS7P222CA0017.outlook.office365.com (2603:10b6:8:2e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.20 via Frontend Transport; Sun, 8 May 2022 16:33:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT008.mail.protection.outlook.com (10.13.172.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5227.15 via Frontend Transport; Sun, 8 May 2022 16:33:32 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Sun, 8 May 2022 16:33:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Sun, 8 May 2022 09:33:31 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Sun, 8 May 2022 09:33:29 -0700 From: Eli Cohen To: , CC: , , , Eli Cohen Subject: [PATCH v4 2/3] vdpa: Add support for querying vendor statistics Date: Sun, 8 May 2022 19:33:16 +0300 Message-ID: <20220508163317.204673-3-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220508163317.204673-1-elic@nvidia.com> References: <20220508163317.204673-1-elic@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a8c638a-7289-4ab4-ff80-08da31107e0d X-MS-TrafficTypeDiagnostic: DM6PR12MB3995:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2ZB2LlDtgxmrjcDcHHsAmxbJ6yMOoUhF5Mo1yeReP+n+KA8zTPdPa/3vwx4gk4rHKp1Nd0v3e8G91AYjM5P+DUS+gKYUSFIViRjexTTQPo4Wag30+7/Bp+LPqv9d1ISIgxnA0IAgx+ZCXajNScJ8UxqjEAgPE6N9CN6E9sUhxXZuzFEqNOOlvnODtZa25JyoUg9DOZdCCZROkD9p+iMlwFQa7amUsFLbXDF7hFJ8BhOy25+nVRCFVO8CZ8xw9xQh9pYPDGunSjfrOM07E0jF/Q1EyC2gM3UmPDDSwE+1/aY5o62y8zat1UCuigprWrE2lcVGV3pAEyBwt0ZK7pqjL+vCOtKNwKH5AhJaGmqM9MNe2BhflAx/gSLpYHnez5jlDllxE19YHXZyNiJya8owjsQ0FKtZ94YqZepQ5IF/1yOfDwLa2lkR74ZZwFFjbLib6gp3ET5gDn/+NOygxyvADXuq3MTcMinchGAqYK91f6R64nKIMObYjJJxDyGedXTfMXwoOVdZhVMSmHuclkB14+vnXYeIxc0eCird8dSGHfZNx4FX1mRYIbsCUGt+k1rih7xS96jMhpuok+04ahGpMdiHqG6XkDNAZSzgDX+5SdhbvM3CtUjFSrQbPnpQf6tyhvpVQZ/X9YksP/16ZJQyCSEFm8JINP6a19si7EP0xZQLRkTmfe+77lUJdmyjeSfWue2Rt9HGzgOv2otkz3OY2w== X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(356005)(2616005)(82310400005)(5660300002)(110136005)(36756003)(83380400001)(8936002)(1076003)(107886003)(508600001)(6666004)(70586007)(26005)(70206006)(47076005)(426003)(316002)(4326008)(54906003)(8676002)(336012)(81166007)(40460700003)(2906002)(186003)(7696005)(36860700001)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2022 16:33:32.9024 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a8c638a-7289-4ab4-ff80-08da31107e0d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3995 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Allows to read vendor statistics of a vdpa device. The specific statistics data are received from the upstream driver in the form of an (attribute name, attribute value) pairs. An example of statistics for mlx5_vdpa device are: received_desc - number of descriptors received by the virtqueue completed_desc - number of descriptors completed by the virtqueue A descriptor using indirect buffers is still counted as 1. In addition, N chained descriptors are counted correctly N times as one would expect. A new callback was added to vdpa_config_ops which provides the means for the vdpa driver to return statistics results. The interface allows for reading all the supported virtqueues, including the control virtqueue if it exists. Below are some examples taken from mlx5_vdpa which are introduced in the following patch: 1. Read statistics for the virtqueue at index 1 $ vdpa dev vstats show vdpa-a qidx 1 vdpa-a: queue_type tx queue_index 1 received_desc 3844836 completed_desc 3844836 2. Read statistics for the virtqueue at index 32 $ vdpa dev vstats show vdpa-a qidx 32 vdpa-a: queue_type control_vq queue_index 32 received_desc 62 completed_desc 62 3. Read statisitics for the virtqueue at index 0 with json output $ vdpa -j dev vstats show vdpa-a qidx 0 {"vstats":{"vdpa-a":{ "queue_type":"rx","queue_index":0,"name":"received_desc","value":417776,\ "name":"completed_desc","value":417548}}} 4. Read statistics for the virtqueue at index 0 with preety json output $ vdpa -jp dev vstats show vdpa-a qidx 0 { "vstats": { "vdpa-a": { "queue_type": "rx", "queue_index": 0, "name": "received_desc", "value": 417776, "name": "completed_desc", "value": 417548 } } } Signed-off-by: Eli Cohen --- drivers/vdpa/vdpa.c | 130 ++++++++++++++++++++++++++++++++++++++ include/linux/vdpa.h | 5 ++ include/uapi/linux/vdpa.h | 6 ++ 3 files changed, 141 insertions(+) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index fac89a0d8178..ca808bfcd8d3 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -914,6 +914,74 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, return err; } +static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg, + struct genl_info *info, u32 index) +{ + int err; + + err = vdev->config->get_vendor_vq_stats(vdev, index, msg, info->extack); + if (err) + return err; + + if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index)) + return -EMSGSIZE; + + return 0; +} + +static int vendor_stats_fill(struct vdpa_device *vdev, struct sk_buff *msg, + struct genl_info *info, u32 index) +{ + int err; + + if (!vdev->config->get_vendor_vq_stats) + return -EOPNOTSUPP; + + err = vdpa_fill_stats_rec(vdev, msg, info, index); + if (err) + return err; + + return 0; +} + +static int vdpa_dev_vendor_stats_fill(struct vdpa_device *vdev, + struct sk_buff *msg, + struct genl_info *info, u32 index) +{ + u32 device_id; + void *hdr; + int err; + u32 portid = info->snd_portid; + u32 seq = info->snd_seq; + u32 flags = 0; + + hdr = genlmsg_put(msg, portid, seq, &vdpa_nl_family, flags, + VDPA_CMD_DEV_VSTATS_GET); + if (!hdr) + return -EMSGSIZE; + + if (nla_put_string(msg, VDPA_ATTR_DEV_NAME, dev_name(&vdev->dev))) { + err = -EMSGSIZE; + goto undo_msg; + } + + device_id = vdev->config->get_device_id(vdev); + if (nla_put_u32(msg, VDPA_ATTR_DEV_ID, device_id)) { + err = -EMSGSIZE; + goto undo_msg; + } + + err = vendor_stats_fill(vdev, msg, info, index); + + genlmsg_end(msg, hdr); + + return err; + +undo_msg: + genlmsg_cancel(msg, hdr); + return err; +} + static int vdpa_nl_cmd_dev_config_get_doit(struct sk_buff *skb, struct genl_info *info) { struct vdpa_device *vdev; @@ -995,6 +1063,61 @@ vdpa_nl_cmd_dev_config_get_dumpit(struct sk_buff *msg, struct netlink_callback * return msg->len; } +static int vdpa_nl_cmd_dev_stats_get_doit(struct sk_buff *skb, + struct genl_info *info) +{ + struct vdpa_device *vdev; + struct sk_buff *msg; + const char *devname; + struct device *dev; + u32 index; + int err; + + if (!info->attrs[VDPA_ATTR_DEV_NAME]) + return -EINVAL; + + if (!info->attrs[VDPA_ATTR_DEV_QUEUE_INDEX]) + return -EINVAL; + + devname = nla_data(info->attrs[VDPA_ATTR_DEV_NAME]); + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return -ENOMEM; + + index = nla_get_u32(info->attrs[VDPA_ATTR_DEV_QUEUE_INDEX]); + mutex_lock(&vdpa_dev_mutex); + dev = bus_find_device(&vdpa_bus, NULL, devname, vdpa_name_match); + if (!dev) { + NL_SET_ERR_MSG_MOD(info->extack, "device not found"); + err = -ENODEV; + goto dev_err; + } + vdev = container_of(dev, struct vdpa_device, dev); + if (!vdev->mdev) { + NL_SET_ERR_MSG_MOD(info->extack, "unmanaged vdpa device"); + err = -EINVAL; + goto mdev_err; + } + err = vdpa_dev_vendor_stats_fill(vdev, msg, info, index); + if (err) { + NL_SET_ERR_MSG_MOD(info->extack, "unmanaged vdpa device"); + goto mdev_err; + } + err = genlmsg_reply(msg, info); + + put_device(dev); + mutex_unlock(&vdpa_dev_mutex); + + return err; + +mdev_err: + put_device(dev); +dev_err: + nlmsg_free(msg); + mutex_unlock(&vdpa_dev_mutex); + return err; +} + static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_MGMTDEV_BUS_NAME] = { .type = NLA_NUL_STRING }, [VDPA_ATTR_MGMTDEV_DEV_NAME] = { .type = NLA_STRING }, @@ -1002,6 +1125,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR, /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_QUEUE_INDEX] = NLA_POLICY_RANGE(NLA_U32, 0, 65535), }; static const struct genl_ops vdpa_nl_ops[] = { @@ -1035,6 +1159,12 @@ static const struct genl_ops vdpa_nl_ops[] = { .doit = vdpa_nl_cmd_dev_config_get_doit, .dumpit = vdpa_nl_cmd_dev_config_get_dumpit, }, + { + .cmd = VDPA_CMD_DEV_VSTATS_GET, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .doit = vdpa_nl_cmd_dev_stats_get_doit, + .flags = GENL_ADMIN_PERM, + }, }; static struct genl_family vdpa_nl_family __ro_after_init = { diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 8943a209202e..48ed1fc00830 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -276,6 +276,9 @@ struct vdpa_config_ops { const struct vdpa_vq_state *state); int (*get_vq_state)(struct vdpa_device *vdev, u16 idx, struct vdpa_vq_state *state); + int (*get_vendor_vq_stats)(struct vdpa_device *vdev, u16 idx, + struct sk_buff *msg, + struct netlink_ext_ack *extack); struct vdpa_notification_area (*get_vq_notification)(struct vdpa_device *vdev, u16 idx); /* vq irq is not expected to be changed once DRIVER_OK is set */ @@ -473,4 +476,6 @@ struct vdpa_mgmt_dev { int vdpa_mgmtdev_register(struct vdpa_mgmt_dev *mdev); void vdpa_mgmtdev_unregister(struct vdpa_mgmt_dev *mdev); +#define VDPA_INVAL_QUEUE_INDEX 0xffff + #endif /* _LINUX_VDPA_H */ diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h index 1061d8d2d09d..25c55cab3d7c 100644 --- a/include/uapi/linux/vdpa.h +++ b/include/uapi/linux/vdpa.h @@ -18,6 +18,7 @@ enum vdpa_command { VDPA_CMD_DEV_DEL, VDPA_CMD_DEV_GET, /* can dump */ VDPA_CMD_DEV_CONFIG_GET, /* can dump */ + VDPA_CMD_DEV_VSTATS_GET, }; enum vdpa_attr { @@ -46,6 +47,11 @@ enum vdpa_attr { VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS, /* u32 */ VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */ + + VDPA_ATTR_DEV_QUEUE_INDEX, /* u32 */ + VDPA_ATTR_DEV_VENDOR_ATTR_NAME, /* string */ + VDPA_ATTR_DEV_VENDOR_ATTR_VALUE, /* u64 */ + /* new attributes must be added above here */ VDPA_ATTR_MAX, }; -- 2.35.1