2 * @file frescan_servers.h
4 * @brief FRESCAN sporadic servers
15 * This file contains the FRESCAN sporadic servers that allow to isolate
16 * different streams of data by assigning them a budget and replenishment
21 * See MaRTE OS license
25 #ifndef _MARTE_FRESCAN_SERVERS_H_
26 #define _MARTE_FRESCAN_SERVERS_H_
28 #include "frescan.h" // frescan_prio_t, frescan_ss_t
29 #include "frescan_packets.h" // frescan_packet_t
30 #include <time.h> // struct timespec
31 #include "frescan_data.h"
34 * frescan_servers_init() - initialize server structures
36 * @net: the network instance
39 extern int frescan_servers_init(frescan_network_t net);
42 * frescan_servers_create() - create a sporadic server
44 * @net: the network instance
45 * @params: the parameters for the server
46 * @id: the identificator for the server as a return value
50 extern int frescan_servers_create(frescan_network_t net,
51 const frescan_server_params_t *params,
55 * frescan_servers_update() - update a sporadic server data
57 * @net: the network instance
58 * @params: the parameters for the server
59 * @id: the identificator for the server
63 extern int frescan_servers_update(frescan_network_t net,
64 const frescan_server_params_t *params,
68 * frescan_servers_destroy() - delete a sporadic server
70 * @net: the network instance
71 * @id: the identificator for the server
75 extern int frescan_servers_destroy(frescan_network_t net, frescan_ss_t id);
78 * frescan_servers_get_data() - get a sporadic server data
80 * @net: the network instance
81 * @params: the parameters of the server
82 * @id: the identificator for the server
86 extern int frescan_servers_get_data(frescan_network_t net,
87 frescan_server_params_t *params,
91 * frescan_servers_get_current_budget() - get the current sporadic server budget
93 * @net: the network instance
94 * @id: the identificator for the server
95 * @current_budget: the current budget of the server
99 extern int frescan_servers_get_current_budget(frescan_network_t net,
101 frescan_budget_t *current_budget);
104 * frescan_servers_get_highest_prio() - get the server with highest priority
106 * @net: the network instance
107 * @id: the identificator for the server
108 * @prio: the priority of that server
110 * If "id" is returned with a value of FRESCAN_MX_IDS,
111 * there are no active servers.
112 * NOTE: id=FRESCAN_MX_IDS is the identifier for fixed priority messages
116 extern int frescan_servers_get_highest_prio(frescan_network_t net,
118 frescan_prio_t *prio);
121 * frescan_servers_frame_sent() - hook to control the server budget and prio
123 * @net: the network instance
124 * @id: the identificator for the server
125 * @packet: the packet sent (with its timestamp)
127 * This function is called when a frame has been effectively sent through the
128 * CAN bus and that frame is associated to a certain server. The function
129 * decreases the capacity of the server and sets the priority to background
130 * in case the budget is exhausted.
132 * NOTE: the replenishment operation is programmed using the corresponding
133 * function at frescan_servers_replenishments module
136 extern int frescan_servers_frame_sent(frescan_network_t net,
138 frescan_packet_t *packet);
140 #endif // _MARTE_FRESCAN_SERVERS_H_