drivers/infiniband/hw/hfi1/pio.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hfi1/pio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hfi1/pio.c- Extension
.c- Size
- 57567 bytes
- Lines
- 2133
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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
linux/delay.hhfi.hqp.htrace.h
Detected Declarations
struct mem_pool_configstruct mem_pool_infofunction __cm_resetfunction pio_send_controlfunction wildcard_to_poolfunction init_sc_pools_and_sizesfunction init_send_contextsfunction sc_hw_allocfunction sc_hw_freefunction group_contextfunction group_sizefunction cr_group_addressesfunction sc_haltedfunction sc_mtu_to_thresholdfunction sc_percent_to_thresholdfunction sc_set_cr_thresholdfunction set_pio_integrityfunction get_buffers_allocatedfunction reset_buffers_allocatedfunction sc_freefunction sc_disablefunction packet_occupancyfunction egress_haltedfunction is_sc_haltedfunction bitfunction sc_waitfunction allocationsfunction pio_freezefunction Userfunction pio_kernel_linkupfunction pio_init_wait_progressfunction pio_reset_allfunction sc_enablefunction sc_return_creditsfunction sc_flushfunction sc_stopfunction sc_add_credit_return_intrfunction sc_del_credit_return_intrfunction hfi1_sc_wantpiobuf_intrfunction hfi1_verbs_sendfunction fill_codefunction sc_release_updatefunction sc_group_release_updatefunction pio_select_send_context_vlfunction pio_select_send_context_scfunction pio_map_freefunction pio_map_rcu_callbackfunction set_threshold
Annotated Snippet
struct mem_pool_config {
int centipercent; /* % of memory, in 100ths of 1% */
int absolute_blocks; /* absolute block count */
};
/* default memory pool configuration: 100% in pool 0 */
static struct mem_pool_config sc_mem_pool_config[NUM_SC_POOLS] = {
/* centi%, abs blocks */
{ 10000, -1 }, /* pool 0 */
{ 0, -1 }, /* pool 1 */
};
/* memory pool information, used when calculating final sizes */
struct mem_pool_info {
int centipercent; /*
* 100th of 1% of memory to use, -1 if blocks
* already set
*/
int count; /* count of contexts in the pool */
int blocks; /* block size of the pool */
int size; /* context size, in blocks */
};
/*
* Convert a pool wildcard to a valid pool index. The wildcards
* start at -1 and increase negatively. Map them as:
* -1 => 0
* -2 => 1
* etc.
*
* Return -1 on non-wildcard input, otherwise convert to a pool number.
*/
static int wildcard_to_pool(int wc)
{
if (wc >= 0)
return -1; /* non-wildcard */
return -wc - 1;
}
static const char *sc_type_names[SC_MAX] = {
"kernel",
"ack",
"user",
"vl15"
};
static const char *sc_type_name(int index)
{
if (index < 0 || index >= SC_MAX)
return "unknown";
return sc_type_names[index];
}
/*
* Read the send context memory pool configuration and send context
* size configuration. Replace any wildcards and come up with final
* counts and sizes for the send context types.
*/
int init_sc_pools_and_sizes(struct hfi1_devdata *dd)
{
struct mem_pool_info mem_pool_info[NUM_SC_POOLS] = { { 0 } };
int total_blocks = (chip_pio_mem_size(dd) / PIO_BLOCK_SIZE) - 1;
int total_contexts = 0;
int fixed_blocks;
int pool_blocks;
int used_blocks;
int cp_total; /* centipercent total */
int ab_total; /* absolute block total */
int extra;
int i;
/*
* When SDMA is enabled, kernel context pio packet size is capped by
* "piothreshold". Reduce pio buffer allocation for kernel context by
* setting it to a fixed size. The allocation allows 3-deep buffering
* of the largest pio packets plus up to 128 bytes header, sufficient
* to maintain verbs performance.
*
* When SDMA is disabled, keep the default pooling allocation.
*/
if (HFI1_CAP_IS_KSET(SDMA)) {
u16 max_pkt_size = (piothreshold < PIO_THRESHOLD_CEILING) ?
piothreshold : PIO_THRESHOLD_CEILING;
sc_config_sizes[SC_KERNEL].size =
3 * (max_pkt_size + 128) / PIO_BLOCK_SIZE;
}
/*
* Step 0:
* - copy the centipercents/absolute sizes from the pool config
Annotation
- Immediate include surface: `linux/delay.h`, `hfi.h`, `qp.h`, `trace.h`.
- Detected declarations: `struct mem_pool_config`, `struct mem_pool_info`, `function __cm_reset`, `function pio_send_control`, `function wildcard_to_pool`, `function init_sc_pools_and_sizes`, `function init_send_contexts`, `function sc_hw_alloc`, `function sc_hw_free`, `function group_context`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.