linux/include/net/bonding.h

/* SPDX-License-Identifier: GPL-1.0+ */
/*
 * Bond several ethernet interfaces into a Cisco, running 'Etherchannel'.
 *
 * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
 * NCM: Network and Communications Management, Inc.
 *
 * BUT, I'm the one who modified it for ethernet, so:
 * (c) Copyright 1999, Thomas Davis, [email protected]
 *
 */

#ifndef _NET_BONDING_H
#define _NET_BONDING_H

#include <linux/timer.h>
#include <linux/proc_fs.h>
#include <linux/if_bonding.h>
#include <linux/cpumask.h>
#include <linux/in6.h>
#include <linux/netpoll.h>
#include <linux/inetdevice.h>
#include <linux/etherdevice.h>
#include <linux/reciprocal_div.h>
#include <linux/if_link.h>

#include <net/bond_3ad.h>
#include <net/bond_alb.h>
#include <net/bond_options.h>
#include <net/ipv6.h>
#include <net/addrconf.h>

#define BOND_MAX_ARP_TARGETS
#define BOND_MAX_NS_TARGETS

#define BOND_DEFAULT_MIIMON

#ifndef __long_aligned
#define __long_aligned
#endif

#define slave_info(bond_dev, slave_dev, fmt, ...)
#define slave_warn(bond_dev, slave_dev, fmt, ...)
#define slave_dbg(bond_dev, slave_dev, fmt, ...)
#define slave_err(bond_dev, slave_dev, fmt, ...)

#define BOND_MODE(bond)

/* slave list primitives */
#define bond_slave_list(bond)

#define bond_has_slaves(bond)

/* IMPORTANT: bond_first/last_slave can return NULL in case of an empty list */
#define bond_first_slave(bond)
#define bond_last_slave(bond)

/* Caller must have rcu_read_lock */
#define bond_first_slave_rcu(bond)

#define bond_is_first_slave(bond, pos)
#define bond_is_last_slave(bond, pos)

/**
 * bond_for_each_slave - iterate over all slaves
 * @bond:	the bond holding this list
 * @pos:	current slave
 * @iter:	list_head * iterator
 *
 * Caller must hold RTNL
 */
#define bond_for_each_slave(bond, pos, iter)

/* Caller must have rcu_read_lock */
#define bond_for_each_slave_rcu(bond, pos, iter)

#define BOND_XFRM_FEATURES

#ifdef CONFIG_NET_POLL_CONTROLLER
extern atomic_t netpoll_block_tx;

static inline void block_netpoll_tx(void)
{}

static inline void unblock_netpoll_tx(void)
{}

static inline int is_netpoll_tx_blocked(struct net_device *dev)
{}
#else
#define block_netpoll_tx
#define unblock_netpoll_tx
#define is_netpoll_tx_blocked
#endif

struct bond_params {};

struct slave {};

static inline struct slave *to_slave(struct kobject *kobj)
{}

struct bond_up_slave {};

/*
 * Link pseudo-state only used internally by monitors
 */
#define BOND_LINK_NOCHANGE

struct bond_ipsec {};

/*
 * Here are the locking policies for the two bonding locks:
 * Get rcu_read_lock when reading or RTNL when writing slave list.
 */
struct bonding {};

#define bond_slave_get_rcu(dev)

#define bond_slave_get_rtnl(dev)

void bond_queue_slave_event(struct slave *slave);
void bond_lower_state_changed(struct slave *slave);

struct bond_vlan_tag {};

/*
 * Returns NULL if the net_device does not belong to any of the bond's slaves
 *
 * Caller must hold bond lock for read
 */
static inline struct slave *bond_get_slave_by_dev(struct bonding *bond,
						  struct net_device *slave_dev)
{}

static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
{}

static inline bool bond_should_override_tx_queue(struct bonding *bond)
{}

static inline bool bond_is_lb(const struct bonding *bond)
{}

static inline bool bond_needs_speed_duplex(const struct bonding *bond)
{}

static inline bool bond_is_nondyn_tlb(const struct bonding *bond)
{}

static inline bool bond_mode_can_use_xmit_hash(const struct bonding *bond)
{}

static inline bool bond_mode_uses_xmit_hash(const struct bonding *bond)
{}

static inline bool bond_mode_uses_arp(int mode)
{}

static inline bool bond_mode_uses_primary(int mode)
{}

static inline bool bond_uses_primary(struct bonding *bond)
{}

static inline struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond)
{}

static inline bool bond_slave_is_up(struct slave *slave)
{}

static inline void bond_set_active_slave(struct slave *slave)
{}

static inline void bond_set_backup_slave(struct slave *slave)
{}

static inline void bond_set_slave_state(struct slave *slave,
					int slave_state, bool notify)
{}

static inline void bond_slave_state_change(struct bonding *bond)
{}

static inline void bond_slave_state_notify(struct bonding *bond)
{}

static inline int bond_slave_state(struct slave *slave)
{}

static inline bool bond_is_active_slave(struct slave *slave)
{}

static inline bool bond_slave_can_tx(struct slave *slave)
{}

static inline bool bond_is_active_slave_dev(const struct net_device *slave_dev)
{}

static inline void bond_hw_addr_copy(u8 *dst, const u8 *src, unsigned int len)
{}

#define BOND_PRI_RESELECT_ALWAYS
#define BOND_PRI_RESELECT_BETTER
#define BOND_PRI_RESELECT_FAILURE

#define BOND_FOM_NONE
#define BOND_FOM_ACTIVE
#define BOND_FOM_FOLLOW

