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 68548A0A02; Thu, 20 Oct 2022 04:22:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F21D242CBF; Thu, 20 Oct 2022 04:21:33 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2129.outbound.protection.outlook.com [40.107.237.129]) by mails.dpdk.org (Postfix) with ESMTP id 4314B42CB1 for ; Thu, 20 Oct 2022 04:21:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VqLe7gIyd6lEk4A8ihlAQSsrOTHo7f4JdlTINu98PNRiCDFqriWbeubQLbnheGuloqvijWGF29zlZw7cvRvsRJSnJ6C53ZpKZjjQmqX9N8gdCO2Fi0XQ4HcVYQcLo9HWzC0uHBeAd2O2Zb/ZeP7slrathm4Y/en4+H/2oVevWXSknbe/Vr+FPo75ouL8AKO5OikoN3eRfQf89nTmp/JNxg5OkCvwB+BwJRowPloCO+/fd8QDJnmi7Jk2qpE+0rMbb9pWJxMSWlQLCspyYLE3Yo70jY8+MsrPbtbIv0CRvoDPIYuTA47/HHCNl8WpFtqcoBJgCv2NCWdk8tUYSQBdlQ== 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=wNZow/sEuDBIqNWLtg2h1norsrFEhmRVgaTYBlqnBTU=; b=beiCnzmmOXYvzWhcrcOBr9yX34jzYe0YTfU78UA8XH1IslxBc843k9ndZDBbAWRGSxNCRMHB85EyFvqnGvBRdCoC/uniNs3brClWsZGdk37lURVPdvkw+NwMT5Yz568CTAzKY9+bNwqHnUh9z3iKNQRUk/S2fl/hSwUmJv5gqD5/gm1Rn+IRLwuym8/Wsqarpz9eE9ofwceA8Y5puTfaQnSRFenAk6nJRxbg4Qp29Y7dmi2iCPqcBcZ1omzlX4ELT/2s7cLsmV8tPZgzxJpoc7Vhf3uu4gtHVQvjJOTw9m4wKhGU+dH6p/9BMGLOxZgIOh43T/I8dNrROGAI0+enpw== 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=wNZow/sEuDBIqNWLtg2h1norsrFEhmRVgaTYBlqnBTU=; b=BNJpOp0qITflq0Yy9kX17S6kdvFDcG4xqAz2duA4wBhsELorS9dzL8eAhYxRFOAIaYyKbI8iVlCXFWRRZb250luUj60/pV0Zj+KO3zrgmGX5xBulAM7mLfyLEycGhKzQ8TV8JlDL27mfjMuM/0fd66pTZj8Q/YaUnKZOblof3kU= 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 CO3PR13MB5784.namprd13.prod.outlook.com (2603:10b6:303:167::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Thu, 20 Oct 2022 02:21:28 +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; Thu, 20 Oct 2022 02:21:28 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v5 17/25] net/nfp: support SRC IPv4 flow action Date: Thu, 20 Oct 2022 10:19:43 +0800 Message-Id: <1666232391-29152-18-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666232391-29152-1-git-send-email-chaoyong.he@corigine.com> References: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> <1666232391-29152-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:196::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO3PR13MB5784:EE_ X-MS-Office365-Filtering-Correlation-Id: 307dbc45-6184-4469-a1af-08dab241cbc0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lAtnK6oUtpOXnzFEqa2NwF1SEkIB03F3CuoUUE4MG6JD1bEbmyv7H7sb3f5NbuBtEnGbTy3a8Y7PLH/tsEd+ohN1b84d+jHC2R/iqE8uEVagGZ+Ns7N3kw372J0MKTZKro8DLYew3j/OSQZUIqqjSBjjs8ieBWNObESRI+GzGtGqcyanE3vzSF+8ybqLrq0xwPfQqr6RyEBZw0c0dLPx1TMYv8CdwymPZEPtPOBr4wtaRnDhDljJbAUW5JeIt5WJ7hJV4Uf1VtWzd03Li7UwJN3Z1cnhN22fc2L6mzfCPemBoSQ8p5OLpd5PonJHC4ykH+uxcE0npaV+cng5rPRNeMYZ/2VRY2sAAricc+sZh8yZKehwtzh4bMN5AVeCq3Bc1UQ1VrBIWYbDWUnztXDe9FbVcln0psiWJiwhywbagLgs+KmA3LnfjcMdMrANcE3e8o5ylEx0tWWkZNk014WZ1qWKftZewQtHyGxDQX+p/I2Vu1+PtOJZwuvm/OpOY2pjQ7lS9e1TfOy6DNZkI6kRF04iuP6zHAeDT/5NNNm00iB6/SDj8FttTi6tcPzWJFDsYXP+WsVB1OuDl09Mx1galusHW9EBsLNCi6f+obeLwAeKnH4VYL5mGu3gdVMYtfRq43r1XKbASgVkZcqfDRmZhvMSb7Oux0hjHGKZaoOc590f3HpKeYk39wrvSU3CYnQR0Jr0b0Sk6VEJVzudkBgCv5E/3RY9h6c5qbTJYFYuNRf3P2aE19NpXKUbjLo5+VFtQ4rL2uPRfiwo6siHDOjctg== 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)(136003)(346002)(396003)(39840400004)(366004)(376002)(451199015)(6916009)(44832011)(2906002)(316002)(8676002)(478600001)(41300700001)(66556008)(66476007)(6486002)(36756003)(4326008)(66946007)(5660300002)(38100700002)(8936002)(38350700002)(2616005)(6512007)(52116002)(186003)(86362001)(6506007)(6666004)(107886003)(83380400001)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NFhkZG4zRXMrUlg0K3NDMzdPY01DZHVua3E2TCs5OGVWZHl0Wi93TlVIOTZJ?= =?utf-8?B?REEyTytvWFBkY0dGNnk1MUE5Wko5VFlLbVBzU1NFU1lWVXZJWE9NeE5MYWVv?= =?utf-8?B?SmRlcng3UG9rcTByL0U0elJlUDZyZ1dJczNnR3dqK1FpMThiQm8wV0ZHb1JP?= =?utf-8?B?RUdYcW9yRnp1KytDbC9Nblo5RllGUmNaZlQ5djBBQ2o1Z0pxT2RGZnIvdmFT?= =?utf-8?B?RXZDUW5pY1g5b1RISkdBZGROcUdPN2lDcFBkankyd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UFo2YjFOQVpmS1lldEJQT3VzbVFId0xWWnZWK1d3TnBjZHkxSmM2WmVwdkZ3?= =?utf-8?B?b0JXTERkU1F6SFhrMTRJaFU3V0Q4RTU5eHdYQkpqNTB2MXFnZ1VzMnpWSEE1?= =?utf-8?B?cVE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 307dbc45-6184-4469-a1af-08dab241cbc0 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2022 02:21:28.8769 (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: NsEzjuEJkyamc2cPLo7xhUw1rnmZowWbgSHO/hwbLioBEhk2QGRsegs936BVGES6Wjnoucw98eV+lsd7/N0qBt/kF23Qf3xxAI9LUJJ9gbo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR13MB5784 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 686a1c0..8b9e153 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) { @@ -620,6 +621,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; @@ -1284,6 +1293,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) @@ -1326,6 +1362,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; @@ -1401,6 +1438,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