^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * An implementation of the DCCP protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This code has been developed by the University of Waikato WAND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * research group. For further information please see https://www.wand.net.nz/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This code also uses code from Lulea University, rereleased as GPL by its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Changes to meet Linux coding standards, to make it meet latest ccid3 draft
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * and to make it work as a loadable module in the DCCP stack written by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Arnaldo Carvalho de Melo <acme@conectiva.com.br>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "../dccp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "ccid3.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #ifdef CONFIG_IP_DCCP_CCID3_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static bool ccid3_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define ccid3_pr_debug(format, a...) DCCP_PR_DEBUG(ccid3_debug, format, ##a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define ccid3_pr_debug(format, a...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * Transmitter Half-Connection Routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #ifdef CONFIG_IP_DCCP_CCID3_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static const char *const ccid3_state_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) [TFRC_SSTATE_NO_SENT] = "NO_SENT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) [TFRC_SSTATE_NO_FBACK] = "NO_FBACK",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) [TFRC_SSTATE_FBACK] = "FBACK",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return ccid3_state_names[state];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static void ccid3_hc_tx_set_state(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) enum ccid3_hc_tx_states state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) enum ccid3_hc_tx_states oldstate = hc->tx_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) dccp_role(sk), sk, ccid3_tx_state_name(oldstate),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ccid3_tx_state_name(state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) WARN_ON(state == oldstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) hc->tx_state = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * Compute the initial sending rate X_init in the manner of RFC 3390:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * X_init = min(4 * s, max(2 * s, 4380 bytes)) / RTT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Note that RFC 3390 uses MSS, RFC 4342 refers to RFC 3390, and rfc3448bis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * (rev-02) clarifies the use of RFC 3390 with regard to the above formula.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * For consistency with other parts of the code, X_init is scaled by 2^6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static inline u64 rfc3390_initial_rate(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) const struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) const __u32 w_init = clamp_t(__u32, 4380U, 2 * hc->tx_s, 4 * hc->tx_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) return scaled_div(w_init << 6, hc->tx_rtt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * ccid3_update_send_interval - Calculate new t_ipi = s / X_inst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * This respects the granularity of X_inst (64 * bytes/second).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) hc->tx_t_ipi = scaled_div32(((u64)hc->tx_s) << 6, hc->tx_x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) DCCP_BUG_ON(hc->tx_t_ipi == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) ccid3_pr_debug("t_ipi=%u, s=%u, X=%u\n", hc->tx_t_ipi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) hc->tx_s, (unsigned int)(hc->tx_x >> 6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static u32 ccid3_hc_tx_idle_rtt(struct ccid3_hc_tx_sock *hc, ktime_t now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) u32 delta = ktime_us_delta(now, hc->tx_t_last_win_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) return delta / hc->tx_rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * ccid3_hc_tx_update_x - Update allowed sending rate X
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @stamp: most recent time if available - can be left NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * This function tracks draft rfc3448bis, check there for latest details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * Note: X and X_recv are both stored in units of 64 * bytes/second, to support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * fine-grained resolution of sending rates. This requires scaling by 2^6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * throughout the code. Only X_calc is unscaled (in bytes/second).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) __u64 min_rate = 2 * hc->tx_x_recv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) const __u64 old_x = hc->tx_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ktime_t now = stamp ? *stamp : ktime_get_real();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * Handle IDLE periods: do not reduce below RFC3390 initial sending rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * when idling [RFC 4342, 5.1]. Definition of idling is from rfc3448bis:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * a sender is idle if it has not sent anything over a 2-RTT-period.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * For consistency with X and X_recv, min_rate is also scaled by 2^6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (ccid3_hc_tx_idle_rtt(hc, now) >= 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) min_rate = rfc3390_initial_rate(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) min_rate = max(min_rate, 2 * hc->tx_x_recv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (hc->tx_p > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) hc->tx_x = min(((__u64)hc->tx_x_calc) << 6, min_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) hc->tx_x = max(hc->tx_x, (((__u64)hc->tx_s) << 6) / TFRC_T_MBI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) } else if (ktime_us_delta(now, hc->tx_t_ld) - (s64)hc->tx_rtt >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) hc->tx_x = min(2 * hc->tx_x, min_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) hc->tx_x = max(hc->tx_x,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) scaled_div(((__u64)hc->tx_s) << 6, hc->tx_rtt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) hc->tx_t_ld = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (hc->tx_x != old_x) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ccid3_pr_debug("X_prev=%u, X_now=%u, X_calc=%u, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) "X_recv=%u\n", (unsigned int)(old_x >> 6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) (unsigned int)(hc->tx_x >> 6), hc->tx_x_calc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) (unsigned int)(hc->tx_x_recv >> 6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ccid3_update_send_interval(hc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * ccid3_hc_tx_update_s - Track the mean packet size `s'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * @len: DCCP packet payload size in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * cf. RFC 4342, 5.3 and RFC 3448, 4.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hc, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) const u16 old_s = hc->tx_s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) hc->tx_s = tfrc_ewma(hc->tx_s, len, 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (hc->tx_s != old_s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) ccid3_update_send_interval(hc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * Update Window Counter using the algorithm from [RFC 4342, 8.1].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * As elsewhere, RTT > 0 is assumed by using dccp_sample_rtt().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) ktime_t now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) u32 delta = ktime_us_delta(now, hc->tx_t_last_win_count),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) quarter_rtts = (4 * delta) / hc->tx_rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (quarter_rtts > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) hc->tx_t_last_win_count = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) hc->tx_last_win_count += min(quarter_rtts, 5U);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) hc->tx_last_win_count &= 0xF; /* mod 16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static void ccid3_hc_tx_no_feedback_timer(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct ccid3_hc_tx_sock *hc = from_timer(hc, t, tx_no_feedback_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct sock *sk = hc->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) unsigned long t_nfb = USEC_PER_SEC / 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) bh_lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (sock_owned_by_user(sk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /* Try again later. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /* XXX: set some sensible MIB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) goto restart_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) ccid3_pr_debug("%s(%p, state=%s) - entry\n", dccp_role(sk), sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) ccid3_tx_state_name(hc->tx_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /* Ignore and do not restart after leaving the established state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if ((1 << sk->sk_state) & ~(DCCPF_OPEN | DCCPF_PARTOPEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /* Reset feedback state to "no feedback received" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (hc->tx_state == TFRC_SSTATE_FBACK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * Determine new allowed sending rate X as per draft rfc3448bis-00, 4.4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * RTO is 0 if and only if no feedback has been received yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (hc->tx_t_rto == 0 || hc->tx_p == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /* halve send rate directly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) hc->tx_x = max(hc->tx_x / 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) (((__u64)hc->tx_s) << 6) / TFRC_T_MBI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ccid3_update_send_interval(hc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * Modify the cached value of X_recv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * If (X_calc > 2 * X_recv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * X_recv = max(X_recv / 2, s / (2 * t_mbi));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * Else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * X_recv = X_calc / 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * Note that X_recv is scaled by 2^6 while X_calc is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if (hc->tx_x_calc > (hc->tx_x_recv >> 5))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) hc->tx_x_recv =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) max(hc->tx_x_recv / 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) (((__u64)hc->tx_s) << 6) / (2*TFRC_T_MBI));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) hc->tx_x_recv = hc->tx_x_calc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) hc->tx_x_recv <<= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) ccid3_hc_tx_update_x(sk, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) ccid3_pr_debug("Reduced X to %llu/64 bytes/sec\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) (unsigned long long)hc->tx_x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * Set new timeout for the nofeedback timer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * See comments in packet_recv() regarding the value of t_RTO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (unlikely(hc->tx_t_rto == 0)) /* no feedback received yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) t_nfb = TFRC_INITIAL_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) t_nfb = max(hc->tx_t_rto, 2 * hc->tx_t_ipi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) restart_timer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) sk_reset_timer(sk, &hc->tx_no_feedback_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) jiffies + usecs_to_jiffies(t_nfb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) bh_unlock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) sock_put(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * ccid3_hc_tx_send_packet - Delay-based dequeueing of TX packets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * @skb: next packet candidate to send on @sk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * This function uses the convention of ccid_packet_dequeue_eval() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * returns a millisecond-delay value between 0 and t_mbi = 64000 msec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct dccp_sock *dp = dccp_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ktime_t now = ktime_get_real();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) s64 delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * This function is called only for Data and DataAck packets. Sending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * zero-sized Data(Ack)s is theoretically possible, but for congestion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * control this case is pathological - ignore it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) if (unlikely(skb->len == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return -EBADMSG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (hc->tx_state == TFRC_SSTATE_NO_SENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) sk_reset_timer(sk, &hc->tx_no_feedback_timer, (jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) usecs_to_jiffies(TFRC_INITIAL_TIMEOUT)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) hc->tx_last_win_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) hc->tx_t_last_win_count = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) /* Set t_0 for initial packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) hc->tx_t_nom = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) hc->tx_s = skb->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) * Use initial RTT sample when available: recommended by erratum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) * to RFC 4342. This implements the initialisation procedure of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * draft rfc3448bis, section 4.2. Remember, X is scaled by 2^6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) if (dp->dccps_syn_rtt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) ccid3_pr_debug("SYN RTT = %uus\n", dp->dccps_syn_rtt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) hc->tx_rtt = dp->dccps_syn_rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) hc->tx_x = rfc3390_initial_rate(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) hc->tx_t_ld = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * Sender does not have RTT sample:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * - set fallback RTT (RFC 4340, 3.4) since a RTT value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * is needed in several parts (e.g. window counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * - set sending rate X_pps = 1pps as per RFC 3448, 4.2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) hc->tx_rtt = DCCP_FALLBACK_RTT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) hc->tx_x = hc->tx_s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) hc->tx_x <<= 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) ccid3_update_send_interval(hc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) delay = ktime_us_delta(hc->tx_t_nom, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) ccid3_pr_debug("delay=%ld\n", (long)delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * Scheduling of packet transmissions (RFC 5348, 8.3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * if (t_now > t_nom - delta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * // send the packet now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) * // send the packet in (t_nom - t_now) milliseconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if (delay >= TFRC_T_DELTA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return (u32)delay / USEC_PER_MSEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) ccid3_hc_tx_update_win_count(hc, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) /* prepare to send now (add options etc.) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) dp->dccps_hc_tx_insert_options = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) DCCP_SKB_CB(skb)->dccpd_ccval = hc->tx_last_win_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /* set the nominal send time for the next following packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) hc->tx_t_nom = ktime_add_us(hc->tx_t_nom, hc->tx_t_ipi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) return CCID_PACKET_SEND_AT_ONCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) static void ccid3_hc_tx_packet_sent(struct sock *sk, unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) ccid3_hc_tx_update_s(hc, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) if (tfrc_tx_hist_add(&hc->tx_hist, dccp_sk(sk)->dccps_gss))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) DCCP_CRIT("packet history - out of memory!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct tfrc_tx_hist_entry *acked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) ktime_t now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) unsigned long t_nfb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) u32 r_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) /* we are only interested in ACKs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_DATAACK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) * Locate the acknowledged packet in the TX history.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) * Returning "entry not found" here can for instance happen when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * - the host has not sent out anything (e.g. a passive server),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) * - the Ack is outdated (packet with higher Ack number was received),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * - it is a bogus Ack (for a packet not sent on this connection).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) acked = tfrc_tx_hist_find_entry(hc->tx_hist, dccp_hdr_ack_seq(skb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) if (acked == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) /* For the sake of RTT sampling, ignore/remove all older entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) tfrc_tx_hist_purge(&acked->next);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) /* Update the moving average for the RTT estimate (RFC 3448, 4.3) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) now = ktime_get_real();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) r_sample = dccp_sample_rtt(sk, ktime_us_delta(now, acked->stamp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) hc->tx_rtt = tfrc_ewma(hc->tx_rtt, r_sample, 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) if (hc->tx_state == TFRC_SSTATE_NO_FBACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) if (hc->tx_t_rto == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * Initial feedback packet: Larger Initial Windows (4.2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) hc->tx_x = rfc3390_initial_rate(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) hc->tx_t_ld = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) ccid3_update_send_interval(hc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) goto done_computing_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) } else if (hc->tx_p == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) * First feedback after nofeedback timer expiry (4.3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) goto done_computing_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) /* Update sending rate (step 4 of [RFC 3448, 4.3]) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) if (hc->tx_p > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) hc->tx_x_calc = tfrc_calc_x(hc->tx_s, hc->tx_rtt, hc->tx_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) ccid3_hc_tx_update_x(sk, &now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) done_computing_x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) ccid3_pr_debug("%s(%p), RTT=%uus (sample=%uus), s=%u, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) "p=%u, X_calc=%u, X_recv=%u, X=%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) dccp_role(sk), sk, hc->tx_rtt, r_sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) hc->tx_s, hc->tx_p, hc->tx_x_calc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) (unsigned int)(hc->tx_x_recv >> 6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) (unsigned int)(hc->tx_x >> 6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) /* unschedule no feedback timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) sk_stop_timer(sk, &hc->tx_no_feedback_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * As we have calculated new ipi, delta, t_nom it is possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * that we now can send a packet, so wake up dccp_wait_for_ccid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) sk->sk_write_space(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) * Update timeout interval for the nofeedback timer. In order to control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * rate halving on networks with very low RTTs (<= 1 ms), use per-route
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) * tunable RTAX_RTO_MIN value as the lower bound.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) hc->tx_t_rto = max_t(u32, 4 * hc->tx_rtt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) USEC_PER_SEC/HZ * tcp_rto_min(sk));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) * Schedule no feedback timer to expire in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) * max(t_RTO, 2 * s/X) = max(t_RTO, 2 * t_ipi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) t_nfb = max(hc->tx_t_rto, 2 * hc->tx_t_ipi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) ccid3_pr_debug("%s(%p), Scheduled no feedback timer to "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) "expire in %lu jiffies (%luus)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) dccp_role(sk), sk, usecs_to_jiffies(t_nfb), t_nfb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) sk_reset_timer(sk, &hc->tx_no_feedback_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) jiffies + usecs_to_jiffies(t_nfb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) static int ccid3_hc_tx_parse_options(struct sock *sk, u8 packet_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) u8 option, u8 *optval, u8 optlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) __be32 opt_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) switch (option) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) case TFRC_OPT_RECEIVE_RATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) case TFRC_OPT_LOSS_EVENT_RATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) /* Must be ignored on Data packets, cf. RFC 4342 8.3 and 8.5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) if (packet_type == DCCP_PKT_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) if (unlikely(optlen != 4)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) DCCP_WARN("%s(%p), invalid len %d for %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) dccp_role(sk), sk, optlen, option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) opt_val = ntohl(get_unaligned((__be32 *)optval));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) if (option == TFRC_OPT_RECEIVE_RATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) /* Receive Rate is kept in units of 64 bytes/second */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) hc->tx_x_recv = opt_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) hc->tx_x_recv <<= 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) dccp_role(sk), sk, opt_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) /* Update the fixpoint Loss Event Rate fraction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) hc->tx_p = tfrc_invert_loss_event_rate(opt_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) dccp_role(sk), sk, opt_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) struct ccid3_hc_tx_sock *hc = ccid_priv(ccid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) hc->tx_state = TFRC_SSTATE_NO_SENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) hc->tx_hist = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) hc->sk = sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) timer_setup(&hc->tx_no_feedback_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) ccid3_hc_tx_no_feedback_timer, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) static void ccid3_hc_tx_exit(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) sk_stop_timer(sk, &hc->tx_no_feedback_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) tfrc_tx_hist_purge(&hc->tx_hist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) info->tcpi_rto = ccid3_hc_tx_sk(sk)->tx_t_rto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) info->tcpi_rtt = ccid3_hc_tx_sk(sk)->tx_rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) u32 __user *optval, int __user *optlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) const struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) struct tfrc_tx_info tfrc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) const void *val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) switch (optname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) case DCCP_SOCKOPT_CCID_TX_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) if (len < sizeof(tfrc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) memset(&tfrc, 0, sizeof(tfrc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) tfrc.tfrctx_x = hc->tx_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) tfrc.tfrctx_x_recv = hc->tx_x_recv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) tfrc.tfrctx_x_calc = hc->tx_x_calc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) tfrc.tfrctx_rtt = hc->tx_rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) tfrc.tfrctx_p = hc->tx_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) tfrc.tfrctx_rto = hc->tx_t_rto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) tfrc.tfrctx_ipi = hc->tx_t_ipi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) len = sizeof(tfrc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) val = &tfrc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) return -ENOPROTOOPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) if (put_user(len, optlen) || copy_to_user(optval, val, len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * Receiver Half-Connection Routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) /* CCID3 feedback types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) enum ccid3_fback_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) CCID3_FBACK_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) CCID3_FBACK_INITIAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) CCID3_FBACK_PERIODIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) CCID3_FBACK_PARAM_CHANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) #ifdef CONFIG_IP_DCCP_CCID3_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) static const char *const ccid3_rx_state_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) [TFRC_RSTATE_NO_DATA] = "NO_DATA",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) [TFRC_RSTATE_DATA] = "DATA",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) return ccid3_rx_state_names[state];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) static void ccid3_hc_rx_set_state(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) enum ccid3_hc_rx_states state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) enum ccid3_hc_rx_states oldstate = hc->rx_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) dccp_role(sk), sk, ccid3_rx_state_name(oldstate),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) ccid3_rx_state_name(state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) WARN_ON(state == oldstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) hc->rx_state = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) static void ccid3_hc_rx_send_feedback(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) const struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) enum ccid3_fback_type fbtype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) struct dccp_sock *dp = dccp_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) ktime_t now = ktime_get();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) s64 delta = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) switch (fbtype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) case CCID3_FBACK_INITIAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) hc->rx_x_recv = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) hc->rx_pinv = ~0U; /* see RFC 4342, 8.5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) case CCID3_FBACK_PARAM_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * When parameters change (new loss or p > p_prev), we do not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) * have a reliable estimate for R_m of [RFC 3448, 6.2] and so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * need to reuse the previous value of X_recv. However, when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) * X_recv was 0 (due to early loss), this would kill X down to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) * s/t_mbi (i.e. one packet in 64 seconds).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) * To avoid such drastic reduction, we approximate X_recv as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * the number of bytes since last feedback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) * This is a safe fallback, since X is bounded above by X_calc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) if (hc->rx_x_recv > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) case CCID3_FBACK_PERIODIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) delta = ktime_us_delta(now, hc->rx_tstamp_last_feedback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) if (delta <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) delta = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) hc->rx_x_recv = scaled_div32(hc->rx_bytes_recv, delta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) ccid3_pr_debug("Interval %lldusec, X_recv=%u, 1/p=%u\n", delta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) hc->rx_x_recv, hc->rx_pinv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) hc->rx_tstamp_last_feedback = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) hc->rx_last_counter = dccp_hdr(skb)->dccph_ccval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) hc->rx_bytes_recv = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) dp->dccps_hc_rx_insert_options = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) dccp_send_ack(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) const struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) __be32 x_recv, pinv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) if (dccp_packet_without_ack(skb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) x_recv = htonl(hc->rx_x_recv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) pinv = htonl(hc->rx_pinv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) if (dccp_insert_option(skb, TFRC_OPT_LOSS_EVENT_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) &pinv, sizeof(pinv)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) dccp_insert_option(skb, TFRC_OPT_RECEIVE_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) &x_recv, sizeof(x_recv)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) * ccid3_first_li - Implements [RFC 5348, 6.3.1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) * Determine the length of the first loss interval via inverse lookup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) * Assume that X_recv can be computed by the throughput equation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) * s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) * X_recv = --------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) * R * fval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) * Find some p such that f(p) = fval; return 1/p (scaled).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) static u32 ccid3_first_li(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) u32 x_recv, p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) s64 delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) u64 fval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) if (hc->rx_rtt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) DCCP_WARN("No RTT estimate available, using fallback RTT\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) hc->rx_rtt = DCCP_FALLBACK_RTT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) delta = ktime_us_delta(ktime_get(), hc->rx_tstamp_last_feedback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) if (delta <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) delta = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) x_recv = scaled_div32(hc->rx_bytes_recv, delta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) if (x_recv == 0) { /* would also trigger divide-by-zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) DCCP_WARN("X_recv==0\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) if (hc->rx_x_recv == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) DCCP_BUG("stored value of X_recv is zero");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) return ~0U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) x_recv = hc->rx_x_recv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) fval = scaled_div(hc->rx_s, hc->rx_rtt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) fval = scaled_div32(fval, x_recv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) p = tfrc_calc_x_reverse_lookup(fval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) ccid3_pr_debug("%s(%p), receive rate=%u bytes/s, implied "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) "loss rate=%u\n", dccp_role(sk), sk, x_recv, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) return p == 0 ? ~0U : scaled_div(1, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) enum ccid3_fback_type do_feedback = CCID3_FBACK_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) const u64 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) const bool is_data_packet = dccp_data_packet(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) if (unlikely(hc->rx_state == TFRC_RSTATE_NO_DATA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) if (is_data_packet) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) do_feedback = CCID3_FBACK_INITIAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) hc->rx_s = payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) * Not necessary to update rx_bytes_recv here,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) * since X_recv = 0 for the first feedback packet (cf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) * RFC 3448, 6.3) -- gerrit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) goto update_records;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) if (tfrc_rx_hist_duplicate(&hc->rx_hist, skb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) return; /* done receiving */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) if (is_data_packet) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) * Update moving-average of s and the sum of received payload bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) hc->rx_s = tfrc_ewma(hc->rx_s, payload, 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) hc->rx_bytes_recv += payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) * Perform loss detection and handle pending losses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) if (tfrc_rx_handle_loss(&hc->rx_hist, &hc->rx_li_hist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) skb, ndp, ccid3_first_li, sk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) do_feedback = CCID3_FBACK_PARAM_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) goto done_receiving;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) if (tfrc_rx_hist_loss_pending(&hc->rx_hist))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) return; /* done receiving */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) * Handle data packets: RTT sampling and monitoring p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) if (unlikely(!is_data_packet))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) goto update_records;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) if (!tfrc_lh_is_initialised(&hc->rx_li_hist)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) const u32 sample = tfrc_rx_hist_sample_rtt(&hc->rx_hist, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) * Empty loss history: no loss so far, hence p stays 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) * Sample RTT values, since an RTT estimate is required for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) * computation of p when the first loss occurs; RFC 3448, 6.3.1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) if (sample != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) hc->rx_rtt = tfrc_ewma(hc->rx_rtt, sample, 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) } else if (tfrc_lh_update_i_mean(&hc->rx_li_hist, skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) * Step (3) of [RFC 3448, 6.1]: Recompute I_mean and, if I_mean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) * has decreased (resp. p has increased), send feedback now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) do_feedback = CCID3_FBACK_PARAM_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) * Check if the periodic once-per-RTT feedback is due; RFC 4342, 10.3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) if (SUB16(dccp_hdr(skb)->dccph_ccval, hc->rx_last_counter) > 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) do_feedback = CCID3_FBACK_PERIODIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) update_records:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) tfrc_rx_hist_add_packet(&hc->rx_hist, skb, ndp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) done_receiving:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) if (do_feedback)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) ccid3_hc_rx_send_feedback(sk, skb, do_feedback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) struct ccid3_hc_rx_sock *hc = ccid_priv(ccid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) hc->rx_state = TFRC_RSTATE_NO_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) tfrc_lh_init(&hc->rx_li_hist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) return tfrc_rx_hist_alloc(&hc->rx_hist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) static void ccid3_hc_rx_exit(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) tfrc_rx_hist_purge(&hc->rx_hist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) tfrc_lh_cleanup(&hc->rx_li_hist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) info->tcpi_ca_state = ccid3_hc_rx_sk(sk)->rx_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) info->tcpi_rcv_rtt = ccid3_hc_rx_sk(sk)->rx_rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) u32 __user *optval, int __user *optlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) const struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) struct tfrc_rx_info rx_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) const void *val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) switch (optname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) case DCCP_SOCKOPT_CCID_RX_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) if (len < sizeof(rx_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) rx_info.tfrcrx_x_recv = hc->rx_x_recv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) rx_info.tfrcrx_rtt = hc->rx_rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) rx_info.tfrcrx_p = tfrc_invert_loss_event_rate(hc->rx_pinv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) len = sizeof(rx_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) val = &rx_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) return -ENOPROTOOPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) if (put_user(len, optlen) || copy_to_user(optval, val, len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) struct ccid_operations ccid3_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) .ccid_id = DCCPC_CCID3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) .ccid_name = "TCP-Friendly Rate Control",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) .ccid_hc_tx_obj_size = sizeof(struct ccid3_hc_tx_sock),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) .ccid_hc_tx_init = ccid3_hc_tx_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) .ccid_hc_tx_exit = ccid3_hc_tx_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) .ccid_hc_tx_send_packet = ccid3_hc_tx_send_packet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) .ccid_hc_tx_packet_sent = ccid3_hc_tx_packet_sent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) .ccid_hc_tx_packet_recv = ccid3_hc_tx_packet_recv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) .ccid_hc_tx_parse_options = ccid3_hc_tx_parse_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) .ccid_hc_rx_obj_size = sizeof(struct ccid3_hc_rx_sock),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) .ccid_hc_rx_init = ccid3_hc_rx_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) .ccid_hc_rx_exit = ccid3_hc_rx_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) .ccid_hc_rx_insert_options = ccid3_hc_rx_insert_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) .ccid_hc_rx_packet_recv = ccid3_hc_rx_packet_recv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) .ccid_hc_rx_get_info = ccid3_hc_rx_get_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) .ccid_hc_tx_get_info = ccid3_hc_tx_get_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) .ccid_hc_rx_getsockopt = ccid3_hc_rx_getsockopt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) .ccid_hc_tx_getsockopt = ccid3_hc_tx_getsockopt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) #ifdef CONFIG_IP_DCCP_CCID3_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) module_param(ccid3_debug, bool, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) MODULE_PARM_DESC(ccid3_debug, "Enable CCID-3 debug messages");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) #endif