summaryrefslogtreecommitdiff
path: root/cesar/bsu/bsu.h
blob: 9be8b2c61bd27f3c34e253955e5048e6fc087068 (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
#ifndef bsu_bsu_h
#define bsu_bsu_h
/* Cesar project {{{
 *
 * Copyright (C) 2010 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    bsu/bsu.h
 * \brief   Beacon Scheduler Updater
 * \ingroup bsu
 *
 * BSU is responsible for computing the Channel Access schedules and send
 * beacons.
 */
#include "bsu/aclf/aclf.h"
#include "mac/pbproc/pbproc.h"
#include "mac/sar/sar.h"
#include "hal/timer/timer.h"
#include "bsu/beacon/beacon.h"
#include "bsu/beacon/defs.h"

/** Forward declaration. */
typedef struct bsu_t bsu_t;
typedef struct bsu_avln_t bsu_avln_t;
typedef struct bsu_avln_ntb_t bsu_avln_ntb_t;

enum bsu_beacon_direction_t
{
    BSU_BEACON_DIRECTION_TO_PLC,
    BSU_BEACON_DIRECTION_FROM_PLC,
    BSU_BEACON_DIRECTION_NB
};
typedef enum bsu_beacon_direction_t bsu_beacon_direction_t;

/** BSU computed parameters. */
struct bsu_params_t
{
    /** Pbproc RX parameters. */
    pbproc_rx_beacon_params_t rx_parameters;
    /** Direction */
    bsu_beacon_direction_t direction;
    /** Frequency error. */
    s32 frequency_error;
    /** Tick offset, difference between the NTB and PHY Date clock. */
    u32 ntb_offset_tck;
};
typedef struct bsu_params_t bsu_params_t;

/** Function to call on beacon reception or beacon sending.
 * \param  ctx  upper layer context.
 * \param  beacon  the beacon sent or received.
 * \param  bparams  the BSU computed data.
 * \warn  the upper layer is responsible for releasing the reference on the
 * beacon.
 */
typedef void
(*bsu_beacon_processed_t) (void *ctx, pb_beacon_t *beacon,
                           bsu_params_t *bparams);

BEGIN_DECLS

/**
 * Initialise the module.
 * \param  aclf  the ACLF module context.
 * \param  mac_config  the mac config structure pointer.
 * \param  phy  the PHY context.
 * \param  mac_store  the mac store database.
 * \param  ca  the channel access context.
 * \param  sar  the SAR context.
 * \param  timer  hal timer to awake the module.
 * \param  cb  the callback function to call on beacon reception or beacon
 * send.
 * \param  cb_ud  callback user context.
 * \return  the context.
 */
bsu_t *
bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
          mac_store_t *mac_store, ca_t *ca, sar_t *sar, hal_timer_t *timer,
          bsu_beacon_processed_t cb, void *cb_ud);

/**
 * Uninitialise the module.
 * \param  the ctx module.
 */
void
bsu_uninit (bsu_t *ctx);

/**
 * Update the data beacon for the bsu.
 * \param  beacon  the beacon data to send a central beacon.
 * \param  sta  true if the station acts as a STA.
 */
void
bsu_update (bsu_beacon_t *beacon, bool sta);

/**
 * Update the tracking AVLN's identification.
 * \param  ctx  the module context.
 * \param  nid  the NID to track.
 * \param  snid  the SNID to track.
 * \param  tei  the TEI to track.
 */
void
bsu_track_avln (bsu_t *ctx, u64 nid, u16 snid, u8 tei);

END_DECLS

#endif /* bsu_bsu_h */