trace channel data to syslog

This commit is contained in:
Martin Bachem 2006-11-13 16:27:19 +00:00
parent ae7ba0a377
commit a824a65c98
2 changed files with 104 additions and 9 deletions

View File

@ -47,7 +47,7 @@ static u_int protocol[MAX_CARDS] = {2,2,2,2,2,2,2,2};
static int layermask[MAX_CARDS]; static int layermask[MAX_CARDS];
static mISDNobject_t hw_mISDNObj; static mISDNobject_t hw_mISDNObj;
static int debug = 0x1FFFF; // 0; static int debug = 0;
static int poll = 128; static int poll = 128;
@ -536,6 +536,11 @@ setup_bchannel(channel_t * bch, int protocol)
} }
if (protocol >= ISDN_PID_NONE) { if (protocol >= ISDN_PID_NONE) {
/*
printk ("HFCS-USB: %s: HFCUSB_FIFO(0x%x) HFCUSB_CON_HDLC(0x%x)\n",
__FUNCTION__, (bch->channel)?2:0, conhdlc);
*/
/* set FIFO to transmit register */ /* set FIFO to transmit register */
queued_Write_hfc(card, HFCUSB_FIFO, queued_Write_hfc(card, HFCUSB_FIFO,
(bch->channel)?2:0); (bch->channel)?2:0);
@ -544,6 +549,11 @@ setup_bchannel(channel_t * bch, int protocol)
/* reset fifo */ /* reset fifo */
queued_Write_hfc(card, HFCUSB_INC_RES_F, 2); queued_Write_hfc(card, HFCUSB_INC_RES_F, 2);
/*
printk ("HFCS-USB: %s: HFCUSB_FIFO(0x%x) HFCUSB_CON_HDLC(0x%x)\n",
__FUNCTION__, (bch->channel)?2:0, conhdlc);
*/
/* set FIFO to receive register */ /* set FIFO to receive register */
queued_Write_hfc(card, HFCUSB_FIFO, queued_Write_hfc(card, HFCUSB_FIFO,
((bch->channel)?3:1)); ((bch->channel)?3:1));
@ -564,6 +574,11 @@ setup_bchannel(channel_t * bch, int protocol)
sctrl |= ((card->chan[B2].channel)?2:1); sctrl |= ((card->chan[B2].channel)?2:1);
sctrl_r |= ((card->chan[B2].channel)?2:1); sctrl_r |= ((card->chan[B2].channel)?2:1);
} }
/*
printk ("HFCS-USB: %s: HFCUSB_SCTRL(0x%x) HFCUSB_SCTRL_R(0x%x)\n",
__FUNCTION__, sctrl, sctrl_r);
*/
queued_Write_hfc(card, HFCUSB_SCTRL, sctrl); queued_Write_hfc(card, HFCUSB_SCTRL, sctrl);
queued_Write_hfc(card, HFCUSB_SCTRL_R, sctrl_r); queued_Write_hfc(card, HFCUSB_SCTRL_R, sctrl_r);
@ -786,10 +801,35 @@ hfcsusb_l2l1(mISDNinstance_t *inst, struct sk_buff *skb)
channel_t *chan = container_of(inst, channel_t, inst); channel_t *chan = container_of(inst, channel_t, inst);
int ret = 0; int ret = 0;
mISDN_head_t *hh = mISDN_HEAD_P(skb); mISDN_head_t *hh = mISDN_HEAD_P(skb);
int i;
if ((hh->prim == PH_DATA_REQ) || (hh->prim == DL_DATA_REQ)) { if ((hh->prim == PH_DATA_REQ) || (hh->prim == DL_DATA_REQ)) {
ret = channel_senddata(chan, hh->dinfo, skb); ret = channel_senddata(chan, hh->dinfo, skb);
if (ret > 0) { if (ret > 0) {
if (!(chan)) {
printk ("CRITICAL ERROR! chan is NULL pointer!\n");
return(-EINVAL);
}
if (!(chan->tx_skb)) {
printk ("CRITICAL ERROR! channel_senddata returned %d without chan->tx_skb\n", ret);
return(-EINVAL);
}
/* just some debug: */
if (test_bit(FLG_DCHANNEL, &chan->Flags)) {
if ((chan->debug) && (debug & DEBUG_HFC_DTRACE)) {
mISDN_debugprint(&chan->inst,
"new TX len(%i): ",
chan->tx_skb->len);
i = 0;
printk(" ");
while (i < chan->tx_skb->len)
printk("%02x ", chan->tx_skb->data[i++]);
printk("\n");
}
}
/* data gets transmitted later in USB ISO OUT traffic */ /* data gets transmitted later in USB ISO OUT traffic */
ret = 0; ret = 0;
} }
@ -930,18 +970,21 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, unsigned int len, int finish)
channel_t *ch = &card->chan[fifo->ch_idx]; channel_t *ch = &card->chan[fifo->ch_idx];
struct sk_buff *skb; /* data buffer for upper layer */ struct sk_buff *skb; /* data buffer for upper layer */
int fifon; int fifon;
int i;
if (!len) if (!len)
return; return;
fifon = fifo->fifonum; fifon = fifo->fifonum;
if (!ch->rx_skb) { if (!ch->rx_skb) {
printk(KERN_INFO "alloc new skb for fifon(%d), len(%d+%d)\n", fifon, ch->maxlen + 3, ch->up_headerlen);
ch->rx_skb = alloc_stack_skb(ch->maxlen + 3, ch->up_headerlen); ch->rx_skb = alloc_stack_skb(ch->maxlen + 3, ch->up_headerlen);
if (!ch->rx_skb) { if (!ch->rx_skb) {
printk(KERN_DEBUG "%s: No mem for rx_skb\n", __FUNCTION__); printk(KERN_DEBUG "%s: No mem for rx_skb\n", __FUNCTION__);
return; return;
} }
skb_trim(ch->rx_skb, 0);
} }
if (fifon == HFCUSB_D_RX) { if (fifon == HFCUSB_D_RX) {
@ -954,14 +997,15 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, unsigned int len, int finish)
} }
} else { } else {
/* B-Channel SKB range check */ /* B-Channel SKB range check */
if ((ch->rx_skb->len + len) >= MAX_DATA_MEM) { if ((ch->rx_skb->len + len) >= 2000) {
printk(KERN_DEBUG "%s: sbk mem exceeded for fifo(%d) HFCUSB_B_RX\n", printk(KERN_DEBUG "%s: sbk mem exceeded for fifo(%d) HFCUSB_B_RX\n",
__FUNCTION__, fifon); __FUNCTION__, fifon);
skb_trim(ch->rx_skb, 0); skb_trim(ch->rx_skb, 0);
return; return;
} }
} }
// printk ("skb_put: len(%d) new_len(%d)", ch->rx_skb->len, len);
memcpy(skb_put(ch->rx_skb, len), data, len); memcpy(skb_put(ch->rx_skb, len), data, len);
if (test_bit(FLG_HDLC, &ch->Flags)) { if (test_bit(FLG_HDLC, &ch->Flags)) {
@ -970,6 +1014,17 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, unsigned int len, int finish)
if ((ch->rx_skb->len > 3) && if ((ch->rx_skb->len > 3) &&
(!(ch->rx_skb->data[ch->rx_skb->len - 1]))) { (!(ch->rx_skb->data[ch->rx_skb->len - 1]))) {
if (ch->debug) {
mISDN_debugprint(&ch->inst,
"fifon(%i) new RX len(%i): ",
fifon, ch->rx_skb->len);
i = 0;
printk(" ");
while (i < ch->rx_skb->len)
printk("%02x ", ch->rx_skb->data[i++]);
printk("\n");
}
/* remove CRC & status */ /* remove CRC & status */
skb_trim(ch->rx_skb, ch->rx_skb->len - 3); skb_trim(ch->rx_skb, ch->rx_skb->len - 3);
@ -988,13 +1043,25 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, unsigned int len, int finish)
ch->rx_skb = NULL; ch->rx_skb = NULL;
} }
queue_ch_frame(ch, INDICATION, MISDN_ID_ANY, skb); queue_ch_frame(ch, INDICATION, MISDN_ID_ANY, skb);
} else { } else {
printk ("HFC-S USB: CRC or minlen ERROR\n"); printk ("HFC-S USB: CRC or minlen ERROR: ");
if (ch->debug) {
mISDN_debugprint(&ch->inst,
"fifon(%i) RX len(%i): ",
fifon, ch->rx_skb->len);
i = 0;
printk(" ");
while (i < ch->rx_skb->len)
printk("%02x ", ch->rx_skb->data[i++]);
printk("\n");
}
skb_trim(ch->rx_skb, 0);
} }
} }
} else { } else {
if (finish || ch->rx_skb->len >= poll) { if (finish || ch->rx_skb->len >= poll) {
printk(KERN_DEBUG "%s: queueing transp data fifon(%i) (%i)\n", __FUNCTION__, fifon, ch->rx_skb->len);
/* deliver transparent data to layer2 */ /* deliver transparent data to layer2 */
queue_ch_frame(ch, INDICATION, MISDN_ID_ANY, ch->rx_skb); queue_ch_frame(ch, INDICATION, MISDN_ID_ANY, ch->rx_skb);
ch->rx_skb = NULL; ch->rx_skb = NULL;
@ -1037,7 +1104,7 @@ rx_iso_complete(struct urb *urb, struct pt_regs *regs)
usb_fifo *fifo = context_iso_urb->owner_fifo; usb_fifo *fifo = context_iso_urb->owner_fifo;
hfcsusb_t *card = fifo->card; hfcsusb_t *card = fifo->card;
int k, len, errcode, offset, num_isoc_packets, fifon, maxlen, int k, len, errcode, offset, num_isoc_packets, fifon, maxlen,
status; status, i;
unsigned int iso_status; unsigned int iso_status;
__u8 *buf; __u8 *buf;
static __u8 eof[8]; static __u8 eof[8];
@ -1048,7 +1115,9 @@ rx_iso_complete(struct urb *urb, struct pt_regs *regs)
if (fifo->active && !status) { if (fifo->active && !status) {
num_isoc_packets = iso_packets[fifon]; num_isoc_packets = iso_packets[fifon];
maxlen = fifo->usb_packet_maxlen; maxlen = fifo->usb_packet_maxlen;
for (k = 0; k < num_isoc_packets; ++k) { for (k = 0; k < num_isoc_packets; ++k) {
len = urb->iso_frame_desc[k].actual_length; len = urb->iso_frame_desc[k].actual_length;
offset = urb->iso_frame_desc[k].offset; offset = urb->iso_frame_desc[k].offset;
buf = context_iso_urb->buffer + offset; buf = context_iso_urb->buffer + offset;
@ -1059,6 +1128,14 @@ rx_iso_complete(struct urb *urb, struct pt_regs *regs)
"HFC-S USB: ISO packet failure - status:%x", "HFC-S USB: ISO packet failure - status:%x",
iso_status); iso_status);
if (fifon == 1) {
printk ("(%d/%d) len(%d) ", k, num_isoc_packets-1, len);
for (i=0; i<len; i++) {
printk ("%x ", buf[i]);
}
printk ("\n");
}
if (fifo->last_urblen != maxlen) { if (fifo->last_urblen != maxlen) {
/* the threshold mask is in the 2nd status byte */ /* the threshold mask is in the 2nd status byte */
card->threshold_mask = buf[1]; card->threshold_mask = buf[1];
@ -1118,6 +1195,7 @@ rx_int_complete(struct urb *urb, struct pt_regs *regs)
usb_fifo *fifo = (usb_fifo *) urb->context; usb_fifo *fifo = (usb_fifo *) urb->context;
hfcsusb_t *card = fifo->card; hfcsusb_t *card = fifo->card;
static __u8 eof[8]; static __u8 eof[8];
int i;
urb->dev = card->dev; /* security init */ urb->dev = card->dev; /* security init */
@ -1133,7 +1211,15 @@ rx_int_complete(struct urb *urb, struct pt_regs *regs)
len = urb->actual_length; len = urb->actual_length;
buf = fifo->buffer; buf = fifo->buffer;
maxlen = fifo->usb_packet_maxlen; maxlen = fifo->usb_packet_maxlen;
if (fifon == 1) {
printk ("fifon %d len %d: ", fifon, len);
for (i=0; i<len; i++) {
printk ("%x ", buf[i]);
}
printk ("\n");
}
if (fifo->last_urblen != fifo->usb_packet_maxlen) { if (fifo->last_urblen != fifo->usb_packet_maxlen) {
/* the threshold mask is in the 2nd status byte */ /* the threshold mask is in the 2nd status byte */
card->threshold_mask = buf[1]; card->threshold_mask = buf[1];
@ -1990,6 +2076,7 @@ hfcsusb_init(void)
{ {
int err; int err;
debug = 0xFFFF;
printk(KERN_INFO "hfcsusb driver Rev. %s (debug=%i)\n", printk(KERN_INFO "hfcsusb driver Rev. %s (debug=%i)\n",
mISDN_getrev(hfcsusb_rev), debug); mISDN_getrev(hfcsusb_rev), debug);

View File

@ -10,7 +10,15 @@
#define DRIVER_AUTHOR "Martin Bachem / Peter Sprenger" #define DRIVER_AUTHOR "Martin Bachem / Peter Sprenger"
#define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver" #define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver"
#define VERBOSE_USB_DEBUG /* DEBUG flags, use combined value for module parameter debug=x */
#define DEBUG_HFC_INIT 0x0001
#define DEBUG_HFC_MODE 0x0002
#define DEBUG_HFC_S0_STATES 0x0004
#define DEBUG_HFC_IRQ 0x0008
#define DEBUG_HFC_FIFO_ERR 0x0010
#define DEBUG_HFC_DTRACE 0x2000
#define DEBUG_HFC_BTRACE 0x4000 /* very(!) heavy messageslog load */
#define DEBUG_HFC_FIFO 0x8000 /* very(!) heavy messageslog load */
/***********/ /***********/