Lines Matching +full:local +full:- +full:timers

2  * llc_conn.c - Driver routines for connection component.
5 * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
51 * llc_conn_state_process - sends event to connection state machine
65 struct llc_sock *llc = llc_sk(skb->sk); in llc_conn_state_process()
68 ev->ind_prim = ev->cfm_prim = 0; in llc_conn_state_process()
72 rc = llc_conn_service(skb->sk, skb); in llc_conn_state_process()
78 switch (ev->ind_prim) { in llc_conn_state_process()
94 * skb->sk pointing to the newly created struct sock in in llc_conn_state_process()
95 * llc_conn_handler. -acme in llc_conn_state_process()
98 skb_queue_tail(&sk->sk_receive_queue, skb); in llc_conn_state_process()
99 sk->sk_state_change(sk); in llc_conn_state_process()
103 if (sk->sk_type == SOCK_STREAM && in llc_conn_state_process()
104 sk->sk_state == TCP_ESTABLISHED) { in llc_conn_state_process()
105 sk->sk_shutdown = SHUTDOWN_MASK; in llc_conn_state_process()
106 sk->sk_socket->state = SS_UNCONNECTED; in llc_conn_state_process()
107 sk->sk_state = TCP_CLOSE; in llc_conn_state_process()
110 sk->sk_state_change(sk); in llc_conn_state_process()
123 if (ev->ind_prim) in llc_conn_state_process()
125 __func__, ev->ind_prim); in llc_conn_state_process()
130 switch (ev->cfm_prim) { in llc_conn_state_process()
132 if (!llc_data_accept_state(llc->state)) in llc_conn_state_process()
133 sk->sk_write_space(sk); in llc_conn_state_process()
135 rc = llc->failed_data_req = 1; in llc_conn_state_process()
138 if (sk->sk_type == SOCK_STREAM && in llc_conn_state_process()
139 sk->sk_state == TCP_SYN_SENT) { in llc_conn_state_process()
140 if (ev->status) { in llc_conn_state_process()
141 sk->sk_socket->state = SS_UNCONNECTED; in llc_conn_state_process()
142 sk->sk_state = TCP_CLOSE; in llc_conn_state_process()
144 sk->sk_socket->state = SS_CONNECTED; in llc_conn_state_process()
145 sk->sk_state = TCP_ESTABLISHED; in llc_conn_state_process()
147 sk->sk_state_change(sk); in llc_conn_state_process()
152 if (sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_CLOSING) { in llc_conn_state_process()
153 sk->sk_socket->state = SS_UNCONNECTED; in llc_conn_state_process()
154 sk->sk_state = TCP_CLOSE; in llc_conn_state_process()
155 sk->sk_state_change(sk); in llc_conn_state_process()
167 if (ev->cfm_prim) in llc_conn_state_process()
169 __func__, ev->cfm_prim); in llc_conn_state_process()
181 skb_queue_tail(&sk->sk_write_queue, skb); in llc_conn_send_pdu()
186 * llc_conn_rtn_pdu - sends received data pdu to upper layer
198 ev->ind_prim = LLC_DATA_PRIM; in llc_conn_rtn_pdu()
202 * llc_conn_resend_i_pdu_as_cmd - resend all all unacknowledged I PDUs
228 while ((skb = skb_dequeue(&llc->pdu_unack_q)) != NULL) { in llc_conn_resend_i_pdu_as_cmd()
232 skb_queue_tail(&sk->sk_write_queue, skb); in llc_conn_resend_i_pdu_as_cmd()
234 llc->vS = LLC_I_GET_NS(pdu); in llc_conn_resend_i_pdu_as_cmd()
238 llc->vS = (llc->vS + 1) % LLC_2_SEQ_NBR_MODULO; in llc_conn_resend_i_pdu_as_cmd()
239 /* any PDUs to re-send are queued up; start sending to MAC */ in llc_conn_resend_i_pdu_as_cmd()
245 * llc_conn_resend_i_pdu_as_rsp - Resend all unacknowledged I PDUs
268 while ((skb = skb_dequeue(&llc->pdu_unack_q)) != NULL) { in llc_conn_resend_i_pdu_as_rsp()
273 skb_queue_tail(&sk->sk_write_queue, skb); in llc_conn_resend_i_pdu_as_rsp()
275 llc->vS = LLC_I_GET_NS(pdu); in llc_conn_resend_i_pdu_as_rsp()
279 llc->vS = (llc->vS + 1) % LLC_2_SEQ_NBR_MODULO; in llc_conn_resend_i_pdu_as_rsp()
280 /* any PDUs to re-send are queued up; start sending to MAC */ in llc_conn_resend_i_pdu_as_rsp()
286 * llc_conn_remove_acked_pdus - Removes acknowledged pdus from tx queue
301 int q_len = skb_queue_len(&llc->pdu_unack_q); in llc_conn_remove_acked_pdus()
305 skb = skb_peek(&llc->pdu_unack_q); in llc_conn_remove_acked_pdus()
309 pdu_pos = ((int)LLC_2_SEQ_NBR_MODULO + (int)nr - in llc_conn_remove_acked_pdus()
313 skb = skb_dequeue(&llc->pdu_unack_q); in llc_conn_remove_acked_pdus()
318 *how_many_unacked = skb_queue_len(&llc->pdu_unack_q); in llc_conn_remove_acked_pdus()
323 * llc_conn_send_pdus - Sends queued PDUs
332 while ((skb = skb_dequeue(&sk->sk_write_queue)) != NULL) { in llc_conn_send_pdus()
336 !(skb->dev->flags & IFF_LOOPBACK)) { in llc_conn_send_pdus()
339 skb_queue_tail(&llc_sk(sk)->pdu_unack_q, skb); in llc_conn_send_pdus()
349 * llc_conn_service - finds transition and changes state of connection
363 if (llc->state > NBR_CONN_STATES) in llc_conn_service()
369 if (!rc && trans->next_state != NO_STATE_CHANGE) { in llc_conn_service()
370 llc->state = trans->next_state; in llc_conn_service()
371 if (!llc_data_accept_state(llc->state)) in llc_conn_service()
372 sk->sk_state_change(sk); in llc_conn_service()
380 * llc_qualify_conn_ev - finds transition for event
395 &llc_conn_state_table[llc->state - 1]; in llc_qualify_conn_ev()
400 for (next_trans = curr_state->transitions + in llc_qualify_conn_ev()
401 llc_find_offset(llc->state - 1, ev->type); in llc_qualify_conn_ev()
402 (*next_trans)->ev; next_trans++) { in llc_qualify_conn_ev()
403 if (!((*next_trans)->ev)(sk, skb)) { in llc_qualify_conn_ev()
410 for (next_qualifier = (*next_trans)->ev_qualifiers; in llc_qualify_conn_ev()
426 * llc_exec_conn_trans_actions - executes related actions
441 for (next_action = trans->ev_actions; in llc_exec_conn_trans_actions()
463 llc->laddr.lsap == laddr->lsap && in llc_estab_match()
464 llc->daddr.lsap == daddr->lsap && in llc_estab_match()
465 ether_addr_equal(llc->laddr.mac, laddr->mac) && in llc_estab_match()
466 ether_addr_equal(llc->daddr.mac, daddr->mac); in llc_estab_match()
470 * __llc_lookup_established - Finds connection for the remote/local sap/mac
473 * @laddr: address of local LLC (MAC + SAP)
477 * mac, remote sap, local mac, and local sap. Returns pointer for
489 struct hlist_nulls_head *laddr_hb = &sap->sk_laddr_hash[slot]; in __llc_lookup_established()
496 if (unlikely(!refcount_inc_not_zero(&rc->sk_refcnt))) in __llc_lookup_established()
498 if (unlikely(llc_sk(rc)->sap != sap || in __llc_lookup_established()
540 sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN && in llc_listener_match()
541 llc->laddr.lsap == laddr->lsap && in llc_listener_match()
542 ether_addr_equal(llc->laddr.mac, laddr->mac); in llc_listener_match()
552 struct hlist_nulls_head *laddr_hb = &sap->sk_laddr_hash[slot]; in __llc_lookup_listener()
559 if (unlikely(!refcount_inc_not_zero(&rc->sk_refcnt))) in __llc_lookup_listener()
561 if (unlikely(llc_sk(rc)->sap != sap || in __llc_lookup_listener()
583 * llc_lookup_listener - Finds listener for local MAC + SAP
585 * @laddr: address of local LLC (MAC + SAP)
589 * local mac, and local sap. Returns pointer for parent socket found,
617 * llc_data_accept_state - designates if in this state data can be sent.
629 * llc_find_next_offset - finds offset for next category of transitions
641 for (next_trans = state->transitions + offset; in llc_find_next_offset()
642 (*next_trans)->ev; next_trans++) in llc_find_next_offset()
648 * llc_build_offset_table - builds offset table of connection
670 * llc_find_offset - finds start offset of category of transitions
700 * llc_sap_add_socket - adds a socket to a SAP
709 struct hlist_head *dev_hb = llc_sk_dev_hash(sap, llc->dev->ifindex); in llc_sap_add_socket()
710 struct hlist_nulls_head *laddr_hb = llc_sk_laddr_hash(sap, &llc->laddr); in llc_sap_add_socket()
713 llc_sk(sk)->sap = sap; in llc_sap_add_socket()
715 spin_lock_bh(&sap->sk_lock); in llc_sap_add_socket()
717 sap->sk_count++; in llc_sap_add_socket()
719 hlist_add_head(&llc->dev_hash_node, dev_hb); in llc_sap_add_socket()
720 spin_unlock_bh(&sap->sk_lock); in llc_sap_add_socket()
724 * llc_sap_remove_socket - removes a socket from SAP
735 spin_lock_bh(&sap->sk_lock); in llc_sap_remove_socket()
737 hlist_del(&llc->dev_hash_node); in llc_sap_remove_socket()
738 sap->sk_count--; in llc_sap_remove_socket()
739 spin_unlock_bh(&sap->sk_lock); in llc_sap_remove_socket()
744 * llc_conn_rcv - sends received pdus to the connection state machine
754 ev->type = LLC_CONN_EV_TYPE_PDU; in llc_conn_rcv()
755 ev->reason = 0; in llc_conn_rcv()
764 struct sock *newsk = llc_sk_alloc(sock_net(sk), sk->sk_family, GFP_ATOMIC, in llc_create_incoming_sock()
765 sk->sk_prot, 0); in llc_create_incoming_sock()
771 memcpy(&newllc->laddr, daddr, sizeof(newllc->laddr)); in llc_create_incoming_sock()
772 memcpy(&newllc->daddr, saddr, sizeof(newllc->daddr)); in llc_create_incoming_sock()
773 newllc->dev = dev; in llc_create_incoming_sock()
775 llc_sap_add_socket(llc->sap, newsk); in llc_create_incoming_sock()
776 llc_sap_hold(llc->sap); in llc_create_incoming_sock()
791 sk = __llc_lookup(sap, &saddr, &daddr, dev_net(skb->dev)); in llc_conn_handler()
797 * This has to be done here and not at the upper layer ->accept in llc_conn_handler()
802 * in the newly created struct sock private area. -acme in llc_conn_handler()
804 if (unlikely(sk->sk_state == TCP_LISTEN)) { in llc_conn_handler()
805 struct sock *newsk = llc_create_incoming_sock(sk, skb->dev, in llc_conn_handler()
816 * machine works. -acme in llc_conn_handler()
820 skb->sk = sk; in llc_conn_handler()
821 skb->destructor = sock_efree; in llc_conn_handler()
828 if (sk_add_backlog(sk, skb, READ_ONCE(sk->sk_rcvbuf))) in llc_conn_handler()
849 * llc_backlog_rcv - Processes rx frames and expired timers.
853 * This function processes frames that has received and timers that has
855 * queue by llc_rcv function (llc_mac.c) and timers queue by timer
864 if (likely(llc->state > 1)) /* not closed */ in llc_backlog_rcv()
870 if (likely(llc->state > 1)) /* not closed */ in llc_backlog_rcv()
886 * llc_sk_init - Initializes a socket with default llc values.
895 llc->state = LLC_CONN_STATE_ADM; in llc_sk_init()
896 llc->inc_cntr = llc->dec_cntr = 2; in llc_sk_init()
897 llc->dec_step = llc->connect_step = 1; in llc_sk_init()
899 timer_setup(&llc->ack_timer.timer, llc_conn_ack_tmr_cb, 0); in llc_sk_init()
900 llc->ack_timer.expire = sysctl_llc2_ack_timeout; in llc_sk_init()
902 timer_setup(&llc->pf_cycle_timer.timer, llc_conn_pf_cycle_tmr_cb, 0); in llc_sk_init()
903 llc->pf_cycle_timer.expire = sysctl_llc2_p_timeout; in llc_sk_init()
905 timer_setup(&llc->rej_sent_timer.timer, llc_conn_rej_tmr_cb, 0); in llc_sk_init()
906 llc->rej_sent_timer.expire = sysctl_llc2_rej_timeout; in llc_sk_init()
908 timer_setup(&llc->busy_state_timer.timer, llc_conn_busy_tmr_cb, 0); in llc_sk_init()
909 llc->busy_state_timer.expire = sysctl_llc2_busy_timeout; in llc_sk_init()
911 llc->n2 = 2; /* max retransmit */ in llc_sk_init()
912 llc->k = 2; /* tx win size, will adjust dynam */ in llc_sk_init()
913 llc->rw = 128; /* rx win size (opt and equal to in llc_sk_init()
915 skb_queue_head_init(&llc->pdu_unack_q); in llc_sk_init()
916 sk->sk_backlog_rcv = llc_backlog_rcv; in llc_sk_init()
920 * llc_sk_alloc - Allocates LLC sock
952 del_timer_sync(&llc->pf_cycle_timer.timer); in llc_sk_stop_all_timers()
953 del_timer_sync(&llc->ack_timer.timer); in llc_sk_stop_all_timers()
954 del_timer_sync(&llc->rej_sent_timer.timer); in llc_sk_stop_all_timers()
955 del_timer_sync(&llc->busy_state_timer.timer); in llc_sk_stop_all_timers()
957 del_timer(&llc->pf_cycle_timer.timer); in llc_sk_stop_all_timers()
958 del_timer(&llc->ack_timer.timer); in llc_sk_stop_all_timers()
959 del_timer(&llc->rej_sent_timer.timer); in llc_sk_stop_all_timers()
960 del_timer(&llc->busy_state_timer.timer); in llc_sk_stop_all_timers()
963 llc->ack_must_be_send = 0; in llc_sk_stop_all_timers()
964 llc->ack_pf = 0; in llc_sk_stop_all_timers()
968 * llc_sk_free - Frees a LLC socket
969 * @sk: - socket to free
977 llc->state = LLC_CONN_OUT_OF_SVC; in llc_sk_free()
978 /* Stop all (possibly) running timers */ in llc_sk_free()
982 skb_queue_len(&llc->pdu_unack_q), in llc_sk_free()
983 skb_queue_len(&sk->sk_write_queue)); in llc_sk_free()
985 skb_queue_purge(&sk->sk_receive_queue); in llc_sk_free()
986 skb_queue_purge(&sk->sk_write_queue); in llc_sk_free()
987 skb_queue_purge(&llc->pdu_unack_q); in llc_sk_free()
989 if (refcount_read(&sk->sk_refcnt) != 1) { in llc_sk_free()
991 sk, __func__, refcount_read(&sk->sk_refcnt)); in llc_sk_free()
1004 * llc_sk_reset - resets a connection
1007 * Resets a connection to the out of service state. Stops its timers
1015 skb_queue_purge(&sk->sk_write_queue); in llc_sk_reset()
1016 skb_queue_purge(&llc->pdu_unack_q); in llc_sk_reset()
1017 llc->remote_busy_flag = 0; in llc_sk_reset()
1018 llc->cause_flag = 0; in llc_sk_reset()
1019 llc->retry_count = 0; in llc_sk_reset()
1021 llc->f_flag = 0; in llc_sk_reset()
1022 llc->s_flag = 0; in llc_sk_reset()
1023 llc->ack_pf = 0; in llc_sk_reset()
1024 llc->first_pdu_Ns = 0; in llc_sk_reset()
1025 llc->ack_must_be_send = 0; in llc_sk_reset()
1026 llc->dec_step = 1; in llc_sk_reset()
1027 llc->inc_cntr = 2; in llc_sk_reset()
1028 llc->dec_cntr = 2; in llc_sk_reset()
1029 llc->X = 0; in llc_sk_reset()
1030 llc->failed_data_req = 0 ; in llc_sk_reset()
1031 llc->last_nr = 0; in llc_sk_reset()