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