--- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -249,6 +249,9 @@ static const struct flow_dissector_key f }, }; +/* QCA NSS bonding support */ +static unsigned long bond_id_mask = 0xFFFFFFF0; + static struct flow_dissector flow_keys_bonding __read_mostly; /*-------------------------- Forward declarations ---------------------------*/ @@ -4099,6 +4102,23 @@ static int bond_get_lowest_level_rcu(str } #endif +/* QCA NSS 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); + static void bond_get_stats(struct net_device *bond_dev, struct rtnl_link_stats64 *stats) { @@ -5431,6 +5451,10 @@ static void bond_destructor(struct net_d if (bond->rr_tx_counter) free_percpu(bond->rr_tx_counter); + + /* QCA NSS bonding support */ + if (bond->id != (~0U)) + clear_bit(bond->id, &bond_id_mask); } void bond_setup(struct net_device *bond_dev) @@ -5999,7 +6023,14 @@ int bond_create(struct net *net, const c bond_work_init_all(bond); - rtnl_unlock(); + /* QCA NSS bonding support */ + bond->id = ~0U; + if (bond_id_mask != (~0UL)) { + bond->id = (u32)ffz(bond_id_mask); + set_bit(bond->id, &bond_id_mask); + } + + rtnl_unlock(); return 0; } --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -255,6 +255,7 @@ struct bonding { spinlock_t ipsec_lock; #endif /* CONFIG_XFRM_OFFLOAD */ struct bpf_prog *xdp_prog; + u32 id; /* QCA NSS bonding */ }; #define bond_slave_get_rcu(dev) \ @@ -629,6 +630,7 @@ struct bond_net { int bond_arp_rcv(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 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);