#define BOND_ARP_TARGETS_ANY
#define BOND_ARP_TARGETS_ALL

#define BOND_ARP_VALIDATE_NONE
#define BOND_ARP_VALIDATE_ACTIVE
#define BOND_ARP_VALIDATE_BACKUP
#define BOND_ARP_VALIDATE_ALL
#define BOND_ARP_FILTER
#define BOND_ARP_FILTER_ACTIVE
#define BOND_ARP_FILTER_BACKUP

#define BOND_SLAVE_NOTIFY_NOW
#define BOND_SLAVE_NOTIFY_LATER

static inline int slave_do_arp_validate(struct bonding *bond,
					struct slave *slave)
{}

static inline int slave_do_arp_validate_only(struct bonding *bond)
{}

static inline int bond_is_ip_target_ok(__be32 addr)
{}

#if IS_ENABLED(CONFIG_IPV6)
static inline int bond_is_ip6_target_ok(struct in6_addr *addr)
{}
#endif

/* Get the oldest arp which we've received on this slave for bond's
 * arp_targets.
 */
static inline unsigned long slave_oldest_target_arp_rx(struct bonding *bond,
						       struct slave *slave)
{}

static inline unsigned long slave_last_rx(struct bonding *bond,
					struct slave *slave)
{}

static inline void slave_update_last_tx(struct slave *slave)
{}

static inline unsigned long slave_last_tx(struct slave *slave)
{}

#ifdef CONFIG_NET_POLL_CONTROLLER
static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave,
					 struct sk_buff *skb)
{}
#else
static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave,
					 struct sk_buff *skb)
{
	BUG();
	return NETDEV_TX_OK;
}
#endif

static inline void bond_set_slave_inactive_flags(struct slave *slave,
						 bool notify)
{}

static inline void bond_set_slave_tx_disabled_flags(struct slave *slave,
						 bool notify)
{}

static inline void bond_set_slave_active_flags(struct slave *slave,
					       bool notify)
{}

static inline void bond_set_slave_rx_enabled_flags(struct slave *slave,
					       bool notify)
{}

static inline bool bond_is_slave_inactive(struct slave *slave)
{}

static inline bool bond_is_slave_rx_disabled(struct slave *slave)
{}

static inline void bond_propose_link_state(struct slave *slave, int state)
{}

static inline void bond_commit_link_state(struct slave *slave, bool notify)
{}

static inline void bond_set_slave_link_state(struct slave *slave, int state,
					     bool notify)
{}

static inline void bond_slave_link_notify(struct bonding *bond)
{}

static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be32 local)
{}

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_create(struct net *net, const char *name);
int bond_create_sysfs(struct bond_net *net);
void bond_destroy_sysfs(struct bond_net *net);
void bond_prepare_sysfs_group(struct bonding *bond);
int bond_sysfs_slave_add(struct slave *slave);
void bond_sysfs_slave_del(struct slave *slave);
void bond_xdp_set_features(struct net_device *bond_dev);
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
		 struct netlink_ext_ack *extack);
int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb);
int bond_set_carrier(struct bonding *bond);
void bond_select_active_slave(struct bonding *bond);
void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
void bond_create_debugfs(void);
void bond_destroy_debugfs(void);
void bond_debug_register(struct bonding *bond);
void bond_debug_unregister(struct bonding *bond);
void bond_debug_reregister(struct bonding *bond);
const char *bond_mode_name(int mode);
void bond_setup(struct net_device *bond_dev);
unsigned int bond_get_num_tx_queues(void);
int bond_netlink_init(void);
void bond_netlink_fini(void);
struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
const char *bond_slave_link_status(s8 link);
struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev,
					      struct net_device *end_dev,
					      int level);
int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave);
void bond_slave_arr_work_rearm(struct bonding *bond, unsigned long delay);
void bond_work_init_all(struct bonding *bond);

#ifdef CONFIG_PROC_FS
void bond_create_proc_entry(struct bonding *bond);
void bond_remove_proc_entry(struct bonding *bond);
void bond_create_proc_dir(struct bond_net *bn);
void bond_destroy_proc_dir(struct bond_net *bn);
#else
static inline void bond_create_proc_entry(struct bonding *bond)
{
}

static inline void bond_remove_proc_entry(struct bonding *bond)
{
}

static inline void bond_create_proc_dir(struct bond_net *bn)
{
}

static inline void bond_destroy_proc_dir(struct bond_net *bn)
{
}
#endif

static inline struct slave *bond_slave_has_mac(struct bonding *bond,
					       const u8 *mac)
{}

/* Caller must hold rcu_read_lock() for read */
static inline bool bond_slave_has_mac_rcu(struct bonding *bond, const u8 *mac)
{}

/* Check if the ip is present in arp ip list, or first free slot if ip == 0
 * Returns -1 if not found, index if found
 */
static inline int bond_get_targets_ip(__be32 *targets, __be32 ip)
{}

#if IS_ENABLED(CONFIG_IPV6)
static inline int bond_get_targets_ip6(struct in6_addr *targets, struct in6_addr *ip)
{}
#endif

/* exported from bond_main.c */
extern unsigned int bond_net_id;

/* exported from bond_netlink.c */
extern struct rtnl_link_ops bond_link_ops;

/* exported from bond_sysfs_slave.c */
extern const struct sysfs_ops slave_sysfs_ops;

/* exported from bond_3ad.c */
extern const u8 lacpdu_mcast_addr[];

static inline netdev_tx_t bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
{}

#endif /* _NET_BONDING_H */