1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2007 FRESCOR consortium partners:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politécnica Valencia, SPAIN
9 // Czech Technical University in Prague, CZECH REPUBLIC
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org for a link to partners' websites
18 // FRESCOR project (FP6/2005/IST/5-034026) is funded
19 // in part by the European Union Sixth Framework Programme
20 // The European Union is not liable of any use that may be
24 // based on previous work (FSF) done in the FIRST project
26 // Copyright (C) 2005 Mälardalen University, SWEDEN
27 // Scuola Superiore S.Anna, ITALY
28 // Universidad de Cantabria, SPAIN
29 // University of York, UK
31 // FSF API web pages: http://marte.unican.es/fsf/docs
32 // http://shark.sssup.it/contrib/first/docs/
34 // This file is part of FRSH API
36 // FRSH API is free software; you can redistribute it and/or modify
37 // it under the terms of the GNU General Public License as published by
38 // the Free Software Foundation; either version 2, or (at your option)
41 // FRSH API is distributed in the hope that it will be useful, but
42 // WITHOUT ANY WARRANTY; without even the implied warranty of
43 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 // General Public License for more details.
46 // You should have received a copy of the GNU General Public License
47 // distributed with FRSH API; see file COPYING. If not, write to the
48 // Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
51 // As a special exception, if you include this header file into source
52 // files to be compiled, this header file does not by itself cause
53 // the resulting executable to be covered by the GNU General Public
54 // License. This exception does not however invalidate any other
55 // reasons why the executable file might be covered by the GNU General
57 // -----------------------------------------------------------------------
59 //==============================================
60 // ******** **** ** **
61 // **///// /**/** /** ****
62 // ** /**//** /** **//**
63 // ******* /** //** /** ** //**
64 // **//// /** //**/** **********
65 // ** /** //****/**//////**
66 // ** /** //***/** /**
69 // FNA(Frescor Network Adaptation layer), pronounced "efe ene a"
70 //==============================================================
75 #include "frsh_core_types.h" /* for frsh_resource_id_t, frsh_contract_t, etc */
76 #include "fna_error.h" /* for ERROR constants */
77 #include <stdint.h> /* for uint32_t, UINT32_MAX */
80 * @defgroup fna FNA Private Interface
82 * FNA is a Network adaption layer that allows to plugin new
83 * network protocols to the distributed module.
85 * It is divided in two parts:
86 * - FRSH_FNA: public types and functions for the FRSH API
87 * - FNA: private functions only used within FRSH.
91 //////////////////////////////////////////////////////////////////////
93 //////////////////////////////////////////////////////////////////////
96 * @defgroup fnainit FNA Initialization
99 * These functions need to be called before using any network
107 * This function will be hooked to the frsh_init function and it is
108 * intented to initialize the protocol and its structures.
110 * @param[in] resource_id The network we are referring to (a protocol
111 * could be able to handle several networks at the same time)
115 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
116 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
117 * FNA_ERR_ALREADY_INITIALIZED:
118 * if the function has already been called before (with success) \n
121 int fna_init(const frsh_resource_id_t resource_id);
125 ///////////////////////////////////////////////////////////////////
127 ///////////////////////////////////////////////////////////////////
130 * @defgroup fnavres FNA Virtual Resources
133 * The following functions are used to negotiate, renegotiate and cancel
134 * virtual network resources.
142 * Internal virtual resource id. The type fna_vres_id_t is a pointer to void.
143 * The FRSH layer will keep a map between the frsh_vres_id_t, this
144 * pointer and the resource_id. This pointer could be used as the ID
145 * itself using casting, or as internal pointer to any structure.
148 typedef void *fna_vres_id_t;
151 * fna_contract_negotiate()
153 * The operation negotiates a contract and if accepted it will return
154 * a fna_vres_id_t. It will also check that the given contract_id is unique
155 * within the network.
157 * If the on-line admission test is enabled, it determines whether the
158 * contract can be admitted or not based on the current contracts
159 * established in the network. Then it creates the vres and
160 * recalculates all necessary parameters for the contracts already
161 * present in the system.
163 * This is a potentially blocking operation, it returns when the
164 * system has either rejected the contract, or admitted it and made it
167 * @param[in] resource_id The network we are referring to (a protocol
168 * could be able to handle several networks at the same time)
169 * @param[in] contract The contract parameters to negotiate
170 * @param[out] vres The internal virtual resource id
173 * FNA_NO_ERROR: in this case it also means contract accepted \n
174 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
175 * FNA_ERR_TOO_MANY_VRES: if there is no space for more vres \n
176 * FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
177 * FNA_ERR_CONTRACT_REJECTED: if the contract is not accepted \n
178 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
179 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
180 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
183 int fna_contract_negotiate
184 (const frsh_resource_id_t resource_id,
185 const frsh_contract_t *contract,
186 fna_vres_id_t *vres);
189 * fna_contract_renegotiate_sync()
191 * The operation renegotiates a contract for an existing vres. If
192 * the on-line admission test is enabled it determines whether the
193 * contract can be admitted or not based on the current contracts
194 * established in the system. If it cannot be admitted, the old
195 * contract remains in effect and an error is returned. If it can be
196 * admitted, it recalculates all necessary parameters for the
197 * contracts already present in the system and returns zero. This is a
198 * potentially blocking operation; it returns when the system has
199 * either rejected the new contract, or admitted it and made it
202 * @param[in] resource_id The network we are referring to (a protocol
203 * could be able to handle several networks at the same time)
204 * @param[in] vres The internal virtual resource id to renegotiate
205 * @param[in] new_contract The new contract
208 * FNA_NO_ERROR: in this case it also means contract accepted \n
209 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
210 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
211 * FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
212 * FNA_ERR_CONTRACT_REJECTED: if the contract is not accepted \n
213 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
214 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
215 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
218 int fna_contract_renegotiate_sync
219 (const frsh_resource_id_t resource_id,
220 const fna_vres_id_t vres,
221 const frsh_contract_t *new_contract);
224 * fna_contract_renegotiate_async()
226 * The operation enqueues a renegotiate operation for an existing
227 * vres, and returns immediately. The renegotiate operation is
228 * performed asynchronously, as soon as it is practical; meanwhile the
229 * system operation will continue normally. When the renegotiation is
230 * made, if the on-line admission test is enabled it determines
231 * whether the contract can be admitted or not based on the current
232 * contracts established in the system. If it cannot be admitted, the
233 * old contract remains in effect. If it can be admitted, it
234 * recalculates all necessary parameters for the contracts already
235 * present in the system.
237 * When the operation is completed, notification is made to the
238 * caller, if requested, via a signal. The status of the operation (in
239 * progress, admitted, rejected) can be checked with the
240 * frsh_vres_get_renegotiation_status() operation. The argument
241 * sig_notify can be FRSH_NULL_SIGNAL (no notification), or any FRSH
242 * signal value and in this case signal_info is to be sent with the signal.
244 * @param[in] resource_id The network we are referring to (a protocol
245 * could be able to handle several networks at the same time)
246 * @param[in] vres The internal virtual resource id to renegotiate
247 * @param[in] new_contract The new contract
248 * @param[in] signal_to_notify Signal number to use to notify vres of
249 * the negotiation result. If FRSH_NULL_SIGNAL, no signal will be raised.
250 * @param[in] signal_info: Associated info that will come with the signal.
251 * This parameter will be ignored if signal_to_notify == FRSH_NULL_SIGNAL.
254 * FNA_NO_ERROR: in this case it also means contract accepted \n
255 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
256 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
257 * FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
258 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
259 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
260 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL, or sig_notify is neither
261 * NULL nor a valid POSIX signal \n
264 int fna_contract_renegotiate_async
265 (const frsh_resource_id_t resource_id,
266 const fna_vres_id_t vres,
267 const frsh_contract_t *new_contract,
268 frsh_signal_t signal_to_notify,
269 frsh_signal_info_t signal_info);
272 * fna_vres_get_renegotiation_status()
274 * The operation reports on the status of the last renegotiation
275 * operation enqueued for the specified vres. It is callable even
276 * after notification of the completion of such operation, if
279 * If the vres is not and has not been involved in any of the
280 * frsh_contract_renegotiate_async() or frsh_group_change_mode_async()
281 * operations, the status returned is FNA_NOT_REQUESTED
283 * @param[in] resource_id The network we are referring to (a protocol
284 * could be able to handle several networks at the same time)
285 * @param[in] vres The internal virtual resource id we want the status from
286 * @param[in] renegotiation_status The status of the last renegotiation on
287 * vres (FRSH_RS_IN_PROGRESS, FRSH_RS_REJECTED, FRSH_RS_ADMITTED,
288 * FRSH_RS_NOT_REQUESTED)
291 * FNA_NO_ERROR: in this case it also means contract accepted \n
292 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
293 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
294 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
295 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
296 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
299 int fna_vres_get_renegotiation_status
300 (const frsh_resource_id_t resource_id,
301 const fna_vres_id_t vres,
302 frsh_renegotiation_status_t *renegotiation_status);
307 * The operation eliminates the specified vres
308 * and recalculates all necessary parameters for the contracts
309 * remaining in the system. This is a potentially blocking operation;
310 * it returns when the system has made the changes effective.
312 * @param[in] resource_id The network we are referring to (a protocol
313 * could be able to handle several networks at the same time)
314 * @param[in] vres The internal virtual resource id to destroy
317 * FNA_NO_ERROR: in this case it also means contract accepted \n
318 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
319 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
320 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
321 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
322 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
326 (const frsh_resource_id_t resource_id,
327 const fna_vres_id_t vres);
330 * fna_vres_get_contract()
332 * This operation stores the contract parameters currently associated
333 * with the specified vres in the variable pointed to by
334 * contract. It returns an error if the vres_id is not recognised.
336 * @param[in] resource_id The network we are referring to (a protocol
337 * could be able to handle several networks at the same time)
338 * @param[in] vres The internal virtual resource id
339 * @param[out] contract The contract parameters that we want
342 * FNA_NO_ERROR: in this case it also means contract accepted \n
343 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
344 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
345 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
346 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
347 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
350 int fna_vres_get_contract
351 (const frsh_resource_id_t resource_id,
352 const fna_vres_id_t vres,
353 frsh_contract_t *contract);
356 * fna_vres_get_usage()
358 * This function gets the execution time spent by all messages that have been
359 * sent through the specified vres.
361 * @param[in] resource_id The network we are referring to (a protocol
362 * could be able to handle several networks at the same time)
363 * @param[in] vres The internal virtual resource id
364 * @param[out] usage Execution time spent by this vres
367 * FNA_NO_ERROR: in this case it also means contract accepted \n
368 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
369 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
370 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
371 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
372 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
375 int fna_vres_get_usage
376 (const frsh_resource_id_t resource_id,
377 const fna_vres_id_t vres,
378 struct timespec *usage);
381 * fna_vres_get_remaining_budget()
383 * This function stores in the variable pointed to by budget the
384 * remaining execution-time budget associated with the specified
385 * vres in the present period.
387 * @param[in] resource_id The network we are referring to (a protocol
388 * could be able to handle several networks at the same time)
389 * @param[in] vres The internal virtual resource id
390 * @param[out] remaining_budget The remaining budget for this period
393 * FNA_NO_ERROR: in this case it also means contract accepted \n
394 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
395 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
396 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
397 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
398 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
401 int fna_vres_get_remaining_budget
402 (const frsh_resource_id_t resource_id,
403 const fna_vres_id_t vres,
404 struct timespec *remaining_budget);
407 * fna_vres_get_budget_and_period()
409 * This function gets the budget and period associated with the specified vres
410 * for each period. If one of these pointers is NULL, the corresponding
411 * information is not stored.
413 * @param[in] resource_id The network we are referring to (a protocol
414 * could be able to handle several networks at the same time)
415 * @param[in] vres The internal virtual resource id
416 * @param[out] budget The budget associated to vres
417 * @param[out] period The period associated to vres
420 * FNA_NO_ERROR: in this case it also means contract accepted \n
421 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
422 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
423 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
424 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
425 * FNA_ERR_BAD_ARGUMENT: if both pointers are NULL \n
428 int fna_vres_get_budget_and_period
429 (const frsh_resource_id_t resource_id,
430 const fna_vres_id_t vres,
431 struct timespec *budget,
432 struct timespec *period);
436 ///////////////////////////////////////////////////////////////////
437 // SPARE CAPACITY FUNCIONS
438 ///////////////////////////////////////////////////////////////////
441 * @defgroup fnaspare FNA Spare Capacity
444 * The following functions are used to get spare capacity data
450 * fna_resource_get_capacity()
452 * This operation gets the spare capacity currently assigned to a importance
453 * level. If we divide this value by UINT32_MAX we will get the network
454 * utilization associated to the spare capacity of a importance level.
456 * The following is typically in stdint.h: \n
457 * - typedef unsigned int uint32_t; \n
458 * - # define UINT32_MAX (4294967295U) \n
460 * @param[in] resource_id The network we are referring to (a protocol
461 * could be able to handle several networks at the same time)
462 * @param[in] importance The importance we want the capacity of
463 * @param[out] capacity The spare capacity for that importance level
466 * FNA_NO_ERROR: in this case it also means contract accepted \n
467 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
468 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
469 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
470 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
473 int fna_resource_get_capacity
474 (const frsh_resource_id_t resource_id,
475 const int importance,
479 * fna_resource_get_total_weight()
481 * This function gets the sum of the weight parameters for all vres in a
482 * network of an importance level.
484 * @param[in] resource_id The network we are referring to (a protocol
485 * could be able to handle several networks at the same time)
486 * @param[in] importance The importance we want the total weight of
487 * @param[out] total_weight The total weight for that importance level
490 * FNA_NO_ERROR: in this case it also means contract accepted \n
491 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
492 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
493 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
494 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
497 int fna_resource_get_total_weight
498 (const frsh_resource_id_t resource_id,
499 const int importance,
503 * fna_vres_decrease_capacity()
505 * This function allows to ask for less budget and period than what we
506 * received. The request must be compatible with the rest of contract
507 * parameters of the vres. If we want to recover the released capacity
508 * we will need to renegotiate.
510 * @param[in] resource_id The network we are referring to (a protocol
511 * could be able to handle several networks at the same time)
512 * @param[in] vres The internal virtual resource id
513 * @param[in] new_budget The new_budget
514 * @param[in] new_period The new Period
517 * FNA_NO_ERROR: in this case it also means contract accepted \n
518 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
519 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
520 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
521 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
522 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
523 * FNA_ERR_CONTRACT_REJECTED: if it is incompatible with the current
527 int fna_vres_decrease_capacity
528 (const frsh_resource_id_t resource_id,
529 const fna_vres_id_t vres,
530 const struct timespec new_budget,
531 const struct timespec new_period);
535 ///////////////////////////////////////////////////////////////////
536 // SEND RECEIVE OPERATIONS
537 ///////////////////////////////////////////////////////////////////
540 * @defgroup fnasendrecv FNA Send and Receive
543 * The following functions are used to send and receive
551 * Similar to previous function but now the sending thread gets blocked
552 * until the message is already sent to the network.
554 * @param[in] endpoint The send endpoint we are sending through. It must
555 * be bound to a virtual resource (resource_id is in the endpoint).
556 * @param[in] msg The message we want to send
557 * @param[in] size The size in bytes of the message
560 * FNA_NO_ERROR: in this case it also means contract accepted \n
561 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
562 * FNA_ERR_NOT_BOUND: if endpoint is not bound to a valid vres \n
563 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
564 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
565 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
566 * FNA_ERR_TOO_LARGE: if the message is too large for the network protocol \n
567 * FNA_ERR_BUFFER_FULL: if the message has been discarded because
568 * the queue is full (and does not have the policy FNA_QP_OLDEST) \n
572 (const frsh_send_endpoint_t *endpoint,
579 * This operation sends a message stored in msg and of length size
580 * through the given send endpoint. The operation is non-blocking and
581 * returns immediately.
583 * @param[in] endpoint The send endpoint we are sending through. It must
584 * be bound to a virtual resource (resource_id is in the endpoint).
585 * @param[in] msg The message we want to send
586 * @param[in] size The size in bytes of the message
589 * FNA_NO_ERROR: in this case it also means contract accepted \n
590 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
591 * FNA_ERR_NOT_BOUND: if endpoint is not bound to a valid vres \n
592 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
593 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
594 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
595 * FNA_ERR_TOO_LARGE: if the message is too large for the network protocol \n
596 * FNA_ERR_BUFFER_FULL: if the message has been discarded because
597 * the queue is full (and does not have the policy FNA_QP_OLDEST) \n
601 (const frsh_send_endpoint_t *endpoint,
608 * This operation is used to receive messages from the network with a
609 * blocking behavior (if there are no messages this operation blocks
610 * the calling thread).
612 * When a message is available, it is copied to buffer (up to its size).
613 * The number of bytes copied is returned in received_bytes. The rest
614 * of the bytes of that message will be lost or not depending on the
615 * protocol (FNA_ERR_NO_SPACE will be returned if it is).
617 * The function fails with FNA_ERR_NO_SPACE if the buffersize is
618 * too small for the message received. In this case the message is
621 * Messages arriving at a receiver buffer that is full will be handled
622 * according to the queueing policy of the endpoint (overwrite oldest,
625 * @param[in] endpoint The receive endpoint we are receiving from.
626 * (resource_id is in the endpoint).
627 * @param[out] buffer Buffer for storing the received message
628 * @param[in] buffer_size The size in bytes of this buffer
629 * @param[out] received_bytes The actual number of received bytes
632 * FNA_NO_ERROR: in this case it also means contract accepted \n
633 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
634 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
635 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
636 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
637 * FNA_ERR_NO_SPACE: if the message size is bigger than the
638 * provided buffer. \n
642 (const frsh_receive_endpoint_t *endpoint,
644 const size_t buffer_size,
645 size_t *received_bytes);
648 * fna_receive_async()
650 * This operation is similar to the previous one but it works in a non
651 * blocking (asynchronous) fashion. If no message is available it
652 * returns with error FNA_NO_MESSAGE.
654 * @param[in] endpoint The receive endpoint we are receiving from.
655 * (resource_id is in the endpoint).
656 * @param[out] buffer Buffer for storing the received message
657 * @param[in] buffer_size The size in bytes of this buffer
658 * @param[out] received_bytes The actual number of received bytes
661 * FNA_NO_ERROR: in this case it also means contract accepted \n
662 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
663 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
664 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
665 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
666 * FNA_ERR_NO_SPACE: if the message size is bigger than the
667 * provided buffer. \n
668 * FNA_NO_MESSAGE: if no messages are available in the queue. \n
671 int fna_receive_async
672 (const frsh_receive_endpoint_t *endpoint,
674 const size_t buffer_size,
675 size_t *received_bytes);
678 * fna_send_endpoint_get_status()
680 * This function tells the number of messages still pending in the
681 * endpoint queue, whether the network is up or down with some
682 * optional information which is protocol_dependent.
684 * @param[in] endpoint The send endpoint (resource_id is in the endpoint).
685 * @param[out] number_of_pending_messages The number of pending messages
686 * @param[out] network_status How is the network (up, down..)
687 * @param[out] protocol_status Protocol dependent status info
690 * FNA_NO_ERROR: in this case it also means contract accepted \n
691 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
692 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
693 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
694 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
697 int fna_send_endpoint_get_status
698 (const frsh_send_endpoint_t *endpoint,
699 int *number_of_pending_messages,
700 frsh_endpoint_network_status *network_status,
701 frsh_protocol_status_t *protocol_status);
704 * fna_receive_endpoint_create()
706 * This operation creates a receive endpoint associated with a
707 * undirectional stream within a network interface of the node.
709 * Receiving endpoints are not bound to any network vres, this is
710 * because don't originate any traffic.
712 * Note that the protocol address is not needed for reception because
713 * it can be determined internally by FRSH based on the network_id.
715 * Note also that messages may come from diferent originators.
717 * @param[in] resource_id Id of the network from which we listen.
718 * @param[in] stream_id Id of the stream within the network.
719 * @param[in] queueing_info Buffering information(queue size and
721 * @param[in] protocol_info Extra protocol info opaque for the
723 * @param[out] endpoint Placeholder for the endpoint object.
726 * FNA_NO_ERROR: in this case it also means contract accepted \n
727 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
728 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
729 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
730 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
732 int fna_receive_endpoint_create
733 (const frsh_resource_id_t resource_id,
734 const frsh_stream_id_t stream_id,
735 const frsh_endpoint_queueing_info_t queueing_info,
736 const frsh_protocol_info_t protocol_info,
737 frsh_receive_endpoint_t *endpoint);
740 * fna_receive_endpoint_get_pending_messages
742 * This function tells the number of messages still pending in the
743 * endpoint queue, whether the network is up or down and some optional
744 * information which is protocol dependent.
746 * @param[in] endpoint The receive endpoint (resource_id is in the endpoint).
747 * @param[out] number_of_pending_messages The number of pending messages
748 * @param[out] network_status How is the network (up, down..)
749 * @param[out] protocol_status Protocol dependent status info
752 * FNA_NO_ERROR: in this case it also means contract accepted \n
753 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
754 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
755 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
756 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
759 int fna_receive_endpoint_get_status
760 (const frsh_receive_endpoint_t *endpoint,
761 int *number_of_pending_messages,
762 frsh_endpoint_network_status *network_status,
763 frsh_protocol_status_t *protocol_status);
767 //////////////////////////////////////////////////////////////////////
768 // NETWORK CONFIGURATION FUNCTIONS
769 //////////////////////////////////////////////////////////////////////
772 * @defgroup frshfnaconfig FNA Network Configuration
775 * These functions are needed to set/get some network dependent values
781 * fna_network_message_get_max_size()
783 * This operation gives the maximum number of bytes that can be sent
784 * at a time through the send function when using the network designated by
785 * 'resource_id' and sending it to 'destination'.
787 * If the application needs to send bigger messages it will have to
790 * Some protocols, like IP, are capable of sending large messages
791 * (and use fragmentation internally) but other protocols don't.
793 * @param[in] resource_id The network we want the tx time from.
794 * @param[in] destination The destination address
795 * @param[out] max_size The maximum number of bytes for each message
799 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
800 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
801 * FNA_ERR_RESOURCE_ID_INVALID: if resource id does not represent
802 * a network accessible from the current processing node \n
803 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL or destination is
807 int fna_network_message_get_max_size
808 (const frsh_resource_id_t resource_id,
809 const frsh_network_address_t destination,
813 * fna_network_bytes_to_budget()
815 * This operation converts a number of bytes into a temporal budget for
816 * a specific network. Network overheads are not included here but are
817 * considered internally when negotiating a specific contract.
819 * @param[in] resource_id The network
820 * @param[in] nbytes Number of bytes
821 * @param[out] budget The network budget for nbytes
825 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
826 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
827 * FNA_ERR_RESOURCE_ID_INVALID: if resource id does not represent
828 * a network accessible from the current processing node \n
829 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL or nbytes is less
833 int fna_network_bytes_to_budget
834 (const frsh_resource_id_t resource_id,
836 struct timespec *budget);
839 * fna_network_budget_to_bytes()
841 * This operation converts a temporal budget into a number of bytes for
842 * a specific network. Network overheads are not included.
844 * @param[in] resource_id The network
845 * @param[in] budget The network budget for nbytes
846 * @param[out] nbytes Number of bytes
850 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
851 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
852 * FNA_ERR_RESOURCE_ID_INVALID: if resource id does not represent
853 * a network accessible from the current processing node \n
854 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL or budget refers to
855 * an invalid time value \n
858 int fna_network_budget_to_bytes
859 (const frsh_resource_id_t resource_id,
860 const struct timespec *budget,
864 * fna_network_get_min_effective_budget()
866 * This operation gets the minimum effective budget for a network. Each message
867 * consumes a contracted budget in "chunks" (i.e: packets) that we call
868 * minimum effective budget.
870 * A negotiated contract, for N bytes in a period T, means that there is a
871 * virtual resource that reserves for the user:
873 * Ceiling ((N bytes) / budget_to_bytes (min_effective_budget)) "CHUNKS"
875 * Note that if the user decides not to send these N bytes at once but, say,
876 * one byte at a time, it will consume one "CHUNK" at a time and the reserved
877 * budget will become exhausted before sending all the bytes.
879 * @param[in] resource_id The network
880 * @param[out] budget The network budget
884 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
885 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
886 * FNA_ERR_RESOURCE_ID_INVALID: if resource id does not represent
887 * a network accessible from the current processing node \n
888 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
891 int fna_network_get_min_effective_budget
892 (const frsh_resource_id_t resource_id,
893 struct timespec *budget);