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 4C7D7A0032; Sat, 22 Oct 2022 10:25:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B580427EA; Sat, 22 Oct 2022 10:25:02 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2110.outbound.protection.outlook.com [40.107.93.110]) by mails.dpdk.org (Postfix) with ESMTP id C27B4427EA for ; Sat, 22 Oct 2022 10:24:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UDCmZDOIoLiaWbrsLDNgGK6dyl17hPndJtoDrtWhPiTUzQaiBrs1R4GGUeMbnJChQZvljrjxzQ+4QLIOSeWz8bxok20uvy7MAkgCfu9VFPGCVnfmpK5HX5t8AleZVD0vbRRN+P+3p1t5efsLEsUDALzpgZEr2R0i0OnPD/+G/CpGobU47y1MvlTASAn/0crTw2NBAEPU7Wtq9asyVeCDHP1vONZXYzTyg5O2SKlCBMfpVQwXhv3hVvdluKW8IPZGS6WUnfnzt9s0AUXUWDcKNaQYz64vB01BdgvDk/hLTh95FnAgKOVjsyLxbCHz+3fYeA/FGdvcXY5tJXSQB6vySA== 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=TyqQNriKSm9e03HR0yLFf/OBpR3rOZrBKfszqcgzr2s=; b=nUdUa16XEVoZJ26gA12SuMlMdYW7BQBJBJryyZqhMZ8dtxkxC40172dkYRYRJoCG9pK19+B2NwKsSLOT0TCmCadw1gIBzmqHfpnZRjCelO/RS7xohEF1IxBFmpPriGv1R2FEe4/ty+lO0nJeBrknnVeajMdxxHqbncEPDonN8L0qgwpDeLNansGH9q3RJgQGuIR/cpxvZMNSv8+H7OieXilB0MrDNjo0kTlufsNk7U6WoCVrJpuZej8fFbUkAyar4PyhPRYpK3YbyfQrRu11ueFc4OtvvN4YboVm5CZNIFLxssX+4vGra0nddpU/qksneOTC2iNP6tkYoz62uaIvDQ== 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=TyqQNriKSm9e03HR0yLFf/OBpR3rOZrBKfszqcgzr2s=; b=vitlPqLov8iUxIiNbrbMUWiiyCb2gEYwyZZhLlqM8T8ukP8OfcxMqVdtuQ1qXr4dWd+sVlaumEYsApnosSq06YdYQJb9nmXdVTV6gmCi1IUeZc3LsY16D2XW0Uw8d2QSYHI+Z/D+OcjU1rYfGxMeppc+90sIUlfBqcSMFmyNOu0= 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:24:54 +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:24:54 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 04/25] net/nfp: prepare for IPv6 tunnel encap flow action Date: Sat, 22 Oct 2022 16:24:08 +0800 Message-Id: <1666427069-10553-5-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: 35838260-7185-4ea8-e29e-08dab406e5a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tM/DzKibY8U9Uoi1BPiTdSeGRCowKdwSEv0IN/ZG9q4+aVFvDfaRpLUfSLFPKVgVri/3yaOP5y0ZpWmdSGamGhOgXqGuEdHJiJ7EYZch7tGX+PQrpToxixF0OjSGBVue5XcL72dxcM9qt99KWXFf+/XXPiK0jAs6mItekgsZEbZ+9qgQzaSeWx6zcTcU2rFBFMEmkLqc/t0uzwwi9OWMkl8rcnkTLTG9SkS+z9Oj1A39iw4mLtRIQhsXw0WAvUrCKV+eaA+/U87FRs943xpq37smLZKq2p9tfxwyteGSOn/jK/ntjZfyS1abU7aVbxoo+QU8S0DFUSO6SaT+ga+tpluyvhRVsIew19bm0ooYyamX2i0cwoRJ2okr0kU/oe/y0n0dSCJWO0nGY7COUMe5ciUMVxb6bfSajZDI9F/Ae6a+ih9KU6i3ymUyNdlYOlF7kKZA9zqCNSMQSv+1hGneI8KY4hwKuYr2VoTjhagDPFOAJU4YpCzS5UrC3My/1+VjOh0AxUUOqodQwPjcMt8DSbZrNdt6XKkq7icx+YRx3OqPxo0HN8gsCftyGhCjepstmQeiceBPpsxEtK/ONaLrsJnGDFtb+GJX2Y5dasqfALFY1/VzHQbM8SqvqmKJ74SmS23YTUxMD2iprtz7cIodgGnb9DsOuOk3kJlECaDHvAp9tt7/cxDtoywkwP4QYO/zNn36Pr46oZTzsdSt5Zjk95rQ/8mgy49Pw+oVJw7vll8KL4okndc43dOrJue82rlRot2eAELDttIVKSZXOanT8kn1h3QHmX5V97JhpLvLsVLPhwn/x/YxUF+AtjO5ORr4 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)(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?RkFDQ0xJT2F3UUJhTVlUa0FkOXdIT05iV25HQ3BFOTl0K25pbzg5N3dwd2ZX?= =?utf-8?B?NXNFMkdxbDdNQS84OUFuZHpPK2xvWWRQOUdFSFJNWC9aUGZweE5MeFRkNFJw?= =?utf-8?B?NnJ2bjN6NVZROXdrTnNlN2xVeXJEM0hUYzFHcXplZ0ZxTmJ0MFVTekZhcGli?= =?utf-8?B?OFJhelNXVzlLU1VKcjVHbFhycnpEa2Z1a2ozOCtDUXJJZ0tzOTJmS3R0VEJI?= =?utf-8?B?UUdIO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czWUM0T3RmMDYzZThPR0Fi?= =?utf-8?B?QTZZa2FYWWU3QytvVEpVeG9pSS8vWnZQS0E5ODhHQU55ODJ3R2czMG1FdFBS?= =?utf-8?B?dnVqUytmM2NZRzgyL0NPckMydGJsamw4NjU5em4zZ2hmTlFkQWVnRjZ2MG96?= =?utf-8?B?c2c9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35838260-7185-4ea8-e29e-08dab406e5a1 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:24:54.2835 (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: /IXEyGjSzyRho9kAgpdryQ8i3bJpzVmEq7lmjmr0U32pmmz5lIQuME8rmxodbpKoxciTFXIKW1SLLklrgkXdUC1m5UJk2hkfx0QjYo3Ud/0= 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 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 7021d1f..8983178 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -275,3 +275,32 @@ 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 e44e311..d1e0562 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -160,6 +160,42 @@ struct nfp_flower_cmsg_tun_neigh_v4 { }; /* + * 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 * -----\ 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 @@ -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 f71f8b1..e1b892f 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -1782,6 +1782,16 @@ struct nfp_mask_id_entry { } __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, uint64_t tun_id, @@ -1845,7 +1855,7 @@ struct nfp_mask_id_entry { 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 @@ struct nfp_mask_id_entry { 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[], -- 1.8.3.1