diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-05-17 19:34:32 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-05-17 19:34:32 +0000 |
commit | 5b68efc40a339a8ae3d9d137c7b9af809c3f5519 (patch) | |
tree | 365f4c82a3123daebaf9a8d41817916c1dd74bf4 /xpp/utils/zconf | |
parent | 5174fc292d1a6184271a39aea2826b57f177454e (diff) |
* Tested with zaptel-1.2.17.1
* Add D-Channel TX, RX and BAD frames count in /proc/xpp/XBUS-*/XPD-*/bri_info
* Adjust output of xpp_sync script. Pad for 8 port BRI.
* Added a debugging module parport_debug (not compiled by default).
* Added an optional patch to zaptel:
- compiles only if ZAPTEL_SYNC_TICK is defined
- Allow interested driver to register for "sync" notification.
- Does not affect drivers that do not use this feature.
* Added external synchronization feature:
- Only if ZAPTEL_SYNC_TICK feature is compiled in
- Than XPP may be synchronized by another card (e.g: an Astribank
with FXS can be synchronized by a Digium PRI card).
- May be enabled/disabled in runtime via the 'sync_tick_active' module
parameter to the xpp.ko module.
* Fixed a potential bug in D-Channel hexdump printing.
* New visual indications in BRI leds:
- Constant ON RED/GREEN: Shows the port type -- NT/TE.
- Very fast "double blink": Layer1 work, no D-Channel yet.
- Steady blinking (1/2 sec): D-Channel trafic detected.
* xpp_fxloader moved to /usr/share/zaptel .
* adj_clock removed: never really used.
* Debugfs code now disabled by default.
* Now we have Zaptel::Hardware and a sample zaptel_hardware script (not
(installed by default).
* We also have a sample perl zapconf (not installed by default) which
aims at replacing genzaptelconf (sans the modules detection).
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2529 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils/zconf')
-rw-r--r-- | xpp/utils/zconf/Zaptel.pm | 2 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Chans.pm | 13 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Hardware.pm | 40 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Hardware/PCI.pm | 105 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Hardware/USB.pm | 108 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Span.pm | 6 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Xpp.pm | 3 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Xpp/Xbus.pm | 13 | ||||
-rw-r--r-- | xpp/utils/zconf/Zaptel/Xpp/Xpd.pm | 16 |
9 files changed, 291 insertions, 15 deletions
diff --git a/xpp/utils/zconf/Zaptel.pm b/xpp/utils/zconf/Zaptel.pm index 7642b0e..3717e72 100644 --- a/xpp/utils/zconf/Zaptel.pm +++ b/xpp/utils/zconf/Zaptel.pm @@ -15,7 +15,7 @@ my $proc_base = "/proc/zaptel"; sub spans() { my @spans; - -d $proc_base or die "Missing '$proc_base'. Perhaps zaptel module isn't loaded?\n"; + -d $proc_base or return (); foreach my $zfile (glob "$proc_base/*") { $zfile =~ s:$proc_base/::; my $span = Zaptel::Span->new($zfile); diff --git a/xpp/utils/zconf/Zaptel/Chans.pm b/xpp/utils/zconf/Zaptel/Chans.pm index 3364060..eef922f 100644 --- a/xpp/utils/zconf/Zaptel/Chans.pm +++ b/xpp/utils/zconf/Zaptel/Chans.pm @@ -22,25 +22,26 @@ sub AUTOLOAD { } } -sub new($$$$$) { +sub new($$$$$$) { my $pack = shift or die "Wasn't called as a class method\n"; my $span = shift or die "Missing a span parameter\n"; my $num = shift or die "Missing a channel number parameter\n"; my $fqn = shift or die "Missing a channel fqn parameter\n"; - my $info = shift; + my $signalling = shift || ''; + my $info = shift || ''; my $self = {}; bless $self, $pack; $self->span($span); $self->num($num); $self->fqn($fqn); + $self->signalling($signalling); $self->info($info); my $type; if($fqn =~ m|\bXPP_(\w+)/.*$|) { $type = $1; # One of our AB - } elsif(defined $info) { - $type = (split(/\s+/, $info))[0]; - $type = 'FXS' if $type =~ /^FXS/; - $type = 'FXO' if $type =~ /^FXO/; + } elsif(defined $signalling) { + $type = 'FXS' if $signalling =~ /^FXS/; + $type = 'FXO' if $signalling =~ /^FXO/; } else { $type = undef; } diff --git a/xpp/utils/zconf/Zaptel/Hardware.pm b/xpp/utils/zconf/Zaptel/Hardware.pm new file mode 100644 index 0000000..321292a --- /dev/null +++ b/xpp/utils/zconf/Zaptel/Hardware.pm @@ -0,0 +1,40 @@ +package Zaptel::Hardware; +# +# Written by Oron Peled <oron@actcom.co.il> +# Copyright (C) 2007, Xorcom +# This program is free software; you can redistribute and/or +# modify it under the same terms as Perl itself. +# +# $Id$ +# +use strict; +use Zaptel::Hardware::USB; +use Zaptel::Hardware::PCI; + +my @zaptel_devices; + +sub device_detected($$) { + my $dev = shift || die; + my $name = shift || die; + warn "Device '$name' already known\n" + if grep { $_->hardware_name eq $name } @zaptel_devices; + push(@zaptel_devices, $dev); +} + +sub device_removed($) { + my $dev = shift || die; + my $name = $dev->hardware_name; + die "Missing zaptel device hardware name" unless $name; + @zaptel_devices = grep { $_->hardware_name ne $name } @zaptel_devices; +} + +sub devices($) { + my $pack = shift || die; + + return @zaptel_devices; +} + +Zaptel::Hardware::USB->scan_devices; +Zaptel::Hardware::PCI->scan_devices; + +1; diff --git a/xpp/utils/zconf/Zaptel/Hardware/PCI.pm b/xpp/utils/zconf/Zaptel/Hardware/PCI.pm new file mode 100644 index 0000000..c6731dc --- /dev/null +++ b/xpp/utils/zconf/Zaptel/Hardware/PCI.pm @@ -0,0 +1,105 @@ +package Zaptel::Hardware::PCI; +# +# Written by Oron Peled <oron@actcom.co.il> +# Copyright (C) 2007, Xorcom +# This program is free software; you can redistribute and/or +# modify it under the same terms as Perl itself. +# +# $Id$ +# +use strict; +use Zaptel::Hardware; + +my @idlist = qw( + 1397:16B8 + 1397:08B4 + 1057:5608 + 10B5:3001 + 10B5:4000 + 10B5:9030 + 10B5:D00D + D161:0800 + D161:2400 + E159:0001 + ); + +$ENV{PATH} .= ":/usr/sbin:/sbin:/usr/bin:/bin"; +my $prog = 'lspci'; + +# Accessors (miniperl does not have Class:Accessor) +our $AUTOLOAD; +sub AUTOLOAD { + my $self = shift; + my $name = uc($AUTOLOAD); + $name =~ s/.*://; # strip fully-qualified portion + if (@_) { + return $self->{$name} = shift; + } else { + return $self->{$name}; + } +} + +my @devices; + +sub pci_sorter() { + return + sprintf("%03d/%03d", $a->bus, $a->dev) cmp + sprintf("%03d/%03d", $b->bus, $b->dev); +} + +sub new($$) { + my $pack = shift or die "Wasn't called as a class method\n"; + my $self = { @_ }; + bless $self, $pack; + my $hardware_name = sprintf("pci:%s:%s:%s", $self->{DOMAIN}, $self->{BUS}, $self->{DEV}); + $self->{HARDWARE_NAME} = $hardware_name; + Zaptel::Hardware::device_detected($self, $hardware_name); + my $sysfile = sprintf "/sys/bus/pci/devices/%s:%s:%s/driver/module", $self->{DOMAIN}, $self->{BUS}, $self->{DEV}; + my $module = readlink($sysfile); + if(defined $module) { + $module =~ s:^.*/::; + $self->{DRIVER} = $module; + } + return $self; +} + +sub devices($) { + my $pack = shift or die "Wasn't called as a class method\n"; + return sort pci_sorter @devices; +} + +my $domain_support = 1; # Optimistic... + +sub scan_devices($) { + my $pack = shift || die; + if(!open(F, "$prog -Dn 2> /dev/null |")) { + $domain_support = 0; + open(F, "$prog -n|") || die "$0: Failed running $prog: $!"; + } + while(<F>) { + chomp; + my ($phys,$id) = (split(/\s+/))[0,2]; + my $domain; + my $bus; + my $dev; + if($domain_support) { + ($domain,$bus,$dev) = split(/:/, $phys); + } else { + ($bus,$dev) = split(/:/, $phys); + $domain = '0000'; + } + next unless grep { uc($id) eq $_ } @idlist; + my($vendor,$product) = split(/:/, $id); + my $d = Zaptel::Hardware::PCI->new( + DOMAIN => $domain, + BUS => $bus, + DEV => $dev, + VENDOR => $vendor, + PRODUCT => $product, + ); + push(@devices, $d); + } + close F; +} + +1; diff --git a/xpp/utils/zconf/Zaptel/Hardware/USB.pm b/xpp/utils/zconf/Zaptel/Hardware/USB.pm new file mode 100644 index 0000000..bbf00fe --- /dev/null +++ b/xpp/utils/zconf/Zaptel/Hardware/USB.pm @@ -0,0 +1,108 @@ +package Zaptel::Hardware::USB; +# +# Written by Oron Peled <oron@actcom.co.il> +# Copyright (C) 2007, Xorcom +# This program is free software; you can redistribute and/or +# modify it under the same terms as Perl itself. +# +# $Id$ +# +use strict; +use Zaptel::Hardware; +use Zaptel::Xpp; +use Zaptel::Xpp::Xbus; + +my @idlist = qw( + e4e4:1130 + e4e4:1131 + e4e4:1132 + e4e4:1140 + e4e4:1141 + e4e4:1142 + e4e4:1150 + e4e4:1151 + e4e4:1152 + ); + + +$ENV{PATH} .= ":/usr/sbin:/sbin:/usr/bin:/bin"; +my $prog = 'lsusb'; + +# Accessors (miniperl does not have Class:Accessor) +our $AUTOLOAD; +sub AUTOLOAD { + my $self = shift; + my $name = uc($AUTOLOAD); + $name =~ s/.*://; # strip fully-qualified portion + if (@_) { + return $self->{$name} = shift; + } else { + return $self->{$name}; + } +} + +my @devices; +my @xbuses = Zaptel::Xpp::xbuses('SORT_CONNECTOR'); + +sub usb_sorter() { + return + sprintf("%03d/%03d", $a->bus, $a->dev) cmp + sprintf("%03d/%03d", $b->bus, $b->dev); +} + +sub xbus_of_usb($$) { + my $bus = shift; + my $dev = shift; + + my ($wanted) = grep { + my $b = $_->usb_bus; + my $d = $_->usb_dev; + defined($b) && $b == $bus && + defined($d) && $d == $dev + } @xbuses; + return $wanted; +} + +sub new($$) { + my $pack = shift or die "Wasn't called as a class method\n"; + my $self = { @_ }; + bless $self, $pack; + my $xbus = xbus_of_usb($self->bus, $self->dev); + if(defined $xbus) { + $self->{XBUS} = $xbus; + $self->{DRIVER} = 'xpp_usb'; + } + my $hardware_name = sprintf("usb:%03d/%03d", $self->{BUS}, $self->{DEV}); + $self->{HARDWARE_NAME} = $hardware_name; + Zaptel::Hardware::device_detected($self, $hardware_name); + return $self; +} + +sub devices($) { + my $pack = shift or die "Wasn't called as a class method\n"; + return sort usb_sorter @devices; +} + +sub scan_devices($) { + my $pack = shift || die; + open(F, "$prog|") || die "$0: Failed running $prog: $!"; + while(<F>) { + chomp; + my ($bus,$dev,$id) = (split(/\s+/))[1,3,5]; + $dev =~ s/://; + $bus =~ s/^0*//; + $dev =~ s/^0*//; + next unless grep { lc($id) eq $_ } @idlist; + my($vendor,$product) = split(/:/, $id); + my $d = Zaptel::Hardware::USB->new( + BUS => $bus, + DEV => $dev, + VENDOR => $vendor, + PRODUCT => $product, + ); + push(@devices, $d); + } + close F; +} + +1; diff --git a/xpp/utils/zconf/Zaptel/Span.pm b/xpp/utils/zconf/Zaptel/Span.pm index c020d2f..8496910 100644 --- a/xpp/utils/zconf/Zaptel/Span.pm +++ b/xpp/utils/zconf/Zaptel/Span.pm @@ -69,14 +69,16 @@ sub new($$) { die "$0: Unkown TERMTYPE [NT/TE]\n" if $self->is_bri and !defined $self->{TERMTYPE}; ($self->{NAME}, $self->{DESCRIPTION}) = (split(/\s+/, $head, 4))[2, 3]; + $self->{IS_ZAPTEL_SYNC_MASTER} = + ($self->{DESCRIPTION} =~ /\(MASTER\)/) ? 1 : 0; $self->{CHANS} = []; while(<F>) { chomp; s/^\s*//; s/\s*$//; next unless /\S/; - my ($chan, $name, $info) = split(/\s+/, $_, 3); - my $c = Zaptel::Chans->new($self, $chan, $name, $info); + my ($chan, $name, $signalling, $info) = split(/\s+/, $_, 4); + my $c = Zaptel::Chans->new($self, $chan, $name, $signalling, $info); push(@{$self->{CHANS}}, $c); } close F; diff --git a/xpp/utils/zconf/Zaptel/Xpp.pm b/xpp/utils/zconf/Zaptel/Xpp.pm index dd1f34c..28de49d 100644 --- a/xpp/utils/zconf/Zaptel/Xpp.pm +++ b/xpp/utils/zconf/Zaptel/Xpp.pm @@ -27,8 +27,9 @@ sub xbuses { my $optsort = shift || 'SORT_NAME'; my @xbuses; + -d "/proc/xpp" or return (); open(F, "$proc_base/xbuses") || - die "$0: Failed to open $proc_base/xbuses. xpp module is loaded?\n"; + die "$0: Failed to open $proc_base/xbuses: $!\n"; while(<F>) { chomp; my ($name, @attr) = split; diff --git a/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm b/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm index 772e050..0dd6d84 100644 --- a/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm +++ b/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm @@ -64,6 +64,19 @@ sub new($$) { bless $self, $pack; $self->{NAME} or die "Missing xbus name"; my $prefix = "$proc_base/" . $self->{NAME}; + my $usbfile = "$prefix/xpp_usb"; + if(open(F, "$usbfile")) { + my $head = <F>; + chomp $head; + close F; + $head =~ s/^device: +([^, ]+)/$1/i or die; + my ($usb_bus, $usb_dev) = split('/', $head); + die unless defined($usb_bus) && defined($usb_dev); + $usb_bus =~ s/^0*//; + $usb_dev =~ s/^0*//; + $self->{USB_BUS} = $usb_bus; + $self->{USB_DEV} = $usb_dev; + } @{$self->{XPDS}} = (); foreach my $fqn (glob "$prefix/XPD-??") { $fqn =~ s:$proc_base/::; diff --git a/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm b/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm index 94176b8..852aaea 100644 --- a/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm +++ b/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm @@ -82,11 +82,17 @@ sub new($$) { bless $self, $pack; my $dir = "$proc_base/" . $self->fqn; $self->{DIR} = $dir; - my ($name) = glob "$dir/*_info"; - die "Missing info file in $dir" unless $name; - $name =~ s|^.*/||; # basename - die "Bad info file name ($name) in $dir" if $name !~ /(\w+)_info/; - $self->{TYPE} = uc($1); + open(F, "$dir/summary") || die "Missing summary file in $dir"; + my $head = <F>; + chomp $head; + # "XPD-00 (BRI_TE ,card present, span registered) SYNC MASTER" + close F; + $head =~ s/^.*\(//; + $head =~ s/\) */, /; + $head =~ s/\s*,\s*/,/g; + my ($type,$present,$registered,$sync) = split(/,/, $head); + $self->{TYPE} = uc($type); + $self->{IS_SYNC_MASTER} = ($sync =~ /MASTER/); return $self; } |