drivers/scsi/elx/libefc/efclib.c
Source file repositories/reference/linux-study-clean/drivers/scsi/elx/libefc/efclib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/elx/libefc/efclib.c- Extension
.c- Size
- 2184 bytes
- Lines
- 82
- Domain
- Driver Families
- Bucket
- drivers/scsi
- 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
linux/module.hlinux/kernel.hefc.h
Detected Declarations
function Copyrightfunction efc_purge_pendingfunction list_for_each_entry_safefunction efcport_destroy
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021 Broadcom. All Rights Reserved. The term
* “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
*/
/*
* LIBEFC LOCKING
*
* The critical sections protected by the efc's spinlock are quite broad and
* may be improved upon in the future. The libefc code and its locking doesn't
* influence the I/O path, so excessive locking doesn't impact I/O performance.
*
* The strategy is to lock whenever processing a request from user driver. This
* means that the entry points into the libefc library are protected by efc
* lock. So all the state machine transitions are protected.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include "efc.h"
int efcport_init(struct efc *efc)
{
u32 rc = 0;
spin_lock_init(&efc->lock);
INIT_LIST_HEAD(&efc->vport_list);
efc->hold_frames = false;
spin_lock_init(&efc->pend_frames_lock);
INIT_LIST_HEAD(&efc->pend_frames);
/* Create Node pool */
efc->node_pool = mempool_create_kmalloc_pool(EFC_MAX_REMOTE_NODES,
sizeof(struct efc_node));
if (!efc->node_pool) {
efc_log_err(efc, "Can't allocate node pool\n");
return -ENOMEM;
}
efc->node_dma_pool = dma_pool_create("node_dma_pool", &efc->pci->dev,
NODE_SPARAMS_SIZE, 0, 0);
if (!efc->node_dma_pool) {
efc_log_err(efc, "Can't allocate node dma pool\n");
mempool_destroy(efc->node_pool);
return -ENOMEM;
}
efc->els_io_pool = mempool_create_kmalloc_pool(EFC_ELS_IO_POOL_SZ,
sizeof(struct efc_els_io_req));
if (!efc->els_io_pool) {
efc_log_err(efc, "Can't allocate els io pool\n");
return -ENOMEM;
}
return rc;
}
static void
efc_purge_pending(struct efc *efc)
{
struct efc_hw_sequence *frame, *next;
unsigned long flags = 0;
spin_lock_irqsave(&efc->pend_frames_lock, flags);
list_for_each_entry_safe(frame, next, &efc->pend_frames, list_entry) {
list_del(&frame->list_entry);
efc->tt.hw_seq_free(efc, frame);
}
spin_unlock_irqrestore(&efc->pend_frames_lock, flags);
}
void efcport_destroy(struct efc *efc)
{
efc_purge_pending(efc);
mempool_destroy(efc->els_io_pool);
mempool_destroy(efc->node_pool);
dma_pool_destroy(efc->node_dma_pool);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `efc.h`.
- Detected declarations: `function Copyright`, `function efc_purge_pending`, `function list_for_each_entry_safe`, `function efcport_destroy`.
- Atlas domain: Driver Families / drivers/scsi.
- 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.