diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2009-05-27 10:01:24 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2009-05-27 10:01:24 +0000 |
commit | 18c6813f2c788b603dab363b9138d65d24252167 (patch) | |
tree | 92402484268f2bc1d5e4e55f7321b9204ad47c5f /kernel/xpp/xbus-core.c | |
parent | 2a73224819e867eaf56371d6055e2ca4d36396b6 (diff) |
Big dump of newer xpp code.
For finer details and separate commits, you are advised to look into the
commit log of dahdi-{linux,tools}.
xpp.r7150
* 116x Astribanks:
- Support for the TwinStar capability and for FXO and (BRI|PRI) on
same device.
- New control protocol ("MPP").
- astribank_hextool - a low-level firmware loading tool instead of
fpga_load .
- astribank_tool - Other MPP activities .
- Can still reset (but just that) through older protocol.
- astribank_hexload is required for loading FPGA firmware for USB_FW.hex
rev > 6885.
- USB_FW rev. 7071 .
- More modular FPGA firmware (1161 only).
- FPGA_1161.hex rev. 7131. PIC_TYPE_* rev. 7107.
- software-settings of some capabilities with astribank_allow .
* XPP:
- init_card_* script are less verbose.
- Reduced rate of "Is a DAHDI sync master" message.
- Replace member bus_id with dev_name() and set_dev_name() for
building with 2.6.30.
- Conditionally remove 'owner' property of procfs was dropped in 2.6.30.
- astribank_hook now enabled by default.
- Has an optional hook for TwinStar.
* BRI:
- hardhdlc support: The bri_dchan patch is no longer needed.
- If bri_dchan patch applied: old code is used, and "dchan" is used.
- If not: new code and "hardhdlc" is used.
- zapconf will generate the right configuration, depending on the new
sysfs driver attribute bri_hardhdlc, but default to "dchan" as
before if not explicitly told.
- Bugfix: explicitly turn off leds on startup.
* FXS:
- Initialization and calibration fixes.
- Notify the user just one about wrong VMWI config
* Dahdi-perl:
- Fix detection of empty slots in wctdm.
- Fix working with ethmf's extra file in /proc/zaptel
- Improved detection of Rhino cards.
- dahdi_genconf's generated text better explains files are generated.
- /etc/xpp_order - allow specifiying an explicit order for
Astribanks to register with Zaptel.
- Dahdi::Xpp::Mpp - A wrapper around astribank_tool .
* dahdi.init:
- A separate waitfor_xpds script. May now have a wait-loop in
some cases.
- xpp_sync needs to only be called after dahdi_cfg .
(for the PRI module).
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4641 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/xbus-core.c')
-rw-r--r-- | kernel/xpp/xbus-core.c | 78 |
1 files changed, 55 insertions, 23 deletions
diff --git a/kernel/xpp/xbus-core.c b/kernel/xpp/xbus-core.c index 9a62f94..68fc617 100644 --- a/kernel/xpp/xbus-core.c +++ b/kernel/xpp/xbus-core.c @@ -90,7 +90,6 @@ const char *xbus_statename(enum xbus_state st) case XBUS_STATE_READY: return "READY"; case XBUS_STATE_DEACTIVATING: return "DEACTIVATING"; case XBUS_STATE_DEACTIVATED: return "DEACTIVATED"; - case XBUS_STATE_DISCONNECTED: return "DISCONNECTED"; case XBUS_STATE_FAIL: return "FAIL"; } return NULL; @@ -481,7 +480,7 @@ static int really_send_cmd_frame(xbus_t *xbus, xframe_t *xframe) BUG_ON(!xbus); BUG_ON(!xframe); BUG_ON(xframe->xframe_magic != XFRAME_MAGIC); - if(XBUS_IS(xbus, DISCONNECTED)) { + if(!XBUS_FLAGS(xbus, CONNECTED)) { XBUS_ERR(xbus, "Dropped command before sending -- hardware deactivated.\n"); dump_xframe("Dropped", xbus, xframe, DBG_ANY); FREE_SEND_XFRAME(xbus, xframe); @@ -521,8 +520,8 @@ int xbus_command_queue_tick(xbus_t *xbus) ret = really_send_cmd_frame(xbus, frm); if(ret < 0) { XBUS_ERR(xbus, - "Failed to send from command_queue (ret=%d)\n", - ret); + "Failed to send from command_queue (ret=%d)\n", + ret); xbus_setstate(xbus, XBUS_STATE_FAIL); } } @@ -562,7 +561,7 @@ int send_cmd_frame(xbus_t *xbus, xframe_t *xframe) BUG_ON(xframe->xframe_magic != XFRAME_MAGIC); - if(XBUS_IS(xbus, DISCONNECTED)) { + if(!XBUS_FLAGS(xbus, CONNECTED)) { XBUS_ERR(xbus, "Dropped command before queueing -- hardware deactivated.\n"); ret = -ENODEV; goto err; @@ -627,7 +626,7 @@ void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe) if(rx_tasklet) { xframe_enqueue_recv(xbus, xframe); } else { - if(likely(!XBUS_IS(xbus, DISCONNECTED))) + if(likely(XBUS_FLAGS(xbus, CONNECTED))) xframe_receive(xbus, xframe); else FREE_RECV_XFRAME(xbus, xframe); /* return to receive_pool */ @@ -728,6 +727,7 @@ static int new_card(xbus_t *xbus, int i; int subunits; int ret = 0; + int remaining_ports; proto_table = xproto_get(type); if(!proto_table) { @@ -736,6 +736,7 @@ static int new_card(xbus_t *xbus, unit, type); return -EINVAL; } + remaining_ports = ports; subunits = (ports + proto_table->ports_per_subunit - 1) / proto_table->ports_per_subunit; XBUS_DBG(DEVICES, xbus, "CARD %d type=%d.%d ports=%d (%dx%d), %d subunits, port-dir=0x%02X\n", @@ -752,6 +753,21 @@ static int new_card(xbus_t *xbus, BUG_ON(!xops); xbus->worker->num_units += subunits - 1; for(i = 0; i < subunits; i++) { + int subunit_ports = proto_table->ports_per_subunit; + + if(subunit_ports > remaining_ports) + subunit_ports = remaining_ports; + remaining_ports -= proto_table->ports_per_subunit; + if(subunit_ports <= 0) { + XBUS_NOTICE(xbus, + "Subunit XPD=%d%d without ports (%d of %d)\n", + unit, + i, + subunit_ports, + ports); + ret = -ENODEV; + goto out; + } if(!XBUS_IS(xbus, RECVD_DESC)) { XBUS_NOTICE(xbus, "Cannot create XPD=%d%d in state %s\n", @@ -761,18 +777,18 @@ static int new_card(xbus_t *xbus, ret = -ENODEV; goto out; } - XBUS_DBG(DEVICES, xbus, "Creating XPD=%d%d type=%d.%d\n", + XBUS_DBG(DEVICES, xbus, "Creating XPD=%d%d type=%d.%d (%d ports)\n", unit, i, type, - subtype); + subtype, subunit_ports); if(!XBUS_IS(xbus, RECVD_DESC)) { XBUS_ERR(xbus, "Aborting creation -- In bad state %s\n", xbus_statename(XBUS_STATE(xbus))); ret = -ENODEV; goto out; } - ret = create_xpd(xbus, proto_table, unit, i, type, subtype, subunits, port_dir); + ret = create_xpd(xbus, proto_table, unit, i, type, subtype, subunits, subunit_ports, port_dir); if(ret < 0) { XBUS_ERR(xbus, "Creation of XPD=%d%d failed %d\n", unit, i, ret); @@ -1086,6 +1102,22 @@ err: return NULL; } +bool xbus_setflags(xbus_t *xbus, int flagbit, bool on) +{ + unsigned long flags; + + spin_lock_irqsave(&xbus->transport.state_lock, flags); + XBUS_DBG(DEVICES, xbus, "%s flag %d\n", + (on) ? "Set" : "Clear", + flagbit); + if(on) + set_bit(flagbit, &(xbus->transport.transport_flags)); + else + clear_bit(flagbit, &(xbus->transport.transport_flags)); + spin_unlock_irqrestore(&xbus->transport.state_lock, flags); + return 1; +} + bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate) { unsigned long flags; @@ -1122,19 +1154,19 @@ bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate) state_flip = 1; /* We are good */ break; case XBUS_STATE_DEACTIVATING: -#if 0 - if(XBUS_IS(xbus, DEACTIVATED) || XBUS_IS(xbus, DISCONNECTED)) + if(XBUS_IS(xbus, DEACTIVATING)) + goto bad_state; + if(XBUS_IS(xbus, DEACTIVATED)) goto bad_state; -#endif break; case XBUS_STATE_DEACTIVATED: if(!XBUS_IS(xbus, DEACTIVATING)) goto bad_state; break; - case XBUS_STATE_DISCONNECTED: - break; case XBUS_STATE_FAIL: - if(XBUS_IS(xbus, DEACTIVATING) || XBUS_IS(xbus, DEACTIVATED) || XBUS_IS(xbus, DISCONNECTED)) + if(XBUS_IS(xbus, DEACTIVATING)) + goto bad_state; + if(XBUS_IS(xbus, DEACTIVATED)) goto bad_state; break; default: @@ -1195,11 +1227,12 @@ int xbus_connect(xbus_t *xbus) BUG_ON(!ops->xframe_send_cmd); BUG_ON(!ops->alloc_xframe); BUG_ON(!ops->free_xframe); + xbus_setflags(xbus, XBUS_FLAG_CONNECTED, 1); xbus_activate(xbus); return 0; } -void xbus_deactivate(xbus_t *xbus, bool is_disconnected) +void xbus_deactivate(xbus_t *xbus) { BUG_ON(!xbus); XBUS_INFO(xbus, "[%s] Deactivating\n", xbus->label); @@ -1213,16 +1246,15 @@ void xbus_deactivate(xbus_t *xbus, bool is_disconnected) xbus_setstate(xbus, XBUS_STATE_DEACTIVATED); worker_reset(xbus->worker); xbus_release_xpds(xbus); - if(!is_disconnected) - xbus_setstate(xbus, XBUS_STATE_IDLE); elect_syncer("deactivate"); } void xbus_disconnect(xbus_t *xbus) { - XBUS_INFO(xbus, "[%s] Disconnecting\n", xbus->label); BUG_ON(!xbus); - xbus_deactivate(xbus, 1); + XBUS_INFO(xbus, "[%s] Disconnecting\n", xbus->label); + xbus_setflags(xbus, XBUS_FLAG_CONNECTED, 0); + xbus_deactivate(xbus); xbus_command_queue_clean(xbus); xbus_command_queue_waitempty(xbus); tasklet_kill(&xbus->receive_tasklet); @@ -1230,7 +1262,6 @@ void xbus_disconnect(xbus_t *xbus) xframe_queue_clear(&xbus->send_pool); xframe_queue_clear(&xbus->receive_pool); xframe_queue_clear(&xbus->pcm_tospan); - xbus_setstate(xbus, XBUS_STATE_DISCONNECTED); del_timer_sync(&xbus->command_timer); transportops_put(xbus); transport_destroy(xbus); @@ -1464,7 +1495,7 @@ static int xbus_read_proc(char *page, char **start, off_t off, int count, int *e xbus->busname, xbus->connector, xbus->label, - (!XBUS_IS(xbus, DISCONNECTED)) ? "connected" : "missing" + (XBUS_FLAGS(xbus, CONNECTED)) ? "connected" : "missing" ); len += xbus_fill_proc_queue(page + len, &xbus->send_pool); len += xbus_fill_proc_queue(page + len, &xbus->receive_pool); @@ -1709,7 +1740,7 @@ static int read_proc_xbuses(char *page, char **start, off_t off, int count, int xbus->busname, xbus->connector, xbus->label, - (!XBUS_IS(xbus, DISCONNECTED)) ? "connected" : "missing" + (XBUS_FLAGS(xbus, CONNECTED)) ? "connected" : "missing" ); } } @@ -1746,6 +1777,7 @@ static void transport_init(xbus_t *xbus, struct xbus_ops *ops, ushort max_send_s spin_lock_init(&xbus->transport.state_lock); spin_lock_init(&xbus->transport.lock); atomic_set(&xbus->transport.transport_refcount, 0); + xbus_setflags(xbus, XBUS_FLAG_CONNECTED, 0); init_waitqueue_head(&xbus->transport.transport_unused); } |