| 736 | } |
| 737 | |
| 738 | static void |
| 739 | bbr_start_hpts_timer(struct tcp_bbr *bbr, struct tcpcb *tp, uint32_t cts, int32_t frm, int32_t slot, uint32_t tot_len) |
| 740 | { |
| 741 | struct inpcb *inp; |
| 742 | struct hpts_diag diag; |
| 743 | uint32_t delayed_ack = 0; |
| 744 | uint32_t left = 0; |
| 745 | uint32_t hpts_timeout; |
| 746 | uint8_t stopped; |
| 747 | int32_t delay_calc = 0; |
| 748 | uint32_t prev_delay = 0; |
| 749 | |
| 750 | inp = tp->t_inpcb; |
| 751 | if (inp->inp_in_hpts) { |
| 752 | /* A previous call is already set up */ |
| 753 | return; |
| 754 | } |
| 755 | if ((tp->t_state == TCPS_CLOSED) || |
| 756 | (tp->t_state == TCPS_LISTEN)) { |
| 757 | return; |
| 758 | } |
| 759 | stopped = bbr->rc_tmr_stopped; |
| 760 | if (stopped && TSTMP_GT(bbr->r_ctl.rc_timer_exp, cts)) { |
| 761 | left = bbr->r_ctl.rc_timer_exp - cts; |
| 762 | } |
| 763 | bbr->r_ctl.rc_hpts_flags = 0; |
| 764 | bbr->r_ctl.rc_timer_exp = 0; |
| 765 | prev_delay = bbr->r_ctl.rc_last_delay_val; |
| 766 | if (bbr->r_ctl.rc_last_delay_val && |
| 767 | (slot == 0)) { |
| 768 | /* |
| 769 | * If a previous pacer delay was in place we |
| 770 | * are not coming from the output side (where |
| 771 | * we calculate a delay, more likely a timer). |
| 772 | */ |
| 773 | slot = bbr->r_ctl.rc_last_delay_val; |
| 774 | if (TSTMP_GT(cts, bbr->rc_pacer_started)) { |
| 775 | /* Compensate for time passed */ |
| 776 | delay_calc = cts - bbr->rc_pacer_started; |
| 777 | if (delay_calc <= slot) |
| 778 | slot -= delay_calc; |
| 779 | } |
| 780 | } |
| 781 | /* Do we have early to make up for by pushing out the pacing time? */ |
| 782 | if (bbr->r_agg_early_set) { |
| 783 | bbr_log_pacing_delay_calc(bbr, 0, bbr->r_ctl.rc_agg_early, cts, slot, 0, bbr->r_agg_early_set, 2); |
| 784 | slot += bbr->r_ctl.rc_agg_early; |
| 785 | bbr->r_ctl.rc_agg_early = 0; |
| 786 | bbr->r_agg_early_set = 0; |
| 787 | } |
| 788 | /* Are we running a total debt that needs to be compensated for? */ |
| 789 | if (bbr->r_ctl.rc_hptsi_agg_delay) { |
| 790 | if (slot > bbr->r_ctl.rc_hptsi_agg_delay) { |
| 791 | /* We nuke the delay */ |
| 792 | slot -= bbr->r_ctl.rc_hptsi_agg_delay; |
| 793 | bbr->r_ctl.rc_hptsi_agg_delay = 0; |
| 794 | } else { |
| 795 | /* We nuke some of the delay, put in a minimal 100usecs */ |
no test coverage detected