summaryrefslogtreecommitdiff
path: root/cesar/cl/inc/context.h
blob: da9dc2ca28a803ef3de544edb0112056e6e94e3d (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 CL_INC_CONTEXT_H_
#define CL_INC_CONTEXT_H_

/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cl/inc/context.h
 * \brief   The convergence layer context.
 * \ingroup cl
 * 
 */

#include "lib/rnd.h"
#include "mac/common/mfs.h"
#include "mac/common/store.h"
#include "mac/common/config.h"
#include "mac/sar/sar.h"

#include "cl/inc/cl_mactotei.h"
#include "cl/inc/trace.h"

/** data tx structure. */
struct cl_data_tx_t
{
    /** the callback function to use once the data hab been sent. */
    cl_data_send_done_cb_t cb;
    /** user data to provide with the callback. */
    void *user;
};
typedef struct cl_data_tx_t cl_data_tx_t;

/** data tx structure. */
struct cl_data_rx_t
{
    /** callback to call the upperlayer once the CL receives a data. */
    cl_data_recv_cb_t cb;
    /** user value to provide with the function callback. */
    void *user;
};
typedef struct cl_data_rx_t cl_data_rx_t;

/** MME tx structure to the upper layer*/
struct cl_mme_tx_t
{
    /** function to call when a mme is for the driver */
    cl_data_recv_cb_t cb;
    /** user data */
    void *user;
    /** mme buffer address */
    u8 *mme_buffer;
};
typedef struct cl_mme_tx_t cl_mme_tx_t; 


struct cl_mme_recv_t
{
    /** The buffer received previously */
    u8 *buffer;
    /** From which layer it comes. */
    bool sar;
};

/** cl mme context */
struct cl_mme_t
{
    /** The Call back to inform the upper layer when a MME has been processed 
     * */
    cl_mme_ul_recv_done_cb_t ul_mme_recv_done;
    void *ul_mme_recv_done_user_data;

    /** Callback to use to add a buffer to the CP. */
    cl_mme_buffer_add_cb_t mme_buffer_add_cb;
    /** The user data to provide with the bellow callback. */
    void *mme_buffer_add_user_data;
    
    /** Callback to call on each reception of MME. */
    cl_mme_recv_cb_t mme_recv_cb;
    /** Data to proved with the callback*/
    void *mme_recv_user_data;
    
    /** Data corresponding to the mme_recv message send to the CP. */
    cl_mme_recv_t mme_recv;
};
typedef struct cl_mme_t cl_mme_t;

struct cl_t
{
    /** The sar context use to send the MME or data. */
    sar_t *sar;
    
    /** Mac store reference. */
    mac_store_t *mac_store;

    /** randome value generator to generate the confounder for the MME. */
    lib_rnd_t random_generator;
    
    /** MME module to use to send or receive the MME to the CP. */
    cl_mme_t mme;
    
    /** mactotei table to send data over the PLC. */
    cl_mactotei_table_t *mactotei;
    
    /** send data context. */
    cl_data_tx_t data_tx;
    
    /** recevie data context. */
    cl_data_rx_t data_rx;
    
    /** When a MME is send as data to the local tei */
    cl_mme_tx_t mme_ul_send;
    
    /** MME buffer to provide to the SAR */
    u8 mme_buffer [2048] __attribute__((aligned(2048)));

    /** The mac config */
    mac_config_t *mac_config;

    /** Tracing system */
#if CONFIG_TRACE
    /** cl Trace */
    trace_buffer_t trace;
#endif /* !CONFIG_TRACE */
};

#endif /* CL_INC_CONTEXT_H_ */