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 69F49A0560; Tue, 18 Oct 2022 05:23:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5150A427F9; Tue, 18 Oct 2022 05:23:18 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2123.outbound.protection.outlook.com [40.107.244.123]) by mails.dpdk.org (Postfix) with ESMTP id B5F5442685 for ; Tue, 18 Oct 2022 05:23:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YrFFd2Cg9VxJ7QIcwbggP54ae5+ALwekOchSvBxL6p8tLYMPDKwPHUKs0ryqB5p1mLs4/cFXe6+jemVSibSNvF7Z5IceDh9uLqBLLKaW6vkUB1F9V5g3iqiUKXvPp6t8XVQqq4HB6sBbLoPrbX6a8uCeGY6kYX0tDy2gPMW9uqubXqJLee8dp7tZKWFaVlpSQAxMfLxHyzHFfXxnt+fDrTOys/771gFmn0EAuGtcvbABoP/8IjSqKjo3THGhZuBnagy4j18BkWYLPyIvfgsjPaSq72wSoiWP6zIEn+hhcAYpu0QuIMNYkEqVCNJVUo+iC4mhqS2TapsHe/fwILjpaQ== 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=XkvZHnKd23qJTWtyPZUemdzdBjMgd8d8hzLzYD5w70I=; b=fCwpwBo+HQxpLFdqMRZy3+FPzATP9YaW4Lwii+d1CLakl5zJ5R8nt3yCt+rwbp4Ebu9b5BagOCSfVU52HlGBscdsddVFIHVNRTk9Ky8IOOf1ePWArS2HjaUUKPUMKtBbb6IDOdTGNpzSYSbGtb2WcCv8LBJx7w1YmHekc4l5KdK5IkCmi6ZZl++wCgbDHrJ34NDFKrfPXlxdV6R81WzUGMRG1u2NXURr4PLO93OdMg/j6vwMls4WNZ9c2qq/7f8zlagG0ZLFW3z2ioj5Xi05BQLYb1vwbrQGfynR0R+5IcgBMvgt2hxU+VwFi2KRyi0jLVEM04fhp1Zt+NHdMOevnA== 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=XkvZHnKd23qJTWtyPZUemdzdBjMgd8d8hzLzYD5w70I=; b=WHdY3onGJ9cXqpvacc86U/oq1ljJ0BpTZ4yq2I1Mttui+THm5d3Fkobnl/qz4A+DRNa02kNyyzzK7Ia7ZiiMjchk4gAzhLHIeuQMdzo8m6NvJ3WgSi3R9GNibVAKnE6lkvU4HnteKOReW4v/GRUzrEiHAt2ZDEEwjEfV28vx6KY= 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 BL3PR13MB5147.namprd13.prod.outlook.com (2603:10b6:208:33a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Tue, 18 Oct 2022 03:23:15 +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, 18 Oct 2022 03:23:15 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 08/25] net/nfp: prepare for the decap action of IPv6 UDP tunnel Date: Tue, 18 Oct 2022 11:22:22 +0800 Message-Id: <1666063359-34283-9-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666063359-34283-1-git-send-email-chaoyong.he@corigine.com> References: <1666063359-34283-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR01CA0184.apcprd01.prod.exchangelabs.com (2603:1096:4:189::9) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BL3PR13MB5147:EE_ X-MS-Office365-Filtering-Correlation-Id: ba8102c0-d2bd-4512-5d6b-08dab0b817e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7VDwx9Kv782JE/7+WVdWDecD9qBvhtxx0e8J2Z7mfTHYX2ogxld3F+kIX8pl8CiZY8pTnoS3SAcXRWT7JVVawrJrFD9wkhEyp+ZWA/I8sRAM0Zir2GBJFBplBTPOfgXKMLruDp+etvnDbs+AE5pcw7QoDy/Ec0ntRJ/NFNYjyWr5RvQqM/iGZefnG2VWZox0L/xHEmEfTccKXMXWI5fALHAn9oXUfjynLjsZKUzYLKnogW7wO5MsNmOBIzqbeb9IT3omYMYwLExksI2w23ghjKuK/8fVJaqqFDqnYoqDWebeKmQsXNzZZDNKWM6TLzSosXt7mVtTHoXUhXPwigtTnNq/MmUJaoq4avFEysjYfocRrCw7j8zQ01SFhfrBEdLQ+R53dzIWjv2rggUAGAkWH5pfLJWvBtHTo/CJpQSWYce492giu3sPuD7463YW34pioX0h52DEtZMOnQJrMXy7H24nOASscQmkWTDKEKw0671b6vMQrWLJOmwWHmSLGs+EmVrYmhUq8jL6L1hHJ1w9v+CGdIFBWBGxgIFnap6QluTQCgARbfCJHnwdze0F/TbXblqHFipty8ez5VqxD/hXFohurKmy2bJ+/+yJkvZCzZsMsxKNGmTKk9KicxPp6gS3mfbCXJcalD2stwtA3l+lr7HjXzkanEt8TwkCLkTopatBERnHcHNfVcjHvEoj633O9FsnU6TLK+/YL2WJNYT1RAcRa8I1RfAk/Gx2fyQXSJ3v/m21Yxm446/qD83EUSm9 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)(136003)(366004)(346002)(39840400004)(396003)(376002)(451199015)(36756003)(4326008)(66946007)(6916009)(316002)(5660300002)(30864003)(66476007)(66556008)(38100700002)(38350700002)(86362001)(107886003)(6666004)(6486002)(478600001)(26005)(6512007)(6506007)(52116002)(41300700001)(8936002)(2906002)(44832011)(8676002)(83380400001)(186003)(66574015)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NjZZalQ1WWs1eUo0RmZsQWlXL1pvckN3TDhTMHhkQTZWNFNiNUl6dkZCSnY5?= =?utf-8?B?dXk1bkpZUjY4TnJET1ZPNWNXbWxuWUJtdDhJTGtycjl6U0x5TFVibVNiMElV?= =?utf-8?B?MGFleHJRNVA4dkNlTzZuV2ZONjc4c1NVN09UdmtISk1sZDJEd21tbFBKQVV3?= =?utf-8?B?ZW9vQkloU1A2Z3k5ckVpSEl6UjZVMjFYRGk1a2cyeDJYU3BBYWRsVUxQUVFw?= =?utf-8?B?MEZVR0k5Tk81eWFzajJ6eEJ4U0VCUlNVdDFkWnJEZVBVclJyc1I5aWcxWUxJ?= =?utf-8?B?Wmtn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a0RWcEpuMWxjbnBN?= =?utf-8?B?aW1xREprNEF3RlhNNzBFNzVzellHRldlcmlLbnc1c2RTN1JWZ1A4cjJ4NFdv?= =?utf-8?B?TEE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba8102c0-d2bd-4512-5d6b-08dab0b817e9 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 03:23:14.9237 (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: 4TBvL05WWQbkYesjgG2D/8JQ9gcL2Rxv/oGB2FOMl+yF8wlewBv9P90SwXRCNdWEGilTq9X8rumuu1qRRZRLMCQw75oi+Zhtk8XmEvflTtc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR13MB5147 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 816c733..cc63aa5 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -487,16 +487,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; } @@ -2096,6 +2175,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) @@ -2419,6 +2551,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) { @@ -3267,6 +3402,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 84a3005..1b4a51f 100644 --- a/drivers/net/nfp/nfp_flow.h +++ b/drivers/net/nfp/nfp_flow.h @@ -176,6 +176,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 { @@ -200,6 +206,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