Lines Matching refs:tp
158 tcp_update_dsack_list(struct tcpcb *tp, tcp_seq rcv_start, tcp_seq rcv_end)
164 INP_WLOCK_ASSERT(tp->t_inpcb);
168 if (SEQ_LT(rcv_end, tp->rcv_nxt) ||
169 ((rcv_end == tp->rcv_nxt) &&
170 (tp->rcv_numsacks > 0 ) &&
171 (tp->sackblks[0].end == tp->rcv_nxt))) {
183 for (i = 0; i < tp->rcv_numsacks; i++) {
184 start = tp->sackblks[i].start;
185 end = tp->sackblks[i].end;
194 if (SEQ_GT(tp->rcv_nxt, end)) {
226 if ((SEQ_LT(tp->rcv_nxt, mid_blk.end) &&
233 for (j = 0; (j < tp->rcv_numsacks) && (n < MAX_SACK_BLKS); j++) {
234 if (((SEQ_LT(tp->sackblks[j].end, mid_blk.start) ||
235 SEQ_GT(tp->sackblks[j].start, mid_blk.end)) &&
236 (SEQ_GT(tp->sackblks[j].start, tp->rcv_nxt))))
237 saved_blks[n++] = tp->sackblks[j];
243 tp->sackblks[j++] = saved_blks[i];
246 tp->rcv_numsacks = j;
254 tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_start, tcp_seq rcv_end)
265 INP_WLOCK_ASSERT(tp->t_inpcb);
271 (tp->rcv_numsacks >= 1) &&
272 (rcv_end == tp->sackblks[0].end)) {
274 head_blk = tp->sackblks[0];
287 for (i = 0; i < tp->rcv_numsacks; i++) {
288 tcp_seq start = tp->sackblks[i].start;
289 tcp_seq end = tp->sackblks[i].end;
290 if (SEQ_GEQ(start, end) || SEQ_LEQ(start, tp->rcv_nxt)) {
357 * Update SACK list in tp->sackblks[].
365 tp->sackblks[0] = head_blk;
375 (rcv_start == tp->sackblks[0].end)) {
382 bcopy(saved_blks, &tp->sackblks[num_head],
387 tp->rcv_numsacks = num_head + num_saved;
391 tcp_clean_dsack_blocks(struct tcpcb *tp)
396 INP_WLOCK_ASSERT(tp->t_inpcb);
403 for (i = 0; i < tp->rcv_numsacks; i++) {
404 tcp_seq start = tp->sackblks[i].start;
405 tcp_seq end = tp->sackblks[i].end;
406 if (SEQ_GEQ(start, end) || SEQ_LEQ(start, tp->rcv_nxt)) {
423 bcopy(saved_blks, &tp->sackblks[0],
426 tp->rcv_numsacks = num_saved;
433 tcp_clean_sackreport(struct tcpcb *tp)
437 INP_WLOCK_ASSERT(tp->t_inpcb);
438 tp->rcv_numsacks = 0;
440 tp->sackblks[i].start = tp->sackblks[i].end=0;
447 tcp_sackhole_alloc(struct tcpcb *tp, tcp_seq start, tcp_seq end)
451 if (tp->snd_numholes >= V_tcp_sack_maxholes ||
465 tp->snd_numholes++;
475 tcp_sackhole_free(struct tcpcb *tp, struct sackhole *hole)
480 tp->snd_numholes--;
483 KASSERT(tp->snd_numholes >= 0, ("tp->snd_numholes >= 0"));
491 tcp_sackhole_insert(struct tcpcb *tp, tcp_seq start, tcp_seq end,
497 hole = tcp_sackhole_alloc(tp, start, end);
503 TAILQ_INSERT_AFTER(&tp->snd_holes, after, hole, scblink);
505 TAILQ_INSERT_TAIL(&tp->snd_holes, hole, scblink);
508 if (tp->sackhint.nexthole == NULL)
509 tp->sackhint.nexthole = hole;
518 tcp_sackhole_remove(struct tcpcb *tp, struct sackhole *hole)
522 if (tp->sackhint.nexthole == hole)
523 tp->sackhint.nexthole = TAILQ_NEXT(hole, scblink);
526 TAILQ_REMOVE(&tp->snd_holes, hole, scblink);
529 tcp_sackhole_free(tp, hole);
534 * tp->snd_holes is an ordered list of holes (oldest to newest, in terms of
540 tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack)
547 INP_WLOCK_ASSERT(tp->t_inpcb);
558 if (SEQ_LT(tp->snd_una, th_ack) && !TAILQ_EMPTY(&tp->snd_holes)) {
559 left_edge_delta = th_ack - tp->snd_una;
560 sack_blocks[num_sack_blks].start = tp->snd_una;
574 SEQ_GT(sack.start, tp->snd_una) &&
576 SEQ_LT(sack.start, tp->snd_max) &&
577 SEQ_GT(sack.end, tp->snd_una) &&
578 SEQ_LEQ(sack.end, tp->snd_max)) {
604 if (TAILQ_EMPTY(&tp->snd_holes)) {
612 tp->snd_fack = SEQ_MAX(tp->snd_una, th_ack);
613 tp->sackhint.sacked_bytes = 0; /* reset */
628 tp->sackhint.last_sack_ack = sblkp->end;
629 if (SEQ_LT(tp->snd_fack, sblkp->start)) {
636 temp = tcp_sackhole_insert(tp, tp->snd_fack,sblkp->start,NULL);
639 tp->snd_fack = sblkp->end;
653 SEQ_LT(tp->snd_fack, sblkp->start))
656 SEQ_LT(tp->snd_fack, sblkp->end)) {
657 delivered_data += sblkp->end - tp->snd_fack;
658 tp->snd_fack = sblkp->end;
662 } else if (SEQ_LT(tp->snd_fack, sblkp->end)) {
664 delivered_data += sblkp->end - tp->snd_fack;
665 tp->snd_fack = sblkp->end;
668 cur = TAILQ_LAST(&tp->snd_holes, sackhole_head); /* Last SACK hole. */
690 tp->sackhint.sack_bytes_rexmit -= (cur->rxmit - cur->start);
691 KASSERT(tp->sackhint.sack_bytes_rexmit >= 0,
701 tcp_sackhole_remove(tp, temp);
726 temp = tcp_sackhole_insert(tp, sblkp->end,
731 tp->sackhint.sack_bytes_rexmit
742 tp->sackhint.sack_bytes_rexmit += (cur->rxmit - cur->start);
753 tp->sackhint.delivered_data = delivered_data;
754 tp->sackhint.sacked_bytes += delivered_data - left_edge_delta;
756 KASSERT((tp->sackhint.sacked_bytes >= 0), ("sacked_bytes < 0"));
764 tcp_free_sackholes(struct tcpcb *tp)
768 INP_WLOCK_ASSERT(tp->t_inpcb);
769 while ((q = TAILQ_FIRST(&tp->snd_holes)) != NULL)
770 tcp_sackhole_remove(tp, q);
771 tp->sackhint.sack_bytes_rexmit = 0;
773 KASSERT(tp->snd_numholes == 0, ("tp->snd_numholes == 0"));
774 KASSERT(tp->sackhint.nexthole == NULL,
775 ("tp->sackhint.nexthole == NULL"));
787 tcp_sack_partialack(struct tcpcb *tp, struct tcphdr *th)
790 u_int maxseg = tcp_maxseg(tp);
792 INP_WLOCK_ASSERT(tp->t_inpcb);
793 tcp_timer_activate(tp, TT_REXMT, 0);
794 tp->t_rtttime = 0;
796 if ((BYTES_THIS_ACK(tp, th) / maxseg) >= 2)
798 tp->snd_cwnd = (tp->sackhint.sack_bytes_rexmit +
799 (tp->snd_nxt - tp->sack_newdata) + num_segs * maxseg);
800 if (tp->snd_cwnd > tp->snd_ssthresh)
801 tp->snd_cwnd = tp->snd_ssthresh;
802 tp->t_flags |= TF_ACKNOW;
803 (void) tp->t_fb->tfb_tcp_output(tp);
812 tcp_sack_output_debug(struct tcpcb *tp, int *sack_bytes_rexmt)
816 INP_WLOCK_ASSERT(tp->t_inpcb);
818 TAILQ_FOREACH(p, &tp->snd_holes, scblink) {
820 if (SEQ_LT(p->rxmit, tp->snd_una)) {/* old SACK hole */
850 tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt)
854 INP_WLOCK_ASSERT(tp->t_inpcb);
855 *sack_bytes_rexmt = tp->sackhint.sack_bytes_rexmit;
856 hole = tp->sackhint.nexthole;
861 tp->sackhint.nexthole = hole;
875 tcp_sack_adjust(struct tcpcb *tp)
877 struct sackhole *p, *cur = TAILQ_FIRST(&tp->snd_holes);
879 INP_WLOCK_ASSERT(tp->t_inpcb);
882 if (SEQ_GEQ(tp->snd_nxt, tp->snd_fack))
890 if (SEQ_LT(tp->snd_nxt, cur->end))
892 if (SEQ_GEQ(tp->snd_nxt, p->start))
895 tp->snd_nxt = p->start;
899 if (SEQ_LT(tp->snd_nxt, cur->end))
901 tp->snd_nxt = tp->snd_fack;