bond_alb.h 4.7 KB

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