drivers/ntb/hw/idt/ntb_hw_idt.c
Source file repositories/reference/linux-study-clean/drivers/ntb/hw/idt/ntb_hw_idt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ntb/hw/idt/ntb_hw_idt.c- Extension
.c- Size
- 91926 bytes
- Lines
- 2914
- 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/stddef.hlinux/types.hlinux/kernel.hlinux/bitops.hlinux/sizes.hlinux/module.hlinux/moduleparam.hlinux/init.hlinux/interrupt.hlinux/spinlock.hlinux/mutex.hlinux/pci.hlinux/aer.hlinux/slab.hlinux/list.hlinux/debugfs.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/ntb.hntb_hw_idt.h
Detected Declarations
function idt_nt_writefunction idt_nt_readfunction idt_sw_writefunction idt_sw_readfunction idt_reg_set_bitsfunction idt_reg_clear_bitsfunction idt_scan_portsfunction idt_ntb_port_numberfunction idt_ntb_peer_port_countfunction idt_ntb_peer_port_numberfunction idt_ntb_peer_port_idxfunction idt_init_linkfunction idt_deinit_linkfunction idt_se_isrfunction idt_ntb_local_link_enablefunction idt_ntb_local_link_disablefunction idt_ntb_local_link_is_upfunction idt_ntb_peer_link_is_upfunction idt_ntb_link_is_upfunction idt_ntb_link_enablefunction idt_ntb_link_disablefunction idt_get_mw_countfunction idt_get_mw_namefunction idt_scan_mwsfunction idt_init_mwsfunction idt_ntb_mw_countfunction idt_ntb_mw_get_alignfunction idt_ntb_peer_mw_countfunction idt_ntb_peer_mw_get_addrfunction idt_ntb_peer_mw_set_transfunction idt_ntb_peer_mw_clear_transfunction idt_db_isrfunction idt_ntb_db_valid_maskfunction idt_ntb_db_readfunction idt_ntb_db_clearfunction idt_ntb_db_read_maskfunction idt_ntb_db_set_maskfunction idt_ntb_db_clear_maskfunction idt_ntb_peer_db_setfunction idt_init_msgfunction idt_msg_isrfunction idt_ntb_msg_countfunction idt_ntb_msg_inbitsfunction idt_ntb_msg_outbitsfunction idt_ntb_msg_read_stsfunction idt_ntb_msg_clear_stsfunction idt_ntb_msg_set_maskfunction idt_ntb_msg_clear_mask
Annotated Snippet
static const struct file_operations idt_dbgfs_info_ops = {
.owner = THIS_MODULE,
.open = simple_open,
.read = idt_dbgfs_info_read
};
/*
* idt_dbgfs_info_read() - DebugFS read info node callback
* @file: File node descriptor.
* @ubuf: User-space buffer to put data to
* @count: Size of the buffer
* @offp: Offset within the buffer
*/
static ssize_t idt_dbgfs_info_read(struct file *filp, char __user *ubuf,
size_t count, loff_t *offp)
{
struct idt_ntb_dev *ndev = filp->private_data;
unsigned char idx, pidx, cnt;
unsigned long irqflags, mdeg;
ssize_t ret = 0, off = 0;
enum ntb_speed speed;
enum ntb_width width;
char *strbuf;
size_t size;
u32 data;
/* Lets limit the buffer size the way the Intel/AMD drivers do */
size = min_t(size_t, count, 0x1000U);
/* Allocate the memory for the buffer */
strbuf = kmalloc(size, GFP_KERNEL);
if (strbuf == NULL)
return -ENOMEM;
/* Put the data into the string buffer */
off += scnprintf(strbuf + off, size - off,
"\n\t\tIDT NTB device Information:\n\n");
/* General local device configurations */
off += scnprintf(strbuf + off, size - off,
"Local Port %hhu, Partition %hhu\n", ndev->port, ndev->part);
/* Peer ports information */
off += scnprintf(strbuf + off, size - off, "Peers:\n");
for (idx = 0; idx < ndev->peer_cnt; idx++) {
off += scnprintf(strbuf + off, size - off,
"\t%hhu. Port %hhu, Partition %hhu\n",
idx, ndev->peers[idx].port, ndev->peers[idx].part);
}
/* Links status */
data = idt_ntb_link_is_up(&ndev->ntb, &speed, &width);
off += scnprintf(strbuf + off, size - off,
"NTB link status\t- 0x%08x, ", data);
off += scnprintf(strbuf + off, size - off, "PCIe Gen %d x%d lanes\n",
speed, width);
/* Mapping table entries */
off += scnprintf(strbuf + off, size - off, "NTB Mapping Table:\n");
for (idx = 0; idx < IDT_MTBL_ENTRY_CNT; idx++) {
spin_lock_irqsave(&ndev->mtbl_lock, irqflags);
idt_nt_write(ndev, IDT_NT_NTMTBLADDR, idx);
data = idt_nt_read(ndev, IDT_NT_NTMTBLDATA);
spin_unlock_irqrestore(&ndev->mtbl_lock, irqflags);
/* Print valid entries only */
if (data & IDT_NTMTBLDATA_VALID) {
off += scnprintf(strbuf + off, size - off,
"\t%hhu. Partition %d, Requester ID 0x%04x\n",
idx, GET_FIELD(NTMTBLDATA_PART, data),
GET_FIELD(NTMTBLDATA_REQID, data));
}
}
off += scnprintf(strbuf + off, size - off, "\n");
/* Outbound memory windows information */
off += scnprintf(strbuf + off, size - off,
"Outbound Memory Windows:\n");
for (idx = 0; idx < ndev->mw_cnt; idx += cnt) {
data = ndev->mws[idx].type;
cnt = idt_get_mw_count(data);
/* Print Memory Window information */
if (data == IDT_MW_DIR)
off += scnprintf(strbuf + off, size - off,
"\t%hhu.\t", idx);
else
off += scnprintf(strbuf + off, size - off,
"\t%hhu-%d.\t", idx, idx + cnt - 1);
Annotation
- Immediate include surface: `linux/stddef.h`, `linux/types.h`, `linux/kernel.h`, `linux/bitops.h`, `linux/sizes.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`.
- Detected declarations: `function idt_nt_write`, `function idt_nt_read`, `function idt_sw_write`, `function idt_sw_read`, `function idt_reg_set_bits`, `function idt_reg_clear_bits`, `function idt_scan_ports`, `function idt_ntb_port_number`, `function idt_ntb_peer_port_count`, `function idt_ntb_peer_port_number`.
- 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.