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 74027A0032; Sat, 22 Oct 2022 10:26:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1110242B7E; Sat, 22 Oct 2022 10:25:20 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2099.outbound.protection.outlook.com [40.107.244.99]) by mails.dpdk.org (Postfix) with ESMTP id 1F0B941155 for ; Sat, 22 Oct 2022 10:25:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gp8aZRcPktYyS6+5lQD3J+u+Cy4Q4QLJSOjs72oH3+qE74Q1n4AEBj7K6pFn87UPzI/A4/Z24HszgxD8EClYl9Tt3Bn17H+D5mIB9CO47GC0bSYF3JUfbMxUBil2X6XCwx+9TCfnuS4uHAxPAuWMyHZMhAVkNwB1Je8ZtcSs13W0Rw9qipEKLY4R4KvAM6DKWHTBSLVkNqkwyUh+9fwb1LTZ+Q2Fsw+ePsUk0lcYXdbb32txPT2mts9x+n08mKt0pqi7G64FBUOHVIm0LlN4t8D5h/Qpv9uwHZj21wQgkfv72QrMzo7DNMlqAJGdnY8QMc3DYAdTqZNBMCmqDsEAdg== 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=gmY5lC7C85XMi7o4Pz9YRhSX87xaLpDMnXrydgN+huw=; b=Gjsm9zzkhmHjPqXMcgdEiSs+xwPK2QT+3zMLM862tyhldfXTcaVAIrHVCgUpUbuvWGqwIwM77Q6eaBGxVRrTEwlvv9gc8ZIX6RmKnzXeR5qf0LNcTj6HsQ6dBsowmwTDE/O0DHEMXFcDdDe0aqIwsZ21bXyVnWhUt0uyt0ApOAVM4yYRZmEeFhkvpsHruYDkP/shY2YNq1BZvX1RGGNmczcd1c7ouIvfqY5nFK04ebfpcQyEwWGbcBdEDUjtIWIvYBlYnOd6Tcuk0Vy87ax5zNYNMUniuwV9U5kpIs7ScWcnmOx4mzk7Y16CQj2SVrDcUimgg2qfvu/b8psFCfvp4w== 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=gmY5lC7C85XMi7o4Pz9YRhSX87xaLpDMnXrydgN+huw=; b=EiyKg2zXfWun+XuTy+7RJvOfoAEAemsFJlIwRIitHaZD4yRmovjeThI8MUZTuLItSRgrdplVSMKfTJL/Sbddp6z2VNEmpz/JedsFVbS9aL63glPWM+gIsa3gtAv/3yx1/jT3x+ag0qsmUhVEqTGmjabXX3Zs/qtcul9teO7R3xM= 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 DM6PR13MB3690.namprd13.prod.outlook.com (2603:10b6:5:24e::14) 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:09 +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:09 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 11/25] net/nfp: support IPv4 GENEVE encap flow action Date: Sat, 22 Oct 2022 16:24:15 +0800 Message-Id: <1666427069-10553-12-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_|DM6PR13MB3690:EE_ X-MS-Office365-Filtering-Correlation-Id: fb9e28a8-264d-4316-f9da-08dab406eea8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SbHdZdXnNiVJMhCnlBxCmJslQ+DF+/C/tR2lOVrH5D0zlOMSTmg2IknfiDn+s8A7drP+brdONqgq+e6G/nnYtl7Jk4eWJkU9rKqUNIDL7d0WRfUSfWRVTCyIN1i5k5zzAtdfUKbRoPZ3/PTdiUH0hJTshtCTF2xTAd6nGFMcROcAlspfnVy9xm3Vj1BcmyNtw5w1oxMXqhU+MlxFCKOF0+wCXJ2gv5GdZ2lOC3pEBAtaEhoNUEoB7OifJ7W0LszAwCygLtndlQRIvre5A7S3Fpa0WlmyQNQKnwgOYhUiUqLVzFpmKA3KiwSta5xgPlT2E3ITjbONLijO+8V4/t3JacXWFWIVRvb6Lv9z1OdkpXayIBuOhw9bM4aYDzqgYOr+dBILYlJXysJJvKhySFHgSYREWD//IwIZfCRRKoOM4Ri5yh10kDWiGD3Y1a3Zy+rn7z3OnGhCF/rwYTQH7a1FtDJysdiUHLS+vLl4T+CP8cWZkpfJ7IJfNH+YYGEvsTOA8xyQreia/tX5FkUdsunAVykm4nuSPaB95Gy3O/HYH6vTir2WEQVQMPFvrdVwZtC/6Xs8oX0JZEXd6KCt0aKBRfqni6d6J1CaSYv7Ar4PiY1gDSBRLCR4Xc132YmA5/H5U8hkVKZMPs7wr3iA9UhvASwJhedAYsNHXMpMpkptVHPCHFPyQkzjcf8Y5Okhi9LGbnI/Mp3heLNKhjKOKgdoUupo4xPxI1/oMZpOycs5xdjXsxnU5pX83JBU1NnDHwgjOueGPRlsKFCzyk6Eya+5Mg== 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)(396003)(366004)(346002)(136003)(39830400003)(451199015)(6916009)(316002)(6506007)(66946007)(4326008)(6666004)(52116002)(6486002)(8676002)(66556008)(66476007)(107886003)(478600001)(6512007)(2616005)(44832011)(41300700001)(2906002)(8936002)(186003)(26005)(5660300002)(83380400001)(36756003)(38350700002)(86362001)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UkNHcG5iaGdCYUlBVFpXUXVtblNacHJ2M0xpc2ZBMDFqUUxjSFpSQ2ltNWV2?= =?utf-8?B?MXhZbE5JNjZTY1JPSkJoSVd4UWU5d1FtQ3VFbDVkbWxPalBScHpEQ0tleGZC?= =?utf-8?B?bFRxQ0tmT2s3MEN1czZlb3Vpdko2emV2R1pMU3RzU0cvUDlUQlNnY1pMT01C?= =?utf-8?B?a2ZwUjJCR0JMZXZNMkdEYmFjRUZGaEJwMWhPR1hiaUZ3TU1Zdjl1V1NQbitG?= =?utf-8?B?QnR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dFNU5B?= =?utf-8?B?N1ZVaklWS1Y5TXZqa0F0SDd6bEVVMW80MjZXNi9NKzhZZVVJeVpuZGtwYmZk?= =?utf-8?B?aXJ1MHdkZmdnVnNMbnVWVmFSSVBQZ3k1QnNXVHpGVFVWZE9QdHEvTmhRcHBm?= =?utf-8?B?Y3c9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb9e28a8-264d-4316-f9da-08dab406eea8 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:09.4607 (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: 0m6UNiv3K9J1dnnYbxCJAeeINDnrck5BbvMuCYGAF5xt7W4Slkwit7rUmsSFvmS2Nua2Y5jqOc2ifU5BXfkcVLNn6TxQAnF5InHdYJ76NHM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB3690 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 6788520..95c97c2 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -44,6 +44,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 1abb02b..faa313e 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 @@ struct nfp_pre_tun_entry { 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; @@ -2623,6 +2634,88 @@ struct nfp_pre_tun_entry { } 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[], struct rte_flow *nfp_flow) @@ -2797,6 +2890,20 @@ struct nfp_pre_tun_entry { 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 RTE_FLOW_ACTION_TYPE_TUNNEL_DECAP"); ret = nfp_flow_action_tunnel_decap(representor, action, -- 1.8.3.1