bond_alb.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. * Changes:
  23. *
  24. * 2003/08/06 - Amir Noam <amir.noam at intel dot com>
  25. * - Add support for setting bond's MAC address with special
  26. * handling required for ALB/TLB.
  27. *
  28. * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
  29. * - Code cleanup and style changes
  30. */
  31. #ifndef __BOND_ALB_H__
  32. #define __BOND_ALB_H__
  33. #include <linux/if_ether.h>
  34. struct bonding;
  35. struct slave;
  36. #define BOND_ALB_INFO(bond) ((bond)->alb_info)
  37. #define SLAVE_TLB_INFO(slave) ((slave)->tlb_info)
  38. struct tlb_client_info {
  39. struct slave *tx_slave; /* A pointer to slave used for transmiting
  40. * packets to a Client that the Hash function
  41. * gave this entry index.
  42. */
  43. u32 tx_bytes; /* Each Client acumulates the BytesTx that
  44. * were tranmitted to it, and after each
  45. * CallBack the LoadHistory is devided
  46. * by the balance interval
  47. */
  48. u32 load_history; /* This field contains the amount of Bytes
  49. * that were transmitted to this client by
  50. * the server on the previous balance
  51. * interval in Bps.
  52. */
  53. u32 next; /* The next Hash table entry index, assigned
  54. * to use the same adapter for transmit.
  55. */
  56. u32 prev; /* The previous Hash table entry index,
  57. * assigned to use the same
  58. */
  59. };
  60. /* -------------------------------------------------------------------------
  61. * struct rlb_client_info contains all info related to a specific rx client
  62. * connection. This is the Clients Hash Table entry struct
  63. * -------------------------------------------------------------------------
  64. */
  65. struct rlb_client_info {
  66. u32 ip_src; /* the server IP address */
  67. u32 ip_dst; /* the client IP address */
  68. u8 mac_dst[ETH_ALEN]; /* the client MAC address */
  69. u32 next; /* The next Hash table entry index */
  70. u32 prev; /* The previous Hash table entry index */
  71. u8 assigned; /* checking whether this entry is assigned */
  72. u8 ntt; /* flag - need to transmit client info */
  73. struct slave *slave; /* the slave assigned to this client */
  74. u8 tag; /* flag - need to tag skb */
  75. unsigned short vlan_id; /* VLAN tag associated with IP address */
  76. };
  77. struct tlb_slave_info {
  78. u32 head; /* Index to the head of the bi-directional clients
  79. * hash table entries list. The entries in the list
  80. * are the entries that were assigned to use this
  81. * slave for transmit.
  82. */
  83. u32 load; /* Each slave sums the loadHistory of all clients
  84. * assigned to it
  85. */
  86. };
  87. struct alb_bond_info {
  88. struct timer_list alb_timer;
  89. struct tlb_client_info *tx_hashtbl; /* Dynamically allocated */
  90. spinlock_t tx_hashtbl_lock;
  91. u32 unbalanced_load;
  92. int tx_rebalance_counter;
  93. int lp_counter;
  94. /* -------- rlb parameters -------- */
  95. int rlb_enabled;
  96. struct packet_type rlb_pkt_type;
  97. struct rlb_client_info *rx_hashtbl; /* Receive hash table */
  98. spinlock_t rx_hashtbl_lock;
  99. u32 rx_hashtbl_head;
  100. u8 rx_ntt; /* flag - need to transmit
  101. * to all rx clients
  102. */
  103. struct slave *next_rx_slave;/* next slave to be assigned
  104. * to a new rx client for
  105. */
  106. u32 rlb_interval_counter;
  107. u8 primary_is_promisc; /* boolean */
  108. u32 rlb_promisc_timeout_counter;/* counts primary
  109. * promiscuity time
  110. */
  111. u32 rlb_update_delay_counter;
  112. u32 rlb_update_retry_counter;/* counter of retries
  113. * of client update
  114. */
  115. u8 rlb_rebalance; /* flag - indicates that the
  116. * rx traffic should be
  117. * rebalanced
  118. */
  119. struct vlan_entry *current_alb_vlan;
  120. };
  121. int bond_alb_initialize(struct bonding *bond, int rlb_enabled);
  122. void bond_alb_deinitialize(struct bonding *bond);
  123. int bond_alb_init_slave(struct bonding *bond, struct slave *slave);
  124. void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave);
  125. void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link);
  126. void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave);
  127. int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
  128. void bond_alb_monitor(struct bonding *bond);
  129. int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
  130. void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
  131. #endif /* __BOND_ALB_H__ */