hfcmulti.c (8bfddfbe2100862fd39b97001d0559ccd4c77f19) hfcmulti.c (7206e659f689558b41aa058c3040b081cb281d03)
1/*
2 * hfcmulti.c low level driver for hfc-4s/hfc-8s/hfc-e1 based cards
3 *
4 * Author Andreas Eversberg (jolly@eversberg.eu)
5 * ported to mqueue mechanism:
6 * Peter Sprenger (sprengermoving-bytes.de)
7 *
8 * inspired by existing hfc-pci driver:

--- 2182 unchanged lines hidden (view full) ---

2191static void
2192hfcmulti_rx(struct hfc_multi *hc, int ch)
2193{
2194 int temp;
2195 int Zsize, z1, z2 = 0; /* = 0, to make GCC happy */
2196 int f1 = 0, f2 = 0; /* = 0, to make GCC happy */
2197 int again = 0;
2198 struct bchannel *bch;
1/*
2 * hfcmulti.c low level driver for hfc-4s/hfc-8s/hfc-e1 based cards
3 *
4 * Author Andreas Eversberg (jolly@eversberg.eu)
5 * ported to mqueue mechanism:
6 * Peter Sprenger (sprengermoving-bytes.de)
7 *
8 * inspired by existing hfc-pci driver:

--- 2182 unchanged lines hidden (view full) ---

2191static void
2192hfcmulti_rx(struct hfc_multi *hc, int ch)
2193{
2194 int temp;
2195 int Zsize, z1, z2 = 0; /* = 0, to make GCC happy */
2196 int f1 = 0, f2 = 0; /* = 0, to make GCC happy */
2197 int again = 0;
2198 struct bchannel *bch;
2199 struct dchannel *dch;
2199 struct dchannel *dch = NULL;
2200 struct sk_buff *skb, **sp = NULL;
2201 int maxlen;
2202
2203 bch = hc->chan[ch].bch;
2200 struct sk_buff *skb, **sp = NULL;
2201 int maxlen;
2202
2203 bch = hc->chan[ch].bch;
2204 dch = hc->chan[ch].dch;
2205 if ((!dch) && (!bch))
2206 return;
2207 if (dch) {
2204 if (bch) {
2205 if (!test_bit(FLG_ACTIVE, &bch->Flags))
2206 return;
2207 } else if (hc->chan[ch].dch) {
2208 dch = hc->chan[ch].dch;
2208 if (!test_bit(FLG_ACTIVE, &dch->Flags))
2209 return;
2209 if (!test_bit(FLG_ACTIVE, &dch->Flags))
2210 return;
2210 sp = &dch->rx_skb;
2211 maxlen = dch->maxlen;
2212 } else {
2211 } else {
2213 if (!test_bit(FLG_ACTIVE, &bch->Flags))
2214 return;
2215 sp = &bch->rx_skb;
2216 maxlen = bch->maxlen;
2212 return;
2217 }
2218next_frame:
2219 /* on first AND before getting next valid frame, R_FIFO must be written
2220 to. */
2221 if (test_bit(HFC_CHIP_B410P, &hc->chip) &&
2222 (hc->chan[ch].protocol == ISDN_P_B_RAW) &&
2223 (hc->chan[ch].slot_rx < 0) &&
2224 (hc->chan[ch].slot_tx < 0))

--- 30 unchanged lines hidden (view full) ---

2255 /* complete hdlc frame */
2256 Zsize++;
2257 if (Zsize < 0)
2258 Zsize += hc->Zlen;
2259 /* if buffer is empty */
2260 if (Zsize <= 0)
2261 return;
2262
2213 }
2214next_frame:
2215 /* on first AND before getting next valid frame, R_FIFO must be written
2216 to. */
2217 if (test_bit(HFC_CHIP_B410P, &hc->chip) &&
2218 (hc->chan[ch].protocol == ISDN_P_B_RAW) &&
2219 (hc->chan[ch].slot_rx < 0) &&
2220 (hc->chan[ch].slot_tx < 0))

--- 30 unchanged lines hidden (view full) ---

