Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1707446imm; Wed, 16 May 2018 01:41:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo3QeCEcPpnEvURdJexDco6zgxh1mlRJXweNvcYFc9FKf9jdU1MTkIHRRCWhz/4hjQQVh5E X-Received: by 2002:a17:902:4081:: with SMTP id c1-v6mr18222585pld.60.1526460093331; Wed, 16 May 2018 01:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526460093; cv=none; d=google.com; s=arc-20160816; b=Nap4xWFd+zyGZUW/57CC9DqjplfR9L4/nqVpFNTk19aWjAYCVSG1SyXvOTebwSNYMA um5VKPvLf4eHHhz0wuEYpadJwn6jKFBzrPPxlZpjeA5Y6QGsp1QF7zLyd2OnojuD1qxq 1kjYS0BOWQFlh0mpo1yviQ6Wc/Kv7FZydsIyyiVhvtg5DhwnaMd/N9/r98yJ7nFwcKxD eqFQEdEdCSBqlROETB3GVCB8ik8IAvutlIaqyShNz9/B0bVCFmZAFyce7n3nkv8gHYnk /4+xhkb4IQDrKHVcSokERBLqVt7QEAG7VqAxl+X8WeOGv2oggmU6HUN74R2n+sq3kViQ RplA== 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:arc-authentication-results; bh=8I4EAwp4XdjyUNsPEBRqHfUcoVEiti6oXKBEQrXUdOE=; b=yV509WJNXVxs3W2o6vbZDqVul4PuQVjPbXUtKhrjosHvnn04pmJHjA0/zJb2hkyKS9 wyY/3IN1A1MROmsw+MOSyrNHY/RNwqZWBu0HrUW7MxjeCzTo/CS3mFepywbYLq8vosGH CrsGoV3ZAC8r/zLtOC7ZARhlzo0LDF6fM7/4wa9/14eC/dSUY/wyvMJmJiMxZLu8Q/Dc ZHdjmrohmTiAhYwFbWmCUE5GJcV3pORbHtXgdbtgzz3Y+cKgBQyb8FMr3wqkEf9fa5EH 8QnAKOPBD1zV+zolTErht/t0cHXbRBx8gZ3OkO7SoXDcMAarlOUofd545Sp/jFQScxxk ZhRg== 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 c5-v6si1119366pgt.559.2018.05.16.01.41.18; Wed, 16 May 2018 01:41:33 -0700 (PDT) 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 S1752727AbeEPIkU (ORCPT + 99 others); Wed, 16 May 2018 04:40:20 -0400 Received: from mga03.intel.com ([134.134.136.65]:30622 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752278AbeEPIhe (ORCPT ); Wed, 16 May 2018 04:37:34 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 May 2018 01:37:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,404,1520924400"; d="scan'208";a="41347762" Received: from debian.sh.intel.com ([10.67.104.203]) by orsmga007.jf.intel.com with ESMTP; 16 May 2018 01:37:32 -0700 From: Tiwei Bie To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: wexu@redhat.com, jfreimann@redhat.com, tiwei.bie@intel.com Subject: [RFC v4 1/5] virtio: add packed ring definitions Date: Wed, 16 May 2018 16:37:33 +0800 Message-Id: <20180516083737.26504-2-tiwei.bie@intel.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516083737.26504-1-tiwei.bie@intel.com> References: <20180516083737.26504-1-tiwei.bie@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Tiwei Bie --- include/uapi/linux/virtio_config.h | 12 +++++++++- include/uapi/linux/virtio_ring.h | 36 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h index 308e2096291f..a6e392325e3a 100644 --- a/include/uapi/linux/virtio_config.h +++ b/include/uapi/linux/virtio_config.h @@ -49,7 +49,7 @@ * transport being used (eg. virtio_ring), the rest are per-device feature * bits. */ #define VIRTIO_TRANSPORT_F_START 28 -#define VIRTIO_TRANSPORT_F_END 34 +#define VIRTIO_TRANSPORT_F_END 36 #ifndef VIRTIO_CONFIG_NO_LEGACY /* Do we get callbacks when the ring is completely used, even if we've @@ -71,4 +71,14 @@ * this is for compatibility with legacy systems. */ #define VIRTIO_F_IOMMU_PLATFORM 33 + +/* This feature indicates support for the packed virtqueue layout. */ +#define VIRTIO_F_RING_PACKED 34 + +/* + * This feature indicates that all buffers are used by the device + * in the same order in which they have been made available. + */ +#define VIRTIO_F_IN_ORDER 35 + #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index 6d5d5faa989b..3932cb80c347 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h @@ -44,6 +44,9 @@ /* This means the buffer contains a list of buffer descriptors. */ #define VRING_DESC_F_INDIRECT 4 +#define VRING_DESC_F_AVAIL(b) ((b) << 7) +#define VRING_DESC_F_USED(b) ((b) << 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 +56,10 @@ * optimization. */ #define VRING_AVAIL_F_NO_INTERRUPT 1 +#define VRING_EVENT_F_ENABLE 0x0 +#define VRING_EVENT_F_DISABLE 0x1 +#define VRING_EVENT_F_DESC 0x2 + /* We support indirect buffer descriptors */ #define VIRTIO_RING_F_INDIRECT_DESC 28 @@ -171,4 +178,33 @@ 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 { + /* __virtio16 off : 15; // Descriptor Event Offset + * __virtio16 wrap : 1; // Descriptor Event Wrap Counter */ + __virtio16 off_wrap; + /* __virtio16 flags : 2; // Descriptor Event Flags */ + __virtio16 flags; +}; + +struct vring_packed_desc { + /* Buffer Address. */ + __virtio64 addr; + /* Buffer Length. */ + __virtio32 len; + /* Buffer ID. */ + __virtio16 id; + /* The flags depending on descriptor type. */ + __virtio16 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.17.0