aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccid.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/ccid.h')
-rw-r--r--net/dccp/ccid.h113
1 files changed, 80 insertions, 33 deletions
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index fdeae7b57319..d27054ba2159 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -60,22 +60,18 @@ struct ccid_operations {
60 void (*ccid_hc_tx_exit)(struct sock *sk); 60 void (*ccid_hc_tx_exit)(struct sock *sk);
61 void (*ccid_hc_rx_packet_recv)(struct sock *sk, 61 void (*ccid_hc_rx_packet_recv)(struct sock *sk,
62 struct sk_buff *skb); 62 struct sk_buff *skb);
63 int (*ccid_hc_rx_parse_options)(struct sock *sk, 63 int (*ccid_hc_rx_parse_options)(struct sock *sk, u8 pkt,
64 unsigned char option, 64 u8 opt, u8 *val, u8 len);
65 unsigned char len, u16 idx,
66 unsigned char* value);
67 int (*ccid_hc_rx_insert_options)(struct sock *sk, 65 int (*ccid_hc_rx_insert_options)(struct sock *sk,
68 struct sk_buff *skb); 66 struct sk_buff *skb);
69 void (*ccid_hc_tx_packet_recv)(struct sock *sk, 67 void (*ccid_hc_tx_packet_recv)(struct sock *sk,
70 struct sk_buff *skb); 68 struct sk_buff *skb);
71 int (*ccid_hc_tx_parse_options)(struct sock *sk, 69 int (*ccid_hc_tx_parse_options)(struct sock *sk, u8 pkt,
72 unsigned char option, 70 u8 opt, u8 *val, u8 len);
73 unsigned char len, u16 idx,
74 unsigned char* value);
75 int (*ccid_hc_tx_send_packet)(struct sock *sk, 71 int (*ccid_hc_tx_send_packet)(struct sock *sk,
76 struct sk_buff *skb); 72 struct sk_buff *skb);
77 void (*ccid_hc_tx_packet_sent)(struct sock *sk, 73 void (*ccid_hc_tx_packet_sent)(struct sock *sk,
78 int more, unsigned int len); 74 unsigned int len);
79 void (*ccid_hc_rx_get_info)(struct sock *sk, 75 void (*ccid_hc_rx_get_info)(struct sock *sk,
80 struct tcp_info *info); 76 struct tcp_info *info);
81 void (*ccid_hc_tx_get_info)(struct sock *sk, 77 void (*ccid_hc_tx_get_info)(struct sock *sk,
@@ -103,31 +99,78 @@ static inline void *ccid_priv(const struct ccid *ccid)
103 return (void *)ccid->ccid_priv; 99 return (void *)ccid->ccid_priv;
104} 100}
105 101
102extern bool ccid_support_check(u8 const *ccid_array, u8 array_len);
103extern int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len);
104extern int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
105 char __user *, int __user *);
106
107extern int ccid_request_modules(u8 const *ccid_array, u8 array_len);
106extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, 108extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx,
107 gfp_t gfp); 109 gfp_t gfp);
108 110
109extern struct ccid *ccid_hc_rx_new(unsigned char id, struct sock *sk, 111static inline int ccid_get_current_rx_ccid(struct dccp_sock *dp)
110 gfp_t gfp); 112{
111extern struct ccid *ccid_hc_tx_new(unsigned char id, struct sock *sk, 113 struct ccid *ccid = dp->dccps_hc_rx_ccid;
112 gfp_t gfp); 114
115 if (ccid == NULL || ccid->ccid_ops == NULL)
116 return -1;
117 return ccid->ccid_ops->ccid_id;
118}
119
120static inline int ccid_get_current_tx_ccid(struct dccp_sock *dp)
121{
122 struct ccid *ccid = dp->dccps_hc_tx_ccid;
123
124 if (ccid == NULL || ccid->ccid_ops == NULL)
125 return -1;
126 return ccid->ccid_ops->ccid_id;
127}
113 128
114extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk); 129extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
115extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk); 130extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
116 131
132/*
133 * Congestion control of queued data packets via CCID decision.
134 *
135 * The TX CCID performs its congestion-control by indicating whether and when a
136 * queued packet may be sent, using the return code of ccid_hc_tx_send_packet().
137 * The following modes are supported via the symbolic constants below:
138 * - timer-based pacing (CCID returns a delay value in milliseconds);
139 * - autonomous dequeueing (CCID internally schedules dccps_xmitlet).
140 */
141
142enum ccid_dequeueing_decision {
143 CCID_PACKET_SEND_AT_ONCE = 0x00000, /* "green light": no delay */
144 CCID_PACKET_DELAY_MAX = 0x0FFFF, /* maximum delay in msecs */
145 CCID_PACKET_DELAY = 0x10000, /* CCID msec-delay mode */
146 CCID_PACKET_WILL_DEQUEUE_LATER = 0x20000, /* CCID autonomous mode */
147 CCID_PACKET_ERR = 0xF0000, /* error condition */
148};
149
150static inline int ccid_packet_dequeue_eval(const int return_code)
151{
152 if (return_code < 0)
153 return CCID_PACKET_ERR;
154 if (return_code == 0)
155 return CCID_PACKET_SEND_AT_ONCE;
156 if (return_code <= CCID_PACKET_DELAY_MAX)
157 return CCID_PACKET_DELAY;
158 return return_code;
159}
160
117static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk, 161static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
118 struct sk_buff *skb) 162 struct sk_buff *skb)
119{ 163{
120 int rc = 0;
121 if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL) 164 if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL)
122 rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb); 165 return ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb);
123 return rc; 166 return CCID_PACKET_SEND_AT_ONCE;
124} 167}
125 168
126static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk, 169static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
127 int more, unsigned int len) 170 unsigned int len)
128{ 171{
129 if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL) 172 if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
130 ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len); 173 ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, len);
131} 174}
132 175
133static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk, 176static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
@@ -144,27 +187,31 @@ static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
144 ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb); 187 ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb);
145} 188}
146 189
190/**
191 * ccid_hc_tx_parse_options - Parse CCID-specific options sent by the receiver
192 * @pkt: type of packet that @opt appears on (RFC 4340, 5.1)
193 * @opt: the CCID-specific option type (RFC 4340, 5.8 and 10.3)
194 * @val: value of @opt
195 * @len: length of @val in bytes
196 */
147static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk, 197static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
148 unsigned char option, 198 u8 pkt, u8 opt, u8 *val, u8 len)
149 unsigned char len, u16 idx,
150 unsigned char* value)
151{ 199{
152 int rc = 0; 200 if (ccid->ccid_ops->ccid_hc_tx_parse_options == NULL)
153 if (ccid->ccid_ops->ccid_hc_tx_parse_options != NULL) 201 return 0;
154 rc = ccid->ccid_ops->ccid_hc_tx_parse_options(sk, option, len, idx, 202 return ccid->ccid_ops->ccid_hc_tx_parse_options(sk, pkt, opt, val, len);
155 value);
156 return rc;
157} 203}
158 204
205/**
206 * ccid_hc_rx_parse_options - Parse CCID-specific options sent by the sender
207 * Arguments are analogous to ccid_hc_tx_parse_options()
208 */
159static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk, 209static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
160 unsigned char option, 210 u8 pkt, u8 opt, u8 *val, u8 len)
161 unsigned char len, u16 idx,
162 unsigned char* value)
163{ 211{
164 int rc = 0; 212 if (ccid->ccid_ops->ccid_hc_rx_parse_options == NULL)
165 if (ccid->ccid_ops->ccid_hc_rx_parse_options != NULL) 213 return 0;
166 rc = ccid->ccid_ops->ccid_hc_rx_parse_options(sk, option, len, idx, value); 214 return ccid->ccid_ops->ccid_hc_rx_parse_options(sk, pkt, opt, val, len);
167 return rc;
168} 215}
169 216
170static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk, 217static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,