Lines Matching full:state

120 	struct gptp_sync_rcv_state *state;  in gptp_set_md_sync_receive()  local
128 state = &GPTP_PORT_STATE(port)->sync_rcv; in gptp_set_md_sync_receive()
129 if (!state->rcvd_sync_ptr || !state->rcvd_follow_up_ptr) { in gptp_set_md_sync_receive()
135 sync_hdr = GPTP_HDR(state->rcvd_sync_ptr); in gptp_set_md_sync_receive()
136 fup_hdr = GPTP_HDR(state->rcvd_follow_up_ptr); in gptp_set_md_sync_receive()
137 fup = GPTP_FOLLOW_UP(state->rcvd_follow_up_ptr); in gptp_set_md_sync_receive()
138 sync_ts = &state->rcvd_sync_ptr->timestamp; in gptp_set_md_sync_receive()
183 struct gptp_pdelay_req_state *state; in gptp_md_pdelay_reset() local
188 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_pdelay_reset()
191 if (state->lost_responses < port_ds->allowed_lost_responses) { in gptp_md_pdelay_reset()
192 state->lost_responses += 1U; in gptp_md_pdelay_reset()
196 state->init_pdelay_compute = true; in gptp_md_pdelay_reset()
202 struct gptp_pdelay_req_state *state; in gptp_md_pdelay_check_multiple_resp() local
206 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_pdelay_check_multiple_resp()
209 if ((state->rcvd_pdelay_resp > 1) || in gptp_md_pdelay_check_multiple_resp()
210 (state->rcvd_pdelay_follow_up > 1)) { in gptp_md_pdelay_check_multiple_resp()
213 state->rcvd_pdelay_resp, in gptp_md_pdelay_check_multiple_resp()
214 state->rcvd_pdelay_follow_up); in gptp_md_pdelay_check_multiple_resp()
215 state->multiple_resp_count++; in gptp_md_pdelay_check_multiple_resp()
217 state->multiple_resp_count = 0U; in gptp_md_pdelay_check_multiple_resp()
220 if (state->multiple_resp_count >= 3U) { in gptp_md_pdelay_check_multiple_resp()
221 state->multiple_resp_count = 0U; in gptp_md_pdelay_check_multiple_resp()
222 k_timer_stop(&state->pdelay_timer); in gptp_md_pdelay_check_multiple_resp()
223 state->pdelay_timer_expired = false; in gptp_md_pdelay_check_multiple_resp()
229 k_timer_start(&state->pdelay_timer, K_MSEC(duration), in gptp_md_pdelay_check_multiple_resp()
232 state->state = GPTP_PDELAY_REQ_SEND_REQ; in gptp_md_pdelay_check_multiple_resp()
241 struct gptp_pdelay_req_state *state; in gptp_md_compute_pdelay_rate_ratio() local
247 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_compute_pdelay_rate_ratio()
251 pkt = state->rcvd_pdelay_resp_ptr; in gptp_md_compute_pdelay_rate_ratio()
258 pkt = state->rcvd_pdelay_follow_up_ptr; in gptp_md_compute_pdelay_rate_ratio()
271 if (state->init_pdelay_compute) { in gptp_md_compute_pdelay_rate_ratio()
272 state->init_pdelay_compute = false; in gptp_md_compute_pdelay_rate_ratio()
274 state->ini_resp_ingress_tstamp = ingress_tstamp; in gptp_md_compute_pdelay_rate_ratio()
275 state->ini_resp_evt_tstamp = resp_evt_tstamp; in gptp_md_compute_pdelay_rate_ratio()
279 state->neighbor_rate_ratio_valid = false; in gptp_md_compute_pdelay_rate_ratio()
281 if (resp_evt_tstamp == state->ini_resp_evt_tstamp) { in gptp_md_compute_pdelay_rate_ratio()
282 state->neighbor_rate_ratio_valid = false; in gptp_md_compute_pdelay_rate_ratio()
286 (resp_evt_tstamp - state->ini_resp_evt_tstamp); in gptp_md_compute_pdelay_rate_ratio()
289 state->ini_resp_ingress_tstamp); in gptp_md_compute_pdelay_rate_ratio()
293 state->ini_resp_ingress_tstamp = ingress_tstamp; in gptp_md_compute_pdelay_rate_ratio()
294 state->ini_resp_evt_tstamp = resp_evt_tstamp; in gptp_md_compute_pdelay_rate_ratio()
295 state->neighbor_rate_ratio_valid = true; in gptp_md_compute_pdelay_rate_ratio()
300 port_ds->neighbor_rate_ratio_valid = state->neighbor_rate_ratio_valid; in gptp_md_compute_pdelay_rate_ratio()
307 struct gptp_pdelay_req_state *state; in gptp_md_compute_prop_time() local
314 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_compute_prop_time()
318 pkt = state->tx_pdelay_req_ptr; in gptp_md_compute_prop_time()
324 pkt = state->rcvd_pdelay_resp_ptr; in gptp_md_compute_prop_time()
330 pkt = state->rcvd_pdelay_resp_ptr; in gptp_md_compute_prop_time()
342 pkt = state->rcvd_pdelay_follow_up_ptr; in gptp_md_compute_prop_time()
377 struct gptp_pdelay_req_state *state; in gptp_md_pdelay_compute() local
383 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_pdelay_compute()
386 if (!state->tx_pdelay_req_ptr || !state->rcvd_pdelay_resp_ptr || in gptp_md_pdelay_compute()
387 !state->rcvd_pdelay_follow_up_ptr) { in gptp_md_pdelay_compute()
404 state->lost_responses = 0U; in gptp_md_pdelay_compute()
407 pkt = state->rcvd_pdelay_follow_up_ptr; in gptp_md_pdelay_compute()
418 if (!state->neighbor_rate_ratio_valid) { in gptp_md_pdelay_compute()
441 if (state->tx_pdelay_req_ptr) { in gptp_md_pdelay_compute()
442 net_pkt_unref(state->tx_pdelay_req_ptr); in gptp_md_pdelay_compute()
443 state->tx_pdelay_req_ptr = NULL; in gptp_md_pdelay_compute()
446 if (state->rcvd_pdelay_resp_ptr) { in gptp_md_pdelay_compute()
447 net_pkt_unref(state->rcvd_pdelay_resp_ptr); in gptp_md_pdelay_compute()
448 state->rcvd_pdelay_resp_ptr = NULL; in gptp_md_pdelay_compute()
451 if (state->rcvd_pdelay_follow_up_ptr) { in gptp_md_pdelay_compute()
452 net_pkt_unref(state->rcvd_pdelay_follow_up_ptr); in gptp_md_pdelay_compute()
453 state->rcvd_pdelay_follow_up_ptr = NULL; in gptp_md_pdelay_compute()
459 struct gptp_pdelay_req_state *state; in gptp_md_pdelay_req_timeout() local
463 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_pdelay_req_timeout()
464 if (timer == &state->pdelay_timer) { in gptp_md_pdelay_req_timeout()
465 state->pdelay_timer_expired = true; in gptp_md_pdelay_req_timeout()
467 if (state->rcvd_pdelay_resp == 0U) { in gptp_md_pdelay_req_timeout()
477 struct gptp_pdelay_req_state *state; in gptp_md_start_pdelay_req() local
481 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_start_pdelay_req()
486 state->lost_responses = 0U; in gptp_md_start_pdelay_req()
487 state->rcvd_pdelay_resp = 0U; in gptp_md_start_pdelay_req()
488 state->rcvd_pdelay_follow_up = 0U; in gptp_md_start_pdelay_req()
489 state->multiple_resp_count = 0U; in gptp_md_start_pdelay_req()
494 struct gptp_sync_rcv_state *state; in gptp_md_follow_up_receipt_timeout() local
498 state = &GPTP_PORT_STATE(port)->sync_rcv; in gptp_md_follow_up_receipt_timeout()
499 if (timer == &state->follow_up_discard_timer) { in gptp_md_follow_up_receipt_timeout()
502 state->follow_up_timeout_expired = true; in gptp_md_follow_up_receipt_timeout()
509 struct gptp_pdelay_req_state *state; in gptp_md_init_pdelay_req_state_machine() local
511 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_init_pdelay_req_state_machine()
513 k_timer_init(&state->pdelay_timer, gptp_md_pdelay_req_timeout, NULL); in gptp_md_init_pdelay_req_state_machine()
515 state->state = GPTP_PDELAY_REQ_NOT_ENABLED; in gptp_md_init_pdelay_req_state_machine()
517 state->neighbor_rate_ratio_valid = false; in gptp_md_init_pdelay_req_state_machine()
518 state->init_pdelay_compute = true; in gptp_md_init_pdelay_req_state_machine()
519 state->rcvd_pdelay_resp = 0U; in gptp_md_init_pdelay_req_state_machine()
520 state->rcvd_pdelay_follow_up = 0U; in gptp_md_init_pdelay_req_state_machine()
521 state->pdelay_timer_expired = false; in gptp_md_init_pdelay_req_state_machine()
523 state->rcvd_pdelay_resp_ptr = NULL; in gptp_md_init_pdelay_req_state_machine()
524 state->rcvd_pdelay_follow_up_ptr = NULL; in gptp_md_init_pdelay_req_state_machine()
525 state->tx_pdelay_req_ptr = NULL; in gptp_md_init_pdelay_req_state_machine()
527 state->ini_resp_evt_tstamp = 0U; in gptp_md_init_pdelay_req_state_machine()
528 state->ini_resp_ingress_tstamp = 0U; in gptp_md_init_pdelay_req_state_machine()
529 state->lost_responses = 0U; in gptp_md_init_pdelay_req_state_machine()
534 struct gptp_pdelay_resp_state *state; in gptp_md_init_pdelay_resp_state_machine() local
536 state = &GPTP_PORT_STATE(port)->pdelay_resp; in gptp_md_init_pdelay_resp_state_machine()
538 state->state = GPTP_PDELAY_RESP_NOT_ENABLED; in gptp_md_init_pdelay_resp_state_machine()
543 struct gptp_sync_rcv_state *state; in gptp_md_init_sync_rcv_state_machine() local
545 state = &GPTP_PORT_STATE(port)->sync_rcv; in gptp_md_init_sync_rcv_state_machine()
547 k_timer_init(&state->follow_up_discard_timer, in gptp_md_init_sync_rcv_state_machine()
550 state->rcvd_sync = false; in gptp_md_init_sync_rcv_state_machine()
551 state->rcvd_follow_up = false; in gptp_md_init_sync_rcv_state_machine()
552 state->rcvd_sync_ptr = NULL; in gptp_md_init_sync_rcv_state_machine()
553 state->rcvd_follow_up_ptr = NULL; in gptp_md_init_sync_rcv_state_machine()
555 state->follow_up_timeout_expired = false; in gptp_md_init_sync_rcv_state_machine()
556 state->follow_up_receipt_timeout = 0U; in gptp_md_init_sync_rcv_state_machine()
558 state->state = GPTP_SYNC_RCV_DISCARD; in gptp_md_init_sync_rcv_state_machine()
563 struct gptp_sync_send_state *state; in gptp_md_init_sync_send_state_machine() local
565 state = &GPTP_PORT_STATE(port)->sync_send; in gptp_md_init_sync_send_state_machine()
567 state->rcvd_md_sync = false; in gptp_md_init_sync_send_state_machine()
568 state->md_sync_timestamp_avail = false; in gptp_md_init_sync_send_state_machine()
569 state->sync_send_ptr = NULL; in gptp_md_init_sync_send_state_machine()
570 state->sync_ptr = NULL; in gptp_md_init_sync_send_state_machine()
572 state->state = GPTP_SYNC_SEND_INITIALIZING; in gptp_md_init_sync_send_state_machine()
590 struct gptp_pdelay_req_state *state; in gptp_md_pdelay_req_state_machine() local
593 state = &GPTP_PORT_STATE(port)->pdelay_req; in gptp_md_pdelay_req_state_machine()
599 if (state->rcvd_pdelay_resp > 1 || state->rcvd_pdelay_follow_up > 1) { in gptp_md_pdelay_req_state_machine()
605 k_timer_stop(&state->pdelay_timer); in gptp_md_pdelay_req_state_machine()
606 state->state = GPTP_PDELAY_REQ_NOT_ENABLED; in gptp_md_pdelay_req_state_machine()
609 switch (state->state) { in gptp_md_pdelay_req_state_machine()
613 * LinkDelaySyncIntervalSetting state machine). in gptp_md_pdelay_req_state_machine()
624 state->pdelay_timer_expired = true; in gptp_md_pdelay_req_state_machine()
625 state->state = GPTP_PDELAY_REQ_INITIAL_SEND_REQ; in gptp_md_pdelay_req_state_machine()
633 state->state = GPTP_PDELAY_REQ_WAIT_ITV_TIMER; in gptp_md_pdelay_req_state_machine()
641 if (state->tx_pdelay_req_ptr) { in gptp_md_pdelay_req_state_machine()
642 net_pkt_unref(state->tx_pdelay_req_ptr); in gptp_md_pdelay_req_state_machine()
643 state->tx_pdelay_req_ptr = NULL; in gptp_md_pdelay_req_state_machine()
646 if (state->rcvd_pdelay_resp_ptr) { in gptp_md_pdelay_req_state_machine()
647 net_pkt_unref(state->rcvd_pdelay_resp_ptr); in gptp_md_pdelay_req_state_machine()
648 state->rcvd_pdelay_resp_ptr = NULL; in gptp_md_pdelay_req_state_machine()
651 if (state->rcvd_pdelay_follow_up_ptr) { in gptp_md_pdelay_req_state_machine()
652 net_pkt_unref(state->rcvd_pdelay_follow_up_ptr); in gptp_md_pdelay_req_state_machine()
653 state->rcvd_pdelay_follow_up_ptr = NULL; in gptp_md_pdelay_req_state_machine()
658 k_timer_stop(&state->pdelay_timer); in gptp_md_pdelay_req_state_machine()
659 state->pdelay_timer_expired = false; in gptp_md_pdelay_req_state_machine()
660 k_timer_start(&state->pdelay_timer, in gptp_md_pdelay_req_state_machine()
669 state->state = GPTP_PDELAY_REQ_WAIT_RESP; in gptp_md_pdelay_req_state_machine()
673 if (state->pdelay_timer_expired) { in gptp_md_pdelay_req_state_machine()
674 state->state = GPTP_PDELAY_REQ_RESET; in gptp_md_pdelay_req_state_machine()
675 } else if (state->rcvd_pdelay_resp != 0U) { in gptp_md_pdelay_req_state_machine()
676 pkt = state->rcvd_pdelay_resp_ptr; in gptp_md_pdelay_req_state_machine()
678 state->state = GPTP_PDELAY_REQ_WAIT_FOLLOW_UP; in gptp_md_pdelay_req_state_machine()
680 state->state = GPTP_PDELAY_REQ_RESET; in gptp_md_pdelay_req_state_machine()
687 if (state->pdelay_timer_expired) { in gptp_md_pdelay_req_state_machine()
688 state->state = GPTP_PDELAY_REQ_RESET; in gptp_md_pdelay_req_state_machine()
689 } else if (state->rcvd_pdelay_follow_up != 0U) { in gptp_md_pdelay_req_state_machine()
690 pkt = state->rcvd_pdelay_follow_up_ptr; in gptp_md_pdelay_req_state_machine()
693 state->state = GPTP_PDELAY_REQ_WAIT_ITV_TIMER; in gptp_md_pdelay_req_state_machine()
695 state->state = GPTP_PDELAY_REQ_RESET; in gptp_md_pdelay_req_state_machine()
702 if (state->pdelay_timer_expired) { in gptp_md_pdelay_req_state_machine()
705 state->rcvd_pdelay_resp = 0U; in gptp_md_pdelay_req_state_machine()
706 state->rcvd_pdelay_follow_up = 0U; in gptp_md_pdelay_req_state_machine()
716 struct gptp_pdelay_resp_state *state; in gptp_md_pdelay_resp_state_machine() local
718 state = &GPTP_PORT_STATE(port)->pdelay_resp; in gptp_md_pdelay_resp_state_machine()
722 state->state = GPTP_PDELAY_RESP_NOT_ENABLED; in gptp_md_pdelay_resp_state_machine()
725 switch (state->state) { in gptp_md_pdelay_resp_state_machine()
728 state->state = GPTP_PDELAY_RESP_INITIAL_WAIT_REQ; in gptp_md_pdelay_resp_state_machine()
748 struct gptp_sync_rcv_state *state; in gptp_md_sync_receive_state_machine() local
751 state = &GPTP_PORT_STATE(port)->sync_rcv; in gptp_md_sync_receive_state_machine()
757 k_timer_stop(&state->follow_up_discard_timer); in gptp_md_sync_receive_state_machine()
760 if (state->rcvd_sync_ptr) { in gptp_md_sync_receive_state_machine()
761 net_pkt_unref(state->rcvd_sync_ptr); in gptp_md_sync_receive_state_machine()
762 state->rcvd_sync_ptr = NULL; in gptp_md_sync_receive_state_machine()
765 if (state->rcvd_follow_up_ptr) { in gptp_md_sync_receive_state_machine()
766 net_pkt_unref(state->rcvd_follow_up_ptr); in gptp_md_sync_receive_state_machine()
767 state->rcvd_follow_up_ptr = NULL; in gptp_md_sync_receive_state_machine()
770 state->rcvd_sync = false; in gptp_md_sync_receive_state_machine()
771 state->rcvd_follow_up = false; in gptp_md_sync_receive_state_machine()
772 state->state = GPTP_SYNC_RCV_DISCARD; in gptp_md_sync_receive_state_machine()
776 switch (state->state) { in gptp_md_sync_receive_state_machine()
779 if (state->rcvd_sync) { in gptp_md_sync_receive_state_machine()
780 gptp_handle_sync(port, state->rcvd_sync_ptr); in gptp_md_sync_receive_state_machine()
781 state->rcvd_sync = false; in gptp_md_sync_receive_state_machine()
782 state->state = GPTP_SYNC_RCV_WAIT_FOLLOW_UP; in gptp_md_sync_receive_state_machine()
783 } else if (state->rcvd_follow_up) { in gptp_md_sync_receive_state_machine()
785 if (state->rcvd_follow_up_ptr) { in gptp_md_sync_receive_state_machine()
786 net_pkt_unref(state->rcvd_follow_up_ptr); in gptp_md_sync_receive_state_machine()
787 state->rcvd_follow_up_ptr = NULL; in gptp_md_sync_receive_state_machine()
790 state->rcvd_follow_up = false; in gptp_md_sync_receive_state_machine()
797 if (state->follow_up_timeout_expired) { in gptp_md_sync_receive_state_machine()
798 k_timer_stop(&state->follow_up_discard_timer); in gptp_md_sync_receive_state_machine()
799 state->follow_up_timeout_expired = false; in gptp_md_sync_receive_state_machine()
800 state->state = GPTP_SYNC_RCV_DISCARD; in gptp_md_sync_receive_state_machine()
801 if (state->rcvd_sync_ptr) { in gptp_md_sync_receive_state_machine()
802 net_pkt_unref(state->rcvd_sync_ptr); in gptp_md_sync_receive_state_machine()
803 state->rcvd_sync_ptr = NULL; in gptp_md_sync_receive_state_machine()
806 state->rcvd_sync = false; in gptp_md_sync_receive_state_machine()
807 } else if (state->rcvd_sync) { in gptp_md_sync_receive_state_machine()
809 gptp_handle_sync(port, state->rcvd_sync_ptr); in gptp_md_sync_receive_state_machine()
810 state->rcvd_sync = false; in gptp_md_sync_receive_state_machine()
811 } else if (state->rcvd_follow_up) { in gptp_md_sync_receive_state_machine()
813 port, state->rcvd_follow_up_ptr)) { in gptp_md_sync_receive_state_machine()
824 state->state = GPTP_SYNC_RCV_WAIT_SYNC; in gptp_md_sync_receive_state_machine()
827 if (state->rcvd_sync_ptr) { in gptp_md_sync_receive_state_machine()
828 net_pkt_unref(state->rcvd_sync_ptr); in gptp_md_sync_receive_state_machine()
829 state->rcvd_sync_ptr = NULL; in gptp_md_sync_receive_state_machine()
832 k_timer_stop(&state->follow_up_discard_timer); in gptp_md_sync_receive_state_machine()
833 state->follow_up_timeout_expired = false; in gptp_md_sync_receive_state_machine()
837 if (state->rcvd_follow_up_ptr) { in gptp_md_sync_receive_state_machine()
838 net_pkt_unref(state->rcvd_follow_up_ptr); in gptp_md_sync_receive_state_machine()
839 state->rcvd_follow_up_ptr = NULL; in gptp_md_sync_receive_state_machine()
842 state->rcvd_follow_up = false; in gptp_md_sync_receive_state_machine()
850 struct gptp_sync_send_state *state; in gptp_md_sync_send_state_machine() local
853 state = &GPTP_PORT_STATE(port)->sync_send; in gptp_md_sync_send_state_machine()
857 state->rcvd_md_sync = false; in gptp_md_sync_send_state_machine()
858 state->state = GPTP_SYNC_SEND_INITIALIZING; in gptp_md_sync_send_state_machine()
865 switch (state->state) { in gptp_md_sync_send_state_machine()
867 state->state = GPTP_SYNC_SEND_SEND_SYNC; in gptp_md_sync_send_state_machine()
871 if (state->rcvd_md_sync) { in gptp_md_sync_send_state_machine()
875 state->sync_ptr = net_pkt_ref(pkt); in gptp_md_sync_send_state_machine()
877 state->sync_send_ptr, in gptp_md_sync_send_state_machine()
882 state->rcvd_md_sync = false; in gptp_md_sync_send_state_machine()
883 state->state = GPTP_SYNC_SEND_SEND_FUP; in gptp_md_sync_send_state_machine()
889 if (state->md_sync_timestamp_avail) { in gptp_md_sync_send_state_machine()
890 state->md_sync_timestamp_avail = false; in gptp_md_sync_send_state_machine()
892 if (!state->sync_ptr) { in gptp_md_sync_send_state_machine()
897 pkt = gptp_prepare_follow_up(port, state->sync_ptr); in gptp_md_sync_send_state_machine()
900 state->sync_ptr, in gptp_md_sync_send_state_machine()
901 state->sync_send_ptr, in gptp_md_sync_send_state_machine()
906 net_pkt_unref(state->sync_ptr); in gptp_md_sync_send_state_machine()
907 state->sync_ptr = NULL; in gptp_md_sync_send_state_machine()
909 state->state = GPTP_SYNC_SEND_SEND_SYNC; in gptp_md_sync_send_state_machine()