summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/cp/inc/cp.h
blob: 9a0aeee7caaf29cf623240ab35b763067ba7eddc (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
122
123
124
125
126
127
128
129
130
#ifndef ce_rx_cp_inc_cp_h
#define ce_rx_cp_inc_cp_h
/* Cesar project {{{
 *
 * Copyright (C) 2009 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    ce/rx/cp/inc/cp.h
 * \brief   Interface to use the CE RX in the CP context (private part).
 * \ingroup ce_rx
 *
 * This header contains the private part of the functions used for the
 * interface between the communication of the CP and the CE RX.
 *
 * This functions must be called in the context of the CE RX and are used to
 * set-up the works that must be executed by the CP.
 */

#include "lib/mbox.h"
#include "cp/types.h"
#include "mac/common/tonemap.h"
#include "ce/rx/inc/rx.h"

/**
 * Timer value for refreshing tone maps (in second).
 */
#define CE_RX_REFRESH_TONE_MAP_S 25

/**
 * Mailbox used for the exchange of work between the CE RX and the CP.
 * The work that can be posted from the CE RX to the CP is quite simple:
 * sending MME to the peer. It can be divided into two sub-parts:
 *  - sending a tone map,
 *  - preventing tone map expiration on the other side (by sending a refresh).
 * The information contains in this node are enough to send a tone map
 * (pointed with the tone map index) to a peer (pointed by its TEI).
 *
 * When the CP process a mail, the state of the structure tone maps has maybe
 * changed (the CE RX can maybe generate multiple tone maps and during this
 * time, the CP has maybe not process our mail). That's why, the mail contains
 * some copy of the fields of the tone maps structure (default TMI, TMI list
 * and intervals list).
 *
 * @warning: if you add a field to this structure, you must add a it to the
 * function ce_rx_cp_mbox_new_node.
 */
typedef struct ce_rx_cp_mbox_t
{
    /**
     * The mailbox node.
     */
    mbox_node_t mbox_node;
    /**
     * The TEI of the peer.
     */
    cp_tei_t tei;
    /**
     * Default TMI.
     */
    u8 default_tmi;
    /**
     * The list of valid tone map index.
     * This field is a bit field (bit is set to one when the tone map is
     * active).
     */
    u32 tmi_list;
    /**
     * List of valid intervals.
     */
    tonemap_intervals_t intervals_list;
    /**
     * The tone map index.
     * If this field is set to 0, no tone map should be sent, just a refresh
     * MME (to prevent tone maps expiration).
     */
    u8 new_tmi;
    /**
     * The old tone map index.
     * When the bit loading of the CE RX creates a new tone map based on an
     * old one, it can give an hint on the tone map index used.
     */
    u8 old_tmi;
    /**
     * Initial CE?
     */
    bool initial_ce;
} ce_rx_cp_mbox_t;

BEGIN_DECLS

/**
 * Initialize the communication between the CE RX and the CP.
 * \param  ce_rx  the CE RX context.
 */
void
ce_rx_cp_init (ce_rx_t *ce_rx);

/**
 * Uninitialize the communication between the CE RX and the CP.
 * \param  ce_rx  the CE RX context.
 */
void
ce_rx_cp_uninit (ce_rx_t *ce_rx);

/**
 * Add work for the CP from the CE RX context.
 * \param  ce_rx  the context of the CE in RX.
 * \param  peer  the peer STA.
 * \param  new_tmi  the new TMI of the tone map to send.
 * \param  old_tmi  the old TMI used (if there is one, 0 otherwise).
 * \param  initial_ce  initial channel estimation?
 */
void
ce_rx_cp_send_mme_new_tone_map (ce_rx_t *ce_rx, sta_t *peer, u8 new_tmi,
                                u8 old_tmi, bool initial_ce);

/**
 * Add work to prevent expirations of the valid tone maps list of a peer.
 * \param  ce_rx  the context of the CE in RX.
 * \param  peer  the peer STA.
 */
void
ce_rx_cp_send_mme_refresh_tmi_list (ce_rx_t *ce_rx, sta_t *peer);

END_DECLS

#endif /* ce_rx_cp_inc_cp_h */