From patchwork Wed Mar 2 16:31:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12766275 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCB23C433F5 for ; Wed, 2 Mar 2022 16:33:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230164AbiCBQeA (ORCPT ); Wed, 2 Mar 2022 11:34:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242730AbiCBQdp (ORCPT ); Wed, 2 Mar 2022 11:33:45 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2083.outbound.protection.outlook.com [40.107.236.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E52A4B877 for ; Wed, 2 Mar 2022 08:33:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cFFasxMwhh43nDXGyNh6ia2jSeSpHGqPiN/vOZgbxlnn+/CMsA8mBCA4tXkzKnlwkyrx5wKnQGfbsUiD4DVixJxdoBP4eTg+bSWwEevpyGnsf29pBf9dCsJx3KTZhYr9EWMO/ymuP0QU2baE9VyN2Lmy/sqkUinX82+fvepkU0i4j/C3zKaBfUevyZ2AO94jf++rDC/hoJKRKY85DC3ovYnMqJ8B8tq4gWowgGodz8xZ0/LoYBZSw1JWrUKVBm4cPKjhU6RmfJLEV9ABbwBSfsg3qSFrB27kq/I4B4kCFyaTW8LR/CMhCttyPEzp2W+OeEM1auUg0UXvcqOwnR/M/A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yJ5oktitWkDDvYvGVIfZD4g1vVPTE6/bC7VtpIdZvWY=; b=PxRq9LlokolFGtj1cDelOUOfqB9y9njQBVQYlPE3R5XciyLKiyvnjYpfMxyySIYrCkwT9mE8Qj34/4eb8S7I0Uv509hfs1Am0yeqrRa0MkndHvoPjH3l5OuYvRoQQrY6dez82FRnUe8gllHQnwuFkT4epfO0mkNRDDmlyvTAgaYrkvAypGpA4h59i/cnXbd/o6abwHOn4yaAJj3X0l9+LI2HLo/XnS3CtuedWZbC+qqKfpSNIWcEb3eo7NqTt1x38EM5hyJnxA4b+Z0oOEnFggmWzlG4CGqZREZpwywlUxZV+PWnLnIMF6bhZ/nNyrLPSNBGxkHwAPT2sg6kqx7nDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yJ5oktitWkDDvYvGVIfZD4g1vVPTE6/bC7VtpIdZvWY=; b=Yt/yqxMWXtQsGHvtyu0ck5DCKxtyi2HbEh2eZzbzuW/yupmnuEqKqJvW4jS7e1x+ntPYkQIhkDJlk1tlWfwpe3Phx1BMakxTuMj5wrxh7DSMCivYs6rSQ61XDCcab5pieSi1ho5mQLZht5BfeJEsg23jOy88d74AOUj4tMPnOwBOdU/6hgPXBkGhUBI4ry8LNXx/5z6At/ftlOBqM0Os2p64bKWbDB+ppaWI1ijS8hMveCAUJ+3LhgDvNskblvhc3QC0/HuBTKdc4/8tTXVUPNOMBQSKVUFRB9kKc2e7375F2BSssB8FoxazOf+D2WGqi6ziBONA7sSrUS5Xh9BWmA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by BYAPR12MB3208.namprd12.prod.outlook.com (2603:10b6:a03:13b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.25; Wed, 2 Mar 2022 16:32:58 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::95a1:8c7f:10ef:2581]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::95a1:8c7f:10ef:2581%6]) with mapi id 15.20.5038.014; Wed, 2 Mar 2022 16:32:58 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, jiri@nvidia.com, roopa@nvidia.com, razor@blackwall.org, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next v2 10/14] mlxsw: reg: Fix packing of router interface counters Date: Wed, 2 Mar 2022 18:31:24 +0200 Message-Id: <20220302163128.218798-11-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220302163128.218798-1-idosch@nvidia.com> References: <20220302163128.218798-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P189CA0029.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::42) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bbbab3a3-c04e-44da-138f-08d9fc6a4fb3 X-MS-TrafficTypeDiagnostic: BYAPR12MB3208:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5jUONqpac9/2wfYqRNsD91JonPr3IlI/yKQJUS5ucjq9NTbC7+CHPzahIUa01wTn/Xh2SpOzjs8W3sAfZrEvdUOnFLmrc/QtECnzCUyDxHPQa+29avz+scKDBg0NkU6RDBx1ZJwnp2plxmvV/z5Igrtn8y2DW87B2h6bAZ2YalNyplu94GvldIeuTwj+1pgkLFaLHF06k+fZnqjr/EkA1qOliv6ySfWuVpbdcJ69IuNoz9zo4We0PXOhETR9QmhJGu9D7/Y+FVUaFZymUE3/l3TTWXIT/E67n6AXa3m8LfKx28ijaCGLfPaaUD5SE43eG35Ei6wuQ/sbxxPZmphETiVcYCt19Lz50Kl972UxLRQRmusYs7VxJUWnxu+0k2ItJ6lTS+80nzihT31RO4cxddjrBtSSp7ceJIACnrFscT6L/NYM0S3pvvH/EQPKR7E10eEXucOYrI+5MWMHyzJW2qhZOKpF0bCDQL46OLduYpe1qs8aLuKQXxEXvXpho6i+kkefMGfQFS9woayAlOL1tij+eYz/eZBJdnzPgxNbvfAaXU7lFUAyZ8N0e0dEx+kqmOfHUWRqEKXYazU/Ol7uJkAKwn0M5eWaJfHolNIV7iEFDyLXArdHC8aWj9GrTHgHWf2nV+2qljXDmlXv6Kmpkg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(8936002)(66574015)(6512007)(107886003)(4326008)(66946007)(66476007)(38100700002)(66556008)(2616005)(2906002)(86362001)(5660300002)(8676002)(26005)(83380400001)(186003)(6666004)(36756003)(6486002)(508600001)(316002)(6916009)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /dfswdcCmJ6WhJoSCEGDsvglMVlyO8wywemVq3Sy2MW0yrtZ45S4+sApn7P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6VLH7g7u7OjfTXzGCTyxOOnOKpGKmPkiWtLjr2knyRAnPjbu5A2yg3e8aIHYrmidv8sPekctPL9GZfCQFtVYarNlcimmPHuAAf8571rCHF33WPUWypWEzpb5+T9LrKG77UvyGaIjM/DZvB6X/qwuegeij53QGaI2J8a/1ny6EhK/dL2QCA8kS1TiLpX6Z6LZ/VOia9fwme35FMNHTlTJCJqbnMOUHYvO6Z6cVO2ZCCz9JCI+1dvjoM4a3CEKQA+5kf52M5weVOgS+gS8oKyBsVlkNl6ngyQEHbV3O0LkAS344SQLzkxtjCSwhFrnIvZ2me00AK5DJloxPW3HZ+4tX6krVfRB1ALMCbsOVWywX85UTZLShTb4dTGVc58ErWyVm24pzo2sMh2bBsxn2otejkuJWqeXBIsFjdBpOFb1mcMJSeedNDnywUitF/1j470eKAPMbQHAz8Wwcjv3axa98yeo1+QNXN7dtXRhARe0cbb/4e+YWWYsS3+uHgjsMA7rQG4H/cUwheL4= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bbbab3a3-c04e-44da-138f-08d9fc6a4fb3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2022 16:32:58.6316 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: B3cxnygTZw1J1TXPa0EVNUa7VlMAhQhFc1bpAd21oAIkRSmbB7uYuqR/r1VPSoBySjC1oURGraTk0+pe0YVOYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3208 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Petr Machata The function mlxsw_reg_ritr_counter_pack() formats a register to configure a router interface (RIF) counter. The parameter `egress' determines whether an ingress or egress counter is to be configured. RITR, the register in question, has two sets of counter-related fields: one for ingress, one for egress. When setting values of the fields, the function sets the proper counter index field, but when setting the counter type, it always sets the egress field. Thus configuration of ingress counters is broken, and in fact an attempt to configure an ingress counter mangles a previously configured egress counter. This was never discovered, because there is currently no way to enable ingress counters on a router interface, only the egress one. Fix in an obvious way. Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index dce21daaf330..67b1a2f8397f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -6784,12 +6784,14 @@ static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index, set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC; else set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT; - mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type); - if (egress) + if (egress) { + mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type); mlxsw_reg_ritr_egress_counter_index_set(payload, index); - else + } else { + mlxsw_reg_ritr_ingress_counter_set_type_set(payload, set_type); mlxsw_reg_ritr_ingress_counter_index_set(payload, index); + } } static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)