blob: d3c1c3fc16590da198a8e0ce150c0b9e44a190e3 [file] [log] [blame]
Per Lidenb97bf3f2006-01-02 19:04:38 +01001/*
2 * net/tipc/link.h: Include file for TIPC link code
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +09003 *
Jon Paul Maloy50100a52014-08-22 18:09:07 -04004 * Copyright (c) 1995-2006, 2013-2014, Ericsson AB
Allan Stephens23dd4cc2011-01-07 11:43:40 -05005 * Copyright (c) 2004-2005, 2010-2011, Wind River Systems
Per Lidenb97bf3f2006-01-02 19:04:38 +01006 * All rights reserved.
7 *
Per Liden9ea1fd32006-01-11 13:30:43 +01008 * Redistribution and use in source and binary forms, with or without
Per Lidenb97bf3f2006-01-02 19:04:38 +01009 * modification, are permitted provided that the following conditions are met:
10 *
Per Liden9ea1fd32006-01-11 13:30:43 +010011 * 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 Lidenb97bf3f2006-01-02 19:04:38 +010019 *
Per Liden9ea1fd32006-01-11 13:30:43 +010020 * 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 Lidenb97bf3f2006-01-02 19:04:38 +010034 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _TIPC_LINK_H
38#define _TIPC_LINK_H
39
Richard Alpe0655f6a2014-11-20 10:29:07 +010040#include <net/genetlink.h>
Per Lidenb97bf3f2006-01-02 19:04:38 +010041#include "msg.h"
Per Lidenb97bf3f2006-01-02 19:04:38 +010042#include "node.h"
43
Ying Xue859fc7c2015-01-09 15:27:01 +080044/* TIPC-specific error codes
45*/
46#define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */
47
Jon Paul Maloy662921c2015-07-30 18:24:21 -040048/* Link FSM events:
Ying Xue135daee2014-02-13 17:29:08 -050049 */
Jon Paul Maloyd3504c32015-07-16 16:54:25 -040050enum {
Jon Paul Maloy662921c2015-07-30 18:24:21 -040051 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 Maloyd3504c32015-07-16 16:54:25 -040059};
Ying Xue135daee2014-02-13 17:29:08 -050060
Jon Paul Maloyd9992972015-07-16 16:54:31 -040061/* Events returned from link at packet reception or at timeout
Jon Paul Maloy6ab30f92015-07-16 16:54:27 -040062 */
63enum {
64 TIPC_LINK_UP_EVT = 1,
Jon Paul Maloy52666982015-10-22 08:51:41 -040065 TIPC_LINK_DOWN_EVT = (1 << 1),
Jon Paul Maloy02d11ca2016-09-01 13:52:49 -040066 TIPC_LINK_SND_STATE = (1 << 2)
Jon Paul Maloy6ab30f92015-07-16 16:54:27 -040067};
68
Ying Xue135daee2014-02-13 17:29:08 -050069/* Starting value for maximum packet size negotiation on unicast links
Per Lidenb97bf3f2006-01-02 19:04:38 +010070 * (unless bearer MTU is less)
71 */
Per Lidenb97bf3f2006-01-02 19:04:38 +010072#define MAX_PKT_DEFAULT 1500
73
Jon Paul Maloyc72fa872015-10-22 08:51:46 -040074bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
Jon Paul Maloy0e054982015-10-22 08:51:36 -040075 int tolerance, char net_plane, u32 mtu, int priority,
Jon Maloy16ad3f42019-12-10 00:52:46 +010076 u32 min_win, u32 max_win, u32 session, u32 ownnode,
Jon Maloy25b0b9c2018-03-22 20:42:51 +010077 u32 peer, u8 *peer_id, u16 peer_caps,
Jon Paul Maloy52666982015-10-22 08:51:41 -040078 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 Maloy440d8962015-07-30 18:24:26 -040082 struct tipc_link **link);
Jon Paul Maloyc72fa872015-10-22 08:51:46 -040083bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
Jon Maloy16ad3f42019-12-10 00:52:46 +010084 int mtu, u32 min_win, u32 max_win, u16 peer_caps,
Jon Paul Maloy52666982015-10-22 08:51:41 -040085 struct sk_buff_head *inputq,
Jon Paul Maloy32301902015-10-22 08:51:37 -040086 struct sk_buff_head *namedq,
Jon Paul Maloy52666982015-10-22 08:51:41 -040087 struct tipc_link *bc_sndlink,
Jon Paul Maloy32301902015-10-22 08:51:37 -040088 struct tipc_link **link);
Jon Paul Maloy6e498152015-07-30 18:24:19 -040089void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
90 int mtyp, struct sk_buff_head *xmitq);
LUU Duc Canhc140eb12018-09-26 21:00:54 +020091void tipc_link_create_dummy_tnl_msg(struct tipc_link *tnl,
92 struct sk_buff_head *xmitq);
Tuong Lienc0b14a02019-05-02 17:23:23 +070093void tipc_link_failover_prepare(struct tipc_link *l, struct tipc_link *tnl,
94 struct sk_buff_head *xmitq);
Jon Paul Maloy282b3a02015-10-15 14:52:45 -040095void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq);
Jon Paul Maloy662921c2015-07-30 18:24:21 -040096int tipc_link_fsm_evt(struct tipc_link *l, int evt);
Jon Paul Maloy662921c2015-07-30 18:24:21 -040097bool tipc_link_is_up(struct tipc_link *l);
Jon Paul Maloyc8199302015-10-15 14:52:46 -040098bool tipc_link_peer_is_down(struct tipc_link *l);
Jon Paul Maloy662921c2015-07-30 18:24:21 -040099bool tipc_link_is_reset(struct tipc_link *l);
Jon Paul Maloy73f646c2015-10-15 14:52:44 -0400100bool tipc_link_is_establishing(struct tipc_link *l);
Jon Paul Maloy662921c2015-07-30 18:24:21 -0400101bool tipc_link_is_synching(struct tipc_link *l);
102bool tipc_link_is_failingover(struct tipc_link *l);
103bool tipc_link_is_blocked(struct tipc_link *l);
Jon Paul Maloyc72fa872015-10-22 08:51:46 -0400104void tipc_link_set_active(struct tipc_link *l, bool active);
Jon Paul Maloy1a906322015-11-19 14:30:47 -0500105void tipc_link_reset(struct tipc_link *l);
Jon Paul Maloy38206d52015-11-19 14:30:46 -0500106void tipc_link_reset_stats(struct tipc_link *l);
107int tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list,
Jon Paul Maloyaf9b0282015-07-16 16:54:24 -0400108 struct sk_buff_head *xmitq);
Jon Paul Maloy38206d52015-11-19 14:30:46 -0500109struct sk_buff_head *tipc_link_inputq(struct tipc_link *l);
110u16 tipc_link_rcv_nxt(struct tipc_link *l);
111u16 tipc_link_acked(struct tipc_link *l);
112u32 tipc_link_id(struct tipc_link *l);
113char *tipc_link_name(struct tipc_link *l);
Tuong Lienb4b97712018-12-19 09:17:56 +0700114char *tipc_link_name_ext(struct tipc_link *l, char *buf);
LUU Duc Canhc140eb12018-09-26 21:00:54 +0200115u32 tipc_link_state(struct tipc_link *l);
Jon Paul Maloy38206d52015-11-19 14:30:46 -0500116char tipc_link_plane(struct tipc_link *l);
117int tipc_link_prio(struct tipc_link *l);
Jon Maloy16ad3f42019-12-10 00:52:46 +0100118int tipc_link_min_win(struct tipc_link *l);
119int tipc_link_max_win(struct tipc_link *l);
Jon Maloy9012de52018-07-10 01:07:35 +0200120void tipc_link_update_caps(struct tipc_link *l, u16 capabilities);
Jon Maloy7ea817f2018-07-10 01:07:36 +0200121bool tipc_link_validate_msg(struct tipc_link *l, struct tipc_msg *hdr);
Jon Paul Maloy38206d52015-11-19 14:30:46 -0500122unsigned long tipc_link_tolerance(struct tipc_link *l);
Richard Alped01332f2016-02-01 08:19:56 +0100123void tipc_link_set_tolerance(struct tipc_link *l, u32 tol,
124 struct sk_buff_head *xmitq);
125void tipc_link_set_prio(struct tipc_link *l, u32 prio,
126 struct sk_buff_head *xmitq);
Jon Paul Maloy38206d52015-11-19 14:30:46 -0500127void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit);
Jon Maloy16ad3f42019-12-10 00:52:46 +0100128void tipc_link_set_queue_limits(struct tipc_link *l, u32 min_win, u32 max_win);
Jon Paul Maloy5be9c082015-11-19 14:30:45 -0500129int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
130 struct tipc_link *link, int nlflags);
Richard Alpe0655f6a2014-11-20 10:29:07 +0100131int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]);
Jon Paul Maloy333ef692015-07-16 16:54:28 -0400132int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq);
Jon Paul Maloyd9992972015-07-16 16:54:31 -0400133int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,
134 struct sk_buff_head *xmitq);
Jon Paul Maloy34b9cd62016-04-15 13:33:07 -0400135int tipc_link_build_state_msg(struct tipc_link *l, struct sk_buff_head *xmitq);
Jon Paul Maloy52666982015-10-22 08:51:41 -0400136void tipc_link_add_bc_peer(struct tipc_link *snd_l,
137 struct tipc_link *uc_l,
138 struct sk_buff_head *xmitq);
139void tipc_link_remove_bc_peer(struct tipc_link *snd_l,
140 struct tipc_link *rcv_l,
141 struct sk_buff_head *xmitq);
Jon Paul Maloy2f566122015-10-22 08:51:39 -0400142int tipc_link_bc_peers(struct tipc_link *l);
Jon Paul Maloy959e1782015-10-22 08:51:43 -0400143void tipc_link_set_mtu(struct tipc_link *l, int mtu);
144int tipc_link_mtu(struct tipc_link *l);
Tuong Lienfc1b6d62019-11-08 12:05:11 +0700145int tipc_link_mss(struct tipc_link *l);
Jon Paul Maloy52666982015-10-22 08:51:41 -0400146void tipc_link_bc_ack_rcv(struct tipc_link *l, u16 acked,
147 struct sk_buff_head *xmitq);
148void tipc_link_build_bc_sync_msg(struct tipc_link *l,
149 struct sk_buff_head *xmitq);
150void tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr);
Jon Paul Maloy02d11ca2016-09-01 13:52:49 -0400151int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,
152 struct sk_buff_head *xmitq);
Jon Paul Maloy52666982015-10-22 08:51:41 -0400153int tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb,
154 struct sk_buff_head *xmitq);
Tuong Lien26574db2018-12-19 09:17:57 +0700155bool tipc_link_too_silent(struct tipc_link *l);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100156#endif