From patchwork Mon Aug 2 14:08: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: 12414069 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.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 532CCC4338F for ; Mon, 2 Aug 2021 14:14:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3618760555 for ; Mon, 2 Aug 2021 14:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236710AbhHBON3 (ORCPT ); Mon, 2 Aug 2021 10:13:29 -0400 Received: from mail-am6eur05on2133.outbound.protection.outlook.com ([40.107.22.133]:56059 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237755AbhHBOKT (ORCPT ); Mon, 2 Aug 2021 10:10:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GtHe2xsIjgMbGS4W98BqsKfa8dsvXm8ogXU4j1nPDJ+y8fUq2zhIHHDlTgzeDxKnWh4REzI+OLEXdEoP0mSMn4WMyjMQCQPpD5bME7PqIJ1FxBKMHEucRXT1fKcyOrXbAH2zdTNu1IDYYKTyvMcFAS7tbY88ekKtvMi4/ypCQz8FosL2FvaYKC4fGanTzKquUHDUQM/UR2B1oEFObciwcD38GeVQymCdeSQ1MQtLV5yEod0DjPSbrQXaWcfD865MAlmEqi8Qt5q4f/ncBS9KbM/8J/mUYCB542IhMjLNvpPO/e3Whd89er9P08gSJnT39j0IloPufnM+RWHOP95Vfg== 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=LxSjiu8IfMhD2mbGIqePBMiVmiMtjHrQJ4FJ1AwMn1k=; b=fDzVFjkOxC3bzUxSEdZG2k8M2HPmVqswSbFiqPyALs2Anq5KZW+NngxQSIvHKboyuqEjvooULBwxco/ddwHpAWd4zDxpULId80iIOB0g6RFNbKRqI0HfTLr5aFhJo2+BO70YjBBww0TRQ8TZyVXC48A6Ktx5QL4HxeV7dhigxh/s1Rqw+vr1zUpUfTXT0qyWbV0qFrAusqTjo8YjDk5FETFzd9pkMnnCK2hvTIUfPpzpr2NesQQZgrKc3Zd6nfa1l+BRjq5TpeRDZvuZkdx5zItgYiCdRo5sXMNj3p3DJcYhKwjYbunBSXWW8n8Qqss+79IHiYzbOSPehyD4B2F8Qw== 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=LxSjiu8IfMhD2mbGIqePBMiVmiMtjHrQJ4FJ1AwMn1k=; b=eRdHMNj2YeY76X7kOwnYCyMFdx2ORZpUoN1UauBwJy+6DVNePw7MDodz0Fk54iIjrbokubouo7P2jPq0bysBVK4G0EZR29U+A7PhSEFN2KtuYpmDiQxMka0GEc04BsiOh9hhA02kSwVhQt4sXzTdCTJx9Panr5ZPMAKoIhQmBBc= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) by AM5P190MB0306.EURP190.PROD.OUTLOOK.COM (2603:10a6:206:20::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Mon, 2 Aug 2021 14:09:23 +0000 Received: from AS8P190MB1063.EURP190.PROD.OUTLOOK.COM ([fe80::380c:126f:278d:b230]) by AS8P190MB1063.EURP190.PROD.OUTLOOK.COM ([fe80::380c:126f:278d:b230%9]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 14:09:23 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , Jamal Hadi Salim , Cong Wang , Andrew Lunn , Vladimir Oltean , Serhiy Boiko , Volodymyr Mytnyk , Taras Chornyi Cc: Vadym Kochan , Taras Chornyi , Mickey Rachamim , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vadym Kochan Subject: [PATCH net-next v2 1/4] net: marvell: prestera: do not fail if FW reply is bigger Date: Mon, 2 Aug 2021 17:08:46 +0300 Message-Id: <20210802140849.2050-2-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210802140849.2050-1-vadym.kochan@plvision.eu> References: <20210802140849.2050-1-vadym.kochan@plvision.eu> X-ClientProxiedBy: AM6P193CA0066.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::43) To AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AM6P193CA0066.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Mon, 2 Aug 2021 14:09:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c28be3c0-9593-4519-0a47-08d955bf2138 X-MS-TrafficTypeDiagnostic: AM5P190MB0306: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +4kiN8dCHMMN5i/AMszGuq+qTHiMGALXoGgj6Opm233S47r87wWBrCEdf1J6R4nVXgQx1r6UXJ2ye8JELxZ6gPORI9Zk7NV3VwSVWk4YbqQnrgJ+S8zsUxGGtRAMzl3x+D10QwrxPtARwulznRFW2mJh45f4V9vPOaIowWBo8QxlN3irqhnhi7V98dfV3eNljtPqHIwf02hVnRPJzdrTpB22pKZIzEpFwgFzvI9Kg3m8hRTEbz00phn4wO64wWb1c/XyVaMsiE/qKHdXe6UkYq/K+EKgG6F5u3zC6ESdtSq+y/NM2IWXorZElp+aXyY/FN3fD2P++xJ8NYHsSwwGu3n3M3IfGB5ujkP0kRLXZPYhDksbDYbMBEiCjXZgNHi9epfRXIltfaa1OMiytkvCzn4esEgRVshP2gMJwKCjXxxU5vdIJ9vG7Ue4Bnz1tBF2GXdqaFb4gf7QtKEwjTVM6Hbv7qqEeFP+QPtyk72Nn8cXkDX9FKLj97zSUTBowqAfwQYQr6RAEDlHtPyt8dIO4xOBZ3w39M9qfzehuJ75rPUiuXk81WTQAoJu6DW/gameQiYTQTi7LJ0lIP0FbYHPuurVWbsyA/7OMST7mRJAFedMy9bG1/vpsSFyQ36AHNb6TZXyEXroTBCgP/6TXecxPE2DGHTMWq+J22WsP2dbx9BAhuJv3iJlHClND4of2eQadrXMFGHQBZOFcUPQEsCW3+RVAxHtG6S6hWa8rqdxaTg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8P190MB1063.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(366004)(346002)(396003)(376002)(39830400003)(136003)(4326008)(44832011)(2616005)(478600001)(8936002)(956004)(186003)(6486002)(5660300002)(86362001)(66476007)(8676002)(6636002)(66556008)(52116002)(66946007)(1076003)(2906002)(36756003)(6512007)(6506007)(7416002)(83380400001)(26005)(110136005)(54906003)(38350700002)(316002)(38100700002)(6666004)(135533001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p7jbaTM93DjDXrFPfigqMOo0INOd1uQ0wAkcCh6DexnkrOCxFnjzvsBALfE+4CmuCEfVZilUjlmBdp86+YeKqLllWLBbatc4PVD+vi5doIb9xyf3H2kTFQKxYFyTiwgZynuYsF7tWixSWXTluyiNodPMVWqUm3EsjRBK+CWbFFumkuXQQy+V7UFxZH3r5+8nJZ4nIjXuzdlSXUozhPnv1uZE95BnkJpZzKeDwqmYYGbfFEFLqriwLjlt4CFKCXWWapZTd+GgI/HylxOWUgGOsG39T0sGscHVagMAlVbd4Xmcges9xvlZXlMUUvyQvo9GQrq7MKAkru0xEAKTIeL8upoJvaGTCZ38hAjAhFDGUXXlpLcoe4BeKxrCjPURaphm/6JBYbxlnmrI2PWBUA8wkauScUlBtxcEJ6/pX2oJNTsTD88oYdVjK0j6ONrWLhWtyl4NctsShQ2NKn1Qyd9pzNTKOfAAHePUpvLL4fxsJywSbNWP4EEHgjmE5tC79XQcX3rxWz/1tYgKXIhjyhRuhC8Tr6XO7XhtEWecRPEPPmT4VFPNoG9Z2yWHBMraV9Ot+eUxGsrhqZrLM01HvehYlr1Ln9TD+00/8Fq8OWTHvO8O10q1rEIo1KwRTJsSdRyxCGXCl6rVbtUjOTq7uWyNJkdGIEGFRUb5FVPfD0Iii0r6Vqiy+f7w/WeYITODTSiCzJgLNRPynsgms1x2LNdLRXVpuG+KVffmp7Jk4YiqnFRuTUJ3gdI6RGxE3qRovXcP+qAi9H4WkulTN00dW7cj0d0yuGKiToht1tAN2yUU2cGyAVbnzGXkZKtFMX3NG/dXAxdWj0BV4QVD4MyyVeauy7v3Z1B+M34B3Pl+MdjjiJqLa1q16NHI5IilC38e4w2QJFEPfVPb2jjZ591r9tNxXPh/aM7wvoegzuu0XUXct8sZeWywCHjHQ4wXGu+/vmck6JJcUdB2R4gfoYJkiNzhwTPLLaoq1QHNAhtSbtf08Wum+2sg3USJn7Gzr2Kp1XhTxP26Aaly9GjVhn1uSH+J+hXQVAyJdameHp7fmsVeUe0vvxLvPFEIIkJDFXT9Q9k6jbr71UnIg8/6PrvtmoimKDmIwP4ASePQX6hf48K84zvhp+emv2Bo6YpBGSKrcC6EiB1/74AA1RL4EUUkH4Nj7Ly5tWzle4v//vu3eGTZ0kYhX8rxtvD7ggPTS9cgyhhy3fP00AG1PFgPZk6+KC0Q3FuqNRgWqZN6Zu5SirUaFUxzcUdLFJNLdfqiWD5/l7HMbXlRr+431yxyQPSA3tLW+TsopPM97Mrt1Tz6OnjXs4sVZuFswPkmJbkqYilglPIV X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: c28be3c0-9593-4519-0a47-08d955bf2138 X-MS-Exchange-CrossTenant-AuthSource: AS8P190MB1063.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 14:09:23.5206 (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: K8DzNGhi5T3szAsI0MfLWAZoCiP77lIKbajpXWKmgjKKOit47QxaiBC7g4DPP95ukq+/8iaJ++/UlDaW/qwbuxTX1h6wzXeET1Z8l+Yr8Fo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5P190MB0306 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadym Kochan There might be a case when driver talks to the newer FW version which has extended message packets with extra fields, in that case lets just copy minimum what we need/can. Signed-off-by: Vadym Kochan --- drivers/net/ethernet/marvell/prestera/prestera_pci.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index a250d394da38..58642b540322 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c @@ -359,12 +359,7 @@ static int prestera_fw_cmd_send(struct prestera_fw *fw, } ret_size = prestera_fw_read(fw, PRESTERA_CMD_RCV_LEN_REG); - if (ret_size > out_size) { - dev_err(fw->dev.dev, "ret_size (%u) > out_len(%zu)\n", - ret_size, out_size); - err = -EMSGSIZE; - goto cmd_exit; - } + ret_size = min_t(u32, ret_size, out_size); memcpy_fromio(out_msg, fw->cmd_mbox + in_size, ret_size); From patchwork Mon Aug 2 14:08:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12414071 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.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 BC6D5C432BE for ; Mon, 2 Aug 2021 14:14:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E4FE60F41 for ; Mon, 2 Aug 2021 14:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236748AbhHBONb (ORCPT ); Mon, 2 Aug 2021 10:13:31 -0400 Received: from mail-vi1eur05on2115.outbound.protection.outlook.com ([40.107.21.115]:18525 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238094AbhHBOKm (ORCPT ); Mon, 2 Aug 2021 10:10:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C+6yOEStGZ1tm2DFonjq1eFWsuV+RvbavT2BEqpkcn9z1pl6jka0AKS4aEemZGT3ZLjiozAlXh+rfsPcea43wfmi3NrqR/3VIZIuU0PmZc76Dm/cztV+zJtin+csyuH6O81TIHrJ8dqB79bM7PpBGQbkgL/Gx9RVCGzjgo3Aa69lGna+/ANQKPMPv6hOAQVJDJj5k7NHa3qyCsWZsmfFHuX1aXqrbLo+6RHAOICl+7cOcibb/ba8rg80oR5U48Yy3yo85KQEoTGw4hnQ/QoRpYV5hSkc1RbO+9vTlAn7q/KuQ5AkVJO0JXwwIuiXnSZNnicH7H6CTKsFo6zJHeVFQw== 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=RhIQKg3e+sAjl5xUMnlo6aA0gTaTnuJ/iSkCqIi//OM=; b=Z1nx+QXeFAbotll9ur+ijWMDlk3Ok20LUbPSd2B01u7DijfsrWG8ffQfykyOMqvMPdYQLJcxgtX+01XiHMmn+0jWL6tE9KUdoDklO7NR5Bsvr1x+ReTeo01x1hKZGYlXudsZouJF7MxieToBCBQrwb8OukCnPm5mjumnxOq6Kk1a+36OjEuUA9HNj6byLXnEuWfR+IK3Z0469nwJi2tZfTDc99dPcyDscRnX4U2OzLjyjY+ivu0JmJuF6TQUnG1OkrJSnq4bQ7F5Q5+V8sPEEge6LMu3cGYyCi9mZ42c0SZ4y690QCWXvm1VyvXUIXgb7Ikzk1LiegFnNc42efWnFA== 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=RhIQKg3e+sAjl5xUMnlo6aA0gTaTnuJ/iSkCqIi//OM=; b=TZ0jEDw2KZscInWbU1qZobUCRvq80ZVOxrU76cjUYXYAdYmtNT44hk4sgsrhsi4+Hq4mfqj3WDbtUmh2ia7GFMjbtGQZnvYDUVW+Fy+b0liMMZuzY/wpfz5WDPSnu2K2BuvuW9lwV2BgMtOuOxejM4E/hM6HLOyaVVPKjPRj/oI= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) by AM5P190MB0306.EURP190.PROD.OUTLOOK.COM (2603:10a6:206:20::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Mon, 2 Aug 2021 14:09:24 +0000 Received: from AS8P190MB1063.EURP190.PROD.OUTLOOK.COM ([fe80::380c:126f:278d:b230]) by AS8P190MB1063.EURP190.PROD.OUTLOOK.COM ([fe80::380c:126f:278d:b230%9]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 14:09:24 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , Jamal Hadi Salim , Cong Wang , Andrew Lunn , Vladimir Oltean , Serhiy Boiko , Volodymyr Mytnyk , Taras Chornyi Cc: Vadym Kochan , Taras Chornyi , Mickey Rachamim , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vadym Kochan Subject: [PATCH net-next v2 2/4] net: marvell: prestera: turn FW supported versions into an array Date: Mon, 2 Aug 2021 17:08:47 +0300 Message-Id: <20210802140849.2050-3-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210802140849.2050-1-vadym.kochan@plvision.eu> References: <20210802140849.2050-1-vadym.kochan@plvision.eu> X-ClientProxiedBy: AM6P193CA0066.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::43) To AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AM6P193CA0066.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Mon, 2 Aug 2021 14:09:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9993f42b-7cb2-4fa8-be1a-08d955bf21b6 X-MS-TrafficTypeDiagnostic: AM5P190MB0306: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:346; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aSlNoeQdPXY103+O4Ha3tG7M0Gpip0L+Rr4h/Ky5b27yIhBK+7RylMP8f6ono2FrJhOje3Ut24DAgYhMcJ5MOks2alKTBG4LDmHLxtj/njJLIpJqT/PxGcS4R1fyw0lUeaNBTBbq/MbelSnvE06+LKYQ/uw8/oYCOaxm6GipCRLw6mN0aqowUIYx3ZyaUk36T2CgpxHLlPDU2kwS4I0VnVFjlOiIANgMW9BODZSgJew6YAhU4KLWKx9FsDkms65J9iQQFXKot66qhOSBq7P+mxB1vVJynV8cAiWCBGU6j/vJk15Jjzq0tCpnGKQqp+z239WDmidS2k7KUIlTAnuF3thFeSV5xOzI8TPF8Lu1y6Cwb1F0v4QWUdG+0vpDIOpXlOP02KOuyrlH0YVj6x9s7AwvpnN0YzZtbQuRtELLDaYV7EPrWoiPn7mGW9hXGSOGZSPKUr0oo//5/oMnJgLW2MosjMHcqmLXoo2yfbhVbhYhtiTvgz5XUf49c8RNOdtUIkHnNnNuFQUpTddRLzBqxEdIt6xhmUvXa63G2Eq2g4mC0Z5iG+gGzSzm2OMyWkImLq6/X/YDM0RIzy2kxFRs/3y+n4hfN+SPJo5uu4GW6mtu2xDqY1bkAuJDZOLXlRc0YWiMIPjGksPbWzSumbwtVNo/aFIno+RDJB34HvClvrOixjAoEjlxAuAjaArCX3x2YQGD3KA9aIeGOTHKQpCVeQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8P190MB1063.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(366004)(346002)(396003)(376002)(39830400003)(136003)(4326008)(44832011)(2616005)(478600001)(8936002)(956004)(186003)(6486002)(5660300002)(86362001)(66476007)(8676002)(6636002)(66556008)(52116002)(66946007)(1076003)(2906002)(36756003)(6512007)(6506007)(7416002)(83380400001)(26005)(110136005)(54906003)(38350700002)(316002)(38100700002)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dwe3V++7uCN2B/Odxq7jzbf+GZpAGRZcvmmbAWZDD6eOnJ2h2h07gdOM7Qzhon0PAoleE/A5q3azQiak1QKkO9dTX3+DBhiaa2sGlErCJS8UmlhAmrxz9V9Xo+0fPlj5gynsT9uuNfusECXg/QIOU4kj3fqvL+vFtJXfnu4Im/5XzuzFWuyHiEneVuCHhpW8/ciP5ZLA/N7p7JBixFdFdHUsSenQb00LnyQfGl//IppySqY4/69Ua1MJA5UQx3XYGF0NVNWSUdsuDGjj/mrUUVqQIe/K4LwdJ0SsESZFYwCF6Z8CWpT5+ov+iMu0tvwu5dz65py7PT4eXNsRDe4t7rGHpoYU9W0he/dEOh+EFGX5StvWzzWUrX/owdb2yKzo2iI9ezQSIynC8WU6vKNakYs6cMRc3urlK+BZxAUBYhUgqfMTYizaDXQEMhxnbn3mWuDuZEKe0gGxmybA/J3/PBjKQ5V9FciU4Ebs8nVxPhnTutKJMu1Vm2Pb4s4GT2oOAOxracoHrJ3yuYz8Ku4z5YjQnWvmggKc9sCNWaXDUp2RPY3ng/7j7hyRzIeDzqpfVIp94M3Zv0jVE+y6wEPOcn1vGXG/EYDF2Ywq69UlHj1psdmbLpTE7u2dqGcnLm8DCv8qslNYVFLPc5xSVNnDhAdHbcD8AjltlNPeMRDftklZYm2wvZwyvqHL7NHDn9UmUkhO00JWk2WdFFNYfw+9Am6Qj4xGjX1zrTZm9meT2/vV0A6bJG8syqE0nYmxL3QWJRgWmIcwPEzXrN7ZFFbIZImrmWXXcLj6rs6swiJzeGSa8+0idN3CutPTHBOGPnM9OW+mM9I4fcIzBP8S8K+p1P5YGmFv0tFqwxhEnFGjeSyuEtqZs16b9X6pEXw8jKTg2yGGtIEgE3A6KrqW4QnbEoFs2zWVaD4HrBWV+y9rnvsilj+pW45oP3dIWBbZacztQw50bKC82UXxxF132HHTzWApXX1NKPLDZ+knwPhsQ7fsKehQFWd+wix16A4XBVN14gDUCfEvaoAcd7IQbbD9aka/7bwjAcfxQU9DbLCMMaHvHP0G3Ofx6834XD9UcCTP0T+7mPmjpshtOmIG6lNbKuVoWit0YBWXh5/3CUrav0nj/Jq879UQxdGaNOZ7EIG0Iyim4yjNWzOeXcIURBMqAxrwtt+42x/SPOyMrvfQlSaZsPkfa0tEa7wZ4iw/dAoEg87ZwyaqzmPC/2kOBlLHdF/iWCKQKQ/8ApLlxac23C8peWnJZ5Upun1Irr72X8O6pxqMV1CWi5z1eBR6mbtqkHCPGpO8UPutnXtOdGxFsgKD0WhxWyw2XacOqCa4loXD X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 9993f42b-7cb2-4fa8-be1a-08d955bf21b6 X-MS-Exchange-CrossTenant-AuthSource: AS8P190MB1063.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 14:09:24.3539 (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: 0vs9ExKQd+I958RsGbS4p+0r4bWBgJmF/p7QyQVBiT9oWoPvpvtTT3/vM/2ziSkgxtn2zXPRkushYzq2482twR/YMttkdSncIBD+X4KqyMY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5P190MB0306 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadym Kochan In case of supporting more than 2 FW versions it is more flexible to have them defined as array. Signed-off-by: Vadym Kochan --- .../ethernet/marvell/prestera/prestera_pci.c | 55 ++++++++----------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index 58642b540322..ce4cf51dba5a 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c @@ -14,11 +14,10 @@ #define PRESTERA_MSG_MAX_SIZE 1500 -#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 +static struct prestera_fw_rev prestera_fw_supp[] = { + { 3, 0 }, + { 2, 0 } +}; #define PRESTERA_FW_PATH_FMT "mrvl/prestera/mvsw_prestera_fw-v%u.%u.img" @@ -629,40 +628,34 @@ static int prestera_fw_hdr_parse(struct prestera_fw *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; + int i; -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; + for (i = 0; i < ARRAY_SIZE(prestera_fw_supp); i++) { + struct prestera_fw_rev *ver = &prestera_fw_supp[i]; - dev_warn(fw->dev.dev, - "missing latest %s firmware, fall-back to previous %u.%u version\n", - fw_path, ver_maj, ver_min); + snprintf(fw_path, sizeof(fw_path), PRESTERA_FW_PATH_FMT, + 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; + err = request_firmware_direct(&fw->bin, fw_path, fw->dev.dev); + if (!err) { + dev_info(fw->dev.dev, "Loading %s ...", fw_path); + fw->rev_supp = *ver; + return 0; } - } - - 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; + if (i == 0) + dev_warn(fw->dev.dev, + "missing latest %s firmware, fall-back to previous version\n", + fw_path); + else + dev_warn(fw->dev.dev, "failed to request previous firmware: %s\n", + fw_path); + } - return 0; + dev_err(fw->dev.dev, "could not find any of the supported firmware versions\n"); + return -ENOENT; } static void prestera_fw_put(struct prestera_fw *fw) From patchwork Mon Aug 2 14:08:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12414065 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.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 99C3CC4320A for ; Mon, 2 Aug 2021 14:13:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CA5761106 for ; Mon, 2 Aug 2021 14:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236785AbhHBONe (ORCPT ); Mon, 2 Aug 2021 10:13:34 -0400 Received: from mail-am6eur05on2093.outbound.protection.outlook.com ([40.107.22.93]:24320 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238230AbhHBOLH (ORCPT ); Mon, 2 Aug 2021 10:11:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jwlkSzQ+ZYz8Mpsges6/WIpinVFSLiPy+IA/jU2ts2qb5qw/WlYRoI2tP21AwZ4bpik0Eqs2v7MpMfAImjLr+l01QNBUxgITKpLSGOePDmK9m6S0DW6y/YN/NnfdWsMkEoOtDNLZkD5BJaEvk3XxrS1cpaHJLSOzVHNWpB2w7n8OXleSuHu83hLMg29NdabwYFQOjZgzMv5iU+UqvNqqmmPTTUQ2DN63ZOIs3bXD+Oufhk5keWMU+4ZHedtRyuP8n+Q7otHUevh/nutEGF6T0r0X1eWIhEQQROyMkNMAuGEyvMs6GOEiLyT8dDpYtEw2nUtlhW9BcbAWMaRT41zhyQ== 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=0SJ3yoNsdCIPNrr6rZDTIOM3bKzoM2LejY+DM/1guLQ=; b=RLh1fMdX6ljS/1rSuQrmbjLJaKOclx6gZTQf653rIlh5WrfQMns95H95PlDEI46/N9nOCOXv5Nev23WwOKvhlLC9fqF0JcDriidXVjFBZWKSvIAVepU9AF6eBwD4X/oHN/jrFOWQioGbVeAdajjJ8GWnN1U3ScWKc82bKw812yUFAEiL+C84HVFSb3wEDmTjMwK0yG3raaA+CZCrw57wohiihIWIgPvmRsmnZFgjLGpGowZfcIKeQNGmh2VtmCwKfy5M1GxObt12AW1nwRMPgxo40cJxfYBJCpf0QBE4C+t2YNDLTvUb6aVjBN2b39Y6YspZ4CbbjI8FjKi3r3VVfA== 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=0SJ3yoNsdCIPNrr6rZDTIOM3bKzoM2LejY+DM/1guLQ=; b=vJQ5Rqui1snsNIzOjnvEer4TO9BBSfNwTxjlP8Krd7y0iL9AWr3InG1WLIEDxh6HJkxsC+fDlI0QmSAGqdvEYuxyT6qzTdrUL3BdfjS78jxLF5YbagJQlGDAsazECLzrVtrohncHiAwyiq1c8lWEiFIrpijisgRhi88weuidajk= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) by AM5P190MB0306.EURP190.PROD.OUTLOOK.COM (2603:10a6:206:20::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Mon, 2 Aug 2021 14:09:25 +0000 Received: from AS8P190MB1063.EURP190.PROD.OUTLOOK.COM ([fe80::380c:126f:278d:b230]) by AS8P190MB1063.EURP190.PROD.OUTLOOK.COM ([fe80::380c:126f:278d:b230%9]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 14:09:25 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , Jamal Hadi Salim , Cong Wang , Andrew Lunn , Vladimir Oltean , Serhiy Boiko , Volodymyr Mytnyk , Taras Chornyi Cc: Vadym Kochan , Taras Chornyi , Mickey Rachamim , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vadym Kochan Subject: [PATCH net-next v2 3/4] net: sched: introduce __tc_classid_to_hwtc() helper Date: Mon, 2 Aug 2021 17:08:48 +0300 Message-Id: <20210802140849.2050-4-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210802140849.2050-1-vadym.kochan@plvision.eu> References: <20210802140849.2050-1-vadym.kochan@plvision.eu> X-ClientProxiedBy: AM6P193CA0066.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::43) To AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AM6P193CA0066.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Mon, 2 Aug 2021 14:09:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 57d62989-2202-46f0-afe5-08d955bf2240 X-MS-TrafficTypeDiagnostic: AM5P190MB0306: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OuUa0HfAMoYCRroFiRbe+Lv6YhaPTMU6A1MJXaC2k5TJXE0urqzosmkSyoqnoI8m/Rl2zdZc5COWsvUE/lvKwvJ5spnUODLo96070JIb97H7ezLnnGxs1aV6gCV4+vZAO79bUbu2P3rxYIcHPz4XtWWNHNOwaS8/a2OdJe1d8ZJa6l7GnTwOQ/zgy6Z/xK0FfOcCa/mCsQdZ/1msK79JQwxnsBYINroXoWPeIBQGNxSexeuul8VjcS5o3SI20o87aMYwmmnqqIyWqwqBJeHPDDt/o1GJxTp+gDMU77y9AcGn6USMJ7D/k/qM0Ds11SsYEe/NZq3IGw3FUbEkZsQTbgq4s3FzAY5TdP/eSD36QozXkDHOTrhwC/ul6ndwitShqqknAIFUaYcCUWHGuffjzjJnL/irZ35BnlCI14GbRBw8k/vivGQK9LZyofEWzeJVFvRrVr+kKiZpZQoI5CzwLuX2hkGkw9NURAEnsmbcdv7ds4eFNKDCJe4aXNLt7NilpwPOasprmdxmCkUAkLEj+9WB356HWx/rZP/t2+m0GwWiNBNdnjv4+2+Id9wDik2N3fjy6E03Z2eadBKGsf9YRZJqUCEN5ee3VnKAgX30tpUk2oWO4wAcm8NpBrJLm2akwnkunXjHbMua5OB479eXhs1ybuBeM29iqq9dSENNjdiSOABiLDO8CC3zA7/S9LEK6TOkrniHmKs6EZol7GDGuQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8P190MB1063.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(366004)(346002)(396003)(376002)(39830400003)(136003)(4326008)(44832011)(2616005)(478600001)(8936002)(956004)(186003)(6486002)(5660300002)(86362001)(66476007)(8676002)(6636002)(66556008)(52116002)(66946007)(1076003)(2906002)(36756003)(6512007)(6506007)(7416002)(83380400001)(26005)(110136005)(54906003)(38350700002)(316002)(38100700002)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E8JjEthoZBs5umgH9+T+9wct9LQyE4uaZSzyR7mmJ56Xukuk7bZBR09yj9Il3fEAtAuPUQqhmppriHVK/qoNLZDqRxJsryrjYcHCjWUBDjH4p2f2FAgexC6c6H4P8G7UgdTKK0aUWbNfYwHIZGjlzp1OpDQ4ErNNzvjbIvPs/QWjcFAPFt5K3kZr/awcp1PUPIZsm8dxK4u3VWCohjQ+3OptJhJTrXd+KXx79xvHXxKH4A79ds1F+SuhCHChPY4WxKGNhwY+7fy1TjI6rOB88Z1RicR2wKCLVPQHOcl/zD0YN0K8Tomxw3iolJBNQtzQ/3woXcHPQ4dSEkmYbArptprWi9sZZo8ygCtMgeVoJosjzxESpVfkUCarGalEB5PIoDZP0++mkgulcvgtAt2q5ixGgmxFwDYrkTXgz/ZkLAPyQtCuwV6vA19Hf7CKlpdApnyKe01rhazGjfHkHfECN7PFn+dHDg8/exc1Qkx/7dvP0mxLchfEc6QonZKXnkeky5T5jDGd663PW5PR2lED0oJISoukY8I8gpJ9Pvksy6uRIoyRZtGbQboj0OBs0wwMNU733KfPHfEJb0lCMfR6DqXYHTpNKf1ZLNM8OvEuRiqAbxArQA9wePZaqP4kl8neEKKNHwdWdqjfgUg4bXzwIq75zam+q4GQXXbQN+AxpQ3YArLuChSpQEf//Cclzd1wQA7G/PIUyGvWBKgKXqoyxFn/qkPm7KE2n4/XA6Ik1zz14dHCAw9RZDcj2S0PJvKaHerCPaFoRJI62gha1KtC2sdvypAku/dvgqpA3yw3s2IzxWti4LswIMl9qd3wdthxJpvD/ZGSIjvOw9YCqClLR/1QkZv26ZpGXTf1BriKCsaT7si3N1orKbbs/DzxBot7oe4tzbuMf3zf+AyL3eX08PWyTpQoHKUK2j39v1bwkj1XqBiHsXFD2vCMZhFLAx0lUJMQHgS/iZIIaSw09XFMVqFMqQp1fwh96RzxMB9IJcdPKAE66X4FEk1M8gf87CIRYuI98YZRcachLUfXXnKfMl7dhFTV38Hvbkg4G0y0aJMrEL3GlBOzUA8Af+BNr7dD/KSV+ZomlLloBk8sVn+UzxAAH+n/LyTPecW2XrHd/LlOlmUHy6Nu3IKnKL4nPywKfdPglBpXdi3ZleOlzeMTCBYA+C1hqx3WYyEhM1Kg1WDdfUp9XXM7Py9vE9DcLyU3yQUHZI5BbXMXBNX6vfj7UMqwAXNOsweBbGJFEv0e9n0UozsmJ8jT9h1iW/JAiyUqWsX3PZrfKxLl76MX6oyUjm3+FrjrA9HHSiKw3iK88Tp+bK3CLzlo+LV1jCnY69yp X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 57d62989-2202-46f0-afe5-08d955bf2240 X-MS-Exchange-CrossTenant-AuthSource: AS8P190MB1063.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 14:09:25.2788 (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: NvsCmn3ULBCyfZto27fHJiVoOuWNzBjeiAZejdBdr0KMVE1wRXf06jdetGfGfVfHrgST7u/y5keBKExsLQzxBucO2q7waVd4pGp8Av1Vku8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5P190MB0306 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadym Kochan There might be a case when the ingress HW queues are globally shared in ASIC and are not per port (netdev). So add a __tc_classid_to_hwtc() version which accepts number of tc instead of netdev. Signed-off-by: Vadym Kochan --- include/net/sch_generic.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index c0069ac00e62..df04f4035a4b 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -668,11 +668,16 @@ qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id) return NULL; } -static inline int tc_classid_to_hwtc(struct net_device *dev, u32 classid) +static inline int __tc_classid_to_hwtc(u32 tc_num, u32 classid) { u32 hwtc = TC_H_MIN(classid) - TC_H_MIN_PRIORITY; - return (hwtc < netdev_get_num_tc(dev)) ? hwtc : -EINVAL; + return (hwtc < tc_num) ? hwtc : -EINVAL; +} + +static inline int tc_classid_to_hwtc(struct net_device *dev, u32 classid) +{ + return __tc_classid_to_hwtc(netdev_get_num_tc(dev), classid); } int qdisc_class_hash_init(struct Qdisc_class_hash *); From patchwork Mon Aug 2 14:08:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12414067 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.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 68F39C4320E for ; Mon, 2 Aug 2021 14:13:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5326D60F36 for ; Mon, 2 Aug 2021 14:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234414AbhHBONj (ORCPT ); Mon, 2 Aug 2021 10:13:39 -0400 Received: from mail-am6eur05on2124.outbound.protection.outlook.com ([40.107.22.124]:50528 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238262AbhHBOLJ (ORCPT ); Mon, 2 Aug 2021 10:11:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZhZttsULKVFSJ9i9IHif+VZ41fcbkaYElFhh48LzwuKntptoYhfb/0IGHE0Tt4gYqfCzMU1P9uvyLxJokBA1WB0MEGmbERd9R7swzi7msxdkUZq0T5QNpgxZi3V8WhUhOS9r2HGNl+J6/k6aTRctjSxrAV1I8h0kBaA5MvesVHLQuGEOOxAL1qyafyFtzASdXNg/0PEqIxosjbw5o/b1X5qIe8oN9FuH8YR2F7vYn89Uqok7sJWhTAw0RpXhxdM9FMy0anU2TCMbi99Jzl54yr+y7Rec52MLsBHH3VZsBz7U6/wdDFX0WR+w3f9EDgNTiJfH4EaGZ3kDiNhphjKzuA== 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=KV5DRV5V3TTeeEivlfB5FBEJPttplsRUpd3OxrOMTPY=; b=iegCLe5rCZQVyJmhzC8wVk7I03sFkG+qP6LyY7dwcnnWzJv9CtM5283l1FRiyQg4g9Xsw6LVrDu/oIsJWPmZjLbIjFoLJZTsqUeQNQPtLnkL0jO7KxyR7H7ohVXSbnn8PiZvIhMyhJRmgnyMSPbyZb731JDj6rq5pLRr54//XeTivoSVGWW0GI3LLq6xcKpPeelazu/OuWRHTh1imQojXlAuF0kxk2/9OUT2/VR0AywxSbZV+xtta64BC355jY/3rtl6d7hmj5CC7/TisfMqJxSm5lqHatSdrX+GOIpNdxteKL+dXZ0KL+yU9D/6biaVQCqorCDpXKCt8ObK2j/HAg== 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=KV5DRV5V3TTeeEivlfB5FBEJPttplsRUpd3OxrOMTPY=; b=m6E+w8jl69WsGPUIvj6PM9yh4Ii8kff3AY7jxtCvhyI+1Gby7UuC4MLwWHNfzsqZ6p99GC1/KdyBTChA0VbTKn6I5SZGnUitNVydOkn/VhewMNkw3KwwunJAz05MujiiV0dUMlhE8YLiA/syZCNoUx84V6O2kSKQaD704AnZsu0= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) by AM5P190MB0306.EURP190.PROD.OUTLOOK.COM (2603:10a6:206:20::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Mon, 2 Aug 2021 14:09:26 +0000 Received: from AS8P190MB1063.EURP190.PROD.OUTLOOK.COM ([fe80::380c:126f:278d:b230]) by AS8P190MB1063.EURP190.PROD.OUTLOOK.COM ([fe80::380c:126f:278d:b230%9]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 14:09:26 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , Jamal Hadi Salim , Cong Wang , Andrew Lunn , Vladimir Oltean , Serhiy Boiko , Volodymyr Mytnyk , Taras Chornyi Cc: Vadym Kochan , Taras Chornyi , Mickey Rachamim , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Volodymyr Mytnyk , Vadym Kochan Subject: [PATCH net-next v2 4/4] net: marvell: prestera: Offload FLOW_ACTION_POLICE Date: Mon, 2 Aug 2021 17:08:49 +0300 Message-Id: <20210802140849.2050-5-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210802140849.2050-1-vadym.kochan@plvision.eu> References: <20210802140849.2050-1-vadym.kochan@plvision.eu> X-ClientProxiedBy: AM6P193CA0066.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::43) To AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AM6P193CA0066.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Mon, 2 Aug 2021 14:09:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc30d9e2-bff5-4e27-d565-08d955bf22c6 X-MS-TrafficTypeDiagnostic: AM5P190MB0306: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 49scudn3JOTUFo9zMbvi1dcKMb2UBVKuVCox9vf3Tgyo1c1vXCNEQ68b4RsW2v03rUI+WkcOxGO2tPen8VWsHU10rGEFTGDfmti9mxuSGfJY3IBdKY2cRkK6X/DXk2d01q1gnY1qdviW6Gvkf6o/ryYXWyByE3SUSBVx+4/JDR4xJofP/+HIcaE/Ld+qfPumMep4yuWy3dwkXBkJm7I+R7kApGyZX5qC9B7SeLeSOmbUMSSXU0LNlXj40Qu/iTuqv/oycgalWfMyp7WBa1eQbmNGGlMYpYppoN3hf+w5j5ZWRO/PdwaHDvcRmnosrzRyMV+L+XVj/9VT6+GJxt/LH6CsCka+W0/yxS8TMzUh+izH2PjzsyKVmOXt/PSVM8VUjtqMpTuVfxpDzFKh/vyzNGU4w3gNbrmy1nqiF1YpYAVL+QgxmeoA+VeK85jBZTOQ7nQGJElZdq2ZjGV/iDgYOz3xSH92A4e4Yf5dH7bwkyRaDiYyE4fE+hc8iW8V7aQdY4BE3+AxhYrsNC57Y+eLiAUUoAKuysac427XXoUrCqOw4nEL4chShhaoLamF4QeFBiIIil4LD+Zc35l6yAonxajVWFMMQAGhL38OfrLq7xjaT/4OGkkYf2bQeHdQwA4ObyqiiIPr0a5KGVdCTn09b4r2OWJrcX8JAaLfQytDwMr1m/Xcvk4UNf+b6EvqiYPLtztMJG1GtFYDfFR4CPyQqQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8P190MB1063.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(366004)(346002)(396003)(376002)(39830400003)(136003)(4326008)(44832011)(2616005)(478600001)(8936002)(956004)(186003)(6486002)(5660300002)(86362001)(66476007)(8676002)(6636002)(66556008)(52116002)(66946007)(1076003)(2906002)(36756003)(6512007)(6506007)(7416002)(83380400001)(26005)(110136005)(54906003)(38350700002)(316002)(38100700002)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L1INxm7P69N1A5mzPx91OP5WOZh6bpKfwvA5ACfbE9Wr8KPLSirsL0D6IQO/LqLMLw6GC7gC9T9sv1Dql4GhjV378kGBT43VOXiwQytlGuIdunPcHwCWeEZdP7Z/paOQHy235drVfmq1ONzKii5unRKqfAIGIsadLIysFRblciGq3ef4MdnB4ZMqn9QuxOkgUaOkN+SB1SJEOiXsZKAvSPZ3Oe1QAZFtmw97GcPZfOeDMgWxB8qhxLm/XzdRN359rtXP2oFIl5B9H2DOMPeH1BcQ0qxy3uiqqz77/ZpE8/3MeHGQnSHOt257IL0Da9H8fpAkcnMcKS42yiUFJ5NVOek0TW7mIsIK5SbRHoG9FdWkCuRLWKyR0vnt3o3xSbReZJe6YGJT3IckOQTFrtcNvF0U15xQZEwH0yGqMcS6wuPgsWjGlKwLYLmNY4p+yy/XSOk2i19PdfprojWlPs0DaeSNQhA/4dhmKr5/aMKpcUw39fqwt5jzibRHJ6wiWheY0ZplkfWmdo4w18sZVDFARllwUlLMAiB3WI2+x/7VOPT+ZDMRDjIQ5g/OUkP8ZpZY8c5xCUOy5s45zLQZXIQOPFzpbGgSwrNFvi0qa875GzDSfye/bJ/g8gE1gwXZZcohf7sNrHcy0bHl5+TsNX8VVwXPXZ64H84aMxSDQeESNh+mL9MwlF9wZA3vyX8AwZHTULGVACwkixtNbyqO4KmhqWgG233WhaD3KigBikcmg/oegP5Ld1EHyxg4qInujGhLv0ALWtSHKR/OCHaEH3c5PMtsSEybs5v5esQJ3KeQ9UNEsnfEJHFvyr5ulnBoE4hFrgykgYJXIJ6xpp0jBDo9iipYgCViNG/il9k6YN1caQJ1ubLCkgM9hrY3muV3jNGsvOJeAttaymxDFlEm/kVtEDQsLdARH7h4XtVAf09i0Mdntw+aI3aTwhmashUbUwvGL4Ss7rceEvp+c6c1ZptnZt237U4Dh6D/JRrZeSFhk3Xh6AT31Lz5P9tUYKGiR6nfubLtUXQn06Z5ODZlGMTOlSkLapvvEvLfws3SPp+oxoZMJIv0byMMKzQ8int/h3L9JUmAxS6cnD/v8FOKYVzCUfeFQBoNxJV5OLRruTafhoWSNSeBqxxo4HVwx/Wd6TcT13qIsYuk4oHW5hSpUBNw7anFWAPkVxW1ERbiuBNARgtu7JS0ieGt7IDOlQCwpriXOX6ebb4SBqm/7tu4LiqkXRI+GgEsD9TQToJnHNp/DUJnHRjPWk/M02h1ow9sEFqxXEcj4WibVNR6Lq/nV1DmFxwX6mmHqTchEMQ++1CCQhmg7ztoBXQIN35kKTIlw8+8 X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: bc30d9e2-bff5-4e27-d565-08d955bf22c6 X-MS-Exchange-CrossTenant-AuthSource: AS8P190MB1063.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 14:09:26.1729 (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: EugPfl0VT0G0jx1fex0peMbElppOIEV2ivrLpl3jytV1sJoHccJ/fzFzosLkX35ayRZpckT2/usoERKjIC+u6gbJyL3ZIj+owQkcEgKDnIs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5P190MB0306 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Serhiy Boiko Offload action police when keyed to a flower classifier. Only rate and burst is supported for now. The conform-exceed drop is assumed as a default value. Policer support requires FW 3.1 version. Still to make a backward compatibility with ACL of FW 3.0 introduced separate FW msg structs for ACL calls which have different field layout. Co-developed-by: Volodymyr Mytnyk Signed-off-by: Volodymyr Mytnyk Signed-off-by: Serhiy Boiko Co-developed-by: Vadym Kochan Signed-off-by: Vadym Kochan --- v2: 1) Added missing "static" in prestera_hw.c: - __prestera_hw_acl_rule_ext_add - __prestera_hw_acl_rule_add .../ethernet/marvell/prestera/prestera_acl.c | 14 ++ .../ethernet/marvell/prestera/prestera_acl.h | 11 +- .../marvell/prestera/prestera_flower.c | 18 +++ .../ethernet/marvell/prestera/prestera_hw.c | 125 +++++++++++++++++- .../ethernet/marvell/prestera/prestera_pci.c | 1 + 5 files changed, 165 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_acl.c b/drivers/net/ethernet/marvell/prestera/prestera_acl.c index 83c75ffb1a1c..9a473f94fab0 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_acl.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_acl.c @@ -8,6 +8,8 @@ #include "prestera_acl.h" #include "prestera_span.h" +#define PRESTERA_ACL_DEF_HW_TC 3 + struct prestera_acl { struct prestera_switch *sw; struct list_head rules; @@ -29,6 +31,7 @@ struct prestera_acl_rule { u32 priority; u8 n_actions; u8 n_matches; + u8 hw_tc; u32 id; }; @@ -203,6 +206,7 @@ prestera_acl_rule_create(struct prestera_flow_block *block, INIT_LIST_HEAD(&rule->action_list); rule->cookie = cookie; rule->block = block; + rule->hw_tc = PRESTERA_ACL_DEF_HW_TC; return rule; } @@ -251,6 +255,16 @@ void prestera_acl_rule_priority_set(struct prestera_acl_rule *rule, rule->priority = priority; } +u8 prestera_acl_rule_hw_tc_get(struct prestera_acl_rule *rule) +{ + return rule->hw_tc; +} + +void prestera_acl_rule_hw_tc_set(struct prestera_acl_rule *rule, u8 hw_tc) +{ + rule->hw_tc = hw_tc; +} + int prestera_acl_rule_match_add(struct prestera_acl_rule *rule, struct prestera_acl_rule_match_entry *entry) { diff --git a/drivers/net/ethernet/marvell/prestera/prestera_acl.h b/drivers/net/ethernet/marvell/prestera/prestera_acl.h index 39b7869be659..2a2fbae1432a 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_acl.h +++ b/drivers/net/ethernet/marvell/prestera/prestera_acl.h @@ -25,7 +25,8 @@ enum prestera_acl_rule_match_entry_type { enum prestera_acl_rule_action { PRESTERA_ACL_RULE_ACTION_ACCEPT, PRESTERA_ACL_RULE_ACTION_DROP, - PRESTERA_ACL_RULE_ACTION_TRAP + PRESTERA_ACL_RULE_ACTION_TRAP, + PRESTERA_ACL_RULE_ACTION_POLICE, }; struct prestera_switch; @@ -50,6 +51,12 @@ struct prestera_flow_block { struct prestera_acl_rule_action_entry { struct list_head list; enum prestera_acl_rule_action id; + union { + struct { + u64 rate; + u64 burst; + } police; + }; }; struct prestera_acl_rule_match_entry { @@ -120,5 +127,7 @@ void prestera_acl_rule_del(struct prestera_switch *sw, int prestera_acl_rule_get_stats(struct prestera_switch *sw, struct prestera_acl_rule *rule, u64 *packets, u64 *bytes, u64 *last_use); +u8 prestera_acl_rule_hw_tc_get(struct prestera_acl_rule *rule); +void prestera_acl_rule_hw_tc_set(struct prestera_acl_rule *rule, u8 hw_tc); #endif /* _PRESTERA_ACL_H_ */ diff --git a/drivers/net/ethernet/marvell/prestera/prestera_flower.c b/drivers/net/ethernet/marvell/prestera/prestera_flower.c index e571ba09ec08..76f30856ac98 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_flower.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_flower.c @@ -5,6 +5,8 @@ #include "prestera_acl.h" #include "prestera_flower.h" +#define PRESTERA_HW_TC_NUM 8 + static int prestera_flower_parse_actions(struct prestera_flow_block *block, struct prestera_acl_rule *rule, struct flow_action *flow_action, @@ -30,6 +32,11 @@ static int prestera_flower_parse_actions(struct prestera_flow_block *block, case FLOW_ACTION_TRAP: a_entry.id = PRESTERA_ACL_RULE_ACTION_TRAP; break; + case FLOW_ACTION_POLICE: + a_entry.id = PRESTERA_ACL_RULE_ACTION_POLICE; + a_entry.police.rate = act->police.rate_bytes_ps; + a_entry.police.burst = act->police.burst; + break; default: NL_SET_ERR_MSG_MOD(extack, "Unsupported action"); pr_err("Unsupported action\n"); @@ -110,6 +117,17 @@ static int prestera_flower_parse(struct prestera_flow_block *block, return -EOPNOTSUPP; } + if (f->classid) { + int hw_tc = __tc_classid_to_hwtc(PRESTERA_HW_TC_NUM, f->classid); + + if (hw_tc < 0) { + NL_SET_ERR_MSG_MOD(f->common.extack, "Unsupported HW TC"); + return hw_tc; + } + + prestera_acl_rule_hw_tc_set(rule, hw_tc); + } + prestera_acl_rule_priority_set(rule, f->common.prio); if (flow_rule_match_key(f_rule, FLOW_DISSECTOR_KEY_META)) { diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c index c1297859e471..918cdfbfed37 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c @@ -91,6 +91,7 @@ enum { enum { PRESTERA_CMD_SWITCH_ATTR_MAC = 1, PRESTERA_CMD_SWITCH_ATTR_AGEING = 2, + PRESTERA_SWITCH_ATTR_TRAP_POLICER = 3, }; enum { @@ -319,6 +320,19 @@ struct prestera_msg_acl_action { u32 id; }; +struct prestera_msg_acl_action_ext { + u32 id; + union { + struct { + u64 rate; + u64 burst; + } police; + struct { + u64 res[3]; + } reserv; + } __packed; +}; + struct prestera_msg_acl_match { u32 type; union { @@ -354,6 +368,16 @@ struct prestera_msg_acl_rule_req { u8 n_matches; }; +struct prestera_msg_acl_rule_ext_req { + struct prestera_msg_cmd cmd; + u32 id; + u32 priority; + u16 ruleset_id; + u8 n_actions; + u8 n_matches; + u8 hw_tc; +}; + struct prestera_msg_acl_rule_resp { struct prestera_msg_ret ret; u32 id; @@ -908,6 +932,36 @@ static int prestera_hw_acl_actions_put(struct prestera_msg_acl_action *action, return 0; } +static int prestera_hw_acl_actions_ext_put(struct prestera_msg_acl_action_ext *action, + struct prestera_acl_rule *rule) +{ + struct list_head *a_list = prestera_acl_rule_action_list_get(rule); + struct prestera_acl_rule_action_entry *a_entry; + int i = 0; + + list_for_each_entry(a_entry, a_list, list) { + action[i].id = a_entry->id; + + switch (a_entry->id) { + case PRESTERA_ACL_RULE_ACTION_ACCEPT: + case PRESTERA_ACL_RULE_ACTION_DROP: + case PRESTERA_ACL_RULE_ACTION_TRAP: + /* just rule action id, no specific data */ + break; + case PRESTERA_ACL_RULE_ACTION_POLICE: + action[i].police.rate = a_entry->police.rate; + action[i].police.burst = a_entry->police.burst; + break; + default: + return -EINVAL; + } + + i++; + } + + return 0; +} + static int prestera_hw_acl_matches_put(struct prestera_msg_acl_match *match, struct prestera_acl_rule *rule) { @@ -963,9 +1017,9 @@ static int prestera_hw_acl_matches_put(struct prestera_msg_acl_match *match, return 0; } -int prestera_hw_acl_rule_add(struct prestera_switch *sw, - struct prestera_acl_rule *rule, - u32 *rule_id) +static int __prestera_hw_acl_rule_add(struct prestera_switch *sw, + struct prestera_acl_rule *rule, + u32 *rule_id) { struct prestera_msg_acl_action *actions; struct prestera_msg_acl_match *matches; @@ -1017,6 +1071,71 @@ int prestera_hw_acl_rule_add(struct prestera_switch *sw, return err; } +static int __prestera_hw_acl_rule_ext_add(struct prestera_switch *sw, + struct prestera_acl_rule *rule, + u32 *rule_id) +{ + struct prestera_msg_acl_action_ext *actions; + struct prestera_msg_acl_rule_ext_req *req; + struct prestera_msg_acl_match *matches; + struct prestera_msg_acl_rule_resp resp; + u8 n_actions; + u8 n_matches; + void *buff; + u32 size; + int err; + + n_actions = prestera_acl_rule_action_len(rule); + n_matches = prestera_acl_rule_match_len(rule); + + size = sizeof(*req) + sizeof(*actions) * n_actions + + sizeof(*matches) * n_matches; + + buff = kzalloc(size, GFP_KERNEL); + if (!buff) + return -ENOMEM; + + req = buff; + actions = buff + sizeof(*req); + matches = buff + sizeof(*req) + sizeof(*actions) * n_actions; + + /* put acl actions into the message */ + err = prestera_hw_acl_actions_ext_put(actions, rule); + if (err) + goto free_buff; + + /* put acl matches into the message */ + err = prestera_hw_acl_matches_put(matches, rule); + if (err) + goto free_buff; + + req->ruleset_id = prestera_acl_rule_ruleset_id_get(rule); + req->priority = prestera_acl_rule_priority_get(rule); + req->n_actions = prestera_acl_rule_action_len(rule); + req->n_matches = prestera_acl_rule_match_len(rule); + req->hw_tc = prestera_acl_rule_hw_tc_get(rule); + + err = prestera_cmd_ret(sw, PRESTERA_CMD_TYPE_ACL_RULE_ADD, + &req->cmd, size, &resp.ret, sizeof(resp)); + if (err) + goto free_buff; + + *rule_id = resp.id; +free_buff: + kfree(buff); + return err; +} + +int prestera_hw_acl_rule_add(struct prestera_switch *sw, + struct prestera_acl_rule *rule, + u32 *rule_id) +{ + if (sw->dev->fw_rev.maj == 3 && sw->dev->fw_rev.min == 0) + return __prestera_hw_acl_rule_add(sw, rule, rule_id); + + return __prestera_hw_acl_rule_ext_add(sw, rule, rule_id); +}; + int prestera_hw_acl_rule_del(struct prestera_switch *sw, u32 rule_id) { struct prestera_msg_acl_rule_req req = { diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index ce4cf51dba5a..f988603af1b6 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c @@ -15,6 +15,7 @@ #define PRESTERA_MSG_MAX_SIZE 1500 static struct prestera_fw_rev prestera_fw_supp[] = { + { 3, 1 }, { 3, 0 }, { 2, 0 } };