isdn_v110.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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 = kmalloc(sizeof(isdn_v110_stream), GFP_ATOMIC)) == NULL)
  80. return NULL;
  81. memset(v, 0, sizeof(isdn_v110_stream));
  82. v->key = key;
  83. v->nbits = 0;
  84. for (i = 0; key & (1 << i); i++)
  85. v->nbits++;
  86. v->nbytes = 8 / v->nbits;
  87. v->decodelen = 0;
  88. switch (key) {
  89. case V110_38400:
  90. v->OnlineFrame = V110_OnMatrix_38400;
  91. v->OfflineFrame = V110_OffMatrix_38400;
  92. break;
  93. case V110_19200:
  94. v->OnlineFrame = V110_OnMatrix_19200;
  95. v->OfflineFrame = V110_OffMatrix_19200;
  96. break;
  97. default:
  98. v->OnlineFrame = V110_OnMatrix_9600;
  99. v->OfflineFrame = V110_OffMatrix_9600;
  100. break;
  101. }
  102. v->framelen = v->nbytes * 10;
  103. v->SyncInit = 5;
  104. v->introducer = 0;
  105. v->dbit = 1;
  106. v->b = 0;
  107. v->skbres = hdrlen;
  108. v->maxsize = maxsize - hdrlen;
  109. if ((v->encodebuf = kmalloc(maxsize, GFP_ATOMIC)) == NULL) {
  110. kfree(v);
  111. return NULL;
  112. }
  113. return v;
  114. }
  115. /* isdn_v110_close frees private V.110 data structures */
  116. void
  117. isdn_v110_close(isdn_v110_stream * v)
  118. {
  119. if (v == NULL)
  120. return;
  121. #ifdef ISDN_V110_DEBUG
  122. printk(KERN_DEBUG "v110 close\n");
  123. #endif
  124. kfree(v->encodebuf);
  125. kfree(v);
  126. }
  127. /*
  128. * ValidHeaderBytes return the number of valid bytes in v->decodebuf
  129. */
  130. static int
  131. ValidHeaderBytes(isdn_v110_stream * v)
  132. {
  133. int i;
  134. for (i = 0; (i < v->decodelen) && (i < v->nbytes); i++)
  135. if ((v->decodebuf[i] & v->key) != 0)
  136. break;
  137. return i;
  138. }
  139. /*
  140. * SyncHeader moves the decodebuf ptr to the next valid header
  141. */
  142. static void
  143. SyncHeader(isdn_v110_stream * v)
  144. {
  145. unsigned char *rbuf = v->decodebuf;
  146. int len = v->decodelen;
  147. if (len == 0)
  148. return;
  149. for (rbuf++, len--; len > 0; len--, rbuf++) /* such den SyncHeader in buf ! */
  150. if ((*rbuf & v->key) == 0) /* erstes byte gefunden ? */
  151. break; /* jupp! */
  152. if (len)
  153. memcpy(v->decodebuf, rbuf, len);
  154. v->decodelen = len;
  155. #ifdef ISDN_V110_DEBUG
  156. printk(KERN_DEBUG "isdn_v110: Header resync\n");
  157. #endif
  158. }
  159. /* DecodeMatrix takes n (n>=1) matrices (v110 frames, 10 bytes) where
  160. len is the number of matrix-lines. len must be a multiple of 10, i.e.
  161. only complete matices must be given.
  162. From these, netto data is extracted and returned in buf. The return-value
  163. is the bytecount of the decoded data.
  164. */
  165. static int
  166. DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf)
  167. {
  168. int line = 0;
  169. int buflen = 0;
  170. int mbit = 64;
  171. int introducer = v->introducer;
  172. int dbit = v->dbit;
  173. unsigned char b = v->b;
  174. while (line < len) { /* Are we done with all lines of the matrix? */
  175. if ((line % 10) == 0) { /* the 0. line of the matrix is always 0 ! */
  176. if (m[line] != 0x00) { /* not 0 ? -> error! */
  177. #ifdef ISDN_V110_DEBUG
  178. printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad Header\n");
  179. /* returning now is not the right thing, though :-( */
  180. #endif
  181. }
  182. line++; /* next line of matrix */
  183. continue;
  184. } else if ((line % 10) == 5) { /* in line 5 there's only e-bits ! */
  185. if ((m[line] & 0x70) != 0x30) { /* 011 has to be at the beginning! */
  186. #ifdef ISDN_V110_DEBUG
  187. printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad 5th line\n");
  188. /* returning now is not the right thing, though :-( */
  189. #endif
  190. }
  191. line++; /* next line */
  192. continue;
  193. } else if (!introducer) { /* every byte starts with 10 (stopbit, startbit) */
  194. introducer = (m[line] & mbit) ? 0 : 1; /* current bit of the matrix */
  195. next_byte:
  196. if (mbit > 2) { /* was it the last bit in this line ? */
  197. mbit >>= 1; /* no -> take next */
  198. continue;
  199. } /* otherwise start with leftmost bit in the next line */
  200. mbit = 64;
  201. line++;
  202. continue;
  203. } else { /* otherwise we need to set a data bit */
  204. if (m[line] & mbit) /* was that bit set in the matrix ? */
  205. b |= dbit; /* yes -> set it in the data byte */
  206. else
  207. b &= dbit - 1; /* no -> clear it in the data byte */
  208. if (dbit < 128) /* is that data byte done ? */
  209. dbit <<= 1; /* no, got the next bit */
  210. else { /* data byte is done */
  211. buf[buflen++] = b; /* copy byte into the output buffer */
  212. introducer = b = 0; /* init of the intro sequence and of the data byte */
  213. dbit = 1; /* next we look for the 0th bit */
  214. }
  215. goto next_byte; /* look for next bit in the matrix */
  216. }
  217. }
  218. v->introducer = introducer;
  219. v->dbit = dbit;
  220. v->b = b;
  221. return buflen; /* return number of bytes in the output buffer */
  222. }
  223. /*
  224. * DecodeStream receives V.110 coded data from the input stream. It recovers the
  225. * original frames.
  226. * The input stream doesn't need to be framed
  227. */
  228. struct sk_buff *
  229. isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb)
  230. {
  231. int i;
  232. int j;
  233. int len;
  234. unsigned char *v110_buf;
  235. unsigned char *rbuf;
  236. if (!skb) {
  237. printk(KERN_WARNING "isdn_v110_decode called with NULL skb!\n");
  238. return NULL;
  239. }
  240. rbuf = skb->data;
  241. len = skb->len;
  242. if (v == NULL) {
  243. /* invalid handle, no chance to proceed */
  244. printk(KERN_WARNING "isdn_v110_decode called with NULL stream!\n");
  245. dev_kfree_skb(skb);
  246. return NULL;
  247. }
  248. if (v->decodelen == 0) /* cache empty? */
  249. for (; len > 0; len--, rbuf++) /* scan for SyncHeader in buf */
  250. if ((*rbuf & v->key) == 0)
  251. break; /* found first byte */
  252. if (len == 0) {
  253. dev_kfree_skb(skb);
  254. return NULL;
  255. }
  256. /* copy new data to decode-buffer */
  257. memcpy(&(v->decodebuf[v->decodelen]), rbuf, len);
  258. v->decodelen += len;
  259. ReSync:
  260. if (v->decodelen < v->nbytes) { /* got a new header ? */
  261. dev_kfree_skb(skb);
  262. return NULL; /* no, try later */
  263. }
  264. if (ValidHeaderBytes(v) != v->nbytes) { /* is that a valid header? */
  265. SyncHeader(v); /* no -> look for header */
  266. goto ReSync;
  267. }
  268. len = (v->decodelen - (v->decodelen % (10 * v->nbytes))) / v->nbytes;
  269. if ((v110_buf = kmalloc(len, GFP_ATOMIC)) == NULL) {
  270. printk(KERN_WARNING "isdn_v110_decode: Couldn't allocate v110_buf\n");
  271. dev_kfree_skb(skb);
  272. return NULL;
  273. }
  274. for (i = 0; i < len; i++) {
  275. v110_buf[i] = 0;
  276. for (j = 0; j < v->nbytes; j++)
  277. v110_buf[i] |= (v->decodebuf[(i * v->nbytes) + j] & v->key) << (8 - ((j + 1) * v->nbits));
  278. v110_buf[i] = FlipBits(v110_buf[i], v->nbits);
  279. }
  280. v->decodelen = (v->decodelen % (10 * v->nbytes));
  281. memcpy(v->decodebuf, &(v->decodebuf[len * v->nbytes]), v->decodelen);
  282. skb_trim(skb, DecodeMatrix(v, v110_buf, len, skb->data));
  283. kfree(v110_buf);
  284. if (skb->len)
  285. return skb;
  286. else {
  287. kfree_skb(skb);
  288. return NULL;
  289. }
  290. }
  291. /* EncodeMatrix takes input data in buf, len is the bytecount.
  292. Data is encoded into v110 frames in m. Return value is the number of
  293. matrix-lines generated.
  294. */
  295. static int
  296. EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
  297. {
  298. int line = 0;
  299. int i = 0;
  300. int mbit = 128;
  301. int dbit = 1;
  302. int introducer = 3;
  303. int ibit[] = {0, 1, 1};
  304. while ((i < len) && (line < mlen)) { /* while we still have input data */
  305. switch (line % 10) { /* in which line of the matrix are we? */
  306. case 0:
  307. m[line++] = 0x00; /* line 0 is always 0 */
  308. mbit = 128; /* go on with the 7th bit */
  309. break;
  310. case 5:
  311. m[line++] = 0xbf; /* line 5 is always 10111111 */
  312. mbit = 128; /* go on with the 7th bit */
  313. break;
  314. }
  315. if (line >= mlen) {
  316. printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
  317. return line;
  318. }
  319. next_bit:
  320. switch (mbit) { /* leftmost or rightmost bit ? */
  321. case 1:
  322. line++; /* rightmost -> go to next line */
  323. if (line >= mlen) {
  324. printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
  325. return line;
  326. }
  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. case 2:
  359. m[line++] = 0xfe;
  360. case 3:
  361. m[line++] = 0xfe;
  362. case 4:
  363. m[line++] = 0xfe;
  364. case 5:
  365. m[line++] = 0xbf;
  366. case 6:
  367. m[line++] = 0xfe;
  368. case 7:
  369. m[line++] = 0xfe;
  370. case 8:
  371. m[line++] = 0xfe;
  372. case 9:
  373. m[line++] = 0xfe;
  374. }
  375. return line; /* that's how many lines we have */
  376. }
  377. /*
  378. * Build a sync frame.
  379. */
  380. static struct sk_buff *
  381. isdn_v110_sync(isdn_v110_stream *v)
  382. {
  383. struct sk_buff *skb;
  384. if (v == NULL) {
  385. /* invalid handle, no chance to proceed */
  386. printk(KERN_WARNING "isdn_v110_sync called with NULL stream!\n");
  387. return NULL;
  388. }
  389. if ((skb = dev_alloc_skb(v->framelen + v->skbres))) {
  390. skb_reserve(skb, v->skbres);
  391. memcpy(skb_put(skb, v->framelen), v->OfflineFrame, v->framelen);
  392. }
  393. return skb;
  394. }
  395. /*
  396. * Build an idle frame.
  397. */
  398. static struct sk_buff *
  399. isdn_v110_idle(isdn_v110_stream *v)
  400. {
  401. struct sk_buff *skb;
  402. if (v == NULL) {
  403. /* invalid handle, no chance to proceed */
  404. printk(KERN_WARNING "isdn_v110_sync called with NULL stream!\n");
  405. return NULL;
  406. }
  407. if ((skb = dev_alloc_skb(v->framelen + v->skbres))) {
  408. skb_reserve(skb, v->skbres);
  409. memcpy(skb_put(skb, v->framelen), v->OnlineFrame, v->framelen);
  410. }
  411. return skb;
  412. }
  413. struct sk_buff *
  414. isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb)
  415. {
  416. int i;
  417. int j;
  418. int rlen;
  419. int mlen;
  420. int olen;
  421. int size;
  422. int sval1;
  423. int sval2;
  424. int nframes;
  425. unsigned char *v110buf;
  426. unsigned char *rbuf;
  427. struct sk_buff *nskb;
  428. if (v == NULL) {
  429. /* invalid handle, no chance to proceed */
  430. printk(KERN_WARNING "isdn_v110_encode called with NULL stream!\n");
  431. return NULL;
  432. }
  433. if (!skb) {
  434. /* invalid skb, no chance to proceed */
  435. printk(KERN_WARNING "isdn_v110_encode called with NULL skb!\n");
  436. return NULL;
  437. }
  438. rlen = skb->len;
  439. nframes = (rlen + 3) / 4;
  440. v110buf = v->encodebuf;
  441. if ((nframes * 40) > v->maxsize) {
  442. size = v->maxsize;
  443. rlen = v->maxsize / 40;
  444. } else
  445. size = nframes * 40;
  446. if (!(nskb = dev_alloc_skb(size + v->skbres + sizeof(int)))) {
  447. printk(KERN_WARNING "isdn_v110_encode: Couldn't alloc skb\n");
  448. return NULL;
  449. }
  450. skb_reserve(nskb, v->skbres + sizeof(int));
  451. if (skb->len == 0) {
  452. memcpy(skb_put(nskb, v->framelen), v->OnlineFrame, v->framelen);
  453. *((int *)skb_push(nskb, sizeof(int))) = 0;
  454. return nskb;
  455. }
  456. mlen = EncodeMatrix(skb->data, rlen, v110buf, size);
  457. /* now distribute 2 or 4 bits each to the output stream! */
  458. rbuf = skb_put(nskb, size);
  459. olen = 0;
  460. sval1 = 8 - v->nbits;
  461. sval2 = v->key << sval1;
  462. for (i = 0; i < mlen; i++) {
  463. v110buf[i] = FlipBits(v110buf[i], v->nbits);
  464. for (j = 0; j < v->nbytes; j++) {
  465. if (size--)
  466. *rbuf++ = ~v->key | (((v110buf[i] << (j * v->nbits)) & sval2) >> sval1);
  467. else {
  468. printk(KERN_WARNING "isdn_v110_encode: buffers full!\n");
  469. goto buffer_full;
  470. }
  471. olen++;
  472. }
  473. }
  474. buffer_full:
  475. skb_trim(nskb, olen);
  476. *((int *)skb_push(nskb, sizeof(int))) = rlen;
  477. return nskb;
  478. }
  479. int
  480. isdn_v110_stat_callback(int idx, isdn_ctrl *c)
  481. {
  482. isdn_v110_stream *v = NULL;
  483. int i;
  484. int ret = 0;
  485. if (idx < 0)
  486. return 0;
  487. switch (c->command) {
  488. case ISDN_STAT_BSENT:
  489. /* Keep the send-queue of the driver filled
  490. * with frames:
  491. * If number of outstanding frames < 3,
  492. * send down an Idle-Frame (or an Sync-Frame, if
  493. * v->SyncInit != 0).
  494. */
  495. if (!(v = dev->v110[idx]))
  496. return 0;
  497. atomic_inc(&dev->v110use[idx]);
  498. for (i=0; i * v->framelen < c->parm.length; i++) {
  499. if (v->skbidle > 0) {
  500. v->skbidle--;
  501. ret = 1;
  502. } else {
  503. if (v->skbuser > 0)
  504. v->skbuser--;
  505. ret = 0;
  506. }
  507. }
  508. for (i = v->skbuser + v->skbidle; i < 2; i++) {
  509. struct sk_buff *skb;
  510. if (v->SyncInit > 0)
  511. skb = isdn_v110_sync(v);
  512. else
  513. skb = isdn_v110_idle(v);
  514. if (skb) {
  515. if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
  516. dev_kfree_skb(skb);
  517. break;
  518. } else {
  519. if (v->SyncInit)
  520. v->SyncInit--;
  521. v->skbidle++;
  522. }
  523. } else
  524. break;
  525. }
  526. atomic_dec(&dev->v110use[idx]);
  527. return ret;
  528. case ISDN_STAT_DHUP:
  529. case ISDN_STAT_BHUP:
  530. while (1) {
  531. atomic_inc(&dev->v110use[idx]);
  532. if (atomic_dec_and_test(&dev->v110use[idx])) {
  533. isdn_v110_close(dev->v110[idx]);
  534. dev->v110[idx] = NULL;
  535. break;
  536. }
  537. mdelay(1);
  538. }
  539. break;
  540. case ISDN_STAT_BCONN:
  541. if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) {
  542. int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
  543. int maxsize = dev->drv[c->driver]->interface->maxbufsize;
  544. atomic_inc(&dev->v110use[idx]);
  545. switch (dev->v110emu[idx]) {
  546. case ISDN_PROTO_L2_V11096:
  547. dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
  548. break;
  549. case ISDN_PROTO_L2_V11019:
  550. dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
  551. break;
  552. case ISDN_PROTO_L2_V11038:
  553. dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
  554. break;
  555. default:;
  556. }
  557. if ((v = dev->v110[idx])) {
  558. while (v->SyncInit) {
  559. struct sk_buff *skb = isdn_v110_sync(v);
  560. if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
  561. dev_kfree_skb(skb);
  562. /* Unable to send, try later */
  563. break;
  564. }
  565. v->SyncInit--;
  566. v->skbidle++;
  567. }
  568. } else
  569. printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
  570. atomic_dec(&dev->v110use[idx]);
  571. }
  572. break;
  573. default:
  574. return 0;
  575. }
  576. return 0;
  577. }