bond_alb.h 6.6 KB

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