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 21520A0543; Tue, 25 Oct 2022 10:01:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E995042C0A; Tue, 25 Oct 2022 10:00:13 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2093.outbound.protection.outlook.com [40.107.223.93]) by mails.dpdk.org (Postfix) with ESMTP id C539942BDF for ; Tue, 25 Oct 2022 10:00:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sq6pXDwKI/nN5HDVgkrLQ3cl+gxUmkcFHnmtGntSAf7NIu6FCKS+vh6dfss9WTYJ2aA07pgnKhmLEV/ZaVB9uzyoK98V6snyCoA1GSqC14XLZay6Dqrdk1KNKyd3s6XSGxRmQmUA3XSVTmXDURKDpcTiu6XL/mF+NBDIh+D5Udtb29pbiBhe0By2E5jbOlfVsw3UW574CaU5hs3Uihi5+TUqnPY9QGFOxR07F3t4kdLNybwGx5J2cNhuqSbbS47ZkHY5qMdKpaiNVIN3wMD0m5JBYKN/2g59Ud/m317Wl48MKYaiEOJokUzLrukiaWLfsttjFlOY46nIa3QTliQLlg== 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=NV7WnMCsstyhD6L1ut1RVoDRfWUbA2rYady/OP3NS1s=; b=elIT64/6Ak2479SlSeq2HN06urfs/ryumTO+Ehuewy4VZ6jSLcwCjGXKsIFg/MzYjPnBB6oX7PtpcZbI3pcnUKR8eM19cNmPI9oiwaWdDAiC7t6VEydpn+zPW7Qjj5Qkyyb8q7oLq4wooKlyuvhN0s8RRkYVZAGTJeXpQfDD8llGrDSXEelBvwRPDTc5b92P+dKC6S1q2zcanlnlENdpXBkx3r6L1bkyg2dOc6Vj1Bu6F0B52icQ50XFSijBwSA+htaocqnvPZfnHpNOCehM7y8rT61A5JoOPHQIS3+3jQ+5t1Gs6EbPlfN4MUqEHyIXKqZtoOE1Z9xFfx8kOAXovw== 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=NV7WnMCsstyhD6L1ut1RVoDRfWUbA2rYady/OP3NS1s=; b=iuvW1pHKYgX1PHRZHSY24MTRgBHaD7DTafo3hUoZXTDCAsjWSxfEG2YggXqvmmQ9gbC3+M0/M9mUWLFbi2bBYzw+koE5kLcbC5xphbIDV+ZbyYR5re2aOS36lm6YVySvNRFN3IBpo5+z9OVOgFBz9U08ZmUnnB9jgSOrjFd6MQU= 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 MW5PR13MB5439.namprd13.prod.outlook.com (2603:10b6:303:196::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Tue, 25 Oct 2022 08:00:10 +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; Tue, 25 Oct 2022 08:00:10 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v3 09/26] net/nfp: prepare for IPv6 UDP tunnel decap flow action Date: Tue, 25 Oct 2022 15:59:01 +0800 Message-Id: <20221025075918.7778-10-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20221025075918.7778-1-chaoyong.he@corigine.com> References: <1666427069-10553-1-git-send-email-chaoyong.he@corigine.com> <20221025075918.7778-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR01CA0142.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::22) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW5PR13MB5439:EE_ X-MS-Office365-Filtering-Correlation-Id: 05aac5d4-6acb-44d3-19f4-08dab65ef022 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Lu/Bl8XcbNkwAGR32U1aA5QsjSxcQLlpoiHHpeTBp4pBicutsFCxjXaic3ZiAcyNi4eAAabN8AY1Hj+P4L4aDvOOaHL/HJ0gUGEDftwmRZATNU3gG0pQhiFiA9ZwQKsr95k0fjH/vMXYFJrcE4hR0Ne5YZXF0uXbC0P/QzjWWEv/qiHswrewvkSvkppSgBPcLitAv6taF//ildcKS30Xv2opCh1QmaOfq74aaEZ+yib02MqjdXq7EUr+HhtpEaYph6EuZtXoF6b9lq/QXxzSCCx8f29cKCDALeAORV5hhJLRSGHCODt5sghcBoz0rSlRCr7ysObHTYkkT5Xan2qpNApedS09cGDezMl4MzFoke+IT9ScO+BEs31DAmgf7m6nYxKy6uHWDIerm/ElTgU168+WoNZtg4+HMmNmN0ZpvlMy/lqAodGIfgm9Mf/3G466Iz9rY5NTWzuOAdpMgztziLnPTvT2IRXzLGgri5a6fIAwL4tQvJ79TbEMUfEPg1WrWwzwBy7EJlggrotlKj8BOuBfHOWZoyUukZRx53M21LMsAOhGNw8K5maoLi92rTvD2vaBbZDpul2L5tcioW5zsjYXBdeqlezvS+xRvMQ99NqgZuZmKfwR0YI53ZooDLhx9UI0tpIy8lwRGsLsNQxoCETefMGW9H1YU/x6h5Uw2374RIqugoP5tAaR2DHTPYeVerUxNqIEzmqUM8QvEVn02uesFb9c5pZddTpjPBjD2XeR+b8U4ZCYGHA2aKwBm5QI 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)(39850400004)(366004)(396003)(346002)(376002)(136003)(451199015)(83380400001)(6506007)(478600001)(316002)(38100700002)(52116002)(38350700002)(2906002)(41300700001)(30864003)(5660300002)(6486002)(44832011)(66946007)(66476007)(4326008)(66556008)(8676002)(6916009)(66574015)(1076003)(8936002)(6512007)(86362001)(2616005)(26005)(107886003)(6666004)(36756003)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SE1QVjcyMk43M3YwVHlxMHhlZjJIVStDemloZXR1MjU3VkRvdlVnWTZsR0Rm?= =?utf-8?B?N2pmMEpPUVpTUjZhdzFzdlR5UUNwdm1TUG9KbGpMS3pvaVFtWjQ1K1pLZEZh?= =?utf-8?B?SFhla2Z5TkhEbXlLWjRNeUdHTGJXRzJIZERPOVRsSHlzSUNVb2UvMUFtQm1O?= =?utf-8?B?SytxVjhxSWUxaWtjYTdFWUNSaDZKazVQZml3ZC9KdXNqditqN21KTW9aam9F?= =?utf-8?B?d1ZXNE5MOWxGY1EvUWVsaC9vM2NLNXJOdlU5Q1VwT05qcXYwdnVvM2tQZS9w?= =?utf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JYWIxQ0ZVdEJDUGVDRjFsWitEVjIvcUtGaDcw?= =?utf-8?B?SEhhMW4yLy9RUnp2VkFJNDJ5d0xwc3pWMW1JdURqN2ZpWU5BZjRQQVpUbFVp?= =?utf-8?B?K3c9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05aac5d4-6acb-44d3-19f4-08dab65ef022 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 08:00:10.1430 (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: LsaKqHz6Ks5DgHJ195wn0FBC4WowwVCt9PUYkMX+nuM+0kIrKZabOhbFG+WkT1lKoiQsG3PznhHerdpN9x1TqkfV3IFkMEjh0Q2Lknj7lgA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR13MB5439 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 f18f3de042..76815cfe14 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -347,6 +347,48 @@ nfp_flower_cmsg_tun_off_v4(struct nfp_app_fw_flower *app_fw_flower) return 0; } +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, diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 0933dacfb1..61f2f83fc9 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 c088d24413..ad484b95b7 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -476,16 +476,95 @@ nfp_tun_del_ipv4_off(struct nfp_app_fw_flower *app_fw_flower, 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 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower, 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 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr, 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 @@ nfp_flow_priv_init(struct nfp_pf_dev *pf_dev) 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 f536da2650..a6994e08ee 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 */ }; -- 2.29.3