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 A7B4AA0560; Tue, 18 Oct 2022 13:29:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2F58D42B92; Tue, 18 Oct 2022 13:28:03 +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 23B5942B88 for ; Tue, 18 Oct 2022 13:28:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WmQ+5cGhBnIn2CTxGvLDcBhWgqPuPSkAGZ28cFQWdORJ3aYuaKD7A2pMRBdKDvXNoBUyndoEEVwe+v5CufpUuKY6KQai3NmrLxWHGLziYC/slBubdLphNnNI2/f/kalCfxgPMGv3PyIaWaJvF+Msxa6VwrgFCSVhD6duo4Im0dXq9PHvZwcIJe9vH26RMWNqQvL+GZHSMy/dNr6Mng+5YnQ8RF8EHKaG4yZWzOhgUj3qmaX25bb67uDoECVJBIdYcnUdCW099ayQhHFqEhIeMFauQpgM+GBwTZDnXWxy006yCnqwQ0RTcwvEOttUn8y03wcv1vl3psKag8sVuBqZEQ== 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=MBelKCqT5P6/6jz6D50cMgv+gBi9Ex8LUCQFzYlw3RY=; b=BJa4jRmyrUUYTfySIQkMVWwbSko34JIH3pXI2wSWk/1fTsgYl/4rLQ/JmG3qHEhhug8TOYa9Y2TSFA8UFC+MibRwMhjGmf9up5k4jcBMIKhBYJ3hgYNPXA7p38pMKa/SBt3mtN0GOhWYJR6NCv1LySPmetFNkFjFE7LnvAab1c7FUPyEN0rI6H/8G9t216Tiuyy66nlm69AAkPsbxwQlhSxUWZL5xDvtPE9m+d58OwaNyCFrX2wy7t44TMh7oNM9qVsYTwSiUp5EFoF4x3d9SVGp1lYWd6KoD2r8taYFls2KS5PHBtnsCxJSelJQMjlBsWNGUIibLg+CD1qgoclZAA== 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=MBelKCqT5P6/6jz6D50cMgv+gBi9Ex8LUCQFzYlw3RY=; b=d/6f+WhpmZ44GU1Tj9+5pfEX+pp/6k4MBg4UBC1dromJ6l3G7S4ZjK8o8h9qabdaJoePMBmgr50FUL7hJlK7xt9xhruNNKruAeqdBGgO5NAxvisx8JsY3q+Dk9bA+nOdCxJtjaND1c56jM/r22gGQaGLyJDkogHMBme0WrSjGRE= 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 CO3PR13MB5686.namprd13.prod.outlook.com (2603:10b6:303:179::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16; Tue, 18 Oct 2022 11:28:00 +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; Tue, 18 Oct 2022 11:28:00 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v4 13/25] net/nfp: support SRC MAC flow action Date: Tue, 18 Oct 2022 19:27:02 +0800 Message-Id: <1666092434-10357-14-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> References: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR02CA0052.apcprd02.prod.outlook.com (2603:1096:4:54::16) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO3PR13MB5686:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f71488a-adbe-494c-6467-08dab0fbd060 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VB6xfulAM5FHOEGW/c9I7XhT/Z89pitCW5JlD0HX7Zabxg2/dGEiu4jrEDlyj5G1TjTSSV7gd+lz88tuUupMDRbLfcuO03C2iMjQABI+aUZzYugG0nDLScj9OoPPPui4mtXN0HebjAhVGDUka/h/2hNn/h1xcMLjRT8S5Os/Ilo1bV7vyjsMupoIlxa41vIaKXUqp40fGJppYS/kRfaJpKdqexFMeeFjGGtHzqdZ/HLGQJ1xkES/zlaUJJ5HKc4sQ1ByeQ21i2Gan3yUeWMDEt3OYqoZLEO4BY3s7IDTWcMm42bZj36/4+ePxAmT95lN7d34Uw5gGz5p6yCh+p+YzkfSxUlUy9gwxda2yNizSuXGtymPTwIeJGIVnSGhLrMprbpibns10Lg/vHPcnVyorNjsFeDONRKQl4hHf1q2zNxDTQZhggaRdYW7AQ6eWhE7bZSWEjknNcLm9CQEf99CelLX1tVQ/4+tWx3HLeD01g+T33hosp65q1zgwfgPo4UTYlQ6+gDFXItyfTb0Z4Y8eiLqil5DxyKVbj522BiM5ikzuzc9L4R6rNLhzaMsqe/M6dRSXShcuO+ll/8WZSxaRhCyDhVIZcbDGECl0U7pVPAM7K6cGlUr9wIOQP/KVIvzRPtFtWvOZLWJhM/uWxWEuRTd9z3Op3tya2JTbBKqWddTRTTR/RAI9Z77eyztYNPnzcHpCkhiwpENPykxlpCtnjoO3w0qBNnLq++hJOL7nwNwNxbtUkPQ9baxigCOPO2xZGPtqvgbBHFlC8m0GJ8nxrSRA5qx7iRqx2zGNGSD0N7EOIjTJ3Z8kq+pZPG3FC5L 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)(346002)(366004)(39840400004)(396003)(136003)(376002)(451199015)(38350700002)(38100700002)(2906002)(41300700001)(316002)(66946007)(66556008)(66476007)(83380400001)(4326008)(8676002)(6916009)(86362001)(44832011)(2616005)(8936002)(186003)(36756003)(5660300002)(6506007)(107886003)(6486002)(478600001)(26005)(6512007)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OTFyczA5ZzJFTWh0a3lOMzdJQkN1QjkvZFc4MzBiZzcwRFFLVmE3MXN6NG15?= =?utf-8?B?VFd0OHFJVkxqbVo0WEw5VS9rMHl0R3JVYW1tK2lzdFRlY3ZTSmdQUW5iS0ZH?= =?utf-8?B?RXYvNUJuOVFvNWhuMEhOSmprdzhIeTQ2OEpQSnkxYWJCSXMyazFoQU9mTGRz?= =?utf-8?B?a1Azd3FYWDA0OTJJTG5jUXJvdGdsUE0yQ0NJQjVhYVZyeGJtOVo5YW00V0Rz?= =?utf-8?B?VFJWckRiOFUzcFFuVEFWMklWZmpGbllpQ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RZK253Yy84U2REUWYvbmVVL2l3WmhNaktqYVNEOWp5SUJodGJH?= =?utf-8?B?WFdwZGU5c1E2U2U0OGVwRXNrMWRybzJ1TUFiN1Mrd1c5SEdzWlRLcmlWSHVq?= =?utf-8?B?QlE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f71488a-adbe-494c-6467-08dab0fbd060 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 11:28:00.6541 (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: o9d6fAyNquxMP/4TCOaOTur5dl+HHofRkstxRJmLX7H4jE1nt4d+Cy2dJpf2ZBRJLo5IwDyRwkwU3yBAj59ssJ7sDD4H2f5ZYRdr6B+VQX4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR13MB5686 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 79a175b..ed43b1f 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -41,3 +41,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 6b0d9ae..a0a8c7b 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -573,6 +573,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) { @@ -603,6 +604,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; @@ -1221,6 +1229,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[], @@ -1230,6 +1268,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; @@ -1266,6 +1305,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