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 90FCEA0543; Tue, 25 Oct 2022 10:01:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0991142BB7; Tue, 25 Oct 2022 10:00:26 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2097.outbound.protection.outlook.com [40.107.212.97]) by mails.dpdk.org (Postfix) with ESMTP id F363D42C14 for ; Tue, 25 Oct 2022 10:00:14 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJ4Ozi3/2wlABzS3IUt4/484sUQBDMb0+OGllhEcVVAQWbcgvXXgRelCf+oze/kwz9JrY6fSAanvtbhr2nRzapgQ4XD/BxCC3lm5x7xy1P61kBXP9Hw1lEnlkr4Q/6lME/dEqNxElhnhOspnXA6fdDS4njouRS/sbVfyPt+h9posFvNTWnEYS3xZLdvH3XuYgc9aYQYDX+x2BFJ5SCuX6QjAK6Ooypa2ZZG3hiwW+OjGmcp03buw63RhcTPPU8uaRovfuR4SxuBYoShTBIgo3uwKLiNngi6MCodr1KWHDzPqP+6COaNCVMKz8+ORD2dRjh4wSlO0JhO/0CJaWj+3Xw== 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=SLKbRPwQ9h6aYUn3PWwHKoLxblQbIOfbMneYmlFyKqQ=; b=j6FS5NXiG+7iSX04rpXEULt7r4YjDBKFQyd0ds9Q4MhaiyjFDT1bFvXGCSvonQNyzfH3qEGx4lWNutCLCEp6hFfN+9M3gny4j9fjqtfR51mXyuTamCoRDf1pZ5a8ZqH+H9tecTfNL1PWDceWAbc2cqIEtnljFxylYk/CEqdEsM+e4KHopnvGs8OKP7LmlSgSrSdOzyPkQRcC7CUcAAWN7QElhXLHjvfGa24loIHCtYBi8s7Mp68O8wlUMwOcID4z3kMCksQKFeIhrshig93Uv/nkP/+ZLoWLzwjAaaK+8eqqTloImkMoRLgP7XS4lAEU5Srp+uRMp6J+hg60Gcb9Iw== 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=SLKbRPwQ9h6aYUn3PWwHKoLxblQbIOfbMneYmlFyKqQ=; b=TkSYE4f4qH+LimdA8Vu2i0f4wdPQau5S4qslJJ2PcHAfFmjAgVk1lkXkpgxzARbsdF/mti74IZH1cxm72mYjy2XTySVrew1ab/ElRh9EOeCoy42YJIiT9h81/S41K7Ecr/W+efkiTzWT2YbcHPgiSUWGPX77Th7vnf2EtuDx1yU= 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 DM6PR13MB3924.namprd13.prod.outlook.com (2603:10b6:5:28f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Tue, 25 Oct 2022 08:00:12 +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:12 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v3 10/26] net/nfp: support IPv4 VXLAN decap flow action Date: Tue, 25 Oct 2022 15:59:02 +0800 Message-Id: <20221025075918.7778-11-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_|DM6PR13MB3924:EE_ X-MS-Office365-Filtering-Correlation-Id: 0676c12e-ce95-47e6-c23f-08dab65ef168 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pBZvAhun+v3keMUBcWNeM4Cqo/Bkn36S12onE6dPhQgfJRZdu49YY3smzC3hTNV5ODVQWnabHRTtyViEnlXG0Sq5uDT68PQ7GxSCmqthhaBT4ezxz6YWRLaSVBMPT1j51E2B1Xm3EyAUgtDxP0Jgi5I8LhFUF6VJFAq1Qd2lKBUjxDGyur3tewCYN2pO4uO6ZdRznyiIarGuI8iKPWEltvwGH1spakBXe219T3E3slSZEvA+IoNmuCM/z1uBz6r0bvM2q6yX3evusHEv+3XOHx478ppnbXsD5DE3O1mQswlLMdHUS5/mt4lFttKLvgmOEtChBF9Ft2id/PJjTHqcg18RpFo3QwEocn12YKHx87sIRH7XFjjSeHb9SihY4HLcV6cpO0VfwNSI/TgjjWfeJUX8NgsXW+XjnMrpD6uPL6WRdIyWiKsPH/lgEgamh7W3A7PYBNAJJGhf1J9HUY/fOn+3zftjKbof+nE73ixUlcxYoMEhkxjZDo1oI/i3pdkIFBwVVeqeb0rrJwWkbHGUMtcbzb6x1hWTfJsjTGnqB3g5R4JHc8BB2tUdWqLM1+CHVPMEijB2fcN/DqIxlEhl3/nwZUb6Bro+szDX2O4os1rerikY2VWxTIEbLIIdz9H3LaPRE3qS4nYTQsvIp6qaE4rAhN7iP7PJKyYiQz4/wI+A88Qy0W4ZQPAk7Q4EBI8mQAF/Ns1zcydoapdvjd05OW8JDs9Qac9TjE0Lto6uXeEyuAmyErUO596zBOnvDQCVdL1bVVaYEJWo69OHyWoLXg== 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)(376002)(366004)(136003)(346002)(39850400004)(396003)(451199015)(86362001)(2906002)(6666004)(186003)(1076003)(107886003)(83380400001)(38100700002)(41300700001)(2616005)(8936002)(6512007)(36756003)(5660300002)(66476007)(66556008)(66574015)(4326008)(8676002)(52116002)(66946007)(26005)(44832011)(6506007)(478600001)(6486002)(6916009)(38350700002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eHNOR0Q2RktxSTk4bmJ2TTBqdUFrNmhWWDd4SnFBTmh1OWFRMlZNV3N0TENn?= =?utf-8?B?akUwVk4xSms2TlZPRUxTK25XTU5qQ2VwYXdSRkRoVWVuU3N5Qllsd0ROME1a?= =?utf-8?B?VFE1Z3QzVExKUkh5dmU3bWNNZVVuai9KOUU5b3ZEeGE1OEtCMFRtazV1eU8w?= =?utf-8?B?Y1Bwb00wVUluUEh3Znd3L2MwSGUxaDZqcTBzdCtLZ3c2OVZTTHpNZUFQNDNh?= =?utf-8?B?R3RGOE5UQ0IzRUJ1VGhjMHByWW91Ukh6Tnp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f-8?B?dXZUbHR2ZFVXeFZPa1gzUDBUOXN2bzdaUUZvdWdLNFVQNHFjajVPc1lVRmQ1?= =?utf-8?B?alZUTm1hT0ViaGwrUHg3MGNzektvNlF1T1hDMU5TeVJvNnJ0NjlmTFJ2aXRo?= =?utf-8?B?ZGc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0676c12e-ce95-47e6-c23f-08dab65ef168 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:12.1746 (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: X7pEg9cxDUNcvnW1/Ip/rsHtSbPIsdvw2HHhovMTppTNKHGmI5dDyLMwr/deMDrhctErIv2a4mS+B1MFmT+JmPF78PTFnP1i2/7We3jEV+4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB3924 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 offload support of decap action for IPv4 VXLAN tunnel. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- doc/guides/nics/features/nfp.ini | 1 + drivers/net/nfp/nfp_flow.c | 75 +++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index 5ccfd61336..9ab840c88b 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -57,4 +57,5 @@ set_mac_src = Y set_tp_dst = Y set_tp_src = Y set_ttl = Y +vxlan_decap = Y vxlan_encap = Y diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index ad484b95b7..e71292ff12 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -413,7 +413,7 @@ nfp_stats_id_free(struct nfp_flow_priv *priv, uint32_t ctx) return 0; } -__rte_unused static int +static int nfp_tun_add_ipv4_off(struct nfp_app_fw_flower *app_fw_flower, rte_be32_t ipv4) { @@ -908,6 +908,9 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], key_ls->act_size += sizeof(struct nfp_fl_act_pre_tun); key_ls->act_size += sizeof(struct nfp_fl_act_set_tun); break; + case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_VXLAN_DECAP detected"); + break; default: PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type); return -ENOTSUP; @@ -1315,7 +1318,7 @@ nfp_flow_merge_sctp(__rte_unused struct nfp_app_fw_flower *app_fw_flower, } static int -nfp_flow_merge_vxlan(__rte_unused struct nfp_app_fw_flower *app_fw_flower, +nfp_flow_merge_vxlan(struct nfp_app_fw_flower *app_fw_flower, struct rte_flow *nfp_flow, char **mbuf_off, const struct rte_flow_item *item, @@ -1323,6 +1326,7 @@ nfp_flow_merge_vxlan(__rte_unused struct nfp_app_fw_flower *app_fw_flower, bool is_mask, __rte_unused bool is_outer_layer) { + int ret = 0; const struct rte_vxlan_hdr *hdr; struct nfp_flower_ipv4_udp_tun *tun4; struct nfp_flower_ipv6_udp_tun *tun6; @@ -1351,6 +1355,8 @@ nfp_flow_merge_vxlan(__rte_unused struct nfp_app_fw_flower *app_fw_flower, } else { tun4 = (struct nfp_flower_ipv4_udp_tun *)*mbuf_off; tun4->tun_id = hdr->vx_vni; + if (!is_mask) + ret = nfp_tun_add_ipv4_off(app_fw_flower, tun4->ipv4.dst); } vxlan_end: @@ -1360,7 +1366,7 @@ nfp_flow_merge_vxlan(__rte_unused struct nfp_app_fw_flower *app_fw_flower, else *mbuf_off += sizeof(struct nfp_flower_ipv4_udp_tun); - return 0; + return ret; } /* Graph of supported items and associated process function */ @@ -2049,7 +2055,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_add_tun_neigh_v4_decap(struct nfp_app_fw_flower *app_fw_flower, struct rte_flow *nfp_flow) { @@ -2427,7 +2433,7 @@ nfp_pre_tun_table_delete(struct nfp_flow_priv *priv, return true; } -__rte_unused static int +static int nfp_pre_tun_table_check_add(struct nfp_flower_representor *repr, uint16_t *index) { @@ -2569,6 +2575,49 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr, return ret; } +static int +nfp_flow_action_tunnel_decap(struct nfp_flower_representor *repr, + __rte_unused const struct rte_flow_action *action, + struct nfp_fl_rule_metadata *nfp_flow_meta, + struct rte_flow *nfp_flow) +{ + int ret; + uint16_t nfp_mac_idx = 0; + struct nfp_flower_meta_tci *meta_tci; + struct nfp_app_fw_flower *app_fw_flower; + + ret = nfp_pre_tun_table_check_add(repr, &nfp_mac_idx); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Pre tunnel table add failed"); + return -EINVAL; + } + + nfp_mac_idx = (nfp_mac_idx << 8) | + NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT | + NFP_TUN_PRE_TUN_IDX_BIT; + + app_fw_flower = repr->app_fw_flower; + ret = nfp_flower_cmsg_tun_mac_rule(app_fw_flower, &repr->mac_addr, + nfp_mac_idx, false); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Send tunnel mac rule failed"); + 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; + } + + 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); + else + return -ENOTSUP; +} + static int nfp_flow_compile_action(struct nfp_flower_representor *representor, const struct rte_flow_action actions[], @@ -2744,6 +2793,17 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor, position += sizeof(struct nfp_fl_act_set_tun); nfp_flow->type = NFP_FLOW_ENCAP; break; + case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: + PMD_DRV_LOG(DEBUG, "process action tunnel decap"); + ret = nfp_flow_action_tunnel_decap(representor, action, + nfp_flow_meta, nfp_flow); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed when process tunnel decap"); + return ret; + } + nfp_flow->type = NFP_FLOW_DECAP; + nfp_flow->install_flag = false; + break; default: PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type); return -ENOTSUP; @@ -3214,6 +3274,11 @@ nfp_flow_tunnel_decap_set(__rte_unused struct rte_eth_dev *dev, } switch (tunnel->type) { + case RTE_FLOW_ITEM_TYPE_VXLAN: + nfp_action->type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP; + *pmd_actions = nfp_action; + *num_of_actions = 1; + break; default: *pmd_actions = NULL; *num_of_actions = 0; -- 2.29.3