bond_alb.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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, write to the Free Software Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. */
  22. #ifndef __BOND_ALB_H__
  23. #define __BOND_ALB_H__
  24. #include <linux/if_ether.h>
  25. struct bonding;
  26. struct slave;
  27. #define BOND_ALB_INFO(bond) ((bond)->alb_info)
  28. #define SLAVE_TLB_INFO(slave) ((slave)->tlb_info)
  29. #define ALB_TIMER_TICKS_PER_SEC 10 /* should be a divisor of HZ */
  30. #define BOND_TLB_REBALANCE_INTERVAL 10 /* In seconds, periodic re-balancing.
  31. * Used for division - never set
  32. * to zero !!!
  33. */
  34. #define BOND_ALB_LP_INTERVAL 1 /* 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_ALB_LP_INTERVAL \
  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. #define MAX_LP_BURST 3
  47. /* rlb defs */
  48. #define RLB_HASH_TABLE_SIZE 256
  49. #define RLB_NULL_INDEX 0xffffffff
  50. #define RLB_UPDATE_DELAY (2*ALB_TIMER_TICKS_PER_SEC) /* 2 seconds */
  51. #define RLB_ARP_BURST_SIZE 2
  52. #define RLB_UPDATE_RETRY 3 /* 3-ticks - must be smaller than the rlb
  53. * rebalance interval (5 min).
  54. */
  55. /* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
  56. * promiscuous after failover
  57. */
  58. #define RLB_PROMISC_TIMEOUT (10*ALB_TIMER_TICKS_PER_SEC)
  59. struct tlb_client_info {
  60. struct slave *tx_slave; /* A pointer to slave used for transmiting
  61. * packets to a Client that the Hash function
  62. * gave this entry index.
  63. */
  64. u32 tx_bytes; /* Each Client accumulates the BytesTx that
  65. * were transmitted to it, and after each
  66. * CallBack the LoadHistory is divided
  67. * by the balance interval
  68. */
  69. u32 load_history; /* This field contains the amount of Bytes
  70. * that were transmitted to this client by
  71. * the server on the previous balance
  72. * interval in Bps.
  73. */
  74. u32 next; /* The next Hash table entry index, assigned
  75. * to use the same adapter for transmit.
  76. */
  77. u32 prev; /* The previous Hash table entry index,
  78. * assigned to use the same
  79. */
  80. };
  81. /* -------------------------------------------------------------------------
  82. * struct rlb_client_info contains all info related to a specific rx client
  83. * connection. This is the Clients Hash Table entry struct
  84. * -------------------------------------------------------------------------
  85. */
  86. struct rlb_client_info {
  87. __be32 ip_src; /* the server IP address */
  88. __be32 ip_dst; /* the client IP address */
  89. u8 mac_dst[ETH_ALEN]; /* the client MAC address */
  90. u32 next; /* The next Hash table entry index */
  91. u32 prev; /* The previous Hash table entry index */
  92. u8 assigned; /* checking whether this entry is assigned */
  93. u8 ntt; /* flag - need to transmit client info */
  94. struct slave *slave; /* the slave assigned to this client */
  95. u8 tag; /* flag - need to tag skb */
  96. unsigned short vlan_id; /* VLAN tag associated with IP address */
  97. };
  98. struct tlb_slave_info {
  99. u32 head; /* Index to the head of the bi-directional clients
  100. * hash table entries list. The entries in the list
  101. * are the entries that were assigned to use this
  102. * slave for transmit.
  103. */
  104. u32 load; /* Each slave sums the loadHistory of all clients
  105. * assigned to it
  106. */
  107. };
  108. struct alb_bond_info {
  109. struct tlb_client_info *tx_hashtbl; /* Dynamically allocated */
  110. spinlock_t tx_hashtbl_lock;
  111. u32 unbalanced_load;
  112. int tx_rebalance_counter;
  113. int lp_counter;
  114. /* -------- rlb parameters -------- */
  115. int rlb_enabled;
  116. struct rlb_client_info *rx_hashtbl; /* Receive hash table */
  117. spinlock_t rx_hashtbl_lock;
  118. u32 rx_hashtbl_head;
  119. u8 rx_ntt; /* flag - need to transmit
  120. * to all rx clients
  121. */
  122. struct slave *next_rx_slave;/* next slave to be assigned
  123. * to a new rx client for
  124. */
  125. u8 primary_is_promisc; /* boolean */
  126. u32 rlb_promisc_timeout_counter;/* counts primary
  127. * promiscuity time
  128. */
  129. u32 rlb_update_delay_counter;
  130. u32 rlb_update_retry_counter;/* counter of retries
  131. * of client update
  132. */
  133. u8 rlb_rebalance; /* flag - indicates that the
  134. * rx traffic should be
  135. * rebalanced
  136. */
  137. struct vlan_entry *current_alb_vlan;
  138. };
  139. int bond_alb_initialize(struct bonding *bond, int rlb_enabled);
  140. void bond_alb_deinitialize(struct bonding *bond);
  141. int bond_alb_init_slave(struct bonding *bond, struct slave *slave);
  142. void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave);
  143. void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link);
  144. void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave);
  145. int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
  146. void bond_alb_monitor(struct work_struct *);
  147. int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
  148. void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
  149. #endif /* __BOND_ALB_H__ */