drivers/infiniband/core/roce_gid_mgmt.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/roce_gid_mgmt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/roce_gid_mgmt.c- Extension
.c- Size
- 25040 bytes
- Lines
- 950
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
core_priv.hlinux/in.hlinux/in6.hnet/addrconf.hnet/bonding.hrdma/ib_cache.hrdma/ib_addr.h
Detected Declarations
struct update_gid_event_workstruct netdev_event_work_cmdstruct netdev_event_workstruct sin_liststruct sin6_liststruct upper_listenum gid_op_typeenum bonding_slave_statefunction roce_gid_type_mask_supportfunction update_gidfunction is_eth_active_slave_of_bonding_rcufunction is_eth_port_of_netdev_filterfunction is_eth_port_inactive_slave_filterfunction is_ndev_for_default_gid_filterfunction pass_all_filterfunction upper_device_filterfunction is_upper_ndev_bond_master_filterfunction update_gid_ipfunction bond_delete_netdev_default_gidsfunction enum_netdev_ipv4_ipsfunction in_dev_for_each_ifa_rcufunction list_for_each_entry_safefunction enum_netdev_ipv6_ipsfunction list_for_each_entry_safefunction _add_netdev_ipsfunction add_netdev_ipsfunction del_netdev_ipsfunction del_default_gidsfunction add_default_gidsfunction enum_all_gids_of_dev_cbfunction for_each_netdevfunction rdma_roce_rescan_devicefunction rdma_roce_rescan_portfunction callback_for_addr_gid_device_scanfunction netdev_upper_walkfunction handle_netdev_upperfunction roce_del_all_netdev_gidsfunction del_netdev_upper_ipsfunction add_netdev_upper_ipsfunction del_netdev_default_ips_joinfunction netdevice_event_work_handlerfunction netdevice_queue_workfunction ndev_event_unlinkfunction ndev_event_linkfunction netdevice_event_changeupperfunction netdevice_eventfunction update_gid_event_work_handlerfunction addr_event
Annotated Snippet
struct update_gid_event_work {
struct work_struct work;
union ib_gid gid;
struct ib_gid_attr gid_attr;
enum gid_op_type gid_op;
};
#define ROCE_NETDEV_CALLBACK_SZ 3
struct netdev_event_work_cmd {
roce_netdev_callback cb;
roce_netdev_filter filter;
struct net_device *ndev;
struct net_device *filter_ndev;
};
struct netdev_event_work {
struct work_struct work;
struct netdev_event_work_cmd cmds[ROCE_NETDEV_CALLBACK_SZ];
};
static const struct {
bool (*is_supported)(const struct ib_device *device, u32 port_num);
enum ib_gid_type gid_type;
} PORT_CAP_TO_GID_TYPE[] = {
{rdma_protocol_roce_eth_encap, IB_GID_TYPE_ROCE},
{rdma_protocol_roce_udp_encap, IB_GID_TYPE_ROCE_UDP_ENCAP},
};
#define CAP_TO_GID_TABLE_SIZE ARRAY_SIZE(PORT_CAP_TO_GID_TYPE)
unsigned long roce_gid_type_mask_support(struct ib_device *ib_dev, u32 port)
{
int i;
unsigned int ret_flags = 0;
if (!rdma_protocol_roce(ib_dev, port))
return 1UL << IB_GID_TYPE_IB;
for (i = 0; i < CAP_TO_GID_TABLE_SIZE; i++)
if (PORT_CAP_TO_GID_TYPE[i].is_supported(ib_dev, port))
ret_flags |= 1UL << PORT_CAP_TO_GID_TYPE[i].gid_type;
return ret_flags;
}
EXPORT_SYMBOL(roce_gid_type_mask_support);
static void update_gid(enum gid_op_type gid_op, struct ib_device *ib_dev,
u32 port, union ib_gid *gid,
struct ib_gid_attr *gid_attr)
{
int i;
unsigned long gid_type_mask = roce_gid_type_mask_support(ib_dev, port);
for (i = 0; i < IB_GID_TYPE_SIZE; i++) {
if ((1UL << i) & gid_type_mask) {
gid_attr->gid_type = i;
switch (gid_op) {
case GID_ADD:
ib_cache_gid_add(ib_dev, port,
gid, gid_attr);
break;
case GID_DEL:
ib_cache_gid_del(ib_dev, port,
gid, gid_attr);
break;
}
}
}
}
enum bonding_slave_state {
BONDING_SLAVE_STATE_ACTIVE = 1UL << 0,
BONDING_SLAVE_STATE_INACTIVE = 1UL << 1,
/* No primary slave or the device isn't a slave in bonding */
BONDING_SLAVE_STATE_NA = 1UL << 2,
};
static enum bonding_slave_state is_eth_active_slave_of_bonding_rcu(struct net_device *dev,
struct net_device *upper)
{
if (upper && netif_is_bond_master(upper)) {
struct net_device *pdev =
bond_option_active_slave_get_rcu(netdev_priv(upper));
if (pdev)
return dev == pdev ? BONDING_SLAVE_STATE_ACTIVE :
BONDING_SLAVE_STATE_INACTIVE;
}
return BONDING_SLAVE_STATE_NA;
Annotation
- Immediate include surface: `core_priv.h`, `linux/in.h`, `linux/in6.h`, `net/addrconf.h`, `net/bonding.h`, `rdma/ib_cache.h`, `rdma/ib_addr.h`.
- Detected declarations: `struct update_gid_event_work`, `struct netdev_event_work_cmd`, `struct netdev_event_work`, `struct sin_list`, `struct sin6_list`, `struct upper_list`, `enum gid_op_type`, `enum bonding_slave_state`, `function roce_gid_type_mask_support`, `function update_gid`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: integration 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.