From patchwork Mon May 31 14:32:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 451869 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.7 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, URIBL_BLOCKED, 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 1BB05C47082 for ; Mon, 31 May 2021 14:36:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01077613D6 for ; Mon, 31 May 2021 14:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233738AbhEaOhq (ORCPT ); Mon, 31 May 2021 10:37:46 -0400 Received: from mail-am6eur05on2090.outbound.protection.outlook.com ([40.107.22.90]:62668 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233550AbhEaOfi (ORCPT ); Mon, 31 May 2021 10:35:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O+yAnc74zxRl03p83g5z3k7zFO8vTN65xeTZWcT7X98t6oAUVEKbPT9UFJQUJ6hKijN9CRvLOYqQSF9pl1xOamy9tCsCJx/C6Vh0oxOXiQYFn567fuQG8PzH1TMV8fNRPluktDuKMcJN5reZsbVlJrR6laVaCOYJMeMFTFEJw18+cDmbQYzu2z0XAc5CBzxXtHRkG/kQYCm0liQBexGQm7EvtTgqBWG8AwiBpNWCeSK3v/C/7XNNr8XbMjZNmf2wmyzAx045I1gO9umSxSeymVqWWqwThKJKICD6S1xPp+Er45gOcExSgWVJonHkHxBbiEqeeEG7RqOqWlkac7eGNw== 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=gZGwfonV1hZgeJ15FTkyMhbF/rueppwUwkYWODEqDWN6ekHcuhelvH/nAR4Nyj1hjjOt54/7KXI5DNcg9wI6pN4akcGL3iH3kvI+W9kUc9FD93OnaxH5k99k8efuOTBqu5MF3c1U1czNeZmVSut15LDF5MLxFgmpcYR2Z1PjOvjwRw83k0QH+LCrj2+c2ghC6mo+DXtbhzgGgRMknir1M8y8Mtmw3ROMujeZ4VP0tdZWol9OpfpBRRFaTuf7UN6F684LGzvxQw3Ryy3G991P685IJuD19ro68FkjwooKG6Y6g0t1ctPyHlXJy8fuNcxTLGDD1DHx/jHBFH605Jb/3g== 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=qS4C/z1UObBrKxmSoE/iJJsBY928igPZcKyBk8+QPu5NVNHjm+PO8un3dwtYdTLuhIUpaE5ee11nLlJL+gGQWAn1NxWLGM1JS9n9FCtOgY842JNHeeBPRrCpnBlhg7xfsHpnav00kVOihHko1l1juwYQXlBXgv027+StGQZjDhk= 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 HE1P190MB0459.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:5b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.29; Mon, 31 May 2021 14:33:25 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a%4]) with mapi id 15.20.4173.030; Mon, 31 May 2021 14:33:25 +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: [PATCH net-next v2 1/4] net: marvell: prestera: disable events interrupt while handling Date: Mon, 31 May 2021 17:32:43 +0300 Message-Id: <20210531143246.24202-2-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210531143246.24202-1-vadym.kochan@plvision.eu> References: <20210531143246.24202-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AM0PR04CA0036.eurprd04.prod.outlook.com (2603:10a6:208:122::49) 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 AM0PR04CA0036.eurprd04.prod.outlook.com (2603:10a6:208:122::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.26 via Frontend Transport; Mon, 31 May 2021 14:33:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 32f730ab-07ba-49e7-1d72-08d924410c7d X-MS-TrafficTypeDiagnostic: HE1P190MB0459: 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: G+v8XAz257chLszrR7uCWRKoJjWxquN39g5uf3KLQL48B8j2ffcWQcFnNX1a7vvTGMlw6R/bg0dmLTV21OFA+/TCuxD+s3Oi8Af8uqladj0kIJPNJbXgx7b4gLXsOXQcSc2Z7Fn23tGRb6b5Rb1hayZA4feG/mjMk9YrSFE5QBIWc9UEB1l5cmGI8Q0828Y3V+Da9mJQ/hEM7Qqj3pNzDT8/8vTJ9gWq1JF8/+l2CAbW2Du9l4jy0BeYFgE8zACspZVl48NZ/JTipnk/GIFrk4uI0u1KoXnDWWwMRz+FUlR8oLEasrzO6y1XGtBIj6QwM0CndQjo+4U9vcWAcnTiDRJlqP2bq9i4dZN6Xple+W3CMfUD6Pko4Ws7U/zuAlJy8Re8KhaR5sQJzUveLSx+Ftk6KZB7QRnrBmSQh4IdwLKiHoweS8k3lcx2yp0WWChYlLn7/f59tuHg+6C9sIkzbVxmOuhP7ib/7ZNr2+5JZO/y66NlXh9mampACYMP9V0gKMgk4eIEDYf0NOK0XDPWLpDs1ZhZAep1DKMeeSgNti48vRjpU52IJwQsU10/HjgI0oSIWE2WNKTbnJpmciw/+wONjmiZOnjjlbvx/ybC5LNX9btZio21Ghrvn15rn+vE06ITswSwlkKfXXm9rtGm7w== 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:(346002)(376002)(396003)(39830400003)(136003)(366004)(16526019)(26005)(5660300002)(6506007)(8676002)(2906002)(6512007)(6486002)(38100700002)(38350700002)(44832011)(316002)(186003)(66476007)(54906003)(110136005)(478600001)(66946007)(86362001)(66556008)(2616005)(6666004)(4326008)(36756003)(1076003)(8936002)(956004)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 4RKS2OeSbbS3Px+4l1gLwhw7nylltweimQLlazQIodvp1aewnG+5trQ4SJ294fLQmLXRRHUEDAfgXuiztw13UY5XMC6jRkXJIK0ZM95J8C1ws8+iGwPJTZD/xsuDL1AW5NLM8A2dnM9CqLp2NyF1+A770g2qxWzHqly2D/JfFwX5cgp3W3FuElwPUMDY6HhN0A767hDR5XHseS0OO5sOWaPocrbp1sqsJwm/UM2A/g+Ft7weaKl+pSIM6WQxjXDJThKbv2jf/46giEeWRG1Be+gPqjNb2PQmXyVOERzqWNfQ6rURST76GC71FYIJanS/mFeKCDQOyarNS1nQMLyRROXgYz02/UeMMBTUQTJvjIE9dFbuThx8aj7vRp/4k1AnYTxNOkfPyeuKcWaqlB7LVtaSsJuK7KssfZfMek+WsqfexpkIEumC+EPGb7gVX8KZAsicbl+SZ4/HROl2VfUN7NPgJSEz8NTkiYjRRKm6vyBYtgLrnlc/2ezi9EJIOjNHVDbNx2/ivX3dicys76dpQuL+i9tH8pxFiSH9qDVExQ6vla49O2SLIbqio4KA4mbn5sBSWggNs9MGkp/5g6ktRPYXSAPKFHybNslVqt92HtzRxhBUSfCVEaLi2jITs1l7CePesNYqipymM47fi4ppJ5wytcBUvFlZXKgp5zpnv3uCPt1jNBXeMVovojie0uesJ75FzN9GS9I637+D0PO5zYIvtvJ8yfsn3i6emFG4AKyqoucszt/uz3/yLyTelMSedXL3oM7r1LsoUfbcvawWfv/TZF6ZkhkpJO+7B4IFhcAuN5ASzoAcM9FvGCRYc7NJA7pDMBv4nEGi85Bpwr3YCcOkcpZZG/S0YHb6Iqam+LRSw/tAPSyv2YzcmGOXwI9ooP+CNzZ/GqaR5LKhfylCOX/v7t6qAabBwysln1HgUYB5WB74Pac1c25t6Q+SbBhKuDkTKyXlGQorxTrg2LUR6N6ObNSqkZe2R8Afe9PSqkwVqREEM/H8jaNOzw8Kg/ui2HCHEVRgQWx1uwxFihuJfarDwCwg36jNi1Hti7h6JKTxNHhpWqFddIcm7ly2Dvr+P9GFe6GJMr7Ve0mDl9VMvfzh9VnY0SFsyvCLsHpeFKMnSWXNKMbcm11qWtbeJZ/QPbmV2/rBaUH5y8OHu0kvOtKjYozEPA4P5TtwUYyxAQmzQJPR8qE0gCruaufqROx8wsweSWws/I8fjWv8WjglIPGdR9sil3dJbTPq5+cC5OSUBmOC7F8iO6EK65A3QUT+lvcehLNQDJIrz+uh08hc5VJ0eq75dnRCuNUauRDCijhlAlKmhhvnHZSMb+pW332l X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 32f730ab-07ba-49e7-1d72-08d924410c7d X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 14:33:25.2684 (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: wLiXfCy60gbRX4twWPZjbtku70zeR4CZF0QqI+/85DRXZ6XkaHmxQAtk1YckXPpCOuQBvSCUfNxu7pI6yw1m1TUVPts0yyl+gs5QrYGeS/8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0459 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Mon May 31 14:32:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 450735 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.7 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, URIBL_BLOCKED, 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 ABF92C47080 for ; Mon, 31 May 2021 14:36:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91BF4611CB for ; Mon, 31 May 2021 14:36:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232268AbhEaOi1 (ORCPT ); Mon, 31 May 2021 10:38:27 -0400 Received: from mail-am6eur05on2100.outbound.protection.outlook.com ([40.107.22.100]:22081 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233451AbhEaOgI (ORCPT ); Mon, 31 May 2021 10:36:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S3XMUFUWoTpRSds/aIJ7O0sL1IJrbYT/byRVrVucEgn/BD3beL1wxSWtICSNdATHSlIB/5hJuA9yVbLjqmPxXpRYHL/+iPfi3sqXw/t6d1DopeACkC0fcXxJJf1WRXIjdgQ8pGjMi0ohwybPK3iJsfLkeZ0294rPjLnO8YbzM/vAcCjkhf/V5/XtiV7fONt5FK7dBdQLMGURhXkSTgFKivFz1fDaFpbvcW7ggG1MxMY1+XlLywArdyc0FjoiId/JbzYHE+F1RshL10Tyy3Igi2E1ep79Ou6SfgS5E1YBAckgrQ5CGNXMSuWPdI7gZCDCEdm50GVHu5C7ou+2sVpWUg== 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=uf+b96qSAq813cgKq/ot1vZgZ5KyDl4odPL1rVWocyU=; b=ho/DcpNcFq5iQRtX4RWvd89eLzxXX/53LZxL5192D984KfFe9mOVfJoIAypb3XJLEvP0TBv1jUTkXVGjG/y/bHGZP2oxr3sTVJ7mvHK6tXqVYLrF+uxIACbKlJaltC5QplYxRr5ePHy1XRepLQlvm6awELW+vLv15Cmz703rVCEEQc0N0B9AMHsvc6SGga08ezmMUWpJgvdqwX0tsFV2oZrbJh9SeML/rrFVXHcWrS73Kf5nEnMqhlCpxm/X6Vnr3Gu1tfTBz7crMCZXfXC5d+ORQZStYwK9cH3uscvUQeZa1yz6lpAsQSapWde6/7pykjoZKoweCTyXLlJONiweIA== 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=uf+b96qSAq813cgKq/ot1vZgZ5KyDl4odPL1rVWocyU=; b=pscOY9SMXrkeL4h/7h9S+8/oF0iODQOqzDDgTHvuP3vEs/t3sZMFOaMg9PO/UxMGy27W4f5XZfy/PwbLarl7SRmcnfxDEigXJkZdUrNrmsfm+5fqK8XxVG8WWFSOQCGEt8w52kgfEBnULKaQOxpNzKgUj37SCh6zkbjN3O1mERk= 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 HE1P190MB0459.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:5b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.29; Mon, 31 May 2021 14:33:26 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a%4]) with mapi id 15.20.4173.030; Mon, 31 May 2021 14:33:26 +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: [PATCH net-next v2 2/4] net: marvell: prestera: align flood setting according to latest firmware version Date: Mon, 31 May 2021 17:32:44 +0300 Message-Id: <20210531143246.24202-3-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210531143246.24202-1-vadym.kochan@plvision.eu> References: <20210531143246.24202-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AM0PR04CA0036.eurprd04.prod.outlook.com (2603:10a6:208:122::49) 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 AM0PR04CA0036.eurprd04.prod.outlook.com (2603:10a6:208:122::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.26 via Frontend Transport; Mon, 31 May 2021 14:33:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e164827-9c05-448d-c2f8-08d924410d27 X-MS-TrafficTypeDiagnostic: HE1P190MB0459: 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: Q4C/JQeSZUhmL+m1FG8MEDtEbGgSqD6iQaA2G8aXhTPry3URMnuIhkWNyVaGBKfgA0r9E10aAV5dOQKK0JOe80fDPavztCqYR7ufXl8qvvcsSTbrLveGksCdgVJvlszVG8Uqn5piOi8TVycmPB9h0a+8VNDK11MV7xJtwcHFT38IXnviHTlg5WdWmvGh9v8BKD5fR5+zSSruiAYf9LudVwJ+O0/RWJU3Vt9yNo9zQy6COVnFe8/+5FbcntX0v1ZfqRPIq9X5k2fDHz++RLDaix+yybKFza3+A2S76nb39NSo8CzMQ0IibiYs951q3DRuYfcJKQ7dnWEBlHW6tAwxwA+7TUVGQ1+8Ndj2Mzum9OG7w6FNnnu9ayE0NdKkqcTbHR94w/fS171lL/O+GPkBQwMqmR3bfIjlHFcfMngel6ogZCY+1fURF/JzgYZvqsf6F6+jrfX6aaLHVujknkYCdvHrLL7VNx+H1EAgpg9YnrAbIH2p8tnM7LpiK0MBGFuKJtqRfYQJ1hR/gJF25YkUqu6ev0y/sfM0Qs783aoYWIdPmwRSt736fCgTT5OA6h/9n1kMQCfKILTFlOgPb4DZXH53K3F3VFLK18+ioD5dwwtBAwP5daFBCt9UtUMmmlyeavl1ow/sr99rrjSy0Wn5Vw== 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:(346002)(376002)(396003)(39830400003)(136003)(366004)(16526019)(26005)(5660300002)(6506007)(8676002)(2906002)(6512007)(6486002)(38100700002)(38350700002)(44832011)(316002)(186003)(66476007)(54906003)(110136005)(478600001)(66946007)(86362001)(66556008)(2616005)(6666004)(4326008)(36756003)(83380400001)(1076003)(8936002)(956004)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: x2us+XJGF4mj3+NtQS/KHjZg322+yC+ngKu4y2WNjRt7ocrZmu1/8SYt+a0R44B3Nl83TOsANuJSUVM8Bw6trqBpqgMsT1FP6AW3L1W+ko6Vur9fEUtntOk+D5O8DTiud6CWHOowZo5gSa6+8+p5v7QcZp2kZ/zX4S+uWKnauyzuAu95oHbAddakvwxfNYMjjFgflARdZYLa4JRKeUy2A03nOecuuXtm559VJkwzFRJ3sR2Q1pgzT+IIEVTrPP2sCYc0wmrbHCgNCfAkowKp93rgUblbz+W8QVTJeaQnf2UNKVh9saxQMY7IosagINWo98Lk/E+7CNGWNFaA9PcINe8pVzDjnsQXJ286nEPJ8v/709S71hvc5pzSq4EDeAqDihebFyU6OyCEZP7xtO1Fy9cxT1SSSZUmjNJ8CdUQRopJ7UXmcWFexSFYAtO3EDG318CH4Rh++aNVh4/5ZgJlnk1g68vw8aQ6hB2eJ1JOeF8hO4oOZI+lexOVVEKp3DPqLqcYuodzscXZUoze5MzlPIe0XGCloi3qAfGYozxWod9HBeJ2K7W5vS0onlTvwEoMxtuJ9yZp715cm1lQM4F6k8T/eXdVhCOAMkEOdxM4yK561/FqEWHupYxkLKJ2J0mm30Q9D3LFI+b3Qm1DlMY7v8IifhjM6SqWu98urMYcp4BReK0GR0/7NsD6FJ66RTzTU1wIneivf2K33/YjEWltvXOmVXUiRJ57+sTWRzvEHFiyBhO4a5yzmxxp7goKLQAGhLn7MutbvMGTNLJWyWex9wdPO0psZ0NKQA8TiydHkwyuz1E4s5f0HNzsT6HnryYFWyhSRV9YxAStMvyEjeEBXqbg/DJGjqT9YcBCAAhQKhxD5+2xeSrYU3TYkdWN4ydJhYBuL/SdZLm/eyP2TsZjo/hN33a1fJRfYnL0Q2LpvvPVDha8XjawUsGYoL8l1db1QCOJ2qQWoZ3OiBr89Ze9P3Y2CRriF93QV+KLEpb2eaPhqi5WpXnwvSfLb/4E1P28SxvDJcbA2u75rXIP/RCELUXmAVW19jop2Wn+eHu5KLUjzqZvlkCU/Gigd08yFsU5IXdk6FtY0lQrZEgSpS+xL+LOcXaUzF+Tt2mQjFxEciwg8mk94Z8vpD5zcVQ+NP47Q3thF/VU3AWQiheK2/Qq46nhJYf8tPVpCgwtwaEHvpzzhhbc5yIEHpGXMFAgjYQtlnwfhfglYaocnd502Wp2Rf5/wBXBimMtdK5HGgFFHDF8rXLCaj6CliS86M8u/PccsawLD2YGA+OqmX6bgijgZYGnWmIBHowgfb5oAjeEno1NX4o55vwD1YGBNGFsK4Ov X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 6e164827-9c05-448d-c2f8-08d924410d27 X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 14:33:26.3188 (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: UKcwYr6E7sI0982jH4DdzvA3KIVWgFdmksNHF0yo/duaOPLmErI8aQuNNRpFAHJb9WBUeODSw8IdHFgPMILNPx9bagnZbXNw9ffOdv8njMA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0459 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Mon May 31 14:32:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 451868 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.7 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, URIBL_BLOCKED, 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 6EDA8C47080 for ; Mon, 31 May 2021 14:38:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45BF56103E for ; Mon, 31 May 2021 14:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233727AbhEaOjP (ORCPT ); Mon, 31 May 2021 10:39:15 -0400 Received: from mail-am6eur05on2118.outbound.protection.outlook.com ([40.107.22.118]:17120 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232946AbhEaOgi (ORCPT ); Mon, 31 May 2021 10:36:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1wzkRxfrH0NU4zkesFV20SPaykB6GvZrg6+uyvlbG6w/XNH0qlvatPhIih8cQVyS4hLEo/W6gqP2xN81Nw7ekp7GCQ4mfb3K8QB1w5gzl38mlzZBBZuFgYqvfxDNJhO1+BMmcduyWxpa/iYJeCNVNRf6S4kjT/frgOndYBq7nxxzHZMGO7nlXzTqhnK/FnoojLPrE+OEaQe6EqhtDM66AlY4AVUFHl3JAU+WsOPDV2NJOWJ8uPgWZ3TaPGiHPr5rZ0R/L9ySGINKg3CoVsGkeND990ncYruTh2RHrDgGmpFx+dszpCy+FGZmSin+Vb9WFvhWx0qzOS2a9pZI/Af3Q== 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=E/67bw3QdgrX3UZ3tWSjuRgPVlDTEESo0Rb+ODwCu1D0LN4Zt5KgIFl4iaCVHiDvxxIdocezVJOxui4SWLVliI6Q+R7tPvd5q52Gbc9jxThb9EgYMEbDxc4x0CEIZ1GYYxeG5t4mFcmDqVCciqIfVQO/0QcoCAmrQKg2W8+q+E0hHiWFDK5RRphH1YC5AGP7ZEavqjZR/uusL24/T+Bp5CBA5YuelhxLQnjZRxXkGpCsX/0Z8kQjf9s7NIyRQ5H8bK/jeifD5/zEaWPEP8hmtGOO4sq1TbKzq2ANNXSQu5Xj7BFwxDwh0pluSVKOp7M9Qws6MtZVXo02TqTDoWMUlA== 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=p/JvhLdpObUosgU/EY1Ab8PR3G4Ec/5ZkgKYP9Cz8mMySZYdqPkyiW+BcnPiF7XUKTeFbzbOB5KQA0wwmWVUQ5ILZ/mAHswl19B9h1d90Rf5yTWWRCoXfKFp8dTWuDKGOd2PFaMKdHBQ80ky3vAb3/E5b/i18NvqbeVCMGNQs84= 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 HE1P190MB0459.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:5b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.29; Mon, 31 May 2021 14:33:27 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a%4]) with mapi id 15.20.4173.030; Mon, 31 May 2021 14:33:27 +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: [PATCH net-next v2 3/4] net: marvell: prestera: bump supported firmware version to 3.0 Date: Mon, 31 May 2021 17:32:45 +0300 Message-Id: <20210531143246.24202-4-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210531143246.24202-1-vadym.kochan@plvision.eu> References: <20210531143246.24202-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AM0PR04CA0036.eurprd04.prod.outlook.com (2603:10a6:208:122::49) 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 AM0PR04CA0036.eurprd04.prod.outlook.com (2603:10a6:208:122::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.26 via Frontend Transport; Mon, 31 May 2021 14:33:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4d1713b-c526-401e-fcf7-08d924410dc4 X-MS-TrafficTypeDiagnostic: HE1P190MB0459: 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: wlOi/3iD/CJJIz2gmUmJMmBNZYjcvKQ/aJB+dsM7so6232KjCy5QnxlgeWV3o8xFrcdjKCTwaH7o3Y1rVbCGlxTsff49Y8N/gGdjjPtbOMcj1tdSDqAqdOLC+l9CxXiavhY/e9WYvoKigjtYS91jz6NdSK+ev8im3q9mB4yIJTd8wOfUkI7JNJnJlVUGZnLt3P7yxA0GG0VrgGCb8Zsbj53+nHs4H97xjYXgvtOx0ifWHoqmlU2RAOlrWRYAm4bc9MhEOJIRoVsol+uH3QioWVLLRP110sgHehUy7Vl0Qu47x4hjr4catC+d+dQUu4JEUO44WyPvTA7OSoKh69WbY2UHNT29KgPv+HteHLQ83WbkA+rgKxj9Ip7G5y4yflal+Q0S6NHnw7VFzZOAMAYG8GIMcq/KUMs0LjCB0xV/lAQAdoRg3yhpxk9REg0/sEooB0UKxRVpQfBrirw+yRqXND6A05OA7ePB6Wfiyk2fR8LEV22+ct4fR5Hx0z0nbRamqzCW5s6llDnr1URcOOgxinyS/MC8LJE2dJwutfVlZdk+i9soeIIK16z4X1IQZPNlaKHCvl9im2ITCPFoal7i1T2nvSMhulNcKe1OAXtU5u7djfhjSySUPiCYhAVEXB+2jX/OyjrDpt6VS5OpCpYMzw== 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:(346002)(376002)(396003)(39830400003)(136003)(366004)(16526019)(26005)(5660300002)(6506007)(4744005)(8676002)(2906002)(6512007)(6486002)(38100700002)(38350700002)(44832011)(316002)(186003)(66476007)(54906003)(110136005)(478600001)(66946007)(86362001)(66556008)(2616005)(6666004)(4326008)(36756003)(83380400001)(1076003)(8936002)(956004)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dsx10KngfQaXIDR8aSpt3V1yURAzQS268D1VIurHJ+aTLPbaVbpWwDQDXCNjL5+ZeP9KYxoEMNDKh2IM74ZKEUvB/9ah1Vpv1Ujfacm5gKwFzjRqA4o2CaWlDZUuYkg/4iDgl60ENBuaYlvurqomdYEXCmgyr8b5RR6wjtzSDf4rZ63CQwRLrSRD2xWdqgd+uOYIh6DRrJjIdMmD5uFBZh9CyyC7lTlN2b2rOJCRg2lampJKT8kZk/lxuczjSvnJvofcdNmJInGPFq7S7a+dhJjJZ+FMOT1Ts8ZPfsP/6NcRD9sZDHSAHhZH952iGFXjZnhcukBREeLGxZrtLANv1MbhxxYVljSqsVr4E7Y297apSEEZwFSaSS+aZtKIZdpNofLWfOW1rDe6yOrXPfXC00zuLjroUDycXcKD0GcqhKqat+bzOQTTNVqc4RzHYZn/hn5BZZrpIETsf6bGnx2BfExXw6/x3YuO7A1cDRAp931t+ohDK5ZzYEvewcqOL58Q/e6YIU4tsFUaJ+X3q/PU9CuNF73x2D1UJa5yVaxhKKXJGZaVWajfwE86R3lgjaM+cFOpiDy4dCQImUKybdpEnaYmrnbAitqssAFWG9JZBGltaVFDmtPqvAmVptfSQ7kRw0UnBd2gfPNA40ZOfhQ5OHvfy2kgPQMg657kqST/ZR4su8+pyqF9zqTMZqgWb1/1jui4pAgnTb/oPl/WaZTnQmSiPZXzK7J0cox1PP6Z2Z59olnubqpA2hYJKsiP31DpEYa3EYRqAsOU1T458FIynpSJt15E4/xcu37ox9j975sketWBx+ie00caSJ5bGJ6vYZ8r6Hwy4AtRRm0jqbLQwD6iTJTj9VbOJPdViRl+M2xkqZ5vcfQWsGkkcCbKf0LJ141rZLAMdZvXKGsEIMiCTMCKbztGwOUUJTFx29VW/YMHoAGbFcWo1uSNdhFHqqWI2O55gdylKozGLRPys15x7/uFskMEhbE5cROuOk4MI5tZBKVPApcBzw9z/ZcW+PspcnH1wxN73MsQVQG3i1tQSyt5kg9Ph6DEIP9F3NtqG/+onP0Icl1nsLs/A+pBbgMyuIFrz0ZdKcEEPzUEYgTbrCN+UdDmlauw1e4vS+mz49YNsw/LdsIxb225W0lwPjbfIWM3c98j6joEJA4ScR6AWbzTspTrzb4xfmJcpscW7ST+ywkXo07omPwjPP0rK5dAKVx4yFiLO6F7+KmjGxIzFVH6PfdzI1S9D+klCg7/5OS8/Ksc0DoHz8M7nF2+xJZfsLvpl/SFEV839jw2+EPLAjZPAqZNXjzYnvaDSRIYvm7tiZWJovO+U9kPSNMhPGmb X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: c4d1713b-c526-401e-fcf7-08d924410dc4 X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 14:33:27.4052 (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: iFh30CkcyDXxGJeSd5Q8IZKSwxVDgsHZMk1gJAc2pdM7MT6dSNXmgwOXluxiNFZ/3i5yCEMyBKG5pyugxI5yHgzUtELBgyW95p1ikrCBYQM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0459 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Mon May 31 14:32:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 450734 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.7 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, URIBL_BLOCKED, 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 303CFC47083 for ; Mon, 31 May 2021 14:38:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1049E60FE5 for ; Mon, 31 May 2021 14:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233529AbhEaOkK (ORCPT ); Mon, 31 May 2021 10:40:10 -0400 Received: from mail-am6eur05on2113.outbound.protection.outlook.com ([40.107.22.113]:28577 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233025AbhEaOhT (ORCPT ); Mon, 31 May 2021 10:37:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FvuW0M9NJH9ECmRJde7Oj5uapM48Wbyb/2PP9YdAn3DyVUQQiIZhmZIk1i/g/e/LN3F9RNk0BvyvSTHMZb77F4qh0qrRKHAL/iO74Tc21qsPAM0O8rjEMkAqeU2qkoEEQlHYPtnMiPEeVD2+GGBa5RkTjEw/+/O2FlglTEE4QBK7gFN15op5UouBwc6S/Iv56NZze7WGvv7J3k8yXs7dqcc2iU/e3YrWnfg+qri8Qo0roEBKPSuioXNL+wrQCTq7Wqs1KS+vbfkOg3iW9wPiRw3UxUHBEoxsh14o9u0SdmP8QE1xXt4HYnExiQ5OZtDjM5mJMxkLw8CPwIzDVr7eJg== 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=rCIlyxVXoTX/u+Ehbc83bcxcKnV13yZZB54XutUckOE=; b=nXW5Fg2ywP7TN7FVK0iEjuk98mPXGaD0/Grw273jbD1WBS/P1c2Fwk0uvdcEsr3/z9myzJmqkar1fHFyN17+UoFsxybOLymii6am5nMbG3x9Cg1oOV6i/3vx7zDvCzkir+lo0yYO1DJCtnmSZlhhGtBbglLertwnjJYaOhtn6UOi9Gkp3LAmvTatZ2gsr1tohfXBnUEvOsggHXVhunvNOQnslMWHPvfHsox6f5P5RjkDnLDo/c3ulcTs5cu+o63RmNXOQutiy6ON9lv0hCgUw86n/epGjuUVao4BAr8w8xjqu9XmHuKHtQA5N1orfYSORm3r8EY/Vqxs1hxzk9pVIQ== 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=rCIlyxVXoTX/u+Ehbc83bcxcKnV13yZZB54XutUckOE=; b=uefW+RQtTEF0Wv/0aBUa4C6ea8XyxgbB+nQS2gE+kRvS5l3S1AAyskT73c/Xs95Y7PRUBVWm4vKXDecslMhCb/O4Ws9Dbm4gi2pavl6TyslsHJf6fsbul680N+0/AZVj/1yKpunpT7ZwNwRd515j3sAC3TnsiL4nhWRTjqgf2Lo= 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 HE1P190MB0459.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:5b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.29; Mon, 31 May 2021 14:33:28 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::edb4:ae92:2efe:8c8a%4]) with mapi id 15.20.4173.030; Mon, 31 May 2021 14:33:28 +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: [PATCH net-next v2 4/4] net: marvell: prestera: try to load previous fw version Date: Mon, 31 May 2021 17:32:46 +0300 Message-Id: <20210531143246.24202-5-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210531143246.24202-1-vadym.kochan@plvision.eu> References: <20210531143246.24202-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AM0PR04CA0036.eurprd04.prod.outlook.com (2603:10a6:208:122::49) 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 AM0PR04CA0036.eurprd04.prod.outlook.com (2603:10a6:208:122::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.26 via Frontend Transport; Mon, 31 May 2021 14:33:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40a05c35-0768-43b5-df45-08d924410e6e X-MS-TrafficTypeDiagnostic: HE1P190MB0459: 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: 2n83S/Ib7T3HjIocBseR2q4odKnfKfVyj0hxQXfCK4TY8lSwku8eL8w0Dsc/NZ0aVcmGnpZJRO25oGrBT8dlBOuc/HDAIq0DtKQtJNU4rBDVkpQNUVHdUbv4BwHRwEdyXFZH6MQibXDQu5lRRuydRC3WECr2cNS8fsYZDph/tRWAh0xMFzr9W8HLM7dySQuNJQxb5pQUx7XyiGsLqKtGNzl6w0LEB7izNm7vbUjXk59Op6K7vz1OkVaYd4Lh8xjWCP1ru20D9rw71afrtCU5iyITmTSO3nT0I+LsTVv+lEKwBrmm7IrCMlo0QeAHgp78y4O5VMD08aXo0s31JmqfHoFWR9CIiNhAr+5yJMo/hOL0hI6RchHdLLCSI1kL6Uv6rQhTbMukqKg5Waf8BmkkUhrFOZwGwuE2WVAwYl9c9iQailsFoIs3uBRdrI1L7vQaxQ3LyJmjl2229yfuYPnGqi2V0GZLIY0F1jHNuHDZokBfQD8FqS69DGbhe/+kg/Yy+L+j8J35yu5kGVUjbApaYr3ddmMufsGmsbbCeEFmd79dG4lD84toQdjl/hqj1TUw9BHL2A4AueP7m4hjoHZPSgUVTvFJlQK6lmQUtZ+c+lsXf1TzLRmkE9FcuxV+3Hg7k/ouMhdU06gXsj2ujsTQFA== 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:(346002)(376002)(396003)(39830400003)(136003)(366004)(16526019)(26005)(5660300002)(6506007)(8676002)(2906002)(6512007)(6486002)(38100700002)(38350700002)(44832011)(316002)(186003)(66476007)(54906003)(110136005)(478600001)(66946007)(86362001)(66556008)(2616005)(6666004)(4326008)(36756003)(83380400001)(1076003)(8936002)(956004)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pFCaW++bP5OHBaEEcGWC/CVekvHYW8sasJGFGbjxpMG+bB880EcPlSYrcFx8aXvK0hNC0YjpAFL5Dt5kyZWUru3VBa6CXTNSvs6m2d+0UwRMEq0Rkp2sIuooF5Pwnk8hcDdBiEyo4r7Ef7aUUqzY1nALsXJfJOBxwCDl+jp95JErzgtuwVJZP5LWcmvrivDpBZuo2BtUFhdRTA93D6RTjt4wq7gUZ7xOhDdPBA8htG63TM+/zc01upWTTwNxakp67Zl/w+1YGeVjnTGx++zxKrF1bls3hQG5mcUVioTPWq9BWHBctEChs4nVYY69QbGWQeVxVlFF77GEANWDfGSJrXsyX98cdQLpdC8f2CHobr8u4sZd3YDmwUlzNqML+Q6WasKlh5MbqKQJD2CsCshoAwOaIn2mgLwQhx4Djr26eMMzry81skJ/zywKqihmmSq3vJOdyL7uzzAW8JxEuBV4FREsNPoEKDzM2NDDTg33ihHQKoW067opqwola3OGSzGsUKoqYFOjhm+jBKTBAoqSNd5+cDz7QruKkLWipbTRxCXncPJh+Rvk9uEapF9sHL2rrHl9Bs3HLqnfBOuCuNvh/N3aHYM4nohYB+nrmpA+m53/wAcJ/LqA+BP0+bhUDgOzoozmQY08XHGCQzYoQ2loArurxfJAZvz+dF0UofQouK6jNi9xi4aCJlFRaApqvko9inyFhL3sL+KQpy8ZhQUaDksxuJEH3dBlNXW5ixEyGmB5KruCwMTnOEP75Ks3nBA+CTZfeQ84RR00QUTMNUbu7x5WkJY+gEgLrbzH9HdXzNl5JhQWTMw6XaC2+N3JLzuIeNnw+nT3FBsW31J35sU/LKFC2+t3fW3OEzDvbWQTVM2zYdYc4ssegDpCV67+CC5wxeOkxotTHrCxuta7Oy4DUbfQe4jIv8nJ5HIXgXg9kZ0P1PI+dRu4Nto7LKYl/RP5HeaEV2bbO9mXGosEQeJes9f4URrp64qOlvIK2P+YcncHtcIpswATlnGyQfx+H/VFHvcuZzFrSEXsYlgejjXsNvGDicyIg3Br8MC9A2lVh/zVgcKSMyYC5FUMfAz9JXpp/1mGJygo1kTeikLp7ETohgt4ul6MV6hxOV6ovGDlvdcZLDjYaxvI2CuQ6R2JsvkMMb+WaWvep3qwwAl4xAUzFPJjI4JxOQwBBlQiNDmLEVNKCTjCiPXkpPCygG4rrDJB0CQEH+LHLl0NjA8LJis2LRogmLMigUK0TTxydOyTi0Ym5xmky2psAkmYexqQtEpB+348gTjLyZy54SAaCcUxiwoBRHQYQokLWk2X5+L0GsEWppgYLhdoDCQu8dGTphuO X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 40a05c35-0768-43b5-df45-08d924410e6e X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 14:33:28.5186 (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: /ESRc4HDSrDz8f2BfkEbF5j3PZGvOJblCpKAjlUosmzXQqSEi7kMtK/DDjNYjDsvTyB1t6j8VbrsnDsHlOY+GXA/gPhwVl4h1Nsc/rv7oUE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0459 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Reviewed-by: Andrew Lunn --- Notes: RFC v2: 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; }