[dahdi-commits] tzafrir: linux/trunk r4480 - in /linux/trunk: ./ drivers/dahdi/xpp/
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Sun Jun 29 10:05:48 CDT 2008
Author: tzafrir
Date: Sun Jun 29 10:05:48 2008
New Revision: 4480
URL: http://svn.digium.com/view/dahdi?view=rev&rev=4480
Log:
Changes in XPP initialization and configuration:
* The configuration for XPP init_card_* scripts is done now
in /etc/dahdi/xpp.conf and uses a simple syntax (example included).
For PRI modules, the 'pri_protocol' setting, determines how
to configure it (E1/T1).
* In Astribank PRI modules, the LED behaviour represent which ports
are *CLOCK MASTER* (red color) and which are *CLOCK SLAVE* (green color).
Usually (but not always), this corresponds to the NT/TE settings in Asterisk.
* dahdi_genconf now replaces zapconf and deprecates genzaptelconf.
Relevant configuration settings were removed from the kernel
package and are implemented and described in the tools package.
Modified:
linux/trunk/UPGRADE.txt
linux/trunk/drivers/dahdi/xpp/XppConfig.pm
linux/trunk/drivers/dahdi/xpp/card_global.c
linux/trunk/drivers/dahdi/xpp/card_pri.c
linux/trunk/drivers/dahdi/xpp/init_card_1_30
linux/trunk/drivers/dahdi/xpp/init_card_2_30
linux/trunk/drivers/dahdi/xpp/init_card_4_30
linux/trunk/drivers/dahdi/xpp/xpp.conf
Modified: linux/trunk/UPGRADE.txt
URL: http://svn.digium.com/view/dahdi/linux/trunk/UPGRADE.txt?view=diff&rev=4480&r1=4479&r2=4480
==============================================================================
--- linux/trunk/UPGRADE.txt (original)
+++ linux/trunk/UPGRADE.txt Sun Jun 29 10:05:48 2008
@@ -66,6 +66,7 @@
ztspeed -> dahdi_speed
zttest -> dahdi_test
zttool -> dahdi_tool
+ zapconf -> dahdi_genconf (deprecate genzaptelconf)
* The system configuration file has moved from /etc/zaptel.conf to
/etc/dahdi/system.conf.
@@ -73,3 +74,12 @@
* The dahdi_cfg tool can now be used to select an echo canceler on a
channel-by-channel basis in the system configuration file; see
system.conf.sample for examples of how to do this.
+
+* The configuration for XPP init_card_* scripts is done now
+ in /etc/dahdi/xpp.conf and uses a simple syntax (example included).
+ For PRI modules, the 'pri_protocol' setting, determines how
+ to configure it (E1/T1).
+
+* In Astribank PRI modules, the LED behaviour represent which ports
+ are *CLOCK MASTER* (red color) and which are *CLOCK SLAVE* (green color).
+ Usually (but not always), this corresponds to the NT/TE settings in Asterisk.
Modified: linux/trunk/drivers/dahdi/xpp/XppConfig.pm
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/XppConfig.pm?view=diff&rev=4480&r1=4479&r2=4480
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/XppConfig.pm (original)
+++ linux/trunk/drivers/dahdi/xpp/XppConfig.pm Sun Jun 29 10:05:48 2008
@@ -11,77 +11,28 @@
my $conf_file = "/etc/dahdi/xpp.conf";
-sub subst_var($$) {
- my $lookup = shift;
- my $string = shift;
-
- if(defined $lookup->{$string}) {
- return $lookup->{$string};
- } else {
- return $string;
- }
-}
-
-sub read_config($) {
- my $input = shift || die;
- my %xpp_config;
- my $lookup = \%xpp_config;
-
- open(F, $input) || die "Failed reading configuration $input: $!\n";
-LINE:
- while(<F>) {
- chomp;
- s/#.*//; # strip comments
- next unless /\S/;
- s/^\s*//;
- if(s/\\$//) {
- my $next = <F>;
- $next =~ s/^\s*//;
- $_ .= " $next";
- redo LINE;
- }
- my ($key, $value) = split(/=/, $_, 2);
- # Trim whitespace around key/value
- $key =~ s/^\s*(\S+)\s*$/$1/;
- $value =~ s/^\s*(\S+)\s*$/$1/;
- # Variable substitution
- my $new_value = $value;
- $new_value =~ s/\$(\w+)/subst_var($lookup,$1)/eg;
- $xpp_config{$key} = $new_value;
- }
- close F;
- return %xpp_config;
-}
-
sub import {
my $pack = shift || die "Import without package?";
my $init_dir = shift || die "$pack::import -- missing init_dir parameter";
my $local_conf = "$init_dir/xpp.conf";
$conf_file = $local_conf if -r $local_conf;
- my %x = read_config($conf_file);
}
-sub show_vars {
- my $assoc = shift;
- foreach (sort keys %{$assoc}) {
- print "$_\t$assoc->{$_}\n";
+sub read_config($) {
+ my $opts = shift || die;
+
+ open(F, $conf_file) || return ();
+ while(<F>) {
+ chomp;
+ s/#.*//; # strip comments
+ next unless /\S/;
+ s/\s*$//; # Trim trailing whitespace
+ my ($key, $value) = split(/\s+/, $_, 2);
+ $opts->{$key} = $value;
}
+ close F;
+ $opts->{'xppconf'} = $conf_file;
+ return %{$opts};
}
-sub source_vars {
- my @keys = @_;
- my %conf = read_config($conf_file);
- my %result;
- my $k;
- my $v;
-
- foreach (@keys) {
- if(defined $conf{$_}) {
- $result{$_} = $conf{$_};
- }
- }
- return ($conf_file, %result);
-}
-
-
1;
Modified: linux/trunk/drivers/dahdi/xpp/card_global.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_global.c?view=diff&rev=4480&r1=4479&r2=4480
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_global.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_global.c Sun Jun 29 10:05:48 2008
@@ -795,6 +795,7 @@
snprintf(directionstr, MAX_ENV_STR, "UNIT_SUBUNITS_DIR=%d", direction_mask);
snprintf(revstr, MAX_ENV_STR, "XBUS_REVISION=%d", xbus->revision);
snprintf(connectorstr, MAX_ENV_STR, "XBUS_CONNECTOR=%s", xbus->location);
+ snprintf(connectorstr, MAX_ENV_STR, "XBUS_LABEL=%s", xbus->label);
if(snprintf(init_card, MAX_PATH_STR, "%s/init_card_%d_%d",
initdir, xpd->type, xbus->revision) > MAX_PATH_STR) {
XPD_NOTICE(xpd, "Cannot initialize. pathname is longer than %d characters.\n", MAX_PATH_STR);
Modified: linux/trunk/drivers/dahdi/xpp/card_pri.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_pri.c?view=diff&rev=4480&r1=4479&r2=4480
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_pri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_pri.c Sun Jun 29 10:05:48 2008
@@ -100,25 +100,16 @@
return num_channels[pri_protocol];
}
-static const char *type_name(enum pri_protocol pri_protocol, bool is_nt)
-{
- static const char *names[2][4] = {
- /* TE */ [0] = {
- [PRI_PROTO_0] = "Unknown_TE",
- [PRI_PROTO_E1] = "E1_TE",
- [PRI_PROTO_T1] = "T1_TE",
- [PRI_PROTO_J1] = "J1_TE"
- },
- /* NT */ [1] = {
- [PRI_PROTO_0] = "Unknown_NT",
- [PRI_PROTO_E1] = "E1_NT",
- [PRI_PROTO_T1] = "T1_NT",
- [PRI_PROTO_J1] = "J1_NT"
- }
- };
- int term = (is_nt) ? 1 : 0;
-
- return names[term][pri_protocol];
+static const char *type_name(enum pri_protocol pri_protocol)
+{
+ static const char *names[4] = {
+ [PRI_PROTO_0] = "Unknown",
+ [PRI_PROTO_E1] = "E1",
+ [PRI_PROTO_T1] = "T1",
+ [PRI_PROTO_J1] = "J1"
+ };
+
+ return names[pri_protocol];
}
static int pri_linecompat(enum pri_protocol pri_protocol)
@@ -159,10 +150,10 @@
};
enum pri_led_selectors {
- TE_RED_LED = 0,
- TE_GREEN_LED = 1,
- NT_RED_LED = 2,
- NT_GREEN_LED = 3,
+ BOTTOM_RED_LED = 0,
+ BOTTOM_GREEN_LED = 1,
+ TOP_RED_LED = 2,
+ TOP_GREEN_LED = 3,
};
#define NUM_LEDS 4
@@ -242,7 +233,6 @@
#define REG_CMR1_STF BIT(2)
struct PRI_priv_data {
- bool is_nt;
bool clock_source;
struct proc_dir_entry *pri_info;
enum pri_protocol pri_protocol;
@@ -450,7 +440,7 @@
xpd->wanted_pcm_mask = BITMASK(xpd->channels);
priv->deflaw = deflaw;
priv->dchan_num = dchan_num;
- xpd->type_name = type_name(priv->pri_protocol, priv->is_nt);
+ xpd->type_name = type_name(priv->pri_protocol);
XPD_DBG(GENERAL, xpd, "%s, channels=%d, dchan_num=%d, deflaw=%d\n",
pri_protocol_name(set_proto),
xpd->channels,
@@ -509,7 +499,7 @@
/*
* Called from:
* - set_master_mode() --
- * As a result of ztcfg or writing to /proc/xpp/XBUS-??/XPD-/??/pri_info
+ * As a result of dahdi_cfg
* - layer1_state() --
* As a result of an alarm.
*/
@@ -568,12 +558,8 @@
/*
* Normally set by the timing parameter in /etc/dahdi/system.conf
- * If this is called by ztcfg, than it's too late to change
+ * If this is called by dahdi_cfg, than it's too late to change
* dahdi sync priority (we are already registered)
- * There are two workarounds to mitigate this problem:
- * 1. So we set *our* sync master at least.
- * 2. And we try to call it with a sane default from set_nt()
- * which is called before dahdi registration.
*/
static int set_master_mode(const char *msg, xpd_t *xpd)
{
@@ -604,9 +590,11 @@
return 0;
}
-static int set_nt(const char *msg, xpd_t *xpd, bool is_nt)
-{
- struct PRI_priv_data *priv;
+static int set_localloop(const char *msg, xpd_t *xpd, bool localloop)
+{
+ struct PRI_priv_data *priv;
+ byte lim0 = 0;
+ byte xsp = 0;
BUG_ON(!xpd);
priv = xpd->priv;
@@ -615,31 +603,8 @@
xpd->span.spanno, __FUNCTION__, msg);
return -EBUSY;
}
- priv->is_nt = is_nt;
- xpd->type_name = type_name(priv->pri_protocol, is_nt);
- xpd->direction = (is_nt) ? TO_PHONE : TO_PSTN;
- XPD_DBG(SIGNAL, xpd, "%s(%s): %s %s\n", __FUNCTION__, msg, xpd->type_name, (is_nt) ? "NT" : "TE");
- if(xpd->timing_priority == 0 && !is_nt) /* by default set timing priority from NT/TE */
- xpd->timing_priority = 1;
- set_master_mode(msg, xpd);
- return 0;
-}
-
-static int set_localloop(const char *msg, xpd_t *xpd, bool localloop)
-{
- struct PRI_priv_data *priv;
- byte lim0 = 0;
- byte xsp = 0;
-
- BUG_ON(!xpd);
- priv = xpd->priv;
- if(SPAN_REGISTERED(xpd)) {
- XPD_NOTICE(xpd, "Registered as span %d. Cannot do %s(%s)\n",
- xpd->span.spanno, __FUNCTION__, msg);
- return -EBUSY;
- }
lim0 |= (localloop) ? REG_LIM0_LL : 0;
- if(priv->is_nt)
+ if(priv->clock_source)
lim0 |= REG_LIM0_MAS;
else
lim0 &= ~REG_LIM0_MAS;
@@ -760,7 +725,7 @@
fmr2 |= REG_FMR2_E_RFS1;
}
XPD_DBG(GENERAL, xpd, "[%s] lineconfig=%s/%s/%s %s (0x%X)\n",
- (priv->is_nt)?"NT":"TE",
+ (priv->clock_source)?"MASTER":"SLAVE",
framingstr, codingstr, crcstr,
(lineconfig & DAHDI_CONFIG_NOTOPEN)?"YELLOW":"",
lineconfig);
@@ -796,11 +761,11 @@
return -EINVAL;
}
/*
- * FIXME: lc->name is unused by ztcfg and dahdi...
+ * FIXME: lc->name is unused by dahdi_cfg and dahdi...
* We currently ignore it also.
*/
XPD_DBG(GENERAL, xpd, "[%s] lbo=%d lineconfig=0x%X sync=%d\n",
- (priv->is_nt)?"NT":"TE", lc->lbo, lc->lineconfig, lc->sync);
+ (priv->clock_source)?"MASTER":"SLAVE", lc->lbo, lc->lineconfig, lc->sync);
ret = pri_lineconfig(xpd, lc->lineconfig);
if(!ret) {
span->lineconfig = lc->lineconfig;
@@ -837,10 +802,9 @@
if(!xpd)
return NULL;
priv = xpd->priv;
- priv->pri_protocol = PRI_PROTO_0; /* Default, changes in set_pri_proto() */
+ priv->pri_protocol = PRI_PROTO_0; /* Default, changes in set_pri_proto() */
priv->deflaw = DAHDI_LAW_DEFAULT; /* Default, changes in set_pri_proto() */
- xpd->type_name =
- type_name(priv->pri_protocol, 0); /* Default, changes in set_nt() */
+ xpd->type_name = type_name(priv->pri_protocol);
if(xpd_common_init(xbus, xpd, unit, subunit, subtype, subunits) < 0)
goto err;
if(pri_proc_create(xbus, xpd) < 0)
@@ -862,7 +826,6 @@
xproto_table_t *proto_table;
BUG_ON(!xpd);
- XPD_DBG(GENERAL, xpd, "\n");
xpd->type = XPD_TYPE_PRI;
proto_table = &PROTO_TABLE(PRI);
priv = xpd->priv;
@@ -874,6 +837,11 @@
XPD_NOTICE(xpd, "PRI protocol not set\n");
goto err;
}
+ xpd->type_name = type_name(priv->pri_protocol);
+ xpd->direction = TO_PSTN;
+ XPD_DBG(DEVICES, xpd, "%s\n", xpd->type_name);
+ xpd->timing_priority = 1; /* SLAVE */
+ set_master_mode(__FUNCTION__, xpd);
for(ret = 0; ret < NUM_LEDS; ret++) {
DO_LED(xpd, ret, PRI_LED_ON);
msleep(20);
@@ -1002,7 +970,7 @@
/*
* LED managment is done by the driver now:
- * - Turn constant ON RED/GREEN led to indicate NT/TE port
+ * - Turn constant ON RED/GREEN led to indicate MASTER/SLAVE port
* - Very fast "Double Blink" to indicate Layer1 alive (without D-Channel)
* - Constant blink (1/2 sec cycle) to indicate D-Channel alive.
*/
@@ -1018,12 +986,12 @@
BUG_ON(!xpd);
priv = xpd->priv;
BUG_ON(!priv);
- if(priv->is_nt) {
- which_led = NT_RED_LED;
- other_led = TE_GREEN_LED;
+ if(xpd->timing_priority == 0) {
+ which_led = TOP_RED_LED;
+ other_led = BOTTOM_GREEN_LED;
} else {
- which_led = TE_GREEN_LED;
- other_led = NT_RED_LED;
+ which_led = BOTTOM_GREEN_LED;
+ other_led = TOP_RED_LED;
}
ledstate = priv->ledstate[which_led];
timer_count = xpd->timer_count;
@@ -1455,11 +1423,10 @@
static bool pri_packet_is_valid(xpacket_t *pack)
{
- const xproto_entry_t *xe_nt = NULL;
- const xproto_entry_t *xe_te = NULL;
+ const xproto_entry_t *xe = NULL;
// DBG(GENERAL, "\n");
- xe_nt = xproto_card_entry(&PROTO_TABLE(PRI), XPACKET_OP(pack));
- return xe_nt != NULL || xe_te != NULL;
+ xe = xproto_card_entry(&PROTO_TABLE(PRI), XPACKET_OP(pack));
+ return xe != NULL;
}
static void pri_packet_dump(const char *msg, xpacket_t *pack)
@@ -1478,8 +1445,6 @@
int ret = 0;
bool got_localloop = 0;
bool got_nolocalloop = 0;
- bool got_te = 0;
- bool got_nt = 0;
bool got_e1 = 0;
bool got_t1 = 0;
bool got_j1 = 0;
@@ -1509,10 +1474,6 @@
got_localloop = 1;
else if(strnicmp(tok, "NOLOCALLOOP", 8) == 0)
got_nolocalloop = 1;
- else if(strnicmp(tok, "NT", 2) == 0)
- got_nt = 1;
- else if(strnicmp(tok, "TE", 2) == 0)
- got_te = 1;
else if(strnicmp(tok, "E1", 2) == 0)
got_e1 = 1;
else if(strnicmp(tok, "T1", 2) == 0)
@@ -1539,10 +1500,6 @@
ret = set_localloop(msg, xpd, 1);
if(got_nolocalloop)
ret = set_localloop(msg, xpd, 0);
- if(got_nt)
- ret = set_nt(msg, xpd, 1);
- if(got_te)
- ret = set_nt(msg, xpd, 0);
return (ret) ? ret : count;
}
@@ -1562,7 +1519,7 @@
priv = xpd->priv;
BUG_ON(!priv);
len += sprintf(page + len, "PRI: %s %s%s (deflaw=%d, dchan=%d)\n",
- (priv->is_nt) ? "NT" : "TE",
+ (priv->clock_source) ? "MASTER" : "SLAVE",
pri_protocol_name(priv->pri_protocol),
(priv->local_loopback) ? " LOCALLOOP" : "",
priv->deflaw, priv->dchan_num);
Modified: linux/trunk/drivers/dahdi/xpp/init_card_1_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_1_30?view=diff&rev=4480&r1=4479&r2=4480
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_1_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_1_30 Sun Jun 29 10:05:48 2008
@@ -52,8 +52,9 @@
getopts('o:', \%opts);
-my $debug;
-my $skip_calib;
+my %settings;
+$settings{debug} = 0;
+$settings{fxs_skip_calib} = 0;
my $xpd_name = sprintf("XPD-%1d0", $ENV{UNIT_NUMBER});
my $chipregs = "$ENV{XPP_BASE}/$ENV{XBUS_NAME}/$xpd_name/chipregs";
@@ -63,7 +64,7 @@
}
sub debug {
- logit @_ if $debug;
+ logit @_ if $settings{debug};
}
# Arrange for error logging
@@ -372,14 +373,11 @@
}
sub read_defaults() {
- # Source default files
- my $var_debug = 'DEBUG_INIT_FXS';
- my $var_skip_calib = 'INIT_FXS_SKIP_CALIB';
- my ($default_file, %source_defaults) =
- XppConfig::source_vars($var_debug, $var_skip_calib);
- $debug = $source_defaults{$var_debug};
- $skip_calib = $source_defaults{$var_skip_calib};
- main::logit "From $default_file: $var_debug=$debug $var_skip_calib=$skip_calib";
+ if(XppConfig::read_config(\%settings)) {
+ main::logit "Defaults from $settings{xppconf}";
+ } else {
+ main::logit "No defaults file, use hard-coded defaults.";
+ }
}
package main;
@@ -392,7 +390,7 @@
main::debug "after init_indirect_registers";
FXS::init_early_direct_regs();
main::debug "after init_early_direct_regs";
-if($skip_calib) {
+if($settings{fxs_skip_calib}) {
main::logit "==== WARNING: SKIPPED SLIC CALIBRATION =====";
} else {
FXS::calibrate_slics;
Modified: linux/trunk/drivers/dahdi/xpp/init_card_2_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_2_30?view=diff&rev=4480&r1=4479&r2=4480
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_2_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_2_30 Sun Jun 29 10:05:48 2008
@@ -52,7 +52,8 @@
getopts('o:v:', \%opts);
-my $debug;
+my %settings;
+$settings{debug} = 0;
my $xpd_name;
my $chipregs;
@@ -62,7 +63,7 @@
}
sub debug {
- logit @_ if $debug;
+ logit @_ if $settings{debug};
}
# Arrange for error logging
@@ -310,23 +311,22 @@
}
sub read_defaults() {
- # Source default files
- my $var_debug = 'DEBUG_INIT_FXO';
- my $var_opermode = 'opermode';
- my ($default_file, %source_defaults) =
- XppConfig::source_vars($var_debug, $var_opermode);
- $debug = $source_defaults{$var_debug};
- my $tmp_opermode = $source_defaults{$var_opermode};
- if(defined($tmp_opermode) and $tmp_opermode) {
- # Verify
- my $mode = $opermode_table{$tmp_opermode};
- if(! defined $mode) {
- main::logit "Unknown opermode='$tmp_opermode'";
- die;
- }
- $OPERMODE = $tmp_opermode;
- }
- main::logit "From $default_file: $var_debug=$debug $var_opermode=$tmp_opermode";
+ if(XppConfig::read_config(\%settings)) {
+ main::logit "Defaults from $settings{xppconf}";
+ my $o = $settings{opermode};
+ if(defined($o)) {
+ # Verify
+ my $mode = $opermode_table{$o};
+ if(! defined $mode) {
+ main::logit "Unknown opermode='$o'";
+ die;
+ }
+ $OPERMODE = $o;
+ main::logit "Set OPERMODE = $o";
+ }
+ } else {
+ main::logit "No defaults file, use hard-coded defaults.";
+ }
}
package main;
Modified: linux/trunk/drivers/dahdi/xpp/init_card_4_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_4_30?view=diff&rev=4480&r1=4479&r2=4480
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_4_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_4_30 Sun Jun 29 10:05:48 2008
@@ -33,6 +33,7 @@
# 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
@@ -59,9 +60,10 @@
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";
@@ -142,24 +144,12 @@
PRI::gen "0 WD 83 9B"; # PC4 (Port configuration 4): RPD_1.GPI (nConfig1), XPD_1.GPOL (MUX_SEL2)
}
-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) =
- XppConfig::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;
@@ -168,57 +158,46 @@
my $pack = shift;
my $port = { @_ };
bless $port, $pack;
- $port->process_pri_spec;
return $port;
+}
+
+sub get_pri_protocol {
+ my $port = shift;
+ my $subunit = $port->{PORT_NUM};
+ my $xpd_name = "XPD-$ENV{UNIT_NUMBER}$subunit";
+ 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 write_pri_info {
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";
-}
-
-sub process_pri_spec($) {
- 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;
- }
- }
- }
- 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;
+ my $pri_protocol = $port->get_pri_protocol;
+
+ if(defined $pri_protocol) {
+ main::logit "$xpd_name: pri_protocol $pri_protocol";
+ open(INFO, ">$info") || die "Failed to open '$info': $!\n";
+ print INFO "$pri_protocol\n" || die "Failed writing '$pri_protocol' to '$info': $!\n";
+ close INFO || die "Failed during close of '$info': $!\n";
+ } else {
+ main::logit "$xpd_name: Skip setting pri protocol -- non given";
+ }
}
sub port_setup($) {
@@ -349,7 +328,7 @@
logit "Starting '$0'";
-PRI::read_pri_specs;
+PRI::read_defaults;
sub main() {
my @ports;
@@ -359,12 +338,9 @@
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;
Modified: linux/trunk/drivers/dahdi/xpp/xpp.conf
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/xpp.conf?view=diff&rev=4480&r1=4479&r2=4480
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xpp.conf (original)
+++ linux/trunk/drivers/dahdi/xpp/xpp.conf Sun Jun 29 10:05:48 2008
@@ -4,15 +4,12 @@
# of init_card_* initialization scripts.
#
-#INIT_FXS_SKIP_CALIB=1
-DEBUG_INIT_FXS=0
-DEBUG_INIT_FXO=0
+fxs_skip_calib 0
+debug 0
-opermode=ISRAEL
+opermode ISRAEL
-#TYPE=T1
-TYPE = E1
-
-XPP_PRI_SETUP = \
- NUM/*/XPD-0[02]=TE,$TYPE \
- NUM/*/XPD-0[13]=NT,$TYPE
+pri_protocol E1
+#pri_protocol/xbus-00/xpd-02 T1
+#pri_protocol/connector:usb-0000:00:1d.7-7/xpd-03 T1
+#pri_protocol/label:usb:0000183/xpd-03 T1
More information about the dahdi-commits
mailing list