freetdm: add support for setting the channel tx/rx queue size from config file (wanpipe.conf) and from CLI
This commit is contained in:
parent
88a6ac2ff4
commit
63706a839f
|
@ -1,4 +1,13 @@
|
|||
[defaults]
|
||||
; User space interval at which data will be delivered
|
||||
codec_ms => 20
|
||||
|
||||
; wink and flash interval
|
||||
wink_ms => 150
|
||||
flash_ms => 750
|
||||
|
||||
; size of the driver queue of elements of MTU size
|
||||
; typical case is 10 elements of 80 bytes each (10ms of ulaw/alaw)
|
||||
; don't mess with this if you don't know what you're doing
|
||||
; txqueue_size => 10
|
||||
; rxqueue_size => 10
|
||||
|
|
|
@ -3621,8 +3621,9 @@ void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *
|
|||
"ftdm trace <path> <span_id|span_name> [<chan_id>]\n" \
|
||||
"ftdm notrace <span_id|span_name> [<chan_id>]\n" \
|
||||
"ftdm q931_pcap <span_id> on|off [pcapfilename without suffix]\n" \
|
||||
"ftdm gains <txgain> <rxgain> <span_id> [<chan_id>]\n" \
|
||||
"ftdm gains <rxgain> <txgain> <span_id> [<chan_id>]\n" \
|
||||
"ftdm dtmf on|off <span_id> [<chan_id>]\n" \
|
||||
"ftdm queuesize <rxsize> <txsize> <span_id> [<chan_id>]\n" \
|
||||
"--------------------------------------------------------------------------------\n"
|
||||
SWITCH_STANDARD_API(ft_function)
|
||||
{
|
||||
|
@ -4059,7 +4060,7 @@ SWITCH_STANDARD_API(ft_function)
|
|||
ftdm_channel_t *chan;
|
||||
ftdm_span_t *span = NULL;
|
||||
if (argc < 4) {
|
||||
stream->write_function(stream, "-ERR Usage: ft gains <rxgain> <txgain> <span_id> [<chan_id>]\n");
|
||||
stream->write_function(stream, "-ERR Usage: ftdm gains <rxgain> <txgain> <span_id> [<chan_id>]\n");
|
||||
goto end;
|
||||
}
|
||||
ftdm_span_find_by_name(argv[3], &span);
|
||||
|
@ -4094,6 +4095,50 @@ SWITCH_STANDARD_API(ft_function)
|
|||
}
|
||||
}
|
||||
stream->write_function(stream, "+OK gains set to Rx %f and Tx %f\n", rxgain, txgain);
|
||||
} else if (!strcasecmp(argv[0], "queuesize")) {
|
||||
unsigned int i = 0;
|
||||
uint32_t rxsize = 10;
|
||||
uint32_t txsize = 10;
|
||||
uint32_t chan_id = 0;
|
||||
uint32_t ccount = 0;
|
||||
ftdm_channel_t *chan;
|
||||
ftdm_span_t *span = NULL;
|
||||
if (argc < 4) {
|
||||
stream->write_function(stream, "-ERR Usage: ftdm queuesize <rxsize> <txsize> <span_id> [<chan_id>]\n");
|
||||
goto end;
|
||||
}
|
||||
ftdm_span_find_by_name(argv[3], &span);
|
||||
if (!span) {
|
||||
stream->write_function(stream, "-ERR invalid span\n");
|
||||
goto end;
|
||||
}
|
||||
if (argc > 4) {
|
||||
chan_id = atoi(argv[4]);
|
||||
if (chan_id > ftdm_span_get_chan_count(span)) {
|
||||
stream->write_function(stream, "-ERR invalid chan\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
i = sscanf(argv[1], "%u", &rxsize);
|
||||
i += sscanf(argv[2], "%u", &txsize);
|
||||
if (i != 2) {
|
||||
stream->write_function(stream, "-ERR invalid queue sizes provided\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (chan_id) {
|
||||
chan = ftdm_span_get_channel(span, chan_id);
|
||||
ftdm_channel_command(chan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &rxsize);
|
||||
ftdm_channel_command(chan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &txsize);
|
||||
} else {
|
||||
ccount = ftdm_span_get_chan_count(span);
|
||||
for (i = 1; i < ccount; i++) {
|
||||
chan = ftdm_span_get_channel(span, i);
|
||||
ftdm_channel_command(chan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &rxsize);
|
||||
ftdm_channel_command(chan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &txsize);
|
||||
}
|
||||
}
|
||||
stream->write_function(stream, "+OK queue sizes set to Rx %d and Tx %d\n", rxsize, txsize);
|
||||
} else if (!strcasecmp(argv[0], "restart")) {
|
||||
uint32_t chan_id = 0;
|
||||
ftdm_channel_t *chan;
|
||||
|
|
|
@ -91,6 +91,8 @@ typedef enum {
|
|||
*/
|
||||
static struct {
|
||||
uint32_t codec_ms;
|
||||
uint32_t rxqueue_size;
|
||||
uint32_t txqueue_size;
|
||||
uint32_t wink_ms;
|
||||
uint32_t flash_ms;
|
||||
uint32_t ring_on_ms;
|
||||
|
@ -406,6 +408,20 @@ static FIO_CONFIGURE_FUNCTION(wanpipe_configure)
|
|||
} else {
|
||||
wp_globals.codec_ms = num;
|
||||
}
|
||||
} else if (!strcasecmp(var, "rxqueue_size")) {
|
||||
num = atoi(val);
|
||||
if (num < 1 || num > 1000) {
|
||||
ftdm_log(FTDM_LOG_WARNING, "invalid rx queue size at line %d\n", lineno);
|
||||
} else {
|
||||
wp_globals.rxqueue_size = num;
|
||||
}
|
||||
} else if (!strcasecmp(var, "txqueue_size")) {
|
||||
num = atoi(val);
|
||||
if (num < 1 || num > 1000) {
|
||||
ftdm_log(FTDM_LOG_WARNING, "invalid tx queue size at line %d\n", lineno);
|
||||
} else {
|
||||
wp_globals.txqueue_size = num;
|
||||
}
|
||||
} else if (!strcasecmp(var, "wink_ms")) {
|
||||
num = atoi(val);
|
||||
if (num < 50 || num > 3000) {
|
||||
|
@ -544,6 +560,13 @@ static FIO_OPEN_FUNCTION(wanpipe_open)
|
|||
ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL);
|
||||
ftdmchan->effective_interval = ftdmchan->native_interval = wp_globals.codec_ms;
|
||||
ftdmchan->packet_len = ftdmchan->native_interval * 8;
|
||||
|
||||
if (wp_globals.txqueue_size > 0) {
|
||||
ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &wp_globals.txqueue_size);
|
||||
}
|
||||
if (wp_globals.rxqueue_size > 0) {
|
||||
ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &wp_globals.rxqueue_size);
|
||||
}
|
||||
}
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
|
@ -1573,6 +1596,9 @@ static FIO_IO_LOAD_FUNCTION(wanpipe_init)
|
|||
wp_globals.flash_ms = 750;
|
||||
wp_globals.ring_on_ms = 2000;
|
||||
wp_globals.ring_off_ms = 4000;
|
||||
/* 0 for queue size will leave driver defaults */
|
||||
wp_globals.txqueue_size = 0;
|
||||
wp_globals.rxqueue_size = 0;
|
||||
wanpipe_interface.name = "wanpipe";
|
||||
wanpipe_interface.configure_span = wanpipe_configure_span;
|
||||
wanpipe_interface.configure = wanpipe_configure;
|
||||
|
|
Loading…
Reference in New Issue