All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	Sunil Goutham <sgoutham@marvell.com>
Subject: [PATCH v6 06/15] octeontx2-af: Convert mbox msg id check to a macro
Date: Thu,  4 Oct 2018 23:51:49 +0530	[thread overview]
Message-ID: <1538677318-5002-7-git-send-email-sunil.kovvuri@gmail.com> (raw)
In-Reply-To: <1538677318-5002-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>
Signed-off-by: Sunil Goutham <sgoutham@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

  parent reply	other threads:[~2018-10-05  1:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04 18:21 [PATCH v6 00/15] octeontx2-af: Add RVU Admin Function driver sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 01/15] octeontx2-af: Add Marvell OcteonTX2 RVU AF driver sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 02/15] octeontx2-af: Reset all RVU blocks sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 03/15] octeontx2-af: Gather RVU blocks HW info sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 04/15] octeontx2-af: Add mailbox support infra sunil.kovvuri
2018-10-05 21:50   ` David Miller
2018-10-06  5:01     ` [EXT] " Goutham, Sunil
2018-10-04 18:21 ` [PATCH v6 05/15] octeontx2-af: Add mailbox IRQ and msg handlers sunil.kovvuri
2018-10-04 18:21 ` sunil.kovvuri [this message]
2018-10-04 18:21 ` [PATCH v6 07/15] octeontx2-af: Scan blocks for LFs provisioned to PF/VF sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 08/15] octeontx2-af: Add RVU block LF provisioning support sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 09/15] octeontx2-af: Configure block LF's MSIX vector offset sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 10/15] octeontx2-af: Reconfig MSIX base with IOVA sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 11/15] octeontx2-af: Add Marvell OcteonTX2 CGX driver sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 12/15] octeontx2-af: Set RVU PFs to CGX LMACs mapping sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 13/15] octeontx2-af: Add support for CGX link management sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 14/15] octeontx2-af: Register for CGX lmac events sunil.kovvuri
2018-10-04 18:21 ` [PATCH v6 15/15] MAINTAINERS: Add entry for Marvell OcteonTX2 Admin Function driver 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=1538677318-5002-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 \
    --cc=sgoutham@marvell.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.