From patchwork Thu May 20 15:34:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12270931 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91466C433B4 for ; Thu, 20 May 2021 15:35:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B7886101D for ; Thu, 20 May 2021 15:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238746AbhETPhM (ORCPT ); Thu, 20 May 2021 11:37:12 -0400 Received: from mail-vi1eur05on2090.outbound.protection.outlook.com ([40.107.21.90]:8577 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234023AbhETPhJ (ORCPT ); Thu, 20 May 2021 11:37:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DbIQHbI07gB11Ee4vg6o1ChxiBbtzCXpsdSNGqH/6UVY+qtc1rQFSSs6BkFGjfeKzmeTN/0R5m4Fu7+ZR+t8XdNDRnOi5dqpkIPZZVW2v6Hk6ZQ/G3DSEa3xDj+aFyYnUvwCN7SkjR6Blj8f5euZQzK/gZp3XQlIcIYbUCd2Pn8/ht+bBT934hQ9us8dB4zgpq1XpNiNPU4imz+xOQ4TnaIoEgIQUH8F7Q1dGL1B7d3lGwPQBjKgFsgVy4ygnC7vfz1UBdMXSASzP//mesiRyQ6TkrarAmpTXLqQergUC273rp26YMfNaFksWBHLV43xFLeccED/0LtYQ3197/6YPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v8bp5vVsYCRNZgSkqz9f+7TdXrBaQ2RlSE6aJGIpDuw=; b=Pz4AQ5DVUW4EQ/DsBBwxkl/gQHIyf22mijitGMUlnb2ey+850oA/c3YAgwYwyDW4jiISBJ2MzzpVhsMOsN2bgW1wCjyp6KFIb4dFbWFjjGWl0F/p0zQj5RN4oCIbg42TF92MTiIrcLd92u3Uog35/aGwz+WRavlJl3yaiTvwS/PIYaqissaEe96/CZQje2OI1H0i5uPuI0K+qpptO08feYml5p8dm0sKHCKi6XWqNZqXwjUFwxjtuRWA6FTK/r1ePy2H090+YPbFqZ8uklQ3p8CZnbDOPxB68gFxinK04Mb+cYCAY0Lj0D6wkSCCPMBxDtukED1oDKWo1wIGHGGcIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=plvision.eu; dmarc=pass action=none header.from=plvision.eu; dkim=pass header.d=plvision.eu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plvision.eu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v8bp5vVsYCRNZgSkqz9f+7TdXrBaQ2RlSE6aJGIpDuw=; b=eGC6tV9PBn+RRlVqWY7s2eeTu3qN4/qUJ6UCXLJLHBCZO/1M2g6lLNydZgR5o3k5T2YVbYDo3tMFfsQk0wDx672O5yU7WirMChuObyXmZo4qSaeAHA2Y9cWJjSSaK1ZDnlyiEQwRc0ghn63yEgioELY3RWKEC8c6LemKDRb/K2A= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) by HE1P190MB0268.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:62::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Thu, 20 May 2021 15:35:44 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a%5]) with mapi id 15.20.4129.033; Thu, 20 May 2021 15:35:43 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Andrew Lunn Cc: Vadym Kochan , Taras Chornyi , linux-kernel@vger.kernel.org, Mickey Rachamim , Vadym Kochan Subject: [RFC net-next v2 1/4] net: marvell: prestera: disable events interrupt while handling Date: Thu, 20 May 2021 18:34:57 +0300 Message-Id: <20210520153500.22930-2-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210520153500.22930-1-vadym.kochan@plvision.eu> References: <20210520153500.22930-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AM4PR0101CA0065.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::33) To HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AM4PR0101CA0065.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Thu, 20 May 2021 15:35:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69640ae9-e925-4825-dfe3-08d91ba4ee5a X-MS-TrafficTypeDiagnostic: HE1P190MB0268: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1079; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nm1KnyCflYzypfgPiV0Xe7Lx2eZst3gxttML4Eg+ipAmIu5NJNP6ikRm7pSR2fDk+EkLN+i40PjqTIOE1rqu9yZyNxEq+kNBxhIBBZKJJV4LE2Ru6e+mwriUplUw6XXKaYpK96qSQibzkmxGXZ3T3suL4vcAJbeU4d35SERIrRVDOQK02E0jT/egSJfuynSRg4n6qccYTpg2Tn/qRr1PKklXTfWxIpA1Mkj5kawCajUqtmK8C5het/P2g3VSdwEMwG2n6GyEhQJANqS6tCWiDjXu4OFHp02TpF3aiBN0tP1rHzf/InUWFhJvatAoSN4WEm1Di6Us+rpi656Bx/cdAlnH00lLcYnAQnK3dzOxsTIxXd3B46t8R82k3j6DROlqn9w5Hi4L89RQZRntSMtqTWLENy+wRr3U9IdzKNzKyzCOijC0LpEfaFZMLMEYmI5ipJAUhkz2X/iVO6Z0rA0UUSI1yD+nWatisai+MqGGrtmUgO0r9hF7OYYAvef2JwA6oF2bo93VJxNs820UIteieUV+jVo4VPr7moAcKUJIT0XwSoxouDHEhdbRBGXx5P7Kmt5QgeXRn7EQVcmW1awUm0/AdQJxFPmS0F9n4s/WuTO7S/bM0zuC5tvC2TGTA+AY5rHUREPXQqEkqJ59LgVpMg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1P190MB0539.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(396003)(136003)(376002)(39830400003)(346002)(366004)(6666004)(26005)(5660300002)(4326008)(6512007)(66476007)(8676002)(66946007)(316002)(66556008)(110136005)(956004)(54906003)(36756003)(186003)(16526019)(52116002)(1076003)(2906002)(8936002)(38100700002)(38350700002)(86362001)(2616005)(44832011)(6506007)(6486002)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: UP+ghVJOEQwWwEr4FFjKHJDI9ej+JDRqjIJ+tjyMRbfnBsC6zrgWToZoAAw4tENZVAxs9ptdC/WJ3/7lUO7HyQzYx56+eh5yPBxt/xKJ4K7QKwXJ2mgYRFM+7L+ErLW5EJh6Rgm4DB5bX07+NAUEOQLbS853vVifsnJ1ywjzM5kFXCgrbhEJ7ATUHzH+PIGwqsS0rRE0J7uGiXBlQjsdjbBQgN2F+SNPaWKDCWYslUQhpay+pe+dlO0cOklLs0M6ZcVqZUNWBtJQdDGztysiSP0Qxz1ADToMcOD7nO2dQF00nkvBnI0Q3shnjHNdRfmtx5h6KyWLkn01JpdAFzQAULIK3hQujzbf3qBdfTrn8JsKR1fTIA7Um5Kc+xW8eZRHTIyTk41p4tVARJ65Xd6LRpD+AyHDHzPX7tKMcs/FfwchqCz5rU+PHkhh7YZ6phGPcB8ShYTygK4R1Zjnyl+O4aZU7f5nqdSk/OUZO/vzKPGgyWrUykFSbgszIYW2DSaV1l3fON2W/zVIOtlClFqvvta97Y0ng80vvKWyX1EXPmBtSu4AGwbjUEBO6xjsNnh6q7u/AipEg5QcGdEfT20YQMezf+C+H+GpGVFcZhmAKpd0EOcFiuNmZITQV3D6RN1hzE5KiK6ezywwHEXUODdW1Hso5FJVSO2QUM50Ns5p79uSpOf0Uhx4zD6ZE/msrL8TK13CZtncZrRK0+uChCcs1fTbyuPvhMCtApJPHI0oU3j1vGIYia+0Dg9USbE2V4tFD9JI9oX5Jm0qzySbP4tDVTA+/MUWQmVaHI3TLlU7DgN3xU247l+/OSyT3U/5+C/anlVrdHjD2Cj+KSCTBLkW3m6PeUZVu5xcTbBJawY6IDxwF1x1gjiCg8U9qYTPbmbEHi8jLM2l2ikCazdu80PherD9UJrsz+WIcq5GujsJ0siFfio5Gy6K3Nrno/uHHKbZEouPh+4kJTXYjNDlWIvIQ6r6Vrqo+zNNR6Z9ffDeSdjSwuricu2fWBZ21D9X6xNXEuebnfVXWcIu501awC3ZeI7zeA2LNHOgShRCywQ6gekp/nzYHKmCuN3xw6yhp7d5m19dCzYQHVfe3UCQPIn5nu12B7SGZ3Mdcr4rxk6Oqm/3WjlIpW5+GkFw1TtNmAmSq6pPmsVjtqbYuZ7tRxZ2OocLsaBj4lSDIxfWLY0ev3GLhLYxGix9Pmz45fEf7xXMeTeHJWEqRUkJt1N2QBBqcEztl8OyZRF4ypCRxk1PCQQ2dITyBnr5FXzqrrdwYv5bK6O9uMIl5sxoJGb/LHiBjBADUwETdtLYPUGa8cuVsmjGYoCFESEPJ2Sm3VD8RJJR X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 69640ae9-e925-4825-dfe3-08d91ba4ee5a X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 15:35:43.9344 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 03707b74-30f3-46b6-a0e0-ff0a7438c9c4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lozxAP8HOtannqZE9pDajfmKFV2CVVf20UEwVvjpL7BRSdQQGIualIGt0c3TCj8X+IEoX96qA6aM6G3jQ5CtIP83YfeOHAAEfOZBAWsufto= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0268 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vadym Kochan There are change in firmware which requires that receiver will disable event interrupts before handling them and enable them after finish with handling. Events still may come into the queue but without receiver interruption. Signed-off-by: Vadym Kochan --- .../ethernet/marvell/prestera/prestera_pci.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index 298110119272..dba6cacd7d9c 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /* Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved */ +#include #include #include #include @@ -144,6 +145,11 @@ struct prestera_fw_regs { /* PRESTERA_CMD_RCV_CTL_REG flags */ #define PRESTERA_CMD_F_REPL_SENT BIT(0) +#define PRESTERA_FW_EVT_CTL_STATUS_MASK GENMASK(1, 0) + +#define PRESTERA_FW_EVT_CTL_STATUS_ON 0 +#define PRESTERA_FW_EVT_CTL_STATUS_OFF 1 + #define PRESTERA_EVTQ_REG_OFFSET(q, f) \ (PRESTERA_FW_REG_OFFSET(evtq_list) + \ (q) * sizeof(struct prestera_fw_evtq_regs) + \ @@ -260,6 +266,15 @@ static u8 prestera_fw_evtq_pick(struct prestera_fw *fw) return PRESTERA_EVT_QNUM_MAX; } +static void prestera_fw_evt_ctl_status_set(struct prestera_fw *fw, u32 val) +{ + u32 status = prestera_fw_read(fw, PRESTERA_FW_STATUS_REG); + + u32p_replace_bits(&status, val, PRESTERA_FW_EVT_CTL_STATUS_MASK); + + prestera_fw_write(fw, PRESTERA_FW_STATUS_REG, status); +} + static void prestera_fw_evt_work_fn(struct work_struct *work) { struct prestera_fw *fw; @@ -269,6 +284,8 @@ static void prestera_fw_evt_work_fn(struct work_struct *work) fw = container_of(work, struct prestera_fw, evt_work); msg = fw->evt_msg; + prestera_fw_evt_ctl_status_set(fw, PRESTERA_FW_EVT_CTL_STATUS_OFF); + while ((qid = prestera_fw_evtq_pick(fw)) < PRESTERA_EVT_QNUM_MAX) { u32 idx; u32 len; @@ -288,6 +305,8 @@ static void prestera_fw_evt_work_fn(struct work_struct *work) if (fw->dev.recv_msg) fw->dev.recv_msg(&fw->dev, msg, len); } + + prestera_fw_evt_ctl_status_set(fw, PRESTERA_FW_EVT_CTL_STATUS_ON); } static int prestera_fw_wait_reg32(struct prestera_fw *fw, u32 reg, u32 cmp, From patchwork Thu May 20 15:34:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12270933 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71FBEC43460 for ; Thu, 20 May 2021 15:35:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5128660FE7 for ; Thu, 20 May 2021 15:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240123AbhETPhP (ORCPT ); Thu, 20 May 2021 11:37:15 -0400 Received: from mail-vi1eur05on2090.outbound.protection.outlook.com ([40.107.21.90]:8577 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235891AbhETPhL (ORCPT ); Thu, 20 May 2021 11:37:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gtZPzh/PqJk1xEj7hNYgpZjhBhPYuQo8Ehr4zXNtLMSpJ+64L1bnMCB3l/xn5nyGnc3V4l70KbsNBA0XF631y6t8S7R16UCKXS56y+OIjqABQUCaiTPR6MplIjDljImLYliBEdw3MEk15VFwuPCvBoAdUnIc2d6tmsu7fSYGBfTcIJvmVnyugLV8sHUvwAGd8HPHnRe+NPD1uqRTifBkvOKa2tb2TGvOTEktic0kC/Us6fEgiS4KSfBGdccNvXdXGxPzHniEIOBLA+IWjScdM6m3Bf9NXOthEmxZtF6wpVwhOLW32c1EgnHr4XEamLYalHPI9MQLHZQ5WiDTLca3Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xe0P7WfdIFuu+woSaGWO4fiFYO5nO0G/uHHqlGEqyM8=; b=AuFzEZvZd1l2gkqMOBw7hvUC2IwI5Ydokc0vc42t9Z7cuw/I3mH12P3CIeUTPvWBh4JvLMaue0kEMxO9WCb6YNabNowYRO3KVUap5lLL8sgcOvF7mnPgz69M5+K0yqdLIXRGSJ320oRFnYc8zaYyKmcTQ856yCiOcgBTZFd9OW4ljGYommRfG7pboOrg812tY8ggHWCMZLA75bPkW2YgfZdkL7jd4B2DRudn6T4gpizZmG33IA0MNMRhCngVqkPgkn6HkVrrh0sbt6qDbXCYHDgKjvhrmL9+Urzbv7hpuk9Ogez6wRHPv9rtvFYmRWLkUoWrtpD13Msc60gflE1JEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=plvision.eu; dmarc=pass action=none header.from=plvision.eu; dkim=pass header.d=plvision.eu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plvision.eu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xe0P7WfdIFuu+woSaGWO4fiFYO5nO0G/uHHqlGEqyM8=; b=KVhqWcgH/gZeBgf3J7UpUEFJ/rMz1UlJmaxN7hJXusjuSGrQeacOMNHa+9W2ckgxzRS+fW5pMtRAPqmx/km0tinCv9VMqhHh/GtsL8ubz3dCD2sECQataBSTwbF60ZSEf80Dm7Esbp4tcm+/aEutt0IUaJS6doziqfsQKkNVH2E= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) by HE1P190MB0268.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:62::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Thu, 20 May 2021 15:35:45 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a%5]) with mapi id 15.20.4129.033; Thu, 20 May 2021 15:35:45 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Andrew Lunn Cc: Vadym Kochan , Taras Chornyi , linux-kernel@vger.kernel.org, Mickey Rachamim , Vadym Kochan Subject: [RFC net-next v2 2/4] net: marvell: prestera: align flood setting according to latest firmware version Date: Thu, 20 May 2021 18:34:58 +0300 Message-Id: <20210520153500.22930-3-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210520153500.22930-1-vadym.kochan@plvision.eu> References: <20210520153500.22930-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AM4PR0101CA0065.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::33) To HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AM4PR0101CA0065.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Thu, 20 May 2021 15:35:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a2de1718-ae2e-46ba-8619-08d91ba4eefc X-MS-TrafficTypeDiagnostic: HE1P190MB0268: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XaUHISmN9YJmf9qPKSgvmbvfIHRImyA36wgAjIPWNkPx50tZL92d7H+XmrviP147tJ02Q4ZKsBSAH0GX9oQdJ2mVo2gaLwVRRW9xWYKomG3CkpLNHgcfceQttgy/cX/TCW1kadPr+fikQiFtrFjHPSM4K6QuR+pmEd+jwehVZgfKOSlRz6R0lb0DFHk/kc9tqTS0Fgkzfg1UcGd2qoPvPiJ+q97/V9a4XloewHShcPAxOpJ7rtUIT/ddaw0gLDjrWOhxXdNGsdWTFDARUmuDs9Z9H5MxQjTFhTxX2cJzbBQF5pYDdBE7JFo3tbJVyh3ZCW2NtsjJRk8kQBCUtscWu0obnhtLqekjxnHuMmxdo17nfsz0wVem8NZYLyO/nSMbY0MgM7RU9LQGoz8PBIbQ72rHOLbMleH1fBTEbFnD58qAVEV/JFT9xYz+4g7w+78B0Mjfg2BE2jwDLgrPlLJM6ezg7MM/emMrFMEBs7tPfZt03jBsSkymPxuf64sfOVT067oftyesDof/exfZF83osp1+nY/5HcMV/oC7LxjP/BvRXcvAtoa1y4kngKyKbd26fSk7A02eydJx+0kxG09Kwt6rD0i5cIHZqlrhLxhshA3XuJmFuhqvfeQ+u40yCRCVGxioSTckLHxgAekbAitgJiXyljK9SUlNpSOK+RBPZF0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1P190MB0539.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(396003)(136003)(376002)(39830400003)(346002)(366004)(6666004)(26005)(5660300002)(4326008)(6512007)(66476007)(8676002)(66946007)(316002)(66556008)(110136005)(956004)(54906003)(36756003)(186003)(16526019)(52116002)(1076003)(2906002)(8936002)(83380400001)(38100700002)(38350700002)(86362001)(2616005)(44832011)(6506007)(6486002)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 8Q3xKfTF7AzOiO1b7OU9G8Z8YoA1oBLC0ujnY73mL0xh/YhJh5ciifUk2Zp5mAVuHQULlxIskWuXuf1JuGmc4Lh/mFDSvoxwdvC76e4hHzEUJ0NbuF4JP5MN4y6kBhWfTpBM2gxUAUI84CRIRzs0CkxVMj+7FAf+CfKocu0Ya1Y554BjNlQ+jVvpcZyjJtxia//CYF6HwfTiM/a6A7vV/1EpqAqJ2BGk7NozjPxM7cHwztRhrMFC/5pgnmszL/g+GDgn0PsgBjh7J5Z60lC7Hoj0ORDAEgrIuHg6Gsk5j3BaHFqf+4yQviQeshLyEdQ2HFzfLBeXksKfgUZ70zDX4J0af2OKpsuIiGsm7fSfLN+l0rUvsvFNM4h8Pu01UGWh2E1mc2aCk3xoJz4wLlV7DVin4YVx/V+OLOO+wBtKIZ7+jBWqzFfkMGTN3FXQrZd2TXxvdvS3adJubJYL8QJen/xyL7dqRqknO9qQZGQppBL+0+rU+yWXH3KFc+rAjrNIplK6t84sIDtBFZQQDrl+VzTzn72sUlLBACWFkafDn+5jkc0K7gH8miBwJsXKKF2K3p2p9M94wf0O5kom4j7nBhx5/mNKB07c/B3zZMda1e283PjtxDPFmVX9hcU38jrKcl/YjQixEDK7eSLnMHGokcspWLrHn4DRVlPH1y38b06yyVCpah+mMagn2zwuvcJCw5Bhfsac7uMMc7sEU2TEbruGb0M9Stz4qtjJYSRjKBywPMliprlvOZvmd3PXQIQjskCMcAT7uHLrar1ZdOWnqGNrjzgNQFQ+GmtYGuNnpUdzm0KnWUSktCmYag3fVIXJpxydcD+7PsYFQOO3Cf+rkcEkEPgNpPIA9/xnPQPRw5z20jF8PyFjEviHj6cmbMs/sVbrKl263C/QM1kcRGuAg+Xa+E1xVMe+6kqwgOCpHUy1oPxABlMmOij9ylKyEV/5WrMa3e8UQCurXZRJ5ojZ1kU/8Q8UGUBvqLBmpwFOloL6bx1sJk4HET1TvcWxtpyrbZX1wEJbr4PDOlfu6NEEX1udQSdSJskWAEq2fGrRuOl4M2sHQnDv6waxrSyK9wZdfskyeWl4srNiVi/+87ErGFTJNPEADgV95t9mHeDgyweWoMYr218dAnqCRzHSxMuOAABrTSby7uMLRcSUpfmn+BWM/f2a6E1zWJq/1TywJiuKLrsNNDZnQ3E+mFjJ14/A2RS3G8yeG4aZIpufmhD5xJa1+DUyRZ6cdZxd+HqF6XNfwVamQsgbrwQuPElgo8ze8vWuSYgz/14BCjKUlauq45Z1xLhhySiMdfhKz7nHWkAcW/MNMBXRu6c9ZSG0QE+J X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: a2de1718-ae2e-46ba-8619-08d91ba4eefc X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 15:35:44.9228 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 03707b74-30f3-46b6-a0e0-ff0a7438c9c4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QknT5rlEjln/JTvqEKYBbVJ1czaMMi2xhrQRFZ81QvgEncEgzym22LoIXKqE1s2VKaz0bVewsrE0SgXRStgIqruDv7K1bpJPLvvgaCkvAQ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0268 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vadym Kochan Latest FW IPC flood message format was changed to configure uc/mc flooding separately, so change code according to this. Signed-off-by: Vadym Kochan --- Notes: RFC: 1) Add support for previous FW ABI version (suggested by Andrew Lunn) .../ethernet/marvell/prestera/prestera_hw.c | 85 ++++++++++++++++++- .../ethernet/marvell/prestera/prestera_hw.h | 3 +- .../marvell/prestera/prestera_switchdev.c | 17 ++-- 3 files changed, 94 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c index 0424718d5998..96ce73b50fec 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c @@ -2,6 +2,7 @@ /* Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved */ #include +#include #include #include @@ -85,6 +86,11 @@ enum { PRESTERA_PORT_TP_AUTO, }; +enum { + PRESTERA_PORT_FLOOD_TYPE_UC = 0, + PRESTERA_PORT_FLOOD_TYPE_MC = 1, +}; + enum { PRESTERA_PORT_GOOD_OCTETS_RCV_CNT, PRESTERA_PORT_BAD_OCTETS_RCV_CNT, @@ -188,6 +194,11 @@ struct prestera_msg_port_mdix_param { u8 admin_mode; }; +struct prestera_msg_port_flood_param { + u8 type; + u8 enable; +}; + union prestera_msg_port_param { u8 admin_state; u8 oper_state; @@ -205,6 +216,7 @@ union prestera_msg_port_param { struct prestera_msg_port_mdix_param mdix; struct prestera_msg_port_autoneg_param autoneg; struct prestera_msg_port_cap_param cap; + struct prestera_msg_port_flood_param flood_ext; }; struct prestera_msg_port_attr_req { @@ -988,7 +1000,43 @@ int prestera_hw_port_learning_set(struct prestera_port *port, bool enable) &req.cmd, sizeof(req)); } -int prestera_hw_port_flood_set(struct prestera_port *port, bool flood) +static int prestera_hw_port_uc_flood_set(struct prestera_port *port, bool flood) +{ + struct prestera_msg_port_attr_req req = { + .attr = PRESTERA_CMD_PORT_ATTR_FLOOD, + .port = port->hw_id, + .dev = port->dev_id, + .param = { + .flood_ext = { + .type = PRESTERA_PORT_FLOOD_TYPE_UC, + .enable = flood, + } + } + }; + + return prestera_cmd(port->sw, PRESTERA_CMD_TYPE_PORT_ATTR_SET, + &req.cmd, sizeof(req)); +} + +static int prestera_hw_port_mc_flood_set(struct prestera_port *port, bool flood) +{ + struct prestera_msg_port_attr_req req = { + .attr = PRESTERA_CMD_PORT_ATTR_FLOOD, + .port = port->hw_id, + .dev = port->dev_id, + .param = { + .flood_ext = { + .type = PRESTERA_PORT_FLOOD_TYPE_MC, + .enable = flood, + } + } + }; + + return prestera_cmd(port->sw, PRESTERA_CMD_TYPE_PORT_ATTR_SET, + &req.cmd, sizeof(req)); +} + +static int prestera_hw_port_flood_set_v2(struct prestera_port *port, bool flood) { struct prestera_msg_port_attr_req req = { .attr = PRESTERA_CMD_PORT_ATTR_FLOOD, @@ -1003,6 +1051,41 @@ int prestera_hw_port_flood_set(struct prestera_port *port, bool flood) &req.cmd, sizeof(req)); } +int prestera_hw_port_flood_set(struct prestera_port *port, unsigned long mask, + unsigned long val) +{ + int err; + + if (port->sw->dev->fw_rev.maj <= 2) { + if (!(mask & BR_FLOOD)) + return 0; + + return prestera_hw_port_flood_set_v2(port, val & BR_FLOOD); + } + + if (mask & BR_FLOOD) { + err = prestera_hw_port_uc_flood_set(port, val & BR_FLOOD); + if (err) + goto err_uc_flood; + } + + if (mask & BR_MCAST_FLOOD) { + err = prestera_hw_port_mc_flood_set(port, val & BR_MCAST_FLOOD); + if (err) + goto err_mc_flood; + } + + return 0; + +err_mc_flood: + prestera_hw_port_mc_flood_set(port, 0); +err_uc_flood: + if (mask & BR_FLOOD) + prestera_hw_port_uc_flood_set(port, 0); + + return err; +} + int prestera_hw_vlan_create(struct prestera_switch *sw, u16 vid) { struct prestera_msg_vlan_req req = { diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.h b/drivers/net/ethernet/marvell/prestera/prestera_hw.h index b2b5ac95b4e3..e8dd0e2b81d2 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.h +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.h @@ -138,7 +138,8 @@ int prestera_hw_port_mdix_get(const struct prestera_port *port, u8 *status, int prestera_hw_port_mdix_set(const struct prestera_port *port, u8 mode); int prestera_hw_port_speed_get(const struct prestera_port *port, u32 *speed); int prestera_hw_port_learning_set(struct prestera_port *port, bool enable); -int prestera_hw_port_flood_set(struct prestera_port *port, bool flood); +int prestera_hw_port_flood_set(struct prestera_port *port, unsigned long mask, + unsigned long val); int prestera_hw_port_accept_frm_type(struct prestera_port *port, enum prestera_accept_frm_type type); /* Vlan API */ diff --git a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c index cb564890a3dc..6442dc411285 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c @@ -404,7 +404,8 @@ prestera_bridge_1d_port_join(struct prestera_bridge_port *br_port) if (err) return err; - err = prestera_hw_port_flood_set(port, br_port->flags & BR_FLOOD); + err = prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD, + br_port->flags); if (err) goto err_port_flood_set; @@ -415,7 +416,6 @@ prestera_bridge_1d_port_join(struct prestera_bridge_port *br_port) return 0; err_port_learning_set: - prestera_hw_port_flood_set(port, false); err_port_flood_set: prestera_hw_bridge_port_delete(port, bridge->bridge_id); @@ -528,7 +528,7 @@ static void prestera_port_bridge_leave(struct prestera_port *port, prestera_bridge_1d_port_leave(br_port); prestera_hw_port_learning_set(port, false); - prestera_hw_port_flood_set(port, false); + prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD, 0); prestera_port_vid_stp_set(port, PRESTERA_VID_ALL, BR_STATE_FORWARDING); prestera_bridge_port_put(br_port); } @@ -590,11 +590,9 @@ static int prestera_port_attr_br_flags_set(struct prestera_port *port, if (!br_port) return 0; - if (flags.mask & BR_FLOOD) { - err = prestera_hw_port_flood_set(port, flags.val & BR_FLOOD); - if (err) - return err; - } + err = prestera_hw_port_flood_set(port, flags.mask, flags.val); + if (err) + return err; if (flags.mask & BR_LEARNING) { err = prestera_hw_port_learning_set(port, @@ -901,7 +899,8 @@ prestera_port_vlan_bridge_join(struct prestera_port_vlan *port_vlan, if (port_vlan->br_port) return 0; - err = prestera_hw_port_flood_set(port, br_port->flags & BR_FLOOD); + err = prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD, + br_port->flags); if (err) return err; From patchwork Thu May 20 15:34:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12270935 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A477C43470 for ; Thu, 20 May 2021 15:35:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DC816109F for ; Thu, 20 May 2021 15:35:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243841AbhETPhS (ORCPT ); Thu, 20 May 2021 11:37:18 -0400 Received: from mail-vi1eur05on2090.outbound.protection.outlook.com ([40.107.21.90]:8577 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236975AbhETPhN (ORCPT ); Thu, 20 May 2021 11:37:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Usxtu2m6CoRQgwDDFO/xw2AqMhrZtXuYLdhiJO3MzqzMmAopJNOExXMSEWB6G8lLyTtEhHZcD32XDKhQaN2AOyT/W9hA5bdrqhvv3doWEk0xA/S+0W2brM01mk3a71zK7AlHwDAruppO0ZcJDIE2D92uqIKcvrp3SUJAXodO6/5J/UyWOGYvJsiAun8gsOhY/u0URpUFF3tkAj1QSfGn37fQBgkQ1AYzfCi/gHDbLsmJSZ5ZvttK357je3Cg1q0pqwR4fuGhVgLFXaDRu1dcj/W8XMkEzJA64Te571RyDo1uoAoz4KEKwp8zisffbeg/ijOZs3dXjQpnybulc1lcdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nm5M0IGogy/b30i99jK4zCqxL/S9+iPH1g7g2oXLShg=; b=eXkwHRKmfVSeEHboAmLYLxIfMX8YPZE5U/5QvSopoLXiJbCOYmyvqzNtC95QdeaIS0V/fvxKHzqy6dAarbCpsqEjUYTbiZI41qEpaTMxEsRbjQ6Dsm4dUkmUYUSvcbX+R/TLmJgBeyGFuax8igSAviJYPZyeZVhg/8CSqbBJtA6EHV2R0D+vfOTUSJTqyM7bmcZMz6k8bIotpVm1yeEuTsKZLNd8YU87TidyQVxhToV4rdS2RlI0OrO8yCTHiYpOne+VMvtNIZkcaMfS6Y//PrRWe2IHkA/ijtfF9c1qjA6Nzx0sOK/UIYLPb5BXJxNgjcDMO2kGtk60Cx+LRd6QqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=plvision.eu; dmarc=pass action=none header.from=plvision.eu; dkim=pass header.d=plvision.eu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plvision.eu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nm5M0IGogy/b30i99jK4zCqxL/S9+iPH1g7g2oXLShg=; b=pH+5spE8ucSgfGWU5T2HtrnvhHy5aLVYCDaLLNfl9W9TrPzB4TnJ/xUZomzBMFwxhuoxwlwllWYhhVmSz8PaLzHMCrqmOaZISYDje14hPcENaJVtr1Z+MwdTH4LYPHLb89L599YhI/NtGCw/+ymX2w65H64f1ZdL6YBlHSISg28= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) by HE1P190MB0268.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:62::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Thu, 20 May 2021 15:35:46 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a%5]) with mapi id 15.20.4129.033; Thu, 20 May 2021 15:35:46 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Andrew Lunn Cc: Vadym Kochan , Taras Chornyi , linux-kernel@vger.kernel.org, Mickey Rachamim , Vadym Kochan Subject: [RFC net-next v2 3/4] net: marvell: prestera: bump supported firmware version to 3.0 Date: Thu, 20 May 2021 18:34:59 +0300 Message-Id: <20210520153500.22930-4-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210520153500.22930-1-vadym.kochan@plvision.eu> References: <20210520153500.22930-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AM4PR0101CA0065.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::33) To HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AM4PR0101CA0065.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Thu, 20 May 2021 15:35:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed1da5ef-3aff-40b7-df82-08d91ba4ef8b X-MS-TrafficTypeDiagnostic: HE1P190MB0268: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:102; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p9txhqJLiKDFc25CPgsLm71Qfi5bP7PCb6M6rrrvmFyWos/5NTQQtLGNh8rcTeGh494+XmkIx4oXwrbWuBQUfNhQIB/7phYPiO90u0Gr3jd23WF7Eigg+X/pO5ZB2DHBoqAHtjlBfeKA74Hf04PZntNwH7VsBIWyYlAymPY3qABNb7Z/Ysx65dv5cQRKn23apbeN+XrSoBKy+QjuMo1DBZdVm5wBP9f8aajLFD7UFweffb3A9Wrj2n2LB+MmMtEYg++G8CjrZlohHBaUcav39WCInAwIWAQ/ZVr088c1WUNMd2F192nqzHB/erSxeY2bkn9+R8ctjspIA8P4u1T94CFkKxLUkh111qaoakX+4iGUTETZ4A+P3qtLgpjnY+mrNXuH3ljiBh1OMB60WYeFyMb68eQPd9mfjqSIjUxmFLZna+kFV0aRhy5cUV3m7it1/METknU7LGT8k9tlqp7unkl2JgZOmi/n+kwjGVg9sUoKt/CSzcX+sSMvSJMOVhASpO/IwlwUwA2DH9wE9nzFWDiAKPIrNYEP2d2ZzcM9e1o4XPtlVjgG/Jhfn6tlhIZLvjzXt3ii7Gi/1yKDxD/BjAnryP1ZQt1a5CKZ+oxsjrFR2HPNVf3oXW7u8Hcni5I9NaoXR9rXl/F0gEN2BQ22nw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1P190MB0539.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(396003)(136003)(376002)(39830400003)(346002)(366004)(6666004)(26005)(5660300002)(4326008)(6512007)(66476007)(8676002)(66946007)(316002)(66556008)(110136005)(956004)(54906003)(36756003)(186003)(16526019)(52116002)(1076003)(2906002)(8936002)(83380400001)(4744005)(38100700002)(38350700002)(86362001)(2616005)(44832011)(6506007)(6486002)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: PKR/TAzAPpe8fVcHuTzF9hthQ5rk5wBcxAP0p4sAHwxd0LE5zTI4foNK1W6QMXaY6idntHnI9elUX67uiL2KY4SV9qjb+gCdq2kfocZQhMqmovMw7AJX0tncVLqxCX9CIpD09CSK+C5SayhU3KyA0IOdm278rL1Dx6y4NskKDSJdZuVK2fXo2lceq7Os2poggaUP0k5bKEeUbOenzO0t3OJ+So6I53EzzBfkqjdv3iSVZx6JIAuIc6GTjbRQ4Mh7iuCex9kuRF//9c1MATW3pK5gyOfBXoN/l1P9urC+6hD9Q1kuLY/KH89aYTgrIKDdWWFio7cYm3tKQq7ZUMNY2N6oZhLKtP0U8VO8jP6EtH2fZtYCqGeo1wlunlczeFfsUb1bW4mCU7l9IMEgl+9b3MGQXq+KQCgqzzLxY73Su/hBBMq5MYhzY1GZSOpOJJfNicjbKcLiyz6+PhoErnf6Liu0+5Ori50wvsqcB7VbSI5plYETPbPBLsVwKvyrBO6TAa8vHOhFV3TckEpDRw1MLH/20TBxWhcT5/irhGyzjS+6hIAq7aXgemsA+tegjW85DwAYlxPnD7dB9jKOzTWiR54cnccmW+aWetMBnQVNlpq7ktrqZkYyKPbQPBJaNcfGt0tsRPdLSAqj4jLxUke6Wn3xGl4/2iSH99kMEGlx01g9y1Fev3wRn95H4IALdalO9fZEHkeOo9bumewaNbtw9mbAXzPrKitoQ+OBYRnRGdSDedoIOPe9nweFILaNydbmWIHl/H6b0iqdEGySt6ZvK0P+ggJrGfnSVsqnNU7kkJP8aXHk8uzKP4bgc9ljC7qF84AP0EJOjlJGrZ395dxmNYQ7wf0ONnEQccw75Rs+AhzlNxYZXN2Dr+UVFnBfETgAhiH6DjSEtgaMBudGIwKWFufJNAyrNcFCskn3Mvj721qEWUJby6K6qt+KD0eK3tKJZctYdLEUhjF5ZlTrC4sqU94mVGLqMQ9YlGylWmCh2knZO4qwdt7q9i/IYSImBri7FzJmzJYB5khQ3x/ZDC0o3F8jqzXLnG1GbYM84bDHeoBQteQjDzxns3fekwo7eJXRw6Mnj1b/9QDjZRkmNmEX6av2juZS42t4bfuOw06bYkKKlGw8bmBwgbL5sW8Y8B4R8Grw8JFyJE1NxDS37cRWXIduJU+c2clEFwVx+qUXz/cFj0yFZF6LFbbCN65P885OlCBHGjlzhsvxGFpkT2gH0lOEGx3n8NVmwMesnCxA1Ag+sc+ifxDtXRwTNGlQVLi/bQkNB7ralFIB8kwfD3yjymgop5p9nWdWLksGf9U7AJvopGIPatnSjiuNpeC2v4z/ X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: ed1da5ef-3aff-40b7-df82-08d91ba4ef8b X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 15:35:45.9212 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 03707b74-30f3-46b6-a0e0-ff0a7438c9c4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iWBjPGvYbdDbxgxAgVCJkdIjw8g+qnEihq74jw/UqdiXocZNEgFQCU/784YeKBW2nsM1/oFCoNt7YKPHgv5WQnPC0aQ9kwniXRKtM/FUQa4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0268 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vadym Kochan New firmware version has some ABI and feature changes like: - LAG support - initial L3 support - changed events handling logic Signed-off-by: Vadym Kochan --- drivers/net/ethernet/marvell/prestera/prestera_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index dba6cacd7d9c..5edd4d2ac672 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c @@ -14,7 +14,7 @@ #define PRESTERA_MSG_MAX_SIZE 1500 -#define PRESTERA_SUPP_FW_MAJ_VER 2 +#define PRESTERA_SUPP_FW_MAJ_VER 3 #define PRESTERA_SUPP_FW_MIN_VER 0 #define PRESTERA_FW_PATH_FMT "mrvl/prestera/mvsw_prestera_fw-v%u.%u.img" From patchwork Thu May 20 15:35:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12270937 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D84CC43461 for ; Thu, 20 May 2021 15:36:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28F3360FE7 for ; Thu, 20 May 2021 15:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243939AbhETPhY (ORCPT ); Thu, 20 May 2021 11:37:24 -0400 Received: from mail-vi1eur05on2090.outbound.protection.outlook.com ([40.107.21.90]:8577 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240517AbhETPhP (ORCPT ); Thu, 20 May 2021 11:37:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eYA6Nat/v0kXeJhRUqNIDMbD023sPi5pXVKadTSOzDhMeNOuBoIbe0ug0NCoBQ8HNro67+boMUD3SdifbbsK28tosblO9dCGCbPWS//9pQn3p4vxmrvZ3GtYY4CI9TvMRmeignHcNUDqwICqsHWb7VC9zYvlM+1hCxcH8f6xlOyRR6DJ2vQNNg3cZnkX277XnYNyRioCpWRqfzhsQHKOSSyZkuxRbMYd3PeWUmmcdzqiWSikzx+bce5YU7hBN1xc5bWU5rICvpq67RhaGSby2UigoDIlnfA6GJksx3uXUnW0EqebYfo5U82bNebouT9YEaAeTEDnZ1KNd+k8RoHEKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=05sY2SRMHPIV4oXtcsnvXFpQaIN1643PIPcK1mV8zyo=; b=I3TVmGrEX2o3Rg+6mG+TsUipiLH14e1oKyEkPOI4feRajtyGuP3F8vSCuH0elY8xw4fpfzhps0qwIFbmO0P5cL0RNnKEJF6xr1Ww/JQ9oXibWdNcW3qxKBr0IGby9YhUHMxAh5SBhrsysaBqvsLzqtLw3ZLtaEyIYr5jdEfnlRP13XfuW9fLeUn7WBs09pr7DAyTIe8lWYPiw9qLm7eaoHlfBKMmx7AJOIzi0Vam08a4rl0k7Fj7qWO3PbckbGzrUgnxHXUDskxrfw6EmoV5Ww8jYoY7GBYdmt8V44Xr2ciwLIklr59mCr28cvQ9E5JtcE8BL+0NAuLSUuemcnpKfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=plvision.eu; dmarc=pass action=none header.from=plvision.eu; dkim=pass header.d=plvision.eu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plvision.eu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=05sY2SRMHPIV4oXtcsnvXFpQaIN1643PIPcK1mV8zyo=; b=XVMXhaVJcDz4FIHedaXAyM15VllUm9CwmVc7438Eo29IjruX0JyIGIYpL0/OYZups840E1yZoxndAPMkAL+mPGKOzYXdLRmG+FWsbJTFzAxr+0YwakbvJpozgir+3PHi+CRhVyfdrN38bxvkH2lA1soMJDe8YCHe/+NfA5akoVc= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) by HE1P190MB0268.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:62::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Thu, 20 May 2021 15:35:47 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a%5]) with mapi id 15.20.4129.033; Thu, 20 May 2021 15:35:46 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Andrew Lunn Cc: Vadym Kochan , Taras Chornyi , linux-kernel@vger.kernel.org, Mickey Rachamim , Vadym Kochan Subject: [RFC net-next v2 4/4] net: marvell: prestera: try to load previous fw version Date: Thu, 20 May 2021 18:35:00 +0300 Message-Id: <20210520153500.22930-5-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210520153500.22930-1-vadym.kochan@plvision.eu> References: <20210520153500.22930-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AM4PR0101CA0065.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::33) To HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AM4PR0101CA0065.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Thu, 20 May 2021 15:35:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1cd24824-bfde-4859-5f50-08d91ba4f024 X-MS-TrafficTypeDiagnostic: HE1P190MB0268: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:216; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RP571Y7hY8CRi2HhaGVjk45hcTdbVjblgkmPLjQTfvC5UzZ4VlJHvYtHNkyuOSpgb6a6pLNnUU+GGdklq1h5kxorHPAKzj4250tA9JVMj3pQS57Bibdoo29VDvjsxgOVlEsr//Psm3ZofG4vjrOb7ar5OrjSVveU8ubcWVFPfY0no3iNt7SG1tRcoc0K167L3W0eJKMIgeKrc4iNw1DtMP+4UHOsoZvnOQYxzSaNIlFrDQhlciELP7hwRQR/g7okxpEplk7aV7eVZYhuHGymuMloRBHMNoYMFXsznu6FUKOOgl6v36dgUz/C89zVSmuxL2Oj5/HZC3WUYC3cmAYx34ZRJHEFKMsSlqVhHzq9LQ71z9Kpr3f0gwuexTnt+0c7zp8rHuQpINL9Ac1cknOgt9y021frBXp2kYSe2oWD/4h+Ifh6pAofLIkvmUCxlkEJLs7akCoh01iKVVCjPGNJ9ZEEA6zq2puHvSupIYmV75bJH1c8Or46yWDYieMxu32uZXSA/uNEbj1THsNQiuXSUFuNfVv5L8mxXBD2srjfTOfn1LE0i9+IJnH2cyoRs12p+Qf5wFZsroEdPnI0/oF43MSRVWOPEN4p7mGEkASHlu3oA1TwapROf03lWOxe3YZzYGxDNnmEUZ36dBb01Giz+Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1P190MB0539.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(396003)(136003)(376002)(39830400003)(346002)(366004)(6666004)(26005)(5660300002)(4326008)(6512007)(66476007)(8676002)(66946007)(316002)(66556008)(110136005)(956004)(54906003)(36756003)(186003)(16526019)(52116002)(1076003)(2906002)(8936002)(83380400001)(38100700002)(38350700002)(86362001)(2616005)(44832011)(6506007)(6486002)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +PRCXYixVFsl1z9024c/9hf3FhWTTRk6rIrdJHVe1hVtkpDM7JVGpMXVNYxBYH7fn2ff5ixTSEsXbSmTGyULDm28MCTPf8ixPGKJB7gD19BVIvwCZVT4wcH1dl0QIY8jW526uMQ7NITkJGtW1cjIKQaPoTnat0SyA7IxfGNum5Eht01nvkqPA4+sBFO1bvJzWlNzVKlDV0y+pKgRfKm8iPNO54axyyk3tSDqfL6Z/h9JUaHKDCY8oQlmmD3ZaKE8huYTGn+5pBq6uUeRgsvd4V8IuEbT8wbh4tQhWImANBTtYv40zpii/cwCxUS9QScLHqHofygngdI0KdEwR768dc1I/Pq6d/M4sX+9Cxi65NxKaLfRkiZ2wly4omYRmgaWappweY8MWdXIattRAsSnWQI0V8jKSE3F+6pqOvhuTRdTbTcSylWoA4pyMcdIf/jFKF+plzMi3Rz7BbEUZCZlXa2ujLGr0//YEKt1V+X+64k5Nt2A82EZQn16zZf2xFbSHnRq58Y52yudcVT3+W54tPiOAbyedFdoq+R3ajiCUijc4qcyP/lcMUWjKhsU+WKH0ZEo/jLPAQla0NqIaaaTOrMpZAQMADMaNLFjtNS7CCH1KUyz/q3WrnLP0E06TPjL+C91EECvC8iYpu6alqj72+4nc2nmcb5IOKpNxXPyYGfYpZozSlvRkyaeXFSWvYXtIpDrkYH/pOHdipULxrxNS5YbvafojqZemy1HBg7qyzoml6nWYTyJk0E5fxSqIQJbFWuqXb9tDT19PQGRTp+4dAvBqVFzmEkyROGcYu+4ALXY+94UxXJ0Zbll6MKr9WaO5wKBuyh52bTZ95nXNcXiSoWvdXRoZrRqhIHv4nQK0SOUEp3VO0lsWiTRk14vgHXQn4qVNUfBH9MYxapsE8gukLpjWVnjJXfGFRvnp/8ysmP7IktSFBqi8N2VwUOapMMCbTBBb3XlWXbskHr25BrqpTpJWS8pfCQVE8bVAs1/LFLkGc0Av77kbstXh5uwJUKJQbLfDf5PJMQOwYl8crOs9OUpeGynokvMjjZQ58TsY3AKs9+0Mmx22B+33qyY4mt5HO5NG1HuwYPj5wOYuo0qaMxG+v2cAKZcAX3vK9z657T7mEhZ41tjOUwLsJAHqpue5pm6Obe+/vZTdmuXEH9gaRnjpD/plnEIGAF2P73bFmjQf0zKncU4EDrrRZ4oMaa3RVyQydfMi6Smi9amQCi5L2Xi6ySLYqGv3Rh8ecDndF+Ibo/SYouK5ePHxgGvwYQSsk3c02qTYhLRZfzHGKCEz9Db4TugCvrh31XHvkQ2N0xm+zmErEn0D64A6f4eIPK5 X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 1cd24824-bfde-4859-5f50-08d91ba4f024 X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 15:35:46.8617 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 03707b74-30f3-46b6-a0e0-ff0a7438c9c4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PnHXb9956wO/qEdoq3KNgzta8gBX1C4TTRmj6faQL2otzDMqIsbjYuXCd8i2WNq0JrZBtt49yI1HiIl3GpTX2kxIDq/cbVIaaD8lqMtoCEk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0268 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vadym Kochan Lets try to load previous fw version in case the latest one is missing on existing system. Signed-off-by: Vadym Kochan --- Notes: RFCv2: 1) Get rid of automatic decrementing of major version but hard code it. 2) Print error message with file path if previous FW could not be loaded. .../ethernet/marvell/prestera/prestera_pci.c | 83 ++++++++++++++----- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index 5edd4d2ac672..a250d394da38 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c @@ -17,6 +17,9 @@ #define PRESTERA_SUPP_FW_MAJ_VER 3 #define PRESTERA_SUPP_FW_MIN_VER 0 +#define PRESTERA_PREV_FW_MAJ_VER 2 +#define PRESTERA_PREV_FW_MIN_VER 0 + #define PRESTERA_FW_PATH_FMT "mrvl/prestera/mvsw_prestera_fw-v%u.%u.img" #define PRESTERA_FW_HDR_MAGIC 0x351D9D06 @@ -172,6 +175,8 @@ struct prestera_fw_evtq { }; struct prestera_fw { + struct prestera_fw_rev rev_supp; + const struct firmware *bin; struct workqueue_struct *wq; struct prestera_device dev; u8 __iomem *ldr_regs; @@ -595,25 +600,24 @@ static void prestera_fw_rev_parse(const struct prestera_fw_header *hdr, static int prestera_fw_rev_check(struct prestera_fw *fw) { struct prestera_fw_rev *rev = &fw->dev.fw_rev; - u16 maj_supp = PRESTERA_SUPP_FW_MAJ_VER; - u16 min_supp = PRESTERA_SUPP_FW_MIN_VER; - if (rev->maj == maj_supp && rev->min >= min_supp) + if (rev->maj == fw->rev_supp.maj && rev->min >= fw->rev_supp.min) return 0; dev_err(fw->dev.dev, "Driver supports FW version only '%u.%u.x'", - PRESTERA_SUPP_FW_MAJ_VER, PRESTERA_SUPP_FW_MIN_VER); + fw->rev_supp.maj, fw->rev_supp.min); return -EINVAL; } -static int prestera_fw_hdr_parse(struct prestera_fw *fw, - const struct firmware *img) +static int prestera_fw_hdr_parse(struct prestera_fw *fw) { - struct prestera_fw_header *hdr = (struct prestera_fw_header *)img->data; struct prestera_fw_rev *rev = &fw->dev.fw_rev; + struct prestera_fw_header *hdr; u32 magic; + hdr = (struct prestera_fw_header *)fw->bin->data; + magic = be32_to_cpu(hdr->magic_number); if (magic != PRESTERA_FW_HDR_MAGIC) { dev_err(fw->dev.dev, "FW img hdr magic is invalid"); @@ -628,11 +632,52 @@ static int prestera_fw_hdr_parse(struct prestera_fw *fw, return prestera_fw_rev_check(fw); } +static int prestera_fw_get(struct prestera_fw *fw) +{ + int ver_maj = PRESTERA_SUPP_FW_MAJ_VER; + int ver_min = PRESTERA_SUPP_FW_MIN_VER; + char fw_path[128]; + int err; + +pick_fw_ver: + snprintf(fw_path, sizeof(fw_path), PRESTERA_FW_PATH_FMT, + ver_maj, ver_min); + + err = request_firmware_direct(&fw->bin, fw_path, fw->dev.dev); + if (err) { + if (ver_maj == PRESTERA_SUPP_FW_MAJ_VER) { + ver_maj = PRESTERA_PREV_FW_MAJ_VER; + ver_min = PRESTERA_PREV_FW_MIN_VER; + + dev_warn(fw->dev.dev, + "missing latest %s firmware, fall-back to previous %u.%u version\n", + fw_path, ver_maj, ver_min); + + goto pick_fw_ver; + } else { + dev_err(fw->dev.dev, "failed to request previous firmware: %s\n", + fw_path); + return err; + } + } + + dev_info(fw->dev.dev, "Loading %s ...", fw_path); + + fw->rev_supp.maj = ver_maj; + fw->rev_supp.min = ver_min; + fw->rev_supp.sub = 0; + + return 0; +} + +static void prestera_fw_put(struct prestera_fw *fw) +{ + release_firmware(fw->bin); +} + static int prestera_fw_load(struct prestera_fw *fw) { size_t hlen = sizeof(struct prestera_fw_header); - const struct firmware *f; - char fw_path[128]; int err; err = prestera_ldr_wait_reg32(fw, PRESTERA_LDR_READY_REG, @@ -651,30 +696,24 @@ static int prestera_fw_load(struct prestera_fw *fw) fw->ldr_wr_idx = 0; - snprintf(fw_path, sizeof(fw_path), PRESTERA_FW_PATH_FMT, - PRESTERA_SUPP_FW_MAJ_VER, PRESTERA_SUPP_FW_MIN_VER); - - err = request_firmware_direct(&f, fw_path, fw->dev.dev); - if (err) { - dev_err(fw->dev.dev, "failed to request firmware file\n"); + err = prestera_fw_get(fw); + if (err) return err; - } - err = prestera_fw_hdr_parse(fw, f); + err = prestera_fw_hdr_parse(fw); if (err) { dev_err(fw->dev.dev, "FW image header is invalid\n"); goto out_release; } - prestera_ldr_write(fw, PRESTERA_LDR_IMG_SIZE_REG, f->size - hlen); + prestera_ldr_write(fw, PRESTERA_LDR_IMG_SIZE_REG, fw->bin->size - hlen); prestera_ldr_write(fw, PRESTERA_LDR_CTL_REG, PRESTERA_LDR_CTL_DL_START); - dev_info(fw->dev.dev, "Loading %s ...", fw_path); - - err = prestera_ldr_fw_send(fw, f->data + hlen, f->size - hlen); + err = prestera_ldr_fw_send(fw, fw->bin->data + hlen, + fw->bin->size - hlen); out_release: - release_firmware(f); + prestera_fw_put(fw); return err; }