2251 /* complete hdlc frame */
2252 Zsize++;
2253 if (Zsize < 0)
2254 Zsize += hc->Zlen;
2255 /* if buffer is empty */
2256 if (Zsize <= 0)
2257 return;
2258
2263 if (*sp == NULL) {
2264 *sp = mI_alloc_skb(maxlen + 3, GFP_ATOMIC);
2265 if (*sp == NULL) {
2266 printk(KERN_DEBUG "%s: No mem for rx_skb\n",
2267 __func__);
2259 if (bch) {
2260 maxlen = bchannel_get_rxbuf(bch, Zsize);
2261 if (maxlen < 0) {
2262 pr_warning("card%d.B%d: No bufferspace for %d bytes\n",
2263 hc->id + 1, bch->nr, Zsize);
2268 return;
2269 }
2264 return;
2265 }
2266 sp = &bch->rx_skb;
2267 maxlen = bch->maxlen;
2268 } else { /* Dchannel */
2269 sp = &dch->rx_skb;
2270 maxlen = dch->maxlen + 3;
2271 if (*sp == NULL) {
2272 *sp = mI_alloc_skb(maxlen, GFP_ATOMIC);
2273 if (*sp == NULL) {
2274 pr_warning("card%d: No mem for dch rx_skb\n",
2275 hc->id + 1);
2276 return;
2277 }
2278 }
2270 }
2271 /* show activity */
2272 if (dch)
2273 hc->activity_rx |= 1 << hc->chan[ch].port;
2274
2275 /* empty fifo with what we have */
2276 if (dch || test_bit(FLG_HDLC, &bch->Flags)) {
2277 if (debug & DEBUG_HFCMULTI_FIFO)
2278 printk(KERN_DEBUG "%s(card %d): fifo(%d) reading %d "
2279 "bytes (z1=%04x, z2=%04x) HDLC %s (f1=%d, f2=%d) "
2280 "got=%d (again %d)\n", __func__, hc->id + 1, ch,
2281 Zsize, z1, z2, (f1 == f2) ? "fragment" : "COMPLETE",
2282 f1, f2, Zsize + (*sp)->len, again);
2283 /* HDLC */
2279 }
2280 /* show activity */
2281 if (dch)
2282 hc->activity_rx |= 1 << hc->chan[ch].port;
2283
2284 /* empty fifo with what we have */
2285 if (dch || test_bit(FLG_HDLC, &bch->Flags)) {
2286 if (debug & DEBUG_HFCMULTI_FIFO)
2287 printk(KERN_DEBUG "%s(card %d): fifo(%d) reading %d "
2288 "bytes (z1=%04x, z2=%04x) HDLC %s (f1=%d, f2=%d) "
2289 "got=%d (again %d)\n", __func__, hc->id + 1, ch,
2290 Zsize, z1, z2, (f1 == f2) ? "fragment" : "COMPLETE",
2291 f1, f2, Zsize + (*sp)->len, again);
2292 /* HDLC */
2284 if ((Zsize + (*sp)->len) > (maxlen + 3)) {
2293 if ((Zsize + (*sp)->len) > maxlen) {
2285 if (debug & DEBUG_HFCMULTI_FIFO)
2286 printk(KERN_DEBUG
2287 "%s(card %d): hdlc-frame too large.\n",
2288 __func__, hc->id + 1);
2289 skb_trim(*sp, 0);
2290 HFC_outb_nodebug(hc, R_INC_RES_FIFO, V_RES_F);
2291 HFC_wait_nodebug(hc);
2292 return;

--- 53 unchanged lines hidden (view full) ---

2346 recv_Bchannel(bch, MISDN_ID_ANY);
2347 *sp = skb;
2348 again++;
2349 goto next_frame;
2350 }
2351 /* there is an incomplete frame */
2352 } else {
2353 /* transparent */
2294 if (debug & DEBUG_HFCMULTI_FIFO)
2295 printk(KERN_DEBUG
2296 "%s(card %d): hdlc-frame too large.\n",
2297 __func__, hc->id + 1);
2298 skb_trim(*sp, 0);
2299 HFC_outb_nodebug(hc, R_INC_RES_FIFO, V_RES_F);
2300 HFC_wait_nodebug(hc);
2301 return;

--- 53 unchanged lines hidden (view full) ---

2355 recv_Bchannel(bch, MISDN_ID_ANY);
2356 *sp = skb;
2357 again++;
2358 goto next_frame;
2359 }
2360 /* there is an incomplete frame */
2361 } else {
2362 /* transparent */
2354 if (Zsize > skb_tailroom(*sp))
2355 Zsize = skb_tailroom(*sp);
2356 hc->read_fifo(hc, skb_put(*sp, Zsize), Zsize);
2363 hc->read_fifo(hc, skb_put(*sp, Zsize), Zsize);
2357 if (((*sp)->len) < MISDN_COPY_SIZE) {
2358 skb = *sp;
2359 *sp = mI_alloc_skb(skb->len, GFP_ATOMIC);
2360 if (*sp) {
2361 memcpy(skb_put(*sp, skb->len),
2362 skb->data, skb->len);
2363 skb_trim(skb, 0);
2364 } else {
2365 printk(KERN_DEBUG "%s: No mem\n", __func__);
2366 *sp = skb;
2367 skb = NULL;
2368 }
2369 } else {
2370 skb = NULL;
2371 }
2372 if (debug & DEBUG_HFCMULTI_FIFO)
2373 printk(KERN_DEBUG
2374 "%s(card %d): fifo(%d) reading %d bytes "
2375 "(z1=%04x, z2=%04x) TRANS\n",
2376 __func__, hc->id + 1, ch, Zsize, z1, z2);
2377 /* only bch is transparent */
2378 recv_Bchannel(bch, hc->chan[ch].Zfill);
2364 if (debug & DEBUG_HFCMULTI_FIFO)
2365 printk(KERN_DEBUG
2366 "%s(card %d): fifo(%d) reading %d bytes "
2367 "(z1=%04x, z2=%04x) TRANS\n",
2368 __func__, hc->id + 1, ch, Zsize, z1, z2);
2369 /* only bch is transparent */
2370 recv_Bchannel(bch, hc->chan[ch].Zfill);
2379 *sp = skb;
2380 }
2381}
2382
2383
2384/*
2385 * Interrupt handler
2386 */
2387static void

--- 3205 unchanged lines hidden ---
2371 }
2372}
2373
2374
2375/*
2376 * Interrupt handler
2377 */
2378static void

--- 3205 unchanged lines hidden ---