1b97bf3fdSPer Liden /* 2b97bf3fdSPer Liden * net/tipc/link.h: Include file for TIPC link code 3b97bf3fdSPer Liden * 450100a5eSJon Paul Maloy * Copyright (c) 1995-2006, 2013-2014, Ericsson AB 523dd4cceSAllan Stephens * Copyright (c) 2004-2005, 2010-2011, Wind River Systems 6b97bf3fdSPer Liden * All rights reserved. 7b97bf3fdSPer Liden * 8b97bf3fdSPer Liden * Redistribution and use in source and binary forms, with or without 9b97bf3fdSPer Liden * modification, are permitted provided that the following conditions are met: 10b97bf3fdSPer Liden * 119ea1fd3cSPer Liden * 1. Redistributions of source code must retain the above copyright 129ea1fd3cSPer Liden * notice, this list of conditions and the following disclaimer. 139ea1fd3cSPer Liden * 2. Redistributions in binary form must reproduce the above copyright 149ea1fd3cSPer Liden * notice, this list of conditions and the following disclaimer in the 159ea1fd3cSPer Liden * documentation and/or other materials provided with the distribution. 169ea1fd3cSPer Liden * 3. Neither the names of the copyright holders nor the names of its 179ea1fd3cSPer Liden * contributors may be used to endorse or promote products derived from 189ea1fd3cSPer Liden * this software without specific prior written permission. 199ea1fd3cSPer Liden * 209ea1fd3cSPer Liden * Alternatively, this software may be distributed under the terms of the 219ea1fd3cSPer Liden * GNU General Public License ("GPL") version 2 as published by the Free 229ea1fd3cSPer Liden * Software Foundation. 23b97bf3fdSPer Liden * 24b97bf3fdSPer Liden * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25b97bf3fdSPer Liden * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26b97bf3fdSPer Liden * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27b97bf3fdSPer Liden * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 28b97bf3fdSPer Liden * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29b97bf3fdSPer Liden * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30b97bf3fdSPer Liden * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31b97bf3fdSPer Liden * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32b97bf3fdSPer Liden * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33b97bf3fdSPer Liden * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34b97bf3fdSPer Liden * POSSIBILITY OF SUCH DAMAGE. 35b97bf3fdSPer Liden */ 36b97bf3fdSPer Liden 37b97bf3fdSPer Liden #ifndef _TIPC_LINK_H 38b97bf3fdSPer Liden #define _TIPC_LINK_H 39b97bf3fdSPer Liden 400655f6a8SRichard Alpe #include <net/genetlink.h> 41b97bf3fdSPer Liden #include "msg.h" 42b97bf3fdSPer Liden #include "node.h" 43b97bf3fdSPer Liden 44859fc7c0SYing Xue /* TIPC-specific error codes 45859fc7c0SYing Xue */ 46859fc7c0SYing Xue #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ 47859fc7c0SYing Xue 48662921cdSJon Paul Maloy /* Link FSM events: 49135daee6SYing Xue */ 50d3504c34SJon Paul Maloy enum { 51662921cdSJon Paul Maloy LINK_ESTABLISH_EVT = 0xec1ab1e, 52662921cdSJon Paul Maloy LINK_PEER_RESET_EVT = 0x9eed0e, 53662921cdSJon Paul Maloy LINK_FAILURE_EVT = 0xfa110e, 54662921cdSJon Paul Maloy LINK_RESET_EVT = 0x10ca1d0e, 55662921cdSJon Paul Maloy LINK_FAILOVER_BEGIN_EVT = 0xfa110bee, 56662921cdSJon Paul Maloy LINK_FAILOVER_END_EVT = 0xfa110ede, 57662921cdSJon Paul Maloy LINK_SYNCH_BEGIN_EVT = 0xc1ccbee, 58662921cdSJon Paul Maloy LINK_SYNCH_END_EVT = 0xc1ccede 59d3504c34SJon Paul Maloy }; 60135daee6SYing Xue 61d999297cSJon Paul Maloy /* Events returned from link at packet reception or at timeout 626ab30f9cSJon Paul Maloy */ 636ab30f9cSJon Paul Maloy enum { 646ab30f9cSJon Paul Maloy TIPC_LINK_UP_EVT = 1, 6552666986SJon Paul Maloy TIPC_LINK_DOWN_EVT = (1 << 1), 6602d11ca2SJon Paul Maloy TIPC_LINK_SND_STATE = (1 << 2) 676ab30f9cSJon Paul Maloy }; 686ab30f9cSJon Paul Maloy 69135daee6SYing Xue /* Starting value for maximum packet size negotiation on unicast links 70b97bf3fdSPer Liden * (unless bearer MTU is less) 71b97bf3fdSPer Liden */ 72b97bf3fdSPer Liden #define MAX_PKT_DEFAULT 1500 73b97bf3fdSPer Liden 74c72fa872SJon Paul Maloy bool tipc_link_create(struct net *net, char *if_name, int bearer_id, 750e05498eSJon Paul Maloy int tolerance, char net_plane, u32 mtu, int priority, 7616ad3f40SJon Maloy u32 min_win, u32 max_win, u32 session, u32 ownnode, 7725b0b9c4SJon Maloy u32 peer, u8 *peer_id, u16 peer_caps, 7852666986SJon Paul Maloy struct tipc_link *bc_sndlink, 7952666986SJon Paul Maloy struct tipc_link *bc_rcvlink, 8052666986SJon Paul Maloy struct sk_buff_head *inputq, 8132301906SJon Paul Maloy struct sk_buff_head *namedq, 8232301906SJon Paul Maloy struct tipc_link **link); 8303b6fefdSTuong Lien bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, u8 *peer_id, 8416ad3f40SJon Maloy int mtu, u32 min_win, u32 max_win, u16 peer_caps, 8552666986SJon Paul Maloy struct sk_buff_head *inputq, 8652666986SJon Paul Maloy struct sk_buff_head *namedq, 8752666986SJon Paul Maloy struct tipc_link *bc_sndlink, 8852666986SJon Paul Maloy struct tipc_link **link); 896e498158SJon Paul Maloy void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl, 906e498158SJon Paul Maloy int mtyp, struct sk_buff_head *xmitq); 91c140eb16SLUU Duc Canh void tipc_link_create_dummy_tnl_msg(struct tipc_link *tnl, 92c140eb16SLUU Duc Canh struct sk_buff_head *xmitq); 93c0b14a08STuong Lien void tipc_link_failover_prepare(struct tipc_link *l, struct tipc_link *tnl, 94c0b14a08STuong Lien struct sk_buff_head *xmitq); 95282b3a05SJon Paul Maloy void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq); 96662921cdSJon Paul Maloy int tipc_link_fsm_evt(struct tipc_link *l, int evt); 97662921cdSJon Paul Maloy bool tipc_link_is_up(struct tipc_link *l); 98c8199300SJon Paul Maloy bool tipc_link_peer_is_down(struct tipc_link *l); 99662921cdSJon Paul Maloy bool tipc_link_is_reset(struct tipc_link *l); 10073f646ceSJon Paul Maloy bool tipc_link_is_establishing(struct tipc_link *l); 101662921cdSJon Paul Maloy bool tipc_link_is_synching(struct tipc_link *l); 102662921cdSJon Paul Maloy bool tipc_link_is_failingover(struct tipc_link *l); 103662921cdSJon Paul Maloy bool tipc_link_is_blocked(struct tipc_link *l); 104c72fa872SJon Paul Maloy void tipc_link_set_active(struct tipc_link *l, bool active); 1051a90632dSJon Paul Maloy void tipc_link_reset(struct tipc_link *l); 10638206d59SJon Paul Maloy void tipc_link_reset_stats(struct tipc_link *l); 107af9b028eSJon Paul Maloy int tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list, 108af9b028eSJon Paul Maloy struct sk_buff_head *xmitq); 10938206d59SJon Paul Maloy struct sk_buff_head *tipc_link_inputq(struct tipc_link *l); 11038206d59SJon Paul Maloy u16 tipc_link_rcv_nxt(struct tipc_link *l); 11138206d59SJon Paul Maloy u16 tipc_link_acked(struct tipc_link *l); 11238206d59SJon Paul Maloy u32 tipc_link_id(struct tipc_link *l); 11338206d59SJon Paul Maloy char *tipc_link_name(struct tipc_link *l); 114c140eb16SLUU Duc Canh u32 tipc_link_state(struct tipc_link *l); 11538206d59SJon Paul Maloy char tipc_link_plane(struct tipc_link *l); 11638206d59SJon Paul Maloy int tipc_link_prio(struct tipc_link *l); 11716ad3f40SJon Maloy int tipc_link_min_win(struct tipc_link *l); 11816ad3f40SJon Maloy int tipc_link_max_win(struct tipc_link *l); 1199012de50SJon Maloy void tipc_link_update_caps(struct tipc_link *l, u16 capabilities); 1207ea817f4SJon Maloy bool tipc_link_validate_msg(struct tipc_link *l, struct tipc_msg *hdr); 12138206d59SJon Paul Maloy unsigned long tipc_link_tolerance(struct tipc_link *l); 122d01332f1SRichard Alpe void tipc_link_set_tolerance(struct tipc_link *l, u32 tol, 123d01332f1SRichard Alpe struct sk_buff_head *xmitq); 124d01332f1SRichard Alpe void tipc_link_set_prio(struct tipc_link *l, u32 prio, 125d01332f1SRichard Alpe struct sk_buff_head *xmitq); 12638206d59SJon Paul Maloy void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit); 12716ad3f40SJon Maloy void tipc_link_set_queue_limits(struct tipc_link *l, u32 min_win, u32 max_win); 1285be9c086SJon Paul Maloy int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, 1295be9c086SJon Paul Maloy struct tipc_link *link, int nlflags); 1300655f6a8SRichard Alpe int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); 131333ef69eSJon Paul Maloy int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq); 132d999297cSJon Paul Maloy int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb, 133d999297cSJon Paul Maloy struct sk_buff_head *xmitq); 13434b9cd64SJon Paul Maloy int tipc_link_build_state_msg(struct tipc_link *l, struct sk_buff_head *xmitq); 13552666986SJon Paul Maloy void tipc_link_add_bc_peer(struct tipc_link *snd_l, 13652666986SJon Paul Maloy struct tipc_link *uc_l, 13752666986SJon Paul Maloy struct sk_buff_head *xmitq); 13852666986SJon Paul Maloy void tipc_link_remove_bc_peer(struct tipc_link *snd_l, 13952666986SJon Paul Maloy struct tipc_link *rcv_l, 14052666986SJon Paul Maloy struct sk_buff_head *xmitq); 1412f566124SJon Paul Maloy int tipc_link_bc_peers(struct tipc_link *l); 142959e1781SJon Paul Maloy void tipc_link_set_mtu(struct tipc_link *l, int mtu); 143959e1781SJon Paul Maloy int tipc_link_mtu(struct tipc_link *l); 144fc1b6d6dSTuong Lien int tipc_link_mss(struct tipc_link *l); 145d7626b5aSTuong Lien u16 tipc_get_gap_ack_blks(struct tipc_gap_ack_blks **ga, struct tipc_link *l, 146d7626b5aSTuong Lien struct tipc_msg *hdr, bool uc); 147d7626b5aSTuong Lien int tipc_link_bc_ack_rcv(struct tipc_link *l, u16 acked, u16 gap, 148d7626b5aSTuong Lien struct tipc_gap_ack_blks *ga, 149a91d55d1STuong Lien struct sk_buff_head *xmitq, 150a91d55d1STuong Lien struct sk_buff_head *retrq); 15152666986SJon Paul Maloy void tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr); 15202d11ca2SJon Paul Maloy int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr, 15352666986SJon Paul Maloy struct sk_buff_head *xmitq); 15452666986SJon Paul Maloy int tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb, 15552666986SJon Paul Maloy struct sk_buff_head *xmitq); 15626574db0STuong Lien bool tipc_link_too_silent(struct tipc_link *l); 157*be07f056SXin Long struct net *tipc_link_net(struct tipc_link *l); 158b97bf3fdSPer Liden #endif 159