Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef _NET_BOND_ALB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define _NET_BOND_ALB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/if_ether.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) struct bonding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) struct slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define BOND_ALB_INFO(bond)   ((bond)->alb_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define SLAVE_TLB_INFO(slave) ((slave)->tlb_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define ALB_TIMER_TICKS_PER_SEC	    10	/* should be a divisor of HZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define BOND_TLB_REBALANCE_INTERVAL 10	/* In seconds, periodic re-balancing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 					 * Used for division - never set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 					 * to zero !!!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define BOND_ALB_DEFAULT_LP_INTERVAL 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval)	/* In seconds, periodic send of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 								 * learning packets to the switch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 								 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 				  * ALB_TIMER_TICKS_PER_SEC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 			   * ALB_TIMER_TICKS_PER_SEC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 				 * Note that this value MUST NOT be smaller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 				 * because the key hash table is BYTE wide !
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define TLB_NULL_INDEX		0xffffffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /* rlb defs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define RLB_HASH_TABLE_SIZE	256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define RLB_NULL_INDEX		0xffffffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define RLB_UPDATE_DELAY	(2*ALB_TIMER_TICKS_PER_SEC) /* 2 seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define RLB_ARP_BURST_SIZE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define RLB_UPDATE_RETRY	3 /* 3-ticks - must be smaller than the rlb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 				   * rebalance interval (5 min).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 				   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * promiscuous after failover
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define RLB_PROMISC_TIMEOUT	(10*ALB_TIMER_TICKS_PER_SEC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) struct tlb_client_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct slave *tx_slave;	/* A pointer to slave used for transmiting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 				 * packets to a Client that the Hash function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				 * gave this entry index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	u32 tx_bytes;		/* Each Client accumulates the BytesTx that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 				 * were transmitted to it, and after each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 				 * CallBack the LoadHistory is divided
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 				 * by the balance interval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u32 load_history;	/* This field contains the amount of Bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 				 * that were transmitted to this client by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 				 * the server on the previous balance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 				 * interval in Bps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	u32 next;		/* The next Hash table entry index, assigned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 				 * to use the same adapter for transmit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	u32 prev;		/* The previous Hash table entry index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 				 * assigned to use the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) /* -------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * struct rlb_client_info contains all info related to a specific rx client
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * connection. This is the Clients Hash Table entry struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * Note that this is not a proper hash table; if a new client's IP address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * hash collides with an existing client entry, the old entry is replaced.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * There is a linked list (linked by the used_next and used_prev members)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * linking all the used entries of the hash table. This allows updating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * all the clients without walking over all the unused elements of the table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * There are also linked lists of entries with identical hash(ip_src). These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * allow cleaning up the table from ip_src<->mac_src associations that have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * become outdated and would cause sending out invalid ARP updates to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * network. These are linked by the (src_next and src_prev members).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * -------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) struct rlb_client_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	__be32 ip_src;		/* the server IP address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	__be32 ip_dst;		/* the client IP address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	u8  mac_src[ETH_ALEN];	/* the server MAC address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	u8  mac_dst[ETH_ALEN];	/* the client MAC address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	/* list of used hash table entries, starting at rx_hashtbl_used_head */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	u32 used_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	u32 used_prev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	/* ip_src based hashing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	u32 src_next;	/* next entry with same hash(ip_src) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	u32 src_prev;	/* prev entry with same hash(ip_src) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	u32 src_first;	/* first entry with hash(ip_src) == this entry's index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	u8  assigned;		/* checking whether this entry is assigned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	u8  ntt;		/* flag - need to transmit client info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	struct slave *slave;	/* the slave assigned to this client */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	unsigned short vlan_id;	/* VLAN tag associated with IP address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct tlb_slave_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	u32 head;	/* Index to the head of the bi-directional clients
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			 * hash table entries list. The entries in the list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			 * are the entries that were assigned to use this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			 * slave for transmit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	u32 load;	/* Each slave sums the loadHistory of all clients
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			 * assigned to it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct alb_bond_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct tlb_client_info	*tx_hashtbl; /* Dynamically allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	u32			unbalanced_load;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	atomic_t		tx_rebalance_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	int			lp_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	/* -------- rlb parameters -------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	int rlb_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	struct rlb_client_info	*rx_hashtbl;	/* Receive hash table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	u32			rx_hashtbl_used_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	u8			rx_ntt;	/* flag - need to transmit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 					 * to all rx clients
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	struct slave		*rx_slave;/* last slave to xmit from */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	u8			primary_is_promisc;	   /* boolean */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	u32			rlb_promisc_timeout_counter;/* counts primary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 							     * promiscuity time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 							     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	u32			rlb_update_delay_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	u32			rlb_update_retry_counter;/* counter of retries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 							  * of client update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 							  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	u8			rlb_rebalance;	/* flag - indicates that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 						 * rx traffic should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 						 * rebalanced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 						 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) int bond_alb_initialize(struct bonding *bond, int rlb_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) void bond_alb_deinitialize(struct bonding *bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) int bond_alb_init_slave(struct bonding *bond, struct slave *slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) int bond_tlb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct slave *bond_xmit_alb_slave_get(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				      struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct slave *bond_xmit_tlb_slave_get(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				      struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) void bond_alb_monitor(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #endif /* _NET_BOND_ALB_H */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)