[zaptel-commits] sruffell: branch sruffell/zaptel-1.4-transcoder r4318 - /team/sruffell/zaptel...
SVN commits to the Zaptel project
zaptel-commits at lists.digium.com
Thu May 22 12:01:16 CDT 2008
Author: sruffell
Date: Thu May 22 12:01:15 2008
New Revision: 4318
URL: http://svn.digium.com/view/zaptel?view=rev&rev=4318
Log:
Primarily....
- Release the io region if firmware isn't availble from user space.
- Do not compile in the network interface by default.
Modified:
team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/base.c
team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/wctc4xxp.h
Modified: team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/base.c?view=diff&rev=4318&r1=4317&r2=4318
==============================================================================
--- team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/base.c (original)
+++ team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/base.c Thu May 22 12:01:15 2008
@@ -93,7 +93,7 @@
#define G729_SAMPLES 160 /* G.729 */
#define G723_SAMPLES 240 /* G.723.1 */
-#define G729_BYTES 20 /* G.729 */
+#define G729_BYTES 20 /* G.729 */
#define G723_6K_BYTES 24 /* G.723.1 at 6.3kb/s */
#define G723_5K_BYTES 20 /* G.723.1 at 5.3kb/s */
#define G723_SID_BYTES 4 /* G.723.1 SID frame */
@@ -543,8 +543,7 @@
dr->desc, dr->desc_dma);
}
-static void
-wcdte_cleanup_command_list(struct wcdte *wc)
+static void wcdte_cleanup_command_list(struct wcdte *wc)
{
unsigned long flags;
struct dte_cmd *cmd;
@@ -560,6 +559,7 @@
free_cmd(cmd);
}
WARN_ON(!list_empty(&wc->cmd_list));
+ WARN_ON(!list_empty(&wc->lost_cmd_list));
spin_unlock_irqrestore(&wc->cmd_list_lock, flags);
}
@@ -696,49 +696,19 @@
static int __zt_send_cmd(struct wcdte *wc, struct dte_cmd *cmd)
{
int ret = 0;
- u16 command;
- unsigned int retries = 0;
- const unsigned int MAX_RETRIES = 1;
-
- command = (cmd->cmd[0x18] << 8) | cmd->cmd[0x19];
-
- wc->last_command_sent = command;
- wc->last_seqno = cmd->cmd[16];
-
- /* \todo I put the retry code in here, before determining that packets
- * were sitting in the tx queue. I haven't yet seen a case where the
- * retry actually allows a packet to complete. Might be a candidate
- * for removal in order to simplify this function. */
- while (retries++ < MAX_RETRIES) {
- dte_transmit_cmd(wc, cmd);
-#if 0 /* This is debug code when investigating the source of the timeouts... */
- if (wait_for_completion_killable(&cmd->complete)) {
- DTE_DEBUG(DTE_DEBUG_GENERAL,
- "Failed to complete transmit.\n");
-
- /* Save this command on the lost list in order to be
- * cleaned up later. */
- spin_lock_irqsave(&wc->cmd_list_lock, flags);
- list_add_tail(&cmd->node, &wc->lost_cmd_list);
- spin_unlock_irqrestore(&wc->cmd_list_lock, flags);
- return -EINTR;
- }
-#else
- /* wait_for_completion(&cmd->complete); */
-#endif
- /* \todo why is this command treated differently? */
- if (0x0000 == command) {
- ret = wcdte_waitfor_dte(wc, RCV_CSMENCAPS_ACK, 2);
- } else {
- ret = wcdte_waitfor_dte(wc, RCV_CSMENCAPS, 0);
- }
- if (unlikely(-EIO == ret)) {
- continue;
- }
- break;
- }
- free_cmd(cmd);
-
+ struct csm_encaps_hdr *cmd_hdr = (struct csm_encaps_hdr*)(&cmd->cmd[14]);
+
+ wc->last_command_sent = be16_to_cpu(cmd_hdr->function);
+ wc->last_seqno = cmd_hdr->seq_num;
+
+ dte_transmit_cmd(wc, cmd);
+
+ /* \todo why is this command treated differently? */
+ if (0x0000 == cmd_hdr->function) {
+ ret = wcdte_waitfor_dte(wc, RCV_CSMENCAPS_ACK, 2);
+ } else {
+ ret = wcdte_waitfor_dte(wc, RCV_CSMENCAPS, 0);
+ }
return ret;
}
@@ -1411,20 +1381,6 @@
}
}
-#if DEFERRED_PROCESSING == WORKQUEUE
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
-static void dte_wque_run(struct work_struct *work)
-{
- struct wcdte *wc = container_of(work, struct wcdte, dte_work);
-#else
-static void dte_wque_run(void *work_data)
-{
- struct wcdte *wc = work_data;
-#endif
- service_dte(wc);
-}
-#endif
-
ZAP_IRQ_HANDLER(wcdte_interrupt)
{
struct wcdte *wc = dev_id;
@@ -1450,11 +1406,7 @@
if (ints & RX_COMPLETE_INTERRUPT) {
reg |= RX_COMPLETE_INTERRUPT;
}
-# if DEFERRED_PROCESSING == WORKQUEUE
- queue_work(wc->dte_wq, &wc->dte_work);
-# else
service_dte(wc);
-# endif
wcdte_setctl(wc, 0x0028, reg);
} else {
if ((ints & 0x00008000) && debug)
@@ -1468,11 +1420,6 @@
if ((ints & 0x00000080) && debug) {
DTE_PRINTK(INFO, "Receive Desciptor Unavailable INT\n");
-# if DEFERRED_PROCESSING == WORKQUEUE
- queue_work(wc->dte_wq, &wc->dte_work);
-# else
- service_dte(wc);
-# endif
}
if ((ints & 0x00000020) && debug)
@@ -1876,43 +1823,6 @@
return 0;
}
-#if 0
-static int
-call_create_channel(struct wcdte *wc, int seq_num, int timeslot)
-{
- int res = 0;
- struct dte_cmd *cmd;
- u8 _cmd[] = CMD_MSG_CREATE_CHANNEL(seq_num, timeslot);
-
- if (!(cmd = alloc_cmd(wc))) {
- return -ENOMEM;
- }
- BUG_ON(sizeof(_cmd) > SFRAME_SIZE);
- memcpy(cmd->cmd, _cmd, sizeof(_cmd));
- cmd->cmdlen = sizeof(_cmd);
- dte_transmit_cmd(wc, cmd);
- /* todo wait for the command to complete */
- return res;
-}
-
-static int
-call_query_channel(struct wcdte *wc, int seq_num, int timeslot)
-{
- struct dte_cmd *cmd;
- u8 _cmd[] = CMD_MSG_QUERY_CHANNEL(seq_num, timeslot);
- if (!(cmd = alloc_cmd(wc))) {
- return -ENOMEM;
- }
- BUG_ON(sizeof(_cmd) > SFRAME_SIZE);
- memcpy(cmd->cmd, _cmd, sizeof(_cmd));
- cmd->cmdlen = sizeof(_cmd);
- dte_transmit_cmd(wc, cmd);
- /* \todo wait for the command to complete */
- return 0;
-}
-
-#endif
-
static int
wcdte_create_channel_pair(struct wcdte *wc, struct channel_pvt *cpvt,
u8 simple, u8 complicated)
@@ -2430,7 +2340,8 @@
ifaces[x] = wc;
memset(wc, 0, sizeof(*wc));
- snprintf(wc->board_name, sizeof(wc->board_name), "tc400b%d", x);
+ snprintf(wc->board_name, sizeof(wc->board_name)-1, "%s%d",
+ d->short_name, x);
wc->iobase = pci_resource_start(pdev, 0);
wc->pdev = pdev;
wc->pos = x;
@@ -2483,21 +2394,10 @@
goto error_exit_swinit;
}
-# if DEFERRED_PROCESSING == WORKQUEUE
- /* Initialize the work queue */
- wc->dte_wq = create_singlethread_workqueue(board_name);
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
- INIT_WORK(&wc->dte_work, dte_wque_run);
-# else
- INIT_WORK(&wc->dte_work, dte_wque_run, wc);
-# endif
-# endif
-
-
#if defined(HOTPLUG_FIRMWARE)
if ((res = request_firmware(&firmware, tc400m_firmware, &wc->pdev->dev)) ||
!firmware) {
- DTE_PRINTK(ERR, "Firmware %s not available from userspace.\n", tc400m_firmware);
+ DTE_PRINTK(ERR, "Firmware %s not available from userspace. (%d)\n", tc400m_firmware, res);
goto error_exit_swinit;
}
#else
@@ -2605,6 +2505,7 @@
zt_transcoder_register(wc->uencode);
zt_transcoder_register(wc->udecode);
LEAVING();
+
return 0;
error_exit_hwinit:
@@ -2612,21 +2513,25 @@
wcdte_cleanup_command_list(wc);
free_irq(pdev->irq, wc);
pci_set_drvdata(pdev, NULL);
- release_region(wc->iobase, 0xff);
error_exit_swinit:
- if (wc->netdev) wcdte_net_unregister(wc);
+ wcdte_net_unregister(wc);
if (wc->encoders) kfree(wc->encoders);
if (wc->decoders) kfree(wc->decoders);
if (wc->uencode) zt_transcoder_free(wc->uencode);
if (wc->udecode) zt_transcoder_free(wc->udecode);
if (wc->txd) {
- if (wc->txd->desc) wcdte_cleanup_descriptor_ring(wc->txd);
+ if (wc->txd->desc) {
+ wcdte_cleanup_descriptor_ring(wc->txd);
+ }
kfree(wc->txd);
}
if (wc->rxd) {
- if (wc->rxd && wc->rxd->desc) wcdte_cleanup_descriptor_ring(wc->rxd);
+ if (wc->rxd && wc->rxd->desc) {
+ wcdte_cleanup_descriptor_ring(wc->rxd);
+ }
kfree(wc->rxd);
}
+ release_region(wc->iobase, 0xff);
kfree(wc);
LEAVING();
return res;
@@ -2696,11 +2601,6 @@
/* There isn't anything that would run in the workqueue that will wait
* on an interrupt. */
-#if DEFERRED_PROCESSING == WORKQUEUE
- /* Kill workqueue */
- destroy_workqueue(wc->dte_wq);
-#endif
-
zt_transcoder_unregister(wc->udecode);
zt_transcoder_unregister(wc->uencode);
@@ -2758,11 +2658,18 @@
int __init ztdte_init(void)
{
int res;
+# ifndef CONFIG_WCDTE_NETWORK_IF
+ if (debug & (DTE_DEBUG_NETWORK_IF|DTE_DEBUG_NETWORK_EARLY)) {
+ printk(KERN_WARNING "%s: The Network interface was not compiled into the driver.\n", THIS_MODULE->name);
+ debug &= ~(DTE_DEBUG_NETWORK_IF|DTE_DEBUG_NETWORK_EARLY);
+ }
+# endif
+
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
- cmd_cache = kmem_cache_create("tc400b", sizeof(struct dte_cmd), 0,
+ cmd_cache = kmem_cache_create(THIS_MODULE->name, sizeof(struct dte_cmd), 0,
SLAB_HWCACHE_ALIGN, NULL, NULL);
# else
- cmd_cache = kmem_cache_create("tc400b", sizeof(struct dte_cmd), 0,
+ cmd_cache = kmem_cache_create(THIS_MODULE->name, sizeof(struct dte_cmd), 0,
SLAB_HWCACHE_ALIGN, NULL);
# endif
@@ -2783,8 +2690,6 @@
kmem_cache_destroy(cmd_cache);
}
-module_param(debug_packets, int, S_IRUGO);
-MODULE_PARM_DESC(debug_packets, "The maximum number of packets to save.");
module_param(debug, int, S_IRUGO | S_IWUSR);
module_param(debug_des, int, S_IRUGO | S_IWUSR);
module_param(debug_des_cnt, int, S_IRUGO | S_IWUSR);
Modified: team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/wctc4xxp.h
URL: http://svn.digium.com/view/zaptel/team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/wctc4xxp.h?view=diff&rev=4318&r1=4317&r2=4318
==============================================================================
--- team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/wctc4xxp.h (original)
+++ team/sruffell/zaptel-1.4-transcoder/kernel/wctc4xxp/wctc4xxp.h Thu May 22 12:01:15 2008
@@ -37,7 +37,13 @@
#include <linux/netdevice.h>
#include <linux/completion.h>
-#define CONFIG_WCDTE_NETWORK_IF
+/* COMPILE TIME OPTIONS =================================================== */
+
+/* If CONFIG_WCDTE_NETWORK_IF is defined the driver will create a standard
+ * network interface for debugging. */
+
+#undef CONFIG_WCDTE_NETWORK_IF
+
#define WARN() WARN_ON(1)
#define DTE_PRINTK(_lvl, _fmt, _args...) \
@@ -56,7 +62,17 @@
printk(KERN_DEBUG "%s: " _fmt, (wc)->board_name, ## _args); \
} \
-#define SFRAME_SIZE 1518
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+#define WARN_ON_ONCE(__condition) do { \
+ static int __once = 1; \
+ if (unlikely(__condition)) { \
+ if (__once) { \
+ __once = 0; \
+ WARN_ON(0); \
+ } \
+ } \
+} while(0)
+#endif
extern int debug;
@@ -70,6 +86,7 @@
unsigned long flags;
struct completion complete;
/* cmd must be the last field. */
+#define SFRAME_SIZE 1518
u8 cmd[SFRAME_SIZE];
};
@@ -89,7 +106,6 @@
extern struct kmem_cache *cmd_cache;
#endif
-
static inline struct dte_cmd *
__alloc_cmd(unsigned alloc_flags, unsigned long cmd_flags)
{
@@ -120,9 +136,7 @@
struct wcdte {
char board_name[40];
- struct pci_dev *pdev;
const char *variety;
- unsigned int intmask;
int pos;
int cards;
spinlock_t reglock;
@@ -137,6 +151,7 @@
spinlock_t cmd_list_lock;
struct list_head cmd_list;
+
/* This is a list to hold those commands which were flagged to not
* auto delete, but which we stopped waiting for because of a signal.
* Use the cmd_list_lock to protect this list. */
@@ -157,16 +172,12 @@
* physical interface to the transcoding engine.
*
*/
- unsigned long iobase;
+ struct pci_dev *pdev;
+ unsigned int intmask;
+ unsigned long iobase;
struct dte_descriptor_ring *txd;
struct dte_descriptor_ring *rxd;
-#if DEFERRED_PROCESSING == WORKQUEUE
- struct workqueue_struct *dte_wq;
- struct work_struct dte_work;
-#endif
- struct work_struct reset_work;
-
struct zt_transcoder *uencode;
struct zt_transcoder *udecode;
struct channel_pvt *encoders;
@@ -176,13 +187,13 @@
struct dentry *debugfs_file;
#endif
+#ifdef CONFIG_WCDTE_NETWORK_IF
/*
* This section contains the members necessary for exporting the
* network interface to the host system. This is only used for
* debugging purposes.
*
*/
-#ifdef CONFIG_WCDTE_NETWORK_IF
struct sk_buff_head captured_packets;
struct net_device *netdev;
struct net_device_stats net_stats;
@@ -194,6 +205,7 @@
};
static inline int wcdte_reset_pending(struct wcdte *wc) {
+
return test_bit(DTEF_RESET_PENDING, &wc->flags);
}
@@ -206,7 +218,7 @@
int __res; \
u8 _cmd[] = command; \
struct dte_cmd *cmd; \
- if (!(cmd=__alloc_cmd(GFP_KERNEL, NO_AUTO_FREE_CMD))) \
+ if (!(cmd=__alloc_cmd(GFP_KERNEL, 0))) \
return -ENOMEM; \
BUG_ON(sizeof(_cmd) > SFRAME_SIZE); \
memcpy(cmd->cmd, _cmd, sizeof(_cmd)); \
More information about the zaptel-commits
mailing list