Loading...
Searching...
No Matches
i460_mux.c File Reference

ITU-T I.460 sub-channel multiplexer + demultiplexer. More...

`#include <errno.h>`
`#include <osmocom/core/bits.h>`
`#include <osmocom/core/utils.h>`
`#include <osmocom/core/msgb.h>`
`#include <osmocom/gsm/i460_mux.h>`

## Functions

static int | osmo_i460_subchan_count (struct osmo_i460_timeslot *ts)
static bool | osmo_i460_has_single_64k_schan (struct osmo_i460_timeslot *ts)
static void | demux_subchan_append_bit (struct osmo_i460_subchan *schan, uint8_t bit)
static void | demux_subchan_extract_bits (struct osmo_i460_subchan *schan, const uint8_t *data, size_t data_len)
void | osmo_i460_demux_in (struct osmo_i460_timeslot *ts, const uint8_t *data, size_t data_len)
| Data from E1 timeslot into de-multiplexer.
void | osmo_i460_mux_enqueue (struct osmo_i460_subchan *schan, struct msgb *msg)
| enqueue a to-be-transmitted message buffer containing unpacked bits
static ubit_t | mux_schan_provide_bit (struct osmo_i460_subchan *schan)
static uint8_t | mux_subchan_provide_bits (struct osmo_i460_subchan *schan, uint8_t *mask)
| provide one byte with the subchan-specific bits of given sub-channel.
static uint8_t | mux_timeslot_provide_bits (struct osmo_i460_timeslot *ts)
int | osmo_i460_mux_out (struct osmo_i460_timeslot *ts, uint8_t *out, size_t out_len)
| Data from E1 timeslot into de-multiplexer.
static int | alloc_bitbuf (void *ctx, struct osmo_i460_subchan *schan, size_t num_bits)
static int | find_unused_subchan_idx (const struct osmo_i460_timeslot *ts)
static void | subchan_reset (struct osmo_i460_subchan *schan, bool first_time)
void | osmo_i460_ts_init (struct osmo_i460_timeslot *ts)
| initialize an I.460 timeslot
struct osmo_i460_subchan * | osmo_i460_subchan_add (void *ctx, struct osmo_i460_timeslot *ts, const struct osmo_i460_schan_desc *chd)
| add a new sub-channel to the given timeslot
void | osmo_i460_subchan_del (struct osmo_i460_subchan *schan)

## Detailed Description

ITU-T I.460 sub-channel multiplexer + demultiplexer.

## Function Documentation

## alloc_bitbuf()

static int alloc_bitbuf | ( | void * | ctx,
|  | struct osmo_i460_subchan * | schan,
|  | size_t | num_bits
| ) |  |

static

References osmo_i460_subchan::demux, len, osmo_i460_subchan_demux::out_bitbuf, and osmo_i460_subchan_demux::out_bitbuf_size.

Referenced by osmo_i460_subchan_add().

## demux_subchan_append_bit()

static void demux_subchan_append_bit | ( | struct osmo_i460_subchan * | schan,
|  | uint8_t | bit
| ) |  |

static

References osmo_i460_subchan::demux, len, OSMO_ASSERT, osmo_ubit2pbit(), osmo_i460_subchan_demux::out_bitbuf, osmo_i460_subchan_demux::out_bitbuf_size, osmo_i460_subchan_demux::out_cb_bits, osmo_i460_subchan_demux::out_cb_bytes, osmo_i460_subchan_demux::out_idx, and osmo_i460_subchan_demux::user_data.

Referenced by demux_subchan_extract_bits().

## demux_subchan_extract_bits()

static void demux_subchan_extract_bits | ( | struct osmo_i460_subchan * | schan,
|  | const uint8_t * | data,
|  | size_t | data_len
| ) |  |

static

References osmo_i460_subchan::bit_offset, data, demux_subchan_append_bit(), len, OSMO_ASSERT, OSMO_I460_RATE_16k, OSMO_I460_RATE_32k, OSMO_I460_RATE_64k, OSMO_I460_RATE_8k, and osmo_i460_subchan::rate.

Referenced by osmo_i460_demux_in().

## find_unused_subchan_idx()

static int find_unused_subchan_idx | ( | const struct osmo_i460_timeslot * | ts | ) |

static

References ARRAY_SIZE, len, OSMO_I460_RATE_NONE, osmo_i460_subchan::rate, osmo_i460_timeslot::schan, ts, and osmo_i460_subchan::ts.

Referenced by osmo_i460_subchan_add().

## mux_schan_provide_bit()

static ubit_t mux_schan_provide_bit | ( | struct osmo_i460_subchan * | schan | ) |

static

References osmo_i460_subchan_mux::in_cb_queue_empty, len, msgb::list, llist_entry, msg, msgb_length(), osmo_i460_subchan::mux, llist_head::next, osmo_i460_subchan_mux::tx_queue, and osmo_i460_subchan_mux::user_data.

Referenced by mux_subchan_provide_bits().

## mux_subchan_provide_bits()

static uint8_t mux_subchan_provide_bits | ( | struct osmo_i460_subchan * | schan,
|  | uint8_t * | mask
| ) |  |

static

provide one byte with the subchan-specific bits of given sub-channel.

Parameters

  [in] | schan | sub-channel that is to provide bits \parma[out] mask bitmask of those bits filled in

