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.52.45 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796231733; b=hctC6Lfu+qWAKuWXkhGd5vLxYXNKmTTxiPkCmLrsJSYrdvPxl2pMyuSJTERCXKvYyv8W xOhPpoB8cpWs5V8pPjYURxvoOmgX1W/WyVHUkXQ1Tz+Q8IaJMvcdU3kAt+4VlDv6L79kz G3n1e+wbDdaTxTl0MVGip4abu9TDAI8aSCU2ul3kDtjJaFlnIojM6ZOQFZNyHDN1QdIaZ 9jz+VEeuyMTPKPWmszMMVuHrt0IEMhODDWiNg3oDBBrRXpN6m0LW0FsKIlCAPwtDad033 eoZSoDpx5pZMokBk/wOIvNcc8Ee1Hb86gfXiLh7bUYn6Ck9lmXp8b/WIzPo9xTVf1+Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796231733; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To: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=s3Q+Qf7NlGkiSq7+EqIHEl1DPoXJN49KTtjxBYWnjIE=; b=dOtyYuQCdIURoSkM95fHf+CLS0SdydWJAQsqGanevsvtH/g5a7E4jrJ6vHY3Ea2DSRzp 53B+vTIm9GeTs6EA9DedaXJOZWl12lKC8XLqtpm8B/rgdvf9o5PW3Il0gFLJze/oS3JN4 pIrm3FnvRLgI9YJ9FfT6IlVGv210qlO26+9EhShpQTfhpKJkUQtEvxSnmXGdFaO77PqLG xxbOZPJoN4MuharvcYki5VwYdTsjNXDiF2Y5VpaRpUKqB/AaqrUPhifMzuwtPVhhf3GfU TYbYCtFBrP9HI/HYzH805yhYC1VKccD1OLSaJ8Qi0HHGg0KfSk8F9iC3emDft5VfUcg== 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=N0aczKf5; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.52.45 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011045.outbound.protection.outlook.com [52.101.52.45]) (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 26D83606A330 for ; Wed, 2 Dec 2026 17:15:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26D83606A330 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=N0aczKf5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wguVRBo6WjoNn2to6ad8w71lV2Vdvl/3/fVzdagq2n0MyRjb21jf34BfVDV+NiaejhhpnoRHGKYAoQbBwIObuwamVVOe32RFVJUvVSrquhSJjNakTSRxUluNzDpFZwddK2r/m77H7y69fOMaK6V/5AlUXcEh7n9A2YEtNGtwFz5URoxpxHJ+erKQygs7ah8dUO5fHN23piXwBM9HkhgGFE0i6liCYypJoZYg3t8IxD9FsZBv8h3UWSwfrTbzkYMfht/7/7sdn+bhoEZLgm9ZwI9jHed8rpZ/LIDSPxiryOKtXfJM/X9DYOiGiKHze/uwZSBYTC3MAqmgeXbxCTSWnA== 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=s3Q+Qf7NlGkiSq7+EqIHEl1DPoXJN49KTtjxBYWnjIE=; b=uo6mhI8ie/1GLo/PutKp3UR4lVdS0plFdA60zaC1esQg9EqbwSGKUHsLpXXOQ+EpbGRgQVJaYfPCy+b2li7Dsepmhp8MwX43Vc5NiZIAHscSK7dLxE1SGrEHsKcJPFA70vVbNGkGgi8yLbRz3cWEMyIDGlthKpgsY1fb67ubopOA2FYBEFXgbUCsQ4nVc+0T/qsWutKLzROEpZtQR14rIIG4CBeuVUG/yxNB78BC7oJ+NIXgkfE96bQ7rQBPwNibrFM50YMBAV71w4P+81H9Lx5gpCHtWzML7xFtyG7YiY4+wjI8N9mZPtX8R8q+6gEviHWEiGW2j9EFccYMph+Syg== 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=s3Q+Qf7NlGkiSq7+EqIHEl1DPoXJN49KTtjxBYWnjIE=; b=N0aczKf5118x1I/xoVq3g7s3H3ORgBq1h6t/o1xA9u6/o3csM6GiBCurRbR6pkpEt368Fp+Q74YOH+zLLa42ODqKiCQiJDWtDu/vcMD79Uu+rCJUUHwK5GW/TalyRfpgpC1BLrXs/0Yu8UZcoKURuHLUmXEP3EFwEiWwbHob6XaU/0OEil3d4k42J3emHpYrUOASSBCCfI3GcruINAYlo2pim5+LifvwnmOZZSfJCaFNJrQpt2JkCiUt6/rGBqBsozmTPxZAP2fyVYtOXWtSL8pkzrGwCISf9NqLRDdWuxQ81guz2xKjbVvVPET6oW4NXHuwgNbaPRTW0pqcnxV4fg== 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 PH7PR12MB6587.namprd12.prod.outlook.com (2603:10b6:510:211::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.11; Wed, 2 Dec 2026 17:15:28 +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.009; Wed, 2 Dec 2026 17:15:27 +0000 Message-ID: <6b6bb519-b3e2-40c4-9281-13bf5f1566de@nvidia.com> Date: Wed, 2 Dec 2026 19:15:22 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v4] net: mlx5: Allow police as the last action of a TC rule To: linux-rdma@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: TLZP290CA0009.ISRP290.PROD.OUTLOOK.COM (2603:1096:950:9::18) To SA0PR12MB4367.namprd12.prod.outlook.com (2603:10b6:806:94::13) X-Mailing-List: linux-rdma@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_|PH7PR12MB6587:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a2cf8dd-9234-49f0-9be7-08df5097dc0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|376014|18002099003|22082099003|10067099003|56012099006|261026121527099003|261026140227099003|261028144727099003|261022105027099003|261021123027099003|261021121427099003|261102123227099003|261009223027099003|5023799004|11063799006|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: PjX4X44J5eDq5X5LaqAnJAbUYhfmzbNM3K3GQYXJGrVycKk/bSVwIbIfl4lZae+H27inHNx9IpB7oCecrH4UMaAdJBel0EdJctNZRuKKuTSywLDVl+i/SPTM4s8vEbEIr+qgBJzxkpKHCVtMAZPCh74pOorb9aTRLI1OnhjfDtvIR1Urgd7RQ/BXUgT8I8VRKcqNDd3KGNadZEXulgKMzlmE4IeysuMVKqiE3zTu7A6E7D9mtLK47jRpMUSPqMGSiGiQd1Q0+RQG/nUoTE2aKFHDq9xaxmPiis3Cbli07ilzl3ftE4C7N92dE0EkrQmJX4z8ZCkaBq4rH+vjSYk+tvsJ6VBEhoH8RwAQvGkAa5xK/DVRTX8bntQVYIWdGoCCdEeIa5cH2zhZphs1dl27LQ+LkrZL0gJw/7JiNpoMJJziQpcYxzhN99ikjzsn/PKUYFv5wXHRwyH586gXzbax+lrfMA+MbrC40B4awGce2DFq9L0dngDu+sH+u7gk+dfh1+Vshbnf6U/vmjbyjWbJXzjyBquYlDE5CMH8husMHL4Er5eMAyFN3sKT5z1vhiUTCLW8o5oYiZjGzrGkub/6nqPxrPcNWdpJ7aK8hPM5LrO3Uhl2d0YYaehhh32w410Q2votYLwORb0gry7FClTF9wbc9qAoIDcbzEctVR5FR/8= 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)(366016)(23010399003)(1800799024)(376014)(18002099003)(22082099003)(10067099003)(56012099006)(261026121527099003)(261026140227099003)(261028144727099003)(261022105027099003)(261021123027099003)(261021121427099003)(261102123227099003)(261009223027099003)(5023799004)(11063799006)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N3RDVURFdXJqNnlHMGtRNlNUMFVyK1RoenFhU3Q3cjhYS0E5UHdCZnBmS0or?= =?utf-8?B?MllPb056T0V6TUFlRGFYYnVWdGU5N2ptMXdVejR4b0tpZDlQb2NBbllPNEVT?= =?utf-8?B?QktyNkNzNlMvYllPOTBWZUpYSHNlZHhXOFFOMy93RWVGUWdqN1dRclJ5emJW?= =?utf-8?B?YWhlYk5lWkI1a2Z2S2NwMC9pL2R2R29nR0tFbEMvKytrMGdNWjBEY1VXRm1l?= =?utf-8?B?VWZvNWVYd3FOUk1aUmdzWCs1UVkwL3Z3a2UxZ0E0UVBGaGtMR2lYcGhhMkR1?= =?utf-8?B?Mkk4c0JaVzVZVDBnR1E0ZmlrSnIxMkRFMjE1cmNKcTh1dUg5czR1dHNESjlU?= =?utf-8?B?enZjbDVtRU1BTU5sa0FpZFhrR0dsb1FobkVzOW9USWtuUjQxMXVkcGpWaDYr?= =?utf-8?B?NGEzZmdFcm1xejl3e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?utf-8?B?Z1E5YWliVEVpNVF6aUtmTW05UERIMC9ES04zSGR1aEJMN2FlcVRFR0tnMkxt?= =?utf-8?B?WXNRYkxMT3liWExRS0lNR3BjTDllVE5MaG42aXY4dmVMbXFEWmdPdz09?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a2cf8dd-9234-49f0-9be7-08df5097dc0d X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4367.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 17:15:27.3769 (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: OG+LONLIsKRoQRA64XHzs/p8XtxX2XPx9OA/a+GWCfZyewqUv/1Ve7Hlk9Bc+B7voqTCnxNB0h4xOzjxCOjW+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6587 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 I'm okay with this version. 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; >