18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * net/tipc/link.h: Include file for TIPC link code 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 1995-2006, 2013-2014, Ericsson AB 58c2ecf20Sopenharmony_ci * Copyright (c) 2004-2005, 2010-2011, Wind River Systems 68c2ecf20Sopenharmony_ci * All rights reserved. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 98c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions are met: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 128c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 138c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 148c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in the 158c2ecf20Sopenharmony_ci * documentation and/or other materials provided with the distribution. 168c2ecf20Sopenharmony_ci * 3. Neither the names of the copyright holders nor the names of its 178c2ecf20Sopenharmony_ci * contributors may be used to endorse or promote products derived from 188c2ecf20Sopenharmony_ci * this software without specific prior written permission. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 218c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 228c2ecf20Sopenharmony_ci * Software Foundation. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 258c2ecf20Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 268c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 278c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 288c2ecf20Sopenharmony_ci * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 298c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 308c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 318c2ecf20Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 328c2ecf20Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 338c2ecf20Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 348c2ecf20Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGE. 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#ifndef _TIPC_LINK_H 388c2ecf20Sopenharmony_ci#define _TIPC_LINK_H 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#include <net/genetlink.h> 418c2ecf20Sopenharmony_ci#include "msg.h" 428c2ecf20Sopenharmony_ci#include "node.h" 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* TIPC-specific error codes 458c2ecf20Sopenharmony_ci*/ 468c2ecf20Sopenharmony_ci#define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* Link FSM events: 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_cienum { 518c2ecf20Sopenharmony_ci LINK_ESTABLISH_EVT = 0xec1ab1e, 528c2ecf20Sopenharmony_ci LINK_PEER_RESET_EVT = 0x9eed0e, 538c2ecf20Sopenharmony_ci LINK_FAILURE_EVT = 0xfa110e, 548c2ecf20Sopenharmony_ci LINK_RESET_EVT = 0x10ca1d0e, 558c2ecf20Sopenharmony_ci LINK_FAILOVER_BEGIN_EVT = 0xfa110bee, 568c2ecf20Sopenharmony_ci LINK_FAILOVER_END_EVT = 0xfa110ede, 578c2ecf20Sopenharmony_ci LINK_SYNCH_BEGIN_EVT = 0xc1ccbee, 588c2ecf20Sopenharmony_ci LINK_SYNCH_END_EVT = 0xc1ccede 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* Events returned from link at packet reception or at timeout 628c2ecf20Sopenharmony_ci */ 638c2ecf20Sopenharmony_cienum { 648c2ecf20Sopenharmony_ci TIPC_LINK_UP_EVT = 1, 658c2ecf20Sopenharmony_ci TIPC_LINK_DOWN_EVT = (1 << 1), 668c2ecf20Sopenharmony_ci TIPC_LINK_SND_STATE = (1 << 2) 678c2ecf20Sopenharmony_ci}; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* Starting value for maximum packet size negotiation on unicast links 708c2ecf20Sopenharmony_ci * (unless bearer MTU is less) 718c2ecf20Sopenharmony_ci */ 728c2ecf20Sopenharmony_ci#define MAX_PKT_DEFAULT 1500 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cibool tipc_link_create(struct net *net, char *if_name, int bearer_id, 758c2ecf20Sopenharmony_ci int tolerance, char net_plane, u32 mtu, int priority, 768c2ecf20Sopenharmony_ci u32 min_win, u32 max_win, u32 session, u32 ownnode, 778c2ecf20Sopenharmony_ci u32 peer, u8 *peer_id, u16 peer_caps, 788c2ecf20Sopenharmony_ci struct tipc_link *bc_sndlink, 798c2ecf20Sopenharmony_ci struct tipc_link *bc_rcvlink, 808c2ecf20Sopenharmony_ci struct sk_buff_head *inputq, 818c2ecf20Sopenharmony_ci struct sk_buff_head *namedq, 828c2ecf20Sopenharmony_ci struct tipc_link **link); 838c2ecf20Sopenharmony_cibool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, u8 *peer_id, 848c2ecf20Sopenharmony_ci int mtu, u32 min_win, u32 max_win, u16 peer_caps, 858c2ecf20Sopenharmony_ci struct sk_buff_head *inputq, 868c2ecf20Sopenharmony_ci struct sk_buff_head *namedq, 878c2ecf20Sopenharmony_ci struct tipc_link *bc_sndlink, 888c2ecf20Sopenharmony_ci struct tipc_link **link); 898c2ecf20Sopenharmony_civoid tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl, 908c2ecf20Sopenharmony_ci int mtyp, struct sk_buff_head *xmitq); 918c2ecf20Sopenharmony_civoid tipc_link_create_dummy_tnl_msg(struct tipc_link *tnl, 928c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 938c2ecf20Sopenharmony_civoid tipc_link_failover_prepare(struct tipc_link *l, struct tipc_link *tnl, 948c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 958c2ecf20Sopenharmony_civoid tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq); 968c2ecf20Sopenharmony_ciint tipc_link_fsm_evt(struct tipc_link *l, int evt); 978c2ecf20Sopenharmony_cibool tipc_link_is_up(struct tipc_link *l); 988c2ecf20Sopenharmony_cibool tipc_link_peer_is_down(struct tipc_link *l); 998c2ecf20Sopenharmony_cibool tipc_link_is_reset(struct tipc_link *l); 1008c2ecf20Sopenharmony_cibool tipc_link_is_establishing(struct tipc_link *l); 1018c2ecf20Sopenharmony_cibool tipc_link_is_synching(struct tipc_link *l); 1028c2ecf20Sopenharmony_cibool tipc_link_is_failingover(struct tipc_link *l); 1038c2ecf20Sopenharmony_cibool tipc_link_is_blocked(struct tipc_link *l); 1048c2ecf20Sopenharmony_civoid tipc_link_set_active(struct tipc_link *l, bool active); 1058c2ecf20Sopenharmony_civoid tipc_link_reset(struct tipc_link *l); 1068c2ecf20Sopenharmony_civoid tipc_link_reset_stats(struct tipc_link *l); 1078c2ecf20Sopenharmony_ciint tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list, 1088c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1098c2ecf20Sopenharmony_cistruct sk_buff_head *tipc_link_inputq(struct tipc_link *l); 1108c2ecf20Sopenharmony_ciu16 tipc_link_rcv_nxt(struct tipc_link *l); 1118c2ecf20Sopenharmony_ciu16 tipc_link_acked(struct tipc_link *l); 1128c2ecf20Sopenharmony_ciu32 tipc_link_id(struct tipc_link *l); 1138c2ecf20Sopenharmony_cichar *tipc_link_name(struct tipc_link *l); 1148c2ecf20Sopenharmony_ciu32 tipc_link_state(struct tipc_link *l); 1158c2ecf20Sopenharmony_cichar tipc_link_plane(struct tipc_link *l); 1168c2ecf20Sopenharmony_ciint tipc_link_prio(struct tipc_link *l); 1178c2ecf20Sopenharmony_ciint tipc_link_min_win(struct tipc_link *l); 1188c2ecf20Sopenharmony_ciint tipc_link_max_win(struct tipc_link *l); 1198c2ecf20Sopenharmony_civoid tipc_link_update_caps(struct tipc_link *l, u16 capabilities); 1208c2ecf20Sopenharmony_cibool tipc_link_validate_msg(struct tipc_link *l, struct tipc_msg *hdr); 1218c2ecf20Sopenharmony_ciunsigned long tipc_link_tolerance(struct tipc_link *l); 1228c2ecf20Sopenharmony_civoid tipc_link_set_tolerance(struct tipc_link *l, u32 tol, 1238c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1248c2ecf20Sopenharmony_civoid tipc_link_set_prio(struct tipc_link *l, u32 prio, 1258c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1268c2ecf20Sopenharmony_civoid tipc_link_set_abort_limit(struct tipc_link *l, u32 limit); 1278c2ecf20Sopenharmony_civoid tipc_link_set_queue_limits(struct tipc_link *l, u32 min_win, u32 max_win); 1288c2ecf20Sopenharmony_ciint __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, 1298c2ecf20Sopenharmony_ci struct tipc_link *link, int nlflags); 1308c2ecf20Sopenharmony_ciint tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); 1318c2ecf20Sopenharmony_ciint tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq); 1328c2ecf20Sopenharmony_ciint tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb, 1338c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1348c2ecf20Sopenharmony_ciint tipc_link_build_state_msg(struct tipc_link *l, struct sk_buff_head *xmitq); 1358c2ecf20Sopenharmony_civoid tipc_link_add_bc_peer(struct tipc_link *snd_l, 1368c2ecf20Sopenharmony_ci struct tipc_link *uc_l, 1378c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1388c2ecf20Sopenharmony_civoid tipc_link_remove_bc_peer(struct tipc_link *snd_l, 1398c2ecf20Sopenharmony_ci struct tipc_link *rcv_l, 1408c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1418c2ecf20Sopenharmony_ciint tipc_link_bc_peers(struct tipc_link *l); 1428c2ecf20Sopenharmony_civoid tipc_link_set_mtu(struct tipc_link *l, int mtu); 1438c2ecf20Sopenharmony_ciint tipc_link_mtu(struct tipc_link *l); 1448c2ecf20Sopenharmony_ciint tipc_link_mss(struct tipc_link *l); 1458c2ecf20Sopenharmony_ciu16 tipc_get_gap_ack_blks(struct tipc_gap_ack_blks **ga, struct tipc_link *l, 1468c2ecf20Sopenharmony_ci struct tipc_msg *hdr, bool uc); 1478c2ecf20Sopenharmony_ciint tipc_link_bc_ack_rcv(struct tipc_link *l, u16 acked, u16 gap, 1488c2ecf20Sopenharmony_ci struct tipc_gap_ack_blks *ga, 1498c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq, 1508c2ecf20Sopenharmony_ci struct sk_buff_head *retrq); 1518c2ecf20Sopenharmony_civoid tipc_link_build_bc_sync_msg(struct tipc_link *l, 1528c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1538c2ecf20Sopenharmony_civoid tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr); 1548c2ecf20Sopenharmony_ciint tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr, 1558c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1568c2ecf20Sopenharmony_ciint tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb, 1578c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 1588c2ecf20Sopenharmony_cibool tipc_link_too_silent(struct tipc_link *l); 1598c2ecf20Sopenharmony_cistruct net *tipc_link_net(struct tipc_link *l); 1608c2ecf20Sopenharmony_ci#endif 161