2 * Copyright (c) 2020 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef SRC_VNET_TCP_TCP_CC_H_
17 #define SRC_VNET_TCP_TCP_CC_H_
19 #include <vnet/tcp/tcp_types.h>
22 tcp_cc_rcv_ack (tcp_connection_t * tc, tcp_rate_sample_t * rs)
24 tc->cc_algo->rcv_ack (tc, rs);
25 tc->tsecr_last_ack = tc->rcv_opts.tsecr;
29 tcp_cc_rcv_cong_ack (tcp_connection_t * tc, tcp_cc_ack_t ack_type,
30 tcp_rate_sample_t * rs)
32 tc->cc_algo->rcv_cong_ack (tc, ack_type, rs);
36 tcp_cc_congestion (tcp_connection_t * tc)
38 tc->cc_algo->congestion (tc);
42 tcp_cc_loss (tcp_connection_t * tc)
44 tc->cc_algo->loss (tc);
48 tcp_cc_recovered (tcp_connection_t * tc)
50 tc->cc_algo->recovered (tc);
54 tcp_cc_undo_recovery (tcp_connection_t * tc)
56 if (tc->cc_algo->undo_recovery)
57 tc->cc_algo->undo_recovery (tc);
61 tcp_cc_event (tcp_connection_t * tc, tcp_cc_event_t evt)
63 if (tc->cc_algo->event)
64 tc->cc_algo->event (tc, evt);
68 tcp_cc_get_pacing_rate (tcp_connection_t * tc)
70 if (tc->cc_algo->get_pacing_rate)
71 return tc->cc_algo->get_pacing_rate (tc);
73 f64 srtt = clib_min ((f64) tc->srtt * TCP_TICK, tc->mrtt_us);
75 /* TODO should constrain to interface's max throughput but
76 * we don't have link speeds for sw ifs ..*/
77 return ((f64) tc->cwnd / srtt);
81 tcp_cc_data (tcp_connection_t * tc)
83 return (void *) tc->cc_data;
87 * Register exiting cc algo type
89 void tcp_cc_algo_register (tcp_cc_algorithm_type_e type,
90 const tcp_cc_algorithm_t * vft);
93 * Register new cc algo type
95 tcp_cc_algorithm_type_e tcp_cc_algo_new_type (const tcp_cc_algorithm_t * vft);
96 tcp_cc_algorithm_t *tcp_cc_algo_get (tcp_cc_algorithm_type_e type);
99 void newreno_rcv_cong_ack (tcp_connection_t * tc, tcp_cc_ack_t ack_type,
100 tcp_rate_sample_t * rs);
103 #endif /* SRC_VNET_TCP_TCP_CC_H_ */
106 * fd.io coding-style-patch-verification: ON
109 * eval: (c-set-style "gnu")