ROFL-pipeline  v0.6.0dev
port_queue.h
Go to the documentation of this file.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
12 #ifndef __PORT_QUEUE_H__
13 #define __PORT_QUEUE_H__
14 
15 #include <stdbool.h>
16 #include <inttypes.h>
17 
18 #include "rofl.h"
19 #include "platform/lock.h"
20 
21 #define PORT_QUEUE_MAX_LEN_NAME 32
22 
23 //Opaque platform queue state (to be used, maybe, for platform hooks)
24 typedef void platform_queue_state_t;
25 
30 typedef struct queue_stats {
31  uint64_t tx_packets; /* Number of transmitted packets by the queue. */
32  uint64_t tx_bytes; /* Number of transmitted bytes by the queue. */
33  uint64_t overrun; /* Number of packets dropped due to overrun. */
34 
35  //Mutex for statistics
36  platform_mutex_t* mutex;
38 
39 
49 typedef struct port_queue{
50 
51  bool set; //Signal if queue is set (running or used)
52 
56  uint32_t id;
57 
61  char name[PORT_QUEUE_MAX_LEN_NAME];
62 
66  uint16_t length;
67 
71  uint16_t min_rate;
72 
76  uint16_t max_rate;
77 
82 
83  /* Opaque platform queue specific extra state */
84  platform_queue_state_t* platform_queue_state;
86 
87 
88 /*
89 * Functions
90 */
91 
92 //C++ extern C
93 ROFL_BEGIN_DECLS
94 
95 /*
96 * @brief Init a port_queue structure.
97 * @ingroup mgmt
98 */
99 rofl_result_t __port_queue_init(port_queue_t* queue, uint32_t id, char* name, uint16_t length, uint16_t min_rate, uint16_t max_rate);
100 
101 /*
102 * @brief Destroy a port_queue structure
103 * @ingroup mgmt
104 */
105 rofl_result_t __port_queue_destroy(port_queue_t* queue);
106 
107 //C++ extern C
108 ROFL_END_DECLS
109 
110 #endif //PORT_QUEUE
queue_stats_t stats
Queue statistics.
Definition: port_queue.h:81
Defines the locking interface used by the library. The user of the library MUST provide an implementa...
struct port_queue port_queue_t
Switch queue abstraction.
uint32_t id
Queue id.
Definition: port_queue.h:56
uint16_t max_rate
Maximum rate (0 when unknown)
Definition: port_queue.h:76
char name[PORT_QUEUE_MAX_LEN_NAME]
Queue name.
Definition: port_queue.h:61
uint16_t length
Length of the queue (slot num.)
Definition: port_queue.h:66
struct queue_stats queue_stats_t
Queue stats.
Switch queue abstraction.
Definition: port_queue.h:49
Queue stats.
Definition: port_queue.h:30
uint16_t min_rate
Minimum rate (0 when unknown)
Definition: port_queue.h:71