summaryrefslogtreecommitdiff
path: root/cesar/cp2/cco/bw/bw_prio_heap.h
blob: 7c099597db58573a2d1accf91cdb9cbe8cb28bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef cp2_cco_bw_prio_heap_h
#define cp2_cco_bw_prio_heap_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp_cco_bw_prio_heap.h
 * \brief   « brief description »
 * \ingroup « module »
 *
 * « long description »
 */
#include "lib/list.h"
#include "cp2/cp.h"

/**
 * connection storage regarding to its priority and time arrival.
 */
struct cp_cco_bw_prio_conn_t
{
    /**
     * connection identifier
     */
    u16 cid;

    /**
     * Allocation status true : allocated false : not allocated
     */
    bool alloc_status;

    /**
     * Node of the List
     */
    list_node_t node;

};
typedef struct cp_cco_bw_prio_conn_t cp_cco_bw_prio_conn_t;

/**
 * Table that stores the pending connection in order of arrival. Each
 * table has a specific priority level assigned (0 to 3). It manages the
 * order and return the most prior connection
 */
struct cp_cco_bw_prio_heap_t
{
    /**
     * level of priority of the heap (4 different levels)
     */
    u8 table_priority_level;

    /**
     * stage of the allocation. Faster to get to the next connection to
     * allocate.
     */
    u32 nb_conn_allocated;

    /**
     * Number of connection into the heap
     * */
    u32 nb_conn;

    /**
     * first connection of the heap
     */
    list_t conns;

};
typedef struct cp_cco_bw_prio_heap_t cp_cco_bw_prio_heap_t;

/*
 * gets the most prior pending connection return its CID.
 * \param  ctx  the module context.
 * \return  \todo fill this
 *
 */
cp_cco_bw_prio_conn_t*
cp_cco_bw_prio_heap_get_most_prior_conn (cp_t *ctx);

/**
 * delete a connection.
 * \param  ctx  the module context.
 * \param  cid  Connection identifier
 *
 */
void
cp_cco_bw_prio_heap_del_conn (cp_t *ctx, u16 cid);

/**
 * add a connection.
 * \param  ctx  the module context.
 * \param  cid  Connection identifier
 *
 */
void
cp_cco_bw_prio_heap_add_conn (cp_t *ctx, u16 cid, u8 prio);

/**
 * Clears the status of the allocation
 * \param  ctx  Control Plane Context
 *
 */
void
cp_cco_bw_prio_heap_clear_conn(cp_t *ctx);

/**
 * Init function
 */
void
cp_cco_bw_prio_heap_init(cp_t *ctx);

/**
 * Uninit function
 */
void
cp_cco_bw_prio_heap_uninit(cp_t *ctx);

#endif /* cp_cco_bw_prio_heap_h */