Commit 088ec0cc authored by Tilman Schmidt's avatar Tilman Schmidt Committed by David S. Miller

gigaset: prepare for CAPI implementation

Reorganize the code of the Gigaset driver, moving all isdn4linux
dependencies to the source file i4l.c so that it can be replaced
by a file capi.c interfacing to Kernel CAPI instead.

Impact: refactoring, no functional change
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7ecc59c1
...@@ -119,10 +119,7 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -119,10 +119,7 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
int inputstate = bcs->inputstate; int inputstate = bcs->inputstate;
__u16 fcs = bcs->fcs; __u16 fcs = bcs->fcs;
struct sk_buff *skb = bcs->skb; struct sk_buff *skb = bcs->skb;
unsigned char error;
struct sk_buff *compskb;
int startbytes = numbytes; int startbytes = numbytes;
int l;
if (unlikely(inputstate & INS_byte_stuff)) { if (unlikely(inputstate & INS_byte_stuff)) {
inputstate &= ~INS_byte_stuff; inputstate &= ~INS_byte_stuff;
...@@ -158,8 +155,8 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -158,8 +155,8 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
#endif #endif
/* end of frame */ /* end of frame */
error = 1; gigaset_isdn_rcv_err(bcs);
gigaset_rcv_error(NULL, cs, bcs); dev_kfree_skb(skb);
} else if (!(inputstate & INS_have_data)) { /* 7E 7E */ } else if (!(inputstate & INS_have_data)) { /* 7E 7E */
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
++bcs->emptycount; ++bcs->emptycount;
...@@ -170,54 +167,39 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -170,54 +167,39 @@ static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
"7e----------------------------"); "7e----------------------------");
/* end of frame */ /* end of frame */
error = 0;
if (unlikely(fcs != PPP_GOODFCS)) { if (unlikely(fcs != PPP_GOODFCS)) {
dev_err(cs->dev, dev_err(cs->dev,
"Checksum failed, %u bytes corrupted!\n", "Checksum failed, %u bytes corrupted!\n",
skb->len); skb->len);
compskb = NULL; gigaset_isdn_rcv_err(bcs);
gigaset_rcv_error(compskb, cs, bcs); dev_kfree_skb(skb);
error = 1; } else if (likely(skb->len > 2)) {
__skb_trim(skb, skb->len - 2);
gigaset_skb_rcvd(bcs, skb);
} else { } else {
if (likely((l = skb->len) > 2)) { if (skb->len) {
skb->tail -= 2; dev_err(cs->dev,
skb->len -= 2; "invalid packet size (%d)\n", skb->len);
} else { gigaset_isdn_rcv_err(bcs);
dev_kfree_skb(skb);
skb = NULL;
inputstate |= INS_skip_frame;
if (l == 1) {
dev_err(cs->dev,
"invalid packet size (1)!\n");
error = 1;
gigaset_rcv_error(NULL,
cs, bcs);
}
}
if (likely(!(error ||
(inputstate &
INS_skip_frame)))) {
gigaset_rcv_skb(skb, cs, bcs);
} }
dev_kfree_skb(skb);
} }
} }
if (unlikely(error))
if (skb)
dev_kfree_skb(skb);
fcs = PPP_INITFCS; fcs = PPP_INITFCS;
inputstate &= ~(INS_have_data | INS_skip_frame); inputstate &= ~(INS_have_data | INS_skip_frame);
if (unlikely(bcs->ignore)) { if (unlikely(bcs->ignore)) {
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
skb = NULL; skb = NULL;
} else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) {
skb_reserve(skb, HW_HDR_LEN);
} else { } else {
dev_warn(cs->dev, skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
"could not allocate new skb\n"); if (skb != NULL) {
inputstate |= INS_skip_frame; skb_reserve(skb, cs->hw_hdr_len);
} else {
dev_warn(cs->dev,
"could not allocate new skb\n");
inputstate |= INS_skip_frame;
}
} }
break; break;
...@@ -314,18 +296,21 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes, ...@@ -314,18 +296,21 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
/* pass data up */ /* pass data up */
if (likely(inputstate & INS_have_data)) { if (likely(inputstate & INS_have_data)) {
if (likely(!(inputstate & INS_skip_frame))) { if (likely(!(inputstate & INS_skip_frame))) {
gigaset_rcv_skb(skb, cs, bcs); gigaset_skb_rcvd(bcs, skb);
} }
inputstate &= ~(INS_have_data | INS_skip_frame); inputstate &= ~(INS_have_data | INS_skip_frame);
if (unlikely(bcs->ignore)) { if (unlikely(bcs->ignore)) {
inputstate |= INS_skip_frame; inputstate |= INS_skip_frame;
skb = NULL; skb = NULL;
} else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN))
!= NULL)) {
skb_reserve(skb, HW_HDR_LEN);
} else { } else {
dev_warn(cs->dev, "could not allocate new skb\n"); skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
inputstate |= INS_skip_frame; if (skb != NULL) {
skb_reserve(skb, cs->hw_hdr_len);
} else {
dev_warn(cs->dev,
"could not allocate new skb\n");
inputstate |= INS_skip_frame;
}
} }
} }
...@@ -383,7 +368,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf) ...@@ -383,7 +368,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
/* FIXME use function pointers? */ /* FIXME use function pointers? */
if (inbuf->inputstate & INS_command) if (inbuf->inputstate & INS_command)
procbytes = cmd_loop(c, src, numbytes, inbuf); procbytes = cmd_loop(c, src, numbytes, inbuf);
else if (inbuf->bcs->proto2 == ISDN_PROTO_L2_HDLC) else if (inbuf->bcs->proto2 == L2_HDLC)
procbytes = hdlc_loop(c, src, numbytes, inbuf); procbytes = hdlc_loop(c, src, numbytes, inbuf);
else else
procbytes = iraw_loop(c, src, numbytes, inbuf); procbytes = iraw_loop(c, src, numbytes, inbuf);
...@@ -440,16 +425,16 @@ EXPORT_SYMBOL_GPL(gigaset_m10x_input); ...@@ -440,16 +425,16 @@ EXPORT_SYMBOL_GPL(gigaset_m10x_input);
/* == data output ========================================================== */ /* == data output ========================================================== */
/* Encoding of a PPP packet into an octet stuffed HDLC frame /*
* with FCS, opening and closing flags. * Encode a data packet into an octet stuffed HDLC frame with FCS,
* opening and closing flags, preserving headroom data.
* parameters: * parameters:
* skb skb containing original packet (freed upon return) * skb skb containing original packet (freed upon return)
* head number of headroom bytes to allocate in result skb * headroom number of headroom bytes to preserve
* tail number of tailroom bytes to allocate in result skb
* Return value: * Return value:
* pointer to newly allocated skb containing the result frame * pointer to newly allocated skb containing the result frame
*/ */
static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail) static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom)
{ {
struct sk_buff *hdlc_skb; struct sk_buff *hdlc_skb;
__u16 fcs; __u16 fcs;
...@@ -471,16 +456,17 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail) ...@@ -471,16 +456,17 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
/* size of new buffer: original size + number of stuffing bytes /* size of new buffer: original size + number of stuffing bytes
* + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes
* + room for acknowledgement header
*/ */
hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + tail + head); hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + headroom);
if (!hdlc_skb) { if (!hdlc_skb) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NULL; return NULL;
} }
skb_reserve(hdlc_skb, head);
/* Copy acknowledge request into new skb */ /* Copy acknowledgement header into new skb */
memcpy(hdlc_skb->head, skb->head, 2); skb_reserve(hdlc_skb, headroom);
memcpy(hdlc_skb->head, skb->head, headroom);
/* Add flag sequence in front of everything.. */ /* Add flag sequence in front of everything.. */
*(skb_put(hdlc_skb, 1)) = PPP_FLAG; *(skb_put(hdlc_skb, 1)) = PPP_FLAG;
...@@ -515,15 +501,16 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail) ...@@ -515,15 +501,16 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
return hdlc_skb; return hdlc_skb;
} }
/* Encoding of a raw packet into an octet stuffed bit inverted frame /*
* Encode a data packet into an octet stuffed raw bit inverted frame,
* preserving headroom data.
* parameters: * parameters:
* skb skb containing original packet (freed upon return) * skb skb containing original packet (freed upon return)
* head number of headroom bytes to allocate in result skb * headroom number of headroom bytes to preserve
* tail number of tailroom bytes to allocate in result skb
* Return value: * Return value:
* pointer to newly allocated skb containing the result frame * pointer to newly allocated skb containing the result frame
*/ */
static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail) static struct sk_buff *iraw_encode(struct sk_buff *skb, int headroom)
{ {
struct sk_buff *iraw_skb; struct sk_buff *iraw_skb;
unsigned char c; unsigned char c;
...@@ -531,12 +518,15 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail) ...@@ -531,12 +518,15 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
int len; int len;
/* worst case: every byte must be stuffed */ /* worst case: every byte must be stuffed */
iraw_skb = dev_alloc_skb(2*skb->len + tail + head); iraw_skb = dev_alloc_skb(2*skb->len + headroom);
if (!iraw_skb) { if (!iraw_skb) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NULL; return NULL;
} }
skb_reserve(iraw_skb, head);
/* Copy acknowledgement header into new skb */
skb_reserve(iraw_skb, headroom);
memcpy(iraw_skb->head, skb->head, headroom);
cp = skb->data; cp = skb->data;
len = skb->len; len = skb->len;
...@@ -555,8 +545,10 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail) ...@@ -555,8 +545,10 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
* @bcs: B channel descriptor structure. * @bcs: B channel descriptor structure.
* @skb: data to send. * @skb: data to send.
* *
* Called by i4l.c to encode and queue an skb for sending, and start * Called by LL to encode and queue an skb for sending, and start
* transmission if necessary. * transmission if necessary.
* Once the payload data has been transmitted completely, gigaset_skb_sent()
* will be called with the first cs->hw_hdr_len bytes of skb->head preserved.
* *
* Return value: * Return value:
* number of bytes accepted for sending (skb->len) if ok, * number of bytes accepted for sending (skb->len) if ok,
...@@ -567,10 +559,10 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb) ...@@ -567,10 +559,10 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
unsigned len = skb->len; unsigned len = skb->len;
unsigned long flags; unsigned long flags;
if (bcs->proto2 == ISDN_PROTO_L2_HDLC) if (bcs->proto2 == L2_HDLC)
skb = HDLC_Encode(skb, HW_HDR_LEN, 0); skb = HDLC_Encode(skb, bcs->cs->hw_hdr_len);
else else
skb = iraw_encode(skb, HW_HDR_LEN, 0); skb = iraw_encode(skb, bcs->cs->hw_hdr_len);
if (!skb) { if (!skb) {
dev_err(bcs->cs->dev, dev_err(bcs->cs->dev,
"unable to allocate memory for encoding!\n"); "unable to allocate memory for encoding!\n");
......
...@@ -911,7 +911,7 @@ static int starturbs(struct bc_state *bcs) ...@@ -911,7 +911,7 @@ static int starturbs(struct bc_state *bcs)
int rc; int rc;
/* initialize L2 reception */ /* initialize L2 reception */
if (bcs->proto2 == ISDN_PROTO_L2_HDLC) if (bcs->proto2 == L2_HDLC)
bcs->inputstate |= INS_flag_hunt; bcs->inputstate |= INS_flag_hunt;
/* submit all isochronous input URBs */ /* submit all isochronous input URBs */
...@@ -1064,7 +1064,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) ...@@ -1064,7 +1064,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
"%s: buffer busy at frame %d", "%s: buffer busy at frame %d",
__func__, nframe); __func__, nframe);
/* tasklet will be restarted from /* tasklet will be restarted from
gigaset_send_skb() */ gigaset_isoc_send_skb() */
} else { } else {
dev_err(ucx->bcs->cs->dev, dev_err(ucx->bcs->cs->dev,
"%s: buffer error %d at frame %d\n", "%s: buffer error %d at frame %d\n",
......
...@@ -463,6 +463,12 @@ void gigaset_freecs(struct cardstate *cs) ...@@ -463,6 +463,12 @@ void gigaset_freecs(struct cardstate *cs)
switch (cs->cs_init) { switch (cs->cs_init) {
default: default:
/* clear B channel structures */
for (i = 0; i < cs->channels; ++i) {
gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i);
gigaset_freebcs(cs->bcs + i);
}
/* clear device sysfs */ /* clear device sysfs */
gigaset_free_dev_sysfs(cs); gigaset_free_dev_sysfs(cs);
...@@ -477,22 +483,16 @@ void gigaset_freecs(struct cardstate *cs) ...@@ -477,22 +483,16 @@ void gigaset_freecs(struct cardstate *cs)
case 2: /* error in initcshw */ case 2: /* error in initcshw */
/* Deregister from LL */ /* Deregister from LL */
make_invalid(cs, VALID_ID); make_invalid(cs, VALID_ID);
gig_dbg(DEBUG_INIT, "clearing iif"); gigaset_isdn_unregister(cs);
gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD);
/* fall through */ /* fall through */
case 1: /* error when regestering to LL */ case 1: /* error when registering to LL */
gig_dbg(DEBUG_INIT, "clearing at_state"); gig_dbg(DEBUG_INIT, "clearing at_state");
clear_at_state(&cs->at_state); clear_at_state(&cs->at_state);
dealloc_at_states(cs); dealloc_at_states(cs);
/* fall through */ /* fall through */
case 0: /* error in one call to initbcs */ case 0: /* error in basic setup */
for (i = 0; i < cs->channels; ++i) {
gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i);
gigaset_freebcs(cs->bcs + i);
}
clear_events(cs); clear_events(cs);
gig_dbg(DEBUG_INIT, "freeing inbuf"); gig_dbg(DEBUG_INIT, "freeing inbuf");
kfree(cs->inbuf); kfree(cs->inbuf);
...@@ -620,11 +620,14 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, ...@@ -620,11 +620,14 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
if (cs->ignoreframes) { if (cs->ignoreframes) {
bcs->inputstate |= INS_skip_frame; bcs->inputstate |= INS_skip_frame;
bcs->skb = NULL; bcs->skb = NULL;
} else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) } else {
skb_reserve(bcs->skb, HW_HDR_LEN); bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
else { if (bcs->skb != NULL)
pr_err("out of memory\n"); skb_reserve(bcs->skb, cs->hw_hdr_len);
bcs->inputstate |= INS_skip_frame; else {
pr_err("out of memory\n");
bcs->inputstate |= INS_skip_frame;
}
} }
bcs->channel = channel; bcs->channel = channel;
...@@ -726,14 +729,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -726,14 +729,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->mode = M_UNKNOWN; cs->mode = M_UNKNOWN;
cs->mstate = MS_UNINITIALIZED; cs->mstate = MS_UNINITIALIZED;
for (i = 0; i < channels; ++i) {
gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i);
if (!gigaset_initbcs(cs->bcs + i, cs, i)) {
pr_err("could not allocate channel %d data\n", i);
goto error;
}
}
++cs->cs_init; ++cs->cs_init;
gig_dbg(DEBUG_INIT, "setting up at_state"); gig_dbg(DEBUG_INIT, "setting up at_state");
...@@ -758,7 +753,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -758,7 +753,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->cmdbytes = 0; cs->cmdbytes = 0;
gig_dbg(DEBUG_INIT, "setting up iif"); gig_dbg(DEBUG_INIT, "setting up iif");
if (!gigaset_register_to_LL(cs, modulename)) { if (!gigaset_isdn_register(cs, modulename)) {
pr_err("error registering ISDN device\n"); pr_err("error registering ISDN device\n");
goto error; goto error;
} }
...@@ -777,6 +772,15 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -777,6 +772,15 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
/* set up device sysfs */ /* set up device sysfs */
gigaset_init_dev_sysfs(cs); gigaset_init_dev_sysfs(cs);
/* set up channel data structures */
for (i = 0; i < channels; ++i) {
gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i);
if (!gigaset_initbcs(cs->bcs + i, cs, i)) {
pr_err("could not allocate channel %d data\n", i);
goto error;
}
}
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
cs->running = 1; cs->running = 1;
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
......
...@@ -127,7 +127,6 @@ ...@@ -127,7 +127,6 @@
#define ACT_NOTIFY_BC_UP 39 #define ACT_NOTIFY_BC_UP 39
#define ACT_DIAL 40 #define ACT_DIAL 40
#define ACT_ACCEPT 41 #define ACT_ACCEPT 41
#define ACT_PROTO_L2 42
#define ACT_HUP 43 #define ACT_HUP 43
#define ACT_IF_LOCK 44 #define ACT_IF_LOCK 44
#define ACT_START 45 #define ACT_START 45
...@@ -365,8 +364,6 @@ struct reply_t gigaset_tab_cid[] = ...@@ -365,8 +364,6 @@ struct reply_t gigaset_tab_cid[] =
{EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME {EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME
/* misc. */ /* misc. */
{EV_PROTO_L2, -1, -1, -1, -1,-1, {ACT_PROTO_L2}}, //FIXME
{RSP_ZCON, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME {RSP_ZCON, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME
{RSP_ZCCR, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME {RSP_ZCCR, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME
{RSP_ZAOC, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME {RSP_ZAOC, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME
...@@ -714,7 +711,7 @@ static void disconnect(struct at_state_t **at_state_p) ...@@ -714,7 +711,7 @@ static void disconnect(struct at_state_t **at_state_p)
/* notify LL */ /* notify LL */
if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) { if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) {
bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL); bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL);
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DHUP); gigaset_isdn_hupD(bcs);
} }
} else { } else {
/* no B channel assigned: just deallocate */ /* no B channel assigned: just deallocate */
...@@ -872,12 +869,12 @@ static void bchannel_down(struct bc_state *bcs) ...@@ -872,12 +869,12 @@ static void bchannel_down(struct bc_state *bcs)
{ {
if (bcs->chstate & CHS_B_UP) { if (bcs->chstate & CHS_B_UP) {
bcs->chstate &= ~CHS_B_UP; bcs->chstate &= ~CHS_B_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BHUP); gigaset_isdn_hupB(bcs);
} }
if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) { if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) {
bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL); bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL);
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DHUP); gigaset_isdn_hupD(bcs);
} }
gigaset_free_channel(bcs); gigaset_free_channel(bcs);
...@@ -894,15 +891,16 @@ static void bchannel_up(struct bc_state *bcs) ...@@ -894,15 +891,16 @@ static void bchannel_up(struct bc_state *bcs)
} }
bcs->chstate |= CHS_B_UP; bcs->chstate |= CHS_B_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BCONN); gigaset_isdn_connB(bcs);
} }
static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_index) static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_index)
{ {
struct bc_state *bcs = at_state->bcs; struct bc_state *bcs = at_state->bcs;
struct cardstate *cs = at_state->cs; struct cardstate *cs = at_state->cs;
int retval; char **commands = data;
unsigned long flags; unsigned long flags;
int i;
bcs->chstate |= CHS_NOTIFY_LL; bcs->chstate |= CHS_NOTIFY_LL;
...@@ -913,10 +911,10 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind ...@@ -913,10 +911,10 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind
} }
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
retval = gigaset_isdn_setup_dial(at_state, data); for (i = 0; i < AT_NUM; ++i) {
if (retval != 0) kfree(bcs->commands[i]);
goto error; bcs->commands[i] = commands[i];
}
at_state->pending_commands |= PC_CID; at_state->pending_commands |= PC_CID;
gig_dbg(DEBUG_CMD, "Scheduling PC_CID"); gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
...@@ -924,6 +922,10 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind ...@@ -924,6 +922,10 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind
return; return;
error: error:
for (i = 0; i < AT_NUM; ++i) {
kfree(commands[i]);
commands[i] = NULL;
}
at_state->pending_commands |= PC_NOCID; at_state->pending_commands |= PC_NOCID;
gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID"); gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID");
cs->commands_pending = 1; cs->commands_pending = 1;
...@@ -933,20 +935,31 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind ...@@ -933,20 +935,31 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind
static void start_accept(struct at_state_t *at_state) static void start_accept(struct at_state_t *at_state)
{ {
struct cardstate *cs = at_state->cs; struct cardstate *cs = at_state->cs;
int retval; struct bc_state *bcs = at_state->bcs;
int i;
retval = gigaset_isdn_setup_accept(at_state); for (i = 0; i < AT_NUM; ++i) {
kfree(bcs->commands[i]);
bcs->commands[i] = NULL;
}
if (retval == 0) { bcs->commands[AT_PROTO] = kmalloc(9, GFP_ATOMIC);
at_state->pending_commands |= PC_ACCEPT; bcs->commands[AT_ISO] = kmalloc(9, GFP_ATOMIC);
gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT"); if (!bcs->commands[AT_PROTO] || !bcs->commands[AT_ISO]) {
cs->commands_pending = 1; dev_err(at_state->cs->dev, "out of memory\n");
} else {
/* error reset */ /* error reset */
at_state->pending_commands |= PC_HUP; at_state->pending_commands |= PC_HUP;
gig_dbg(DEBUG_CMD, "Scheduling PC_HUP"); gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
cs->commands_pending = 1; cs->commands_pending = 1;
return;
} }
snprintf(bcs->commands[AT_PROTO], 9, "^SBPR=%u\r", bcs->proto2);
snprintf(bcs->commands[AT_ISO], 9, "^SISO=%u\r", bcs->channel + 1);
at_state->pending_commands |= PC_ACCEPT;
gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
cs->commands_pending = 1;
} }
static void do_start(struct cardstate *cs) static void do_start(struct cardstate *cs)
...@@ -957,7 +970,7 @@ static void do_start(struct cardstate *cs) ...@@ -957,7 +970,7 @@ static void do_start(struct cardstate *cs)
schedule_init(cs, MS_INIT); schedule_init(cs, MS_INIT);
cs->isdn_up = 1; cs->isdn_up = 1;
gigaset_i4l_cmd(cs, ISDN_STAT_RUN); gigaset_isdn_start(cs);
// FIXME: not in locked mode // FIXME: not in locked mode
// FIXME 2: only after init sequence // FIXME 2: only after init sequence
...@@ -975,7 +988,7 @@ static void finish_shutdown(struct cardstate *cs) ...@@ -975,7 +988,7 @@ static void finish_shutdown(struct cardstate *cs)
/* Tell the LL that the device is not available .. */ /* Tell the LL that the device is not available .. */
if (cs->isdn_up) { if (cs->isdn_up) {
cs->isdn_up = 0; cs->isdn_up = 0;
gigaset_i4l_cmd(cs, ISDN_STAT_STOP); gigaset_isdn_stop(cs);
} }
/* The rest is done by cleanup_cs () in user mode. */ /* The rest is done by cleanup_cs () in user mode. */
...@@ -1276,7 +1289,7 @@ static void do_action(int action, struct cardstate *cs, ...@@ -1276,7 +1289,7 @@ static void do_action(int action, struct cardstate *cs,
break; break;
} }
bcs->chstate |= CHS_D_UP; bcs->chstate |= CHS_D_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN); gigaset_isdn_connD(bcs);
cs->ops->init_bchannel(bcs); cs->ops->init_bchannel(bcs);
break; break;
case ACT_DLE1: case ACT_DLE1:
...@@ -1284,7 +1297,7 @@ static void do_action(int action, struct cardstate *cs, ...@@ -1284,7 +1297,7 @@ static void do_action(int action, struct cardstate *cs,
bcs = cs->bcs + cs->curchannel; bcs = cs->bcs + cs->curchannel;
bcs->chstate |= CHS_D_UP; bcs->chstate |= CHS_D_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN); gigaset_isdn_connD(bcs);
cs->ops->init_bchannel(bcs); cs->ops->init_bchannel(bcs);
break; break;
case ACT_FAKEHUP: case ACT_FAKEHUP:
...@@ -1474,11 +1487,6 @@ static void do_action(int action, struct cardstate *cs, ...@@ -1474,11 +1487,6 @@ static void do_action(int action, struct cardstate *cs,
case ACT_ACCEPT: case ACT_ACCEPT:
start_accept(at_state); start_accept(at_state);
break; break;
case ACT_PROTO_L2:
gig_dbg(DEBUG_CMD, "set protocol to %u",
(unsigned) ev->parameter);
at_state->bcs->proto2 = ev->parameter;
break;
case ACT_HUP: case ACT_HUP:
at_state->pending_commands |= PC_HUP; at_state->pending_commands |= PC_HUP;
cs->commands_pending = 1; cs->commands_pending = 1;
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/isdnif.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -40,7 +39,6 @@ ...@@ -40,7 +39,6 @@
#define MAX_REC_PARAMS 10 /* Max. number of params in response string */ #define MAX_REC_PARAMS 10 /* Max. number of params in response string */
#define MAX_RESP_SIZE 512 /* Max. size of a response string */ #define MAX_RESP_SIZE 512 /* Max. size of a response string */
#define HW_HDR_LEN 2 /* Header size used to store ack info */
#define MAX_EVENTS 64 /* size of event queue */ #define MAX_EVENTS 64 /* size of event queue */
...@@ -216,7 +214,6 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, ...@@ -216,7 +214,6 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
#define EV_START -110 #define EV_START -110
#define EV_STOP -111 #define EV_STOP -111
#define EV_IF_LOCK -112 #define EV_IF_LOCK -112
#define EV_PROTO_L2 -113
#define EV_ACCEPT -114 #define EV_ACCEPT -114
#define EV_DIAL -115 #define EV_DIAL -115
#define EV_HUP -116 #define EV_HUP -116
...@@ -259,6 +256,11 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, ...@@ -259,6 +256,11 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
#define SM_LOCKED 0 #define SM_LOCKED 0
#define SM_ISDN 1 /* default */ #define SM_ISDN 1 /* default */
/* layer 2 protocols (AT^SBPR=...) */
#define L2_BITSYNC 0
#define L2_HDLC 1
#define L2_VOICE 2
struct gigaset_ops; struct gigaset_ops;
struct gigaset_driver; struct gigaset_driver;
...@@ -395,7 +397,7 @@ struct bc_state { ...@@ -395,7 +397,7 @@ struct bc_state {
unsigned chstate; /* bitmap (CHS_*) */ unsigned chstate; /* bitmap (CHS_*) */
int ignore; int ignore;
unsigned proto2; /* Layer 2 protocol (ISDN_PROTO_L2_*) */ unsigned proto2; /* layer 2 protocol (L2_*) */
char *commands[AT_NUM]; /* see AT_XXXX */ char *commands[AT_NUM]; /* see AT_XXXX */
#ifdef CONFIG_GIGASET_DEBUG #ifdef CONFIG_GIGASET_DEBUG
...@@ -456,12 +458,13 @@ struct cardstate { ...@@ -456,12 +458,13 @@ struct cardstate {
unsigned running; /* !=0 if events are handled */ unsigned running; /* !=0 if events are handled */
unsigned connected; /* !=0 if hardware is connected */ unsigned connected; /* !=0 if hardware is connected */
unsigned isdn_up; /* !=0 after ISDN_STAT_RUN */ unsigned isdn_up; /* !=0 after gigaset_isdn_start() */
unsigned cidmode; unsigned cidmode;
int myid; /* id for communication with LL */ int myid; /* id for communication with LL */
isdn_if iif; void *iif; /* LL interface structure */
unsigned short hw_hdr_len; /* headroom needed in data skbs */
struct reply_t *tabnocid; struct reply_t *tabnocid;
struct reply_t *tabcid; struct reply_t *tabcid;
...@@ -616,7 +619,9 @@ struct gigaset_ops { ...@@ -616,7 +619,9 @@ struct gigaset_ops {
int (*baud_rate)(struct cardstate *cs, unsigned cflag); int (*baud_rate)(struct cardstate *cs, unsigned cflag);
int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag); int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag);
/* Called from i4l.c to put an skb into the send-queue. */ /* Called from LL interface to put an skb into the send-queue.
* After sending is completed, gigaset_skb_sent() must be called
* with the first cs->hw_hdr_len bytes of skb->head preserved. */
int (*send_skb)(struct bc_state *bcs, struct sk_buff *skb); int (*send_skb)(struct bc_state *bcs, struct sk_buff *skb);
/* Called from ev-layer.c to process a block of data /* Called from ev-layer.c to process a block of data
...@@ -638,8 +643,7 @@ struct gigaset_ops { ...@@ -638,8 +643,7 @@ struct gigaset_ops {
* Functions implemented in asyncdata.c * Functions implemented in asyncdata.c
*/ */
/* Called from i4l.c to put an skb into the send-queue. /* Called from LL interface to put an skb into the send queue. */
* After sending gigaset_skb_sent() should be called. */
int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb); int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb);
/* Called from ev-layer.c to process a block of data /* Called from ev-layer.c to process a block of data
...@@ -650,8 +654,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf); ...@@ -650,8 +654,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf);
* Functions implemented in isocdata.c * Functions implemented in isocdata.c
*/ */
/* Called from i4l.c to put an skb into the send-queue. /* Called from LL interface to put an skb into the send queue. */
* After sending gigaset_skb_sent() should be called. */
int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb); int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb);
/* Called from ev-layer.c to process a block of data /* Called from ev-layer.c to process a block of data
...@@ -674,36 +677,26 @@ void gigaset_isowbuf_init(struct isowbuf_t *iwb, unsigned char idle); ...@@ -674,36 +677,26 @@ void gigaset_isowbuf_init(struct isowbuf_t *iwb, unsigned char idle);
int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size); int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size);
/* =========================================================================== /* ===========================================================================
* Functions implemented in i4l.c/gigaset.h * Functions implemented in LL interface
*/ */
/* Called by gigaset_initcs() for setting up with the isdn4linux subsystem */ /* Called from common.c for setting up/shutting down with the ISDN subsystem */
int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid); int gigaset_isdn_register(struct cardstate *cs, const char *isdnid);
void gigaset_isdn_unregister(struct cardstate *cs);
/* Called from xxx-gigaset.c to indicate completion of sending an skb */ /* Called from hardware module to indicate completion of an skb */
void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb); void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb);
void gigaset_skb_rcvd(struct bc_state *bcs, struct sk_buff *skb);
void gigaset_isdn_rcv_err(struct bc_state *bcs);
/* Called from common.c/ev-layer.c to indicate events relevant to the LL */ /* Called from common.c/ev-layer.c to indicate events relevant to the LL */
void gigaset_isdn_start(struct cardstate *cs);
void gigaset_isdn_stop(struct cardstate *cs);
int gigaset_isdn_icall(struct at_state_t *at_state); int gigaset_isdn_icall(struct at_state_t *at_state);
int gigaset_isdn_setup_accept(struct at_state_t *at_state); void gigaset_isdn_connD(struct bc_state *bcs);
int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data); void gigaset_isdn_hupD(struct bc_state *bcs);
void gigaset_isdn_connB(struct bc_state *bcs);
void gigaset_i4l_cmd(struct cardstate *cs, int cmd); void gigaset_isdn_hupB(struct bc_state *bcs);
void gigaset_i4l_channel_cmd(struct bc_state *bcs, int cmd);
static inline void gigaset_isdn_rcv_err(struct bc_state *bcs)
{
isdn_ctrl response;
/* error -> LL */
gig_dbg(DEBUG_CMD, "sending L1ERR");
response.driver = bcs->cs->myid;
response.command = ISDN_STAT_L1ERR;
response.arg = bcs->channel;
response.parm.errcode = ISDN_STAT_L1ERR_RECV;
bcs->cs->iif.statcallb(&response);
}
/* =========================================================================== /* ===========================================================================
* Functions implemented in ev-layer.c * Functions implemented in ev-layer.c
...@@ -816,35 +809,6 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs) ...@@ -816,35 +809,6 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs)
/* handling routines for sk_buff */ /* handling routines for sk_buff */
/* ============================= */ /* ============================= */
/* pass received skb to LL
* Warning: skb must not be accessed anymore!
*/
static inline void gigaset_rcv_skb(struct sk_buff *skb,
struct cardstate *cs,
struct bc_state *bcs)
{
cs->iif.rcvcallb_skb(cs->myid, bcs->channel, skb);
bcs->trans_down++;
}
/* handle reception of corrupted skb
* Warning: skb must not be accessed anymore!
*/
static inline void gigaset_rcv_error(struct sk_buff *procskb,
struct cardstate *cs,
struct bc_state *bcs)
{
if (procskb)
dev_kfree_skb(procskb);
if (bcs->ignore)
--bcs->ignore;
else {
++bcs->corrupted;
gigaset_isdn_rcv_err(bcs);
}
}
/* append received bytes to inbuf */ /* append received bytes to inbuf */
int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src, int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
unsigned numbytes); unsigned numbytes);
......
This diff is collapsed.
...@@ -500,7 +500,7 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len) ...@@ -500,7 +500,7 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len)
int result; int result;
switch (bcs->proto2) { switch (bcs->proto2) {
case ISDN_PROTO_L2_HDLC: case L2_HDLC:
result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len); result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len);
gig_dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d", gig_dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d",
__func__, len, result); __func__, len, result);
...@@ -542,8 +542,9 @@ static inline void hdlc_flush(struct bc_state *bcs) ...@@ -542,8 +542,9 @@ static inline void hdlc_flush(struct bc_state *bcs)
if (likely(bcs->skb != NULL)) if (likely(bcs->skb != NULL))
skb_trim(bcs->skb, 0); skb_trim(bcs->skb, 0);
else if (!bcs->ignore) { else if (!bcs->ignore) {
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) bcs->skb = dev_alloc_skb(SBUFSIZE + bcs->cs->hw_hdr_len);
skb_reserve(bcs->skb, HW_HDR_LEN); if (bcs->skb)
skb_reserve(bcs->skb, bcs->cs->hw_hdr_len);
else else
dev_err(bcs->cs->dev, "could not allocate skb\n"); dev_err(bcs->cs->dev, "could not allocate skb\n");
} }
...@@ -557,7 +558,9 @@ static inline void hdlc_flush(struct bc_state *bcs) ...@@ -557,7 +558,9 @@ static inline void hdlc_flush(struct bc_state *bcs)
*/ */
static inline void hdlc_done(struct bc_state *bcs) static inline void hdlc_done(struct bc_state *bcs)
{ {
struct cardstate *cs = bcs->cs;
struct sk_buff *procskb; struct sk_buff *procskb;
unsigned int len;
if (unlikely(bcs->ignore)) { if (unlikely(bcs->ignore)) {
bcs->ignore--; bcs->ignore--;
...@@ -568,32 +571,33 @@ static inline void hdlc_done(struct bc_state *bcs) ...@@ -568,32 +571,33 @@ static inline void hdlc_done(struct bc_state *bcs)
if ((procskb = bcs->skb) == NULL) { if ((procskb = bcs->skb) == NULL) {
/* previous error */ /* previous error */
gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__); gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
gigaset_rcv_error(NULL, bcs->cs, bcs); gigaset_isdn_rcv_err(bcs);
} else if (procskb->len < 2) { } else if (procskb->len < 2) {
dev_notice(bcs->cs->dev, "received short frame (%d octets)\n", dev_notice(cs->dev, "received short frame (%d octets)\n",
procskb->len); procskb->len);
bcs->hw.bas->runts++; bcs->hw.bas->runts++;
gigaset_rcv_error(procskb, bcs->cs, bcs); dev_kfree_skb(procskb);
gigaset_isdn_rcv_err(bcs);
} else if (bcs->fcs != PPP_GOODFCS) { } else if (bcs->fcs != PPP_GOODFCS) {
dev_notice(bcs->cs->dev, "frame check error (0x%04x)\n", dev_notice(cs->dev, "frame check error (0x%04x)\n", bcs->fcs);
bcs->fcs);
bcs->hw.bas->fcserrs++; bcs->hw.bas->fcserrs++;
gigaset_rcv_error(procskb, bcs->cs, bcs); dev_kfree_skb(procskb);
gigaset_isdn_rcv_err(bcs);
} else { } else {
procskb->len -= 2; /* subtract FCS */ len = procskb->len;
procskb->tail -= 2; __skb_trim(procskb, len -= 2); /* subtract FCS */
gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)", gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)", __func__, len);
__func__, procskb->len);
dump_bytes(DEBUG_STREAM_DUMP, dump_bytes(DEBUG_STREAM_DUMP,
"rcv data", procskb->data, procskb->len); "rcv data", procskb->data, len);
bcs->hw.bas->goodbytes += procskb->len; bcs->hw.bas->goodbytes += len;
gigaset_rcv_skb(procskb, bcs->cs, bcs); gigaset_skb_rcvd(bcs, procskb);
} }
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
skb_reserve(bcs->skb, HW_HDR_LEN); if (bcs->skb)
skb_reserve(bcs->skb, cs->hw_hdr_len);
else else
dev_err(bcs->cs->dev, "could not allocate skb\n"); dev_err(cs->dev, "could not allocate skb\n");
bcs->fcs = PPP_INITFCS; bcs->fcs = PPP_INITFCS;
} }
...@@ -610,12 +614,8 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits) ...@@ -610,12 +614,8 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits); dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits);
bcs->hw.bas->alignerrs++; bcs->hw.bas->alignerrs++;
gigaset_rcv_error(bcs->skb, bcs->cs, bcs); gigaset_isdn_rcv_err(bcs);
__skb_trim(bcs->skb, 0);
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN);
else
dev_err(bcs->cs->dev, "could not allocate skb\n");
bcs->fcs = PPP_INITFCS; bcs->fcs = PPP_INITFCS;
} }
...@@ -648,8 +648,8 @@ static const unsigned char bitcounts[256] = { ...@@ -648,8 +648,8 @@ static const unsigned char bitcounts[256] = {
/* hdlc_unpack /* hdlc_unpack
* perform HDLC frame processing (bit unstuffing, flag detection, FCS calculation) * perform HDLC frame processing (bit unstuffing, flag detection, FCS calculation)
* on a sequence of received data bytes (8 bits each, LSB first) * on a sequence of received data bytes (8 bits each, LSB first)
* pass on successfully received, complete frames as SKBs via gigaset_rcv_skb * pass on successfully received, complete frames as SKBs via gigaset_skb_rcvd
* notify of errors via gigaset_rcv_error * notify of errors via gigaset_isdn_rcv_err
* tally frames, errors etc. in BC structure counters * tally frames, errors etc. in BC structure counters
* parameters: * parameters:
* src received data * src received data
...@@ -841,7 +841,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -841,7 +841,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
} }
/* trans_receive /* trans_receive
* pass on received USB frame transparently as SKB via gigaset_rcv_skb * pass on received USB frame transparently as SKB via gigaset_skb_rcvd
* invert bytes * invert bytes
* tally frames, errors etc. in BC structure counters * tally frames, errors etc. in BC structure counters
* parameters: * parameters:
...@@ -852,6 +852,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -852,6 +852,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
static inline void trans_receive(unsigned char *src, unsigned count, static inline void trans_receive(unsigned char *src, unsigned count,
struct bc_state *bcs) struct bc_state *bcs)
{ {
struct cardstate *cs = bcs->cs;
struct sk_buff *skb; struct sk_buff *skb;
int dobytes; int dobytes;
unsigned char *dst; unsigned char *dst;
...@@ -862,12 +863,12 @@ static inline void trans_receive(unsigned char *src, unsigned count, ...@@ -862,12 +863,12 @@ static inline void trans_receive(unsigned char *src, unsigned count,
return; return;
} }
if (unlikely((skb = bcs->skb) == NULL)) { if (unlikely((skb = bcs->skb) == NULL)) {
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); bcs->skb = skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
if (!skb) { if (!skb) {
dev_err(bcs->cs->dev, "could not allocate skb\n"); dev_err(cs->dev, "could not allocate skb\n");
return; return;
} }
skb_reserve(skb, HW_HDR_LEN); skb_reserve(skb, cs->hw_hdr_len);
} }
bcs->hw.bas->goodbytes += skb->len; bcs->hw.bas->goodbytes += skb->len;
dobytes = TRANSBUFSIZE - skb->len; dobytes = TRANSBUFSIZE - skb->len;
...@@ -881,14 +882,14 @@ static inline void trans_receive(unsigned char *src, unsigned count, ...@@ -881,14 +882,14 @@ static inline void trans_receive(unsigned char *src, unsigned count,
if (dobytes == 0) { if (dobytes == 0) {
dump_bytes(DEBUG_STREAM_DUMP, dump_bytes(DEBUG_STREAM_DUMP,
"rcv data", skb->data, skb->len); "rcv data", skb->data, skb->len);
gigaset_rcv_skb(skb, bcs->cs, bcs); gigaset_skb_rcvd(bcs, skb);
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); bcs->skb = skb =
dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
if (!skb) { if (!skb) {
dev_err(bcs->cs->dev, dev_err(cs->dev, "could not allocate skb\n");
"could not allocate skb\n");
return; return;
} }
skb_reserve(bcs->skb, HW_HDR_LEN); skb_reserve(skb, cs->hw_hdr_len);
dobytes = TRANSBUFSIZE; dobytes = TRANSBUFSIZE;
} }
} }
...@@ -897,7 +898,7 @@ static inline void trans_receive(unsigned char *src, unsigned count, ...@@ -897,7 +898,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs) void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs)
{ {
switch (bcs->proto2) { switch (bcs->proto2) {
case ISDN_PROTO_L2_HDLC: case L2_HDLC:
hdlc_unpack(src, count, bcs); hdlc_unpack(src, count, bcs);
break; break;
default: /* assume transparent */ default: /* assume transparent */
...@@ -981,8 +982,10 @@ void gigaset_isoc_input(struct inbuf_t *inbuf) ...@@ -981,8 +982,10 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
* @bcs: B channel descriptor structure. * @bcs: B channel descriptor structure.
* @skb: data to send. * @skb: data to send.
* *
* Called by i4l.c to queue an skb for sending, and start transmission if * Called by LL to queue an skb for sending, and start transmission if
* necessary. * necessary.
* Once the payload data has been transmitted completely, gigaset_skb_sent()
* will be called with the first cs->hw_hdr_len bytes of skb->head preserved.
* *
* Return value: * Return value:
* number of bytes accepted for sending (skb->len) if ok, * number of bytes accepted for sending (skb->len) if ok,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment