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 95A89A0032; Fri, 21 Oct 2022 10:05:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA85F42BD6; Fri, 21 Oct 2022 10:03:07 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2100.outbound.protection.outlook.com [40.107.236.100]) by mails.dpdk.org (Postfix) with ESMTP id 1B3B742BC5 for ; Fri, 21 Oct 2022 10:03:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CemCOmbnKhoQEUBRhztHuZkVXWGjZNdqaE/5go5zDpj/pltg8R7r/aZjquplzQG6Gr39v7Qe5LKQ0Z9pWWX4RJMCXFLCP213gJb5ncUBQ6eVU89vOwIwvfHrDcTMyVgAzSm4VmgxwdhsHUHUN98wAj0bh2PYFPYYH5qo4mZcp/V9+I//mu3Ye9I41EgaYKyeUeVzSLXpZR5OMqvubb6nIJ3I/POWLXbB1GFc31dOQ/1J/3vlsiPrrZF3lCQCCIgIwyEWx8Owk37Ihy2k2aU8epq7bzqYY9GU8YOufzu0B81CMz8gpipOQmct5utpFCrIuwm5MG7ViQlCbtj/QB/eKQ== 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=OfUTHo7/tyu2FxaFOk+keyG+XSc5wVsRJfL4eHpP/JU=; b=VolsSK4z4EpBq5GX6sQMs/aZgzxktrQ+O47pRxl2WyhofBfKpnkN1w5tdZZ8XGBU0mGK668BYV7yHQxNLacupnhCnavMMGpRSxAMdnUq7y6MkoyWuUhuwrXT3VX7uLwMnjKGuKzP264upVDVi7ptTTsHnOkbv1M9+iO1M4j3nHAGuZ9xv6RUpLVbj25mh+t3KopZPIQLkgwSCjwfrGkYXQAoz6hfkoA/I3VBoNU01UEJyyu+ZC58zWtBN0TAtatpbrVoo1Z6O0qmyj20cQ9aOC97PVBpV8kWV04l6LOllNtU3kt+hduG9H3YmwLS0q7GSYhWyeep4Qp9en97RUzMjg== 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=OfUTHo7/tyu2FxaFOk+keyG+XSc5wVsRJfL4eHpP/JU=; b=ChPtFdUQRAOt8B4XbzTd4UQvZYa4QjdPp5fXKkjheapmjTDa4VBFzebA495iCO6SNf+AITMOrMVR8GsxkU0T1ufW7pSxSyEiUwrsDBDgHQfqMJbctByFVHW5bNuX5Px4s1NOaHIpoypbSzXFIfvEA0N+qZa8BRAdn2pPOXEvPtw= 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 BL3PR13MB5162.namprd13.prod.outlook.com (2603:10b6:208:339::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.17; Fri, 21 Oct 2022 08:02:59 +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; Fri, 21 Oct 2022 08:02:59 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v6 19/27] net/nfp: support SRC IPv4 flow action Date: Fri, 21 Oct 2022 16:01:55 +0800 Message-Id: <1666339323-24016-20-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666339323-24016-1-git-send-email-chaoyong.he@corigine.com> References: <1666232391-29152-1-git-send-email-chaoyong.he@corigine.com> <1666339323-24016-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0051.apcprd01.prod.exchangelabs.com (2603:1096:4:193::6) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BL3PR13MB5162:EE_ X-MS-Office365-Filtering-Correlation-Id: e12462d9-cfe7-4da6-66a8-08dab33aab82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D1eV49OSUrzIqXIG9CGW/22kCNUZ6F3KZN2srnlw++TRKJMC1JUQUlfkmAfU1lwPIX8rNRJNJzhF/F4/NgUgtj6tykzmPItpEAnCmz7BB5q8OyGFWbvIZCelZeBX10gQJtESUTVfRpE+d/oMuWsqBaCUztGFUme/6Zunfp/POG7BwzrVS2GXpuTcSdgpGK1DK6dhmsWxSAfWSgwm0hOXNZ0aTGOazIY2kazxso7EBpfThaS5l+ZbMd3BfLgeEZ6rZHanWOOQ1n4GaTkywJTfZlExLniDazEB1ZrE9jXkNomzVnM4LeP6+DtP4GvVlhv8amZKF+OB7ZJe88GzTIcDNF/is7usXgF9YFrT8CpbDmSafP+NAAD/h7CusSdz8H3vkmNZ6MSKr7q7o3Iv1j4P9X7zsW/XCmpA3MXZy+JTKeA01InisC0Lz04EmDCBPX+4my7JeI6OUTwVUWIo9w7VbP/RmXeuxyIuNtCsdszC1y1VuyLGnwuUBtpyjVLSqEP+6kxwKKMRfKOM9RyksZBpYdtPf8F/FQj+Zo4eVP8zQRiICd31l5TkWRWqkTcVDKoV3Xq7XPkN2vZdQBNB7bdMNM+2NUZ3gXIUphMknywbWoIJIuhizua18d/owQWuMadLV0Vv03bBuafDEVng6uTrnrtNs59/GUKZgL0EtaFJMmetcbSCA9+cv6uIK4/W2Ae22dVgBI3yctr1VaxyYkrJx+hTPG1E11Vyuy++amJv0Dga3ST+V4OFZNpWOEQAukQc6WIDQdEt21q0hWahpoJBDg== 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)(346002)(136003)(39840400004)(366004)(451199015)(2616005)(6916009)(38350700002)(6512007)(6506007)(52116002)(8936002)(66946007)(4326008)(186003)(107886003)(8676002)(41300700001)(2906002)(66556008)(316002)(66476007)(38100700002)(44832011)(26005)(5660300002)(6666004)(83380400001)(478600001)(6486002)(86362001)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?R2JMOTVPYlgxdGVHSGM0eC94Mzc0R0JKY3M2UGFNb015bmhYaFBmREl3S0Nk?= =?utf-8?B?aTVwZVVnUzdGL2ZwU1FFMXlZbEV4cWI3eUxGMytuL3I2aVNpemV5SW9uM1N5?= =?utf-8?B?eEJoRm5rVnBnVkFlUHhSMjlHeXBhVGRLOVo2aFdkdXFDQnc1Z1BoNjdac0ky?= =?utf-8?B?dFBXbUErZ1ArM1hiWm53dTFoa0xweUVPRGVxbExGWFE3V1M1M3I0d2c3RHpY?= =?utf-8?B?ME9sZHhxZU5oQ09BS3NUWHZLdnpONDV0SDQ3V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qQ3JrNFRIQjhMdi9NOGFPYU9PZEkraHA3SEZBLy8zbllqNkZrckxk?= =?utf-8?B?b1lZNnNzTi9ldzk2ZE1XQmxORmxvN1MxYVVWKzdzNVJwRmZMamVteXd4ck0v?= =?utf-8?B?REE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: e12462d9-cfe7-4da6-66a8-08dab33aab82 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2022 08:02:59.4833 (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: HhK8/tPoZh8UCjxjOvwbVofBLMa3it4Ag96vpfQlAfO2UD4EoJka1CaknbUrm8Em7oGbYIDc5Lm1AXE/LKHSj0bSdWdi6GY/BH+nivd7nlI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR13MB5162 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 corresponding data structure and logics, to support the offload of set source IPv4 address action. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- doc/guides/nics/features/nfp.ini | 1 + drivers/net/nfp/flower/nfp_flower_cmsg.h | 25 ++++++++++++++++++ drivers/net/nfp/nfp_flow.c | 45 ++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index 005129d..e62b3f7 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -44,5 +44,6 @@ of_push_vlan = Y of_set_vlan_pcp = Y of_set_vlan_vid = Y port_id = Y +set_ipv4_src = Y set_mac_dst = Y set_mac_src = Y diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 30a9ff5..77cb51d 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -374,6 +374,31 @@ struct nfp_fl_act_push_vlan { rte_be16_t vlan_tci; }; +/* + * IPv4 addrs + * 3 2 1 + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | - |opcode | |jump_id| - | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv4_saddr_mask | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv4_saddr | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv4_daddr_mask | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv4_daddr | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_fl_act_set_ip4_addrs { + struct nfp_fl_act_head head; + rte_be16_t reserved; + rte_be32_t ipv4_src_mask; + rte_be32_t ipv4_src; + rte_be32_t ipv4_dst_mask; + rte_be32_t ipv4_dst; +}; + int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower); int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower, struct nfp_flower_representor *repr); diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 2339efb..d8c0e63 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -562,6 +562,7 @@ struct nfp_mask_id_entry { { int ret = 0; bool mac_set_flag = false; + bool ip_set_flag = false; const struct rte_flow_action *action; for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) { @@ -614,6 +615,14 @@ struct nfp_mask_id_entry { case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP: PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP detected"); break; + case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC detected"); + if (!ip_set_flag) { + key_ls->act_size += + sizeof(struct nfp_fl_act_set_ip4_addrs); + ip_set_flag = true; + } + break; default: PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type); return -ENOTSUP; @@ -1278,6 +1287,33 @@ struct nfp_mask_id_entry { nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_POPV); } +static void +nfp_flow_action_set_ip(char *act_data, + const struct rte_flow_action *action, + bool ip_src_flag, + bool ip_set_flag) +{ + size_t act_size; + struct nfp_fl_act_set_ip4_addrs *set_ip; + const struct rte_flow_action_set_ipv4 *set_ipv4; + + if (ip_set_flag) + set_ip = (struct nfp_fl_act_set_ip4_addrs *)act_data - 1; + else + set_ip = (struct nfp_fl_act_set_ip4_addrs *)act_data; + + act_size = sizeof(struct nfp_fl_act_set_ip4_addrs); + set_ip->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS; + set_ip->head.len_lw = act_size >> NFP_FL_LW_SIZ; + set_ip->reserved = 0; + + set_ipv4 = (const struct rte_flow_action_set_ipv4 *)action->conf; + if (ip_src_flag) + set_ip->ipv4_src = set_ipv4->ipv4_addr; + else + set_ip->ipv4_dst = set_ipv4->ipv4_addr; +} + static int nfp_flow_action_push_vlan(char *act_data, const struct rte_flow_action *action) @@ -1320,6 +1356,7 @@ struct nfp_mask_id_entry { char *position; char *action_data; bool drop_flag = false; + bool ip_set_flag = false; bool mac_set_flag = false; uint32_t total_actions = 0; const struct rte_flow_action *action; @@ -1389,6 +1426,14 @@ struct nfp_mask_id_entry { action += 2; position += sizeof(struct nfp_fl_act_push_vlan); break; + case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC: + PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC"); + nfp_flow_action_set_ip(position, action, true, ip_set_flag); + if (!ip_set_flag) { + position += sizeof(struct nfp_fl_act_set_ip4_addrs); + ip_set_flag = true; + } + break; default: PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type); return -ENOTSUP; -- 1.8.3.1