summaryrefslogtreecommitdiff
path: root/hal/phy/maximus/inc/maximus_phy_ctx.h
blob: 8f293f6c8242a8df773a04251734459699980f21 (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
#ifndef hal_phy_maximus_inc_maximus_phy_context_h
#define hal_phy_maximus_inc_maximus_phy_context_h
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal/phy/maximus/inc/maximus_phy_context.h
 * \brief   HAL Phy context for Maximus.
 * \ingroup hal_phy_maximus
 */
#include <stdint.h> // for uint32_t type
#include "hal/phy/access.h"
#include "hal/phy/bridgedma.h"
#include "hal/phy/forward.h"
#include "hal/phy/pbdma.h"
#include "hal/phy/phy.h"
#include "host/station.h"
#include "host/netclock.h"
#include "maximus/common/types/phy_types.h"

enum medium_state_t
{
    MAXIMUS_PHY_MEDIUM_NONE = 0x00,
    MAXIMUS_PHY_MEDIUM_PRE_DETECTED = 0x01,
    MAXIMUS_PHY_MEDIUM_BUSY_RX = 0x01,
    MAXIMUS_PHY_MEDIUM_PRP = 0x03,
    MAXIMUS_PHY_MEDIUM_BUSY_TX = 0x02,
    MAXIMUS_PHY_MEDIUM_IDLE = 0x04     
};
typedef enum medium_state_t medium_state_t;

/** Phy access structure for Maximus */
struct maximus_phy_access_t
{
    /** Channel access priority. Priority to assert in next PRP. Can be changed at anytime (by 'phy_access_backoff_update'). */
    u8 cap_mpdu;
    /** Number of slots measured since end of PRP and before PRE detection. */
    uint slot_count;
    /** Possible values are: NONE, BUSY_RX, BUSY_TX, PRP, IDLE. */
    medium_state_t medium_state;
    /** PRP result. */
    bool prp_result;
    /** Id of netclock message sent by 'phy_access_timer_program'. */
    netclock_id_t netclock_id;
    /** Callback contexts to insert into callback queue. */
    netclock_callback_t *access_backoff_netclock_cb;
    netclock_callback_t *access_timer_netclock_cb;
};
typedef struct maximus_phy_access_t maximus_phy_access_t;

/** Phy control structure for Maximus */
struct maximus_phy_ctrl_t
{
    /** User data passed to any callback. */
    void *user_data;
    /** RX FC event callback. */
    phy_rx_fc_cb_t rx_fc_cb;
    /** ACCESS event callback. */
    phy_access_cb_t access_cb;
    /** ACCESS CONFIRM event callback. */
    phy_access_conf_cb_t access_conf_cb;
    /** PB DMA callback. */
    phy_pbdma_cb_t pbdma_cb;
    /** DSR callback. */
    phy_deferred_cb_t deferred_cb;
    /** Current phy date. */
    u32 current_date;
    /** Homeplug 1.0 frame control. */
    u32 fc_10;
    /** Abort TX if PRP was lost. */
    bool stop_tx_on_prp_lost;
    /** Frame control. */
    u32 fc_av[4];
    /** Frame control mode. */
    phy_fc_mode_t fc_mode;
    /** Used to enable or disable PRE detection. */
    bool pre_detection;
    /** Callback contexts to insert into callback queue. */
    netclock_callback_t *tx_frame_netclock_cb;   
    netclock_callback_t *rx_activate_netclock_cb;
};
typedef struct maximus_phy_ctrl_t maximus_phy_ctrl_t;

/** PB DMA structure for Maximus */
struct maximus_pbdma_t
{
    /** PB size. */
    phy_pb_size_t pb_size;
    /** Internal PB counter. */
    u8 index_current_pb;
    /** Do not encrypt or decrypt using AES. */
    bool bypass_aes;
    /** Three first AES initialisation vector words. */
    u32 iv[3];
    /** AES network encryption key. */
    u32 nek[4];
    /** Total number of PB. */
    uint nb_total;
    /** Number of ready descriptors. */
    uint nb_ready;
    /** Number of the PB after which an interrupt is triggered. */
    uint nb_pb_it;
    /** First PB descriptor. */
    phy_pb_t *first_pb;
    /** First transfer descriptor. */
    phy_chandata_t *first_chandata;
    /** Frequency noise. */
    u16 frequency_noise[PHY_CARRIER_MAX_NB];
    /** Time noise. */
    u8 time_noise[PHY_SYMBOL_MAX_NB];
    /** Transfer function of channel response. */
    u64 spectrum[PHY_CARRIER_MAX_NB];
};
typedef struct maximus_pbdma_t maximus_pbdma_t;

/** Tone Map DMA structure for Maximus */
struct maximus_tmdma_t
{
    /** Modulation type. */
    phy_mod_t mod;
    /** TCC rate. */
    phy_fecrate_t fecrate;
    /** Guard interval for third symbol and following symbols. */
    phy_gil_t gil;
    /** Tonemap index where to store tonemap. */
    uint tonemap_index;
    /** Tonemask blocks first descriptor. */
    blk_t *tonemask;
    /** ROBO parameters. */
    phy_robo_param_t *robo_param;
    /** Tonemap blocks first descriptor. */
    blk_t *tonemap;
};
typedef struct maximus_tmdma_t maximus_tmdma_t;

/** Phy context structure for Maximus */
struct phy_t
{
    maximus_phy_access_t  access;
    maximus_phy_ctrl_t    control;
    maximus_pbdma_t       pb_dma;
    maximus_tmdma_t       tm_dma;
};
/* Forward declaration in hal/phy/forward.h. */

#endif /* hal_phy_maximus_inc_maximus_phy_context_h */