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 69900A0032; Sat, 22 Oct 2022 10:27:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4F0242BD1; Sat, 22 Oct 2022 10:25:48 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2105.outbound.protection.outlook.com [40.107.95.105]) by mails.dpdk.org (Postfix) with ESMTP id 5D15742B9B for ; Sat, 22 Oct 2022 10:25:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3w1j0/yNPlzysk+jICZpW/Cgy1aQ9nJzfcNqM0+W4krCs1u7qksY/PZzR/nAIfAKl7fj9vZeqlCus28IIYbDrP0jw4H+squdRQ/SMsxuprjC4MeY7RFzDio/N+UbA/rti5J7OX04gB51O3Cbo2LKpdUcknXOwGKF/hr53uVIfMuCQMiKpPX9UfrkC0VTAZWA1VVP0uGs+fzMI8nRGuwJ/kOLuVkQIrplayY4tzzourn9KHYGb6kJDZT6S0FOeVyEXAmaMx3ZQ1j7Z6mPZpNmqkgw3HPqJsgqXRYrl630JsXWPYYDgVAyOZvMC3JQtChwd9QTJd5mNxQXVpXoKoy+A== 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=IcApbIvcqYAMW4t3PdmKQq5sapMOjnsmcxxevrUL1mw=; b=Hjj9CoCndhr8wUbOvNTfuYl767znvLxZ2U9WuPGu2Hduh/ngbZBhMj41Ub5aVLsgpBvR6EZeC9+7cSi8EJ706uCv8UOkZf05IX38KR+JfEZyD9klx6/0JQEqWnuhID48lGCK3ONxo0lnRW7YBzq2gyS+HyNHmzEsJL/mFCuYFFzpepysAz7UcsBMHZPFokzFik4QywakpXApQ0YahNl9xzyKVImCEKE9CTgYsfrYCF55aNvtJsFwrjxVisKwirRuYiJDkzuOR7fBuow/HecM06KLnH72GtyRkoM0z+fAVIbGEQv5RSNRpjlq5O1PxvRHksw45lZ7dax5+TC5tGGKcw== 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=IcApbIvcqYAMW4t3PdmKQq5sapMOjnsmcxxevrUL1mw=; b=dt+1IQL4Q46ysXwbGtqdFN76NQW3pcRaiHDg5YbnSwFIcEqqcE0Z3ArouryCxF4PGOq6bBv7b/vTRTzxIUmG8aFulfq1FzMvlojiihxERX6a2LaQUSlcyXwN9sKigQUfGuR/9RcQN2bdNQey+TcnAjj+dzJ/cShdWcj0GzXNM6w= 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 CH2PR13MB3848.namprd13.prod.outlook.com (2603:10b6:610:9d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Sat, 22 Oct 2022 08:25:41 +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:25:41 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 25/25] net/nfp: support new tunnel solution Date: Sat, 22 Oct 2022 16:24:29 +0800 Message-Id: <1666427069-10553-26-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_|CH2PR13MB3848:EE_ X-MS-Office365-Filtering-Correlation-Id: b8b12573-099f-46ce-171c-08dab40701c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NkKuvX7cVUnKhh4qaZAQF+2XHZeiq+nsxg8TR2x89OReBxa3ChU5beNSxMsxtzAszVhXIFpT+ewxJbIwSKYOJ/EhoMXlpF/vILinRpQc8u3PfJCaMh/sFSRQmy/H++r1qmLgv26euHspYqW9tb4QXBVOvSIVkTd5nfzCJ9mw7azHTCDhZ022xfCj7xF/gmQO2ScqJLhu1e/fg17QY1xA+5kBF9pixgFNFVflvV7pYUopRMAdNDM7EOLwmb4Scsc0Sy+7jZp/EvVgKiMPIS5R6fjFnioVtAco/2a2KRMM65Rhj/jf+zD/o4akSHtoSr+8AImnvUiqGigk/8ZHsKTWdpg2kscFLe+xfSIDrSizzzRfIvzhrrG/tLM85LV1+aU6NOTx2+jaOnl3xGh0Rve/19rxg+vqyTOGJmgdja5eK4O3PORw6UunyE4kn7KhtLobMT4u/lZ4MBP97eLUwarcJFPrFeXlN/cZlIqsDHHInflrZHPMmT+CI5nWxl82LVPRgNQvjsxxayVz2pFg52St5pzU9/lyECkz/md2F+E+0NnuRa9Y1GAuqtafUxXAOYkk1ETnuOBicknaKj73MZVYLwGTNPcRtI48rJfbwJIlAFvERoFm42K4SIo2cESCgVl1hM3c5qOcUE7xGxdieOXnVjin1FgIErtWk2D+JoZFbdYeG8PFRs0LX2Kppq41hGPEi6sfZLMEW+ZQGIuD6oEkcvJocXA6wOY5m+iI9aLa6gzv7S8+2pdu5jRwPrjwYbu3KOa3+hBJTT92u6ljwheptg== 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)(396003)(39830400003)(346002)(376002)(451199015)(4326008)(107886003)(36756003)(38100700002)(66946007)(66556008)(316002)(6512007)(83380400001)(52116002)(66476007)(8676002)(44832011)(66574015)(6666004)(6506007)(30864003)(38350700002)(5660300002)(8936002)(6916009)(2616005)(478600001)(186003)(41300700001)(26005)(6486002)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Z1ZjaUdyS0ZyK2tMTVBkVDNWMmVXNm80K1NPWW9qdWk2cjJPUlVmdWd2aDlp?= =?utf-8?B?NGs0VWFKaTdPTnJDWkRTenNMSGtjd1dQRHRhbHUxNXFhc2lTK05HbEpFc0lz?= =?utf-8?B?SE9TZFk3UHRqSmk2bUhIYzJsbFFVbHluSUpQV1g2aUxBOWtwNUJEVm44Ukd4?= =?utf-8?B?bFAwT1BQT0xtMVlQMFhJaGY0eUlNeWNWTUtuYVBMUElhdTNMU1RiNFNaUitw?= =?utf-8?B?K0FqTzJrYkl1OVhmUWVSbVFkWmpKMGJMUldHSUd2aHRlNzUyYzJYc1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E1PaHVCWmwveDliaytUcDRVUURWYUNNZUg1ZnpzYWpnRWYwQk9wRnB4?= =?utf-8?B?aGdiWmF2b25CMUV1VndLYW81Tk50ZGVpK1ZLUk9rcGZGVnllZGdaR3htdndr?= =?utf-8?B?NkE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8b12573-099f-46ce-171c-08dab40701c0 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:25:41.6451 (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: 0NucwA8jHsNLYJGkJ235pSXA7RHh74B9ODHIMMmqq27CzWppUNfh3TPQ4N7LNDapQy+RnN5ueX3qTsFoyYpQ/0giGin2dcZS4W32D6QBtGo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR13MB3848 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 41b0fe2..aa8199d 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -1074,6 +1074,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; @@ -1115,6 +1117,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 12a0fb5..ab8876d 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 @@ -55,9 +70,18 @@ struct nfp_app_fw_flower { /* service id of ctrl vnic service */ uint32_t ctrl_vnic_id; + /* 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 4c6cfe4..01494e7 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -2384,8 +2384,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; @@ -2419,11 +2421,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; @@ -2432,6 +2440,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); } @@ -2492,8 +2511,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; @@ -2527,11 +2548,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)); @@ -2540,6 +2567,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); } @@ -2557,12 +2595,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) { @@ -2590,6 +2630,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; } @@ -2877,12 +2951,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; @@ -2933,18 +3009,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 @@ -3654,11 +3732,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