Skip to content

Commit fe84f41

Browse files
Gerrit Renkerdavem330
Gerrit Renker
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent de7fe78 commit fe84f41

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

net/dccp/ccid.h

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,41 @@ static inline int ccid_get_current_tx_ccid(struct dccp_sock *dp)
134134
extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
135135
extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
136136

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+
137166
static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
138167
struct sk_buff *skb)
139168
{
140-
int rc = 0;
141169
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;
144172
}
145173

146174
static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,

net/dccp/ccids/ccid3.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
268268
sock_put(sk);
269269
}
270270

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.
276276
*/
277277
static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
278278
{
@@ -348,7 +348,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
348348

349349
/* set the nominal send time for the next following packet */
350350
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;
352352
}
353353

354354
static void ccid3_hc_tx_packet_sent(struct sock *sk, unsigned int len)

0 commit comments

Comments
 (0)