From patchwork Thu Sep 1 10:15:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12962248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3071FECAAD3 for ; Thu, 1 Sep 2022 10:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234152AbiIAKZF (ORCPT ); Thu, 1 Sep 2022 06:25:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234132AbiIAKY5 (ORCPT ); Thu, 1 Sep 2022 06:24:57 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23D1D767E; Thu, 1 Sep 2022 03:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662027895; x=1693563895; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9HjL/W+gmiSSE6abdxbrCjvq1RrEYFDNTS5WWx3pgq8=; b=O5bH6lSeSICePShjYlLL6xPzrY7X2vAYzfpHE7TPRCXg8LfhMiAJqOaZ wPd2Em1+nS7sHvJizbQWO1lWq4X3LBaaEwja8bcQMvSxPu6opoWCRYNMo U3a4VReViTEe0eGvoDFOO6dC7/QHNKF8SmZMp1mb8qVPChcQgNZgxIjB+ Ma0QC39aQDMJvInx9en7PRM5QuXgkbXF8EG+cZM4njTdVYAVe8csxhJRu FlgaHioBOoce/tR2W4L9m/q0YzulrnX9S+NmzG123pmoag+zEZ/ubS+4b do9ZMT6Sof/Vn5E7wfgl2buKM2q2lSGc0hYcYwalFEMJFVvEnFAKztil4 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="321825553" X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="321825553" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 03:24:54 -0700 X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="642276426" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 03:24:53 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, Zhu Lingshan Subject: [RFC 1/4] vDPA/ifcvf: add get/set_vq_endian support for vDPA Date: Thu, 1 Sep 2022 18:15:58 +0800 Message-Id: <20220901101601.61420-2-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220901101601.61420-1-lingshan.zhu@intel.com> References: <20220901101601.61420-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This commit introuduces new config operatoions for vDPA: vdpa_config_ops.get_vq_endian: set vq endian-ness vdpa_config_ops.set_vq_endian: get vq endian-ness Because the endian-ness is a device wide attribute, so seting a vq's endian-ness will result in changing the device endian-ness, including all vqs and the config space. These two operations are implemented in ifcvf in this commit. Signed-off-by: Zhu Lingshan --- drivers/vdpa/ifcvf/ifcvf_base.h | 1 + drivers/vdpa/ifcvf/ifcvf_main.c | 15 +++++++++++++++ include/linux/vdpa.h | 13 +++++++++++++ 3 files changed, 29 insertions(+) diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h index f5563f665cc6..640238b95033 100644 --- a/drivers/vdpa/ifcvf/ifcvf_base.h +++ b/drivers/vdpa/ifcvf/ifcvf_base.h @@ -19,6 +19,7 @@ #include #include #include +#include #define N3000_DEVICE_ID 0x1041 #define N3000_SUBSYS_DEVICE_ID 0x001A diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index f9c0044c6442..270637d0f3a5 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -684,6 +684,19 @@ static struct vdpa_notification_area ifcvf_get_vq_notification(struct vdpa_devic return area; } +static u8 ifcvf_vdpa_get_vq_endian(struct vdpa_device *vdpa_dev, u16 idx) +{ + return VHOST_VRING_LITTLE_ENDIAN; +} + +static int ifcvf_vdpa_set_vq_endian(struct vdpa_device *vdpa_dev, u16 idx, u8 endian) +{ + if (endian != VHOST_VRING_LITTLE_ENDIAN) + return -EFAULT; + + return 0; +} + /* * IFCVF currently doesn't have on-chip IOMMU, so not * implemented set_map()/dma_map()/dma_unmap() @@ -715,6 +728,8 @@ static const struct vdpa_config_ops ifc_vdpa_ops = { .set_config = ifcvf_vdpa_set_config, .set_config_cb = ifcvf_vdpa_set_config_cb, .get_vq_notification = ifcvf_get_vq_notification, + .get_vq_endian = ifcvf_vdpa_get_vq_endian, + .set_vq_endian = ifcvf_vdpa_set_vq_endian, }; static struct virtio_device_id id_table_net[] = { diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index d282f464d2f1..5eb83453ba86 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -174,6 +174,17 @@ struct vdpa_map_file { * @idx: virtqueue index * Returns int: irq number of a virtqueue, * negative number if no irq assigned. + * @set_vq_endian: set endian-ness for a virtqueue + * @vdev: vdpa device + * @idx: virtqueue index + * @endian: the endian-ness to set, + * can be VHOST_VRING_LITTLE_ENDIAN or VHOST_VRING_BIG_ENDIAN + * Returns integer: success (0) or error (< 0) + * @get_vq_endian: get the endian-ness of a virtqueue + * @vdev: vdpa device + * @idx: virtqueue index + * Returns u8, the endian-ness of the virtqueue, + * can be VHOST_VRING_LITTLE_ENDIAN or VHOST_VRING_BIG_ENDIAN * @get_vq_align: Get the virtqueue align requirement * for the device * @vdev: vdpa device @@ -306,6 +317,8 @@ struct vdpa_config_ops { (*get_vq_notification)(struct vdpa_device *vdev, u16 idx); /* vq irq is not expected to be changed once DRIVER_OK is set */ int (*get_vq_irq)(struct vdpa_device *vdev, u16 idx); + int (*set_vq_endian)(struct vdpa_device *vdev, u16 idx, u8 endian); + u8 (*get_vq_endian)(struct vdpa_device *vdev, u16 idx); /* Device ops */ u32 (*get_vq_align)(struct vdpa_device *vdev); From patchwork Thu Sep 1 10:15:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12962249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 179D7C64991 for ; Thu, 1 Sep 2022 10:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234156AbiIAKZJ (ORCPT ); Thu, 1 Sep 2022 06:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234136AbiIAKY6 (ORCPT ); Thu, 1 Sep 2022 06:24:58 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C76BC0A; Thu, 1 Sep 2022 03:24:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662027897; x=1693563897; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=naLk2YiNHCZm3464X+DKcA0rSEwd3MmdrZMnwC4yXq8=; b=L6PkeszHekLHuf9DuiKWN+3fWsBGjhYkXtzyz4JFFrGdJQlaML9egKmE 4PevFyMQPzPrV+5X7qeqYhoaB7dXXrp/z7ZDmDI2Dwx/CKawxjcyNQmk0 9mmJvt+R6pk9GfPSXYVGiXy1QR4rFQKtQGlIb8PHhl4+FdovasP3Zu0t4 ZN/KM0tSk+DVl4bZcyKxCxKBa6+qHJ71j/wnygNmJVdch7aAWDhU2OS7Q hEDqdeeBHYq9DqinGPhNdj2HIA6m5k1aPs3/3KSO4EUcV/vlCh0LV1gRH v1KXih+i7NkukbuzHI3sl1JS3DEY/opkRtuNrlyD7Ma7TjZybTb3S+cWk Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="321825558" X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="321825558" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 03:24:56 -0700 X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="642276438" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 03:24:55 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, Zhu Lingshan Subject: [RFC 2/4] vDPA: support ioctl VHOST_GET/SET_VRING_ENDIAN Date: Thu, 1 Sep 2022 18:15:59 +0800 Message-Id: <20220901101601.61420-3-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220901101601.61420-1-lingshan.zhu@intel.com> References: <20220901101601.61420-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This commit add ioctl VHOST_GET_VRING_ENDIAN and VHOST_SET_VRING_ENDIAN support for vhost_vdpa. So that QEMU can be aware of the endian-ness of the vDPA device. Signed-off-by: Zhu Lingshan --- drivers/vhost/vdpa.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 166044642fd5..084fbf04c6bb 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -547,11 +547,41 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, vq->last_avail_idx = vq_state.split.avail_index; break; - } + case VHOST_SET_VRING_ENDIAN: + if (!ops->set_vq_endian) + return -EOPNOTSUPP; + + if (copy_from_user(&s, argp, sizeof(s))) + return -EFAULT; + + if (s.num != VHOST_VRING_LITTLE_ENDIAN && + s.num != VHOST_VRING_BIG_ENDIAN) + return -EINVAL; + + if (ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK) + return -EFAULT; + + r = ops->set_vq_endian(vdpa, s.index, s.num); + if (r) + return -EFAULT; + + return 0; + case VHOST_GET_VRING_ENDIAN: + if (!ops->get_vq_endian) + return -EOPNOTSUPP; + + s.index = idx; + s.num = ops->get_vq_endian(vdpa, idx); + + if (copy_to_user(argp, &s, sizeof(s))) + return -EFAULT; + + return 0; r = vhost_vring_ioctl(&v->vdev, cmd, argp); if (r) return r; + } switch (cmd) { case VHOST_SET_VRING_ADDR: From patchwork Thu Sep 1 10:16:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12962251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D236ECAAD1 for ; Thu, 1 Sep 2022 10:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233997AbiIAKZN (ORCPT ); Thu, 1 Sep 2022 06:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234100AbiIAKZA (ORCPT ); Thu, 1 Sep 2022 06:25:00 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 003DCDEF6; Thu, 1 Sep 2022 03:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662027898; x=1693563898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IP+YY7Vlyu3Y2ILLuj9EI+J4/4vQcHrQeC3vNdfstEk=; b=ISpZ6M35BSuFwukjAOn9I6RGwNw1ISc7Gt3/H39T8X0cIzyhsM3X/Ndq ebk/F1l660cN2cqMqsMPRH0d5+WKYgcjpZDC8Z1elzC+ih/B6FDrrG/UF FU6WCOMvlB41tNtGB42PuBsZ7Vvj80BFobSpUQRjR2I/x7/7oMcaQLH4/ KGIp6cUbfzjL9DbWJzzaG3hBEgJ/ABURwgwNEXgq95/X4fK73gxx7telX oVYg4s1KSjR1GQAN4Ku+w0DKMeAc2X4knPN0LHxK6cnUHCg+mDEMG6sMU Vdspk0/eMglbdZJ8c6k2urcADvkzGGfnzwRO0uWln0PnCiRBWJqudZ9B+ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="321825560" X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="321825560" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 03:24:58 -0700 X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="642276444" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 03:24:56 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, Zhu Lingshan Subject: [RFC 3/4] vDPA: detect device endian in _net_config_fill() and _fill_stats_rec() Date: Thu, 1 Sep 2022 18:16:00 +0800 Message-Id: <20220901101601.61420-4-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220901101601.61420-1-lingshan.zhu@intel.com> References: <20220901101601.61420-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This commit detect endian-ness of the device by vdpa_config_ops.get_vq_endian(), so that functions vdpa_dev_net_config_fill() and vdpa_fill_stats_rec() can convert the endian-ness correctly by __virtio16_to_cpu(). Signed-off-by: Zhu Lingshan --- drivers/vdpa/vdpa.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index c06c02704461..8a08caf573d1 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -814,21 +815,31 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg) { + const struct vdpa_config_ops *ops = vdev->config; struct virtio_net_config config = {}; u64 features; u16 val_u16; + u8 le; - vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); + ops->get_config(vdev, 0, &config, sizeof(config)); + + /* endian-ness is a device wide attr, so reading the endian-ness of vq0 + * can get the endian-ness of the device config space. + */ + if (ops->get_vq_endian(vdev, 0) == VHOST_VRING_LITTLE_ENDIAN) + le = true; + else + le = false; if (nla_put(msg, VDPA_ATTR_DEV_NET_CFG_MACADDR, sizeof(config.mac), config.mac)) return -EMSGSIZE; - val_u16 = __virtio16_to_cpu(true, config.status); + val_u16 = __virtio16_to_cpu(le, config.status); if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_STATUS, val_u16)) return -EMSGSIZE; - val_u16 = __virtio16_to_cpu(true, config.mtu); + val_u16 = __virtio16_to_cpu(le, config.mtu); if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16)) return -EMSGSIZE; @@ -897,6 +908,7 @@ static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg, u16 max_vqp; u8 status; int err; + u8 le; status = vdev->config->get_status(vdev); if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) { @@ -905,7 +917,15 @@ static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg, } vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); - max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs); + /* endian-ness is a device wide attr, so reading the endian-ness of vq0 + * can get the endian-ness of the device config space. + */ + if (vdev->config->get_vq_endian(vdev, 0) == VHOST_VRING_LITTLE_ENDIAN) + le = true; + else + le = false; + + max_vqp = __virtio16_to_cpu(le, config.max_virtqueue_pairs); if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, max_vqp)) return -EMSGSIZE; From patchwork Thu Sep 1 10:16:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12962250 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2D46ECAAD1 for ; Thu, 1 Sep 2022 10:25:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234161AbiIAKZK (ORCPT ); Thu, 1 Sep 2022 06:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234119AbiIAKZC (ORCPT ); Thu, 1 Sep 2022 06:25:02 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC64CF582; Thu, 1 Sep 2022 03:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662027900; x=1693563900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z5PGIJ24d2/V8jR3uKC69UP3AbGrpcu/ETrBJkm8rrQ=; b=UBsawSrK26fpjiAP0v2ToxrAYYK/Orhpbb0jaeKjBIIwRmMuSHvXnMpI +neiY4i3cEnQLTP7dXPwrCSvNlh1e4AGrNuQ1xlPyEyKRMn8XexddzcPH dKS2tOJxS4sBnnV1rcfb8fJUaixywhN4KTMFWF6HpCHJb0S2DYI1o/Kox 4IvL0kxu28iBrj/84EUESyr32zRo83jLDVbYXNWz0eE3I/favNdEmUc0k tlvnSqSlJWTibwKOhzPr0XBPIGYMe8/V0Vj5HfIi/dihud3ubYYKTmdMp l/oUaGDSrHh2N5pM6g/M2oCgvgi5hpLqsa2C44MvXm+8NPVxqbZGbiAjR w==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="321825567" X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="321825567" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 03:25:00 -0700 X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="642276453" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 03:24:58 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, Zhu Lingshan Subject: [RFC 4/4] vDPA: report device endian-ness to userspace through netlink Date: Thu, 1 Sep 2022 18:16:01 +0800 Message-Id: <20220901101601.61420-5-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220901101601.61420-1-lingshan.zhu@intel.com> References: <20220901101601.61420-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This commit introduces a new netlink attr VDPA_ATTR_DEV_ENDIAN to report device endian-ness to usersapce. So the userspace tools can be aware of the endian-ness of the device, even uninitialized legacy/transitional devices. Signed-off-by: Zhu Lingshan --- drivers/vdpa/vdpa.c | 3 +++ include/uapi/linux/vdpa.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 8a08caf573d1..d361f951ff63 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -848,6 +848,9 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms VDPA_ATTR_PAD)) return -EMSGSIZE; + if (nla_put_u8(msg, VDPA_ATTR_DEV_ENDIAN, le)) + return -EMSGSIZE; + return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config); } diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h index 25c55cab3d7c..bb9797781f97 100644 --- a/include/uapi/linux/vdpa.h +++ b/include/uapi/linux/vdpa.h @@ -51,6 +51,7 @@ enum vdpa_attr { VDPA_ATTR_DEV_QUEUE_INDEX, /* u32 */ VDPA_ATTR_DEV_VENDOR_ATTR_NAME, /* string */ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE, /* u64 */ + VDPA_ATTR_DEV_ENDIAN, /* u8 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,