link.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * net/tipc/link.h: Include file for TIPC link code
  3. *
  4. * Copyright (c) 1995-2006, 2013-2014, Ericsson AB
  5. * Copyright (c) 2004-2005, 2010-2011, Wind River Systems
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the names of the copyright holders nor the names of its
  17. * contributors may be used to endorse or promote products derived from
  18. * this software without specific prior written permission.
  19. *
  20. * Alternatively, this software may be distributed under the terms of the
  21. * GNU General Public License ("GPL") version 2 as published by the Free
  22. * Software Foundation.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  31. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  32. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  33. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. * POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. #ifndef _TIPC_LINK_H
  37. #define _TIPC_LINK_H
  38. #include <net/genetlink.h>
  39. #include "msg.h"
  40. #include "node.h"
  41. /* TIPC-specific error codes
  42. */
  43. #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */
  44. /* Link FSM events:
  45. */
  46. enum {
  47. LINK_ESTABLISH_EVT = 0xec1ab1e,
  48. LINK_PEER_RESET_EVT = 0x9eed0e,
  49. LINK_FAILURE_EVT = 0xfa110e,
  50. LINK_RESET_EVT = 0x10ca1d0e,
  51. LINK_FAILOVER_BEGIN_EVT = 0xfa110bee,
  52. LINK_FAILOVER_END_EVT = 0xfa110ede,
  53. LINK_SYNCH_BEGIN_EVT = 0xc1ccbee,
  54. LINK_SYNCH_END_EVT = 0xc1ccede
  55. };
  56. /* Events returned from link at packet reception or at timeout
  57. */
  58. enum {
  59. TIPC_LINK_UP_EVT = 1,
  60. TIPC_LINK_DOWN_EVT = (1 << 1),
  61. TIPC_LINK_SND_STATE = (1 << 2)
  62. };
  63. /* Starting value for maximum packet size negotiation on unicast links
  64. * (unless bearer MTU is less)
  65. */
  66. #define MAX_PKT_DEFAULT 1500
  67. bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
  68. int tolerance, char net_plane, u32 mtu, int priority,
  69. u32 min_win, u32 max_win, u32 session, u32 ownnode,
  70. u32 peer, u8 *peer_id, u16 peer_caps,
  71. struct tipc_link *bc_sndlink,
  72. struct tipc_link *bc_rcvlink,
  73. struct sk_buff_head *inputq,
  74. struct sk_buff_head *namedq,
  75. struct tipc_link **link);
  76. bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, u8 *peer_id,
  77. int mtu, u32 min_win, u32 max_win, u16 peer_caps,
  78. struct sk_buff_head *inputq,
  79. struct sk_buff_head *namedq,
  80. struct tipc_link *bc_sndlink,
  81. struct tipc_link **link);
  82. void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
  83. int mtyp, struct sk_buff_head *xmitq);
  84. void tipc_link_create_dummy_tnl_msg(struct tipc_link *tnl,
  85. struct sk_buff_head *xmitq);
  86. void tipc_link_failover_prepare(struct tipc_link *l, struct tipc_link *tnl,
  87. struct sk_buff_head *xmitq);
  88. void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq);
  89. int tipc_link_fsm_evt(struct tipc_link *l, int evt);
  90. bool tipc_link_is_up(struct tipc_link *l);
  91. bool tipc_link_peer_is_down(struct tipc_link *l);
  92. bool tipc_link_is_reset(struct tipc_link *l);
  93. bool tipc_link_is_establishing(struct tipc_link *l);
  94. bool tipc_link_is_synching(struct tipc_link *l);
  95. bool tipc_link_is_failingover(struct tipc_link *l);
  96. bool tipc_link_is_blocked(struct tipc_link *l);
  97. void tipc_link_set_active(struct tipc_link *l, bool active);
  98. void tipc_link_reset(struct tipc_link *l);
  99. void tipc_link_reset_stats(struct tipc_link *l);
  100. int tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list,
  101. struct sk_buff_head *xmitq);
  102. struct sk_buff_head *tipc_link_inputq(struct tipc_link *l);
  103. u16 tipc_link_rcv_nxt(struct tipc_link *l);
  104. u16 tipc_link_acked(struct tipc_link *l);
  105. u32 tipc_link_id(struct tipc_link *l);
  106. char *tipc_link_name(struct tipc_link *l);
  107. u32 tipc_link_state(struct tipc_link *l);
  108. char tipc_link_plane(struct tipc_link *l);
  109. int tipc_link_prio(struct tipc_link *l);
  110. int tipc_link_min_win(struct tipc_link *l);
  111. int tipc_link_max_win(struct tipc_link *l);
  112. void tipc_link_update_caps(struct tipc_link *l, u16 capabilities);
  113. bool tipc_link_validate_msg(struct tipc_link *l, struct tipc_msg *hdr);
  114. unsigned long tipc_link_tolerance(struct tipc_link *l);
  115. void tipc_link_set_tolerance(struct tipc_link *l, u32 tol,
  116. struct sk_buff_head *xmitq);
  117. void tipc_link_set_prio(struct tipc_link *l, u32 prio,
  118. struct sk_buff_head *xmitq);
  119. void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit);
  120. void tipc_link_set_queue_limits(struct tipc_link *l, u32 min_win, u32 max_win);
  121. int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
  122. struct tipc_link *link, int nlflags);
  123. int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]);
  124. int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq);
  125. int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,
  126. struct sk_buff_head *xmitq);
  127. int tipc_link_build_state_msg(struct tipc_link *l, struct sk_buff_head *xmitq);
  128. void tipc_link_add_bc_peer(struct tipc_link *snd_l,
  129. struct tipc_link *uc_l,
  130. struct sk_buff_head *xmitq);
  131. void tipc_link_remove_bc_peer(struct tipc_link *snd_l,
  132. struct tipc_link *rcv_l,
  133. struct sk_buff_head *xmitq);
  134. int tipc_link_bc_peers(struct tipc_link *l);
  135. void tipc_link_set_mtu(struct tipc_link *l, int mtu);
  136. int tipc_link_mtu(struct tipc_link *l);
  137. int tipc_link_mss(struct tipc_link *l);
  138. u16 tipc_get_gap_ack_blks(struct tipc_gap_ack_blks **ga, struct tipc_link *l,
  139. struct tipc_msg *hdr, bool uc);
  140. int tipc_link_bc_ack_rcv(struct tipc_link *l, u16 acked, u16 gap,
  141. struct tipc_gap_ack_blks *ga,
  142. struct sk_buff_head *xmitq,
  143. struct sk_buff_head *retrq);
  144. void tipc_link_build_bc_sync_msg(struct tipc_link *l,
  145. struct sk_buff_head *xmitq);
  146. void tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr);
  147. int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,
  148. struct sk_buff_head *xmitq);
  149. int tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb,
  150. struct sk_buff_head *xmitq);
  151. bool tipc_link_too_silent(struct tipc_link *l);
  152. struct net *tipc_link_net(struct tipc_link *l);
  153. #endif