Returns
  bits of given sub-channel

References osmo_i460_subchan::bit_offset, len, mux_schan_provide_bit(), OSMO_ASSERT, OSMO_I460_RATE_16k, OSMO_I460_RATE_32k, OSMO_I460_RATE_64k, OSMO_I460_RATE_8k, and osmo_i460_subchan::rate.

Referenced by mux_timeslot_provide_bits().

## mux_timeslot_provide_bits()

static uint8_t mux_timeslot_provide_bits | ( | struct osmo_i460_timeslot * | ts | ) |

static

References ARRAY_SIZE, len, mux_subchan_provide_bits(), OSMO_I460_RATE_NONE, osmo_i460_subchan::rate, osmo_i460_timeslot::schan, ts, and osmo_i460_subchan::ts.

Referenced by osmo_i460_mux_out().

## osmo_i460_demux_in()

void osmo_i460_demux_in | ( | struct osmo_i460_timeslot * | ts,
|  | const uint8_t * | data,
|  | size_t | data_len
| ) |  |

Data from E1 timeslot into de-multiplexer.

Parameters

  [in] | ts | timeslot state
  [in] | data | input data bytes as received from E1/T1
  [in] | data_len | length of data in bytes

References ARRAY_SIZE, data, osmo_i460_subchan::demux, demux_subchan_extract_bits(), len, osmo_i460_has_single_64k_schan(), OSMO_I460_RATE_NONE, osmo_pbit2ubit(), osmo_i460_subchan_demux::out_cb_bits, osmo_i460_subchan_demux::out_cb_bytes, osmo_i460_subchan::rate, ts, and osmo_i460_subchan_demux::user_data.

## osmo_i460_has_single_64k_schan()

static bool osmo_i460_has_single_64k_schan | ( | struct osmo_i460_timeslot * | ts | ) |

static

References OSMO_I460_RATE_64k, osmo_i460_subchan_count(), and ts.

Referenced by osmo_i460_demux_in().

## osmo_i460_mux_enqueue()

void osmo_i460_mux_enqueue | ( | struct osmo_i460_subchan * | schan,
|  | struct msgb * | msg
| ) |  |

enqueue a to-be-transmitted message buffer containing unpacked bits

References msg, msgb_enqueue(), msgb_length(), osmo_i460_subchan::mux, OSMO_ASSERT, and osmo_i460_subchan_mux::tx_queue.

## osmo_i460_mux_out()

int osmo_i460_mux_out | ( | struct osmo_i460_timeslot * | ts,
|  | uint8_t * | out,
|  | size_t | out_len
| ) |  |

Data from E1 timeslot into de-multiplexer.

Parameters

  [in] | ts | timeslot state
  [out] | out | caller-provided buffer where to store generated output bytes
  [in] | out_len | number of bytes to be stored at out

References len, mux_timeslot_provide_bits(), and osmo_i460_subchan::ts.

## osmo_i460_subchan_add()

struct osmo_i460_subchan * osmo_i460_subchan_add | ( | void * | ctx,
|  | struct osmo_i460_timeslot * | ts,
|  | const struct osmo_i460_schan_desc * | chd
| ) |  |

add a new sub-channel to the given timeslot

Parameters

  [in] | ctx | talloc context from where to allocate the internal buffer
  [in] | ts | timeslot to which to add a sub-channel
  [in] | chd | description of the sub-channel to be added

Returns
  pointer to sub-channel on success, NULL on error

References alloc_bitbuf(), osmo_i460_subchan::bit_offset, osmo_i460_subchan::demux, find_unused_subchan_idx(), osmo_i460_subchan_mux::in_cb_queue_empty, len, osmo_i460_subchan::mux, osmo_i460_subchan_demux::out_cb_bits, osmo_i460_subchan_demux::out_cb_bytes, osmo_i460_subchan::rate, osmo_i460_timeslot::schan, subchan_reset(), osmo_i460_subchan::ts, osmo_i460_subchan_demux::user_data, and osmo_i460_subchan_mux::user_data.

## osmo_i460_subchan_count()

static int osmo_i460_subchan_count | ( | struct osmo_i460_timeslot * | ts | ) |

static

References ARRAY_SIZE, len, OSMO_I460_RATE_NONE, and ts.

Referenced by osmo_i460_has_single_64k_schan().

## osmo_i460_subchan_del()

void osmo_i460_subchan_del | ( | struct osmo_i460_subchan * | schan | ) |

References subchan_reset().

## osmo_i460_ts_init()

void osmo_i460_ts_init | ( | struct osmo_i460_timeslot * | ts | ) |

initialize an I.460 timeslot

References ARRAY_SIZE, len, osmo_i460_timeslot::schan, subchan_reset(), and osmo_i460_subchan::ts.

## subchan_reset()

static void subchan_reset | ( | struct osmo_i460_subchan * | schan,
|  | bool | first_time
| ) |  |

static

References osmo_i460_subchan::demux, INIT_LLIST_HEAD, len, osmo_i460_subchan::mux, OSMO_I460_RATE_NONE, osmo_i460_subchan_demux::out_bitbuf, osmo_i460_subchan::rate, and osmo_i460_subchan_mux::tx_queue.

Referenced by osmo_i460_subchan_add(), osmo_i460_subchan_del(), and osmo_i460_ts_init().