From patchwork Tue Dec 14 14:25:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12676167 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 B6E03C433F5 for ; Tue, 14 Dec 2021 14:26:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbhLNO0S (ORCPT ); Tue, 14 Dec 2021 09:26:18 -0500 Received: from mail-co1nam11on2066.outbound.protection.outlook.com ([40.107.220.66]:44352 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229731AbhLNO0R (ORCPT ); Tue, 14 Dec 2021 09:26:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jbcP9JsPJ7esskv+iklFUsn7Lz8EISFjJpybGrjPk6wsmUigpQ5e/bjgG9+uKsGuCsbDuI5PC6Cyz3N1GhRBDdds75MDH1ExYIcTQNyeETddCpjVvl/nCWUrSWSSfwYOqnu839+IJyAINZmvIzq6N/OqSKBLJKC7KSL6TYqongKsFtnOO64mEkyTWquVePiUBK3saqBBbThsEyxMPog7zZRqN+6nJB0FpRkGlwZYwJSqFvGkWPwwY2Q014/Wda31QBL6RaUb7YCfyuFU6lI02o2G4xOZUHg8OIdp2tYKfVosuKIsc4xDY7N2Pr1KduW3pnAloSkXfAmdQDF79M9WqQ== 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=onKMOd4nll4q9oWeHEnwXRSCyMgt0QtiYaIdIhQmk5s=; b=Kux4x/nF4DvIOHK4FOaTkyxj1qbecPvf8pjzIc2uJclwCvW/7Wzap9c1ZHWCRDcPhwUOLTPgGRFTJfMbZuUkxsAScZDmRrUA47YH6D+kFFDxuN3O4vD7KkLIof51bFDGdWaf2FinaF/JD5PvgjY/9ne4y1pviB3QkW7wGJS16432E/zzxrEJrObXhkZQLurw2L/+OvsOdz6TR8ENOOlLXobKFWU8fU1JHVsDSwbUH6ghSCYWJfzAwIudl9ruZNk5vaZz/lUTjGpKayRXN/4z04ED3XqEhfVUJ/ph9ktNGHRrp+59JkkgiTKxeL00bZgI7+Q2I970lN1sLK42kdxAtQ== 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=onKMOd4nll4q9oWeHEnwXRSCyMgt0QtiYaIdIhQmk5s=; b=LFeSHE5xkT4MlbttBYxoiWNZysTQlXs+h5/9dWs5zeCLWP1YWvVCmuXnXnBmgbubUkp1obIMpnsdsjBtnMC7Ghe6qnhbarJ3yTi0Ik2ZS3yHEFVZmk4IUs897LIhSwke+fsGEo9ijsyedV4mPx2exeeCKOlpSl8aAr9bNytaMgY1Y1cEoa08ulQINF168W85JkuQtSYSLhZ3DP6OxfHW3q8eOmfNSxe+GVFy+IYhnBDNF6qQ7ryLtD6IHezrGiMFhk0QWbY0SgB+hB79Or6Z2iDjkki5wD+1x5hvc+jO5L136JLWBz+4XvPgWLQ7WkLfcO8G9DHs3aymHcF8GeAg2Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BY5PR12MB3955.namprd12.prod.outlook.com (2603:10b6:a03:1a2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.11; Tue, 14 Dec 2021 14:26:15 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 14:26:15 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 1/8] mlxsw: spectrum: Add hash table for IPv6 address mapping Date: Tue, 14 Dec 2021 16:25:44 +0200 Message-Id: <20211214142551.606542-2-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214142551.606542-1-idosch@nvidia.com> References: <20211214142551.606542-1-idosch@nvidia.com> X-ClientProxiedBy: MR2P264CA0114.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::30) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR2P264CA0114.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::30) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 14 Dec 2021 14:26:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8190e5a1-f480-4647-8e9a-08d9bf0daff6 X-MS-TrafficTypeDiagnostic: BY5PR12MB3955:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OMha30veO9lHo6nfhrFXqSyzz2PSSmULe9Lh1xJDIM0vHOisqHmjaZKXXBSIGjFgytJaGYBi02RozE9FHiF70AdFKOpSy8UMQkFisl4Bx1l2Ol44VBVtDoQEEFB5dtjaADUhM7XJ76KRMBO9GqjTzcDWIkwF9AEXBSpKz8XPkKnUTx6bUueo+HB0AWkkJhhWZgEBcztTx8Fu5kUMBou2NTb+Zm2L1/Ad2LTfH4v89H0oA7XmKcGzqInFjYxcDX39RveMGjL4Rf/tfjfjynYuV+rmFUruqSm1mxBRyp5u7e1Qcda85V6sQ5qZw+tz3QJnSihj+XLrqJoJ69fc8SaPs3eWxEVHlzkyyMkABF1pdkPlSPPUkDYbx8Sc3pK2BzOZtalrduPGqpu/QbN1KWL6ASxm0dCax2SySKvjNHUEUF7S/sh7ixyXHQi2eJgxz2d901kkDkgJkhBg/ZZM4ysOu+5JczS0lNegTGgJjLvfjfumaxLIzUEeOMmMszTN0AqzTO6GqphtTpVfmzyxye6NEtvEQ6SzT2WI1zhV1h91nMZ6OMg+aVV76P13cSkkRWDmGL3izEtcT0PEWjczXGsvKqYL2qfSuNFmADHGCBEPpaK+t02sZ5jOKja3tY8bGCDbeUim5WD5NjX323zu8OpXmw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(1076003)(6666004)(6486002)(6496006)(508600001)(2906002)(6916009)(186003)(86362001)(5660300002)(66556008)(4326008)(316002)(38100700002)(8676002)(66946007)(107886003)(66574015)(8936002)(83380400001)(66476007)(36756003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f6Df0va11trfIfOw25dPBRhOaawfo+FR597QKL2t5jzVRQC55Rk/Uz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O7cz4XYAznUV90rtwcvVPNYoiLsjTQSrlWjFmklZ2E2HehHPrxdBcS4NB1SjvD33oMREHNJ6L2rzbV84agpfZ5i2PkApL9Nzz+6GZhVFHoKudYdrHbut7V7t9VI6hZnQDyQ37B8lQ5A4xQermKNHt2NP/G56+/lrARQC1KIZNKJdvoZ7CO3GGgmMz+jzIm4WSsZmNwjBrmpStBJ69ZOPC23Jy4w3yuJOAnw/9tL/DE5AN+/En2ayxJh0TmpfgdliWeRFEY5XEXtj74tkB8u8YwBkccw2ya0ZFENLoFHfInyxq6cjXnmB46SJrFqZ2MqSxv+XoVyYyFY0L8ALS6Tox6qqPM4K2GSpR8I9Sgv/frpytASgdIL3kzEc8RQ8f7wNfEC9PACMA4dmECCvfuZPe3yLNeonGo9+MYuGr0C0VmacB7GMErQ7Rm8ZPoe1KtUwY709ht0951r0bBlaqXSdxC+753nn+hkA7gOZnzDrHuP7QhJnAlzf4yvQ2tSFnHvrx10DjxMCcqfTSx4YGGUKV3xdjo4xcXl9D98x+YxcqCve9064uezP7w410jpk= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8190e5a1-f480-4647-8e9a-08d9bf0daff6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 14:26:15.8849 (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: FaAUzxP5j8elGX6TN3ejoE0FGZa+eh66fzoToIKlsoLtgdbcfWNSi/pU+HlzlZptuUzpEpm9HzuqJCsCIUrVew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3955 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen The device supports forwarding entries such as routes and FDBs that perform tunnel (e.g., VXLAN, IP-in-IP) encapsulation or decapsulation. When the underlay is IPv6, these entries do not encode the 128 bit IPv6 address used for encapsulation / decapsulation. Instead, these entries encode a 24 bit pointer to an array called KVDL where the IPv6 address is stored. Currently, only IP-in-IP with IPv6 underlay is supported, but subsequent patches will add support for VxLAN with IPv6 underlay. To avoid duplicating the logic required to store and retrieve these IPv6 addresses, introduce a hash table that will store the mapping between IPv6 addresses and their KVDL index. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 143 ++++++++++++++++++ .../net/ethernet/mellanox/mlxsw/spectrum.h | 7 + 2 files changed, 150 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index fb06b2ddfd6d..5251f33af0fb 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2755,6 +2755,140 @@ static void mlxsw_sp_parsing_fini(struct mlxsw_sp *mlxsw_sp) mutex_destroy(&mlxsw_sp->parsing.lock); } +struct mlxsw_sp_ipv6_addr_node { + struct in6_addr key; + struct rhash_head ht_node; + u32 kvdl_index; + refcount_t refcount; +}; + +static const struct rhashtable_params mlxsw_sp_ipv6_addr_ht_params = { + .key_offset = offsetof(struct mlxsw_sp_ipv6_addr_node, key), + .head_offset = offsetof(struct mlxsw_sp_ipv6_addr_node, ht_node), + .key_len = sizeof(struct in6_addr), + .automatic_shrinking = true, +}; + +static int +mlxsw_sp_ipv6_addr_init(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6, + u32 *p_kvdl_index) +{ + struct mlxsw_sp_ipv6_addr_node *node; + char rips_pl[MLXSW_REG_RIPS_LEN]; + int err; + + err = mlxsw_sp_kvdl_alloc(mlxsw_sp, + MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 1, + p_kvdl_index); + if (err) + return err; + + mlxsw_reg_rips_pack(rips_pl, *p_kvdl_index, addr6); + err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rips), rips_pl); + if (err) + goto err_rips_write; + + node = kzalloc(sizeof(*node), GFP_KERNEL); + if (!node) { + err = -ENOMEM; + goto err_node_alloc; + } + + node->key = *addr6; + node->kvdl_index = *p_kvdl_index; + refcount_set(&node->refcount, 1); + + err = rhashtable_insert_fast(&mlxsw_sp->ipv6_addr_ht, + &node->ht_node, + mlxsw_sp_ipv6_addr_ht_params); + if (err) + goto err_rhashtable_insert; + + return 0; + +err_rhashtable_insert: + kfree(node); +err_node_alloc: +err_rips_write: + mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 1, + *p_kvdl_index); + return err; +} + +static void mlxsw_sp_ipv6_addr_fini(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_ipv6_addr_node *node) +{ + u32 kvdl_index = node->kvdl_index; + + rhashtable_remove_fast(&mlxsw_sp->ipv6_addr_ht, &node->ht_node, + mlxsw_sp_ipv6_addr_ht_params); + kfree(node); + mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 1, + kvdl_index); +} + +int mlxsw_sp_ipv6_addr_kvdl_index_get(struct mlxsw_sp *mlxsw_sp, + const struct in6_addr *addr6, + u32 *p_kvdl_index) +{ + struct mlxsw_sp_ipv6_addr_node *node; + int err = 0; + + mutex_lock(&mlxsw_sp->ipv6_addr_ht_lock); + node = rhashtable_lookup_fast(&mlxsw_sp->ipv6_addr_ht, addr6, + mlxsw_sp_ipv6_addr_ht_params); + if (node) { + refcount_inc(&node->refcount); + *p_kvdl_index = node->kvdl_index; + goto out_unlock; + } + + err = mlxsw_sp_ipv6_addr_init(mlxsw_sp, addr6, p_kvdl_index); + +out_unlock: + mutex_unlock(&mlxsw_sp->ipv6_addr_ht_lock); + return err; +} + +void +mlxsw_sp_ipv6_addr_put(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6) +{ + struct mlxsw_sp_ipv6_addr_node *node; + + mutex_lock(&mlxsw_sp->ipv6_addr_ht_lock); + node = rhashtable_lookup_fast(&mlxsw_sp->ipv6_addr_ht, addr6, + mlxsw_sp_ipv6_addr_ht_params); + if (WARN_ON(!node)) + goto out_unlock; + + if (!refcount_dec_and_test(&node->refcount)) + goto out_unlock; + + mlxsw_sp_ipv6_addr_fini(mlxsw_sp, node); + +out_unlock: + mutex_unlock(&mlxsw_sp->ipv6_addr_ht_lock); +} + +static int mlxsw_sp_ipv6_addr_ht_init(struct mlxsw_sp *mlxsw_sp) +{ + int err; + + err = rhashtable_init(&mlxsw_sp->ipv6_addr_ht, + &mlxsw_sp_ipv6_addr_ht_params); + if (err) + return err; + + mutex_init(&mlxsw_sp->ipv6_addr_ht_lock); + return 0; +} + +static void mlxsw_sp_ipv6_addr_ht_fini(struct mlxsw_sp *mlxsw_sp) +{ + mutex_destroy(&mlxsw_sp->ipv6_addr_ht_lock); + rhashtable_destroy(&mlxsw_sp->ipv6_addr_ht); +} + static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, const struct mlxsw_bus_info *mlxsw_bus_info, struct netlink_ext_ack *extack) @@ -2843,6 +2977,12 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, goto err_afa_init; } + err = mlxsw_sp_ipv6_addr_ht_init(mlxsw_sp); + if (err) { + dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize hash table for IPv6 addresses\n"); + goto err_ipv6_addr_ht_init; + } + err = mlxsw_sp_nve_init(mlxsw_sp); if (err) { dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize NVE\n"); @@ -2944,6 +3084,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, err_acl_init: mlxsw_sp_nve_fini(mlxsw_sp); err_nve_init: + mlxsw_sp_ipv6_addr_ht_fini(mlxsw_sp); +err_ipv6_addr_ht_init: mlxsw_sp_afa_fini(mlxsw_sp); err_afa_init: mlxsw_sp_counter_pool_fini(mlxsw_sp); @@ -3075,6 +3217,7 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core) mlxsw_sp_router_fini(mlxsw_sp); mlxsw_sp_acl_fini(mlxsw_sp); mlxsw_sp_nve_fini(mlxsw_sp); + mlxsw_sp_ipv6_addr_ht_fini(mlxsw_sp); mlxsw_sp_afa_fini(mlxsw_sp); mlxsw_sp_counter_pool_fini(mlxsw_sp); mlxsw_sp_switchdev_fini(mlxsw_sp); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index ef4188e203a0..80580c892bb3 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -203,6 +203,8 @@ struct mlxsw_sp { const struct mlxsw_listener *listeners; size_t listeners_count; u32 lowest_shaper_bs; + struct rhashtable ipv6_addr_ht; + struct mutex ipv6_addr_ht_lock; /* Protects ipv6_addr_ht */ }; struct mlxsw_sp_ptp_ops { @@ -587,6 +589,11 @@ mlxsw_sp_sample_trigger_params_set(struct mlxsw_sp *mlxsw_sp, void mlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp, const struct mlxsw_sp_sample_trigger *trigger); +int mlxsw_sp_ipv6_addr_kvdl_index_get(struct mlxsw_sp *mlxsw_sp, + const struct in6_addr *addr6, + u32 *p_kvdl_index); +void +mlxsw_sp_ipv6_addr_put(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6); extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals; extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals; From patchwork Tue Dec 14 14:25:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12676169 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 4E6E1C433EF for ; Tue, 14 Dec 2021 14:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231845AbhLNO0Z (ORCPT ); Tue, 14 Dec 2021 09:26:25 -0500 Received: from mail-mw2nam10on2066.outbound.protection.outlook.com ([40.107.94.66]:4065 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231143AbhLNO0Y (ORCPT ); Tue, 14 Dec 2021 09:26:24 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JbN3ygF8J2HqTj3gNu2Xul4+68G9MlfwjsctT43rE89drIZD2umR6zHzVs2wy4KYexu23NwJgWPGDWCHD3v7isba45B6fbLDMoqxAHSMuBH0OsR2o+lJf4z72idpgmYJbL6YLlVSnMGyebIjK4IjZxqyyzN+VRRLlX4oTnmzsVyUV5OaFu3n9fA//XH67EQcJJo7det0vD6lY6PntMsJm8iRYFjU9iv89XUhNMc6kPc1VVvU6mplK/vonXqqmvuQRsqZaxz9cYpgzuGeKFMpNXIf0yzmo+cKlo39xbgPcnZZAjtnZ0Be/vqdwsBIgjq0BgT8Ym92MFa7TrU9J2o3bg== 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=z0svjKxQIOQnp00aY8PgIwlewMwcRbNN4wmNZv4CGe0=; b=MACa2/ncYWPaS9hvTtwiOg3hebEwYLZW7E3BiA1jzogg5itIxEHU+GANKnMGhHxulu8EJbf5nWpFGP2t1ZOl4hHARKz6k2WXKDqXbTONmtJSYrizJcGBKvUGUUqjwOPwbHrArTUY1k59Xh7v0bwRf9pLHMbjmk89MsGZWhh4M+F0/oefhVi3ozuiNIKm6hKYxED4ZYffy4dkZDGl7m67TB/xvVKCDYUveoZJKdGFYlkhVGfCst1sTMD7iaaagWB7l1tK1DRLfdcKJgrsWe+5VCMHQO5OTd9c7ZhY3dd0bdcW4Qe0KpSi190gc7RtIWhZUwBkj33F9GYgp16cHoA6+g== 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=z0svjKxQIOQnp00aY8PgIwlewMwcRbNN4wmNZv4CGe0=; b=VEaW9j33t9Ww2FLVWiXCD+Bsr+s9rGlSUo0NNLtMGRWM3pSrXTEaW+7TPqIDKg4n6VKFZA90NBxEJGRV7jrhOM3el2DnvLQMQCtBVeXcpNCHGfSDjvKKxa2XNvE1z38SwdLMQ+/R+FqHFfcV09LD2FYzvrySlbWNCvoaHHIVkNQ4x0oYw7CaOrr7QlgHrI8HHQUiQFTd6gjZYFcsluFDx13puICsNOve9hksLCsMxHcVGVD5bQtg3M9HR0NjKQgUOsmTaNEy3DY3IGC7UkZerIo6ueHxTTVVTyZQ/cSD5lv0OweESg6AEDDjMOfJW4pr0G+lawzn4htvy+5Qm/qNOw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BYAPR12MB3031.namprd12.prod.outlook.com (2603:10b6:a03:d8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.13; Tue, 14 Dec 2021 14:26:23 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 14:26:23 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 2/8] mlxsw: spectrum_ipip: Use common hash table for IPv6 address mapping Date: Tue, 14 Dec 2021 16:25:45 +0200 Message-Id: <20211214142551.606542-3-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214142551.606542-1-idosch@nvidia.com> References: <20211214142551.606542-1-idosch@nvidia.com> X-ClientProxiedBy: MR2P264CA0184.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501::23) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR2P264CA0184.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501::23) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 14 Dec 2021 14:26:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed43afb9-a147-48df-2371-08d9bf0db42c X-MS-TrafficTypeDiagnostic: BYAPR12MB3031:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qq7vE/Fklfy2Rzb7zKjj60hk82ZRg/v6UX74b/+4KOQLzdzIyLaVlbwGdKH4C32pweyLa2vyZWc+v7gz1yxrUO8Bc7C1XZBFbEQWQKcrSRTJYL2ljgihmDWM0TSz2iM53V1wXKyzS8XQfvIauH3P8PZs5a/pcZlHGW4hqyHlfETthtd9wVrE5HLAxOZAIUmb52H7ijEQ9o8HtrDEnNc6yNYyB0BR6l7PtnmBy9T7yNMvrK3LEBrOcKxtr2Ue+lWLG8HiNvzdGB+32BwlSmynIxMLnQQOlGwC9aJdvrSFW5Qjxa+Ktzgzj49ewWRX0upu1oeuT0YZSTt1L6Z4b3M5zeOT4zXHwlcvX8FzZAOmvyIEWOsbKWzYgjzR8WPnyOAmjTOrEcn+oD3Gxq4mZsWG8OFxvn7ENNDdsG+BYHhMBP8iIK9jYCXGyIliZeDZatPvUwuhzmUMFqIDjwtmURMaIHrl7H3WWe4jHt4DDiOng4kpDmWznOin+JYuONR+AOvCKiZ7/vVtxRXBDRz8du7dSn9haG3OkMbTzy+EPVuKMwsswry1H5p8f93e0W3bkPXhcpBT+zbKpyAu1/d+eLzYIIIA3XwPubaFATiLT2aRZTZ1aqISZ6QnjpIVwj4aIGDznarja5KsGgMfyNU0NuWwiw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6666004)(66946007)(6496006)(508600001)(8936002)(83380400001)(107886003)(2906002)(66476007)(66556008)(86362001)(186003)(38100700002)(316002)(4326008)(8676002)(2616005)(1076003)(5660300002)(6486002)(36756003)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XX0mdHh9JUtJk69257NPMQL/NUFaqbCDGXHLRpUjl59U+Fd7igqrF3jS8SzG7RXKWXOSp+7s+7aPlb1QaSxS19wEHsdFHvuNXgZmniPb9qAe/EUzNgxMlkZJZ8mCjRQG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KzSteCiB71ixo2hwmVV8+fR/EOaf5Za2PuZCQUq/Cw2iOnqMx2hhc9PXieoFRWDON3wRGXJjBOVXE+QNiDhhe3V7DyWHVuM8GhFHvxHUOzncE0FiomyIEUbayfkwe8hyCZHjEaKWNCtWIxCNgAlffyK44IJZTjzg47ucYCAvbQymIj4jah70qxxspg3VQ1QY2ozjBOjismSfWk+kCumLHolVQYPJsLL0KwMvRxbpnNuauL3w6hYTC1lZg5fN5SqayFr3S8cXrrW6DkaePDe+xUT+bkRYlg5B28/qkePVAAZSWgrdZbWkgZo/pHDWwVAvcjAYrD6zlHOnuFObUrQAxE4Q15OgmRs7VA4HMJTHj0DhO9D+T3Ot3i46VJg8pLys6rV8LwHNlWaSlk/TvEqwSl/GBqplUcuua6G06WM4zxJAI0n+/FOLM9mRyt7utzsrDx2CCijOIo7WnoGfP7OMgDNndzYUSzaZkI06EM7+Av9ujc= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed43afb9-a147-48df-2371-08d9bf0db42c X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 14:26:23.1032 (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: dvEC8Q7GWz9cTQlAZvEjDkR4vbwpGzJLUP2mSxnYGoyGpNVvvPR3fRk+4o0I937pq+rUVv2MgRbT48QcRCzN8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3031 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Use the common hash table introduced by the previous patch instead of the IP-in-IP specific implementation. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c index ad3926de88f2..01cf5a6a26bd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c @@ -568,37 +568,21 @@ static int mlxsw_sp2_ipip_rem_addr_set_gre6(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_ipip_entry *ipip_entry) { - char rips_pl[MLXSW_REG_RIPS_LEN]; struct __ip6_tnl_parm parms6; - int err; - - err = mlxsw_sp_kvdl_alloc(mlxsw_sp, - MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 1, - &ipip_entry->dip_kvdl_index); - if (err) - return err; parms6 = mlxsw_sp_ipip_netdev_parms6(ipip_entry->ol_dev); - mlxsw_reg_rips_pack(rips_pl, ipip_entry->dip_kvdl_index, - &parms6.raddr); - err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rips), rips_pl); - if (err) - goto err_rips_write; - - return 0; - -err_rips_write: - mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 1, - ipip_entry->dip_kvdl_index); - return err; + return mlxsw_sp_ipv6_addr_kvdl_index_get(mlxsw_sp, &parms6.raddr, + &ipip_entry->dip_kvdl_index); } static void mlxsw_sp2_ipip_rem_addr_unset_gre6(struct mlxsw_sp *mlxsw_sp, const struct mlxsw_sp_ipip_entry *ipip_entry) { - mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 1, - ipip_entry->dip_kvdl_index); + struct __ip6_tnl_parm parms6; + + parms6 = mlxsw_sp_ipip_netdev_parms6(ipip_entry->ol_dev); + mlxsw_sp_ipv6_addr_put(mlxsw_sp, &parms6.raddr); } static const struct mlxsw_sp_ipip_ops mlxsw_sp2_ipip_gre6_ops = { From patchwork Tue Dec 14 14:25:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12676171 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 556C3C433F5 for ; Tue, 14 Dec 2021 14:26:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231863AbhLNO0c (ORCPT ); Tue, 14 Dec 2021 09:26:32 -0500 Received: from mail-dm6nam12on2081.outbound.protection.outlook.com ([40.107.243.81]:62001 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231909AbhLNO0b (ORCPT ); Tue, 14 Dec 2021 09:26:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bW7mHp46LLpn1oVbv3z+YGuAfhgHLrhve4LI6buZHP7QGnSch/hC/UEWBUQp6ordJPGP6KHANzHqkn9zPyf4Gd8Z5bGfjy0e9gwpzxAQ75c8bl7NwJRSVuxQM4OeuOc9MxKXnn2Wyro6lMGbygCt6NDSpHF4DNTtRrQSG9yK3bshsLQUZkUOXq6K5WvQ1oJzjh7yaCe5q0f/sPUkKzesFQMkj+yhjV8IoSWmYVC58ML0+jpPaVbWcM/4aGt4qf8/grvcpj61mhjpmbYFNs0+KKuC95KKeolyyapvF1bweyBfq+AEpkWMUSay8I3fV8FaNhmAudMZvySWwf+3tGHDKQ== 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=XquaiKsjOoyFTCTgQ/mJwXP0G/3qt/0YelHgenQaNqM=; b=T0TDf74SSMBjmENtK0cFZf6bi2LVpErgaa1NXcjxrG9WH88ApXvHL46Lhxy6MWMO3VLuUsLN6i6Zu+ql6q2s5yxyIaCOLf667FNuZocLW9t3HDCRTlDJ5p95fv+3qUnk4K2Aj94eoTp9mkOrTk0YRUMiuGkppv9Znkitf0AxEh/o6mw8FBegoAmgkL3KAPkEbJ14q1Mvd4xQw8/UEEUgi1Fe9BQxfJmY1nB2kxhw7N1HZseMy/vXfEQbdUHjPEXqUIlD8vMJgBpBHMECdbIg/BI7b41CkM5NQooqAWdLCZYGbRhhnedv1YiffZJboZ3suLFvV9x0Y+Ojc9sR8zfncQ== 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=XquaiKsjOoyFTCTgQ/mJwXP0G/3qt/0YelHgenQaNqM=; b=U1lMQhroz5RGjTFRPYy6qqEHENrPqBMP9YSNYKnnAaF5NmWsKu3+JRgfr+TJp1kKduCiXoMnndptWNPbosKbO+fgB4Dl8kRjLBhsumhoP5AgbssAjF4MY5huTBqPdHOlbiJjKHLZaMxZ6gC+NQajhE92Wv4VyfZa12osHk9R9CNnbCkXNqJd2Hy98aSmfJtDWWFlTiYEJbEdIrWTgmiHnitFfYBE4T/QCUBsAlSuZ+yAd57EzpQGEcwyjmgrXFjGJHwFm6ppUIm9tCVcGvUq0xd/tT5gcU7mftjQ8OXYpVzCW7KpwPzksjiPE0ja7xuSoeqpAe4a6sWX+LFf8kyvcQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BY5PR12MB3955.namprd12.prod.outlook.com (2603:10b6:a03:1a2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.11; Tue, 14 Dec 2021 14:26:29 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 14:26:29 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 3/8] mlxsw: spectrum_nve_vxlan: Make VxLAN flags check per address family Date: Tue, 14 Dec 2021 16:25:46 +0200 Message-Id: <20211214142551.606542-4-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214142551.606542-1-idosch@nvidia.com> References: <20211214142551.606542-1-idosch@nvidia.com> X-ClientProxiedBy: MR2P264CA0065.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::29) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR2P264CA0065.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::29) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 14 Dec 2021 14:26:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 399f24cd-ba36-4003-4581-08d9bf0db82d X-MS-TrafficTypeDiagnostic: BY5PR12MB3955:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gI2GRpj29OpZ+wKya62f4e+JmvGDC8Esurx0iBOJhk2oNf+b+KEIfZBypZNQvs/4RxR7lmLkL8G7FbFHaWctBgq6+S/mCXGsXCHydJ69f+8Zlinl/+Skez0laKeM/ok64Yx+5KPus3MPlE9DaIZINbQbz5H/rPVQxBFQ5fnoTKmKZkNCDPYFyZ+6IeI3YMJM4xDNL6IvSBwjwYfmAO/HhWMl9jamE5/KC1lHgtppifoqfSSXAarMFBosY7K05UGhndagnAixOcu0kJCKTyMGrEKW54M/egUo7zFXUqGaroPIslY3NJyNvo8/QW3OOEOag6EgxAh0KXyLeHokjPaFdpkYgbs1uMt236gq+0hA46wr08tGs3bqcrvlKM5PHCtQTbPKtI3VN4xZWfz73Re8nNo6tlMnVGsIuTY3y1F8/ovo7mvazyyQ2er/K/BuLlntxUuPI6ik8A8tNP7LbNPTp4JlmDw/yxINYRBY/rvqtGz/IQi+VBQjCrl+mddr6W++VkEx3272a7YhX1Zu2AYILSrN1ua+LV2N/oxjdxhzjVn/H6iGm8SCgrNvRICb0Dwm3X/W94N8Dt7FEMiL7FHwCrTA7Hd27QYijN1bdxBdAfnqw5tpVv3X5DJr8C58qeyf481T/irXvJegiCfihypttQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(1076003)(6666004)(6486002)(6496006)(508600001)(2906002)(6916009)(186003)(86362001)(5660300002)(66556008)(4326008)(316002)(38100700002)(8676002)(66946007)(107886003)(8936002)(83380400001)(66476007)(36756003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-Mess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oVutz91DrhndCYgvaxT2RlBSjuGzfPUGl2GSh03RXt9tO+4GPb07Bd5dhBX53tj6RtxG/9mxC/LHmT9V0koQyR31Vz6cp26BfREnj+EO4VuhpNMy+2SmkPrH3U1D4FizbyQTuQJZ/XI/k6fMlENLHj9+3oT/HUYEnIi48iBF8F0CUFWzrO9lEZ8QY3LnuXN3Go8GAypSb3wLl3kfPWXCWOi+Q82K+KpO8OnNSZ4+rc1fQjcaMawGA5AhC8JrMwwtjo+l4DB8Mz2QmV5fcNvWOIrETZkOQZ+jx/HFlQ6CGTe7wW7jhUIrqJY9YE4InGbnVtSt0N8Cdb0vqM4CSlFUc2T/VC/N+gFCRj3ZLEhQWcplI7GqwQaMBscqOSPRWPngfnvYEJ2gVlk20BP+t8uOYjZjglBRxgGQ0E0GUhTj7pBgxSitkJ5qw2jF+ai228KyIcJJ73cfgq4LPQzA0JlIKQDPXQWIlMHwMs48fIimCnV1u8F+VGFH2kcaA3u3leh+QfJkpvH+9LxWZn9upJtKXzW0AW7qU0bSxiH9zMhcQus4E53ps1IXxhKk9Qb5gqIaY8v1+Gr92/uChamDtCZw7O38zYJqL9MyoQCylNSrL0eoQp6xNODcqgc34IGehr5oziBKvz5uGyVbhS9d8cW+vY0sl/o= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 399f24cd-ba36-4003-4581-08d9bf0db82d X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 14:26:29.8059 (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: Ibj/79thuWUkzs/ge1OnzevWf0F1vTYoqQUCM4oXwakdo4P0AbtAbgqGuEHW+AsN72wmQ5JvFuF7a6lWiWv7yg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3955 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen As part of 'can_offload' checks, there is a check of VxLAN flags. The supported flags for IPv6 VxLAN will be different from the existing flags because of some limitations. As preparation for IPv6 underlay support, make this check per address family. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_nve_vxlan.c | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c index d018d2da5949..766a20e05393 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c @@ -10,9 +10,25 @@ #include "spectrum.h" #include "spectrum_nve.h" -#define MLXSW_SP_NVE_VXLAN_SUPPORTED_FLAGS (VXLAN_F_UDP_ZERO_CSUM_TX | \ +#define MLXSW_SP_NVE_VXLAN_IPV4_SUPPORTED_FLAGS (VXLAN_F_UDP_ZERO_CSUM_TX | \ VXLAN_F_LEARN) +static bool mlxsw_sp_nve_vxlan_ipv4_flags_check(const struct vxlan_config *cfg, + struct netlink_ext_ack *extack) +{ + if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM_TX)) { + NL_SET_ERR_MSG_MOD(extack, "VxLAN: Zero UDP checksum must be allowed for TX"); + return false; + } + + if (cfg->flags & ~MLXSW_SP_NVE_VXLAN_IPV4_SUPPORTED_FLAGS) { + NL_SET_ERR_MSG_MOD(extack, "VxLAN: Unsupported flag"); + return false; + } + + return true; +} + static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve, const struct mlxsw_sp_nve_params *params, struct netlink_ext_ack *extack) @@ -55,14 +71,11 @@ static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve, return false; } - if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM_TX)) { - NL_SET_ERR_MSG_MOD(extack, "VxLAN: UDP checksum is not supported"); - return false; - } - - if (cfg->flags & ~MLXSW_SP_NVE_VXLAN_SUPPORTED_FLAGS) { - NL_SET_ERR_MSG_MOD(extack, "VxLAN: Unsupported flag"); - return false; + switch (cfg->saddr.sa.sa_family) { + case AF_INET: + if (!mlxsw_sp_nve_vxlan_ipv4_flags_check(cfg, extack)) + return false; + break; } if (cfg->ttl == 0) { From patchwork Tue Dec 14 14:25:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12676173 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 DE672C433FE for ; Tue, 14 Dec 2021 14:26:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232455AbhLNO0i (ORCPT ); Tue, 14 Dec 2021 09:26:38 -0500 Received: from mail-mw2nam10on2055.outbound.protection.outlook.com ([40.107.94.55]:45377 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232444AbhLNO0i (ORCPT ); Tue, 14 Dec 2021 09:26:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EVfk8kJoA3Wjgt+LI84qhvzA/pVsHUH9u5+zaEXC65uhxj2UNUXxSkXixOghxtUEl3xqgCp2+4dUPV+tySVvdR0yjc05CsOUEFGH34Sdb4XoqyJEeaP+9+E2NeFYLsynCwaMR+vp7uLrSMURHhQ46MpPKNpcpM+GzSMlnO26IjQc7Jvv3cxB3ezvWYAnPljQkMWghvlXbmYNZ2j6WMlOqHtHC5Z4nna5OWJLGYSX69rdTyqXGmyO/5Y8xrj413XlxH1p43TMpoQmRAEL2+Jv6C8ZFs9FtsdzBXz8fExUAsX2SLNt0xUW69mMb9Fy0pXCYazMJ+o7L1G22mXvU/Oh/Q== 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=dSP/DwCcOdy+SH368Pc/Jojf94WmSDoHhr42tlZ7zYs=; b=SgZqDbHcOgbQtFdOnzEpyJjxr/rRo9CuIkvhCGHP8TmDLb4V6yxqY+a4gHNAK1H9gheBgx92Zigy53yK/Aa9lgOPmm5+CeBOOHAR6ncz5UM0cdnL53evmlfid+NZ84efyAeba6FUvHdIIEFAlLqUOMzcL1zAGr2CggYBX7hCwgmbK6x1cJiiAM4MNuBeYfTkgzmCLHBWerS4BrAGtHGN1ZOkTyxBR6tpzKtCD4atlowoxPiIOV8XvKN87fEqmGQICurWYJLDjlMkyY6J1OaXSomWHfvbpB53rdWd6PtT1hhHAAjHJRt5SrtVQzk4hosyrJIpohQAHqkO++BBM7eCwQ== 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=dSP/DwCcOdy+SH368Pc/Jojf94WmSDoHhr42tlZ7zYs=; b=A5pcT86HneUi3vXpyqx60lfk7WbgybUSE6X1clezE3tgL9stflDEY4PWCMg1jQPNbjz7yELFGXPS2hBIaZLQT1EIu1p530AVLf6WPeL1LT8wD14Ou9vpBkJgmIow2kC67nfgf5zM5CoAzZ4p8ab34spLyuwZzdoj8XLM3cBUVTmxkc0+DwKpYvXoqG9Y62uaRyytnXfuzTX1pP6XuiH26Yh1UWHkuE6PUT6Xy2CzBHyrlXAEDaXakyX78VfPMR1noDvmEjT4TFCaJN9Dzxq3r2He8SNoWJHRTNWY1AipaB38P+KngcAeuzzOsfG8UxYBQNG/VN1HFJ+ZMlQG4S09uw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BYAPR12MB3031.namprd12.prod.outlook.com (2603:10b6:a03:d8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.13; Tue, 14 Dec 2021 14:26:36 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 14:26:36 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 4/8] mlxsw: Split handling of FDB tunnel entries between address families Date: Tue, 14 Dec 2021 16:25:47 +0200 Message-Id: <20211214142551.606542-5-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214142551.606542-1-idosch@nvidia.com> References: <20211214142551.606542-1-idosch@nvidia.com> X-ClientProxiedBy: MR2P264CA0047.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500::35) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR2P264CA0047.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500::35) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 14 Dec 2021 14:26:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ea9d8c30-8282-46df-7829-08d9bf0dbc60 X-MS-TrafficTypeDiagnostic: BYAPR12MB3031:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DzBlLhMUluKKwafko2corUfaB5Cy5oNUSxeKGMey8Al1HYxTkREy3lKEU52XkEphfnQSc0sWZSC4kSPlXR9l7WiNuKzQTr1nwPpisQYTPZbjDaWBQIk5gKo+H46ULSUGZRW0vu7gzFhJwEV17wizsqBdlO6Pl1Qyb/zWmAKBRJ+e5gRlhnIQ1fXsjByN+SapoHskm0cs4CTtXel+OkVNGH7Ddc3IHmSV0egij7o6oduBtn+VPu4RlrWTSxfCXrqGwQAU2vw91k+rgg0JQwpDixGxtbXFAwTN3+meW3Fq62uKKPkTrrhcnvkXaVFLbrHGIMypTLLn9Gf1tSLr0ImUZTFHXx9UOODCt7mUrr8vkmSsZ8HCd3c4YAKIyWSwrkcjUivP6ewfARkg/9tnNQTkOz/Vc5Y8tksPt9zXoB78lrqely963iJbd1H5ZnS2hLxOVnf46UTyHh4J/bOkr2Z/BiTElFYm5HflR3A2iFJI4JtWNWLLE2ZErFGSwVrSiwpEpo7o/UOY1OkAYzQ7LR7wDcCHainw/19alJTplXN7OAAAonH4XD/FDh05JcDFd3IlwQhI3ZiVkkNfj+UdN3KHHV/KjvAzowq0PcQG+DhC9tpqECEwXnVfBzzE4PEM0Tg9FBf+JVgq02B5b6tgmXjXJg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6666004)(66946007)(6496006)(508600001)(8936002)(83380400001)(107886003)(2906002)(66476007)(66556008)(86362001)(186003)(38100700002)(316002)(4326008)(8676002)(2616005)(1076003)(5660300002)(6486002)(36756003)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dkfof1zfop9b2bFRQmFP7AQcq8+mGFYqBgp7wTEV+yN0P+9BL+3KJamEX2nVBQTSZiKvbTWERoSD6sSZy0jBox1N0DgtBmE4X6kc0xEeq2fcuo+n0JnLzqB0/YlD8HQRrETu9aIjf44ON0aDxG4EJwp3xdyFhMwbVKaycq+MoaxfYozaA4tblENQJll7bqwTs5NO0rFe4UIXPs9t5RyX8wsexJHm5L7Ej0kZZv8iBmBxH7ziFX1yN7ShjxMClPD7MRxpEtmzd1Wy2DJPvyVJYw7TbZm7eC32rx0/GM4HuHM5LWhDFrZY+a2kgXnDxip5wrs5MkDxBCMVtw2xR6hVmWRWP6iHHcTk53UljfPPZj8sy1A1q3Z10jLim5XQ1jP5BOBYKZ/4+Y13Vx8WZDuX7Fmx7j9o/FyWu2mCjwy9GJaXVWGuzTi3xDRb4Ye8tlDPQvT2lBcffsVWZ2vCE9KzQyM9ibMuZUP+O7mE12JL1A3z401OJCC4o+4SA93vnKDS1AUguyyJyNE5QRuKvJJ7oJJGPG3fYYIR0IPn8DnrB70dUOORLxJkK5dti7owNrtk4LmsrP11KZCkR8on+GX6x5hsV2zejX/vx5SksD5dOFUaew5VgFi57NJWuaB1pJ28khKmSkLyt9lSrS/SxJo2h/vUnuyuAo1pkxLC0bEt7X0tBGR1u3+DHyosDbFfSqDxNsLD9TMvtdou4Bdj7eX/HOW4yM5YxxjXN2l3JlZu+jMw/LsAqj54DtYFL7mnALJi5RluYCCaNapP+6ZIa/VugR9R2nqHqxpgg8CWzUOGvEIv4rpkUhASYTKImbqpzVZhaB4tjPpxe6R/FRo4t/syDdESoLAjkEd1KsqP7AiNhHzTupawNstitVA0l0+fLwSbgfRCEv3I0E2jvxiW6ZBhGtcw3x1RlTt3jHgnosPDM/DAnmrSLPWdTncvRzlMNfrIAC25835iMX3/5hVOfEm4FeQIS+t5c7jlY8cG6uhS8h7SVXTblRr9D90AQD3DAXM7g/Ti4nsNIxmPm0Eg5dxe2mrhew7tvTpIG48UKZe4eLPLSmgb4/g+GujmqMrRfXYHR7iu1fHzKocNE8p9Ym64GsuQ50eC3Rl9NBzwv6huPW3Tm/zgTRowqmQo01k6emVcgq59kdRmm/hE+JNv5hzn7bPy+FVcIZTdbED6GrU0WjfLbrX2UIEL2fYZRJhC5Jkku8LZ1JOp5UXJ3ypBP15HbIpWd79YNLletGH8ChGrx9+b2m0lvXoZ2LteSu3BWpeKj+LoyBJYIpqiQ2O1riSgTnCo4Bwwrli1RUTyC8vu3zpFeJD8vcV8BL+azajJPjxbNisQNpeKqIS5zRfzxPuAKp1g1X5FYA5+WZdM6rKwCqXeMATS2MSPD4ByKO+PjOWqw4jwzW1XTwshmrTD7tqRPzcfNUfhVIfsle3kAYSRIm2X8eS7bjNs8/gKVrAUzij7f7DkdoeNBRejYNipE6+p8IlajAaWU+nI+TBwts/2Kidlr4a7dfLP8HHOZKW+wgpmT1Zal7B2bK1R6gYVFQvsGMzr4MB4i7zEivru9Cz6jsG8c4gTRbV2ZlrGtQIKVQ253nulzAYYsh2kl1KjZxKdtCX14Yn2NrQ1ta29Nzx+FBmCVi5KHOVgKUQMzh5zNjD4evfcqs0i5OqxYhUJx4w3ESD290ZzYjaPPGDZqY11TBY= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea9d8c30-8282-46df-7829-08d9bf0dbc60 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 14:26:36.7429 (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: OUGPp6doNInq4y2cEgmND/kFbvS+fJxSQE5v0rnHrxmUEmWDSfqL9xxv7hp77v4FzNKnaRutEajw+aP/1hPXDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3031 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Currently, the function which adds/removes unicast tunnel FDB entries is shared between IPv4 and IPv6, while for IPv6 it warns because there is no support for it. The code for IPv6 will be more complicated because it needs to allocate/release a KVDL pointer for the underlay IPv6 address. As a preparation for IPv6 underlay support, split the code according to address family. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 17 +++++-- .../mellanox/mlxsw/spectrum_switchdev.c | 45 ++++++++++--------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index 5eaba2abf212..50226dae9d4e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -504,19 +504,30 @@ static inline void mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index, enum mlxsw_reg_sfd_rec_policy policy, const char *mac, u16 fid, - enum mlxsw_reg_sfd_rec_action action, u32 uip, + enum mlxsw_reg_sfd_rec_action action, enum mlxsw_reg_sfd_uc_tunnel_protocol proto) { mlxsw_reg_sfd_rec_pack(payload, rec_index, MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac, action); mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy); - mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24); - mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip); mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid); mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto); } +static inline void +mlxsw_reg_sfd_uc_tunnel_pack4(char *payload, int rec_index, + enum mlxsw_reg_sfd_rec_policy policy, + const char *mac, u16 fid, + enum mlxsw_reg_sfd_rec_action action, u32 uip) +{ + mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24); + mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip); + mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index, policy, mac, fid, + action, + MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4); +} + enum mlxsw_reg_tunnel_port { MLXSW_REG_TUNNEL_PORT_NVE, MLXSW_REG_TUNNEL_PORT_VPLS, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index c5fd69a6bedd..53473647870d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -1290,38 +1290,24 @@ static enum mlxsw_reg_sfd_op mlxsw_sp_sfd_op(bool adding) MLXSW_REG_SFD_OP_WRITE_REMOVE; } -static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp, - const char *mac, u16 fid, - enum mlxsw_sp_l3proto proto, - const union mlxsw_sp_l3addr *addr, - bool adding, bool dynamic) +static int +mlxsw_sp_port_fdb_tun_uc_op4(struct mlxsw_sp *mlxsw_sp, bool dynamic, + const char *mac, u16 fid, __be32 addr, bool adding) { - enum mlxsw_reg_sfd_uc_tunnel_protocol sfd_proto; char *sfd_pl; u8 num_rec; u32 uip; int err; - switch (proto) { - case MLXSW_SP_L3_PROTO_IPV4: - uip = be32_to_cpu(addr->addr4); - sfd_proto = MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4; - break; - case MLXSW_SP_L3_PROTO_IPV6: - default: - WARN_ON(1); - return -EOPNOTSUPP; - } - sfd_pl = kmalloc(MLXSW_REG_SFD_LEN, GFP_KERNEL); if (!sfd_pl) return -ENOMEM; + uip = be32_to_cpu(addr); mlxsw_reg_sfd_pack(sfd_pl, mlxsw_sp_sfd_op(adding), 0); - mlxsw_reg_sfd_uc_tunnel_pack(sfd_pl, 0, - mlxsw_sp_sfd_rec_policy(dynamic), mac, fid, - MLXSW_REG_SFD_REC_ACTION_NOP, uip, - sfd_proto); + mlxsw_reg_sfd_uc_tunnel_pack4(sfd_pl, 0, + mlxsw_sp_sfd_rec_policy(dynamic), mac, + fid, MLXSW_REG_SFD_REC_ACTION_NOP, uip); num_rec = mlxsw_reg_sfd_num_rec_get(sfd_pl); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfd), sfd_pl); if (err) @@ -1335,6 +1321,23 @@ static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp, return err; } +static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp, + const char *mac, u16 fid, + enum mlxsw_sp_l3proto proto, + const union mlxsw_sp_l3addr *addr, + bool adding, bool dynamic) +{ + switch (proto) { + case MLXSW_SP_L3_PROTO_IPV4: + return mlxsw_sp_port_fdb_tun_uc_op4(mlxsw_sp, dynamic, mac, fid, + addr->addr4, adding); + case MLXSW_SP_L3_PROTO_IPV6: + default: + WARN_ON(1); + return -EOPNOTSUPP; + } +} + static int __mlxsw_sp_port_fdb_uc_op(struct mlxsw_sp *mlxsw_sp, u16 local_port, const char *mac, u16 fid, bool adding, enum mlxsw_reg_sfd_rec_action action, From patchwork Tue Dec 14 14:25:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12676175 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 B8EFCC433F5 for ; Tue, 14 Dec 2021 14:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232484AbhLNO0p (ORCPT ); Tue, 14 Dec 2021 09:26:45 -0500 Received: from mail-mw2nam10on2073.outbound.protection.outlook.com ([40.107.94.73]:22144 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232444AbhLNO0o (ORCPT ); Tue, 14 Dec 2021 09:26:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j7bpg+S2phmj8jhJmkAAZs1QZf4KQotoA7mDeMW/Ct/DNI/zknGoviLF3EsFhKUc4jr1HKCQlr1uUubiyZqOQ3I38L2URYjtdI2qNSoSAkyfLTn7uHuabZ6WKcIG5jGusJDodjmftoxSt37jgkA4VDIPinwYoDm2mGAvSiqoXDJ1mdzzUOIcOB2MdF6H7jp+b9w/kdNt7HyvQz5IOa8NCumX+44myOnVl8bD53a8j31rEHWbXLVnN1olfCS8k1y9syIHm0+FpZLfBly/dmfJ5DQLGojFcGSgqDQe0QXlezEE4UmaDA5AlXFPoyhT+NQqHZDi9Jt1NpTZ9iK+5EmksA== 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=Q4P2MaxWEtRyDc2+stlZ7a4T9LeCSs96Oj4z6yJoiuQ=; b=mz2zvhRslKLv661ly3cWvM7ZRzt4rqZTv0Og+cNrzNwg4SLaKh7o/UviE8a5SPPlbJqoxtLAgZJaeFrvDACEJkv+rdB/TLZ4dzlYd74mEmwqpvm47Np3O6rnc0/9NCUYKLiP0eu3TBLO2OFxGqRpXo7EX6+JTs3JtWBOqlWC1Di7m6ryeZD1G2XgiNoWCoNHDHfX84HvzGow8xAkZ0eFC1zu9dPz0QAOmlOPiihw8JYO5tOL6uTdzAD8rIWoIP/6irXEdE8nEvxNgv2mGh5NKU+WxFKI0Drueu1wHB6eQvhS8KwTz6oV/w1paSMcE1MD3LSdo/z5APGNMlHH+tWy6A== 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=Q4P2MaxWEtRyDc2+stlZ7a4T9LeCSs96Oj4z6yJoiuQ=; b=YqrSl/0fW3ZNXo6khISHbEpRHmte8bS1Nx7qfl8xTQuZg0NioeAxZQ11jEoqzx3iWqfZPhI0Zl+ZF0dZrnBSG/nmrJVs1FKav6a3Fln8gKHmMYnk88x6AoeUA4AZskmOj9PCeR97tiBu7YCME/M10gJrwKF1SM8qISDRV6IU8DiHKpFlNHyRAJDWaOM23F/K0DF2OpdCYb4ciFc3PRSn0XZ1XhP+zCtFXI5jUsGVZ9bZhmEMNqbIDI9NcvHMZ8Z/pzGxvYVklNd9zKXvWL+w7W7o/W4gaYXvc/96I2PsHnGh1SODO34W0pRviS7aDaJUNdhKUAt9XN/ycaXPRsEyJQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BYAPR12MB3031.namprd12.prod.outlook.com (2603:10b6:a03:d8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.13; Tue, 14 Dec 2021 14:26:43 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 14:26:42 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 5/8] mlxsw: reg: Add a function to fill IPv6 unicast FDB entries Date: Tue, 14 Dec 2021 16:25:48 +0200 Message-Id: <20211214142551.606542-6-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214142551.606542-1-idosch@nvidia.com> References: <20211214142551.606542-1-idosch@nvidia.com> X-ClientProxiedBy: MR2P264CA0019.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::31) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR2P264CA0019.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::31) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 14 Dec 2021 14:26:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81e38361-11dc-4037-c6ec-08d9bf0dc00b X-MS-TrafficTypeDiagnostic: BYAPR12MB3031:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vNdIi0eTD7waSGiLaU/m5JJ/PZvH1nQkzc1AED160hXSugg58gk8Zce77zNbbsZyqITuUmmmxGGJ/8F2Bo2dBBdapbgRZFEd476/cWDLdhnr52g2yMWjigaWyt7UhNHxxjME1n3kD3nYr0Tk6zPddGsq++fALQcp0zpRcTwn/kCv4h8uZgYeiRPIEYLzaMAMxlRl5JMb4ItPipgtg0iz1WSdyIn0rGSmur5jjtHD4/qZnGu1enpMz+bsLkAnZBbDEw8EsbvwyhE74X+Ivv91dD9PBJqjcMy3al61f7XSqW/gxomz/aHtzAJGgNh2GB1lE2CE8phRfvM/xu0SKBePw0w1OWyXsukmCBAvqbviOrkLhjYa4rL9X6CUWsFKwmjpeiaWXi45NKMUmYX5fNAqpkceQQMNyROIIyK6AKQmSJxj2/2L1o7B87e8qym2Q+58fQEh8SvMz+WoT5G6+QjRuvpy1U08DIvhijyKMARGObAyexzSySYCUT9V+nKbk2GAvr3pJWmlpIJ8jqe02LGBGQ5DVMVR2CZGRJhqsgMEiZ+7hdaCVhxnRblDHaC60mZ1+z1fag8ZsHiWYVjD7ffyCpyslnaC5HOX42WgV1kliusDStXZiZ0XKXeS6LT+07VmW1KNWMU5JVFlgblypbWi8g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66946007)(6496006)(508600001)(8936002)(107886003)(2906002)(66476007)(66556008)(86362001)(186003)(38100700002)(316002)(4326008)(8676002)(2616005)(1076003)(5660300002)(6486002)(36756003)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5CzijFKiMvprGjApbftzIJD66XSSXl3Sjd1rpPNW9VsQ/AyOYVrq9AoPsJHUaFcm28cHmuOOYbsRNCs7zSsrzcW2pZCerv1ZYl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RNLeHnxz3IAu+r69VCqJgrF2uebh34sv3he0966wWCovXlHNYAJGIj394WELocWpgxMQn8ifaQXpGDUykFaplwUuv44s+ztyYGhFiFQzS75cwpJC6vv0vL7/OGpFymQhLfLRa6yjjAUIwYFHV+wK9QQlR4hza8BfRGoCkltO6QYyQJx5xsOQ7CHe4WWgpf+RXQ2sTISJkKjfUIBIS0ISkeEd/ZsQvXA2xmyNfzuxgLECB4W4ZApSHtc6hn+mNwq9NB5VprczA1JhpeuXlYv0bPGU5ukKHnRQ4cvcrhqDxhfJ1IyJ1TtUaCfyeCCYghqQw4gsy3gFWzj4J/44rIBnK8DWalPlCOeRUZbQjg/cPwK0McpRaFDWleVml/PqhOYikOfgFPH8fIh9p8AoELYcvDhyX+cVmZ05/pYWNB6Xlj41BdS6jp1VieVBsIc8Nphtw64NlQKTwY7TdT0v10gh27NZ7SorykuU5ewuGKfzeT4aWHrXVk6vIl1Pclqyy1D+wwU6KFXGZlNWDSxWyJb1MKps= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81e38361-11dc-4037-c6ec-08d9bf0dc00b X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 14:26:42.8831 (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: GHVgQpmJvuwC0Et4I7EYvzM3XQBvEzCS1QQe0U1vK+yOTGoNB46q/OITsG2N9vbMVO6LnZL+HG0jkV9vh5YjpQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3031 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Add a function to fill IPv6 unicast FDB entries. Use the common function for common fields. Unlike IPv4 entries, the underlay IP address is not filled in the register payload, but instead a pointer to KVDL is used. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index 50226dae9d4e..f748b537bdab 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -528,6 +528,19 @@ mlxsw_reg_sfd_uc_tunnel_pack4(char *payload, int rec_index, MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4); } +static inline void +mlxsw_reg_sfd_uc_tunnel_pack6(char *payload, int rec_index, const char *mac, + u16 fid, enum mlxsw_reg_sfd_rec_action action, + u32 uip_ptr) +{ + mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip_ptr); + /* Only static policy is supported for IPv6 unicast tunnel entry. */ + mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index, + MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY, + mac, fid, action, + MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6); +} + enum mlxsw_reg_tunnel_port { MLXSW_REG_TUNNEL_PORT_NVE, MLXSW_REG_TUNNEL_PORT_VPLS, From patchwork Tue Dec 14 14:25:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12676177 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 E347FC433EF for ; Tue, 14 Dec 2021 14:26:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232444AbhLNO0y (ORCPT ); Tue, 14 Dec 2021 09:26:54 -0500 Received: from mail-mw2nam10on2072.outbound.protection.outlook.com ([40.107.94.72]:50656 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232536AbhLNO0w (ORCPT ); Tue, 14 Dec 2021 09:26:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nByttKWrfxav9pu7oyCmUIOjOY1vlVfqUqUWgPrEp1m61vAQYT1n+n4hN4Vtxj/qqPI1jzh1oI1uy3cwCt8NR7/bSBds+/GNqx2t70pz9kKnxp9eNA3s7bM2ofSXGRnew0k2DYi8FaDauSaWKaxG2BJnddjz3U6oUdzI2K4ECkt2OZCJcMy4B5CWAnRo7A+7nwkZQmwdrnuiORb/iA08IB3aV2vwwDsperAxTJEj7f2hwlq17TdyUfkKtA+hcOVSl65mvKlSGVjYF96EndkW7mdvQcCpjyVjQBIdbp0LqtKyS9sLewzAAslC9yR/cyj01VqIq5UImpaIvEQrXXM2+w== 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=nsUrAaA8O0zAh7OKuN4Ogr0fqwQj+Gp3CxL2a8gkZ6I=; b=G3Tdp25lImpZ0u8h/NjJ1hGnI/oCsDtWyMrfREJPJzNs4RkfvzIoKLmbjlJOXRs5Pkyw2QUwTjAh4+bL+xUTyEYw/LDZq6i1NXzazjj2k7NGO69VUaVRwEShIApPcTYeEgpzJR1lq2o29EZTHloGE4sUu/m6LHO8sibICe0f3roC2VxT8+uWesYyY/SPJ5iTZshcYkHB9gc5nJkAmNtWZCzpxLpJbCBiNa3MfjZgk+i1rK2kR2Sh3VDzYHMlU1ixqEu3/NqV7ysoRLEmVAt+jYKqzryyECgkFOJ7BKHOoLnVD2EqrDlmbOsQMGC64VLYV21gFnphrfb+hdK5d8HMeA== 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=nsUrAaA8O0zAh7OKuN4Ogr0fqwQj+Gp3CxL2a8gkZ6I=; b=k4djfL8D8my7Q2/2DkJBQ6lbNYWL90NJUOGLsfdxldeVkUdR6kmkQVriwX0cl54kr74xVWeIGD6LwkhwiDCtvZG8/h+52Qz2Zi1nwPGymfqoZfpOTT/8AVi3VLnKxGOJIV9MTiBDAw3Q9z6jAsex31ccwLTd1s3TQCV+gxHZpuHNIY+4/fKd/1K7aDTzjlE/IesWZ45RkE5MtmB9dmmvvXggAfPEPjLcfqP09a716QUcfYWp+9aQ1WtFLXIO3I5jWFb5maEeyBrgHdj+aJyNsRBKXXR2rsHZ0I4z3n7Yc1RM0I9jbhJ0g99D0QGKRw5sFwm81eBGTp7ciVRbgmahSQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BYAPR12MB3031.namprd12.prod.outlook.com (2603:10b6:a03:d8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.13; Tue, 14 Dec 2021 14:26:50 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 14:26:50 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 6/8] mlxsw: spectrum_nve: Keep track of IPv6 addresses used by FDB entries Date: Tue, 14 Dec 2021 16:25:49 +0200 Message-Id: <20211214142551.606542-7-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214142551.606542-1-idosch@nvidia.com> References: <20211214142551.606542-1-idosch@nvidia.com> X-ClientProxiedBy: MR1P264CA0109.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:50::20) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR1P264CA0109.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:50::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.17 via Frontend Transport; Tue, 14 Dec 2021 14:26:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c901344e-a761-4804-7ee2-08d9bf0dc486 X-MS-TrafficTypeDiagnostic: BYAPR12MB3031:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pf4lTy1sSPNbWfICEjoP1JcjlC1neaBrYKxK51T+KHcmK2NDzmX8+RYYf0rCLFc+Fx+lN6UOLyXi/YEdqLNcB3Y+nAC0THTLbZMsJtGADQEhJZJOIYjpzS5oI0cvIFtV9VqcblRQNRyj5MPXqHINEU43/lC51uLTfUhpy9c6rf8a/yxKRk2rsGnhq32wvIYih+eZXUDbEtUx9uEa9V6AFoLc7QVBFpYl9bvqfkleQbaJGLn6gzUxRcnvo0aK++wVLcIB7DSvk0LnEklWIkzpP/6mMjJqURI+3v2j0wMge7WihIUltzGit3cHqvp+7FV4zF/MMBELp/7XBRyR6kv/fdJKArTp1gP44kuLjWmBfUSfTWcW6Zp8U+RxC5VOMw5PBbW2qLSoP8i4gkDcO6ZPUsmGqVpMCpWF9uvqcTevucEgNS2LJl8bAvcayPz/f/V5CLzNCleCXJ83kxj8E872Uw6hF1jI7jpxyMTzoI8RgB+E8ch4542rWxGFnbqFYYFaiyWwfqWjBAYvQh28OUhlOGqi4Mvrvy8+W99Ss1rWDeBWdDSfSyBlV8i/Iu42qO92olfpdSvL6UnckFVLKrdzjcrI5BCGFw5kxAeCgKn5cwY27dKbjACyaTrjB+eFlMBOiIKhzjVgAHXHtoTq/AOjJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66946007)(6496006)(508600001)(8936002)(83380400001)(107886003)(2906002)(66476007)(66556008)(86362001)(186003)(38100700002)(316002)(4326008)(8676002)(2616005)(1076003)(5660300002)(6486002)(36756003)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LczflRD4IgrOywXKz34BkP7O9TyyDqBlnAcCUZIAQ8E4g6OFj5tYlQ9Xbn+dLxfKK9NtGiolvS5teapSXe+v873Yrl7axLsFDcv3VQz3DdaDn5vQ8DLqKpHVs5fMr3PoVNphBwqBwNppt6/6TIWwRklGp42nkV0IiST23egUakTD6pi3Wg7TTfxDBswBY8lpOO891sn3Fr2fqWO9lkK1DDf8Udc5Uax4WYTpCvvUmtS8jxM0Pu4GY4ccL6ovkTls6fuHM52Y0LYwvI/cyEdhcFUfKuoS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nktUUf/0UWFFZgMitgZob4mr2VnmaqRko6pvOltV/qhR6j4oi8mDwbkw94SUokrSMuvhJuPycwU+Lp9Ck2VZo+41+gfCO7jvT7ScehkY9DooZwXn2FnoPbp7k6bMDRJWJ5Ht9eGj7CarhpCbXBxkQ7y4kRI3G3aJH/nSqws14/cm+wO73tK9T2MEzZUIZacOp/tRO41lMaLi8giU8qOcnwJpPAgN2IVnnNm4dLAAjnBHFVs9/dRFOhw3N+yYwI18MNcQhSw0cv3rCmNbG+/QKq5VgSzXQPRR8l1pIr89dB3B429fcLOT/JaLgia8WMp97q7zk58n00hwyNn2FE= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c901344e-a761-4804-7ee2-08d9bf0dc486 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 14:26:50.6170 (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: Je25wQ7xERaA1fg9oVMTxsZPCnQd3ApXgsIYhn/lEAhYNNtO3D7i3MZ5N7vUDOVaW4gtB8TGpN6knx2P9+WVUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3031 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen FDB entries that perform VxLAN encapsulation with an IPv6 underlay hold a reference on a resource. Namely, the KVDL entry where the IPv6 underlay destination IP is stored. When such an FDB entry is deleted, it needs to drop the reference from the corresponding KVDL entry. To that end, maintain a hash table that maps an FDB entry (i.e., {MAC, FID}) to the IPv6 address used by it. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/spectrum.h | 11 ++ .../ethernet/mellanox/mlxsw/spectrum_nve.c | 151 +++++++++++++++++- .../ethernet/mellanox/mlxsw/spectrum_nve.h | 2 + 3 files changed, 162 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 80580c892bb3..8445fc5c9ea3 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -1317,6 +1317,17 @@ void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, enum mlxsw_sp_l3proto proto, union mlxsw_sp_l3addr *addr); +int mlxsw_sp_nve_ipv6_addr_kvdl_set(struct mlxsw_sp *mlxsw_sp, + const struct in6_addr *addr6, + u32 *p_kvdl_index); +void mlxsw_sp_nve_ipv6_addr_kvdl_unset(struct mlxsw_sp *mlxsw_sp, + const struct in6_addr *addr6); +int +mlxsw_sp_nve_ipv6_addr_map_replace(struct mlxsw_sp *mlxsw_sp, const char *mac, + u16 fid_index, + const struct in6_addr *new_addr6); +void mlxsw_sp_nve_ipv6_addr_map_del(struct mlxsw_sp *mlxsw_sp, const char *mac, + u16 fid_index); int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, struct mlxsw_sp_nve_params *params, struct netlink_ext_ack *extack); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c index 9eba8fa684ae..dfe070434cbe 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c @@ -787,6 +787,142 @@ static void mlxsw_sp_nve_fdb_clear_offload(struct mlxsw_sp *mlxsw_sp, ops->fdb_clear_offload(nve_dev, vni); } +struct mlxsw_sp_nve_ipv6_ht_key { + u8 mac[ETH_ALEN]; + u16 fid_index; +}; + +struct mlxsw_sp_nve_ipv6_ht_node { + struct rhash_head ht_node; + struct list_head list; + struct mlxsw_sp_nve_ipv6_ht_key key; + struct in6_addr addr6; +}; + +static const struct rhashtable_params mlxsw_sp_nve_ipv6_ht_params = { + .key_len = sizeof(struct mlxsw_sp_nve_ipv6_ht_key), + .key_offset = offsetof(struct mlxsw_sp_nve_ipv6_ht_node, key), + .head_offset = offsetof(struct mlxsw_sp_nve_ipv6_ht_node, ht_node), +}; + +int mlxsw_sp_nve_ipv6_addr_kvdl_set(struct mlxsw_sp *mlxsw_sp, + const struct in6_addr *addr6, + u32 *p_kvdl_index) +{ + return mlxsw_sp_ipv6_addr_kvdl_index_get(mlxsw_sp, addr6, p_kvdl_index); +} + +void mlxsw_sp_nve_ipv6_addr_kvdl_unset(struct mlxsw_sp *mlxsw_sp, + const struct in6_addr *addr6) +{ + mlxsw_sp_ipv6_addr_put(mlxsw_sp, addr6); +} + +static struct mlxsw_sp_nve_ipv6_ht_node * +mlxsw_sp_nve_ipv6_ht_node_lookup(struct mlxsw_sp *mlxsw_sp, const char *mac, + u16 fid_index) +{ + struct mlxsw_sp_nve_ipv6_ht_key key = {}; + + ether_addr_copy(key.mac, mac); + key.fid_index = fid_index; + return rhashtable_lookup_fast(&mlxsw_sp->nve->ipv6_ht, &key, + mlxsw_sp_nve_ipv6_ht_params); +} + +static int mlxsw_sp_nve_ipv6_ht_insert(struct mlxsw_sp *mlxsw_sp, + const char *mac, u16 fid_index, + const struct in6_addr *addr6) +{ + struct mlxsw_sp_nve_ipv6_ht_node *ipv6_ht_node; + struct mlxsw_sp_nve *nve = mlxsw_sp->nve; + int err; + + ipv6_ht_node = kzalloc(sizeof(*ipv6_ht_node), GFP_KERNEL); + if (!ipv6_ht_node) + return -ENOMEM; + + ether_addr_copy(ipv6_ht_node->key.mac, mac); + ipv6_ht_node->key.fid_index = fid_index; + ipv6_ht_node->addr6 = *addr6; + + err = rhashtable_insert_fast(&nve->ipv6_ht, &ipv6_ht_node->ht_node, + mlxsw_sp_nve_ipv6_ht_params); + if (err) + goto err_rhashtable_insert; + + list_add(&ipv6_ht_node->list, &nve->ipv6_addr_list); + + return 0; + +err_rhashtable_insert: + kfree(ipv6_ht_node); + return err; +} + +static void +mlxsw_sp_nve_ipv6_ht_remove(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nve_ipv6_ht_node *ipv6_ht_node) +{ + struct mlxsw_sp_nve *nve = mlxsw_sp->nve; + + list_del(&ipv6_ht_node->list); + rhashtable_remove_fast(&nve->ipv6_ht, &ipv6_ht_node->ht_node, + mlxsw_sp_nve_ipv6_ht_params); + kfree(ipv6_ht_node); +} + +int +mlxsw_sp_nve_ipv6_addr_map_replace(struct mlxsw_sp *mlxsw_sp, const char *mac, + u16 fid_index, + const struct in6_addr *new_addr6) +{ + struct mlxsw_sp_nve_ipv6_ht_node *ipv6_ht_node; + + ASSERT_RTNL(); + + ipv6_ht_node = mlxsw_sp_nve_ipv6_ht_node_lookup(mlxsw_sp, mac, + fid_index); + if (!ipv6_ht_node) + return mlxsw_sp_nve_ipv6_ht_insert(mlxsw_sp, mac, fid_index, + new_addr6); + + mlxsw_sp_ipv6_addr_put(mlxsw_sp, &ipv6_ht_node->addr6); + ipv6_ht_node->addr6 = *new_addr6; + return 0; +} + +void mlxsw_sp_nve_ipv6_addr_map_del(struct mlxsw_sp *mlxsw_sp, const char *mac, + u16 fid_index) +{ + struct mlxsw_sp_nve_ipv6_ht_node *ipv6_ht_node; + + ASSERT_RTNL(); + + ipv6_ht_node = mlxsw_sp_nve_ipv6_ht_node_lookup(mlxsw_sp, mac, + fid_index); + if (WARN_ON(!ipv6_ht_node)) + return; + + mlxsw_sp_nve_ipv6_ht_remove(mlxsw_sp, ipv6_ht_node); +} + +static void mlxsw_sp_nve_ipv6_addr_flush_by_fid(struct mlxsw_sp *mlxsw_sp, + u16 fid_index) +{ + struct mlxsw_sp_nve_ipv6_ht_node *ipv6_ht_node, *tmp; + struct mlxsw_sp_nve *nve = mlxsw_sp->nve; + + list_for_each_entry_safe(ipv6_ht_node, tmp, &nve->ipv6_addr_list, + list) { + if (ipv6_ht_node->key.fid_index != fid_index) + continue; + + mlxsw_sp_ipv6_addr_put(mlxsw_sp, &ipv6_ht_node->addr6); + mlxsw_sp_nve_ipv6_ht_remove(mlxsw_sp, ipv6_ht_node); + } +} + int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, struct mlxsw_sp_nve_params *params, struct netlink_ext_ack *extack) @@ -845,6 +981,7 @@ void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp, mlxsw_sp_nve_flood_ip_flush(mlxsw_sp, fid); mlxsw_sp_nve_fdb_flush_by_fid(mlxsw_sp, fid_index); + mlxsw_sp_nve_ipv6_addr_flush_by_fid(mlxsw_sp, fid_index); if (WARN_ON(mlxsw_sp_fid_nve_ifindex(fid, &nve_ifindex) || mlxsw_sp_fid_vni(fid, &vni))) @@ -981,7 +1118,13 @@ int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp) err = rhashtable_init(&nve->mc_list_ht, &mlxsw_sp_nve_mc_list_ht_params); if (err) - goto err_rhashtable_init; + goto err_mc_rhashtable_init; + + err = rhashtable_init(&nve->ipv6_ht, &mlxsw_sp_nve_ipv6_ht_params); + if (err) + goto err_ipv6_rhashtable_init; + + INIT_LIST_HEAD(&nve->ipv6_addr_list); err = mlxsw_sp_nve_qos_init(mlxsw_sp); if (err) @@ -1000,8 +1143,10 @@ int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp) err_nve_resources_query: err_nve_ecn_init: err_nve_qos_init: + rhashtable_destroy(&nve->ipv6_ht); +err_ipv6_rhashtable_init: rhashtable_destroy(&nve->mc_list_ht); -err_rhashtable_init: +err_mc_rhashtable_init: mlxsw_sp->nve = NULL; kfree(nve); return err; @@ -1010,6 +1155,8 @@ int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp) void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp) { WARN_ON(mlxsw_sp->nve->num_nve_tunnels); + WARN_ON(!list_empty(&mlxsw_sp->nve->ipv6_addr_list)); + rhashtable_destroy(&mlxsw_sp->nve->ipv6_ht); rhashtable_destroy(&mlxsw_sp->nve->mc_list_ht); kfree(mlxsw_sp->nve); mlxsw_sp->nve = NULL; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.h index 98d1fdc25eac..0d21de1d0395 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.h @@ -23,6 +23,8 @@ struct mlxsw_sp_nve_config { struct mlxsw_sp_nve { struct mlxsw_sp_nve_config config; struct rhashtable mc_list_ht; + struct rhashtable ipv6_ht; + struct list_head ipv6_addr_list; /* Saves hash table nodes. */ struct mlxsw_sp *mlxsw_sp; const struct mlxsw_sp_nve_ops **nve_ops_arr; unsigned int num_nve_tunnels; /* Protected by RTNL */ From patchwork Tue Dec 14 14:25:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12676179 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 7F1ECC433EF for ; Tue, 14 Dec 2021 14:27:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232506AbhLNO1A (ORCPT ); Tue, 14 Dec 2021 09:27:00 -0500 Received: from mail-mw2nam10on2078.outbound.protection.outlook.com ([40.107.94.78]:32160 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232459AbhLNO07 (ORCPT ); Tue, 14 Dec 2021 09:26:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aQmI+NMf6B61enoM2+R1ylI+nICLANL0xTg3ba6pise7omiVqen1uZ/CJgo/M2sbByNNPdesHILsy9FEsecxoOcu9ZRK//jrloiUGN5AI26dSp6+y5n5WrlDdGFhS2B9wttat2XcL8VXPPSjSqoH58y8Te1sqJXXPr3HoMEcn8Xilwswhk5mo1Mc/uCMUZs4/3F312yuPo4AzTvp5DNjWlMjVtP8Rq6gNSdqmPRmB9L3EkrJCWik+X47H4xbmk5g4VYQGDPdi8aLp5xq9db1QaWI4x1fPOd/5jaLLHquUFjZUSNX1g0H8ab0gTo8LrMBDvUbgF+xeIPWsoLZE7uqMQ== 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=YltDwW3fLo2qwXucgfJUSgQZRf1KlfwcY6A7VADEX1I=; b=AugXOsQfnE61QlBzx69F7FY0vkDGmhqeaUYDVWyq8BqTrgsVWZgrt7FvUvZCvbPzH1jAWGZlxBPSStsXbX+J9GlyW3Qso2txRTHm5CMwBiYDqnJFUF7YJLoRZ8VNlWltireHf/nz2ZFNXriSSI7pvXIXlnCrNx26rBVsB8rtRn9sPnkqLeZZJiT315gdGu2Roh0LwBBi9jndlfcY9MIVgJxnSNLGbA3TWMQbRyDILjlOJ2xFNP6v2LtApVMmrbiehtAl4c/W1we0+JW5Ni9WMlRyR8SXJ1DUgfXn+lnKNOJZOOf+XgXHjIeltRzhqITeFZnOnYYNJeOox5kVhzPplA== 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=YltDwW3fLo2qwXucgfJUSgQZRf1KlfwcY6A7VADEX1I=; b=XgHqvM+pgfXE+41cBvZmbA5ClmG/Wct7HosrnuQkMrlppUhCCG42SSh+J2kkErLjsMGwQv1jChHQ8y8fv6O5EoayhmHKN4iiOOITT4mEqlaeYdq+NRr5Haz43xDmGpdkJgMJ1gnsIBdTe8ghX92ZQI4llBPzUhihDbtWlKxkABeeCNY82s7TvVOxV1fzLKVuLQz5uwlgM6iyTJ2aFnCg/oDuPbVE76PmvNGz7tDEMslR/JxDM/DoldDdeaKIe8ooGXeBacJDTax/MXMigcjG/WGL1JZJbTTBsKdPS+Pp4pgyeDzTcPKy4Hry4QIZ7I7uWLA/h4I0+mndWlG1YtKNQA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BYAPR12MB3031.namprd12.prod.outlook.com (2603:10b6:a03:d8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.13; Tue, 14 Dec 2021 14:26:57 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 14:26:57 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 7/8] mlxsw: Add support for VxLAN with IPv6 underlay Date: Tue, 14 Dec 2021 16:25:50 +0200 Message-Id: <20211214142551.606542-8-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214142551.606542-1-idosch@nvidia.com> References: <20211214142551.606542-1-idosch@nvidia.com> X-ClientProxiedBy: MR2P264CA0062.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::26) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR2P264CA0062.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::26) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 14 Dec 2021 14:26:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 660234c8-6cdf-4a07-9f01-08d9bf0dc8a6 X-MS-TrafficTypeDiagnostic: BYAPR12MB3031:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8jmSs43AmUMMXjFztjLPNSZDhQPRVoNA/kPsIv4PCMVcpvUyokRhV64vc60fkKjqqP6J5fjphuxNBAXecwRun7l6PS+v30ggIxnoAWHNfV7DvGMA2j/51p1/oUTYQ4PHSJYCHH1cCl72wMbQU9z5bi8pojvIqpXEgvizOe8R4YKMdEjR4QeyV53CJEm0N+RZDaQKVEZ7qtoez87ARcKGU02+5J26pRl2/PU9KQLZfd5JzhfZ+jcZ8dHFnrSyvryqYlfoUfw1Pkc/418U0Fa9xjhy+weL9HKgLaUqw3wVCIz09WYos6mGpm+hXWXbdsNXlYfzC3+2t5/y0MaHJIOeILFtl73sd5aRffFfEXZeq5oMb0fhxLde3SV6vqLWfh5gCq5qTh3TRVmpsgoGgav3ZOG4hNnU127Vd23iiBYww+9Z9puU/aHFDPtOkDidmloAYVTchUTCG5kGlPy/ffXpE1dmZ54KUhfCYLE67OKPIniP6NQBwIvYDcqAKJadM0omUK7BugE1zjjCVVzDp7QPxGMUsQgCcpZutXCX3XbR0SdlcJiFRr9jTze+8EL2Jtmt1VpKdqOKAjslB0P8oqtZmyaSfpDQsxz9nZfPYp2B/+UCNnqNvXB9dmVBK4Agl9lii5ALpnXV2exg/JQ18LjmlQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6666004)(66946007)(6496006)(508600001)(8936002)(83380400001)(107886003)(66574015)(2906002)(66476007)(66556008)(86362001)(186003)(38100700002)(316002)(4326008)(8676002)(2616005)(1076003)(5660300002)(6486002)(36756003)(6916009)(30864003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GxGGKN8iZSiCQdlBKcOz7akb24qpPCZMoyv6XdfOicFZDQXETG9ht+H5xS9z1Z4gcnlvSZj2Lzzfqr/klYJ8yVht1os4OWp4lTixPJIohdDflcwTBBnWVJsV9VBodpD8t/TOey/zIg7yuyCMT2lzBVJWuVTgFnO4aZvRvRNIR0n6GNahZE6dO3uPpZlAOGeROyeHTg6oo4b9xoUBdesSnA1Ij2N5OWMy4863i3y+7p4c7HJaYSe74n1+FOssELqXB2eur89/wMryJLGYXIV69FoEDsBV8P/nRrBjdjtMXA5SK2AGg8BeeM1yCFMe+v2ss68w+umfh5Ub3LG3iFyfWeQGdciKH9BaFmUdwbHz4VjlR0lBwKbwMRIaRuIUj7SKsQI186ToIn0vipnw4SF89vnY9EenINl9bFLDg+KyecV+YnF/j6S2JTuDaxj7UAO1trEzVQgqr8c5B4geVG+7OSydj4Lg5Z7GG/YYytPKgbZtdYE1hWcAQ0QO8EG6BnlbFh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+4rU75CxGM4xn9eC4xkxcVnQc0R4Cq1OOY8VXGcTnIGb49sj5MaoXx/Vbl5z+P9hEAsqJJBZrc8ydlMbB238CFwvR6jWp7D2055EdjKo= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 660234c8-6cdf-4a07-9f01-08d9bf0dc8a6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 14:26:57.6478 (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: Fiy6KlnK9ENk9xoTlnY89O3nQwwyeoOU1ZttuVeSw/+BEY31LRqVg1X+/Q+wr+f5oylAeh4P2iwmoy+aGVow+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3031 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Currently, mlxsw driver supports VxLAN with IPv4 underlay only. Add support for IPv6 underlay. The main differences are: * Learning is not supported for IPv6 FDB entries, use static entries and do not allow 'learning' flag for IPv6 VxLAN. * IPv6 addresses for FDB entries should be saved as part of KVDL. Use the new API to allocate and release entries for IPv6 addresses. * Spectrum ASICs do not fill UDP checksum, while in software IPv6 UDP packets with checksum zero are dropped. Force the relevant flags which allow the VxLAN device to generate UDP packets with zero checksum and also receive them. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_nve.c | 14 +++- .../mellanox/mlxsw/spectrum_nve_vxlan.c | 66 +++++++++++++-- .../ethernet/mellanox/mlxsw/spectrum_router.c | 14 ++++ .../mellanox/mlxsw/spectrum_switchdev.c | 84 +++++++++++++++++++ 4 files changed, 168 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c index dfe070434cbe..d2b57a045aa4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c @@ -130,15 +130,25 @@ mlxsw_sp_nve_mc_record_ipv6_entry_add(struct mlxsw_sp_nve_mc_record *mc_record, struct mlxsw_sp_nve_mc_entry *mc_entry, const union mlxsw_sp_l3addr *addr) { - WARN_ON(1); + u32 kvdl_index; + int err; + + err = mlxsw_sp_ipv6_addr_kvdl_index_get(mc_record->mlxsw_sp, + &addr->addr6, &kvdl_index); + if (err) + return err; - return -EINVAL; + mc_entry->ipv6_entry.addr6 = addr->addr6; + mc_entry->ipv6_entry.addr6_kvdl_index = kvdl_index; + return 0; } static void mlxsw_sp_nve_mc_record_ipv6_entry_del(const struct mlxsw_sp_nve_mc_record *mc_record, const struct mlxsw_sp_nve_mc_entry *mc_entry) { + mlxsw_sp_ipv6_addr_put(mc_record->mlxsw_sp, + &mc_entry->ipv6_entry.addr6); } static void diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c index 766a20e05393..d309b77a0194 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c @@ -12,6 +12,9 @@ #define MLXSW_SP_NVE_VXLAN_IPV4_SUPPORTED_FLAGS (VXLAN_F_UDP_ZERO_CSUM_TX | \ VXLAN_F_LEARN) +#define MLXSW_SP_NVE_VXLAN_IPV6_SUPPORTED_FLAGS (VXLAN_F_IPV6 | \ + VXLAN_F_UDP_ZERO_CSUM6_TX | \ + VXLAN_F_UDP_ZERO_CSUM6_RX) static bool mlxsw_sp_nve_vxlan_ipv4_flags_check(const struct vxlan_config *cfg, struct netlink_ext_ack *extack) @@ -29,6 +32,27 @@ static bool mlxsw_sp_nve_vxlan_ipv4_flags_check(const struct vxlan_config *cfg, return true; } +static bool mlxsw_sp_nve_vxlan_ipv6_flags_check(const struct vxlan_config *cfg, + struct netlink_ext_ack *extack) +{ + if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM6_TX)) { + NL_SET_ERR_MSG_MOD(extack, "VxLAN: Zero UDP checksum must be allowed for TX"); + return false; + } + + if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM6_RX)) { + NL_SET_ERR_MSG_MOD(extack, "VxLAN: Zero UDP checksum must be allowed for RX"); + return false; + } + + if (cfg->flags & ~MLXSW_SP_NVE_VXLAN_IPV6_SUPPORTED_FLAGS) { + NL_SET_ERR_MSG_MOD(extack, "VxLAN: Unsupported flag"); + return false; + } + + return true; +} + static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve, const struct mlxsw_sp_nve_params *params, struct netlink_ext_ack *extack) @@ -36,11 +60,6 @@ static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve, struct vxlan_dev *vxlan = netdev_priv(params->dev); struct vxlan_config *cfg = &vxlan->cfg; - if (cfg->saddr.sa.sa_family != AF_INET) { - NL_SET_ERR_MSG_MOD(extack, "VxLAN: Only IPv4 underlay is supported"); - return false; - } - if (vxlan_addr_multicast(&cfg->remote_ip)) { NL_SET_ERR_MSG_MOD(extack, "VxLAN: Multicast destination IP is not supported"); return false; @@ -76,6 +95,10 @@ static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve, if (!mlxsw_sp_nve_vxlan_ipv4_flags_check(cfg, extack)) return false; break; + case AF_INET6: + if (!mlxsw_sp_nve_vxlan_ipv6_flags_check(cfg, extack)) + return false; + break; } if (cfg->ttl == 0) { @@ -103,6 +126,22 @@ static bool mlxsw_sp1_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve, return mlxsw_sp_nve_vxlan_can_offload(nve, params, extack); } +static void +mlxsw_sp_nve_vxlan_ul_proto_sip_config(const struct vxlan_config *cfg, + struct mlxsw_sp_nve_config *config) +{ + switch (cfg->saddr.sa.sa_family) { + case AF_INET: + config->ul_proto = MLXSW_SP_L3_PROTO_IPV4; + config->ul_sip.addr4 = cfg->saddr.sin.sin_addr.s_addr; + break; + case AF_INET6: + config->ul_proto = MLXSW_SP_L3_PROTO_IPV6; + config->ul_sip.addr6 = cfg->saddr.sin6.sin6_addr; + break; + } +} + static void mlxsw_sp_nve_vxlan_config(const struct mlxsw_sp_nve *nve, const struct mlxsw_sp_nve_params *params, struct mlxsw_sp_nve_config *config) @@ -115,8 +154,7 @@ static void mlxsw_sp_nve_vxlan_config(const struct mlxsw_sp_nve *nve, config->flowlabel = cfg->label; config->learning_en = cfg->flags & VXLAN_F_LEARN ? 1 : 0; config->ul_tb_id = RT_TABLE_MAIN; - config->ul_proto = MLXSW_SP_L3_PROTO_IPV4; - config->ul_sip.addr4 = cfg->saddr.sin.sin_addr.s_addr; + mlxsw_sp_nve_vxlan_ul_proto_sip_config(cfg, config); config->udp_dport = cfg->dst_port; } @@ -124,6 +162,7 @@ static void mlxsw_sp_nve_vxlan_config_prepare(char *tngcr_pl, const struct mlxsw_sp_nve_config *config) { + struct in6_addr addr6; u8 udp_sport; mlxsw_reg_tngcr_pack(tngcr_pl, MLXSW_REG_TNGCR_TYPE_VXLAN, true, @@ -135,7 +174,18 @@ mlxsw_sp_nve_vxlan_config_prepare(char *tngcr_pl, get_random_bytes(&udp_sport, sizeof(udp_sport)); udp_sport = (udp_sport % (0xee - 0x80 + 1)) + 0x80; mlxsw_reg_tngcr_nve_udp_sport_prefix_set(tngcr_pl, udp_sport); - mlxsw_reg_tngcr_usipv4_set(tngcr_pl, be32_to_cpu(config->ul_sip.addr4)); + + switch (config->ul_proto) { + case MLXSW_SP_L3_PROTO_IPV4: + mlxsw_reg_tngcr_usipv4_set(tngcr_pl, + be32_to_cpu(config->ul_sip.addr4)); + break; + case MLXSW_SP_L3_PROTO_IPV6: + addr6 = config->ul_sip.addr6; + mlxsw_reg_tngcr_usipv6_memcpy_to(tngcr_pl, + (const char *)&addr6); + break; + } } static int diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 764731eae2cd..d40762cfc453 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -1307,6 +1307,10 @@ mlxsw_sp_router_ip2me_fib_entry_find(struct mlxsw_sp *mlxsw_sp, u32 tb_id, addr_prefix_len = 32; break; case MLXSW_SP_L3_PROTO_IPV6: + addrp = &addr->addr6; + addr_len = 16; + addr_prefix_len = 128; + break; default: WARN_ON(1); return NULL; @@ -7002,6 +7006,8 @@ mlxsw_sp_fib6_entry_type_set_local(struct mlxsw_sp *mlxsw_sp, { struct mlxsw_sp_nexthop_group_info *nhgi = fib_entry->nh_group->nhgi; union mlxsw_sp_l3addr dip = { .addr6 = rt->fib6_dst.addr }; + u32 tb_id = mlxsw_sp_fix_tb_id(rt->fib6_table->tb6_id); + struct mlxsw_sp_router *router = mlxsw_sp->router; int ifindex = nhgi->nexthops[0].ifindex; struct mlxsw_sp_ipip_entry *ipip_entry; @@ -7015,6 +7021,14 @@ mlxsw_sp_fib6_entry_type_set_local(struct mlxsw_sp *mlxsw_sp, return mlxsw_sp_fib_entry_decap_init(mlxsw_sp, fib_entry, ipip_entry); } + if (mlxsw_sp_router_nve_is_decap(mlxsw_sp, tb_id, + MLXSW_SP_L3_PROTO_IPV6, &dip)) { + u32 tunnel_index; + + tunnel_index = router->nve_decap_config.tunnel_index; + fib_entry->decap.tunnel_index = tunnel_index; + fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_NVE_DECAP; + } return 0; } diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 53473647870d..65c1724c63b0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -1321,6 +1321,88 @@ mlxsw_sp_port_fdb_tun_uc_op4(struct mlxsw_sp *mlxsw_sp, bool dynamic, return err; } +static int mlxsw_sp_port_fdb_tun_uc_op6_sfd_write(struct mlxsw_sp *mlxsw_sp, + const char *mac, u16 fid, + u32 kvdl_index, bool adding) +{ + char *sfd_pl; + u8 num_rec; + int err; + + sfd_pl = kmalloc(MLXSW_REG_SFD_LEN, GFP_KERNEL); + if (!sfd_pl) + return -ENOMEM; + + mlxsw_reg_sfd_pack(sfd_pl, mlxsw_sp_sfd_op(adding), 0); + mlxsw_reg_sfd_uc_tunnel_pack6(sfd_pl, 0, mac, fid, + MLXSW_REG_SFD_REC_ACTION_NOP, kvdl_index); + num_rec = mlxsw_reg_sfd_num_rec_get(sfd_pl); + err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfd), sfd_pl); + if (err) + goto out; + + if (num_rec != mlxsw_reg_sfd_num_rec_get(sfd_pl)) + err = -EBUSY; + +out: + kfree(sfd_pl); + return err; +} + +static int mlxsw_sp_port_fdb_tun_uc_op6_add(struct mlxsw_sp *mlxsw_sp, + const char *mac, u16 fid, + const struct in6_addr *addr) +{ + u32 kvdl_index; + int err; + + err = mlxsw_sp_nve_ipv6_addr_kvdl_set(mlxsw_sp, addr, &kvdl_index); + if (err) + return err; + + err = mlxsw_sp_port_fdb_tun_uc_op6_sfd_write(mlxsw_sp, mac, fid, + kvdl_index, true); + if (err) + goto err_sfd_write; + + err = mlxsw_sp_nve_ipv6_addr_map_replace(mlxsw_sp, mac, fid, addr); + if (err) + /* Replace can fail only for creating new mapping, so removing + * the FDB entry in the error path is OK. + */ + goto err_addr_replace; + + return 0; + +err_addr_replace: + mlxsw_sp_port_fdb_tun_uc_op6_sfd_write(mlxsw_sp, mac, fid, kvdl_index, + false); +err_sfd_write: + mlxsw_sp_nve_ipv6_addr_kvdl_unset(mlxsw_sp, addr); + return err; +} + +static void mlxsw_sp_port_fdb_tun_uc_op6_del(struct mlxsw_sp *mlxsw_sp, + const char *mac, u16 fid, + const struct in6_addr *addr) +{ + mlxsw_sp_nve_ipv6_addr_map_del(mlxsw_sp, mac, fid); + mlxsw_sp_port_fdb_tun_uc_op6_sfd_write(mlxsw_sp, mac, fid, 0, false); + mlxsw_sp_nve_ipv6_addr_kvdl_unset(mlxsw_sp, addr); +} + +static int +mlxsw_sp_port_fdb_tun_uc_op6(struct mlxsw_sp *mlxsw_sp, const char *mac, + u16 fid, const struct in6_addr *addr, bool adding) +{ + if (adding) + return mlxsw_sp_port_fdb_tun_uc_op6_add(mlxsw_sp, mac, fid, + addr); + + mlxsw_sp_port_fdb_tun_uc_op6_del(mlxsw_sp, mac, fid, addr); + return 0; +} + static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, enum mlxsw_sp_l3proto proto, @@ -1332,6 +1414,8 @@ static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp, return mlxsw_sp_port_fdb_tun_uc_op4(mlxsw_sp, dynamic, mac, fid, addr->addr4, adding); case MLXSW_SP_L3_PROTO_IPV6: + return mlxsw_sp_port_fdb_tun_uc_op6(mlxsw_sp, mac, fid, + &addr->addr6, adding); default: WARN_ON(1); return -EOPNOTSUPP; From patchwork Tue Dec 14 14:25:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12676181 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 4D5C0C433FE for ; Tue, 14 Dec 2021 14:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbhLNO1M (ORCPT ); Tue, 14 Dec 2021 09:27:12 -0500 Received: from mail-co1nam11on2050.outbound.protection.outlook.com ([40.107.220.50]:38689 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232459AbhLNO1L (ORCPT ); Tue, 14 Dec 2021 09:27:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cA9b51CP89A3rfOMeG5Z/dhPii5a3/Uvj9YXYpz+DvOQYLrOyKv12b8GP9QbYz2yi3W5mg+r6SiZRWEEM0wVlsI+9k9F0zHNBypuv/mggTBvHzJvni6oEW93a6sHaG/MNhBxE2LIIJqExJCBBxw2Th5Ts7lcHcxRbE4mpPDr9f6/OEZxJfvyVCJS1EeOXVcsYM43JXITkoX/EPTaXMh7wJPUUGrMTw4AWc1EtRINISy9qwpvTHXVzmXuWIcBr/EMe5F8Aging1Vy/NyM/x9IfaRE8UO88CrHKejp9/B/5xG0gJ5nf5kLLTJuxKVPtEv2dJ3Ff9eQ2QaDu7ceRTW5cA== 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=4EynPtvCfFy6hU3turNJYELvASNWH3FYOeKA/cCRasQ=; b=B9HP9XORI9K3kO/GbpG4/NRGSiGkM6Ebw5qT0zvgt3lqeKql/JMCSMi0mlErCB+hNfzqf5DRJXjtfalila+ZGcyBNpui6czHafSXlZujKRNaObY9Vpp7C3wrrK/oVMQG15I3+cBlkCCupJXXaPITNaId7nBs6eyVsszDAVha99yza45fx5cKPuZPEXNRmugcnEKlc/lh8SklC4FAYMAc5lx1EHnAD9FNhaY/bFDsPiOvpuQGVBIkazyA9ukMymt6DO2IGHtJiypTxbHPrTVMRjo86xrR6QmoG5K4C9jpBtriQdW/62umvWOJJ4pptkquke0NGHpowcE0ARePfXHMbw== 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=4EynPtvCfFy6hU3turNJYELvASNWH3FYOeKA/cCRasQ=; b=HCBjhADdHRVm9I1dMASLW7L7hk9hBCinZSv9hIB3E958JFforoSQlTJcJyO1HjRkYXaLOLD4nGfuNaNiWHSaxQ0NBXoyOBCcUfdVZx5hj9IwH3GyktFUE7b5/g7TMXIiltnY3AzUHCHK4VFXshB4OKM0syu1e3ZvXZVvtPFiAwXUdLsDV4CAYAzzI/E3OtOveK51tISw8MGCkoBGZrKwRIKpK0g7uSe973Sukw4vWxOcKrt0W7o9SrSX0SJR4/TKHhtc+TrQmMkllSZ6nJRqHp8n96fLRSUnGrqs2GetouikPPwXm6VJV06v2goWII2PLLP8fdJk0cw5EOTYf3O8vQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BYAPR12MB3031.namprd12.prod.outlook.com (2603:10b6:a03:d8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.13; Tue, 14 Dec 2021 14:27:03 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 14:27:03 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 8/8] selftests: mlxsw: vxlan: Remove IPv6 test case Date: Tue, 14 Dec 2021 16:25:51 +0200 Message-Id: <20211214142551.606542-9-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214142551.606542-1-idosch@nvidia.com> References: <20211214142551.606542-1-idosch@nvidia.com> X-ClientProxiedBy: MR2P264CA0179.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501::18) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR2P264CA0179.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501::18) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 14 Dec 2021 14:27:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4456ad37-0f0d-440f-3db0-08d9bf0dcc41 X-MS-TrafficTypeDiagnostic: BYAPR12MB3031:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vSV7RoZqIL4Pweoc7Y6LsqsI4tKpu2kdIayufXw/7CyiQujC2aobpcxgmI0VGZ7aNu69wAvPkkwlAlxtVxxqMSdQUUQKRkTKvcfaocB1GUHgx1KIe7mSCD6zQ9vCquMCF8ksBHT7Rw1/dPGGBXINuvGNHWuktuZr1e71f+2US48DtFlHKt+dJphQEalhXxGH3TOKUfcHhtEZN/CMvu+16iiBbYJLlUUWulvlyTtESjZiTQyPt05jKYztuJpOGapK2jmqB8YGrhvtRax3vm9cHGbKA/Uw2nYBHPh1q/TTYg2L23eADaC7r7c+HmqRdwK3cY4zzlQ9P7GugJoZkKBhnLmpLxhK8Mn9mXiC8zfJ3ACPxbujSih2nGZ/8nqMzc6obAFZG78/ay2jVYvVuErJjBAVadD0dJUyfMPw3cZxNwsNzExEfFb0RgtkMdqEKyzJQLasxFb922Qc910CmQF1gPVlGxSYeYHEwlRM1mLkdPoGnbrvdsw/aNTQ/hVQeSbeijyk+14VhCS8GeLiMwlj2fdLYlq5zk7OteuO6hjEuk6CFogcMvsDSt1fOawcRR0DxE6fopHATUi0zXZ6PGfH7u3ewZ1f/ai3jDrVo/ld56bsf6wTYggdd14Wa11a8BqirlCxO6cXG2//7R4HwbK2TA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6666004)(66946007)(6496006)(508600001)(8936002)(83380400001)(107886003)(2906002)(66476007)(66556008)(86362001)(186003)(38100700002)(316002)(4326008)(8676002)(2616005)(1076003)(5660300002)(6486002)(36756003)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MyQItLZ7Qx4vBNxkrOM6OjYmF0dcveriYizZjZaiyLy8suqWxw0bKuIyxY6HrmS0AEZxPpCyY5lbdZRT8ibowXZ+qyD5nnJn4XwGC7S+1MtwwI1QusVYeIWR+mjn3q6M9c5yvx+BjCdjT+vL+t/hs2Hc00x/5nFvwKu9f6BOzzW5DqzSbicMZz+QiuBvNbVtmaUFbboxz8hxepADHEuRBz44i+71p+S6CZ08Kmkb+3XxytzJETYCrhdu7IWpKBC0uc5AfZlIocr6/VyBngrE7ZYHrDOYVPAd/DTPn2oaZsDk1hGs6/9fKi0G9S7ir5bzV5OqP9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QZngoGGg+7PfYa7540W33MT1JgFM05NA59NRWU1tmbbnqFSv5F6ivSQHlEEDxmQuTI47AATP8b2ZGrADsqOP4D8g7Xopwvr1hmABscvmPsYKBg7/iNxA6BWTcqvwKJ5pHirSDlEH94ChRiAHvLhk698lJ8cBi6ea1V/og0LM9R9WnXr0sfFfd6Ardxn3d5MQjnIMkqKS7BhXXsao+gM9gwCD5CPGAdIpug0t37F7gZY+fZeZ/l5OkuGNCzfwjaCHesLtIX1H/xfRqzk6BHFuonyBQ9RRNo3ZeQLIA5l2RqmlWyLiAahKkX82BoDFpmAROMwg= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4456ad37-0f0d-440f-3db0-08d9bf0dcc41 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 14:27:03.4912 (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: hUYicYCqh2yHrJcn8fUl+jgWPkLAz/JO0QpqDfXx3lPlj9Zui2EP4po2yEy4YYK7U3ohS1++kbfIjk0OLQnd5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3031 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Currently, there is a test case to verify that VxLAN with IPv6 underlay is forbidden. Remove this test case as support for VxLAN with IPv6 underlay was added by the previous patch. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- .../selftests/drivers/net/mlxsw/vxlan.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/vxlan.sh b/tools/testing/selftests/drivers/net/mlxsw/vxlan.sh index 729a86cc4ede..3639b89c81ba 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/vxlan.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/vxlan.sh @@ -145,23 +145,6 @@ sanitization_single_dev_no_local_ip_test() log_test "vxlan device with no local ip" } -sanitization_single_dev_local_ipv6_test() -{ - RET=0 - - ip link add dev br0 type bridge mcast_snooping 0 - - ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \ - ttl 20 tos inherit local 2001:db8::1 dstport 4789 - - sanitization_single_dev_test_fail - - ip link del dev vxlan0 - ip link del dev br0 - - log_test "vxlan device with local ipv6 address" -} - sanitization_single_dev_learning_enabled_test() { RET=0 @@ -276,7 +259,6 @@ sanitization_single_dev_test() sanitization_single_dev_mcast_enabled_test sanitization_single_dev_mcast_group_test sanitization_single_dev_no_local_ip_test - sanitization_single_dev_local_ipv6_test sanitization_single_dev_learning_enabled_test sanitization_single_dev_local_interface_test sanitization_single_dev_port_range_test