Lines Matching +full:- +full:l

4  * Copyright (c) 1996-2007, 2012-2016, Ericsson AB
5 * Copyright (c) 2004-2007, 2010-2013, Wind River Systems
82 * struct tipc_link - TIPC link data structure
244 static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
246 static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
250 static void link_print(struct tipc_link *l, const char *str);
251 static int tipc_link_build_nack_msg(struct tipc_link *l,
253 static void tipc_link_build_bc_init_msg(struct tipc_link *l,
256 struct tipc_link *l, u8 start_index);
257 static u16 tipc_build_gap_ack_blks(struct tipc_link *l, struct tipc_msg *hdr);
258 static int tipc_link_advance_transmq(struct tipc_link *l, struct tipc_link *r,
263 static void tipc_link_update_cwin(struct tipc_link *l, int released,
266 * Simple non-static link routines (i.e. referenced outside this file)
268 bool tipc_link_is_up(struct tipc_link *l)
270 return l->state & (LINK_ESTABLISHED | LINK_SYNCHING);
273 bool tipc_link_peer_is_down(struct tipc_link *l)
275 return l->state == LINK_PEER_RESET;
278 bool tipc_link_is_reset(struct tipc_link *l)
280 return l->state & (LINK_RESET | LINK_FAILINGOVER | LINK_ESTABLISHING);
283 bool tipc_link_is_establishing(struct tipc_link *l)
285 return l->state == LINK_ESTABLISHING;
288 bool tipc_link_is_synching(struct tipc_link *l)
290 return l->state == LINK_SYNCHING;
293 bool tipc_link_is_failingover(struct tipc_link *l)
295 return l->state == LINK_FAILINGOVER;
298 bool tipc_link_is_blocked(struct tipc_link *l)
300 return l->state & (LINK_RESETTING | LINK_PEER_RESET | LINK_FAILINGOVER);
303 static bool link_is_bc_sndlink(struct tipc_link *l)
305 return !l->bc_sndlink;
308 static bool link_is_bc_rcvlink(struct tipc_link *l)
310 return ((l->bc_rcvlink == l) && !link_is_bc_sndlink(l));
313 void tipc_link_set_active(struct tipc_link *l, bool active)
315 l->active = active;
318 u32 tipc_link_id(struct tipc_link *l)
320 return l->peer_bearer_id << 16 | l->bearer_id;
323 int tipc_link_min_win(struct tipc_link *l)
325 return l->min_win;
328 int tipc_link_max_win(struct tipc_link *l)
330 return l->max_win;
333 int tipc_link_prio(struct tipc_link *l)
335 return l->priority;
338 unsigned long tipc_link_tolerance(struct tipc_link *l)
340 return l->tolerance;
343 struct sk_buff_head *tipc_link_inputq(struct tipc_link *l)
345 return l->inputq;
348 char tipc_link_plane(struct tipc_link *l)
350 return l->net_plane;
353 struct net *tipc_link_net(struct tipc_link *l)
355 return l->net;
358 void tipc_link_update_caps(struct tipc_link *l, u16 capabilities)
360 l->peer_caps = capabilities;
367 struct tipc_link *rcv_l = uc_l->bc_rcvlink;
369 snd_l->ackers++;
370 rcv_l->acked = snd_l->snd_nxt - 1;
371 snd_l->state = LINK_ESTABLISHED;
379 u16 ack = snd_l->snd_nxt - 1;
381 snd_l->ackers--;
382 rcv_l->bc_peer_is_up = true;
383 rcv_l->state = LINK_ESTABLISHED;
387 rcv_l->state = LINK_RESET;
388 if (!snd_l->ackers) {
391 snd_l->state = LINK_RESET;
396 int tipc_link_bc_peers(struct tipc_link *l)
398 return l->ackers;
401 static u16 link_bc_rcv_gap(struct tipc_link *l)
403 struct sk_buff *skb = skb_peek(&l->deferdq);
406 if (more(l->snd_nxt, l->rcv_nxt))
407 gap = l->snd_nxt - l->rcv_nxt;
409 gap = buf_seqno(skb) - l->rcv_nxt;
413 void tipc_link_set_mtu(struct tipc_link *l, int mtu)
415 l->mtu = mtu;
418 int tipc_link_mtu(struct tipc_link *l)
420 return l->mtu;
423 int tipc_link_mss(struct tipc_link *l)
426 return l->mtu - INT_H_SIZE - EMSG_OVERHEAD;
428 return l->mtu - INT_H_SIZE;
432 u16 tipc_link_rcv_nxt(struct tipc_link *l)
434 return l->rcv_nxt;
437 u16 tipc_link_acked(struct tipc_link *l)
439 return l->acked;
442 char *tipc_link_name(struct tipc_link *l)
444 return l->name;
447 u32 tipc_link_state(struct tipc_link *l)
449 return l->state;
453 * tipc_link_create - create a new link
472 * @peer_id: 128-bit ID of peer
488 struct tipc_link *l;
490 l = kzalloc(sizeof(*l), GFP_ATOMIC);
491 if (!l)
493 *link = l;
494 l->session = session;
504 snprintf(l->name, sizeof(l->name), "%s:%s-%s:unknown",
507 strcpy(l->if_name, if_name);
508 l->addr = peer;
509 l->peer_caps = peer_caps;
510 l->net = net;
511 l->in_session = false;
512 l->bearer_id = bearer_id;
513 l->tolerance = tolerance;
515 bc_rcvlink->tolerance = tolerance;
516 l->net_plane = net_plane;
517 l->advertised_mtu = mtu;
518 l->mtu = mtu;
519 l->priority = priority;
520 tipc_link_set_queue_limits(l, min_win, max_win);
521 l->ackers = 1;
522 l->bc_sndlink = bc_sndlink;
523 l->bc_rcvlink = bc_rcvlink;
524 l->inputq = inputq;
525 l->namedq = namedq;
526 l->state = LINK_RESETTING;
527 __skb_queue_head_init(&l->transmq);
528 __skb_queue_head_init(&l->backlogq);
529 __skb_queue_head_init(&l->deferdq);
530 __skb_queue_head_init(&l->failover_deferdq);
531 skb_queue_head_init(&l->wakeupq);
532 skb_queue_head_init(l->inputq);
537 * tipc_link_bc_create - create new link to be used for broadcast
547 * @peer_id: 128-bit ID of peer
560 struct tipc_link *l;
567 l = *link;
573 /* Broadcast receiver link name: "broadcast-link:<peer>" */
574 snprintf(l->name, sizeof(l->name), "%s:%s", tipc_bclink_name,
577 strcpy(l->name, tipc_bclink_name);
579 trace_tipc_link_reset(l, TIPC_DUMP_ALL, "bclink created!");
580 tipc_link_reset(l);
581 l->state = LINK_RESET;
582 l->ackers = 0;
583 l->bc_rcvlink = l;
586 if (link_is_bc_sndlink(l))
587 l->state = LINK_ESTABLISHED;
590 if (link_is_bc_rcvlink(l) && !(peer_caps & TIPC_BCAST_RCAST))
597 * tipc_link_fsm_evt - link finite state machine
598 * @l: pointer to link
601 int tipc_link_fsm_evt(struct tipc_link *l, int evt)
604 int old_state = l->state;
606 switch (l->state) {
610 l->state = LINK_PEER_RESET;
613 l->state = LINK_RESET;
628 l->state = LINK_ESTABLISHING;
631 l->state = LINK_FAILINGOVER;
647 l->state = LINK_ESTABLISHING;
664 l->state = LINK_RESET;
681 l->state = LINK_ESTABLISHED;
684 l->state = LINK_FAILINGOVER;
687 l->state = LINK_RESET;
702 l->state = LINK_PEER_RESET;
706 l->state = LINK_RESETTING;
710 l->state = LINK_RESET;
716 l->state = LINK_SYNCHING;
727 l->state = LINK_PEER_RESET;
731 l->state = LINK_RESETTING;
735 l->state = LINK_RESET;
741 l->state = LINK_ESTABLISHED;
750 pr_err("Unknown FSM state %x in %s\n", l->state, l->name);
752 trace_tipc_link_fsm(l->name, old_state, l->state, evt);
756 evt, l->state, l->name);
757 trace_tipc_link_fsm(l->name, old_state, l->state, evt);
761 /* link_profile_stats - update statistical profiling of traffic
763 static void link_profile_stats(struct tipc_link *l)
770 l->stats.accu_queue_sz += skb_queue_len(&l->transmq);
771 l->stats.queue_sz_counts++;
773 skb = skb_peek(&l->transmq);
784 l->stats.msg_lengths_total += length;
785 l->stats.msg_length_counts++;
787 l->stats.msg_length_profile[0]++;
789 l->stats.msg_length_profile[1]++;
791 l->stats.msg_length_profile[2]++;
793 l->stats.msg_length_profile[3]++;
795 l->stats.msg_length_profile[4]++;
797 l->stats.msg_length_profile[5]++;
799 l->stats.msg_length_profile[6]++;
803 * tipc_link_too_silent - check if link is "too silent"
804 * @l: tipc link to be checked
809 bool tipc_link_too_silent(struct tipc_link *l)
811 return (l->silent_intv_cnt + 2 > l->abort_limit);
814 /* tipc_link_timeout - perform periodic task as instructed from node timeout
816 int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
823 u16 bc_snt = l->bc_sndlink->snd_nxt - 1;
824 u16 bc_acked = l->bc_rcvlink->acked;
825 struct tipc_mon_state *mstate = &l->mon_state;
827 trace_tipc_link_timeout(l, TIPC_DUMP_NONE, " ");
828 trace_tipc_link_too_silent(l, TIPC_DUMP_ALL, " ");
829 switch (l->state) {
833 link_profile_stats(l);
834 tipc_mon_get_state(l->net, l->addr, mstate, l->bearer_id);
835 if (mstate->reset || (l->silent_intv_cnt > l->abort_limit))
836 return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
838 state |= l->bc_rcvlink->rcv_unacked;
839 state |= l->rcv_unacked;
840 state |= !skb_queue_empty(&l->transmq);
841 probe = mstate->probing;
842 probe |= l->silent_intv_cnt;
843 if (probe || mstate->monitoring)
844 l->silent_intv_cnt++;
845 probe |= !skb_queue_empty(&l->deferdq);
846 if (l->snd_nxt == l->checkpoint) {
847 tipc_link_update_cwin(l, 0, 0);
850 l->checkpoint = l->snd_nxt;
853 setup = l->rst_cnt++ <= 4;
854 setup |= !(l->rst_cnt % 16);
870 tipc_link_build_proto_msg(l, mtyp, probe, 0, 0, 0, 0, xmitq);
876 * link_schedule_user - schedule a message sender for wakeup after congestion
877 * @l: congested link
881 static int link_schedule_user(struct tipc_link *l, struct tipc_msg *hdr)
883 u32 dnode = tipc_own_addr(l->net);
889 dnode, l->addr, dport, 0, 0);
891 return -ENOBUFS;
893 TIPC_SKB_CB(skb)->chain_imp = msg_importance(hdr);
894 skb_queue_tail(&l->wakeupq, skb);
895 l->stats.link_congs++;
896 trace_tipc_link_conges(l, TIPC_DUMP_ALL, "wakeup scheduled!");
897 return -ELINKCONG;
901 * link_prepare_wakeup - prepare users for wakeup after congestion
902 * @l: congested link
906 static void link_prepare_wakeup(struct tipc_link *l)
908 struct sk_buff_head *wakeupq = &l->wakeupq;
909 struct sk_buff_head *inputq = l->inputq;
918 avail[imp] = l->backlog[imp].limit - l->backlog[imp].len;
921 imp = TIPC_SKB_CB(skb)->chain_imp;
924 avail[imp]--;
929 spin_lock_bh(&inputq->lock);
931 spin_unlock_bh(&inputq->lock);
936 * tipc_link_set_skb_retransmit_time - set the time at which retransmission of
939 * @l: link the skb will be transmitted on
942 struct tipc_link *l)
944 if (link_is_bc_sndlink(l))
945 TIPC_SKB_CB(skb)->nxt_retr = TIPC_BC_RETR_LIM;
947 TIPC_SKB_CB(skb)->nxt_retr = TIPC_UC_RETR_TIME;
950 void tipc_link_reset(struct tipc_link *l)
957 l->in_session = false;
958 /* Force re-synch of peer session number before establishing */
959 l->peer_session--;
960 l->session++;
961 l->mtu = l->advertised_mtu;
963 spin_lock_bh(&l->wakeupq.lock);
964 skb_queue_splice_init(&l->wakeupq, &list);
965 spin_unlock_bh(&l->wakeupq.lock);
967 spin_lock_bh(&l->inputq->lock);
968 skb_queue_splice_init(&list, l->inputq);
969 spin_unlock_bh(&l->inputq->lock);
971 __skb_queue_purge(&l->transmq);
972 __skb_queue_purge(&l->deferdq);
973 __skb_queue_purge(&l->backlogq);
974 __skb_queue_purge(&l->failover_deferdq);
976 l->backlog[imp].len = 0;
977 l->backlog[imp].target_bskb = NULL;
979 kfree_skb(l->reasm_buf);
980 kfree_skb(l->reasm_tnlmsg);
981 kfree_skb(l->failover_reasm_skb);
982 l->reasm_buf = NULL;
983 l->reasm_tnlmsg = NULL;
984 l->failover_reasm_skb = NULL;
985 l->rcv_unacked = 0;
986 l->snd_nxt = 1;
987 l->rcv_nxt = 1;
988 l->snd_nxt_state = 1;
989 l->rcv_nxt_state = 1;
990 l->acked = 0;
991 l->last_gap = 0;
992 kfree(l->last_ga);
993 l->last_ga = NULL;
994 l->silent_intv_cnt = 0;
995 l->rst_cnt = 0;
996 l->bc_peer_is_up = false;
997 memset(&l->mon_state, 0, sizeof(l->mon_state));
998 tipc_link_reset_stats(l);
1003 * @l: link to use
1009 * Return: 0 if success, or errno: -ELINKCONG, -EMSGSIZE or -ENOBUFS
1011 int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
1014 struct sk_buff_head *backlogq = &l->backlogq;
1015 struct sk_buff_head *transmq = &l->transmq;
1017 u16 bc_ack = l->bc_rcvlink->rcv_nxt - 1;
1018 u16 ack = l->rcv_nxt - 1;
1019 u16 seqno = l->snd_nxt;
1021 unsigned int mss = tipc_link_mss(l);
1022 unsigned int cwin = l->window;
1023 unsigned int mtu = l->mtu;
1038 return -EMSGSIZE;
1043 if (unlikely(l->backlog[imp].len >= l->backlog[imp].limit)) {
1045 pr_warn("%s<%s>, link overflow", link_rst_msg, l->name);
1047 return -ENOBUFS;
1049 rc = link_schedule_user(l, hdr);
1053 l->stats.sent_fragmented++;
1054 l->stats.sent_fragments += pkt_cnt;
1068 return -ENOBUFS;
1071 tipc_link_set_skb_retransmit_time(skb, l);
1073 TIPC_SKB_CB(skb)->ackers = l->ackers;
1074 l->rcv_unacked = 0;
1075 l->stats.sent_pkts++;
1079 if (tipc_msg_try_bundle(l->backlog[imp].target_bskb, &skb,
1080 mss, l->addr, &new_bundle)) {
1083 l->backlog[imp].target_bskb = skb;
1084 l->backlog[imp].len++;
1088 l->stats.sent_bundles++;
1089 l->stats.sent_bundled++;
1091 l->stats.sent_bundled++;
1095 l->backlog[imp].target_bskb = NULL;
1096 l->backlog[imp].len += (1 + skb_queue_len(list));
1100 l->snd_nxt = seqno;
1104 static void tipc_link_update_cwin(struct tipc_link *l, int released,
1107 int bklog_len = skb_queue_len(&l->backlogq);
1108 struct sk_buff_head *txq = &l->transmq;
1110 u16 cwin = l->window;
1114 l->ssthresh = max_t(u16, l->window / 2, 300);
1115 l->window = min_t(u16, l->ssthresh, l->window);
1120 l->ssthresh = max_t(u16, l->window / 2, 300);
1121 l->window = l->min_win;
1129 if (txq_len && l->snd_nxt - buf_seqno(skb_peek(txq)) != txq_len)
1132 l->cong_acks += released;
1135 if (cwin <= l->ssthresh) {
1136 l->window = min_t(u16, cwin + released, l->max_win);
1140 if (l->cong_acks < cwin)
1142 l->window = min_t(u16, ++cwin, l->max_win);
1143 l->cong_acks = 0;
1146 static void tipc_link_advance_backlog(struct tipc_link *l,
1149 u16 bc_ack = l->bc_rcvlink->rcv_nxt - 1;
1150 struct sk_buff_head *txq = &l->transmq;
1152 u16 ack = l->rcv_nxt - 1;
1153 u16 seqno = l->snd_nxt;
1155 u16 cwin = l->window;
1159 skb = skb_peek(&l->backlogq);
1165 __skb_dequeue(&l->backlogq);
1168 l->backlog[imp].len--;
1169 if (unlikely(skb == l->backlog[imp].target_bskb))
1170 l->backlog[imp].target_bskb = NULL;
1171 __skb_queue_tail(&l->transmq, skb);
1172 tipc_link_set_skb_retransmit_time(skb, l);
1175 TIPC_SKB_CB(skb)->ackers = l->ackers;
1179 l->rcv_unacked = 0;
1180 l->stats.sent_pkts++;
1183 l->snd_nxt = seqno;
1187 * link_retransmit_failure() - Detect repeated retransmit failures
1188 * @l: tipc link sender
1189 * @r: tipc link receiver (= l in case of unicast)
1195 static bool link_retransmit_failure(struct tipc_link *l, struct tipc_link *r,
1198 struct sk_buff *skb = skb_peek(&l->transmq);
1204 if (!TIPC_SKB_CB(skb)->retr_cnt)
1207 if (!time_after(jiffies, TIPC_SKB_CB(skb)->retr_stamp +
1208 msecs_to_jiffies(r->tolerance * 10)))
1212 if (link_is_bc_sndlink(l) && !less(r->acked, msg_seqno(hdr)))
1215 pr_warn("Retransmission failure on link <%s>\n", l->name);
1216 link_print(l, "State of link ");
1222 jiffies_to_msecs(TIPC_SKB_CB(skb)->retr_stamp),
1223 TIPC_SKB_CB(skb)->retr_cnt);
1225 trace_tipc_list_dump(&l->transmq, true, "retrans failure!");
1226 trace_tipc_link_dump(l, TIPC_DUMP_NONE, "retrans failure!");
1229 if (link_is_bc_sndlink(l)) {
1230 r->state = LINK_RESET;
1233 *rc |= tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
1239 /* tipc_data_input - deliver data and name distr msgs to upper layer
1244 static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb,
1247 struct sk_buff_head *mc_inputq = l->bc_rcvlink->inputq;
1267 l->bc_rcvlink->state = LINK_ESTABLISHED;
1268 skb_queue_tail(l->namedq, skb);
1278 TIPC_SKB_CB(skb)->decrypted) {
1279 tipc_crypto_msg_rcv(l->net, skb);
1291 /* tipc_link_input - process packet that has passed link protocol check
1295 static int tipc_link_input(struct tipc_link *l, struct sk_buff *skb,
1307 l->stats.recv_bundles++;
1308 l->stats.recv_bundled += msg_msgcnt(hdr);
1310 tipc_data_input(l, iskb, &tmpq);
1314 l->stats.recv_fragments++;
1316 l->stats.recv_fragmented++;
1317 tipc_data_input(l, skb, inputq);
1318 } else if (!*reasm_skb && !link_is_bc_rcvlink(l)) {
1320 return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
1324 tipc_bcast_lock(l->net);
1325 tipc_link_bc_init_rcv(l->bc_rcvlink, hdr);
1326 tipc_bcast_unlock(l->net);
1333 /* tipc_link_tnl_rcv() - receive TUNNEL_PROTOCOL message, drop or process the
1336 * @l: tunnel link
1340 static int tipc_link_tnl_rcv(struct tipc_link *l, struct sk_buff *skb,
1343 struct sk_buff **reasm_skb = &l->failover_reasm_skb;
1344 struct sk_buff **reasm_tnlmsg = &l->reasm_tnlmsg;
1345 struct sk_buff_head *fdefq = &l->failover_deferdq;
1375 /* Successful but non-complete reassembly? */
1376 if (*reasm_tnlmsg || link_is_bc_rcvlink(l))
1379 return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
1386 if (unlikely(less(seqno, l->drop_point))) {
1390 if (unlikely(seqno != l->drop_point)) {
1395 l->drop_point++;
1396 if (!tipc_data_input(l, iskb, inputq))
1397 rc |= tipc_link_input(l, iskb, inputq, reasm_skb);
1400 } while ((iskb = __tipc_skb_dequeue(fdefq, l->drop_point)));
1406 * tipc_get_gap_ack_blks - get Gap ACK blocks from PROTOCOL/STATE_MSG
1408 * @l: the tipc link
1414 u16 tipc_get_gap_ack_blks(struct tipc_gap_ack_blks **ga, struct tipc_link *l,
1421 if (l->peer_caps & TIPC_GAP_ACK_BLOCK) {
1423 sz = ntohs(p->len);
1425 if (sz == struct_size(p, gacks, size_add(p->ugack_cnt, p->bgack_cnt))) {
1427 if ((uc && p->ugack_cnt) || (!uc && p->bgack_cnt))
1430 } else if (uc && sz == struct_size(p, gacks, p->ugack_cnt)) {
1431 if (p->ugack_cnt) {
1432 p->bgack_cnt = 0;
1446 struct tipc_link *l, u8 start_index)
1448 struct tipc_gap_ack *gacks = &ga->gacks[start_index];
1449 struct sk_buff *skb = skb_peek(&l->deferdq);
1457 skb_queue_walk(&l->deferdq, skb) {
1460 gacks[n].ack = htons(expect - 1);
1461 gacks[n].gap = htons(seqno - expect);
1464 l->name, n,
1465 skb_queue_len(&l->deferdq));
1482 /* tipc_build_gap_ack_blks - build Gap ACK blocks
1483 * @l: tipc unicast link
1492 static u16 tipc_build_gap_ack_blks(struct tipc_link *l, struct tipc_msg *hdr)
1494 struct tipc_link *bcl = l->bc_rcvlink;
1501 tipc_bcast_lock(bcl->net);
1502 msg_set_bcast_ack(hdr, bcl->rcv_nxt - 1);
1504 ga->bgack_cnt = __tipc_build_gap_ack_blks(ga, bcl, 0);
1505 tipc_bcast_unlock(bcl->net);
1508 ga->ugack_cnt = (msg_seq_gap(hdr)) ?
1509 __tipc_build_gap_ack_blks(ga, l, ga->bgack_cnt) : 0;
1512 len = struct_size(ga, gacks, size_add(ga->bgack_cnt, ga->ugack_cnt));
1513 ga->len = htons(len);
1517 /* tipc_link_advance_transmq - advance TIPC link transmq queue by releasing
1520 * @l: tipc link with transmq queue to be advanced
1521 * @r: tipc link "receiver" i.e. in case of broadcast (= "l" if unicast)
1528 * happens (- unlikely case)
1532 static int tipc_link_advance_transmq(struct tipc_link *l, struct tipc_link *r,
1538 struct tipc_gap_ack_blks *last_ga = r->last_ga, *this_ga = NULL;
1542 u32 qlen = skb_queue_len(&l->transmq);
1544 u16 bc_ack = l->bc_rcvlink->rcv_nxt - 1;
1545 u16 ack = l->rcv_nxt - 1;
1547 u16 end = r->acked, start = end, offset = r->last_gap;
1548 u16 si = (last_ga) ? last_ga->start_index : 0;
1549 bool is_uc = !link_is_bc_sndlink(l);
1552 trace_tipc_link_retrans(r, acked + 1, acked + gap, &l->transmq);
1557 gack_cnt = ga->ugack_cnt;
1558 gacks = &ga->gacks[ga->bgack_cnt];
1561 this_ga = kmemdup(ga, struct_size(ga, gacks, ga->bgack_cnt),
1564 this_ga->start_index = 0;
1566 gack_cnt = this_ga->bgack_cnt;
1567 gacks = &this_ga->gacks[0];
1575 skb_queue_walk_safe(&l->transmq, skb, tmp) {
1583 if (!more(seqno, r->acked))
1587 if (!last_ga || si >= last_ga->bgack_cnt)
1590 end = ntohs(last_ga->gacks[si].ack);
1591 offset = ntohs(last_ga->gacks[si].gap);
1595 si < last_ga->bgack_cnt) ||
1599 last_ga->bgack_cnt);
1606 if (--TIPC_SKB_CB(skb)->ackers)
1610 __skb_unlink(skb, &l->transmq);
1615 link_retransmit_failure(l, r, rc))) {
1622 if (time_before(jiffies, TIPC_SKB_CB(skb)->nxt_retr))
1624 tipc_link_set_skb_retransmit_time(skb, l);
1631 _skb->priority = TC_PRIO_CONTROL;
1633 l->stats.retransmitted++;
1635 r->stats.retransmitted++;
1638 if (!TIPC_SKB_CB(skb)->retr_cnt++)
1639 TIPC_SKB_CB(skb)->retr_stamp = jiffies;
1655 r->last_ga = this_ga;
1656 r->last_gap = gap;
1659 si--;
1660 offset = start - acked - 1;
1664 if (si < last_ga->bgack_cnt) {
1665 last_ga->start_index = si;
1666 r->last_gap = offset;
1669 r->last_ga = NULL;
1670 r->last_gap = 0;
1673 r->last_gap = 0;
1675 r->acked = acked;
1680 return qlen - skb_queue_len(&l->transmq);
1688 int tipc_link_build_state_msg(struct tipc_link *l, struct sk_buff_head *xmitq)
1690 if (!l)
1694 if (link_is_bc_rcvlink(l)) {
1695 if (((l->rcv_nxt ^ tipc_own_addr(l->net)) & 0xf) != 0xf)
1697 l->rcv_unacked = 0;
1700 l->snd_nxt = l->rcv_nxt;
1704 l->rcv_unacked = 0;
1705 l->stats.sent_acks++;
1706 tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, 0, xmitq);
1712 void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq)
1717 if (l->state == LINK_ESTABLISHING)
1720 tipc_link_build_proto_msg(l, mtyp, 0, 0, 0, 0, 0, xmitq);
1724 if (skb && (l->state == LINK_RESET))
1732 static int tipc_link_build_nack_msg(struct tipc_link *l,
1735 u32 def_cnt = ++l->stats.deferred_recv;
1736 struct sk_buff_head *dfq = &l->deferdq;
1740 if (link_is_bc_rcvlink(l)) {
1742 match2 = tipc_own_addr(l->net) & 0xf;
1748 if (defq_len >= 3 && !((defq_len - 3) % 16)) {
1749 u16 rcvgap = buf_seqno(skb_peek(dfq)) - l->rcv_nxt;
1751 tipc_link_build_proto_msg(l, STATE_MSG, 0, 0,
1757 /* tipc_link_rcv - process TIPC packets/messages arriving from off-node
1758 * @l: the link that should handle the message
1762 int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,
1765 struct sk_buff_head *defq = &l->deferdq;
1773 return tipc_link_proto_rcv(l, skb, xmitq);
1776 l->silent_intv_cnt = 0;
1781 rcv_nxt = l->rcv_nxt;
1784 if (unlikely(!tipc_link_is_up(l))) {
1785 if (l->state == LINK_ESTABLISHING)
1793 l->stats.duplicates++;
1797 released += tipc_link_advance_transmq(l, l, msg_ack(hdr), 0,
1803 l->stats.duplicates++;
1804 rc |= tipc_link_build_nack_msg(l, xmitq);
1809 l->rcv_nxt++;
1810 l->stats.recv_pkts++;
1813 rc |= tipc_link_tnl_rcv(l, skb, l->inputq);
1814 else if (!tipc_data_input(l, skb, l->inputq))
1815 rc |= tipc_link_input(l, skb, l->inputq, &l->reasm_buf);
1816 if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN))
1817 rc |= tipc_link_build_state_msg(l, xmitq);
1820 } while ((skb = __tipc_skb_dequeue(defq, l->rcv_nxt)));
1824 tipc_link_update_cwin(l, released, 0);
1825 tipc_link_advance_backlog(l, xmitq);
1826 if (unlikely(!skb_queue_empty(&l->wakeupq)))
1827 link_prepare_wakeup(l);
1832 static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
1837 struct tipc_mon_state *mstate = &l->mon_state;
1838 struct sk_buff_head *dfq = &l->deferdq;
1839 struct tipc_link *bcl = l->bc_rcvlink;
1848 if (tipc_link_is_blocked(l))
1851 if (!tipc_link_is_up(l) && (mtyp == STATE_MSG))
1855 rcvgap = buf_seqno(skb_peek(dfq)) - l->rcv_nxt;
1859 l->addr, tipc_own_addr(l->net), 0, 0, 0);
1865 msg_set_session(hdr, l->session);
1866 msg_set_bearer_id(hdr, l->bearer_id);
1867 msg_set_net_plane(hdr, l->net_plane);
1868 msg_set_next_sent(hdr, l->snd_nxt);
1869 msg_set_ack(hdr, l->rcv_nxt - 1);
1870 msg_set_bcast_ack(hdr, bcl->rcv_nxt - 1);
1872 msg_set_last_bcast(hdr, l->bc_sndlink->snd_nxt - 1);
1877 msg_set_seqno(hdr, l->snd_nxt + U16_MAX / 2);
1880 if (l->peer_caps & TIPC_LINK_PROTO_SEQNO)
1881 msg_set_seqno(hdr, l->snd_nxt_state++);
1887 if (l->peer_caps & TIPC_GAP_ACK_BLOCK)
1888 glen = tipc_build_gap_ack_blks(l, hdr);
1889 tipc_mon_prep(l->net, data + glen, &dlen, mstate, l->bearer_id);
1892 l->stats.sent_states++;
1893 l->rcv_unacked = 0;
1898 msg_set_dest_session(hdr, l->peer_session);
1900 msg_set_max_pkt(hdr, l->advertised_mtu);
1901 strcpy(data, l->if_name);
1906 l->stats.sent_probes++;
1908 l->stats.sent_nacks++;
1910 bcl->stats.sent_nacks++;
1911 skb->priority = TC_PRIO_CONTROL;
1913 trace_tipc_proto_build(skb, false, l->name);
1916 void tipc_link_create_dummy_tnl_msg(struct tipc_link *l,
1919 u32 onode = tipc_own_addr(l->net);
1923 u32 dnode = l->addr;
1936 msg_set_bearer_id(hdr, l->peer_bearer_id);
1943 tipc_link_xmit(l, &tnlq, xmitq);
1949 void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
1954 struct sk_buff_head *queue = &l->transmq;
1956 u16 pktlen, pktcnt, seqno = l->snd_nxt;
1970 if (mtyp == SYNCH_MSG && (tnl->peer_caps & TIPC_TUNNEL_ENHANCED)) {
1972 INT_H_SIZE, 0, l->addr,
1973 tipc_own_addr(l->net),
1982 syncpt = l->snd_nxt + skb_queue_len(&l->backlogq) - 1;
1984 msg_set_bearer_id(hdr, l->peer_bearer_id);
1994 BASIC_H_SIZE, 0, l->addr, tipc_own_addr(l->net),
2001 tipc_link_xmit(l, &tnlq, &tmpxq);
2005 tipc_msg_init(tipc_own_addr(l->net), &tnlhdr, TUNNEL_PROTOCOL,
2006 mtyp, INT_H_SIZE, l->addr);
2008 pktcnt = l->snd_nxt - buf_seqno(skb_peek(&l->transmq));
2010 pktcnt = skb_queue_len(&l->transmq);
2011 pktcnt += skb_queue_len(&l->backlogq);
2013 msg_set_bearer_id(&tnlhdr, l->peer_bearer_id);
2018 if (queue == &l->backlogq)
2030 if (pktlen > tnl->mtu - INT_H_SIZE) {
2032 (tnl->peer_caps & TIPC_TUNNEL_ENHANCED)) {
2033 rc = tipc_msg_fragment(skb, &tnlhdr, tnl->mtu,
2040 pktcnt += skb_queue_len(&frags) - 1;
2064 if (queue != &l->backlogq) {
2065 queue = &l->backlogq;
2078 struct sk_buff_head *fdefq = &tnl->failover_deferdq;
2080 tnl->drop_point = l->rcv_nxt;
2081 tnl->failover_reasm_skb = l->reasm_buf;
2082 l->reasm_buf = NULL;
2090 skb_queue_splice_init(&l->deferdq, fdefq);
2095 * tipc_link_failover_prepare() - prepare tnl for link failover
2097 * This is a special version of the precursor - tipc_link_tnl_prepare(),
2100 * @l: failover link
2104 void tipc_link_failover_prepare(struct tipc_link *l, struct tipc_link *tnl,
2107 struct sk_buff_head *fdefq = &tnl->failover_deferdq;
2117 tnl->drop_point = 1;
2118 tnl->failover_reasm_skb = NULL;
2131 bool tipc_link_validate_msg(struct tipc_link *l, struct tipc_msg *hdr)
2133 u16 curr_session = l->peer_session;
2142 if (!l->in_session)
2147 if (!l->in_session)
2153 if (!l->in_session)
2158 if (!tipc_link_is_up(l) && msg_ack(hdr))
2160 if (!(l->peer_caps & TIPC_LINK_PROTO_SEQNO))
2163 return !less(msg_seqno(hdr), l->rcv_nxt_state);
2174 static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
2186 u16 rcv_nxt = l->rcv_nxt;
2193 trace_tipc_proto_rcv(skb, false, l->name);
2198 if (tipc_link_is_blocked(l) || !xmitq)
2201 if (tipc_own_addr(l->net) > msg_prevnode(hdr))
2202 l->net_plane = msg_net_plane(hdr);
2210 if (!tipc_link_validate_msg(l, hdr)) {
2212 trace_tipc_link_dump(l, TIPC_DUMP_NONE, "PROTO invalid (1)!");
2220 if (msg_max < tipc_bearer_min_mtu(l->net, l->bearer_id))
2223 if_name = strrchr(l->name, ':') + 1;
2224 if (sizeof(l->name) - (if_name - l->name) <= TIPC_MAX_IF_NAME)
2230 /* Update own tolerance if peer indicates a non-zero value */
2232 l->tolerance = peers_tol;
2233 l->bc_rcvlink->tolerance = peers_tol;
2236 if (tipc_in_range(peers_prio, l->priority + 1, TIPC_MAX_LINK_PRI))
2237 l->priority = peers_prio;
2239 /* If peer is going down we want full re-establish cycle */
2241 rc = tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
2245 /* If this endpoint was re-created while peer was ESTABLISHING
2246 * it doesn't know current session number. Force re-synch.
2249 l->session != msg_dest_session(hdr)) {
2250 if (less(l->session, msg_dest_session(hdr)))
2251 l->session = msg_dest_session(hdr) + 1;
2256 if (mtyp == RESET_MSG || !tipc_link_is_up(l))
2257 rc = tipc_link_fsm_evt(l, LINK_PEER_RESET_EVT);
2260 if (mtyp == ACTIVATE_MSG && l->state == LINK_ESTABLISHING)
2263 l->peer_session = msg_session(hdr);
2264 l->in_session = true;
2265 l->peer_bearer_id = msg_bearer_id(hdr);
2266 if (l->mtu > msg_max)
2267 l->mtu = msg_max;
2272 glen = tipc_get_gap_ack_blks(&ga, l, hdr, true);
2276 l->rcv_nxt_state = msg_seqno(hdr) + 1;
2278 /* Update own tolerance if peer indicates a non-zero value */
2280 l->tolerance = peers_tol;
2281 l->bc_rcvlink->tolerance = peers_tol;
2284 if ((peers_prio != l->priority) &&
2286 l->priority = peers_prio;
2287 rc = tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
2290 l->silent_intv_cnt = 0;
2291 l->stats.recv_states++;
2293 l->stats.recv_probes++;
2295 if (!tipc_link_is_up(l)) {
2296 if (l->state == LINK_ESTABLISHING)
2301 tipc_mon_rcv(l->net, data + glen, dlen - glen, l->addr,
2302 &l->mon_state, l->bearer_id);
2307 !tipc_link_is_synching(l) &&
2308 skb_queue_empty(&l->deferdq))
2309 rcvgap = peers_snd_nxt - l->rcv_nxt;
2311 tipc_link_build_proto_msg(l, STATE_MSG, 0, reply,
2314 released = tipc_link_advance_transmq(l, l, ack, gap, ga, xmitq,
2317 l->stats.recv_nacks++;
2319 tipc_link_update_cwin(l, released, retransmitted);
2321 tipc_link_advance_backlog(l, xmitq);
2322 if (unlikely(!skb_queue_empty(&l->wakeupq)))
2323 link_prepare_wakeup(l);
2330 /* tipc_link_build_bc_proto_msg() - create broadcast protocol message
2332 static bool tipc_link_build_bc_proto_msg(struct tipc_link *l, bool bcast,
2338 struct sk_buff *dfrd_skb = skb_peek(&l->deferdq);
2339 u16 ack = l->rcv_nxt - 1;
2340 u16 gap_to = peers_snd_nxt - 1;
2343 0, l->addr, tipc_own_addr(l->net), 0, 0, 0);
2347 msg_set_last_bcast(hdr, l->bc_sndlink->snd_nxt - 1);
2351 gap_to = buf_seqno(dfrd_skb) - 1;
2358 /* tipc_link_build_bc_init_msg() - synchronize broadcast link endpoints.
2363 static void tipc_link_build_bc_init_msg(struct tipc_link *l,
2369 if (!tipc_link_build_bc_proto_msg(l->bc_rcvlink, false, 0, &list))
2372 tipc_link_xmit(l, &list, xmitq);
2375 /* tipc_link_bc_init_rcv - receive initial broadcast synch data from peer
2377 void tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr)
2382 if (tipc_link_is_up(l))
2386 l->rcv_nxt = peers_snd_nxt;
2387 l->state = LINK_ESTABLISHED;
2391 if (l->peer_caps & TIPC_BCAST_SYNCH)
2399 l->rcv_nxt = peers_snd_nxt;
2402 /* tipc_link_bc_sync_rcv - update rcv link according to peer's send state
2404 int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,
2410 if (!tipc_link_is_up(l))
2418 l->bc_peer_is_up = true;
2420 if (!l->bc_peer_is_up)
2424 if (more(peers_snd_nxt, l->rcv_nxt + l->window))
2427 l->snd_nxt = peers_snd_nxt;
2428 if (link_bc_rcv_gap(l))
2432 if (l->peer_caps & TIPC_BCAST_STATE_NACK)
2437 if (!more(peers_snd_nxt, l->rcv_nxt)) {
2438 l->nack_state = BC_NACK_SND_CONDITIONAL;
2443 if (l->nack_state == BC_NACK_SND_SUPPRESS) {
2444 l->nack_state = BC_NACK_SND_UNCONDITIONAL;
2449 if (l->nack_state == BC_NACK_SND_CONDITIONAL) {
2450 l->nack_state = BC_NACK_SND_UNCONDITIONAL;
2451 if ((peers_snd_nxt - l->rcv_nxt) < TIPC_MIN_LINK_WIN)
2456 tipc_link_build_bc_proto_msg(l, true, peers_snd_nxt, xmitq);
2457 l->nack_state = BC_NACK_SND_SUPPRESS;
2466 struct tipc_link *l = r->bc_sndlink;
2470 if (!tipc_link_is_up(r) || !r->bc_peer_is_up)
2474 l->stats.recv_nacks++;
2475 r->stats.recv_nacks++;
2478 if (less(acked, r->acked) || (acked == r->acked && !gap && !ga))
2481 trace_tipc_link_bc_ack(r, acked, gap, &l->transmq);
2482 tipc_link_advance_transmq(l, r, acked, gap, ga, retrq, &unused, &rc);
2484 tipc_link_advance_backlog(l, xmitq);
2485 if (unlikely(!skb_queue_empty(&l->wakeupq)))
2486 link_prepare_wakeup(l);
2495 int tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb,
2509 if (!tipc_link_is_up(l) || !l->bc_peer_is_up)
2515 if (dnode == tipc_own_addr(l->net)) {
2516 rc = tipc_link_bc_ack_rcv(l, acked, to - acked, NULL, xmitq,
2518 l->stats.recv_nacks++;
2523 if (more(peers_snd_nxt, l->rcv_nxt) && !less(l->rcv_nxt, from))
2524 l->nack_state = BC_NACK_SND_SUPPRESS;
2529 void tipc_link_set_queue_limits(struct tipc_link *l, u32 min_win, u32 max_win)
2531 int max_bulk = TIPC_MAX_PUBL / (l->mtu / ITEM_SIZE);
2533 l->min_win = min_win;
2534 l->ssthresh = max_win;
2535 l->max_win = max_win;
2536 l->window = min_win;
2537 l->backlog[TIPC_LOW_IMPORTANCE].limit = min_win * 2;
2538 l->backlog[TIPC_MEDIUM_IMPORTANCE].limit = min_win * 4;
2539 l->backlog[TIPC_HIGH_IMPORTANCE].limit = min_win * 6;
2540 l->backlog[TIPC_CRITICAL_IMPORTANCE].limit = min_win * 8;
2541 l->backlog[TIPC_SYSTEM_IMPORTANCE].limit = max_bulk;
2545 * tipc_link_reset_stats - reset link statistics
2546 * @l: pointer to link
2548 void tipc_link_reset_stats(struct tipc_link *l)
2550 memset(&l->stats, 0, sizeof(l->stats));
2553 static void link_print(struct tipc_link *l, const char *str)
2555 struct sk_buff *hskb = skb_peek(&l->transmq);
2556 u16 head = hskb ? msg_seqno(buf_msg(hskb)) : l->snd_nxt - 1;
2557 u16 tail = l->snd_nxt - 1;
2559 pr_info("%s Link <%s> state %x\n", str, l->name, l->state);
2560 pr_info("XMTQ: %u [%u-%u], BKLGQ: %u, SNDNX: %u, RCVNX: %u\n",
2561 skb_queue_len(&l->transmq), head, tail,
2562 skb_queue_len(&l->backlogq), l->snd_nxt, l->rcv_nxt);
2581 return -EINVAL;
2589 return -EINVAL;
2597 return -EINVAL;
2615 {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments},
2616 {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented},
2617 {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles},
2618 {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled},
2620 {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments},
2621 {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented},
2622 {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles},
2623 {TIPC_NLA_STATS_TX_BUNDLED, s->sent_bundled},
2624 {TIPC_NLA_STATS_MSG_PROF_TOT, (s->msg_length_counts) ?
2625 s->msg_length_counts : 1},
2626 {TIPC_NLA_STATS_MSG_LEN_CNT, s->msg_length_counts},
2627 {TIPC_NLA_STATS_MSG_LEN_TOT, s->msg_lengths_total},
2628 {TIPC_NLA_STATS_MSG_LEN_P0, s->msg_length_profile[0]},
2629 {TIPC_NLA_STATS_MSG_LEN_P1, s->msg_length_profile[1]},
2630 {TIPC_NLA_STATS_MSG_LEN_P2, s->msg_length_profile[2]},
2631 {TIPC_NLA_STATS_MSG_LEN_P3, s->msg_length_profile[3]},
2632 {TIPC_NLA_STATS_MSG_LEN_P4, s->msg_length_profile[4]},
2633 {TIPC_NLA_STATS_MSG_LEN_P5, s->msg_length_profile[5]},
2634 {TIPC_NLA_STATS_MSG_LEN_P6, s->msg_length_profile[6]},
2635 {TIPC_NLA_STATS_RX_STATES, s->recv_states},
2636 {TIPC_NLA_STATS_RX_PROBES, s->recv_probes},
2637 {TIPC_NLA_STATS_RX_NACKS, s->recv_nacks},
2638 {TIPC_NLA_STATS_RX_DEFERRED, s->deferred_recv},
2639 {TIPC_NLA_STATS_TX_STATES, s->sent_states},
2640 {TIPC_NLA_STATS_TX_PROBES, s->sent_probes},
2641 {TIPC_NLA_STATS_TX_NACKS, s->sent_nacks},
2642 {TIPC_NLA_STATS_TX_ACKS, s->sent_acks},
2643 {TIPC_NLA_STATS_RETRANSMITTED, s->retransmitted},
2644 {TIPC_NLA_STATS_DUPLICATES, s->duplicates},
2645 {TIPC_NLA_STATS_LINK_CONGS, s->link_congs},
2646 {TIPC_NLA_STATS_MAX_QUEUE, s->max_queue_sz},
2647 {TIPC_NLA_STATS_AVG_QUEUE, s->queue_sz_counts ?
2648 (s->accu_queue_sz / s->queue_sz_counts) : 0}
2653 return -EMSGSIZE;
2665 return -EMSGSIZE;
2678 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
2681 return -EMSGSIZE;
2683 attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_LINK);
2687 if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name))
2689 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, tipc_cluster_mask(self)))
2691 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu))
2693 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->stats.recv_pkts))
2695 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->stats.sent_pkts))
2699 if (nla_put_flag(msg->skb, TIPC_NLA_LINK_UP))
2701 if (link->active)
2702 if (nla_put_flag(msg->skb, TIPC_NLA_LINK_ACTIVE))
2705 prop = nla_nest_start_noflag(msg->skb, TIPC_NLA_LINK_PROP);
2708 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_PRIO, link->priority))
2710 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_TOL, link->tolerance))
2712 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN,
2713 link->window))
2715 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_PRIO, link->priority))
2717 nla_nest_end(msg->skb, prop);
2719 err = __tipc_nl_add_stats(msg->skb, &link->stats);
2723 nla_nest_end(msg->skb, attrs);
2724 genlmsg_end(msg->skb, hdr);
2729 nla_nest_cancel(msg->skb, prop);
2731 nla_nest_cancel(msg->skb, attrs);
2733 genlmsg_cancel(msg->skb, hdr);
2735 return -EMSGSIZE;
2750 {TIPC_NLA_STATS_RX_INFO, stats->recv_pkts},
2751 {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments},
2752 {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented},
2753 {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles},
2754 {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled},
2755 {TIPC_NLA_STATS_TX_INFO, stats->sent_pkts},
2756 {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments},
2757 {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented},
2758 {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles},
2759 {TIPC_NLA_STATS_TX_BUNDLED, stats->sent_bundled},
2760 {TIPC_NLA_STATS_RX_NACKS, stats->recv_nacks},
2761 {TIPC_NLA_STATS_RX_DEFERRED, stats->deferred_recv},
2762 {TIPC_NLA_STATS_TX_NACKS, stats->sent_nacks},
2763 {TIPC_NLA_STATS_TX_ACKS, stats->sent_acks},
2764 {TIPC_NLA_STATS_RETRANSMITTED, stats->retransmitted},
2765 {TIPC_NLA_STATS_DUPLICATES, stats->duplicates},
2766 {TIPC_NLA_STATS_LINK_CONGS, stats->link_congs},
2767 {TIPC_NLA_STATS_MAX_QUEUE, stats->max_queue_sz},
2768 {TIPC_NLA_STATS_AVG_QUEUE, stats->queue_sz_counts ?
2769 (stats->accu_queue_sz / stats->queue_sz_counts) : 0}
2774 return -EMSGSIZE;
2786 return -EMSGSIZE;
2804 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
2808 return -EMSGSIZE;
2811 attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_LINK);
2816 if (nla_put_flag(msg->skb, TIPC_NLA_LINK_UP))
2819 if (nla_put_flag(msg->skb, TIPC_NLA_LINK_BROADCAST))
2821 if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name))
2823 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, 0))
2825 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, 0))
2828 prop = nla_nest_start_noflag(msg->skb, TIPC_NLA_LINK_PROP);
2831 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, bcl->max_win))
2833 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_BROADCAST, bc_mode))
2836 if (nla_put_u32(msg->skb, TIPC_NLA_PROP_BROADCAST_RATIO,
2839 nla_nest_end(msg->skb, prop);
2841 err = __tipc_nl_add_bc_link_stat(msg->skb, &bcl->stats);
2846 nla_nest_end(msg->skb, attrs);
2847 genlmsg_end(msg->skb, hdr);
2852 nla_nest_cancel(msg->skb, prop);
2854 nla_nest_cancel(msg->skb, attrs);
2857 genlmsg_cancel(msg->skb, hdr);
2859 return -EMSGSIZE;
2862 void tipc_link_set_tolerance(struct tipc_link *l, u32 tol,
2865 l->tolerance = tol;
2866 if (l->bc_rcvlink)
2867 l->bc_rcvlink->tolerance = tol;
2868 if (tipc_link_is_up(l))
2869 tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, tol, 0, xmitq);
2872 void tipc_link_set_prio(struct tipc_link *l, u32 prio,
2875 l->priority = prio;
2876 tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, prio, xmitq);
2879 void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit)
2881 l->abort_limit = limit;
2885 * tipc_link_dump - dump TIPC link data
2886 * @l: tipc link to be dumped
2888 * - TIPC_DUMP_NONE: don't dump link queues
2889 * - TIPC_DUMP_TRANSMQ: dump link transmq queue
2890 * - TIPC_DUMP_BACKLOGQ: dump link backlog queue
2891 * - TIPC_DUMP_DEFERDQ: dump link deferd queue
2892 * - TIPC_DUMP_INPUTQ: dump link input queue
2893 * - TIPC_DUMP_WAKEUP: dump link wakeup queue
2894 * - TIPC_DUMP_ALL: dump all the link queues above
2897 int tipc_link_dump(struct tipc_link *l, u16 dqueues, char *buf)
2905 if (!l) {
2910 i += scnprintf(buf, sz, "link data: %x", l->addr);
2911 i += scnprintf(buf + i, sz - i, " %x", l->state);
2912 i += scnprintf(buf + i, sz - i, " %u", l->in_session);
2913 i += scnprintf(buf + i, sz - i, " %u", l->session);
2914 i += scnprintf(buf + i, sz - i, " %u", l->peer_session);
2915 i += scnprintf(buf + i, sz - i, " %u", l->snd_nxt);
2916 i += scnprintf(buf + i, sz - i, " %u", l->rcv_nxt);
2917 i += scnprintf(buf + i, sz - i, " %u", l->snd_nxt_state);
2918 i += scnprintf(buf + i, sz - i, " %u", l->rcv_nxt_state);
2919 i += scnprintf(buf + i, sz - i, " %x", l->peer_caps);
2920 i += scnprintf(buf + i, sz - i, " %u", l->silent_intv_cnt);
2921 i += scnprintf(buf + i, sz - i, " %u", l->rst_cnt);
2922 i += scnprintf(buf + i, sz - i, " %u", 0);
2923 i += scnprintf(buf + i, sz - i, " %u", 0);
2924 i += scnprintf(buf + i, sz - i, " %u", l->acked);
2926 list = &l->transmq;
2930 i += scnprintf(buf + i, sz - i, " | %u %u %u", len,
2934 list = &l->deferdq;
2938 i += scnprintf(buf + i, sz - i, " | %u %u %u", len,
2942 list = &l->backlogq;
2946 i += scnprintf(buf + i, sz - i, " | %u %u %u", len,
2950 list = l->inputq;
2954 i += scnprintf(buf + i, sz - i, " | %u %u %u\n", len,
2959 i += scnprintf(buf + i, sz - i, "transmq: ");
2960 i += tipc_list_dump(&l->transmq, false, buf + i);
2963 i += scnprintf(buf + i, sz - i,
2965 l->backlog[TIPC_LOW_IMPORTANCE].len,
2966 l->backlog[TIPC_MEDIUM_IMPORTANCE].len,
2967 l->backlog[TIPC_HIGH_IMPORTANCE].len,
2968 l->backlog[TIPC_CRITICAL_IMPORTANCE].len,
2969 l->backlog[TIPC_SYSTEM_IMPORTANCE].len);
2970 i += tipc_list_dump(&l->backlogq, false, buf + i);
2973 i += scnprintf(buf + i, sz - i, "deferdq: ");
2974 i += tipc_list_dump(&l->deferdq, false, buf + i);
2977 i += scnprintf(buf + i, sz - i, "inputq: ");
2978 i += tipc_list_dump(l->inputq, false, buf + i);
2981 i += scnprintf(buf + i, sz - i, "wakeup: ");
2982 i += tipc_list_dump(&l->wakeupq, false, buf + i);