isdn_v110.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /* $Id: isdn_v110.c,v 1.1.2.2 2004/01/12 22:37:19 keil Exp $
  2. *
  3. * Linux ISDN subsystem, V.110 related functions (linklevel).
  4. *
  5. * Copyright by Thomas Pfeiffer (pfeiffer@pds.de)
  6. *
  7. * This software may be used and distributed according to the terms
  8. * of the GNU General Public License, incorporated herein by reference.
  9. *
  10. */
  11. #include <linux/string.h>
  12. #include <linux/kernel.h>
  13. #include <linux/slab.h>
  14. #include <linux/mm.h>
  15. #include <linux/delay.h>
  16. #include <linux/isdn.h>
  17. #include "isdn_v110.h"
  18. #undef ISDN_V110_DEBUG
  19. char *isdn_v110_revision = "$Revision: 1.1.2.2 $";
  20. #define V110_38400 255
  21. #define V110_19200 15
  22. #define V110_9600 3
  23. /*
  24. * The following data are precoded matrices, online and offline matrix
  25. * for 9600, 19200 und 38400, respectively
  26. */
  27. static unsigned char V110_OnMatrix_9600[] =
  28. {0xfc, 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff,
  29. 0xff, 0xfd, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xfd,
  30. 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff,
  31. 0xff, 0xfd, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xfd};
  32. static unsigned char V110_OffMatrix_9600[] =
  33. {0xfc, 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  34. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  35. 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  36. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  37. static unsigned char V110_OnMatrix_19200[] =
  38. {0xf0, 0xf0, 0xff, 0xf7, 0xff, 0xf7, 0xff, 0xf7, 0xff, 0xf7,
  39. 0xfd, 0xff, 0xff, 0xf7, 0xff, 0xf7, 0xff, 0xf7, 0xff, 0xf7};
  40. static unsigned char V110_OffMatrix_19200[] =
  41. {0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  42. 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  43. static unsigned char V110_OnMatrix_38400[] =
  44. {0x00, 0x7f, 0x7f, 0x7f, 0x7f, 0xfd, 0x7f, 0x7f, 0x7f, 0x7f};
  45. static unsigned char V110_OffMatrix_38400[] =
  46. {0x00, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff};
  47. /*
  48. * FlipBits reorders sequences of keylen bits in one byte.
  49. * E.g. source order 7654321 will be converted to 45670123 when keylen = 4,
  50. * and to 67452301 when keylen = 2. This is necessary because ordering on
  51. * the isdn line is the other way.
  52. */
  53. static inline unsigned char
  54. FlipBits(unsigned char c, int keylen)
  55. {
  56. unsigned char b = c;
  57. unsigned char bit = 128;
  58. int i;
  59. int j;
  60. int hunks = (8 / keylen);
  61. c = 0;
  62. for (i = 0; i < hunks; i++) {
  63. for (j = 0; j < keylen; j++) {
  64. if (b & (bit >> j))
  65. c |= bit >> (keylen - j - 1);
  66. }
  67. bit >>= keylen;
  68. }
  69. return c;
  70. }
  71. /* isdn_v110_open allocates and initializes private V.110 data
  72. * structures and returns a pointer to these.
  73. */
  74. static isdn_v110_stream *
  75. isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
  76. {
  77. int i;
  78. isdn_v110_stream *v;
  79. if ((v = kzalloc(sizeof(isdn_v110_stream), GFP_ATOMIC)) == NULL)
  80. return NULL;
  81. v->key = key;
  82. v->nbits = 0;
  83. for (i = 0; key & (1 << i); i++)
  84. v->nbits++;
  85. v->nbytes = 8 / v->nbits;
  86. v->decodelen = 0;
  87. switch (key) {
  88. case V110_38400:
  89. v->OnlineFrame = V110_OnMatrix_38400;
  90. v->OfflineFrame = V110_OffMatrix_38400;
  91. break;
  92. case V110_19200:
  93. v->OnlineFrame = V110_OnMatrix_19200;
  94. v->OfflineFrame = V110_OffMatrix_19200;
  95. break;
  96. default:
  97. v->OnlineFrame = V110_OnMatrix_9600;
  98. v->OfflineFrame = V110_OffMatrix_9600;
  99. break;
  100. }
  101. v->framelen = v->nbytes * 10;
  102. v->SyncInit = 5;
  103. v->introducer = 0;
  104. v->dbit = 1;
  105. v->b = 0;
  106. v->skbres = hdrlen;
  107. v->maxsize = maxsize - hdrlen;
  108. if ((v->encodebuf = kmalloc(maxsize, GFP_ATOMIC)) == NULL) {
  109. kfree(v);
  110. return NULL;
  111. }
  112. return v;
  113. }
  114. /* isdn_v110_close frees private V.110 data structures */
  115. void
  116. isdn_v110_close(isdn_v110_stream *v)
  117. {
  118. if (v == NULL)
  119. return;
  120. #ifdef ISDN_V110_DEBUG
  121. printk(KERN_DEBUG "v110 close\n");
  122. #endif
  123. kfree(v->encodebuf);
  124. kfree(v);
  125. }
  126. /*
  127. * ValidHeaderBytes return the number of valid bytes in v->decodebuf
  128. */
  129. static int
  130. ValidHeaderBytes(isdn_v110_stream *v)
  131. {
  132. int i;
  133. for (i = 0; (i < v->decodelen) && (i < v->nbytes); i++)
  134. if ((v->decodebuf[i] & v->key) != 0)
  135. break;
  136. return i;
  137. }
  138. /*
  139. * SyncHeader moves the decodebuf ptr to the next valid header
  140. */
  141. static void
  142. SyncHeader(isdn_v110_stream *v)
  143. {
  144. unsigned char *rbuf = v->decodebuf;
  145. int len = v->decodelen;
  146. if (len == 0)
  147. return;
  148. for (rbuf++, len--; len > 0; len--, rbuf++) /* such den SyncHeader in buf ! */
  149. if ((*rbuf & v->key) == 0) /* erstes byte gefunden ? */
  150. break; /* jupp! */
  151. if (len)
  152. memcpy(v->decodebuf, rbuf, len);
  153. v->decodelen = len;
  154. #ifdef ISDN_V110_DEBUG
  155. printk(KERN_DEBUG "isdn_v110: Header resync\n");
  156. #endif
  157. }
  158. /* DecodeMatrix takes n (n>=1) matrices (v110 frames, 10 bytes) where
  159. len is the number of matrix-lines. len must be a multiple of 10, i.e.
  160. only complete matices must be given.
  161. From these, netto data is extracted and returned in buf. The return-value
  162. is the bytecount of the decoded data.
  163. */
  164. static int
  165. DecodeMatrix(isdn_v110_stream *v, unsigned char *m, int len, unsigned char *buf)
  166. {
  167. int line = 0;
  168. int buflen = 0;
  169. int mbit = 64;
  170. int introducer = v->introducer;
  171. int dbit = v->dbit;
  172. unsigned char b = v->b;
  173. while (line < len) { /* Are we done with all lines of the matrix? */
  174. if ((line % 10) == 0) { /* the 0. line of the matrix is always 0 ! */
  175. if (m[line] != 0x00) { /* not 0 ? -> error! */
  176. #ifdef ISDN_V110_DEBUG
  177. printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad Header\n");
  178. /* returning now is not the right thing, though :-( */
  179. #endif
  180. }
  181. line++; /* next line of matrix */
  182. continue;
  183. } else if ((line % 10) == 5) { /* in line 5 there's only e-bits ! */
  184. if ((m[line] & 0x70) != 0x30) { /* 011 has to be at the beginning! */
  185. #ifdef ISDN_V110_DEBUG
  186. printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad 5th line\n");
  187. /* returning now is not the right thing, though :-( */
  188. #endif
  189. }
  190. line++; /* next line */
  191. continue;
  192. } else if (!introducer) { /* every byte starts with 10 (stopbit, startbit) */
  193. introducer = (m[line] & mbit) ? 0 : 1; /* current bit of the matrix */
  194. next_byte:
  195. if (mbit > 2) { /* was it the last bit in this line ? */
  196. mbit >>= 1; /* no -> take next */
  197. continue;
  198. } /* otherwise start with leftmost bit in the next line */
  199. mbit = 64;
  200. line++;
  201. continue;
  202. } else { /* otherwise we need to set a data bit */
  203. if (m[line] & mbit) /* was that bit set in the matrix ? */
  204. b |= dbit; /* yes -> set it in the data byte */
  205. else
  206. b &= dbit - 1; /* no -> clear it in the data byte */
  207. if (dbit < 128) /* is that data byte done ? */
  208. dbit <<= 1; /* no, got the next bit */
  209. else { /* data byte is done */
  210. buf[buflen++] = b; /* copy byte into the output buffer */
  211. introducer = b = 0; /* init of the intro sequence and of the data byte */
  212. dbit = 1; /* next we look for the 0th bit */
  213. }
  214. goto next_byte; /* look for next bit in the matrix */
  215. }
  216. }
  217. v->introducer = introducer;
  218. v->dbit = dbit;
  219. v->b = b;
  220. return buflen; /* return number of bytes in the output buffer */
  221. }
  222. /*
  223. * DecodeStream receives V.110 coded data from the input stream. It recovers the
  224. * original frames.
  225. * The input stream doesn't need to be framed
  226. */
  227. struct sk_buff *
  228. isdn_v110_decode(isdn_v110_stream *v, struct sk_buff *skb)
  229. {
  230. int i;
  231. int j;
  232. int len;
  233. unsigned char *v110_buf;
  234. unsigned char *rbuf;
  235. if (!skb) {
  236. printk(KERN_WARNING "isdn_v110_decode called with NULL skb!\n");
  237. return NULL;
  238. }
  239. rbuf = skb->data;
  240. len = skb->len;
  241. if (v == NULL) {
  242. /* invalid handle, no chance to proceed */
  243. printk(KERN_WARNING "isdn_v110_decode called with NULL stream!\n");
  244. dev_kfree_skb(skb);
  245. return NULL;
  246. }
  247. if (v->decodelen == 0) /* cache empty? */
  248. for (; len > 0; len--, rbuf++) /* scan for SyncHeader in buf */
  249. if ((*rbuf & v->key) == 0)
  250. break; /* found first byte */
  251. if (len == 0) {
  252. dev_kfree_skb(skb);
  253. return NULL;
  254. }
  255. /* copy new data to decode-buffer */
  256. memcpy(&(v->decodebuf[v->decodelen]), rbuf, len);
  257. v->decodelen += len;
  258. ReSync:
  259. if (v->decodelen < v->nbytes) { /* got a new header ? */
  260. dev_kfree_skb(skb);
  261. return NULL; /* no, try later */
  262. }
  263. if (ValidHeaderBytes(v) != v->nbytes) { /* is that a valid header? */
  264. SyncHeader(v); /* no -> look for header */
  265. goto ReSync;
  266. }
  267. len = (v->decodelen - (v->decodelen % (10 * v->nbytes))) / v->nbytes;
  268. if ((v110_buf = kmalloc(len, GFP_ATOMIC)) == NULL) {
  269. printk(KERN_WARNING "isdn_v110_decode: Couldn't allocate v110_buf\n");
  270. dev_kfree_skb(skb);
  271. return NULL;
  272. }
  273. for (i = 0; i < len; i++) {
  274. v110_buf[i] = 0;
  275. for (j = 0; j < v->nbytes; j++)
  276. v110_buf[i] |= (v->decodebuf[(i * v->nbytes) + j] & v->key) << (8 - ((j + 1) * v->nbits));
  277. v110_buf[i] = FlipBits(v110_buf[i], v->nbits);
  278. }
  279. v->decodelen = (v->decodelen % (10 * v->nbytes));
  280. memcpy(v->decodebuf, &(v->decodebuf[len * v->nbytes]), v->decodelen);
  281. skb_trim(skb, DecodeMatrix(v, v110_buf, len, skb->data));
  282. kfree(v110_buf);
  283. if (skb->len)
  284. return skb;
  285. else {
  286. kfree_skb(skb);
  287. return NULL;
  288. }
  289. }
  290. /* EncodeMatrix takes input data in buf, len is the bytecount.
  291. Data is encoded into v110 frames in m. Return value is the number of
  292. matrix-lines generated.
  293. */
  294. static int
  295. EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
  296. {
  297. int line = 0;
  298. int i = 0;
  299. int mbit = 128;
  300. int dbit = 1;
  301. int introducer = 3;
  302. int ibit[] = {0, 1, 1};
  303. while ((i < len) && (line < mlen)) { /* while we still have input data */
  304. switch (line % 10) { /* in which line of the matrix are we? */
  305. case 0:
  306. m[line++] = 0x00; /* line 0 is always 0 */
  307. mbit = 128; /* go on with the 7th bit */
  308. break;
  309. case 5:
  310. m[line++] = 0xbf; /* line 5 is always 10111111 */
  311. mbit = 128; /* go on with the 7th bit */
  312. break;
  313. }
  314. if (line >= mlen) {
  315. printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
  316. return line;
  317. }
  318. next_bit:
  319. switch (mbit) { /* leftmost or rightmost bit ? */
  320. case 1:
  321. line++; /* rightmost -> go to next line */
  322. if (line >= mlen) {
  323. printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
  324. return line;
  325. }
  326. /* else: fall through */
  327. case 128:
  328. m[line] = 128; /* leftmost -> set byte to 1000000 */
  329. mbit = 64; /* current bit in the matrix line */
  330. continue;
  331. }
  332. if (introducer) { /* set 110 sequence ? */
  333. introducer--; /* set on digit less */
  334. m[line] |= ibit[introducer] ? mbit : 0; /* set corresponding bit */
  335. mbit >>= 1; /* bit of matrix line >> 1 */
  336. goto next_bit; /* and go on there */
  337. } /* else push data bits into the matrix! */
  338. m[line] |= (buf[i] & dbit) ? mbit : 0; /* set data bit in matrix */
  339. if (dbit == 128) { /* was it the last one? */
  340. dbit = 1; /* then go on with first bit of */
  341. i++; /* next byte in input buffer */
  342. if (i < len) /* input buffer done ? */
  343. introducer = 3; /* no, write introducer 110 */
  344. else { /* input buffer done ! */
  345. m[line] |= (mbit - 1) & 0xfe; /* set remaining bits in line to 1 */
  346. break;
  347. }
  348. } else /* not the last data bit */
  349. dbit <<= 1; /* then go to next data bit */
  350. mbit >>= 1; /* go to next bit of matrix */
  351. goto next_bit;
  352. }
  353. /* if necessary, generate remaining lines of the matrix... */
  354. if ((line) && ((line + 10) < mlen))
  355. switch (++line % 10) {
  356. case 1:
  357. m[line++] = 0xfe;
  358. /* fall through */
  359. case 2:
  360. m[line++] = 0xfe;
  361. /* fall through */
  362. case 3:
  363. m[line++] = 0xfe;
  364. /* fall through */
  365. case 4:
  366. m[line++] = 0xfe;
  367. /* fall through */
  368. case 5:
  369. m[line++] = 0xbf;
  370. /* fall through */
  371. case 6:
  372. m[line++] = 0xfe;
  373. /* fall through */
  374. case 7:
  375. m[line++] = 0xfe;
  376. /* fall through */
  377. case 8:
  378. m[line++] = 0xfe;
  379. /* fall through */
  380. case 9:
  381. m[line++] = 0xfe;
  382. }
  383. return line; /* that's how many lines we have */
  384. }
  385. /*
  386. * Build a sync frame.
  387. */
  388. static struct sk_buff *
  389. isdn_v110_sync(isdn_v110_stream *v)
  390. {
  391. struct sk_buff *skb;
  392. if (v == NULL) {
  393. /* invalid handle, no chance to proceed */
  394. printk(KERN_WARNING "isdn_v110_sync called with NULL stream!\n");
  395. return NULL;
  396. }
  397. if ((skb = dev_alloc_skb(v->framelen + v->skbres))) {
  398. skb_reserve(skb, v->skbres);
  399. skb_put_data(skb, v->OfflineFrame, v->framelen);
  400. }
  401. return skb;
  402. }
  403. /*
  404. * Build an idle frame.
  405. */
  406. static struct sk_buff *
  407. isdn_v110_idle(isdn_v110_stream *v)
  408. {
  409. struct sk_buff *skb;
  410. if (v == NULL) {
  411. /* invalid handle, no chance to proceed */
  412. printk(KERN_WARNING "isdn_v110_sync called with NULL stream!\n");
  413. return NULL;
  414. }
  415. if ((skb = dev_alloc_skb(v->framelen + v->skbres))) {
  416. skb_reserve(skb, v->skbres);
  417. skb_put_data(skb, v->OnlineFrame, v->framelen);
  418. }
  419. return skb;
  420. }
  421. struct sk_buff *
  422. isdn_v110_encode(isdn_v110_stream *v, struct sk_buff *skb)
  423. {
  424. int i;
  425. int j;
  426. int rlen;
  427. int mlen;
  428. int olen;
  429. int size;
  430. int sval1;
  431. int sval2;
  432. int nframes;
  433. unsigned char *v110buf;
  434. unsigned char *rbuf;
  435. struct sk_buff *nskb;
  436. if (v == NULL) {
  437. /* invalid handle, no chance to proceed */
  438. printk(KERN_WARNING "isdn_v110_encode called with NULL stream!\n");
  439. return NULL;
  440. }
  441. if (!skb) {
  442. /* invalid skb, no chance to proceed */
  443. printk(KERN_WARNING "isdn_v110_encode called with NULL skb!\n");
  444. return NULL;
  445. }
  446. rlen = skb->len;
  447. nframes = (rlen + 3) / 4;
  448. v110buf = v->encodebuf;
  449. if ((nframes * 40) > v->maxsize) {
  450. size = v->maxsize;
  451. rlen = v->maxsize / 40;
  452. } else
  453. size = nframes * 40;
  454. if (!(nskb = dev_alloc_skb(size + v->skbres + sizeof(int)))) {
  455. printk(KERN_WARNING "isdn_v110_encode: Couldn't alloc skb\n");
  456. return NULL;
  457. }
  458. skb_reserve(nskb, v->skbres + sizeof(int));
  459. if (skb->len == 0) {
  460. skb_put_data(nskb, v->OnlineFrame, v->framelen);
  461. *((int *)skb_push(nskb, sizeof(int))) = 0;
  462. return nskb;
  463. }
  464. mlen = EncodeMatrix(skb->data, rlen, v110buf, size);
  465. /* now distribute 2 or 4 bits each to the output stream! */
  466. rbuf = skb_put(nskb, size);
  467. olen = 0;
  468. sval1 = 8 - v->nbits;
  469. sval2 = v->key << sval1;
  470. for (i = 0; i < mlen; i++) {
  471. v110buf[i] = FlipBits(v110buf[i], v->nbits);
  472. for (j = 0; j < v->nbytes; j++) {
  473. if (size--)
  474. *rbuf++ = ~v->key | (((v110buf[i] << (j * v->nbits)) & sval2) >> sval1);
  475. else {
  476. printk(KERN_WARNING "isdn_v110_encode: buffers full!\n");
  477. goto buffer_full;
  478. }
  479. olen++;
  480. }
  481. }
  482. buffer_full:
  483. skb_trim(nskb, olen);
  484. *((int *)skb_push(nskb, sizeof(int))) = rlen;
  485. return nskb;
  486. }
  487. int
  488. isdn_v110_stat_callback(int idx, isdn_ctrl *c)
  489. {
  490. isdn_v110_stream *v = NULL;
  491. int i;
  492. int ret = 0;
  493. if (idx < 0)
  494. return 0;
  495. switch (c->command) {
  496. case ISDN_STAT_BSENT:
  497. /* Keep the send-queue of the driver filled
  498. * with frames:
  499. * If number of outstanding frames < 3,
  500. * send down an Idle-Frame (or an Sync-Frame, if
  501. * v->SyncInit != 0).
  502. */
  503. if (!(v = dev->v110[idx]))
  504. return 0;
  505. atomic_inc(&dev->v110use[idx]);
  506. for (i = 0; i * v->framelen < c->parm.length; i++) {
  507. if (v->skbidle > 0) {
  508. v->skbidle--;
  509. ret = 1;
  510. } else {
  511. if (v->skbuser > 0)
  512. v->skbuser--;
  513. ret = 0;
  514. }
  515. }
  516. for (i = v->skbuser + v->skbidle; i < 2; i++) {
  517. struct sk_buff *skb;
  518. if (v->SyncInit > 0)
  519. skb = isdn_v110_sync(v);
  520. else
  521. skb = isdn_v110_idle(v);
  522. if (skb) {
  523. if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
  524. dev_kfree_skb(skb);
  525. break;
  526. } else {
  527. if (v->SyncInit)
  528. v->SyncInit--;
  529. v->skbidle++;
  530. }
  531. } else
  532. break;
  533. }
  534. atomic_dec(&dev->v110use[idx]);
  535. return ret;
  536. case ISDN_STAT_DHUP:
  537. case ISDN_STAT_BHUP:
  538. while (1) {
  539. atomic_inc(&dev->v110use[idx]);
  540. if (atomic_dec_and_test(&dev->v110use[idx])) {
  541. isdn_v110_close(dev->v110[idx]);
  542. dev->v110[idx] = NULL;
  543. break;
  544. }
  545. mdelay(1);
  546. }
  547. break;
  548. case ISDN_STAT_BCONN:
  549. if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) {
  550. int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
  551. int maxsize = dev->drv[c->driver]->interface->maxbufsize;
  552. atomic_inc(&dev->v110use[idx]);
  553. switch (dev->v110emu[idx]) {
  554. case ISDN_PROTO_L2_V11096:
  555. dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
  556. break;
  557. case ISDN_PROTO_L2_V11019:
  558. dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
  559. break;
  560. case ISDN_PROTO_L2_V11038:
  561. dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
  562. break;
  563. default:;
  564. }
  565. if ((v = dev->v110[idx])) {
  566. while (v->SyncInit) {
  567. struct sk_buff *skb = isdn_v110_sync(v);
  568. if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
  569. dev_kfree_skb(skb);
  570. /* Unable to send, try later */
  571. break;
  572. }
  573. v->SyncInit--;
  574. v->skbidle++;
  575. }
  576. } else
  577. printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
  578. atomic_dec(&dev->v110use[idx]);
  579. }
  580. break;
  581. default:
  582. return 0;
  583. }
  584. return 0;
  585. }