2 * llc_station.c - station component of LLC
4 * Copyright (c) 1997 by Procom Technology, Inc.
5 * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
7 * This program can be redistributed or modified under the terms of the
8 * GNU General Public License as published by the Free Software Foundation.
9 * This program is distributed without any warranty or implied warranty
10 * of merchantability or fitness for a particular purpose.
12 * See the GNU General Public License for more details.
14 #include <linux/init.h>
15 #include <linux/module.h>
17 #include <net/llc_sap.h>
18 #include <net/llc_conn.h>
19 #include <net/llc_c_ac.h>
20 #include <net/llc_s_ac.h>
21 #include <net/llc_c_ev.h>
22 #include <net/llc_c_st.h>
23 #include <net/llc_s_ev.h>
24 #include <net/llc_s_st.h>
25 #include <net/llc_pdu.h>
28 * struct llc_station - LLC station component
30 * SAP and connection resource manager, one per adapter.
32 * @state - state of station
33 * @xid_r_count - XID response PDU counter
34 * @mac_sa - MAC source address
35 * @sap_list - list of related SAPs
36 * @ev_q - events entering state mach.
37 * @mac_pdu_q - PDUs ready to send to MAC
42 struct timer_list ack_timer
;
46 struct sk_buff_head list
;
49 struct sk_buff_head mac_pdu_q
;
52 #define LLC_STATION_ACK_TIME (3 * HZ)
54 int sysctl_llc_station_ack_timeout
= LLC_STATION_ACK_TIME
;
56 /* Types of events (possible values in 'ev->type') */
57 #define LLC_STATION_EV_TYPE_SIMPLE 1
58 #define LLC_STATION_EV_TYPE_CONDITION 2
59 #define LLC_STATION_EV_TYPE_PRIM 3
60 #define LLC_STATION_EV_TYPE_PDU 4 /* command/response PDU */
61 #define LLC_STATION_EV_TYPE_ACK_TMR 5
62 #define LLC_STATION_EV_TYPE_RPT_STATUS 6
65 #define LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK 1
66 #define LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK 2
67 #define LLC_STATION_EV_ACK_TMR_EXP_LT_RETRY_CNT_MAX_RETRY 3
68 #define LLC_STATION_EV_ACK_TMR_EXP_EQ_RETRY_CNT_MAX_RETRY 4
69 #define LLC_STATION_EV_RX_NULL_DSAP_XID_C 5
70 #define LLC_STATION_EV_RX_NULL_DSAP_0_XID_R_XID_R_CNT_EQ 6
71 #define LLC_STATION_EV_RX_NULL_DSAP_1_XID_R_XID_R_CNT_EQ 7
72 #define LLC_STATION_EV_RX_NULL_DSAP_TEST_C 8
73 #define LLC_STATION_EV_DISABLE_REQ 9
75 struct llc_station_state_ev
{
80 struct list_head node
; /* node in station->ev_q.list */
83 static __inline__
struct llc_station_state_ev
*
84 llc_station_ev(struct sk_buff
*skb
)
86 return (struct llc_station_state_ev
*)skb
->cb
;
89 typedef int (*llc_station_ev_t
)(struct sk_buff
*skb
);
91 #define LLC_STATION_STATE_DOWN 1 /* initial state */
92 #define LLC_STATION_STATE_DUP_ADDR_CHK 2
93 #define LLC_STATION_STATE_UP 3
95 #define LLC_NBR_STATION_STATES 3 /* size of state table */
97 typedef int (*llc_station_action_t
)(struct sk_buff
*skb
);
99 /* Station component state table structure */
100 struct llc_station_state_trans
{
103 llc_station_action_t
*ev_actions
;
106 struct llc_station_state
{
108 struct llc_station_state_trans
**transitions
;
111 static struct llc_station llc_main_station
;
113 static int llc_stat_ev_enable_with_dup_addr_check(struct sk_buff
*skb
)
115 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
117 return ev
->type
== LLC_STATION_EV_TYPE_SIMPLE
&&
119 LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK
? 0 : 1;
122 static int llc_stat_ev_enable_without_dup_addr_check(struct sk_buff
*skb
)
124 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
126 return ev
->type
== LLC_STATION_EV_TYPE_SIMPLE
&&
128 LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK
? 0 : 1;
131 static int llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry(struct sk_buff
*skb
)
133 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
135 return ev
->type
== LLC_STATION_EV_TYPE_ACK_TMR
&&
136 llc_main_station
.retry_count
<
137 llc_main_station
.maximum_retry
? 0 : 1;
140 static int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct sk_buff
*skb
)
142 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
144 return ev
->type
== LLC_STATION_EV_TYPE_ACK_TMR
&&
145 llc_main_station
.retry_count
==
146 llc_main_station
.maximum_retry
? 0 : 1;
149 static int llc_stat_ev_rx_null_dsap_xid_c(struct sk_buff
*skb
)
151 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
152 struct llc_pdu_un
*pdu
= llc_pdu_un_hdr(skb
);
154 return ev
->type
== LLC_STATION_EV_TYPE_PDU
&&
155 LLC_PDU_IS_CMD(pdu
) && /* command PDU */
156 LLC_PDU_TYPE_IS_U(pdu
) && /* U type PDU */
157 LLC_U_PDU_CMD(pdu
) == LLC_1_PDU_CMD_XID
&&
158 !pdu
->dsap
? 0 : 1; /* NULL DSAP value */
161 static int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct sk_buff
*skb
)
163 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
164 struct llc_pdu_un
*pdu
= llc_pdu_un_hdr(skb
);
166 return ev
->type
== LLC_STATION_EV_TYPE_PDU
&&
167 LLC_PDU_IS_RSP(pdu
) && /* response PDU */
168 LLC_PDU_TYPE_IS_U(pdu
) && /* U type PDU */
169 LLC_U_PDU_RSP(pdu
) == LLC_1_PDU_CMD_XID
&&
170 !pdu
->dsap
&& /* NULL DSAP value */
171 !llc_main_station
.xid_r_count
? 0 : 1;
174 static int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct sk_buff
*skb
)
176 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
177 struct llc_pdu_un
*pdu
= llc_pdu_un_hdr(skb
);
179 return ev
->type
== LLC_STATION_EV_TYPE_PDU
&&
180 LLC_PDU_IS_RSP(pdu
) && /* response PDU */
181 LLC_PDU_TYPE_IS_U(pdu
) && /* U type PDU */
182 LLC_U_PDU_RSP(pdu
) == LLC_1_PDU_CMD_XID
&&
183 !pdu
->dsap
&& /* NULL DSAP value */
184 llc_main_station
.xid_r_count
== 1 ? 0 : 1;
187 static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff
*skb
)
189 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
190 struct llc_pdu_un
*pdu
= llc_pdu_un_hdr(skb
);
192 return ev
->type
== LLC_STATION_EV_TYPE_PDU
&&
193 LLC_PDU_IS_CMD(pdu
) && /* command PDU */
194 LLC_PDU_TYPE_IS_U(pdu
) && /* U type PDU */
195 LLC_U_PDU_CMD(pdu
) == LLC_1_PDU_CMD_TEST
&&
196 !pdu
->dsap
? 0 : 1; /* NULL DSAP */
199 static int llc_stat_ev_disable_req(struct sk_buff
*skb
)
201 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
203 return ev
->type
== LLC_STATION_EV_TYPE_PRIM
&&
204 ev
->prim
== LLC_DISABLE_PRIM
&&
205 ev
->prim_type
== LLC_PRIM_TYPE_REQ
? 0 : 1;
209 * llc_station_send_pdu - queues PDU to send
210 * @skb: Address of the PDU
212 * Queues a PDU to send to the MAC layer.
214 static void llc_station_send_pdu(struct sk_buff
*skb
)
216 skb_queue_tail(&llc_main_station
.mac_pdu_q
, skb
);
217 while ((skb
= skb_dequeue(&llc_main_station
.mac_pdu_q
)) != NULL
)
218 if (dev_queue_xmit(skb
))
222 static int llc_station_ac_start_ack_timer(struct sk_buff
*skb
)
224 mod_timer(&llc_main_station
.ack_timer
,
225 jiffies
+ sysctl_llc_station_ack_timeout
);
229 static int llc_station_ac_set_retry_cnt_0(struct sk_buff
*skb
)
231 llc_main_station
.retry_count
= 0;
235 static int llc_station_ac_inc_retry_cnt_by_1(struct sk_buff
*skb
)
237 llc_main_station
.retry_count
++;
241 static int llc_station_ac_set_xid_r_cnt_0(struct sk_buff
*skb
)
243 llc_main_station
.xid_r_count
= 0;
247 static int llc_station_ac_inc_xid_r_cnt_by_1(struct sk_buff
*skb
)
249 llc_main_station
.xid_r_count
++;
253 static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff
*skb
)
256 struct sk_buff
*nskb
= llc_alloc_frame(NULL
, skb
->dev
);
260 llc_pdu_header_init(nskb
, LLC_PDU_TYPE_U
, 0, 0, LLC_PDU_CMD
);
261 llc_pdu_init_as_xid_cmd(nskb
, LLC_XID_NULL_CLASS_2
, 127);
262 rc
= llc_mac_hdr_init(nskb
, llc_station_mac_sa
, llc_station_mac_sa
);
265 llc_station_send_pdu(nskb
);
273 static int llc_station_ac_send_xid_r(struct sk_buff
*skb
)
275 u8 mac_da
[ETH_ALEN
], dsap
;
277 struct sk_buff
* nskb
= llc_alloc_frame(NULL
, skb
->dev
);
282 llc_pdu_decode_sa(skb
, mac_da
);
283 llc_pdu_decode_ssap(skb
, &dsap
);
284 llc_pdu_header_init(nskb
, LLC_PDU_TYPE_U
, 0, dsap
, LLC_PDU_RSP
);
285 llc_pdu_init_as_xid_rsp(nskb
, LLC_XID_NULL_CLASS_2
, 127);
286 rc
= llc_mac_hdr_init(nskb
, llc_station_mac_sa
, mac_da
);
289 llc_station_send_pdu(nskb
);
297 static int llc_station_ac_send_test_r(struct sk_buff
*skb
)
299 u8 mac_da
[ETH_ALEN
], dsap
;
301 struct sk_buff
*nskb
= llc_alloc_frame(NULL
, skb
->dev
);
306 llc_pdu_decode_sa(skb
, mac_da
);
307 llc_pdu_decode_ssap(skb
, &dsap
);
308 llc_pdu_header_init(nskb
, LLC_PDU_TYPE_U
, 0, dsap
, LLC_PDU_RSP
);
309 llc_pdu_init_as_test_rsp(nskb
, skb
);
310 rc
= llc_mac_hdr_init(nskb
, llc_station_mac_sa
, mac_da
);
313 llc_station_send_pdu(nskb
);
321 static int llc_station_ac_report_status(struct sk_buff
*skb
)
326 /* COMMON STATION STATE transitions */
328 /* dummy last-transition indicator; common to all state transition groups
329 * last entry for this state
330 * all members are zeros, .bss zeroes it
332 static struct llc_station_state_trans llc_stat_state_trans_end
;
334 /* DOWN STATE transitions */
336 /* state transition for LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK event */
337 static llc_station_action_t llc_stat_down_state_actions_1
[] = {
338 [0] = llc_station_ac_start_ack_timer
,
339 [1] = llc_station_ac_set_retry_cnt_0
,
340 [2] = llc_station_ac_set_xid_r_cnt_0
,
341 [3] = llc_station_ac_send_null_dsap_xid_c
,
345 static struct llc_station_state_trans llc_stat_down_state_trans_1
= {
346 .ev
= llc_stat_ev_enable_with_dup_addr_check
,
347 .next_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
348 .ev_actions
= llc_stat_down_state_actions_1
,
351 /* state transition for LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK event */
352 static llc_station_action_t llc_stat_down_state_actions_2
[] = {
353 [0] = llc_station_ac_report_status
, /* STATION UP */
357 static struct llc_station_state_trans llc_stat_down_state_trans_2
= {
358 .ev
= llc_stat_ev_enable_without_dup_addr_check
,
359 .next_state
= LLC_STATION_STATE_UP
,
360 .ev_actions
= llc_stat_down_state_actions_2
,
363 /* array of pointers; one to each transition */
364 static struct llc_station_state_trans
*llc_stat_dwn_state_trans
[] = {
365 [0] = &llc_stat_down_state_trans_1
,
366 [1] = &llc_stat_down_state_trans_2
,
367 [2] = &llc_stat_state_trans_end
,
370 /* UP STATE transitions */
371 /* state transition for LLC_STATION_EV_DISABLE_REQ event */
372 static llc_station_action_t llc_stat_up_state_actions_1
[] = {
373 [0] = llc_station_ac_report_status
, /* STATION DOWN */
377 static struct llc_station_state_trans llc_stat_up_state_trans_1
= {
378 .ev
= llc_stat_ev_disable_req
,
379 .next_state
= LLC_STATION_STATE_DOWN
,
380 .ev_actions
= llc_stat_up_state_actions_1
,
383 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_XID_C event */
384 static llc_station_action_t llc_stat_up_state_actions_2
[] = {
385 [0] = llc_station_ac_send_xid_r
,
389 static struct llc_station_state_trans llc_stat_up_state_trans_2
= {
390 .ev
= llc_stat_ev_rx_null_dsap_xid_c
,
391 .next_state
= LLC_STATION_STATE_UP
,
392 .ev_actions
= llc_stat_up_state_actions_2
,
395 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_TEST_C event */
396 static llc_station_action_t llc_stat_up_state_actions_3
[] = {
397 [0] = llc_station_ac_send_test_r
,
401 static struct llc_station_state_trans llc_stat_up_state_trans_3
= {
402 .ev
= llc_stat_ev_rx_null_dsap_test_c
,
403 .next_state
= LLC_STATION_STATE_UP
,
404 .ev_actions
= llc_stat_up_state_actions_3
,
407 /* array of pointers; one to each transition */
408 static struct llc_station_state_trans
*llc_stat_up_state_trans
[] = {
409 [0] = &llc_stat_up_state_trans_1
,
410 [1] = &llc_stat_up_state_trans_2
,
411 [2] = &llc_stat_up_state_trans_3
,
412 [3] = &llc_stat_state_trans_end
,
415 /* DUP ADDR CHK STATE transitions */
416 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_0_XID_R_XID_R_CNT_EQ
419 static llc_station_action_t llc_stat_dupaddr_state_actions_1
[] = {
420 [0] = llc_station_ac_inc_xid_r_cnt_by_1
,
424 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_1
= {
425 .ev
= llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq
,
426 .next_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
427 .ev_actions
= llc_stat_dupaddr_state_actions_1
,
430 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_1_XID_R_XID_R_CNT_EQ
433 static llc_station_action_t llc_stat_dupaddr_state_actions_2
[] = {
434 [0] = llc_station_ac_report_status
, /* DUPLICATE ADDRESS FOUND */
438 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_2
= {
439 .ev
= llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq
,
440 .next_state
= LLC_STATION_STATE_DOWN
,
441 .ev_actions
= llc_stat_dupaddr_state_actions_2
,
444 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_XID_C event */
445 static llc_station_action_t llc_stat_dupaddr_state_actions_3
[] = {
446 [0] = llc_station_ac_send_xid_r
,
450 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_3
= {
451 .ev
= llc_stat_ev_rx_null_dsap_xid_c
,
452 .next_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
453 .ev_actions
= llc_stat_dupaddr_state_actions_3
,
456 /* state transition for LLC_STATION_EV_ACK_TMR_EXP_LT_RETRY_CNT_MAX_RETRY
459 static llc_station_action_t llc_stat_dupaddr_state_actions_4
[] = {
460 [0] = llc_station_ac_start_ack_timer
,
461 [1] = llc_station_ac_inc_retry_cnt_by_1
,
462 [2] = llc_station_ac_set_xid_r_cnt_0
,
463 [3] = llc_station_ac_send_null_dsap_xid_c
,
467 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_4
= {
468 .ev
= llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry
,
469 .next_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
470 .ev_actions
= llc_stat_dupaddr_state_actions_4
,
473 /* state transition for LLC_STATION_EV_ACK_TMR_EXP_EQ_RETRY_CNT_MAX_RETRY
476 static llc_station_action_t llc_stat_dupaddr_state_actions_5
[] = {
477 [0] = llc_station_ac_report_status
, /* STATION UP */
481 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_5
= {
482 .ev
= llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry
,
483 .next_state
= LLC_STATION_STATE_UP
,
484 .ev_actions
= llc_stat_dupaddr_state_actions_5
,
487 /* state transition for LLC_STATION_EV_DISABLE_REQ event */
488 static llc_station_action_t llc_stat_dupaddr_state_actions_6
[] = {
489 [0] = llc_station_ac_report_status
, /* STATION DOWN */
493 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_6
= {
494 .ev
= llc_stat_ev_disable_req
,
495 .next_state
= LLC_STATION_STATE_DOWN
,
496 .ev_actions
= llc_stat_dupaddr_state_actions_6
,
499 /* array of pointers; one to each transition */
500 static struct llc_station_state_trans
*llc_stat_dupaddr_state_trans
[] = {
501 [0] = &llc_stat_dupaddr_state_trans_6
, /* Request */
502 [1] = &llc_stat_dupaddr_state_trans_4
, /* Timer */
503 [2] = &llc_stat_dupaddr_state_trans_5
,
504 [3] = &llc_stat_dupaddr_state_trans_1
, /* Receive frame */
505 [4] = &llc_stat_dupaddr_state_trans_2
,
506 [5] = &llc_stat_dupaddr_state_trans_3
,
507 [6] = &llc_stat_state_trans_end
,
510 static struct llc_station_state
511 llc_station_state_table
[LLC_NBR_STATION_STATES
] = {
512 [LLC_STATION_STATE_DOWN
- 1] = {
513 .curr_state
= LLC_STATION_STATE_DOWN
,
514 .transitions
= llc_stat_dwn_state_trans
,
516 [LLC_STATION_STATE_DUP_ADDR_CHK
- 1] = {
517 .curr_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
518 .transitions
= llc_stat_dupaddr_state_trans
,
520 [LLC_STATION_STATE_UP
- 1] = {
521 .curr_state
= LLC_STATION_STATE_UP
,
522 .transitions
= llc_stat_up_state_trans
,
527 * llc_exec_station_trans_actions - executes actions for transition
528 * @trans: Address of the transition
529 * @skb: Address of the event that caused the transition
531 * Executes actions of a transition of the station state machine. Returns
532 * 0 if all actions complete successfully, nonzero otherwise.
534 static u16
llc_exec_station_trans_actions(struct llc_station_state_trans
*trans
,
538 llc_station_action_t
*next_action
= trans
->ev_actions
;
540 for (; next_action
&& *next_action
; next_action
++)
541 if ((*next_action
)(skb
))
547 * llc_find_station_trans - finds transition for this event
548 * @skb: Address of the event
550 * Search thru events of the current state of the station until list
551 * exhausted or it's obvious that the event is not valid for the current
552 * state. Returns the address of the transition if cound, %NULL otherwise.
554 static struct llc_station_state_trans
*
555 llc_find_station_trans(struct sk_buff
*skb
)
558 struct llc_station_state_trans
*rc
= NULL
;
559 struct llc_station_state_trans
**next_trans
;
560 struct llc_station_state
*curr_state
=
561 &llc_station_state_table
[llc_main_station
.state
- 1];
563 for (next_trans
= curr_state
->transitions
; next_trans
[i
]->ev
; i
++)
564 if (!next_trans
[i
]->ev(skb
)) {
572 * llc_station_free_ev - frees an event
573 * @skb: Address of the event
577 static void llc_station_free_ev(struct sk_buff
*skb
)
579 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
581 if (ev
->type
== LLC_STATION_EV_TYPE_PDU
)
586 * llc_station_next_state - processes event and goes to the next state
587 * @skb: Address of the event
589 * Processes an event, executes any transitions related to that event and
590 * updates the state of the station.
592 static u16
llc_station_next_state(struct sk_buff
*skb
)
595 struct llc_station_state_trans
*trans
;
597 if (llc_main_station
.state
> LLC_NBR_STATION_STATES
)
599 trans
= llc_find_station_trans(skb
);
601 /* got the state to which we next transition; perform the
602 * actions associated with this transition before actually
603 * transitioning to the next state
605 rc
= llc_exec_station_trans_actions(trans
, skb
);
607 /* transition station to next state if all actions
608 * execute successfully; done; wait for next event
610 llc_main_station
.state
= trans
->next_state
;
612 /* event not recognized in current state; re-queue it for
613 * processing again at a later time; return failure
617 llc_station_free_ev(skb
);
622 * llc_station_service_events - service events in the queue
624 * Get an event from the station event queue (if any); attempt to service
625 * the event; if event serviced, get the next event (if any) on the event
626 * queue; if event not service, re-queue the event on the event queue and
627 * attempt to service the next event; when serviced all events in queue,
628 * finished; if don't transition to different state, just service all
629 * events once; if transition to new state, service all events again.
630 * Caller must hold llc_main_station.ev_q.lock.
632 static void llc_station_service_events(void)
636 while ((skb
= skb_dequeue(&llc_main_station
.ev_q
.list
)) != NULL
)
637 llc_station_next_state(skb
);
641 * llc_station_state_process: queue event and try to process queue.
642 * @skb: Address of the event
644 * Queues an event (on the station event queue) for handling by the
645 * station state machine and attempts to process any queued-up events.
647 static void llc_station_state_process(struct sk_buff
*skb
)
649 spin_lock_bh(&llc_main_station
.ev_q
.lock
);
650 skb_queue_tail(&llc_main_station
.ev_q
.list
, skb
);
651 llc_station_service_events();
652 spin_unlock_bh(&llc_main_station
.ev_q
.lock
);
655 static void llc_station_ack_tmr_cb(unsigned long timeout_data
)
657 struct sk_buff
*skb
= alloc_skb(0, GFP_ATOMIC
);
660 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
662 ev
->type
= LLC_STATION_EV_TYPE_ACK_TMR
;
663 llc_station_state_process(skb
);
668 * llc_station_rcv - send received pdu to the station state machine
669 * @skb: received frame.
671 * Sends data unit to station state machine.
673 static void llc_station_rcv(struct sk_buff
*skb
)
675 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
677 ev
->type
= LLC_STATION_EV_TYPE_PDU
;
679 llc_station_state_process(skb
);
682 int __init
llc_station_init(void)
686 struct llc_station_state_ev
*ev
;
688 skb_queue_head_init(&llc_main_station
.mac_pdu_q
);
689 skb_queue_head_init(&llc_main_station
.ev_q
.list
);
690 spin_lock_init(&llc_main_station
.ev_q
.lock
);
691 setup_timer(&llc_main_station
.ack_timer
, llc_station_ack_tmr_cb
,
692 (unsigned long)&llc_main_station
);
693 llc_main_station
.ack_timer
.expires
= jiffies
+
694 sysctl_llc_station_ack_timeout
;
695 skb
= alloc_skb(0, GFP_ATOMIC
);
699 llc_set_station_handler(llc_station_rcv
);
700 ev
= llc_station_ev(skb
);
701 memset(ev
, 0, sizeof(*ev
));
702 llc_main_station
.maximum_retry
= 1;
703 llc_main_station
.state
= LLC_STATION_STATE_DOWN
;
704 ev
->type
= LLC_STATION_EV_TYPE_SIMPLE
;
705 ev
->prim_type
= LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK
;
706 rc
= llc_station_next_state(skb
);
711 void __exit
llc_station_exit(void)
713 llc_set_station_handler(NULL
);