summaryrefslogtreecommitdiff
path: root/kernel/xpp/init_card_4_30
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-03-19 20:08:29 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-03-19 20:08:29 +0000
commitd8562c778088ff6ab3383df5ceead41eff4bf124 (patch)
tree43e394ae225fd7183018c2ae08d3fb1e5bcb12cb /kernel/xpp/init_card_4_30
parentb6b3226735f5e3b3fb000fa92daa7a574265c817 (diff)
xpp: a massive backport from DAHDI. From Xorcom branch-rel-6839-r6908 .
Sun Mar 1 2009 Oron Peled <oron@actcom.co.il> - xpp.r6795 * Fix cases where the command_queue overflowed during initialization. - Also add a 'command_queue_length' parameter to xpp.ko * More migrations to sysfs: - Add a 'transport' attribute to our astribank devices which points to the usb device we use. E.g: /sys/bus/astribanks/devices/xbus-00/transport is symlinked to ../../../../../../devices/pci0000:00/0000:00:10.4/usb5/5-4 - Move /proc/xpp/XBUS-??/XPD-??/span to /sys/bus/xpds/devices/??:?:?/span - Migrate from /proc/xpp/sync to: /sys/bus/astribanks/drivers/xppdrv/sync - New 'offhook' attribute in: /sys/bus/xpds/devices/??:?:?/offhook * PRI: change the "timing" priority to match the convention used by other PRI cards -- I.e: lower numbers (not 0) have higher priority. * FXO: - Power denial: create two module parameters instead of hard-coded constants (power_denial_safezone, power_denial_minlen). For sites that get non-standard power-denial signals from central office on offhook. - Don't hangup on power-denial, just notify Dahdi and wait for - Fix caller-id detection for the case central office sends it before first ring without any indication before. Asterisk's desicion. Mon, Dec 8 2008 Oron Peled <oron@actcom.co.il> - xpp.r6430 * PRI: - Match our span clocking priorities (in system.conf) to Digium -- this is a reversal of the previous state. Now lower numbers (greater than 0) are better. - Synchronization fixes for PRI ports other than 0. - Fix T1 CRC for some countries (e.g: China). * FXS: fix bug in VMWI detection if using old asterisk which does not provide ZT_VMWI ioctl(). * FXO: - Improve caller_id_style module parameter. This provide a workaround for countries that send this information without any notification (reverse polarity, ring, etc.) - Don't force on-hook upon power-denial. So, loopstart devices would ignore these as expected. * Implement a flow-control to prevent user space (init_card_* scripts) from pressuring our command queue. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4631 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/init_card_4_30')
-rwxr-xr-xkernel/xpp/init_card_4_30141
1 files changed, 73 insertions, 68 deletions
diff --git a/kernel/xpp/init_card_4_30 b/kernel/xpp/init_card_4_30
index 38c1911..6d56398 100755
--- a/kernel/xpp/init_card_4_30
+++ b/kernel/xpp/init_card_4_30
@@ -1,6 +1,9 @@
#! /usr/bin/perl -w
use strict;
+# Make warnings fatal
+local $SIG{__WARN__} = sub { die @_ };
+
#
# $Id$
#
@@ -33,6 +36,7 @@ use strict;
# 4 - PRI
# XBUS_REVISION - xbus revision number
# XBUS_CONNECTOR - xbus connector string
+# XBUS_LABEL - xbus label string
#
# Output data format:
# - An optional comment start with ';' or '#' until the end of line
@@ -54,13 +58,15 @@ use Getopt::Std;
my $program = basename("$0");
my $init_dir = dirname("$0");
+BEGIN { $init_dir = dirname($0); unshift(@INC, "$init_dir"); }
+use XppConfig $init_dir;
my $unit_id;
my %opts;
-$ENV{XPP_BASE} = '/proc/xpp';
-my @pri_specs;
getopts('o:', \%opts);
+my %settings;
+
sub logit {
print STDERR "$unit_id: @_\n";
}
@@ -73,6 +79,21 @@ if (-t STDERR) {
$unit_id = "$ENV{XBUS_NAME}/UNIT-$ENV{UNIT_NUMBER}";
open (STDERR, "| logger -t $program -p kern.info") || die;
logit "Non Interactive startup";
+ foreach my $k (qw(
+ XBUS_NAME
+ XBUS_NUMBER
+ UNIT_NUMBER
+ UNIT_TYPE
+ UNIT_SUBUNITS
+ UNIT_SUBUNITS_DIR
+ XBUS_REVISION
+ XBUS_CONNECTOR
+ XBUS_LABEL)) {
+ unless(defined $ENV{$k}) {
+ logit "Missing ENV{$k}\n";
+ die;
+ }
+ }
}
sub select_subunit($) {
@@ -83,8 +104,14 @@ sub select_subunit($) {
if($opts{o}) {
$output = $opts{o};
} else {
- my $xpd_name = sprintf("XPD-%1d%1d", $ENV{UNIT_NUMBER}, $subunit);
- $output = "$ENV{XPP_BASE}/$ENV{XBUS_NAME}/$xpd_name/chipregs";
+ $output = sprintf "/sys/bus/xpds/devices/%02d:%1d:%1d/chipregs",
+ $ENV{XBUS_NUMBER}, $ENV{UNIT_NUMBER}, $subunit;
+ if(! -f $output) {
+ my $xpd_name = sprintf("XPD-%1d%1d", $ENV{UNIT_NUMBER}, $subunit);
+ $output = "/proc/xpp/$ENV{XBUS_NAME}/$xpd_name/chipregs";
+ logit "OLD DRIVER: does not use /sys chipregs. Falling back to /proc"
+ if -f $output;
+ }
}
open(REG, ">$output") || die "Failed to open '$output': $!\n";
my $oldfh = select REG;
@@ -141,24 +168,12 @@ sub finish_quad() {
# PRI::gen "0 WD 80 00"; # PC1 (Port configuration 1): RPB_1.SYPR , XPB_1.SYPX
}
-sub read_pri_specs() {
- # For lab tests
- my $labfile = "${0}.setup";
-
- # Source default files
- $ENV{ZAPTEL_DEFAULTS} = "$labfile" if -r "$labfile";
- my $setup_var = 'XPP_PRI_SETUP';
- my $setup_string;
- my ($default_file, %source_defaults) =
- Zaptel::Config::Defaults::source_vars($setup_var);
- $setup_string = $source_defaults{$setup_var};
- $setup_string =~ s/^\s+//; # trim
- $setup_string =~ s/\s+$//; # trim
- $setup_string =~ s/\s+/\n/g; # cannonical spaces
- #main::logit "From $default_file: $setup_var=\n$setup_string";
- @pri_specs = split(/\s+/, $setup_string);
- push(@pri_specs, 'NUM/*=TE,E1'); # Fall back default (last)
- main::logit "pri_specs: @pri_specs";
+sub read_defaults() {
+ if(XppConfig::read_config(\%settings)) {
+ main::logit "Defaults from $settings{xppconf}";
+ } else {
+ main::logit "No defaults file, use hard-coded defaults.";
+ }
}
package PRI::Port;
@@ -167,57 +182,52 @@ sub new {
my $pack = shift;
my $port = { @_ };
bless $port, $pack;
- $port->process_pri_spec;
return $port;
}
-sub write_pri_info {
+sub get_pri_protocol {
my $port = shift;
my $subunit = $port->{PORT_NUM};
- my @pri_setup = @{$port->{PRI_SETUP}};
- my $pri_type = $pri_setup[0] || die "Missing pri_type parameter";
- my $pri_proto = $pri_setup[1] || die "Missing pri_proto parameter";
my $xpd_name = "XPD-$ENV{UNIT_NUMBER}$subunit";
- my $info = "$ENV{XPP_BASE}/$ENV{XBUS_NAME}/$xpd_name/pri_info";
-
- main::logit "$xpd_name: PRI_SETUP $pri_type $pri_proto";
- open(INFO, ">$info") || die "Failed to open '$info': $!\n";
- print INFO "$pri_type $pri_proto\n" || die "Failed writing to '$info': $!\n";
- close INFO || die "Failed during close of '$info': $!\n";
+ my $pri_protocol;
+ my @keys = (
+ "pri_protocol/connector:$ENV{XBUS_CONNECTOR}/$xpd_name",
+ "pri_protocol/label:$ENV{XBUS_LABEL}/$xpd_name",
+ "pri_protocol/$ENV{XBUS_NAME}/$xpd_name",
+ "pri_protocol"
+ );
+ foreach my $k (@keys) {
+ $k = lc($k); # Lowercase
+ $pri_protocol = $settings{$k};
+ if(defined $pri_protocol) {
+ $port->{pri_protocol} = $pri_protocol;
+ return $pri_protocol;
+ }
+ }
+ return undef;
}
-sub process_pri_spec($) {
+sub write_pri_info {
my $port = shift;
my $subunit = $port->{PORT_NUM};
- my $xpd_name = "XPD-$ENV{UNIT_NUMBER}$subunit";
- my $match;
- my $setup;
- my @pri_setup;
-SPEC:
- for(my $i = 0; $i < @pri_specs; $i++) {
- my $spec = $pri_specs[$i];
- ($match, $setup) = split(/=/, $spec);
- next unless defined $match and defined $setup;
- # Convert "globs" to regex
- $match =~ s/\*/.*/g;
- $match =~ s/\?/./g;
- #logit "match: $match";
- my @patlist = (
- "CONNECTOR/$ENV{XBUS_CONNECTOR}/$xpd_name",
- "NUM/$ENV{XBUS_NAME}/$xpd_name"
- );
- foreach my $pattern (@patlist) {
- #logit "testmatch: $pattern =~ $match";
- if($pattern =~ $match) {
- main::logit "$xpd_name: MATCH '$pattern' ~ '$match' setup=$setup";
- last SPEC;
- }
+ my $pri_protocol = $port->get_pri_protocol;
+ my $xpd_name = sprintf("XPD-%1d%1d", $ENV{UNIT_NUMBER}, $subunit);
+
+ if(defined $pri_protocol) {
+ main::logit "$xpd_name: pri_protocol $pri_protocol";
+ my $file = sprintf "/sys/bus/xpds/devices/%02d:%1d:%1d/pri_protocol",
+ $ENV{XBUS_NUMBER}, $ENV{UNIT_NUMBER}, $subunit;
+ if(! -f $file) {
+ $file = "/proc/xpp/$ENV{XBUS_NAME}/$xpd_name/pri_info";
+ main::logit "OLD DRIVER: does not use /sys chipregs. Falling back to /proc"
+ if -f $file;
}
+ open(INFO, ">$file") || die "Failed to open '$file': $!\n";
+ print INFO "$pri_protocol\n" || die "Failed writing '$pri_protocol' to '$file': $!\n";
+ close INFO || die "Failed during close of '$file': $!\n";
+ } else {
+ main::logit "$xpd_name: Skip setting pri protocol -- non given";
}
- die "No setup matching $ENV{XBUS_NAME}/$xpd_name\n" unless defined $setup;
- @pri_setup = split(/,/, $setup);
- die "Bad setup string '$setup'\n" unless @pri_setup;
- $port->{'PRI_SETUP'} = \@pri_setup;
}
sub port_setup($) {
@@ -348,12 +358,10 @@ sub port_setup($) {
}
package main;
-BEGIN { my $dir = dirname($0); unshift(@INC, "$dir", "$dir/zconf"); }
-use Zaptel::Config::Defaults;
logit "Starting '$0'";
-PRI::read_pri_specs;
+PRI::read_defaults;
sub main() {
my @ports;
@@ -363,12 +371,9 @@ sub main() {
PRI::init_quad;
# Must initialize all 4 ports, regardless how much there are
for($subunit = 0; $subunit < 4; $subunit++) {
- my $is_nt = 0;
-
- #logit "main(): Initializing subunit $subunit is_nt=$is_nt";
+ #logit "main(): Initializing subunit $subunit";
my $p = PRI::Port->new(
'PORT_NUM' => $subunit,
- 'PRI_NT' => $is_nt,
'EXIST' => ($subunit < $ENV{UNIT_SUBUNITS})
);
$p->port_setup;