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 AC94FA0560; Tue, 18 Oct 2022 05:25:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA4B242BE7; Tue, 18 Oct 2022 05:23:52 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2103.outbound.protection.outlook.com [40.107.100.103]) by mails.dpdk.org (Postfix) with ESMTP id 9153142BD5 for ; Tue, 18 Oct 2022 05:23:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JP7N9A3whwKqlE49hj714sbLwWkjUNVECNQekwOroUv2ZVqRDYDSS+HgX2mtwd0ZJzKS+lVsWFKzuVt84RySNzFEFdp1NZ1UDNZ0siU9oJTn+7ZiFnQGcw7TGVVZH0ETfFQr5KZOM80R8LLQY1lBE8hzrV0gn4NI91//7zXAVJucmhYRsAot4aekEswGERN7aioJ3/O2TUIqQ+tiMhXIO5XoFDVMNEYUfJjNzNh8+zxjMA6jhshi0BdsC0B/qzE+ieOCLkdWObDDr8OvMX1nTGHDW4FRyje5pRtC3zZ9Ylfh4SVcNxL0x1GtypglDI9ZOVI4/tyhazrZFtbMkx/miw== 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=7ZydYMWhjWsbv+7QrigJvLX5tWrT081pFMeaUvNj5uw=; b=c9IDrfm0EJOvMd6wH3+pF2gRyJaU8/GpqjAZ3dB2YNxLQaRifmiDGKbE4PBduEQ+ufxftAXW5+Y14toX9P4OWtB8VSckHI7PjQheew4w5ipVDOSTHLmWsGYeAt7NgcgE4QmTgPpJiRRqsf7jaXfcUgwB4vlY8wLbY+r2mMixqrMOzfvGXRpqigYV6e4eMYERK4iiQfkcBEe5DyLmM/6pVDBUuGU2aEZo8cmsZNBkOvCVOZCI5XjQUmem9JWkTbc75kthRDjijo1b3KVk6tVzZslR35tnd/y/0dKmcgRHnG9N7ItdoDWBSeScLBCAc/HVTZAp6+uKIp/+tSL+KH+Avw== 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=7ZydYMWhjWsbv+7QrigJvLX5tWrT081pFMeaUvNj5uw=; b=XO9NdAOIB6eL+gp+aFA4caHZ5d11qZ9lhK4ktXa657fy2+A/Zt7QoNLiZHXXbOKxiknWPrKz0UtknsRRTi4Ogc0+iLbyyxQxciTkF9Yukd3yTbsPTtrHkaA381rgiqtXMHQ+vsuG+bB8XOWZxnK6jj9uIEpd5TVu5e1B+NQ30g8= 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 MW3PR13MB4122.namprd13.prod.outlook.com (2603:10b6:303:5a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.8; Tue, 18 Oct 2022 03:23:49 +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:49 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 25/25] net/nfp: add the support of new tunnel solution Date: Tue, 18 Oct 2022 11:22:39 +0800 Message-Id: <1666063359-34283-26-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_|MW3PR13MB4122:EE_ X-MS-Office365-Filtering-Correlation-Id: 986cda88-5ef0-485d-ad4a-08dab0b82c58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2jXNAubvjDttxdro7nUlTSy0rsShV30gsciXG/FKD2vBfse34ZTlf1i0O7O3Uh43ZrCwRTqD05b0BA0DKx33OKtnbepR4h2wjhf4mAlcGTn2IhxYw29m6HCTzLr3kjrKRdVhO7vn1hVtFnO5vudx16+jfJ48pIUnEbr8GQShvVSFrcK0P7Iy4FRfEsiEa1wNC/567Ev674dIm+yvP4cRhOkAr0kBXXmFJToqtLxJXmpNILCWxbFRY/xSvHUWRpjq4WYQ0h8zGeqzTjT/Um9U+Yq1XwPSjWD/6brQfMVp0OsgUIbuxotdSVPdpOVAwb5JgZFb/iiEuoh/Zze3Jec45Wyh+S4GD5OSRTRtAQgv02uv5TH8UTkzLLJeoJZCZX7CBMkGH1Kjhe9Jpltjpyt5ggIRsTyD8Hds5CdSrCmLzPgMQSvPvaM88dEyUpMli7G2e2sfhQ3bLpoi4udLhfJNVS/jbGsFH/k3MRfm6T9wDk0tbjlGQJcRR8IUtsbHmB3EdEhccEBoTh4lXDrNy0luw+hpN0LwCQAf6ub22R/h2EmX2Ih/MJrbAHbLeRIieT7iEvp5hCQNU0ZsDJIbw2szhymnCYHtyrd2fmVyNWWgAoNpSz2CkbA+MZ+g5jf4zTtZiQGo0lR8VlB0dX+VTcAb6a4jURFQ66NUKARCC4ZzoLWcWvcvNjICKu05hR83j7EFhV1R92oGsWhHLNGBvVvcrAgUe2ixt14VS70+yYUFgMvpxQW1noQars+3aLiznapAtW/5uASRwPGIuwl4hLLaH9fgtoW4JuxcJ0DLndNyAfHW9ypOwh+dmyyqTDWctL9l 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)(346002)(366004)(376002)(39840400004)(396003)(451199015)(38100700002)(86362001)(38350700002)(4326008)(8676002)(66556008)(66476007)(66946007)(316002)(6916009)(30864003)(5660300002)(44832011)(41300700001)(8936002)(66574015)(2616005)(186003)(2906002)(83380400001)(107886003)(6666004)(6486002)(478600001)(6512007)(52116002)(6506007)(26005)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?djJ5SnZwU3NLc2JrSGhzVG1pbEZ6V1Z5ZzRMKzBZbVRDcm12NGVkTUVZQkxU?= =?utf-8?B?Q244YlNZWllYT3NNMTJuNWl1NlRBQ2FTTzVLOW9Pa3hPcmhXbXJkTHQyQzZZ?= =?utf-8?B?VTlmYnYvd2YzenUrbzhkc3dlVkJjS1hWdGVmbmtPNTdsaHpOeVMrQ3J4ejly?= =?utf-8?B?cWt4TVgwR1p1eFN0SmY3NUxQT3Y0OGVTN3ZHQldweDF5bU95REd5aXJlSXdZ?= =?utf-8?B?dCsyN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a1pIa3ZXTHpVMGMvVWNUTnFsKy96?= =?utf-8?B?OW50UnhFVEMrTTMrSHNNcGIyMzJjR3VpT3YzbjFZcHJaL3JvNmlYK1hHNmtR?= =?utf-8?B?VTZhckYyYWZjeVVKSEVQb1hiMTJhNTFjME1rbzdOQVY5RXNrRFpvelE0L3V6?= =?utf-8?B?WkE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 986cda88-5ef0-485d-ad4a-08dab0b82c58 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:49.2076 (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: RjwnTqmum1jNmL/tYGbpQpIZUWwyEa6Gy4GlxR/8DcJGuVJGaEYk5R/oH62onIfqWlbZNsGYwX+nK+Fndp4psgsuaMxUfmYA154La/CCfls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB4122 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 The new version of flower firmware application add the support of a new tunnel solution. It changes the structure of tunnel neighbor, and use a feature flag to indicate which tunnel solution is used. Add the logic of read extra features from firmware, and store it in the app private structure. Adjust the data structure and related logic to make the PMD support both version of tunnel solutions. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 14 ++++ drivers/net/nfp/flower/nfp_flower.h | 24 +++++++ drivers/net/nfp/flower/nfp_flower_cmsg.c | 4 ++ drivers/net/nfp/flower/nfp_flower_cmsg.h | 17 +++++ drivers/net/nfp/nfp_flow.c | 118 +++++++++++++++++++++++++------ 5 files changed, 157 insertions(+), 20 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 168bf0c..d2a8f9b 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -1073,6 +1073,8 @@ nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev) { int ret; + int err; + uint64_t ext_features; unsigned int numa_node; struct nfp_net_hw *pf_hw; struct nfp_net_hw *ctrl_hw; @@ -1114,6 +1116,18 @@ goto vnic_cleanup; } + /* Read the extra features */ + ext_features = nfp_rtsym_read_le(pf_dev->sym_tbl, "_abi_flower_extra_features", + &err); + if (err != 0) { + PMD_INIT_LOG(ERR, "Couldn't read extra features from fw"); + ret = -EIO; + goto pf_cpp_area_cleanup; + } + + /* Store the extra features */ + app_fw_flower->ext_features = ext_features; + /* Fill in the PF vNIC and populate app struct */ app_fw_flower->pf_hw = pf_hw; pf_hw->ctrl_bar = pf_dev->ctrl_bar; diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index b90391c..dc0eb36 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -6,6 +6,21 @@ #ifndef _NFP_FLOWER_H_ #define _NFP_FLOWER_H_ +/* Extra features bitmap. */ +#define NFP_FL_FEATS_GENEVE RTE_BIT64(0) +#define NFP_FL_NBI_MTU_SETTING RTE_BIT64(1) +#define NFP_FL_FEATS_GENEVE_OPT RTE_BIT64(2) +#define NFP_FL_FEATS_VLAN_PCP RTE_BIT64(3) +#define NFP_FL_FEATS_VF_RLIM RTE_BIT64(4) +#define NFP_FL_FEATS_FLOW_MOD RTE_BIT64(5) +#define NFP_FL_FEATS_PRE_TUN_RULES RTE_BIT64(6) +#define NFP_FL_FEATS_IPV6_TUN RTE_BIT64(7) +#define NFP_FL_FEATS_VLAN_QINQ RTE_BIT64(8) +#define NFP_FL_FEATS_QOS_PPS RTE_BIT64(9) +#define NFP_FL_FEATS_QOS_METER RTE_BIT64(10) +#define NFP_FL_FEATS_DECAP_V2 RTE_BIT64(11) +#define NFP_FL_FEATS_HOST_ACK RTE_BIT64(31) + /* * Flower fallback and ctrl path always adds and removes * 8 bytes of prepended data. Tx descriptors must point @@ -52,9 +67,18 @@ struct nfp_app_fw_flower { /* PF representor */ struct nfp_flower_representor *pf_repr; + /* Flower extra features */ + uint64_t ext_features; + struct nfp_flow_priv *flow_priv; }; +static inline bool +nfp_flower_support_decap_v2(const struct nfp_app_fw_flower *app_fw_flower) +{ + return app_fw_flower->ext_features & NFP_FL_FEATS_DECAP_V2; +} + int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev); int nfp_secondary_init_app_fw_flower(struct nfp_cpp *cpp); uint16_t nfp_flower_pf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 76815cf..babdd8e 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -263,6 +263,8 @@ } msg_len = sizeof(struct nfp_flower_cmsg_tun_neigh_v4); + if (!nfp_flower_support_decap_v2(app_fw_flower)) + msg_len -= sizeof(struct nfp_flower_tun_neigh_ext); msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH, msg_len); memcpy(msg, payload, msg_len); @@ -292,6 +294,8 @@ } msg_len = sizeof(struct nfp_flower_cmsg_tun_neigh_v6); + if (!nfp_flower_support_decap_v2(app_fw_flower)) + msg_len -= sizeof(struct nfp_flower_tun_neigh_ext); msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6, msg_len); memcpy(msg, payload, msg_len); diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index a48da67..04601cb 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -136,6 +136,21 @@ struct nfp_flower_tun_neigh { }; /* + * 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 | VLAN_TPID | VLAN_ID | + * +---------------------------------------------------------------+ + * 1 | HOST_CTX | + * +---------------------------------------------------------------+ + */ +struct nfp_flower_tun_neigh_ext { + rte_be16_t vlan_tpid; + rte_be16_t vlan_tci; + rte_be32_t host_ctx; +}; + +/* * NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V4 * 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 @@ -157,6 +172,7 @@ struct nfp_flower_cmsg_tun_neigh_v4 { rte_be32_t dst_ipv4; rte_be32_t src_ipv4; struct nfp_flower_tun_neigh common; + struct nfp_flower_tun_neigh_ext ext; }; /* @@ -193,6 +209,7 @@ struct nfp_flower_cmsg_tun_neigh_v6 { uint8_t dst_ipv6[16]; uint8_t src_ipv6[16]; struct nfp_flower_tun_neigh common; + struct nfp_flower_tun_neigh_ext ext; }; #define NFP_TUN_PRE_TUN_RULE_DEL (1 << 0) diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 1ccc6ef..ac60e90 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -2402,8 +2402,10 @@ struct nfp_pre_tun_entry { static int nfp_flower_add_tun_neigh_v4_decap(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_fl_rule_metadata *nfp_flow_meta, struct rte_flow *nfp_flow) { + bool exists = false; struct nfp_fl_tun *tmp; struct nfp_fl_tun *tun; struct nfp_flow_priv *priv; @@ -2437,11 +2439,17 @@ struct nfp_pre_tun_entry { 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; + exists = true; + break; } } - LIST_INSERT_HEAD(&priv->nn_list, tun, next); + if (exists) { + if (!nfp_flower_support_decap_v2(app_fw_flower)) + return 0; + } else { + LIST_INSERT_HEAD(&priv->nn_list, tun, next); + } memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v4)); payload.dst_ipv4 = ipv4->ipv4_src; @@ -2450,6 +2458,17 @@ struct nfp_pre_tun_entry { memcpy(payload.common.src_mac, eth->mac_dst, RTE_ETHER_ADDR_LEN); payload.common.port_id = port->in_port; + if (nfp_flower_support_decap_v2(app_fw_flower)) { + if (meta_tci->tci != 0) { + payload.ext.vlan_tci = meta_tci->tci; + payload.ext.vlan_tpid = 0x88a8; + } else { + payload.ext.vlan_tci = 0xffff; + payload.ext.vlan_tpid = 0xffff; + } + payload.ext.host_ctx = nfp_flow_meta->host_ctx_id; + } + return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload); } @@ -2510,8 +2529,10 @@ struct nfp_pre_tun_entry { static int nfp_flower_add_tun_neigh_v6_decap(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_fl_rule_metadata *nfp_flow_meta, struct rte_flow *nfp_flow) { + bool exists = false; struct nfp_fl_tun *tmp; struct nfp_fl_tun *tun; struct nfp_flow_priv *priv; @@ -2545,11 +2566,17 @@ struct nfp_pre_tun_entry { 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; + exists = true; + break; } } - LIST_INSERT_HEAD(&priv->nn_list, tun, next); + if (exists) { + if (!nfp_flower_support_decap_v2(app_fw_flower)) + return 0; + } else { + 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)); @@ -2558,6 +2585,17 @@ struct nfp_pre_tun_entry { memcpy(payload.common.src_mac, eth->mac_dst, RTE_ETHER_ADDR_LEN); payload.common.port_id = port->in_port; + if (nfp_flower_support_decap_v2(app_fw_flower)) { + if (meta_tci->tci != 0) { + payload.ext.vlan_tci = meta_tci->tci; + payload.ext.vlan_tpid = 0x88a8; + } else { + payload.ext.vlan_tci = 0xffff; + payload.ext.vlan_tpid = 0xffff; + } + payload.ext.host_ctx = nfp_flow_meta->host_ctx_id; + } + return nfp_flower_cmsg_tun_neigh_v6_rule(app_fw_flower, &payload); } @@ -2575,12 +2613,14 @@ struct nfp_pre_tun_entry { static int nfp_flower_del_tun_neigh(struct nfp_app_fw_flower *app_fw_flower, - struct rte_flow *nfp_flow) + struct rte_flow *nfp_flow, + bool decap_flag) { int ret; bool flag = false; struct nfp_fl_tun *tmp; struct nfp_fl_tun *tun; + struct nfp_flower_in_port *port; tun = &nfp_flow->tun; LIST_FOREACH(tmp, &app_fw_flower->flow_priv->nn_list, next) { @@ -2608,6 +2648,40 @@ struct nfp_pre_tun_entry { } } + if (!decap_flag) + return 0; + + port = (struct nfp_flower_in_port *)(nfp_flow->payload.unmasked_data + + sizeof(struct nfp_fl_rule_metadata) + + sizeof(struct nfp_flower_meta_tci)); + + if (tmp->payload.v6_flag != 0) { + struct nfp_flower_cmsg_tun_neigh_v6 nn_v6; + memset(&nn_v6, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6)); + memcpy(nn_v6.dst_ipv6, tmp->payload.dst.dst_ipv6, sizeof(nn_v6.dst_ipv6)); + memcpy(nn_v6.src_ipv6, tmp->payload.src.src_ipv6, sizeof(nn_v6.src_ipv6)); + memcpy(nn_v6.common.dst_mac, tmp->payload.dst_addr, RTE_ETHER_ADDR_LEN); + memcpy(nn_v6.common.src_mac, tmp->payload.src_addr, RTE_ETHER_ADDR_LEN); + nn_v6.common.port_id = port->in_port; + + ret = nfp_flower_cmsg_tun_neigh_v6_rule(app_fw_flower, &nn_v6); + } else { + struct nfp_flower_cmsg_tun_neigh_v4 nn_v4; + memset(&nn_v4, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v4)); + nn_v4.dst_ipv4 = tmp->payload.dst.dst_ipv4; + nn_v4.src_ipv4 = tmp->payload.src.src_ipv4; + memcpy(nn_v4.common.dst_mac, tmp->payload.dst_addr, RTE_ETHER_ADDR_LEN); + memcpy(nn_v4.common.src_mac, tmp->payload.src_addr, RTE_ETHER_ADDR_LEN); + nn_v4.common.port_id = port->in_port; + + ret = nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &nn_v4); + } + + if (ret != 0) { + PMD_DRV_LOG(DEBUG, "Failed to send the nn entry"); + return -EINVAL; + } + return 0; } @@ -2895,12 +2969,14 @@ struct nfp_pre_tun_entry { goto free_entry; } - ret = nfp_flower_cmsg_pre_tunnel_rule(repr->app_fw_flower, nfp_flow_meta, - nfp_mac_idx, true); - if (ret != 0) { - PMD_DRV_LOG(ERR, "Send pre tunnel rule failed"); - ret = -EINVAL; - goto free_entry; + if (!nfp_flower_support_decap_v2(repr->app_fw_flower)) { + ret = nfp_flower_cmsg_pre_tunnel_rule(repr->app_fw_flower, nfp_flow_meta, + nfp_mac_idx, true); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Send pre tunnel rule failed"); + ret = -EINVAL; + goto free_entry; + } } find_entry->ref_cnt = 1U; @@ -2951,18 +3027,20 @@ struct nfp_pre_tun_entry { return -EINVAL; } - ret = nfp_flower_cmsg_pre_tunnel_rule(app_fw_flower, nfp_flow_meta, - nfp_mac_idx, false); - if (ret != 0) { - PMD_DRV_LOG(ERR, "Send pre tunnel rule failed"); - return -EINVAL; + if (!nfp_flower_support_decap_v2(app_fw_flower)) { + ret = nfp_flower_cmsg_pre_tunnel_rule(app_fw_flower, nfp_flow_meta, + nfp_mac_idx, false); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Send pre tunnel rule failed"); + return -EINVAL; + } } meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data; if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) - return nfp_flower_add_tun_neigh_v4_decap(app_fw_flower, nfp_flow); + return nfp_flower_add_tun_neigh_v4_decap(app_fw_flower, nfp_flow_meta, nfp_flow); else - return nfp_flower_add_tun_neigh_v6_decap(app_fw_flower, nfp_flow); + return nfp_flower_add_tun_neigh_v6_decap(app_fw_flower, nfp_flow_meta, nfp_flow); } static int @@ -3662,11 +3740,11 @@ struct nfp_pre_tun_entry { break; case NFP_FLOW_ENCAP: /* Delete the entry from nn table */ - ret = nfp_flower_del_tun_neigh(app_fw_flower, nfp_flow); + ret = nfp_flower_del_tun_neigh(app_fw_flower, nfp_flow, false); break; case NFP_FLOW_DECAP: /* Delete the entry from nn table */ - ret = nfp_flower_del_tun_neigh(app_fw_flower, nfp_flow); + ret = nfp_flower_del_tun_neigh(app_fw_flower, nfp_flow, true); if (ret != 0) goto exit; -- 1.8.3.1