From: sunil.kovvuri@gmail.com
To: netdev@vger.kernel.org, davem@davemloft.net
Cc: arnd@arndb.de, linux-soc@vger.kernel.org,
Aleksey Makarov <amakarov@marvell.com>
Subject: [PATCH 06/15] octeontx2-af: Convert mbox msg id check to a macro
Date: Fri, 28 Sep 2018 11:37:43 +0530 [thread overview]
Message-ID: <1538114872-10820-7-git-send-email-sunil.kovvuri@gmail.com> (raw)
In-Reply-To: <1538114872-10820-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/net/ethernet/marvell/octeontx2/af/rvu.c | 44 +++++++++++++++++++++----
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index e795c2f..25f79bf 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/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-09-28 12:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-28 6:07 [PATCH 00/15] octeontx2-af: Add RVU Admin Function driver sunil.kovvuri
2018-09-28 6:07 ` [PATCH 01/15] octeontx2-af: Add Marvell OcteonTX2 RVU AF driver sunil.kovvuri
2018-09-28 6:07 ` [PATCH 02/15] octeontx2-af: Reset all RVU blocks sunil.kovvuri
2018-09-28 6:07 ` [PATCH 03/15] octeontx2-af: Gather RVU blocks HW info sunil.kovvuri
2018-09-28 6:07 ` [PATCH 04/15] octeontx2-af: Add mailbox support infra sunil.kovvuri
2018-09-28 6:07 ` [PATCH 05/15] octeontx2-af: Add mailbox IRQ and msg handlers sunil.kovvuri
2018-09-28 6:07 ` sunil.kovvuri [this message]
2018-09-28 6:07 ` [PATCH 07/15] octeontx2-af: Scan blocks for LFs provisioned to PF/VF sunil.kovvuri
2018-09-28 6:07 ` [PATCH 08/15] octeontx2-af: Add RVU block LF provisioning support sunil.kovvuri
2018-09-28 6:07 ` [PATCH 09/15] octeontx2-af: Configure block LF's MSIX vector offset sunil.kovvuri
2018-09-28 6:07 ` [PATCH 10/15] octeontx2-af: Reconfig MSIX base with IOVA sunil.kovvuri
2018-09-28 6:07 ` [PATCH 11/15] octeontx2-af: Add Marvell OcteonTX2 CGX driver sunil.kovvuri
2018-09-28 8:14 ` Arnd Bergmann
2018-09-28 9:19 ` Sunil Kovvuri
2018-09-28 6:07 ` [PATCH 12/15] octeontx2-af: Set RVU PFs to CGX LMACs mapping sunil.kovvuri
2018-09-28 6:07 ` [PATCH 13/15] octeontx2-af: Add support for CGX link management sunil.kovvuri
2018-09-28 8:19 ` Arnd Bergmann
2018-09-28 9:31 ` Sunil Kovvuri
2018-09-28 10:00 ` Arnd Bergmann
2018-09-28 6:07 ` [PATCH 14/15] octeontx2-af: Register for CGX lmac events sunil.kovvuri
2018-09-28 6:07 ` [PATCH 15/15] MAINTAINERS: Add entry for Marvell OcteonTX2 Admin Function driver sunil.kovvuri
2018-09-28 8:27 ` [PATCH 00/15] octeontx2-af: Add RVU " Arnd Bergmann
2018-09-28 9:35 ` 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=1538114872-10820-7-git-send-email-sunil.kovvuri@gmail.com \
--to=sunil.kovvuri@gmail.com \
--cc=amakarov@marvell.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=linux-soc@vger.kernel.org \
--cc=netdev@vger.kernel.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).