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 E8F6BA0032; Sat, 22 Oct 2022 10:25:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6EE742826; Sat, 22 Oct 2022 10:25:11 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2121.outbound.protection.outlook.com [40.107.101.121]) by mails.dpdk.org (Postfix) with ESMTP id CDED04280E for ; Sat, 22 Oct 2022 10:25:04 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKRmgoB/RuyzTAZajkP+RZP0b01VHIRqBJZq+SJbLGwWnzBiYvxsW/Agn2vy/tfIWzb9ucg0eoKjHBOs9iN3O6wzSdjfODajYX/yeycv1emg3MfyrlWu3Ifd371OVwcHNPdAx3P7iYn8G9aQRA0mTk4Nq+tzQ+jK7OtOXbXvPLjKqTiuFtUP2reSTQGkpJ+HVFA4EKBgM2M6FvyDeydNiy3IOSy0suxbHKguaj6dyJoPtXYjFm2YCnzAkrD2yLJ+hQIQkuLfISvpcuXI2plDg9VkK7oDhjL3pjTUp+B5bG1sVNLVY+bbQFetqVoDmxm0G/GCezDHAuX/Iq4bdlLzfg== 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=jliCd/nIeGTL/9h591nPJmFwNw8wmS1SEpWrvudXAvg=; b=keDLoFz0UWchbGUXv7hu1dc5i4A2IqosMyrv502DwurvGgl+NRi9qXvK9D/qXTXz39c93eNXARs4NvtpbaXmS+KHIKyHwH5k5eU5YEYd5VNY67UutcpP13evHbRC6WZrp8Jmix6qGtYgdu0crNd6GYPID1QtSBA2uiMyvbNt9NHt2KYEgLbBPAJX0McpxPbjcANtw23Bs+gR4IKUV10eV0+jtF5IuseX/cb1Ivd6IS0XwNycrb6gqwKSsckL3sYG5uUeQInrUv500xIZ/sh4bX6xHDRfODsiT69sp5by6TnZpKLIvW/XgW2F2Td40Z+ToNdJ6TTWk47a5HER97Grfw== 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=jliCd/nIeGTL/9h591nPJmFwNw8wmS1SEpWrvudXAvg=; b=GcSHOphly6oNBmIhHiR5iW/NBApGIsaZ9r2V/DBQ9fZ+mun7ubfCjbUrXVq8fNogDug3IWOHVsfaRGyK+8lwPffJ30TY+yEJD7MnSdXwfv5CJIIX/qZc6NbpZ6IpdsZ+7qESbY8jdlWvUYPBpSio+xeQkFSzAosToRTrG/E7l1I= 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 PH7PR13MB5454.namprd13.prod.outlook.com (2603:10b6:510:130::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.8; Sat, 22 Oct 2022 08:25:03 +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; Sat, 22 Oct 2022 08:25:03 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 08/25] net/nfp: prepare for IPv6 UDP tunnel decap flow action Date: Sat, 22 Oct 2022 16:24:12 +0800 Message-Id: <1666427069-10553-9-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666427069-10553-1-git-send-email-chaoyong.he@corigine.com> References: <1666063359-34283-1-git-send-email-chaoyong.he@corigine.com> <1666427069-10553-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR02CA0056.apcprd02.prod.outlook.com (2603:1096:4:54::20) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB5454:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f520451-c213-48db-3983-08dab406eac4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dulH9spawytQdEbHg0IBO84Nq+28fUT0z4BmNadupRA3S5TzipXYfs0+0z52FPI81F26fWXf+6fCwmfgx4KJZCSdVslozdkJzc8nNnDLyfyYAhHt6D8RAllxq7dpplPHTzLd7zVn/sIGS4bpIHKsTbiJKfY7IZcQltMgwGD9LFipMgnx7TCQ0kIZu2QY8b4odepXSpNIG1EmOe4WCKTMQgJAN9YrYJ3ch/hyrPNCIRbk/OWlb2bE2dU64m/CTrE4pLUJEhR+Ft6F3fu6NLhI2c1PXI8ZTbgNhx6u9ZZLLJpIpA2V/DLZrScpwjBFeArVNKIKWpVH84L/OlynJFdTAFgm8rQUi76FFcdzaqfT4sSi7NweM2/FLPKVdDYVIRo0otUHKcyWXQcEWvstpMWTZ5rZAJ0NuOVQG6HHSWAUmK8SLBCkBNRruCAzRFDG0R4CDyrOl6R4RTv51ZLPHLkkSWbUoD4FzRL6IPOWqs8uLtaykTTprkJdvW4eHGXSKtiFZse26vin5w4F4x9Xb2HilglutuBvVhXEfKAQ6YNh9VUtWiMMwCweWSVRQSKO1m3opmba5p5/cwQVnLIjx1RcrDWU11jhw99PdCeJcEGmJH5ZOy5LRIa5PneXd3I+PCU2M/x2yXzVR/5zWEUTY31NjH7uvescguzZNIgAieD4Zmkw8kL0ZOu/CjkUCLVVNlR78p/V8Tg0owoChb6rZ7WaTJNcD0iJyDDKMhNnLHzd9mJPtWCKEJ2KkZ5C215quKmz1WQkXaxIduFQ5U+DyfdTrhSGqQBFU/K+BucO8y3culI= 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)(346002)(366004)(396003)(376002)(39840400004)(136003)(451199015)(186003)(6916009)(316002)(66574015)(83380400001)(2616005)(38350700002)(86362001)(44832011)(30864003)(38100700002)(66556008)(5660300002)(41300700001)(107886003)(478600001)(6506007)(6486002)(6666004)(8676002)(26005)(6512007)(8936002)(4326008)(2906002)(52116002)(66946007)(66476007)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MGNHVGdReEdQbWZWUjdSTlppRUhoK1V6eUlhOUYvSTR0Yjhsa2JWaTN6NkZs?= =?utf-8?B?czkwZGNtZjA2WHFpcHRwcVNBUlZ6aVFDbUFhMmhWdEY3UE5HQ2d1T2gzR3BC?= =?utf-8?B?a2ZwYThoM3hWQkRRK3F2TkVDOGZvMyszVXZpelF4VVJISFFvTU91T3E5R05z?= =?utf-8?B?VXlHWTFYeWlQWk16UFNUUUo1WTE2dkk2aGpRU0t1MzRMNjVnTjNFajV6V3ZU?= =?utf-8?B?N2N4L293eS9BeHNnWVZ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?= =?utf-8?B?VFpBdUpMdzE2UGt5ZnZ1LzQzS1Vlc2EwYmJDeWhqMXdkUU1sYkYxYW9aVStD?= =?utf-8?B?MTg5STlraWg3TkFXZ2Q0WlJiSm8zYTZObFN3bjZCNmZYc29ZeDMwLzBDYTNU?= =?utf-8?B?S0E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f520451-c213-48db-3983-08dab406eac4 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2022 08:25:02.9128 (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: PkxlogRLtjOqq0yTzgweLw/ZkOPIk9pqEV4hCFbCU2X/CMyYwjgVF9neKBE2RKBMTjy0ZzTPw/VNz/F3eKz0TyP1CLeqx3OwM6Mab55w4y8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5454 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 related data structure and functions, prepare for the decap action of IPv6 UDP tunnel. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower_cmsg.c | 42 +++++++++ drivers/net/nfp/flower/nfp_flower_cmsg.h | 24 +++++ drivers/net/nfp/nfp_flow.c | 145 ++++++++++++++++++++++++++++++- drivers/net/nfp/nfp_flow.h | 9 ++ 4 files changed, 217 insertions(+), 3 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index f18f3de..76815cf 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -348,6 +348,48 @@ } int +nfp_flower_cmsg_tun_off_v6(struct nfp_app_fw_flower *app_fw_flower) +{ + uint16_t cnt; + uint32_t count = 0; + struct rte_mbuf *mbuf; + struct nfp_flow_priv *priv; + struct nfp_ipv6_addr_entry *entry; + struct nfp_flower_cmsg_tun_ipv6_addr *msg; + + mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool); + if (mbuf == NULL) { + PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for v6 tun addr"); + return -ENOMEM; + } + + msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_TUN_IPS_V6, sizeof(*msg)); + + priv = app_fw_flower->flow_priv; + rte_spinlock_lock(&priv->ipv6_off_lock); + LIST_FOREACH(entry, &priv->ipv6_off_list, next) { + if (count >= NFP_FL_IPV6_ADDRS_MAX) { + rte_spinlock_unlock(&priv->ipv6_off_lock); + PMD_DRV_LOG(ERR, "IPv6 offload exceeds limit."); + return -ERANGE; + } + memcpy(&msg->ipv6_addr[count * 16], entry->ipv6_addr, 16UL); + count++; + } + msg->count = rte_cpu_to_be_32(count); + rte_spinlock_unlock(&priv->ipv6_off_lock); + + cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf); + if (cnt == 0) { + PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed."); + rte_pktmbuf_free(mbuf); + return -EIO; + } + + return 0; +} + +int nfp_flower_cmsg_pre_tunnel_rule(struct nfp_app_fw_flower *app_fw_flower, struct nfp_fl_rule_metadata *nfp_flow_meta, uint16_t mac_idx, diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 0933dac..61f2f83 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -280,6 +280,29 @@ struct nfp_flower_cmsg_tun_ipv4_addr { rte_be32_t ipv4_addr[NFP_FL_IPV4_ADDRS_MAX]; }; +#define NFP_FL_IPV6_ADDRS_MAX 4 + +/* + * NFP_FLOWER_CMSG_TYPE_TUN_IP_V6 + * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +---------------------------------------------------------------+ + * 0 | Number of IP Addresses | + * +---------------------------------------------------------------+ + * 1 | IP Address1 #1 | + * +---------------------------------------------------------------+ + * 2 | IP Address1 #2 | + * +---------------------------------------------------------------+ + * | ... | + * +---------------------------------------------------------------+ + * 16 | IP Address4 #4 | + * +---------------------------------------------------------------+ + */ +struct nfp_flower_cmsg_tun_ipv6_addr { + rte_be32_t count; + uint8_t ipv6_addr[NFP_FL_IPV6_ADDRS_MAX * 16]; +}; + /* * NFP_FLOWER_CMSG_TYPE_FLOW_STATS * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 @@ -802,6 +825,7 @@ int nfp_flower_cmsg_tun_neigh_v4_rule(struct nfp_app_fw_flower *app_fw_flower, int nfp_flower_cmsg_tun_neigh_v6_rule(struct nfp_app_fw_flower *app_fw_flower, struct nfp_flower_cmsg_tun_neigh_v6 *payload); int nfp_flower_cmsg_tun_off_v4(struct nfp_app_fw_flower *app_fw_flower); +int nfp_flower_cmsg_tun_off_v6(struct nfp_app_fw_flower *app_fw_flower); int nfp_flower_cmsg_pre_tunnel_rule(struct nfp_app_fw_flower *app_fw_flower, struct nfp_fl_rule_metadata *nfp_flow_meta, uint16_t mac_idx, diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index c088d24..ad484b9 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -476,16 +476,95 @@ struct nfp_pre_tun_entry { return 0; } +__rte_unused static int +nfp_tun_add_ipv6_off(struct nfp_app_fw_flower *app_fw_flower, + uint8_t ipv6[]) +{ + struct nfp_flow_priv *priv; + struct nfp_ipv6_addr_entry *entry; + struct nfp_ipv6_addr_entry *tmp_entry; + + priv = app_fw_flower->flow_priv; + + rte_spinlock_lock(&priv->ipv6_off_lock); + LIST_FOREACH(entry, &priv->ipv6_off_list, next) { + if (!memcmp(entry->ipv6_addr, ipv6, sizeof(entry->ipv6_addr))) { + entry->ref_count++; + rte_spinlock_unlock(&priv->ipv6_off_lock); + return 0; + } + } + rte_spinlock_unlock(&priv->ipv6_off_lock); + + tmp_entry = rte_zmalloc("nfp_ipv6_off", sizeof(struct nfp_ipv6_addr_entry), 0); + if (tmp_entry == NULL) { + PMD_DRV_LOG(ERR, "Mem error when offloading IP6 address."); + return -ENOMEM; + } + memcpy(tmp_entry->ipv6_addr, ipv6, sizeof(tmp_entry->ipv6_addr)); + tmp_entry->ref_count = 1; + + rte_spinlock_lock(&priv->ipv6_off_lock); + LIST_INSERT_HEAD(&priv->ipv6_off_list, tmp_entry, next); + rte_spinlock_unlock(&priv->ipv6_off_lock); + + return nfp_flower_cmsg_tun_off_v6(app_fw_flower); +} + +static int +nfp_tun_del_ipv6_off(struct nfp_app_fw_flower *app_fw_flower, + uint8_t ipv6[]) +{ + struct nfp_flow_priv *priv; + struct nfp_ipv6_addr_entry *entry; + + priv = app_fw_flower->flow_priv; + + rte_spinlock_lock(&priv->ipv6_off_lock); + LIST_FOREACH(entry, &priv->ipv6_off_list, next) { + if (!memcmp(entry->ipv6_addr, ipv6, sizeof(entry->ipv6_addr))) { + entry->ref_count--; + if (entry->ref_count == 0) { + LIST_REMOVE(entry, next); + rte_free(entry); + rte_spinlock_unlock(&priv->ipv6_off_lock); + return nfp_flower_cmsg_tun_off_v6(app_fw_flower); + } + break; + } + } + rte_spinlock_unlock(&priv->ipv6_off_lock); + + return 0; +} + static int nfp_tun_check_ip_off_del(struct nfp_flower_representor *repr, struct rte_flow *nfp_flow) { int ret; + uint32_t key_layer2 = 0; struct nfp_flower_ipv4_udp_tun *udp4; + struct nfp_flower_ipv6_udp_tun *udp6; + struct nfp_flower_meta_tci *meta_tci; + struct nfp_flower_ext_meta *ext_meta = NULL; - udp4 = (struct nfp_flower_ipv4_udp_tun *)(nfp_flow->payload.mask_data - - sizeof(struct nfp_flower_ipv4_udp_tun)); - ret = nfp_tun_del_ipv4_off(repr->app_fw_flower, udp4->ipv4.dst); + meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data; + if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META) + ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1); + + if (ext_meta != NULL) + key_layer2 = rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2); + + if (key_layer2 & NFP_FLOWER_LAYER2_TUN_IPV6) { + udp6 = (struct nfp_flower_ipv6_udp_tun *)(nfp_flow->payload.mask_data - + sizeof(struct nfp_flower_ipv6_udp_tun)); + ret = nfp_tun_del_ipv6_off(repr->app_fw_flower, udp6->ipv6.ipv6_dst); + } else { + udp4 = (struct nfp_flower_ipv4_udp_tun *)(nfp_flow->payload.mask_data - + sizeof(struct nfp_flower_ipv4_udp_tun)); + ret = nfp_tun_del_ipv4_off(repr->app_fw_flower, udp4->ipv4.dst); + } return ret; } @@ -2078,6 +2157,59 @@ struct nfp_pre_tun_entry { return nfp_flower_cmsg_tun_neigh_v6_rule(app_fw_flower, &payload); } +__rte_unused static int +nfp_flower_add_tun_neigh_v6_decap(struct nfp_app_fw_flower *app_fw_flower, + struct rte_flow *nfp_flow) +{ + struct nfp_fl_tun *tmp; + struct nfp_fl_tun *tun; + struct nfp_flow_priv *priv; + struct nfp_flower_ipv6 *ipv6; + struct nfp_flower_mac_mpls *eth; + struct nfp_flower_in_port *port; + struct nfp_flower_meta_tci *meta_tci; + struct nfp_flower_cmsg_tun_neigh_v6 payload; + + meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data; + port = (struct nfp_flower_in_port *)(meta_tci + 1); + eth = (struct nfp_flower_mac_mpls *)(port + 1); + + if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_TP) + ipv6 = (struct nfp_flower_ipv6 *)((char *)eth + + sizeof(struct nfp_flower_mac_mpls) + + sizeof(struct nfp_flower_tp_ports)); + else + ipv6 = (struct nfp_flower_ipv6 *)((char *)eth + + sizeof(struct nfp_flower_mac_mpls)); + + tun = &nfp_flow->tun; + tun->payload.v6_flag = 1; + memcpy(tun->payload.dst.dst_ipv6, ipv6->ipv6_src, sizeof(tun->payload.dst.dst_ipv6)); + memcpy(tun->payload.src.src_ipv6, ipv6->ipv6_dst, sizeof(tun->payload.src.src_ipv6)); + memcpy(tun->payload.dst_addr, eth->mac_src, RTE_ETHER_ADDR_LEN); + memcpy(tun->payload.src_addr, eth->mac_dst, RTE_ETHER_ADDR_LEN); + + tun->ref_cnt = 1; + priv = app_fw_flower->flow_priv; + LIST_FOREACH(tmp, &priv->nn_list, next) { + if (memcmp(&tmp->payload, &tun->payload, sizeof(struct nfp_fl_tun_entry)) == 0) { + tmp->ref_cnt++; + return 0; + } + } + + LIST_INSERT_HEAD(&priv->nn_list, tun, next); + + memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6)); + memcpy(payload.dst_ipv6, ipv6->ipv6_src, sizeof(payload.dst_ipv6)); + memcpy(payload.src_ipv6, ipv6->ipv6_dst, sizeof(payload.src_ipv6)); + memcpy(payload.common.dst_mac, eth->mac_src, RTE_ETHER_ADDR_LEN); + memcpy(payload.common.src_mac, eth->mac_dst, RTE_ETHER_ADDR_LEN); + payload.common.port_id = port->in_port; + + return nfp_flower_cmsg_tun_neigh_v6_rule(app_fw_flower, &payload); +} + static int nfp_flower_del_tun_neigh_v6(struct nfp_app_fw_flower *app_fw_flower, uint8_t *ipv6) @@ -2401,6 +2533,9 @@ struct nfp_pre_tun_entry { nfp_mac_idx = (find_entry->mac_index << 8) | NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT | NFP_TUN_PRE_TUN_IDX_BIT; + if (nfp_flow->tun.payload.v6_flag != 0) + nfp_mac_idx |= NFP_TUN_PRE_TUN_IPV6_BIT; + ret = nfp_flower_cmsg_tun_mac_rule(repr->app_fw_flower, &repr->mac_addr, nfp_mac_idx, true); if (ret != 0) { @@ -3263,6 +3398,10 @@ struct nfp_pre_tun_entry { rte_spinlock_init(&priv->ipv4_off_lock); LIST_INIT(&priv->ipv4_off_list); + /* ipv6 off list */ + rte_spinlock_init(&priv->ipv6_off_lock); + LIST_INIT(&priv->ipv6_off_list); + /* neighbor next list */ LIST_INIT(&priv->nn_list); diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h index f536da2..a6994e0 100644 --- a/drivers/net/nfp/nfp_flow.h +++ b/drivers/net/nfp/nfp_flow.h @@ -177,6 +177,12 @@ struct nfp_ipv4_addr_entry { int ref_count; }; +struct nfp_ipv6_addr_entry { + LIST_ENTRY(nfp_ipv6_addr_entry) next; + uint8_t ipv6_addr[16]; + int ref_count; +}; + #define NFP_TUN_PRE_TUN_RULE_LIMIT 32 struct nfp_flow_priv { @@ -201,6 +207,9 @@ struct nfp_flow_priv { /* IPv4 off */ LIST_HEAD(, nfp_ipv4_addr_entry) ipv4_off_list; /**< Store ipv4 off */ rte_spinlock_t ipv4_off_lock; /**< Lock the ipv4 off list */ + /* IPv6 off */ + LIST_HEAD(, nfp_ipv6_addr_entry) ipv6_off_list; /**< Store ipv6 off */ + rte_spinlock_t ipv6_off_lock; /**< Lock the ipv6 off list */ /* neighbor next */ LIST_HEAD(, nfp_fl_tun)nn_list; /**< Store nn entry */ }; -- 1.8.3.1