From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756097Ab1EDU5N (ORCPT ); Wed, 4 May 2011 16:57:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4689 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754145Ab1EDUvv (ORCPT ); Wed, 4 May 2011 16:51:51 -0400 Date: Wed, 4 May 2011 23:51:19 +0300 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Rusty Russell , Carsten Otte , Christian Borntraeger , linux390@de.ibm.com, Martin Schwidefsky , Heiko Carstens , Shirley Ma , lguest@lists.ozlabs.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, Krishna Kumar , Tom Lendacky , steved@us.ibm.com, habanero@linux.vnet.ibm.com Subject: [PATCH 06/18] virtio_ring: avail event index interface Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define a new feature bit for the host to declare that it uses an avail_event index (like Xen) instead of a feature bit to enable/disable interrupts. Signed-off-by: Michael S. Tsirkin --- include/linux/virtio_ring.h | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index f5c1b75..f791772 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h @@ -32,6 +32,9 @@ /* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ #define VIRTIO_RING_F_USED_EVENT_IDX 29 +/* The Host publishes the avail index for which it expects a kick + * at the end of the used ring. Guest should ignore the used->flags field. */ +#define VIRTIO_RING_F_AVAIL_EVENT_IDX 32 /* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ struct vring_desc { @@ -96,11 +99,13 @@ struct vring { * __u16 used_flags; * __u16 used_idx; * struct vring_used_elem used[num]; + * __u16 avail_event_idx; * }; */ -/* We publish the used event index at the end of the available ring. - * It is at the end for backwards compatibility. */ +/* We publish the used event index at the end of the available ring, and vice + * versa. They are at the end for backwards compatibility. */ #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) +#define vring_avail_event(vr) (*(__u16 *)&(vr)->used->ring[(vr)->num]) static inline void vring_init(struct vring *vr, unsigned int num, void *p, unsigned long align) @@ -116,7 +121,7 @@ static inline unsigned vring_size(unsigned int num, unsigned long align) { return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) + align - 1) & ~(align - 1)) - + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num; + + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num; } #ifdef __KERNEL__ -- 1.7.5.53.gc233e From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: [PATCH 06/18] virtio_ring: avail event index interface Date: Wed, 4 May 2011 23:51:19 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Krishna Kumar , Carsten Otte , lguest@lists.ozlabs.org, Shirley Ma , kvm@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, habanero@linux.vnet.ibm.com, Heiko Carstens , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, steved@us.ibm.com, Christian Borntraeger , Tom Lendacky , Martin Schwidefsky , linux390@de.ibm.com To: linux-kernel@vger.kernel.org Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org List-Id: netdev.vger.kernel.org Define a new feature bit for the host to declare that it uses an avail_event index (like Xen) instead of a feature bit to enable/disable interrupts. Signed-off-by: Michael S. Tsirkin --- include/linux/virtio_ring.h | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index f5c1b75..f791772 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h @@ -32,6 +32,9 @@ /* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ #define VIRTIO_RING_F_USED_EVENT_IDX 29 +/* The Host publishes the avail index for which it expects a kick + * at the end of the used ring. Guest should ignore the used->flags field. */ +#define VIRTIO_RING_F_AVAIL_EVENT_IDX 32 /* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ struct vring_desc { @@ -96,11 +99,13 @@ struct vring { * __u16 used_flags; * __u16 used_idx; * struct vring_used_elem used[num]; + * __u16 avail_event_idx; * }; */ -/* We publish the used event index at the end of the available ring. - * It is at the end for backwards compatibility. */ +/* We publish the used event index at the end of the available ring, and vice + * versa. They are at the end for backwards compatibility. */ #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) +#define vring_avail_event(vr) (*(__u16 *)&(vr)->used->ring[(vr)->num]) static inline void vring_init(struct vring *vr, unsigned int num, void *p, unsigned long align) @@ -116,7 +121,7 @@ static inline unsigned vring_size(unsigned int num, unsigned long align) { return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) + align - 1) & ~(align - 1)) - + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num; + + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num; } #ifdef __KERNEL__ -- 1.7.5.53.gc233e From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: [PATCH 06/18] virtio_ring: avail event index interface Date: Wed, 4 May 2011 23:51:19 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org List-Archive: List-Post: Cc: Krishna Kumar , Carsten Otte , lguest@lists.ozlabs.org, Shirley Ma , kvm@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, habanero@linux.vnet.ibm.com, Heiko Carstens , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, steved@us.ibm.com, Christian Borntraeger , Tom Lendacky , Martin Schwidefsky , linux390@de.ibm.com List-ID: Define a new feature bit for the host to declare that it uses an avail_event index (like Xen) instead of a feature bit to enable/disable interrupts. Signed-off-by: Michael S. Tsirkin --- include/linux/virtio_ring.h | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index f5c1b75..f791772 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h @@ -32,6 +32,9 @@ /* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ #define VIRTIO_RING_F_USED_EVENT_IDX 29 +/* The Host publishes the avail index for which it expects a kick + * at the end of the used ring. Guest should ignore the used->flags field. */ +#define VIRTIO_RING_F_AVAIL_EVENT_IDX 32 /* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ struct vring_desc { @@ -96,11 +99,13 @@ struct vring { * __u16 used_flags; * __u16 used_idx; * struct vring_used_elem used[num]; + * __u16 avail_event_idx; * }; */ -/* We publish the used event index at the end of the available ring. - * It is at the end for backwards compatibility. */ +/* We publish the used event index at the end of the available ring, and vice + * versa. They are at the end for backwards compatibility. */ #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) +#define vring_avail_event(vr) (*(__u16 *)&(vr)->used->ring[(vr)->num]) static inline void vring_init(struct vring *vr, unsigned int num, void *p, unsigned long align) @@ -116,7 +121,7 @@ static inline unsigned vring_size(unsigned int num, unsigned long align) { return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) + align - 1) & ~(align - 1)) - + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num; + + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num; } #ifdef __KERNEL__ -- 1.7.5.53.gc233e