summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/inc/ber_margin_update.h
blob: eb9196387949f19755e6a7811cafc95c4a9d349a (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
#ifndef ce_rx_bitloading_inc_ber_margin_update_h
#define ce_rx_bitloading_inc_ber_margin_update_h
/* Cesar project {{{
 *
 * Copyright (C) 2011 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    ce/rx/bitloading/inc/ber_margin_update.h
 * \brief   Functions related to BER margin update
 * \ingroup ce_rx
 */

#include "hal/phy/defs.h"
#include "ce/rx/tonemask.h"
#include "ce/rx/bitloading/inc/ber.h"
#include "ce/rx/ce_rx_param.h"

/**
 * Minimum/lower and maximum/upper bound.
 */
typedef enum ce_rx_bl_bmu_bound_t
{
    CE_RX_BL_BMU_MIN,
    CE_RX_BL_BMU_MAX,
    CE_RX_BL_BMU_NB,
} ce_rx_bl_bmu_bound_t;

/**
 * Minimum and maximum limit.
 */
typedef enum ce_rx_bl_bmu_ber_limit_t
{
    CE_RX_BL_BMU_BER_MIN,
    CE_RX_BL_BMU_BER_MAX,
    CE_RX_BL_BMU_BER_NB,
} ce_rx_bl_bmu_ber_limit_t;

/**
 * Number of polynomial for BMU.
 */
typedef enum ce_rx_bl_bmu_poly_t
{
    CE_RX_BL_BMU_POLY_PLUS,
    CE_RX_BL_BMU_POLY_MINUS,
    CE_RX_BL_BMU_POLY_NB,
    CE_RX_BL_BMU_POLY_NONE,
} ce_rx_bl_bmu_poly_t;

/**
 * Maximum degrees supported by the polynomials.
 */
#define CE_RX_BL_BMU_POLY_DEG_MAX 2

/**
 * Configuration of the BER margin update.
 */
typedef struct ce_rx_bl_bmu_conf_t
{
    /**
     * Limits of the PBER tunnel.
     */
    uint pber_limit[CE_RX_BL_BMU_NB];
    /**
     * Limits of the BER margin.
     */
    s64 ber_margin_limit[PHY_FEC_RATE_NB][CE_RX_BL_BMU_BER_NB];
    /**
     * Polynomials of the BMU.
     */
    s64 poly[CE_RX_BL_BMU_POLY_NB][CE_RX_BL_BMU_POLY_DEG_MAX];
    /**
     * FEC rate factors to apply for each FEC rate.
     */
    uint fec_rate_factors[PHY_FEC_RATE_NB];
    /**
     * Minimum number of PB to consider before allowing BMU.
     */
    uint pb_count_min;
    /**
     * Minimum number of oscillation to consider before disabling BMU.
     * BMU will only be disable when under the PBER tunnel. If we are over the
     * PBER high limit, we still let the BMU do its jobs.
     */
    uint oscillation_count_min;
} ce_rx_bl_bmu_conf_t;

/**
 * The configuration of the BER margin update.
 */
extern ce_rx_bl_bmu_conf_t ce_rx_bl_bmu_conf;

/**
 * Initialize BMU configuration.
 * \param  tonemask information
 *
 * This function is used to initialize the configuration of the BER margin
 * update. You need to call this function at initialization.
 */
extern inline void
ce_rx_bl_bmu_conf_init (tonemask_info_t *tonemask_info)
{
    uint i;
    /* Set ber margin limits. */
    for (i = 0; i < PHY_FEC_RATE_NB; i++)
    {
        u64 ber = ce_rx_bl_ber_pt_bpt (i, tonemask_info->carrier_nb,
                                     ce_rx_bl_initial_bpt[i]);
        ce_rx_bl_bmu_conf.ber_margin_limit[i][CE_RX_BL_BMU_BER_MIN] =
                -CE_RX_BL_BER_DEFAULT_OVER + ber + 1;
        ce_rx_bl_bmu_conf.ber_margin_limit[i][CE_RX_BL_BMU_BER_MAX] = ber - 1;
    }
    /* Set Pber limits. */
    ce_rx_bl_bmu_conf.pber_limit[CE_RX_BL_BMU_MIN] = CE_RX_BL_BER_MARGIN_UPDATE_PBER_LIMIT_MIN;
    ce_rx_bl_bmu_conf.pber_limit[CE_RX_BL_BMU_MAX] = CE_RX_BL_BER_MARGIN_UPDATE_PBER_LIMIT_MAX;
    /* Plus polynomial. */
    ce_rx_bl_bmu_conf.poly[CE_RX_BL_BMU_POLY_PLUS][0] = CE_RX_BL_BMU_POLY_SUP_A;
    ce_rx_bl_bmu_conf.poly[CE_RX_BL_BMU_POLY_PLUS][1] = CE_RX_BL_BMU_POLY_SUP_B;
    /* Minus polynomial. */
    ce_rx_bl_bmu_conf.poly[CE_RX_BL_BMU_POLY_MINUS][0] = CE_RX_BL_BMU_POLY_INF_A;
    ce_rx_bl_bmu_conf.poly[CE_RX_BL_BMU_POLY_MINUS][1] = CE_RX_BL_BMU_POLY_INF_B;
    /* Polynomial factors. */
    ce_rx_bl_bmu_conf.fec_rate_factors[CE_RX_BL_BMU_POLY_PLUS] =  CE_RX_BL_BMU_POLY_FEC_RATE_1_2_FACTOR;
    ce_rx_bl_bmu_conf.fec_rate_factors[CE_RX_BL_BMU_POLY_MINUS] =  CE_RX_BL_BMU_POLY_FEC_RATE_16_21_FACTOR;
    /* Set min value for internal counters. */
    ce_rx_bl_bmu_conf.pb_count_min = CE_RX_BL_BMU_PB_COUNT_MIN;
    ce_rx_bl_bmu_conf.oscillation_count_min = CE_RX_BL_BMU_OSCILLATION_COUNT_MIN;
}

#endif /* inc_ber_margin_update_h */