From patchwork Sun Feb 6 15:36:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12736592 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 C256AC433F5 for ; Sun, 6 Feb 2022 15:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243953AbiBFPhW (ORCPT ); Sun, 6 Feb 2022 10:37:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233954AbiBFPhV (ORCPT ); Sun, 6 Feb 2022 10:37:21 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2054.outbound.protection.outlook.com [40.107.93.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C434DC043186 for ; Sun, 6 Feb 2022 07:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sx4TK+8FzEhdqbXSeVnNidTAxy6UwXKSfSHIjyBSXkkBuge1dq813P9oKst59t/joHymyeYt0wvSFQIY4AhJ2tdXJfANU8omMhB+pcL1mx2aULp6i03ty1Za9/YE9uyvzpObqxkHXzCfxiPrXFXGjZsG4mEixgpglxrak4WAgQWWKEjcU0dwnTM98OuY4D665XO7RBcYIdGgkxqb7mtWO4uM+6G2IShp8T5t7zHnT75Ct8q+Xs2Pq6Sxn3rUAF7+KN3hX6u5VCKVioEPzsFqfd+wKDSyq8S7rIsHsXRAAdNk7JqHf5G97ayGx1vFDMNqpqlAox0/qEpSzqmGx0lTsg== 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=tZqrEsaOrrfXQaKNVEyMiwjknDyBZJ9tZW1JwRDmFeU=; b=AwGfGkQ6ipReFrpnsmaaed9iN6Xe0Yr6uQiIPZoGXFxBbRX59b/U6v9rX2iDjxmtm+a9csSDVDgoOUR8Od42z7E0xbr5QpUPtbitiaUufNTTQAUnr5d99YafR7gPC428QdtSZFs2EtffKMMxUsH9Zvx+DABz/VS8vduxAtK65JRB0JRCtG3Z/3yP6f87BBG3feb5+9wVbbhm/5XDYrd/nXfcLowLxNjfk8YBLilsGKGujsV+qBYQuBUYi492dYjvV3Ef94hS1Yn8QWcp9QwvuVIaovPvmXuIWHqpGorpuBt2LJI2iugJNdBZFDr9CpJ51TUJ7TaLj4cmFVE1f385Jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=tZqrEsaOrrfXQaKNVEyMiwjknDyBZJ9tZW1JwRDmFeU=; b=tVF3HU/MrFFwJ7TnmJVNY+fz0WZZlrSzvS9guA8xNZ3Dzv1pJrXLqocD4sqMpcjRk4jTkPD0cuMDg6S/OFbuvW0F2Or0yb7rcIVtItczbNMEE8cHmV6F1blip78stQ5G3UJWIpt6dOWJpBh5t4vHEF7RCqn9o53XWaDzcnwHcyEkJTgdF3YEQdMvrQir5ZMK/vzezeyKm34wZrYy1GPKxS0ck1F4Gox2cZ2GZwl+k71OI+I8HC5n560cQuf32oD8iYhOt+wl9P0QcZrtfraB+y4+NJ8iZ6z28vfYvUabdGqAXXUm+W2e6yGNs6jI7DqVGxKmSzILEeFgk21M0ZyntA== 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 BN8PR12MB3395.namprd12.prod.outlook.com (2603:10b6:408:43::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Sun, 6 Feb 2022 15:37:16 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::5cff:a12b:dfa4:3eff]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::5cff:a12b:dfa4:3eff%3]) with mapi id 15.20.4951.018; Sun, 6 Feb 2022 15:37:16 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, danieller@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 1/4] mlxsw: core_acl_flex_actions: Add SIP_DIP_ACTION Date: Sun, 6 Feb 2022 17:36:10 +0200 Message-Id: <20220206153613.763944-2-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220206153613.763944-1-idosch@nvidia.com> References: <20220206153613.763944-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR09CA0134.eurprd09.prod.outlook.com (2603:10a6:803:12c::18) 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: 27b6a3e5-a96e-4a76-6492-08d9e9868db6 X-MS-TrafficTypeDiagnostic: BN8PR12MB3395:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1169; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6bhp03vAxBtsNX4Y6JUSRbCvipF/L4QpWsX1TIgaBp3T5BaU03AAtMRXjwUJqQnIuoG0Ko8y+fIcnVbDM2U7hpBQWiNvwFLtCIHRxR27c8UBt7ReLruqxNWK9oqz+C2yqmVW2j/wkBd6BXC0AuHfr/ochscGLSx+hR593efmAZI4tFCyq28xUPnccURy5JBz3Xn4hpEvk1OGZbri0eBbH7OL+2lHpQQjP8YGsiwVvTHzEgyA9j8QMzj1YzfRuYQnP777s2qnOURED48I/aUB5NEvdmvs1wTVbAYPs0R7g1i2Of3OdGKQ1O6LRFsdEegeQqnGmj0lTS5UfRJwQuzh98r73zDvIsSL/NEKqBzWdaPo3MRMj7nyvviDBD0shZKgjRTvn/q0mS0dIDQiH+3QyCObem4GMoZEBGEmW3cPIG+CzaX9IlMgE5jrSpbg2bHIxFzljT6ywu535gTwvQiywSESvw+RwX9MWDKA8iir2wmY1qZObHdDoHBr+1vu09jlc4MX1aF0HQkR1IcuzunjnvItHsdJ09Gh6iszaEfPPNFEiR/ufc6iOepAOgcJzdO96lEo1oC/eOjdFDBXx9+yPkOj8jujh2kM+tYLDvJ2HHkN0teRXscIoEgtGNNojNiz+bpJxjnqh5FI1mOE+CzIPw== 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)(6486002)(26005)(186003)(83380400001)(6506007)(6666004)(6512007)(5660300002)(6916009)(316002)(36756003)(8676002)(4326008)(2906002)(66556008)(66476007)(86362001)(8936002)(66946007)(508600001)(107886003)(1076003)(2616005)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XDowa06lkGL+Lj1GiEHChtJ3rzEd8/I12SVVg3fBj2uAUFuZH7GimzrOssg30JGfNkfHlxb25gPX/FNd9b+e98dr+2Fva0SzciPM3r5ZaHwkQ5inJlL8wswo05mHLF83NvYGTnpJ3SHzU/wAvfX4kAlLtbzzPyfK76Gf1qFMDA2vyJD7eTknTKki4tYvgUiFDxBrC7wIIxaHyI4/p8IhlJp34urAvlpoPje+Sm4idaltK/u/y0rEaAIZRNV8CGEjpfhxVtPId595AGEA9q2Uhwf3VdxUwQfUhOBSdZHfyJMGmunxVofEaead3hX8H+TQBW22aVib03Gf7X8hG3WVwWnM018Xd6S5O0DhH9FpzYywR15vvCphZ6eADN0mpcamVDZquXvoQBtKkXWmH1bXc8x0tx3dH7nfzp4YSkgC7AyuKiQqZ1SZNOallMANX0k5EAnEAqfw2OMv7E4TNsbNJ6y6iMD/qYDkgWltzteyphtY+YneVLAp3E0T2UZYdNWtpLm+jDhOoszMe45dzPQqFSuYThXDI+ZmqAWrkP1290L550jaZ3xI8+9wV13+EysbyNUDxS8k7FDkDI/5sa7U7ZRL5B+xV76Ut7+0Es48RK16X09BgsD/PYAPLpZW46iydDatQt2OGM0ySYljwGYlO9vgilbag0WDfgxKfa0Ady81UQOI9YmwfE2G1oI3pf7lMSbFuzXt4TojXNFYPSDDX5sOXHjD3Bfmtz9I+6ZbD2WS2uAwf8iy9QfnLdXwBrikqDRwWKeHF59ANBdUU7L0vGBnM953P3JhTL32uf+qaHud+t2seVPQCMa97AaKR3ab4soyGSSpqdgcDKIOV6Nfij3xhoTtnqBE7uAbFsd7txfKubRMT7Xt90Gpb7homcOYgTEXUWL45afn1iazNHhXcdDjhmneTqBK+UKTxKONHaw4S/2xPwWrH1rFjNwgtqnhRovTRKX7AXKtsGTTta7FeCfWFhy9Sr/doXWbhWjmjwAfMwecUhnOtIYUUevbpT+WFs13Fm428j44l9O2b4t97E8tttNoUVeD7c3wh/rL1WaRDXX4JSzJHdD2jJB57mlyCtHDXcGxAtSq6n2OpUl0DpurwddyOIfBAntggLrU1mzDI312lX2RbFgiy51g2S6f4yoYp3AaCZ77uLv5BE8P70edOd7x1gUu/XJYIe71cZo0uTl8dTTXosZyaEC6s0l1see0MXh2mdaeSW9tGZbTjBYNsg/JXDqP0sJzRj10aMyrkUxMws0SlZ8vNO6a51v3wLj4oZNDj3iooz02f9xgymkFojLQrX643JSsQQ9zCUSJfU2jeb+3Ei5fBAQSrmPDcuqUnFBlqeg905j48DiqucWJVwn+03bO2IIga4VvAEAgSU+kO4S/Dz19RO62fYgacpQEhd0sGs55EWUPK6Y4wXOYKbBY4yrODwd6HfIMjfFd+kbfYJQlFfUm93ojNbAa7rXS0bzoGC0h79fJyXInNXkn3cZPMoyKaRI3twiikJ5wqHv8tQ0vpBJG774k5Bh/KGGETgvyAg+lULXGLPLQ3bx5h5kH6CABLr0cPajLtZPXdZS+h0Q+P7A0UIas5lbsOH4JKB0tPMbodR9kV/aIhccHqps3Lg0/hM65jOxAut0= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27b6a3e5-a96e-4a76-6492-08d9e9868db6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2022 15:37:16.2847 (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: iiFtbK8zu4+UoeQeDXojadC3XCg86SM+90Zjj7UMBOF+Crpi8N5mfkoKKLM/LcThQWPQf+u8zk/w2zvS7RZs3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3395 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Danielle Ratson Add fields related to SIP_DIP_ACTION, which is used for changing of SIP and DIP addresses. Signed-off-by: Danielle Ratson Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/core_acl_flex_actions.c | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c index 77e82e6cf6e8..b6fe26ee488b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c @@ -1957,6 +1957,51 @@ int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block, } EXPORT_SYMBOL(mlxsw_afa_block_append_mcrouter); +/* SIP DIP Action + * -------------- + * The SIP_DIP_ACTION is used for modifying the SIP and DIP fields of the + * packet, e.g. for NAT. The L3 checksum is updated. Also, if the L4 is TCP or + * if the L4 is UDP and the checksum field is not zero, then the L4 checksum is + * updated. + */ + +#define MLXSW_AFA_IP_CODE 0x11 +#define MLXSW_AFA_IP_SIZE 2 + +enum mlxsw_afa_ip_s_d { + /* ip refers to dip */ + MLXSW_AFA_IP_S_D_DIP, + /* ip refers to sip */ + MLXSW_AFA_IP_S_D_SIP, +}; + +/* afa_ip_s_d + * Source or destination. + */ +MLXSW_ITEM32(afa, ip, s_d, 0x00, 31, 1); + +enum mlxsw_afa_ip_m_l { + /* LSB: ip[63:0] refers to ip[63:0] */ + MLXSW_AFA_IP_M_L_LSB, + /* MSB: ip[63:0] refers to ip[127:64] */ + MLXSW_AFA_IP_M_L_MSB, +}; + +/* afa_ip_m_l + * MSB or LSB. + */ +MLXSW_ITEM32(afa, ip, m_l, 0x00, 30, 1); + +/* afa_ip_ip_63_32 + * Bits [63:32] in the IP address to change to. + */ +MLXSW_ITEM32(afa, ip, ip_63_32, 0x08, 0, 32); + +/* afa_ip_ip_31_0 + * Bits [31:0] in the IP address to change to. + */ +MLXSW_ITEM32(afa, ip, ip_31_0, 0x0C, 0, 32); + /* L4 Port Action * -------------- * The L4_PORT_ACTION is used for modifying the sport and dport fields of the packet, e.g. for NAT. From patchwork Sun Feb 6 15:36:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12736593 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 D60D7C433EF for ; Sun, 6 Feb 2022 15:37:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239002AbiBFPh3 (ORCPT ); Sun, 6 Feb 2022 10:37:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242568AbiBFPhZ (ORCPT ); Sun, 6 Feb 2022 10:37:25 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2077.outbound.protection.outlook.com [40.107.93.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A041CC06173B for ; Sun, 6 Feb 2022 07:37:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EmCab49sD1fnabpMq1wxlavBKMdhFDFSAr+ksQcOkwy98Ne0G1JMFWr2xQM4lUX2HBLUzIOgQ98q2E89kBbLGcF/M9hkWXH6ZpRrwy0TFQz2jCbj9nJ+cH/6bqykMnHydi0bssYMLIfrTlpdKL/FAS3RwyE04vPg2nMe0ID7M6SCLgOBrdj9OlaV6yrBpUsttXYA5VzK0UXbEomKbaFd5qxZbQn+dPshermyNWFmjdidHTSe0VFQqTJz9T1/s3Rk2cX932GAjhKEiOUdN01SXSLFbfFeW0i1DRk2Kc/m3FnGcAPMydITncSis2uJHgBxwdNi0m1FBpR7y/xixUXwkQ== 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=EhFZnaA0UcRkVu/aROFGmCXMJ3mwDyeA1oV8ELcRXNg=; b=OhGgIoI4FFxQJ7QFHxCHDJtdfQJ54xHoIiUoyi8hwLKDJUA1LwPD6QRwHuJm6jrkgGlPuHmNsc8awUBgVfFFonTUjfwJ67ACh4TI/imX/TDcS8wwrRve4wDPJ0dTmAedF5mUYttr0vycCk4oyFYyViJAVoqZl8DFfFtLOCoLBrZDJnyZLv5HDtDX5cO9de2bSyCGkvgYSrina5/YQQVg5VkG+5ZBM+uK3Av2B/SpNCGrKnFLAr1YyETicYRxqBREDC7JzY81q8GTgCUNGPtsIlE484OMomDUNAhdtoOCbWl4sYXeTCo8toVnkfUXSE6vFcMZgzuFGYgUCeJFM0L3ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=EhFZnaA0UcRkVu/aROFGmCXMJ3mwDyeA1oV8ELcRXNg=; b=ivHtCAn1ILq7d0xV4Vg8KURlsG5zI9dSaoTYwDVDzV9P+KBZkESdGXRepoBZahNV2GPWZ5+AqZyMEoUT4CpfvRY4N/871ocRDgkIS2cJD8FwPBB5rvaCp9dLZS3dmc8kVxpZc8SoeuSV5BmDgaF/jMWJowJ7Xg3jGx0ye0mDfDSCTh2vR6+G72PhB6IP6ihuiXsuZmPVqJCAQryN61fakhOiMoUqNiOGvhQ02lE1U6e4F7pMlMJu7xdQkjA/05LJ1McQrTwaSXfgpshaUYey+LcqV6rFftVKdzdnQNIfSpsKd2R2YhwsN14F02TGN59lMqBwV6qZO7OzmpNKTnWnbQ== 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 BN8PR12MB3395.namprd12.prod.outlook.com (2603:10b6:408:43::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Sun, 6 Feb 2022 15:37:23 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::5cff:a12b:dfa4:3eff]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::5cff:a12b:dfa4:3eff%3]) with mapi id 15.20.4951.018; Sun, 6 Feb 2022 15:37:23 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, danieller@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 2/4] mlxsw: Support FLOW_ACTION_MANGLE for SIP and DIP IPv4 addresses Date: Sun, 6 Feb 2022 17:36:11 +0200 Message-Id: <20220206153613.763944-3-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220206153613.763944-1-idosch@nvidia.com> References: <20220206153613.763944-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P195CA0072.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:59::25) 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: 1edae700-e1a0-42aa-28bd-08d9e98691b6 X-MS-TrafficTypeDiagnostic: BN8PR12MB3395:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:298; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4DRQjjNLqif4dDcChZ/6cy6olawPIW9FW7f7X/PuzkRlG+seiP+hkCtBALGJRTjrIit3qNbgjaOPE4k9Xg97HMl/B96jMmpY4ltOI0pbODkEP+tkS4Hpun3hHLrHTo9Onj0CoVhiC6tRl9W6U2hVWgXrAlBrGCtKQQGYwowHKcs6gsvrX1voiSSzYu7dZdwbtpNsVfUhXivzf2sTEXqF9zgJs32cF6n+sln/MbjEr4J4hnVaA8ElXFTODedQZuKEPyiHeTqT9x2D+ak4XF7fioRsXvq7L7v8JNrTF7ZhNA4nffJWAxkeh11lSSun4v0KY26sDa8DG5NOh53PekCHuEcHThOngdJ/piyhzAE2mJVp6l20+9wYHf2j+1JDY0M70QeMPDDcCnZdftDFqiQuiZKrSGG5OYv96Jp6kQJbdx+qzTGTrJWllXK/QnqAlswAGlc5dUauyzEhxndV7ubGosHUkt4YGa9A3ZUIhhPYmma9RPsXr3Ihp3esMDUYedgXrRUinsYp22QTcxi86ri56Qzy4jLJW91mItryqqVD7LDggjtBlP/8MUSgEZgkj7J5pBTI4gi2k5/1997BWNpntaY1cK2fVitS04icIKRoSrEykZEBCpz8BGvE6bdVWcHhFIw4s95q4lYtFuMDN+LMzQ== 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)(6486002)(26005)(186003)(83380400001)(6506007)(6666004)(6512007)(5660300002)(6916009)(316002)(36756003)(8676002)(4326008)(2906002)(66556008)(66476007)(86362001)(8936002)(66946007)(508600001)(107886003)(1076003)(2616005)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3HVuKdxTYGdl0VhjO/pdYKzt0kHT8txpM8osbxgnHp03QLYfceVp5KMrBfT0aVc+ToVtriNpnKtjMh+Smj7ncLlgL6H/v3smLobxd8tm6TsptP+NqHMYKUkyDrUKEOZODJPs/vfDclwGuN3/HuMMyyZcxR5lzX2msDAlCiAGGLAZdpqK6cLAvDTkVKhLGAR2eNAod+E1rDEL7/zJKKEkoNbUAZhl6Z/Y4ufeyoa/Y5VX0BkK0JKl1NKn7Ef5tbWpMvTbF4BzxOwcjnteNkPz6AADUz0pu5k39LlkwXGIW9JH6HQEoTHTXC0j/fePDZ13FeMWjquv9/0FsIDfK9hqvb6rR4MOAVEBZ072YoyHC/SF1BXWJPBm/g/+mae4b/6NKAJc03SEP7YopS73hpa6GKyzYO4vwjxSVVL3F93jgca27ZWGrMSQZZ9AYZlhl15dK1Cn/2WO1iUYw6idaeiNgsOItt9DaoeEQNRFtiCMnvDsuHppFp+qXDcQJECK/KBUNhJALxmKphVQGDJgGnBXJt7Sf7YOedY+QDeDMl5njJH3KYvX7UNpa0NWWq4wcfdtUijs5ROtyZYsW//fWTNzskWSlolJb81gX/y0kUHQd0iCuvLeyQsBzWOLHOSKPQKWYOMiWzy5CMa+v1x5P72EgSg1/x3aR4Uz/AiJ2JIw/D8MSu//Qa47DXZ3gRq2dRF1HGd9PwKyl555sTzPUJ1Cyd9t8TLyVXgkLcPpQvL5TZz4mapulqskPs+FIzPOfVJ7QVuzr2ddrWBj9DgKCitRnQexlqBueUcdebCkUaH24LOyoDr1YIHwBiF/ZrzjB94X5ONOg3Fsu7JcTQP06EIt2qhWlOu1hCyfCU9725lG07dFjHYQcMwkdWtlLFuh0PWsjoD3CSCFPsTxmolfOld/LHaeQjYWMh92NeTCYhqBr9vtUD5LhmqOwLF4zZrjILd22B+EKItfoYOWp0zgZibeHmcjLXE9nvNcd4ZhlXVDkX5Mvd8ulHPy87KjXyH5WOR5vwSZ5wt8if106nLv4V0G7AfiuHDha2MOl7DphPG+w51FxWtnckbHjUl0UGZFMK6ar1INxzCgQ4k9xjUu7JjKrPWDZ8ezgQPv6iwBHii4T1R0YgwU1nRPVywterAvUIzqswudp3GZ4u2yXfxaJleLYFAN4i5Xd5RRs989nf/pgkumBEuggQpO/NI8/fp0jwORcVHl3OtPUnEvqI6lxgSF7JGC8/jvKxVdDkImamzJ09p8Ah2MOo3kuOMGZEX7l0iIWLCOKmCZR7a8kzs7bj0u+Vg6JSWNKBxyaf4t5WEr8Gf+085HemNqztZRJK5lmXvLOTe7TeARXMiWUUaLj05psLmYlgu5aQbuxi0PCVtOqyHNKjz5srxzonRnEUjqGh2EavTRu4ztRYTq9v5O3mkRo28wqBByuy7Tlc6sbY8mfd4tfZTjk837xe9KiP+nNnRcF2+oegsldnXwjWcTtJc6U5fCYZfWcXRFNDEJ9oxOqlAG+Q02OEyJuwScrWFL5ti0eOLTCF8V6fxcAZ6IWzR5Swya7PaMM/zoVEHCy6ejFkdrNUf5Tjo5BifwVPvrisyTGObwrGnVNUwMpnZYoHXcPGC0zSJAr3Vw0QetWRC5N/o= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1edae700-e1a0-42aa-28bd-08d9e98691b6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2022 15:37:23.0721 (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: LQhqHcfv0umiepVtMM/OAEIcaeaXYYjnrbL6Z4NdcLYEUdfzplDT3T29cuFpGp0klTrZmYmJiMR1/pCYQADkxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3395 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Danielle Ratson Spectrum-2 supports an ACL action SIP_DIP, which allows IPv4 and IPv6 source and destination addresses change. Offload suitable mangles to the IPv4 address change action. Signed-off-by: Danielle Ratson Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/core_acl_flex_actions.c | 32 +++++++++++++++++++ .../mellanox/mlxsw/core_acl_flex_actions.h | 3 ++ .../ethernet/mellanox/mlxsw/spectrum_acl.c | 12 +++++++ 3 files changed, 47 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c index b6fe26ee488b..fa33caecc91d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c @@ -2002,6 +2002,38 @@ MLXSW_ITEM32(afa, ip, ip_63_32, 0x08, 0, 32); */ MLXSW_ITEM32(afa, ip, ip_31_0, 0x0C, 0, 32); +static void mlxsw_afa_ip_pack(char *payload, enum mlxsw_afa_ip_s_d s_d, + enum mlxsw_afa_ip_m_l m_l, u32 ip_31_0, + u32 ip_63_32) +{ + mlxsw_afa_ip_s_d_set(payload, s_d); + mlxsw_afa_ip_m_l_set(payload, m_l); + mlxsw_afa_ip_ip_31_0_set(payload, ip_31_0); + mlxsw_afa_ip_ip_63_32_set(payload, ip_63_32); +} + +int mlxsw_afa_block_append_ip(struct mlxsw_afa_block *block, bool is_dip, + bool is_lsb, u32 val_31_0, u32 val_63_32, + struct netlink_ext_ack *extack) +{ + enum mlxsw_afa_ip_s_d s_d = is_dip ? MLXSW_AFA_IP_S_D_DIP : + MLXSW_AFA_IP_S_D_SIP; + enum mlxsw_afa_ip_m_l m_l = is_lsb ? MLXSW_AFA_IP_M_L_LSB : + MLXSW_AFA_IP_M_L_MSB; + char *act = mlxsw_afa_block_append_action(block, + MLXSW_AFA_IP_CODE, + MLXSW_AFA_IP_SIZE); + + if (IS_ERR(act)) { + NL_SET_ERR_MSG_MOD(extack, "Cannot append IP action"); + return PTR_ERR(act); + } + + mlxsw_afa_ip_pack(act, s_d, m_l, val_31_0, val_63_32); + return 0; +} +EXPORT_SYMBOL(mlxsw_afa_block_append_ip); + /* L4 Port Action * -------------- * The L4_PORT_ACTION is used for modifying the sport and dport fields of the packet, e.g. for NAT. diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h index 16cbd6acbb01..db58037be46e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h @@ -92,6 +92,9 @@ int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid, int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block, u16 expected_irif, u16 min_mtu, bool rmid_valid, u32 kvdl_index); +int mlxsw_afa_block_append_ip(struct mlxsw_afa_block *block, bool is_dip, + bool is_lsb, u32 val_31_0, u32 val_63_32, + struct netlink_ext_ack *extack); int mlxsw_afa_block_append_l4port(struct mlxsw_afa_block *block, bool is_dport, u16 l4_port, struct netlink_ext_ack *extack); int mlxsw_afa_block_append_police(struct mlxsw_afa_block *block, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c index 70c11bfac08f..6e43a6ba09bd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c @@ -511,6 +511,8 @@ enum mlxsw_sp_acl_mangle_field { MLXSW_SP_ACL_MANGLE_FIELD_IP_ECN, MLXSW_SP_ACL_MANGLE_FIELD_IP_SPORT, MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT, + MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP, + MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP, }; struct mlxsw_sp_acl_mangle_action { @@ -561,6 +563,9 @@ static struct mlxsw_sp_acl_mangle_action mlxsw_sp_acl_mangle_actions[] = { MLXSW_SP_ACL_MANGLE_ACTION_UDP(0, 0x0000ffff, 16, IP_SPORT), MLXSW_SP_ACL_MANGLE_ACTION_UDP(0, 0xffff0000, 0, IP_DPORT), + + MLXSW_SP_ACL_MANGLE_ACTION_IP4(12, 0x00000000, 0, IP4_SIP), + MLXSW_SP_ACL_MANGLE_ACTION_IP4(16, 0x00000000, 0, IP4_DIP), }; static int @@ -615,6 +620,13 @@ static int mlxsw_sp2_acl_rulei_act_mangle_field(struct mlxsw_sp *mlxsw_sp, return mlxsw_afa_block_append_l4port(rulei->act_block, false, val, extack); case MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT: return mlxsw_afa_block_append_l4port(rulei->act_block, true, val, extack); + /* IPv4 fields */ + case MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP: + return mlxsw_afa_block_append_ip(rulei->act_block, false, + true, val, 0, extack); + case MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP: + return mlxsw_afa_block_append_ip(rulei->act_block, true, + true, val, 0, extack); default: break; } From patchwork Sun Feb 6 15:36:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12736594 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 1D0B7C433F5 for ; Sun, 6 Feb 2022 15:37:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242568AbiBFPhf (ORCPT ); Sun, 6 Feb 2022 10:37:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244001AbiBFPhd (ORCPT ); Sun, 6 Feb 2022 10:37:33 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2082.outbound.protection.outlook.com [40.107.93.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BB05C0401C0 for ; Sun, 6 Feb 2022 07:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QM/YV+xR4g33zEzXM8y96+hrkJPixzJmKvKP1BApKINT4m90saNPP9eta8kp1NJUThUEFNtUkz5mYzpl1MujD74htsWkBRdV/LJNahwf5B1T38XZPPY++rnPQtvXA1TADIJXSlwwP4NTm2qa4/yHlMlYjChgz4k32nyLU/zu+/5ZdVqr0ohqBi7X7QPfjG4cmHaJQe4bXiVcTuEVJjzOqGPdaOniX5PNbjd72fzFbgxL3unTuQNFZRUiZNyHUv/DbzW66cKMT8phmOgBIw6gFLdg1ULF0OufoRDBF8xpYkfoH2VqGh7Fs9D4BSUbIwCW7B//BzYBBsGWVB/GGd/+jg== 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=PZ1lNa/9Y2vLJpfKZ3Pdmmwn0ZpPfS1/5Wory5HZKig=; b=l6WdQBQ4MbyEOSUqxxu4qPHPB0zonf1CgKtbJodc0tWieWfvyEQxWGpXq4lWqj5lkSD97PnFaN+ipMCPcdNpGDw++6/4WgmVTSoZiOAoeMjv1OKljttkKIpc1/4XSj9qaE4LYvpnNAcKQrUEyaBfhIXicTbqqtsOjL2QuQwFxUWuRv2S5hEHNgFn8Lpn4tUpKuJ5inIu2v/T515opknZOZWOXBz2Kcv0pFbFeDrakK/l03AyTMdW92ihuijfnAOTHrlRQhx5/ykL/C2I8QioEXd83kRruE7xbRSQEtiIUedLXbiBklp8St0ohdwqOo/jw1ebHdL+yMVcyaBuCpmIXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=PZ1lNa/9Y2vLJpfKZ3Pdmmwn0ZpPfS1/5Wory5HZKig=; b=EeqSNUWVrVFPTouivdZ3Baq86iEzwquSdNdL0YGvU2oMW553ky/E/CFHNZY4Q0f6PWRIholkmovV8sjnDpa5Rf6+s30p9FprnSpCwtx4UwBBTbR2BV2sGm5vnDeKp7XAk4Bd38qE/LCoRTroJdj/pS7AsKMtA16CT+Cyfu6Ji62GSimbXhCinoB8ItZIB1QPGKMY5weNvmudr6Je1y8GLg3wmeUxn/8T2t6l4XdXQs5lc/LhwssGIzU2RQ3n8Dl/JRPOWSvm79EKShJg5lJMF+zDlxcWiMUFR8jtHiP6e93/jNAz+Gp5lBVMe6GWbCL4O3iLv2i1u+iF4T5JRcewzQ== 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 BN8PR12MB3395.namprd12.prod.outlook.com (2603:10b6:408:43::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Sun, 6 Feb 2022 15:37:29 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::5cff:a12b:dfa4:3eff]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::5cff:a12b:dfa4:3eff%3]) with mapi id 15.20.4951.018; Sun, 6 Feb 2022 15:37:29 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, danieller@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 3/4] mlxsw: Support FLOW_ACTION_MANGLE for SIP and DIP IPv6 addresses Date: Sun, 6 Feb 2022 17:36:12 +0200 Message-Id: <20220206153613.763944-4-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220206153613.763944-1-idosch@nvidia.com> References: <20220206153613.763944-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P18901CA0016.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::26) 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: 5c70beeb-88cb-4126-45bb-08d9e986958d X-MS-TrafficTypeDiagnostic: BN8PR12MB3395:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:747; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CZ33ySPW7EOn1ZU+jLRTVt9QxZSD0RuhIOgX4FUFoMRW4nU0t/gxNwR3xTNC85BTf+7EaBXq22Wp4BCNPNLEa2Be6zdsYiwayXbXmqxytT57LfSdAP+elUNizm50HZkzKXNmtoTnguz5MymcmgLRM3Z8DxYUbAdUNzsiG85ZwZqAz7F0IrtaI6KlTn2+2TwwsY9rUuZnvUgSWrza7+AU7jLvHl3rGgA4VHN3QXjg8B+KcSRNvkFjM+nLXPk+409tZiiSA0DNsWbpNTdqN4dtG9WZxa+Lf8RNXa9IglMEuCa+RcbYHMi+VyzgJc5OZYB9M6ZHOBQFka/4hg5k8y4xB1crm7QLAbFDTiGnhKrkJd5ZqjnE0FBjbg77NiRspCdysWu5+RJnBCmBqbWxVvGVs4nphR25gFZgvVNk38UKNbsJSWn96V9kLKFAvTO4yPRoChxpZlRnfmL8yK4y+slpqmLGsfdMRwJ97NTQhK+2UOkWltIFGQYiB+HnPYnH+ojMgTFvKgZdK1+tU9jy475drIJ1Z/e8QXK9YR8qMwkddWJ8HzvhwEvPu1YxlG1j+Ba8Hn10deDH67rZmG84rtSveX713fTGH6WKg9vOW0Xg+ibiuZHV9G5aP/wYyko31v4EQPobSB7eQ0G2ttW8osKkRA== 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)(6486002)(26005)(186003)(83380400001)(6506007)(6666004)(6512007)(5660300002)(6916009)(316002)(36756003)(8676002)(4326008)(2906002)(66556008)(66476007)(86362001)(8936002)(66946007)(508600001)(107886003)(1076003)(2616005)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rrxTURnIufke+A92dbdZ8ICIdY5Z9do/hKDI80UOWElCtz94gwS9RAD+S9Ip4/EUdBg6gUkNnB3rIsQ8YiwNqrqvj0GWK+K7NZl6cNY9IMRU6QJQP41+faeCESbJCAnZi9+LiDu+yhmT0x6ChapQvkLAnngY6pJnmTajvcRpUGeXym61zcJOSXFt/Ftbys6H4j7Y5ywogNQPWSg0gvhG5Vc4gzKRZAcrslO1KGcn6E+mDt5U8JTYO1sOxMxPSMg09PTSi6dZooY8ngsI0wRpPu1WxyO6iGAzNF3Oc6Dtmg9Wm1b0L3vw9w9CRHn721OdMznIGsiMHWmaxFGnCav5hO1vLlf3T6Uis36WkF4XUycGJVOe5JlQJjXxK4ryDFov5OktSCLb9+alU93ehaRFxSY9XGARkzj65HRyN+aqOA5dxxyi+6y4/xjX4BCI2A9wVs+FiChSqVs7jtlosr2yx3MAcuJuymhhmoKaS/3OU4LAimiwPgVTuy9YT21r68kUuW7HmyfqwCdmgGsK5fodnyGRPssz43RGFgQ84jJMBZWTCLAkoiWjuD/5GF1bgaAItrZEUDjKtlLXIH37OV7DNMzXEaVWoTv4d181y/qCjWUg3UUmjXETl03YmFkJr6eDg2H4qsQ/WHGJeKwq3coNc3/X3AGqF8Wb/PA+JKILezCXa0ff5XgQm33GmWzK/OgWqD9jLoSU0VCUvOaC0Jls7tZaBhHain85GSpN1owOvtKEoKKP7IEOTjIZ2d1vW2ijSbgToraI3rLSX2xk7sHHmI77rWms7XEQpaNb/4uqprYoXdNFwmKggqeEQAfIeAy3hYHyfEbaGbT/jtW/eww/jDltSgdBpimyf59ZrgAQkHWFTbPITuLsMXzyXGhWENi68DQW8QRdLINmZTYwwtvLhGy46izE4BiddvK9wirpYYuL7NJYrr/nLRyUCn+lA90Zkod93k538WJGt/0usS+NT3cYH7oPUhmYERQI3JKBnZMKuS1GEt0x8/Qej1cXts02dzFKCJiK3DJ9Vid6HR8OQnSEVkPsyQFM9XHoexiO35Xq//l5QaNF2fmrlhBF5oZD80C+Q8zzYAzWgADfHizNyf+qJAokbwfGkFRPGPGfJtI4UWBfLwyVE3EI8MTBNOmYMJcLVVfpw03eDV5nWqIiqgME9qW9l/6+N0xfyKJkkXeLw8SxwT7c4QMnevea5MojtF/3qcGuq2IsU0I235HJKamXeF2K++Wn75121fFtL5CD/z2Fuqwzmyq1dgjSXGSSc016czORKb5v/Ep8ZHx1etljegIT1//PkBPfr46JbTsQQWTvJMBwJxzWPuz37VXeuIopz4eeDU4dwPuXy6EX+P3Zs5TxPS1PuolCAtPk8mP9bc9E/ZpE19lDvZIzCf0M4n13TDDUcGj/wSkF7t5Q3/88qD+13n6yUOo4GLDwMoZaz2521M+kUQ2uEKGR11OkuUiDb/QWGKYv2OkIutdKlAALcGjg90snqpxjwBQRcpxPz1UzXd0YcdvnByHMVOJfaGJyLQrxVn7a2ChuHhIaA3SgCe338hejavjjvs/O9Tu7fUZvL5G9VKTofC/xbuShqQXTFNEG8Xh1tH7/5iA7S4O7mDI4RhNhFCWgJg2trvE= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c70beeb-88cb-4126-45bb-08d9e986958d X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2022 15:37:29.4682 (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: fJIrGt+Ps0og01lM+iHoYQ8/lEi8t5+13h3lUHgh48ppaTVFiYTxNSIXx/Pntg6UrnrcT1GWaVHo0ZrixRru4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3395 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Danielle Ratson Spectrum-2 supports an ACL action SIP_DIP, which allows IPv4 and IPv6 source and destination addresses change. Offload suitable mangles to the IPv6 address change action. Signed-off-by: Danielle Ratson Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/spectrum.h | 25 +++++- .../ethernet/mellanox/mlxsw/spectrum_acl.c | 83 ++++++++++++++++--- .../ethernet/mellanox/mlxsw/spectrum_flower.c | 6 ++ 3 files changed, 103 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 30942b6ffcf9..20588e699588 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -820,6 +820,24 @@ int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core); /* spectrum2_kvdl.c */ extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops; +enum mlxsw_sp_acl_mangle_field { + MLXSW_SP_ACL_MANGLE_FIELD_IP_DSFIELD, + MLXSW_SP_ACL_MANGLE_FIELD_IP_DSCP, + MLXSW_SP_ACL_MANGLE_FIELD_IP_ECN, + MLXSW_SP_ACL_MANGLE_FIELD_IP_SPORT, + MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT, + MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP, + MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP, + MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_1, + MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_2, + MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_3, + MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_4, + MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_1, + MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_2, + MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_3, + MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_4, +}; + struct mlxsw_sp_acl_rule_info { unsigned int priority; struct mlxsw_afk_element_values values; @@ -828,9 +846,14 @@ struct mlxsw_sp_acl_rule_info { ingress_bind_blocker:1, egress_bind_blocker:1, counter_valid:1, - policer_index_valid:1; + policer_index_valid:1, + ipv6_valid:1; unsigned int counter_index; u16 policer_index; + struct { + u32 prev_val; + enum mlxsw_sp_acl_mangle_field prev_field; + } ipv6; }; /* spectrum_flow.c */ diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c index 6e43a6ba09bd..6c5af018546f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c @@ -505,16 +505,6 @@ int mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp, extack); } -enum mlxsw_sp_acl_mangle_field { - MLXSW_SP_ACL_MANGLE_FIELD_IP_DSFIELD, - MLXSW_SP_ACL_MANGLE_FIELD_IP_DSCP, - MLXSW_SP_ACL_MANGLE_FIELD_IP_ECN, - MLXSW_SP_ACL_MANGLE_FIELD_IP_SPORT, - MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT, - MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP, - MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP, -}; - struct mlxsw_sp_acl_mangle_action { enum flow_action_mangle_base htype; /* Offset is u32-aligned. */ @@ -566,6 +556,15 @@ static struct mlxsw_sp_acl_mangle_action mlxsw_sp_acl_mangle_actions[] = { MLXSW_SP_ACL_MANGLE_ACTION_IP4(12, 0x00000000, 0, IP4_SIP), MLXSW_SP_ACL_MANGLE_ACTION_IP4(16, 0x00000000, 0, IP4_DIP), + + MLXSW_SP_ACL_MANGLE_ACTION_IP6(8, 0x00000000, 0, IP6_SIP_1), + MLXSW_SP_ACL_MANGLE_ACTION_IP6(12, 0x00000000, 0, IP6_SIP_2), + MLXSW_SP_ACL_MANGLE_ACTION_IP6(16, 0x00000000, 0, IP6_SIP_3), + MLXSW_SP_ACL_MANGLE_ACTION_IP6(20, 0x00000000, 0, IP6_SIP_4), + MLXSW_SP_ACL_MANGLE_ACTION_IP6(24, 0x00000000, 0, IP6_DIP_1), + MLXSW_SP_ACL_MANGLE_ACTION_IP6(28, 0x00000000, 0, IP6_DIP_2), + MLXSW_SP_ACL_MANGLE_ACTION_IP6(32, 0x00000000, 0, IP6_DIP_3), + MLXSW_SP_ACL_MANGLE_ACTION_IP6(36, 0x00000000, 0, IP6_DIP_4), }; static int @@ -604,6 +603,22 @@ static int mlxsw_sp1_acl_rulei_act_mangle_field(struct mlxsw_sp *mlxsw_sp, return err; } +static int +mlxsw_sp2_acl_rulei_act_mangle_field_ip_odd(struct mlxsw_sp_acl_rule_info *rulei, + enum mlxsw_sp_acl_mangle_field field, + u32 val, struct netlink_ext_ack *extack) +{ + if (!rulei->ipv6_valid) { + rulei->ipv6.prev_val = val; + rulei->ipv6_valid = true; + rulei->ipv6.prev_field = field; + return 0; + } + + NL_SET_ERR_MSG_MOD(extack, "Unsupported mangle field order"); + return -EOPNOTSUPP; +} + static int mlxsw_sp2_acl_rulei_act_mangle_field(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei, struct mlxsw_sp_acl_mangle_action *mact, @@ -627,6 +642,54 @@ static int mlxsw_sp2_acl_rulei_act_mangle_field(struct mlxsw_sp *mlxsw_sp, case MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP: return mlxsw_afa_block_append_ip(rulei->act_block, true, true, val, 0, extack); + /* IPv6 fields */ + case MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_1: + case MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_3: + case MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_1: + case MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_3: + return mlxsw_sp2_acl_rulei_act_mangle_field_ip_odd(rulei, + mact->field, + val, extack); + case MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_2: + if (rulei->ipv6_valid && + rulei->ipv6.prev_field == MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_1) { + rulei->ipv6_valid = false; + return mlxsw_afa_block_append_ip(rulei->act_block, + false, false, val, + rulei->ipv6.prev_val, + extack); + } + break; + case MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_4: + if (rulei->ipv6_valid && + rulei->ipv6.prev_field == MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_3) { + rulei->ipv6_valid = false; + return mlxsw_afa_block_append_ip(rulei->act_block, + false, true, val, + rulei->ipv6.prev_val, + extack); + } + break; + case MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_2: + if (rulei->ipv6_valid && + rulei->ipv6.prev_field == MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_1) { + rulei->ipv6_valid = false; + return mlxsw_afa_block_append_ip(rulei->act_block, + true, false, val, + rulei->ipv6.prev_val, + extack); + } + break; + case MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_4: + if (rulei->ipv6_valid && + rulei->ipv6.prev_field == MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_3) { + rulei->ipv6_valid = false; + return mlxsw_afa_block_append_ip(rulei->act_block, + true, true, val, + rulei->ipv6.prev_val, + extack); + } + break; default: break; } diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index bb417db773b9..f54af3d9a03b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -233,6 +233,12 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, return -EOPNOTSUPP; } } + + if (rulei->ipv6_valid) { + NL_SET_ERR_MSG_MOD(extack, "Unsupported mangle field"); + return -EOPNOTSUPP; + } + return 0; } From patchwork Sun Feb 6 15:36:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12736595 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 4AA67C433F5 for ; Sun, 6 Feb 2022 15:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243975AbiBFPhl (ORCPT ); Sun, 6 Feb 2022 10:37:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244020AbiBFPhk (ORCPT ); Sun, 6 Feb 2022 10:37:40 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 371CDC043189 for ; Sun, 6 Feb 2022 07:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FO374YcKiiTRU21Okzu2FB/+bCN5QZEyuYULRMEYEduoUMYe/qigw/w7M/vuT3qz/nhTlngY0NXL8CNgydqKvibGJtPg9oBIuK0L/bZ0yBkVgaw9xgrtpP15ZWoPA+KMiFoIpZ7qOVo3tr6fDH7Ft4akLHrCeIRuFiGMejXgNkN0TEJcsmskp31A1d87DhjdLz+Muz4vcrMfdfM2hHARF9IlUalepXU9q67lAHIdggiMIah+N0bYigtOZTbMoIp813d4m4BphrRPOa7o9c/d/cKF6k/ngu4oJQjyn2q1pn77g1FO92Xe9IjMryuTQVmhdtX9Dqo4O+4xn29dqdr03A== 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=pGNysapJmQG4vrxgE2eKWvUNBAwgLkYOCBw7uNwQs6g=; b=JKW4sFmz/78r5Qz81/xGTIjCIHwAcbgGhYIxl/RoYL+aapqEy8DHXvfK6YKR6+zFhroyQzWFeLUeIzn/V2YjrEddKNGEt3EwGF+TnBOPAeA0ZH9FHsoTr15rA426h3aYD7B2v6XiqPNjRNsf/QAI1BmydmnDoTDstUoKU78ZjQ8RkEnzu2jBYSEXjj7aUeXwHX/dQhZFYYQhVqr88vnj9z7yuQh17O483HqaVH+Ya9Qv97xbiA2bl5XbuNFSzid/cLo9wW96/FnnnQHwZY7weWO1fJd2+oyXoSVzjrBH6zL9A4lTxCbnMkHwIHIgnw6xV/c4qhIislSGUZPvw6+BDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=pGNysapJmQG4vrxgE2eKWvUNBAwgLkYOCBw7uNwQs6g=; b=nmPTyMMep185hTvcUduQq8h0p+I8mU/GjnrKSD9/C+adSEP8jWq/QfK08U2OGOpCheilHLwx97kZeoDcKhpvR4OrVC2NvOJSuu0emJf+SZ22ZKIuEnzKmyBA1WKn3/DHeHUpdLLZZfzsDOnKzg6N6PV5lKEGuGns+HI/pmYK8eMtYdgYodnr/519xW9JaLGPOKZ8yn7wbX0v6V7Z8pi5K0Wfym2wmQW71IzSab5gqqC+8EdYxmGvDdBGfRJnp/H+oXw7RvQFdmM8dLDEP2S+aS0Qz7cGO4r/HwvR/V7sP6behb7vYZMe0Ti0daKxr67icPTDMVsEgChLhJW5hJBGlA== 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 BN8PR12MB3395.namprd12.prod.outlook.com (2603:10b6:408:43::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Sun, 6 Feb 2022 15:37:36 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::5cff:a12b:dfa4:3eff]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::5cff:a12b:dfa4:3eff%3]) with mapi id 15.20.4951.018; Sun, 6 Feb 2022 15:37:36 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, danieller@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 4/4] selftests: forwarding: Add a test for pedit munge SIP and DIP Date: Sun, 6 Feb 2022 17:36:13 +0200 Message-Id: <20220206153613.763944-5-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220206153613.763944-1-idosch@nvidia.com> References: <20220206153613.763944-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0701CA0026.eurprd07.prod.outlook.com (2603:10a6:800:90::12) 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: a28f4d15-1a49-4d59-a766-08d9e98699d1 X-MS-TrafficTypeDiagnostic: BN8PR12MB3395:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J7FCxa6AR5Kt85VkFV+cLt/JLXI1pMLP58s6OsHpkpffhmdMEdFVPj6qX1MxQxBpfrL2NhxiaKAV8yG9YQAQnO2zVbhnACqTuwXY33fKd/EqjugAstPBcqXS6+Kb+HBoD24BIBHlkj0E2KGhrMNf4u4A0+nmsJxjKW5dol/MZ9UEqfv8+0Ii6dkxI0BJW23egILtsiqe39i/UIIlnwAXMairk1VwJvgjSrYmyJXgO4bxeU/z7LQEyW+KlLK0plizHkVo5yBf9XXn1CclQtBlmXyMSX5gkUNv+NL5e1iN97B9rikA0oufiIbSceN6WrAKNC4PVOt5ij6qTFo56ekh1gmOwLkOhjOv6JWnng1/am0ghhZGoOjekTXgQeq5ZTn+cydt9GfXPLlsRbO7UdJemchx3fsEzmpO73rTxfIzAAxKefAMzjwXSZyw+6FbfnA/xl/4VTt3McFlw3eWb3p8rXz0quup0XAsLUxy91Zbe4iL1mbffYDpk0m9HJWTPBMDP5/OA87H2108jnm7sjdeO1tnQoj01UHkQQucfb2XlmiYcmQ1f+3AT66USX+o4k3DOa9k39ADIJ/umbLx45N2NyPESb3hxXLkdsPhTlpuORWc7EkzsBgSgJrV5T9aSGXjeKIPrasW+raJ/XYXReZUGA== 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)(6486002)(26005)(186003)(6506007)(6666004)(6512007)(5660300002)(6916009)(316002)(36756003)(8676002)(4326008)(2906002)(66556008)(66476007)(86362001)(8936002)(66946007)(508600001)(107886003)(1076003)(2616005)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iqszi9w6deIG7T5E2jXTTCtL0vNe8XRzafDLZWtgosjhQcxblL3aOBZGYXjC3PfD09UV/+dhwIE1fuqVzPv8mWVoioKxV9o03pR4RQp5wFMkgLFA8SWuiWD0gMEQ5kbSYNAN8V+rWsPgJ9DssrNNDKKzmJBP+koIDKa3xVNob7cIWmJroPC85GhrcQLwgaKWGLwDOXpfdw/iv4ciGcYjnJIyVgBl7Yn5Ihm9gGPWrOn5KFMvIIswuVZv1MLkGCh+JvLAolO7PWjEMYmWpphXWyXKz32LqZgrguonZ/E+LbfujjzfUxOcwiOaBJnuFVdKArDQTvjr4SwsZxkjt5g3nIGn+bkPIbDQbZmwbMUi9pm8HEM/Og0CaEkCNi+PsWc8GgYblISlxFHkg2VW9fXhaeUZi8uld89G4eKjfLtrEamaio2rv3vmyhfWTDDRHOe/ywAN1xXfnetsKIEWCZ/Mcn6CKrde8BBDEDU29FbdVSUuX22JCB/5iKHk2PIGFEHNeWwBbh8pwDaempf6b7LGQBB+jPxsOKIeW1/dA1Yaex8gvrome+nA54lRalrkPy7mWMy5NcpD5GFJhyqew0Mb97jKACI5SosT64EJDJvcXTEO2h/Mxhi6CVJ6U89NFHSNnBS8JMMJE+6tag3vOJjw5pSyKHkkTBndy7Z3w+yBmzymTMK9Pm1ZJQtDSs22YhqlIxLdR30SUjKCAshacFotEvywNA4En+IQh42tU/qOyJDTiWuvpQSZasnsdMTzkTj3vSemOR6mAfaTzjj91TjHpEl9d2++1+G7GCz5BbfLYR1Q4xXaWTqtwI0TUtzI0bEEJkR04xHnGf67yLcjBRAu6ZwWTmvONsDtscgIHsUWkr3KvJ81wGXET/trbFmXZ9bYZKFW0NCb2Qzt0Qzom/aX+ahhH8VtccIFsL5tZ4APcZwkCnXoPnfu4cNFo3t6FQKLuBhpAHJwhO9X/QrHtTnIlwYX/aAPQqLmoVLJ3RqG7UZamgyoe6bC/9Uy4sRIC7wXHpJ+0U8f97Fz3icOCf8yuECTRCMEVpNow1WwNmN3dKv46hM9CIf7p631GMWCGw6ek1r2Z43s/ZpTnMDbo8MF4trW3rmmxa3ISrpZMuErU12xXm4URftSEPHZ7fQ3ki/2dLly9K6CUH5zvu6X7LvX+P1VbtqKT29uGciwfX0nBNdRYOzvM7wO+O4eOutTgW0YH0+gZhi1ndl55RZ0PV2Nw5PZ9UvYSvUQ/eVlE++zSGCTq5HTuwpDMVoeZf0TcIzCOBo+B0/+NSKjv56wwYHaUoRtCRUde6N9t7YXpaP9CmAzuGBIEmt7NVe2RrytviSqCEUCd3K68AG9lnULntfQF4G4I0k+R4vpIhJdzWVojDbxPKmPU6dHYfLbJnPRw3t5q2AvuvepJWT8VJq71ci+41+lC5NGTBteaZisQ4IvLRs5jvksVNrn1YjMY5YLlbuNmllxUEKrhKvr9F5RBfvxHydQMQiuz/j6JPXxuf3vGzxty3Q/GVvKuAhq5Beu8uxC19cCba9Hkxt6d1PiRaOcRsRjvsmpvuakpWjD8zP0C304FR32r34nyn6V+3vZNLXZWGF+KWqMX1B46+mGz+VzbcqeRbzSv2zLGPcqMUx1YFo= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a28f4d15-1a49-4d59-a766-08d9e98699d1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2022 15:37:36.7210 (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: vg/MRmu0EnUspNnlXgXv5lHRKa3xG2dN5QNoUjDFKCKtPWEgvYpG5drFA5+jDLi2jVOhYLtItn0eM7xNabLeow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3395 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Danielle Ratson Add a test that checks that pedit adjusts source and destination addresses of IPv4 and IPv6 packets. Output example: $ ./pedit_ip.sh TEST: ping [ OK ] TEST: ping6 [ OK ] TEST: dev swp2 ingress pedit ip src set 198.51.100.1 [ OK ] TEST: dev swp3 egress pedit ip src set 198.51.100.1 [ OK ] TEST: dev swp2 ingress pedit ip dst set 198.51.100.1 [ OK ] TEST: dev swp3 egress pedit ip dst set 198.51.100.1 [ OK ] TEST: dev swp2 ingress pedit ip6 src set 2001:db8:2::1 [ OK ] TEST: dev swp3 egress pedit ip6 src set 2001:db8:2::1 [ OK ] TEST: dev swp2 ingress pedit ip6 dst set 2001:db8:2::1 [ OK ] TEST: dev swp3 egress pedit ip6 dst set 2001:db8:2::1 [ OK ] Signed-off-by: Danielle Ratson Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../selftests/net/forwarding/pedit_ip.sh | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/pedit_ip.sh diff --git a/tools/testing/selftests/net/forwarding/pedit_ip.sh b/tools/testing/selftests/net/forwarding/pedit_ip.sh new file mode 100755 index 000000000000..d14efb2d23b2 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/pedit_ip.sh @@ -0,0 +1,201 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# This test sends traffic from H1 to H2. Either on ingress of $swp1, or on +# egress of $swp2, the traffic is acted upon by a pedit action. An ingress +# filter installed on $h2 verifies that the packet looks like expected. +# +# +----------------------+ +----------------------+ +# | H1 | | H2 | +# | + $h1 | | $h2 + | +# | | 192.0.2.1/28 | | 192.0.2.2/28 | | +# +----|-----------------+ +----------------|-----+ +# | | +# +----|----------------------------------------------------------------|-----+ +# | SW | | | +# | +-|----------------------------------------------------------------|-+ | +# | | + $swp1 BR $swp2 + | | +# | +--------------------------------------------------------------------+ | +# +---------------------------------------------------------------------------+ + +ALL_TESTS=" + ping_ipv4 + ping_ipv6 + test_ip4_src + test_ip4_dst + test_ip6_src + test_ip6_dst +" + +NUM_NETIFS=4 +source lib.sh +source tc_common.sh + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 2001:db8:1::1/64 +} + +h1_destroy() +{ + simple_if_fini $h1 192.0.2.1/28 2001:db8:1::1/64 +} + +h2_create() +{ + simple_if_init $h2 192.0.2.2/28 2001:db8:1::2/64 + tc qdisc add dev $h2 clsact +} + +h2_destroy() +{ + tc qdisc del dev $h2 clsact + simple_if_fini $h2 192.0.2.2/28 2001:db8:1::2/64 +} + +switch_create() +{ + ip link add name br1 up type bridge vlan_filtering 1 + ip link set dev $swp1 master br1 + ip link set dev $swp1 up + ip link set dev $swp2 master br1 + ip link set dev $swp2 up + + tc qdisc add dev $swp1 clsact + tc qdisc add dev $swp2 clsact +} + +switch_destroy() +{ + tc qdisc del dev $swp2 clsact + tc qdisc del dev $swp1 clsact + + ip link set dev $swp2 down + ip link set dev $swp2 nomaster + ip link set dev $swp1 down + ip link set dev $swp1 nomaster + ip link del dev br1 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + h2mac=$(mac_get $h2) + + vrf_prepare + h1_create + h2_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h2_destroy + h1_destroy + vrf_cleanup +} + +ping_ipv4() +{ + ping_test $h1 192.0.2.2 +} + +ping_ipv6() +{ + ping6_test $h1 2001:db8:1::2 +} + +do_test_pedit_ip() +{ + local pedit_locus=$1; shift + local pedit_action=$1; shift + local match_prot=$1; shift + local match_flower=$1; shift + local mz_flags=$1; shift + + tc filter add $pedit_locus handle 101 pref 1 \ + flower action pedit ex munge $pedit_action + tc filter add dev $h2 ingress handle 101 pref 1 prot $match_prot \ + flower skip_hw $match_flower action pass + + RET=0 + + $MZ $mz_flags $h1 -c 10 -d 20msec -p 100 -a own -b $h2mac -q -t ip + + local pkts + pkts=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= 10" \ + tc_rule_handle_stats_get "dev $h2 ingress" 101) + check_err $? "Expected to get 10 packets, but got $pkts." + + pkts=$(tc_rule_handle_stats_get "$pedit_locus" 101) + ((pkts >= 10)) + check_err $? "Expected to get 10 packets on pedit rule, but got $pkts." + + log_test "$pedit_locus pedit $pedit_action" + + tc filter del dev $h2 ingress pref 1 + tc filter del $pedit_locus pref 1 +} + +do_test_pedit_ip6() +{ + local locus=$1; shift + local pedit_addr=$1; shift + local flower_addr=$1; shift + + do_test_pedit_ip "$locus" "$pedit_addr set 2001:db8:2::1" ipv6 \ + "$flower_addr 2001:db8:2::1" \ + "-6 -A 2001:db8:1::1 -B 2001:db8:1::2" +} + +do_test_pedit_ip4() +{ + local locus=$1; shift + local pedit_addr=$1; shift + local flower_addr=$1; shift + + do_test_pedit_ip "$locus" "$pedit_addr set 198.51.100.1" ip \ + "$flower_addr 198.51.100.1" \ + "-A 192.0.2.1 -B 192.0.2.2" +} + +test_ip4_src() +{ + do_test_pedit_ip4 "dev $swp1 ingress" "ip src" src_ip + do_test_pedit_ip4 "dev $swp2 egress" "ip src" src_ip +} + +test_ip4_dst() +{ + do_test_pedit_ip4 "dev $swp1 ingress" "ip dst" dst_ip + do_test_pedit_ip4 "dev $swp2 egress" "ip dst" dst_ip +} + +test_ip6_src() +{ + do_test_pedit_ip6 "dev $swp1 ingress" "ip6 src" src_ip + do_test_pedit_ip6 "dev $swp2 egress" "ip6 src" src_ip +} + +test_ip6_dst() +{ + do_test_pedit_ip6 "dev $swp1 ingress" "ip6 dst" dst_ip + do_test_pedit_ip6 "dev $swp2 egress" "ip6 dst" dst_ip +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS