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 33C3CA0032; Fri, 21 Oct 2022 10:04:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3227842C3F; Fri, 21 Oct 2022 10:02:59 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2121.outbound.protection.outlook.com [40.107.94.121]) by mails.dpdk.org (Postfix) with ESMTP id D62B142C0A for ; Fri, 21 Oct 2022 10:02:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h/lIRW+ZLbh0PMfHQuCEzSp249gtYhjAhDORm27ihkdkx+vsJtIQa1RqMmegt0qWZZ7FAAkbgrkGp01+qsQ78AwcwAtfIM4Kzvr1u/Reqh+dRxJogqTQLgHhAMCKZLz5Bxf/lGaS4OLIUCnP+a+LOK1i5fpLsQfFrb+/jAiX1lm6b3B+tOuC+a/WIRj0xwo+G4p7E3l6vobG5Bc4Yji5Kum7KQ9QOVaZ0GfCDQnC2Pnjj3naKhdmELkwZekgJ24xaGbh3f8t7Q09E8QqEpeKClV6tdIjiQm0/t3tLGgG+xhv2m1PdotDUdsQe5Damvi1t38XiOLSdVJTcbnZjvSWVA== 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=+FAa5B6T6iAHYqcyWs/bO089KGKyPT6SRLc37geH30A=; b=W/p9SFZ+eHK6Jh/MgGd98WpzBau6JyGQDO6C2bpnwSaQ1F9ZZC8KR/pQxhAMtowwPaO60oEagUjk7Iy2OLkLt2SECx3RzXbdFnU7GdiFqT0BpM1Nc4g2s7DY9oYhdCM5ZNxLkCGugU6CHCJvta5VJQ6wZoUsaS5wjMxtCq4OlvQbeR3zlRwiZpBgLsMAwOyQHhdIlcAtiJjTRQyuUUT4yMwW/TbI/NPC7HBaGC7+BMmP/2RpG/E2wTISaguRU0HyRU+ErU2DLhAArblxmEKOs2MNatX4zg7r0+KtfsL9YSsEfcUU5AfN/Tb9g+1d2a9EhEnF5GF/9kgEzl3mGXjwag== 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=+FAa5B6T6iAHYqcyWs/bO089KGKyPT6SRLc37geH30A=; b=K/ezYcVzH6UR8/m+v+SoxDEM79FiQmijfUS/kDspvrh3y3a2N5Z5X2fEGgfnOaYcJ6BiOg021Y6vL95J6jtBHT99AZ4/Uhdwwer+CRtyL7m6qHu6pYsFaFb3jF75j8Yx+ioGt/zu2Vp7chsSGBUHdSYXzrizFHAjZJzHwAeUUUU= 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 DM6PR13MB4493.namprd13.prod.outlook.com (2603:10b6:5:1b9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.22; Fri, 21 Oct 2022 08:02:51 +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:51 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v6 15/27] net/nfp: support SRC MAC flow action Date: Fri, 21 Oct 2022 16:01:51 +0800 Message-Id: <1666339323-24016-16-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_|DM6PR13MB4493:EE_ X-MS-Office365-Filtering-Correlation-Id: d1445e28-231e-45a4-6b68-08dab33aa6b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zmYLiWhLXhHoDRqTMmAKSzwVVfvuN48xNqiFzgTb05WW7MKi97QrdU+Ep2u4+ySzU9t/ZlWC0yUQLYlQ0dtBOsJtwaf4HGWrWlJMND7jQyc7fbqJ07y4ifX6P7uyK5Y7g/UogyXjvSNNaQopqCn8h18zewF6OcNmjYeMuCDtYVkmsN1Ppf2Ym1NyQJkUO8aijKdpWk2/wikqPpIm0qxxW1DrZngbynqGVYHRBuh0saBQv2qE4T2+OFBfhcQrVd+PCnM0zjtXcw30QIcNkjCRmU+AKK2Le3hRduvPwlLqKZwvvJhKnGk/6hukWozjW5agXyVXaaB3E+WkTMnE9ubQuSaUPNWxOZ+g5DXlFsQHBW/VtE0lo323rX8aNtVAqSIzIbsK/TZlIUqMXD0zCEia6KgfuKkeWxUU/YLWhRF0iktJpHm3EN4Vt+YBoiNSBOw10NhlTPfg/p/0BF5NndptWlK3ejB+69rpIqY5mQopHaPzrvEXWPR+os8z9SYownFrl5UinTE2uHovfeU1b8e8/v++M7BVFBBVgDsfUelA3ftr/HyHNmsKozLQ4FRAUR3W9Aqb7/q+sh7vqHuJCV5wLb4YoD6pKuU08pqt552smx/gHzGuVrZpHXNd0Tkam4CqoTPO7noZCQ41eO7aHTRanceInmqIEBU7CqFnd7yttQbFd601fV3Sd+W7gFlE6yskGmNioD+6xTfiDBDZMZSUMgJYTn+2TV0/yOa5MxKYVzZBQh9VN8ghrbG0kg4ueptQ 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)(136003)(396003)(376002)(39830400003)(451199015)(36756003)(8936002)(66556008)(86362001)(41300700001)(478600001)(83380400001)(2906002)(5660300002)(186003)(6916009)(38350700002)(2616005)(4326008)(6512007)(66476007)(52116002)(66946007)(316002)(8676002)(6506007)(26005)(107886003)(38100700002)(6486002)(44832011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MmlSVDJkY0ViTmRMdVdSV08vZmtEckFrdEcyZWphd1E3SE93c2o5KytjU3Nl?= =?utf-8?B?WTU0ZFhDL0FaOFF2UE5hejAxSU41OVJVVGtFeWRPYUpUQVZnRUgwVTBQQkV3?= =?utf-8?B?RDBybzg3T3dRTnZzcHV4K3h4RGF5U0twWTJRaHNxVmE4T1J5MnBFUnVYbHZp?= =?utf-8?B?bU9waTJhL1RJSzZHZkRvQ0dqWTNoaVA2QVdoSjFEYkRkWk91eWVscWZuVU84?= =?utf-8?B?dFlFVDk4OGR1ZWdHa3dWVVF6cVNrMlRVRmtYaDEvZ2F0c2cxS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ROSU93L0FWWUc3enpBV3F3c0puWFZxR1No?= =?utf-8?B?cXZqRVN5RW9XYXpBSGdHMXNIVUFTOWpwRUZkMENjKzlPeEp4MWpwc1U2Rm1C?= =?utf-8?B?RXc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1445e28-231e-45a4-6b68-08dab33aa6b8 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:51.4488 (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: AfBYpJCKtovDZ1jEjBDrHANfmliVck66E8aW9R4s3Ki7+MXTmsCnnPc7bJVsnxaKi0m04rMPd6nEd5Ujo77q5ewBL1g0OU15OjpeN/xpBm0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB4493 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 13b2b30..8c065c4 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) { @@ -585,6 +586,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; @@ -1203,6 +1211,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[], @@ -1212,6 +1250,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; @@ -1242,6 +1281,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