summaryrefslogtreecommitdiff
path: root/cesar/cl/inc/context.h
blob: 662e56118ff9752274a74782ef7a0dbad5004154 (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#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 "common/defs/ethernet.h"

#include "lib/slab.h"
#include "mac/common/mfs.h"
#include "mac/common/store.h"
#include "mac/common/config.h"
#include "mac/sar/sar.h"
#include "cl/cl_mactotei.h"
#include "cl/brg_rx.h"
#include "cl/inc/bridge_table.h"        // bridge_table_context_t

#include "cl/inc/trace.h"
#include "config/cl/eoc.h"

#include "cl/cl_eoc_mactotei.h"
#include "common/defs/igmp.h"

/** Define the delay at the one the data inside the cl_data_send_link_t are
 * considered expired. */
#define CL_DATA_SEND_EXCEED_TIME_MS 100

/** 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;
};
typedef struct cl_mme_tx_t cl_mme_tx_t;

struct cl_send_t
{
    /** The CL context. */
    cl_t *cl;
    /** The buffer to give back. */
    u8 *buffer;
    /** MME if the buffer contains a MME. */
    bool mme;
};

/** 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;
};
typedef struct cl_mme_t cl_mme_t;

/** Keep DATA about last data SEND. This should help the CL to use
 * previous MFS to send the new Frame if it is for the same destination Mac
 * Address. The date inside it is only set if it the current time is exceed
 * see CL_DATA_SEND_EXCEED_TIME_MS. */
struct cl_data_send_link_t
{
    /** Last update time, Set with the arrival time stamp in the NTB clock. */
    u32 last_update_date_ntb;
    /** Destination Mac address. */
    mac_t dmac;
    /** Source Mac address. */
    mac_t smac;
    /** Tag provided by linux. */
    uint tag;
    /** Link associated. */
    mfs_tx_t *mfs;
};
typedef struct cl_data_send_link_t cl_data_send_link_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;

    /** 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;

#if CONFIG_CL_EOC_ROUTE
    /** Table for routing packages in EoC, maps MAC to TEI of STA on CCo side
     * and limits number of MAC address behind STA
     */
    cl_eoc_mactotei_table_t cl_eoc_mactotei_table;
#endif

    /** 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 static_mme_buffer [ETH_PACKET_MAX_SIZE];
    u8 *mme_buffer;

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

    /** Slab allocator. */
    slab_cache_t slab_buffer_handler;

    /** The bridge table module context. */
    bridge_table_context_t bridge_table;

    /** Last link used on a Data send. */
    cl_data_send_link_t data_send_link;

    /** Groups for multi-unicast. */
    igmp_groups_t groups;

    /** RX bridge Table. */
    cl_brg_rx_t *brg_rx;

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

#endif /* CL_INC_CONTEXT_H_ */