fs/smb/smbdirect/devices.c
Source file repositories/reference/linux-study-clean/fs/smb/smbdirect/devices.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/smbdirect/devices.c- Extension
.c- Size
- 7012 bytes
- Lines
- 278
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
internal.h
Detected Declarations
function Copyrightfunction smbdirect_ib_client_addfunction rdma_for_each_portfunction smbdirect_ib_client_removefunction smbdirect_ib_client_renamefunction smbdirect_netdev_find_rdma_capable_node_typefunction rdma_for_each_portfunction RoCEfunction netdev_for_each_lower_devfunction smbdirect_devices_initfunction smbdirect_devices_exitexport smbdirect_netdev_rdma_capable_node_type
Annotated Snippet
if (sdev->ib_dev == ib_dev) {
list_del(&sdev->list);
pr_info("ib_dev[%.*s] removed\n",
IB_DEVICE_NAME_MAX, sdev->ib_name);
kfree(sdev);
break;
}
}
write_unlock(&smbdirect_globals.devices.lock);
}
static void smbdirect_ib_client_rename(struct ib_device *ib_dev, void *client_data)
{
struct smbdirect_device *sdev;
write_lock(&smbdirect_globals.devices.lock);
list_for_each_entry(sdev, &smbdirect_globals.devices.list, list) {
if (sdev->ib_dev == ib_dev) {
pr_info("ib_dev[%.*s] renamed to [%.*s]\n",
IB_DEVICE_NAME_MAX, sdev->ib_name,
IB_DEVICE_NAME_MAX, ib_dev->name);
snprintf(sdev->ib_name, ARRAY_SIZE(sdev->ib_name), "%.*s",
IB_DEVICE_NAME_MAX, ib_dev->name);
break;
}
}
write_unlock(&smbdirect_globals.devices.lock);
}
static struct ib_client smbdirect_ib_client = {
.name = "smbdirect_ib_client",
.add = smbdirect_ib_client_add,
.remove = smbdirect_ib_client_remove,
.rename = smbdirect_ib_client_rename,
};
static u8 smbdirect_netdev_find_rdma_capable_node_type(struct net_device *netdev)
{
struct smbdirect_device *sdev;
u8 node_type = RDMA_NODE_UNSPECIFIED;
read_lock(&smbdirect_globals.devices.lock);
list_for_each_entry(sdev, &smbdirect_globals.devices.list, list) {
u32 pi;
rdma_for_each_port(sdev->ib_dev, pi) {
struct net_device *ndev;
ndev = ib_device_get_netdev(sdev->ib_dev, pi);
if (!ndev)
continue;
if (ndev == netdev) {
dev_put(ndev);
node_type = sdev->ib_dev->node_type;
goto out;
}
dev_put(ndev);
}
}
out:
read_unlock(&smbdirect_globals.devices.lock);
if (node_type == RDMA_NODE_UNSPECIFIED) {
struct ib_device *ibdev;
ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_UNKNOWN);
if (ibdev) {
node_type = smbdirect_ib_device_rdma_capable_node_type(ibdev);
ib_device_put(ibdev);
}
}
return node_type;
}
/*
* Returns RDMA_NODE_UNSPECIFIED when the netdev has
* no support for smbdirect capable rdma.
*
* Otherwise RDMA_NODE_RNIC is returned for iwarp devices
* and RDMA_NODE_IB_CA or Infiniband and RoCE (v1 and v2)
*/
u8 smbdirect_netdev_rdma_capable_node_type(struct net_device *netdev)
{
struct net_device *lower_dev;
struct list_head *iter;
u8 node_type = RDMA_NODE_UNSPECIFIED;
node_type = smbdirect_netdev_find_rdma_capable_node_type(netdev);
Annotation
- Immediate include surface: `internal.h`.
- Detected declarations: `function Copyright`, `function smbdirect_ib_client_add`, `function rdma_for_each_port`, `function smbdirect_ib_client_remove`, `function smbdirect_ib_client_rename`, `function smbdirect_netdev_find_rdma_capable_node_type`, `function rdma_for_each_port`, `function RoCE`, `function netdev_for_each_lower_dev`, `function smbdirect_devices_init`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
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.