From patchwork Fri Jul 30 13:39:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12411261 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 37ADFC4338F for ; Fri, 30 Jul 2021 13:40:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B5D260F4A for ; Fri, 30 Jul 2021 13:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239015AbhG3NkJ (ORCPT ); Fri, 30 Jul 2021 09:40:09 -0400 Received: from mail-eopbgr20123.outbound.protection.outlook.com ([40.107.2.123]:37764 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239078AbhG3Nju (ORCPT ); Fri, 30 Jul 2021 09:39:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oTX9AfPvn0apczWDA8P2IYFdB85MtN38o2jfXbzhnXn2hUIcxX76Cti3Cdp6dnmzdi3OJlwZ2JlfXrUNgxIOqIHwJ8Cu2YeM/mLBZrbfr5WBJk+MvIUWC4QfuCCp6LGvzb/EyHCYzpVVWjYm1L2MaGxR/E4HDPnXPTZ5iyx1YVQHR+1OWnuETmyfZZ90jNl4dgz+O8lS71hBSnUv73vuiollSdCfwPCn84TGSx4RTMLO4RRrkdcGZ6WcSGk0tgltgk3y8oPxDLwV1yUAwLY0cpe9UgSbRZ4UFogkMJ2bVkmCxdKsLT7tedK10+jUEOrgQLEeSMjTMNOURHHZumXydw== 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=MlZNnCouaMwDzkD+aAT/BmwmdFYeL/2w6CddCVD7Q9ZuSN5RDIF7ifD86OblU5tlCNYURm7DjQDc1sP+AsoSQWbDjajWMdxwOBkNFDZ+oPz77CaU8tD7ZLmBCHowRhHbpc2YaB6VrFiU8QWxpCL3BEfcucJ8VMsdjEqcCGMTWYuLSzCwnCuW5027e1NYFzKUfCudKeo8xArwQ+fdQNgtuZ8o60TUorH8W7U2iSQY8HoSbX/g2ikgM7eZFiJiKmRCEwhyJ8Q7qvqEokfRAxn88YSMbllDdiE5WcR1q2INuygAeLaGnbZJSrEmO7kMQj0JdqszuxzaU6cTA4ABieyjSA== 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=j5gPTYQGVWjfNDj8twlC4rrNuDEgBSldVz4qCrFdVLwcW+ZrxxdNri5itBXsdqQiizK7MrKYyCXEePTz9v2SACtFVB6mCSBh9I5J128+WwRnIn8F87+FU1TvHAAhmSu9bqXCPAW6pBYFaTImbnxhK0Yt9Eu7G4j5F97bVefpza4= 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 AS8P190MB1271.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 30 Jul 2021 13:39:43 +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.025; Fri, 30 Jul 2021 13:39:43 +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 1/4] net: marvell: prestera: do not fail if FW reply is bigger Date: Fri, 30 Jul 2021 16:39:22 +0300 Message-Id: <20210730133925.18851-2-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210730133925.18851-1-vadym.kochan@plvision.eu> References: <20210730133925.18851-1-vadym.kochan@plvision.eu> X-ClientProxiedBy: AM6P194CA0012.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::25) 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 AM6P194CA0012.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Fri, 30 Jul 2021 13:39:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bdbd04e5-9936-4a9f-3154-08d9535f7cab X-MS-TrafficTypeDiagnostic: AS8P190MB1271: 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: zXYU6BSKAWB5DWgS3uyIqiwXRuMEtM/U7CUNzhwruXq9D9AjnpCHlChRuE9gRJtIbXSVrn60dZVo0laAQda31Rd5MUy8nTIHauPF2KGQ3qfddLde0IeormPznHUYXamM2jZ9ljrJ9+yB9rkR0ZS1Fwqscjrfjq/HBs0MyZGxxqB8/aR8Uaaj6FRAbmB3MRz8QPsgZQ8PD9ipnn0YvKWSLR/cYHUcfXVYJH2POVbnNl11+9Wxy3fHurFzKGACt/KrEscGNOS9taZCPMsK/J406gh0WvbOHag+gP0ZtvJ+yT71Y0NYw63oQeXTlyw2a7cxoNc8bWuliMi/qUjCkuRlBtt/5gu6I/4BQVZscJZC1Sic/Q33cBzqJ1y1Rndz9Bk5NjZ3YvG0AC6uZ4glLbFbNlfDYh7vWdY8F+UeCR32HoxSU1jlxgrJz2SQYldKiBRw/oKS59cmYojWP3Bjx/1g5huu3ktDa/wKcN3Ilzyv+IOnHT6+2HU17EoaE35IbiKGZRLnxcDcQTTYyGCLHKdrKO19pK1zhMLrw6Bwi43GHmcSHfVo4EVOyB5j320S5qWJYYAI9nxXm6/VD0xOvwy4RVUAtFdqG6BEapDNeTFVRo9iRigIfC9Wp/12WLI4QAjomv8zdcTd3QI4GYX64SE5YUdrzSoc45hw4XPEZpw7Mf6wuGCW1BQtR/rMzuocLrcl1c5nLSPaz+Szra+qBlH/RcTUdBBr47bFfZ6D/Ahf69k= 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:(346002)(136003)(39830400003)(366004)(396003)(376002)(52116002)(8676002)(83380400001)(5660300002)(36756003)(54906003)(26005)(186003)(110136005)(6636002)(6666004)(8936002)(44832011)(2616005)(956004)(478600001)(6486002)(2906002)(6506007)(1076003)(6512007)(38100700002)(86362001)(38350700002)(66946007)(66556008)(7416002)(316002)(4326008)(66476007)(135533001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WLtz6C+Jv417jtYym92abSJzhxGkjhsBBeyON28FcMus5yxYOniWwn0aSDwhA5eJxmlxajDiDrgAOMUzvKpWQcJ2BFYT099OJ2QgmGJTPRAEZsCjGgg1mp+uzA1L4EdFECrmPJqzeZ04pXa3F3A3SneDP4KxnSfZpBPX9avhhKRSGwJUDFEhdJc7IquSFjVdPllt34Zlx2vY9F5u3negnBGwyImRriqr3YGhaIih7aBktk5tD8VcY0Hu48VgQr4C4g5Sj0e653k7gxANpubvJvAr3YYLRGXwluS5Nq244vH3m1kadAB0Po10PQJNj9NJE30aMXzvDFasLP5ZQ3qxqfqAhV06Bww5SxMUYhpfxx3i88I2TdeIduYBhznkA246rQlxGUGf3dzFSD4KR24RHb0Ff5w+i8WuvkwuUn56WC7g6+Sn02Ad9y1ets2n4bxjoTiffHiT6BZowlmLCQ2JXZB5QvCC1FurWp9sT31L/SzRQdS9MdlMIHGE8oIgbFJ/9bYPljFCLshIOVlBh9gh18QIEJ8wcps9FCO1UltEbSHBwGXXLT0PVo8+0knlUY8+7nzMmSbcjcXw0j7fk0dcq4k3w89EQb2m179Xddm1IgaMYCRUDthrPBJvammGXW/70RkwWfBM+qfPRO0wIKcYyQWW0vtZHjOxYtZUjQxpjYCo8xxKE0U0nQ/Htr78AFjhKrLZC/NgINQEP9Zz4cXrJEU0SJHRWSij3cH1vdf4jY4Rwt14tRhuM3TTWJkTz4xe+kd+Xx3xUj2HfEA6b90XIqk70knynrpvMyJxi+f/ZlSbYuT7NsiJg3l8pxj+WjN19AwdRGdl2B0TdwHhjBFq7LSeBFowwDgvlSz0R6Md9AlO06UP8c2V/TnwXP4SWtnRmac7JrjGczxVjX425+8LV4BV1aV45J2zj9qbT8RGtujLfo8eGzZmSMHQ9dR7iRdRRURjrlyeCdeuqKg1TreJsw9y9espzY0u4q0mOZ6H9voLU74XM3/+Ru15URACe/58nasYULUy3OHh+vyhbRFUs4CTTUsKfBj7PMNzP4P5OSnVbypeXbrulQtcXkRwStPLFR/D6SvWga2X5fcj6kLhlBO6k9HHgp1NrW4kqrSdMZqfrONNovtjkl/OMA8vO/OvdPhU38LjIlXvGPDEL37fOhtDKRNGA8IhNGOS3rKI2ThpPKnloLJIUjnVENrPhvX7WGIrkNvKc+pEITQqTDhrbYlHh1ORhuuRL/qg91Jf8eSf6CFB/MSTb8qGaZLpM+TMU6e2EvKMZKh+FjgzqVWOCFYMJRMAjfTVvPdwI7gU11I57Nisl1wUt3Vfpx9dpcah X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: bdbd04e5-9936-4a9f-3154-08d9535f7cab X-MS-Exchange-CrossTenant-AuthSource: AS8P190MB1063.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2021 13:39:42.9343 (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: Izoj9PGMsCSUlTjBGzlveQ2+nRL4Xx8di+VIF4l7dfm/giHPAPNL5xskOzZdqw4zMkZ4hW0xGcmK6foQGxMbGUeHYhgG3YljbC3GeVUCVhg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1271 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 Fri Jul 30 13:39:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12411265 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 F35A9C432BE for ; Fri, 30 Jul 2021 13:40:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DADD060F4A for ; Fri, 30 Jul 2021 13:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239061AbhG3NkZ (ORCPT ); Fri, 30 Jul 2021 09:40:25 -0400 Received: from mail-eopbgr20123.outbound.protection.outlook.com ([40.107.2.123]:37764 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238970AbhG3NkG (ORCPT ); Fri, 30 Jul 2021 09:40:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BkzDVd30uICIfvUO9REXpJeg3ucvHR1Dg5d8VQHdFaGGhhHWOtHVIoAKBSa8RF4+veQLQiRpv1brHZnZ83YUCyF5aOTyLS8uAESNWvdoQqkMSDdNY4WJHIbBdcqTjhB0NnNFjJ0fXEfv5dIJKbDll8tudGLrjTTGCZvf2DeMFNOhgHxVeAK0mDyHQEeO7R7InPa0HRdX3epzakUIrA2Y7uDTsj4TbPAUkPssTRyo0cRagMz1s5zUef2UfxE9ZJXWa1v12rv706ZoDVlzvF+8hIQ5stIJza0YSJZ1jdrRHKf8h0sqGLm9cGZHO2Q0GP6U4n2Kr8yCSkhTR4yghFbz7g== 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=j2D9Ie+n6ooFR9WjfDF8ky8V8inOWaaqjwMp5vSEVAvcXfHxgTanbL+CDLtEkJkTON/xALln1Q1gXiGsKveQR+qWjzIyN2JQmumkFy0lDj+zWYiaVGtIRkuLmGh8B/3v7gb6uC6DI55A7A3ScVaSx2K6av+Iwesjg1F5R/d9Lu520nnEuxrChFkcXbnLAK0W9LGzzJuqMnbtQlIl8TxoStP7/23VEiXODCxxTy1rwAKrm4/HXWj12N8akaJgAeQvfw0j4zeqKQbwv9nOTYIz0lb0GYNFiYiTq+Otfx0SfyrSQHQmnE36Rln1nxg23DJTQwlShYXUDhV5nnNrsGIxjg== 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=CqSieUAKBAs72N1PPldeXPtxKQGDCD0sQt7aGrMEJJm46882q07BIXjrE/zcIoyZwkEyuhIXvy8vNO3b9SfkbyOjQcYLCK83Z0Gt/lbcqjf823X2XwPPdzRpuCYOls/+DGSodiFYhXUNHm8v3IflualQ94OSXohNsfLPyy1KdmQ= 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 AS8P190MB1271.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 30 Jul 2021 13:39:43 +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.025; Fri, 30 Jul 2021 13:39:43 +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 2/4] net: marvell: prestera: turn FW supported versions into an array Date: Fri, 30 Jul 2021 16:39:23 +0300 Message-Id: <20210730133925.18851-3-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210730133925.18851-1-vadym.kochan@plvision.eu> References: <20210730133925.18851-1-vadym.kochan@plvision.eu> X-ClientProxiedBy: AM6P194CA0012.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::25) 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 AM6P194CA0012.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Fri, 30 Jul 2021 13:39:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f2ffb3e4-a20e-43b4-3fdd-08d9535f7d32 X-MS-TrafficTypeDiagnostic: AS8P190MB1271: 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: weMuVEqQwFpjo/5vxi6Xu/PNzgn6ijHp355p2MuET44ufLgdhMjO+ehVz4hAC7+MjYxQUR89KJJZceZuIT6kUPJWuiivFd6y18FcM0AqrsNH42V4qMA5vWQ3Y3jI1jsQ8lW3yGV9QBjqasl+v+++IOQdqvlZ42UMC7FR41Fh+G/VZYgA/T8p0ISv0BzYuLFkudpk1wBFsDbqnI+V9cgWCTzcszP+GBAeAMz0clvIaovMZkBijElVs38kri3UL/2FSAEbet8awyNEw9bsADFrX8os11vzzX1FeSOzZF4Dza0Ifg8KKXoH0+yTDjBVe4Nl7frZCrVHMjqT8z0YFKE9C2qEolybo4NdtjjUFh5gGLdpoPM/u+WBtZ3whVjGdnJ/37kdlwyhyO7BTlTIlMMrH9flSksxFSGnn6x3SUtjM/IxTWacOLdm1kqWFtFYocy+kw8UTJr9VkvTxXC3MVta01CQWmuxAQwYjZR/cz8O46XjIphbyt8hVqXgm3ER38soGA4HclPOJ+/fkjEOYq1kMCgfT0rigtyaqAcZAzSbdnqViEgwac57Q869r+bFgWd/53tl/S2AdHsfFQS0hb02qH5YGfJe4Uch4Zmxrc/V9Nrz9KwRFBsC8G0rRnJxw2sz7RM1rhgVLKulh+Ip9h8l4Nnmsjuhol+8Lz/Tn2S7JoPpQD8eQzpM8+RgveYtq78tJChDI6yTuiO9u0aJK4jqCg== 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:(346002)(136003)(39830400003)(366004)(396003)(376002)(52116002)(8676002)(83380400001)(5660300002)(36756003)(54906003)(26005)(186003)(110136005)(6636002)(6666004)(8936002)(44832011)(2616005)(956004)(478600001)(6486002)(2906002)(6506007)(1076003)(6512007)(38100700002)(86362001)(38350700002)(66946007)(66556008)(7416002)(316002)(4326008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g862kYPUJb3bDup7SIpN8pjbVceUUI0v6XOccjXOHIZU+oObF/OnB5SLAEtzMEo5PP5n3AGzoQ3FNTw1Hk5CBd3/zn8zz+8tfmqWPNhCVpdPBbOKHHHx7Qc0cS96nGUdveyqAJGOvOf+I6ZciytbzAXPPUl5Sc/fLDhiYWwdN5hdHaVwzbuFQVC7JhiL6htbFWsOsj+r1oKLRXDiHsdjqIuYLQOvSHjEwlpOyq3/bZwW4Jpmu0guosZbr7wIXCZ1IXQHC53WvLgKeoq6YAbX/+QqVsipwol+vhAc+QwZqmFhuVHeviteyruG5nuZmmMEIJ6nxcmUIsvEaloeqNgl4WrftgIPfs7GXLlErpJH97qsnyBoTm/aLXD3a2JrvSeMurmfVZ3pkPqNul9DYNwQZdXU8NKgdhJ2/M3b8Gb16cuTrvF4uKJWHUy0ZDS3Z0qkL4f7NxfwM7rzkHIliw8VlvwtuP9ENnac8jkQ9cW2kLkyBFZTaODd9Vc/e1WFlt5HdHezqX1IrC11AJcVtlUK3d+UkHXxNh8OOEfMALbsXMC6mdeKSjjfyKiatAaoGzrS4nc+MPcxEwWH+tURlZ6ZCpPP3sFqds4dv0JLqM8mSF4to3CkZRcBmoWZRhflewYLcqMtXa0JW5/PRvETEawGcwAh1EZDRIlPudEGw95V0I4aeWjbVfQYbPUdWdLo+j/GzBeautJStm9I097pKzQPUd7n1+n4EPzWc703JwiSC889K3cGD4qAgS57ibC2m3Vvg+XOzQuNO9dBju96Rri+LEAUc//wKLCUGmQKRPVbPgMYxSzXJNJNGCvaICtP71tw4MpwkGY9ftBFjcdAuZ357JRYnc3TFe1u6wjZ/HGvtjCqmRyxuKJ+Qmnk4Ev0KRLfAl6u1TnH80wgs/M9o2G8kwNYfnYPY0dXCwSvJjacHnGuT+sSCZV6FY5TTVHa7TS8dCcS3pgqxtP3gH0KXQPMBIUZW2omJ113FKEO0DEzM4ONX2Den2LLSU5cruKxE0rOPYI9CgCZKB3crOvWQGQZCWapBMp19AWNVuqGnA2N8cH0fCWnf7SwqUsDdYkGyEzWRpqgTRlygttgJhROz0iCUM6R1b2ql/XofbaKVrGDb8J4LhSnU8qJp0xhxw2W34IboNSunQVsyZY38p/kO6RL54tvf3o4s0nG7fviA2aMG4Yswm8VdzaxPKILAifv63424vmhjYIVFcqWAV5n0i74z8+u0PGHXEMsw4/QtBs2vQG24Cv+BLIWZt2iAOeT5Z7fv9GqcF5xOmPNRn6X5M8sInWM3Pb2uVRHHoK4Wh3psusazNj1MTCu4EpS4t1NOTfg X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: f2ffb3e4-a20e-43b4-3fdd-08d9535f7d32 X-MS-Exchange-CrossTenant-AuthSource: AS8P190MB1063.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2021 13:39:43.8194 (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: ybRj6w2eLktmluE29aj/1OAY2YmYXgteoXDG3H5u91lYG+aVagJO4GZPdQJK6Mn/Fl7HEfNCHzw2ptwtbVqU2937ATG0w0NonwEtl86cqzs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1271 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 Fri Jul 30 13:39:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12411267 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 A3F16C4338F for ; Fri, 30 Jul 2021 13:40:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D42060EFF for ; Fri, 30 Jul 2021 13:40:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239066AbhG3Nki (ORCPT ); Fri, 30 Jul 2021 09:40:38 -0400 Received: from mail-eopbgr20123.outbound.protection.outlook.com ([40.107.2.123]:37764 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239007AbhG3NkJ (ORCPT ); Fri, 30 Jul 2021 09:40:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l+TjGKRWQAXc0bCnZP1dZYiUepi7l5QAfdgBWVWq2uVTCvTvUKtDVLjEscrNwXolmQy1pVh9x9BafuBHtOSmSc5mZglkfpAagtnAZx4XJBIPedroWO7mBanylHStfA3gXC0weDWWbTGr3Hg9K9FK9tGM4EOAJUWzW8sO6+6j7LpX7eFIG2CroB4VQxcDmYhKwQpkN8R1mpBkfDAfcRV/5O3Ha3+FNtgmRKgC8kbAciAZDdrsAUHvt6PPtWTy253C0K7EME0KDuaBiBspfCU4dsEzrjYnS6UrDzfXjDPEU7i/D7nyN5st3WKPQ8VwNeecA5tA5dQAfMhTrbsGMsXKzQ== 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=7kP9oM0zFva25BhuKewz9q/gaIkw9UA0YoJA7v8DZYo=; b=CWfEDwBZj/PBwthDexMyTSCgNsnxQidRohAaa5MWmutDKYVVkXwP8Ozi3tZpbH6b8X2mED10GihsmTcg4MlGkXubW4kot1lvmXVV9+O7cbG6k6KbLAubYTJ6VIRa9H0M44syhO0ECegEj8i+f9dB6ahXjWa1tUxYQWL9Al3GCu/YY1SganL050OXXDwRQ3NqIGzZmVlRwqWXGxqPJ0KN5x4uTemba8UWysatoSlfGGInm/c8f8VbFFd2yBA9oXrJ5uVBp/dbgqd3pQ8jSb0a2YmufIOVEP3sUsg4qAlKDmYEtvpkeJUElb0sIk+dSrWevtxODqJ4AvZvWo50PwlMsw== 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=7kP9oM0zFva25BhuKewz9q/gaIkw9UA0YoJA7v8DZYo=; b=e/8KT0mQN/9+WFmIQvxuWCdKrQ3L5bOxdZgcTSLM3jeqN1KMOBfLKb6RpedHXXbOHteYH2ml3z9F802bBJedsixdlAG83vOvkPlpw8HYY0n9mN4OHvnjYcyX63Z9GFakz/ZDxXGGzgDtWyG6bC+qkJcGInKHKLzj8J18DVpaI9c= 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 AS8P190MB1271.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 30 Jul 2021 13:39:44 +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.025; Fri, 30 Jul 2021 13:39:44 +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 3/4] net: sched: introduce __tc_classid_to_hwtc() helper Date: Fri, 30 Jul 2021 16:39:24 +0300 Message-Id: <20210730133925.18851-4-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210730133925.18851-1-vadym.kochan@plvision.eu> References: <20210730133925.18851-1-vadym.kochan@plvision.eu> X-ClientProxiedBy: AM6P194CA0012.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::25) 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 AM6P194CA0012.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Fri, 30 Jul 2021 13:39:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fdc346a8-1dda-4939-0d71-08d9535f7db5 X-MS-TrafficTypeDiagnostic: AS8P190MB1271: 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: /OMDr5lSkX5WgfowaR0DX/r5nh+dcYKjiHzGWZbHyqx9RqcD430V/4r9eFVKQqUcVyqgAIQHEmnuLgxLetU3Hdc4265rE19Xt6jUthfEncY22gfJ7JI2/y0Fyz/C5L3j5DzTXo+gQ/nJD5DG6oFJLURt9+F0JWNhyt23L90Frnscuo6CGN2O4wDs8UhTuSYkl9LpqQs4TfKvtzl/dMsTPTnuAWby6J1nac5R/ZsB3ixpcakn42YKd2zaV/GxvwU+dg/3J43Y6UshcapdkKutIQqRyRnlzgpyvagV4QG6YTztyzkv4ut17WyeimEtdvscM0F0u16Ta/13nNF27fHXg+4qzRezGejh7m5ur2TbKa1aB3dMrDW/uTRtv5gT7c3NMyMs3xcJLEn6uluY3Cn1s9ybPzLbFX4D+JxnxY8Q56PNcjXakSdRrXaEagigwLDy8UXv+9mjsLgJnWTeyPqOEdN7MwJlCwA+hz5i42VyWFajh6drmiXKmv7g+yZUkD/e5BFMWqZDTj9/1U8vNthWkUG+3YQDzozMYU2gy7GoHPegK9Ct0laRJxj5jPJ1yRjFXlKLO8DjmLHDnjRCNLyTxZo2FHD0cc8tdxOaHVENBv3/CYqzZQ8sWoXZ0U4Gj4COD8GcZDL6aoA4eja66EiVldx5u91GKy3UT8UxCMqZhKVL1fI7zrUtzbjOEDP1rAkHPlrN35q1vAWy0Eng7b57pw== 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:(346002)(136003)(39830400003)(366004)(396003)(376002)(52116002)(8676002)(83380400001)(5660300002)(36756003)(54906003)(26005)(186003)(110136005)(6636002)(6666004)(8936002)(44832011)(2616005)(956004)(478600001)(6486002)(2906002)(6506007)(1076003)(6512007)(38100700002)(86362001)(38350700002)(66946007)(66556008)(7416002)(316002)(4326008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uwgZZv8h/7O54AIrexb9+3C7SO7ZJZSOjDvCoURRw17KZw0+96EkdEmQgwAWuBvFwa/bkn2P6VtmwMPFhVOAvFjI+HNfHQxyTc/AzAZIfo/RHNwm39BwdVmjLiupYYcxxcROcwAhlRCFQziRMFY178aaUAwAKv3P2P0P6cdNO3noC3lDBRQ70mfzenZj1xiZfUWH6G8orbZYfF/AeQYUI3uB3qyf3dFG/AyLIKp4ztYe0Rs2Cum8ahww1zoBxqlx172xFQUSELE/8U98qtmopcBG9R2tmo1uiO8RM8FF41smrdaVPWB8zu89fnZZnQOfm6tAXVigqAg5xMio0slosNuzrOe9Zt1jGO2LAWk6cq3HhNUGgzEU36pyXE8oqRoQMfgIHwkeqHqk4NZ7opF/hBwafcOS/+AgU6enm/PWHWTPMqtyHbVqwkLU6DmGKEt/bZgqkp26uwti+y1Ug1S/N+S/2dPlO/sDXBVbUqDTBtKftG0gJ6Y1yu81rbGPW8ksQzBWWGvPEjtOYV6ZjLfcFLkxWZ164QG1VSoerRQd2wkS5+5lkWS37xM3xMAOabrOBF9wJjwdj+BpYuJj3EyNOEyU5HiyH7Ial4reMvZYezR26BUw9uLGrPa2mgkCk2cBzpHNvRPIsr2CvSlpvVthje1euTKLocnlr/8dcm5T0FtGLpVa79NKmFeFxuMKkq8zif91qkSOO6hN69J9ioW4mb6TzS8ld87alS8FaT3vJozMFD5U5Zf/93C+Y13fgdJEYOzvCgucOZ37gyhIKGmVdv2MxWUJrTlWes87FQC/z6rj15KxrFsJ/dBUpKUehSxv16u9GkVbuxj6oq5pLJV4YC1DbnoRCpI8yYQsXSe9KCqBWXs2We5rsrJJtvPURLFSDuYOh+IOacVsNpNGz8R4O4l4x8TjX66MSDTpM4lIg12F50gr2rChqtVdVHbOlOaA+xbi9zUPJOs71nMnHzh9kZnvYmGZO/adyYAWOmplJbD8bQrlWnuNyQbd98IXALSZgj7pF+XlV49UGfu5EC/f0SdIILIj60PVLai3lCjeRcqdftZDQzgmjGoHtf53f87K1oF9naw016+erBDFXlyvGFaelBePAgWaq4DquMkykkS8BSVtloi2FLcvyKWLIg5Qum/uKll2FKSmj6C7EAWc2TVGZxzx1YnV+C0hCunfe9Pj3d3/YYa0r4pFfkbrtAqhgnFyJZ4OG19VB2IYwgrq5y4HKWr5Ssu9wzfsO6RuTvdVMiZG35GpWqdCYTxmECdindvx2YBEU52UNcWcdzx8W8CTzPNJr2gK++Pie5VtEKIsO+S6vjbsXKmAVuK3lMuI X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: fdc346a8-1dda-4939-0d71-08d9535f7db5 X-MS-Exchange-CrossTenant-AuthSource: AS8P190MB1063.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2021 13:39:44.6846 (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: myzA0ilC3gdRyJFb7GjrvK6R5z5s8uA8ip/E5EK/6wGDap3a+H0L+dV9pU8yEfKv2c7sNs0wuUcO0zKKZBBwG7mdSEudzjUYHONs66L9TGs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1271 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 9ed33e6840bd..b6e65658b0d8 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 Fri Jul 30 13:39:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12411269 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 EB83AC4338F for ; Fri, 30 Jul 2021 13:40:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D31E360F94 for ; Fri, 30 Jul 2021 13:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239042AbhG3Nkm (ORCPT ); Fri, 30 Jul 2021 09:40:42 -0400 Received: from mail-eopbgr20123.outbound.protection.outlook.com ([40.107.2.123]:37764 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239011AbhG3NkK (ORCPT ); Fri, 30 Jul 2021 09:40:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gED3MwAEtKex1k0B+oitjSYKmEWrXNp7AP6kNeOFVK+ttkTQZ7mKSEkv8K5tiee+3bCFQbc9RMMp/m8j0UUIjErs74GOL796lp4BAeeHUrTiVdSaSmrkAKYH3fMy+e49hDsVr4jhvTtJSaQenVx4jfh+BpISq11JSzPPJ3EsjJ1iD73suihKH+VzTrPD2QaFcQ1hmUCiqBNJMhH+81Lo9RYZ+ZcS4QZd77KydYEGGVaxIN3yCkWiBhvUdd1SjGyFpRcyPdKL+nyuaNWgi0eHWn/+1NlvRPmklokhU+fZN1YPW9zbRbyxTbiyifpZrpxkSit4Tt0UOaw0lokU7Qn1iw== 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=vddhFZWo8GTPMKr7Gb4+5GIgWUP3/r0dzf8NPUO8yZ8=; b=Fd7VTVdJiT1w1BV9zvoMGBq4KwaLBZ/+6lnWwKih4krJrDUG4zaGjIz6/a1+lDV+4eI3XjOZo5OeoC2kNMD+o5B7+I3WNL+sLrj043v4oNsjICfy+deHei2HRQ3nA3Jbq02mB/y4AytC7ZEN5/KxfLBEvkSzP4M20l3Suzl6EIYltWuCkFL13JzfWD1Shs24N2gnECFUyPjz9FQMTjRKBSU4y5xRrAqZ2zkrd34gL0P5z7zy/Gl3ZDpuAZxl/TI1bQ6vJONVNY4VjHbC7U7Zxj5LZDIM9kQ4zV/RP6In1jHiF1gEJA7qI72GIRGmolqjZRlU9FN8HKzzSBQlrTbo8w== 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=vddhFZWo8GTPMKr7Gb4+5GIgWUP3/r0dzf8NPUO8yZ8=; b=jtS2yD/Dl31RlslKQheNdWllQyGZ7qMA2/3glrrS2TBqGZmJty2rXwWhmZIOXCWaM3BLFZHiMvqWb7srxKhCacTzk8sr4nIjWwJj54ikOBpMbE01sBXAsnfCzkWjHvAJqIWbyL1EwxeM6dVa+ugIIyRJG5bjL6YTlzH5HA5ScA8= 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 AS8P190MB1271.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 30 Jul 2021 13:39:45 +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.025; Fri, 30 Jul 2021 13:39:45 +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 4/4] net: marvell: prestera: Offload FLOW_ACTION_POLICE Date: Fri, 30 Jul 2021 16:39:25 +0300 Message-Id: <20210730133925.18851-5-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210730133925.18851-1-vadym.kochan@plvision.eu> References: <20210730133925.18851-1-vadym.kochan@plvision.eu> X-ClientProxiedBy: AM6P194CA0012.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::25) 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 AM6P194CA0012.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Fri, 30 Jul 2021 13:39:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 25ad0637-7040-45a6-90ab-08d9535f7e3c X-MS-TrafficTypeDiagnostic: AS8P190MB1271: 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: WhbAsttMKcFvzkb+UkLqDIZauDyTh6XIeRAeJ7GUYq/dj9KWiGoZBDYqbNNxVHwhO8PGVlFVWE/CI131pJdAEjKBFReK2CBUxibLynSTxwSkK1aOHJ+N8Mil898z30BPADMVx/GW9cX3tUwmgiSUzoXVN9hibcUkIMsb3HWjOjCKKxp8u+WCYQPuYS53us56C3pvAUsBkCrm58mDgBAkRY+C2wMZTR4fcN+vJk/+5ke3qKu4UpZEjZz4eMy5gsUUtfYyXE7BWkwKqRFgA9JvJ+RizkWpsfxUeJdbqkeQ18CCr4V/tVe31Io415VCRdfyWu7VPMMkOBLxd6BR2Rv7YF+nhtY5Mc9BtitiT0WPSwyGz6iM1YeT8khxHIiJNXClPEH9MLM80bwnbStJA7qxjj11hTDXm6B4ICc3R+5m1xz6eqTANKWELcI6j8eJn3KUc0KuHBu9RMX/mSEBtE7oTgZsAsgRZSl7rL963lD1WAi1MO+c8VGMW227WcTJCC4wJ/MDoMF1Mfk9neSRSIAoZ2E36WHAJxzc+Sw04pZlZ+Rq766Zi8vtSDyBrCISiXwKJzDzDhW6m6Pcc5lMv6PpVWhpc2Dn9mPOjcoi+sKJs9TYu52s4lpbFFXNaEJqugHazGW6YXeNhgBCVcYcFVy4ZemvsYOdEFiKs3d4DzlmjSUOQ4F5kRR8cygWIFbVUoFi 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:(346002)(136003)(39830400003)(366004)(396003)(376002)(52116002)(8676002)(83380400001)(5660300002)(36756003)(54906003)(26005)(186003)(110136005)(6636002)(6666004)(8936002)(44832011)(2616005)(956004)(478600001)(6486002)(2906002)(6506007)(1076003)(6512007)(38100700002)(86362001)(38350700002)(66946007)(66556008)(7416002)(316002)(4326008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MkK6CIaxksJaZp3ARtXSDoyXc1Ua62ubZ/h2HsnshihsoRtx7S6+JRfCbGySMO0JxxfQF1EfCZdXvOcdvarhP2eyz9XKBLHf/1r6u2/PR8wvoRml4F2WnBgmbk6dy0ey3RJu88VYmBuYohV+vBmCqJoBR6cR7ldSmIzBa4WNg6q9FpM9TZm8kp47Xn302qDKBUiau1zEZtUOS2u4NAwvQA8TDBi2IR3zLDkqwTMoYPdSTMonkiF9oxGVuf+24ThxNYBr1VbJRsP16P/u3Lr5xPxUo5A/vvvaZp+N2OzGQphhrk35RGcCTjqj/bwGxFEJgPP1OWZfKZy4mqTGKAo3qXDy3Yw+wiyv2BGbv69/g1zwHoi0ZaToDDGaQk+Xs3Stq4vVumr39MDjQmXYR/izNat4ULV1PkN3bpnyvfC5dpNVuxAiBHPkBHuNd1bQRidjq4l9tKDLqkJzQ04Bsht6h7mRC7f/sf/uGH73C1PHN0H3//sMVCoKvT5PjqJ3BLNXaNobfkbAxtggydnhk1vkJ0ETfVoDzwFxNtGVu5xN+CgMsE8BLUnXQYKOY3mBkds0sa5/6isWx8qch7W7hzU6du5IJ8gqLKtNfBPhlCs1he+YyafeMZRoFr02+Nk8Hi2fBg7w9/SeCeM/c0SW88AJbL0IQNAzy03dcupyU1Sxxv0siE7IxJTo2rA4URTIU3Yeu79saqGp7xJgq3LvgHP+v3EXyS/AABimQQudfq0lu+daGZXW5lwG+8uytPX4WM7d9/N+3a4vj0kq5PgXxRhNtspv94OWDlZrE1Of24LBbKRViFdVxCItJy9cbIEwApKi3QgsFNGEiBCIM59aapIiyyezV0PgvnqS4dIqi3s5t3baG6KCZVtdyc0AnuXrHFcAL94K/leZsq3sJyax9VeJ0H97zr+zDPfM27+XY2SPgtwJ8DOADpzSAu/4WBSNoO5j6RrU9IHNAePBw1yXAGcbOCEdWu2lHuiF3Bn5MC5c1HbvxaR1ytKTb/J09xeQKSI+D/cV5gD5cnKiN9+cONlkyvlfvR3mninurL+W5v74wG3qXvLzlKzqskqgQEm6c6TLql3PhX/uU7eTKj0E0X2CKynwO/Cbs0ZCxCMRXXFx5gk9IP9Iz19mQoValar5dhqakTzwlNJVm6tC530C5vY1EZ5m9qKAeTV1YnkLv3427j0ojQD10hxE5vNWA1tPGeOqQXWhwPhTAleTnVJd0mgysGKoVOq9l749t354WVt+s2yUKYc8EHoR5qdFEUPMWmpzDU0W9U2xGd4ql8m+bjU/tO1jykT5a9tLqQ/9dgOkbZJ8zt4h5NZXNgFHU354E7L9 X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 25ad0637-7040-45a6-90ab-08d9535f7e3c X-MS-Exchange-CrossTenant-AuthSource: AS8P190MB1063.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2021 13:39:45.5936 (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: kW/RdWYAlvTtpY5uGYOvYPkMJ38m0MtC5sJfBX1qSt90RrAwebquQUVeU2vjSS9H/1fCCXR8kl1lgZU+IW1JVfew+jFV68OfEauQv/St9FI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1271 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 Reported-by: kernel test robot Reported-by: kernel test robot --- .../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..2d1dfb52aca4 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) +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; } +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 } };