isdn_v110.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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. case 128:
  327. m[line] = 128; /* leftmost -> set byte to 1000000 */
  328. mbit = 64; /* current bit in the matrix line */
  329. continue;
  330. }
  331. if (introducer) { /* set 110 sequence ? */
  332. introducer--; /* set on digit less */
  333. m[line] |= ibit[introducer] ? mbit : 0; /* set corresponding bit */
  334. mbit >>= 1; /* bit of matrix line >> 1 */
  335. goto next_bit; /* and go on there */
  336. } /* else push data bits into the matrix! */
  337. m[line] |= (buf[i] & dbit) ? mbit : 0; /* set data bit in matrix */
  338. if (dbit == 128) { /* was it the last one? */
  339. dbit = 1; /* then go on with first bit of */
  340. i++; /* next byte in input buffer */
  341. if (i < len) /* input buffer done ? */
  342. introducer = 3; /* no, write introducer 110 */
  343. else { /* input buffer done ! */
  344. m[line] |= (mbit - 1) & 0xfe; /* set remaining bits in line to 1 */
  345. break;
  346. }
  347. } else /* not the last data bit */
  348. dbit <<= 1; /* then go to next data bit */
  349. mbit >>= 1; /* go to next bit of matrix */
  350. goto next_bit;
  351. }
  352. /* if necessary, generate remaining lines of the matrix... */
  353. if ((line) && ((line + 10) < mlen))
  354. switch (++line % 10) {
  355. case 1:
  356. m[line++] = 0xfe;
  357. case 2:
  358. m[line++] = 0xfe;
  359. case 3:
  360. m[line++] = 0xfe;
  361. case 4:
  362. m[line++] = 0xfe;
  363. case 5:
  364. m[line++] = 0xbf;
  365. case 6:
  366. m[line++] = 0xfe;
  367. case 7:
  368. m[line++] = 0xfe;
  369. case 8:
  370. m[line++] = 0xfe;
  371. case 9:
  372. m[line++] = 0xfe;
  373. }
  374. return line; /* that's how many lines we have */
  375. }
  376. /*
  377. * Build a sync frame.
  378. */
  379. static struct sk_buff *
  380. isdn_v110_sync(isdn_v110_stream *v)
  381. {
  382. struct sk_buff *skb;
  383. if (v == NULL) {
  384. /* invalid handle, no chance to proceed */
  385. printk(KERN_WARNING "isdn_v110_sync called with NULL stream!\n");
  386. return NULL;
  387. }
  388. if ((skb = dev_alloc_skb(v->framelen + v->skbres))) {
  389. skb_reserve(skb, v->skbres);
  390. memcpy(skb_put(skb, v->framelen), v->OfflineFrame, v->framelen);
  391. }
  392. return skb;
  393. }
  394. /*
  395. * Build an idle frame.
  396. */
  397. static struct sk_buff *
  398. isdn_v110_idle(isdn_v110_stream *v)
  399. {
  400. struct sk_buff *skb;
  401. if (v == NULL) {
  402. /* invalid handle, no chance to proceed */
  403. printk(KERN_WARNING "isdn_v110_sync called with NULL stream!\n");
  404. return NULL;
  405. }
  406. if ((skb = dev_alloc_skb(v->framelen + v->skbres))) {
  407. skb_reserve(skb, v->skbres);
  408. memcpy(skb_put(skb, v->framelen), v->OnlineFrame, v->framelen);
  409. }
  410. return skb;
  411. }
  412. struct sk_buff *
  413. isdn_v110_encode(isdn_v110_stream *v, struct sk_buff *skb)
  414. {
  415. int i;
  416. int j;
  417. int rlen;
  418. int mlen;
  419. int olen;
  420. int size;
  421. int sval1;
  422. int sval2;
  423. int nframes;
  424. unsigned char *v110buf;
  425. unsigned char *rbuf;
  426. struct sk_buff *nskb;
  427. if (v == NULL) {
  428. /* invalid handle, no chance to proceed */
  429. printk(KERN_WARNING "isdn_v110_encode called with NULL stream!\n");
  430. return NULL;
  431. }
  432. if (!skb) {
  433. /* invalid skb, no chance to proceed */
  434. printk(KERN_WARNING "isdn_v110_encode called with NULL skb!\n");
  435. return NULL;
  436. }
  437. rlen = skb->len;
  438. nframes = (rlen + 3) / 4;
  439. v110buf = v->encodebuf;
  440. if ((nframes * 40) > v->maxsize) {
  441. size = v->maxsize;
  442. rlen = v->maxsize / 40;
  443. } else
  444. size = nframes * 40;
  445. if (!(nskb = dev_alloc_skb(size + v->skbres + sizeof(int)))) {
  446. printk(KERN_WARNING "isdn_v110_encode: Couldn't alloc skb\n");
  447. return NULL;
  448. }
  449. skb_reserve(nskb, v->skbres + sizeof(int));
  450. if (skb->len == 0) {
  451. memcpy(skb_put(nskb, v->framelen), v->OnlineFrame, v->framelen);
  452. *((int *)skb_push(nskb, sizeof(int))) = 0;
  453. return nskb;
  454. }
  455. mlen = EncodeMatrix(skb->data, rlen, v110buf, size);
  456. /* now distribute 2 or 4 bits each to the output stream! */
  457. rbuf = skb_put(nskb, size);
  458. olen = 0;
  459. sval1 = 8 - v->nbits;
  460. sval2 = v->key << sval1;
  461. for (i = 0; i < mlen; i++) {
  462. v110buf[i] = FlipBits(v110buf[i], v->nbits);
  463. for (j = 0; j < v->nbytes; j++) {
  464. if (size--)
  465. *rbuf++ = ~v->key | (((v110buf[i] << (j * v->nbits)) & sval2) >> sval1);
  466. else {
  467. printk(KERN_WARNING "isdn_v110_encode: buffers full!\n");
  468. goto buffer_full;
  469. }
  470. olen++;
  471. }
  472. }
  473. buffer_full:
  474. skb_trim(nskb, olen);
  475. *((int *)skb_push(nskb, sizeof(int))) = rlen;
  476. return nskb;
  477. }
  478. int
  479. isdn_v110_stat_callback(int idx, isdn_ctrl *c)
  480. {
  481. isdn_v110_stream *v = NULL;
  482. int i;
  483. int ret = 0;
  484. if (idx < 0)
  485. return 0;
  486. switch (c->command) {
  487. case ISDN_STAT_BSENT:
  488. /* Keep the send-queue of the driver filled
  489. * with frames:
  490. * If number of outstanding frames < 3,
  491. * send down an Idle-Frame (or an Sync-Frame, if
  492. * v->SyncInit != 0).
  493. */
  494. if (!(v = dev->v110[idx]))
  495. return 0;
  496. atomic_inc(&dev->v110use[idx]);
  497. for (i = 0; i * v->framelen < c->parm.length; i++) {
  498. if (v->skbidle > 0) {
  499. v->skbidle--;
  500. ret = 1;
  501. } else {
  502. if (v->skbuser > 0)
  503. v->skbuser--;
  504. ret = 0;
  505. }
  506. }
  507. for (i = v->skbuser + v->skbidle; i < 2; i++) {
  508. struct sk_buff *skb;
  509. if (v->SyncInit > 0)
  510. skb = isdn_v110_sync(v);
  511. else
  512. skb = isdn_v110_idle(v);
  513. if (skb) {
  514. if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
  515. dev_kfree_skb(skb);
  516. break;
  517. } else {
  518. if (v->SyncInit)
  519. v->SyncInit--;
  520. v->skbidle++;
  521. }
  522. } else
  523. break;
  524. }
  525. atomic_dec(&dev->v110use[idx]);
  526. return ret;
  527. case ISDN_STAT_DHUP:
  528. case ISDN_STAT_BHUP:
  529. while (1) {
  530. atomic_inc(&dev->v110use[idx]);
  531. if (atomic_dec_and_test(&dev->v110use[idx])) {
  532. isdn_v110_close(dev->v110[idx]);
  533. dev->v110[idx] = NULL;
  534. break;
  535. }
  536. mdelay(1);
  537. }
  538. break;
  539. case ISDN_STAT_BCONN:
  540. if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) {
  541. int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
  542. int maxsize = dev->drv[c->driver]->interface->maxbufsize;
  543. atomic_inc(&dev->v110use[idx]);
  544. switch (dev->v110emu[idx]) {
  545. case ISDN_PROTO_L2_V11096:
  546. dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
  547. break;
  548. case ISDN_PROTO_L2_V11019:
  549. dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
  550. break;
  551. case ISDN_PROTO_L2_V11038:
  552. dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
  553. break;
  554. default:;
  555. }
  556. if ((v = dev->v110[idx])) {
  557. while (v->SyncInit) {
  558. struct sk_buff *skb = isdn_v110_sync(v);
  559. if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
  560. dev_kfree_skb(skb);
  561. /* Unable to send, try later */
  562. break;
  563. }
  564. v->SyncInit--;
  565. v->skbidle++;
  566. }
  567. } else
  568. printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
  569. atomic_dec(&dev->v110use[idx]);
  570. }
  571. break;
  572. default:
  573. return 0;
  574. }
  575. return 0;
  576. }