From d8562c778088ff6ab3383df5ceead41eff4bf124 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Thu, 19 Mar 2009 20:08:29 +0000 Subject: xpp: a massive backport from DAHDI. From Xorcom branch-rel-6839-r6908 . Sun Mar 1 2009 Oron Peled - xpp.r6795 * Fix cases where the command_queue overflowed during initialization. - Also add a 'command_queue_length' parameter to xpp.ko * More migrations to sysfs: - Add a 'transport' attribute to our astribank devices which points to the usb device we use. E.g: /sys/bus/astribanks/devices/xbus-00/transport is symlinked to ../../../../../../devices/pci0000:00/0000:00:10.4/usb5/5-4 - Move /proc/xpp/XBUS-??/XPD-??/span to /sys/bus/xpds/devices/??:?:?/span - Migrate from /proc/xpp/sync to: /sys/bus/astribanks/drivers/xppdrv/sync - New 'offhook' attribute in: /sys/bus/xpds/devices/??:?:?/offhook * PRI: change the "timing" priority to match the convention used by other PRI cards -- I.e: lower numbers (not 0) have higher priority. * FXO: - Power denial: create two module parameters instead of hard-coded constants (power_denial_safezone, power_denial_minlen). For sites that get non-standard power-denial signals from central office on offhook. - Don't hangup on power-denial, just notify Dahdi and wait for - Fix caller-id detection for the case central office sends it before first ring without any indication before. Asterisk's desicion. Mon, Dec 8 2008 Oron Peled - xpp.r6430 * PRI: - Match our span clocking priorities (in system.conf) to Digium -- this is a reversal of the previous state. Now lower numbers (greater than 0) are better. - Synchronization fixes for PRI ports other than 0. - Fix T1 CRC for some countries (e.g: China). * FXS: fix bug in VMWI detection if using old asterisk which does not provide ZT_VMWI ioctl(). * FXO: - Improve caller_id_style module parameter. This provide a workaround for countries that send this information without any notification (reverse polarity, ring, etc.) - Don't force on-hook upon power-denial. So, loopstart devices would ignore these as expected. * Implement a flow-control to prevent user space (init_card_* scripts) from pressuring our command queue. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4631 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- kernel/xpp/xbus-core.h | 92 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 28 deletions(-) (limited to 'kernel/xpp/xbus-core.h') diff --git a/kernel/xpp/xbus-core.h b/kernel/xpp/xbus-core.h index 85fac80..a24d76b 100644 --- a/kernel/xpp/xbus-core.h +++ b/kernel/xpp/xbus-core.h @@ -86,18 +86,35 @@ static struct xbus_counters { #define XBUS_COUNTER_MAX ARRAY_SIZE(xbus_counters) +enum xbus_state { + XBUS_STATE_START, + XBUS_STATE_IDLE, + XBUS_STATE_SENT_REQUEST, + XBUS_STATE_RECVD_DESC, + XBUS_STATE_READY, + XBUS_STATE_DEACTIVATING, + XBUS_STATE_DEACTIVATED, + XBUS_STATE_DISCONNECTED, + XBUS_STATE_FAIL, +}; + +const char *xbus_statename(enum xbus_state st); + struct xbus_transport { struct xbus_ops *ops; void *priv; + struct device *transport_device; ushort max_send_size; - bool transport_running; /* Hardware is functional */ + enum xbus_state xbus_state; + spinlock_t state_lock; atomic_t transport_refcount; wait_queue_head_t transport_unused; spinlock_t lock; }; #define MAX_SEND_SIZE(xbus) ((xbus)->transport.max_send_size) -#define TRANSPORT_RUNNING(xbus) ((xbus)->transport.transport_running) +#define XBUS_STATE(xbus) ((xbus)->transport.xbus_state) +#define XBUS_IS(xbus, st) (XBUS_STATE(xbus) == XBUS_STATE_ ## st) #define TRANSPORT_EXIST(xbus) ((xbus)->transport.ops != NULL) struct xbus_ops *transportops_get(xbus_t *xbus); @@ -133,8 +150,10 @@ void put_xframe(struct xframe_queue *q, xframe_t *xframe); #define FREE_SEND_XFRAME(xbus, xframe) put_xframe(&(xbus)->send_pool, (xframe)) #define FREE_RECV_XFRAME(xbus, xframe) put_xframe(&(xbus)->receive_pool, (xframe)) -xbus_t *get_xbus(uint num); -void put_xbus(xbus_t *xbus); +xbus_t *xbus_num(uint num); +xbus_t *get_xbus(const char *msg, xbus_t *xbus); +void put_xbus(const char *msg, xbus_t *xbus); +int refcount_xbus(xbus_t *xbus); /* * An xbus is a transport layer for Xorcom Protocol commands @@ -143,7 +162,7 @@ struct xbus { char busname[XBUS_NAMELEN]; /* set by xbus_new() */ /* low-level bus drivers set these 2 fields */ - char location[XBUS_DESCLEN]; + char connector[XBUS_DESCLEN]; char label[LABEL_SIZE]; byte revision; /* Protocol revision */ struct xbus_transport transport; @@ -151,6 +170,8 @@ struct xbus { int num; struct xpd *xpds[MAX_XPDS]; + int command_tick_counter; + int usec_nosend; /* Firmware flow control */ struct xframe_queue command_queue; wait_queue_head_t command_queue_empty; @@ -180,7 +201,6 @@ struct xbus { #define dev_to_xbus(dev) container_of(dev, struct xbus, astribank) spinlock_t lock; - atomic_t xbus_ref_count; /* How many need this struct? */ /* PCM metrics */ struct timeval last_tx_sync; @@ -198,6 +218,7 @@ struct xbus { #endif struct xbus_workqueue *worker; + struct semaphore in_worker; /* * Sync adjustment @@ -206,11 +227,7 @@ struct xbus { int sync_adjustment_offset; long pll_updated_at; - struct rw_semaphore in_use; -#define XBUS_GET(xbus) down_read_trylock(&(xbus)->in_use) -#define XBUS_PUT(xbus) up_read(&(xbus)->in_use) - - int num_xpds; + atomic_t num_xpds; #ifdef XPP_DEBUGFS struct dentry *debugfs_dir; @@ -245,6 +262,7 @@ struct xframe { size_t frame_maxlen; byte *packets; /* max XFRAME_DATASIZE */ byte *first_free; + int usec_towait; /* prevent overflowing AB */ void *priv; }; @@ -281,25 +299,43 @@ xpacket_t *xframe_next_packet(xframe_t *xframe, int len); xpd_t *xpd_of(const xbus_t *xbus, int xpd_num); xpd_t *xpd_byaddr(const xbus_t *xbus, uint unit, uint subunit); -xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size, void *priv); -void xbus_remove(xbus_t *xbus); -int xbus_activate(xbus_t *xbus); -void xbus_disconnect(xbus_t *xbus); -void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -void xbus_populate(struct work_struct *work); -#else -void xbus_populate(void *data); -#endif - -int xbus_register_xpd(xbus_t *xbus, xpd_t *xpd); -int xbus_unregister_xpd(xbus_t *xbus, xpd_t *xpd); +bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate); +xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size, struct device *transport_device, void *priv); +void xbus_free(xbus_t *xbus); +int xbus_connect(xbus_t *xbus); +int xbus_activate(xbus_t *xbus); +void xbus_deactivate(xbus_t *xbus, bool is_disconnected); +void xbus_disconnect(xbus_t *xbus); +void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe); +int xbus_process_worker(xbus_t *xbus); +int waitfor_xpds(xbus_t *xbus, char *buf); + +int xbus_xpd_bind(xbus_t *xbus, xpd_t *xpd, int unit, int subunit); +int xbus_xpd_unbind(xbus_t *xbus, xpd_t *xpd); /* sysfs */ -int register_xpp_bus(void); -void unregister_xpp_bus(void); -int xbus_sysfs_create(xbus_t *xbus); -void xbus_sysfs_remove(xbus_t *xbus); +int xpd_device_register(xbus_t *xbus, xpd_t *xpd); +void xpd_device_unregister(xpd_t *xpd); + +int xpp_driver_init(void); +void xpp_driver_exit(void); +int xbus_sysfs_create(xbus_t *xbus); +void xbus_sysfs_remove(xbus_t *xbus); + +#ifdef OLD_HOTPLUG_SUPPORT_269 +/* Copy from new kernels lib/kobject_uevent.c */ +enum kobject_action { + KOBJ_ADD, + KOBJ_REMOVE, + KOBJ_CHANGE, + KOBJ_MOUNT, + KOBJ_UMOUNT, + KOBJ_OFFLINE, + KOBJ_ONLINE, +}; +#endif + +void astribank_uevent_send(xbus_t *xbus, enum kobject_action act); #endif /* XBUS_CORE_H */ -- cgit v1.2.3