Commit a134be24 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

o LAPB: use refcounts and rwlock to protect lapb_cb and list

Also some CodingStyle code reformatting.
Ah, killed the typedef for lapb_cb.
parent 2150b1f5
...@@ -78,8 +78,8 @@ struct lapb_frame { ...@@ -78,8 +78,8 @@ struct lapb_frame {
/* /*
* The per LAPB connection control structure. * The per LAPB connection control structure.
*/ */
typedef struct lapb_cb { struct lapb_cb {
struct lapb_cb *next; struct list_head node;
void *token; void *token;
/* Link status fields */ /* Link status fields */
...@@ -100,43 +100,45 @@ typedef struct lapb_cb { ...@@ -100,43 +100,45 @@ typedef struct lapb_cb {
/* FRMR control information */ /* FRMR control information */
struct lapb_frame frmr_data; struct lapb_frame frmr_data;
unsigned char frmr_type; unsigned char frmr_type;
} lapb_cb;
atomic_t refcnt;
};
/* lapb_iface.c */ /* lapb_iface.c */
extern void lapb_connect_confirmation(lapb_cb *, int); extern void lapb_connect_confirmation(struct lapb_cb *lapb, int);
extern void lapb_connect_indication(lapb_cb *, int); extern void lapb_connect_indication(struct lapb_cb *lapb, int);
extern void lapb_disconnect_confirmation(lapb_cb *, int); extern void lapb_disconnect_confirmation(struct lapb_cb *lapb, int);
extern void lapb_disconnect_indication(lapb_cb *, int); extern void lapb_disconnect_indication(struct lapb_cb *lapb, int);
extern int lapb_data_indication(lapb_cb *, struct sk_buff *); extern int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *);
extern int lapb_data_transmit(lapb_cb *, struct sk_buff *); extern int lapb_data_transmit(struct lapb_cb *lapb, struct sk_buff *);
/* lapb_in.c */ /* lapb_in.c */
extern void lapb_data_input(lapb_cb *, struct sk_buff *); extern void lapb_data_input(struct lapb_cb *lapb, struct sk_buff *);
/* lapb_out.c */ /* lapb_out.c */
extern void lapb_kick(lapb_cb *); extern void lapb_kick(struct lapb_cb *lapb);
extern void lapb_transmit_buffer(lapb_cb *, struct sk_buff *, int); extern void lapb_transmit_buffer(struct lapb_cb *lapb, struct sk_buff *, int);
extern void lapb_establish_data_link(lapb_cb *); extern void lapb_establish_data_link(struct lapb_cb *lapb);
extern void lapb_enquiry_response(lapb_cb *); extern void lapb_enquiry_response(struct lapb_cb *lapb);
extern void lapb_timeout_response(lapb_cb *); extern void lapb_timeout_response(struct lapb_cb *lapb);
extern void lapb_check_iframes_acked(lapb_cb *, unsigned short); extern void lapb_check_iframes_acked(struct lapb_cb *lapb, unsigned short);
extern void lapb_check_need_response(lapb_cb *, int, int); extern void lapb_check_need_response(struct lapb_cb *lapb, int, int);
/* lapb_subr.c */ /* lapb_subr.c */
extern void lapb_clear_queues(lapb_cb *); extern void lapb_clear_queues(struct lapb_cb *lapb);
extern void lapb_frames_acked(lapb_cb *, unsigned short); extern void lapb_frames_acked(struct lapb_cb *lapb, unsigned short);
extern void lapb_requeue_frames(lapb_cb *); extern void lapb_requeue_frames(struct lapb_cb *lapb);
extern int lapb_validate_nr(lapb_cb *, unsigned short); extern int lapb_validate_nr(struct lapb_cb *lapb, unsigned short);
extern void lapb_decode(lapb_cb *, struct sk_buff *, struct lapb_frame *); extern void lapb_decode(struct lapb_cb *lapb, struct sk_buff *, struct lapb_frame *);
extern void lapb_send_control(lapb_cb *, int, int, int); extern void lapb_send_control(struct lapb_cb *lapb, int, int, int);
extern void lapb_transmit_frmr(lapb_cb *); extern void lapb_transmit_frmr(struct lapb_cb *lapb);
/* lapb_timer.c */ /* lapb_timer.c */
extern void lapb_start_t1timer(lapb_cb *); extern void lapb_start_t1timer(struct lapb_cb *lapb);
extern void lapb_start_t2timer(lapb_cb *); extern void lapb_start_t2timer(struct lapb_cb *lapb);
extern void lapb_stop_t1timer(lapb_cb *); extern void lapb_stop_t1timer(struct lapb_cb *lapb);
extern void lapb_stop_t2timer(lapb_cb *); extern void lapb_stop_t2timer(struct lapb_cb *lapb);
extern int lapb_t1timer_running(lapb_cb *); extern int lapb_t1timer_running(struct lapb_cb *lapb);
/* /*
* Debug levels. * Debug levels.
......
This diff is collapsed.
This diff is collapsed.
...@@ -38,56 +38,54 @@ ...@@ -38,56 +38,54 @@
* This procedure is passed a buffer descriptor for an iframe. It builds * This procedure is passed a buffer descriptor for an iframe. It builds
* the rest of the control part of the frame and then writes it out. * the rest of the control part of the frame and then writes it out.
*/ */
static void lapb_send_iframe(lapb_cb *lapb, struct sk_buff *skb, int poll_bit) static void lapb_send_iframe(struct lapb_cb *lapb, struct sk_buff *skb, int poll_bit)
{ {
unsigned char *frame; unsigned char *frame;
if (skb == NULL) if (!skb)
return; return;
if (lapb->mode & LAPB_EXTENDED) { if (lapb->mode & LAPB_EXTENDED) {
frame = skb_push(skb, 2); frame = skb_push(skb, 2);
frame[0] = LAPB_I; frame[0] = LAPB_I;
frame[0] |= (lapb->vs << 1); frame[0] |= lapb->vs << 1;
frame[1] = (poll_bit) ? LAPB_EPF : 0; frame[1] = poll_bit ? LAPB_EPF : 0;
frame[1] |= (lapb->vr << 1); frame[1] |= lapb->vr << 1;
} else { } else {
frame = skb_push(skb, 1); frame = skb_push(skb, 1);
*frame = LAPB_I; *frame = LAPB_I;
*frame |= (poll_bit) ? LAPB_SPF : 0; *frame |= poll_bit ? LAPB_SPF : 0;
*frame |= (lapb->vr << 5); *frame |= lapb->vr << 5;
*frame |= (lapb->vs << 1); *frame |= lapb->vs << 1;
} }
#if LAPB_DEBUG > 1 #if LAPB_DEBUG > 1
printk(KERN_DEBUG "lapb: (%p) S%d TX I(%d) S%d R%d\n", lapb->token, lapb->state, poll_bit, lapb->vs, lapb->vr); printk(KERN_DEBUG "lapb: (%p) S%d TX I(%d) S%d R%d\n",
lapb->token, lapb->state, poll_bit, lapb->vs, lapb->vr);
#endif #endif
lapb_transmit_buffer(lapb, skb, LAPB_COMMAND); lapb_transmit_buffer(lapb, skb, LAPB_COMMAND);
} }
void lapb_kick(lapb_cb *lapb) void lapb_kick(struct lapb_cb *lapb)
{ {
struct sk_buff *skb, *skbn; struct sk_buff *skb, *skbn;
unsigned short modulus, start, end; unsigned short modulus, start, end;
modulus = (lapb->mode & LAPB_EXTENDED) ? LAPB_EMODULUS : LAPB_SMODULUS; modulus = (lapb->mode & LAPB_EXTENDED) ? LAPB_EMODULUS : LAPB_SMODULUS;
start = !skb_peek(&lapb->ack_queue) ? lapb->va : lapb->vs;
start = (skb_peek(&lapb->ack_queue) == NULL) ? lapb->va : lapb->vs;
end = (lapb->va + lapb->window) % modulus; end = (lapb->va + lapb->window) % modulus;
if (!(lapb->condition & LAPB_PEER_RX_BUSY_CONDITION) && if (!(lapb->condition & LAPB_PEER_RX_BUSY_CONDITION) &&
start != end && start != end && skb_peek(&lapb->write_queue)) {
skb_peek(&lapb->write_queue) != NULL) {
lapb->vs = start; lapb->vs = start;
/* /*
* Dequeue the frame and copy it. * Dequeue the frame and copy it.
*/ */
skb = skb_dequeue(&lapb->write_queue); skb = skb_dequeue(&lapb->write_queue);
do { do {
if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) { if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) {
...@@ -95,7 +93,7 @@ void lapb_kick(lapb_cb *lapb) ...@@ -95,7 +93,7 @@ void lapb_kick(lapb_cb *lapb)
break; break;
} }
if (skb->sk != NULL) if (skb->sk)
skb_set_owner_w(skbn, skb->sk); skb_set_owner_w(skbn, skb->sk);
/* /*
...@@ -119,7 +117,7 @@ void lapb_kick(lapb_cb *lapb) ...@@ -119,7 +117,7 @@ void lapb_kick(lapb_cb *lapb)
} }
} }
void lapb_transmit_buffer(lapb_cb *lapb, struct sk_buff *skb, int type) void lapb_transmit_buffer(struct lapb_cb *lapb, struct sk_buff *skb, int type)
{ {
unsigned char *ptr; unsigned char *ptr;
...@@ -152,26 +150,30 @@ void lapb_transmit_buffer(lapb_cb *lapb, struct sk_buff *skb, int type) ...@@ -152,26 +150,30 @@ void lapb_transmit_buffer(lapb_cb *lapb, struct sk_buff *skb, int type)
} }
#if LAPB_DEBUG > 2 #if LAPB_DEBUG > 2
printk(KERN_DEBUG "lapb: (%p) S%d TX %02X %02X %02X\n", lapb->token, lapb->state, skb->data[0], skb->data[1], skb->data[2]); printk(KERN_DEBUG "lapb: (%p) S%d TX %02X %02X %02X\n",
lapb->token, lapb->state,
skb->data[0], skb->data[1], skb->data[2]);
#endif #endif
if (!lapb_data_transmit(lapb, skb)) if (!lapb_data_transmit(lapb, skb))
kfree_skb(skb); kfree_skb(skb);
} }
void lapb_establish_data_link(lapb_cb *lapb) void lapb_establish_data_link(struct lapb_cb *lapb)
{ {
lapb->condition = 0x00; lapb->condition = 0x00;
lapb->n2count = 0; lapb->n2count = 0;
if (lapb->mode & LAPB_EXTENDED) { if (lapb->mode & LAPB_EXTENDED) {
#if LAPB_DEBUG > 1 #if LAPB_DEBUG > 1
printk(KERN_DEBUG "lapb: (%p) S%d TX SABME(1)\n", lapb->token, lapb->state); printk(KERN_DEBUG "lapb: (%p) S%d TX SABME(1)\n",
lapb->token, lapb->state);
#endif #endif
lapb_send_control(lapb, LAPB_SABME, LAPB_POLLON, LAPB_COMMAND); lapb_send_control(lapb, LAPB_SABME, LAPB_POLLON, LAPB_COMMAND);
} else { } else {
#if LAPB_DEBUG > 1 #if LAPB_DEBUG > 1
printk(KERN_DEBUG "lapb: (%p) S%d TX SABM(1)\n", lapb->token, lapb->state); printk(KERN_DEBUG "lapb: (%p) S%d TX SABM(1)\n",
lapb->token, lapb->state);
#endif #endif
lapb_send_control(lapb, LAPB_SABM, LAPB_POLLON, LAPB_COMMAND); lapb_send_control(lapb, LAPB_SABM, LAPB_POLLON, LAPB_COMMAND);
} }
...@@ -180,10 +182,11 @@ void lapb_establish_data_link(lapb_cb *lapb) ...@@ -180,10 +182,11 @@ void lapb_establish_data_link(lapb_cb *lapb)
lapb_stop_t2timer(lapb); lapb_stop_t2timer(lapb);
} }
void lapb_enquiry_response(lapb_cb *lapb) void lapb_enquiry_response(struct lapb_cb *lapb)
{ {
#if LAPB_DEBUG > 1 #if LAPB_DEBUG > 1
printk(KERN_DEBUG "lapb: (%p) S%d TX RR(1) R%d\n", lapb->token, lapb->state, lapb->vr); printk(KERN_DEBUG "lapb: (%p) S%d TX RR(1) R%d\n",
lapb->token, lapb->state, lapb->vr);
#endif #endif
lapb_send_control(lapb, LAPB_RR, LAPB_POLLON, LAPB_RESPONSE); lapb_send_control(lapb, LAPB_RR, LAPB_POLLON, LAPB_RESPONSE);
...@@ -191,32 +194,30 @@ void lapb_enquiry_response(lapb_cb *lapb) ...@@ -191,32 +194,30 @@ void lapb_enquiry_response(lapb_cb *lapb)
lapb->condition &= ~LAPB_ACK_PENDING_CONDITION; lapb->condition &= ~LAPB_ACK_PENDING_CONDITION;
} }
void lapb_timeout_response(lapb_cb *lapb) void lapb_timeout_response(struct lapb_cb *lapb)
{ {
#if LAPB_DEBUG > 1 #if LAPB_DEBUG > 1
printk(KERN_DEBUG "lapb: (%p) S%d TX RR(0) R%d\n", lapb->token, lapb->state, lapb->vr); printk(KERN_DEBUG "lapb: (%p) S%d TX RR(0) R%d\n",
lapb->token, lapb->state, lapb->vr);
#endif #endif
lapb_send_control(lapb, LAPB_RR, LAPB_POLLOFF, LAPB_RESPONSE); lapb_send_control(lapb, LAPB_RR, LAPB_POLLOFF, LAPB_RESPONSE);
lapb->condition &= ~LAPB_ACK_PENDING_CONDITION; lapb->condition &= ~LAPB_ACK_PENDING_CONDITION;
} }
void lapb_check_iframes_acked(lapb_cb *lapb, unsigned short nr) void lapb_check_iframes_acked(struct lapb_cb *lapb, unsigned short nr)
{ {
if (lapb->vs == nr) { if (lapb->vs == nr) {
lapb_frames_acked(lapb, nr); lapb_frames_acked(lapb, nr);
lapb_stop_t1timer(lapb); lapb_stop_t1timer(lapb);
lapb->n2count = 0; lapb->n2count = 0;
} else { } else if (lapb->va != nr) {
if (lapb->va != nr) { lapb_frames_acked(lapb, nr);
lapb_frames_acked(lapb, nr); lapb_start_t1timer(lapb);
lapb_start_t1timer(lapb);
}
} }
} }
void lapb_check_need_response(lapb_cb *lapb, int type, int pf) void lapb_check_need_response(struct lapb_cb *lapb, int type, int pf)
{ {
if (type == LAPB_COMMAND && pf) if (type == LAPB_COMMAND && pf)
lapb_enquiry_response(lapb); lapb_enquiry_response(lapb);
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
/* /*
* This routine purges all the queues of frames. * This routine purges all the queues of frames.
*/ */
void lapb_clear_queues(lapb_cb *lapb) void lapb_clear_queues(struct lapb_cb *lapb)
{ {
skb_queue_purge(&lapb->write_queue); skb_queue_purge(&lapb->write_queue);
skb_queue_purge(&lapb->ack_queue); skb_queue_purge(&lapb->ack_queue);
...@@ -47,7 +47,7 @@ void lapb_clear_queues(lapb_cb *lapb) ...@@ -47,7 +47,7 @@ void lapb_clear_queues(lapb_cb *lapb)
* acknowledged. This replaces the boxes labelled "V(a) <- N(r)" on the * acknowledged. This replaces the boxes labelled "V(a) <- N(r)" on the
* SDL diagram. * SDL diagram.
*/ */
void lapb_frames_acked(lapb_cb *lapb, unsigned short nr) void lapb_frames_acked(struct lapb_cb *lapb, unsigned short nr)
{ {
struct sk_buff *skb; struct sk_buff *skb;
int modulus; int modulus;
...@@ -57,16 +57,15 @@ void lapb_frames_acked(lapb_cb *lapb, unsigned short nr) ...@@ -57,16 +57,15 @@ void lapb_frames_acked(lapb_cb *lapb, unsigned short nr)
/* /*
* Remove all the ack-ed frames from the ack queue. * Remove all the ack-ed frames from the ack queue.
*/ */
if (lapb->va != nr) { if (lapb->va != nr)
while (skb_peek(&lapb->ack_queue) != NULL && lapb->va != nr) { while (skb_peek(&lapb->ack_queue) && lapb->va != nr) {
skb = skb_dequeue(&lapb->ack_queue); skb = skb_dequeue(&lapb->ack_queue);
kfree_skb(skb); kfree_skb(skb);
lapb->va = (lapb->va + 1) % modulus; lapb->va = (lapb->va + 1) % modulus;
} }
}
} }
void lapb_requeue_frames(lapb_cb *lapb) void lapb_requeue_frames(struct lapb_cb *lapb)
{ {
struct sk_buff *skb, *skb_prev = NULL; struct sk_buff *skb, *skb_prev = NULL;
...@@ -76,7 +75,7 @@ void lapb_requeue_frames(lapb_cb *lapb) ...@@ -76,7 +75,7 @@ void lapb_requeue_frames(lapb_cb *lapb)
* possibility of an empty output queue. * possibility of an empty output queue.
*/ */
while ((skb = skb_dequeue(&lapb->ack_queue)) != NULL) { while ((skb = skb_dequeue(&lapb->ack_queue)) != NULL) {
if (skb_prev == NULL) if (!skb_prev)
skb_queue_head(&lapb->write_queue, skb); skb_queue_head(&lapb->write_queue, skb);
else else
skb_append(skb_prev, skb); skb_append(skb_prev, skb);
...@@ -88,7 +87,7 @@ void lapb_requeue_frames(lapb_cb *lapb) ...@@ -88,7 +87,7 @@ void lapb_requeue_frames(lapb_cb *lapb)
* Validate that the value of nr is between va and vs. Return true or * Validate that the value of nr is between va and vs. Return true or
* false for testing. * false for testing.
*/ */
int lapb_validate_nr(lapb_cb *lapb, unsigned short nr) int lapb_validate_nr(struct lapb_cb *lapb, unsigned short nr)
{ {
unsigned short vc = lapb->va; unsigned short vc = lapb->va;
int modulus; int modulus;
...@@ -96,25 +95,27 @@ int lapb_validate_nr(lapb_cb *lapb, unsigned short nr) ...@@ -96,25 +95,27 @@ int lapb_validate_nr(lapb_cb *lapb, unsigned short nr)
modulus = (lapb->mode & LAPB_EXTENDED) ? LAPB_EMODULUS : LAPB_SMODULUS; modulus = (lapb->mode & LAPB_EXTENDED) ? LAPB_EMODULUS : LAPB_SMODULUS;
while (vc != lapb->vs) { while (vc != lapb->vs) {
if (nr == vc) return 1; if (nr == vc)
return 1;
vc = (vc + 1) % modulus; vc = (vc + 1) % modulus;
} }
if (nr == lapb->vs) return 1; return nr == lapb->vs;
return 0;
} }
/* /*
* This routine is the centralised routine for parsing the control * This routine is the centralised routine for parsing the control
* information for the different frame formats. * information for the different frame formats.
*/ */
void lapb_decode(lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame) void lapb_decode(struct lapb_cb *lapb, struct sk_buff *skb,
struct lapb_frame *frame)
{ {
frame->type = LAPB_ILLEGAL; frame->type = LAPB_ILLEGAL;
#if LAPB_DEBUG > 2 #if LAPB_DEBUG > 2
printk(KERN_DEBUG "lapb: (%p) S%d RX %02X %02X %02X\n", lapb->token, lapb->state, skb->data[0], skb->data[1], skb->data[2]); printk(KERN_DEBUG "lapb: (%p) S%d RX %02X %02X %02X\n",
lapb->token, lapb->state,
skb->data[0], skb->data[1], skb->data[2]);
#endif #endif
if (lapb->mode & LAPB_MLP) { if (lapb->mode & LAPB_MLP) {
...@@ -146,22 +147,31 @@ void lapb_decode(lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame) ...@@ -146,22 +147,31 @@ void lapb_decode(lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame)
skb_pull(skb, 1); skb_pull(skb, 1);
if (lapb->mode & LAPB_EXTENDED) { if (lapb->mode & LAPB_EXTENDED) {
if ((skb->data[0] & LAPB_S) == 0) { if (!(skb->data[0] & LAPB_S)) {
frame->type = LAPB_I; /* I frame - carries NR/NS/PF */ /*
* I frame - carries NR/NS/PF
*/
frame->type = LAPB_I;
frame->ns = (skb->data[0] >> 1) & 0x7F; frame->ns = (skb->data[0] >> 1) & 0x7F;
frame->nr = (skb->data[1] >> 1) & 0x7F; frame->nr = (skb->data[1] >> 1) & 0x7F;
frame->pf = skb->data[1] & LAPB_EPF; frame->pf = skb->data[1] & LAPB_EPF;
frame->control[0] = skb->data[0]; frame->control[0] = skb->data[0];
frame->control[1] = skb->data[1]; frame->control[1] = skb->data[1];
skb_pull(skb, 2); skb_pull(skb, 2);
} else if ((skb->data[0] & LAPB_U) == 1) { /* S frame - take out PF/NR */ } else if ((skb->data[0] & LAPB_U) == 1) {
/*
* S frame - take out PF/NR
*/
frame->type = skb->data[0] & 0x0F; frame->type = skb->data[0] & 0x0F;
frame->nr = (skb->data[1] >> 1) & 0x7F; frame->nr = (skb->data[1] >> 1) & 0x7F;
frame->pf = skb->data[1] & LAPB_EPF; frame->pf = skb->data[1] & LAPB_EPF;
frame->control[0] = skb->data[0]; frame->control[0] = skb->data[0];
frame->control[1] = skb->data[1]; frame->control[1] = skb->data[1];
skb_pull(skb, 2); skb_pull(skb, 2);
} else if ((skb->data[0] & LAPB_U) == 3) { /* U frame - take out PF */ } else if ((skb->data[0] & LAPB_U) == 3) {
/*
* U frame - take out PF
*/
frame->type = skb->data[0] & ~LAPB_SPF; frame->type = skb->data[0] & ~LAPB_SPF;
frame->pf = skb->data[0] & LAPB_SPF; frame->pf = skb->data[0] & LAPB_SPF;
frame->control[0] = skb->data[0]; frame->control[0] = skb->data[0];
...@@ -169,16 +179,25 @@ void lapb_decode(lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame) ...@@ -169,16 +179,25 @@ void lapb_decode(lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame)
skb_pull(skb, 1); skb_pull(skb, 1);
} }
} else { } else {
if ((skb->data[0] & LAPB_S) == 0) { if (!(skb->data[0] & LAPB_S)) {
frame->type = LAPB_I; /* I frame - carries NR/NS/PF */ /*
* I frame - carries NR/NS/PF
*/
frame->type = LAPB_I;
frame->ns = (skb->data[0] >> 1) & 0x07; frame->ns = (skb->data[0] >> 1) & 0x07;
frame->nr = (skb->data[0] >> 5) & 0x07; frame->nr = (skb->data[0] >> 5) & 0x07;
frame->pf = skb->data[0] & LAPB_SPF; frame->pf = skb->data[0] & LAPB_SPF;
} else if ((skb->data[0] & LAPB_U) == 1) { /* S frame - take out PF/NR */ } else if ((skb->data[0] & LAPB_U) == 1) {
/*
* S frame - take out PF/NR
*/
frame->type = skb->data[0] & 0x0F; frame->type = skb->data[0] & 0x0F;
frame->nr = (skb->data[0] >> 5) & 0x07; frame->nr = (skb->data[0] >> 5) & 0x07;
frame->pf = skb->data[0] & LAPB_SPF; frame->pf = skb->data[0] & LAPB_SPF;
} else if ((skb->data[0] & LAPB_U) == 3) { /* U frame - take out PF */ } else if ((skb->data[0] & LAPB_U) == 3) {
/*
* U frame - take out PF
*/
frame->type = skb->data[0] & ~LAPB_SPF; frame->type = skb->data[0] & ~LAPB_SPF;
frame->pf = skb->data[0] & LAPB_SPF; frame->pf = skb->data[0] & LAPB_SPF;
} }
...@@ -195,7 +214,8 @@ void lapb_decode(lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame) ...@@ -195,7 +214,8 @@ void lapb_decode(lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame)
* Only supervisory or unnumbered frames are processed, FRMRs are handled * Only supervisory or unnumbered frames are processed, FRMRs are handled
* by lapb_transmit_frmr below. * by lapb_transmit_frmr below.
*/ */
void lapb_send_control(lapb_cb *lapb, int frametype, int poll_bit, int type) void lapb_send_control(struct lapb_cb *lapb, int frametype,
int poll_bit, int type)
{ {
struct sk_buff *skb; struct sk_buff *skb;
unsigned char *dptr; unsigned char *dptr;
...@@ -209,18 +229,18 @@ void lapb_send_control(lapb_cb *lapb, int frametype, int poll_bit, int type) ...@@ -209,18 +229,18 @@ void lapb_send_control(lapb_cb *lapb, int frametype, int poll_bit, int type)
if ((frametype & LAPB_U) == LAPB_U) { if ((frametype & LAPB_U) == LAPB_U) {
dptr = skb_put(skb, 1); dptr = skb_put(skb, 1);
*dptr = frametype; *dptr = frametype;
*dptr |= (poll_bit) ? LAPB_SPF : 0; *dptr |= poll_bit ? LAPB_SPF : 0;
} else { } else {
dptr = skb_put(skb, 2); dptr = skb_put(skb, 2);
dptr[0] = frametype; dptr[0] = frametype;
dptr[1] = (lapb->vr << 1); dptr[1] = (lapb->vr << 1);
dptr[1] |= (poll_bit) ? LAPB_EPF : 0; dptr[1] |= poll_bit ? LAPB_EPF : 0;
} }
} else { } else {
dptr = skb_put(skb, 1); dptr = skb_put(skb, 1);
*dptr = frametype; *dptr = frametype;
*dptr |= (poll_bit) ? LAPB_SPF : 0; *dptr |= poll_bit ? LAPB_SPF : 0;
if ((frametype & LAPB_U) == LAPB_S) /* S frames carry NR */ if ((frametype & LAPB_U) == LAPB_S) /* S frames carry NR */
*dptr |= (lapb->vr << 5); *dptr |= (lapb->vr << 5);
} }
...@@ -231,7 +251,7 @@ void lapb_send_control(lapb_cb *lapb, int frametype, int poll_bit, int type) ...@@ -231,7 +251,7 @@ void lapb_send_control(lapb_cb *lapb, int frametype, int poll_bit, int type)
* This routine generates FRMRs based on information previously stored in * This routine generates FRMRs based on information previously stored in
* the LAPB control block. * the LAPB control block.
*/ */
void lapb_transmit_frmr(lapb_cb *lapb) void lapb_transmit_frmr(struct lapb_cb *lapb)
{ {
struct sk_buff *skb; struct sk_buff *skb;
unsigned char *dptr; unsigned char *dptr;
...@@ -254,7 +274,10 @@ void lapb_transmit_frmr(lapb_cb *lapb) ...@@ -254,7 +274,10 @@ void lapb_transmit_frmr(lapb_cb *lapb)
*dptr++ = lapb->frmr_type; *dptr++ = lapb->frmr_type;
#if LAPB_DEBUG > 1 #if LAPB_DEBUG > 1
printk(KERN_DEBUG "lapb: (%p) S%d TX FRMR %02X %02X %02X %02X %02X\n", lapb->token, lapb->state, skb->data[1], skb->data[2], skb->data[3], skb->data[4], skb->data[5]); printk(KERN_DEBUG "lapb: (%p) S%d TX FRMR %02X %02X %02X %02X %02X\n",
lapb->token, lapb->state,
skb->data[1], skb->data[2], skb->data[3],
skb->data[4], skb->data[5]);
#endif #endif
} else { } else {
dptr = skb_put(skb, 4); dptr = skb_put(skb, 4);
...@@ -268,7 +291,9 @@ void lapb_transmit_frmr(lapb_cb *lapb) ...@@ -268,7 +291,9 @@ void lapb_transmit_frmr(lapb_cb *lapb)
*dptr++ = lapb->frmr_type; *dptr++ = lapb->frmr_type;
#if LAPB_DEBUG > 1 #if LAPB_DEBUG > 1
printk(KERN_DEBUG "lapb: (%p) S%d TX FRMR %02X %02X %02X\n", lapb->token, lapb->state, skb->data[1], skb->data[2], skb->data[3]); printk(KERN_DEBUG "lapb: (%p) S%d TX FRMR %02X %02X %02X\n",
lapb->token, lapb->state, skb->data[1],
skb->data[2], skb->data[3]);
#endif #endif
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
static void lapb_t1timer_expiry(unsigned long); static void lapb_t1timer_expiry(unsigned long);
static void lapb_t2timer_expiry(unsigned long); static void lapb_t2timer_expiry(unsigned long);
void lapb_start_t1timer(lapb_cb *lapb) void lapb_start_t1timer(struct lapb_cb *lapb)
{ {
del_timer(&lapb->t1timer); del_timer(&lapb->t1timer);
...@@ -48,7 +48,7 @@ void lapb_start_t1timer(lapb_cb *lapb) ...@@ -48,7 +48,7 @@ void lapb_start_t1timer(lapb_cb *lapb)
add_timer(&lapb->t1timer); add_timer(&lapb->t1timer);
} }
void lapb_start_t2timer(lapb_cb *lapb) void lapb_start_t2timer(struct lapb_cb *lapb)
{ {
del_timer(&lapb->t2timer); del_timer(&lapb->t2timer);
...@@ -59,24 +59,24 @@ void lapb_start_t2timer(lapb_cb *lapb) ...@@ -59,24 +59,24 @@ void lapb_start_t2timer(lapb_cb *lapb)
add_timer(&lapb->t2timer); add_timer(&lapb->t2timer);
} }
void lapb_stop_t1timer(lapb_cb *lapb) void lapb_stop_t1timer(struct lapb_cb *lapb)
{ {
del_timer(&lapb->t1timer); del_timer(&lapb->t1timer);
} }
void lapb_stop_t2timer(lapb_cb *lapb) void lapb_stop_t2timer(struct lapb_cb *lapb)
{ {
del_timer(&lapb->t2timer); del_timer(&lapb->t2timer);
} }
int lapb_t1timer_running(lapb_cb *lapb) int lapb_t1timer_running(struct lapb_cb *lapb)
{ {
return timer_pending(&lapb->t1timer); return timer_pending(&lapb->t1timer);
} }
static void lapb_t2timer_expiry(unsigned long param) static void lapb_t2timer_expiry(unsigned long param)
{ {
lapb_cb *lapb = (lapb_cb *)param; struct lapb_cb *lapb = (struct lapb_cb *)param;
if (lapb->condition & LAPB_ACK_PENDING_CONDITION) { if (lapb->condition & LAPB_ACK_PENDING_CONDITION) {
lapb->condition &= ~LAPB_ACK_PENDING_CONDITION; lapb->condition &= ~LAPB_ACK_PENDING_CONDITION;
...@@ -86,7 +86,7 @@ static void lapb_t2timer_expiry(unsigned long param) ...@@ -86,7 +86,7 @@ static void lapb_t2timer_expiry(unsigned long param)
static void lapb_t1timer_expiry(unsigned long param) static void lapb_t1timer_expiry(unsigned long param)
{ {
lapb_cb *lapb = (lapb_cb *)param; struct lapb_cb *lapb = (struct lapb_cb *)param;
switch (lapb->state) { switch (lapb->state) {
......
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