From 18c6813f2c788b603dab363b9138d65d24252167 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Wed, 27 May 2009 10:01:24 +0000 Subject: 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 --- .../xpp/utils/zconf/Zaptel/Config/Gen/Unicall.pm | 4 +- kernel/xpp/utils/zconf/Zaptel/Config/Gen/Users.pm | 2 + .../xpp/utils/zconf/Zaptel/Config/Gen/Xpporder.pm | 142 +++++++++++++++++++++ kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zapata.pm | 4 +- kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zaptel.pm | 47 +++++-- kernel/xpp/utils/zconf/Zaptel/Config/Params.pm | 2 +- 6 files changed, 187 insertions(+), 14 deletions(-) create mode 100644 kernel/xpp/utils/zconf/Zaptel/Config/Gen/Xpporder.pm (limited to 'kernel/xpp/utils/zconf/Zaptel/Config') diff --git a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Unicall.pm b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Unicall.pm index 3e1048d..6d9552f 100644 --- a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Unicall.pm +++ b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Unicall.pm @@ -32,7 +32,9 @@ sub generate($) { print "Generating $file\n" if $genopts->{verbose}; open(F, ">$file") || die "$0: Failed to open $file: $!\n"; my $old = select F; - printf "; Autogenerated by %s on %s -- do not hand edit\n", $0, scalar(localtime); + printf "; Autogenerated by $0 on %s\n", scalar(localtime); + print "; If you edit this file and execute $0 again,\n"; + print "; your manual changes will be LOST.\n"; print "; This file should be #included in unicall.conf\n\n"; foreach my $span (@spans) { next unless $span->is_digital(); diff --git a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Users.pm b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Users.pm index 7c9e937..dbbf9d2 100644 --- a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Users.pm +++ b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Users.pm @@ -88,6 +88,8 @@ sub generate($) { ;! Filename: @{[basename($file)]} ($file) ;! Generator: $0 ;! Creation Date: @{[scalar(localtime)]} +;! If you edit this file and execute $0 again,\n"; +;! your manual changes will be LOST.\n"; ;! [general] ; diff --git a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Xpporder.pm b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Xpporder.pm new file mode 100644 index 0000000..0d34d93 --- /dev/null +++ b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Xpporder.pm @@ -0,0 +1,142 @@ +package Zaptel::Config::Gen::Xpporder; +use strict; + +use Zaptel::Config::Gen qw(is_true); +use Zaptel::Xpp; + +sub new($$$) { + my $pack = shift || die; + my $gconfig = shift || die; + my $genopts = shift || die; + my $file = $ENV{XPPORDER_CONF} || "/etc/xpp_order"; + my $self = { + FILE => $file, + GCONFIG => $gconfig, + GENOPTS => $genopts, + }; + bless $self, $pack; + return $self; +} + +# +# Returns list of xbuses sorted by the span numbers assigned +# to their XPD's. Also checks that each XBUS span numbers are sequential. +sub get_sorted_xbuses(@) { + my @spans = @_; # Verify our spans + my @xbuses = Zaptel::Xpp::xbuses; + my %xbus_of_span; + my %xbus_beginning; + my %seen_spans; + my @sorted_xbuses; + foreach my $xbus (@xbuses) { + my $last_spanno; + foreach my $xpd ($xbus->xpds) { + my $spanno = $xpd->spanno; + if(!$spanno) { + printf STDERR "%s: Is not registered. Skipping.\n", $xpd->fqn; + next; + } + $seen_spans{$spanno}++; + if($xbus_of_span{$spanno}) { + printf STDERR "%s: Span %d already seen on %s\n", + $xpd->fqn, $spanno, $xbus_of_span{$spanno}->name; + die; + } + $xbus_of_span{$spanno} = $xbus; + # Check XPD's sequential numbering + if(defined $last_spanno) { + if($last_spanno + 1 != $spanno) { + printf STDERR "%s: Bad span numbers (%d, %d)\n", + $xpd->fqn, $last_spanno, $spanno; + die; + } + } else { + $xbus_beginning{$xbus} = $spanno; + } + $last_spanno = $spanno; + } + } + foreach my $span (@spans) { + my $spanno = $span->num; + if(!defined($seen_spans{$spanno})) { + warn "Span $spanno: Ignored: Does not belong to any XPD\n"; + } + } + @sorted_xbuses = sort { $xbus_beginning{$a} <=> $xbus_beginning{$b} } @xbuses; + return @sorted_xbuses; +} + +sub generate($$$) { + my $self = shift || die; + my $file = $self->{FILE}; + my $gconfig = $self->{GCONFIG}; + my $genopts = $self->{GENOPTS}; + my @spans = @_; # Verify it's all our spans + my @xbuses = get_sorted_xbuses(@spans); + warn "Empty configuration -- no xbuses\n" unless @xbuses; + rename "$file", "$file.bak" + or $! == 2 # ENOENT (No dependency on Errno.pm) + or die "Failed to backup old config: $!\n"; + #$gconfig->dump; + print "Generating $file\n" if $genopts->{verbose}; + open(F, ">$file") || die "$0: Failed to open $file: $!\n"; + my $old = select F; + printf "# Autogenerated by $0 on %s\n", scalar(localtime); + print "# If you edit this file and execute $0 again,\n"; + print "# your manual changes will be LOST.\n"; + print <<'HEAD'; +# +# This is an optional configuration file for ordering +# Zaptel registration. +# +# It is read from /etc/xpp_order. This location +# may be overridden via the environment variable XPPORDER_CONF +# +# Lines may contain: +# - The Astribank label (verbatim) +# - The Astribank connector string (prefixed with @) +# Ordering number of each listed Astribank is determined +# by its position in this file. +# Astribanks not listed in this file, get an ordering +# number of 99 (last). +# +# Astribanks with same ordering number are sorted by their +# connectors (to preserve legacy behavior). +# +# Examples: +#usb:1234 +#@usb-0000:06:02.2-2 +HEAD + foreach my $xbus (@xbuses) { + my $label = $xbus->label; + my $connector = $xbus->connector; + my $name = $xbus->name; + printf "%s\t# %s (%s)\n", $label, $connector, $name; + } + close F; + select $old; +} + +1; + +__END__ + +=head1 NAME + +Xpporder - Generate Astribank ordering information for zt_registration. + +=head1 SYNOPSIS + + use Zaptel::Config::Gen::Xpporder; + + my $cfg = new Zaptel::Config::Gen::Xpporder(\%global_config, \%genopts); + $cfg->generate; + +=head1 DESCRIPTION + +Generate the F. +This is the configuration for zt_registration(1). +The order is determined according to current Zaptel registration +order. + +Its location may be overriden via the environment variable F. diff --git a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zapata.pm b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zapata.pm index e8fd733..8e0ebce 100644 --- a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zapata.pm +++ b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zapata.pm @@ -140,7 +140,9 @@ sub generate($) { print "Generating $file\n" if $genopts->{verbose}; open(F, ">$file") || die "$0: Failed to open $file: $!\n"; my $old = select F; - printf "; Autogenerated by %s on %s -- do not hand edit\n", $0, scalar(localtime); + printf "; Autogenerated by $0 on %s\n", scalar(localtime); + print "; If you edit this file and execute $0 again,\n"; + print "; your manual changes will be LOST.\n"; print <<"HEAD"; ; Zaptel Channels Configurations (zapata.conf) ; diff --git a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zaptel.pm b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zaptel.pm index 2c30c33..892442f 100644 --- a/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zaptel.pm +++ b/kernel/xpp/utils/zconf/Zaptel/Config/Gen/Zaptel.pm @@ -39,11 +39,6 @@ sub gen_digital($$) { $span_crc4 = ''; $framing = 'cas'; } - my $dchan_type = 'dchan'; - if ($span->is_bri() && is_true($gconfig->{'bri_hardhdlc'})) { - $dchan_type = 'hardhdlc'; - } - $timing = ($termtype eq 'NT') ? 0 : $bri_te_last_timing++; printf "span=%d,%d,%d,%s,%s%s%s\n", $num, @@ -54,14 +49,42 @@ sub gen_digital($$) { $span_crc4, $span_yellow; printf "# termtype: %s\n", lc($termtype); - if ($gconfig->{'pri_connection_type'} eq 'PRI') { + my $dchan_type; + if ($span->is_bri()) { + my $use_bristuff = 0; + my $cfg_hardhdlc = $gconfig->{'bri_hardhdlc'}; + my $xpd = $span->xpd(); + if(!defined($cfg_hardhdlc) || $cfg_hardhdlc =~ /AUTO/i) { + # Autodetect + if(defined($xpd)) { + # Bristuff? + if(defined($xpd->dchan_hardhdlc) && !is_true($xpd->dchan_hardhdlc)) { + $use_bristuff = 1; + } + } + } elsif(!is_true($cfg_hardhdlc)) { + $use_bristuff = 1; + } + if($use_bristuff) { + $dchan_type = 'dchan'; + } else { + $dchan_type = 'hardhdlc'; + } printf "bchan=%s\n", Zaptel::Config::Gen::bchan_range($span); my $dchan = $span->dchan(); printf "$dchan_type=%d\n", $dchan->num(); - } elsif ($gconfig->{'pri_connection_type'} eq 'R2' ) { - my $idle_bits = $gconfig->{'r2_idle_bits'}; - printf "cas=%s:$idle_bits\n", Zaptel::Config::Gen::bchan_range($span); - printf "dchan=%d\n", $span->dchan()->num(); + } elsif($span->is_pri()) { + if ($gconfig->{'pri_connection_type'} eq 'PRI') { + printf "bchan=%s\n", Zaptel::Config::Gen::bchan_range($span); + my $dchan = $span->dchan(); + printf "dchan=%d\n", $dchan->num(); + } elsif ($gconfig->{'pri_connection_type'} eq 'R2' ) { + my $idle_bits = $gconfig->{'r2_idle_bits'}; + printf "cas=%s:$idle_bits\n", Zaptel::Config::Gen::bchan_range($span); + printf "dchan=%d\n", $span->dchan()->num(); + } + } else { + die "Digital span $num is not BRI, nor PRI?"; } } @@ -100,7 +123,9 @@ sub generate($$$) { print "Generating $file\n" if $genopts->{verbose}; open(F, ">$file") || die "$0: Failed to open $file: $!\n"; my $old = select F; - printf "# Autogenerated by %s on %s -- do not hand edit\n", $0, scalar(localtime); + printf "# Autogenerated by $0 on %s\n", scalar(localtime); + print "# If you edit this file and execute $0 again,\n"; + print "# your manual changes will be LOST.\n"; print <<"HEAD"; # Zaptel Configuration File # diff --git a/kernel/xpp/utils/zconf/Zaptel/Config/Params.pm b/kernel/xpp/utils/zconf/Zaptel/Config/Params.pm index 7f6ae80..35ded3b 100644 --- a/kernel/xpp/utils/zconf/Zaptel/Config/Params.pm +++ b/kernel/xpp/utils/zconf/Zaptel/Config/Params.pm @@ -106,7 +106,7 @@ sub item($$) { brint_overlap => 'no', bri_sig_style => 'bri_ptmp', echo_can => 'mg2', - bri_hardhdlc => 'no', + bri_hardhdlc => 'auto', pri_connection_type => 'PRI', r2_idle_bits => '1101', 'pri_termtype' => [ 'SPAN/* TE' ], -- cgit v1.2.3