diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-12-18 14:31:07 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-12-18 14:31:07 +0000 |
commit | cfd61537b47387b0fb5c8228baad6cec16d8f6e6 (patch) | |
tree | 108deea65c09c7c273a9b981f8783efcd433eaea /xpp/xproto.c | |
parent | 4391b4a6ee42bdfd8e097c5ee5485e9eb13f19a0 (diff) |
xpp r5151:
* xpd_pri: Basically ready.
* PCM synchronization changes:
- Each Astribank unit ticks independently. Each with its own PLL.
- HOST synchronization is gone. Loading of xpp will no longer cause
useless 250 ticks per second if you have no Astribank.
- Synchronization from the zaptel sync master requires setting
ZAPTEL as sync source (xpp_sync ZAPTEL).
* rx_tasklet is now a parameter of the module xpp, rather than of xpp_usb.
* New FPGA firmware: 5128 (1151) / 5122 (1141, 1131):
- Fixes synchronization issues.
- PRI module: E1 should now work.
* perl module and utilities:
- Modules no longer magically scan system on initialization.
- Scanning is by calling explicit methods.
- "Serial" has been renamed "Label". It is basically unique, but
should be modifieble.
- Some basic documentation of zaptel perl modules.
* Default sort order of zt_registration is back to SORT_CONNCTOR.
* zt_registration proc file now shows the number of span registered to
if registered. Try: grep . /proc/xpp/XBUS-*/XPD-*/zt_registration
* genzaptelconf: Allow using a custom command instead of
/etc/init.d/asterisk to start/stop asterisk.
* Fixed the typo "Slagish".
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3506 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/xproto.c')
-rw-r--r-- | xpp/xproto.c | 97 |
1 files changed, 47 insertions, 50 deletions
diff --git a/xpp/xproto.c b/xpp/xproto.c index 89417b8..83a66d8 100644 --- a/xpp/xproto.c +++ b/xpp/xproto.c @@ -205,59 +205,29 @@ out: return ret; } -int xframe_receive(xbus_t *xbus, xframe_t *xframe) +static int xframe_receive_cmd(xbus_t *xbus, xframe_t *xframe) { - byte *p; - byte *xpacket_start; byte *xframe_end; - int ret = 0; xpacket_t *pack; + byte *p; int len; - bool is_pcm; - struct timeval now; - int usec; + int ret; - if(!down_read_trylock(&xbus->in_use)) { - XBUS_DBG(GENERAL, xbus, "Dropped xframe. Is in_use\n"); - return -ENODEV; - } - p = xpacket_start = xframe->packets; - xframe_end = xpacket_start + XFRAME_LEN(xframe); - if(XFRAME_LEN(xframe) < RPACKET_HEADERSIZE) { - static int rate_limit; - - if((rate_limit++ % 1003) == 0) { - XBUS_NOTICE(xbus, "short xframe\n"); - dump_xframe("short xframe", xbus, xframe); - } - goto bad_proto; - } - /* - * We want to check that xframes do not mix PCM and other commands - */ - is_pcm = XPACKET_IS_PCM((xpacket_t *)p); - if(is_pcm && (print_dbg & DBG_PCM)) - dump_xframe("RX_XFRAME_PCM", xbus, xframe); + p = xframe->packets; + xframe_end = p + XFRAME_LEN(xframe); do { pack = (xpacket_t *)p; len = XPACKET_LEN(pack); /* Sanity checks */ - if(unlikely(is_pcm && XPACKET_OP(pack) != XPROTO_NAME(GLOBAL,PCM_READ))) { - static int rate_limit; - - if((rate_limit++ % 1003) == 0) { - XBUS_DBG(GENERAL, xbus, "Non-PCM packet within a PCM xframe\n"); - dump_xframe("In PCM xframe", xbus, xframe); - } - // goto bad_proto; - } else if(unlikely(!is_pcm && XPACKET_OP(pack) == XPROTO_NAME(GLOBAL,PCM_READ))) { + if(unlikely(XPACKET_OP(pack) == XPROTO_NAME(GLOBAL,PCM_READ))) { static int rate_limit; if((rate_limit++ % 1003) == 0) { XBUS_DBG(GENERAL, xbus, "A PCM packet within a Non-PCM xframe\n"); dump_xframe("In Non-PCM xframe", xbus, xframe); } - // goto bad_proto; + ret = -EPROTO; + goto out; } p += len; if(p > xframe_end || len < RPACKET_HEADERSIZE) { @@ -267,33 +237,60 @@ int xframe_receive(xbus_t *xbus, xframe_t *xframe) XBUS_NOTICE(xbus, "Invalid packet length %d\n", len); dump_xframe("BAD LENGTH", xbus, xframe); } - goto bad_proto; + ret = -EPROTO; + goto out; } ret = packet_process(xbus, pack); if(unlikely(ret < 0)) - goto out; + break; } while(p < xframe_end); - if(is_pcm) - XBUS_COUNTER(xbus, RX_XFRAME_PCM)++; out: + FREE_RECV_XFRAME(xbus, xframe); + return ret; +} + +int xframe_receive(xbus_t *xbus, xframe_t *xframe) +{ + int ret = 0; + struct timeval now; + struct timeval tv_received; + int usec; + + if(XFRAME_LEN(xframe) < RPACKET_HEADERSIZE) { + static int rate_limit; + + if((rate_limit++ % 1003) == 0) { + XBUS_NOTICE(xbus, "short xframe\n"); + dump_xframe("short xframe", xbus, xframe); + } + return -EPROTO; + } + if(!XBUS_GET(xbus)) { + XBUS_DBG(GENERAL, xbus, "Dropped xframe. Is shutting down.\n"); + return -ENODEV; + } + tv_received = xframe->tv_received; + /* + * We want to check that xframes do not mix PCM and other commands + */ + if(XPACKET_IS_PCM((xpacket_t *)xframe->packets)) + xframe_receive_pcm(xbus, xframe); + else + ret = xframe_receive_cmd(xbus, xframe); /* Calculate total processing time */ do_gettimeofday(&now); - usec = (now.tv_sec - xframe->tv_received.tv_sec) * 1000000 + - now.tv_usec - xframe->tv_received.tv_usec; + usec = (now.tv_sec - tv_received.tv_sec) * 1000000 + + now.tv_usec - tv_received.tv_usec; if(usec > xbus->max_rx_process) xbus->max_rx_process = usec; - xbus->ops->xframe_free(xbus, xframe); - up_read(&xbus->in_use); + XBUS_PUT(xbus); return ret; -bad_proto: - ret = -EPROTO; - goto out; } #define VERBOSE_DEBUG 1 #define ERR_REPORT_LIMIT 20 -void dump_packet(const char *msg, xpacket_t *packet, bool print_dbg) +void dump_packet(const char *msg, const xpacket_t *packet, bool print_dbg) { byte op = XPACKET_OP(packet); byte *addr = (byte *)&XPACKET_ADDR(packet); |