From patchwork Fri Dec 13 10:18:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11290389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E026138D for ; Fri, 13 Dec 2019 10:19:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF3AD2077B for ; Fri, 13 Dec 2019 10:19:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="HlTnMGpp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF3AD2077B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifi1a-0004pZ-40; Fri, 13 Dec 2019 10:18:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifi1Y-0004pU-I4 for xen-devel@lists.xenproject.org; Fri, 13 Dec 2019 10:18:16 +0000 X-Inumbo-ID: e070f21c-1d91-11ea-8ed0-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e070f21c-1d91-11ea-8ed0-12813bfff9fa; Fri, 13 Dec 2019 10:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1576232296; x=1607768296; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=7zv2VGSpbGZKSR/YsccBpEM9LdE0rl0c7z3fPTpzpMQ=; b=HlTnMGppFIcLkgBZt+l3RO0Mty+kidktW8WvPVbh4UGhYZGyotJl4qsi /06UCBLIE4FQO6Wxo4Y1mkf5ne4WPaKAKOlEQXLkf7XqzfQDIo6FJwaL8 ZtcJp2D1JVkCkxpkTSWQ95lvZGSyIpIwxsjUnS3g0RiTDgLZQAkgsGyfV 0=; IronPort-SDR: wgYugDSQhhsr2B7f6XnQ+FLoy0+i9chuqyzOm5g97s1qYxDIDasCttw53REZPOcKKhpEVj7J+/ QnJtbkK2RfHA== X-IronPort-AV: E=Sophos;i="5.69,309,1571702400"; d="scan'208";a="8338717" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-8549039f.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 13 Dec 2019 10:18:15 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-8549039f.us-west-2.amazon.com (Postfix) with ESMTPS id E5123A1BB7; Fri, 13 Dec 2019 10:18:13 +0000 (UTC) Received: from EX13D32EUC002.ant.amazon.com (10.43.164.94) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 13 Dec 2019 10:18:13 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D32EUC002.ant.amazon.com (10.43.164.94) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 13 Dec 2019 10:18:12 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 13 Dec 2019 10:18:10 +0000 From: Paul Durrant To: Date: Fri, 13 Dec 2019 10:18:09 +0000 Message-ID: <20191213101809.20784-1-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH] public/io/ring.h: add FRONT/BACK_RING_ATTACH macros X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Paul Durrant , Konrad Rzeszutek Wilk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The version of this header present in the Linux source tree has contained such macros for some time. These macros, as the names imply, allow front or back rings to be set up for existent (rather than freshly created and zeroed) shared rings. This patch is to update this, the canonical version of the header, to match the latest definition of these macros in the Linux source. NOTE: The way the new macros are defined allows the FRONT/BACK_RING_INIT macros to be re-defined in terms of them, thereby reducing duplication. Signed-off-by: Paul Durrant Reviewed-by: Juergen Gross --- Cc: Konrad Rzeszutek Wilk Cc: Juergen Gross --- xen/include/public/io/ring.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/xen/include/public/io/ring.h b/xen/include/public/io/ring.h index c5d53e3103..d68615ae2f 100644 --- a/xen/include/public/io/ring.h +++ b/xen/include/public/io/ring.h @@ -175,20 +175,24 @@ typedef struct __name##_back_ring __name##_back_ring_t (void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \ } while(0) -#define FRONT_RING_INIT(_r, _s, __size) do { \ - (_r)->req_prod_pvt = 0; \ - (_r)->rsp_cons = 0; \ +#define FRONT_RING_ATTACH(_r, _s, _i, __size) do { \ + (_r)->req_prod_pvt = (_i); \ + (_r)->rsp_cons = (_i); \ (_r)->nr_ents = __RING_SIZE(_s, __size); \ (_r)->sring = (_s); \ } while (0) -#define BACK_RING_INIT(_r, _s, __size) do { \ - (_r)->rsp_prod_pvt = 0; \ - (_r)->req_cons = 0; \ +#define FRONT_RING_INIT(_r, _s, __size) FRONT_RING_ATTACH(_r, _s, 0, __size) + +#define BACK_RING_ATTACH(_r, _s, _i, __size) do { \ + (_r)->rsp_prod_pvt = (_i); \ + (_r)->req_cons = (_i); \ (_r)->nr_ents = __RING_SIZE(_s, __size); \ (_r)->sring = (_s); \ } while (0) +#define BACK_RING_INIT(_r, _s, __size) BACK_RING_ATTACH(_r, _s, 0, __size) + /* How big is this ring? */ #define RING_SIZE(_r) \ ((_r)->nr_ents)