From patchwork Tue Sep 4 11:54:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 10587221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 357DE14BD for ; Tue, 4 Sep 2018 12:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E26A2933E for ; Tue, 4 Sep 2018 12:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1259A29342; Tue, 4 Sep 2018 12:00:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AD7342933E for ; Tue, 4 Sep 2018 12:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=G/Qdowq1/iO9JxbG9zzTL6ZPKpup+sntT+i7hAUEo7A=; b=uFcdDzxhFWHLkpbtLDiocecO2j VRZPWVicKRe0tCgbshvzluIpFHPO/pYjCjLAK0LaCVyx/ggVvgwGAv9Di9MaVGz9fALkIDxlfg6nh LIcv3bH5qqcbYv8JcXVWVwMnt4xcB/41yOgBtgo0r9NunjHbqHyzqZvD7ibejy679pDGNnSFrJdB+ dp7rEUqlP5bRxpkfn7HOpjEqcWKw22NCbQ2OHFUa/lEdGh4Ck/VqBdXvUQNAdi9Sq3jjIrNfmB8C+ 6kbo7jhiiEXo4oLC9e7Sgl+0m6ThJXChckBPbyO7kZ9dfRmm3HWMEll0wzURaezxplqDqQkBxaCKw 3RnycG7A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxA0S-0008PP-VV; Tue, 04 Sep 2018 12:00:29 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fx9vw-0005eq-4e for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 11:55:49 +0000 Received: by mail-pf1-x442.google.com with SMTP id k19-v6so1594613pfi.1 for ; Tue, 04 Sep 2018 04:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rTck22z5Fb2QfzdSq16kU7wq0iTR4gwoypzlJecOfhs=; b=blsfUuB/fKiCPAlfPuopDoVBQ7jUCV35NqynYNtJH2nj5fGgpd/gkpZ6glhljqy3jN hHHyWoKAvZrhJAHbJCJe1gUDDaDG9QMI3WKy8y8wK+nMCwuiGAQ6j8W9hta1EAIyG01U fFKBlsIQq/Co7oG7AQtMRAYmdbNDa0cpIFQHVp5qJmQpmheJPn4QfeCvkU1tIK1kRkHw xyGCiWWdwMT4gmfw400Ddg/grqSzZWarmqVV5RjHa/B94AZIk4CjFGza8eJIC65XYOLY HKrj6S33aosY1Dwmv9sS0UmSKeme4QVhaNWT50eX70OQGZSzqV76zurwgGdHJ//9IV0u ijXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rTck22z5Fb2QfzdSq16kU7wq0iTR4gwoypzlJecOfhs=; b=DcHWYlO9KjqWRLekw7tB+FzD8Z19ZgMcA7gnNwmmoFyH3sxZ8OfIwGoWPTM4/fZXYD hiBiAQZFGxuCjAI8OFC2F4MLWP9+t29gGC31+uQcLlQXQb1flNBTGjRaqCdztMORyNCD Lf5i1OJhJPJ+Gwu+cjzrpZ7tmh98eFBsAuhz7oZaZdp6afpZaoF8iHouwj/TAR4OL2W+ L5hYYbQFk5TLfMlfNby+surLLsfzjoF+c6NvKEaW1OLZMz09+Zq0hVLaQrS9GJEQPyIN D7neLDMmJc14/rsk5G5Z/UHSFIm2iHHtvTTRD7tXif+qOPqCIlJ4J1rRL8fnwbi8HuP4 ZxuQ== X-Gm-Message-State: APzg51ABAFykw5RT1JEoOUfybS629HAEqzWBGAjVkrt3KGLv1JTi2R/6 HA534b/4zx0zjl+J/6zsF7U= X-Google-Smtp-Source: ANB0VdZozI0CjPwLHGI3vTNU+MqWls4AO9BdZXUTZ7Bx2D/iE4ALgfhiE6bAm1UlR8eJYkB+S6ncrQ== X-Received: by 2002:a63:5964:: with SMTP id j36-v6mr30731170pgm.222.1536062137144; Tue, 04 Sep 2018 04:55:37 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id u184-v6sm29740190pgd.46.2018.09.04.04.55.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 04:55:36 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Subject: [PATCH v2 06/15] soc: octeontx2: Convert mbox msg id check to a macro Date: Tue, 4 Sep 2018 17:24:41 +0530 Message-Id: <1536062090-30446-7-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536062090-30446-1-git-send-email-sunil.kovvuri@gmail.com> References: <1536062090-30446-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180904_045548_309700_CFA929E9 X-CRM114-Status: GOOD ( 14.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, Aleksey Makarov , linux-soc@vger.kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Aleksey Makarov With 10's of mailbox messages expected to be handled in future, checking for message id could become a lengthy switch case. Hence added a macro to auto generate the switch case for each msg id. Signed-off-by: Aleksey Makarov --- drivers/soc/marvell/octeontx2/rvu.c | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/drivers/soc/marvell/octeontx2/rvu.c b/drivers/soc/marvell/octeontx2/rvu.c index e795c2f..25f79bf 100644 --- a/drivers/soc/marvell/octeontx2/rvu.c +++ b/drivers/soc/marvell/octeontx2/rvu.c @@ -258,6 +258,12 @@ static int rvu_setup_hw_resources(struct rvu *rvu) return 0; } +static int rvu_mbox_handler_READY(struct rvu *rvu, struct msg_req *req, + struct ready_msg_rsp *rsp) +{ + return 0; +} + static int rvu_process_mbox_msg(struct rvu *rvu, int devid, struct mbox_msghdr *req) { @@ -265,13 +271,39 @@ static int rvu_process_mbox_msg(struct rvu *rvu, int devid, if (req->sig != OTX2_MBOX_REQ_SIG) goto bad_message; - if (req->id == MBOX_MSG_READY) - return 0; - + switch (req->id) { +#define M(_name, _id, _req_type, _rsp_type) \ + case _id: { \ + struct _rsp_type *rsp; \ + int err; \ + \ + rsp = (struct _rsp_type *)otx2_mbox_alloc_msg( \ + &rvu->mbox, devid, \ + sizeof(struct _rsp_type)); \ + if (rsp) { \ + rsp->hdr.id = _id; \ + rsp->hdr.sig = OTX2_MBOX_RSP_SIG; \ + rsp->hdr.pcifunc = req->pcifunc; \ + rsp->hdr.rc = 0; \ + } \ + \ + err = rvu_mbox_handler_ ## _name(rvu, \ + (struct _req_type *)req, \ + rsp); \ + if (rsp && err) \ + rsp->hdr.rc = err; \ + \ + return rsp ? err : -ENOMEM; \ + } +MBOX_MESSAGES +#undef M + break; bad_message: - otx2_reply_invalid_msg(&rvu->mbox, devid, req->pcifunc, - req->id); - return -ENODEV; + default: + otx2_reply_invalid_msg(&rvu->mbox, devid, req->pcifunc, + req->id); + return -ENODEV; + } } static void rvu_mbox_handler(struct work_struct *work)