2 * @file frescan_queues.h
4 * @brief FRESCAN queues to manage the packets by prio and servers
15 * This file contains the FRESCAN queues where frescan packets are stored and
20 //----------------------------------------------------------------------
21 // Copyright (C) 2006 - 2009 by the FRESCOR consortium:
23 // Universidad de Cantabria, SPAIN
24 // University of York, UK
25 // Scuola Superiore Sant'Anna, ITALY
26 // Kaiserslautern University, GERMANY
27 // Univ. Politecnica Valencia, SPAIN
28 // Czech Technical University in Prague, CZECH REPUBLIC
30 // Thales Communication S.A. FRANCE
31 // Visual Tools S.A. SPAIN
32 // Rapita Systems Ltd UK
35 // See http://www.frescor.org
37 // The FRESCOR project (FP6/2005/IST/5-034026) is funded
38 // in part by the European Union Sixth Framework Programme
39 // The European Union is not liable of any use that may be
43 // based on previous work (FSF) done in the FIRST project
45 // Copyright (C) 2005 Mälardalen University, SWEDEN
46 // Scuola Superiore S.Anna, ITALY
47 // Universidad de Cantabria, SPAIN
48 // University of York, UK
50 // This file is part of FNA (Frescor Network Adaptation)
52 // FNA is free software; you can redistribute it and/or modify it
53 // under terms of the GNU General Public License as published by the
54 // Free Software Foundation; either version 2, or (at your option) any
55 // later version. FNA is distributed in the hope that it will be
56 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
57 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
58 // General Public License for more details. You should have received a
59 // copy of the GNU General Public License along with FNA; see file
60 // COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
61 // Cambridge, MA 02139, USA.
63 // As a special exception, including FNA header files in a file,
64 // instantiating FNA generics or templates, or linking other files
65 // with FNA objects to produce an executable application, does not
66 // by itself cause the resulting executable application to be covered
67 // by the GNU General Public License. This exception does not
68 // however invalidate any other reasons why the executable file might be
69 // covered by the GNU Public License.
70 // -----------------------------------------------------------------------
74 #ifndef _MARTE_FRESCAN_QUEUES_H_
75 #define _MARTE_FRESCAN_QUEUES_H_
77 #include "frescan_types.h"
80 * frescan_queues_init() - initialize the queues
82 * This function initializes the queue structures for an instance of frescan
83 * protocol. We provide different sizes and constants so, at initialization
84 * time, the structures are allocated from the heap. Note, that this approach
85 * is not conflicting with real-time systems where typically static allocation
86 * is used because we only do it at the initialization and also because we
87 * are using a real-time memory allocator. The advantage is that we have the
88 * flexibility of using different values for different instances of the
89 * protocol and that we can also supply the protocol compiled as a library.
91 * @queues: the queues structures
92 * @frescan_init_params_t: some init parameters for the queues
94 * TODO: add maximum number of packets per queue?? so far they are taken from
96 * TODO: add policy for overwritting
99 int frescan_queues_init(frescan_queues_t *queues,
100 frescan_init_params_t *params);
103 * frescan_pqueue_enqueue() - enqueue a packet
105 * this function enqueues a frescan_packet into the a priority queue. For the
106 * case of same priority packets they are stored at the tail, following a FIFO
109 * @pqueue: the priority queue
110 * @packet: the packet that we want to store
114 int frescan_pqueue_enqueue(frescan_prio_queue_t *pqueue,
115 frescan_packet_t *packet,
116 frescan_prio_t prio);
119 * frescan_pqueue_requeue() - requeue a packet
121 * this function requeues a previously extracted frescan_packet. It puts
122 * the packet at the head of the fifo queue. This is useful when you abort
123 * the transmission of the packet beacuse another one with highest priority
124 * has arrived, and you still want to preserve the order in which the packets
127 * @pqueue: the priority queue
128 * @packet: the packet that we want to store
132 int frescan_pqueue_requeue(frescan_prio_queue_t *pqueue,
133 frescan_packet_t *packet,
134 frescan_prio_t prio);
137 * frescan_pqueue_dequeue() - dequeue the packet with highest priority
139 * @pqueue: the priority queue
140 * @packet: the packet extracted
141 * @blocking: if there are no packets we can choose to block or not. In
142 * a non-blocking mode, if there are no packets 'packet' will be NULL
146 int frescan_pqueue_dequeue(frescan_prio_queue_t *pqueue,
147 frescan_packet_t **packet,
148 frescan_prio_t *packet_prio,
152 * frescan_pqueue_get_highest_prio() - returns the packet with highest prio
153 * but not extracting it from the queue.
155 * @pqueue: the priority queue
156 * @packet: the packet with highest prio (not extracted from the pqueue)
160 int frescan_pqueue_get_highest_prio(frescan_prio_queue_t *pqueue,
161 frescan_packet_t **packet,
162 frescan_prio_t *packet_prio);
165 * frescan_servers_enqueue() - enqueue a packet through a server
167 * @net: the network instance
168 * @id: the identificator for the server
169 * @packet: the packet being enqueued
173 int frescan_servers_enqueue(frescan_network_t net,
175 frescan_packet_t *packet);
178 * frescan_servers_requeue() - requeue a packet through a server
180 * @net: the network instance
181 * @id: the identificator for the server
182 * @packet: the packet being requeued
186 int frescan_servers_requeue(frescan_network_t net,
188 frescan_packet_t *packet);
191 * frescan_servers_dequeue() - dequeue a packet from a server
193 * @net: the network instance
194 * @id: the identificator for the server
195 * @packet: the packet dequeued
199 int frescan_servers_dequeue(frescan_network_t net,
201 frescan_packet_t **packet,
202 frescan_prio_t *packet_prio);
204 #endif // _MARTE_FRESCAN_QUEUES_H_