From patchwork Tue Sep 4 16:28:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 10587685 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 C7F07112B for ; Tue, 4 Sep 2018 16:47:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B663029DFB for ; Tue, 4 Sep 2018 16:47:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A872329E01; Tue, 4 Sep 2018 16:47:58 +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 4288429DFB for ; Tue, 4 Sep 2018 16:47:58 +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=mmT05l5gqhd0YIHFIy3TEAf3Cv 6+DRXYxZvZjtLO4zBYTIpfNHiv4XimizyN88m+5IFbO7tBPy3brGqOYVsX1IacHvWH7NT/fAUT1uv I+h13uskF2iN57RQfmpx0OO2Gf0YNuieLkWmF29QVdJV34zpCt5oyBbFXStfSo2Cf6qTLNdI9spH8 MBwjgiWEzs6Wgq8dqdOUV1T6mSHwwqxvf+GKNWE+LuxigLkAgI3VaNYu9fUSy1WsQEYVCHO0eHWs2 Q6zgEN7mArqKrI0juc2daRxKwXK9nn142bWWeLONYRhPNEE1bGYO6MDWB2Aru00adNhYhg8Lp7F9/ ps06F+cg==; 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 1fxEUX-00011p-Lk; Tue, 04 Sep 2018 16:47:49 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxECm-0004Zo-Rc for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 16:29:30 +0000 Received: by mail-pl1-x643.google.com with SMTP id f6-v6so1885926plo.1 for ; Tue, 04 Sep 2018 09:29:18 -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=b0Ng6nIO6IgWmLAzTRdB3CEx3vlfsyxJGBGCFIqT9nEfYeDTSzAjRv2jiTGok5SZtI NHmuEB8YNsCH+8+X2poiFYqK9Braz6qjhj97PtoJH+d5ODAsjSZLdxK1YU5v1yBrYNqC GxWFCOWSjKWiLUD9/JrA9DxghqxQCmtBTIXvbV3Z3c8gienzh5VgnkriiZfeiJTERMaY qV6ag8/EfhdIv52ZtM1g33rWqGRhd84rkpoxeuVPL+z4ELFYmL1h8h3Pnz7bmSM0119E mmJqLTsIvS/VxCt7hZJxPf9iBQ5nyQpu7uAxamlM67Mr18j4pqs1VdEYpKQM2azYh2zE AcmQ== 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=dtiwgi/Xn+cMXZapI771I1Ny4mGSNkR0FfWZH4rSEzvTG51HZVdafUWqpe1gxgeW4Q ZMzDYqAyBm9teCb1IgRMmPgGWrbCcDM42Csnad647EKbT+XK3KzS2NVGXvlT/Zd5mkOx vTdLZvRS/jDzZrAHM/W/4ff9zVJc4gQu2YCXJ5IJKlWRodxlPXt3dwiPfmiya0vl85hH TvOot/8gYXXZzSEj3RyVk419fKIJZR6Tv1i3yxDZl397QXV3jiUXVVoTazBCjUFS6JjE FuS8ZMkPh9IaamnZQTitVa0GZyMdfBcdnfhPxuyKesYGNd2DEY9ybEGqP28HQxqixZdv xMeg== X-Gm-Message-State: APzg51C4zE8VGnxtNOcP80Uw7Al+ui4pyyfR9pc2qhqc8dUb/Ux1j8zH 0O45WU3xRmNYqVLRitBVTOI= X-Google-Smtp-Source: ANB0VdZ/oKB12m+wx1CaZrxtddjaRvvJasT+K/Awni/n3QId8Zfe+IU9USG6GmTAIwf5ct4wwNJU2w== X-Received: by 2002:a17:902:402:: with SMTP id 2-v6mr14153919ple.277.1536078557789; Tue, 04 Sep 2018 09:29:17 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id j191-v6sm32243827pfc.136.2018.09.04.09.29.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 09:29:16 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Subject: [PATCH v3 06/15] soc: octeontx2: Convert mbox msg id check to a macro Date: Tue, 4 Sep 2018 21:58:36 +0530 Message-Id: <1536078525-31534-7-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536078525-31534-1-git-send-email-sunil.kovvuri@gmail.com> References: <1536078525-31534-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_092928_929016_15D9353C X-CRM114-Status: GOOD ( 14.02 ) 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 , netdev@vger.kernel.org, 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)