Skip to content

Commit 984546e

Browse files
author
Jonas Berg
committed
Use a separate data structure for the scheduler
This makes it easier to test in isolation, and cleans up the pnet_t struct
1 parent 78f6761 commit 984546e

15 files changed

+297
-221
lines changed

src/common/pf_alarm.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ static void pf_alarm_apms_timeout (
827827

828828
if (
829829
pf_scheduler_add (
830-
net,
830+
&net->scheduler_data,
831831
p_apmx->timeout_us,
832832
pf_alarm_apms_timeout,
833833
p_apmx,
@@ -1462,7 +1462,7 @@ static int pf_alarm_apms_apms_a_data_req (
14621462
retransmission timer */
14631463
if (
14641464
pf_scheduler_add (
1465-
net,
1465+
&net->scheduler_data,
14661466
p_apmx->timeout_us,
14671467
pf_alarm_apms_timeout,
14681468
p_apmx,
@@ -1552,7 +1552,9 @@ static int pf_alarm_apmx_close (pnet_t * net, pf_ar_t * p_ar, uint8_t err_code)
15521552
{
15531553
/* Free resources */
15541554
/* StopTimer */
1555-
pf_scheduler_remove_if_running (net, &p_ar->apmx[ix].resend_timeout);
1555+
pf_scheduler_remove_if_running (
1556+
&net->scheduler_data,
1557+
&p_ar->apmx[ix].resend_timeout);
15561558

15571559
p_ar->apmx[ix].p_ar = NULL;
15581560
p_ar->apmx[ix].apms_state = PF_APMS_STATE_CLOSED;

src/common/pf_cpm_driver_sw.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void pf_cpm_control_interval_expired (
8888
/* Timer auto-reload */
8989
if (
9090
pf_scheduler_add (
91-
net,
91+
&net->scheduler_data,
9292
p_iocr->cpm.control_interval,
9393
pf_cpm_control_interval_expired,
9494
arg,
@@ -155,7 +155,7 @@ static int pf_cpm_driver_sw_close_req (
155155
pf_cpm_t * p_cpm = &p_ar->iocrs[crep].cpm;
156156

157157
p_cpm->ci_running = false; /* StopTimer */
158-
pf_scheduler_remove_if_running (net, &p_cpm->ci_timeout);
158+
pf_scheduler_remove_if_running (&net->scheduler_data, &p_cpm->ci_timeout);
159159

160160
pf_eth_frame_id_map_remove (net, p_cpm->frame_id[0]);
161161
if (p_cpm->nbr_frame_id == 2)
@@ -425,7 +425,7 @@ static int pf_cpm_driver_sw_activate_req (
425425
}
426426
pf_scheduler_init_handle (&p_cpm->ci_timeout, "cpm");
427427
ret = pf_scheduler_add (
428-
net,
428+
&net->scheduler_data,
429429
p_cpm->control_interval,
430430
pf_cpm_control_interval_expired,
431431
p_iocr,

src/common/pf_dcp.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static void pf_dcp_restart_sam_timeout (pnet_t * net, const pnet_ethaddr_t * mac
242242

243243
memcpy (&net->dcp_sam, mac, sizeof (net->dcp_sam));
244244
(void)pf_scheduler_restart (
245-
net,
245+
&net->scheduler_data,
246246
PF_DCP_SAM_TIMEOUT,
247247
pf_dcp_clear_sam,
248248
NULL,
@@ -627,7 +627,7 @@ static void pf_dcp_control_signal_led (
627627

628628
/* Schedule another round */
629629
(void)pf_scheduler_add (
630-
net,
630+
&net->scheduler_data,
631631
PF_DCP_SIGNAL_LED_HALF_INTERVAL,
632632
pf_dcp_control_signal_led,
633633
(void *)(uintptr_t)state,
@@ -659,7 +659,7 @@ int pf_dcp_trigger_signal_led (pnet_t * net)
659659
"DCP(%d): Received request to flash LED\n",
660660
__LINE__);
661661
(void)pf_scheduler_add (
662-
net,
662+
&net->scheduler_data,
663663
PF_DCP_SIGNAL_LED_HALF_INTERVAL,
664664
pf_dcp_control_signal_led,
665665
(void *)(2 * PF_DCP_SIGNAL_LED_NUMBER_OF_FLASHES - 1),
@@ -1945,7 +1945,7 @@ static int pf_dcp_identify_req (
19451945
#endif
19461946

19471947
(void)pf_scheduler_add (
1948-
net,
1948+
&net->scheduler_data,
19491949
response_delay,
19501950
pf_dcp_responder,
19511951
p_rsp,

src/common/pf_lldp.c

+12-6
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ void pf_lldp_restart_peer_timeout (
510510
{
511511
pf_port_t * p_port_data = pf_port_get_state (net, loc_port_num);
512512

513-
pf_scheduler_remove_if_running (net, &p_port_data->lldp.rx_timeout);
513+
pf_scheduler_remove_if_running (
514+
&net->scheduler_data,
515+
&p_port_data->lldp.rx_timeout);
514516

515517
/*
516518
* Profinet states that the time to live shall be 20 seconds,
@@ -529,7 +531,7 @@ void pf_lldp_restart_peer_timeout (
529531

530532
if (
531533
pf_scheduler_add (
532-
net,
534+
&net->scheduler_data,
533535
timeout_in_secs * 1000000,
534536
pf_lldp_receive_timeout,
535537
p_port_data,
@@ -547,7 +549,9 @@ void pf_lldp_stop_peer_timeout (pnet_t * net, int loc_port_num)
547549
{
548550
pf_port_t * p_port_data = pf_port_get_state (net, loc_port_num);
549551

550-
pf_scheduler_remove_if_running (net, &p_port_data->lldp.rx_timeout);
552+
pf_scheduler_remove_if_running (
553+
&net->scheduler_data,
554+
&p_port_data->lldp.rx_timeout);
551555
}
552556

553557
/**
@@ -1096,7 +1100,7 @@ static void pf_lldp_trigger_sending (
10961100

10971101
if (
10981102
pf_scheduler_add (
1099-
net,
1103+
&net->scheduler_data,
11001104
PF_LLDP_SEND_INTERVAL * 1000,
11011105
pf_lldp_trigger_sending,
11021106
p_port_data,
@@ -1125,7 +1129,7 @@ static void pf_lldp_tx_restart (pnet_t * net, int loc_port_num, bool send)
11251129

11261130
if (
11271131
pf_scheduler_restart (
1128-
net,
1132+
&net->scheduler_data,
11291133
PF_LLDP_SEND_INTERVAL * 1000,
11301134
pf_lldp_trigger_sending,
11311135
p_port_data,
@@ -1187,7 +1191,9 @@ void pf_lldp_send_disable (pnet_t * net, int loc_port_num)
11871191
"LLDP(%d): Disabling LLDP transmission for port %d\n",
11881192
__LINE__,
11891193
loc_port_num);
1190-
pf_scheduler_remove_if_running (net, &p_port_data->lldp.tx_timeout);
1194+
pf_scheduler_remove_if_running (
1195+
&net->scheduler_data,
1196+
&p_port_data->lldp.tx_timeout);
11911197
}
11921198

11931199
/**

src/common/pf_ppm_driver_sw.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void pf_ppm_drv_sw_send (pnet_t * net, void * arg, uint32_t current_time)
5858
delay = p_arg->ppm.next_exec - current_time;
5959
if (
6060
pf_scheduler_add (
61-
net,
61+
&net->scheduler_data,
6262
delay,
6363
pf_ppm_drv_sw_send,
6464
arg,
@@ -102,7 +102,7 @@ int pf_ppm_drv_sw_activate_req (pnet_t * net, pf_ar_t * p_ar, uint32_t crep)
102102

103103
pf_scheduler_init_handle (&p_ppm->ci_timeout, "ppm");
104104
ret = pf_scheduler_add (
105-
net,
105+
&net->scheduler_data,
106106
p_ppm->control_interval,
107107
pf_ppm_drv_sw_send,
108108
p_iocr,
@@ -124,7 +124,7 @@ int pf_ppm_drv_sw_close_req (pnet_t * net, pf_ar_t * p_ar, uint32_t crep)
124124
p_ar->arep,
125125
crep);
126126

127-
pf_scheduler_remove_if_running (net, &p_ppm->ci_timeout);
127+
pf_scheduler_remove_if_running (&net->scheduler_data, &p_ppm->ci_timeout);
128128

129129
return 0;
130130
}

0 commit comments

Comments
 (0)