net: gptp: Refactor because of timeout overhaul
Use k_timeout_t internally, no change to user API. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
9f17c33b60
commit
f1d886ad29
3 changed files with 19 additions and 16 deletions
|
@ -735,7 +735,7 @@ void gptp_update_pdelay_req_interval(int port, s8_t log_val)
|
||||||
new_itv = 1;
|
new_itv = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_timer_start(&state_pdelay->pdelay_timer, new_itv, K_NO_WAIT);
|
k_timer_start(&state_pdelay->pdelay_timer, K_MSEC(new_itv), K_NO_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gptp_update_sync_interval(int port, s8_t log_val)
|
void gptp_update_sync_interval(int port, s8_t log_val)
|
||||||
|
@ -785,7 +785,8 @@ void gptp_update_sync_interval(int port, s8_t log_val)
|
||||||
new_itv = 1;
|
new_itv = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_timer_start(&state_pss_send->half_sync_itv_timer, new_itv, period);
|
k_timer_start(&state_pss_send->half_sync_itv_timer, K_MSEC(new_itv),
|
||||||
|
period);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gptp_update_announce_interval(int port, s8_t log_val)
|
void gptp_update_announce_interval(int port, s8_t log_val)
|
||||||
|
@ -814,7 +815,8 @@ void gptp_update_announce_interval(int port, s8_t log_val)
|
||||||
new_itv = 1;
|
new_itv = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_timer_start(&state_ann->ann_send_periodic_timer, new_itv, K_NO_WAIT);
|
k_timer_start(&state_ann->ann_send_periodic_timer, K_MSEC(new_itv),
|
||||||
|
K_NO_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct port_user_data {
|
struct port_user_data {
|
||||||
|
|
|
@ -596,7 +596,7 @@ void gptp_handle_sync(int port, struct net_pkt *pkt)
|
||||||
struct gptp_port_ds *port_ds;
|
struct gptp_port_ds *port_ds;
|
||||||
struct gptp_hdr *hdr;
|
struct gptp_hdr *hdr;
|
||||||
u64_t upstream_sync_itv;
|
u64_t upstream_sync_itv;
|
||||||
s32_t duration;
|
k_timeout_t duration;
|
||||||
|
|
||||||
state = &GPTP_PORT_STATE(port)->sync_rcv;
|
state = &GPTP_PORT_STATE(port)->sync_rcv;
|
||||||
port_ds = GPTP_PORT_DS(port);
|
port_ds = GPTP_PORT_DS(port);
|
||||||
|
@ -605,7 +605,7 @@ void gptp_handle_sync(int port, struct net_pkt *pkt)
|
||||||
upstream_sync_itv = NSEC_PER_SEC * GPTP_POW2(hdr->log_msg_interval);
|
upstream_sync_itv = NSEC_PER_SEC * GPTP_POW2(hdr->log_msg_interval);
|
||||||
|
|
||||||
/* Convert ns to ms. */
|
/* Convert ns to ms. */
|
||||||
duration = (upstream_sync_itv / 1000000U);
|
duration = K_MSEC((upstream_sync_itv / 1000000U));
|
||||||
|
|
||||||
/* Start timeout timer. */
|
/* Start timeout timer. */
|
||||||
k_timer_start(&state->follow_up_discard_timer, duration, K_NO_WAIT);
|
k_timer_start(&state->follow_up_discard_timer, duration, K_NO_WAIT);
|
||||||
|
|
|
@ -352,9 +352,9 @@ static void gptp_mi_pss_rcv_compute(int port)
|
||||||
static void start_rcv_sync_timer(struct gptp_port_ds *port_ds,
|
static void start_rcv_sync_timer(struct gptp_port_ds *port_ds,
|
||||||
struct gptp_pss_rcv_state *state)
|
struct gptp_pss_rcv_state *state)
|
||||||
{
|
{
|
||||||
s32_t duration;
|
k_timeout_t duration;
|
||||||
|
|
||||||
duration = port_ds->sync_receipt_timeout_time_itv;
|
duration = K_MSEC(port_ds->sync_receipt_timeout_time_itv);
|
||||||
|
|
||||||
k_timer_start(&state->rcv_sync_receipt_timeout_timer, duration,
|
k_timer_start(&state->rcv_sync_receipt_timeout_timer, duration,
|
||||||
K_NO_WAIT);
|
K_NO_WAIT);
|
||||||
|
@ -455,7 +455,7 @@ static void gptp_mi_pss_send_state_machine(int port)
|
||||||
struct gptp_pss_send_state *state;
|
struct gptp_pss_send_state *state;
|
||||||
struct gptp_port_ds *port_ds;
|
struct gptp_port_ds *port_ds;
|
||||||
struct gptp_global_ds *global_ds;
|
struct gptp_global_ds *global_ds;
|
||||||
s32_t duration;
|
k_timeout_t duration;
|
||||||
|
|
||||||
global_ds = GPTP_GLOBAL_DS();
|
global_ds = GPTP_GLOBAL_DS();
|
||||||
state = &GPTP_PORT_STATE(port)->pss_send;
|
state = &GPTP_PORT_STATE(port)->pss_send;
|
||||||
|
@ -503,8 +503,8 @@ static void gptp_mi_pss_send_state_machine(int port)
|
||||||
state->send_sync_receipt_timeout_timer_expired = false;
|
state->send_sync_receipt_timeout_timer_expired = false;
|
||||||
|
|
||||||
/* Convert ns to ms. */
|
/* Convert ns to ms. */
|
||||||
duration = gptp_uscaled_ns_to_timer_ms(
|
duration = K_MSEC(gptp_uscaled_ns_to_timer_ms(
|
||||||
&port_ds->half_sync_itv);
|
&port_ds->half_sync_itv));
|
||||||
|
|
||||||
/* Start 0.5 * syncInterval timeout timer. */
|
/* Start 0.5 * syncInterval timeout timer. */
|
||||||
k_timer_start(&state->half_sync_itv_timer, duration,
|
k_timer_start(&state->half_sync_itv_timer, duration,
|
||||||
|
@ -546,8 +546,9 @@ static void gptp_mi_pss_send_state_machine(int port)
|
||||||
k_timer_stop(&state->send_sync_receipt_timeout_timer);
|
k_timer_stop(&state->send_sync_receipt_timeout_timer);
|
||||||
state->send_sync_receipt_timeout_timer_expired = false;
|
state->send_sync_receipt_timeout_timer_expired = false;
|
||||||
|
|
||||||
duration = port_ds->sync_receipt_timeout_time_itv /
|
duration =
|
||||||
(NSEC_PER_USEC * USEC_PER_MSEC);
|
K_MSEC(port_ds->sync_receipt_timeout_time_itv /
|
||||||
|
(NSEC_PER_USEC * USEC_PER_MSEC));
|
||||||
|
|
||||||
k_timer_start(&state->send_sync_receipt_timeout_timer,
|
k_timer_start(&state->send_sync_receipt_timeout_timer,
|
||||||
duration, K_NO_WAIT);
|
duration, K_NO_WAIT);
|
||||||
|
@ -1492,8 +1493,8 @@ static void gptp_mi_port_announce_information_state_machine(int port)
|
||||||
k_timer_stop(&state->ann_rcpt_expiry_timer);
|
k_timer_stop(&state->ann_rcpt_expiry_timer);
|
||||||
state->ann_expired = false;
|
state->ann_expired = false;
|
||||||
k_timer_start(&state->ann_rcpt_expiry_timer,
|
k_timer_start(&state->ann_rcpt_expiry_timer,
|
||||||
gptp_uscaled_ns_to_timer_ms(
|
K_MSEC(gptp_uscaled_ns_to_timer_ms(
|
||||||
&bmca_data->ann_rcpt_timeout_time_interval),
|
&bmca_data->ann_rcpt_timeout_time_interval)),
|
||||||
K_NO_WAIT);
|
K_NO_WAIT);
|
||||||
/* Fallthrough. */
|
/* Fallthrough. */
|
||||||
|
|
||||||
|
@ -1890,8 +1891,8 @@ static void gptp_mi_port_announce_transmit_state_machine(int port)
|
||||||
k_timer_stop(&state->ann_send_periodic_timer);
|
k_timer_stop(&state->ann_send_periodic_timer);
|
||||||
state->ann_trigger = false;
|
state->ann_trigger = false;
|
||||||
k_timer_start(&state->ann_send_periodic_timer,
|
k_timer_start(&state->ann_send_periodic_timer,
|
||||||
gptp_uscaled_ns_to_timer_ms(
|
K_MSEC(gptp_uscaled_ns_to_timer_ms(
|
||||||
&bmca_data->announce_interval),
|
&bmca_data->announce_interval)),
|
||||||
K_NO_WAIT);
|
K_NO_WAIT);
|
||||||
|
|
||||||
state->state = GPTP_PA_TRANSMIT_POST_IDLE;
|
state->state = GPTP_PA_TRANSMIT_POST_IDLE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue