| 748 | } |
| 749 | |
| 750 | static const struct tcp_hwrate_limit_table * |
| 751 | tcp_int_find_suitable_rate(const struct tcp_rate_set *rs, |
| 752 | uint64_t bytes_per_sec, uint32_t flags) |
| 753 | { |
| 754 | struct tcp_hwrate_limit_table *arte = NULL, *rte = NULL; |
| 755 | uint64_t mbits_per_sec, ind_calc; |
| 756 | int i; |
| 757 | |
| 758 | mbits_per_sec = (bytes_per_sec * 8); |
| 759 | if (flags & RS_PACING_LT) { |
| 760 | if ((mbits_per_sec < RS_ONE_MEGABIT_PERSEC) && |
| 761 | (rs->rs_lowest_valid <= 2)){ |
| 762 | /* |
| 763 | * Smaller than 1Meg, only |
| 764 | * 3 entries can match it. |
| 765 | */ |
| 766 | for(i = rs->rs_lowest_valid; i < 3; i++) { |
| 767 | if (bytes_per_sec <= rs->rs_rlt[i].rate) { |
| 768 | rte = &rs->rs_rlt[i]; |
| 769 | break; |
| 770 | } else if (rs->rs_rlt[i].flags & HDWRPACE_INITED) { |
| 771 | arte = &rs->rs_rlt[i]; |
| 772 | } |
| 773 | } |
| 774 | goto done; |
| 775 | } else if ((mbits_per_sec > RS_ONE_GIGABIT_PERSEC) && |
| 776 | (rs->rs_rlt[(ALL_HARDWARE_RATES-1)].flags & HDWRPACE_INITED)){ |
| 777 | /* |
| 778 | * Larger than 1G (the majority of |
| 779 | * our table. |
| 780 | */ |
| 781 | if (mbits_per_sec < RS_TEN_GIGABIT_PERSEC) |
| 782 | rte = &rs->rs_rlt[(ALL_HARDWARE_RATES-1)]; |
| 783 | else |
| 784 | arte = &rs->rs_rlt[(ALL_HARDWARE_RATES-1)]; |
| 785 | goto done; |
| 786 | } |
| 787 | /* |
| 788 | * If we reach here its in our table (between 1Meg - 1000Meg), |
| 789 | * just take the rounded down mbits per second, and add |
| 790 | * 1Megabit to it, from this we can calculate |
| 791 | * the index in the table. |
| 792 | */ |
| 793 | ind_calc = mbits_per_sec/RS_ONE_MEGABIT_PERSEC; |
| 794 | if ((ind_calc * RS_ONE_MEGABIT_PERSEC) != mbits_per_sec) |
| 795 | ind_calc++; |
| 796 | /* our table is offset by 3, we add 2 */ |
| 797 | ind_calc += 2; |
| 798 | if (ind_calc > (ALL_HARDWARE_RATES-1)) { |
| 799 | /* This should not happen */ |
| 800 | ind_calc = ALL_HARDWARE_RATES-1; |
| 801 | } |
| 802 | if ((ind_calc >= rs->rs_lowest_valid) && |
| 803 | (ind_calc <= rs->rs_highest_valid)) |
| 804 | rte = &rs->rs_rlt[ind_calc]; |
| 805 | } else if (flags & RS_PACING_EXACT_MATCH) { |
| 806 | if ((mbits_per_sec < RS_ONE_MEGABIT_PERSEC) && |
| 807 | (rs->rs_lowest_valid <= 2)){ |
no outgoing calls
no test coverage detected