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 C055DA0544; Mon, 10 Oct 2022 08:11:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5986A42BB1; Mon, 10 Oct 2022 08:09:57 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2136.outbound.protection.outlook.com [40.107.96.136]) by mails.dpdk.org (Postfix) with ESMTP id 20F5742B95 for ; Mon, 10 Oct 2022 08:09:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cOcK8rXUaaEOtP0LmOOoKraiNT0xVO+rThvf/G0qbiBkUITXziNvtsYHi2jJUCvkkWUVgFPuYdfA/jCX/DEb45ZJQ6Fd6BKQg7Ux9YPlODJbE4CMBt6s0KyE29IO6AilI/FWXj6fcpK9ByRV9Bty6bb7/JDI4sBAClnHFVA8aG8OWVgx5ikwZxzDmXsmv3/JC5OTyj+CY8pePQ5chceuFl8QT9DUNrAUHFJLcx0OE7kY83JAfCfBcWcwtnCb56sNESH5bubozXq+Xy4Jwz00hcu0xg917TVToguInT1WPWdhYxRVIcGl0qLdwUlXY/7jGBu1PLwAMhXnJZ9CwuzYCg== 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=301h8cUW8GU15zGKVditf0EZCI0GPYW1gOPhdna3N0I=; b=cOnfZTe9CoOlWQtwpC3+phyXbtyye0az8QxFJmU1FghBpxZ3gqfl1knszY1mF1Iok6DX0U59lq2Et9VcUD/a/x7//PFwFlI41pkdjWaVXBM4Naiusb1vKGuiq9V0FS8CBDJkFo9Gg85cPOkTC2rkP600Z8FckHE0SfMGUwZUo8CWZESXD7UssG68XdaWxSPy98Wo0eqEpCEaC7yoGlbLo6QxKSS1ZwbtahD/gN+INYxRXpDJyoxR1SJYggfc+inOPh1jssRn+8mhz6740vyCwuSseOLGQxKjbffISDfmCKYIAdOVu8XPvNPgUQmS+ksaN7OwlqTZGPikTYlLrCnGhg== 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=301h8cUW8GU15zGKVditf0EZCI0GPYW1gOPhdna3N0I=; b=PWEYNmcLSiNMSKhUO1ogfMtE+dTtPxzMaFdKgRe+YtpEj9EjslR2MAtF6M6BWmHiHCYlwmg6k0TMCK90ze7a2yTEK25W+Up4coIszh0uwHqnm8Gwiq2JXBWEi+vPSTn4WfPQ9io0O4wjw/r6uW45arzvZ5FCNg+fO5mVLMHQCwk= 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 SN4PR13MB5296.namprd13.prod.outlook.com (2603:10b6:806:207::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.14; Mon, 10 Oct 2022 06:09:53 +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; Mon, 10 Oct 2022 06:09:53 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 16/24] net/nfp: add the offload support of set SRC IPv4 action Date: Mon, 10 Oct 2022 14:08:54 +0800 Message-Id: <1665382142-21684-17-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1665382142-21684-1-git-send-email-chaoyong.he@corigine.com> References: <1665382142-21684-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_|SN4PR13MB5296:EE_ X-MS-Office365-Filtering-Correlation-Id: b8e4b408-a8b7-4a1a-5820-08daaa860b0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aU8+JDQJgF9HgHQrLTLWhXNQrDoSrThsHsOLjNU/IdHzfdJYv1inamccPg5tX3Sm79A4AE3NSdIXmdJdzwWUYnNFe/+t73kAeBrjAi7ZHvuXRU9p+9O0GonwyFq1mtswURx+npu1R1aK40luomGtd5IoiYyEuVXIeD2/RT0DpekaxWihhm4Bu8Xj6CQHZAfby/RZbDVP0imdkEwVZ0/zXJs277CnlnHAVZvniKOeyfJUUig27WX4u0N7D9+aKEt67Bjj2twzVVIg1gZVM45Q1FJyu/n9rbRapg9aX3G8eaA6N6Zzjs3NZ4xuGdjsgAJf3ZNwKrAudmisaBkRLaDxmRt1y3+ZpgSU41LrJbL5w02Z2cJGM1Zc1GH4ofzXCmHnmPaVKWHgyRmEMTQrVDzII7meNqUcqOq9vGgcgtM7o+YXT7RbRJT+e7SxFsFob+WEtsLNDdhkuhwJfoLd5sY40bH5pqGwfU+xyv4bxn5IcNG2t9RvoLbxJhW4JyrQW1dWriq8NUFRBrE1HnltrG2hYWvo+bF/NY4awZQPJlC22c4sJRGYvbv1iFYmKz7QslviOgHE6RX4Xu5tyijV6FAoF+4WRge3+Nac3VnvGIwoovCwWqNC9pVz/NHpGTDSzFLRa8Qm8WEtvofX/OaswP5/ItoGTKWpzOh3qy9CRUqqxJ9zLsivEH9FIvn3cHM92Gz9yJSpLPhNPiE9gQTiKK1Q6KDgNFH0IgvuRSs7PT43QYnKU4H2tLQVve9Z0YHxl7/PgnWuWCZWbE0anztKNZ7tmUaal2atm/ja6i/fB74z2KW8ed7YwlLFY2qHWdUaYTQv 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)(366004)(39840400004)(396003)(346002)(376002)(136003)(451199015)(6916009)(316002)(2906002)(186003)(6486002)(2616005)(66476007)(107886003)(66556008)(41300700001)(66946007)(83380400001)(8936002)(8676002)(4326008)(5660300002)(44832011)(26005)(6506007)(6512007)(52116002)(86362001)(478600001)(36756003)(38350700002)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aitqc25ldDMyMmt3U1M5RXJYYTNCT2Q5NTE0MTl1NmdTcmFVbzJtWkgvS0lz?= =?utf-8?B?d2ZHVEZVaFhqK0JzdjZnRlBHOVVJVElIR0F5cFJkanFsMFBpcGc2TjZKS1N5?= =?utf-8?B?Q095SU4xK0xWQVNhSldQK21kZGswUzdpWmtkVVZGdHh3VThqN3dFZURKZlp3?= =?utf-8?B?dmNvdk1Wam82WEs1SjlLSTh5a0JTTXNqUkVPRmM0NU5yNVhleThEZkVOYU4w?= =?utf-8?B?VytLSkhLcFZVS05DejBxMXNjM3Y4eUlweldLakZZUjlhVW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5YT2xEMllyVjdjSGlTYllyOFU3NS9UeUg4Wkw0?= =?utf-8?B?aCszQ0NZVVF6QW96bWpOaktQYTdGNlE2MlM1emw4MFRwS3QzS3BCbUZzMm9B?= =?utf-8?B?Z1E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8e4b408-a8b7-4a1a-5820-08daaa860b0a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2022 06:09:51.5163 (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: /3E21JFuft6QNuSbvmbJ8amuuQ8kV2MkFR3+vnwZs5/fcO6C43M7UVsWqlKTsrb+owYkm4n8HgV7BNjmQCREUPXRZVP+FbSfm9meK+J5tIs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR13MB5296 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 514e0ba..8f7120b 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -46,5 +46,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 d66bcca..54f94e5 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -574,6 +574,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) { @@ -632,6 +633,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; @@ -1296,6 +1305,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) @@ -1338,6 +1374,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; @@ -1413,6 +1450,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