From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.201.31 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796296680; b=bSnjZWQXLlWZDj6nuZFEXL8r7sf7ZGj+oIT6EUcGZqvwlGy37YLnw7OizbeKr8pLe49C VIYCPpwmtaEeZInXXDKqcWAlfaxB9Zobczi6FyZHxPubV7JA/Vgc5XRT2XpEmO2dQuwiN lbv7vi4TTBVqzO3jYTW2t3hDuL2knxG5QsPmMt6zuH21EMNewXshDkg59901II6A6EDNE YtehtIKboZiqf2CG34JtlOoitAGzp21ggPON2IVX5e3HwRdxg9lr4Y6Gc9fDmRbusP2YE OQT0x3UJmGHw3cZsBLVJGWFaiLiyxT6nVZ6/jaqQEs1gHZ/xsUtkZp3yJ7px/vtxFXg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296680; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=qEr5zIcc/hqph039qdIzsBmohHNm6oCzAPzSrLbWJKs=; b=bwc9jdXepmgnUr9+/misuslG5oxyJMCIfHZY2mgPJzLfvQoCnW8W5IfOjTID1CEqLpX9 VCmLI8kIK7NSOFbdSv2HG2ku5QMQ0kM4e0CYUbZpF8wa414WN++e1Wawq1wPmStX+oCG0 Tnjfz1yJVWO+Yl+lsDWODu2mkhk/OVJOm5G75wwa8ABSlIxlqVnx1EQGh3AiTslQjlSuh HqAUr6ikPxf5UTHQPWcJupJ1IB/+xHZhlDhOCeGcA4AkgdnBbtZm8MPERlfShbU/pFI+g axAcq56rRd/EQ/Ud6EkjoyzYQRosQAOgaM6GRfNU5R0spx4gJV2jbKQQZN3LUv8MVbg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=JAWT+vqX; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.201.31 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010031.outbound.protection.outlook.com [52.101.201.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B2FE606A322; Thu, 3 Dec 2026 11:17:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1B2FE606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=JAWT+vqX ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NQM8OPG7Cx0VWD2biDRZwZU/jTnc31Sag26nfWbxLUapOKv2xiXSsQcQ/LLHeheqAh0x6MMHdcdCWIz3UdGmfnwj2Gb6Xji5Xkosbi/bVpL1GwZPrBNN+/CeEuqOUm2WmbFvMovnjSkVVphEwLoeyh7mayTYNlaPeYH+aFyTlsIo0R6NcFFjVqo/75U59NMCeVLyNCYfsgZWWniOI/wKDKIRMOLkqOAfPxNo/GE/+cJeeUpYx5zKhIV40EoV+A2MBm0pXZ+JbLskKVGCmQM0oJzmQZUt3NqJUoQKlJAuVME/KzL8C5MVBvSUQf4ItDfzabLJ9K7nPKh/0OBj8PXXyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qEr5zIcc/hqph039qdIzsBmohHNm6oCzAPzSrLbWJKs=; b=tA9F2O6NZ8e/pAcrSgLoiWrxFXpqbWK8Le6GJcqOR7ULqkmnDuIf1Hn2GIDtG2aaK65HGfKQf4iChzjGX+fFmmQvLEiTRptZVkP2IesjpIXxWpMajjvaxVLZUfO+V8irHYCj7eMV+tUfBiHJ2/arOArWqDHFZwjCUtk48TQcBNJwGsEJA0BQDC/Kg1GfpNyTP8PPMD+9d+UCz1zaOoJeR4wJW6fVood3RrQczjdRWYhYOCGPiHSIVKPVbjPbRLlcQUtjE7DiYwB/X/SKC+gd0IdMIOxA/v1tnz1hi3kb2+EXso0otJ7xgDDgJnN+7s73MYFW2YYnTlGJMcyC6aRvkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qEr5zIcc/hqph039qdIzsBmohHNm6oCzAPzSrLbWJKs=; b=JAWT+vqXO1Nr+r8q+C8QWahgbGvNc8FMYMfON05VScY0xwWV6LzqLPcDCc2FabsgJjDlovjlqoLVh3hjO9DvnAB+WCAKBaWUe4NUMebkAqFt5MMVPIxlMXHPlT49LwzQRh3lA0s1Ur70VE3FmEUKZly9K8poPlJdpPCOmYs4Pq7oQjUySFEFF1yoSoGXbr32RxlZClTLnpZdGCKyR9hb+fVnkBK2ECw1oujYsLJrX9fdcWkYBouxlBTD6Macwm6/HFOCQKedoVp58nMkDYtQzkN5DMRRsQRKvxv/VobFb5CoNY1/+LlTZ+LRP8LQ2Di3+UV7CBQV177xgBGmGGHftQ== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SA0PR12MB4367.namprd12.prod.outlook.com (2603:10b6:806:94::13) by CY8PR12MB7731.namprd12.prod.outlook.com (2603:10b6:930:86::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Thu, 3 Dec 2026 11:17:53 +0000 Received: from SA0PR12MB4367.namprd12.prod.outlook.com ([fe80::2815:8a95:1a44:be1c]) by SA0PR12MB4367.namprd12.prod.outlook.com ([fe80::2815:8a95:1a44:be1c%6]) with mapi id 15.21.0688.010; Thu, 3 Dec 2026 11:17:53 +0000 Message-ID: <583bba00-348e-4eb9-9243-b3fe6db90055@nvidia.com> Date: Thu, 3 Dec 2026 13:17:50 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v4] net: mlx5: Allow police as the last action of a TC rule To: Mohsin Bashir , netdev@vger.kernel.org Cc: saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, cjubran@nvidia.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261201212455.2836814-1-mohsin.bashr@gmail.com> Content-Language: en-US From: Mark Bloch In-Reply-To: <20261201212455.2836814-1-mohsin.bashr@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: TLZP290CA0003.ISRP290.PROD.OUTLOOK.COM (2603:1096:950:9::17) To SA0PR12MB4367.namprd12.prod.outlook.com (2603:10b6:806:94::13) X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA0PR12MB4367:EE_|CY8PR12MB7731:EE_ X-MS-Office365-Filtering-Correlation-Id: f4d56bea-1a0c-4450-408b-08df512f12fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|366016|1800799024|10067099003|261022105027099003|11063799006|5023799004|56012099006|261009223027099003|261021123027099003|261102123227099003|261021121427099003|261028144727099003|261026121527099003|261026140227099003|18002099003|22082099003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: u38zLgp4uBPRYOgM6zhMHRPHtM3TLEowffyT9KqvpnMtqa40LT3g6BHul97e7Pppx3LYLYU1b/ycFCHQD5E/C+wh4eCu9og9i/IZCAVX2jx3U1y3Nbr6p/+f50+3vyqhsJVFQhPrMjkwCbaATREdu2h3wMWD8+hWM/7KyLNNxQF+TW2ZsC6IGCxc0hI2WXmydAiO6fCCLaJ1unKc9iuPgK6Ipf6NYaxkP1K8OKfHiBJjYp4k8lZ7Cp4maTMxWZfA7lA+Y7K+la4zyqLrXKzH0jR+4a376b1zjq+lDXuoSFn2DbFb0hsaJtJ7/mz/CQr5b2S4fCB1LKw1ny6uQ0PhE8INJ7AZDkuUKJYzGCVR4HVCmn6VlwLnHdINzEzNy7DbDVEHOlgAbjD+SUDnEg76BCZLuDfWPfHiBVdZP9ymBwYQjwXQUXAlWeo3NbWZ9/46pAlZmd9IbAci2gx2LHGtMI12x1Y1o/MX3nOQx6SM5cvCbCMFDWFxoxR5oZgdqB08clWpCoHFGFtAimbW/fNcZBEfddf4qMJX+BpsKroSz0WHVpC0FrNTTEcL0InxVGO6Qr7xkJ4bIBYiCsIJwSZ5EG1MnA2dSPqFpO78G/KJLJZp1V0KoVCincT3RgyL6Z4Qj96NFLKQPSzb6lqDpifalhRn5vVVHYz6vVSImNS9POM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA0PR12MB4367.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(366016)(1800799024)(10067099003)(261022105027099003)(11063799006)(5023799004)(56012099006)(261009223027099003)(261021123027099003)(261102123227099003)(261021121427099003)(261028144727099003)(261026121527099003)(261026140227099003)(18002099003)(22082099003)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OWpITCtKd1c2ZjBHQytkT2pYV1Jja1lXVmtxQVFvdnlodFBpVU82bGJZTzlG?= =?utf-8?B?TnZ5blJGMGs2Ni90bnlDNWJ2MVRqT3ZHdmlCQUZLenc0dkZuMkVpVFJXbitR?= =?utf-8?B?eXJkSHBZRzhMeUVuRlJEWTdpYnFmdDc3eERTZ3JkYzVmRk5SSkdCUlNodFFF?= =?utf-8?B?NTlzU3BCbUpIT3ljYXcrelByTysyYXBiT09MZ0N5djVnM2dWNGU4aHI0WW04?= =?utf-8?B?NkkyZFRCcWJxNTd5WkNaMzZKSXZYUTdLR1lxYXJJRmZvbzdDSHY4Q1R3Y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NadGVhdHRaVUJsK0xuNmlWSVlHNVZBSDZKeWtIUVdSbzRI?= =?utf-8?B?dVN1aStZWUI2dzY1UUl3b1l0ZDdyVFNsU0V3Z0ZOS3FEblArdVhRaThWQzFj?= =?utf-8?B?NUZSd2I1VkdRd1JhbkdaTlBLQitINm9ZKytJTFV3bXpVUWk1T3R6cE9nVDZB?= =?utf-8?B?bURnbERvb1J0cU1WcW9GOXZCNWsvT25DeEtaSmMxd1FhSmhObThkMkIvWmNV?= =?utf-8?B?K2k1SWhsRWRVS28xR1ZaOU8vK05MQzQrOW1ZdzZQblFMMlpRdmtWQT09?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4d56bea-1a0c-4450-408b-08df512f12fc X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4367.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 11:17:53.5800 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JRGM9tLFB4h3DJnpGgfIetFWIGcijLbt18QzzVEhmhKvWpOvxzr0ktijYJvMGoOGIriJ9maQylfLBzKABHqGyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7731 On 01/12/2026 23:24, Mohsin Bashir wrote: > From: Mohsin Bashir > > In switchdev mode, mlx5 does not offload a rule where police is the last > action, although TC needs no other action for such a rule. The upcoming > selftest series relies on these rules. With nothing after police, the > police result alone decides where the packet goes, so each result must > be offloaded as TC executes it. The driver does not do that today. An ok > result is handled as pipe and runs the actions after police, a pipe > result always returns to the post action table, and a jump is counted > from police while TC counts it from the start of the action list. A rate > police is also rejected by verify_attr_actions(), as its forward to the > post meter table is added only after the check. > > Make the offloaded rule behave as it does in TC. An ok result ends > processing in TC. A pipe result does the same when police is the last > action. Send both to the end of the TC chains as the driver already does > for gact ok. For jump, offload only the case where police is the first > action, no pedit or police is skipped, and no action follows itself. The > driver counts a jump in flow action entries and merges only consecutive > entries of the same action, so a pedit with both set and add keys counts > more than once, and an action repeated in a row counts once. A skipped > police takes over the jump. Reject the rest. Existing rules where police > is followed by other actions also change. An ok result now accepts the > packet instead of running those actions. Finally set the forward to the > post meter table while parsing police. This is already done for police > with mtu and lets a police-only rule pass verify_attr_actions(). > > Tested on a ConnectX-7 in switchdev mode with the commands below. The > hardware drop counter showed that the rules are offloaded and limit the > traffic to the configured rate, that the second police only sees the > packets conforming to the first, and that the jump lands on its target. > > tc filter add dev eth0 ingress pref 100 protocol ipv6 flower skip_sw \ > ip_proto udp dst_port 5201 \ > action police rate 100mbit burst 1m conform-exceed drop/ok > > tc filter add dev eth0 ingress pref 100 protocol ipv6 flower skip_sw \ > ip_proto udp dst_port 5201 \ > action police rate 200mbit burst 1m conform-exceed drop/pipe \ > action police rate 100mbit burst 1m conform-exceed drop/pipe > > tc filter add dev eth0 ingress pref 100 protocol ipv6 flower skip_sw \ > ip_proto udp dst_port 5201 \ > action police rate 100mbit burst 1m conform-exceed drop / jump 2 \ > action drop action ok > > Cc: Carolina Jubran > Signed-off-by: Mohsin Bashir > --- Sent by mistake only to the rdma mailing list, sending again to all. Reviewed-by: Mark Bloch > Changelog: > v4: > - Reject only a skipped pedit or police, instead of allowing only > skipped actions that are all drop or all ok, as suggested by Mark: > https://lore.kernel.org/netdev/c5ad051b-5ae8-47d7-ab90-c3853a379335@nvidia.com > v3: https://lore.kernel.org/netdev/20261124220251.776944-1-mohsin.bashr@gmail.com > v2: https://lore.kernel.org/netdev/20261119040010.1405900-1-mohsin.bashr@gmail.com > v1: https://lore.kernel.org/netdev/20261117031337.4126403-1-mohsin.bashr@gmail.com > --- > .../mellanox/mlx5/core/en/tc/act/police.c | 59 ++++++++++++++++++- > .../net/ethernet/mellanox/mlx5/core/en_tc.c | 26 +++++--- > 2 files changed, 75 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c > index 1bd1c94fb977..1e6babff8b2b 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c > @@ -37,6 +37,52 @@ static int police_act_validate(const struct flow_action_entry *act, > return 0; > } > > +static bool > +police_act_can_offload_jump(struct mlx5e_tc_act_parse_state *parse_state, > + const struct flow_action_entry *act, > + int act_index, u32 target) > +{ > + const struct flow_action *flow_action = parse_state->flow_action; > + struct netlink_ext_ack *extack = parse_state->extack; > + const struct flow_action_entry *prev, *entry; > + u32 i; > + > + if (act_index) { > + NL_SET_ERR_MSG_MOD(extack, > + "Jump is only supported when police is the first action"); > + return false; > + } > + > + if (!target || target >= flow_action->num_entries) { > + NL_SET_ERR_MSG_MOD(extack, "Jump target must be a later action"); > + return false; > + } > + > + prev = act; > + for (i = 1; i <= target; i++) { > + entry = &flow_action->entries[i]; > + > + if (i < target && > + (entry->id == FLOW_ACTION_MANGLE || > + entry->id == FLOW_ACTION_ADD || > + entry->id == FLOW_ACTION_POLICE)) { > + NL_SET_ERR_MSG_MOD(extack, > + "Jump over a pedit or police action is not supported"); > + return false; > + } > + > + if (entry->id == prev->id && entry->hw_index == prev->hw_index) { > + NL_SET_ERR_MSG_MOD(extack, > + "Jump over the same action twice in a row is not supported"); > + return false; > + } > + > + prev = entry; > + } > + > + return true; > +} > + > static bool > tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state, > const struct flow_action_entry *act, > @@ -49,6 +95,16 @@ tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state, > if (err) > return false; > > + if (act->police.exceed.act_id == FLOW_ACTION_JUMP && > + !police_act_can_offload_jump(parse_state, act, act_index, > + act->police.exceed.extval)) > + return false; > + > + if (act->police.notexceed.act_id == FLOW_ACTION_JUMP && > + !police_act_can_offload_jump(parse_state, act, act_index, > + act->police.notexceed.extval)) > + return false; > + > return !!mlx5e_get_flow_meters(parse_state->flow->priv->mdev); > } > > @@ -94,13 +150,14 @@ tc_act_parse_police(struct mlx5e_tc_act_parse_state *parse_state, > MLX5_FLOW_STEERING_CAP_MATCH_RANGES)) > return -EOPNOTSUPP; > > - attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; > attr->flags |= MLX5_ATTR_FLAG_MTU; > } else { > attr->action |= MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO; > attr->exe_aso_type = MLX5_EXE_ASO_FLOW_METER; > } > > + attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; > + > return 0; > } > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > index 615af3acdb9e..ddf488e7cb68 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > @@ -3877,7 +3877,7 @@ static int > alloc_branch_attr(struct mlx5e_tc_flow *flow, > struct mlx5e_tc_act_branch_ctrl *cond, > struct mlx5_flow_attr **cond_attr, > - u32 *jump_count, > + u32 *jump_count, bool last, > struct netlink_ext_ack *extack) > { > struct mlx5_flow_attr *attr; > @@ -3894,11 +3894,17 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow, > case FLOW_ACTION_DROP: > attr->action |= MLX5_FLOW_CONTEXT_ACTION_DROP; > break; > - case FLOW_ACTION_ACCEPT: > case FLOW_ACTION_PIPE: > - err = set_branch_dest_ft(flow->priv, attr); > - if (err) > - goto out_err; > + if (!last) { > + err = set_branch_dest_ft(flow->priv, attr); > + if (err) > + goto out_err; > + break; > + } > + fallthrough; > + case FLOW_ACTION_ACCEPT: > + attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; > + attr->flags |= MLX5_ATTR_FLAG_ACCEPT; > break; > case FLOW_ACTION_JUMP: > if (*jump_count) { > @@ -3970,7 +3976,7 @@ dec_jump_count(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act, > static int > parse_branch_ctrl(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act, > struct mlx5e_tc_flow *flow, struct mlx5_flow_attr *attr, > - struct mlx5e_tc_jump_state *jump_state, > + struct mlx5e_tc_jump_state *jump_state, bool last, > struct netlink_ext_ack *extack) > { > struct mlx5e_tc_act_branch_ctrl cond_true, cond_false; > @@ -3983,7 +3989,7 @@ parse_branch_ctrl(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act, > tc_act->get_branch_ctrl(act, &cond_true, &cond_false); > > err = alloc_branch_attr(flow, &cond_true, > - &attr->branch_true, &jump_count, extack); > + &attr->branch_true, &jump_count, last, extack); > if (err) > goto out_err; > > @@ -3991,7 +3997,7 @@ parse_branch_ctrl(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act, > jump_state->jumping_attr = attr->branch_true; > > err = alloc_branch_attr(flow, &cond_false, > - &attr->branch_false, &jump_count, extack); > + &attr->branch_false, &jump_count, last, extack); > if (err) > goto err_branch_false; > > @@ -4055,7 +4061,9 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state, > > dec_jump_count(act, tc_act, attr, priv, &jump_state); > > - err = parse_branch_ctrl(act, tc_act, flow, attr, &jump_state, extack); > + err = parse_branch_ctrl(act, tc_act, flow, attr, &jump_state, > + flow_action_is_last_entry(flow_action, act), > + extack); > if (err) > goto out_free_post_acts; >