libosmoisdn 1.10.0.27-aec32
Osmocom ISDN library
i460_mux.h
Go to the documentation of this file.
1
3/*
4 * (C) 2020 by Harald Welte <laforge@gnumonks.org>
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#pragma once
20#include <stdint.h>
21#include <osmocom/core/bits.h>
23#include <osmocom/core/msgb.h>
24
25#define OSMO_I460_NUM_SUBCHAN 8
26
27/* I.460 sub-slot rate */
29 OSMO_I460_RATE_NONE, /* disabled */
34};
35
37
38typedef void (*out_cb_bits_t)(struct osmo_i460_subchan *schan, void *user_data,
39 const ubit_t *bits, unsigned int num_bits);
40typedef void (*out_cb_bytes_t)(struct osmo_i460_subchan *schan, void *user_data,
41 const uint8_t *bytes, unsigned int num_bytes);
42
45 uint8_t *out_bitbuf;
47 unsigned int out_bitbuf_size;
49 unsigned int out_idx;
53 void *user_data;
54};
55
56typedef void (*in_cb_queue_empty_t)(struct osmo_i460_subchan *schan, void *user_data);
57
62 void *user_data;
63};
64
66 struct osmo_i460_timeslot *ts; /* back-pointer */
67 enum osmo_i460_rate rate; /* 8/16/32/64k */
68 uint8_t bit_offset; /* bit offset inside each byte of the B-channel */
71};
72
75};
76
80 uint8_t bit_offset;
81 struct {
82 /* size (in bits) of the internal buffer; determines granularity */
83 size_t num_bits;
93 /* opaque user data pointer to pass to out_cb */
94 void *user_data;
96
97 struct {
98 /* call-back function whenever the muxer requires more input data from the sub-channels,
99 * but has nothing enqueued yet. A typical function would then call osmo_i460_mux_enqueue() */
101 /* opaque user data pointer to pass to in_cb */
102 void *user_data;
104};
105
106void osmo_i460_demux_in(struct osmo_i460_timeslot *ts, const uint8_t *data, size_t data_len);
107
108void osmo_i460_mux_enqueue(struct osmo_i460_subchan *schan, struct msgb *msg);
109int osmo_i460_mux_out(struct osmo_i460_timeslot *ts, uint8_t *out, size_t out_len);
110
112
113struct osmo_i460_subchan *
114osmo_i460_subchan_add(void *ctx, struct osmo_i460_timeslot *ts, const struct osmo_i460_schan_desc *chd);
115
116void osmo_i460_subchan_del(struct osmo_i460_subchan *schan);
117
119
uint8_t ubit_t
uint8_t data[0]
int osmo_i460_mux_out(struct osmo_i460_timeslot *ts, uint8_t *out, size_t out_len)
Get multiplexed data from de-multiplexer (for feeding it into an E1 timeslot).
Definition: i460_mux.c:269
void osmo_i460_subchan_del(struct osmo_i460_subchan *schan)
Definition: i460_mux.c:382
void(* out_cb_bytes_t)(struct osmo_i460_subchan *schan, void *user_data, const uint8_t *bytes, unsigned int num_bytes)
Definition: i460_mux.h:40
void osmo_i460_demux_in(struct osmo_i460_timeslot *ts, const uint8_t *data, size_t data_len)
Feed multiplexed data (from an E1 timeslot) into de-multiplexer.
Definition: i460_mux.c:128
#define OSMO_I460_NUM_SUBCHAN
Definition: i460_mux.h:25
void osmo_i460_ts_init(struct osmo_i460_timeslot *ts)
initialize an I.460 timeslot
Definition: i460_mux.c:335
void osmo_i460_mux_enqueue(struct osmo_i460_subchan *schan, struct msgb *msg)
enqueue a to-be-transmitted message buffer containing unpacked bits
Definition: i460_mux.c:163
void(* out_cb_bits_t)(struct osmo_i460_subchan *schan, void *user_data, const ubit_t *bits, unsigned int num_bits)
Definition: i460_mux.h:38
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
Definition: i460_mux.c:352
int osmo_i460_subchan_count(struct osmo_i460_timeslot *ts)
count the number of sub-channels in this I.460 slot.
Definition: i460_mux.c:29
osmo_i460_rate
Definition: i460_mux.h:28
@ OSMO_I460_RATE_NONE
Definition: i460_mux.h:29
@ OSMO_I460_RATE_16k
Definition: i460_mux.h:32
@ OSMO_I460_RATE_32k
Definition: i460_mux.h:31
@ OSMO_I460_RATE_8k
Definition: i460_mux.h:33
@ OSMO_I460_RATE_64k
Definition: i460_mux.h:30
void(* in_cb_queue_empty_t)(struct osmo_i460_subchan *schan, void *user_data)
Definition: i460_mux.h:56
description of a sub-channel; passed by caller
Definition: i460_mux.h:78
struct osmo_i460_schan_desc::@1 mux
enum osmo_i460_rate rate
Definition: i460_mux.h:79
size_t num_bits
Definition: i460_mux.h:83
out_cb_bits_t out_cb_bits
call-back function called whenever we received num_bits
Definition: i460_mux.h:85
void * user_data
Definition: i460_mux.h:94
struct osmo_i460_schan_desc::@0 demux
in_cb_queue_empty_t in_cb_queue_empty
Definition: i460_mux.h:100
out_cb_bytes_t out_cb_bytes
out_cb_bytes call-back function called whenever we received num_bits.
Definition: i460_mux.h:92
uint8_t bit_offset
Definition: i460_mux.h:80
Definition: i460_mux.h:43
out_cb_bits_t out_cb_bits
callback to be called once we have received out_bitbuf_size bits
Definition: i460_mux.h:51
out_cb_bytes_t out_cb_bytes
Definition: i460_mux.h:52
uint8_t * out_bitbuf
bit-buffer for output bits
Definition: i460_mux.h:45
unsigned int out_idx
offset of next bit to be written in out_bitbuf
Definition: i460_mux.h:49
unsigned int out_bitbuf_size
size of out_bitbuf in bytes
Definition: i460_mux.h:47
void * user_data
Definition: i460_mux.h:53
Definition: i460_mux.h:58
in_cb_queue_empty_t in_cb_queue_empty
Definition: i460_mux.h:61
struct llist_head tx_queue
list of to-be-transmitted message buffers
Definition: i460_mux.h:60
void * user_data
Definition: i460_mux.h:62
Definition: i460_mux.h:65
struct osmo_i460_timeslot * ts
Definition: i460_mux.h:66
struct osmo_i460_subchan_demux demux
Definition: i460_mux.h:69
uint8_t bit_offset
Definition: i460_mux.h:68
enum osmo_i460_rate rate
Definition: i460_mux.h:67
struct osmo_i460_subchan_mux mux
Definition: i460_mux.h:70
Definition: i460_mux.h:73
struct osmo_i460_subchan schan[OSMO_I460_NUM_SUBCHAN]
Definition: i460_mux.h:74