summaryrefslogtreecommitdiff
path: root/cesar/bsu/inc/context.h
blob: 4447509c7d585daca414429d1a619f38b6f677a6 (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
#ifndef bsu_inc_context_h
#define bsu_inc_context_h
/* Cesar project {{{
 *
 * Copyright (C) 2010 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    bsu/inc/context.h
 * \brief   BSU context.
 * \ingroup bsu
 */
#include "common/defs/homeplugAV.h"
#include "bsu/bsu.h"
#include "bsu/ntb/ntb_sync.h"
#include "bsu/beacon/beacon.h"
#include "bsu/inc/trace.h"
#include "lib/stats.h"

/** Number of foreign AVLNs handled. */
#define BSU_FOREIGN_AVLNS_NB (HPAV_AVLNS_NB_MAX - 1)

/** Index of processed data used by the merge schedule process. */
struct bsu_avln_schedules_process_t
{
    /** Persistent schedules to use. */
    bsu_beacon_bmi_persistent_schedule_desc_t *ps;
    /** Persistent schedules allocation index. */
    uint ps_alloc_index;
    /** Non persistent schedules allocation index. */
    uint nps_alloc_index;
};
typedef struct bsu_avln_schedules_process_t bsu_avln_schedules_process_t;

#if CONFIG_STATS
/** Statistics. */
struct bsu_stats_t
{
    /** Current NTB offset tck. */
    u32 ntb_offset_tck;
    /** Current frequency error in q30. */
    uint frequency_error_q30;
};
typedef struct bsu_stats_t bsu_stats_t;
#endif

/** BSU AVLN data. */
struct bsu_avln_t
{
    /** The beacon received. */
    bsu_beacon_t beacon;
    /** NTB synchronisation data.  */
    bsu_ntb_sync_t sync;
    /** BTOs. */
    s16 bto [HPAV_BEACON_BTO_NB];
    /** SNID. */
    u8 snid;
    /** CCo's Mac address. */
    mac_t cco_mac_address;
};

struct bsu_t
{
    /** Mac config. */
    mac_config_t *mac_config;
    /** Mac Store. */
    mac_store_t *mac_store;
    /** Channel access context. */
    ca_t *ca;
    /** SAR context. */
    sar_t *sar;
    /** Phy context. */
    phy_t *phy;
    /** Upper layer user data.*/
    void *ul_data;
    /** Call back to provide the beacon to the upper layer. */
    bsu_beacon_processed_t ul_cb;
    /** ACLF context. */
    bsu_aclf_t *aclf;
    /** PBProc context. */
    pbproc_t *pbproc;
    /** Station's AVLN. */
    bsu_avln_t *sta_avln;
    /** Others AVLN's data. */
    bsu_avln_t avlns[HPAV_AVLNS_NB_MAX];
    /** Number of others AVLN NTB. */
    uint avlns_nb;
    /** Special power on AVLN data. */
    bsu_avln_t poweron;
    /** NID to track. */
    u64 nid_track;
    /** SNID to track. */
    u8 snid_track;
    /** TEI to track. */
    u8 tei_track;
    /** Mac address of the CCo the station tracks.
     * Zero if the CCo does not provide the mac address in the central beacon. */
    mac_t cco_mac_address_track;
    /** Track a new AVLN.  */
    bool track_new;
    /** Channel access schedules in use. */
    uint ca_schedules_in_use[BSU_BEACON_SCHEDULES_NB];
    /** Is station */
    bsu_update_sta_type_t is_sta;
    /** HAL timer context. */
    hal_timer_t *hal_timer;
    /** HAL timer instance. */
    hal_timer_instance_t timer;
    /** Activated status. */
    bool activate;
    /** Beacons MFS. */
    mfs_tx_t *mfs_beacons[BSU_BEACON_TYPE_NB];
    /** Statistics sent beacons. */
    u32 beacon_nb_sent[BSU_BEACON_TYPE_NB];
    /** Statistics received beacons. */
    u32 beacon_nb_recv[BSU_BEACON_TYPE_NB];
    /** NEK switch. */
    uint nek_switch;
    /** Station's discover info updated by CP. */
    bsu_beacon_bmi_discover_info_t discover_info;
    /** NTB clock synchronization weight configuration. k is for 1/2^k. */
    uint bsu_ntb_clk_sync_weight_k;
#if CONFIG_TRACE
    /** Trace system. */
    trace_buffer_t trace;
#endif /* !CONFIG_TRACE */
#if CONFIG_STATS
    /** Statistics. */
    bsu_stats_t stats;
#endif
    /** Retrieved information from the beacon of the tracked AVLN */
    bool avln_tracked;
};

#endif /* bsu_inc_context_h */