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>
50 * llc_conn_state_process - sends event to connection state machine
64 struct llc_sock *llc = llc_sk(skb->sk); in llc_conn_state_process()
67 ev->ind_prim = ev->cfm_prim = 0; in llc_conn_state_process()
71 rc = llc_conn_service(skb->sk, skb); in llc_conn_state_process()
77 switch (ev->ind_prim) { in llc_conn_state_process()
93 * skb->sk pointing to the newly created struct sock in in llc_conn_state_process()
94 * llc_conn_handler. -acme in llc_conn_state_process()
97 skb_queue_tail(&sk->sk_receive_queue, skb); in llc_conn_state_process()
98 sk->sk_state_change(sk); in llc_conn_state_process()
102 if (sk->sk_type == SOCK_STREAM && in llc_conn_state_process()
103 sk->sk_state == TCP_ESTABLISHED) { in llc_conn_state_process()
104 sk->sk_shutdown = SHUTDOWN_MASK; in llc_conn_state_process()
105 sk->sk_socket->state = SS_UNCONNECTED; in llc_conn_state_process()
106 sk->sk_state = TCP_CLOSE; in llc_conn_state_process()
109 sk->sk_state_change(sk); in llc_conn_state_process()
122 if (ev->ind_prim) in llc_conn_state_process()
124 __func__, ev->ind_prim); in llc_conn_state_process()
129 switch (ev->cfm_prim) { in llc_conn_state_process()
131 if (!llc_data_accept_state(llc->state)) in llc_conn_state_process()
132 sk->sk_write_space(sk); in llc_conn_state_process()
134 rc = llc->failed_data_req = 1; in llc_conn_state_process()
137 if (sk->sk_type == SOCK_STREAM && in llc_conn_state_process()
138 sk->sk_state == TCP_SYN_SENT) { in llc_conn_state_process()
139 if (ev->status) { in llc_conn_state_process()
140 sk->sk_socket->state = SS_UNCONNECTED; in llc_conn_state_process()
141 sk->sk_state = TCP_CLOSE; in llc_conn_state_process()
143 sk->sk_socket->state = SS_CONNECTED; in llc_conn_state_process()
144 sk->sk_state = TCP_ESTABLISHED; in llc_conn_state_process()
146 sk->sk_state_change(sk); in llc_conn_state_process()
151 if (sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_CLOSING) { in llc_conn_state_process()
152 sk->sk_socket->state = SS_UNCONNECTED; in llc_conn_state_process()
153 sk->sk_state = TCP_CLOSE; in llc_conn_state_process()
154 sk->sk_state_change(sk); in llc_conn_state_process()
166 if (ev->cfm_prim) in llc_conn_state_process()
168 __func__, ev->cfm_prim); in llc_conn_state_process()
180 skb_queue_tail(&sk->sk_write_queue, skb); in llc_conn_send_pdu()
185 * llc_conn_rtn_pdu - sends received data pdu to upper layer
197 ev->ind_prim = LLC_DATA_PRIM; in llc_conn_rtn_pdu()
201 * llc_conn_resend_i_pdu_as_cmd - resend all all unacknowledged I PDUs
227 while ((skb = skb_dequeue(&llc->pdu_unack_q)) != NULL) { in llc_conn_resend_i_pdu_as_cmd()
231 skb_queue_tail(&sk->sk_write_queue, skb); in llc_conn_resend_i_pdu_as_cmd()
233 llc->vS = LLC_I_GET_NS(pdu); in llc_conn_resend_i_pdu_as_cmd()
237 llc->vS = (llc->vS + 1) % LLC_2_SEQ_NBR_MODULO; in llc_conn_resend_i_pdu_as_cmd()
238 /* any PDUs to re-send are queued up; start sending to MAC */ in llc_conn_resend_i_pdu_as_cmd()
244 * llc_conn_resend_i_pdu_as_rsp - Resend all unacknowledged I PDUs
267 while ((skb = skb_dequeue(&llc->pdu_unack_q)) != NULL) { in llc_conn_resend_i_pdu_as_rsp()
272 skb_queue_tail(&sk->sk_write_queue, skb); in llc_conn_resend_i_pdu_as_rsp()
274 llc->vS = LLC_I_GET_NS(pdu); in llc_conn_resend_i_pdu_as_rsp()
278 llc->vS = (llc->vS + 1) % LLC_2_SEQ_NBR_MODULO; in llc_conn_resend_i_pdu_as_rsp()
279 /* any PDUs to re-send are queued up; start sending to MAC */ in llc_conn_resend_i_pdu_as_rsp()
285 * llc_conn_remove_acked_pdus - Removes acknowledged pdus from tx queue
300 int q_len = skb_queue_len(&llc->pdu_unack_q); in llc_conn_remove_acked_pdus()
304 skb = skb_peek(&llc->pdu_unack_q); in llc_conn_remove_acked_pdus()
308 pdu_pos = ((int)LLC_2_SEQ_NBR_MODULO + (int)nr - in llc_conn_remove_acked_pdus()
312 skb = skb_dequeue(&llc->pdu_unack_q); in llc_conn_remove_acked_pdus()
317 *how_many_unacked = skb_queue_len(&llc->pdu_unack_q); in llc_conn_remove_acked_pdus()
322 * llc_conn_send_pdus - Sends queued PDUs
331 while ((skb = skb_dequeue(&sk->sk_write_queue)) != NULL) { in llc_conn_send_pdus()
335 !(skb->dev->flags & IFF_LOOPBACK)) { in llc_conn_send_pdus()
338 skb_queue_tail(&llc_sk(sk)->pdu_unack_q, skb); in llc_conn_send_pdus()
348 * llc_conn_service - finds transition and changes state of connection
362 if (llc->state > NBR_CONN_STATES) in llc_conn_service()
368 if (!rc && trans->next_state != NO_STATE_CHANGE) { in llc_conn_service()
369 llc->state = trans->next_state; in llc_conn_service()
370 if (!llc_data_accept_state(llc->state)) in llc_conn_service()
371 sk->sk_state_change(sk); in llc_conn_service()
379 * llc_qualify_conn_ev - finds transition for event
394 &llc_conn_state_table[llc->state - 1]; in llc_qualify_conn_ev()
399 for (next_trans = curr_state->transitions + in llc_qualify_conn_ev()
400 llc_find_offset(llc->state - 1, ev->type); in llc_qualify_conn_ev()
401 (*next_trans)->ev; next_trans++) { in llc_qualify_conn_ev()
402 if (!((*next_trans)->ev)(sk, skb)) { in llc_qualify_conn_ev()
409 for (next_qualifier = (*next_trans)->ev_qualifiers; in llc_qualify_conn_ev()
425 * llc_exec_conn_trans_actions - executes related actions
440 for (next_action = trans->ev_actions; in llc_exec_conn_trans_actions()
460 return llc->laddr.lsap == laddr->lsap && in llc_estab_match()
461 llc->daddr.lsap == daddr->lsap && in llc_estab_match()
462 ether_addr_equal(llc->laddr.mac, laddr->mac) && in llc_estab_match()
463 ether_addr_equal(llc->daddr.mac, daddr->mac); in llc_estab_match()
467 * __llc_lookup_established - Finds connection for the remote/local sap/mac
470 * @laddr: address of local LLC (MAC + SAP)
473 * mac, remote sap, local mac, and local sap. Returns pointer for
484 struct hlist_nulls_head *laddr_hb = &sap->sk_laddr_hash[slot]; in __llc_lookup_established()
491 if (unlikely(!refcount_inc_not_zero(&rc->sk_refcnt))) in __llc_lookup_established()
493 if (unlikely(llc_sk(rc)->sap != sap || in __llc_lookup_established()
532 return sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN && in llc_listener_match()
533 llc->laddr.lsap == laddr->lsap && in llc_listener_match()
534 ether_addr_equal(llc->laddr.mac, laddr->mac); in llc_listener_match()
543 struct hlist_nulls_head *laddr_hb = &sap->sk_laddr_hash[slot]; in __llc_lookup_listener()
550 if (unlikely(!refcount_inc_not_zero(&rc->sk_refcnt))) in __llc_lookup_listener()
552 if (unlikely(llc_sk(rc)->sap != sap || in __llc_lookup_listener()
574 * llc_lookup_listener - Finds listener for local MAC + SAP
576 * @laddr: address of local LLC (MAC + SAP)
579 * local mac, and local sap. Returns pointer for parent socket found,
605 * llc_data_accept_state - designates if in this state data can be sent.
617 * llc_find_next_offset - finds offset for next category of transitions
629 for (next_trans = state->transitions + offset; in llc_find_next_offset()
630 (*next_trans)->ev; next_trans++) in llc_find_next_offset()
636 * llc_build_offset_table - builds offset table of connection
658 * llc_find_offset - finds start offset of category of transitions
688 * llc_sap_add_socket - adds a socket to a SAP
697 struct hlist_head *dev_hb = llc_sk_dev_hash(sap, llc->dev->ifindex); in llc_sap_add_socket()
698 struct hlist_nulls_head *laddr_hb = llc_sk_laddr_hash(sap, &llc->laddr); in llc_sap_add_socket()
701 llc_sk(sk)->sap = sap; in llc_sap_add_socket()
703 spin_lock_bh(&sap->sk_lock); in llc_sap_add_socket()
705 sap->sk_count++; in llc_sap_add_socket()
707 hlist_add_head(&llc->dev_hash_node, dev_hb); in llc_sap_add_socket()
708 spin_unlock_bh(&sap->sk_lock); in llc_sap_add_socket()
712 * llc_sap_remove_socket - removes a socket from SAP
723 spin_lock_bh(&sap->sk_lock); in llc_sap_remove_socket()
725 hlist_del(&llc->dev_hash_node); in llc_sap_remove_socket()
726 sap->sk_count--; in llc_sap_remove_socket()
727 spin_unlock_bh(&sap->sk_lock); in llc_sap_remove_socket()
732 * llc_conn_rcv - sends received pdus to the connection state machine
742 ev->type = LLC_CONN_EV_TYPE_PDU; in llc_conn_rcv()
743 ev->reason = 0; in llc_conn_rcv()
752 struct sock *newsk = llc_sk_alloc(sock_net(sk), sk->sk_family, GFP_ATOMIC, in llc_create_incoming_sock()
753 sk->sk_prot, 0); in llc_create_incoming_sock()
759 memcpy(&newllc->laddr, daddr, sizeof(newllc->laddr)); in llc_create_incoming_sock()
760 memcpy(&newllc->daddr, saddr, sizeof(newllc->daddr)); in llc_create_incoming_sock()
761 newllc->dev = dev; in llc_create_incoming_sock()
763 llc_sap_add_socket(llc->sap, newsk); in llc_create_incoming_sock()
764 llc_sap_hold(llc->sap); in llc_create_incoming_sock()
785 * This has to be done here and not at the upper layer ->accept in llc_conn_handler()
790 * in the newly created struct sock private area. -acme in llc_conn_handler()
792 if (unlikely(sk->sk_state == TCP_LISTEN)) { in llc_conn_handler()
793 struct sock *newsk = llc_create_incoming_sock(sk, skb->dev, in llc_conn_handler()
804 * machine works. -acme in llc_conn_handler()
808 skb->sk = sk; in llc_conn_handler()
809 skb->destructor = sock_efree; in llc_conn_handler()
816 if (sk_add_backlog(sk, skb, READ_ONCE(sk->sk_rcvbuf))) in llc_conn_handler()
837 * llc_backlog_rcv - Processes rx frames and expired timers.
841 * This function processes frames that has received and timers that has
843 * queue by llc_rcv function (llc_mac.c) and timers queue by timer
852 if (likely(llc->state > 1)) /* not closed */ in llc_backlog_rcv()
858 if (likely(llc->state > 1)) /* not closed */ in llc_backlog_rcv()
874 * llc_sk_init - Initializes a socket with default llc values.
883 llc->state = LLC_CONN_STATE_ADM; in llc_sk_init()
884 llc->inc_cntr = llc->dec_cntr = 2; in llc_sk_init()
885 llc->dec_step = llc->connect_step = 1; in llc_sk_init()
887 timer_setup(&llc->ack_timer.timer, llc_conn_ack_tmr_cb, 0); in llc_sk_init()
888 llc->ack_timer.expire = sysctl_llc2_ack_timeout; in llc_sk_init()
890 timer_setup(&llc->pf_cycle_timer.timer, llc_conn_pf_cycle_tmr_cb, 0); in llc_sk_init()
891 llc->pf_cycle_timer.expire = sysctl_llc2_p_timeout; in llc_sk_init()
893 timer_setup(&llc->rej_sent_timer.timer, llc_conn_rej_tmr_cb, 0); in llc_sk_init()
894 llc->rej_sent_timer.expire = sysctl_llc2_rej_timeout; in llc_sk_init()
896 timer_setup(&llc->busy_state_timer.timer, llc_conn_busy_tmr_cb, 0); in llc_sk_init()
897 llc->busy_state_timer.expire = sysctl_llc2_busy_timeout; in llc_sk_init()
899 llc->n2 = 2; /* max retransmit */ in llc_sk_init()
900 llc->k = 2; /* tx win size, will adjust dynam */ in llc_sk_init()
901 llc->rw = 128; /* rx win size (opt and equal to in llc_sk_init()
903 skb_queue_head_init(&llc->pdu_unack_q); in llc_sk_init()
904 sk->sk_backlog_rcv = llc_backlog_rcv; in llc_sk_init()
908 * llc_sk_alloc - Allocates LLC sock
940 del_timer_sync(&llc->pf_cycle_timer.timer); in llc_sk_stop_all_timers()
941 del_timer_sync(&llc->ack_timer.timer); in llc_sk_stop_all_timers()
942 del_timer_sync(&llc->rej_sent_timer.timer); in llc_sk_stop_all_timers()
943 del_timer_sync(&llc->busy_state_timer.timer); in llc_sk_stop_all_timers()
945 del_timer(&llc->pf_cycle_timer.timer); in llc_sk_stop_all_timers()
946 del_timer(&llc->ack_timer.timer); in llc_sk_stop_all_timers()
947 del_timer(&llc->rej_sent_timer.timer); in llc_sk_stop_all_timers()
948 del_timer(&llc->busy_state_timer.timer); in llc_sk_stop_all_timers()
951 llc->ack_must_be_send = 0; in llc_sk_stop_all_timers()
952 llc->ack_pf = 0; in llc_sk_stop_all_timers()
956 * llc_sk_free - Frees a LLC socket
957 * @sk: - socket to free
965 llc->state = LLC_CONN_OUT_OF_SVC; in llc_sk_free()
966 /* Stop all (possibly) running timers */ in llc_sk_free()
970 skb_queue_len(&llc->pdu_unack_q), in llc_sk_free()
971 skb_queue_len(&sk->sk_write_queue)); in llc_sk_free()
973 skb_queue_purge(&sk->sk_receive_queue); in llc_sk_free()
974 skb_queue_purge(&sk->sk_write_queue); in llc_sk_free()
975 skb_queue_purge(&llc->pdu_unack_q); in llc_sk_free()
977 if (refcount_read(&sk->sk_refcnt) != 1) { in llc_sk_free()
979 sk, __func__, refcount_read(&sk->sk_refcnt)); in llc_sk_free()
992 * llc_sk_reset - resets a connection
995 * Resets a connection to the out of service state. Stops its timers
1003 skb_queue_purge(&sk->sk_write_queue); in llc_sk_reset()
1004 skb_queue_purge(&llc->pdu_unack_q); in llc_sk_reset()
1005 llc->remote_busy_flag = 0; in llc_sk_reset()
1006 llc->cause_flag = 0; in llc_sk_reset()
1007 llc->retry_count = 0; in llc_sk_reset()
1009 llc->f_flag = 0; in llc_sk_reset()
1010 llc->s_flag = 0; in llc_sk_reset()
1011 llc->ack_pf = 0; in llc_sk_reset()
1012 llc->first_pdu_Ns = 0; in llc_sk_reset()
1013 llc->ack_must_be_send = 0; in llc_sk_reset()
1014 llc->dec_step = 1; in llc_sk_reset()
1015 llc->inc_cntr = 2; in llc_sk_reset()
1016 llc->dec_cntr = 2; in llc_sk_reset()
1017 llc->X = 0; in llc_sk_reset()
1018 llc->failed_data_req = 0 ; in llc_sk_reset()
1019 llc->last_nr = 0; in llc_sk_reset()