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 AD805A0A02; Thu, 20 Oct 2022 04:22:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 58F1C42CAA; Thu, 20 Oct 2022 04:21:26 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2120.outbound.protection.outlook.com [40.107.101.120]) by mails.dpdk.org (Postfix) with ESMTP id 6292542CA3 for ; Thu, 20 Oct 2022 04:21:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lBxNgy9mjzcibNFNMW5BfW3VeJy3y45fGQS9D2NfxO4SKZu6V6OKC9C34y+1nymzXI+GBpzB9PitxrTgXPBlSGcfohoTjapAn0jOTG5k0RcM9ao07TnEovwaFnz71VblSGZqw4cUsBPQK107rfWxeAI5cRNEA+2NZ0tfkDwFe4XvzhoV9h9g6hSNoOwYl6AHO11IyiEXevoNcqlquaLmXjnOV3cMmspHmuw33/VF8pKcvn7JUB5A/3V2T4+OPRaJsKsdHB7pbocDsDJ6lEx2y6SibGa5I4kCa+ksO/QRKpTk5bobmk3KZU3ffGIakHofrXYZYqTvaPFzkZjAqgSaYA== 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=5QhbA3KOmhK3oF+Mk749wmVXDxaphbNU4+xlgq4Hdmc=; b=dt6Hkb76IOoRQ9xu74UVKKNAJ/f5B0iJ7u7XgVxyQhyfx/Mdz8Kn3nWDVC4ixsvsHi+lxCeYNtkzgjQw4gpWqrYJ6z9BigtyLtA4lI0N3aybj+boH8a2KNS+wgPp7fyj21ZQ8avlG8PGvLGpsS4AHVeE8opLABteg3yfWxSXc10zcsmgqNtPso/aBslGMmkrJduWXobujAhiGbjHPc1aWeVXuCHCqY07EkpfWbbW0qpWkgmJQsrwShILAOzTtbraypXA0UYLPkapQ5Cmn1OpqcOoQIJb9+Df92Q78Wvfs3ncOhyv2kpYYdC8J1EXq3DSx0sOcPNt8/XxMm1HYgpk3Q== 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=5QhbA3KOmhK3oF+Mk749wmVXDxaphbNU4+xlgq4Hdmc=; b=ddtC+hV3BEOBPkcj/QXDzRMb6tD5Fg1AmiqjiPwzin91G9onM0hIRH7jnhaBj8kqf7PN4wakEPds7WK+bZOefgLaKqUY8f1VF4h6Tu0mbqEXM9HTlwLE4AsO8Pr/zviUB0oZ2X7Pl9k7z3YqCc03PrnzdgMMiAwX6XLWgi17QaE= 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 DM4PR13MB5906.namprd13.prod.outlook.com (2603:10b6:8:4c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16; Thu, 20 Oct 2022 02:21:20 +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:20 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v5 13/25] net/nfp: support SRC MAC flow action Date: Thu, 20 Oct 2022 10:19:39 +0800 Message-Id: <1666232391-29152-14-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_|DM4PR13MB5906:EE_ X-MS-Office365-Filtering-Correlation-Id: 680c35e9-7cf4-4d78-4455-08dab241c6d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8n84hNdP5dK0Sd6NoNitSXTCzlBltIm/sysZ81nn8U21Uyl0HO1vPMSTaZaS+KsT010/CC191H0kcoYeE548I17CdCLJtyCjcUdQdnxyTAE9r1/pggD8a/8xQQ4t4O/gBnOufNOsqkNnIlC4TuQoRNBkRVHzzyJ8pTH1DVAUEnzfqXJQi7jP/IOVOu7i2Anrc2LOowWpr2XZe+JAWB06Y5mhXBDtvZy6q7oDH8hYVpcWjLT+NK6gp2lFsXeKo3F4EvYd+HzVWQB/VY0HSpsDT0YQlFfHr+qJ7Omcxge2DDwzbN7WPW3sinEWrZr/siLvOIcl/RqCFpyqtiNd0E4yaPELeBcU6IdJerGCFSaIucFOvrFURq6rtnRiKR1S2JiQ2Vr6vD+09hoG8rvICrV0U7ci/Ee2GmU4cuxo5V0gQ2B0InM5kRnaJzwo7OIKqv9jDv4QXoWR2r4TeD99aEg6ISI+xaaPh91DkoTvEi8GNK4hR/B0racS24RDIt/03Fp9NATlc4VY+VRz2IKTzYdsD2lw8AH8BtqB6bGOQktqzYchXJnpHmQjrCwAHnH3T918GSqS+sH2Go0xDHGn8zbkbVzGFxF+QtgXrEXMPKGf7UKDkmoptqOVGfOrP/5HnCrK9OuOUnIKhj61hvXCVjwrvseeRqZzRvosKr7M3J35ZZxcYEr9RXaHOx8G6Yk2iOTGO6hgKR5w4Roli6NlJ4RbRTfY4TJfR1xUoI8dHNZBuFtWmmXb167LzcolZ1xJ4AEZLTyWp5/rTBWNdE8qI9tx8hDt6kRoUV4QuF1HANco5lhk4g+/n4k89465EXo3OOCb 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)(376002)(39840400004)(346002)(396003)(366004)(451199015)(38100700002)(478600001)(38350700002)(316002)(6916009)(2906002)(186003)(66476007)(52116002)(66556008)(6666004)(66946007)(107886003)(4326008)(6506007)(2616005)(41300700001)(5660300002)(36756003)(8676002)(6486002)(8936002)(26005)(44832011)(86362001)(83380400001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NUtPbkd2UEFWc0hDSTIwMzg0ZStFUHN1bEpHem9SMnNEdkFySE8rMU9TdE9J?= =?utf-8?B?RkgyQklmNlJDd1hWWExIdDB6TXo0dW94WTdvWUJVSDlkeG9hK3RNMXRvRzdJ?= =?utf-8?B?cENSMFdSRVFLSTdJMnl6bnNFZzV5VmpwNzkzRWpQVUY3VlpxMmtnOS9QRGxK?= =?utf-8?B?aXpLTDFZdHY1ZGlRdnEzaFpkbjgwbG5nNG5BR3VYa1hBRDZuZ1RJb0w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hpRitLWlVGOGxGUXFnWHhiUVdqck53NDNIbmgz?= =?utf-8?B?RjByS1g2SnB4cjN4aXVIYlBhQ2JrQ0NVSk5tclo1SHlUOTJQSkVEaUhXUGlp?= =?utf-8?B?QWhLckM5MG5iWFJVaUE3Z2RRQWN5ZHV2Nml6YnEyNWZ6RHBQeEovUHpYckpy?= =?utf-8?B?L1E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 680c35e9-7cf4-4d78-4455-08dab241c6d0 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:20.5908 (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: IZIfZipBNs+GQ/ZBxdagN/fM2Pz+dbTJ+lyeKOREcq7o5rG6xvX6ylpoc7FyGRKid9s7s6CdnndDWl0HdaHGCr7JS3OnhSMToDcObsFatls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR13MB5906 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 MAC 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 | 27 ++++++++++++++++++ drivers/net/nfp/nfp_flow.c | 47 ++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index 27575d1..f7cd070 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -40,3 +40,4 @@ vlan = Y count = Y drop = Y port_id = 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 36d406f..b61342e 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -335,6 +335,33 @@ struct nfp_fl_act_output { rte_be32_t port; }; +/* + * ETH + * 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| - | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | eth_dst_47_16_mask | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | eth_dst_15_0_mask | eth_src_47_32_mask | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | eth_src_31_0_mask | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | eth_dst_47_16 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | eth_dst_15_0 | eth_src_47_32 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | eth_src_31_0 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_fl_act_set_eth { + struct nfp_fl_act_head head; + rte_be16_t reserved; + uint8_t eth_addr_mask[RTE_ETHER_ADDR_LEN * 2]; + uint8_t eth_addr[RTE_ETHER_ADDR_LEN * 2]; +}; + 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 35456a5..f40d777 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -561,6 +561,7 @@ struct nfp_mask_id_entry { struct nfp_fl_key_ls *key_ls) { int ret = 0; + bool mac_set_flag = false; const struct rte_flow_action *action; for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) { @@ -591,6 +592,13 @@ struct nfp_mask_id_entry { PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_PORT_ID detected"); key_ls->act_size += sizeof(struct nfp_fl_act_output); break; + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_MAC_SRC detected"); + if (!mac_set_flag) { + key_ls->act_size += sizeof(struct nfp_fl_act_set_eth); + mac_set_flag = true; + } + break; default: PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type); return -ENOTSUP; @@ -1209,6 +1217,36 @@ struct nfp_mask_id_entry { return 0; } +static void +nfp_flow_action_set_mac(char *act_data, + const struct rte_flow_action *action, + bool mac_src_flag, + bool mac_set_flag) +{ + size_t act_size; + struct nfp_fl_act_set_eth *set_eth; + const struct rte_flow_action_set_mac *set_mac; + + if (mac_set_flag) + set_eth = (struct nfp_fl_act_set_eth *)act_data - 1; + else + set_eth = (struct nfp_fl_act_set_eth *)act_data; + + act_size = sizeof(struct nfp_fl_act_set_eth); + set_eth->head.jump_id = NFP_FL_ACTION_OPCODE_SET_ETHERNET; + set_eth->head.len_lw = act_size >> NFP_FL_LW_SIZ; + set_eth->reserved = 0; + + set_mac = (const struct rte_flow_action_set_mac *)action->conf; + if (mac_src_flag) { + rte_memcpy(&set_eth->eth_addr[RTE_ETHER_ADDR_LEN], + set_mac->mac_addr, RTE_ETHER_ADDR_LEN); + } else { + rte_memcpy(&set_eth->eth_addr[0], + set_mac->mac_addr, RTE_ETHER_ADDR_LEN); + } +} + static int nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor, const struct rte_flow_action actions[], @@ -1218,6 +1256,7 @@ struct nfp_mask_id_entry { char *position; char *action_data; bool drop_flag = false; + bool mac_set_flag = false; uint32_t total_actions = 0; const struct rte_flow_action *action; struct nfp_fl_rule_metadata *nfp_flow_meta; @@ -1254,6 +1293,14 @@ struct nfp_mask_id_entry { position += sizeof(struct nfp_fl_act_output); break; + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: + PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_MAC_SRC"); + nfp_flow_action_set_mac(position, action, true, mac_set_flag); + if (!mac_set_flag) { + position += sizeof(struct nfp_fl_act_set_eth); + mac_set_flag = true; + } + break; default: PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type); return -ENOTSUP; -- 1.8.3.1