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: 490607 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 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: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: 490608 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 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 } };