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 6232EA0543; Tue, 25 Oct 2022 10:01:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CDB0742C13; Tue, 25 Oct 2022 10:00:27 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2120.outbound.protection.outlook.com [40.107.212.120]) by mails.dpdk.org (Postfix) with ESMTP id 7A80742670 for ; Tue, 25 Oct 2022 10:00:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ShQzyG98MxUPxzJOdybyW8HwYNjEc00vmD1Fi21v58INGn2+K9NPE1MXlkyJZr44LHBAbCorQOlSro9pC2tvgYnv53tHF7xAAwHa5m1+mmIepI3QahSmBEQHtQPTtoMZBu7l2DwJnKbSyJ9GF8U7+NtK1/hIMa+9Utx+CzfQWOexVD8ICshvdVp3JN4yoKZtb13F4CnPhWtQLb6Yq4Xnc9hWoICcOKzbbU3vmp4behfQgWGK8JP+WaKbk1FbEn/l5CKZj943f0noTwlBUrvchSI9qliIfw7CvBs1JKJVz1TkLSmIKYfj91vskVVXRhLUsUCVbxII68MubK4VLL0+Hw== 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=QoKbReR/ZbK84RxmmLZXAW8GScAx2sQP2XI9k+nNquU=; b=ZwjIN9kFu+SbjwGIK+Z55TlmHmA/nU+m5xVJ/NyfuqJCc3l2QxRn1I/s77aGIhacIFf4SKTP9WLyLH97eV8uaercMX0gxcTjBqQrq2jf4Tn54kFwWnBX78qtbWAqlfTZwGzUr5HrHgtYyPmvDCSiGgR9SR6zVADWWZ8SUXMlGW/VHqJSC8kwH7IfCgsrJAk8SFKPxZbQEYwAnaZxDDi5nYEJSu6Dfcd/5IzJvPC5/qNI8Y1LpBYfvSbJytJpTsQJa3fXUyKdpFtLrLf+HrlrDeay4+2Je3sE9KLbitHtIMi3nryNrxR5gspfI2DBfnFLg/AKu7kloxmw7LIs1Nz8HA== 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=QoKbReR/ZbK84RxmmLZXAW8GScAx2sQP2XI9k+nNquU=; b=Tz3ZyJm6TBFOZqtmTGVQKgQuB5XSAagb8P0efQmSmYT7QETXK/1iNrwmL6VMkO0VX/IEDdvnaUUGfvsEUQ02WbZT3JmfGv8OBfnv2p0QJgdP7398cIbN9sbFRIl6EstWJz9DIwTYhtAUL62v8HmMaA04QSpwY45UdeGq0RWFFm8= 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:16 +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:16 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v3 12/26] net/nfp: support IPv4 GENEVE encap flow action Date: Tue, 25 Oct 2022 15:59:04 +0800 Message-Id: <20221025075918.7778-13-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: 9ac7c88e-10fc-4b86-9333-08dab65ef3d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DNnq0ho/beuzob5atOeaZz4YI6w7jTAwUyVXccSc1CaRwGO0i+CcV+PAT/D0iVRus8zSplDaJ3mlZhkkTYlcIqVE7WF3T/6TTItet6+sGxbPao+5fXCdPtyqpTz/MEhhkJ0eX03tWqTzLoAUgMPF/YfZ2s30olE/3wcK3KZGAUyp6HUZa/cTnFPF81uZjUtWicwKgSdEY/eH62cZmbeTpsWDB9saFFy2Q2LjRO/9Iuo0AiRnjLWdZx9z+aAS7H9/1hPsUO6/UCxyONgOR3/pk3iial++xG+bLCMUCF4v7v91l2CsE+Zy0qepq/Q4Bd1Sw6voyc/FcCQc5nOZuGsg8xlyQ11VKzQfmftzTutgoqw42pXTN8mZ7AyMr+YwQt4GbZVx3725wxraNJIFA5rYd36/RJIM5b/QS6VLKMZ9jyPSwg/uMz50b9L+F2PVGCSa1NG+lXbLzWStIo46YmRhvuO9sWKuToIY2ONyKje4Xd3oxYxO1Q5bBCIKQ5chp0P6v/nSdEJSfzDfiJJyoLLmsUY/17Nn87j2NZ7eQxUJfwnlzGlyN//qk0MjqiqIH7aHAsj/PVslBbHJHq5Pp4fZ3FovU9XpkRuPnSDLDH3tVDVNCmYTcVQB5sOX84mY7NqLepzLGihGZ88Mk8djCf+PcFduBvPtOkzivvF4+nIGgqgqm0gpLViVGPyadR1eu6VE2BsbsFEhyl2fW69KW2LKLF+PeRJ6W4KLbLssdianEeyQX3pt22nqfwswL3d6e0k/9f/s8LAgwavV6ZUix3l1XQ== 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)(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?WWg4ZklwaXlyS2VOOUVFMHB3TTg2N0RJUEE4bFN5WGdhaDU1Y1FINU1rdkx5?= =?utf-8?B?cUszdEJtZEE4aHh4cTk2RmpaTVlnRW5BaVNFMDZJYXZ2MFArb3d5VEQvdHBI?= =?utf-8?B?ZFg2ZzBqODQwUnVFcnZzblpXNExEdnFidmcvZEN6eEJoTlV2YnRHR294K0E5?= =?utf-8?B?TWo4aGJvT0U3Y2tOdDZiNkpiZ005Z3RJV3VkTUFuaGhlZ3VUbTNweFpJWnpu?= =?utf-8?B?NzEvdUY4WUt5WVR2M1NhditrbHJpU2hTNXErM2t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f-8?B?aVRnRUVqcHNHVFBBeEVGNUg0eTFjSFNqUStEMXpXOEhQS2ErNUxSaFBXWWYx?= =?utf-8?B?aUlONS9NaDBQM0RCZy9BRVVTcC9iTFJWc3ZuNWxJUXhTZWp1enRhNDNzVllz?= =?utf-8?B?OWc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ac7c88e-10fc-4b86-9333-08dab65ef3d0 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:16.2091 (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: MFHZtBEarQaD6BOe6GKJwjHnD+mjuDPc+QBhj7k8edGgwj64n7z5Uikb2oZhr+5IH6WeVF3WmIEP2QEHpXJzCZgsBNYyIdrnvB7ABICXD3g= 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 encap action for IPv4 GENEVE tunnel. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- doc/guides/nics/features/nfp.ini | 1 + drivers/net/nfp/nfp_flow.c | 107 +++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index 9ab840c88b..deb27ee2d8 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -45,6 +45,7 @@ of_pop_vlan = Y of_push_vlan = Y of_set_vlan_pcp = Y of_set_vlan_vid = Y +raw_encap = Y port_id = Y set_ipv4_dscp = Y set_ipv4_dst = Y diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 9e8073b0f8..7d19781bd9 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -38,6 +38,12 @@ struct vxlan_data { __VA_ARGS__, RTE_FLOW_ITEM_TYPE_END, \ }) +/* Data length of various conf of raw encap action */ +#define GENEVE_V4_LEN (sizeof(struct rte_ether_hdr) + \ + sizeof(struct rte_ipv4_hdr) + \ + sizeof(struct rte_udp_hdr) + \ + sizeof(struct rte_flow_item_geneve)) + /* Process structure associated with a flow item */ struct nfp_flow_item_proc { /* Bit-mask for fields supported by this PMD. */ @@ -908,6 +914,11 @@ 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_RAW_ENCAP: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RAW_ENCAP detected"); + 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; @@ -2622,6 +2633,88 @@ nfp_flow_action_tunnel_decap(struct nfp_flower_representor *repr, return nfp_flower_add_tun_neigh_v6_decap(app_fw_flower, nfp_flow); } +static int +nfp_flow_action_geneve_encap_v4(struct nfp_app_fw_flower *app_fw_flower, + char *act_data, + char *actions, + const struct rte_flow_action_raw_encap *raw_encap, + struct nfp_fl_rule_metadata *nfp_flow_meta, + struct nfp_fl_tun *tun) +{ + uint64_t tun_id; + const struct rte_ether_hdr *eth; + const struct rte_flow_item_udp *udp; + const struct rte_flow_item_ipv4 *ipv4; + const struct rte_flow_item_geneve *geneve; + struct nfp_fl_act_pre_tun *pre_tun; + struct nfp_fl_act_set_tun *set_tun; + size_t act_pre_size = sizeof(struct nfp_fl_act_pre_tun); + size_t act_set_size = sizeof(struct nfp_fl_act_set_tun); + + eth = (const struct rte_ether_hdr *)raw_encap->data; + ipv4 = (const struct rte_flow_item_ipv4 *)(eth + 1); + udp = (const struct rte_flow_item_udp *)(ipv4 + 1); + geneve = (const struct rte_flow_item_geneve *)(udp + 1); + + pre_tun = (struct nfp_fl_act_pre_tun *)actions; + memset(pre_tun, 0, act_pre_size); + nfp_flow_pre_tun_v4_process(pre_tun, ipv4->hdr.dst_addr); + + set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size); + memset(set_tun, 0, act_set_size); + tun_id = (geneve->vni[0] << 16) | (geneve->vni[1] << 8) | geneve->vni[2]; + nfp_flow_set_tun_process(set_tun, NFP_FL_TUN_GENEVE, tun_id, + ipv4->hdr.time_to_live, ipv4->hdr.type_of_service); + set_tun->tun_proto = geneve->protocol; + + /* Send the tunnel neighbor cmsg to fw */ + return nfp_flower_add_tun_neigh_v4_encap(app_fw_flower, nfp_flow_meta, + tun, eth, ipv4); +} + +static int +nfp_flow_action_raw_encap(struct nfp_app_fw_flower *app_fw_flower, + char *act_data, + char *actions, + const struct rte_flow_action *action, + struct nfp_fl_rule_metadata *nfp_flow_meta, + struct nfp_fl_tun *tun) +{ + int ret; + size_t act_len; + size_t act_pre_size; + const struct rte_flow_action_raw_encap *raw_encap; + + raw_encap = action->conf; + if (raw_encap->data == NULL) { + PMD_DRV_LOG(ERR, "The raw encap action conf is NULL."); + return -EINVAL; + } + + /* Pre_tunnel action must be the first on action list. + * If other actions already exist, they need to be + * pushed forward. + */ + act_len = act_data - actions; + if (act_len != 0) { + act_pre_size = sizeof(struct nfp_fl_act_pre_tun); + memmove(actions + act_pre_size, actions, act_len); + } + + switch (raw_encap->size) { + case GENEVE_V4_LEN: + ret = nfp_flow_action_geneve_encap_v4(app_fw_flower, act_data, + actions, raw_encap, nfp_flow_meta, tun); + break; + default: + PMD_DRV_LOG(ERR, "Not an valid raw encap action conf."); + ret = -EINVAL; + break; + } + + return ret; +} + static int nfp_flow_compile_action(struct nfp_flower_representor *representor, const struct rte_flow_action actions[], @@ -2797,6 +2890,20 @@ 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_RAW_ENCAP: + PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RAW_ENCAP"); + ret = nfp_flow_action_raw_encap(representor->app_fw_flower, + position, action_data, action, nfp_flow_meta, + &nfp_flow->tun); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed when process" + " RTE_FLOW_ACTION_TYPE_RAW_ENCAP"); + return ret; + } + position += sizeof(struct nfp_fl_act_pre_tun); + 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, -- 2.29.3