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, 33 insertions, 80 deletions
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index d27054ba2159..fdeae7b57319 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -60,18 +60,22 @@ 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, u8 pkt, 63 int (*ccid_hc_rx_parse_options)(struct sock *sk,
64 u8 opt, u8 *val, u8 len); 64 unsigned char option,
65 unsigned char len, u16 idx,
66 unsigned char* value);
65 int (*ccid_hc_rx_insert_options)(struct sock *sk, 67 int (*ccid_hc_rx_insert_options)(struct sock *sk,
66 struct sk_buff *skb); 68 struct sk_buff *skb);
67 void (*ccid_hc_tx_packet_recv)(struct sock *sk, 69 void (*ccid_hc_tx_packet_recv)(struct sock *sk,
68 struct sk_buff *skb); 70 struct sk_buff *skb);
69 int (*ccid_hc_tx_parse_options)(struct sock *sk, u8 pkt, 71 int (*ccid_hc_tx_parse_options)(struct sock *sk,
70 u8 opt, u8 *val, u8 len); 72 unsigned char option,
73 unsigned char len, u16 idx,
74 unsigned char* value);
71 int (*ccid_hc_tx_send_packet)(struct sock *sk, 75 int (*ccid_hc_tx_send_packet)(struct sock *sk,
72 struct sk_buff *skb); 76 struct sk_buff *skb);
73 void (*ccid_hc_tx_packet_sent)(struct sock *sk, 77 void (*ccid_hc_tx_packet_sent)(struct sock *sk,
74 unsigned int len); 78 int more, unsigned int len);
75 void (*ccid_hc_rx_get_info)(struct sock *sk, 79 void (*ccid_hc_rx_get_info)(struct sock *sk,
76 struct tcp_info *info); 80 struct tcp_info *info);
77 void (*ccid_hc_tx_get_info)(struct sock *sk, 81 void (*ccid_hc_tx_get_info)(struct sock *sk,
@@ -99,78 +103,31 @@ static inline void *ccid_priv(const struct ccid *ccid)
99 return (void *)ccid->ccid_priv; 103 return (void *)ccid->ccid_priv;
100} 104}
101 105
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);
108extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, 106extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx,
109 gfp_t gfp); 107 gfp_t gfp);
110 108
111static inline int ccid_get_current_rx_ccid(struct dccp_sock *dp) 109extern struct ccid *ccid_hc_rx_new(unsigned char id, struct sock *sk,
112{ 110 gfp_t gfp);
113 struct ccid *ccid = dp->dccps_hc_rx_ccid; 111extern struct ccid *ccid_hc_tx_new(unsigned char id, struct sock *sk,
114 112 gfp_t gfp);
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}
128 113
129extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk); 114extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
130extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk); 115extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
131 116
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
161static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk, 117static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
162 struct sk_buff *skb) 118 struct sk_buff *skb)
163{ 119{
120 int rc = 0;
164 if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL) 121 if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL)
165 return ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb); 122 rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb);
166 return CCID_PACKET_SEND_AT_ONCE; 123 return rc;
167} 124}
168 125
169static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk, 126static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
170 unsigned int len) 127 int more, unsigned int len)
171{ 128{
172 if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL) 129 if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
173 ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, len); 130 ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len);
174} 131}
175 132
176static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk, 133static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
@@ -187,31 +144,27 @@ static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
187 ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb); 144 ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb);
188} 145}
189 146
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 */
197static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk, 147static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
198 u8 pkt, u8 opt, u8 *val, u8 len) 148 unsigned char option,
149 unsigned char len, u16 idx,
150 unsigned char* value)
199{ 151{
200 if (ccid->ccid_ops->ccid_hc_tx_parse_options == NULL) 152 int rc = 0;
201 return 0; 153 if (ccid->ccid_ops->ccid_hc_tx_parse_options != NULL)
202 return ccid->ccid_ops->ccid_hc_tx_parse_options(sk, pkt, opt, val, len); 154 rc = ccid->ccid_ops->ccid_hc_tx_parse_options(sk, option, len, idx,
155 value);
156 return rc;
203} 157}
204 158
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 */
209static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk, 159static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
210 u8 pkt, u8 opt, u8 *val, u8 len) 160 unsigned char option,
161 unsigned char len, u16 idx,
162 unsigned char* value)
211{ 163{
212 if (ccid->ccid_ops->ccid_hc_rx_parse_options == NULL) 164 int rc = 0;
213 return 0; 165 if (ccid->ccid_ops->ccid_hc_rx_parse_options != NULL)
214 return ccid->ccid_ops->ccid_hc_rx_parse_options(sk, pkt, opt, val, len); 166 rc = ccid->ccid_ops->ccid_hc_rx_parse_options(sk, option, len, idx, value);
167 return rc;
215} 168}
216 169
217static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk, 170static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,