drivers/net/bonding/bond_alb.c
Source file repositories/reference/linux-study-clean/drivers/net/bonding/bond_alb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/bonding/bond_alb.c- Extension
.c- Size
- 50220 bytes
- Lines
- 1836
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/skbuff.hlinux/netdevice.hlinux/etherdevice.hlinux/pkt_sched.hlinux/spinlock.hlinux/slab.hlinux/timer.hlinux/ip.hlinux/ipv6.hlinux/if_arp.hlinux/if_ether.hlinux/if_bonding.hlinux/if_vlan.hlinux/in.hnet/arp.hnet/ipv6.hnet/ndisc.hasm/byteorder.hnet/bonding.hnet/bond_alb.h
Detected Declarations
struct learning_pktstruct arp_pktstruct alb_walk_datafunction _simple_hashfunction tlb_init_table_entryfunction tlb_init_slavefunction __tlb_clear_slavefunction tlb_clear_slavefunction tlb_initializefunction tlb_deinitializefunction compute_gapfunction rlb_update_entry_from_arpfunction rlb_arp_recvfunction bond_for_each_slave_rcufunction rlb_teach_disabled_mac_on_primaryfunction rlb_clear_slavefunction rlb_update_clientfunction rlb_update_rx_clientsfunction rlb_req_update_slave_clientsfunction rlb_req_update_subnet_clientsfunction primaryfunction rlb_rebalancefunction rlb_init_table_entry_dstfunction rlb_init_table_entry_srcfunction rlb_init_table_entryfunction rlb_delete_table_entry_dstfunction rlb_src_unlinkfunction rlb_delete_table_entryfunction rlb_src_linkfunction rlb_purge_src_ipfunction rlb_initializefunction rlb_deinitializefunction rlb_clear_vlanfunction alb_send_lp_vidfunction alb_upper_dev_walkfunction alb_send_learning_packetsfunction alb_set_slave_mac_addrfunction alb_swap_mac_addrfunction alb_fasten_mac_swapfunction alb_change_hw_addr_on_detachfunction alb_handle_addr_collision_on_attachfunction addressesfunction bond_for_each_slavefunction alb_determine_ndfunction bond_alb_initializefunction bond_alb_deinitializefunction bond_do_alb_xmitfunction bond_tlb_xmit
Annotated Snippet
struct learning_pkt {
u8 mac_dst[ETH_ALEN];
u8 mac_src[ETH_ALEN];
__be16 type;
u8 padding[ETH_ZLEN - ETH_HLEN];
};
struct arp_pkt {
__be16 hw_addr_space;
__be16 prot_addr_space;
u8 hw_addr_len;
u8 prot_addr_len;
__be16 op_code;
u8 mac_src[ETH_ALEN]; /* sender hardware address */
__be32 ip_src; /* sender IP address */
u8 mac_dst[ETH_ALEN]; /* target hardware address */
__be32 ip_dst; /* target IP address */
};
#pragma pack()
/* Forward declaration */
static void alb_send_learning_packets(struct slave *slave, const u8 mac_addr[],
bool strict_match);
static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp);
static void rlb_src_unlink(struct bonding *bond, u32 index);
static void rlb_src_link(struct bonding *bond, u32 ip_src_hash,
u32 ip_dst_hash);
static inline u8 _simple_hash(const u8 *hash_start, int hash_size)
{
int i;
u8 hash = 0;
for (i = 0; i < hash_size; i++)
hash ^= hash_start[i];
return hash;
}
/*********************** tlb specific functions ***************************/
static inline void tlb_init_table_entry(struct tlb_client_info *entry, int save_load)
{
if (save_load) {
entry->load_history = 1 + entry->tx_bytes /
BOND_TLB_REBALANCE_INTERVAL;
entry->tx_bytes = 0;
}
entry->tx_slave = NULL;
entry->next = TLB_NULL_INDEX;
entry->prev = TLB_NULL_INDEX;
}
static inline void tlb_init_slave(struct slave *slave)
{
SLAVE_TLB_INFO(slave).load = 0;
SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX;
}
static void __tlb_clear_slave(struct bonding *bond, struct slave *slave,
int save_load)
{
struct tlb_client_info *tx_hash_table;
u32 index;
/* clear slave from tx_hashtbl */
tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl;
/* skip this if we've already freed the tx hash table */
if (tx_hash_table) {
index = SLAVE_TLB_INFO(slave).head;
while (index != TLB_NULL_INDEX) {
u32 next_index = tx_hash_table[index].next;
tlb_init_table_entry(&tx_hash_table[index], save_load);
index = next_index;
}
}
tlb_init_slave(slave);
}
static void tlb_clear_slave(struct bonding *bond, struct slave *slave,
int save_load)
{
spin_lock_bh(&bond->mode_lock);
__tlb_clear_slave(bond, slave, save_load);
spin_unlock_bh(&bond->mode_lock);
}
Annotation
- Immediate include surface: `linux/skbuff.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/pkt_sched.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/timer.h`, `linux/ip.h`.
- Detected declarations: `struct learning_pkt`, `struct arp_pkt`, `struct alb_walk_data`, `function _simple_hash`, `function tlb_init_table_entry`, `function tlb_init_slave`, `function __tlb_clear_slave`, `function tlb_clear_slave`, `function tlb_initialize`, `function tlb_deinitialize`.
- Atlas domain: Driver Families / drivers/net.
- 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.