| 564 | } |
| 565 | |
| 566 | static void |
| 567 | cdg_ack_received(struct cc_var *ccv, uint16_t ack_type) |
| 568 | { |
| 569 | struct cdg *cdg_data; |
| 570 | struct ertt *e_t; |
| 571 | long qdiff_max, qdiff_min; |
| 572 | int congestion, new_measurement, slowstart; |
| 573 | |
| 574 | cdg_data = ccv->cc_data; |
| 575 | e_t = (struct ertt *)khelp_get_osd(CCV(ccv, osd), ertt_id); |
| 576 | new_measurement = e_t->flags & ERTT_NEW_MEASUREMENT; |
| 577 | congestion = 0; |
| 578 | cdg_data->maxrtt_in_rtt = imax(e_t->rtt, cdg_data->maxrtt_in_rtt); |
| 579 | cdg_data->minrtt_in_rtt = imin(e_t->rtt, cdg_data->minrtt_in_rtt); |
| 580 | |
| 581 | if (new_measurement) { |
| 582 | slowstart = (CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh)); |
| 583 | /* |
| 584 | * Update smoothed gradient measurements. Since we are only |
| 585 | * using one measurement per RTT, use max or min rtt_in_rtt. |
| 586 | * This is also less noisy than a sample RTT measurement. Max |
| 587 | * RTT measurements can have trouble due to OS issues. |
| 588 | */ |
| 589 | if (cdg_data->maxrtt_in_prevrtt) { |
| 590 | qdiff_max = ((long)(cdg_data->maxrtt_in_rtt - |
| 591 | cdg_data->maxrtt_in_prevrtt) << D_P_E ); |
| 592 | qdiff_min = ((long)(cdg_data->minrtt_in_rtt - |
| 593 | cdg_data->minrtt_in_prevrtt) << D_P_E ); |
| 594 | |
| 595 | if (cdg_data->sample_q_size == 0) { |
| 596 | cdg_data->max_qtrend = qdiff_max; |
| 597 | cdg_data->min_qtrend = qdiff_min; |
| 598 | } else |
| 599 | calc_moving_average(cdg_data, qdiff_max, qdiff_min); |
| 600 | |
| 601 | /* Probabilistic backoff with respect to gradient. */ |
| 602 | if (slowstart && qdiff_min > 0) |
| 603 | congestion = prob_backoff(qdiff_min); |
| 604 | else if (cdg_data->min_qtrend > 0) |
| 605 | congestion = prob_backoff(cdg_data->min_qtrend); |
| 606 | else if (slowstart && qdiff_max > 0) |
| 607 | congestion = prob_backoff(qdiff_max); |
| 608 | else if (cdg_data->max_qtrend > 0) |
| 609 | congestion = prob_backoff(cdg_data->max_qtrend); |
| 610 | |
| 611 | /* Update estimate of queue state. */ |
| 612 | if (cdg_data->min_qtrend > 0 && |
| 613 | cdg_data->max_qtrend <= 0) { |
| 614 | cdg_data->queue_state = CDG_Q_FULL; |
| 615 | } else if (cdg_data->min_qtrend >= 0 && |
| 616 | cdg_data->max_qtrend < 0) { |
| 617 | cdg_data->queue_state = CDG_Q_EMPTY; |
| 618 | cdg_data->shadow_w = 0; |
| 619 | } else if (cdg_data->min_qtrend > 0 && |
| 620 | cdg_data->max_qtrend > 0) { |
| 621 | cdg_data->queue_state = CDG_Q_RISING; |
| 622 | } else if (cdg_data->min_qtrend < 0 && |
| 623 | cdg_data->max_qtrend < 0) { |
nothing calls this directly
no test coverage detected