summaryrefslogtreecommitdiff
path: root/xpp/utils/zconf/Zaptel/Hardware/PCI.pm
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-05-17 22:55:21 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-05-17 22:55:21 +0000
commit3af1b5fa2ec86d21762ad1cea81d2b275d4a9d48 (patch)
tree12da5f31396b3b1d3f99ed1bad8725bd50120689 /xpp/utils/zconf/Zaptel/Hardware/PCI.pm
parentc16f6ead0e9050d59d73f39f3015ecb64aecc214 (diff)
XPP revision 3965:
* 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. * 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/trunk@2537 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils/zconf/Zaptel/Hardware/PCI.pm')
-rw-r--r--xpp/utils/zconf/Zaptel/Hardware/PCI.pm105
1 files changed, 105 insertions, 0 deletions
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;