From patchwork Fri Jul 2 18:29:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12356395 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 6A971C07E96 for ; Fri, 2 Jul 2021 18:29:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EFCC6140E for ; Fri, 2 Jul 2021 18:29:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230207AbhGBScW (ORCPT ); Fri, 2 Jul 2021 14:32:22 -0400 Received: from mail-vi1eur05on2124.outbound.protection.outlook.com ([40.107.21.124]:46816 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230115AbhGBScU (ORCPT ); Fri, 2 Jul 2021 14:32:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hZjN/j4uNQfr+AmB2yIHKcOo9aS8emmRwIFRZnZvmPWwguDEb8lS8w09ss9N4k0Ib1d1+cEhUnGdFjmRmTKPJ/Egd1Viucw4KNBrpJXpXCbc5K0gv8YzQby1GeXFim6JkP+D8wBMOo6FZtv5tHtb2yXsNV9upZbiIkhIugFoV/dgFDPBFXtjH6cy48guV3MqNaoFbAwPbPySH0Vk2mSBqxfykKty7KxQa8rOo5yJnOI5hcIxx/oFQ0dB468lG5MHd8fdsK2fy71UK3S1UbNDWtsBx2AyjImj8iPuKeyd/+iVO/TyzuiOlwC4lHbgXJH/FxgzkyaYMW02tzUygaaMYQ== 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=kqPzlpAOTdicMTzRqKeWhL7ROy0/vIG20rO0ylBzRTo9y609nFsqofoVYJHVhJExmo+gvONRUa3golP5vZ8nKGUbMBd1DJ7ospi7IqBbOTg5hwhFQ5KQjmnH9z9u7A+OOuRzMGsAL133Vb4hCO59bu380WlQX0zxccZfAUkZFUCS5iiGQ2Tn50xk+S1PT3+DILl8c01IOZ3HtKQqAdsPdYqA43r3R2pMkPOqubL/TCD+y1/8F38pjUZXfSXA7RootO70L/CsjXzBBr+DYtjNtAGzgQ0dYT/Lrm2kuoUqxeFxfFti8wHt9hixMsLMVEhM5xYtGZyg1zqiPwKYXtmVBw== 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=OEiY3kSr5bR1ZsbB310h+hAFxys3qCmzAsLCivMV1UnlBiRs5ye9Y8CMV3bnvfs5OGo9Kh6TjbEVspts3V9DdsLTiRvmCHZtPHjyLEGvcd4mHlED+/afZZW/pn+mRHoGjYTj9dYKBUfELu6ivf/o4yiYbe4ngxuhQMxQsXKIqGU= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) by HE1P190MB0394.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:62::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Fri, 2 Jul 2021 18:29:45 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::40d:b065:3aa7:ac38]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::40d:b065:3aa7:ac38%5]) with mapi id 15.20.4264.032; Fri, 2 Jul 2021 18:29:45 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Andrew Lunn , Jiri Pirko , Vladimir Oltean , Volodymyr Mytnyk , Serhiy Boiko Cc: Vadym Kochan , Taras Chornyi , linux-kernel@vger.kernel.org, Mickey Rachamim , Vadym Kochan Subject: [RFC net-next 1/4] net: marvell: prestera: do not fail if FW reply is bigger Date: Fri, 2 Jul 2021 21:29:12 +0300 Message-Id: <20210702182915.1035-2-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702182915.1035-1-vadym.kochan@plvision.eu> References: <20210702182915.1035-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) To HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 18:29:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0604c0b2-2392-404b-3213-08d93d875d9d X-MS-TrafficTypeDiagnostic: HE1P190MB0394: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n+neQMYGYgMAa2GB6XLErqqfckKvo/OrKq8/CRgshex5r9iPcwoYmQpDtGJltDEK0x2O7TQOpiRRl0aTnMJEjpnvwqi7NlPjRN8iKQR2TAcG7ULzIzXuV88sw1fosqs9dFBHABQbJxjr76z9fB5CqD2r1JCmJ0+bYs1/gjAbzERlM7f3qjJS7AcdOJIP5oXyUr1bPbvS+xbz86qcC3DOoL2qsbY5Kq6r73KFvw2UelUp1v0ru/1ZSlBHbqDz9j0knRRu3QOP5Xr/RZnLfob2q1AWJ3wDv9IdHRF3uVXoJRKgIqYl0gVeeJoi7YwC8ZhsZW98yAoqw9bxN10fTX3VbzzR9qtCCby/KPmV+YaQYegnUytx1dymPU694CaAnnqSUgHnubWIIic0/TJICrBwSa5XSqxZ7RayhKxTGI3X1sOtO/dQWGzyefzsGZiw4i61NBPneLEY/his9t9OeyFWcIy9BjmztDBP0RlqaFOjf1AiGOp1PCZ0V2kvx5vlHqtOP/ZsmvAwrLpE+OusL1uDFU5bCdeKf24TwcrDmO8kzsLhKRBemwdb36VUdKmz7HmsxfYfoJ7IpGf1SjyoC6WTnHvJ0OrtcB1Fn0u9YJ/LZcAne11zN4Jq4kr5FjIQfMueFPV+lFdwr6vnCjKg1sXxwQih3Mgi7Nd1JtgEIbXzDDb6urF8ooVQOZ9YXhXQddblOJMg3Ejb/vVNT05e3C8N3gF9/i7Ngb5KgGqTjG/jYwc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1P190MB0539.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(39830400003)(396003)(366004)(346002)(376002)(136003)(6636002)(7416002)(2906002)(316002)(110136005)(54906003)(44832011)(2616005)(956004)(38350700002)(83380400001)(86362001)(6666004)(36756003)(38100700002)(66476007)(4326008)(1076003)(6506007)(8676002)(8936002)(5660300002)(52116002)(16526019)(66556008)(6486002)(26005)(478600001)(66946007)(6512007)(186003)(135533001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P71OMki/uARe8rkLvCjlY0/KbFWOA24y3uGqu2JtdziELIyqJoJieFdzqV9lNrPj1LSCEm8JqHfyBHe0znppm2Yl4DebSY3adOTvslE1N7F9xa5hoIf/u8Gd+mgbctrWwCMCWCHekKwE6mm9FF4IRB/ngfoyQ3SoSeAgZTxjhB02sccS6edeorRRkGBM4LzAv/07FVb5kt7RFGTzzWGcfu90vFAsNlRjkRolMTA7r0Z2hQ0NuQghbIWy9663nenYn6ZF4Mgy2Tb7n8vzfjlyFz1vDc0pI4+VaelBZ+jGppKmSVc2TfIvgYIv7BP20vvohGZBjJELTi69M8JfyaAvh9/L1EqLBr8UUAIaa9fr1APJw/9wTRZxV2R8qnaMjni0vy6I7j7XcZE0hgDAwK1AOqkyImuYPCzT2pQH7gazTuyfX+7my1rCf1sBMCQfG88A5arjz67emeiCAFVZsU8sIMHY4TF5c8ZWp3EkD2+WYKYD9g8J4746sVF/eFWRvFroTqj2E+32PUjFpzTNEVFUvpUEC9q9P94bPSLwuum9Wx70BvQusMCBBSKLe2m/Ldx3493EyYI9Jsbht1aql6N3FR5/F6hbAnjarHj4etunlAP0JSw9mUd2gNeegCoJCuO352Cc9kTiDREnSpG8G2tArRvu9ETWeqlg954oBvcslVwQ6f8Mv67CJRe1iwwni+A5yik3OapghaKfi9U0RvkBaqdnF2B/D8HUDvbt98qiAMy9Mo4YgXXptbne2MvZV6J9u3qELtL6ttwM37kn5l/AXtEQrmc48qx57NkEfgXtaenFPx6zzALgSRVm6SrSbpLarrhcNfa98QTsW1ri+oUX4hbIle19fYeP4AS5spGXfcph4CHzwuDjVD60/z4BaHeJ8ucRz8n13IZcqlvFhqLHE50hc5+q7AQ0gQv57FZucTEzasg52YWI5zYj5lnDMhl/GTYF+sXq579Ou5+tkAa5ciBOy0RXGvsb8ny+INYb+8EeafXICKCAn3KSOVOC+35soJUE7Qyz8FsaMDE2W/37+ol2tRBwszPmBp5MdRpnLTxdsVHBnJZxiDnGjFOGktqE2pjqhvMlPmTfPem6u/3H1unGyAWtFrnmnRRao6d9hke722T5jP996CiokINO6J6sXudbKb6dovrrwcH2/Zv2/W61jMjqR0fRORmwJ5FhD/W8qObqeFjr8yPS75LKZoAbJMiKnxMMQQwiWyK/fJn4M9bi1OpxpYJza2VusQPdwO9pSVIzdDdqwx5yVuTdbcmiGevBggU+bOPUfSFDGCcqsBm46DVt2lN5Alj4+VP59CrymYk53j4FbXuEwwlj73xf X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 0604c0b2-2392-404b-3213-08d93d875d9d X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2021 18:29:45.1877 (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: p9N7QkkwsEcP/4imLYh2r1GXgd90fObsPQSiTlYjDWT/unVXKRay9L8ScXNolCEuYb70y9GWo0qtQkiOmWo1RDcyey+YNrDOW/tfkqLveNE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0394 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vadym Kochan There 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 2 18:29:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12356397 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 64E90C07E95 for ; Fri, 2 Jul 2021 18:29:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4793361411 for ; Fri, 2 Jul 2021 18:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbhGBSc2 (ORCPT ); Fri, 2 Jul 2021 14:32:28 -0400 Received: from mail-vi1eur05on2124.outbound.protection.outlook.com ([40.107.21.124]:46816 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230119AbhGBScV (ORCPT ); Fri, 2 Jul 2021 14:32:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UB+og3lebGB8DQLfUCvqnurrTzekQNXpvfDfwFJ+51nPFjAwn78xJ5CWBPFm8K+K7XvxXWbOuZDKJ3mAMdWsp/3pJvmHD7WnFzJyX6MDtX+2Ljz8DM88Rwbl4GFCp0cMd4z/zJkHyzzp/uMMKwhFC13SWOybQIT7tZn6cXiUI58XgqiLtb0JeHzDLTOnByMbyw6ujaYTXctUfBpZxbThFKmQgpBVFsWgqAGVWcBy/qXQ9wxEqSCuPKZLV86bO8qyaP9wxYmfuH8IGM+7rt3ZXKYBV+mkVhte6kz2LM04ZBa4/oqb9B1F2PhxCz33pPvIMopvFqGMPruieMwMiVoPzw== 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=ed6pFY+YBLB+LbVtoREdK5GZn2zLXZtk6CeO5dUczRQQx7pyG52e+GtZCeQbnoX4MElK6UayPfFuFEFxp9lOtY/3PBK4cXuxjydp8HNU+rKnDy38psVClkaw+roYmgHf9xQ0MGGYjQbwMzfkut0fF1LJAmZXkmTSX7+IYbcVZoSbO/tmCCXx0J1o0nno1kanTh4f6+OHPFQVPivW2COzswyN2NkYGQK4/bvxuEF1OqUroWyTl4PsQaAtaPdGbdytgDgqR+dLcp0eIy5WK4ZCI3CgTXwp3zy2M9PBhTHOrbuSkwIzbqz+NPN1Kvht4tTadIc+mtaWE8xu1uXDrI6utQ== 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=wM+aYHKeZ+YPVcin5Ok3N3GkfrwegIxyKPay7XhDB7PwAF7GHJxfy7w1BeM50o/Fqr3XQC7T5bxYWXnBlt8IMG6y3ozmWDXogW7h5tKAkCxjhEmYA1lI7w6l5VNfHfZt+tO8Z+ynyKN3bbLIOdfe6hv4ng+8v/F1f787Bm1I1Yk= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) by HE1P190MB0394.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:62::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Fri, 2 Jul 2021 18:29:46 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::40d:b065:3aa7:ac38]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::40d:b065:3aa7:ac38%5]) with mapi id 15.20.4264.032; Fri, 2 Jul 2021 18:29:46 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Andrew Lunn , Jiri Pirko , Vladimir Oltean , Volodymyr Mytnyk , Serhiy Boiko Cc: Vadym Kochan , Taras Chornyi , linux-kernel@vger.kernel.org, Mickey Rachamim , Vadym Kochan Subject: [RFC net-next 2/4] net: marvell: prestera: turn FW supported versions into an array Date: Fri, 2 Jul 2021 21:29:13 +0300 Message-Id: <20210702182915.1035-3-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702182915.1035-1-vadym.kochan@plvision.eu> References: <20210702182915.1035-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) To HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 18:29:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d465d096-d4ff-4dd6-b8f9-08d93d875e4c X-MS-TrafficTypeDiagnostic: HE1P190MB0394: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:346; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qZIZn5pw21+97dZZiBJkGzFzAkRVoXX82LCfwoIAAwyp3X9ZMBV9IE96G5yrfAXNM/qYzGJfSw+w8XpRKr1j9/rHgVtM+17YSDDlw3UY0wZvpF1wisZtCPtKyz8XUilh2rsnWXNzEXBlSFbC7DHcEJPfgmF88TSYPx8lymDaR/0y6MvZWjnW/T/PWSiuFwcJII1ad/Txes1YrRCidkV/3mKzpQIqslstnm6CQDX1Tewj/Jsh1Nkk8kCK/fIL11hFxx6ergYcsOG87L5MJ8zMAgyFMIB/cE2PN2GRxfqqgec9J1Lyu9SJZIV7ptjKVd67foZyj2G56LktB6Cu7AznAhybIYADVOUO3GUjzMR7QTy+7T1bzpSMHTlzyxEcScWx77i07pERSNxieEBJqpDo52WsmOlut5aabs8ouFhA3A3nKMPbBcUSwllW8Annovvjyj/9MVCylOMJyIQZL3CU/A2TOvf8Q7kt1Pss7gfk/ldsoGIQ+tMAyoztIXHTS8z8Hr1yVClM0Wt+RX8yPUkyifKa+kwCqmpxaIamOpbrD7m1KXm7Lb9IzlATgnyjmkoE7TG+8qSVXSL5rCRGAR95mHX/MkkegMHPQnQ8q6WO8Q0suuIgCtH2CyG6elGzhxYAvRepJxmSB0eKIcDP7X4smJfXo2Kz4LAtikzopjmTQU7j4a1h0QtTXEvk+00h2Rg7QSXn0RF3kS0XY9LDCuljRQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1P190MB0539.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(39830400003)(396003)(366004)(346002)(376002)(136003)(6636002)(7416002)(2906002)(316002)(110136005)(54906003)(44832011)(2616005)(956004)(38350700002)(83380400001)(86362001)(6666004)(36756003)(38100700002)(66476007)(4326008)(1076003)(6506007)(8676002)(8936002)(5660300002)(52116002)(16526019)(66556008)(6486002)(26005)(478600001)(66946007)(6512007)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gmY1UpY7m513fOVW2f09PmzR9C/NzTq5oyW+/d+CZepOMMr3M3BtsXy5Ih9k4tHdivi+DodmCiPgQG6TnUqVS7pRBwazvlLBN+H5FMAYVskmnZUWlNjf1XrS4nI86ZxhIwMyfZadpIdGLTAKNUYGoUqKlZTjOYj7h737zgtdUieuKRNwRSjTSAuuvw+OvwPpjuNrWrIPeaJI+nNXn9jNFh2Oyr2knY8ufdCEhfWml0O4XW7FRc2KorKas+BAuf3PnCFHA651BhVhCRlXCTOqycZGMxD0BAcrntF+N8TJ/ms0JzxoMF5WbPCcDoLuz6cse1kMLpc0SoZVyhPSxeQT4h0lTZfz1RrB3V2tRqYG+aOuDLBEAomCkrBRddW7eIRsohdGnFyrtKtJ041cCZwiveztE5g1ZKh2Y2LHKX1FBXrNHleCLpKXl9zIMloZYVKtAiEyvXduQKaz/f4QKthPiXygfXa98sZKUB5UVstzHnz6SQUKEm452AzQFukHG3EB/KetjznpAsgMhH9w9ByI4TMMskFEKoRHMiEpmVHzhOnMlAFpIoaYLe3/yDWpayI4LwAgXy2sFvN8Bs2OLELUMK3nIgs6qEFR5myUBBwqKicVtNUbZ6r/9qhQ9dla05TiYC9MsCsxLvwvTirutJIapo8xaaU8BbL2HbJKG19cpRJKqrLG7hjfKRcyitQzt2+N977Ud4Vf5iCmeRqBH6YwyVa1HCyRo6CQiNnlwRbfQa80abFSd5Uf8lkeILzQmvL1Gs5YjQr8FNvoa0h6V5TsHyPOaHre0zuHkuIlkNHj078SHZTO0UcfFgx1S7GAUQXfj/0fASgoMmmgFEeQnXP7b8mA9aFugFWI0BqdD9m9o2ABfuajMWI4hHiaoBq1RMZYyjrTAs25l2Ea5LSITN3BgDMAOwc8ax23skt2LxlzBY5ui6KTV4sDamWy6uGeIr5fKUWrknWx3Uca9VPc49XVxJZ6Iif74USPDP7QhNMPK2gvmgRikHnA6eZOrOOFOionOTCFDWH2uw9nvLrspNaaMKSxSm2RU6JLZb2dxU5CdZWvztt7fT/M+Zh1ULDn1dsfdW4CpzzYLGHYN9FeEtzAb8dF/VX8X8NIV17tojjV2oHA/1+l+IEEmAMW0xzLX4U9NInB/4GUtWT2TEqt6LSqFv8Emqf7OmHun6KyjxPwJS2E103bwXsqElHh7SuPK/iJSKxyfUPi318pI0ouLwCYaPwFoDaSyE46XAVfqjY9wR10h7/3Y6rcwwllPZ7PUqLuynpL5g4G4PDZ51ji5sPznez7lHqpoTTv2bW+014Zg0vywZ4Wb7O5UOjJxGw1MHEb X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: d465d096-d4ff-4dd6-b8f9-08d93d875e4c X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2021 18:29:46.3050 (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: z/BbmvnTQda8NIJ9LaeCOjxzlFNyK+Pyp+5Wgu3RXlflHwdphXfFbOl44aykdLcKCEE8/GGEuOteTehyICZ63eB9IjasMmNYDkigONdUPn0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0394 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 2 18:29:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12356399 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 918EBC07E95 for ; Fri, 2 Jul 2021 18:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 754A461416 for ; Fri, 2 Jul 2021 18:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230334AbhGBScb (ORCPT ); Fri, 2 Jul 2021 14:32:31 -0400 Received: from mail-vi1eur05on2124.outbound.protection.outlook.com ([40.107.21.124]:46816 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230185AbhGBScW (ORCPT ); Fri, 2 Jul 2021 14:32:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hiN8eNOt6VGnQkrOpx519V8RB4YpniVO4u8F5TsXE2NC/nd7Eo4kQxjZqpAaGZwe/SYv92mSMDpKoK+mqeJE0NF1k9QIiGKbEfd90UhgK1NGdlk216PcxfSjf40OnbApJAAcl/EyGSVdTzGlJhdcaAnK+kxynGHzWeypQ/1KbhxK9P9m5K/S7m8roN/JAp8IwK5IvkMNTpXzcgwMBT6g9xEwUkWIhA04Ck/PVzAHsSnLyr9CNBM/9eJQvDPPgNyWe5yrM4qY56AuGyedOJX6U+DsonJVgE12k+yy/aZYM0XBkVMqzV+Zv+jMo+puSQKvFYMNKv11i1fsxY6KpvNXjw== 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=ibGAMwtwAnEfaYyvEMS07uvn7AubVDODrfmkQ47esjXrfBKmqngRgvEpoOPKfFPK5FKqsmNcuk8dlsICatekLPzcTWlskURxTmuwlAuc5Gcnp1kqD1SdLBogHU1R+IYJRdkXKsIRb8yid0RQslFsE0G671N9U+8Dx0PkuHbecli6APrz/LXMEo3A7VIkLpI/8VuyWVyUrQbm44r0L6b4m2zvoEtnN/MXnS+O/6ZsIo2XhUsjUAajnus3rhWVD96RZrFUNP2z2ToHQ9EW9zorZP1Ybnr3UKa+L6yOoLKVMjs9PJRj79IbK1S/USFOK9VHZ+0Lvshy30jXFP8aCDULBA== 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=LYYb6oY/QoCMajGxDV7p828J8zAy5JOaIGf79033sDsdRNlA3YWF4O1LO+SASiV0+gpEYeA30q9V4RK0I77Kn2Yb4tMB/P6pBoRDPrAqpPGPuNLUSUNDgQP39MDHs6q0EACMoiHEqg+DB0xyNk0BAq2CjNH42sSogQWYEOd0++k= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) by HE1P190MB0394.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:62::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Fri, 2 Jul 2021 18:29:47 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::40d:b065:3aa7:ac38]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::40d:b065:3aa7:ac38%5]) with mapi id 15.20.4264.032; Fri, 2 Jul 2021 18:29:47 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Andrew Lunn , Jiri Pirko , Vladimir Oltean , Volodymyr Mytnyk , Serhiy Boiko Cc: Vadym Kochan , Taras Chornyi , linux-kernel@vger.kernel.org, Mickey Rachamim , Vadym Kochan Subject: [RFC net-next 3/4] net: sched: introduce __tc_classid_to_hwtc() helper Date: Fri, 2 Jul 2021 21:29:14 +0300 Message-Id: <20210702182915.1035-4-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702182915.1035-1-vadym.kochan@plvision.eu> References: <20210702182915.1035-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) To HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 18:29:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58b7ca91-2354-4846-51ca-08d93d875ef4 X-MS-TrafficTypeDiagnostic: HE1P190MB0394: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t7bVH+SrmmUftatcVCQ6W+3SnhW6zMz7Lt4HXvLM8WXzk7Fe3sgug1BC7dRznk8XG0LoevZLpL4YV+Gdw02zq/k8RiiZoZoSi7f3blPnqsHEK4bUXWVngtJLdrd4O/O3IAZWSTelK7MjOVv+ljWVylvB5LlKv+Xy5+WYIxF8wjvZNFQEzI84Jqer3mAs8y2x9gZ8dEBek5I7bx843v2gDQoMWZSRAEoi+DtCCSc6ym9o+FrhiRe46V0BVQ7GiY/PhZBohyLFsmTa6Jcc6eeF0Z8LanVcAwmwboIxhPEBklBOFuD5jrUJFtXFUqbTUXay6+Xn4jyMvKnIxGFVXzWQNgrYObN8zM/p6YfIOBidQBkL2URrfeaZIsQGfaz9W5ZeaY6iI4/SDgeyyIwEffNeumKj4eJQEBJ2QHo0fMJ+roBLcU+NUQ6GKPTh+RKA867G9cMeBkJAGRsOXESz2e0hD/gqpwLFFmNdKccPf6hfUSeKV2MX2hRxt5DW1mF3Ru63lqsdkaBPoF0w0XA83g3+oRTm4zY7fzmJnhV4l+H3udlTtczx63njuF3Ql6d6qzUg3EpkbkyQcINgwhIjYVJY2+WqvGQ4E5uB9bJFyhfT6pcXBj8XUwv8rjtDWjmci6K7IgmXx3G68e62Qa1CmNTgPwJKtsRYT7fhKLsQvjdbWJIS09yvn+/GESfCRH63GFw+WV50DyeYp01W58j0HZPbVw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1P190MB0539.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(39830400003)(396003)(366004)(346002)(376002)(136003)(6636002)(7416002)(2906002)(316002)(110136005)(54906003)(44832011)(2616005)(956004)(38350700002)(83380400001)(86362001)(6666004)(36756003)(38100700002)(66476007)(4326008)(1076003)(6506007)(8676002)(8936002)(5660300002)(52116002)(16526019)(66556008)(6486002)(26005)(478600001)(66946007)(6512007)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 57lsg2waCyZLmhlNs8xZIbON9U/j2/T4zo8/nvktpn1gj8foIlw396bKbO9CTSnmx4CaonKlWKwt3QnvwsyTX2DMzGaQT9E8rB8/XuxWVQ6gbLU11C11yIBfF1lPTAXiotr86xNCqXutwdZLkhCy//BnHEF1XPR/ZYkLUlmUWCEHHSqegpXxFyu8QptOPdYUi9i5HRtigNhOAH7+4JA3XInnQJVOc+LP94n+BR2tgQkZEpkwtmTAc13dtkPjBsi1Do8/S/fBxGSUG4Q/OK1quie/Q0A529S2ZscBSQr/aq/P8kuhDAnopCur1kiHndgrSD+gqA543+RBGCwdlSrHmqEG/Q+nwg9Nlo8oyt3sneRlNOQ6WH/OC4MllONpcFPOxJXVjAO6zcCNSqLKE+WQPQsgDNoavAglY3ReuGLayNFj32Cbj0ZEdEcf2uRqg1Ar1tn0jkbnxb5OIaLdgzkUNSygukA2qmKH80Q7d0jrL/BY+HOgzdKdy2c4jRSqLdQSahAsLOyoxEg5WIoJm4X9taA6Qh/IYlTOECL5GEqYhr34JNEIwj6S9hk+B/F/KbLtNsZvhrmXRVcwIZ2q250F0tW3RfqL57IYIcLCGX8ooWIWRv/4Lj1b4ONghpgOn/EdpqhdBvpPrFBRQu8OCCHYjyiSixVNBtXBTukz4a/K15U99e52VC9ah3jFHrsYLhKhSTWgqjjcVV6iBkCdYSGq2GKvKcG2oyeHHfZMymS8TKX/kt/6Gtllub6tilRLUz1OS60YqiDKTTMgCsqOfHOP50wycg5oEtvqMThXFxNbgJt/A3z5S69hRANqwlh/TnhocB3MDDgb+gf85f0caNX8NOmAJ6Dhoiz4iHOD0nBlu6NVlXCji7TCxZAzE+MrvTaePmPRTzYARgXiAJmfPURVrhNmzN+3U3MUGXnG0XK1dVoOea84psjvqqSQEwH/lRGuWmpXSdf30H64wwuqyPdz6EMOOAbb8PNyQeHSj76qClAUsG2UawM3CLIayP1TpFBX5s6WWaEp0ar/DPbSgAxEOVmrs1tMVPdhRcG+fzxRG+SbfG3ftwFD3hK1MIV1W76hF758pQxP05jm+8bmBlM360QmdnMuDVBwFGjI8UBTMymLANjlS7lsnTwIPMW0KCD6XJG7dCwJVSvUB4RbCbLTm159uEJ+Nx/HhnErIIpycTUibTcXPJ8yGwgpq3aOu1Nt6HOJlWBdRb3GpyMfyIoRxOV8d5ROM+FEVKzB6/18Ry72QxDO55C9HrLoSxV1UYtZ6yW55YI7yytCtud569GO1tcIyb1u0K6GA1++bgbHcngZmywJjt2l2KU8EXc42bIl X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 58b7ca91-2354-4846-51ca-08d93d875ef4 X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2021 18:29:47.4364 (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: 49LVlUR1BEKuXDPwBbjnh4H8V85wEcbTrX2fRRPnvnlt5AMg3Eb85hTuNqzTFiuwHAHeQsUaIsvKup2DKSYvkSOCqEy5aHdRqhonluNE+5s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0394 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vadym Kochan There 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 2 18:29:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadym Kochan X-Patchwork-Id: 12356401 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 0C20DC07E97 for ; Fri, 2 Jul 2021 18:30:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E64D861402 for ; Fri, 2 Jul 2021 18:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230288AbhGBSca (ORCPT ); Fri, 2 Jul 2021 14:32:30 -0400 Received: from mail-vi1eur05on2124.outbound.protection.outlook.com ([40.107.21.124]:46816 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230225AbhGBScY (ORCPT ); Fri, 2 Jul 2021 14:32:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UOWv5q8Ba3y8knxrZxBIQfTNj9sJj49qMza9eKS87WFP6oKZCyJVH6MnB9KlVHIPs5LWcuE7GQGRG/42sfy5Y10G/3dCs2UESu2WSMIREJJGHKtGDhEIlC6QiooTuljV0hdVu+2OtZcWdFQBHN0PUDxRV5uinAIITTPkEUExBEeHWF2octfg2ZvsFFYmBRcTxDYPdNCURJ08hiaUQchCT24Kc5UnZIn/srVIcu/C9ur0+G1VwlTZzr5Akeiu113eJpCr3ujghpYWHiDD5E/JCYOQvZ3amst4EBi1wnk6MaHT8RuNnL7vtsZY/mW64jaO3RPHOzBG7wEjYBtJjSAWTw== 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=Ty9ar5LrmdiN3HFCWem01wIFltNebEPbCQUreUsqe32kSMn9JurbDMYPd1OSzciFWAih7M2LPNM0bh5oGAMFxfbokZn4mAxcB7xFnkKYopeHaKbVwabrNJaYKtQkhdBQVU/8R4tEKU/tux1bU0tPmABTwc3IvS6rcnJJ/87K2fkztBh63S8NNiwDlTbaTT0GPfL51bhAFr9YwVWal6C2ZmpYt034WR1UkyA4dEUQRI4QGk13o3NI87OVOMAoE8awkgFwAQS30JkIF2k+MuGSaEdeQfe2z/n8dJ0puwzqVF1Kx1diybQrGCR2MHoOeX0nMtmJL8WduQ4N8C6/loQonA== 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=iHinzJt4W7JPGhPcIzXp+LlEk5NeJCvgBOttjktkiszweb8MUvsJQ2x+RsL3On9YWVNwf6QDxdn2QBy4WO7/26CgQ8Cdmvij0U5ySQZFb2PrllwqQWSOtCfiqIktwa+D8Qj9009K6lpXqPbeQzYqPi96SLNoBMe9UhMPQgDq0qQ= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=plvision.eu; Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) by HE1P190MB0394.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:62::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Fri, 2 Jul 2021 18:29:48 +0000 Received: from HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::40d:b065:3aa7:ac38]) by HE1P190MB0539.EURP190.PROD.OUTLOOK.COM ([fe80::40d:b065:3aa7:ac38%5]) with mapi id 15.20.4264.032; Fri, 2 Jul 2021 18:29:48 +0000 From: Vadym Kochan To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Andrew Lunn , Jiri Pirko , Vladimir Oltean , Volodymyr Mytnyk , Serhiy Boiko Cc: Vadym Kochan , Taras Chornyi , linux-kernel@vger.kernel.org, Mickey Rachamim , Volodymyr Mytnyk , Vadym Kochan Subject: [RFC net-next 4/4] net: marvell: prestera: Offload FLOW_ACTION_POLICE Date: Fri, 2 Jul 2021 21:29:15 +0300 Message-Id: <20210702182915.1035-5-vadym.kochan@plvision.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702182915.1035-1-vadym.kochan@plvision.eu> References: <20210702182915.1035-1-vadym.kochan@plvision.eu> X-Originating-IP: [217.20.186.93] X-ClientProxiedBy: AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) To HE1P190MB0539.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:56::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc60716vkochan.x.ow.s (217.20.186.93) by AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 18:29:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f04c8fd-5469-470d-c6c6-08d93d875fab X-MS-TrafficTypeDiagnostic: HE1P190MB0394: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lXbomPMS/XJE6GKy+6mtg219UhGqo1UneG8l9ujY/+KjHC3n7wy5A00OXIUV3TE+yRKdSXvCgkOpCLegHEPr7Zb2EuCRLQxo61x2MGdfzwl5WTxMvrlJH+is5ANq9IBjAK5UjdcYYCrMBWYC4exGjIpTu13oahUT5DMRqnuU6l9NT9Ixvod7gN6rCA3yUkuuSIyCCGGQLE0qTLm9Iv0onmbc4sp1hxpb1mOiREaD+oajsZNIPCATfgI0In38hXBFg5iGSZy+DQNI0o5AAPJM4lwwgBzSZ5ESF900tpR5vqUVL6UA3+gbwKhXjEMkp+B4viqvUd87AiFqml0HdHEV5IpVji5r2+P1Mt75ywDFiIb4TmJE86f7Gu2kprABKxSMXQ0emz+u8W8vpaaN5Kb9hNsjlLmjRsLw42tFi+nveQxTPZCRl1544vh+68BfuBcI1f4UpCmrFOPVwcpIBcpy/5DDxy+VMRObYV3lBQ3BHmiEyMj1kb77RkzbvDqgvWTFOdekYMZmmOQM/McDjcko1LnbgoUArel0wnGfMFS5D874TRaUZY0lNbhr2vafpMyhQ3Rfi+4EV9uf+jQfmjnK0k5AWQRI8F+rmXtY1VEClUjfTuNoX3PUc9nENGCtwXkqcfpZ4iK1Ey+yTC8UuqLC5Tb2uYyptDDfu41L/y3jVIs3l715vBB7OKyXCOCgUplh X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1P190MB0539.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(39830400003)(396003)(366004)(346002)(376002)(136003)(6636002)(7416002)(2906002)(316002)(110136005)(54906003)(44832011)(2616005)(956004)(38350700002)(83380400001)(86362001)(6666004)(36756003)(38100700002)(66476007)(4326008)(1076003)(6506007)(8676002)(8936002)(5660300002)(52116002)(16526019)(66556008)(6486002)(26005)(478600001)(66946007)(6512007)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ci0hWjuvv4VEgbb8I4R/IVoXFiRkduUZKgMlA36R36X0klwYy6oEKtt0317iSzznO2Cn3PM83eFx5L4D3YHdYNhtnpZ4duDrqDq+J+v5CSYckxUgGoREZQFuFI9mFKO6n8yLw5bHb5tyPlLuYpQqEtE8ONl2+L8+QzFNQFfkTPaEMOp3mimRk1tpIjnZ8nUPQRUOpLLcg1HHxXFITDuSRg3ObNXkKGFGZUrpUbtw7+tI1spQKTBXjcMpARr0+7eT6GRt3x6NN1FAmDUAd5nwambmvmobUHgLxdhfoa3X9TLwDnv6MUNmj7R8QY5Fw2iz1DsAfAMmcBRqGi5oCAh+d4TmOp1xcNdrsN/Xa71YyJDyGrVtBcWvE2HZUPOUbUphDVKpggdLyb2NPyY4Z4OZCSSjN+T0Q9fK6i5G/VFXn/dp6iC1ZUJXgWFdIUF1P8SDR73G3dJDNsQRAe1NoHnK4miwVyex8WrgzlYPK7U296ALjpZ1go5Dg08bL9cyOzSZBUyWDQFhGl1wpmE3A98aYxHL45qqzRardkl8eA61MWgFePXfiI5y/7V1p7SFARKeWqGolzx2RwmoyHVQXJCg1dOPBg65NhBR24X6Ivf2u/8ASq326CX3XvHZoUxaS+cEL2RlyJpd1PO2o6hjysClxAnXElNwfMoA7UAIO8gjYuK6HXrVQXkQ+2L1BNkTGGub83wg0hGxyCa0PXdQjxRcZxgnv7xbhJVOctlgt+8zV3Q7mMzz6J+yJATKgMuv2F29oOHz9V4lYn042aynlhWVMAWKDQbiXG/IR2kw/Z32n+pNz6+co5CL0iT9F9AHg5StPEQkT09NIPUvgMQlRHyg4uhX2sSTzWeyjcjP703Z7+oDC2LOFfXLIvCYLIBk5oYJSqyaZg6i32l0sQ3UB9+IcY9V0Q5BpWbYGAihZr0Dtrwl5JJs4RguuJFKbO/2jBBoDYqDO6FzKZSYhS20WGUAPydijWTa8Ddeak0HEILVaqy2kBuRsbBrOO/wdbuBAUIYvBEGbdEXQqtcXV2WTefXA/7mVrfz7d2PU/63mswMPtP11ThFWukmK/Xy0IIS3+ucpv2+TFBmKjkwBfCF9agn+8ku7ohXF9bumlAeHH7fshbKmESnWwuM+u1ZU6RZkXxQGvepe6jAfd4SSDtfvovCWV8oWuX//D5KkvivpHRubCpg5/MPQ0qQKkPmPi81X8GFCv8XT9OLqlhtAew0EvFBCXwLU8YL+r6YUZxyrOyvgKNLA7vdIyy96nKo/vH6nJUE652Sodotr7E5efjsnHy/3j0OWh2x4vVNAOSFxEqUIHtCTvNjcQH+azNtvHS05VWg X-OriginatorOrg: plvision.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 2f04c8fd-5469-470d-c6c6-08d93d875fab X-MS-Exchange-CrossTenant-AuthSource: HE1P190MB0539.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2021 18:29:48.6227 (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: cl6dGTPxqThgGKufbd9wLEpv2xLQYwezQ3r997M0F3Z+FH70YysggXBKXgpkNhogTVTgL1g1mju7P1S5DSnSP7/EpZhmRjvn9qZF7+jCfBw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1P190MB0394 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- .../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 } };