Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp291770imu; Fri, 7 Dec 2018 00:51:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/U5f0QYWWg3vzpxFoForQ1Qzzr1WR3eKA4eRqU2pQrU2lyZMHsaRMRF7iUkcLZ5fv3dIuyZ X-Received: by 2002:a63:6cc8:: with SMTP id h191mr1144158pgc.366.1544172716616; Fri, 07 Dec 2018 00:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544172716; cv=none; d=google.com; s=arc-20160816; b=dSI1T0B6KzL57UomAhp9P8eRS1G5ACtdkhdke4vDHkHr7UBNZlfOsSvjSiNpZb6p1C 4B/OSe5vY9kDn2Ek7wwwtvB5kJOWRVTcgZesksoSgUKVfEt1RLcmSvgY0nD4GEDl+5VU Hg4EIFlinui6L0HEV64pkZVfSY60cDdnCSywWvSXnm60tOOqyPhaU4x3F64sUW/Xvp/o EfezojX4s1Px1z8OSkgJz08uYwdR5kb7Z9zEhgCqDEtjjAEoTRmtG5DypmSsoJzpQrYD kGq9Uqqip9n0GJID0WTcHOLBwdYsv6cia9Qg16HIkvEivUJaxwdpVHnGjYmVwaBoEckK x3Rg== 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=oJi/WnsgdAaPpwD48w6k7O0daGnIQQirpEB/meplaXc=; b=L0QIDLMG6dpDntf+7FwTo71jiS+VuvyQiAD9/TAkHJaPX+8wmDALVy9mYMej5JyJjt xkiMO401M7q80St+h2U+LENFNDlaFqHGfWOb123yun+XDoggEuoX+5edTIUkukXVZlYI S9ufNwxnhwiVMd8kUFffplX3PQ/TApRZVGdvKNt58qe+GHw1k5KVsemsiA7l3uF07l+O r/7n4G4N8EXye7DG5ckL7Iom01KjmExMUywaeyeczRBJJcYI0aCN6zBfawOa3VnYfLkI yFo4r1ZqqBDXf+Hg7QfgUPLmdg1uPchgRbxWY1DB3wirSUpw9ah6h6dRMwipSQurliw2 WnTg== 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 n24si2168546pgv.119.2018.12.07.00.51.41; Fri, 07 Dec 2018 00:51:56 -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 S1726059AbeLGIvD (ORCPT + 99 others); Fri, 7 Dec 2018 03:51:03 -0500 Received: from mga18.intel.com ([134.134.136.126]:1705 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725978AbeLGIvC (ORCPT ); Fri, 7 Dec 2018 03:51:02 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2018 00:51:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,324,1539673200"; d="scan'208";a="96888331" Received: from btwcube1.sh.intel.com ([10.67.104.173]) by orsmga007.jf.intel.com with ESMTP; 07 Dec 2018 00:50:59 -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: [RFC 1/3] virtio_ring: define flags as shifts consistently Date: Fri, 7 Dec 2018 16:48:40 +0800 Message-Id: <20181207084842.13133-2-tiwei.bie@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181207084842.13133-1-tiwei.bie@intel.com> References: <20181207084842.13133-1-tiwei.bie@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce _SPLIT_ and/or _PACKED_ variants for VRING_DESC_F_*, VRING_AVAIL_F_NO_INTERRUPT and VRING_USED_F_NO_NOTIFY. These variants are defined as shifts instead of shifted values for consistency with other _F_ flags. Suggested-by: Michael S. Tsirkin Signed-off-by: Tiwei Bie --- include/uapi/linux/virtio_ring.h | 57 ++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index 2414f8af26b3..9b0c0d92ab62 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h @@ -37,29 +37,52 @@ #include #include -/* This marks a buffer as continuing via the next field. */ +/* + * Notice: unlike other _F_ flags, below flags are defined as shifted + * values instead of shifts for compatibility. + */ +/* Same as VRING_SPLIT_DESC_F_NEXT. */ #define VRING_DESC_F_NEXT 1 -/* This marks a buffer as write-only (otherwise read-only). */ +/* Same as VRING_SPLIT_DESC_F_WRITE. */ #define VRING_DESC_F_WRITE 2 -/* This means the buffer contains a list of buffer descriptors. */ +/* Same as VRING_SPLIT_DESC_F_INDIRECT. */ #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. */ +/* Same as VRING_SPLIT_USED_F_NO_NOTIFY. */ #define VRING_USED_F_NO_NOTIFY 1 -/* The Guest uses this in avail->flags to advise the Host: don't interrupt me - * when you consume a buffer. It's unreliable, so it's simply an - * optimization. */ +/* Same as VRING_SPLIT_AVAIL_F_NO_INTERRUPT. */ #define VRING_AVAIL_F_NO_INTERRUPT 1 +/* Mark a buffer as continuing via the next field in split ring. */ +#define VRING_SPLIT_DESC_F_NEXT 0 +/* Mark a buffer as write-only (otherwise read-only) in split ring. */ +#define VRING_SPLIT_DESC_F_WRITE 1 +/* Mean the buffer contains a list of buffer descriptors in split ring. */ +#define VRING_SPLIT_DESC_F_INDIRECT 2 + +/* + * The Host uses this in used->flags in split ring 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. + */ +#define VRING_SPLIT_USED_F_NO_NOTIFY 0 +/* + * The Guest uses this in avail->flags in split ring to advise the Host: + * don't interrupt me when you consume a buffer. It's unreliable, so it's + * simply an optimization. + */ +#define VRING_SPLIT_AVAIL_F_NO_INTERRUPT 0 + +/* Mark a buffer as continuing via the next field in packed ring. */ +#define VRING_PACKED_DESC_F_NEXT 0 +/* Mark a buffer as write-only (otherwise read-only) in packed ring. */ +#define VRING_PACKED_DESC_F_WRITE 1 +/* Mean the buffer contains a list of buffer descriptors in packed ring. */ +#define VRING_PACKED_DESC_F_INDIRECT 2 + +/* Mark a descriptor as available or used in packed ring. */ +#define VRING_PACKED_DESC_F_AVAIL 7 +#define VRING_PACKED_DESC_F_USED 15 + /* Enable events in packed ring. */ #define VRING_PACKED_EVENT_FLAG_ENABLE 0x0 /* Disable events in packed ring. */ -- 2.17.1