Skip to content

Commit af02dbf

Browse files
kliteynkuba-moo
authored andcommitted
net/mlx5: HWS, rework the check if matcher size can be increased
When checking if the matcher size can be increased, check both match and action RTCs. Also, consider the increasing step - check that it won't cause the new matcher size to become unsupported. Additionally, since we're using '+ 1' for action RTC size yet again, define it as macro and use in all the required places. Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com> Reviewed-by: Mark Bloch <mbloch@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://patch.msgid.link/20250114130646.1937192-2-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 707ec62 commit af02dbf

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,22 @@ hws_bwc_matcher_size_maxed_out(struct mlx5hws_bwc_matcher *bwc_matcher)
468468
{
469469
struct mlx5hws_cmd_query_caps *caps = bwc_matcher->matcher->tbl->ctx->caps;
470470

471-
return bwc_matcher->size_log + MLX5HWS_MATCHER_ASSURED_MAIN_TBL_DEPTH >=
472-
caps->ste_alloc_log_max - 1;
471+
/* check the match RTC size */
472+
if ((bwc_matcher->size_log +
473+
MLX5HWS_MATCHER_ASSURED_MAIN_TBL_DEPTH +
474+
MLX5HWS_BWC_MATCHER_SIZE_LOG_STEP) >
475+
(caps->ste_alloc_log_max - 1))
476+
return true;
477+
478+
/* check the action RTC size */
479+
if ((bwc_matcher->size_log +
480+
MLX5HWS_BWC_MATCHER_SIZE_LOG_STEP +
481+
ilog2(roundup_pow_of_two(bwc_matcher->matcher->action_ste.max_stes)) +
482+
MLX5HWS_MATCHER_ACTION_RTC_UPDATE_MULT) >
483+
(caps->ste_alloc_log_max - 1))
484+
return true;
485+
486+
return false;
473487
}
474488

475489
static bool

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/matcher.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ static int hws_matcher_create_rtc(struct mlx5hws_matcher *matcher,
289289
* (2 to support writing new STEs for update rule))
290290
*/
291291
ste->order = ilog2(roundup_pow_of_two(action_ste->max_stes)) +
292-
attr->table.sz_row_log + 1;
292+
attr->table.sz_row_log +
293+
MLX5HWS_MATCHER_ACTION_RTC_UPDATE_MULT;
293294
rtc_attr.log_size = ste->order;
294295
rtc_attr.log_depth = 0;
295296
rtc_attr.update_index_mode = MLX5_IFC_RTC_STE_UPDATE_MODE_BY_OFFSET;
@@ -561,7 +562,8 @@ static int hws_matcher_bind_at(struct mlx5hws_matcher *matcher)
561562
pool_attr.flags = MLX5HWS_POOL_FLAGS_FOR_STE_ACTION_POOL;
562563
/* Pool size is similar to action RTC size */
563564
pool_attr.alloc_log_sz = ilog2(roundup_pow_of_two(action_ste->max_stes)) +
564-
matcher->attr.table.sz_row_log + 1;
565+
matcher->attr.table.sz_row_log +
566+
MLX5HWS_MATCHER_ACTION_RTC_UPDATE_MULT;
565567
hws_matcher_set_pool_attr(&pool_attr, matcher);
566568
action_ste->pool = mlx5hws_pool_create(ctx, &pool_attr);
567569
if (!action_ste->pool) {

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/matcher.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
/* Required depth of the main large table */
1919
#define MLX5HWS_MATCHER_ASSURED_MAIN_TBL_DEPTH 2
2020

21+
/* Action RTC size multiplier that is required in order
22+
* to support rule update for rules with action STEs.
23+
*/
24+
#define MLX5HWS_MATCHER_ACTION_RTC_UPDATE_MULT 1
25+
2126
enum mlx5hws_matcher_offset {
2227
MLX5HWS_MATCHER_OFFSET_TAG_DW1 = 12,
2328
MLX5HWS_MATCHER_OFFSET_TAG_DW0 = 13,

0 commit comments

Comments
 (0)