Received: by 10.192.165.156 with SMTP id m28csp822269imm; Fri, 13 Apr 2018 08:24:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ZRxeuO1YujsnwmRloPJ80YG2KNjqf9pDJtAi35D0Oeyaa23txFEhn6NnsyVWNLYOEl1nv X-Received: by 2002:a17:902:580d:: with SMTP id m13-v6mr3067009pli.325.1523633049798; Fri, 13 Apr 2018 08:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523633049; cv=none; d=google.com; s=arc-20160816; b=kup0sJpebO8rYZoA+b2ogtvxNLJ9X04psBnarf613+ymRZGpeujOZL2DWd8qKHobqc UzedeRbRk5DFqCP9YN8SjKNghd+cQod4Q3sH8uXsENAnAJzZ3EV8Syu92RMciXidaF0d felEUen11gLg96MUnyzmo59HtRVg/C9djkUoPnOH2cBN5ZcGyERvJUeFxmzRoJRA7wkw AFnInHpXqXVX46yXsnJC43yalljNt/L8ownK5MTvSPkDZ65Y6n2ujJ63+JqS3i34qRjq 4B8KJPy3CfPEVlR2BKvdkniXJuY4a0hJJ4XNEw4uL7K48ebcPdDYYJ5JYPhnOTY74a4x 0CCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=uTwBowApd+gmUwkytXYBsUzn0vcuopXZxMwZrJzfq0U=; b=v6otOsgBUszNRwmgcKtfacJAA1wDCTfY2EYVTCwiv3rPwMXXaUAUDacEaCrwB0mIUK L/d+4nSYjRTK3b4NkEPMHYCySz8IQECrWav+p2UsTGpwExr6uJW4KFxk5l14TYd6D97w hmHF/xiVZdsl/FSUsxTbxjJpxIhwt0XSOAHQ7a6fiMvSmwCzsgjDSzrbQNuw7DhS91Bh rqnu/wgAa7nI20vYdf4lDziR1ceVdq5ECkL4FOomyTHAcTC0vfWHrAiSqCD8ssAUbWfL 5OBvfJk4o4AcHyw/qTwXoh0vVJ/VVL23sGqByE97GunNuwQeirqercDDumcvo3KzvQSa vCEg== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o13si2246038pgr.108.2018.04.13.08.23.55; Fri, 13 Apr 2018 08:24:09 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751050AbeDMPWs (ORCPT + 99 others); Fri, 13 Apr 2018 11:22:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57576 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750783AbeDMPWr (ORCPT ); Fri, 13 Apr 2018 11:22:47 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 858C0406E97E; Fri, 13 Apr 2018 15:22:46 +0000 (UTC) Received: from redhat.com (ovpn-123-27.rdu2.redhat.com [10.10.123.27]) by smtp.corp.redhat.com (Postfix) with SMTP id 1ABA72166BB2; Fri, 13 Apr 2018 15:22:45 +0000 (UTC) Date: Fri, 13 Apr 2018 18:22:45 +0300 From: "Michael S. Tsirkin" To: Tiwei Bie Cc: jasowang@redhat.com, wexu@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, jfreimann@redhat.com Subject: Re: [RFC v2] virtio: support packed ring Message-ID: <20180413181808-mutt-send-email-mst@kernel.org> References: <20180401141216.8969-1-tiwei.bie@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180401141216.8969-1-tiwei.bie@intel.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 13 Apr 2018 15:22:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 13 Apr 2018 15:22:46 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 01, 2018 at 10:12:16PM +0800, Tiwei Bie wrote: > +static inline bool more_used(const struct vring_virtqueue *vq) > +{ > + return vq->packed ? more_used_packed(vq) : more_used_split(vq); > +} > + > +void *virtqueue_get_buf_ctx_split(struct virtqueue *_vq, unsigned int *len, > + void **ctx) > +{ > + struct vring_virtqueue *vq = to_vvq(_vq); > + void *ret; > + unsigned int i; > + u16 last_used; > + > + START_USE(vq); > + > + if (unlikely(vq->broken)) { > + END_USE(vq); > + return NULL; > + } > + > + if (!more_used(vq)) { > + pr_debug("No more buffers in queue\n"); > + END_USE(vq); > + return NULL; > + } So virtqueue_get_buf_ctx_split should only call more_used_split. to avoid such issues I think we should lay out the code like this: XXX_split XXX_packed XXX wrappers > +/* The standard layout I'd drop standard here. > for the packed ring is a continuous chunk of memory > + * which looks like this. > + * > + * struct vring_packed > + * { Can the opening bracket go on the prev line pls? > + * // The actual descriptors (16 bytes each) > + * struct vring_packed_desc desc[num]; > + * > + * // Padding to the next align boundary. > + * char pad[]; > + * > + * // Driver Event Suppression > + * struct vring_packed_desc_event driver; > + * > + * // Device Event Suppression > + * struct vring_packed_desc_event device; Maybe that's how our driver does it but it's not based on spec so I don't think this belongs in the header. > + * }; > + */ > + > +static inline unsigned vring_packed_size(unsigned int num, unsigned long align) > +{ > + return ((sizeof(struct vring_packed_desc) * num + align - 1) > + & ~(align - 1)) + sizeof(struct vring_packed_desc_event) * 2; > +} > + Cant say this API makes sense for me. > #endif /* _UAPI_LINUX_VIRTIO_RING_H */ > -- > 2.11.0