--- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -252,6 +252,8 @@ static const struct flow_dissector_key f }, }; +static unsigned long bond_id_mask = 0xFFFFFFF0; /* QCA NSS ECM bonding support */ + static struct flow_dissector flow_keys_bonding __read_mostly; /*-------------------------- Forward declarations ---------------------------*/ @@ -4383,6 +4385,24 @@ static int bond_get_lowest_level_rcu(str } #endif +/* QCA NSS ECM bonding support */ +int bond_get_id(struct net_device *bond_dev) +{ + struct bonding *bond; + int bond_id = 0; + + if (!((bond_dev->priv_flags & IFF_BONDING) && + (bond_dev->flags & IFF_MASTER))) + return -EINVAL; + + bond = netdev_priv(bond_dev); + bond_id = bond->id; + + return bond_id; +} +EXPORT_SYMBOL(bond_get_id); +/* QCA NSS ECM bonding support */ + static void bond_get_stats(struct net_device *bond_dev, struct rtnl_link_stats64 *stats) { @@ -5795,6 +5815,11 @@ static void bond_destructor(struct net_d if (bond->rr_tx_counter) free_percpu(bond->rr_tx_counter); + + /* QCA NSS ECM bonding support */ + if (bond->id != (~0U)) + clear_bit(bond->id, &bond_id_mask); + /* QCA NSS ECM bonding support */ } void bond_setup(struct net_device *bond_dev) @@ -6358,6 +6383,14 @@ int bond_create(struct net *net, const c bond_work_init_all(bond); + /* QCA NSS ECM bonding support - Start */ + bond->id = ~0U; + if (bond_id_mask != (~0UL)) { + bond->id = (u32)ffz(bond_id_mask); + set_bit(bond->id, &bond_id_mask); + } + /* QCA NSS ECM bonding support - End */ + out: rtnl_unlock(); return res; --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -265,6 +265,7 @@ struct bonding { spinlock_t ipsec_lock; #endif /* CONFIG_XFRM_OFFLOAD */ struct bpf_prog *xdp_prog; + u32 id; /* QCA NSS ECM bonding support */ }; #define bond_slave_get_rcu(dev) \ @@ -658,6 +659,7 @@ struct bond_net { int bond_rcv_validate(const struct sk_buff *skb, struct bonding *bond, struct slave *slave); netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); +int bond_get_id(struct net_device *bond_dev); /* QCA NSS ECM bonding support */ int bond_create(struct net *net, const char *name); int bond_create_sysfs(struct bond_net *net); void bond_destroy_sysfs(struct bond_net *net);