libosmoisdn 1.10.0.58-6cd7a
Osmocom ISDN library
|
TA (Terminal Adapter) implementation as per ITU-T V.110. More...
#include <stdbool.h>
#include <stdint.h>
#include <errno.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/bits.h>
#include <osmocom/core/tdef.h>
#include <osmocom/core/fsm.h>
#include <osmocom/isdn/v110.h>
#include <osmocom/isdn/v110_ta.h>
Data Structures | |
struct | v110_ta_state |
struct | osmo_v110_ta |
Macros | |
#define | S(x) (1 << (x)) |
#define | V24_FLAGMASK_IS_ON(flags, circuit) (((flags) & S(circuit)) != 0) |
#define | V24_FLAGMASK_IS_OFF(flags, circuit) (((flags) & S(circuit)) == 0) |
#define | V24_FLAGMASK_SET_ON(flags, circuit) (flags) |= S(circuit) |
#define | V24_FLAGMASK_SET_OFF(flags, circuit) (flags) &= ~S(circuit) |
#define | V110_SX_BIT_ON 0 |
#define | V110_SX_BIT_OFF 1 |
#define | v110_ta_fsm_state_chg(state) |
Functions | |
static bool | v110_df_x_bits_are (const struct osmo_v110_decoded_frame *df, ubit_t cmp) |
static bool | v110_df_s_bits_are (const struct osmo_v110_decoded_frame *df, ubit_t cmp) |
static bool | v110_df_d_bits_are (const struct osmo_v110_decoded_frame *df, ubit_t cmp) |
static void | v110_ta_handle_frame (const struct osmo_v110_ta *ta, const struct osmo_v110_decoded_frame *df) |
static void | v110_ta_build_frame (const struct osmo_v110_ta *ta, struct osmo_v110_decoded_frame *df) |
static void | v110_ta_flags_update (struct osmo_v110_ta *ta, unsigned int v24_flags) |
static void | v110_ta_fsm_idle_ready_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state) |
static void | v110_ta_fsm_idle_ready (struct osmo_fsm_inst *fi, uint32_t event, void *data) |
static void | v110_ta_fsm_connect_ta_to_line_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state) |
static void | v110_ta_fsm_connect_ta_to_line (struct osmo_fsm_inst *fi, uint32_t event, void *data) |
static void | v110_ta_fsm_data_transfer_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state) |
static void | v110_ta_fsm_data_transfer (struct osmo_fsm_inst *fi, uint32_t event, void *data) |
static void | v110_ta_fsm_disconnect_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state) |
static void | v110_ta_fsm_disconnect (struct osmo_fsm_inst *fi, uint32_t event, void *data) |
static void | v110_ta_fsm_resyncing_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state) |
static void | v110_ta_fsm_resyncing (struct osmo_fsm_inst *fi, uint32_t event, void *data) |
static int | v110_ta_timer_cb (struct osmo_fsm_inst *fi) |
static | __attribute__ ((constructor)) |
struct osmo_v110_ta * | osmo_v110_ta_alloc (void *ctx, const char *name, const struct osmo_v110_ta_cfg *cfg) |
Allocate a V.110 TA (Terminal Adapter) instance. More... | |
void | osmo_v110_ta_free (struct osmo_v110_ta *ta) |
Release memory taken by the given V.110 TA instance. More... | |
int | osmo_v110_ta_set_timer_val_ms (struct osmo_v110_ta *ta, enum osmo_v110_ta_timer timer, unsigned long val_ms) |
Configure a timer of the given V.110 TA instance. More... | |
int | osmo_v110_ta_frame_in (struct osmo_v110_ta *ta, const struct osmo_v110_decoded_frame *in) |
Feed a [decoded] V.110 frame into the given TA instance. More... | |
int | osmo_v110_ta_frame_out (struct osmo_v110_ta *ta, struct osmo_v110_decoded_frame *out) |
Pull a [decoded] V.110 frame out of the given TA instance. More... | |
int | osmo_v110_ta_sync_ind (struct osmo_v110_ta *ta) |
Indicate a synchronization establishment event. More... | |
int | osmo_v110_ta_desync_ind (struct osmo_v110_ta *ta) |
Indicate a synchronization loss event. More... | |
unsigned int | osmo_v110_ta_get_status (const struct osmo_v110_ta *ta) |
Get the V.24 status bit-mask of the given TA instance. More... | |
static int | v110_ta_set_status (struct osmo_v110_ta *ta, unsigned int status) |
Set the V.24 status bit-mask of the given TA instance. More... | |
bool | osmo_v110_ta_get_circuit (const struct osmo_v110_ta *ta, enum osmo_v110_ta_circuit circuit) |
Get state of a V.24 circuit of the given TA instance. More... | |
int | osmo_v110_ta_set_circuit (struct osmo_v110_ta *ta, enum osmo_v110_ta_circuit circuit, bool active) |
Activate/deactivate a V.24 circuit of the given TA instance. More... | |
Variables | |
const struct value_string | osmo_v110_ta_circuit_names [] |
const struct value_string | osmo_v110_ta_circuit_descs [] |
static const struct osmo_tdef | v110_ta_tdef [] |
static const struct value_string | v110_ta_fsm_event_names [] |
static const struct osmo_tdef_state_timeout | v110_ta_fsm_timeouts [32] |
static const struct osmo_fsm_state | v110_ta_states [] |
static struct osmo_fsm | osmo_v110_ta_fsm |
TA (Terminal Adapter) implementation as per ITU-T V.110.
#define V110_SX_BIT_OFF 1 |
#define V110_SX_BIT_ON 0 |
#define v110_ta_fsm_state_chg | ( | state | ) |
enum v110_ta_d_bit_mode |
enum v110_ta_fsm_event |
enum v110_ta_fsm_state |
|
static |
References OSMO_ASSERT, osmo_fsm_register(), and osmo_v110_ta_fsm.
struct osmo_v110_ta * osmo_v110_ta_alloc | ( | void * | ctx, |
const char * | name, | ||
const struct osmo_v110_ta_cfg * | cfg | ||
) |
Allocate a V.110 TA (Terminal Adapter) instance.
[in] | ctx | parent talloc context. |
[in] | name | name of the TA instance. |
[in] | cfg | initial configuration of the TA instance. |
References osmo_v110_ta::cfg, DLGLOBAL, osmo_v110_ta::fi, osmo_v110_ta_cfg::flow_ctrl, osmo_v110_ta_cfg::local, LOGL_DEBUG, LOGL_ERROR, LOGP, name, osmo_v110_ta::name, OSMO_ASSERT, osmo_fsm_inst_alloc(), osmo_fsm_inst_free(), osmo_fsm_inst_state_chg, osmo_tdefs_reset(), OSMO_V110_LOCAL_FLOW_CTRL_NONE, osmo_v110_ta_fsm, osmo_v110_ta_cfg::rx_cb, osmo_v110_ta::Tdefs, osmo_v110_ta_cfg::tx_cb, V110_TA_ST_IDLE_READY, and v110_ta_tdef.
int osmo_v110_ta_desync_ind | ( | struct osmo_v110_ta * | ta | ) |
Indicate a synchronization loss event.
This function is intended to be called when the lower layer experiences a loss of synchronization with the frame clock.
[in] | ta | TA instance to indicate the event to. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_DESYNC_IND.
int osmo_v110_ta_frame_in | ( | struct osmo_v110_ta * | ta, |
const struct osmo_v110_decoded_frame * | in | ||
) |
Feed a [decoded] V.110 frame into the given TA instance.
This function, like its out counterpart, is intended to be used by the lower layers receiving V.110 frames over some medium. The caller of this function is responsible for finding the synchronization pattern (if needed), aligning to the frame boundaries, and decoding frames using osmo_v110_decode_frame() or osmo_csd*_decode_frame().
Bits E1/E2/E3 are expected to be set by the caller (if not being transmitted over the medium) in accordance with the configured synchronous user rate.
Bits D1..D48 are passed to the bit rate adaption function RA1. The resulting output is then passed to the upper layer (application) via the configured .rx_cb(). Though, in certain states of the TA's FSM, bits D1..D48 are ignored and the upper layer gets a sequence of binary '0' or '1'.
[in] | ta | TA instance to feed the given frame into. |
[in] | in | pointer to a [decoded] V.110 frame. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_RX_FRAME_IND.
int osmo_v110_ta_frame_out | ( | struct osmo_v110_ta * | ta, |
struct osmo_v110_decoded_frame * | out | ||
) |
Pull a [decoded] V.110 frame out of the given TA instance.
This function, like its in counterpart, is intended to be used by the lower layers transmitting V.110 frames over some medium. The caller of this function is responsible for encoding the output frame using osmo_v110_encode_frame() or osmo_csd*_encode_frame().
Bits E1/E2/E3 are set in accordance with the configured synchronous user rate. Bits E4/E5/E6/E7 are unconditionally set to binary '1'.
Bits D1..D48 are set depending on the state of TA's FSM:
[in] | ta | TA instance to pull a frame from. |
[out] | out | where to store a [decoded] V.110 frame. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_TX_FRAME_RTS.
void osmo_v110_ta_free | ( | struct osmo_v110_ta * | ta | ) |
Release memory taken by the given V.110 TA instance.
[in] | ta | TA instance to be free()d. |
References osmo_v110_ta::fi, and osmo_fsm_inst_free().
bool osmo_v110_ta_get_circuit | ( | const struct osmo_v110_ta * | ta, |
enum osmo_v110_ta_circuit | circuit | ||
) |
Get state of a V.24 circuit of the given TA instance.
[in] | ta | TA instance to get the circuit state. |
[in] | circuit | a V.24 circuit, one of OSMO_V110_TA_C_*. |
References osmo_v110_ta::state, V24_FLAGMASK_IS_ON, and v110_ta_state::v24_flags.
unsigned int osmo_v110_ta_get_status | ( | const struct osmo_v110_ta * | ta | ) |
Get the V.24 status bit-mask of the given TA instance.
[in] | ta | TA instance to get the circuit bit-mask. |
References osmo_v110_ta::state, and v110_ta_state::v24_flags.
int osmo_v110_ta_set_circuit | ( | struct osmo_v110_ta * | ta, |
enum osmo_v110_ta_circuit | circuit, | ||
bool | active | ||
) |
Activate/deactivate a V.24 circuit of the given TA instance.
[in] | ta | TA instance to update the circuit state. |
[in] | circuit | a V.24 circuit, one of OSMO_V110_TA_C_* (DTE->DCE). |
[in] | active | activate (true) or deactivate (false) the circuit. |
References osmo_v110_ta::fi, LOGL_ERROR, LOGPFSML, OSMO_V110_TA_C_105, OSMO_V110_TA_C_108, OSMO_V110_TA_C_133, osmo_v110_ta_circuit_name(), osmo_v110_ta::state, v110_ta_set_status(), V24_FLAGMASK_SET_OFF, V24_FLAGMASK_SET_ON, and v110_ta_state::v24_flags.
int osmo_v110_ta_set_timer_val_ms | ( | struct osmo_v110_ta * | ta, |
enum osmo_v110_ta_timer | timer, | ||
unsigned long | val_ms | ||
) |
Configure a timer of the given V.110 TA instance.
[in] | ta | TA instance to be configured. |
[in] | timer | a timer to be configured. |
[in] | val_ms | the new timeout value to set (in milliseconds). |
References OSMO_TDEF_MS, osmo_tdef_set(), and osmo_v110_ta::Tdefs.
int osmo_v110_ta_sync_ind | ( | struct osmo_v110_ta * | ta | ) |
Indicate a synchronization establishment event.
This function is intended to be called when the lower layer achieves synchronization to the frame clock.
[in] | ta | TA instance to indicate the event to. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_SYNC_IND.
|
inlinestatic |
References osmo_v110_decoded_frame::d_bits, and MAX_D_BITS.
Referenced by v110_ta_fsm_data_transfer().
|
inlinestatic |
References ARRAY_SIZE, and osmo_v110_decoded_frame::s_bits.
Referenced by v110_ta_fsm_connect_ta_to_line(), v110_ta_fsm_data_transfer(), and v110_ta_fsm_disconnect().
|
inlinestatic |
References osmo_v110_decoded_frame::x_bits.
Referenced by v110_ta_fsm_connect_ta_to_line().
|
static |
References osmo_v110_ta::cfg, osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, MAX_D_BITS, OSMO_ASSERT, osmo_v110_sync_ra1_get_user_data_chunk_bitlen(), osmo_v110_sync_ra1_user_to_ir(), osmo_v110_ta_cfg::priv, osmo_v110_ta_cfg::rate, osmo_v110_decoded_frame::s_bits, osmo_v110_ta::state, ts, osmo_v110_ta_cfg::tx_cb, V110_TA_DBIT_M_ALL_ONE, V110_TA_DBIT_M_ALL_ZERO, V110_TA_DBIT_M_FORWARD, and osmo_v110_decoded_frame::x_bits.
Referenced by v110_ta_fsm_connect_ta_to_line(), v110_ta_fsm_data_transfer(), v110_ta_fsm_disconnect(), v110_ta_fsm_idle_ready(), and v110_ta_fsm_resyncing().
|
static |
References osmo_v110_ta::cfg, osmo_v110_ta_cfg::priv, osmo_v110_ta::state, osmo_v110_ta_cfg::status_update_cb, and v110_ta_state::v24_flags.
Referenced by v110_ta_fsm_connect_ta_to_line(), v110_ta_fsm_data_transfer(), v110_ta_fsm_data_transfer_onenter(), v110_ta_fsm_disconnect_onenter(), v110_ta_fsm_idle_ready_onenter(), and v110_ta_fsm_resyncing().
|
static |
References data, osmo_v110_ta::fi, OSMO_ASSERT, osmo_timer_del(), OSMO_V110_TA_C_106, OSMO_V110_TA_C_107, OSMO_V110_TA_C_108, OSMO_V110_TA_C_109, osmo_fsm_inst::priv, osmo_v110_ta::state, osmo_fsm_inst::timer, ts, v110_df_s_bits_are(), v110_df_x_bits_are(), V110_SX_BIT_ON, v110_ta_build_frame(), V110_TA_DBIT_M_FORWARD, V110_TA_EV_RX_FRAME_IND, V110_TA_EV_SYNC_IND, V110_TA_EV_TIMEOUT, V110_TA_EV_TX_FRAME_RTS, V110_TA_EV_V24_STATUS_CHG, v110_ta_flags_update(), v110_ta_fsm_state_chg, v110_ta_handle_frame(), V110_TA_ST_DATA_TRANSFER, V110_TA_ST_IDLE_READY, V24_FLAGMASK_IS_OFF, V24_FLAGMASK_IS_ON, V24_FLAGMASK_SET_ON, and v110_ta_state::v24_flags.
|
static |
|
static |
References data, osmo_v110_ta::fi, OSMO_ASSERT, OSMO_V110_TA_C_107, OSMO_V110_TA_C_108, OSMO_V110_TA_C_109, osmo_fsm_inst::priv, osmo_v110_ta::state, ts, v110_df_d_bits_are(), v110_df_s_bits_are(), V110_SX_BIT_OFF, v110_ta_build_frame(), V110_TA_EV_DESYNC_IND, V110_TA_EV_RX_FRAME_IND, V110_TA_EV_TX_FRAME_RTS, V110_TA_EV_V24_STATUS_CHG, v110_ta_flags_update(), v110_ta_fsm_state_chg, v110_ta_handle_frame(), V110_TA_ST_DISCONNECTING, V110_TA_ST_RESYNCING, V24_FLAGMASK_IS_ON, V24_FLAGMASK_SET_OFF, and v110_ta_state::v24_flags.
|
static |
References osmo_v110_ta::cfg, osmo_v110_ta_cfg::end_to_end, osmo_v110_ta::fi, osmo_v110_ta_cfg::flow_ctrl, OSMO_V110_TA_C_106, OSMO_V110_TA_C_107, OSMO_V110_TA_C_109, osmo_fsm_inst::priv, osmo_v110_ta::state, ts, V110_SX_BIT_ON, V110_TA_DBIT_M_FORWARD, v110_ta_flags_update(), V24_FLAGMASK_SET_ON, and v110_ta_state::v24_flags.
|
static |
References data, osmo_v110_ta::fi, OSMO_ASSERT, osmo_fsm_inst::priv, v110_df_s_bits_are(), V110_SX_BIT_OFF, v110_ta_build_frame(), V110_TA_EV_DESYNC_IND, V110_TA_EV_RX_FRAME_IND, V110_TA_EV_TIMEOUT, V110_TA_EV_TX_FRAME_RTS, V110_TA_EV_V24_STATUS_CHG, v110_ta_fsm_state_chg, v110_ta_handle_frame(), and V110_TA_ST_IDLE_READY.
|
static |
|
static |
References data, osmo_v110_ta::fi, OSMO_ASSERT, OSMO_V110_TA_C_108, osmo_fsm_inst::priv, osmo_v110_ta::state, ts, v110_ta_build_frame(), V110_TA_EV_RX_FRAME_IND, V110_TA_EV_TX_FRAME_RTS, V110_TA_EV_V24_STATUS_CHG, v110_ta_fsm_state_chg, v110_ta_handle_frame(), V110_TA_ST_CON_TA_TO_LINE, and V24_FLAGMASK_IS_ON.
|
static |
|
static |
References data, osmo_v110_ta::fi, OSMO_ASSERT, OSMO_V110_TA_C_107, osmo_fsm_inst::priv, osmo_v110_ta::state, ts, V110_SX_BIT_OFF, V110_SX_BIT_ON, v110_ta_build_frame(), V110_TA_DBIT_M_ALL_ZERO, V110_TA_EV_SYNC_IND, V110_TA_EV_TIMEOUT, V110_TA_EV_TX_FRAME_RTS, V110_TA_EV_V24_STATUS_CHG, v110_ta_flags_update(), v110_ta_fsm_state_chg, V110_TA_ST_DATA_TRANSFER, V110_TA_ST_DISCONNECTING, V24_FLAGMASK_SET_OFF, and v110_ta_state::v24_flags.
|
static |
|
static |
References osmo_v110_ta::cfg, MAX_D_BITS, OSMO_ASSERT, osmo_v110_sync_ra1_get_user_data_chunk_bitlen(), osmo_v110_sync_ra1_ir_to_user(), osmo_v110_ta_cfg::priv, osmo_v110_ta_cfg::rate, osmo_v110_ta_cfg::rx_cb, osmo_v110_ta::state, ts, V110_TA_DBIT_M_ALL_ONE, V110_TA_DBIT_M_ALL_ZERO, and V110_TA_DBIT_M_FORWARD.
Referenced by v110_ta_fsm_connect_ta_to_line(), v110_ta_fsm_data_transfer(), v110_ta_fsm_disconnect(), and v110_ta_fsm_idle_ready().
|
static |
Set the V.24 status bit-mask of the given TA instance.
[in] | ta | TA instance to update the circuit state. |
[in] | status | bit-mask of OSMO_V110_TA_C_*. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, osmo_v110_ta::state, V110_TA_EV_V24_STATUS_CHG, and v110_ta_state::v24_flags.
Referenced by osmo_v110_ta_set_circuit().
|
static |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_TIMEOUT.
const struct value_string osmo_v110_ta_circuit_descs[] |
Referenced by osmo_v110_ta_circuit_desc().
const struct value_string osmo_v110_ta_circuit_names[] |
Referenced by osmo_v110_ta_circuit_name().
|
static |
Referenced by __attribute__(), and osmo_v110_ta_alloc().
|
static |
|
static |
|
static |
|
static |
Referenced by osmo_v110_ta_alloc().