drivers/net/ethernet/netronome/nfp/flower/lag_conf.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/flower/lag_conf.c- Extension
.c- Size
- 19139 bytes
- Lines
- 727
- 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
main.h
Detected Declarations
struct nfp_flower_cmsg_lag_configstruct nfp_fl_lag_groupenum nfp_fl_lag_batchfunction nfp_fl_get_next_pkt_numberfunction nfp_fl_increment_versionfunction nfp_fl_lag_group_createfunction nfp_fl_lag_find_group_for_master_with_lagfunction nfp_fl_lag_get_group_infofunction nfp_flower_lag_populate_pre_actionfunction nfp_flower_lag_get_info_from_netdevfunction nfp_flower_lag_get_output_idfunction nfp_fl_lag_config_groupfunction nfp_fl_lag_do_workfunction for_each_netdev_in_bond_rcufunction nfp_fl_lag_put_unprocessedfunction nfp_fl_send_unprocessedfunction nfp_flower_lag_unprocessed_msgfunction nfp_fl_lag_schedule_group_removefunction nfp_fl_lag_schedule_group_deletefunction nfp_fl_lag_changeupper_eventfunction nfp_fl_lag_changels_eventfunction nfp_flower_lag_netdev_eventfunction nfp_flower_lag_resetfunction nfp_flower_lag_initfunction nfp_flower_lag_cleanup
Annotated Snippet
struct nfp_flower_cmsg_lag_config {
u8 ctrl_flags;
u8 reserved[2];
u8 ttl;
__be32 pkt_number;
__be32 batch_ver;
__be32 group_id;
__be32 group_inst;
__be32 members[];
};
/**
* struct nfp_fl_lag_group - list entry for each LAG group
* @group_id: Assigned group ID for host/kernel sync
* @group_inst: Group instance in case of ID reuse
* @list: List entry
* @master_ndev: Group master Netdev
* @dirty: Marked if the group needs synced to HW
* @offloaded: Marked if the group is currently offloaded to NIC
* @to_remove: Marked if the group should be removed from NIC
* @to_destroy: Marked if the group should be removed from driver
* @slave_cnt: Number of slaves in group
*/
struct nfp_fl_lag_group {
unsigned int group_id;
u8 group_inst;
struct list_head list;
struct net_device *master_ndev;
bool dirty;
bool offloaded;
bool to_remove;
bool to_destroy;
unsigned int slave_cnt;
};
#define NFP_FL_LAG_PKT_NUMBER_MASK GENMASK(30, 0)
#define NFP_FL_LAG_VERSION_MASK GENMASK(22, 0)
#define NFP_FL_LAG_HOST_TTL 0xff
/* Use this ID with zero members to ack a batch config */
#define NFP_FL_LAG_SYNC_ID 0
#define NFP_FL_LAG_GROUP_MIN 1 /* ID 0 reserved */
#define NFP_FL_LAG_GROUP_MAX 31 /* IDs 1 to 31 are valid */
/* wait for more config */
#define NFP_FL_LAG_DELAY (msecs_to_jiffies(2))
#define NFP_FL_LAG_RETRANS_LIMIT 100 /* max retrans cmsgs to store */
static unsigned int nfp_fl_get_next_pkt_number(struct nfp_fl_lag *lag)
{
lag->pkt_num++;
lag->pkt_num &= NFP_FL_LAG_PKT_NUMBER_MASK;
return lag->pkt_num;
}
static void nfp_fl_increment_version(struct nfp_fl_lag *lag)
{
/* LSB is not considered by firmware so add 2 for each increment. */
lag->batch_ver += 2;
lag->batch_ver &= NFP_FL_LAG_VERSION_MASK;
/* Zero is reserved by firmware. */
if (!lag->batch_ver)
lag->batch_ver += 2;
}
static struct nfp_fl_lag_group *
nfp_fl_lag_group_create(struct nfp_fl_lag *lag, struct net_device *master)
{
struct nfp_fl_lag_group *group;
struct nfp_flower_priv *priv;
int id;
priv = container_of(lag, struct nfp_flower_priv, nfp_lag);
id = ida_alloc_range(&lag->ida_handle, NFP_FL_LAG_GROUP_MIN,
NFP_FL_LAG_GROUP_MAX, GFP_KERNEL);
if (id < 0) {
nfp_flower_cmsg_warn(priv->app,
"No more bonding groups available\n");
return ERR_PTR(id);
}
group = kmalloc_obj(*group);
if (!group) {
ida_free(&lag->ida_handle, id);
return ERR_PTR(-ENOMEM);
}
Annotation
- Immediate include surface: `main.h`.
- Detected declarations: `struct nfp_flower_cmsg_lag_config`, `struct nfp_fl_lag_group`, `enum nfp_fl_lag_batch`, `function nfp_fl_get_next_pkt_number`, `function nfp_fl_increment_version`, `function nfp_fl_lag_group_create`, `function nfp_fl_lag_find_group_for_master_with_lag`, `function nfp_fl_lag_get_group_info`, `function nfp_flower_lag_populate_pre_action`, `function nfp_flower_lag_get_info_from_netdev`.
- 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.