drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c- Extension
.c- Size
- 34397 bytes
- Lines
- 1239
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
internal.h
Detected Declarations
function hws_bwc_gen_queue_idxfunction hws_bwc_get_burst_thfunction hws_bwc_get_queue_lockfunction hws_bwc_lock_all_queuesfunction hws_bwc_unlock_all_queuesfunction hws_bwc_matcher_init_attrfunction hws_bwc_matcher_move_all_simplefunction list_for_each_entryfunction hws_bwc_matcher_move_allfunction hws_bwc_matcher_movefunction mlx5hws_bwc_matcher_create_simplefunction hws_bwc_matcher_init_size_rxtxfunction hws_bwc_matcher_init_sizefunction mlx5hws_bwc_matcher_createfunction mlx5hws_bwc_matcher_destroy_simplefunction mlx5hws_bwc_matcher_destroyfunction mlx5hws_bwc_queue_pollfunction mlx5hws_bwc_rule_fill_attrfunction mlx5hws_bwc_rule_allocfunction mlx5hws_bwc_rule_freefunction hws_bwc_rule_list_addfunction hws_bwc_rule_list_removefunction hws_bwc_rule_destroy_hws_asyncfunction hws_bwc_rule_destroy_hws_syncfunction hws_bwc_rule_cnt_decfunction hws_bwc_matcher_rehash_shrinkfunction hws_bwc_rule_cnt_dec_with_shrinkfunction mlx5hws_bwc_rule_destroy_simplefunction mlx5hws_bwc_rule_destroyfunction hws_bwc_rule_create_asyncfunction hws_bwc_rule_create_syncfunction hws_bwc_rule_update_syncfunction hws_bwc_matcher_size_maxed_outfunction hws_bwc_matcher_rehash_size_neededfunction hws_bwc_rule_actions_to_action_typesfunction hws_bwc_matcher_extend_atfunction hws_bwc_matcher_extend_sizefunction hws_bwc_matcher_find_atfunction hws_bwc_matcher_rehash_sizefunction hws_bwc_matcher_size_maxed_outfunction hws_bwc_matcher_size_maxed_outfunction hws_bwc_rule_get_at_idxfunction hws_bwc_rule_cnt_inc_rxtxfunction hws_bwc_rule_cnt_incfunction hws_bwc_rule_cnt_inc_with_rehashfunction mlx5hws_bwc_rule_create_simplefunction mlx5hws_bwc_rule_createfunction hws_bwc_rule_action_update
Annotated Snippet
list_for_each_entry(bwc_rule, rules_list, list_node) {
ret = mlx5hws_matcher_resize_rule_move(matcher,
bwc_rule->rule,
&rule_attr);
if (unlikely(ret)) {
if (!move_error) {
mlx5hws_err(ctx,
"Moving BWC rule: move failed (%d), attempting to move rest of the rules\n",
ret);
move_error = ret;
}
/* Rule wasn't queued, no need to poll */
continue;
}
pending_rules++;
drain = pending_rules >=
hws_bwc_get_burst_th(ctx, rule_attr.queue_id);
ret = mlx5hws_bwc_queue_poll(ctx,
rule_attr.queue_id,
&pending_rules,
drain);
if (unlikely(ret)) {
if (ret == -ETIMEDOUT) {
mlx5hws_err(ctx,
"Moving BWC rule: timeout polling for completions (%d), aborting rehash\n",
ret);
return ret;
}
if (!poll_error) {
mlx5hws_err(ctx,
"Moving BWC rule: polling for completions failed (%d), attempting to move rest of the rules\n",
ret);
poll_error = ret;
}
}
}
if (pending_rules) {
queue = &ctx->send_queue[rule_attr.queue_id];
mlx5hws_send_engine_flush_queue(queue);
ret = mlx5hws_bwc_queue_poll(ctx,
rule_attr.queue_id,
&pending_rules,
true);
if (unlikely(ret)) {
if (ret == -ETIMEDOUT) {
mlx5hws_err(ctx,
"Moving bwc rule: timeout draining completions (%d), aborting rehash\n",
ret);
return ret;
}
if (!drain_error) {
mlx5hws_err(ctx,
"Moving bwc rule: drain failed (%d), attempting to move rest of the rules\n",
ret);
drain_error = ret;
}
}
}
}
/* Return the first error that happened */
if (unlikely(move_error))
return move_error;
if (unlikely(poll_error))
return poll_error;
if (unlikely(drain_error))
return drain_error;
return ret;
}
static int hws_bwc_matcher_move_all(struct mlx5hws_bwc_matcher *bwc_matcher)
{
switch (bwc_matcher->matcher_type) {
case MLX5HWS_BWC_MATCHER_SIMPLE:
return hws_bwc_matcher_move_all_simple(bwc_matcher);
case MLX5HWS_BWC_MATCHER_COMPLEX_FIRST:
return mlx5hws_bwc_matcher_complex_move_first(bwc_matcher);
case MLX5HWS_BWC_MATCHER_COMPLEX_SUBMATCHER:
return mlx5hws_bwc_matcher_complex_move(bwc_matcher);
default:
return -EINVAL;
}
}
static int hws_bwc_matcher_move(struct mlx5hws_bwc_matcher *bwc_matcher)
{
struct mlx5hws_context *ctx = bwc_matcher->matcher->tbl->ctx;
Annotation
- Immediate include surface: `internal.h`.
- Detected declarations: `function hws_bwc_gen_queue_idx`, `function hws_bwc_get_burst_th`, `function hws_bwc_get_queue_lock`, `function hws_bwc_lock_all_queues`, `function hws_bwc_unlock_all_queues`, `function hws_bwc_matcher_init_attr`, `function hws_bwc_matcher_move_all_simple`, `function list_for_each_entry`, `function hws_bwc_matcher_move_all`, `function hws_bwc_matcher_move`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.