Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6946780imm; Tue, 28 Aug 2018 04:00:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZiJS1mimZy6e73Sy4yGjptHoS11Le5mvwmQagMbudFngNgfwujDisBVM7qGm18CHMmdw87 X-Received: by 2002:a62:34c4:: with SMTP id b187-v6mr998976pfa.15.1535454053141; Tue, 28 Aug 2018 04:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535454053; cv=none; d=google.com; s=arc-20160816; b=mjTr2LxGkiqK4z2vpuWATGLvgrV7orIFyaq54lmSeSSL5adFKlhAZttUbgSto36EoY nDqjniHe2I8RRfPpwZ3Y08MrrTG5fmtst9Jw+XUamN8ggkVwsiBxZaOQyElfiY5/6ntC RKZB2BpK4k45wK5iMiI8Q/a1BEtWkONxBWUT8xK2xfvOGBOheFnTl7eFMNFZ96Cr1ZLo wjGnvgntEFJ0rydhuR3hw+83gvwgdb+M2YH70OQdTSUZkmLDHIr+UwjyxOaP5T03PVat l5Ll80dToKgHN2W4rOC5/lWrCb+wgVxjNBs6wlNWrnjwuF5MAKnwUnoToGFwwvPbdpbp XT+A== 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=l2dBXl2DcYOwq4SVIg6GWljbReXjFsCmu+tW8iRUwsCm1YjkenGPV8MJNnxnObiKl/ egzlsUTzS7cke5/0cjZEyKd3FgqtpneHzN8Bcrmi8816ZL9YoeMmu661Mad450Vvm4Tr 6CdeFlEYhbFnFkR9tNzPJZ7cjazpfFfmGzTpmxPPgu4ySvfdsaEMMEn+Y/x/9w62/C0o aYHprS9Hua7ZCyqW+h9xPQ9MqDSXulQl72zAIAJ/43/vwCAfCWu8rKm6/VDBSxpkyNG4 y6ExEJdE9NGqtpVh54WYKFbktw7XQWLgi1lKgk4k06cwYKl0IDUbBxPOvkMAH1d2qcgc v92Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E53wG019; 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 d38-v6si748142pla.422.2018.08.28.04.00.37; Tue, 28 Aug 2018 04:00:53 -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=E53wG019; 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 S1727857AbeH1OtH (ORCPT + 99 others); Tue, 28 Aug 2018 10:49:07 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44769 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbeH1OtE (ORCPT ); Tue, 28 Aug 2018 10:49:04 -0400 Received: by mail-pl1-f194.google.com with SMTP id ba4-v6so560206plb.11; Tue, 28 Aug 2018 03:57:58 -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=E53wG019bO8SmDPDcRw3FM4nHWMnyL9wVxTrtZaXBmNiXmPCmZARMfkJdfFPrx0hYA TuOPg/6dQREYWHCfPw5GRuPZE4yn30txo/+fHzLDhmba0/2+/l5iqU1Fn8bAhyiMDfW1 yhBbbPhsHa1AOB2WeiJSM09RTvWH6s109PJ0oJ2yA3rryF4n9urlXPWRCbsjseaWeCCj eFu9kPOqRxBPxZpq24iaSI/uzKxZqIGcgb9Gk5rRVEvfRIMVPDErQVrJAexgbF9zexC/ au4HQeNnLb7giGaA+jtZGThWlorGDQ107xQxBc0Ux4dhg9/dUIxsW2XDY3ivfnJMyQGh tLvA== 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=tQ69LIZjxXnHcVzeC5fDr2Yb7gwZYlLcIvcjl7rTvvYeQqmaAi+fUbBwFmTOl0pRBu TOLeRRLdFwC5N64kqYkzhBnNZfd7MnDY6xxZZoLoLeinpFBJd+g35D47Oa1idhk2qXtX eZ8ss3vg/i02OjUEVslQw0CHNQd97RQT7igSHZQ7tm28xoHQkfySnYxeosbfjLD4EbwJ wjK6lkghvUL1mILtxFYIMVve08aZldiCw5gNoeNi372KpAFIS1mjZClGjI/TrIuLZ3pe eeoM62sYmnee7qDkXdnI1yKXu8GAw38JDEmT9p60KX8zzBLxUmmP9mWbzJrrprl9NmaM QT6Q== X-Gm-Message-State: APzg51AuMicxz9a9MTpOCI4QZSUxKxeZLTcvEklQ/49fmAaE/2upJrjD BIc3bBMfdQlKbxsb3lPn2VTv/7xz X-Received: by 2002:a17:902:8ec7:: with SMTP id x7-v6mr1032791plo.336.1535453878066; Tue, 28 Aug 2018 03:57:58 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id n22-v6sm2946798pfj.68.2018.08.28.03.57.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 03:57:57 -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, Aleksey Makarov Subject: [PATCH 06/15] soc: octeontx2: Convert mbox msg id check to a macro Date: Tue, 28 Aug 2018 16:27:09 +0530 Message-Id: <1535453838-12154-7-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535453838-12154-1-git-send-email-sunil.kovvuri@gmail.com> References: <1535453838-12154-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