1 This experimental patch splits one E1 card into three virtual cards,
4 TS 6,7,8,9,10 is card 1
5 TS 11,12,13,14 is card 2
7 This allows you to run one L2 TEI handler on each of the virtual cards,
8 which is required if you want to run multiple BTS on a single E1 link.
10 Thanks to Andreas Eversberg for this patch.
12 diff --git a/drivers/isdn/hardware/mISDN/hfc_multi.h b/drivers/isdn/hardware/mISDN/hfc_multi.h
13 index 0c77386..02dd4a1 100644
14 --- a/drivers/isdn/hardware/mISDN/hfc_multi.h
15 +++ b/drivers/isdn/hardware/mISDN/hfc_multi.h
16 @@ -209,14 +209,17 @@ struct hfc_multi {
17 u_long ledstate; /* save last state of leds */
18 int opticalsupport; /* has the e1 board */
19 /* an optical Interface */
20 - int dslot; /* channel # of d-channel (E1) default 16 */
22 + u_int bmask[32]; /* bitmask of bchannels for port */
23 + u_char dnum[32]; /* array of used dchannel numbers for port */
24 + u_char created[32]; /* what port is created */
25 + u_int activity[32]; /* if there is any action on this */
26 + /* port (will be cleared after */
27 + /* showing led-states) */
29 u_long wdcount; /* every 500 ms we need to */
30 /* send the watchdog a signal */
31 u_char wdbyte; /* watchdog toggle byte */
32 - u_int activity[8]; /* if there is any action on this */
33 - /* port (will be cleared after */
34 - /* showing led-states) */
35 int e1_state; /* keep track of last state */
36 int e1_getclock; /* if sync is retrieved from interface */
37 int syncronized; /* keep track of existing sync interface */
38 @@ -233,7 +236,6 @@ struct hfc_multi {
39 * the bch->channel is equvalent to the hfc-channel
41 struct hfc_chan chan[32];
42 - u_char created[8]; /* what port is created */
43 signed char slot_owner[256]; /* owner channel of slot */
46 diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
47 index e1dab30..4fe2d27 100644
48 --- a/drivers/isdn/hardware/mISDN/hfcmulti.c
49 +++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
50 @@ -1619,8 +1619,8 @@ hfcmulti_leds(struct hfc_multi *hc)
51 * left red: frame sync, but no L1
52 * right green: L2 active
54 - if (hc->chan[hc->dslot].sync != 2) { /* no frame sync */
55 - if (hc->chan[hc->dslot].dch->dev.D.protocol
56 + if (hc->chan[hc->dnum[0]].sync != 2) { /* no frame sync */
57 + if (hc->chan[hc->dnum[0]].dch->dev.D.protocol
61 @@ -2428,55 +2428,56 @@ handle_timer_irq(struct hfc_multi *hc)
64 if (hc->ctype == HFC_TYPE_E1 && hc->created[0]) {
65 - dch = hc->chan[hc->dslot].dch;
66 - if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dslot].cfg)) {
67 +#warning todo: put interface parameters to hc
68 + dch = hc->chan[hc->dnum[0]].dch;
69 + if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dnum[0]].cfg)) {
71 temp = HFC_inb_nodebug(hc, R_SYNC_STA) & V_SIG_LOS;
72 - if (!temp && hc->chan[hc->dslot].los)
73 + if (!temp && hc->chan[hc->dnum[0]].los)
74 signal_state_up(dch, L1_SIGNAL_LOS_ON,
76 - if (temp && !hc->chan[hc->dslot].los)
77 + if (temp && !hc->chan[hc->dnum[0]].los)
78 signal_state_up(dch, L1_SIGNAL_LOS_OFF,
80 - hc->chan[hc->dslot].los = temp;
81 + hc->chan[hc->dnum[0]].los = temp;
83 - if (test_bit(HFC_CFG_REPORT_AIS, &hc->chan[hc->dslot].cfg)) {
84 + if (test_bit(HFC_CFG_REPORT_AIS, &hc->chan[hc->dnum[0]].cfg)) {
86 temp = HFC_inb_nodebug(hc, R_SYNC_STA) & V_AIS;
87 - if (!temp && hc->chan[hc->dslot].ais)
88 + if (!temp && hc->chan[hc->dnum[0]].ais)
89 signal_state_up(dch, L1_SIGNAL_AIS_ON,
91 - if (temp && !hc->chan[hc->dslot].ais)
92 + if (temp && !hc->chan[hc->dnum[0]].ais)
93 signal_state_up(dch, L1_SIGNAL_AIS_OFF,
95 - hc->chan[hc->dslot].ais = temp;
96 + hc->chan[hc->dnum[0]].ais = temp;
98 - if (test_bit(HFC_CFG_REPORT_SLIP, &hc->chan[hc->dslot].cfg)) {
99 + if (test_bit(HFC_CFG_REPORT_SLIP, &hc->chan[hc->dnum[0]].cfg)) {
101 temp = HFC_inb_nodebug(hc, R_SLIP) & V_FOSLIP_RX;
102 - if (!temp && hc->chan[hc->dslot].slip_rx)
103 + if (!temp && hc->chan[hc->dnum[0]].slip_rx)
104 signal_state_up(dch, L1_SIGNAL_SLIP_RX,
105 " bit SLIP detected RX");
106 - hc->chan[hc->dslot].slip_rx = temp;
107 + hc->chan[hc->dnum[0]].slip_rx = temp;
108 temp = HFC_inb_nodebug(hc, R_SLIP) & V_FOSLIP_TX;
109 - if (!temp && hc->chan[hc->dslot].slip_tx)
110 + if (!temp && hc->chan[hc->dnum[0]].slip_tx)
111 signal_state_up(dch, L1_SIGNAL_SLIP_TX,
112 " bit SLIP detected TX");
113 - hc->chan[hc->dslot].slip_tx = temp;
114 + hc->chan[hc->dnum[0]].slip_tx = temp;
116 - if (test_bit(HFC_CFG_REPORT_RDI, &hc->chan[hc->dslot].cfg)) {
117 + if (test_bit(HFC_CFG_REPORT_RDI, &hc->chan[hc->dnum[0]].cfg)) {
119 temp = HFC_inb_nodebug(hc, R_RX_SL0_0) & V_A;
120 - if (!temp && hc->chan[hc->dslot].rdi)
121 + if (!temp && hc->chan[hc->dnum[0]].rdi)
122 signal_state_up(dch, L1_SIGNAL_RDI_ON,
124 - if (temp && !hc->chan[hc->dslot].rdi)
125 + if (temp && !hc->chan[hc->dnum[0]].rdi)
126 signal_state_up(dch, L1_SIGNAL_RDI_OFF,
128 - hc->chan[hc->dslot].rdi = temp;
129 + hc->chan[hc->dnum[0]].rdi = temp;
131 temp = HFC_inb_nodebug(hc, R_JATT_DIR);
132 - switch (hc->chan[hc->dslot].sync) {
133 + switch (hc->chan[hc->dnum[0]].sync) {
135 if ((temp & 0x60) == 0x60) {
136 if (debug & DEBUG_HFCMULTI_SYNC)
137 @@ -2485,10 +2486,10 @@ handle_timer_irq(struct hfc_multi *hc)
140 HFC_outb(hc, R_RX_OFF,
141 - hc->chan[hc->dslot].jitter | V_RX_INIT);
142 + hc->chan[hc->dnum[0]].jitter | V_RX_INIT);
143 HFC_outb(hc, R_TX_OFF,
144 - hc->chan[hc->dslot].jitter | V_RX_INIT);
145 - hc->chan[hc->dslot].sync = 1;
146 + hc->chan[hc->dnum[0]].jitter | V_RX_INIT);
147 + hc->chan[hc->dnum[0]].sync = 1;
148 goto check_framesync;
151 @@ -2499,7 +2500,7 @@ handle_timer_irq(struct hfc_multi *hc)
155 - hc->chan[hc->dslot].sync = 0;
156 + hc->chan[hc->dnum[0]].sync = 0;
160 @@ -2510,7 +2511,7 @@ check_framesync:
162 "now in frame sync\n",
164 - hc->chan[hc->dslot].sync = 2;
165 + hc->chan[hc->dnum[0]].sync = 2;
169 @@ -2520,7 +2521,7 @@ check_framesync:
170 "%s: (id=%d) E1 lost "
171 "clock & frame sync\n",
173 - hc->chan[hc->dslot].sync = 0;
174 + hc->chan[hc->dnum[0]].sync = 0;
177 temp = HFC_inb_nodebug(hc, R_SYNC_STA);
178 @@ -2530,7 +2531,7 @@ check_framesync:
182 - hc->chan[hc->dslot].sync = 1;
183 + hc->chan[hc->dnum[0]].sync = 1;
187 @@ -2746,7 +2747,8 @@ hfcmulti_interrupt(int intno, void *dev_id)
188 if (r_irq_misc & V_STA_IRQ) {
189 if (hc->ctype == HFC_TYPE_E1) {
191 - dch = hc->chan[hc->dslot].dch;
193 + dch = hc->chan[hc->dnum[0]].dch;
194 e1_syncsta = HFC_inb_nodebug(hc, R_SYNC_STA);
195 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)
196 && hc->e1_getclock) {
197 @@ -2768,7 +2770,15 @@ hfcmulti_interrupt(int intno, void *dev_id)
199 dch->state = HFC_inb_nodebug(hc, R_E1_RD_STA)
201 +#warning todo hack!!! broadcast state change!!!
202 + dch = hc->chan[hc->dnum[0]].dch;
203 schedule_event(dch, FLG_PHCHANGE);
204 + dch = hc->chan[hc->dnum[1]].dch;
205 + dch->state = HFC_inb_nodebug(hc, R_E1_RD_STA)
207 + schedule_event(dch, FLG_PHCHANGE);
210 if (debug & DEBUG_HFCMULTI_STATE)
212 "%s: E1 (id=%d) newstate %x\n",
213 @@ -3851,31 +3861,35 @@ hfcmulti_initmode(struct dchannel *dch)
214 if (debug & DEBUG_HFCMULTI_INIT)
215 printk(KERN_DEBUG "%s: entered\n", __func__);
218 + pt = hc->chan[i].port;
219 if (hc->ctype == HFC_TYPE_E1) {
220 - hc->chan[hc->dslot].slot_tx = -1;
221 - hc->chan[hc->dslot].slot_rx = -1;
222 - hc->chan[hc->dslot].conf = -1;
224 - mode_hfcmulti(hc, hc->dslot, dch->dev.D.protocol,
226 +#warning todo: don''t do it if dnum == 0
227 + hc->chan[hc->dnum[pt]].slot_tx = -1;
228 + hc->chan[hc->dnum[pt]].slot_rx = -1;
229 + hc->chan[hc->dnum[pt]].conf = -1;
230 + if (hc->dnum[pt]) {
231 + mode_hfcmulti(hc, dch->slot, dch->dev.D.protocol,
233 dch->timer.function = (void *) hfcmulti_dbusy_timer;
234 dch->timer.data = (long) dch;
235 init_timer(&dch->timer);
237 for (i = 1; i <= 31; i++) {
238 - if (i == hc->dslot)
239 + if (!((1 << i) & hc->bmask[pt])) /* skip unused channel */
241 hc->chan[i].slot_tx = -1;
242 hc->chan[i].slot_rx = -1;
243 hc->chan[i].conf = -1;
244 mode_hfcmulti(hc, i, ISDN_P_NONE, -1, 0, -1, 0);
247 - if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dslot].cfg)) {
248 +#warning todo (global)
249 + if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dnum[pt]].cfg)) {
250 HFC_outb(hc, R_LOS0, 255); /* 2 ms */
251 HFC_outb(hc, R_LOS1, 255); /* 512 ms */
253 - if (test_bit(HFC_CFG_OPTICAL, &hc->chan[hc->dslot].cfg)) {
254 + if (test_bit(HFC_CFG_OPTICAL, &hc->chan[hc->dnum[pt]].cfg)) {
255 HFC_outb(hc, R_RX0, 0);
256 hc->hw.r_tx0 = 0 | V_OUT_EN;
258 @@ -3888,12 +3902,12 @@ hfcmulti_initmode(struct dchannel *dch)
259 HFC_outb(hc, R_TX_FR0, 0x00);
260 HFC_outb(hc, R_TX_FR1, 0xf8);
262 - if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dslot].cfg))
263 + if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dnum[pt]].cfg))
264 HFC_outb(hc, R_TX_FR2, V_TX_MF | V_TX_E | V_NEG_E);
266 HFC_outb(hc, R_RX_FR0, V_AUTO_RESYNC | V_AUTO_RECO | 0);
268 - if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dslot].cfg))
269 + if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dnum[pt]].cfg))
270 HFC_outb(hc, R_RX_FR1, V_RX_MF | V_RX_MF_SYNC);
272 if (dch->dev.D.protocol == ISDN_P_NT_E1) {
273 @@ -3957,7 +3971,7 @@ hfcmulti_initmode(struct dchannel *dch)
274 plxsd_checksync(hc, 0);
279 hc->chan[i].slot_tx = -1;
280 hc->chan[i].slot_rx = -1;
281 hc->chan[i].conf = -1;
282 @@ -3973,8 +3987,6 @@ hfcmulti_initmode(struct dchannel *dch)
283 hc->chan[i - 1].slot_rx = -1;
284 hc->chan[i - 1].conf = -1;
285 mode_hfcmulti(hc, i - 1, ISDN_P_NONE, -1, 0, -1, 0);
287 - pt = hc->chan[i].port;
288 /* select interface */
289 HFC_outb(hc, R_ST_SEL, pt);
290 /* undocumented: delay after R_ST_SEL */
291 @@ -4557,6 +4569,8 @@ release_port(struct hfc_multi *hc, struct dchannel *dch)
294 for (i = 0; i <= 31; i++) {
295 + if (!((1 << i) & hc->bmask[pt])) /* skip unused channel */
297 if (hc->chan[i].bch) {
298 if (debug & DEBUG_HFCMULTI_INIT)
300 @@ -4680,12 +4694,13 @@ release_card(struct hfc_multi *hc)
304 -init_e1_port(struct hfc_multi *hc, struct hm_map *m)
305 +init_e1_port(struct hfc_multi *hc, struct hm_map *m, int pt)
307 struct dchannel *dch;
308 struct bchannel *bch;
310 char name[MISDN_MAX_IDLEN];
313 dch = kzalloc(sizeof(struct dchannel), GFP_KERNEL);
315 @@ -4698,13 +4713,12 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
316 (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
317 dch->dev.D.send = handle_dmsg;
318 dch->dev.D.ctrl = hfcm_dctrl;
319 - dch->dev.nrbchan = (hc->dslot) ? 30 : 31;
320 - dch->slot = hc->dslot;
321 - hc->chan[hc->dslot].dch = dch;
322 - hc->chan[hc->dslot].port = 0;
323 - hc->chan[hc->dslot].nt_timer = -1;
324 + dch->slot = hc->dnum[pt];
325 + hc->chan[hc->dnum[pt]].dch = dch;
326 + hc->chan[hc->dnum[pt]].port = pt;
327 + hc->chan[hc->dnum[pt]].nt_timer = -1;
328 for (ch = 1; ch <= 31; ch++) {
329 - if (ch == hc->dslot) /* skip dchannel */
330 + if (!((1 << ch) & hc->bmask[pt])) /* skip unused channel */
332 bch = kzalloc(sizeof(struct bchannel), GFP_KERNEL);
334 @@ -4733,7 +4747,10 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
335 hc->chan[ch].bch = bch;
336 hc->chan[ch].port = 0;
337 set_channelmap(bch->nr, dch->dev.channelmap);
340 + dch->dev.nrbchan = bcount;
341 +#warning todo: must be set globally, and must be a seperate function
342 /* set optical line type */
343 if (port[Port_cnt] & 0x001) {
344 if (!m->opticalsupport) {
345 @@ -4749,7 +4766,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
348 test_and_set_bit(HFC_CFG_OPTICAL,
349 - &hc->chan[hc->dslot].cfg);
350 + &hc->chan[hc->dnum[pt]].cfg);
354 @@ -4759,7 +4776,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
355 "LOS report: card(%d) port(%d)\n",
356 __func__, HFC_cnt + 1, 1);
357 test_and_set_bit(HFC_CFG_REPORT_LOS,
358 - &hc->chan[hc->dslot].cfg);
359 + &hc->chan[hc->dnum[pt]].cfg);
362 if (port[Port_cnt] & 0x008) {
363 @@ -4768,7 +4785,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
364 "AIS report: card(%d) port(%d)\n",
365 __func__, HFC_cnt + 1, 1);
366 test_and_set_bit(HFC_CFG_REPORT_AIS,
367 - &hc->chan[hc->dslot].cfg);
368 + &hc->chan[hc->dnum[pt]].cfg);
370 /* set SLIP report */
371 if (port[Port_cnt] & 0x010) {
372 @@ -4778,7 +4795,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
373 "card(%d) port(%d)\n",
374 __func__, HFC_cnt + 1, 1);
375 test_and_set_bit(HFC_CFG_REPORT_SLIP,
376 - &hc->chan[hc->dslot].cfg);
377 + &hc->chan[hc->dnum[pt]].cfg);
380 if (port[Port_cnt] & 0x020) {
381 @@ -4788,7 +4805,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
382 "card(%d) port(%d)\n",
383 __func__, HFC_cnt + 1, 1);
384 test_and_set_bit(HFC_CFG_REPORT_RDI,
385 - &hc->chan[hc->dslot].cfg);
386 + &hc->chan[hc->dnum[pt]].cfg);
389 if (!(port[Port_cnt] & 0x100)) {
390 @@ -4797,7 +4814,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
391 " card(%d) port(%d)\n",
392 __func__, HFC_cnt + 1, 1);
393 test_and_set_bit(HFC_CFG_CRC4,
394 - &hc->chan[hc->dslot].cfg);
395 + &hc->chan[hc->dnum[pt]].cfg);
397 if (debug & DEBUG_HFCMULTI_INIT)
398 printk(KERN_DEBUG "%s: PORT turn off CRC4"
399 @@ -4829,20 +4846,23 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
401 /* set elastic jitter buffer */
402 if (port[Port_cnt] & 0x3000) {
403 - hc->chan[hc->dslot].jitter = (port[Port_cnt]>>12) & 0x3;
404 + hc->chan[hc->dnum[pt]].jitter = (port[Port_cnt]>>12) & 0x3;
405 if (debug & DEBUG_HFCMULTI_INIT)
407 "%s: PORT set elastic "
408 "buffer to %d: card(%d) port(%d)\n",
409 - __func__, hc->chan[hc->dslot].jitter,
410 + __func__, hc->chan[hc->dnum[pt]].jitter,
413 - hc->chan[hc->dslot].jitter = 2; /* default */
414 - snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1);
415 + hc->chan[hc->dnum[pt]].jitter = 2; /* default */
417 + snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d-%d", HFC_cnt + 1, pt+1);
419 + snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1);
420 ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name);
423 - hc->created[0] = 1;
424 + hc->created[pt] = 1;
427 release_port(hc, dch);
428 @@ -5009,18 +5029,30 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
430 hc->pcm = pcm[HFC_cnt];
431 hc->io_mode = iomode[HFC_cnt];
432 +#warning todo: rework module parameters for customizing e1 fragments.... yea, let''s call it: fragments
433 if (dslot[HFC_cnt] < 0 && hc->ctype == HFC_TYPE_E1) {
436 printk(KERN_INFO "HFC-E1 card has disabled D-channel, but "
439 if (dslot[HFC_cnt] > 0 && dslot[HFC_cnt] < 32
440 && hc->ctype == HFC_TYPE_E1) {
441 - hc->dslot = dslot[HFC_cnt];
442 + hc->dnum[0] = dslot[HFC_cnt];
443 printk(KERN_INFO "HFC-E1 card has alternating D-channel on "
444 "time slot %d\n", dslot[HFC_cnt]);
449 +#warning todo HACK!!! just a small map of two "fragments"
450 + if (hc->ctype == HFC_TYPE_E1) {
452 + hc->bmask[0] = 0x0000003c;
454 + hc->bmask[1] = 0x00000780;
456 + hc->bmask[2] = 0x00007800;
460 /* set chip specific features */
462 @@ -5103,7 +5135,7 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
465 if (hc->ctype == HFC_TYPE_E1)
466 - ret_err = init_e1_port(hc, m);
467 + ret_err = init_e1_port(hc, m, pt);
469 ret_err = init_multi_port(hc, pt);
470 if (debug & DEBUG_HFCMULTI_INIT)
471 @@ -5115,10 +5147,14 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
473 while (pt) { /* release already registered ports */
475 - release_port(hc, hc->chan[(pt << 2) + 2].dch);
476 + if (hc->ctype == HFC_TYPE_E1)
477 + release_port(hc, hc->chan[hc->dnum[pt]].dch);
479 + release_port(hc, hc->chan[(pt << 2) + 2].dch);
483 +#warning todo: count it right, add additional "fragment" counter...