diff options
author | Tilman Schmidt <tilman@imap.cc> | 2010-06-21 09:54:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-26 00:16:59 -0400 |
commit | e7752ee280608a24e27f163641121bdc2c68d6af (patch) | |
tree | a731b1d9b2c95732d2882a52bb20e4af7546de59 /drivers/isdn/gigaset/asyncdata.c | |
parent | ed770f01360b392564650bf1553ce723fa46afec (diff) |
isdn/gigaset: honor CAPI application's buffer size request
Fix the Gigaset CAPI driver to limit the length of a connection's
payload data receive buffers to the corresponding CAPI application's
data buffer size, as some real-life CAPI applications tend to be
rather unhappy if they receive bigger data blocks than requested.
Impact: bugfix
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/gigaset/asyncdata.c')
-rw-r--r-- | drivers/isdn/gigaset/asyncdata.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c index c5016bd2d94f..c3b1dc3a13a0 100644 --- a/drivers/isdn/gigaset/asyncdata.c +++ b/drivers/isdn/gigaset/asyncdata.c | |||
@@ -126,26 +126,6 @@ static unsigned lock_loop(unsigned numbytes, struct inbuf_t *inbuf) | |||
126 | return numbytes; | 126 | return numbytes; |
127 | } | 127 | } |
128 | 128 | ||
129 | /* set up next receive skb for data mode | ||
130 | */ | ||
131 | static void new_rcv_skb(struct bc_state *bcs) | ||
132 | { | ||
133 | struct cardstate *cs = bcs->cs; | ||
134 | unsigned short hw_hdr_len = cs->hw_hdr_len; | ||
135 | |||
136 | if (bcs->ignore) { | ||
137 | bcs->skb = NULL; | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | bcs->skb = dev_alloc_skb(SBUFSIZE + hw_hdr_len); | ||
142 | if (bcs->skb == NULL) { | ||
143 | dev_warn(cs->dev, "could not allocate new skb\n"); | ||
144 | return; | ||
145 | } | ||
146 | skb_reserve(bcs->skb, hw_hdr_len); | ||
147 | } | ||
148 | |||
149 | /* process a block of received bytes in HDLC data mode | 129 | /* process a block of received bytes in HDLC data mode |
150 | * (mstate != MS_LOCKED && !(inputstate & INS_command) && proto2 == L2_HDLC) | 130 | * (mstate != MS_LOCKED && !(inputstate & INS_command) && proto2 == L2_HDLC) |
151 | * Collect HDLC frames, undoing byte stuffing and watching for DLE escapes. | 131 | * Collect HDLC frames, undoing byte stuffing and watching for DLE escapes. |
@@ -159,8 +139,8 @@ static unsigned hdlc_loop(unsigned numbytes, struct inbuf_t *inbuf) | |||
159 | struct cardstate *cs = inbuf->cs; | 139 | struct cardstate *cs = inbuf->cs; |
160 | struct bc_state *bcs = cs->bcs; | 140 | struct bc_state *bcs = cs->bcs; |
161 | int inputstate = bcs->inputstate; | 141 | int inputstate = bcs->inputstate; |
162 | __u16 fcs = bcs->fcs; | 142 | __u16 fcs = bcs->rx_fcs; |
163 | struct sk_buff *skb = bcs->skb; | 143 | struct sk_buff *skb = bcs->rx_skb; |
164 | unsigned char *src = inbuf->data + inbuf->head; | 144 | unsigned char *src = inbuf->data + inbuf->head; |
165 | unsigned procbytes = 0; | 145 | unsigned procbytes = 0; |
166 | unsigned char c; | 146 | unsigned char c; |
@@ -245,8 +225,7 @@ byte_stuff: | |||
245 | 225 | ||
246 | /* prepare reception of next frame */ | 226 | /* prepare reception of next frame */ |
247 | inputstate &= ~INS_have_data; | 227 | inputstate &= ~INS_have_data; |
248 | new_rcv_skb(bcs); | 228 | skb = gigaset_new_rx_skb(bcs); |
249 | skb = bcs->skb; | ||
250 | } else { | 229 | } else { |
251 | /* empty frame (7E 7E) */ | 230 | /* empty frame (7E 7E) */ |
252 | #ifdef CONFIG_GIGASET_DEBUG | 231 | #ifdef CONFIG_GIGASET_DEBUG |
@@ -255,8 +234,7 @@ byte_stuff: | |||
255 | if (!skb) { | 234 | if (!skb) { |
256 | /* skipped (?) */ | 235 | /* skipped (?) */ |
257 | gigaset_isdn_rcv_err(bcs); | 236 | gigaset_isdn_rcv_err(bcs); |
258 | new_rcv_skb(bcs); | 237 | skb = gigaset_new_rx_skb(bcs); |
259 | skb = bcs->skb; | ||
260 | } | 238 | } |
261 | } | 239 | } |
262 | 240 | ||
@@ -279,11 +257,11 @@ byte_stuff: | |||
279 | #endif | 257 | #endif |
280 | inputstate |= INS_have_data; | 258 | inputstate |= INS_have_data; |
281 | if (skb) { | 259 | if (skb) { |
282 | if (skb->len == SBUFSIZE) { | 260 | if (skb->len >= bcs->rx_bufsize) { |
283 | dev_warn(cs->dev, "received packet too long\n"); | 261 | dev_warn(cs->dev, "received packet too long\n"); |
284 | dev_kfree_skb_any(skb); | 262 | dev_kfree_skb_any(skb); |
285 | /* skip remainder of packet */ | 263 | /* skip remainder of packet */ |
286 | bcs->skb = skb = NULL; | 264 | bcs->rx_skb = skb = NULL; |
287 | } else { | 265 | } else { |
288 | *__skb_put(skb, 1) = c; | 266 | *__skb_put(skb, 1) = c; |
289 | fcs = crc_ccitt_byte(fcs, c); | 267 | fcs = crc_ccitt_byte(fcs, c); |
@@ -292,7 +270,7 @@ byte_stuff: | |||
292 | } | 270 | } |
293 | 271 | ||
294 | bcs->inputstate = inputstate; | 272 | bcs->inputstate = inputstate; |
295 | bcs->fcs = fcs; | 273 | bcs->rx_fcs = fcs; |
296 | return procbytes; | 274 | return procbytes; |
297 | } | 275 | } |
298 | 276 | ||
@@ -308,18 +286,18 @@ static unsigned iraw_loop(unsigned numbytes, struct inbuf_t *inbuf) | |||
308 | struct cardstate *cs = inbuf->cs; | 286 | struct cardstate *cs = inbuf->cs; |
309 | struct bc_state *bcs = cs->bcs; | 287 | struct bc_state *bcs = cs->bcs; |
310 | int inputstate = bcs->inputstate; | 288 | int inputstate = bcs->inputstate; |
311 | struct sk_buff *skb = bcs->skb; | 289 | struct sk_buff *skb = bcs->rx_skb; |
312 | unsigned char *src = inbuf->data + inbuf->head; | 290 | unsigned char *src = inbuf->data + inbuf->head; |
313 | unsigned procbytes = 0; | 291 | unsigned procbytes = 0; |
314 | unsigned char c; | 292 | unsigned char c; |
315 | 293 | ||
316 | if (!skb) { | 294 | if (!skb) { |
317 | /* skip this block */ | 295 | /* skip this block */ |
318 | new_rcv_skb(bcs); | 296 | gigaset_new_rx_skb(bcs); |
319 | return numbytes; | 297 | return numbytes; |
320 | } | 298 | } |
321 | 299 | ||
322 | while (procbytes < numbytes && skb->len < SBUFSIZE) { | 300 | while (procbytes < numbytes && skb->len < bcs->rx_bufsize) { |
323 | c = *src++; | 301 | c = *src++; |
324 | procbytes++; | 302 | procbytes++; |
325 | 303 | ||
@@ -343,7 +321,7 @@ static unsigned iraw_loop(unsigned numbytes, struct inbuf_t *inbuf) | |||
343 | if (inputstate & INS_have_data) { | 321 | if (inputstate & INS_have_data) { |
344 | gigaset_skb_rcvd(bcs, skb); | 322 | gigaset_skb_rcvd(bcs, skb); |
345 | inputstate &= ~INS_have_data; | 323 | inputstate &= ~INS_have_data; |
346 | new_rcv_skb(bcs); | 324 | gigaset_new_rx_skb(bcs); |
347 | } | 325 | } |
348 | 326 | ||
349 | bcs->inputstate = inputstate; | 327 | bcs->inputstate = inputstate; |