Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dccp: Return-value convention of hc_tx_send_packet()

This patch reorganises the return value convention of the CCID TX sending
function, to permit more flexible schemes, as required by subsequent patches.

Currently the convention is
* values < 0 mean error,
* a value == 0 means "send now", and
* a value x > 0 means "send in x milliseconds".

The patch provides symbolic constants and a function to interpret return values.

In addition, it caps the maximum positive return value to 0xFFFF milliseconds,
corresponding to 65.535 seconds. This is possible since in CCID-3/4 the
maximum possible inter-packet gap is fixed at t_mbi = 64 sec.

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Gerrit Renker and committed by
David S. Miller
fe84f414 de7fe787

+37 -9
+31 -3
net/dccp/ccid.h
··· 134 134 extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk); 135 135 extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk); 136 136 137 + /* 138 + * Congestion control of queued data packets via CCID decision. 139 + * 140 + * The TX CCID performs its congestion-control by indicating whether and when a 141 + * queued packet may be sent, using the return code of ccid_hc_tx_send_packet(). 142 + * The following modes are supported via the symbolic constants below: 143 + * - timer-based pacing (CCID returns a delay value in milliseconds); 144 + * - autonomous dequeueing (CCID internally schedules dccps_xmitlet). 145 + */ 146 + 147 + enum ccid_dequeueing_decision { 148 + CCID_PACKET_SEND_AT_ONCE = 0x00000, /* "green light": no delay */ 149 + CCID_PACKET_DELAY_MAX = 0x0FFFF, /* maximum delay in msecs */ 150 + CCID_PACKET_DELAY = 0x10000, /* CCID msec-delay mode */ 151 + CCID_PACKET_WILL_DEQUEUE_LATER = 0x20000, /* CCID autonomous mode */ 152 + CCID_PACKET_ERR = 0xF0000, /* error condition */ 153 + }; 154 + 155 + static inline int ccid_packet_dequeue_eval(const int return_code) 156 + { 157 + if (return_code < 0) 158 + return CCID_PACKET_ERR; 159 + if (return_code == 0) 160 + return CCID_PACKET_SEND_AT_ONCE; 161 + if (return_code <= CCID_PACKET_DELAY_MAX) 162 + return CCID_PACKET_DELAY; 163 + return return_code; 164 + } 165 + 137 166 static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk, 138 167 struct sk_buff *skb) 139 168 { 140 - int rc = 0; 141 169 if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL) 142 - rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb); 143 - return rc; 170 + return ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb); 171 + return CCID_PACKET_SEND_AT_ONCE; 144 172 } 145 173 146 174 static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
+6 -6
net/dccp/ccids/ccid3.c
··· 268 268 sock_put(sk); 269 269 } 270 270 271 - /* 272 - * returns 273 - * > 0: delay (in msecs) that should pass before actually sending 274 - * = 0: can send immediately 275 - * < 0: error condition; do not send packet 271 + /** 272 + * ccid3_hc_tx_send_packet - Delay-based dequeueing of TX packets 273 + * @skb: next packet candidate to send on @sk 274 + * This function uses the convention of ccid_packet_dequeue_eval() and 275 + * returns a millisecond-delay value between 0 and t_mbi = 64000 msec. 276 276 */ 277 277 static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) 278 278 { ··· 348 348 349 349 /* set the nominal send time for the next following packet */ 350 350 hc->tx_t_nom = ktime_add_us(hc->tx_t_nom, hc->tx_t_ipi); 351 - return 0; 351 + return CCID_PACKET_SEND_AT_ONCE; 352 352 } 353 353 354 354 static void ccid3_hc_tx_packet_sent(struct sock *sk, unsigned int len)