From: sunil.kovvuri@gmail.com (sunil.kovvuri at gmail.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/15] soc: octeontx2: Convert mbox msg id check to a macro
Date: Tue, 28 Aug 2018 16:27:09 +0530 [thread overview]
Message-ID: <1535453838-12154-7-git-send-email-sunil.kovvuri@gmail.com> (raw)
In-Reply-To: <1535453838-12154-1-git-send-email-sunil.kovvuri@gmail.com>
From: Aleksey Makarov <amakarov@marvell.com>
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 <amakarov@marvell.com>
---
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)
--
2.7.4
next prev parent reply other threads:[~2018-08-28 10:57 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-28 10:57 [PATCH 00/15] soc: octeontx2: Add RVU admin function driver sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 01/15] soc: octeontx2: Add Marvell OcteonTX2 RVU AF driver sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 02/15] soc: octeontx2: Reset all RVU blocks sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 03/15] soc: octeontx2: Gather RVU blocks HW info sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 04/15] soc: octeontx2: Add mailbox support infra sunil.kovvuri at gmail.com
2018-08-28 12:03 ` Arnd Bergmann
2018-08-28 12:47 ` Sunil Kovvuri
2018-08-28 12:52 ` Arnd Bergmann
2018-08-28 13:23 ` Sunil Kovvuri
2018-08-30 13:56 ` Arnd Bergmann
2018-08-30 18:36 ` Sunil Kovvuri
2018-08-31 14:16 ` Arnd Bergmann
2018-08-31 17:25 ` Sunil Kovvuri
2018-08-28 10:57 ` [PATCH 05/15] soc: octeontx2: Add mailbox IRQ and msg handlers sunil.kovvuri at gmail.com
2018-08-28 10:57 ` sunil.kovvuri at gmail.com [this message]
2018-08-28 10:57 ` [PATCH 07/15] soc: octeontx2: Scan blocks for LFs provisioned to PF/VF sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 08/15] soc: octeontx2: Add RVU block LF provisioning support sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 09/15] soc: octeontx2: Configure block LF's MSIX vector offset sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA sunil.kovvuri at gmail.com
2018-08-28 12:08 ` Arnd Bergmann
2018-08-28 12:42 ` Sunil Kovvuri
2018-08-28 12:57 ` Arnd Bergmann
2018-08-28 13:17 ` Sunil Kovvuri
2018-08-30 13:53 ` Arnd Bergmann
2018-08-30 18:39 ` Sunil Kovvuri
2018-08-28 10:57 ` [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver sunil.kovvuri at gmail.com
2018-08-28 12:10 ` Arnd Bergmann
2018-08-28 12:30 ` Sunil Kovvuri
2018-08-28 12:48 ` Arnd Bergmann
2018-08-28 13:09 ` Sunil Kovvuri
2018-08-30 14:07 ` Arnd Bergmann
2018-08-30 17:55 ` Sunil Kovvuri
2018-08-31 14:20 ` Arnd Bergmann
2018-08-31 16:00 ` Sunil Kovvuri
2018-08-31 18:29 ` Arnd Bergmann
2018-08-31 18:35 ` Sunil Kovvuri
2018-08-28 10:57 ` [PATCH 12/15] soc: octeontx2: Set RVU PFs to CGX LMACs mapping sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 13/15] soc: octeontx2: Add support for CGX link management sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 14/15] soc: octeontx2: Register for CGX lmac events sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 15/15] MAINTAINERS: Add entry for Marvell OcteonTX2 Admin Function driver sunil.kovvuri at gmail.com
2018-08-28 12:23 ` [PATCH 00/15] soc: octeontx2: Add RVU admin function driver Arnd Bergmann
2018-08-28 13:24 ` Sunil Kovvuri
2018-08-30 9:40 ` Sunil Kovvuri
2018-08-30 13:26 ` Andrew Lunn
2018-08-30 18:31 ` Sunil Kovvuri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1535453838-12154-7-git-send-email-sunil.kovvuri@gmail.com \
--to=sunil.kovvuri@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).