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 363A4A0543; Tue, 25 Oct 2022 10:00:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B2C9B42BEF; Tue, 25 Oct 2022 10:00:06 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2105.outbound.protection.outlook.com [40.107.223.105]) by mails.dpdk.org (Postfix) with ESMTP id 58C1242BCE for ; Tue, 25 Oct 2022 10:00:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WN3680CnDAUd7oZXmfL2e8D+rMskE7hT1IhsDsvQTWhTREsRuXdrb3MKaycQWZnncIxH2gLi3oZKE8YD6Tk2afFcbcV5PoZH9YbSCyB3WcIb+okzqQps9cMIWfFbKK9QKyJ5UuXQy29v5obc3VESBhOJCmHznelyrMT2wYtsiMV9W39o0ZkAlssGFza9TXWP/puDD9zH6fJbq7fIpuCtsKYF2zykcCS1iOPSRjQV0v8O5izyitr8vFrilLwhS+mQqrW03aVKJnTADIPpjubWneHDkjxF7py5Pen9iD2kbwE0IR5nEljDAAowa7xy+tRd/w7Ge161C5PxmsVTzYqGmA== 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=74y9dN8OAZoGdZMFwP6pxtEVhjfXH/vY/a8SwqFCsFY=; b=CBb7uxASOnlMxM+1OblPh2MgiqCtLJyoXgn8+bX3E4/GwFnpdRWssoduIJRMsUyOKQgGU2yu6jjj0mbR5YPEPDdFoRsxrwi9yDrPrvnmX2CYAxU+kbYPG6ZsuqfxB5+TCOU3dRh3x3ZgVC7Lq/51z1fFFTiXKnKR03zOTM/soaigyyA+HADAhLR2/GRLVzCXQdDuMhtcirSWU0FuukTDkK9vGTizaIL3E1POTHlUjXsINH03FZhXHzEEVp5ZMZSiCjrwGEDiPaJuXo23wOr3loLYzr0v4VlFeXDKWDjK9t8XGA7gmIDg3rZr3UrpkKIKB92toFnbFvc0zIuhkQkK+A== 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=74y9dN8OAZoGdZMFwP6pxtEVhjfXH/vY/a8SwqFCsFY=; b=JhpUfh+//0+aJknnEEn4G+qsdmVkStLvVGQ2kCSjjvVINypsz2xBVREfvjfiqn8x9Es0XOKlix0EFqUzMBmWiwT435Wr2A7kBLlN5QYfdT8IceIWnZ0mD4dUdom1U7pnsZ+RIYh9gPHzT3zytXPikAwcL9bTxvphAl96yWGxm8g= 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:02 +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:01 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v3 05/26] net/nfp: prepare for IPv6 tunnel encap flow action Date: Tue, 25 Oct 2022 15:58:57 +0800 Message-Id: <20221025075918.7778-6-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: 3bf04d3b-87f6-4c4c-0836-08dab65eeb2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VtOxZsPE3t3Gey12RCa08n1rfmYZAHvbOh2tExX7LKLlaLD7jCU00DKk+cyw+paUyxd9a4ycQvYK2HjUGRy60nld8G3358dmBpFSHgEhfnbK8byqqR/1fssU+XzdmX5wiMd6qtMOxQh69FVu54k4CjJyJUgqUgZW5/U/phcM7swCpSAjBS2PS9zkPGjYQEUEXG4zeVUCAJ/rXBAYiLA3ht66UYHmDS2ug1vCjWAQwBAIkTKhhJfuz1E2vktb95a1LR5cjI09YKulb11gzVl5Dmii3TX36d4bIgx9AYOcSeoVdCG8eD8mW76zhZsZBSDvOZ+Unbdc88Mb0B1PlXW72JBN4nQ6c/2mZuvAcyjaMvjM0P6GGWkqX59Y6jPq1uL01aqK0EflOFk4abQFym/GY9sunjR60L4BhI0yfec6ZbovIAoSxOFeC1l3f2YFek8nmz81J0s8n3Rl3on5UBHJ4fL3QtRNP1v8xrHicCCyd1k+wnLS+rU97K6oAq1h4mDG637ZaAqw4Yjp6fyRgTmmyAl3MzoJk8P57tu0iqh35vg3ngCr+2p/5ODicnDzP6TIpahARQo4j6anE1bZGlZrTy9xj+Q/gyZlmwGbBad9pgk0wPWJuC/StUxDhN7pxm0WVnSci0ATFY+c/mHIcxn6wgDwTF9XMRmEgd5ARC2OERR3rrHrN+SIeISjHRVCN1SmT3GBku36U6K3cZq+HUFRxDP68PPP3I8m+g9ybOa9IdbdBi9hLVG9GVFy2MuQ58V9PSkhA/onepnVCWxXSgeYsg== 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)(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?cXE1Z0RvQktLa3NkYmp5ZVlvSEdiSHJXb1Z4TFVEdjF1T242bFRUWkJwWnJo?= =?utf-8?B?dERtTlBLa2xaTTB4WkRKN3BuSW1kNjROeFdVenV3R1BPUXZHVXRrcDRLd2U4?= =?utf-8?B?Rms4bmFuVWIxWUxRbGE1K0EwZWpBWDNrODZDczRSUk9JMUhjdk9pYkNVd0Jo?= =?utf-8?B?KythdEdONmNTZThEVFlPWVhsTDVBWmRpaEszaGJ1d3F3UlNKMFovT3IyanJm?= =?utf-8?B?Z1dOKzdCbmJPR1k1RzkzZ1pNYmdHcDdIbm9SKzdadDdrb25VZXJDcTFo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RseVppYXUzTzluQWZ6ZFNieHNTK2ZaUlphSWEv?= =?utf-8?B?b2hIYkZxK3lJK2tuekJsVkpDTk9MbEsyRmpYVTllVVlYc29kTUhZVHBIanBV?= =?utf-8?B?b0E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bf04d3b-87f6-4c4c-0836-08dab65eeb2c 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:01.8339 (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: 2a9gPBseakfjtocmPRhIErnox+ktp/+kaQXMGgvzaqSGtfsR/3IXA0F0fg10VxRGkPhY20GCsaVcL/KoKgttEo3deUZqTqYrjEceO/Aas5c= 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 encap action of IPv6 tunnel. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower_cmsg.c | 29 +++++++ drivers/net/nfp/flower/nfp_flower_cmsg.h | 40 +++++++++ drivers/net/nfp/nfp_flow.c | 105 ++++++++++++++++++++++- 3 files changed, 173 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 7021d1fd43..8983178378 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -275,3 +275,32 @@ nfp_flower_cmsg_tun_neigh_v4_rule(struct nfp_app_fw_flower *app_fw_flower, return 0; } + +int +nfp_flower_cmsg_tun_neigh_v6_rule(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_flower_cmsg_tun_neigh_v6 *payload) +{ + uint16_t cnt; + size_t msg_len; + struct rte_mbuf *mbuf; + struct nfp_flower_cmsg_tun_neigh_v6 *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 neigh"); + return -ENOMEM; + } + + msg_len = sizeof(struct nfp_flower_cmsg_tun_neigh_v6); + msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6, msg_len); + memcpy(msg, payload, msg_len); + + 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; +} diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index e44e311176..d1e0562cf9 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -159,6 +159,42 @@ struct nfp_flower_cmsg_tun_neigh_v4 { struct nfp_flower_tun_neigh common; }; +/* + * NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_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 | DST_IPV6 [0] | + * +---------------------------------------------------------------+ + * 1 | DST_IPV6 [1] | + * +---------------------------------------------------------------+ + * 2 | DST_IPV6 [2] | + * +---------------------------------------------------------------+ + * 3 | DST_IPV6 [3] | + * +---------------------------------------------------------------+ + * 4 | SRC_IPV6 [0] | + * +---------------------------------------------------------------+ + * 5 | SRC_IPV6 [1] | + * +---------------------------------------------------------------+ + * 6 | SRC_IPV6 [2] | + * +---------------------------------------------------------------+ + * 7 | SRC_IPV6 [3] | + * +---------------------------------------------------------------+ + * 8 | DST_MAC_B5_B4_B3_B2 | + * +-------------------------------+-------------------------------+ + * 9 | DST_MAC_B1_B0 | SRC_MAC_B5_B4 | + * +-------------------------------+-------------------------------+ + * 10 | SRC_MAC_B3_B2_B1_B0 | + * +---------------+---------------+---------------+---------------+ + * 11 | Egress Port (NFP internal) | + * +---------------------------------------------------------------+ + */ +struct nfp_flower_cmsg_tun_neigh_v6 { + uint8_t dst_ipv6[16]; + uint8_t src_ipv6[16]; + struct nfp_flower_tun_neigh common; +}; + /* * 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 @@ -629,6 +665,8 @@ struct nfp_fl_act_pre_tun { }; }; +#define NFP_FL_PRE_TUN_IPV6 (1 << 0) + /* * Set tunnel * 3 2 1 @@ -676,5 +714,7 @@ int nfp_flower_cmsg_flow_add(struct nfp_app_fw_flower *app_fw_flower, struct rte_flow *flow); int nfp_flower_cmsg_tun_neigh_v4_rule(struct nfp_app_fw_flower *app_fw_flower, struct nfp_flower_cmsg_tun_neigh_v4 *payload); +int nfp_flower_cmsg_tun_neigh_v6_rule(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_flower_cmsg_tun_neigh_v6 *payload); #endif /* _NFP_CMSG_H_ */ diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index f71f8b1d5b..e1b892f303 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -1781,6 +1781,16 @@ nfp_flow_pre_tun_v4_process(struct nfp_fl_act_pre_tun *pre_tun, pre_tun->ipv4_dst = ipv4_dst; } +__rte_unused static void +nfp_flow_pre_tun_v6_process(struct nfp_fl_act_pre_tun *pre_tun, + const uint8_t ipv6_dst[]) +{ + pre_tun->head.jump_id = NFP_FL_ACTION_OPCODE_PRE_TUNNEL; + pre_tun->head.len_lw = sizeof(struct nfp_fl_act_pre_tun) >> NFP_FL_LW_SIZ; + pre_tun->flags = rte_cpu_to_be_16(NFP_FL_PRE_TUN_IPV6); + memcpy(pre_tun->ipv6_dst, ipv6_dst, sizeof(pre_tun->ipv6_dst)); +} + __rte_unused static void nfp_flow_set_tun_process(struct nfp_fl_act_set_tun *set_tun, enum nfp_flower_tun_type tun_type, @@ -1845,7 +1855,7 @@ nfp_flower_add_tun_neigh_v4_encap(struct nfp_app_fw_flower *app_fw_flower, return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload); } -__rte_unused static int +static int nfp_flower_del_tun_neigh_v4(struct nfp_app_fw_flower *app_fw_flower, rte_be32_t ipv4) { @@ -1857,6 +1867,99 @@ nfp_flower_del_tun_neigh_v4(struct nfp_app_fw_flower *app_fw_flower, return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload); } +__rte_unused static int +nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_fl_rule_metadata *nfp_flow_meta, + struct nfp_fl_tun *tun, + const struct rte_ether_hdr *eth, + const struct rte_flow_item_ipv6 *ipv6) +{ + struct nfp_fl_tun *tmp; + struct nfp_flow_priv *priv; + struct nfp_flower_in_port *port; + struct nfp_flower_cmsg_tun_neigh_v6 payload; + + tun->payload.v6_flag = 1; + memcpy(tun->payload.dst.dst_ipv6, ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6)); + memcpy(tun->payload.src.src_ipv6, ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6)); + memcpy(tun->payload.dst_addr, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN); + memcpy(tun->payload.src_addr, eth->src_addr.addr_bytes, 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); + + port = (struct nfp_flower_in_port *)((char *)nfp_flow_meta + + sizeof(struct nfp_fl_rule_metadata) + + sizeof(struct nfp_flower_meta_tci)); + + memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6)); + memcpy(payload.dst_ipv6, ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6)); + memcpy(payload.src_ipv6, ipv6->hdr.src_addr, sizeof(payload.src_ipv6)); + memcpy(payload.common.dst_mac, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN); + memcpy(payload.common.src_mac, eth->src_addr.addr_bytes, 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) +{ + struct nfp_flower_cmsg_tun_neigh_v6 payload; + + memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6)); + memcpy(payload.dst_ipv6, ipv6, sizeof(payload.dst_ipv6)); + + return nfp_flower_cmsg_tun_neigh_v6_rule(app_fw_flower, &payload); +} + +__rte_unused static int +nfp_flower_del_tun_neigh(struct nfp_app_fw_flower *app_fw_flower, + struct rte_flow *nfp_flow) +{ + int ret; + bool flag = false; + struct nfp_fl_tun *tmp; + struct nfp_fl_tun *tun; + + tun = &nfp_flow->tun; + LIST_FOREACH(tmp, &app_fw_flower->flow_priv->nn_list, next) { + ret = memcmp(&tmp->payload, &tun->payload, sizeof(struct nfp_fl_tun_entry)); + if (ret == 0) { + tmp->ref_cnt--; + flag = true; + break; + } + } + + if (!flag) { + PMD_DRV_LOG(DEBUG, "Can't find nn entry in the nn list"); + return -EINVAL; + } + + if (tmp->ref_cnt == 0) { + LIST_REMOVE(tmp, next); + if (tmp->payload.v6_flag != 0) { + return nfp_flower_del_tun_neigh_v6(app_fw_flower, + tmp->payload.dst.dst_ipv6); + } else { + return nfp_flower_del_tun_neigh_v4(app_fw_flower, + tmp->payload.dst.dst_ipv4); + } + } + + return 0; +} + static int nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor, const struct rte_flow_action actions[], -- 2.29.3