Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1825901imu; Wed, 21 Nov 2018 02:32:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xh6W5y1pAIpFv25ZoohMtfC1wRSw0kTFHimWknKBJeS+ie/TYkw+Sn+QbiDc7WUz8qzCEU X-Received: by 2002:a63:1848:: with SMTP id 8mr5374758pgy.81.1542796355770; Wed, 21 Nov 2018 02:32:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542796355; cv=none; d=google.com; s=arc-20160816; b=XOm+4rwuFRmCMvCUIshp4EDU//esurxqjioYLG/L15XIoL4+aasx8ixgSRbzBy1pgY zuXhIjfVE6VLznbwf1IBuwl8+PBjMIg0bcaJG9+Cl5+DO5oHNBtyZyzU4Sd1J2zsLXNC dUyPxSPhJwSaa06TsaSqc7PFaHSwd0spujf6uHiwtJhdVsnfvWZxTzkORGOGTeh3b8QO OdtkT3GgJuHP2qQl/BCyiQAGfz5v4t40BfPbTG0AAjJKsVH9rdC4KcSQE1Iz54HLw31z vC7yNfSFJHU0PafPoHEeDfyUE8ECukXesUpOG7tUHE9SNCtvdXE2+fxtxpf3e/rqX+tU 3etg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=gy6+kVEQMSWT3pXXPWTYNAfa5VfC5sSk97f1OIy+03g=; b=TOkISVlHFIRNEXWRGb76R55NcQxp3N86ewof2J6xM1sMYLjwdUw1kkHn4Y1rPNndZ6 JEQXdyFJo7CKsm/8dGmA+4FoGXLtB1yrcPFIebf70GwQAQc/Oi4k1w50FxKfFJuJ5493 viL9N4oPp+UjYnVG+zuBoetyD3uUj1Nh3IcEr8+/f+mW+96koVbzOrtHN1nroYEGSQp+ aPmmqLEaFjQmgVDjuRr4zu0wbuiVf89iTCsK9JAtYzkAcwUjJgqC2eEXv1L+8luWmVyc jVNKxvypqJYOjvvxrkGiy5u6YDsSWKf8wN5GGUOv/FlaKYcZuLon7VjKuKYARDyCBcuc E/9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k72si43090272pge.310.2018.11.21.02.32.19; Wed, 21 Nov 2018 02:32:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729402AbeKUUjP (ORCPT + 99 others); Wed, 21 Nov 2018 15:39:15 -0500 Received: from mga18.intel.com ([134.134.136.126]:14789 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbeKUUjO (ORCPT ); Wed, 21 Nov 2018 15:39:14 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2018 02:05:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,260,1539673200"; d="scan'208";a="275727007" Received: from btwcube1.sh.intel.com ([10.67.104.173]) by orsmga005.jf.intel.com with ESMTP; 21 Nov 2018 02:05:23 -0800 From: Tiwei Bie To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, virtio-dev@lists.oasis-open.org Cc: wexu@redhat.com, jfreimann@redhat.com, maxime.coquelin@redhat.com, tiwei.bie@intel.com Subject: [PATCH net-next v3 01/13] virtio: add packed ring types and macros Date: Wed, 21 Nov 2018 18:03:18 +0800 Message-Id: <20181121100330.24846-2-tiwei.bie@intel.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181121100330.24846-1-tiwei.bie@intel.com> References: <20181121100330.24846-1-tiwei.bie@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add types and macros for packed ring. Signed-off-by: Tiwei Bie --- include/uapi/linux/virtio_config.h | 3 +++ include/uapi/linux/virtio_ring.h | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h index 449132c76b1c..1196e1c1d4f6 100644 --- a/include/uapi/linux/virtio_config.h +++ b/include/uapi/linux/virtio_config.h @@ -75,6 +75,9 @@ */ #define VIRTIO_F_IOMMU_PLATFORM 33 +/* This feature indicates support for the packed virtqueue layout. */ +#define VIRTIO_F_RING_PACKED 34 + /* * Does the device support Single Root I/O Virtualization? */ diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index 6d5d5faa989b..2414f8af26b3 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h @@ -44,6 +44,13 @@ /* This means the buffer contains a list of buffer descriptors. */ #define VRING_DESC_F_INDIRECT 4 +/* + * Mark a descriptor as available or used in packed ring. + * Notice: they are defined as shifts instead of shifted values. + */ +#define VRING_PACKED_DESC_F_AVAIL 7 +#define VRING_PACKED_DESC_F_USED 15 + /* The Host uses this in used->flags to advise the Guest: don't kick me when * you add a buffer. It's unreliable, so it's simply an optimization. Guest * will still kick if it's out of buffers. */ @@ -53,6 +60,23 @@ * optimization. */ #define VRING_AVAIL_F_NO_INTERRUPT 1 +/* Enable events in packed ring. */ +#define VRING_PACKED_EVENT_FLAG_ENABLE 0x0 +/* Disable events in packed ring. */ +#define VRING_PACKED_EVENT_FLAG_DISABLE 0x1 +/* + * Enable events for a specific descriptor in packed ring. + * (as specified by Descriptor Ring Change Event Offset/Wrap Counter). + * Only valid if VIRTIO_RING_F_EVENT_IDX has been negotiated. + */ +#define VRING_PACKED_EVENT_FLAG_DESC 0x2 + +/* + * Wrap counter bit shift in event suppression structure + * of packed ring. + */ +#define VRING_PACKED_EVENT_F_WRAP_CTR 15 + /* We support indirect buffer descriptors */ #define VIRTIO_RING_F_INDIRECT_DESC 28 @@ -171,4 +195,32 @@ static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old) return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old); } +struct vring_packed_desc_event { + /* Descriptor Ring Change Event Offset/Wrap Counter. */ + __le16 off_wrap; + /* Descriptor Ring Change Event Flags. */ + __le16 flags; +}; + +struct vring_packed_desc { + /* Buffer Address. */ + __le64 addr; + /* Buffer Length. */ + __le32 len; + /* Buffer ID. */ + __le16 id; + /* The flags depending on descriptor type. */ + __le16 flags; +}; + +struct vring_packed { + unsigned int num; + + struct vring_packed_desc *desc; + + struct vring_packed_desc_event *driver; + + struct vring_packed_desc_event *device; +}; + #endif /* _UAPI_LINUX_VIRTIO_RING_H */ -- 2.14.5