Lines Matching refs:seq

157 	struct l2tp_seq		seq;		/* ctrl sequence number state */  member
335 static void ng_l2tp_seq_check(struct l2tp_seq *seq);
336 #define SEQ_LOCK(seq) do { \ argument
337 mtx_lock(&(seq)->mtx); \
338 ng_l2tp_seq_check(seq); \
340 #define SEQ_UNLOCK(seq) do { \ argument
341 ng_l2tp_seq_check(seq); \
342 mtx_unlock(&(seq)->mtx); \
345 #define SEQ_LOCK(seq) mtx_lock(&(seq)->mtx) argument
346 #define SEQ_UNLOCK(seq) mtx_unlock(&(seq)->mtx) argument
348 #define SEQ_LOCK_ASSERT(seq) mtx_assert(&(seq)->mtx, MA_OWNED) argument
656 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_shutdown() local
659 SEQ_LOCK(seq); in ng_l2tp_shutdown()
661 SEQ_UNLOCK(seq); in ng_l2tp_shutdown()
664 callout_drain(&seq->rack_timer); in ng_l2tp_shutdown()
665 callout_drain(&seq->xack_timer); in ng_l2tp_shutdown()
667 mtx_destroy(&seq->mtx); in ng_l2tp_shutdown()
901 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_rcvdata_lower() local
903 SEQ_LOCK(seq); in ng_l2tp_rcvdata_lower()
910 SEQ_UNLOCK(seq); in ng_l2tp_rcvdata_lower()
921 if (ns != seq->nr || seq->inproc) { in ng_l2tp_rcvdata_lower()
922 if (L2TP_SEQ_DIFF(ns, seq->nr) <= 0) in ng_l2tp_rcvdata_lower()
926 ng_l2tp_xmit_ctrl(priv, NULL, seq->ns); in ng_l2tp_rcvdata_lower()
935 SEQ_UNLOCK(seq); in ng_l2tp_rcvdata_lower()
947 seq->inproc = 1; in ng_l2tp_rcvdata_lower()
948 SEQ_UNLOCK(seq); in ng_l2tp_rcvdata_lower()
953 SEQ_LOCK(seq); in ng_l2tp_rcvdata_lower()
955 seq->inproc = 0; in ng_l2tp_rcvdata_lower()
960 seq->nr++; in ng_l2tp_rcvdata_lower()
962 if (!callout_active(&seq->xack_timer)) { in ng_l2tp_rcvdata_lower()
963 callout_reset(&seq->xack_timer, in ng_l2tp_rcvdata_lower()
968 SEQ_UNLOCK(seq); in ng_l2tp_rcvdata_lower()
1014 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_rcvdata_ctrl() local
1044 SEQ_LOCK(seq); in ng_l2tp_rcvdata_ctrl()
1047 for (i = 0; i < L2TP_MAX_XWIN && seq->xwin[i] != NULL; i++); in ng_l2tp_rcvdata_ctrl()
1049 SEQ_UNLOCK(seq); in ng_l2tp_rcvdata_ctrl()
1054 seq->xwin[i] = m; in ng_l2tp_rcvdata_ctrl()
1057 if (i >= seq->cwnd) { in ng_l2tp_rcvdata_ctrl()
1058 SEQ_UNLOCK(seq); in ng_l2tp_rcvdata_ctrl()
1063 if (!callout_active(&seq->rack_timer)) in ng_l2tp_rcvdata_ctrl()
1064 callout_reset(&seq->rack_timer, hz, ng_l2tp_seq_rack_timeout, in ng_l2tp_rcvdata_ctrl()
1067 ns = seq->ns++; in ng_l2tp_rcvdata_ctrl()
1071 SEQ_UNLOCK(seq); in ng_l2tp_rcvdata_ctrl()
1184 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_seq_init() local
1188 memset(seq, 0, sizeof(*seq)); in ng_l2tp_seq_init()
1189 seq->cwnd = 1; in ng_l2tp_seq_init()
1190 seq->wmax = priv->conf.peer_win; in ng_l2tp_seq_init()
1191 if (seq->wmax > L2TP_MAX_XWIN) in ng_l2tp_seq_init()
1192 seq->wmax = L2TP_MAX_XWIN; in ng_l2tp_seq_init()
1193 seq->ssth = seq->wmax; in ng_l2tp_seq_init()
1194 mtx_init(&seq->mtx, "ng_l2tp", NULL, MTX_DEF); in ng_l2tp_seq_init()
1195 callout_init_mtx(&seq->rack_timer, &seq->mtx, CALLOUT_RETURNUNLOCKED); in ng_l2tp_seq_init()
1196 callout_init_mtx(&seq->xack_timer, &seq->mtx, CALLOUT_RETURNUNLOCKED); in ng_l2tp_seq_init()
1205 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_seq_set() local
1216 seq->ns = conf->ns; in ng_l2tp_seq_set()
1217 seq->nr = conf->nr; in ng_l2tp_seq_set()
1218 seq->rack = conf->rack; in ng_l2tp_seq_set()
1219 seq->xack = conf->xack; in ng_l2tp_seq_set()
1230 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_seq_adjust() local
1234 SEQ_LOCK(seq); in ng_l2tp_seq_adjust()
1238 SEQ_UNLOCK(seq); in ng_l2tp_seq_adjust()
1248 if (new_wmax < seq->wmax) in ng_l2tp_seq_adjust()
1250 seq->wmax = new_wmax; in ng_l2tp_seq_adjust()
1253 SEQ_UNLOCK(seq); in ng_l2tp_seq_adjust()
1263 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_seq_reset() local
1266 SEQ_LOCK_ASSERT(seq); in ng_l2tp_seq_reset()
1269 (void )callout_stop(&seq->rack_timer); in ng_l2tp_seq_reset()
1270 (void )callout_stop(&seq->xack_timer); in ng_l2tp_seq_reset()
1274 if (seq->xwin[i] == NULL) in ng_l2tp_seq_reset()
1276 m_freem(seq->xwin[i]); in ng_l2tp_seq_reset()
1283 seq->ns = 0; in ng_l2tp_seq_reset()
1284 seq->nr = 0; in ng_l2tp_seq_reset()
1285 seq->rack = 0; in ng_l2tp_seq_reset()
1286 seq->xack = 0; in ng_l2tp_seq_reset()
1287 seq->wmax = L2TP_MAX_XWIN; in ng_l2tp_seq_reset()
1288 seq->cwnd = 1; in ng_l2tp_seq_reset()
1289 seq->ssth = seq->wmax; in ng_l2tp_seq_reset()
1290 seq->acks = 0; in ng_l2tp_seq_reset()
1291 seq->rexmits = 0; in ng_l2tp_seq_reset()
1292 bzero(seq->xwin, sizeof(seq->xwin)); in ng_l2tp_seq_reset()
1301 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_seq_recv_nr() local
1307 SEQ_LOCK_ASSERT(seq); in ng_l2tp_seq_recv_nr()
1310 if ((nack = L2TP_SEQ_DIFF(nr, seq->rack)) <= 0) in ng_l2tp_seq_recv_nr()
1312 if (L2TP_SEQ_DIFF(nr, seq->ns) > 0) { in ng_l2tp_seq_recv_nr()
1320 seq->rack = nr; in ng_l2tp_seq_recv_nr()
1321 seq->rexmits = 0; in ng_l2tp_seq_recv_nr()
1325 m_freem(seq->xwin[i]); in ng_l2tp_seq_recv_nr()
1326 memmove(seq->xwin, seq->xwin + nack, in ng_l2tp_seq_recv_nr()
1327 (L2TP_MAX_XWIN - nack) * sizeof(*seq->xwin)); in ng_l2tp_seq_recv_nr()
1328 memset(seq->xwin + (L2TP_MAX_XWIN - nack), 0, in ng_l2tp_seq_recv_nr()
1329 nack * sizeof(*seq->xwin)); in ng_l2tp_seq_recv_nr()
1336 if (seq->cwnd < seq->wmax) { in ng_l2tp_seq_recv_nr()
1338 if (seq->cwnd < seq->ssth) { in ng_l2tp_seq_recv_nr()
1339 seq->cwnd += nack; in ng_l2tp_seq_recv_nr()
1341 if (seq->cwnd > seq->ssth) { /* into cg.av. phase */ in ng_l2tp_seq_recv_nr()
1342 nack = seq->cwnd - seq->ssth; in ng_l2tp_seq_recv_nr()
1343 seq->cwnd = seq->ssth; in ng_l2tp_seq_recv_nr()
1348 if (seq->cwnd >= seq->ssth) { in ng_l2tp_seq_recv_nr()
1349 seq->acks += nack; in ng_l2tp_seq_recv_nr()
1350 while (seq->acks >= seq->cwnd) { in ng_l2tp_seq_recv_nr()
1351 seq->acks -= seq->cwnd; in ng_l2tp_seq_recv_nr()
1352 if (seq->cwnd < seq->wmax) in ng_l2tp_seq_recv_nr()
1353 seq->cwnd++; in ng_l2tp_seq_recv_nr()
1359 if (callout_active(&seq->rack_timer)) in ng_l2tp_seq_recv_nr()
1360 (void )callout_stop(&seq->rack_timer); in ng_l2tp_seq_recv_nr()
1363 if (seq->xwin[0] == NULL) in ng_l2tp_seq_recv_nr()
1367 callout_reset(&seq->rack_timer, hz, ng_l2tp_seq_rack_timeout, in ng_l2tp_seq_recv_nr()
1374 ns = seq->ns; in ng_l2tp_seq_recv_nr()
1376 while ((i = L2TP_SEQ_DIFF(seq->ns, seq->rack)) < seq->cwnd in ng_l2tp_seq_recv_nr()
1377 && seq->xwin[i] != NULL) { in ng_l2tp_seq_recv_nr()
1378 xwin[j++] = seq->xwin[i]; in ng_l2tp_seq_recv_nr()
1379 seq->ns++; in ng_l2tp_seq_recv_nr()
1393 SEQ_LOCK(seq); in ng_l2tp_seq_recv_nr()
1409 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_seq_xack_timeout() local
1411 SEQ_LOCK_ASSERT(seq); in ng_l2tp_seq_xack_timeout()
1412 MPASS(!callout_pending(&seq->xack_timer)); in ng_l2tp_seq_xack_timeout()
1413 MPASS(callout_active(&seq->xack_timer)); in ng_l2tp_seq_xack_timeout()
1418 ng_l2tp_xmit_ctrl(priv, NULL, seq->ns); in ng_l2tp_seq_xack_timeout()
1436 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_seq_rack_timeout() local
1440 SEQ_LOCK_ASSERT(seq); in ng_l2tp_seq_rack_timeout()
1441 MPASS(seq->xwin[0]); in ng_l2tp_seq_rack_timeout()
1442 MPASS(!callout_pending(&seq->rack_timer)); in ng_l2tp_seq_rack_timeout()
1443 MPASS(callout_active(&seq->rack_timer)); in ng_l2tp_seq_rack_timeout()
1451 if (seq->rexmits++ >= priv->conf.rexmit_max) in ng_l2tp_seq_rack_timeout()
1455 delay = (seq->rexmits > 12) ? (1 << 12) : (1 << seq->rexmits); in ng_l2tp_seq_rack_timeout()
1458 callout_reset(&seq->rack_timer, hz * delay, ng_l2tp_seq_rack_timeout, in ng_l2tp_seq_rack_timeout()
1462 seq->ns = seq->rack; in ng_l2tp_seq_rack_timeout()
1463 seq->ssth = (seq->cwnd + 1) / 2; in ng_l2tp_seq_rack_timeout()
1464 seq->cwnd = 1; in ng_l2tp_seq_rack_timeout()
1465 seq->acks = 0; in ng_l2tp_seq_rack_timeout()
1468 m = L2TP_COPY_MBUF(seq->xwin[0], M_NOWAIT); in ng_l2tp_seq_rack_timeout()
1470 SEQ_UNLOCK(seq); in ng_l2tp_seq_rack_timeout()
1473 ng_l2tp_xmit_ctrl(priv, m, seq->ns++); in ng_l2tp_seq_rack_timeout()
1490 struct l2tp_seq *const seq = &priv->seq; in ng_l2tp_xmit_ctrl() local
1495 SEQ_LOCK_ASSERT(seq); in ng_l2tp_xmit_ctrl()
1499 if (callout_active(&seq->xack_timer)) in ng_l2tp_xmit_ctrl()
1500 (void )callout_stop(&seq->xack_timer); in ng_l2tp_xmit_ctrl()
1502 nr = seq->xack = seq->nr; in ng_l2tp_xmit_ctrl()
1504 SEQ_UNLOCK(seq); in ng_l2tp_xmit_ctrl()
1572 ng_l2tp_seq_check(struct l2tp_seq *seq) in ng_l2tp_seq_check() argument
1579 SEQ_LOCK_ASSERT(seq); in ng_l2tp_seq_check()
1581 self_unack = L2TP_SEQ_DIFF(seq->nr, seq->xack); in ng_l2tp_seq_check()
1582 peer_unack = L2TP_SEQ_DIFF(seq->ns, seq->rack); in ng_l2tp_seq_check()
1583 CHECK(seq->wmax <= L2TP_MAX_XWIN); in ng_l2tp_seq_check()
1584 CHECK(seq->cwnd >= 1); in ng_l2tp_seq_check()
1585 CHECK(seq->cwnd <= seq->wmax); in ng_l2tp_seq_check()
1586 CHECK(seq->ssth >= 1); in ng_l2tp_seq_check()
1587 CHECK(seq->ssth <= seq->wmax); in ng_l2tp_seq_check()
1588 if (seq->cwnd < seq->ssth) in ng_l2tp_seq_check()
1589 CHECK(seq->acks == 0); in ng_l2tp_seq_check()
1591 CHECK(seq->acks <= seq->cwnd); in ng_l2tp_seq_check()
1594 CHECK(peer_unack <= seq->wmax); in ng_l2tp_seq_check()
1595 CHECK((self_unack == 0) ^ callout_active(&seq->xack_timer)); in ng_l2tp_seq_check()
1596 CHECK((peer_unack == 0) ^ callout_active(&seq->rack_timer)); in ng_l2tp_seq_check()
1598 CHECK(seq->xwin[i] != NULL); in ng_l2tp_seq_check()
1599 for ( ; i < seq->cwnd; i++) /* verify peer's recv window full */ in ng_l2tp_seq_check()
1600 CHECK(seq->xwin[i] == NULL); in ng_l2tp_seq_check()