summaryrefslogtreecommitdiff
path: root/kernel/xpp/utils/twinstar_setup
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-05-27 10:01:24 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-05-27 10:01:24 +0000
commit18c6813f2c788b603dab363b9138d65d24252167 (patch)
tree92402484268f2bc1d5e4e55f7321b9204ad47c5f /kernel/xpp/utils/twinstar_setup
parent2a73224819e867eaf56371d6055e2ca4d36396b6 (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/utils/twinstar_setup')
-rw-r--r--kernel/xpp/utils/twinstar_setup155
1 files changed, 155 insertions, 0 deletions
diff --git a/kernel/xpp/utils/twinstar_setup b/kernel/xpp/utils/twinstar_setup
new file mode 100644
index 0000000..d2686b6
--- /dev/null
+++ b/kernel/xpp/utils/twinstar_setup
@@ -0,0 +1,155 @@
+#! /usr/bin/perl -w
+#
+# Written by Oron Peled <oron@actcom.co.il>
+# Copyright (C) 2009, Xorcom
+# This program is free software; you can redistribute and/or
+# modify it under the same terms as Perl itself.
+#
+# $Id$
+#
+use strict;
+use File::Basename;
+BEGIN {
+ my $dir = dirname($0); unshift(@INC, "$dir", "$dir/zconf");
+ $ENV{PATH} = "$dir:$ENV{PATH}";
+}
+
+use Zaptel::Config::Gen qw(is_true);
+use Zaptel::Hardware;
+use Zaptel::Xpp::Mpp;
+use Zaptel::Xpp::Xbus;
+
+my $xpporder_file = $ENV{XPPORDER_CONF} || "/etc/xpp_order";
+
+my @devices = Zaptel::Hardware->device_list;
+my @xbuses = Zaptel::Xpp::xbuses;
+
+my $format = "%-20s %-10s # %s\n";
+
+sub bad_xpds($) {
+ my $xbus = shift || die;
+ my $bad_xpds = 0;
+
+ foreach my $xpd ($xbus->xpds) {
+ if(! $xpd->spanno) {
+ my $fqn = $xpd->fqn;
+ warn "\t$fqn -- Not registered with ZAPTEL\n";
+ $bad_xpds++;
+ }
+ }
+ return $bad_xpds;
+}
+
+sub twinstar_checks() {
+ my @twinstar_good;
+ my $first_port;
+ if(! -d "/sys/bus/astribanks") {
+ die "CANNOT generate TwinStar setup -- xpp drivers are not loaded\n";
+ }
+ foreach my $dev (@devices) {
+ my $hwname = $dev->hardware_name;
+ my $xbus;
+ my $loaded;
+ my $tws_port;
+ my $tws_power;
+ my $tws_watchdog;
+ my $mppinfo;
+ if(! $dev->is_astribank) {
+ warn "SKIP $hwname -- Only Astribanks can be used for TwinStar\n";
+ next;
+ }
+ Zaptel::Xpp::Mpp->mpp_addinfo($dev);
+ $mppinfo = $dev->mppinfo;
+ if(! defined $mppinfo) {
+ warn "SKIP $hwname -- is not TwinStar ready\n";
+ next;
+ }
+ if(! defined $mppinfo->{MPP_TALK}) {
+ warn "SKIP $hwname -- USB firmware is not loaded\n";
+ next;
+ }
+ if(! $mppinfo->{TWINSTAR_CAPABLE}) {
+ warn "SKIP $hwname -- is not TwinStar capable\n";
+ next;
+ }
+ $xbus = $dev->xbus;
+ if(! defined $xbus) {
+ warn "SKIP $hwname -- No XBUS for this device (FPGA firmware? Initialization?)\n";
+ next;
+ }
+ my $dev = $xbus->transport;
+ my $connector = $xbus->connector;
+ my $label = $xbus->label;
+ my $xbusstr = sprintf "%s (%s) [%s]", $xbus->name, $connector, $label;
+ if(bad_xpds($xbus)) {
+ warn "SKIP $xbusstr -- Not registered with ZAPTEL\n";
+ next;
+ }
+ my $port = $mppinfo->{TWINSTAR_PORT};
+ if(! defined $port) {
+ warn "SKIP $xbusstr -- Cannot read USB port info\n";
+ next;
+ }
+ my $power = $mppinfo->{TWINSTAR_POWER};
+ if(! defined $power) {
+ warn "SKIP $xbusstr -- Cannot read USB power info\n";
+ next;
+ }
+ if(!$power->[0] || !$power->[1]) {
+ warn "WARNING: Only one cable: $xbusstr\n";
+ }
+ $first_port = $port unless defined $first_port;
+ printf "GOOD: %-15s port=%d %s\n", $label, $port, $connector;
+ push(@twinstar_good, $xbus);
+ if($first_port != $port) {
+ die
+ "$0: ",
+ "XBUS($connector, $label) ",
+ "connected to PORT $port ",
+ "(others to $first_port)\n";
+ }
+ }
+ return @twinstar_good;
+}
+
+my @twinstar_good = twinstar_checks;
+if(!@twinstar_good) {
+ print STDERR "Abort. No Twinstar capable Astribanks found\n";
+ exit 1;
+}
+print "Generating Configuration\n";
+system("zapconf -v xpporder");
+die "Failed: $?\n" if $?;
+
+1;
+
+__END__
+
+=head1 NAME
+
+twinstar_setup - Prepares a server for Astribank TwinStar operation.
+
+=head1 DESCRIPTION
+
+This script prepares a server for Astribank TwinStar operation.
+The stages are:
+
+=over
+
+=item Preliminary checks
+
+Check that we have only TwinStar capable Astribanks, that the drivers are already loaded.
+
+=item Configuration Generation
+
+Indirectly generate the F</etc/xpp_order> file that describes the current configuration.
+This is done by running C<zapconf xpporder>
+
+This configuration file is used by twinstar_hook(8) to know when all Astribanks has reconnected
+to the backup server.
+
+=item Deployment to Backup Server
+
+Not implemented yet. Should be done manualy.
+
+=back