From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DA323A0544; Mon, 10 Oct 2022 08:29:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 807CE4021E; Mon, 10 Oct 2022 08:29:11 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2122.outbound.protection.outlook.com [40.107.93.122]) by mails.dpdk.org (Postfix) with ESMTP id E760F40146 for ; Mon, 10 Oct 2022 08:29:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlCcVSXC9cpkTd9Nl1ft/lexWlFFO/WAaY1pn2I1y7Ugji4W/tZNX3bNHwZ3uOY5DDSZwq+pkkaW/nnmY/4aFLxbCC2oD3svi7HxE6pOaKZJyPkAhDNKUAkIbWyvd3WL+fj11WRv4U7CJJHRR6uAlPt0htZaWCN9vSvlHHkVSScOu7CI6HzA5/8N32VjN5lWsCN4uv2jn1IfpRsMkXSyAs0UdGvYRbqWJgoL1treIt24KjJRqlUB25o+XxwuEjw0K6M8WqoVWN9CKWHKGOVJCYRQcX9Unx/cYChTmwXhisUcmQvyBH7Dy/8DCn0oIuzfcqddTFnv87BRXo3iRXRTvA== 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=oufUtIiUzCnJ6Lzv5W3V4Qn5VyBf4/oP+pg/xDXgZI4=; b=HLRKzKssX19+S59fvFyDCA2fWL07eKu7bz/fFDz2DwpX4QaCwdE+QDO2bGXY6aC5Wc+aZi+osaXkZXE8m4gczXUo2vmO7fu/IaZrP9KQQbQ+480zop9fXvNQe2+deTJVUA7lXPWS1uJBmzQOZgOXuji9D1qC0xbzzdmYDbICYHEmjfg4exHvT9t/anPY1H+g3QMMYfyRVz2B73CZzksEA8wFa2GkvVi23HP40op9JhtoxV+rpuaOIzKgEGxbPuCcVy8zqkf5WEIeMuGokpl4aVQ8VAJTFeZY1yoUZZY1GsEo7XE/LLFnkbGm4BDOvGo8FvVJ3n80u1Zdn71zBajd7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oufUtIiUzCnJ6Lzv5W3V4Qn5VyBf4/oP+pg/xDXgZI4=; b=fShAbA6Us2Yqiq35uzNuEXz7EGekw1IhK5fruOHXHW0Ouu2JTweDdXDM0Qkb8H3d4tD5/P/q4xZiZNQOtgk6gorJbylgfAQiPmqcQN88db+2aACamOFa3rW/z7Y0BPZKnRYmXIaNqvDjQeYMVt9AZ5j3/L2aaumH5Pduj0Tj77Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by MW4PR13MB5940.namprd13.prod.outlook.com (2603:10b6:303:1b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.9; Mon, 10 Oct 2022 06:29:06 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7c26:1a0b:2825:6f4b]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7c26:1a0b:2825:6f4b%4]) with mapi id 15.20.5723.014; Mon, 10 Oct 2022 06:29:06 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH] net/nfp: add the feature of RSS based on VXLAN inner layer Date: Mon, 10 Oct 2022 14:28:49 +0800 Message-Id: <1665383329-23583-1-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR06CA0008.apcprd06.prod.outlook.com (2603:1096:4:186::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW4PR13MB5940:EE_ X-MS-Office365-Filtering-Correlation-Id: f957e286-2062-4474-d2f0-08daaa88bb47 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IFHPBaFvEBtL7N547Pfe4ED70bp+c79FZRr9qs+ECimvgQTaktj9ChaR19RP143S2GFLmEmhxj1jgs9WHIpr6KR7CoAxJzDIVqQI9JdzdQLDiVlO4yq4Ch+Xje83cUbTwEj1UPUiKLU2bAqoWnRw3uIIQtmWjt9LsGx2jjIMwdDH9n1Ca6lZYBx7SqxmbqdPi/BQybeobgCCkAxNxZcEuJ9RpadhbdZq7urRVjihPjYAij4rH9IS8l94Xj9Nhh0uBFo3O+45dQCoXCinQTvxkk2rb21xi/UCynxbdptWhzcZfoNlnprZZPopFY5tZOoALvpNFQBCeKxLhDC77sSqU0BDG/mMe77o+zDRdPR3uDwfM0C3IvhMzInvCXxQ+Xit9Q0Ob0nDz6v+7WYSQW1SpH2EVFsVNamblFZFKDN/2ElghPdHVi18RSscVGKgkvTLQXlcvZzDDC8J+ukN2xUYRS6mJv2teI4bGufk61jNNJfcfQagXxfAGEFyL0Uke9Mp3MYabrtlvmFSRYpza7lWbwaLJTKPy0j21biOIMEC6IpIU+RftwCA1sVDj+Je8mtm3rQU4OXyjFNkj9KqFYxMmF97KpxRuKYKTSnzLPtR4rJyP7h0OWe1ySgkvCpBvuOUp2G3fzjY5I8UC0wtj3AFcnnx5jHkTa7OFNMkJ3sOnoPzdqVAadIEAyiZGXyY6gF49iNragbXN3oJh3/JXpaT4gCdlODIS8QZAOKwRS/8W64smTrJmXrGySp6jyzWNl3ashB4XlYJVbwQhbDrOaje0A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(376002)(39840400004)(136003)(346002)(366004)(451199015)(4326008)(478600001)(2616005)(186003)(41300700001)(66946007)(66476007)(5660300002)(38350700002)(38100700002)(8676002)(6486002)(66556008)(66574015)(26005)(6916009)(83380400001)(316002)(86362001)(44832011)(6666004)(6506007)(8936002)(6512007)(52116002)(36756003)(2906002)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?c0dKd2lLeVphald1cUNRMFN3R3ZLQWlhcm50dFVsZ3NqeXhveW9uZjgzOEVZ?= =?utf-8?B?NHVSNk5FTmZ4dUZCZ09vQlJRVlkvTGVvekdJait5Rm9SZnlyVnBiNGlidFYw?= =?utf-8?B?QkNsRXRzVDg0NXlaTzc2bzdTT1dQbzdqSmZnK0R0YjJQTVNGL0hOV0RJYTc2?= =?utf-8?B?cG1PemkxYjBEVFREK2Nmb21OV201RHAwVHBCWStPRFN1R1gwUGhpY1RnU1R6?= =?utf-8?B?UXdhVGd5dTcyV2hFRHM0Ync0eGFaUVlCL21GWVR0TzRLQzdHSUhxMmF4Z2lp?= =?utf-8?B?dWVvcDQwVGpHWGVONXFvVnFvckg3djE2NkVBb2dVa1VsMjBqbURDRm5sSk4y?= =?utf-8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klhUG5OblpT?= =?utf-8?B?VEE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f957e286-2062-4474-d2f0-08daaa88bb47 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2022 06:29:06.2229 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HYHMtwGRE5yazLa0G6dljhCvesZjJ3rYY9HUlzCKjCxS0VDpLnLi1xYy7zzxwaaXZY85MqY4Cm4h6POc7+Dyjeo+cNkJJnWvp1TMlHHcyBc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR13MB5940 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add the logics to support the feature of RSS packets based on the inner layer of VXLAN tunnel. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund Depends-on: series-24819 ("preparation for the rte_flow offload of nfp PMD") --- drivers/net/nfp/flower/nfp_flower.c | 2 +- drivers/net/nfp/flower/nfp_flower_cmsg.c | 1 + drivers/net/nfp/flower/nfp_flower_ctrl.c | 2 +- drivers/net/nfp/flower/nfp_flower_representor.c | 2 +- drivers/net/nfp/nfp_common.c | 33 +++++++ drivers/net/nfp/nfp_common.h | 4 + drivers/net/nfp/nfp_cpp_bridge.h | 2 - drivers/net/nfp/nfp_ethdev.c | 111 ++++++++++++++++++++++++ drivers/net/nfp/nfp_ethdev_vf.c | 1 + drivers/net/nfp/nfp_rxtx.c | 1 + 10 files changed, 154 insertions(+), 5 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 3e97f5c..da96d2f 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -10,9 +10,9 @@ #include #include +#include "../nfp_ctrl.h" #include "../nfp_common.h" #include "../nfp_logs.h" -#include "../nfp_ctrl.h" #include "../nfp_cpp_bridge.h" #include "../nfp_rxtx.h" #include "../nfpcore/nfp_mip.h" diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 750a629..b719eb2 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -5,6 +5,7 @@ #include "../nfpcore/nfp_nsp.h" #include "../nfp_logs.h" +#include "../nfp_ctrl.h" #include "../nfp_common.h" #include "nfp_flower.h" #include "nfp_flower_cmsg.h" diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c index df908ef..961ca34 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -6,9 +6,9 @@ #include #include +#include "../nfp_ctrl.h" #include "../nfp_common.h" #include "../nfp_logs.h" -#include "../nfp_ctrl.h" #include "../nfp_rxtx.h" #include "nfp_flower.h" #include "nfp_flower_ctrl.h" diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 0e60f50..8db73e0 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -6,9 +6,9 @@ #include #include +#include "../nfp_ctrl.h" #include "../nfp_common.h" #include "../nfp_logs.h" -#include "../nfp_ctrl.h" #include "../nfp_rxtx.h" #include "../nfpcore/nfp_mip.h" #include "../nfpcore/nfp_rtsym.h" diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 07781a1..ec6a669 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -37,6 +37,7 @@ #include "nfpcore/nfp_rtsym.h" #include "nfpcore/nfp_nsp.h" +#include "nfp_ctrl.h" #include "nfp_common.h" #include "nfp_ctrl.h" #include "nfp_rxtx.h" @@ -1370,6 +1371,38 @@ } } +int +nfp_net_set_vxlan_port(struct nfp_net_hw *hw, + size_t idx, + uint16_t port) +{ + int ret; + uint32_t i; + + if (idx > NFP_NET_N_VXLAN_PORTS) { + PMD_DRV_LOG(ERR, "The idx value is out of range."); + return -ERANGE; + } + + hw->vxlan_ports[idx] = port; + + for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) { + nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port), + (hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]); + } + + rte_spinlock_lock(&hw->reconfig_lock); + + nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN); + rte_wmb(); + + ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN); + + rte_spinlock_unlock(&hw->reconfig_lock); + + return ret; +} + RTE_LOG_REGISTER_SUFFIX(nfp_logtype_init, init, NOTICE); RTE_LOG_REGISTER_SUFFIX(nfp_logtype_driver, driver, NOTICE); RTE_LOG_REGISTER_SUFFIX(nfp_logtype_cpp, cpp, NOTICE); diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index 27ea9c2..cc9ac01 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -209,6 +209,9 @@ struct nfp_net_hw { int stride_rx; int stride_tx; + uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS]; + uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS]; + uint8_t *qcp_cfg; rte_spinlock_t reconfig_lock; @@ -438,6 +441,7 @@ int nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev, void nfp_net_close_rx_queue(struct rte_eth_dev *dev); void nfp_net_stop_tx_queue(struct rte_eth_dev *dev); void nfp_net_close_tx_queue(struct rte_eth_dev *dev); +int nfp_net_set_vxlan_port(struct nfp_net_hw *hw, size_t idx, uint16_t port); #define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ (&((struct nfp_net_adapter *)adapter)->hw) diff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h index 7fee3a9..2abc77c 100644 --- a/drivers/net/nfp/nfp_cpp_bridge.h +++ b/drivers/net/nfp/nfp_cpp_bridge.h @@ -16,8 +16,6 @@ #ifndef _NFP_CPP_BRIDGE_H_ #define _NFP_CPP_BRIDGE_H_ -#include "nfp_common.h" - #define NFP_CPP_MEMIO_BOUNDARY (1 << 20) #define NFP_BRIDGE_OP_READ 20 #define NFP_BRIDGE_OP_WRITE 30 diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index e131021..0e3d82a 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -32,6 +32,7 @@ #include "nfpcore/nfp_rtsym.h" #include "nfpcore/nfp_nsp.h" +#include "nfp_ctrl.h" #include "nfp_common.h" #include "nfp_ctrl.h" #include "nfp_rxtx.h" @@ -138,6 +139,10 @@ update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING; + /* Enable vxlan */ + new_ctrl |= NFP_NET_CFG_CTRL_VXLAN; + update |= NFP_NET_CFG_UPDATE_VXLAN; + if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG) new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG; @@ -319,6 +324,110 @@ return 0; } +static int +nfp_net_find_vxlan_idx(struct nfp_net_hw *hw, + uint16_t port, + uint32_t *idx) +{ + uint32_t i; + int free_idx = -1; + + for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i++) { + if (hw->vxlan_ports[i] == port) { + free_idx = i; + break; + } + + if (hw->vxlan_usecnt[i] == 0) { + free_idx = i; + break; + } + } + + if (free_idx == -1) + return -EINVAL; + + *idx = free_idx; + + return 0; +} + +static int +nfp_udp_tunnel_port_add(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *tunnel_udp) +{ + int ret; + uint32_t idx; + uint16_t vxlan_port; + struct nfp_net_hw *hw; + enum rte_eth_tunnel_type tnl_type; + + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + vxlan_port = tunnel_udp->udp_port; + tnl_type = tunnel_udp->prot_type; + + if (tnl_type != RTE_ETH_TUNNEL_TYPE_VXLAN) { + PMD_DRV_LOG(ERR, "Not VXLAN tunnel"); + return -ENOTSUP; + } + + ret = nfp_net_find_vxlan_idx(hw, vxlan_port, &idx); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed find valid vxlan idx"); + return -EINVAL; + } + + if (hw->vxlan_usecnt[idx] == 0) { + ret = nfp_net_set_vxlan_port(hw, idx, vxlan_port); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed set vxlan port"); + return -EINVAL; + } + } + + hw->vxlan_usecnt[idx]++; + + return 0; +} + +static int +nfp_udp_tunnel_port_del(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *tunnel_udp) +{ + int ret; + uint32_t idx; + uint16_t vxlan_port; + struct nfp_net_hw *hw; + enum rte_eth_tunnel_type tnl_type; + + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + vxlan_port = tunnel_udp->udp_port; + tnl_type = tunnel_udp->prot_type; + + if (tnl_type != RTE_ETH_TUNNEL_TYPE_VXLAN) { + PMD_DRV_LOG(ERR, "Not VXLAN tunnel"); + return -ENOTSUP; + } + + ret = nfp_net_find_vxlan_idx(hw, vxlan_port, &idx); + if (ret != 0 || hw->vxlan_usecnt[idx] == 0) { + PMD_DRV_LOG(ERR, "Failed find valid vxlan idx"); + return -EINVAL; + } + + hw->vxlan_usecnt[idx]--; + + if (hw->vxlan_usecnt[idx] == 0) { + ret = nfp_net_set_vxlan_port(hw, idx, 0); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed set vxlan port"); + return -EINVAL; + } + } + + return 0; +} + /* Initialise and register driver with DPDK Application */ static const struct eth_dev_ops nfp_net_eth_dev_ops = { .dev_configure = nfp_net_configure, @@ -347,6 +456,8 @@ .tx_queue_release = nfp_net_tx_queue_release, .rx_queue_intr_enable = nfp_rx_queue_intr_enable, .rx_queue_intr_disable = nfp_rx_queue_intr_disable, + .udp_tunnel_port_add = nfp_udp_tunnel_port_add, + .udp_tunnel_port_del = nfp_udp_tunnel_port_del, }; static inline int diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index 6c6caef..fa0d289 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -18,6 +18,7 @@ #include "nfpcore/nfp_mip.h" #include "nfpcore/nfp_rtsym.h" +#include "nfp_ctrl.h" #include "nfp_common.h" #include "nfp_ctrl.h" #include "nfp_rxtx.h" diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index b8c874d..b764845 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -16,6 +16,7 @@ #include #include +#include "nfp_ctrl.h" #include "nfp_common.h" #include "nfp_ctrl.h" #include "nfp_rxtx.h" -- 1.8.3.1