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/config.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
18 #include <net/llc_sap.h>
19 #include <net/llc_conn.h>
20 #include <net/llc_c_ac.h>
21 #include <net/llc_s_ac.h>
22 #include <net/llc_c_ev.h>
23 #include <net/llc_c_st.h>
24 #include <net/llc_s_ev.h>
25 #include <net/llc_s_st.h>
26 #include <net/llc_pdu.h>
29 * struct llc_station - LLC station component
31 * SAP and connection resource manager, one per adapter.
33 * @state - state of station
34 * @xid_r_count - XID response PDU counter
35 * @mac_sa - MAC source address
36 * @sap_list - list of related SAPs
37 * @ev_q - events entering state mach.
38 * @mac_pdu_q - PDUs ready to send to MAC
43 struct timer_list ack_timer
;
47 struct sk_buff_head list
;
50 struct sk_buff_head mac_pdu_q
;
53 #define LLC_STATION_ACK_TIME (3 * HZ)
55 int sysctl_llc_station_ack_timeout
= LLC_STATION_ACK_TIME
;
57 /* Types of events (possible values in 'ev->type') */
58 #define LLC_STATION_EV_TYPE_SIMPLE 1
59 #define LLC_STATION_EV_TYPE_CONDITION 2
60 #define LLC_STATION_EV_TYPE_PRIM 3
61 #define LLC_STATION_EV_TYPE_PDU 4 /* command/response PDU */
62 #define LLC_STATION_EV_TYPE_ACK_TMR 5
63 #define LLC_STATION_EV_TYPE_RPT_STATUS 6
66 #define LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK 1
67 #define LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK 2
68 #define LLC_STATION_EV_ACK_TMR_EXP_LT_RETRY_CNT_MAX_RETRY 3
69 #define LLC_STATION_EV_ACK_TMR_EXP_EQ_RETRY_CNT_MAX_RETRY 4
70 #define LLC_STATION_EV_RX_NULL_DSAP_XID_C 5
71 #define LLC_STATION_EV_RX_NULL_DSAP_0_XID_R_XID_R_CNT_EQ 6
72 #define LLC_STATION_EV_RX_NULL_DSAP_1_XID_R_XID_R_CNT_EQ 7
73 #define LLC_STATION_EV_RX_NULL_DSAP_TEST_C 8
74 #define LLC_STATION_EV_DISABLE_REQ 9
76 struct llc_station_state_ev
{
81 struct list_head node
; /* node in station->ev_q.list */
84 static __inline__
struct llc_station_state_ev
*
85 llc_station_ev(struct sk_buff
*skb
)
87 return (struct llc_station_state_ev
*)skb
->cb
;
90 typedef int (*llc_station_ev_t
)(struct sk_buff
*skb
);
92 #define LLC_STATION_STATE_DOWN 1 /* initial state */
93 #define LLC_STATION_STATE_DUP_ADDR_CHK 2
94 #define LLC_STATION_STATE_UP 3
96 #define LLC_NBR_STATION_STATES 3 /* size of state table */
98 typedef int (*llc_station_action_t
)(struct sk_buff
*skb
);
100 /* Station component state table structure */
101 struct llc_station_state_trans
{
104 llc_station_action_t
*ev_actions
;
107 struct llc_station_state
{
109 struct llc_station_state_trans
**transitions
;
112 static struct llc_station llc_main_station
;
114 static int llc_stat_ev_enable_with_dup_addr_check(struct sk_buff
*skb
)
116 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
118 return ev
->type
== LLC_STATION_EV_TYPE_SIMPLE
&&
120 LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK
? 0 : 1;
123 static int llc_stat_ev_enable_without_dup_addr_check(struct sk_buff
*skb
)
125 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
127 return ev
->type
== LLC_STATION_EV_TYPE_SIMPLE
&&
129 LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK
? 0 : 1;
132 static int llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry(struct sk_buff
*skb
)
134 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
136 return ev
->type
== LLC_STATION_EV_TYPE_ACK_TMR
&&
137 llc_main_station
.retry_count
<
138 llc_main_station
.maximum_retry
? 0 : 1;
141 static int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct sk_buff
*skb
)
143 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
145 return ev
->type
== LLC_STATION_EV_TYPE_ACK_TMR
&&
146 llc_main_station
.retry_count
==
147 llc_main_station
.maximum_retry
? 0 : 1;
150 static int llc_stat_ev_rx_null_dsap_xid_c(struct sk_buff
*skb
)
152 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
153 struct llc_pdu_un
*pdu
= llc_pdu_un_hdr(skb
);
155 return ev
->type
== LLC_STATION_EV_TYPE_PDU
&&
156 LLC_PDU_IS_CMD(pdu
) && /* command PDU */
157 LLC_PDU_TYPE_IS_U(pdu
) && /* U type PDU */
158 LLC_U_PDU_CMD(pdu
) == LLC_1_PDU_CMD_XID
&&
159 !pdu
->dsap
? 0 : 1; /* NULL DSAP value */
162 static int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct sk_buff
*skb
)
164 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
165 struct llc_pdu_un
*pdu
= llc_pdu_un_hdr(skb
);
167 return ev
->type
== LLC_STATION_EV_TYPE_PDU
&&
168 LLC_PDU_IS_RSP(pdu
) && /* response PDU */
169 LLC_PDU_TYPE_IS_U(pdu
) && /* U type PDU */
170 LLC_U_PDU_RSP(pdu
) == LLC_1_PDU_CMD_XID
&&
171 !pdu
->dsap
&& /* NULL DSAP value */
172 !llc_main_station
.xid_r_count
? 0 : 1;
175 static int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct sk_buff
*skb
)
177 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
178 struct llc_pdu_un
*pdu
= llc_pdu_un_hdr(skb
);
180 return ev
->type
== LLC_STATION_EV_TYPE_PDU
&&
181 LLC_PDU_IS_RSP(pdu
) && /* response PDU */
182 LLC_PDU_TYPE_IS_U(pdu
) && /* U type PDU */
183 LLC_U_PDU_RSP(pdu
) == LLC_1_PDU_CMD_XID
&&
184 !pdu
->dsap
&& /* NULL DSAP value */
185 llc_main_station
.xid_r_count
== 1 ? 0 : 1;
188 static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff
*skb
)
190 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
191 struct llc_pdu_un
*pdu
= llc_pdu_un_hdr(skb
);
193 return ev
->type
== LLC_STATION_EV_TYPE_PDU
&&
194 LLC_PDU_IS_CMD(pdu
) && /* command PDU */
195 LLC_PDU_TYPE_IS_U(pdu
) && /* U type PDU */
196 LLC_U_PDU_CMD(pdu
) == LLC_1_PDU_CMD_TEST
&&
197 !pdu
->dsap
? 0 : 1; /* NULL DSAP */
200 static int llc_stat_ev_disable_req(struct sk_buff
*skb
)
202 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
204 return ev
->type
== LLC_STATION_EV_TYPE_PRIM
&&
205 ev
->prim
== LLC_DISABLE_PRIM
&&
206 ev
->prim_type
== LLC_PRIM_TYPE_REQ
? 0 : 1;
210 * llc_station_send_pdu - queues PDU to send
211 * @skb: Address of the PDU
213 * Queues a PDU to send to the MAC layer.
215 static void llc_station_send_pdu(struct sk_buff
*skb
)
217 skb_queue_tail(&llc_main_station
.mac_pdu_q
, skb
);
218 while ((skb
= skb_dequeue(&llc_main_station
.mac_pdu_q
)) != NULL
)
219 if (dev_queue_xmit(skb
))
223 static int llc_station_ac_start_ack_timer(struct sk_buff
*skb
)
225 mod_timer(&llc_main_station
.ack_timer
,
226 jiffies
+ sysctl_llc_station_ack_timeout
);
230 static int llc_station_ac_set_retry_cnt_0(struct sk_buff
*skb
)
232 llc_main_station
.retry_count
= 0;
236 static int llc_station_ac_inc_retry_cnt_by_1(struct sk_buff
*skb
)
238 llc_main_station
.retry_count
++;
242 static int llc_station_ac_set_xid_r_cnt_0(struct sk_buff
*skb
)
244 llc_main_station
.xid_r_count
= 0;
248 static int llc_station_ac_inc_xid_r_cnt_by_1(struct sk_buff
*skb
)
250 llc_main_station
.xid_r_count
++;
254 static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff
*skb
)
257 struct sk_buff
*nskb
= llc_alloc_frame(NULL
, skb
->dev
);
261 llc_pdu_header_init(nskb
, LLC_PDU_TYPE_U
, 0, 0, LLC_PDU_CMD
);
262 llc_pdu_init_as_xid_cmd(nskb
, LLC_XID_NULL_CLASS_2
, 127);
263 rc
= llc_mac_hdr_init(nskb
, llc_station_mac_sa
, llc_station_mac_sa
);
266 llc_station_send_pdu(nskb
);
274 static int llc_station_ac_send_xid_r(struct sk_buff
*skb
)
276 u8 mac_da
[ETH_ALEN
], dsap
;
278 struct sk_buff
* nskb
= llc_alloc_frame(NULL
, skb
->dev
);
283 llc_pdu_decode_sa(skb
, mac_da
);
284 llc_pdu_decode_ssap(skb
, &dsap
);
285 llc_pdu_header_init(nskb
, LLC_PDU_TYPE_U
, 0, dsap
, LLC_PDU_RSP
);
286 llc_pdu_init_as_xid_rsp(nskb
, LLC_XID_NULL_CLASS_2
, 127);
287 rc
= llc_mac_hdr_init(nskb
, llc_station_mac_sa
, mac_da
);
290 llc_station_send_pdu(nskb
);
298 static int llc_station_ac_send_test_r(struct sk_buff
*skb
)
300 u8 mac_da
[ETH_ALEN
], dsap
;
302 struct sk_buff
*nskb
= llc_alloc_frame(NULL
, skb
->dev
);
307 llc_pdu_decode_sa(skb
, mac_da
);
308 llc_pdu_decode_ssap(skb
, &dsap
);
309 llc_pdu_header_init(nskb
, LLC_PDU_TYPE_U
, 0, dsap
, LLC_PDU_RSP
);
310 llc_pdu_init_as_test_rsp(nskb
, skb
);
311 rc
= llc_mac_hdr_init(nskb
, llc_station_mac_sa
, mac_da
);
314 llc_station_send_pdu(nskb
);
322 static int llc_station_ac_report_status(struct sk_buff
*skb
)
327 /* COMMON STATION STATE transitions */
329 /* dummy last-transition indicator; common to all state transition groups
330 * last entry for this state
331 * all members are zeros, .bss zeroes it
333 static struct llc_station_state_trans llc_stat_state_trans_end
;
335 /* DOWN STATE transitions */
337 /* state transition for LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK event */
338 static llc_station_action_t llc_stat_down_state_actions_1
[] = {
339 [0] = llc_station_ac_start_ack_timer
,
340 [1] = llc_station_ac_set_retry_cnt_0
,
341 [2] = llc_station_ac_set_xid_r_cnt_0
,
342 [3] = llc_station_ac_send_null_dsap_xid_c
,
346 static struct llc_station_state_trans llc_stat_down_state_trans_1
= {
347 .ev
= llc_stat_ev_enable_with_dup_addr_check
,
348 .next_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
349 .ev_actions
= llc_stat_down_state_actions_1
,
352 /* state transition for LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK event */
353 static llc_station_action_t llc_stat_down_state_actions_2
[] = {
354 [0] = llc_station_ac_report_status
, /* STATION UP */
358 static struct llc_station_state_trans llc_stat_down_state_trans_2
= {
359 .ev
= llc_stat_ev_enable_without_dup_addr_check
,
360 .next_state
= LLC_STATION_STATE_UP
,
361 .ev_actions
= llc_stat_down_state_actions_2
,
364 /* array of pointers; one to each transition */
365 static struct llc_station_state_trans
*llc_stat_dwn_state_trans
[] = {
366 [0] = &llc_stat_down_state_trans_1
,
367 [1] = &llc_stat_down_state_trans_2
,
368 [2] = &llc_stat_state_trans_end
,
371 /* UP STATE transitions */
372 /* state transition for LLC_STATION_EV_DISABLE_REQ event */
373 static llc_station_action_t llc_stat_up_state_actions_1
[] = {
374 [0] = llc_station_ac_report_status
, /* STATION DOWN */
378 static struct llc_station_state_trans llc_stat_up_state_trans_1
= {
379 .ev
= llc_stat_ev_disable_req
,
380 .next_state
= LLC_STATION_STATE_DOWN
,
381 .ev_actions
= llc_stat_up_state_actions_1
,
384 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_XID_C event */
385 static llc_station_action_t llc_stat_up_state_actions_2
[] = {
386 [0] = llc_station_ac_send_xid_r
,
390 static struct llc_station_state_trans llc_stat_up_state_trans_2
= {
391 .ev
= llc_stat_ev_rx_null_dsap_xid_c
,
392 .next_state
= LLC_STATION_STATE_UP
,
393 .ev_actions
= llc_stat_up_state_actions_2
,
396 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_TEST_C event */
397 static llc_station_action_t llc_stat_up_state_actions_3
[] = {
398 [0] = llc_station_ac_send_test_r
,
402 static struct llc_station_state_trans llc_stat_up_state_trans_3
= {
403 .ev
= llc_stat_ev_rx_null_dsap_test_c
,
404 .next_state
= LLC_STATION_STATE_UP
,
405 .ev_actions
= llc_stat_up_state_actions_3
,
408 /* array of pointers; one to each transition */
409 static struct llc_station_state_trans
*llc_stat_up_state_trans
[] = {
410 [0] = &llc_stat_up_state_trans_1
,
411 [1] = &llc_stat_up_state_trans_2
,
412 [2] = &llc_stat_up_state_trans_3
,
413 [3] = &llc_stat_state_trans_end
,
416 /* DUP ADDR CHK STATE transitions */
417 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_0_XID_R_XID_R_CNT_EQ
420 static llc_station_action_t llc_stat_dupaddr_state_actions_1
[] = {
421 [0] = llc_station_ac_inc_xid_r_cnt_by_1
,
425 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_1
= {
426 .ev
= llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq
,
427 .next_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
428 .ev_actions
= llc_stat_dupaddr_state_actions_1
,
431 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_1_XID_R_XID_R_CNT_EQ
434 static llc_station_action_t llc_stat_dupaddr_state_actions_2
[] = {
435 [0] = llc_station_ac_report_status
, /* DUPLICATE ADDRESS FOUND */
439 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_2
= {
440 .ev
= llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq
,
441 .next_state
= LLC_STATION_STATE_DOWN
,
442 .ev_actions
= llc_stat_dupaddr_state_actions_2
,
445 /* state transition for LLC_STATION_EV_RX_NULL_DSAP_XID_C event */
446 static llc_station_action_t llc_stat_dupaddr_state_actions_3
[] = {
447 [0] = llc_station_ac_send_xid_r
,
451 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_3
= {
452 .ev
= llc_stat_ev_rx_null_dsap_xid_c
,
453 .next_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
454 .ev_actions
= llc_stat_dupaddr_state_actions_3
,
457 /* state transition for LLC_STATION_EV_ACK_TMR_EXP_LT_RETRY_CNT_MAX_RETRY
460 static llc_station_action_t llc_stat_dupaddr_state_actions_4
[] = {
461 [0] = llc_station_ac_start_ack_timer
,
462 [1] = llc_station_ac_inc_retry_cnt_by_1
,
463 [2] = llc_station_ac_set_xid_r_cnt_0
,
464 [3] = llc_station_ac_send_null_dsap_xid_c
,
468 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_4
= {
469 .ev
= llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry
,
470 .next_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
471 .ev_actions
= llc_stat_dupaddr_state_actions_4
,
474 /* state transition for LLC_STATION_EV_ACK_TMR_EXP_EQ_RETRY_CNT_MAX_RETRY
477 static llc_station_action_t llc_stat_dupaddr_state_actions_5
[] = {
478 [0] = llc_station_ac_report_status
, /* STATION UP */
482 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_5
= {
483 .ev
= llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry
,
484 .next_state
= LLC_STATION_STATE_UP
,
485 .ev_actions
= llc_stat_dupaddr_state_actions_5
,
488 /* state transition for LLC_STATION_EV_DISABLE_REQ event */
489 static llc_station_action_t llc_stat_dupaddr_state_actions_6
[] = {
490 [0] = llc_station_ac_report_status
, /* STATION DOWN */
494 static struct llc_station_state_trans llc_stat_dupaddr_state_trans_6
= {
495 .ev
= llc_stat_ev_disable_req
,
496 .next_state
= LLC_STATION_STATE_DOWN
,
497 .ev_actions
= llc_stat_dupaddr_state_actions_6
,
500 /* array of pointers; one to each transition */
501 static struct llc_station_state_trans
*llc_stat_dupaddr_state_trans
[] = {
502 [0] = &llc_stat_dupaddr_state_trans_6
, /* Request */
503 [1] = &llc_stat_dupaddr_state_trans_4
, /* Timer */
504 [2] = &llc_stat_dupaddr_state_trans_5
,
505 [3] = &llc_stat_dupaddr_state_trans_1
, /* Receive frame */
506 [4] = &llc_stat_dupaddr_state_trans_2
,
507 [5] = &llc_stat_dupaddr_state_trans_3
,
508 [6] = &llc_stat_state_trans_end
,
511 static struct llc_station_state
512 llc_station_state_table
[LLC_NBR_STATION_STATES
] = {
513 [LLC_STATION_STATE_DOWN
- 1] = {
514 .curr_state
= LLC_STATION_STATE_DOWN
,
515 .transitions
= llc_stat_dwn_state_trans
,
517 [LLC_STATION_STATE_DUP_ADDR_CHK
- 1] = {
518 .curr_state
= LLC_STATION_STATE_DUP_ADDR_CHK
,
519 .transitions
= llc_stat_dupaddr_state_trans
,
521 [LLC_STATION_STATE_UP
- 1] = {
522 .curr_state
= LLC_STATION_STATE_UP
,
523 .transitions
= llc_stat_up_state_trans
,
528 * llc_exec_station_trans_actions - executes actions for transition
529 * @trans: Address of the transition
530 * @skb: Address of the event that caused the transition
532 * Executes actions of a transition of the station state machine. Returns
533 * 0 if all actions complete successfully, nonzero otherwise.
535 static u16
llc_exec_station_trans_actions(struct llc_station_state_trans
*trans
,
539 llc_station_action_t
*next_action
= trans
->ev_actions
;
541 for (; next_action
&& *next_action
; next_action
++)
542 if ((*next_action
)(skb
))
548 * llc_find_station_trans - finds transition for this event
549 * @skb: Address of the event
551 * Search thru events of the current state of the station until list
552 * exhausted or it's obvious that the event is not valid for the current
553 * state. Returns the address of the transition if cound, %NULL otherwise.
555 static struct llc_station_state_trans
*
556 llc_find_station_trans(struct sk_buff
*skb
)
559 struct llc_station_state_trans
*rc
= NULL
;
560 struct llc_station_state_trans
**next_trans
;
561 struct llc_station_state
*curr_state
=
562 &llc_station_state_table
[llc_main_station
.state
- 1];
564 for (next_trans
= curr_state
->transitions
; next_trans
[i
]->ev
; i
++)
565 if (!next_trans
[i
]->ev(skb
)) {
573 * llc_station_free_ev - frees an event
574 * @skb: Address of the event
578 static void llc_station_free_ev(struct sk_buff
*skb
)
580 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
582 if (ev
->type
== LLC_STATION_EV_TYPE_PDU
)
587 * llc_station_next_state - processes event and goes to the next state
588 * @skb: Address of the event
590 * Processes an event, executes any transitions related to that event and
591 * updates the state of the station.
593 static u16
llc_station_next_state(struct sk_buff
*skb
)
596 struct llc_station_state_trans
*trans
;
598 if (llc_main_station
.state
> LLC_NBR_STATION_STATES
)
600 trans
= llc_find_station_trans(skb
);
602 /* got the state to which we next transition; perform the
603 * actions associated with this transition before actually
604 * transitioning to the next state
606 rc
= llc_exec_station_trans_actions(trans
, skb
);
608 /* transition station to next state if all actions
609 * execute successfully; done; wait for next event
611 llc_main_station
.state
= trans
->next_state
;
613 /* event not recognized in current state; re-queue it for
614 * processing again at a later time; return failure
618 llc_station_free_ev(skb
);
623 * llc_station_service_events - service events in the queue
625 * Get an event from the station event queue (if any); attempt to service
626 * the event; if event serviced, get the next event (if any) on the event
627 * queue; if event not service, re-queue the event on the event queue and
628 * attempt to service the next event; when serviced all events in queue,
629 * finished; if don't transition to different state, just service all
630 * events once; if transition to new state, service all events again.
631 * Caller must hold llc_main_station.ev_q.lock.
633 static void llc_station_service_events(void)
637 while ((skb
= skb_dequeue(&llc_main_station
.ev_q
.list
)) != NULL
)
638 llc_station_next_state(skb
);
642 * llc_station_state_process: queue event and try to process queue.
643 * @skb: Address of the event
645 * Queues an event (on the station event queue) for handling by the
646 * station state machine and attempts to process any queued-up events.
648 static void llc_station_state_process(struct sk_buff
*skb
)
650 spin_lock_bh(&llc_main_station
.ev_q
.lock
);
651 skb_queue_tail(&llc_main_station
.ev_q
.list
, skb
);
652 llc_station_service_events();
653 spin_unlock_bh(&llc_main_station
.ev_q
.lock
);
656 static void llc_station_ack_tmr_cb(unsigned long timeout_data
)
658 struct sk_buff
*skb
= alloc_skb(0, GFP_ATOMIC
);
661 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
663 ev
->type
= LLC_STATION_EV_TYPE_ACK_TMR
;
664 llc_station_state_process(skb
);
669 * llc_station_rcv - send received pdu to the station state machine
670 * @skb: received frame.
672 * Sends data unit to station state machine.
674 static void llc_station_rcv(struct sk_buff
*skb
)
676 struct llc_station_state_ev
*ev
= llc_station_ev(skb
);
678 ev
->type
= LLC_STATION_EV_TYPE_PDU
;
680 llc_station_state_process(skb
);
683 int __init
llc_station_init(void)
687 struct llc_station_state_ev
*ev
;
689 skb_queue_head_init(&llc_main_station
.mac_pdu_q
);
690 skb_queue_head_init(&llc_main_station
.ev_q
.list
);
691 spin_lock_init(&llc_main_station
.ev_q
.lock
);
692 init_timer(&llc_main_station
.ack_timer
);
693 llc_main_station
.ack_timer
.data
= (unsigned long)&llc_main_station
;
694 llc_main_station
.ack_timer
.function
= llc_station_ack_tmr_cb
;
695 llc_main_station
.ack_timer
.expires
= jiffies
+
696 sysctl_llc_station_ack_timeout
;
697 skb
= alloc_skb(0, GFP_ATOMIC
);
701 llc_set_station_handler(llc_station_rcv
);
702 ev
= llc_station_ev(skb
);
703 memset(ev
, 0, sizeof(*ev
));
704 llc_main_station
.maximum_retry
= 1;
705 llc_main_station
.state
= LLC_STATION_STATE_DOWN
;
706 ev
->type
= LLC_STATION_EV_TYPE_SIMPLE
;
707 ev
->prim_type
= LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK
;
708 rc
= llc_station_next_state(skb
);
713 void __exit
llc_station_exit(void)
715 llc_set_station_handler(NULL
);