drivers/net/ethernet/broadcom/bnge/bnge_hwrm.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnge/bnge_hwrm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnge/bnge_hwrm.c- Extension
.c- Size
- 14564 bytes
- Lines
- 549
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
asm/byteorder.hlinux/dma-mapping.hlinux/dmapool.hlinux/delay.hlinux/errno.hlinux/kernel.hlinux/list.hlinux/pci.hbnge.hbnge_hwrm.h
Detected Declarations
function bnge_cal_sentinelfunction bnge_hwrm_req_createfunction bnge_hwrm_req_timeoutfunction bnge_hwrm_req_alloc_flagsfunction bnge_hwrm_req_replacefunction bnge_hwrm_req_flagsfunction __hwrm_ctx_invalidatefunction bnge_hwrm_req_dropfunction bnge_map_hwrm_errorfunction bnge_hwrm_create_tokenfunction bnge_hwrm_destroy_tokenfunction bnge_hwrm_req_dbgfunction __hwrm_send_ctxfunction bnge_hwrm_req_sendfunction bnge_hwrm_req_send_silentfunction bnge_hwrm_req_dma_slicefunction bnge_cleanup_hwrm_resourcesfunction bnge_init_hwrm_resources
Annotated Snippet
if (i < BNGE_HWRM_SHORT_TIMEOUT_COUNTER) {
usleep_range(BNGE_HWRM_SHORT_MIN_TIMEOUT,
BNGE_HWRM_SHORT_MAX_TIMEOUT);
} else {
usleep_range(BNGE_HWRM_MIN_TIMEOUT,
BNGE_HWRM_MAX_TIMEOUT);
}
}
if (READ_ONCE(token->state) != BNGE_HWRM_COMPLETE) {
bnge_hwrm_err(bd, ctx, "No hwrm cmpl received: 0x%x\n",
req_type);
goto exit;
}
len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
valid = ((u8 *)ctx->resp) + len - 1;
} else {
__le16 seen_out_of_seq = ctx->req->seq_id; /* will never see */
int j;
/* Check if response len is updated */
for (i = 0; i < tmo_count; i++) {
if (token &&
READ_ONCE(token->state) == BNGE_HWRM_DEFERRED) {
bnge_hwrm_destroy_token(bd, token);
token = NULL;
}
len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
if (len) {
__le16 resp_seq = READ_ONCE(ctx->resp->seq_id);
if (resp_seq == ctx->req->seq_id)
break;
if (resp_seq != seen_out_of_seq) {
dev_warn(bd->dev, "Discarding out of seq response: 0x%x for msg {0x%x 0x%x}\n",
le16_to_cpu(resp_seq), req_type, le16_to_cpu(ctx->req->seq_id));
seen_out_of_seq = resp_seq;
}
}
/* on first few passes, just barely sleep */
if (i < BNGE_HWRM_SHORT_TIMEOUT_COUNTER) {
usleep_range(BNGE_HWRM_SHORT_MIN_TIMEOUT,
BNGE_HWRM_SHORT_MAX_TIMEOUT);
} else {
usleep_range(BNGE_HWRM_MIN_TIMEOUT,
BNGE_HWRM_MAX_TIMEOUT);
}
}
if (i >= tmo_count) {
bnge_hwrm_err(bd, ctx,
"Error (timeout: %u) msg {0x%x 0x%x} len:%d\n",
bnge_hwrm_timeout(i), req_type,
le16_to_cpu(ctx->req->seq_id), len);
goto exit;
}
/* Last byte of resp contains valid bit */
valid = ((u8 *)ctx->resp) + len - 1;
for (j = 0; j < BNGE_HWRM_FIN_WAIT_USEC; ) {
/* make sure we read from updated DMA memory */
dma_rmb();
if (*valid)
break;
if (j < 10) {
udelay(1);
j++;
} else {
usleep_range(20, 30);
j += 20;
}
}
if (j >= BNGE_HWRM_FIN_WAIT_USEC) {
bnge_hwrm_err(bd, ctx, "Error (timeout: %u) msg {0x%x 0x%x} len:%d v:%d\n",
bnge_hwrm_timeout(i) + j, req_type,
le16_to_cpu(ctx->req->seq_id), len, *valid);
goto exit;
}
}
/* Zero valid bit for compatibility. Valid bit in an older spec
* may become a new field in a newer spec. We must make sure that
* a new field not implemented by old spec will read zero.
*/
*valid = 0;
rc = le16_to_cpu(ctx->resp->error_code);
if (rc == HWRM_ERR_CODE_BUSY && !(ctx->flags & BNGE_HWRM_CTX_SILENT))
Annotation
- Immediate include surface: `asm/byteorder.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/delay.h`, `linux/errno.h`, `linux/kernel.h`, `linux/list.h`, `linux/pci.h`.
- Detected declarations: `function bnge_cal_sentinel`, `function bnge_hwrm_req_create`, `function bnge_hwrm_req_timeout`, `function bnge_hwrm_req_alloc_flags`, `function bnge_hwrm_req_replace`, `function bnge_hwrm_req_flags`, `function __hwrm_ctx_invalidate`, `function bnge_hwrm_req_drop`, `function bnge_map_hwrm_error`, `function bnge_hwrm_create_token`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.