Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2457534imm; Tue, 4 Sep 2018 04:58:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbyUFq1H/uM2qV9z3Z5rTNtBNMqA3xZueE21F2ttirv6Rf4QLOSZL9VJ6oiiuMPWPlgSagZ X-Received: by 2002:a62:89d8:: with SMTP id n85-v6mr34495276pfk.83.1536062303430; Tue, 04 Sep 2018 04:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536062303; cv=none; d=google.com; s=arc-20160816; b=jz3/Wsbkfejpi9X8cbAVvKc5AjQRndC/ekfgHk8bkHWZlaDmgR7izRnQef5GLEwolI tqhlzKlJk6AhVlnLtZkK5twNX6MN5ROV+He30PqVzriJbTSgHOgrJZEdvWV0wiMDd469 WvBAkTtlFKnCbbBLkI0TbsxUvpzVT38UXFbiDusEp5bXANuhq6N6FCX9bY+mookgaf0S IA3KuOIURW70CS0iAlv/C86kD6i7yriLHLFUVsuWvJIziOIrBtzos5SiHUzuazi+n+sx vUfqjmnJn7ueJey1j2j+9Xm49oyRvQR2jJ3enSyRQofZNchwLcQxQLMBl0ihBYE/UyL7 TBUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rTck22z5Fb2QfzdSq16kU7wq0iTR4gwoypzlJecOfhs=; b=Z6os2pY6ASsqCeII4fOC3dtiztD/iR3rIkXv64mHzYYvZUf84V3II8aTh2lgRwUoYM KwMhgVTShxETae1rTVit3uUDMdb/rLJodeVOlNqeBPq8mTb9kLcay5jV7QY5gDraMyQD vfL0UF879ozt8RCvuH9wuuYqX+9iU9GuHPtenyC8cpy4zNy+Cb89EfeNBNXZ0YMjOgUz p9sgAJIXp+ywiZXlE5O8FMnYbbPlJGLxh6F8HZtKTyr3fI2+fyzNDvX2ObBBZs7jC1Gu RTGQKxMaAkmzK1u4PlZ3fxxesJGRwKBI/R9nldzpSmAdMSVe29mv5w/RWpBU48/JnrM0 tXcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="blsfUuB/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s32-v6si21489592pgl.531.2018.09.04.04.58.08; Tue, 04 Sep 2018 04:58:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="blsfUuB/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727489AbeIDQU1 (ORCPT + 99 others); Tue, 4 Sep 2018 12:20:27 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46098 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727072AbeIDQU0 (ORCPT ); Tue, 4 Sep 2018 12:20:26 -0400 Received: by mail-pf1-f195.google.com with SMTP id u24-v6so1563679pfn.13; 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=fJ594BS4bnCEwgL9Ti5DmoFvjVK5L1hgZMgZrZHq5DYz1w2XEWtzETk1g9KHq98nBt 1M7FIAWSumVT/1xdWG+PrRnMQeelwixt7bPwOWw2WdryjvAvIOpKj1aoc+Z6HTg5VJOJ Gc+fLV+KE85kEjd8dAXoziU+lWtijDh29/XEUCCMqvcMisIIWdHW7RHG9Cgut8ERHZ4q a2aGNPfRRirNG++JxvOOCr9xyUENlmdFkUf/Q3IsPkP0zBEfqbvRujHTVnwyaTod9mbf iwwSQwRnvJcU4t5kfOYuCrUyr84F4O8wo2j43XEaJt5zX8Ai51z5cU03hbWQqCbJDyZL fGKQ== X-Gm-Message-State: APzg51CjzKxQ7n2PmDQ3KTdufTVdDKEo7xXcBz3cMl7G2CNs4dc0IFXG Al1wFoqiloAzmbhdy+u0snlpng1l 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 Cc: linux-arm-kernel@lists.infradead.org, linux-soc@vger.kernel.org, andrew@lunn.ch, davem@davemloft.net, Aleksey Makarov 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.7.4