Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * net/tipc/link.h: Include file for TIPC link code |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 3 | * |
Jon Paul Maloy | 50100a5 | 2014-08-22 18:09:07 -0400 | [diff] [blame] | 4 | * Copyright (c) 1995-2006, 2013-2014, Ericsson AB |
Allan Stephens | 23dd4cc | 2011-01-07 11:43:40 -0500 | [diff] [blame] | 5 | * Copyright (c) 2004-2005, 2010-2011, Wind River Systems |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 8 | * Redistribution and use in source and binary forms, with or without |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 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. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 19 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 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 |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 34 | * POSSIBILITY OF SUCH DAMAGE. |
| 35 | */ |
| 36 | |
| 37 | #ifndef _TIPC_LINK_H |
| 38 | #define _TIPC_LINK_H |
| 39 | |
Richard Alpe | 0655f6a | 2014-11-20 10:29:07 +0100 | [diff] [blame] | 40 | #include <net/genetlink.h> |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 41 | #include "msg.h" |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 42 | #include "node.h" |
| 43 | |
Ying Xue | 859fc7c | 2015-01-09 15:27:01 +0800 | [diff] [blame] | 44 | /* TIPC-specific error codes |
| 45 | */ |
| 46 | #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ |
| 47 | |
Jon Paul Maloy | 662921c | 2015-07-30 18:24:21 -0400 | [diff] [blame] | 48 | /* Link FSM events: |
Ying Xue | 135daee | 2014-02-13 17:29:08 -0500 | [diff] [blame] | 49 | */ |
Jon Paul Maloy | d3504c3 | 2015-07-16 16:54:25 -0400 | [diff] [blame] | 50 | enum { |
Jon Paul Maloy | 662921c | 2015-07-30 18:24:21 -0400 | [diff] [blame] | 51 | LINK_ESTABLISH_EVT = 0xec1ab1e, |
| 52 | LINK_PEER_RESET_EVT = 0x9eed0e, |
| 53 | LINK_FAILURE_EVT = 0xfa110e, |
| 54 | LINK_RESET_EVT = 0x10ca1d0e, |
| 55 | LINK_FAILOVER_BEGIN_EVT = 0xfa110bee, |
| 56 | LINK_FAILOVER_END_EVT = 0xfa110ede, |
| 57 | LINK_SYNCH_BEGIN_EVT = 0xc1ccbee, |
| 58 | LINK_SYNCH_END_EVT = 0xc1ccede |
Jon Paul Maloy | d3504c3 | 2015-07-16 16:54:25 -0400 | [diff] [blame] | 59 | }; |
Ying Xue | 135daee | 2014-02-13 17:29:08 -0500 | [diff] [blame] | 60 | |
Jon Paul Maloy | d999297 | 2015-07-16 16:54:31 -0400 | [diff] [blame] | 61 | /* Events returned from link at packet reception or at timeout |
Jon Paul Maloy | 6ab30f9 | 2015-07-16 16:54:27 -0400 | [diff] [blame] | 62 | */ |
| 63 | enum { |
| 64 | TIPC_LINK_UP_EVT = 1, |
Jon Paul Maloy | 5266698 | 2015-10-22 08:51:41 -0400 | [diff] [blame] | 65 | TIPC_LINK_DOWN_EVT = (1 << 1), |
| 66 | TIPC_LINK_SND_BC_ACK = (1 << 2) |
Jon Paul Maloy | 6ab30f9 | 2015-07-16 16:54:27 -0400 | [diff] [blame] | 67 | }; |
| 68 | |
Ying Xue | 135daee | 2014-02-13 17:29:08 -0500 | [diff] [blame] | 69 | /* Starting value for maximum packet size negotiation on unicast links |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 70 | * (unless bearer MTU is less) |
| 71 | */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 72 | #define MAX_PKT_DEFAULT 1500 |
| 73 | |
Jon Paul Maloy | c72fa87 | 2015-10-22 08:51:46 -0400 | [diff] [blame] | 74 | bool tipc_link_create(struct net *net, char *if_name, int bearer_id, |
Jon Paul Maloy | 0e05498 | 2015-10-22 08:51:36 -0400 | [diff] [blame] | 75 | int tolerance, char net_plane, u32 mtu, int priority, |
| 76 | int window, u32 session, u32 ownnode, u32 peer, |
Jon Paul Maloy | 5266698 | 2015-10-22 08:51:41 -0400 | [diff] [blame] | 77 | u16 peer_caps, |
Jon Paul Maloy | 5266698 | 2015-10-22 08:51:41 -0400 | [diff] [blame] | 78 | struct tipc_link *bc_sndlink, |
| 79 | struct tipc_link *bc_rcvlink, |
| 80 | struct sk_buff_head *inputq, |
| 81 | struct sk_buff_head *namedq, |
Jon Paul Maloy | 440d896 | 2015-07-30 18:24:26 -0400 | [diff] [blame] | 82 | struct tipc_link **link); |
Jon Paul Maloy | c72fa87 | 2015-10-22 08:51:46 -0400 | [diff] [blame] | 83 | bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, |
Jon Paul Maloy | 5266698 | 2015-10-22 08:51:41 -0400 | [diff] [blame] | 84 | int mtu, int window, u16 peer_caps, |
| 85 | struct sk_buff_head *inputq, |
Jon Paul Maloy | 3230190 | 2015-10-22 08:51:37 -0400 | [diff] [blame] | 86 | struct sk_buff_head *namedq, |
Jon Paul Maloy | 5266698 | 2015-10-22 08:51:41 -0400 | [diff] [blame] | 87 | struct tipc_link *bc_sndlink, |
Jon Paul Maloy | 3230190 | 2015-10-22 08:51:37 -0400 | [diff] [blame] | 88 | struct tipc_link **link); |
Jon Paul Maloy | 6e49815 | 2015-07-30 18:24:19 -0400 | [diff] [blame] | 89 | void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl, |
| 90 | int mtyp, struct sk_buff_head *xmitq); |
Jon Paul Maloy | 282b3a0 | 2015-10-15 14:52:45 -0400 | [diff] [blame] | 91 | void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq); |
Jon Paul Maloy | 662921c | 2015-07-30 18:24:21 -0400 | [diff] [blame] | 92 | int tipc_link_fsm_evt(struct tipc_link *l, int evt); |
Jon Paul Maloy | 662921c | 2015-07-30 18:24:21 -0400 | [diff] [blame] | 93 | bool tipc_link_is_up(struct tipc_link *l); |
Jon Paul Maloy | c819930 | 2015-10-15 14:52:46 -0400 | [diff] [blame] | 94 | bool tipc_link_peer_is_down(struct tipc_link *l); |
Jon Paul Maloy | 662921c | 2015-07-30 18:24:21 -0400 | [diff] [blame] | 95 | bool tipc_link_is_reset(struct tipc_link *l); |
Jon Paul Maloy | 73f646c | 2015-10-15 14:52:44 -0400 | [diff] [blame] | 96 | bool tipc_link_is_establishing(struct tipc_link *l); |
Jon Paul Maloy | 662921c | 2015-07-30 18:24:21 -0400 | [diff] [blame] | 97 | bool tipc_link_is_synching(struct tipc_link *l); |
| 98 | bool tipc_link_is_failingover(struct tipc_link *l); |
| 99 | bool tipc_link_is_blocked(struct tipc_link *l); |
Jon Paul Maloy | c72fa87 | 2015-10-22 08:51:46 -0400 | [diff] [blame] | 100 | void tipc_link_set_active(struct tipc_link *l, bool active); |
Jon Paul Maloy | 1a90632 | 2015-11-19 14:30:47 -0500 | [diff] [blame] | 101 | void tipc_link_reset(struct tipc_link *l); |
Jon Paul Maloy | 38206d5 | 2015-11-19 14:30:46 -0500 | [diff] [blame] | 102 | void tipc_link_reset_stats(struct tipc_link *l); |
| 103 | int tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list, |
Jon Paul Maloy | af9b028 | 2015-07-16 16:54:24 -0400 | [diff] [blame] | 104 | struct sk_buff_head *xmitq); |
Jon Paul Maloy | 38206d5 | 2015-11-19 14:30:46 -0500 | [diff] [blame] | 105 | struct sk_buff_head *tipc_link_inputq(struct tipc_link *l); |
| 106 | u16 tipc_link_rcv_nxt(struct tipc_link *l); |
| 107 | u16 tipc_link_acked(struct tipc_link *l); |
| 108 | u32 tipc_link_id(struct tipc_link *l); |
| 109 | char *tipc_link_name(struct tipc_link *l); |
| 110 | char tipc_link_plane(struct tipc_link *l); |
| 111 | int tipc_link_prio(struct tipc_link *l); |
| 112 | int tipc_link_window(struct tipc_link *l); |
| 113 | unsigned long tipc_link_tolerance(struct tipc_link *l); |
Richard Alpe | d01332f | 2016-02-01 08:19:56 +0100 | [diff] [blame] | 114 | void tipc_link_set_tolerance(struct tipc_link *l, u32 tol, |
| 115 | struct sk_buff_head *xmitq); |
| 116 | void tipc_link_set_prio(struct tipc_link *l, u32 prio, |
| 117 | struct sk_buff_head *xmitq); |
Jon Paul Maloy | 38206d5 | 2015-11-19 14:30:46 -0500 | [diff] [blame] | 118 | void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit); |
Jon Paul Maloy | 2af5ae3 | 2015-10-22 08:51:48 -0400 | [diff] [blame] | 119 | void tipc_link_set_queue_limits(struct tipc_link *l, u32 window); |
Jon Paul Maloy | 5be9c08 | 2015-11-19 14:30:45 -0500 | [diff] [blame] | 120 | int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, |
| 121 | struct tipc_link *link, int nlflags); |
Richard Alpe | 0655f6a | 2014-11-20 10:29:07 +0100 | [diff] [blame] | 122 | int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); |
Jon Paul Maloy | 333ef69 | 2015-07-16 16:54:28 -0400 | [diff] [blame] | 123 | int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq); |
Jon Paul Maloy | d999297 | 2015-07-16 16:54:31 -0400 | [diff] [blame] | 124 | int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb, |
| 125 | struct sk_buff_head *xmitq); |
Jon Paul Maloy | 34b9cd6 | 2016-04-15 13:33:07 -0400 | [diff] [blame] | 126 | int tipc_link_build_state_msg(struct tipc_link *l, struct sk_buff_head *xmitq); |
Jon Paul Maloy | 5266698 | 2015-10-22 08:51:41 -0400 | [diff] [blame] | 127 | void tipc_link_add_bc_peer(struct tipc_link *snd_l, |
| 128 | struct tipc_link *uc_l, |
| 129 | struct sk_buff_head *xmitq); |
| 130 | void tipc_link_remove_bc_peer(struct tipc_link *snd_l, |
| 131 | struct tipc_link *rcv_l, |
| 132 | struct sk_buff_head *xmitq); |
Jon Paul Maloy | 2f56612 | 2015-10-22 08:51:39 -0400 | [diff] [blame] | 133 | int tipc_link_bc_peers(struct tipc_link *l); |
Jon Paul Maloy | 959e178 | 2015-10-22 08:51:43 -0400 | [diff] [blame] | 134 | void tipc_link_set_mtu(struct tipc_link *l, int mtu); |
| 135 | int tipc_link_mtu(struct tipc_link *l); |
Jon Paul Maloy | 5266698 | 2015-10-22 08:51:41 -0400 | [diff] [blame] | 136 | void tipc_link_bc_ack_rcv(struct tipc_link *l, u16 acked, |
| 137 | struct sk_buff_head *xmitq); |
| 138 | void tipc_link_build_bc_sync_msg(struct tipc_link *l, |
| 139 | struct sk_buff_head *xmitq); |
| 140 | void tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr); |
| 141 | void tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr, |
| 142 | struct sk_buff_head *xmitq); |
| 143 | int tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb, |
| 144 | struct sk_buff_head *xmitq); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 145 | #endif |