drivers/ntb/ntb_transport.c
Source file repositories/reference/linux-study-clean/drivers/ntb/ntb_transport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ntb/ntb_transport.c- Extension
.c- Size
- 64340 bytes
- Lines
- 2569
- Domain
- Driver Families
- Bucket
- drivers/ntb
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/debugfs.hlinux/delay.hlinux/dmaengine.hlinux/dma-mapping.hlinux/errno.hlinux/export.hlinux/interrupt.hlinux/kthread.hlinux/module.hlinux/pci.hlinux/slab.hlinux/seq_file.hlinux/types.hlinux/uaccess.hlinux/mutex.hlinux/wait.hlinux/ntb.hlinux/ntb_transport.h
Detected Declarations
struct ntb_queue_entrystruct ntb_rx_infostruct ntb_transport_qpstruct ntb_transport_mwstruct ntb_transport_client_devstruct ntb_transport_ctxstruct ntb_payload_headerfunction ntb_tx_offload_enabledfunction ntb_transport_bus_matchfunction ntb_transport_bus_probefunction ntb_transport_bus_removefunction ntb_bus_initfunction ntb_bus_removefunction list_for_each_entry_safefunction ntb_transport_client_releasefunction ntb_transport_unregister_client_devfunction list_for_each_entryfunction ntb_transport_register_client_devfunction list_for_each_entryfunction ntb_transport_register_clientfunction ntb_transport_unregister_clientfunction ntb_qp_debugfs_stats_showfunction ntb_list_addfunction ntb_transport_setup_qp_mwfunction ntb_transport_isrfunction ntb_transport_setup_qp_peer_msifunction ntb_transport_setup_qp_msifunction ntb_transport_msi_peer_desc_changedfunction ntb_transport_msi_desc_changedfunction ntb_free_mwfunction ntb_alloc_mw_bufferfunction ntb_set_mwfunction ntb_qp_link_context_resetfunction ntb_qp_link_down_resetfunction ntb_qp_link_cleanupfunction ntb_qp_link_cleanup_workfunction ntb_qp_link_downfunction ntb_transport_link_cleanupfunction ntb_transport_link_cleanup_workfunction ntb_transport_event_callbackfunction ntb_transport_link_workfunction ntb_qp_link_workfunction ntb_transport_init_queuefunction ntb_transport_probefunction ntb_transport_freefunction ntb_complete_rxcfunction ntb_rx_copy_callbackfunction ntb_memcpy_rx
Annotated Snippet
const struct device_driver *drv)
{
return !strncmp(dev_name(dev), drv->name, strlen(drv->name));
}
static int ntb_transport_bus_probe(struct device *dev)
{
const struct ntb_transport_client *client;
int rc;
get_device(dev);
client = drv_client(dev->driver);
rc = client->probe(dev);
if (rc)
put_device(dev);
return rc;
}
static void ntb_transport_bus_remove(struct device *dev)
{
const struct ntb_transport_client *client;
client = drv_client(dev->driver);
client->remove(dev);
put_device(dev);
}
static const struct bus_type ntb_transport_bus = {
.name = "ntb_transport",
.match = ntb_transport_bus_match,
.probe = ntb_transport_bus_probe,
.remove = ntb_transport_bus_remove,
};
static LIST_HEAD(ntb_transport_list);
static int ntb_bus_init(struct ntb_transport_ctx *nt)
{
list_add_tail(&nt->entry, &ntb_transport_list);
return 0;
}
static void ntb_bus_remove(struct ntb_transport_ctx *nt)
{
struct ntb_transport_client_dev *client_dev, *cd;
list_for_each_entry_safe(client_dev, cd, &nt->client_devs, entry) {
dev_err(client_dev->dev.parent, "%s still attached to bus, removing\n",
dev_name(&client_dev->dev));
list_del(&client_dev->entry);
device_unregister(&client_dev->dev);
}
list_del(&nt->entry);
}
static void ntb_transport_client_release(struct device *dev)
{
struct ntb_transport_client_dev *client_dev;
client_dev = dev_client_dev(dev);
kfree(client_dev);
}
/**
* ntb_transport_unregister_client_dev - Unregister NTB client device
* @device_name: Name of NTB client device
*
* Unregister an NTB client device with the NTB transport layer
*/
void ntb_transport_unregister_client_dev(char *device_name)
{
struct ntb_transport_client_dev *client, *cd;
struct ntb_transport_ctx *nt;
list_for_each_entry(nt, &ntb_transport_list, entry)
list_for_each_entry_safe(client, cd, &nt->client_devs, entry)
if (!strncmp(dev_name(&client->dev), device_name,
strlen(device_name))) {
list_del(&client->entry);
device_unregister(&client->dev);
}
}
EXPORT_SYMBOL_GPL(ntb_transport_unregister_client_dev);
/**
* ntb_transport_register_client_dev - Register NTB client device
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/errno.h`, `linux/export.h`, `linux/interrupt.h`, `linux/kthread.h`.
- Detected declarations: `struct ntb_queue_entry`, `struct ntb_rx_info`, `struct ntb_transport_qp`, `struct ntb_transport_mw`, `struct ntb_transport_client_dev`, `struct ntb_transport_ctx`, `struct ntb_payload_header`, `function ntb_tx_offload_enabled`, `function ntb_transport_bus_match`, `function ntb_transport_bus_probe`.
- Atlas domain: Driver Families / drivers/ntb.
- Implementation status: pattern 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.