* Return one of three RTTs to use (in microseconds). */
| 4237 | * Return one of three RTTs to use (in microseconds). |
| 4238 | */ |
| 4239 | static __inline uint32_t |
| 4240 | bbr_get_rtt(struct tcp_bbr *bbr, int32_t rtt_type) |
| 4241 | { |
| 4242 | uint32_t f_rtt; |
| 4243 | uint32_t srtt; |
| 4244 | |
| 4245 | f_rtt = get_filter_value_small(&bbr->r_ctl.rc_rttprop); |
| 4246 | if (get_filter_value_small(&bbr->r_ctl.rc_rttprop) == 0xffffffff) { |
| 4247 | /* We have no rtt at all */ |
| 4248 | if (bbr->rc_tp->t_srtt == 0) |
| 4249 | f_rtt = BBR_INITIAL_RTO; |
| 4250 | else |
| 4251 | f_rtt = (TICKS_2_USEC(bbr->rc_tp->t_srtt) >> TCP_RTT_SHIFT); |
| 4252 | /* |
| 4253 | * Since we don't know how good the rtt is apply a |
| 4254 | * delayed-ack min |
| 4255 | */ |
| 4256 | if (f_rtt < bbr_delayed_ack_time) { |
| 4257 | f_rtt = bbr_delayed_ack_time; |
| 4258 | } |
| 4259 | } |
| 4260 | /* Take the filter version or last measured pkt-rtt */ |
| 4261 | if (rtt_type == BBR_RTT_PROP) { |
| 4262 | srtt = f_rtt; |
| 4263 | } else if (rtt_type == BBR_RTT_PKTRTT) { |
| 4264 | if (bbr->r_ctl.rc_pkt_epoch_rtt) { |
| 4265 | srtt = bbr->r_ctl.rc_pkt_epoch_rtt; |
| 4266 | } else { |
| 4267 | /* No pkt rtt yet */ |
| 4268 | srtt = f_rtt; |
| 4269 | } |
| 4270 | } else if (rtt_type == BBR_RTT_RACK) { |
| 4271 | srtt = bbr->r_ctl.rc_last_rtt; |
| 4272 | /* We need to add in any internal delay for our timer */ |
| 4273 | if (bbr->rc_ack_was_delayed) |
| 4274 | srtt += bbr->r_ctl.rc_ack_hdwr_delay; |
| 4275 | } else if (rtt_type == BBR_SRTT) { |
| 4276 | srtt = (TICKS_2_USEC(bbr->rc_tp->t_srtt) >> TCP_RTT_SHIFT); |
| 4277 | } else { |
| 4278 | /* TSNH */ |
| 4279 | srtt = f_rtt; |
| 4280 | #ifdef BBR_INVARIANTS |
| 4281 | panic("Unknown rtt request type %d", rtt_type); |
| 4282 | #endif |
| 4283 | } |
| 4284 | return (srtt); |
| 4285 | } |
| 4286 | |
| 4287 | static int |
| 4288 | bbr_is_lost(struct tcp_bbr *bbr, struct bbr_sendmap *rsm, uint32_t cts) |
no test coverage detected