xpp: style - Run Lindent
* Here it is: KERNEL_STYLE="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1" TYPEDEFS=' -T gfp_t -T __user -T u_char -T __u8 -T byte -T bool -T charp -T xusb_t -T xbus_t -T xpd_t -T xproto_table_t -T xproto_entry_t -T xframe_t -T xpacket_t -T reg_cmd_t ' indent $TYPEDEFS $KERNEL_STYLE \ --ignore-newlines \ --indent-label0 \ --no-space-after-function-call-names \ "$@" Signed-off-by: Oron Peled <oron.peled@xorcom.com> Acked-By: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10428 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
parent
97ad9f8d03
commit
a2a695c742
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@
|
||||
#include "xpd.h"
|
||||
|
||||
enum bri_opcodes {
|
||||
XPROTO_NAME(BRI, SET_LED) = 0x33,
|
||||
XPROTO_NAME(BRI, SET_LED) = 0x33,
|
||||
};
|
||||
|
||||
#endif /* CARD_BRI_H */
|
||||
#endif /* CARD_BRI_H */
|
||||
|
@ -42,25 +42,20 @@ static DEF_PARM(int, debug, 0, 0644, "Print DBG statements");
|
||||
static bool echo_packet_is_valid(xpacket_t *pack);
|
||||
static void echo_packet_dump(const char *msg, xpacket_t *pack);
|
||||
|
||||
DEF_RPACKET_DATA(ECHO, SET,
|
||||
__u8 timeslots[ECHO_TIMESLOTS];
|
||||
);
|
||||
DEF_RPACKET_DATA(ECHO, SET, __u8 timeslots[ECHO_TIMESLOTS];);
|
||||
|
||||
DEF_RPACKET_DATA(ECHO, SET_REPLY,
|
||||
__u8 status;
|
||||
__u8 reserved;
|
||||
);
|
||||
DEF_RPACKET_DATA(ECHO, SET_REPLY, __u8 status; __u8 reserved;);
|
||||
|
||||
struct ECHO_priv_data {
|
||||
};
|
||||
|
||||
static xproto_table_t PROTO_TABLE(ECHO);
|
||||
static xproto_table_t PROTO_TABLE(ECHO);
|
||||
|
||||
/*---------------- ECHO: Methods -------------------------------------------*/
|
||||
|
||||
static xpd_t *ECHO_card_new(xbus_t *xbus, int unit, int subunit,
|
||||
const xproto_table_t *proto_table, __u8 subtype,
|
||||
int subunits, int subunit_ports, bool to_phone)
|
||||
const xproto_table_t *proto_table, __u8 subtype,
|
||||
int subunits, int subunit_ports, bool to_phone)
|
||||
{
|
||||
xpd_t *xpd = NULL;
|
||||
int channels = 0;
|
||||
@ -70,8 +65,9 @@ static xpd_t *ECHO_card_new(xbus_t *xbus, int unit, int subunit,
|
||||
return NULL;
|
||||
}
|
||||
XBUS_DBG(GENERAL, xbus, "\n");
|
||||
xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits,
|
||||
sizeof(struct ECHO_priv_data), proto_table, channels);
|
||||
xpd =
|
||||
xpd_alloc(xbus, unit, subunit, subtype, subunits,
|
||||
sizeof(struct ECHO_priv_data), proto_table, channels);
|
||||
if (!xpd)
|
||||
return NULL;
|
||||
xpd->type_name = "ECHO";
|
||||
@ -122,19 +118,16 @@ static int ECHO_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 1003) < 5)
|
||||
notify_bad_xpd(__func__, xbus, addr,
|
||||
orig_xpd->xpdname);
|
||||
notify_bad_xpd(__func__, xbus, addr, orig_xpd->xpdname);
|
||||
return -EPROTO;
|
||||
}
|
||||
spin_lock_irqsave(&xpd->lock, flags);
|
||||
/* Update /proc info only if reply related to last reg read request */
|
||||
if (
|
||||
REG_FIELD(&xpd->requested_reply, regnum) ==
|
||||
REG_FIELD(info, regnum) &&
|
||||
REG_FIELD(&xpd->requested_reply, do_subreg) ==
|
||||
REG_FIELD(info, do_subreg) &&
|
||||
REG_FIELD(&xpd->requested_reply, subreg) ==
|
||||
REG_FIELD(info, subreg)) {
|
||||
if (REG_FIELD(&xpd->requested_reply, regnum) == REG_FIELD(info, regnum)
|
||||
&& REG_FIELD(&xpd->requested_reply, do_subreg) == REG_FIELD(info,
|
||||
do_subreg)
|
||||
&& REG_FIELD(&xpd->requested_reply, subreg) == REG_FIELD(info,
|
||||
subreg)) {
|
||||
xpd->last_reply = *info;
|
||||
}
|
||||
spin_unlock_irqrestore(&xpd->lock, flags);
|
||||
@ -198,7 +191,7 @@ static int ECHO_ec_set(xpd_t *xpd, int pos, bool on)
|
||||
ts[ts_number] &= ~ts_mask;
|
||||
}
|
||||
LINE_DBG(GENERAL, xpd, pos, "%s = %d -- ts_number=%d ts_mask=0x%X\n",
|
||||
__func__, on, ts_number, ts_mask);
|
||||
__func__, on, ts_number, ts_mask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -220,7 +213,7 @@ static int ECHO_ec_get(xpd_t *xpd, int pos)
|
||||
}
|
||||
#if 0
|
||||
LINE_DBG(GENERAL, xpd, pos, "ec_get=%d -- ts_number=%d ts_mask=0x%X\n",
|
||||
is_on, ts_number, ts_mask);
|
||||
is_on, ts_number, ts_mask);
|
||||
#endif
|
||||
return is_on;
|
||||
}
|
||||
@ -233,15 +226,14 @@ static void ECHO_ec_dump(xbus_t *xbus)
|
||||
ts = xbus->echo_state.timeslots;
|
||||
for (i = 0; i + 15 < ECHO_TIMESLOTS; i += 16) {
|
||||
XBUS_DBG(GENERAL, xbus,
|
||||
"EC-DUMP[%03d]: "
|
||||
"0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X "
|
||||
"0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||
i,
|
||||
ts[i+0], ts[i+1], ts[i+2], ts[i+3], ts[i+4], ts[i+5],
|
||||
ts[i+6], ts[i+7],
|
||||
ts[i+8], ts[i+9], ts[i+10], ts[i+11], ts[i+12],
|
||||
ts[i+13], ts[i+14], ts[i+15]
|
||||
);
|
||||
"EC-DUMP[%03d]: "
|
||||
"0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X "
|
||||
"0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||
i, ts[i + 0], ts[i + 1], ts[i + 2], ts[i + 3],
|
||||
ts[i + 4], ts[i + 5], ts[i + 6], ts[i + 7], ts[i + 8],
|
||||
ts[i + 9], ts[i + 10], ts[i + 11], ts[i + 12],
|
||||
ts[i + 13], ts[i + 14], ts[i + 15]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +247,7 @@ static int ECHO_ec_update(xbus_t *xbus)
|
||||
/*---------------- ECHO: Astribank Reply Handlers --------------------------*/
|
||||
HANDLER_DEF(ECHO, SET_REPLY)
|
||||
{
|
||||
__u8 status;
|
||||
__u8 status;
|
||||
|
||||
BUG_ON(!xpd);
|
||||
status = RPACKET_FIELD(pack, ECHO, SET_REPLY, status);
|
||||
@ -263,39 +255,32 @@ HANDLER_DEF(ECHO, SET_REPLY)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct xops echo_xops = {
|
||||
.card_new = ECHO_card_new,
|
||||
.card_init = ECHO_card_init,
|
||||
.card_remove = ECHO_card_remove,
|
||||
.card_tick = ECHO_card_tick,
|
||||
.card_register_reply = ECHO_card_register_reply,
|
||||
static const struct xops echo_xops = {
|
||||
.card_new = ECHO_card_new,
|
||||
.card_init = ECHO_card_init,
|
||||
.card_remove = ECHO_card_remove,
|
||||
.card_tick = ECHO_card_tick,
|
||||
.card_register_reply = ECHO_card_register_reply,
|
||||
};
|
||||
|
||||
static const struct echoops echoops = {
|
||||
.ec_set = ECHO_ec_set,
|
||||
.ec_get = ECHO_ec_get,
|
||||
.ec_update = ECHO_ec_update,
|
||||
.ec_dump = ECHO_ec_dump,
|
||||
static const struct echoops echoops = {
|
||||
.ec_set = ECHO_ec_set,
|
||||
.ec_get = ECHO_ec_get,
|
||||
.ec_update = ECHO_ec_update,
|
||||
.ec_dump = ECHO_ec_dump,
|
||||
};
|
||||
|
||||
static xproto_table_t PROTO_TABLE(ECHO) = {
|
||||
.owner = THIS_MODULE,
|
||||
.entries = {
|
||||
/* Table Card Opcode */
|
||||
XENTRY(ECHO, ECHO, SET_REPLY),
|
||||
},
|
||||
.name = "ECHO",
|
||||
.ports_per_subunit = 1,
|
||||
.type = XPD_TYPE_ECHO,
|
||||
.xops = &echo_xops,
|
||||
.echoops = &echoops,
|
||||
.packet_is_valid = echo_packet_is_valid,
|
||||
.packet_dump = echo_packet_dump,
|
||||
};
|
||||
.owner = THIS_MODULE,.entries = {
|
||||
/* Table Card Opcode */
|
||||
XENTRY(ECHO, ECHO, SET_REPLY),},.name = "ECHO",.ports_per_subunit =
|
||||
1,.type = XPD_TYPE_ECHO,.xops = &echo_xops,.echoops =
|
||||
&echoops,.packet_is_valid =
|
||||
echo_packet_is_valid,.packet_dump = echo_packet_dump,};
|
||||
|
||||
static bool echo_packet_is_valid(xpacket_t *pack)
|
||||
{
|
||||
const xproto_entry_t *xe = NULL;
|
||||
const xproto_entry_t *xe = NULL;
|
||||
// DBG(GENERAL, "\n");
|
||||
xe = xproto_card_entry(&PROTO_TABLE(ECHO), XPACKET_OP(pack));
|
||||
return xe != NULL;
|
||||
@ -309,14 +294,14 @@ static void echo_packet_dump(const char *msg, xpacket_t *pack)
|
||||
/*------------------------- sysfs stuff --------------------------------*/
|
||||
static int echo_xpd_probe(struct device *dev)
|
||||
{
|
||||
xpd_t *ec_xpd;
|
||||
int ret = 0;
|
||||
xpd_t *ec_xpd;
|
||||
int ret = 0;
|
||||
|
||||
ec_xpd = dev_to_xpd(dev);
|
||||
/* Is it our device? */
|
||||
if (ec_xpd->type != XPD_TYPE_ECHO) {
|
||||
XPD_ERR(ec_xpd, "drop suggestion for %s (%d)\n",
|
||||
dev_name(dev), ec_xpd->type);
|
||||
XPD_ERR(ec_xpd, "drop suggestion for %s (%d)\n", dev_name(dev),
|
||||
ec_xpd->type);
|
||||
return -EINVAL;
|
||||
}
|
||||
XPD_DBG(DEVICES, ec_xpd, "SYSFS\n");
|
||||
@ -325,23 +310,22 @@ static int echo_xpd_probe(struct device *dev)
|
||||
|
||||
static int echo_xpd_remove(struct device *dev)
|
||||
{
|
||||
xpd_t *ec_xpd;
|
||||
xpd_t *ec_xpd;
|
||||
|
||||
ec_xpd = dev_to_xpd(dev);
|
||||
XPD_DBG(DEVICES, ec_xpd, "SYSFS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct xpd_driver echo_driver = {
|
||||
.type = XPD_TYPE_ECHO,
|
||||
.driver = {
|
||||
.name = "echo",
|
||||
static struct xpd_driver echo_driver = {
|
||||
.type = XPD_TYPE_ECHO,
|
||||
.driver = {
|
||||
.name = "echo",
|
||||
#ifndef OLD_HOTPLUG_SUPPORT
|
||||
.owner = THIS_MODULE,
|
||||
.owner = THIS_MODULE,
|
||||
#endif
|
||||
.probe = echo_xpd_probe,
|
||||
.remove = echo_xpd_remove
|
||||
}
|
||||
.probe = echo_xpd_probe,
|
||||
.remove = echo_xpd_remove}
|
||||
};
|
||||
|
||||
static int __init card_echo_startup(void)
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include "xpd.h"
|
||||
|
||||
enum echo_opcodes {
|
||||
XPROTO_NAME(ECHO, SET) = 0x39,
|
||||
XPROTO_NAME(ECHO, SET_REPLY) = 0x3A,
|
||||
XPROTO_NAME(ECHO, SET) = 0x39,
|
||||
XPROTO_NAME(ECHO, SET_REPLY) = 0x3A,
|
||||
};
|
||||
|
||||
#endif /* CARD_ECHO_H */
|
||||
#endif /* CARD_ECHO_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,17 +25,14 @@
|
||||
#include "xpd.h"
|
||||
|
||||
enum fxo_opcodes {
|
||||
XPROTO_NAME(FXO, SIG_CHANGED) = 0x06,
|
||||
/**/
|
||||
XPROTO_NAME(FXO, DAA_WRITE) = 0x0F, /* Write to DAA */
|
||||
XPROTO_NAME(FXO, CHAN_CID) = 0x0F, /* Write to DAA */
|
||||
XPROTO_NAME(FXO, LED) = 0x0F, /* Write to DAA */
|
||||
XPROTO_NAME(FXO, SIG_CHANGED) = 0x06,
|
||||
/**/ XPROTO_NAME(FXO, DAA_WRITE) = 0x0F, /* Write to DAA */
|
||||
XPROTO_NAME(FXO, CHAN_CID) = 0x0F, /* Write to DAA */
|
||||
XPROTO_NAME(FXO, LED) = 0x0F, /* Write to DAA */
|
||||
};
|
||||
|
||||
DEF_RPACKET_DATA(FXO, SIG_CHANGED, xpp_line_t sig_status; /* channels: lsb=1, msb=8 */
|
||||
xpp_line_t sig_toggles; /* channels: lsb=1, msb=8 */
|
||||
);
|
||||
|
||||
DEF_RPACKET_DATA(FXO, SIG_CHANGED,
|
||||
xpp_line_t sig_status; /* channels: lsb=1, msb=8 */
|
||||
xpp_line_t sig_toggles; /* channels: lsb=1, msb=8 */
|
||||
);
|
||||
|
||||
#endif /* CARD_FXO_H */
|
||||
#endif /* CARD_FXO_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,17 +25,14 @@
|
||||
#include "xpd.h"
|
||||
|
||||
enum fxs_opcodes {
|
||||
XPROTO_NAME(FXS, SIG_CHANGED) = 0x06,
|
||||
/**/
|
||||
XPROTO_NAME(FXS, CHAN_POWER) = 0x0F, /* Write to SLIC */
|
||||
XPROTO_NAME(FXS, CHAN_CID) = 0x0F, /* Write to SLIC */
|
||||
XPROTO_NAME(FXS, LED) = 0x0F, /* Write to SLIC */
|
||||
XPROTO_NAME(FXS, SIG_CHANGED) = 0x06,
|
||||
/**/ XPROTO_NAME(FXS, CHAN_POWER) = 0x0F, /* Write to SLIC */
|
||||
XPROTO_NAME(FXS, CHAN_CID) = 0x0F, /* Write to SLIC */
|
||||
XPROTO_NAME(FXS, LED) = 0x0F, /* Write to SLIC */
|
||||
};
|
||||
|
||||
DEF_RPACKET_DATA(FXS, SIG_CHANGED, xpp_line_t sig_status; /* channels: lsb=1, msb=8 */
|
||||
xpp_line_t sig_toggles; /* channels: lsb=1, msb=8 */
|
||||
);
|
||||
|
||||
DEF_RPACKET_DATA(FXS, SIG_CHANGED,
|
||||
xpp_line_t sig_status; /* channels: lsb=1, msb=8 */
|
||||
xpp_line_t sig_toggles; /* channels: lsb=1, msb=8 */
|
||||
);
|
||||
|
||||
#endif /* CARD_FXS_H */
|
||||
#endif /* CARD_FXS_H */
|
||||
|
@ -32,21 +32,22 @@
|
||||
|
||||
static const char rcsid[] = "$Id$";
|
||||
|
||||
DEF_PARM(charp,initdir, "/usr/share/dahdi", 0644, "The directory of card initialization scripts");
|
||||
DEF_PARM(charp, initdir, "/usr/share/dahdi", 0644,
|
||||
"The directory of card initialization scripts");
|
||||
|
||||
#define CHIP_REGISTERS "chipregs"
|
||||
|
||||
extern int debug;
|
||||
extern int debug;
|
||||
|
||||
/*---------------- GLOBAL PROC handling -----------------------------------*/
|
||||
|
||||
static int send_magic_request(xbus_t *xbus,
|
||||
unsigned unit, xportno_t portno, bool eoftx)
|
||||
static int send_magic_request(xbus_t *xbus, unsigned unit, xportno_t portno,
|
||||
bool eoftx)
|
||||
{
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
reg_cmd_t *reg_cmd;
|
||||
int ret;
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
reg_cmd_t *reg_cmd;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Zero length multibyte is legal and has special meaning for the
|
||||
@ -65,15 +66,15 @@ static int send_magic_request(xbus_t *xbus,
|
||||
dump_xframe(__func__, xbus, xframe, debug);
|
||||
ret = send_cmd_frame(xbus, xframe);
|
||||
if (ret < 0)
|
||||
PORT_ERR(xbus, unit, portno,
|
||||
"%s: failed sending xframe\n", __func__);
|
||||
PORT_ERR(xbus, unit, portno, "%s: failed sending xframe\n",
|
||||
__func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int parse_hexbyte(const char *buf)
|
||||
{
|
||||
char *endp;
|
||||
unsigned val;
|
||||
char *endp;
|
||||
unsigned val;
|
||||
|
||||
val = simple_strtoul(buf, &endp, 16);
|
||||
if (*endp != '\0' || val > 0xFF)
|
||||
@ -83,26 +84,26 @@ static int parse_hexbyte(const char *buf)
|
||||
|
||||
static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
|
||||
{
|
||||
int argno;
|
||||
char num_args;
|
||||
int portno;
|
||||
bool writing;
|
||||
int op; /* [W]rite, [R]ead */
|
||||
int addr_mode; /* [D]irect, [I]ndirect, [Mm]ulti */
|
||||
bool do_subreg = 0;
|
||||
int regnum;
|
||||
int subreg;
|
||||
int data_low;
|
||||
bool do_datah;
|
||||
int data_high;
|
||||
int ret = -EBADR;
|
||||
int argno;
|
||||
char num_args;
|
||||
int portno;
|
||||
bool writing;
|
||||
int op; /* [W]rite, [R]ead */
|
||||
int addr_mode; /* [D]irect, [I]ndirect, [Mm]ulti */
|
||||
bool do_subreg = 0;
|
||||
int regnum;
|
||||
int subreg;
|
||||
int data_low;
|
||||
bool do_datah;
|
||||
int data_high;
|
||||
int ret = -EBADR;
|
||||
|
||||
num_args = 2; /* port + operation */
|
||||
num_args = 2; /* port + operation */
|
||||
if (argc < num_args) {
|
||||
XPD_ERR(xpd, "Not enough arguments (%d)\n", argc);
|
||||
XPD_ERR(xpd,
|
||||
"Any Command is composed of at least %d words (got only %d)\n",
|
||||
num_args, argc);
|
||||
"Any Command is composed of at least %d words (got only %d)\n",
|
||||
num_args, argc);
|
||||
goto out;
|
||||
}
|
||||
/* Process the arguments */
|
||||
@ -125,47 +126,49 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
|
||||
}
|
||||
op = argv[argno][0];
|
||||
switch (op) {
|
||||
case 'W':
|
||||
writing = 1;
|
||||
num_args++; /* data low */
|
||||
//XPD_DBG(REGS, xpd, "WRITING\n");
|
||||
break;
|
||||
case 'R':
|
||||
writing = 0;
|
||||
//XPD_DBG(REGS, xpd, "READING\n");
|
||||
break;
|
||||
default:
|
||||
XPD_ERR(xpd, "Unknown operation type '%c'\n", op);
|
||||
goto out;
|
||||
case 'W':
|
||||
writing = 1;
|
||||
num_args++; /* data low */
|
||||
//XPD_DBG(REGS, xpd, "WRITING\n");
|
||||
break;
|
||||
case 'R':
|
||||
writing = 0;
|
||||
//XPD_DBG(REGS, xpd, "READING\n");
|
||||
break;
|
||||
default:
|
||||
XPD_ERR(xpd, "Unknown operation type '%c'\n", op);
|
||||
goto out;
|
||||
}
|
||||
addr_mode = argv[argno][1];
|
||||
switch (addr_mode) {
|
||||
case 'I':
|
||||
XPD_NOTICE(xpd, "'I' is deprecated in register commands. Use 'S' instead.\n");
|
||||
/* fall through */
|
||||
case 'S':
|
||||
do_subreg = 1;
|
||||
num_args += 2; /* register + subreg */
|
||||
//XPD_DBG(REGS, xpd, "SUBREG\n");
|
||||
break;
|
||||
case 'D':
|
||||
do_subreg = 0;
|
||||
num_args++; /* register */
|
||||
//XPD_DBG(REGS, xpd, "DIRECT\n");
|
||||
break;
|
||||
case 'M':
|
||||
case 'm':
|
||||
if (op != 'W') {
|
||||
XPD_ERR(xpd,
|
||||
"Can use Multibyte (%c) only with op 'W'\n", addr_mode);
|
||||
goto out;
|
||||
}
|
||||
num_args--; /* No data low */
|
||||
//XPD_DBG(REGS, xpd, "Multibyte (%c)\n", addr_mode);
|
||||
break;
|
||||
default:
|
||||
XPD_ERR(xpd, "Unknown addressing type '%c'\n", addr_mode);
|
||||
case 'I':
|
||||
XPD_NOTICE(xpd,
|
||||
"'I' is deprecated in register commands. Use 'S' instead.\n");
|
||||
/* fall through */
|
||||
case 'S':
|
||||
do_subreg = 1;
|
||||
num_args += 2; /* register + subreg */
|
||||
//XPD_DBG(REGS, xpd, "SUBREG\n");
|
||||
break;
|
||||
case 'D':
|
||||
do_subreg = 0;
|
||||
num_args++; /* register */
|
||||
//XPD_DBG(REGS, xpd, "DIRECT\n");
|
||||
break;
|
||||
case 'M':
|
||||
case 'm':
|
||||
if (op != 'W') {
|
||||
XPD_ERR(xpd,
|
||||
"Can use Multibyte (%c) only with op 'W'\n",
|
||||
addr_mode);
|
||||
goto out;
|
||||
}
|
||||
num_args--; /* No data low */
|
||||
//XPD_DBG(REGS, xpd, "Multibyte (%c)\n", addr_mode);
|
||||
break;
|
||||
default:
|
||||
XPD_ERR(xpd, "Unknown addressing type '%c'\n", addr_mode);
|
||||
goto out;
|
||||
}
|
||||
if (argv[argno][2] != '\0') {
|
||||
XPD_ERR(xpd, "Bad operation field '%s'\n", argv[argno]);
|
||||
@ -173,20 +176,21 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
|
||||
}
|
||||
if (argc < num_args) {
|
||||
XPD_ERR(xpd,
|
||||
"Command \"%s\" is composed of at least %d words (got only %d)\n",
|
||||
argv[argno], num_args, argc);
|
||||
"Command \"%s\" is composed of at least %d words (got only %d)\n",
|
||||
argv[argno], num_args, argc);
|
||||
goto out;
|
||||
}
|
||||
argno++;
|
||||
if (addr_mode == 'M' || addr_mode == 'm') {
|
||||
if (argno < argc) {
|
||||
XPD_ERR(xpd,
|
||||
"Magic-Multibyte(%c) with %d extra arguments\n",
|
||||
addr_mode, argc - argno);
|
||||
"Magic-Multibyte(%c) with %d extra arguments\n",
|
||||
addr_mode, argc - argno);
|
||||
goto out;
|
||||
}
|
||||
ret = send_magic_request(xpd->xbus, xpd->addr.unit, portno,
|
||||
addr_mode == 'm');
|
||||
ret =
|
||||
send_magic_request(xpd->xbus, xpd->addr.unit, portno,
|
||||
addr_mode == 'm');
|
||||
goto out;
|
||||
}
|
||||
/* Normal (non-Magic) register commands */
|
||||
@ -209,7 +213,8 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
|
||||
}
|
||||
subreg = parse_hexbyte(argv[argno]);
|
||||
if (subreg < 0) {
|
||||
XPD_ERR(xpd, "Illegal subregister number '%s'\n", argv[argno]);
|
||||
XPD_ERR(xpd, "Illegal subregister number '%s'\n",
|
||||
argv[argno]);
|
||||
goto out;
|
||||
}
|
||||
//XPD_DBG(REGS, xpd, "Subreg is %X\n", subreg);
|
||||
@ -223,7 +228,8 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
|
||||
}
|
||||
data_low = parse_hexbyte(argv[argno]);
|
||||
if (data_low < 0) {
|
||||
XPD_ERR(xpd, "Illegal data_low number '%s'\n", argv[argno]);
|
||||
XPD_ERR(xpd, "Illegal data_low number '%s'\n",
|
||||
argv[argno]);
|
||||
goto out;
|
||||
}
|
||||
//XPD_DBG(REGS, xpd, "Data Low is %X\n", data_low);
|
||||
@ -238,7 +244,8 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
|
||||
}
|
||||
data_high = parse_hexbyte(argv[argno]);
|
||||
if (data_high < 0) {
|
||||
XPD_ERR(xpd, "Illegal data_high number '%s'\n", argv[argno]);
|
||||
XPD_ERR(xpd, "Illegal data_high number '%s'\n",
|
||||
argv[argno]);
|
||||
goto out;
|
||||
}
|
||||
//XPD_DBG(REGS, xpd, "Data High is %X\n", data_high);
|
||||
@ -246,41 +253,37 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
|
||||
} else
|
||||
data_high = 0;
|
||||
if (argno < argc) {
|
||||
XPD_ERR(xpd,
|
||||
"Command contains an extra %d argument\n",
|
||||
argc - argno);
|
||||
XPD_ERR(xpd, "Command contains an extra %d argument\n",
|
||||
argc - argno);
|
||||
goto out;
|
||||
}
|
||||
#if 0
|
||||
XPD_DBG(REGS, xpd,
|
||||
"portno=%d writing=%d regnum=%d do_subreg=%d subreg=%d dataL=%d do_datah=%d dataH=%d\n",
|
||||
portno, /* portno */
|
||||
writing, /* writing */
|
||||
regnum,
|
||||
do_subreg, /* use subreg */
|
||||
subreg, /* subreg */
|
||||
data_low,
|
||||
do_datah, /* use data_high*/
|
||||
data_high);
|
||||
XPD_DBG(REGS, xpd, "portno=%d writing=%d regnum=%d do_subreg=%d subreg=%d dataL=%d do_datah=%d dataH=%d\n", portno, /* portno */
|
||||
writing, /* writing */
|
||||
regnum, do_subreg, /* use subreg */
|
||||
subreg, /* subreg */
|
||||
data_low, do_datah, /* use data_high */
|
||||
data_high);
|
||||
#endif
|
||||
ret = xpp_register_request(xpd->xbus, xpd, portno,
|
||||
writing, regnum, do_subreg, subreg,
|
||||
data_low, do_datah, data_high, 1);
|
||||
ret =
|
||||
xpp_register_request(xpd->xbus, xpd, portno, writing, regnum,
|
||||
do_subreg, subreg, data_low, do_datah,
|
||||
data_high, 1);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int parse_chip_command(xpd_t *xpd, char *cmdline)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
int ret = -EBADR;
|
||||
__u8 buf[MAX_PROC_WRITE];
|
||||
char *str;
|
||||
char *p;
|
||||
static const int MAX_ARGS = 10;
|
||||
char *argv[MAX_ARGS + 1];
|
||||
int argc;
|
||||
int i;
|
||||
xbus_t *xbus;
|
||||
int ret = -EBADR;
|
||||
__u8 buf[MAX_PROC_WRITE];
|
||||
char *str;
|
||||
char *p;
|
||||
static const int MAX_ARGS = 10;
|
||||
char *argv[MAX_ARGS + 1];
|
||||
int argc;
|
||||
int i;
|
||||
|
||||
BUG_ON(!xpd);
|
||||
xbus = xpd->xbus;
|
||||
@ -295,10 +298,10 @@ int parse_chip_command(xpd_t *xpd, char *cmdline)
|
||||
*p = '\0';
|
||||
if ((p = strchr(buf, ';')) != NULL) /* Truncate comments */
|
||||
*p = '\0';
|
||||
for (p = buf; *p && (*p == ' ' || *p == '\t'); p++) /* Trim leading whitespace */
|
||||
for (p = buf; *p && (*p == ' ' || *p == '\t'); p++) /* Trim leading whitespace */
|
||||
;
|
||||
str = p;
|
||||
for (i = 0; (p = strsep(&str, " \t")) != NULL && i < MAX_ARGS; ) {
|
||||
for (i = 0; (p = strsep(&str, " \t")) != NULL && i < MAX_ARGS;) {
|
||||
if (*p != '\0') {
|
||||
argv[i] = p;
|
||||
// XPD_DBG(REGS, xpd, "ARG %d = '%s'\n", i, p);
|
||||
@ -308,7 +311,8 @@ int parse_chip_command(xpd_t *xpd, char *cmdline)
|
||||
argv[i] = NULL;
|
||||
argc = i;
|
||||
if (p) {
|
||||
XPD_ERR(xpd, "Too many words (%d) to process. Last was '%s'\n", i, p);
|
||||
XPD_ERR(xpd, "Too many words (%d) to process. Last was '%s'\n",
|
||||
i, p);
|
||||
goto out;
|
||||
}
|
||||
if (argc)
|
||||
@ -328,9 +332,9 @@ static void global_packet_dump(const char *msg, xpacket_t *pack);
|
||||
|
||||
/* 0x07 */ HOSTCMD(GLOBAL, AB_REQUEST)
|
||||
{
|
||||
int ret = -ENODEV;
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
int ret = -ENODEV;
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
|
||||
if (!xbus) {
|
||||
DBG(DEVICES, "NO XBUS\n");
|
||||
@ -348,23 +352,24 @@ static void global_packet_dump(const char *msg, xpacket_t *pack);
|
||||
}
|
||||
|
||||
int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
|
||||
bool writing, __u8 regnum, bool do_subreg, __u8 subreg,
|
||||
__u8 data_low, bool do_datah, __u8 data_high, bool should_reply)
|
||||
bool writing, __u8 regnum, bool do_subreg, __u8 subreg,
|
||||
__u8 data_low, bool do_datah, __u8 data_high,
|
||||
bool should_reply)
|
||||
{
|
||||
int ret = 0;
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
reg_cmd_t *reg_cmd;
|
||||
int ret = 0;
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
reg_cmd_t *reg_cmd;
|
||||
|
||||
if (!xbus) {
|
||||
DBG(REGS, "NO XBUS\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, REGISTER_REQUEST, xpd->xbus_idx);
|
||||
XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, REGISTER_REQUEST,
|
||||
xpd->xbus_idx);
|
||||
LINE_DBG(REGS, xpd, portno, "%c%c %02X %02X %02X %02X\n",
|
||||
(writing)?'W':'R',
|
||||
(do_subreg)?'S':'D',
|
||||
regnum, subreg, data_low, data_high);
|
||||
(writing) ? 'W' : 'R', (do_subreg) ? 'S' : 'D', regnum, subreg,
|
||||
data_low, data_high);
|
||||
reg_cmd = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REQUEST, reg_cmd);
|
||||
reg_cmd->bytes = sizeof(*reg_cmd) - 1; // do not count the 'bytes' field
|
||||
reg_cmd->is_multibyte = 0;
|
||||
@ -387,7 +392,8 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
|
||||
if (should_reply)
|
||||
xpd->requested_reply = *reg_cmd;
|
||||
if (debug & DBG_REGS) {
|
||||
dump_reg_cmd("REG_REQ", 1, xbus, xpd->addr.unit, reg_cmd->portnum, reg_cmd);
|
||||
dump_reg_cmd("REG_REQ", 1, xbus, xpd->addr.unit,
|
||||
reg_cmd->portnum, reg_cmd);
|
||||
dump_packet("REG_REQ", pack, 1);
|
||||
}
|
||||
if (!xframe->usec_towait) { /* default processing time of SPI */
|
||||
@ -405,9 +411,9 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
|
||||
*/
|
||||
/* 0x19 */ HOSTCMD(GLOBAL, SYNC_SOURCE, enum sync_mode mode, int drift)
|
||||
{
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
const char *mode_name;
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
const char *mode_name;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
if ((mode_name = sync_mode_name(mode)) == NULL) {
|
||||
@ -424,8 +430,8 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
|
||||
|
||||
/* 0x23 */ HOSTCMD(GLOBAL, RESET_SYNC_COUNTERS)
|
||||
{
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
xframe_t *xframe;
|
||||
xpacket_t *pack;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
//XBUS_DBG(SYNC, xbus, "\n");
|
||||
@ -443,14 +449,14 @@ HANDLER_DEF(GLOBAL, NULL_REPLY)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HANDLER_DEF(GLOBAL, AB_DESCRIPTION) /* 0x08 */
|
||||
{
|
||||
struct xbus_workqueue *worker;
|
||||
__u8 rev;
|
||||
struct unit_descriptor *units;
|
||||
int count_units;
|
||||
int i;
|
||||
int ret = 0;
|
||||
HANDLER_DEF(GLOBAL, AB_DESCRIPTION)
|
||||
{ /* 0x08 */
|
||||
struct xbus_workqueue *worker;
|
||||
__u8 rev;
|
||||
struct unit_descriptor *units;
|
||||
int count_units;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
if (!xbus) {
|
||||
NOTICE("%s: xbus is gone!!!\n", __func__);
|
||||
@ -462,19 +468,18 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION) /* 0x08 */
|
||||
count_units /= sizeof(*units);
|
||||
if (rev != XPP_PROTOCOL_VERSION) {
|
||||
XBUS_NOTICE(xbus, "Bad protocol version %d (should be %d)\n",
|
||||
rev, XPP_PROTOCOL_VERSION);
|
||||
rev, XPP_PROTOCOL_VERSION);
|
||||
ret = -EPROTO;
|
||||
goto proto_err;
|
||||
}
|
||||
if (count_units > NUM_UNITS) {
|
||||
XBUS_NOTICE(xbus, "Too many units %d (should be %d)\n",
|
||||
count_units, NUM_UNITS);
|
||||
count_units, NUM_UNITS);
|
||||
ret = -EPROTO;
|
||||
goto proto_err;
|
||||
}
|
||||
if (count_units <= 0) {
|
||||
XBUS_NOTICE(xbus, "Empty astribank? (%d units)\n",
|
||||
count_units);
|
||||
XBUS_NOTICE(xbus, "Empty astribank? (%d units)\n", count_units);
|
||||
ret = -EPROTO;
|
||||
goto proto_err;
|
||||
}
|
||||
@ -482,7 +487,8 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION) /* 0x08 */
|
||||
ret = -EPROTO;
|
||||
goto proto_err;
|
||||
}
|
||||
XBUS_INFO(xbus, "DESCRIPTOR: %d cards, protocol revision %d\n", count_units, rev);
|
||||
XBUS_INFO(xbus, "DESCRIPTOR: %d cards, protocol revision %d\n",
|
||||
count_units, rev);
|
||||
if (xbus_check_unique(xbus))
|
||||
return -EBUSY;
|
||||
xbus->revision = rev;
|
||||
@ -493,11 +499,13 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION) /* 0x08 */
|
||||
goto out;
|
||||
}
|
||||
for (i = 0; i < count_units; i++) {
|
||||
struct unit_descriptor *this_unit = &units[i];
|
||||
struct card_desc_struct *card_desc;
|
||||
unsigned long flags;
|
||||
struct unit_descriptor *this_unit = &units[i];
|
||||
struct card_desc_struct *card_desc;
|
||||
unsigned long flags;
|
||||
|
||||
if ((card_desc = KZALLOC(sizeof(struct card_desc_struct), GFP_ATOMIC)) == NULL) {
|
||||
if ((card_desc =
|
||||
KZALLOC(sizeof(struct card_desc_struct),
|
||||
GFP_ATOMIC)) == NULL) {
|
||||
XBUS_ERR(xbus, "Card description allocation failed.\n");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
@ -510,16 +518,14 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION) /* 0x08 */
|
||||
card_desc->numchips = this_unit->numchips;
|
||||
card_desc->ports_per_chip = this_unit->ports_per_chip;
|
||||
card_desc->port_dir = this_unit->port_dir;
|
||||
card_desc->ports = card_desc->numchips * card_desc->ports_per_chip;
|
||||
XBUS_INFO(xbus, " CARD %d type=%d.%d ports=%d (%dx%d), port-dir=0x%02X\n",
|
||||
card_desc->xpd_addr.unit,
|
||||
card_desc->type,
|
||||
card_desc->subtype,
|
||||
card_desc->ports,
|
||||
card_desc->numchips,
|
||||
card_desc->ports_per_chip,
|
||||
card_desc->port_dir
|
||||
);
|
||||
card_desc->ports =
|
||||
card_desc->numchips * card_desc->ports_per_chip;
|
||||
XBUS_INFO(xbus,
|
||||
" CARD %d type=%d.%d ports=%d (%dx%d), port-dir=0x%02X\n",
|
||||
card_desc->xpd_addr.unit, card_desc->type,
|
||||
card_desc->subtype, card_desc->ports,
|
||||
card_desc->numchips, card_desc->ports_per_chip,
|
||||
card_desc->port_dir);
|
||||
spin_lock_irqsave(&worker->worker_lock, flags);
|
||||
worker->num_units++;
|
||||
XBUS_COUNTER(xbus, UNITS)++;
|
||||
@ -539,21 +545,23 @@ out:
|
||||
|
||||
HANDLER_DEF(GLOBAL, REGISTER_REPLY)
|
||||
{
|
||||
reg_cmd_t *reg = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REPLY, regcmd);
|
||||
reg_cmd_t *reg = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REPLY, regcmd);
|
||||
|
||||
if (!xpd) {
|
||||
static int rate_limit;
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 1003) < 5)
|
||||
notify_bad_xpd(__func__, xbus, XPACKET_ADDR(pack), "");
|
||||
return -EPROTO;
|
||||
}
|
||||
if (debug & DBG_REGS) {
|
||||
dump_reg_cmd("REG_REPLY", 0, xbus, xpd->addr.unit, reg->portnum, reg);
|
||||
dump_reg_cmd("REG_REPLY", 0, xbus, xpd->addr.unit, reg->portnum,
|
||||
reg);
|
||||
dump_packet("REG_REPLY", pack, 1);
|
||||
}
|
||||
if (! XMETHOD(card_register_reply, xpd)) {
|
||||
XPD_ERR(xpd, "REGISTER_REPLY: without card_register_reply() method\n");
|
||||
if (!XMETHOD(card_register_reply, xpd)) {
|
||||
XPD_ERR(xpd,
|
||||
"REGISTER_REPLY: without card_register_reply() method\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
return CALL_XMETHOD(card_register_reply, xpd, reg);
|
||||
@ -561,9 +569,9 @@ HANDLER_DEF(GLOBAL, REGISTER_REPLY)
|
||||
|
||||
HANDLER_DEF(GLOBAL, SYNC_REPLY)
|
||||
{
|
||||
__u8 mode = RPACKET_FIELD(pack, GLOBAL, SYNC_REPLY, sync_mode);
|
||||
__u8 drift = RPACKET_FIELD(pack, GLOBAL, SYNC_REPLY, drift);
|
||||
const char *mode_name;
|
||||
__u8 mode = RPACKET_FIELD(pack, GLOBAL, SYNC_REPLY, sync_mode);
|
||||
__u8 drift = RPACKET_FIELD(pack, GLOBAL, SYNC_REPLY, drift);
|
||||
const char *mode_name;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
if ((mode_name = sync_mode_name(mode)) == NULL) {
|
||||
@ -580,10 +588,10 @@ HANDLER_DEF(GLOBAL, SYNC_REPLY)
|
||||
|
||||
HANDLER_DEF(GLOBAL, ERROR_CODE)
|
||||
{
|
||||
char tmp_name[TMP_NAME_LEN];
|
||||
static long rate_limit;
|
||||
__u8 category_code;
|
||||
__u8 errorbits;
|
||||
char tmp_name[TMP_NAME_LEN];
|
||||
static long rate_limit;
|
||||
__u8 category_code;
|
||||
__u8 errorbits;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
if ((rate_limit++ % 5003) > 200)
|
||||
@ -592,12 +600,14 @@ HANDLER_DEF(GLOBAL, ERROR_CODE)
|
||||
errorbits = RPACKET_FIELD(pack, GLOBAL, ERROR_CODE, errorbits);
|
||||
if (!xpd) {
|
||||
snprintf(tmp_name, TMP_NAME_LEN, "%s(%1d%1d)", xbus->busname,
|
||||
XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack));
|
||||
XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack));
|
||||
} else {
|
||||
snprintf(tmp_name, TMP_NAME_LEN, "%s/%s", xbus->busname, xpd->xpdname);
|
||||
snprintf(tmp_name, TMP_NAME_LEN, "%s/%s", xbus->busname,
|
||||
xpd->xpdname);
|
||||
}
|
||||
NOTICE("%s: FIRMWARE %s: category=%d errorbits=0x%02X (rate_limit=%ld)\n",
|
||||
tmp_name, cmd->name, category_code, errorbits, rate_limit);
|
||||
NOTICE
|
||||
("%s: FIRMWARE %s: category=%d errorbits=0x%02X (rate_limit=%ld)\n",
|
||||
tmp_name, cmd->name, category_code, errorbits, rate_limit);
|
||||
dump_packet("FIRMWARE: ", pack, 1);
|
||||
/*
|
||||
* FIXME: Should implement an error recovery plan
|
||||
@ -605,24 +615,20 @@ HANDLER_DEF(GLOBAL, ERROR_CODE)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
xproto_table_t PROTO_TABLE(GLOBAL) = {
|
||||
.entries = {
|
||||
/* Prototable Card Opcode */
|
||||
XENTRY( GLOBAL, GLOBAL, NULL_REPLY ),
|
||||
XENTRY( GLOBAL, GLOBAL, AB_DESCRIPTION ),
|
||||
XENTRY( GLOBAL, GLOBAL, SYNC_REPLY ),
|
||||
XENTRY( GLOBAL, GLOBAL, ERROR_CODE ),
|
||||
XENTRY( GLOBAL, GLOBAL, REGISTER_REPLY ),
|
||||
},
|
||||
.name = "GLOBAL",
|
||||
.packet_is_valid = global_packet_is_valid,
|
||||
.packet_dump = global_packet_dump,
|
||||
};
|
||||
/* Prototable Card Opcode */
|
||||
XENTRY(GLOBAL, GLOBAL, NULL_REPLY), XENTRY(GLOBAL, GLOBAL,
|
||||
AB_DESCRIPTION),
|
||||
XENTRY(GLOBAL, GLOBAL, SYNC_REPLY),
|
||||
XENTRY(GLOBAL, GLOBAL, ERROR_CODE),
|
||||
XENTRY(GLOBAL, GLOBAL, REGISTER_REPLY),},.name =
|
||||
"GLOBAL",.packet_is_valid =
|
||||
global_packet_is_valid,.packet_dump = global_packet_dump,};
|
||||
|
||||
static bool global_packet_is_valid(xpacket_t *pack)
|
||||
{
|
||||
const xproto_entry_t *xe;
|
||||
const xproto_entry_t *xe;
|
||||
|
||||
//DBG(GENERAL, "\n");
|
||||
xe = xproto_global_entry(XPACKET_OP(pack));
|
||||
@ -638,26 +644,26 @@ static void global_packet_dump(const char *msg, xpacket_t *pack)
|
||||
|
||||
int run_initialize_registers(xpd_t *xpd)
|
||||
{
|
||||
int ret;
|
||||
xbus_t *xbus;
|
||||
char busstr[MAX_ENV_STR];
|
||||
char busnumstr[MAX_ENV_STR];
|
||||
char modelstr[MAX_ENV_STR];
|
||||
char unitstr[MAX_ENV_STR];
|
||||
char subunitsstr[MAX_ENV_STR];
|
||||
char typestr[MAX_ENV_STR];
|
||||
char directionstr[MAX_ENV_STR];
|
||||
char revstr[MAX_ENV_STR];
|
||||
char connectorstr[MAX_ENV_STR];
|
||||
char xbuslabel[MAX_ENV_STR];
|
||||
char init_card[MAX_PATH_STR];
|
||||
__u8 direction_mask;
|
||||
int i;
|
||||
char *argv[] = {
|
||||
int ret;
|
||||
xbus_t *xbus;
|
||||
char busstr[MAX_ENV_STR];
|
||||
char busnumstr[MAX_ENV_STR];
|
||||
char modelstr[MAX_ENV_STR];
|
||||
char unitstr[MAX_ENV_STR];
|
||||
char subunitsstr[MAX_ENV_STR];
|
||||
char typestr[MAX_ENV_STR];
|
||||
char directionstr[MAX_ENV_STR];
|
||||
char revstr[MAX_ENV_STR];
|
||||
char connectorstr[MAX_ENV_STR];
|
||||
char xbuslabel[MAX_ENV_STR];
|
||||
char init_card[MAX_PATH_STR];
|
||||
__u8 direction_mask;
|
||||
int i;
|
||||
char *argv[] = {
|
||||
init_card,
|
||||
NULL
|
||||
};
|
||||
char *envp[] = {
|
||||
char *envp[] = {
|
||||
busstr,
|
||||
busnumstr,
|
||||
modelstr,
|
||||
@ -684,40 +690,47 @@ int run_initialize_registers(xpd_t *xpd)
|
||||
}
|
||||
direction_mask = 0;
|
||||
for (i = 0; i < xpd->subunits; i++) {
|
||||
xpd_t *su = xpd_byaddr(xbus, xpd->addr.unit, i);
|
||||
xpd_t *su = xpd_byaddr(xbus, xpd->addr.unit, i);
|
||||
|
||||
if (!su) {
|
||||
XPD_ERR(xpd,
|
||||
"Have %d subunits, but not subunit #%d\n",
|
||||
XPD_ERR(xpd, "Have %d subunits, but not subunit #%d\n",
|
||||
xpd->subunits, i);
|
||||
continue;
|
||||
}
|
||||
direction_mask |= (PHONEDEV(su).direction == TO_PHONE) ? BIT(i) : 0;
|
||||
direction_mask |=
|
||||
(PHONEDEV(su).direction == TO_PHONE) ? BIT(i) : 0;
|
||||
}
|
||||
snprintf(busstr, MAX_ENV_STR, "XBUS_NAME=%s", xbus->busname);
|
||||
snprintf(busnumstr, MAX_ENV_STR, "XBUS_NUMBER=%d", xbus->num);
|
||||
snprintf(modelstr, MAX_ENV_STR, "XBUS_MODEL_STRING=%s", xbus->transport.model_string);
|
||||
snprintf(modelstr, MAX_ENV_STR, "XBUS_MODEL_STRING=%s",
|
||||
xbus->transport.model_string);
|
||||
snprintf(unitstr, MAX_ENV_STR, "UNIT_NUMBER=%d", xpd->addr.unit);
|
||||
snprintf(typestr, MAX_ENV_STR, "UNIT_TYPE=%d", xpd->type);
|
||||
snprintf(subunitsstr, MAX_ENV_STR, "UNIT_SUBUNITS=%d", xpd->subunits);
|
||||
snprintf(directionstr, MAX_ENV_STR, "UNIT_SUBUNITS_DIR=%d", direction_mask);
|
||||
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->connector);
|
||||
snprintf(connectorstr, MAX_ENV_STR, "XBUS_CONNECTOR=%s",
|
||||
xbus->connector);
|
||||
snprintf(xbuslabel, 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);
|
||||
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);
|
||||
ret = -E2BIG;
|
||||
goto err;
|
||||
}
|
||||
if (!XBUS_IS(xbus, RECVD_DESC)) {
|
||||
XBUS_ERR(xbus, "Skipped register initialization. In state %s.\n",
|
||||
xbus_statename(XBUS_STATE(xbus)));
|
||||
XBUS_ERR(xbus,
|
||||
"Skipped register initialization. In state %s.\n",
|
||||
xbus_statename(XBUS_STATE(xbus)));
|
||||
ret = -ENODEV;
|
||||
goto err;
|
||||
}
|
||||
XPD_DBG(DEVICES, xpd, "running '%s' for type=%d revision=%d\n",
|
||||
init_card, xpd->type, xbus->revision);
|
||||
init_card, xpd->type, xbus->revision);
|
||||
ret = call_usermodehelper(init_card, argv, envp, 1);
|
||||
/*
|
||||
* Carefully report results
|
||||
@ -725,15 +738,18 @@ int run_initialize_registers(xpd_t *xpd)
|
||||
if (ret == 0)
|
||||
XPD_DBG(DEVICES, xpd, "'%s' finished OK\n", init_card);
|
||||
else if (ret < 0) {
|
||||
XPD_ERR(xpd, "Failed running '%s' (errno %d)\n", init_card, ret);
|
||||
XPD_ERR(xpd, "Failed running '%s' (errno %d)\n", init_card,
|
||||
ret);
|
||||
} else {
|
||||
__u8 exitval = ((unsigned)ret >> 8) & 0xFF;
|
||||
__u8 sigval = ret & 0xFF;
|
||||
__u8 exitval = ((unsigned)ret >> 8) & 0xFF;
|
||||
__u8 sigval = ret & 0xFF;
|
||||
|
||||
if (!exitval) {
|
||||
XPD_ERR(xpd, "'%s' killed by signal %d\n", init_card, sigval);
|
||||
XPD_ERR(xpd, "'%s' killed by signal %d\n", init_card,
|
||||
sigval);
|
||||
} else {
|
||||
XPD_ERR(xpd, "'%s' aborted with exitval %d\n", init_card, exitval);
|
||||
XPD_ERR(xpd, "'%s' aborted with exitval %d\n",
|
||||
init_card, exitval);
|
||||
}
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
@ -26,88 +26,59 @@
|
||||
#include "xbus-pcm.h"
|
||||
|
||||
enum global_opcodes {
|
||||
XPROTO_NAME(GLOBAL, AB_REQUEST) = 0x07,
|
||||
XPROTO_NAME(GLOBAL, AB_DESCRIPTION) = 0x08,
|
||||
XPROTO_NAME(GLOBAL, REGISTER_REQUEST) = 0x0F,
|
||||
XPROTO_NAME(GLOBAL, REGISTER_REPLY) = 0x10,
|
||||
/**/
|
||||
XPROTO_NAME(GLOBAL, PCM_WRITE) = 0x11,
|
||||
XPROTO_NAME(GLOBAL, PCM_READ) = 0x12,
|
||||
/**/
|
||||
XPROTO_NAME(GLOBAL, SYNC_SOURCE) = 0x19,
|
||||
XPROTO_NAME(GLOBAL, SYNC_REPLY) = 0x1A,
|
||||
/**/
|
||||
XPROTO_NAME(GLOBAL, ERROR_CODE) = 0x22,
|
||||
XPROTO_NAME(GLOBAL, RESET_SYNC_COUNTERS) = 0x23,
|
||||
XPROTO_NAME(GLOBAL, NULL_REPLY) = 0xFE,
|
||||
XPROTO_NAME(GLOBAL, AB_REQUEST) = 0x07,
|
||||
XPROTO_NAME(GLOBAL, AB_DESCRIPTION) = 0x08,
|
||||
XPROTO_NAME(GLOBAL, REGISTER_REQUEST) = 0x0F,
|
||||
XPROTO_NAME(GLOBAL, REGISTER_REPLY) = 0x10,
|
||||
/**/ XPROTO_NAME(GLOBAL, PCM_WRITE) = 0x11,
|
||||
XPROTO_NAME(GLOBAL, PCM_READ) = 0x12,
|
||||
/**/ XPROTO_NAME(GLOBAL, SYNC_SOURCE) = 0x19,
|
||||
XPROTO_NAME(GLOBAL, SYNC_REPLY) = 0x1A,
|
||||
/**/ XPROTO_NAME(GLOBAL, ERROR_CODE) = 0x22,
|
||||
XPROTO_NAME(GLOBAL, RESET_SYNC_COUNTERS) = 0x23,
|
||||
XPROTO_NAME(GLOBAL, NULL_REPLY) = 0xFE,
|
||||
};
|
||||
|
||||
struct unit_descriptor {
|
||||
struct xpd_addr addr;
|
||||
__u8 subtype:4;
|
||||
__u8 type:4;
|
||||
__u8 numchips;
|
||||
__u8 ports_per_chip;
|
||||
__u8 port_dir; /* bitmask: 0 - PSTN, 1 - PHONE */
|
||||
__u8 reserved[2];
|
||||
struct xpd_addr ec_addr;
|
||||
struct xpd_addr addr;
|
||||
__u8 subtype:4;
|
||||
__u8 type:4;
|
||||
__u8 numchips;
|
||||
__u8 ports_per_chip;
|
||||
__u8 port_dir; /* bitmask: 0 - PSTN, 1 - PHONE */
|
||||
__u8 reserved[2];
|
||||
struct xpd_addr ec_addr;
|
||||
};
|
||||
|
||||
#define NUM_UNITS 6
|
||||
|
||||
DEF_RPACKET_DATA(GLOBAL, NULL_REPLY);
|
||||
DEF_RPACKET_DATA(GLOBAL, AB_REQUEST,
|
||||
__u8 rev;
|
||||
__u8 reserved;
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, AB_DESCRIPTION,
|
||||
__u8 rev;
|
||||
__u8 reserved[3];
|
||||
struct unit_descriptor unit_descriptor[NUM_UNITS];
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, REGISTER_REQUEST,
|
||||
reg_cmd_t reg_cmd;
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, PCM_WRITE,
|
||||
xpp_line_t lines;
|
||||
__u8 pcm[PCM_CHUNKSIZE];
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, PCM_READ,
|
||||
xpp_line_t lines;
|
||||
__u8 pcm[PCM_CHUNKSIZE];
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, SYNC_SOURCE,
|
||||
__u8 sync_mode;
|
||||
__u8 drift;
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, SYNC_REPLY,
|
||||
__u8 sync_mode;
|
||||
__u8 drift;
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, REGISTER_REPLY,
|
||||
reg_cmd_t regcmd;
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, RESET_SYNC_COUNTERS,
|
||||
__u8 mask;
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, ERROR_CODE,
|
||||
__u8 category_code;
|
||||
__u8 errorbits;
|
||||
__u8 bad_packet[0];
|
||||
);
|
||||
DEF_RPACKET_DATA(GLOBAL, AB_REQUEST, __u8 rev; __u8 reserved;);
|
||||
DEF_RPACKET_DATA(GLOBAL, AB_DESCRIPTION, __u8 rev; __u8 reserved[3];
|
||||
struct unit_descriptor unit_descriptor[NUM_UNITS];);
|
||||
DEF_RPACKET_DATA(GLOBAL, REGISTER_REQUEST, reg_cmd_t reg_cmd;);
|
||||
DEF_RPACKET_DATA(GLOBAL, PCM_WRITE, xpp_line_t lines; __u8 pcm[PCM_CHUNKSIZE];);
|
||||
DEF_RPACKET_DATA(GLOBAL, PCM_READ, xpp_line_t lines; __u8 pcm[PCM_CHUNKSIZE];);
|
||||
DEF_RPACKET_DATA(GLOBAL, SYNC_SOURCE, __u8 sync_mode; __u8 drift;);
|
||||
DEF_RPACKET_DATA(GLOBAL, SYNC_REPLY, __u8 sync_mode; __u8 drift;);
|
||||
DEF_RPACKET_DATA(GLOBAL, REGISTER_REPLY, reg_cmd_t regcmd;);
|
||||
DEF_RPACKET_DATA(GLOBAL, RESET_SYNC_COUNTERS, __u8 mask;);
|
||||
DEF_RPACKET_DATA(GLOBAL, ERROR_CODE, __u8 category_code; __u8 errorbits;
|
||||
__u8 bad_packet[0];);
|
||||
|
||||
/* 0x07 */ DECLARE_CMD(GLOBAL, AB_REQUEST);
|
||||
/* 0x19 */ DECLARE_CMD(GLOBAL, SYNC_SOURCE, enum sync_mode mode, int drift);
|
||||
/* 0x23 */ DECLARE_CMD(GLOBAL, RESET_SYNC_COUNTERS);
|
||||
|
||||
int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
|
||||
bool writing, __u8 regnum, bool do_subreg, __u8 subreg,
|
||||
__u8 data_low, bool do_datah, __u8 data_high, bool should_reply);
|
||||
bool writing, __u8 regnum, bool do_subreg, __u8 subreg,
|
||||
__u8 data_low, bool do_datah, __u8 data_high,
|
||||
bool should_reply);
|
||||
int send_multibyte_request(xbus_t *xbus, unsigned unit, xportno_t portno,
|
||||
bool eoftx, __u8 *buf, unsigned len);
|
||||
bool eoftx, __u8 *buf, unsigned len);
|
||||
extern xproto_table_t PROTO_TABLE(GLOBAL);
|
||||
int run_initialize_registers(xpd_t *xpd);
|
||||
int parse_chip_command(xpd_t *xpd, char *cmdline);
|
||||
extern charp initdir;
|
||||
|
||||
#endif /* CARD_GLOBAL_H */
|
||||
#endif /* CARD_GLOBAL_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,8 +25,7 @@
|
||||
#include "xpd.h"
|
||||
|
||||
enum pri_opcodes {
|
||||
XPROTO_NAME(PRI, SET_LED) = 0x33,
|
||||
XPROTO_NAME(PRI, SET_LED) = 0x33,
|
||||
};
|
||||
|
||||
|
||||
#endif /* CARD_PRI_H */
|
||||
#endif /* CARD_PRI_H */
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
||||
# warning "This module is tested only with 2.6 kernels"
|
||||
#warning "This module is tested only with 2.6 kernels"
|
||||
#endif
|
||||
|
||||
#include <linux/kernel.h>
|
||||
@ -35,28 +35,20 @@
|
||||
static const char rcsid[] = "$Id$";
|
||||
|
||||
#define P_(x) [ x ] = { .value = x, .name = #x, }
|
||||
static struct {
|
||||
static struct {
|
||||
int value;
|
||||
char *name;
|
||||
} poll_names[] = {
|
||||
P_(POLLIN),
|
||||
P_(POLLPRI),
|
||||
P_(POLLOUT),
|
||||
P_(POLLERR),
|
||||
P_(POLLHUP),
|
||||
P_(POLLNVAL),
|
||||
P_(POLLRDNORM),
|
||||
P_(POLLRDBAND),
|
||||
P_(POLLWRNORM),
|
||||
P_(POLLWRBAND),
|
||||
P_(POLLMSG),
|
||||
P_(POLLREMOVE)
|
||||
P_(POLLIN), P_(POLLPRI), P_(POLLOUT), P_(POLLERR), P_(POLLHUP),
|
||||
P_(POLLNVAL), P_(POLLRDNORM), P_(POLLRDBAND), P_(POLLWRNORM),
|
||||
P_(POLLWRBAND), P_(POLLMSG), P_(POLLREMOVE)
|
||||
};
|
||||
|
||||
#undef P_
|
||||
|
||||
void dump_poll(int debug, const char *msg, int poll)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(poll_names); i++) {
|
||||
if (poll & poll_names[i].value)
|
||||
@ -66,10 +58,10 @@ void dump_poll(int debug, const char *msg, int poll)
|
||||
|
||||
void alarm2str(int alarm, char *buf, int buflen)
|
||||
{
|
||||
char *p = buf;
|
||||
int left = buflen;
|
||||
int i;
|
||||
int n;
|
||||
char *p = buf;
|
||||
int left = buflen;
|
||||
int i;
|
||||
int n;
|
||||
|
||||
if (!alarm) {
|
||||
snprintf(buf, buflen, "NONE");
|
||||
@ -83,7 +75,7 @@ void alarm2str(int alarm, char *buf, int buflen)
|
||||
left -= n;
|
||||
}
|
||||
}
|
||||
if (p > buf) /* kill last comma */
|
||||
if (p > buf) /* kill last comma */
|
||||
*(p - 1) = '\0';
|
||||
}
|
||||
|
||||
|
@ -95,11 +95,16 @@ void dump_poll(int debug, const char *msg, int poll);
|
||||
static inline char *rxsig2str(enum dahdi_rxsig sig)
|
||||
{
|
||||
switch (sig) {
|
||||
case DAHDI_RXSIG_ONHOOK: return "ONHOOK";
|
||||
case DAHDI_RXSIG_OFFHOOK: return "OFFHOOK";
|
||||
case DAHDI_RXSIG_START: return "START";
|
||||
case DAHDI_RXSIG_RING: return "RING";
|
||||
case DAHDI_RXSIG_INITIAL: return "INITIAL";
|
||||
case DAHDI_RXSIG_ONHOOK:
|
||||
return "ONHOOK";
|
||||
case DAHDI_RXSIG_OFFHOOK:
|
||||
return "OFFHOOK";
|
||||
case DAHDI_RXSIG_START:
|
||||
return "START";
|
||||
case DAHDI_RXSIG_RING:
|
||||
return "RING";
|
||||
case DAHDI_RXSIG_INITIAL:
|
||||
return "INITIAL";
|
||||
}
|
||||
return "Unknown rxsig";
|
||||
}
|
||||
@ -107,11 +112,16 @@ static inline char *rxsig2str(enum dahdi_rxsig sig)
|
||||
static inline char *txsig2str(enum dahdi_txsig sig)
|
||||
{
|
||||
switch (sig) {
|
||||
case DAHDI_TXSIG_ONHOOK: return "TXSIG_ONHOOK";
|
||||
case DAHDI_TXSIG_OFFHOOK: return "TXSIG_OFFHOOK";
|
||||
case DAHDI_TXSIG_START: return "TXSIG_START";
|
||||
case DAHDI_TXSIG_KEWL: return "TXSIG_KEWL"; /* Drop battery if possible */
|
||||
case DAHDI_TXSIG_TOTAL: break;
|
||||
case DAHDI_TXSIG_ONHOOK:
|
||||
return "TXSIG_ONHOOK";
|
||||
case DAHDI_TXSIG_OFFHOOK:
|
||||
return "TXSIG_OFFHOOK";
|
||||
case DAHDI_TXSIG_START:
|
||||
return "TXSIG_START";
|
||||
case DAHDI_TXSIG_KEWL:
|
||||
return "TXSIG_KEWL"; /* Drop battery if possible */
|
||||
case DAHDI_TXSIG_TOTAL:
|
||||
break;
|
||||
}
|
||||
return "Unknown txsig";
|
||||
}
|
||||
@ -119,24 +129,42 @@ static inline char *txsig2str(enum dahdi_txsig sig)
|
||||
static inline char *event2str(int event)
|
||||
{
|
||||
switch (event) {
|
||||
case DAHDI_EVENT_NONE: return "NONE";
|
||||
case DAHDI_EVENT_ONHOOK: return "ONHOOK";
|
||||
case DAHDI_EVENT_RINGOFFHOOK: return "RINGOFFHOOK";
|
||||
case DAHDI_EVENT_WINKFLASH: return "WINKFLASH";
|
||||
case DAHDI_EVENT_ALARM: return "ALARM";
|
||||
case DAHDI_EVENT_NOALARM: return "NOALARM";
|
||||
case DAHDI_EVENT_ABORT: return "ABORT";
|
||||
case DAHDI_EVENT_OVERRUN: return "OVERRUN";
|
||||
case DAHDI_EVENT_BADFCS: return "BADFCS";
|
||||
case DAHDI_EVENT_DIALCOMPLETE: return "DIALCOMPLETE";
|
||||
case DAHDI_EVENT_RINGERON: return "RINGERON";
|
||||
case DAHDI_EVENT_RINGEROFF: return "RINGEROFF";
|
||||
case DAHDI_EVENT_HOOKCOMPLETE: return "HOOKCOMPLETE";
|
||||
case DAHDI_EVENT_BITSCHANGED: return "BITSCHANGED";
|
||||
case DAHDI_EVENT_PULSE_START: return "PULSE_START";
|
||||
case DAHDI_EVENT_TIMER_EXPIRED: return "TIMER_EXPIRED";
|
||||
case DAHDI_EVENT_TIMER_PING: return "TIMER_PING";
|
||||
case DAHDI_EVENT_POLARITY: return "POLARITY";
|
||||
case DAHDI_EVENT_NONE:
|
||||
return "NONE";
|
||||
case DAHDI_EVENT_ONHOOK:
|
||||
return "ONHOOK";
|
||||
case DAHDI_EVENT_RINGOFFHOOK:
|
||||
return "RINGOFFHOOK";
|
||||
case DAHDI_EVENT_WINKFLASH:
|
||||
return "WINKFLASH";
|
||||
case DAHDI_EVENT_ALARM:
|
||||
return "ALARM";
|
||||
case DAHDI_EVENT_NOALARM:
|
||||
return "NOALARM";
|
||||
case DAHDI_EVENT_ABORT:
|
||||
return "ABORT";
|
||||
case DAHDI_EVENT_OVERRUN:
|
||||
return "OVERRUN";
|
||||
case DAHDI_EVENT_BADFCS:
|
||||
return "BADFCS";
|
||||
case DAHDI_EVENT_DIALCOMPLETE:
|
||||
return "DIALCOMPLETE";
|
||||
case DAHDI_EVENT_RINGERON:
|
||||
return "RINGERON";
|
||||
case DAHDI_EVENT_RINGEROFF:
|
||||
return "RINGEROFF";
|
||||
case DAHDI_EVENT_HOOKCOMPLETE:
|
||||
return "HOOKCOMPLETE";
|
||||
case DAHDI_EVENT_BITSCHANGED:
|
||||
return "BITSCHANGED";
|
||||
case DAHDI_EVENT_PULSE_START:
|
||||
return "PULSE_START";
|
||||
case DAHDI_EVENT_TIMER_EXPIRED:
|
||||
return "TIMER_EXPIRED";
|
||||
case DAHDI_EVENT_TIMER_PING:
|
||||
return "TIMER_PING";
|
||||
case DAHDI_EVENT_POLARITY:
|
||||
return "POLARITY";
|
||||
}
|
||||
return "Unknown event";
|
||||
}
|
||||
@ -144,13 +172,20 @@ static inline char *event2str(int event)
|
||||
static inline char *hookstate2str(int hookstate)
|
||||
{
|
||||
switch (hookstate) {
|
||||
case DAHDI_ONHOOK: return "DAHDI_ONHOOK";
|
||||
case DAHDI_START: return "DAHDI_START";
|
||||
case DAHDI_OFFHOOK: return "DAHDI_OFFHOOK";
|
||||
case DAHDI_WINK: return "DAHDI_WINK";
|
||||
case DAHDI_FLASH: return "DAHDI_FLASH";
|
||||
case DAHDI_RING: return "DAHDI_RING";
|
||||
case DAHDI_RINGOFF: return "DAHDI_RINGOFF";
|
||||
case DAHDI_ONHOOK:
|
||||
return "DAHDI_ONHOOK";
|
||||
case DAHDI_START:
|
||||
return "DAHDI_START";
|
||||
case DAHDI_OFFHOOK:
|
||||
return "DAHDI_OFFHOOK";
|
||||
case DAHDI_WINK:
|
||||
return "DAHDI_WINK";
|
||||
case DAHDI_FLASH:
|
||||
return "DAHDI_FLASH";
|
||||
case DAHDI_RING:
|
||||
return "DAHDI_RING";
|
||||
case DAHDI_RINGOFF:
|
||||
return "DAHDI_RINGOFF";
|
||||
}
|
||||
return "Unknown hookstate";
|
||||
}
|
||||
@ -159,25 +194,42 @@ static inline char *hookstate2str(int hookstate)
|
||||
static inline char *sig2str(int sig)
|
||||
{
|
||||
switch (sig) {
|
||||
case DAHDI_SIG_FXSLS: return "FXSLS";
|
||||
case DAHDI_SIG_FXSKS: return "FXSKS";
|
||||
case DAHDI_SIG_FXSGS: return "FXSGS";
|
||||
case DAHDI_SIG_FXOLS: return "FXOLS";
|
||||
case DAHDI_SIG_FXOKS: return "FXOKS";
|
||||
case DAHDI_SIG_FXOGS: return "FXOGS";
|
||||
case DAHDI_SIG_EM: return "E&M";
|
||||
case DAHDI_SIG_EM_E1: return "E&M-E1";
|
||||
case DAHDI_SIG_CLEAR: return "Clear";
|
||||
case DAHDI_SIG_HDLCRAW: return "HDLCRAW";
|
||||
case DAHDI_SIG_HDLCFCS: return "HDLCFCS";
|
||||
case DAHDI_SIG_HDLCNET: return "HDLCNET";
|
||||
case DAHDI_SIG_SLAVE: return "Slave";
|
||||
case DAHDI_SIG_CAS: return "CAS";
|
||||
case DAHDI_SIG_DACS: return "DACS";
|
||||
case DAHDI_SIG_DACS_RBS: return "DACS+RBS";
|
||||
case DAHDI_SIG_SF: return "SF (ToneOnly)";
|
||||
case DAHDI_SIG_NONE:
|
||||
break;
|
||||
case DAHDI_SIG_FXSLS:
|
||||
return "FXSLS";
|
||||
case DAHDI_SIG_FXSKS:
|
||||
return "FXSKS";
|
||||
case DAHDI_SIG_FXSGS:
|
||||
return "FXSGS";
|
||||
case DAHDI_SIG_FXOLS:
|
||||
return "FXOLS";
|
||||
case DAHDI_SIG_FXOKS:
|
||||
return "FXOKS";
|
||||
case DAHDI_SIG_FXOGS:
|
||||
return "FXOGS";
|
||||
case DAHDI_SIG_EM:
|
||||
return "E&M";
|
||||
case DAHDI_SIG_EM_E1:
|
||||
return "E&M-E1";
|
||||
case DAHDI_SIG_CLEAR:
|
||||
return "Clear";
|
||||
case DAHDI_SIG_HDLCRAW:
|
||||
return "HDLCRAW";
|
||||
case DAHDI_SIG_HDLCFCS:
|
||||
return "HDLCFCS";
|
||||
case DAHDI_SIG_HDLCNET:
|
||||
return "HDLCNET";
|
||||
case DAHDI_SIG_SLAVE:
|
||||
return "Slave";
|
||||
case DAHDI_SIG_CAS:
|
||||
return "CAS";
|
||||
case DAHDI_SIG_DACS:
|
||||
return "DACS";
|
||||
case DAHDI_SIG_DACS_RBS:
|
||||
return "DACS+RBS";
|
||||
case DAHDI_SIG_SF:
|
||||
return "SF (ToneOnly)";
|
||||
case DAHDI_SIG_NONE:
|
||||
break;
|
||||
}
|
||||
return "Unconfigured";
|
||||
}
|
||||
@ -186,17 +238,24 @@ static inline char *alarmbit2str(int alarmbit)
|
||||
{
|
||||
/* from dahdi/kernel.h */
|
||||
switch (1 << alarmbit) {
|
||||
case DAHDI_ALARM_NONE: return "NONE";
|
||||
case DAHDI_ALARM_RECOVER: return "RECOVER";
|
||||
case DAHDI_ALARM_LOOPBACK: return "LOOPBACK";
|
||||
case DAHDI_ALARM_YELLOW: return "YELLOW";
|
||||
case DAHDI_ALARM_RED: return "RED";
|
||||
case DAHDI_ALARM_BLUE: return "BLUE";
|
||||
case DAHDI_ALARM_NOTOPEN: return "NOTOPEN";
|
||||
case DAHDI_ALARM_NONE:
|
||||
return "NONE";
|
||||
case DAHDI_ALARM_RECOVER:
|
||||
return "RECOVER";
|
||||
case DAHDI_ALARM_LOOPBACK:
|
||||
return "LOOPBACK";
|
||||
case DAHDI_ALARM_YELLOW:
|
||||
return "YELLOW";
|
||||
case DAHDI_ALARM_RED:
|
||||
return "RED";
|
||||
case DAHDI_ALARM_BLUE:
|
||||
return "BLUE";
|
||||
case DAHDI_ALARM_NOTOPEN:
|
||||
return "NOTOPEN";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
void alarm2str(int alarm, char *buf, int buflen);
|
||||
|
||||
#endif /* DAHDI_DEBUG_H */
|
||||
#endif /* DAHDI_DEBUG_H */
|
||||
|
@ -7,7 +7,9 @@ static int mmap_match(struct device *dev, struct device_driver *driver)
|
||||
{
|
||||
return !strncmp(dev_name(dev), driver->name, strlen(driver->name));
|
||||
}
|
||||
static int mmap_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
|
||||
|
||||
static int mmap_uevent(struct device *dev, char **envp, int num_envp,
|
||||
char *buffer, int buffer_size)
|
||||
{
|
||||
envp[0] = buffer;
|
||||
envp[1] = NULL;
|
||||
@ -33,8 +35,6 @@ static struct device mmap_bus = {
|
||||
.release = mmap_bus_release,
|
||||
};
|
||||
|
||||
|
||||
|
||||
int register_mmap_device(struct mmap_device *dev)
|
||||
{
|
||||
dev->dev.bus = &mmap_bus_type;
|
||||
@ -48,6 +48,7 @@ void unregister_mmap_device(struct mmap_device *dev)
|
||||
{
|
||||
device_unregister(&dev->dev);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(register_mmap_device);
|
||||
EXPORT_SYMBOL(unregister_mmap_device);
|
||||
|
||||
@ -61,6 +62,7 @@ void unregister_mmap_driver(struct mmap_driver *driver)
|
||||
{
|
||||
driver_unregister(&driver->driver);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(register_mmap_driver);
|
||||
EXPORT_SYMBOL(unregister_mmap_driver);
|
||||
|
||||
@ -84,6 +86,7 @@ void unregister_mmap_bus(void)
|
||||
device_unregister(&mmap_bus);
|
||||
bus_unregister(&mmap_bus_type);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(register_mmap_bus);
|
||||
EXPORT_SYMBOL(unregister_mmap_bus);
|
||||
|
||||
|
@ -19,11 +19,13 @@
|
||||
#include "xframe_queue.h"
|
||||
|
||||
/* Check at compile time that sizeof(xframe_t) is a multiple of 4 */
|
||||
typedef char sizeof_xframe_t_should_be_divisible_by_4[((sizeof(xframe_t) % 4) == 0) * 2 - 1];
|
||||
typedef char
|
||||
sizeof_xframe_t_should_be_divisible_by_4[((sizeof(xframe_t) % 4) ==
|
||||
0) * 2 - 1];
|
||||
|
||||
#define ssync() __builtin_bfin_ssync()
|
||||
|
||||
//#define AB_IN_BUF PF5
|
||||
//#define AB_IN_BUF PF5
|
||||
/* firmware pins */
|
||||
#define DATA PG8
|
||||
#define NCONFIG PG9
|
||||
@ -39,7 +41,7 @@ typedef char sizeof_xframe_t_should_be_divisible_by_4[((sizeof(xframe_t) % 4) ==
|
||||
#define DEBUG_GPIO1 CONF_DONE
|
||||
#define DEBUG_GPIO2 NSTATUS
|
||||
|
||||
static int rx_intr_counter;
|
||||
static int rx_intr_counter;
|
||||
#endif
|
||||
|
||||
#define FPGA_RX_IRQ IRQ_PF7
|
||||
@ -49,9 +51,9 @@ static int rx_intr_counter;
|
||||
#define END_OF_FRAME 0x0001
|
||||
#define GET_LEN 0x0002
|
||||
#define START_RD_BURST 0x0008
|
||||
#define AS_BF_MODE 0x0010 //stand alone Astribank without USB (Asterisk BlackFin Mode)
|
||||
#define EC_BF_MODE 0x0020 //all data between Astribank and USB routed thru BF(EchoCanceler BlackFin Mode)
|
||||
#define NO_BF_MODE 0x0040 //Astribank worke with USB only (no BlackFin Mode)
|
||||
#define AS_BF_MODE 0x0010 //stand alone Astribank without USB (Asterisk BlackFin Mode)
|
||||
#define EC_BF_MODE 0x0020 //all data between Astribank and USB routed thru BF(EchoCanceler BlackFin Mode)
|
||||
#define NO_BF_MODE 0x0040 //Astribank worke with USB only (no BlackFin Mode)
|
||||
#define SET_XA_DIR 0x0080
|
||||
#define GET_XPD_STS 0x0100
|
||||
#define GET_CHECKSUM 0x0200
|
||||
@ -96,7 +98,8 @@ static void update_counter(struct counter *c, struct timeval *tv1)
|
||||
c->intr_min = diff;
|
||||
if (c->intr_max < diff)
|
||||
c->intr_max = diff;
|
||||
c->intr_avg = (c->intr_avg*c->intr_count + diff) / (c->intr_count+1);
|
||||
c->intr_avg =
|
||||
(c->intr_avg * c->intr_count + diff) / (c->intr_count + 1);
|
||||
c->intr_count++;
|
||||
}
|
||||
|
||||
@ -153,18 +156,19 @@ static irqreturn_t xpp_mmap_rx_irq(int irq, void *dev_id)
|
||||
outw(START_RD_BURST, FPGA_BASE_ADDR + 4);
|
||||
insw((unsigned long)FPGA_BASE_ADDR, buf, rxcnt / 2);
|
||||
#if 0
|
||||
for (count = 0; count < rxcnt; count+=2) {
|
||||
for (count = 0; count < rxcnt; count += 2) {
|
||||
unsigned short v = inw(FPGA_BASE_ADDR);
|
||||
buf[count] = v & 0xFF;
|
||||
buf[count+1] = v >> 8;
|
||||
buf[count + 1] = v >> 8;
|
||||
}
|
||||
#endif
|
||||
if (rxcnt & 1)
|
||||
buf[rxcnt-1] = inw(FPGA_BASE_ADDR);
|
||||
buf[rxcnt - 1] = inw(FPGA_BASE_ADDR);
|
||||
/* Sanity check: length of first packet in frame should be no more than the frame length */
|
||||
if (((buf[0] | (buf[1]<<8)) & 0x3FF) > rxcnt) {
|
||||
if (((buf[0] | (buf[1] << 8)) & 0x3FF) > rxcnt) {
|
||||
if (printk_ratelimit()) {
|
||||
ERR("Packet len=%d, frame len=%d\n", (buf[0] | (buf[1]<<8)) & 0x3FF, rxcnt);
|
||||
ERR("Packet len=%d, frame len=%d\n",
|
||||
(buf[0] | (buf[1] << 8)) & 0x3FF, rxcnt);
|
||||
print_buffer("16 bytes of packet: ", buf, 16);
|
||||
}
|
||||
goto free;
|
||||
@ -199,7 +203,7 @@ static void send_buffer(unsigned char *buf, unsigned long len)
|
||||
print_buffer("Sent: ", buf, len);
|
||||
outsw((unsigned long)FPGA_BASE_ADDR, buf, len / 2);
|
||||
if (len & 1)
|
||||
outw((unsigned short)buf[len-1], FPGA_BASE_ADDR);
|
||||
outw((unsigned short)buf[len - 1], FPGA_BASE_ADDR);
|
||||
outw(END_OF_FRAME, FPGA_BASE_ADDR + 4);
|
||||
}
|
||||
|
||||
@ -258,7 +262,9 @@ static int xframe_send_common(xbus_t *xbus, xframe_t *xframe, bool pcm)
|
||||
if (pcm && pcm_in_pool_count >= 1) {
|
||||
static int rate_limit;
|
||||
if ((rate_limit++ % 1000) == 0)
|
||||
XBUS_ERR(xbus, "Dropped PCM xframe (pcm_in_pool_count=%d).\n", pcm_in_pool_count);
|
||||
XBUS_ERR(xbus,
|
||||
"Dropped PCM xframe (pcm_in_pool_count=%d).\n",
|
||||
pcm_in_pool_count);
|
||||
FREE_SEND_XFRAME(xbus, xframe);
|
||||
pcm_dropped++;
|
||||
} else {
|
||||
@ -266,7 +272,8 @@ static int xframe_send_common(xbus_t *xbus, xframe_t *xframe, bool pcm)
|
||||
static int rate_limit;
|
||||
spin_unlock_irqrestore(&tx_ready_lock, flags);
|
||||
if ((rate_limit++ % 1000) == 0)
|
||||
XBUS_ERR(xbus, "Dropped xframe. Cannot enqueue.\n");
|
||||
XBUS_ERR(xbus,
|
||||
"Dropped xframe. Cannot enqueue.\n");
|
||||
FREE_SEND_XFRAME(xbus, xframe);
|
||||
return -E2BIG;
|
||||
}
|
||||
@ -284,10 +291,12 @@ static xframe_t *alloc_xframe(xbus_t *xbus, gfp_t gfp_flags)
|
||||
if (!xframe) {
|
||||
static int rate_limit;
|
||||
if ((rate_limit++ % 1000) < 5)
|
||||
XBUS_ERR(xbus, "frame allocation failed (%d)\n", rate_limit);
|
||||
XBUS_ERR(xbus, "frame allocation failed (%d)\n",
|
||||
rate_limit);
|
||||
return NULL;
|
||||
}
|
||||
xframe_init(xbus, xframe, ((__u8*)xframe) + sizeof(xframe_t), XFRAME_DATASIZE, xbus);
|
||||
xframe_init(xbus, xframe, ((__u8 *)xframe) + sizeof(xframe_t),
|
||||
XFRAME_DATASIZE, xbus);
|
||||
return xframe;
|
||||
}
|
||||
|
||||
@ -316,28 +325,26 @@ static struct xbus_ops xmmap_ops = {
|
||||
|
||||
static int fill_proc_queue(char *p, struct xframe_queue *q)
|
||||
{
|
||||
int len;
|
||||
int len;
|
||||
|
||||
len = sprintf(p,
|
||||
"%-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02ld.%ld ms\n",
|
||||
q->name,
|
||||
q->steady_state_count,
|
||||
q->count,
|
||||
q->max_count,
|
||||
q->worst_count,
|
||||
q->overflows,
|
||||
q->worst_lag_usec / 1000,
|
||||
q->worst_lag_usec % 1000);
|
||||
len =
|
||||
sprintf(p,
|
||||
"%-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02ld.%ld ms\n",
|
||||
q->name, q->steady_state_count, q->count, q->max_count,
|
||||
q->worst_count, q->overflows, q->worst_lag_usec / 1000,
|
||||
q->worst_lag_usec % 1000);
|
||||
xframe_queue_clearstats(q);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int fill_proc_counter(char *p, struct counter *c)
|
||||
{
|
||||
return sprintf(p, "min=%ld\nmax=%ld\navg=%ld\ncount=%ld\n", c->intr_min, c->intr_max, c->intr_avg, c->intr_count);
|
||||
return sprintf(p, "min=%ld\nmax=%ld\navg=%ld\ncount=%ld\n", c->intr_min,
|
||||
c->intr_max, c->intr_avg, c->intr_count);
|
||||
}
|
||||
|
||||
static int xpp_mmap_proc_read(char *page, char **start, off_t off, int count, int *eof, void *data)
|
||||
static int xpp_mmap_proc_read(char *page, char **start, off_t off, int count,
|
||||
int *eof, void *data)
|
||||
{
|
||||
int len = 0;
|
||||
len += fill_proc_queue(page + len, &txpool);
|
||||
@ -347,7 +354,7 @@ static int xpp_mmap_proc_read(char *page, char **start, off_t off, int count, in
|
||||
len += fill_proc_counter(page + len, &rx_counter);
|
||||
len += sprintf(page + len, "\ntx_counter:\n");
|
||||
len += fill_proc_counter(page + len, &tx_counter);
|
||||
if (len <= off+count) {
|
||||
if (len <= off + count) {
|
||||
*eof = 1;
|
||||
tx_counter.intr_min = rx_counter.intr_min = INT_MAX;
|
||||
tx_counter.intr_max = rx_counter.intr_max = 0;
|
||||
@ -363,14 +370,15 @@ static int xpp_mmap_proc_read(char *page, char **start, off_t off, int count, in
|
||||
return len;
|
||||
}
|
||||
|
||||
static int xpp_mmap_proc_write(struct file *file, const char __user *buffer, unsigned long count, void *data)
|
||||
static int xpp_mmap_proc_write(struct file *file, const char __user *buffer,
|
||||
unsigned long count, void *data)
|
||||
{
|
||||
int i = 0;
|
||||
char *txchunk, *p, *endp;
|
||||
|
||||
if (count >= XFRAME_DATASIZE*3+10)
|
||||
if (count >= XFRAME_DATASIZE * 3 + 10)
|
||||
return -EINVAL;
|
||||
p = txchunk = kmalloc(count+1, GFP_KERNEL);
|
||||
p = txchunk = kmalloc(count + 1, GFP_KERNEL);
|
||||
if (copy_from_user(txchunk, buffer, count)) {
|
||||
count = -EFAULT;
|
||||
goto out;
|
||||
@ -379,13 +387,15 @@ static int xpp_mmap_proc_write(struct file *file, const char __user *buffer, uns
|
||||
|
||||
while (*p) {
|
||||
unsigned long value;
|
||||
while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') p++;
|
||||
if (*p == '\0') break;
|
||||
while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r')
|
||||
p++;
|
||||
if (*p == '\0')
|
||||
break;
|
||||
value = simple_strtoul(p, &endp, 16);
|
||||
if (endp == p || value > 0xFF) {
|
||||
INFO("%s: Bad input\n", __func__);
|
||||
count = -EINVAL;
|
||||
goto out;
|
||||
INFO("%s: Bad input\n", __func__);
|
||||
count = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
p = endp;
|
||||
txchunk[i++] = (char)value;
|
||||
@ -399,8 +409,8 @@ out:
|
||||
static struct mmap_driver astribank_driver = {
|
||||
.module = THIS_MODULE,
|
||||
.driver = {
|
||||
.name = "xpp_mmap",
|
||||
},
|
||||
.name = "xpp_mmap",
|
||||
},
|
||||
};
|
||||
|
||||
static struct mmap_device astribank_dev = {
|
||||
@ -408,42 +418,43 @@ static struct mmap_device astribank_dev = {
|
||||
.driver = &astribank_driver,
|
||||
};
|
||||
|
||||
static int __init xpp_mmap_load_fpga(u8 *data, size_t size)
|
||||
static int __init xpp_mmap_load_fpga(u8 * data, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() | DATA | NCONFIG | DCLK); //set data, nconfig and dclk to port out
|
||||
bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() | DATA | NCONFIG | DCLK); //set data, nconfig and dclk to port out
|
||||
bfin_write_PORTG_FER(bfin_read_PORTG_FER() & ~(DATA | NCONFIG | DCLK));
|
||||
bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() & ~(CONF_DONE | NSTATUS));//set conf_done and nstatus to port in
|
||||
bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() & ~(DATA | NCONFIG | DCLK));
|
||||
bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() & ~(CONF_DONE | NSTATUS)); //set conf_done and nstatus to port in
|
||||
bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() &
|
||||
~(DATA | NCONFIG | DCLK));
|
||||
bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() | CONF_DONE | NSTATUS);
|
||||
|
||||
bfin_write_PORTGIO_CLEAR(NCONFIG); //reset fpga during configuration holds nCONFIG low
|
||||
udelay(40); //Tcfg ~40us delay
|
||||
bfin_write_PORTGIO_SET(NCONFIG); //transition nCONFIG to high - reset end.
|
||||
udelay(40); //Tcf2ck ~40us delay
|
||||
bfin_write_PORTGIO_CLEAR(NCONFIG); //reset fpga during configuration holds nCONFIG low
|
||||
udelay(40); //Tcfg ~40us delay
|
||||
bfin_write_PORTGIO_SET(NCONFIG); //transition nCONFIG to high - reset end.
|
||||
udelay(40); //Tcf2ck ~40us delay
|
||||
if (!(bfin_read_PORTGIO() & NSTATUS))
|
||||
return -EIO; //report reset faill - Tcf2st1 pass
|
||||
return -EIO; //report reset faill - Tcf2st1 pass
|
||||
|
||||
#if 0
|
||||
if (!(bfin_read_PORTGIO() & CONF_DONE))
|
||||
return -EIO;
|
||||
#endif
|
||||
bfin_write_PORTGIO_CLEAR(DCLK);
|
||||
for (i=0; i<size; i++) { // loop EP2OUT buffer data to FPGA
|
||||
for (i = 0; i < size; i++) { // loop EP2OUT buffer data to FPGA
|
||||
int j;
|
||||
u8 __u8 = data[i];
|
||||
for (j=0; j<8; j++) //send the configuration data through the DATA0 pin one bit at a time.
|
||||
for (j = 0; j < 8; j++) //send the configuration data through the DATA0 pin one bit at a time.
|
||||
{
|
||||
if (__u8 & 1)
|
||||
if (__u8 &1)
|
||||
bfin_write_PORTGIO_SET(DATA);
|
||||
else
|
||||
bfin_write_PORTGIO_CLEAR(DATA);
|
||||
__u8 >>= 1;
|
||||
__u8 >>=1;
|
||||
bfin_write_PORTGIO_SET(DCLK);
|
||||
bfin_write_PORTGIO_CLEAR(DCLK);
|
||||
}
|
||||
if (!(bfin_read_PORTGIO() & NSTATUS))
|
||||
return -EIO; //check the nSTATUS
|
||||
return -EIO; //check the nSTATUS
|
||||
}
|
||||
bfin_write_PORTGIO_CLEAR(DATA);
|
||||
udelay(1);
|
||||
@ -455,20 +466,22 @@ static int __init xpp_mmap_load_fpga(u8 *data, size_t size)
|
||||
* some pins that were used only during initialization
|
||||
* to be used for debugging from now on.
|
||||
*/
|
||||
bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() | DEBUG_GPIO1 | DEBUG_GPIO2); //set to port out
|
||||
bfin_write_PORTG_FER(bfin_read_PORTG_FER() & ~(DEBUG_GPIO1 | DEBUG_GPIO2));
|
||||
bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() & ~(DEBUG_GPIO1 | DEBUG_GPIO2));
|
||||
bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() | DEBUG_GPIO1 | DEBUG_GPIO2); //set to port out
|
||||
bfin_write_PORTG_FER(bfin_read_PORTG_FER() &
|
||||
~(DEBUG_GPIO1 | DEBUG_GPIO2));
|
||||
bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() &
|
||||
~(DEBUG_GPIO1 | DEBUG_GPIO2));
|
||||
#endif
|
||||
udelay(40); //tCD2UM - CONF_DONE high to user mode
|
||||
udelay(40); //tCD2UM - CONF_DONE high to user mode
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit xpp_mmap_unload_fpga(void)
|
||||
{
|
||||
bfin_write_PORTGIO_CLEAR(NCONFIG); //reset fpga during configuration holds nCONFIG low
|
||||
udelay(40); //Tcfg ~40us delay
|
||||
bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() & ~( DATA | NCONFIG | DCLK)); //disable output pin
|
||||
bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() & ~( CONF_DONE | NSTATUS));//disable input buffer
|
||||
bfin_write_PORTGIO_CLEAR(NCONFIG); //reset fpga during configuration holds nCONFIG low
|
||||
udelay(40); //Tcfg ~40us delay
|
||||
bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() & ~(DATA | NCONFIG | DCLK)); //disable output pin
|
||||
bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() & ~(CONF_DONE | NSTATUS)); //disable input buffer
|
||||
INFO("FPGA Firmware unloaded\n");
|
||||
}
|
||||
|
||||
@ -476,7 +489,8 @@ static int __init xpp_mmap_load_firmware(void)
|
||||
{
|
||||
const struct firmware *fw;
|
||||
int ret;
|
||||
if ((ret = request_firmware(&fw, "astribank.bin", &astribank_dev.dev)) < 0)
|
||||
if ((ret =
|
||||
request_firmware(&fw, "astribank.bin", &astribank_dev.dev)) < 0)
|
||||
return ret;
|
||||
xpp_mmap_load_fpga(fw->data, fw->size);
|
||||
release_firmware(fw);
|
||||
@ -499,27 +513,31 @@ static int __init xpp_mmap_init(void)
|
||||
goto fail_fw;
|
||||
}
|
||||
|
||||
if ((ret = request_irq(FPGA_RX_IRQ, xpp_mmap_rx_irq, IRQF_TRIGGER_RISING, "xpp_mmap_rx", NULL)) < 0) {
|
||||
if ((ret =
|
||||
request_irq(FPGA_RX_IRQ, xpp_mmap_rx_irq, IRQF_TRIGGER_RISING,
|
||||
"xpp_mmap_rx", NULL)) < 0) {
|
||||
ERR("Unable to attach to RX interrupt %d\n", FPGA_RX_IRQ);
|
||||
goto fail_irq_rx;
|
||||
}
|
||||
if ((ret = request_irq(FPGA_TX_IRQ, xpp_mmap_tx_irq, IRQF_TRIGGER_RISING, "xpp_mmap_tx", NULL)) < 0) {
|
||||
if ((ret =
|
||||
request_irq(FPGA_TX_IRQ, xpp_mmap_tx_irq, IRQF_TRIGGER_RISING,
|
||||
"xpp_mmap_tx", NULL)) < 0) {
|
||||
ERR("Unable to attach to TX interrupt %d\n", FPGA_TX_IRQ);
|
||||
goto fail_irq_tx;
|
||||
}
|
||||
if (!request_region((resource_size_t)FPGA_BASE_ADDR, 8, "xpp_mmap")) {
|
||||
if (!request_region((resource_size_t) FPGA_BASE_ADDR, 8, "xpp_mmap")) {
|
||||
ERR("Unable to request memory region at %p\n", FPGA_BASE_ADDR);
|
||||
goto fail_region;
|
||||
}
|
||||
outw(AS_BF_MODE, FPGA_BASE_ADDR + 4);
|
||||
|
||||
xframe_cache = kmem_cache_create("xframe_cache",
|
||||
sizeof(xframe_t) + XFRAME_DATASIZE,
|
||||
0, 0,
|
||||
xframe_cache =
|
||||
kmem_cache_create("xframe_cache",
|
||||
sizeof(xframe_t) + XFRAME_DATASIZE, 0, 0,
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
NULL);
|
||||
NULL);
|
||||
if (!xframe_cache) {
|
||||
ret = -ENOMEM;
|
||||
goto fail_cache;
|
||||
@ -534,7 +552,9 @@ static int __init xpp_mmap_init(void)
|
||||
strncpy(global_xbus->label, "mmap:0", LABEL_SIZE);
|
||||
|
||||
xframe_queue_init(&txpool, 10, 200, "mmap_txpool", global_xbus);
|
||||
if (!(proc_entry = create_proc_entry("xpp_mmap", 0, global_xbus->proc_xbus_dir))) {
|
||||
if (!
|
||||
(proc_entry =
|
||||
create_proc_entry("xpp_mmap", 0, global_xbus->proc_xbus_dir))) {
|
||||
ERR("create_proc_entry() failed\n");
|
||||
ret = -EINVAL;
|
||||
goto fail_proc;
|
||||
@ -552,7 +572,7 @@ fail_proc:
|
||||
fail_xbus:
|
||||
kmem_cache_destroy(xframe_cache);
|
||||
fail_cache:
|
||||
release_region((resource_size_t)FPGA_BASE_ADDR, 8);
|
||||
release_region((resource_size_t) FPGA_BASE_ADDR, 8);
|
||||
fail_region:
|
||||
free_irq(FPGA_TX_IRQ, NULL);
|
||||
fail_irq_tx:
|
||||
@ -579,7 +599,7 @@ static void __exit xpp_mmap_exit(void)
|
||||
xbus_disconnect(xbus);
|
||||
kmem_cache_destroy(xframe_cache);
|
||||
|
||||
release_region((resource_size_t)FPGA_BASE_ADDR, 8);
|
||||
release_region((resource_size_t) FPGA_BASE_ADDR, 8);
|
||||
free_irq(FPGA_RX_IRQ, NULL);
|
||||
free_irq(FPGA_TX_IRQ, NULL);
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
||||
# warning "This module is tested only with 2.6 kernels"
|
||||
#warning "This module is tested only with 2.6 kernels"
|
||||
#endif
|
||||
|
||||
#include <linux/kernel.h>
|
||||
@ -30,21 +30,21 @@
|
||||
#include <linux/parport.h>
|
||||
#include "parport_debug.h"
|
||||
|
||||
static struct parport *debug_sync_parport;
|
||||
static int parport_toggles[8]; /* 8 bit flip-flop */
|
||||
static struct parport *debug_sync_parport;
|
||||
static int parport_toggles[8]; /* 8 bit flip-flop */
|
||||
|
||||
void flip_parport_bit(unsigned char bitnum)
|
||||
{
|
||||
static unsigned char last_value;
|
||||
static unsigned char last_value;
|
||||
DEFINE_SPINLOCK(lock);
|
||||
unsigned long flags;
|
||||
unsigned char mask;
|
||||
unsigned char value;
|
||||
unsigned long flags;
|
||||
unsigned char mask;
|
||||
unsigned char value;
|
||||
|
||||
if (!debug_sync_parport) {
|
||||
if (printk_ratelimit()) {
|
||||
printk(KERN_NOTICE "%s: no debug parallel port\n",
|
||||
THIS_MODULE->name);
|
||||
THIS_MODULE->name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -59,14 +59,16 @@ void flip_parport_bit(unsigned char bitnum)
|
||||
spin_unlock_irqrestore(&lock, flags);
|
||||
parport_write_data(debug_sync_parport, value);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(flip_parport_bit);
|
||||
|
||||
static void parport_attach(struct parport *port)
|
||||
{
|
||||
printk(KERN_INFO "%s: Using %s for debugging\n", THIS_MODULE->name, port->name);
|
||||
printk(KERN_INFO "%s: Using %s for debugging\n", THIS_MODULE->name,
|
||||
port->name);
|
||||
if (debug_sync_parport) {
|
||||
printk(KERN_ERR "%s: Using %s, ignore new attachment %s\n",
|
||||
THIS_MODULE->name, debug_sync_parport->name, port->name);
|
||||
THIS_MODULE->name, debug_sync_parport->name, port->name);
|
||||
return;
|
||||
}
|
||||
parport_get_port(port);
|
||||
@ -78,14 +80,14 @@ static void parport_detach(struct parport *port)
|
||||
printk(KERN_INFO "%s: Releasing %s\n", THIS_MODULE->name, port->name);
|
||||
if (debug_sync_parport != port) {
|
||||
printk(KERN_ERR "%s: Using %s, ignore new detachment %s\n",
|
||||
THIS_MODULE->name, debug_sync_parport->name, port->name);
|
||||
THIS_MODULE->name, debug_sync_parport->name, port->name);
|
||||
return;
|
||||
}
|
||||
parport_put_port(debug_sync_parport);
|
||||
debug_sync_parport = NULL;
|
||||
}
|
||||
|
||||
static struct parport_driver debug_parport_driver = {
|
||||
static struct parport_driver debug_parport_driver = {
|
||||
.name = "parport_debug",
|
||||
.attach = parport_attach,
|
||||
.detach = parport_detach,
|
||||
@ -93,7 +95,7 @@ static struct parport_driver debug_parport_driver = {
|
||||
|
||||
int __init parallel_dbg_init(void)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
ret = parport_register_driver(&debug_parport_driver);
|
||||
return ret;
|
||||
|
@ -28,4 +28,4 @@ void flip_parport_bit(unsigned char bitnum);
|
||||
#define flip_parport_bit(bitnum)
|
||||
#endif
|
||||
|
||||
#endif /* PARPORT_DEBUG_H */
|
||||
#endif /* PARPORT_DEBUG_H */
|
||||
|
@ -4,10 +4,11 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i=0; i<(sizeof(fxo_modes)/sizeof(struct fxo_mode)); i++) {
|
||||
if (fxo_modes[i].name == NULL) break;
|
||||
int reg16=0, reg26=0, reg30=0, reg31=0x20;
|
||||
char ring_osc[BUFSIZ]="", ring_x[BUFSIZ] = "";
|
||||
for (i = 0; i < (sizeof(fxo_modes) / sizeof(struct fxo_mode)); i++) {
|
||||
if (fxo_modes[i].name == NULL)
|
||||
break;
|
||||
int reg16 = 0, reg26 = 0, reg30 = 0, reg31 = 0x20;
|
||||
char ring_osc[BUFSIZ] = "", ring_x[BUFSIZ] = "";
|
||||
|
||||
reg16 |= (fxo_modes[i].ohs << 6);
|
||||
reg16 |= (fxo_modes[i].rz << 1);
|
||||
@ -22,11 +23,15 @@ int main(int argc, char *argv[])
|
||||
reg31 |= (fxo_modes[i].ohs2 << 3);
|
||||
|
||||
if (fxo_modes[i].ring_osc)
|
||||
snprintf(ring_osc, BUFSIZ, "ring_osc=%04X", fxo_modes[i].ring_osc);
|
||||
snprintf(ring_osc, BUFSIZ, "ring_osc=%04X",
|
||||
fxo_modes[i].ring_osc);
|
||||
if (fxo_modes[i].ring_x)
|
||||
snprintf(ring_x, BUFSIZ, "ring_x=%04X", fxo_modes[i].ring_x);
|
||||
printf("%-15s\treg16=%02X\treg26=%02X\treg30=%02X\treg31=%02X\t%s\t%s\n",
|
||||
fxo_modes[i].name, reg16, reg26, reg30, reg31, ring_osc, ring_x);
|
||||
snprintf(ring_x, BUFSIZ, "ring_x=%04X",
|
||||
fxo_modes[i].ring_x);
|
||||
printf
|
||||
("%-15s\treg16=%02X\treg26=%02X\treg30=%02X\treg31=%02X\t%s\t%s\n",
|
||||
fxo_modes[i].name, reg16, reg26, reg30, reg31, ring_osc,
|
||||
ring_x);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,10 +39,10 @@ struct xbus_workqueue;
|
||||
#ifdef __KERNEL__
|
||||
|
||||
struct xbus_ops {
|
||||
int (*xframe_send_pcm)(xbus_t *xbus, xframe_t *xframe);
|
||||
int (*xframe_send_cmd)(xbus_t *xbus, xframe_t *xframe);
|
||||
xframe_t *(*alloc_xframe)(xbus_t *xbus, gfp_t gfp_flags);
|
||||
void (*free_xframe)(xbus_t *xbus, xframe_t *xframe);
|
||||
int (*xframe_send_pcm) (xbus_t *xbus, xframe_t *xframe);
|
||||
int (*xframe_send_cmd) (xbus_t *xbus, xframe_t *xframe);
|
||||
xframe_t *(*alloc_xframe) (xbus_t *xbus, gfp_t gfp_flags);
|
||||
void (*free_xframe) (xbus_t *xbus, xframe_t *xframe);
|
||||
};
|
||||
|
||||
/*
|
||||
@ -67,19 +67,11 @@ enum {
|
||||
|
||||
/* yucky, make an instance so we can size it... */
|
||||
static struct xbus_counters {
|
||||
char *name;
|
||||
char *name;
|
||||
} xbus_counters[] = {
|
||||
C_(UNITS),
|
||||
C_(TX_XFRAME_PCM),
|
||||
C_(RX_XFRAME_PCM),
|
||||
C_(TX_PACK_PCM),
|
||||
C_(RX_PACK_PCM),
|
||||
C_(TX_BYTES),
|
||||
C_(RX_BYTES),
|
||||
C_(TX_PCM_FRAG),
|
||||
C_(RX_CMD),
|
||||
C_(TX_CMD),
|
||||
};
|
||||
C_(UNITS), C_(TX_XFRAME_PCM), C_(RX_XFRAME_PCM), C_(TX_PACK_PCM),
|
||||
C_(RX_PACK_PCM), C_(TX_BYTES), C_(RX_BYTES),
|
||||
C_(TX_PCM_FRAG), C_(RX_CMD), C_(TX_CMD),};
|
||||
|
||||
#undef C_
|
||||
|
||||
@ -99,17 +91,17 @@ enum xbus_state {
|
||||
const char *xbus_statename(enum xbus_state st);
|
||||
|
||||
struct xbus_transport {
|
||||
struct xbus_ops *ops;
|
||||
void *priv;
|
||||
struct device *transport_device;
|
||||
ushort max_send_size;
|
||||
enum xbus_state xbus_state;
|
||||
unsigned long transport_flags;
|
||||
spinlock_t state_lock;
|
||||
atomic_t transport_refcount;
|
||||
wait_queue_head_t transport_unused;
|
||||
spinlock_t lock;
|
||||
char model_string[MAX_ENV_STR];
|
||||
struct xbus_ops *ops;
|
||||
void *priv;
|
||||
struct device *transport_device;
|
||||
ushort max_send_size;
|
||||
enum xbus_state xbus_state;
|
||||
unsigned long transport_flags;
|
||||
spinlock_t state_lock;
|
||||
atomic_t transport_refcount;
|
||||
wait_queue_head_t transport_unused;
|
||||
spinlock_t lock;
|
||||
char model_string[MAX_ENV_STR];
|
||||
};
|
||||
|
||||
#define MAX_SEND_SIZE(xbus) ((xbus)->transport.max_send_size)
|
||||
@ -127,15 +119,15 @@ void transportops_put(xbus_t *xbus);
|
||||
* Encapsulate all poll related data of a single xbus.
|
||||
*/
|
||||
struct xbus_workqueue {
|
||||
struct workqueue_struct *wq;
|
||||
struct work_struct xpds_init_work;
|
||||
bool xpds_init_done;
|
||||
struct list_head card_list;
|
||||
int num_units;
|
||||
int num_units_initialized;
|
||||
wait_queue_head_t wait_for_xpd_initialization;
|
||||
spinlock_t worker_lock;
|
||||
struct semaphore running_initialization;
|
||||
struct workqueue_struct *wq;
|
||||
struct work_struct xpds_init_work;
|
||||
bool xpds_init_done;
|
||||
struct list_head card_list;
|
||||
int num_units;
|
||||
int num_units_initialized;
|
||||
wait_queue_head_t wait_for_xpd_initialization;
|
||||
spinlock_t worker_lock;
|
||||
struct semaphore running_initialization;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -152,10 +144,10 @@ void put_xframe(struct xframe_queue *q, xframe_t *xframe);
|
||||
#define FREE_SEND_XFRAME(xbus, xframe) put_xframe(&(xbus)->send_pool, (xframe))
|
||||
#define FREE_RECV_XFRAME(xbus, xframe) put_xframe(&(xbus)->receive_pool, (xframe))
|
||||
|
||||
xbus_t *xbus_num(uint num);
|
||||
xbus_t *get_xbus(const char *msg, uint num);
|
||||
void put_xbus(const char *msg, xbus_t *xbus);
|
||||
int refcount_xbus(xbus_t *xbus);
|
||||
xbus_t *xbus_num(uint num);
|
||||
xbus_t *get_xbus(const char *msg, uint num);
|
||||
void put_xbus(const char *msg, xbus_t *xbus);
|
||||
int refcount_xbus(xbus_t *xbus);
|
||||
|
||||
/*
|
||||
* Echo canceller related data
|
||||
@ -163,17 +155,17 @@ int refcount_xbus(xbus_t *xbus);
|
||||
#define ECHO_TIMESLOTS 128
|
||||
|
||||
struct echoops {
|
||||
int (*ec_set)(xpd_t *xpd, int pos, bool on);
|
||||
int (*ec_get)(xpd_t *xpd, int pos);
|
||||
int (*ec_update)(xbus_t *xbus);
|
||||
void (*ec_dump)(xbus_t *xbus);
|
||||
int (*ec_set) (xpd_t *xpd, int pos, bool on);
|
||||
int (*ec_get) (xpd_t *xpd, int pos);
|
||||
int (*ec_update) (xbus_t *xbus);
|
||||
void (*ec_dump) (xbus_t *xbus);
|
||||
};
|
||||
|
||||
struct xbus_echo_state {
|
||||
const struct echoops *echoops;
|
||||
__u8 timeslots[ECHO_TIMESLOTS];
|
||||
int xpd_idx;
|
||||
struct device_attribute *da[MAX_XPDS];
|
||||
const struct echoops *echoops;
|
||||
__u8 timeslots[ECHO_TIMESLOTS];
|
||||
int xpd_idx;
|
||||
struct device_attribute *da[MAX_XPDS];
|
||||
};
|
||||
#define ECHOOPS(xbus) ((xbus)->echo_state.echoops)
|
||||
#define EC_METHOD(name, xbus) (ECHOOPS(xbus)->name)
|
||||
@ -183,126 +175,128 @@ struct xbus_echo_state {
|
||||
* An xbus is a transport layer for Xorcom Protocol commands
|
||||
*/
|
||||
struct xbus {
|
||||
char busname[XBUS_NAMELEN]; /* set by xbus_new() */
|
||||
char busname[XBUS_NAMELEN]; /* set by xbus_new() */
|
||||
|
||||
/* low-level bus drivers set these 2 fields */
|
||||
char connector[XBUS_DESCLEN];
|
||||
char label[LABEL_SIZE];
|
||||
__u8 revision; /* Protocol revision */
|
||||
struct xbus_transport transport;
|
||||
struct dahdi_device *ddev;
|
||||
char connector[XBUS_DESCLEN];
|
||||
char label[LABEL_SIZE];
|
||||
__u8 revision; /* Protocol revision */
|
||||
struct xbus_transport transport;
|
||||
struct dahdi_device *ddev;
|
||||
|
||||
int num;
|
||||
struct xpd *xpds[MAX_XPDS];
|
||||
struct xbus_echo_state echo_state;
|
||||
int num;
|
||||
struct xpd *xpds[MAX_XPDS];
|
||||
struct xbus_echo_state echo_state;
|
||||
|
||||
int command_tick_counter;
|
||||
int usec_nosend; /* Firmware flow control */
|
||||
struct xframe_queue command_queue;
|
||||
wait_queue_head_t command_queue_empty;
|
||||
int command_tick_counter;
|
||||
int usec_nosend; /* Firmware flow control */
|
||||
struct xframe_queue command_queue;
|
||||
wait_queue_head_t command_queue_empty;
|
||||
|
||||
struct xframe_queue send_pool; /* empty xframes for send */
|
||||
struct xframe_queue receive_pool; /* empty xframes for receive */
|
||||
struct xframe_queue send_pool; /* empty xframes for send */
|
||||
struct xframe_queue receive_pool; /* empty xframes for receive */
|
||||
|
||||
/* tasklet processing */
|
||||
struct xframe_queue receive_queue;
|
||||
struct tasklet_struct receive_tasklet;
|
||||
int cpu_rcv_intr[NR_CPUS];
|
||||
int cpu_rcv_tasklet[NR_CPUS];
|
||||
struct xframe_queue receive_queue;
|
||||
struct tasklet_struct receive_tasklet;
|
||||
int cpu_rcv_intr[NR_CPUS];
|
||||
int cpu_rcv_tasklet[NR_CPUS];
|
||||
|
||||
struct quirks {
|
||||
unsigned int has_fxo:1;
|
||||
unsigned int has_digital_span:1;
|
||||
} quirks;
|
||||
bool self_ticking;
|
||||
enum sync_mode sync_mode;
|
||||
} quirks;
|
||||
bool self_ticking;
|
||||
enum sync_mode sync_mode;
|
||||
/* Managed by low-level drivers: */
|
||||
enum sync_mode sync_mode_default;
|
||||
struct timer_list command_timer;
|
||||
unsigned int xbus_frag_count;
|
||||
struct xframe_queue pcm_tospan;
|
||||
enum sync_mode sync_mode_default;
|
||||
struct timer_list command_timer;
|
||||
unsigned int xbus_frag_count;
|
||||
struct xframe_queue pcm_tospan;
|
||||
|
||||
struct xpp_ticker ticker; /* for tick rate */
|
||||
struct xpp_drift drift; /* for tick offset */
|
||||
struct xpp_ticker ticker; /* for tick rate */
|
||||
struct xpp_drift drift; /* for tick offset */
|
||||
|
||||
atomic_t pcm_rx_counter;
|
||||
unsigned int global_counter;
|
||||
atomic_t pcm_rx_counter;
|
||||
unsigned int global_counter;
|
||||
|
||||
/* Device-Model */
|
||||
struct device astribank;
|
||||
struct device astribank;
|
||||
#define dev_to_xbus(dev) container_of(dev, struct xbus, astribank)
|
||||
struct kref kref;
|
||||
struct kref kref;
|
||||
#define kref_to_xbus(k) container_of(k, struct xbus, kref)
|
||||
|
||||
spinlock_t lock;
|
||||
spinlock_t lock;
|
||||
|
||||
/* PCM metrics */
|
||||
struct timeval last_tx_sync;
|
||||
struct timeval last_rx_sync;
|
||||
unsigned long max_tx_sync;
|
||||
unsigned long min_tx_sync;
|
||||
unsigned long max_rx_sync;
|
||||
unsigned long min_rx_sync;
|
||||
unsigned long max_rx_process; /* packet processing time (usec) */
|
||||
struct timeval last_tx_sync;
|
||||
struct timeval last_rx_sync;
|
||||
unsigned long max_tx_sync;
|
||||
unsigned long min_tx_sync;
|
||||
unsigned long max_rx_sync;
|
||||
unsigned long min_rx_sync;
|
||||
unsigned long max_rx_process; /* packet processing time (usec) */
|
||||
#ifdef SAMPLE_TICKS
|
||||
#define SAMPLE_SIZE 1000
|
||||
int sample_ticks[SAMPLE_SIZE];
|
||||
bool sample_running;
|
||||
int sample_pos;
|
||||
int sample_ticks[SAMPLE_SIZE];
|
||||
bool sample_running;
|
||||
int sample_pos;
|
||||
#endif
|
||||
|
||||
struct xbus_workqueue worker;
|
||||
struct xbus_workqueue worker;
|
||||
|
||||
/*
|
||||
* Sync adjustment
|
||||
*/
|
||||
int sync_adjustment;
|
||||
int sync_adjustment_offset;
|
||||
long pll_updated_at;
|
||||
int sync_adjustment;
|
||||
int sync_adjustment_offset;
|
||||
long pll_updated_at;
|
||||
|
||||
atomic_t num_xpds;
|
||||
atomic_t num_xpds;
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
struct proc_dir_entry *proc_xbus_dir;
|
||||
struct proc_dir_entry *proc_xbus_summary;
|
||||
struct proc_dir_entry *proc_xbus_dir;
|
||||
struct proc_dir_entry *proc_xbus_summary;
|
||||
#ifdef PROTOCOL_DEBUG
|
||||
struct proc_dir_entry *proc_xbus_command;
|
||||
struct proc_dir_entry *proc_xbus_command;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* statistics */
|
||||
int counters[XBUS_COUNTER_MAX];
|
||||
int counters[XBUS_COUNTER_MAX];
|
||||
};
|
||||
#endif
|
||||
|
||||
#define XFRAME_MAGIC 123456L
|
||||
|
||||
struct xframe {
|
||||
unsigned long xframe_magic;
|
||||
struct list_head frame_list;
|
||||
atomic_t frame_len;
|
||||
xbus_t *xbus;
|
||||
struct timeval tv_created;
|
||||
struct timeval tv_queued;
|
||||
struct timeval tv_submitted;
|
||||
struct timeval tv_received;
|
||||
unsigned long xframe_magic;
|
||||
struct list_head frame_list;
|
||||
atomic_t frame_len;
|
||||
xbus_t *xbus;
|
||||
struct timeval tv_created;
|
||||
struct timeval tv_queued;
|
||||
struct timeval tv_submitted;
|
||||
struct timeval tv_received;
|
||||
/* filled by transport layer */
|
||||
size_t frame_maxlen;
|
||||
__u8 *packets; /* max XFRAME_DATASIZE */
|
||||
__u8 *first_free;
|
||||
int usec_towait; /* prevent overflowing AB */
|
||||
void *priv;
|
||||
size_t frame_maxlen;
|
||||
__u8 *packets; /* max XFRAME_DATASIZE */
|
||||
__u8 *first_free;
|
||||
int usec_towait; /* prevent overflowing AB */
|
||||
void *priv;
|
||||
};
|
||||
|
||||
void xframe_init(xbus_t *xbus, xframe_t *xframe, void *buf, size_t maxsize, void *priv);
|
||||
void xframe_init(xbus_t *xbus, xframe_t *xframe, void *buf, size_t maxsize,
|
||||
void *priv);
|
||||
|
||||
#define XFRAME_LEN(frame) atomic_read(&(frame)->frame_len)
|
||||
|
||||
int xbus_core_init(void); /* Initializer */
|
||||
void xbus_core_shutdown(void); /* Terminator */
|
||||
int xbus_core_init(void); /* Initializer */
|
||||
void xbus_core_shutdown(void); /* Terminator */
|
||||
|
||||
/* Frame handling */
|
||||
void dump_xframe(const char msg[], const xbus_t *xbus, const xframe_t *xframe, int debug);
|
||||
void dump_xframe(const char msg[], const xbus_t *xbus, const xframe_t *xframe,
|
||||
int debug);
|
||||
int send_cmd_frame(xbus_t *xbus, xframe_t *xframe);
|
||||
|
||||
/*
|
||||
@ -320,39 +314,40 @@ xpacket_t *xframe_next_packet(xframe_t *xframe, int len);
|
||||
#define XBUS_UNIT(idx) ((idx) / MAX_SUBUNIT)
|
||||
#define XBUS_SUBUNIT(idx) ((idx) % MAX_SUBUNIT)
|
||||
|
||||
xpd_t *xpd_of(const xbus_t *xbus, int xpd_num);
|
||||
xpd_t *xpd_byaddr(const xbus_t *xbus, uint unit, uint subunit);
|
||||
int xbus_check_unique(xbus_t *xbus);
|
||||
bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate);
|
||||
bool xbus_setflags(xbus_t *xbus, int flagbit, bool on);
|
||||
xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size, struct device *transport_device, void *priv);
|
||||
void xbus_free(xbus_t *xbus);
|
||||
int xbus_connect(xbus_t *xbus);
|
||||
int xbus_activate(xbus_t *xbus);
|
||||
void xbus_deactivate(xbus_t *xbus);
|
||||
void xbus_disconnect(xbus_t *xbus);
|
||||
void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe);
|
||||
int xbus_process_worker(xbus_t *xbus);
|
||||
int waitfor_xpds(xbus_t *xbus, char *buf);
|
||||
xpd_t *xpd_of(const xbus_t *xbus, int xpd_num);
|
||||
xpd_t *xpd_byaddr(const xbus_t *xbus, uint unit, uint subunit);
|
||||
int xbus_check_unique(xbus_t *xbus);
|
||||
bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate);
|
||||
bool xbus_setflags(xbus_t *xbus, int flagbit, bool on);
|
||||
xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size,
|
||||
struct device *transport_device, void *priv);
|
||||
void xbus_free(xbus_t *xbus);
|
||||
int xbus_connect(xbus_t *xbus);
|
||||
int xbus_activate(xbus_t *xbus);
|
||||
void xbus_deactivate(xbus_t *xbus);
|
||||
void xbus_disconnect(xbus_t *xbus);
|
||||
void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe);
|
||||
int xbus_process_worker(xbus_t *xbus);
|
||||
int waitfor_xpds(xbus_t *xbus, char *buf);
|
||||
|
||||
int xbus_xpd_bind(xbus_t *xbus, xpd_t *xpd, int unit, int subunit);
|
||||
int xbus_xpd_unbind(xbus_t *xbus, xpd_t *xpd);
|
||||
int xbus_xpd_bind(xbus_t *xbus, xpd_t *xpd, int unit, int subunit);
|
||||
int xbus_xpd_unbind(xbus_t *xbus, xpd_t *xpd);
|
||||
|
||||
/* sysfs */
|
||||
int xpd_device_register(xbus_t *xbus, xpd_t *xpd);
|
||||
void xpd_device_unregister(xpd_t *xpd);
|
||||
int echocancel_xpd(xpd_t *xpd, int on);
|
||||
int xpd_device_register(xbus_t *xbus, xpd_t *xpd);
|
||||
void xpd_device_unregister(xpd_t *xpd);
|
||||
int echocancel_xpd(xpd_t *xpd, int on);
|
||||
|
||||
int xbus_is_registered(xbus_t *xbus);
|
||||
int xbus_register_dahdi_device(xbus_t *xbus);
|
||||
void xbus_unregister_dahdi_device(xbus_t *xbus);
|
||||
int xbus_is_registered(xbus_t *xbus);
|
||||
int xbus_register_dahdi_device(xbus_t *xbus);
|
||||
void xbus_unregister_dahdi_device(xbus_t *xbus);
|
||||
|
||||
int xpp_driver_init(void);
|
||||
void xpp_driver_exit(void);
|
||||
int xbus_sysfs_transport_create(xbus_t *xbus);
|
||||
void xbus_sysfs_transport_remove(xbus_t *xbus);
|
||||
int xbus_sysfs_create(xbus_t *xbus);
|
||||
void xbus_sysfs_remove(xbus_t *xbus);
|
||||
int xpp_driver_init(void);
|
||||
void xpp_driver_exit(void);
|
||||
int xbus_sysfs_transport_create(xbus_t *xbus);
|
||||
void xbus_sysfs_transport_remove(xbus_t *xbus);
|
||||
int xbus_sysfs_create(xbus_t *xbus);
|
||||
void xbus_sysfs_remove(xbus_t *xbus);
|
||||
|
||||
#ifdef OLD_HOTPLUG_SUPPORT_269
|
||||
/* Copy from new kernels lib/kobject_uevent.c */
|
||||
@ -367,7 +362,6 @@ enum kobject_action {
|
||||
};
|
||||
#endif
|
||||
|
||||
void astribank_uevent_send(xbus_t *xbus, enum kobject_action act);
|
||||
|
||||
#endif /* XBUS_CORE_H */
|
||||
void astribank_uevent_send(xbus_t *xbus, enum kobject_action act);
|
||||
|
||||
#endif /* XBUS_CORE_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -33,10 +33,10 @@
|
||||
#ifdef __KERNEL__
|
||||
|
||||
enum sync_mode {
|
||||
SYNC_MODE_NONE = 0x00,
|
||||
SYNC_MODE_AB = 0x01, /* Astribank sync */
|
||||
SYNC_MODE_PLL = 0x03, /* Adjust XPD's PLL according to HOST */
|
||||
SYNC_MODE_QUERY = 0x80,
|
||||
SYNC_MODE_NONE = 0x00,
|
||||
SYNC_MODE_AB = 0x01, /* Astribank sync */
|
||||
SYNC_MODE_PLL = 0x03, /* Adjust XPD's PLL according to HOST */
|
||||
SYNC_MODE_QUERY = 0x80,
|
||||
};
|
||||
|
||||
/*
|
||||
@ -46,7 +46,7 @@ enum sync_mode {
|
||||
* time representations.
|
||||
*/
|
||||
struct xpp_timestamp {
|
||||
struct timeval tv;
|
||||
struct timeval tv;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -58,12 +58,12 @@ struct xpp_timestamp {
|
||||
* from other dahdi devices).
|
||||
*/
|
||||
struct xpp_ticker { /* for rate calculation */
|
||||
int count;
|
||||
int cycle;
|
||||
struct xpp_timestamp first_sample;
|
||||
struct xpp_timestamp last_sample;
|
||||
int tick_period; /* usec/tick */
|
||||
spinlock_t lock;
|
||||
int count;
|
||||
int cycle;
|
||||
struct xpp_timestamp first_sample;
|
||||
struct xpp_timestamp last_sample;
|
||||
int tick_period; /* usec/tick */
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -71,66 +71,65 @@ struct xpp_ticker { /* for rate calculation */
|
||||
* xbus ticker to a reference ticker.
|
||||
*/
|
||||
struct xpp_drift {
|
||||
int delta_tick; /* from ref_ticker */
|
||||
int lost_ticks; /* occurances */
|
||||
int lost_tick_count;
|
||||
int sync_inaccuracy;
|
||||
struct xpp_timestamp last_lost_tick;
|
||||
long delta_sum;
|
||||
int offset_prev;
|
||||
int offset_range;
|
||||
int offset_min;
|
||||
int offset_max;
|
||||
int min_speed;
|
||||
int max_speed;
|
||||
spinlock_t lock;
|
||||
int delta_tick; /* from ref_ticker */
|
||||
int lost_ticks; /* occurances */
|
||||
int lost_tick_count;
|
||||
int sync_inaccuracy;
|
||||
struct xpp_timestamp last_lost_tick;
|
||||
long delta_sum;
|
||||
int offset_prev;
|
||||
int offset_range;
|
||||
int offset_min;
|
||||
int offset_max;
|
||||
int min_speed;
|
||||
int max_speed;
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
void xpp_drift_init(xbus_t *xbus);
|
||||
|
||||
static inline long usec_diff(const struct timeval *tv1, const struct timeval *tv2)
|
||||
static inline long usec_diff(const struct timeval *tv1,
|
||||
const struct timeval *tv2)
|
||||
{
|
||||
long diff_sec;
|
||||
long diff_usec;
|
||||
long diff_sec;
|
||||
long diff_usec;
|
||||
|
||||
diff_sec = tv1->tv_sec - tv2->tv_sec;
|
||||
diff_usec = tv1->tv_usec - tv2->tv_usec;
|
||||
return diff_sec * 1000000 + diff_usec;
|
||||
}
|
||||
|
||||
|
||||
int xbus_pcm_init(void *top);
|
||||
void xbus_pcm_shutdown(void);
|
||||
int send_pcm_frame(xbus_t *xbus, xframe_t *xframe);
|
||||
void pcm_recompute(xpd_t *xpd, xpp_line_t tmp_pcm_mask);
|
||||
void xframe_receive_pcm(xbus_t *xbus, xframe_t *xframe);
|
||||
void update_wanted_pcm_mask(xpd_t *xpd, xpp_line_t new_mask, uint new_pcm_len);
|
||||
void generic_card_pcm_recompute(xpd_t *xpd, xpp_line_t pcm_mask);
|
||||
void generic_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack);
|
||||
void generic_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack);
|
||||
int generic_timing_priority(xpd_t *xpd);
|
||||
int generic_echocancel_timeslot(xpd_t *xpd, int pos);
|
||||
int generic_echocancel_setmask(xpd_t *xpd, xpp_line_t ec_mask);
|
||||
void fill_beep(u_char *buf, int num, int duration);
|
||||
const char *sync_mode_name(enum sync_mode mode);
|
||||
void xbus_set_command_timer(xbus_t *xbus, bool on);
|
||||
void xbus_request_sync(xbus_t *xbus, enum sync_mode mode);
|
||||
void got_new_syncer(xbus_t *xbus, enum sync_mode mode, int drift);
|
||||
int xbus_command_queue_tick(xbus_t *xbus);
|
||||
void xbus_reset_counters(xbus_t *xbus);
|
||||
void elect_syncer(const char *msg);
|
||||
int exec_sync_command(const char *buf, size_t count);
|
||||
int fill_sync_string(char *buf, size_t count);
|
||||
int xbus_pcm_init(void *top);
|
||||
void xbus_pcm_shutdown(void);
|
||||
int send_pcm_frame(xbus_t *xbus, xframe_t *xframe);
|
||||
void pcm_recompute(xpd_t *xpd, xpp_line_t tmp_pcm_mask);
|
||||
void xframe_receive_pcm(xbus_t *xbus, xframe_t *xframe);
|
||||
void update_wanted_pcm_mask(xpd_t *xpd, xpp_line_t new_mask, uint new_pcm_len);
|
||||
void generic_card_pcm_recompute(xpd_t *xpd, xpp_line_t pcm_mask);
|
||||
void generic_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack);
|
||||
void generic_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack);
|
||||
int generic_timing_priority(xpd_t *xpd);
|
||||
int generic_echocancel_timeslot(xpd_t *xpd, int pos);
|
||||
int generic_echocancel_setmask(xpd_t *xpd, xpp_line_t ec_mask);
|
||||
void fill_beep(u_char *buf, int num, int duration);
|
||||
const char *sync_mode_name(enum sync_mode mode);
|
||||
void xbus_set_command_timer(xbus_t *xbus, bool on);
|
||||
void xbus_request_sync(xbus_t *xbus, enum sync_mode mode);
|
||||
void got_new_syncer(xbus_t *xbus, enum sync_mode mode, int drift);
|
||||
int xbus_command_queue_tick(xbus_t *xbus);
|
||||
void xbus_reset_counters(xbus_t *xbus);
|
||||
void elect_syncer(const char *msg);
|
||||
int exec_sync_command(const char *buf, size_t count);
|
||||
int fill_sync_string(char *buf, size_t count);
|
||||
#ifdef DAHDI_SYNC_TICK
|
||||
void dahdi_sync_tick(struct dahdi_span *span, int is_master);
|
||||
void dahdi_sync_tick(struct dahdi_span *span, int is_master);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_PCMTX
|
||||
extern int pcmtx;
|
||||
extern int pcmtx_chan;
|
||||
extern int pcmtx;
|
||||
extern int pcmtx_chan;
|
||||
#endif
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* XBUS_PCM_H */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* XBUS_PCM_H */
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
||||
# warning "This module is tested only with 2.6 kernels"
|
||||
#warning "This module is tested only with 2.6 kernels"
|
||||
#endif
|
||||
|
||||
#include <linux/kernel.h>
|
||||
@ -52,7 +52,8 @@ static ssize_t sync_show(struct device_driver *driver, char *buf)
|
||||
return fill_sync_string(buf, PAGE_SIZE);
|
||||
}
|
||||
|
||||
static ssize_t sync_store(struct device_driver *driver, const char *buf, size_t count)
|
||||
static ssize_t sync_store(struct device_driver *driver, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
/* DBG(SYNC, "%s\n", buf); */
|
||||
return exec_sync_command(buf, count);
|
||||
@ -66,19 +67,18 @@ static struct driver_attribute xpp_attrs[] = {
|
||||
/*--------- Sysfs Bus handling ----*/
|
||||
static DEVICE_ATTR_READER(xbus_state_show, dev, buf)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
int ret;
|
||||
xbus_t *xbus;
|
||||
int ret;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
ret = XBUS_STATE(xbus);
|
||||
ret = snprintf(buf, PAGE_SIZE, "%s (%d)\n",
|
||||
xbus_statename(ret), ret);
|
||||
ret = snprintf(buf, PAGE_SIZE, "%s (%d)\n", xbus_statename(ret), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_WRITER(xbus_state_store, dev, buf, count)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
xbus_t *xbus;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
XBUS_DBG(GENERAL, xbus, "%s\n", buf);
|
||||
@ -87,9 +87,9 @@ static DEVICE_ATTR_WRITER(xbus_state_store, dev, buf, count)
|
||||
else if (XBUS_IS(xbus, IDLE) && strncmp(buf, "start", 5) == 0)
|
||||
xbus_activate(xbus);
|
||||
else {
|
||||
XBUS_NOTICE(xbus, "%s: Illegal action %s in state %s. Ignored.\n",
|
||||
__func__, buf,
|
||||
xbus_statename(XBUS_STATE(xbus)));
|
||||
XBUS_NOTICE(xbus,
|
||||
"%s: Illegal action %s in state %s. Ignored.\n",
|
||||
__func__, buf, xbus_statename(XBUS_STATE(xbus)));
|
||||
return -EINVAL;
|
||||
}
|
||||
return count;
|
||||
@ -97,34 +97,39 @@ static DEVICE_ATTR_WRITER(xbus_state_store, dev, buf, count)
|
||||
|
||||
static DEVICE_ATTR_READER(status_show, dev, buf)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
int ret;
|
||||
xbus_t *xbus;
|
||||
int ret;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
ret = snprintf(buf, PAGE_SIZE, "%s\n", (XBUS_FLAGS(xbus, CONNECTED))?"connected":"missing");
|
||||
ret =
|
||||
snprintf(buf, PAGE_SIZE, "%s\n",
|
||||
(XBUS_FLAGS(xbus, CONNECTED)) ? "connected" : "missing");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_READER(timing_show, dev, buf)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
struct xpp_drift *driftinfo;
|
||||
int len = 0;
|
||||
struct timeval now;
|
||||
xbus_t *xbus;
|
||||
struct xpp_drift *driftinfo;
|
||||
int len = 0;
|
||||
struct timeval now;
|
||||
|
||||
do_gettimeofday(&now);
|
||||
xbus = dev_to_xbus(dev);
|
||||
driftinfo = &xbus->drift;
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "%-3s", sync_mode_name(xbus->sync_mode));
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len, "%-3s",
|
||||
sync_mode_name(xbus->sync_mode));
|
||||
if (xbus->sync_mode == SYNC_MODE_PLL) {
|
||||
len += snprintf(buf + len, PAGE_SIZE - len,
|
||||
" %5d: lost (%4d,%4d) : ",
|
||||
xbus->ticker.cycle,
|
||||
driftinfo->lost_ticks, driftinfo->lost_tick_count);
|
||||
len += snprintf(buf + len, PAGE_SIZE - len,
|
||||
"DRIFT %3d %ld sec ago",
|
||||
xbus->sync_adjustment,
|
||||
(xbus->pll_updated_at == 0) ? 0 : now.tv_sec - xbus->pll_updated_at);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len,
|
||||
" %5d: lost (%4d,%4d) : ", xbus->ticker.cycle,
|
||||
driftinfo->lost_ticks, driftinfo->lost_tick_count);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len,
|
||||
"DRIFT %3d %ld sec ago", xbus->sync_adjustment,
|
||||
(xbus->pll_updated_at ==
|
||||
0) ? 0 : now.tv_sec - xbus->pll_updated_at);
|
||||
}
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "\n");
|
||||
return len;
|
||||
@ -141,9 +146,9 @@ static DEVICE_ATTR_READER(timing_show, dev, buf)
|
||||
*/
|
||||
static DEVICE_ATTR_READER(samples_show, dev, buf)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
int len = 0;
|
||||
int i;
|
||||
xbus_t *xbus;
|
||||
int len = 0;
|
||||
int i;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
if (xbus->sample_running)
|
||||
@ -151,14 +156,16 @@ static DEVICE_ATTR_READER(samples_show, dev, buf)
|
||||
for (i = 0; i < SAMPLE_SIZE; i++) {
|
||||
if (len > PAGE_SIZE - 20)
|
||||
break;
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "%d\n", xbus->sample_ticks[i]);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len, "%d\n",
|
||||
xbus->sample_ticks[i]);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_WRITER(samples_store, dev, buf, count)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
xbus_t *xbus;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
if (xbus->sample_running)
|
||||
@ -175,8 +182,8 @@ static DEVICE_ATTR_WRITER(samples_store, dev, buf, count)
|
||||
*/
|
||||
static DEVICE_ATTR_WRITER(cls_store, dev, buf, count)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
struct xpp_drift *driftinfo;
|
||||
xbus_t *xbus;
|
||||
struct xpp_drift *driftinfo;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
driftinfo = &xbus->drift;
|
||||
@ -194,8 +201,8 @@ static DEVICE_ATTR_WRITER(cls_store, dev, buf, count)
|
||||
|
||||
static DEVICE_ATTR_READER(waitfor_xpds_show, dev, buf)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
int len;
|
||||
xbus_t *xbus;
|
||||
int len;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
len = waitfor_xpds(xbus, buf);
|
||||
@ -204,8 +211,8 @@ static DEVICE_ATTR_READER(waitfor_xpds_show, dev, buf)
|
||||
|
||||
static DEVICE_ATTR_READER(refcount_xbus_show, dev, buf)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
int len;
|
||||
xbus_t *xbus;
|
||||
int len;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
len = sprintf(buf, "%d\n", refcount_xbus(xbus));
|
||||
@ -214,17 +221,17 @@ static DEVICE_ATTR_READER(refcount_xbus_show, dev, buf)
|
||||
|
||||
static DEVICE_ATTR_READER(driftinfo_show, dev, buf)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
struct xpp_drift *di;
|
||||
struct xpp_ticker *ticker;
|
||||
struct timeval now;
|
||||
int len = 0;
|
||||
int hours;
|
||||
int minutes;
|
||||
int seconds;
|
||||
int speed_range;
|
||||
int uframes_inaccuracy;
|
||||
int i;
|
||||
xbus_t *xbus;
|
||||
struct xpp_drift *di;
|
||||
struct xpp_ticker *ticker;
|
||||
struct timeval now;
|
||||
int len = 0;
|
||||
int hours;
|
||||
int minutes;
|
||||
int seconds;
|
||||
int speed_range;
|
||||
int uframes_inaccuracy;
|
||||
int i;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
di = &xbus->drift;
|
||||
@ -239,25 +246,38 @@ static DEVICE_ATTR_READER(driftinfo_show, dev, buf)
|
||||
hours = minutes / 60;
|
||||
minutes = minutes % 60;
|
||||
#define SHOW(ptr,item) len += snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d\n", #item, (ptr)->item)
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d (was %d:%02d:%02d ago)\n",
|
||||
"lost_ticks", di->lost_ticks, hours, minutes, seconds);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len,
|
||||
"%-15s: %8d (was %d:%02d:%02d ago)\n", "lost_ticks",
|
||||
di->lost_ticks, hours, minutes, seconds);
|
||||
speed_range = abs(di->max_speed - di->min_speed);
|
||||
uframes_inaccuracy = di->sync_inaccuracy / 125;
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d ",
|
||||
"instability", speed_range + uframes_inaccuracy);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d ", "instability",
|
||||
speed_range + uframes_inaccuracy);
|
||||
if (xbus->sync_mode == SYNC_MODE_AB) {
|
||||
buf[len++] = '-';
|
||||
} else {
|
||||
for (i = 0; len < PAGE_SIZE - 1 && i < speed_range + uframes_inaccuracy; i++)
|
||||
for (i = 0;
|
||||
len < PAGE_SIZE - 1
|
||||
&& i < speed_range + uframes_inaccuracy; i++)
|
||||
buf[len++] = '#';
|
||||
}
|
||||
buf[len++] = '\n';
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d (uframes)\n", "inaccuracy", uframes_inaccuracy);
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d\n", "speed_range", speed_range);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d (uframes)\n",
|
||||
"inaccuracy", uframes_inaccuracy);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d\n", "speed_range",
|
||||
speed_range);
|
||||
SHOW(xbus, sync_adjustment);
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d\n", "offset (usec)", di->offset_prev);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d\n",
|
||||
"offset (usec)", di->offset_prev);
|
||||
SHOW(di, offset_range);
|
||||
len += snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d\n", "best_speed", (di->max_speed + di->min_speed) / 2);
|
||||
len +=
|
||||
snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d\n", "best_speed",
|
||||
(di->max_speed + di->min_speed) / 2);
|
||||
SHOW(di, min_speed);
|
||||
SHOW(di, max_speed);
|
||||
SHOW(ticker, cycle);
|
||||
@ -293,33 +313,34 @@ xbus_attr(connector, "%s\n");
|
||||
xbus_attr(label, "%s\n");
|
||||
|
||||
static struct device_attribute xbus_dev_attrs[] = {
|
||||
__ATTR_RO(connector),
|
||||
__ATTR_RO(label),
|
||||
__ATTR_RO(connector),
|
||||
__ATTR_RO(label),
|
||||
__ATTR_RO(status),
|
||||
__ATTR_RO(timing),
|
||||
__ATTR_RO(refcount_xbus),
|
||||
__ATTR_RO(waitfor_xpds),
|
||||
__ATTR_RO(driftinfo),
|
||||
__ATTR(cls, S_IWUSR, NULL, cls_store),
|
||||
__ATTR(xbus_state, S_IRUGO | S_IWUSR, xbus_state_show, xbus_state_store),
|
||||
__ATTR(cls, S_IWUSR, NULL, cls_store),
|
||||
__ATTR(xbus_state, S_IRUGO | S_IWUSR, xbus_state_show,
|
||||
xbus_state_store),
|
||||
#ifdef SAMPLE_TICKS
|
||||
__ATTR(samples, S_IWUSR | S_IRUGO, samples_show, samples_store),
|
||||
__ATTR(samples, S_IWUSR | S_IRUGO, samples_show, samples_store),
|
||||
#endif
|
||||
__ATTR_NULL,
|
||||
__ATTR_NULL,
|
||||
};
|
||||
|
||||
|
||||
static int astribank_match(struct device *dev, struct device_driver *driver)
|
||||
{
|
||||
DBG(DEVICES, "SYSFS MATCH: dev->bus_id = %s, driver->name = %s\n",
|
||||
dev_name(dev), driver->name);
|
||||
dev_name(dev), driver->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef OLD_HOTPLUG_SUPPORT
|
||||
static int astribank_hotplug(struct device *dev, char **envp, int envnum, char *buff, int bufsize)
|
||||
static int astribank_hotplug(struct device *dev, char **envp, int envnum,
|
||||
char *buff, int bufsize)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
xbus_t *xbus;
|
||||
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
@ -349,12 +370,13 @@ static int astribank_hotplug(struct device *dev, char **envp, int envnum, char *
|
||||
return err; \
|
||||
} while (0)
|
||||
|
||||
static int astribank_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
|
||||
static int astribank_uevent(struct device *dev, char **envp, int num_envp,
|
||||
char *buffer, int buffer_size)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
int i = 0;
|
||||
int len = 0;
|
||||
extern char *initdir;
|
||||
xbus_t *xbus;
|
||||
int i = 0;
|
||||
int len = 0;
|
||||
extern char *initdir;
|
||||
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
@ -375,8 +397,8 @@ static int astribank_uevent(struct device *dev, char **envp, int num_envp, char
|
||||
|
||||
static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
extern char *initdir;
|
||||
xbus_t *xbus;
|
||||
extern char *initdir;
|
||||
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
@ -388,27 +410,27 @@ static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* OLD_HOTPLUG_SUPPORT */
|
||||
#endif /* OLD_HOTPLUG_SUPPORT */
|
||||
|
||||
void astribank_uevent_send(xbus_t *xbus, enum kobject_action act)
|
||||
{
|
||||
struct kobject *kobj;
|
||||
struct kobject *kobj;
|
||||
|
||||
kobj = &xbus->astribank.kobj;
|
||||
XBUS_DBG(DEVICES, xbus, "SYFS bus_id=%s action=%d\n",
|
||||
dev_name(&xbus->astribank), act);
|
||||
dev_name(&xbus->astribank), act);
|
||||
|
||||
#if defined(OLD_HOTPLUG_SUPPORT_269)
|
||||
{
|
||||
/* Copy from new kernels lib/kobject_uevent.c */
|
||||
static const char *str[] = {
|
||||
[KOBJ_ADD] "add",
|
||||
[KOBJ_REMOVE] "remove",
|
||||
[KOBJ_CHANGE] "change",
|
||||
[KOBJ_MOUNT] "mount",
|
||||
[KOBJ_UMOUNT] "umount",
|
||||
[KOBJ_OFFLINE] "offline",
|
||||
[KOBJ_ONLINE] "online"
|
||||
static const char *str[] = {
|
||||
[KOBJ_ADD] "add",
|
||||
[KOBJ_REMOVE] "remove",
|
||||
[KOBJ_CHANGE] "change",
|
||||
[KOBJ_MOUNT] "mount",
|
||||
[KOBJ_UMOUNT] "umount",
|
||||
[KOBJ_OFFLINE] "offline",
|
||||
[KOBJ_ONLINE] "online"
|
||||
};
|
||||
kobject_hotplug(str[act], kobj);
|
||||
}
|
||||
@ -421,7 +443,7 @@ void astribank_uevent_send(xbus_t *xbus, enum kobject_action act)
|
||||
|
||||
static void astribank_release(struct device *dev)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
xbus_t *xbus;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xbus = dev_to_xbus(dev);
|
||||
@ -429,9 +451,10 @@ static void astribank_release(struct device *dev)
|
||||
XBUS_ERR(xbus, "Try to release CONNECTED device.\n");
|
||||
BUG();
|
||||
}
|
||||
if (!XBUS_IS(xbus, IDLE) && !XBUS_IS(xbus, FAIL) && !XBUS_IS(xbus, DEACTIVATED)) {
|
||||
if (!XBUS_IS(xbus, IDLE) && !XBUS_IS(xbus, FAIL)
|
||||
&& !XBUS_IS(xbus, DEACTIVATED)) {
|
||||
XBUS_ERR(xbus, "Try to release in state %s\n",
|
||||
xbus_statename(XBUS_STATE(xbus)));
|
||||
xbus_statename(XBUS_STATE(xbus)));
|
||||
BUG();
|
||||
}
|
||||
XBUS_INFO(xbus, "[%s] Astribank Release\n", xbus->label);
|
||||
@ -439,20 +462,20 @@ static void astribank_release(struct device *dev)
|
||||
}
|
||||
|
||||
static struct bus_type toplevel_bus_type = {
|
||||
.name = "astribanks",
|
||||
.match = astribank_match,
|
||||
.name = "astribanks",
|
||||
.match = astribank_match,
|
||||
#ifdef OLD_HOTPLUG_SUPPORT
|
||||
.hotplug = astribank_hotplug,
|
||||
.hotplug = astribank_hotplug,
|
||||
#else
|
||||
.uevent = astribank_uevent,
|
||||
.uevent = astribank_uevent,
|
||||
#endif
|
||||
.dev_attrs = xbus_dev_attrs,
|
||||
.drv_attrs = xpp_attrs,
|
||||
.dev_attrs = xbus_dev_attrs,
|
||||
.drv_attrs = xpp_attrs,
|
||||
};
|
||||
|
||||
static int astribank_probe(struct device *dev)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
xbus_t *xbus;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
XBUS_DBG(DEVICES, xbus, "SYSFS\n");
|
||||
@ -461,7 +484,7 @@ static int astribank_probe(struct device *dev)
|
||||
|
||||
static int astribank_remove(struct device *dev)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
xbus_t *xbus;
|
||||
|
||||
xbus = dev_to_xbus(dev);
|
||||
XBUS_INFO(xbus, "[%s] Atribank Remove\n", xbus->label);
|
||||
@ -469,12 +492,12 @@ static int astribank_remove(struct device *dev)
|
||||
}
|
||||
|
||||
static struct device_driver xpp_driver = {
|
||||
.name = "xppdrv",
|
||||
.bus = &toplevel_bus_type,
|
||||
.probe = astribank_probe,
|
||||
.remove = astribank_remove,
|
||||
.name = "xppdrv",
|
||||
.bus = &toplevel_bus_type,
|
||||
.probe = astribank_probe,
|
||||
.remove = astribank_remove,
|
||||
#ifndef OLD_HOTPLUG_SUPPORT
|
||||
.owner = THIS_MODULE
|
||||
.owner = THIS_MODULE
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -482,12 +505,12 @@ static struct device_driver xpp_driver = {
|
||||
|
||||
static DEVICE_ATTR_READER(chipregs_show, dev, buf)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
unsigned long flags;
|
||||
reg_cmd_t *regs;
|
||||
bool do_datah;
|
||||
char datah_str[50];
|
||||
int len = 0;
|
||||
xpd_t *xpd;
|
||||
unsigned long flags;
|
||||
reg_cmd_t *regs;
|
||||
bool do_datah;
|
||||
char datah_str[50];
|
||||
int len = 0;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -495,29 +518,34 @@ static DEVICE_ATTR_READER(chipregs_show, dev, buf)
|
||||
return -ENODEV;
|
||||
spin_lock_irqsave(&xpd->lock, flags);
|
||||
regs = &xpd->last_reply;
|
||||
len += sprintf(buf + len, "# Writing bad data into this file may damage your hardware!\n");
|
||||
len +=
|
||||
sprintf(buf + len,
|
||||
"# Writing bad data into this file may damage your hardware!\n");
|
||||
len += sprintf(buf + len, "# Consult firmware docs first\n");
|
||||
len += sprintf(buf + len, "#\n");
|
||||
do_datah = REG_FIELD(regs, do_datah) ? 1 : 0;
|
||||
if (do_datah) {
|
||||
snprintf(datah_str, ARRAY_SIZE(datah_str), "\t%02X",
|
||||
REG_FIELD(regs, data_high));
|
||||
REG_FIELD(regs, data_high));
|
||||
} else
|
||||
datah_str[0] = '\0';
|
||||
if (REG_FIELD(regs, do_subreg)) {
|
||||
len += sprintf(buf + len, "#CH\tOP\tReg.\tSub\tDL%s\n",
|
||||
(do_datah) ? "\tDH" : "");
|
||||
len += sprintf(buf + len, "%2d\tRS\t%02X\t%02X\t%02X%s\n",
|
||||
regs->portnum,
|
||||
REG_FIELD(regs, regnum), REG_FIELD(regs, subreg),
|
||||
REG_FIELD(regs, data_low), datah_str);
|
||||
len +=
|
||||
sprintf(buf + len, "#CH\tOP\tReg.\tSub\tDL%s\n",
|
||||
(do_datah) ? "\tDH" : "");
|
||||
len +=
|
||||
sprintf(buf + len, "%2d\tRS\t%02X\t%02X\t%02X%s\n",
|
||||
regs->portnum, REG_FIELD(regs, regnum),
|
||||
REG_FIELD(regs, subreg), REG_FIELD(regs, data_low),
|
||||
datah_str);
|
||||
} else {
|
||||
len += sprintf(buf + len, "#CH\tOP\tReg.\tDL%s\n",
|
||||
(do_datah) ? "\tDH" : "");
|
||||
len += sprintf(buf + len, "%2d\tRD\t%02X\t%02X%s\n",
|
||||
regs->portnum,
|
||||
REG_FIELD(regs, regnum),
|
||||
REG_FIELD(regs, data_low), datah_str);
|
||||
len +=
|
||||
sprintf(buf + len, "#CH\tOP\tReg.\tDL%s\n",
|
||||
(do_datah) ? "\tDH" : "");
|
||||
len +=
|
||||
sprintf(buf + len, "%2d\tRD\t%02X\t%02X%s\n", regs->portnum,
|
||||
REG_FIELD(regs, regnum), REG_FIELD(regs, data_low),
|
||||
datah_str);
|
||||
}
|
||||
spin_unlock_irqrestore(&xpd->lock, flags);
|
||||
return len;
|
||||
@ -525,11 +553,11 @@ static DEVICE_ATTR_READER(chipregs_show, dev, buf)
|
||||
|
||||
static DEVICE_ATTR_WRITER(chipregs_store, dev, buf, count)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
const char *p;
|
||||
char tmp[MAX_PROC_WRITE];
|
||||
int i;
|
||||
int ret;
|
||||
xpd_t *xpd;
|
||||
const char *p;
|
||||
char tmp[MAX_PROC_WRITE];
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -541,14 +569,17 @@ static DEVICE_ATTR_WRITER(chipregs_store, dev, buf, count)
|
||||
i = strcspn(p, "\r\n");
|
||||
if (i > 0) {
|
||||
if (i >= MAX_PROC_WRITE) {
|
||||
XPD_NOTICE(xpd, "Command too long (%d chars)\n", i);
|
||||
XPD_NOTICE(xpd, "Command too long (%d chars)\n",
|
||||
i);
|
||||
return -E2BIG;
|
||||
}
|
||||
memcpy(tmp, p, i);
|
||||
tmp[i] = '\0';
|
||||
ret = parse_chip_command(xpd, tmp);
|
||||
if (ret < 0) {
|
||||
XPD_NOTICE(xpd, "Failed writing command: '%s'\n", tmp);
|
||||
XPD_NOTICE(xpd,
|
||||
"Failed writing command: '%s'\n",
|
||||
tmp);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -562,9 +593,9 @@ static DEVICE_ATTR_WRITER(chipregs_store, dev, buf, count)
|
||||
|
||||
static DEVICE_ATTR_READER(blink_show, dev, buf)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
unsigned long flags;
|
||||
int len = 0;
|
||||
xpd_t *xpd;
|
||||
unsigned long flags;
|
||||
int len = 0;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -578,9 +609,9 @@ static DEVICE_ATTR_READER(blink_show, dev, buf)
|
||||
|
||||
static DEVICE_ATTR_WRITER(blink_store, dev, buf, count)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
char *endp;
|
||||
unsigned long blink;
|
||||
xpd_t *xpd;
|
||||
char *endp;
|
||||
unsigned long blink;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -599,16 +630,18 @@ static DEVICE_ATTR_WRITER(blink_store, dev, buf, count)
|
||||
|
||||
static DEVICE_ATTR_READER(span_show, dev, buf)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
unsigned long flags;
|
||||
int len = 0;
|
||||
xpd_t *xpd;
|
||||
unsigned long flags;
|
||||
int len = 0;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
if (!xpd)
|
||||
return -ENODEV;
|
||||
spin_lock_irqsave(&xpd->lock, flags);
|
||||
len += sprintf(buf, "%d\n", SPAN_REGISTERED(xpd) ? PHONEDEV(xpd).span.spanno : 0);
|
||||
len +=
|
||||
sprintf(buf, "%d\n",
|
||||
SPAN_REGISTERED(xpd) ? PHONEDEV(xpd).span.spanno : 0);
|
||||
spin_unlock_irqrestore(&xpd->lock, flags);
|
||||
return len;
|
||||
}
|
||||
@ -619,9 +652,9 @@ static DEVICE_ATTR_READER(span_show, dev, buf)
|
||||
*/
|
||||
static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
int dahdi_reg;
|
||||
int ret;
|
||||
xpd_t *xpd;
|
||||
int dahdi_reg;
|
||||
int ret;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -632,8 +665,7 @@ static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
|
||||
return -EINVAL;
|
||||
if (!XBUS_IS(xpd->xbus, READY))
|
||||
return -ENODEV;
|
||||
XPD_DBG(DEVICES, xpd,
|
||||
"%s -- deprecated (should use pinned-spans)\n",
|
||||
XPD_DBG(DEVICES, xpd, "%s -- deprecated (should use pinned-spans)\n",
|
||||
(dahdi_reg) ? "register" : "unregister");
|
||||
if (xbus_is_registered(xpd->xbus)) {
|
||||
if (dahdi_reg) {
|
||||
@ -657,8 +689,8 @@ static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
|
||||
|
||||
static DEVICE_ATTR_READER(type_show, dev, buf)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
int len = 0;
|
||||
xpd_t *xpd;
|
||||
int len = 0;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -670,9 +702,9 @@ static DEVICE_ATTR_READER(type_show, dev, buf)
|
||||
|
||||
static DEVICE_ATTR_READER(offhook_show, dev, buf)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
int len = 0;
|
||||
int i;
|
||||
xpd_t *xpd;
|
||||
int len = 0;
|
||||
int i;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -682,7 +714,7 @@ static DEVICE_ATTR_READER(offhook_show, dev, buf)
|
||||
len += sprintf(buf + len, "%d ", IS_OFFHOOK(xpd, i));
|
||||
}
|
||||
if (len) {
|
||||
len--; /* backout last space */
|
||||
len--; /* backout last space */
|
||||
}
|
||||
len += sprintf(buf + len, "\n");
|
||||
return len;
|
||||
@ -690,9 +722,9 @@ static DEVICE_ATTR_READER(offhook_show, dev, buf)
|
||||
|
||||
static DEVICE_ATTR_READER(timing_priority_show, dev, buf)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
unsigned long flags;
|
||||
int len = 0;
|
||||
xpd_t *xpd;
|
||||
unsigned long flags;
|
||||
int len = 0;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -706,8 +738,8 @@ static DEVICE_ATTR_READER(timing_priority_show, dev, buf)
|
||||
|
||||
static DEVICE_ATTR_READER(refcount_xpd_show, dev, buf)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
int len = 0;
|
||||
xpd_t *xpd;
|
||||
int len = 0;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -719,47 +751,49 @@ static DEVICE_ATTR_READER(refcount_xpd_show, dev, buf)
|
||||
|
||||
static int xpd_match(struct device *dev, struct device_driver *driver)
|
||||
{
|
||||
struct xpd_driver *xpd_driver;
|
||||
xpd_t *xpd;
|
||||
struct xpd_driver *xpd_driver;
|
||||
xpd_t *xpd;
|
||||
|
||||
xpd_driver = driver_to_xpd_driver(driver);
|
||||
xpd = dev_to_xpd(dev);
|
||||
if (xpd_driver->type != xpd->type) {
|
||||
XPD_DBG(DEVICES, xpd, "SYSFS match fail: xpd->type = %d, xpd_driver->type = %d\n",
|
||||
xpd->type, xpd_driver->type);
|
||||
XPD_DBG(DEVICES, xpd,
|
||||
"SYSFS match fail: xpd->type = %d, xpd_driver->type = %d\n",
|
||||
xpd->type, xpd_driver->type);
|
||||
return 0;
|
||||
}
|
||||
XPD_DBG(DEVICES, xpd, "SYSFS MATCH: type=%d dev->bus_id = %s, driver->name = %s\n",
|
||||
XPD_DBG(DEVICES, xpd,
|
||||
"SYSFS MATCH: type=%d dev->bus_id = %s, driver->name = %s\n",
|
||||
xpd->type, dev_name(dev), driver->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct device_attribute xpd_dev_attrs[] = {
|
||||
__ATTR(chipregs, S_IRUGO | S_IWUSR, chipregs_show, chipregs_store),
|
||||
__ATTR(blink, S_IRUGO | S_IWUSR, blink_show, blink_store),
|
||||
__ATTR(span, S_IRUGO | S_IWUSR, span_show, span_store),
|
||||
__ATTR_RO(type),
|
||||
__ATTR_RO(offhook),
|
||||
__ATTR_RO(timing_priority),
|
||||
__ATTR(chipregs, S_IRUGO | S_IWUSR, chipregs_show, chipregs_store),
|
||||
__ATTR(blink, S_IRUGO | S_IWUSR, blink_show, blink_store),
|
||||
__ATTR(span, S_IRUGO | S_IWUSR, span_show, span_store),
|
||||
__ATTR_RO(type),
|
||||
__ATTR_RO(offhook),
|
||||
__ATTR_RO(timing_priority),
|
||||
__ATTR_RO(refcount_xpd),
|
||||
__ATTR_NULL,
|
||||
__ATTR_NULL,
|
||||
};
|
||||
|
||||
static struct bus_type xpd_type = {
|
||||
.name = "xpds",
|
||||
.match = xpd_match,
|
||||
.dev_attrs = xpd_dev_attrs,
|
||||
.name = "xpds",
|
||||
.match = xpd_match,
|
||||
.dev_attrs = xpd_dev_attrs,
|
||||
};
|
||||
|
||||
int xpd_driver_register(struct device_driver *driver)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
DBG(DEVICES, "%s\n", driver->name);
|
||||
driver->bus = &xpd_type;
|
||||
if ((ret = driver_register(driver)) < 0) {
|
||||
ERR("%s: driver_register(%s) failed. Error number %d",
|
||||
__func__, driver->name, ret);
|
||||
ERR("%s: driver_register(%s) failed. Error number %d", __func__,
|
||||
driver->name, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -772,7 +806,7 @@ void xpd_driver_unregister(struct device_driver *driver)
|
||||
|
||||
static void xpd_release(struct device *dev)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
xpd_t *xpd;
|
||||
|
||||
BUG_ON(!dev);
|
||||
xpd = dev_to_xpd(dev);
|
||||
@ -782,14 +816,14 @@ static void xpd_release(struct device *dev)
|
||||
|
||||
int xpd_device_register(xbus_t *xbus, xpd_t *xpd)
|
||||
{
|
||||
struct device *dev = &xpd->xpd_dev;
|
||||
int ret;
|
||||
struct device *dev = &xpd->xpd_dev;
|
||||
int ret;
|
||||
|
||||
XPD_DBG(DEVICES, xpd, "SYSFS\n");
|
||||
dev->bus = &xpd_type;
|
||||
dev->parent = &xbus->astribank;
|
||||
dev_set_name(dev, "%02d:%1x:%1x", xbus->num, xpd->addr.unit,
|
||||
xpd->addr.subunit);
|
||||
xpd->addr.subunit);
|
||||
dev_set_drvdata(dev, xpd);
|
||||
dev->release = xpd_release;
|
||||
ret = device_register(dev);
|
||||
@ -802,8 +836,8 @@ int xpd_device_register(xbus_t *xbus, xpd_t *xpd)
|
||||
|
||||
void xpd_device_unregister(xpd_t *xpd)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
struct device *dev;
|
||||
xbus_t *xbus;
|
||||
struct device *dev;
|
||||
|
||||
xbus = xpd->xbus;
|
||||
BUG_ON(!xbus);
|
||||
@ -890,8 +924,8 @@ static DEVICE_ATTR_WRITER(echocancel_store, dev, buf, count)
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(echocancel, S_IRUGO | S_IWUSR, echocancel_show,
|
||||
echocancel_store);
|
||||
static DEVICE_ATTR(echocancel, S_IRUGO | S_IWUSR, echocancel_show,
|
||||
echocancel_store);
|
||||
|
||||
int echocancel_xpd(xpd_t *xpd, int on)
|
||||
{
|
||||
@ -905,19 +939,19 @@ int echocancel_xpd(xpd_t *xpd, int on)
|
||||
|
||||
ret = device_create_file(&xpd->xpd_dev, &dev_attr_echocancel);
|
||||
if (ret)
|
||||
XPD_ERR(xpd,
|
||||
"%s: device_create_file(echocancel) failed: %d\n",
|
||||
XPD_ERR(xpd, "%s: device_create_file(echocancel) failed: %d\n",
|
||||
__func__, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(echocancel_xpd);
|
||||
|
||||
/*--------- Sysfs Device handling ----*/
|
||||
|
||||
void xbus_sysfs_transport_remove(xbus_t *xbus)
|
||||
{
|
||||
struct device *astribank;
|
||||
struct device *astribank;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
XBUS_DBG(DEVICES, xbus, "\n");
|
||||
@ -927,9 +961,9 @@ void xbus_sysfs_transport_remove(xbus_t *xbus)
|
||||
|
||||
int xbus_sysfs_transport_create(xbus_t *xbus)
|
||||
{
|
||||
struct device *astribank;
|
||||
struct device *transport_device;
|
||||
int ret = 0;
|
||||
struct device *astribank;
|
||||
struct device *transport_device;
|
||||
int ret = 0;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
XBUS_DBG(DEVICES, xbus, "\n");
|
||||
@ -940,11 +974,12 @@ int xbus_sysfs_transport_create(xbus_t *xbus)
|
||||
XBUS_ERR(xbus, "%s: Missing transport_device\n", __func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
ret = sysfs_create_link(&astribank->kobj, &transport_device->kobj,
|
||||
"transport");
|
||||
ret =
|
||||
sysfs_create_link(&astribank->kobj, &transport_device->kobj,
|
||||
"transport");
|
||||
if (ret < 0) {
|
||||
XBUS_ERR(xbus, "%s: sysfs_create_link failed: %d\n",
|
||||
__func__, ret);
|
||||
XBUS_ERR(xbus, "%s: sysfs_create_link failed: %d\n", __func__,
|
||||
ret);
|
||||
dev_set_drvdata(astribank, NULL);
|
||||
}
|
||||
return ret;
|
||||
@ -952,7 +987,7 @@ int xbus_sysfs_transport_create(xbus_t *xbus)
|
||||
|
||||
void xbus_sysfs_remove(xbus_t *xbus)
|
||||
{
|
||||
struct device *astribank;
|
||||
struct device *astribank;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
XBUS_DBG(DEVICES, xbus, "\n");
|
||||
@ -966,8 +1001,8 @@ void xbus_sysfs_remove(xbus_t *xbus)
|
||||
|
||||
int xbus_sysfs_create(xbus_t *xbus)
|
||||
{
|
||||
struct device *astribank;
|
||||
int ret = 0;
|
||||
struct device *astribank;
|
||||
int ret = 0;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
astribank = &xbus->astribank;
|
||||
@ -979,7 +1014,8 @@ int xbus_sysfs_create(xbus_t *xbus)
|
||||
astribank->release = astribank_release;
|
||||
ret = device_register(astribank);
|
||||
if (ret) {
|
||||
XBUS_ERR(xbus, "%s: device_register failed: %d\n", __func__, ret);
|
||||
XBUS_ERR(xbus, "%s: device_register failed: %d\n", __func__,
|
||||
ret);
|
||||
dev_set_drvdata(astribank, NULL);
|
||||
}
|
||||
return ret;
|
||||
@ -987,22 +1023,22 @@ int xbus_sysfs_create(xbus_t *xbus)
|
||||
|
||||
int __init xpp_driver_init(void)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
DBG(DEVICES, "SYSFS\n");
|
||||
if ((ret = bus_register(&toplevel_bus_type)) < 0) {
|
||||
ERR("%s: bus_register(%s) failed. Error number %d",
|
||||
__func__, toplevel_bus_type.name, ret);
|
||||
ERR("%s: bus_register(%s) failed. Error number %d", __func__,
|
||||
toplevel_bus_type.name, ret);
|
||||
goto failed_toplevel;
|
||||
}
|
||||
if ((ret = driver_register(&xpp_driver)) < 0) {
|
||||
ERR("%s: driver_register(%s) failed. Error number %d",
|
||||
__func__, xpp_driver.name, ret);
|
||||
ERR("%s: driver_register(%s) failed. Error number %d", __func__,
|
||||
xpp_driver.name, ret);
|
||||
goto failed_xpp_driver;
|
||||
}
|
||||
if ((ret = bus_register(&xpd_type)) < 0) {
|
||||
ERR("%s: bus_register(%s) failed. Error number %d",
|
||||
__func__, xpd_type.name, ret);
|
||||
ERR("%s: bus_register(%s) failed. Error number %d", __func__,
|
||||
xpd_type.name, ret);
|
||||
goto failed_xpd_bus;
|
||||
}
|
||||
return 0;
|
||||
|
@ -34,7 +34,7 @@
|
||||
/* This is to enable user-space programs to include this. */
|
||||
|
||||
#include <stdint.h>
|
||||
typedef uint8_t __u8;
|
||||
typedef uint8_t __u8;
|
||||
typedef uint32_t __u32;
|
||||
|
||||
#include <stdio.h>
|
||||
@ -45,7 +45,10 @@ typedef uint32_t __u32;
|
||||
#define ERR(fmt, ...) printf("ERR: " fmt, ## __VA_ARGS__)
|
||||
#define __user
|
||||
|
||||
struct list_head { struct list_head *next; struct list_head *prev; };
|
||||
struct list_head {
|
||||
struct list_head *next;
|
||||
struct list_head *prev;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -53,7 +56,7 @@ struct list_head { struct list_head *next; struct list_head *prev; };
|
||||
|
||||
#define ALL_LINES ((lineno_t)-1)
|
||||
|
||||
#ifndef BIT /* added in 2.6.24 */
|
||||
#ifndef BIT /* added in 2.6.24 */
|
||||
#define BIT(i) (1UL << (i))
|
||||
#endif
|
||||
#define BIT_SET(x, i) ((x) |= BIT(i))
|
||||
@ -95,10 +98,10 @@ struct list_head { struct list_head *next; struct list_head *prev; };
|
||||
|
||||
#define VALID_XPD_NUM(x) ((x) < MAX_XPDS && (x) >= 0)
|
||||
|
||||
#define CHAN_BITS 5 /* 0-31 for E1 */
|
||||
#define CHAN_BITS 5 /* 0-31 for E1 */
|
||||
|
||||
typedef char *charp;
|
||||
typedef unsigned char byte;
|
||||
typedef char *charp;
|
||||
typedef unsigned char byte;
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/* Kernel versions... */
|
||||
@ -121,7 +124,7 @@ typedef unsigned char byte;
|
||||
#define OLD_HOTPLUG_SUPPORT // for older kernels
|
||||
#endif
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 10)
|
||||
#define OLD_HOTPLUG_SUPPORT_269// for way older kernels
|
||||
#define OLD_HOTPLUG_SUPPORT_269 // for way older kernels
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
|
||||
@ -149,20 +152,20 @@ typedef unsigned char byte;
|
||||
* same linux-2.6-net-infrastructure-updates-to-mac80211-iwl4965.patch
|
||||
* as is the bool typedef. */
|
||||
#if LINUX_VERSION_CODE != KERNEL_VERSION(2, 6, 18) || ! defined(hex_asc)
|
||||
typedef int bool;
|
||||
typedef int bool;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
typedef int bool;
|
||||
typedef int bool;
|
||||
#endif
|
||||
typedef struct xbus xbus_t;
|
||||
typedef struct xpd xpd_t;
|
||||
typedef struct xframe xframe_t;
|
||||
typedef struct xpacket xpacket_t;
|
||||
typedef __u32 xpp_line_t; /* at most 31 lines for E1 */
|
||||
typedef byte lineno_t;
|
||||
typedef byte xportno_t;
|
||||
typedef struct xbus xbus_t;
|
||||
typedef struct xpd xpd_t;
|
||||
typedef struct xframe xframe_t;
|
||||
typedef struct xpacket xpacket_t;
|
||||
typedef __u32 xpp_line_t; /* at most 31 lines for E1 */
|
||||
typedef byte lineno_t;
|
||||
typedef byte xportno_t;
|
||||
|
||||
#define PORT_BROADCAST 255
|
||||
|
||||
#endif /* XDEFS_H */
|
||||
#endif /* XDEFS_H */
|
||||
|
@ -7,7 +7,8 @@ extern int debug;
|
||||
static xframe_t *transport_alloc_xframe(xbus_t *xbus, gfp_t gfp_flags);
|
||||
static void transport_free_xframe(xbus_t *xbus, xframe_t *xframe);
|
||||
|
||||
void xframe_queue_init(struct xframe_queue *q, unsigned int steady_state_count, unsigned int max_count, const char *name, void *priv)
|
||||
void xframe_queue_init(struct xframe_queue *q, unsigned int steady_state_count,
|
||||
unsigned int max_count, const char *name, void *priv)
|
||||
{
|
||||
memset(q, 0, sizeof(*q));
|
||||
spin_lock_init(&q->lock);
|
||||
@ -21,34 +22,33 @@ void xframe_queue_init(struct xframe_queue *q, unsigned int steady_state_count,
|
||||
void xframe_queue_clearstats(struct xframe_queue *q)
|
||||
{
|
||||
q->worst_count = 0;
|
||||
//q->overflows = 0; /* Never clear overflows */
|
||||
//q->overflows = 0; /* Never clear overflows */
|
||||
q->worst_lag_usec = 0L;
|
||||
}
|
||||
|
||||
static void __xframe_dump_queue(struct xframe_queue *q)
|
||||
{
|
||||
xframe_t *xframe;
|
||||
int i = 0;
|
||||
char prefix[30];
|
||||
struct timeval now;
|
||||
xframe_t *xframe;
|
||||
int i = 0;
|
||||
char prefix[30];
|
||||
struct timeval now;
|
||||
|
||||
do_gettimeofday(&now);
|
||||
printk(KERN_DEBUG "%s: dump queue '%s' (first packet in each frame)\n",
|
||||
THIS_MODULE->name,
|
||||
q->name);
|
||||
THIS_MODULE->name, q->name);
|
||||
list_for_each_entry_reverse(xframe, &q->head, frame_list) {
|
||||
xpacket_t *pack = (xpacket_t *)&xframe->packets[0];
|
||||
long usec = usec_diff(&now, &xframe->tv_queued);
|
||||
xpacket_t *pack = (xpacket_t *)&xframe->packets[0];
|
||||
long usec = usec_diff(&now, &xframe->tv_queued);
|
||||
snprintf(prefix, ARRAY_SIZE(prefix), " %3d> %5ld.%03ld msec",
|
||||
i++, usec / 1000, usec % 1000);
|
||||
i++, usec / 1000, usec % 1000);
|
||||
dump_packet(prefix, pack, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static bool __xframe_enqueue(struct xframe_queue *q, xframe_t *xframe)
|
||||
{
|
||||
int ret = 1;
|
||||
static int overflow_cnt;
|
||||
int ret = 1;
|
||||
static int overflow_cnt;
|
||||
|
||||
if (unlikely(q->disabled)) {
|
||||
ret = 0;
|
||||
@ -57,15 +57,12 @@ static bool __xframe_enqueue(struct xframe_queue *q, xframe_t *xframe)
|
||||
if (q->count >= q->max_count) {
|
||||
q->overflows++;
|
||||
if ((overflow_cnt++ % 1000) < 5) {
|
||||
NOTICE("Overflow of %-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02ld.%ld ms\n",
|
||||
q->name,
|
||||
q->steady_state_count,
|
||||
q->count,
|
||||
q->max_count,
|
||||
q->worst_count,
|
||||
q->overflows,
|
||||
q->worst_lag_usec / 1000,
|
||||
q->worst_lag_usec % 1000);
|
||||
NOTICE
|
||||
("Overflow of %-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02ld.%ld ms\n",
|
||||
q->name, q->steady_state_count, q->count,
|
||||
q->max_count, q->worst_count, q->overflows,
|
||||
q->worst_lag_usec / 1000,
|
||||
q->worst_lag_usec % 1000);
|
||||
__xframe_dump_queue(q);
|
||||
}
|
||||
ret = 0;
|
||||
@ -81,8 +78,8 @@ out:
|
||||
|
||||
bool xframe_enqueue(struct xframe_queue *q, xframe_t *xframe)
|
||||
{
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
spin_lock_irqsave(&q->lock, flags);
|
||||
ret = __xframe_enqueue(q, xframe);
|
||||
@ -92,10 +89,10 @@ bool xframe_enqueue(struct xframe_queue *q, xframe_t *xframe)
|
||||
|
||||
static xframe_t *__xframe_dequeue(struct xframe_queue *q)
|
||||
{
|
||||
xframe_t *frm = NULL;
|
||||
struct list_head *h;
|
||||
struct timeval now;
|
||||
unsigned long usec_lag;
|
||||
xframe_t *frm = NULL;
|
||||
struct list_head *h;
|
||||
struct timeval now;
|
||||
unsigned long usec_lag;
|
||||
|
||||
if (list_empty(&q->head))
|
||||
goto out;
|
||||
@ -105,8 +102,10 @@ static xframe_t *__xframe_dequeue(struct xframe_queue *q)
|
||||
frm = list_entry(h, xframe_t, frame_list);
|
||||
do_gettimeofday(&now);
|
||||
usec_lag =
|
||||
(now.tv_sec - frm->tv_queued.tv_sec)*1000*1000 +
|
||||
(now.tv_usec - frm->tv_queued.tv_usec);
|
||||
(now.tv_sec - frm->tv_queued.tv_sec) * 1000 * 1000 + (now.tv_usec -
|
||||
frm->
|
||||
tv_queued.
|
||||
tv_usec);
|
||||
if (q->worst_lag_usec < usec_lag)
|
||||
q->worst_lag_usec = usec_lag;
|
||||
out:
|
||||
@ -115,14 +114,15 @@ out:
|
||||
|
||||
xframe_t *xframe_dequeue(struct xframe_queue *q)
|
||||
{
|
||||
unsigned long flags;
|
||||
xframe_t *frm;
|
||||
unsigned long flags;
|
||||
xframe_t *frm;
|
||||
|
||||
spin_lock_irqsave(&q->lock, flags);
|
||||
frm = __xframe_dequeue(q);
|
||||
spin_unlock_irqrestore(&q->lock, flags);
|
||||
return frm;
|
||||
}
|
||||
|
||||
void xframe_queue_disable(struct xframe_queue *q, bool disabled)
|
||||
{
|
||||
q->disabled = disabled;
|
||||
@ -130,16 +130,17 @@ void xframe_queue_disable(struct xframe_queue *q, bool disabled)
|
||||
|
||||
void xframe_queue_clear(struct xframe_queue *q)
|
||||
{
|
||||
xframe_t *xframe;
|
||||
xbus_t *xbus = q->priv;
|
||||
int i = 0;
|
||||
xframe_t *xframe;
|
||||
xbus_t *xbus = q->priv;
|
||||
int i = 0;
|
||||
|
||||
xframe_queue_disable(q, 1);
|
||||
while ((xframe = xframe_dequeue(q)) != NULL) {
|
||||
transport_free_xframe(xbus, xframe);
|
||||
i++;
|
||||
}
|
||||
XBUS_DBG(DEVICES, xbus, "%s: finished queue clear (%d items)\n", q->name, i);
|
||||
XBUS_DBG(DEVICES, xbus, "%s: finished queue clear (%d items)\n",
|
||||
q->name, i);
|
||||
}
|
||||
|
||||
uint xframe_queue_count(struct xframe_queue *q)
|
||||
@ -151,9 +152,9 @@ uint xframe_queue_count(struct xframe_queue *q)
|
||||
|
||||
static xframe_t *transport_alloc_xframe(xbus_t *xbus, gfp_t gfp_flags)
|
||||
{
|
||||
struct xbus_ops *ops;
|
||||
xframe_t *xframe;
|
||||
unsigned long flags;
|
||||
struct xbus_ops *ops;
|
||||
xframe_t *xframe;
|
||||
unsigned long flags;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
ops = transportops_get(xbus);
|
||||
@ -169,8 +170,8 @@ static xframe_t *transport_alloc_xframe(xbus_t *xbus, gfp_t gfp_flags)
|
||||
|
||||
if ((rate_limit++ % 3001) == 0)
|
||||
XBUS_ERR(xbus,
|
||||
"Failed xframe allocation from transport (%d)\n",
|
||||
rate_limit);
|
||||
"Failed xframe allocation from transport (%d)\n",
|
||||
rate_limit);
|
||||
transportops_put(xbus);
|
||||
/* fall through */
|
||||
}
|
||||
@ -180,8 +181,8 @@ static xframe_t *transport_alloc_xframe(xbus_t *xbus, gfp_t gfp_flags)
|
||||
|
||||
static void transport_free_xframe(xbus_t *xbus, xframe_t *xframe)
|
||||
{
|
||||
struct xbus_ops *ops;
|
||||
unsigned long flags;
|
||||
struct xbus_ops *ops;
|
||||
unsigned long flags;
|
||||
|
||||
BUG_ON(!xbus);
|
||||
ops = xbus->transport.ops;
|
||||
@ -195,11 +196,11 @@ static void transport_free_xframe(xbus_t *xbus, xframe_t *xframe)
|
||||
|
||||
static bool xframe_queue_adjust(struct xframe_queue *q)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
xframe_t *xframe;
|
||||
int delta;
|
||||
unsigned long flags;
|
||||
int ret = 0;
|
||||
xbus_t *xbus;
|
||||
xframe_t *xframe;
|
||||
int delta;
|
||||
unsigned long flags;
|
||||
int ret = 0;
|
||||
|
||||
BUG_ON(!q);
|
||||
xbus = q->priv;
|
||||
@ -214,14 +215,16 @@ static bool xframe_queue_adjust(struct xframe_queue *q)
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 3001) == 0)
|
||||
XBUS_ERR(xbus, "%s: failed frame allocation\n", q->name);
|
||||
XBUS_ERR(xbus, "%s: failed frame allocation\n",
|
||||
q->name);
|
||||
goto out;
|
||||
}
|
||||
if (!__xframe_enqueue(q, xframe)) {
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 3001) == 0)
|
||||
XBUS_ERR(xbus, "%s: failed enqueueing frame\n", q->name);
|
||||
XBUS_ERR(xbus, "%s: failed enqueueing frame\n",
|
||||
q->name);
|
||||
transport_free_xframe(xbus, xframe);
|
||||
goto out;
|
||||
}
|
||||
@ -233,7 +236,8 @@ static bool xframe_queue_adjust(struct xframe_queue *q)
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 3001) == 0)
|
||||
XBUS_ERR(xbus, "%s: failed dequeueing frame\n", q->name);
|
||||
XBUS_ERR(xbus, "%s: failed dequeueing frame\n",
|
||||
q->name);
|
||||
goto out;
|
||||
}
|
||||
transport_free_xframe(xbus, xframe);
|
||||
@ -246,8 +250,8 @@ out:
|
||||
|
||||
xframe_t *get_xframe(struct xframe_queue *q)
|
||||
{
|
||||
xframe_t *xframe;
|
||||
xbus_t *xbus;
|
||||
xframe_t *xframe;
|
||||
xbus_t *xbus;
|
||||
|
||||
BUG_ON(!q);
|
||||
xbus = (xbus_t *)q->priv;
|
||||
@ -258,7 +262,8 @@ xframe_t *get_xframe(struct xframe_queue *q)
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 3001) == 0)
|
||||
XBUS_ERR(xbus, "%s STILL EMPTY (%d)\n", q->name, rate_limit);
|
||||
XBUS_ERR(xbus, "%s STILL EMPTY (%d)\n", q->name,
|
||||
rate_limit);
|
||||
return NULL;
|
||||
}
|
||||
BUG_ON(xframe->xframe_magic != XFRAME_MAGIC);
|
||||
@ -279,7 +284,7 @@ xframe_t *get_xframe(struct xframe_queue *q)
|
||||
|
||||
void put_xframe(struct xframe_queue *q, xframe_t *xframe)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
xbus_t *xbus;
|
||||
|
||||
BUG_ON(!q);
|
||||
xbus = (xbus_t *)q->priv;
|
||||
@ -294,7 +299,6 @@ void put_xframe(struct xframe_queue *q, xframe_t *xframe)
|
||||
xframe_queue_adjust(q);
|
||||
}
|
||||
|
||||
|
||||
EXPORT_SYMBOL(xframe_queue_init);
|
||||
EXPORT_SYMBOL(xframe_queue_clearstats);
|
||||
EXPORT_SYMBOL(xframe_enqueue);
|
||||
|
@ -8,23 +8,22 @@
|
||||
#define XFRAME_QUEUE_MARGIN 10
|
||||
|
||||
struct xframe_queue {
|
||||
struct list_head head;
|
||||
bool disabled;
|
||||
unsigned int count;
|
||||
unsigned int max_count;
|
||||
unsigned int steady_state_count;
|
||||
spinlock_t lock;
|
||||
const char *name;
|
||||
void *priv;
|
||||
struct list_head head;
|
||||
bool disabled;
|
||||
unsigned int count;
|
||||
unsigned int max_count;
|
||||
unsigned int steady_state_count;
|
||||
spinlock_t lock;
|
||||
const char *name;
|
||||
void *priv;
|
||||
/* statistics */
|
||||
unsigned int worst_count;
|
||||
unsigned int overflows;
|
||||
unsigned long worst_lag_usec; /* since xframe creation */
|
||||
unsigned int worst_count;
|
||||
unsigned int overflows;
|
||||
unsigned long worst_lag_usec; /* since xframe creation */
|
||||
};
|
||||
|
||||
void xframe_queue_init(struct xframe_queue *q,
|
||||
unsigned int steady_state_count, unsigned int max_count,
|
||||
const char *name, void *priv);
|
||||
void xframe_queue_init(struct xframe_queue *q, unsigned int steady_state_count,
|
||||
unsigned int max_count, const char *name, void *priv);
|
||||
__must_check bool xframe_enqueue(struct xframe_queue *q, xframe_t *xframe);
|
||||
__must_check xframe_t *xframe_dequeue(struct xframe_queue *q);
|
||||
void xframe_queue_clearstats(struct xframe_queue *q);
|
||||
@ -32,4 +31,4 @@ void xframe_queue_disable(struct xframe_queue *q, bool disabled);
|
||||
void xframe_queue_clear(struct xframe_queue *q);
|
||||
uint xframe_queue_count(struct xframe_queue *q);
|
||||
|
||||
#endif /* XFRAME_QUEUE_ */
|
||||
#endif /* XFRAME_QUEUE_ */
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <asm/semaphore.h>
|
||||
#endif
|
||||
#include <linux/moduleparam.h>
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#include <dahdi/kernel.h>
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
|
||||
/* also added in RHEL kernels with the OpenInfiniband backport: */
|
||||
#if LINUX_VERSION_CODE != KERNEL_VERSION(2, 6, 9) || !defined(DEFINE_SPINLOCK)
|
||||
typedef unsigned gfp_t; /* Added in 2.6.14 */
|
||||
typedef unsigned gfp_t; /* Added in 2.6.14 */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -81,21 +81,21 @@ typedef unsigned gfp_t; /* Added in 2.6.14 */
|
||||
module_param_array(name, type, &name ## _num_values, 0644); \
|
||||
MODULE_PARM_DESC(name, desc " ( 1-" __MODULE_STRING(count) ")")
|
||||
#endif
|
||||
#endif // __KERNEL__
|
||||
#endif // __KERNEL__
|
||||
|
||||
#define CARD_DESC_MAGIC 0xca9dde5c
|
||||
|
||||
struct card_desc_struct {
|
||||
struct list_head card_list;
|
||||
u32 magic;
|
||||
__u8 type; /* LSB: 1 - to_phone, 0 - to_line */
|
||||
__u8 subtype;
|
||||
struct xpd_addr xpd_addr;
|
||||
__u8 numchips;
|
||||
__u8 ports_per_chip;
|
||||
__u8 ports;
|
||||
__u8 port_dir;
|
||||
struct xpd_addr ec_addr; /* echo canceler address */
|
||||
struct card_desc_struct {
|
||||
struct list_head card_list;
|
||||
u32 magic;
|
||||
__u8 type; /* LSB: 1 - to_phone, 0 - to_line */
|
||||
__u8 subtype;
|
||||
struct xpd_addr xpd_addr;
|
||||
__u8 numchips;
|
||||
__u8 ports_per_chip;
|
||||
__u8 ports;
|
||||
__u8 port_dir;
|
||||
struct xpd_addr ec_addr; /* echo canceler address */
|
||||
};
|
||||
|
||||
typedef enum xpd_direction {
|
||||
@ -120,12 +120,9 @@ enum {
|
||||
|
||||
/* yucky, make an instance so we can size it... */
|
||||
static struct xpd_counters {
|
||||
char *name;
|
||||
char *name;
|
||||
} xpd_counters[] = {
|
||||
C_(PCM_READ),
|
||||
C_(PCM_WRITE),
|
||||
C_(RECV_ERRORS),
|
||||
};
|
||||
C_(PCM_READ), C_(PCM_WRITE), C_(RECV_ERRORS),};
|
||||
|
||||
#undef C_
|
||||
|
||||
@ -138,43 +135,43 @@ enum xpd_state {
|
||||
XPD_STATE_NOHW,
|
||||
};
|
||||
|
||||
bool xpd_setstate(xpd_t *xpd, enum xpd_state newstate);
|
||||
const char *xpd_statename(enum xpd_state st);
|
||||
bool xpd_setstate(xpd_t *xpd, enum xpd_state newstate);
|
||||
const char *xpd_statename(enum xpd_state st);
|
||||
|
||||
#define PHONEDEV(xpd) ((xpd)->phonedev)
|
||||
#define IS_PHONEDEV(xpd) (PHONEDEV(xpd).phoneops)
|
||||
|
||||
struct phonedev {
|
||||
const struct phoneops *phoneops; /* Card level operations */
|
||||
struct dahdi_span span;
|
||||
struct dahdi_chan *chans[32];
|
||||
const struct phoneops *phoneops; /* Card level operations */
|
||||
struct dahdi_span span;
|
||||
struct dahdi_chan *chans[32];
|
||||
#define XPD_CHAN(xpd, chan) (PHONEDEV(xpd).chans[(chan)])
|
||||
struct dahdi_echocan_state *ec[32];
|
||||
|
||||
int channels;
|
||||
xpd_direction_t direction; /* TO_PHONE, TO_PSTN */
|
||||
xpp_line_t no_pcm; /* Temporary: disable PCM (for USB-1) */
|
||||
xpp_line_t offhook_state; /* Actual chip state: 0 - ONHOOK, 1 - OFHOOK */
|
||||
xpp_line_t oht_pcm_pass; /* Transfer on-hook PCM */
|
||||
int channels;
|
||||
xpd_direction_t direction; /* TO_PHONE, TO_PSTN */
|
||||
xpp_line_t no_pcm; /* Temporary: disable PCM (for USB-1) */
|
||||
xpp_line_t offhook_state; /* Actual chip state: 0 - ONHOOK, 1 - OFHOOK */
|
||||
xpp_line_t oht_pcm_pass; /* Transfer on-hook PCM */
|
||||
/* Voice Mail Waiting Indication: */
|
||||
unsigned int msg_waiting[CHANNELS_PERXPD];
|
||||
xpp_line_t digital_outputs; /* 0 - no, 1 - yes */
|
||||
xpp_line_t digital_inputs; /* 0 - no, 1 - yes */
|
||||
xpp_line_t digital_signalling; /* BRI signalling channels */
|
||||
uint timing_priority; /* from 'span' directives in chan_dahdi.conf */
|
||||
unsigned int msg_waiting[CHANNELS_PERXPD];
|
||||
xpp_line_t digital_outputs; /* 0 - no, 1 - yes */
|
||||
xpp_line_t digital_inputs; /* 0 - no, 1 - yes */
|
||||
xpp_line_t digital_signalling; /* BRI signalling channels */
|
||||
uint timing_priority; /* from 'span' directives in chan_dahdi.conf */
|
||||
|
||||
/* Assure atomicity of changes to pcm_len and wanted_pcm_mask */
|
||||
spinlock_t lock_recompute_pcm;
|
||||
spinlock_t lock_recompute_pcm;
|
||||
/* maintained by card drivers */
|
||||
uint pcm_len; /* allocation length of PCM packet (dynamic) */
|
||||
xpp_line_t wanted_pcm_mask;
|
||||
xpp_line_t silence_pcm; /* inject silence during next tick */
|
||||
xpp_line_t mute_dtmf;
|
||||
uint pcm_len; /* allocation length of PCM packet (dynamic) */
|
||||
xpp_line_t wanted_pcm_mask;
|
||||
xpp_line_t silence_pcm; /* inject silence during next tick */
|
||||
xpp_line_t mute_dtmf;
|
||||
|
||||
bool ringing[CHANNELS_PERXPD];
|
||||
bool ringing[CHANNELS_PERXPD];
|
||||
|
||||
atomic_t dahdi_registered; /* Am I fully registered with dahdi */
|
||||
atomic_t open_counter; /* Number of open channels */
|
||||
atomic_t dahdi_registered; /* Am I fully registered with dahdi */
|
||||
atomic_t open_counter; /* Number of open channels */
|
||||
|
||||
/* Echo cancelation */
|
||||
u_char ec_chunk1[CHANNELS_PERXPD][DAHDI_CHUNKSIZE];
|
||||
@ -186,51 +183,51 @@ struct phonedev {
|
||||
*/
|
||||
struct xpd {
|
||||
char xpdname[XPD_NAMELEN];
|
||||
struct phonedev phonedev;
|
||||
struct phonedev phonedev;
|
||||
|
||||
const struct xops *xops;
|
||||
xpd_type_t type;
|
||||
const char *type_name;
|
||||
__u8 subtype;
|
||||
int subunits; /* all siblings */
|
||||
enum xpd_state xpd_state;
|
||||
struct device xpd_dev;
|
||||
const struct xops *xops;
|
||||
xpd_type_t type;
|
||||
const char *type_name;
|
||||
__u8 subtype;
|
||||
int subunits; /* all siblings */
|
||||
enum xpd_state xpd_state;
|
||||
struct device xpd_dev;
|
||||
#define dev_to_xpd(dev) container_of(dev, struct xpd, xpd_dev)
|
||||
struct kref kref;
|
||||
struct kref kref;
|
||||
#define kref_to_xpd(k) container_of(k, struct xpd, kref)
|
||||
|
||||
xbus_t *xbus; /* The XBUS we are connected to */
|
||||
struct device *echocancel;
|
||||
xbus_t *xbus; /* The XBUS we are connected to */
|
||||
struct device *echocancel;
|
||||
|
||||
spinlock_t lock;
|
||||
spinlock_t lock;
|
||||
|
||||
int flags;
|
||||
unsigned long blink_mode; /* bitmask of blinking ports */
|
||||
int flags;
|
||||
unsigned long blink_mode; /* bitmask of blinking ports */
|
||||
#define DEFAULT_LED_PERIOD (1000/8) /* in tick */
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
struct proc_dir_entry *proc_xpd_dir;
|
||||
struct proc_dir_entry *proc_xpd_summary;
|
||||
struct proc_dir_entry *proc_xpd_dir;
|
||||
struct proc_dir_entry *proc_xpd_summary;
|
||||
#endif
|
||||
|
||||
int counters[XPD_COUNTER_MAX];
|
||||
int counters[XPD_COUNTER_MAX];
|
||||
|
||||
const xproto_table_t *xproto; /* Card level protocol table */
|
||||
void *priv; /* Card level private data */
|
||||
bool card_present;
|
||||
reg_cmd_t requested_reply;
|
||||
reg_cmd_t last_reply;
|
||||
const xproto_table_t *xproto; /* Card level protocol table */
|
||||
void *priv; /* Card level private data */
|
||||
bool card_present;
|
||||
reg_cmd_t requested_reply;
|
||||
reg_cmd_t last_reply;
|
||||
|
||||
unsigned long last_response; /* in jiffies */
|
||||
unsigned xbus_idx; /* index in xbus->xpds[] */
|
||||
struct xpd_addr addr;
|
||||
unsigned long last_response; /* in jiffies */
|
||||
unsigned xbus_idx; /* index in xbus->xpds[] */
|
||||
struct xpd_addr addr;
|
||||
struct list_head xpd_list;
|
||||
unsigned int timer_count;
|
||||
unsigned int timer_count;
|
||||
};
|
||||
|
||||
#define for_each_line(xpd, i) for ((i) = 0; (i) < PHONEDEV(xpd).channels; (i)++)
|
||||
#define IS_BRI(xpd) ((xpd)->type == XPD_TYPE_BRI)
|
||||
#define TICK_TOLERANCE 500 /* usec */
|
||||
#define TICK_TOLERANCE 500 /* usec */
|
||||
|
||||
#ifdef DEBUG_SYNC_PARPORT
|
||||
void xbus_flip_bit(xbus_t *xbus, unsigned int bitnum0, unsigned int bitnum1);
|
||||
@ -240,7 +237,7 @@ void xbus_flip_bit(xbus_t *xbus, unsigned int bitnum0, unsigned int bitnum1);
|
||||
|
||||
static inline void *my_kzalloc(size_t size, gfp_t flags)
|
||||
{
|
||||
void *p;
|
||||
void *p;
|
||||
|
||||
p = kmalloc(size, flags);
|
||||
if (p)
|
||||
@ -249,18 +246,18 @@ static inline void *my_kzalloc(size_t size, gfp_t flags)
|
||||
}
|
||||
|
||||
struct xpd_driver {
|
||||
xpd_type_t type;
|
||||
xpd_type_t type;
|
||||
|
||||
struct device_driver driver;
|
||||
struct device_driver driver;
|
||||
#define driver_to_xpd_driver(driver) container_of(driver, struct xpd_driver, driver)
|
||||
};
|
||||
|
||||
int xpd_driver_register(struct device_driver *driver);
|
||||
void xpd_driver_unregister(struct device_driver *driver);
|
||||
xpd_t *get_xpd(const char *msg, xpd_t *xpd);
|
||||
void put_xpd(const char *msg, xpd_t *xpd);
|
||||
int refcount_xpd(xpd_t *xpd);
|
||||
int xpd_driver_register(struct device_driver *driver);
|
||||
void xpd_driver_unregister(struct device_driver *driver);
|
||||
xpd_t *get_xpd(const char *msg, xpd_t *xpd);
|
||||
void put_xpd(const char *msg, xpd_t *xpd);
|
||||
int refcount_xpd(xpd_t *xpd);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* XPD_H */
|
||||
#endif /* XPD_H */
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
||||
# warning "This module is tested only with 2.6 kernels"
|
||||
#warning "This module is tested only with 2.6 kernels"
|
||||
#endif
|
||||
|
||||
#include <linux/kernel.h>
|
||||
@ -57,7 +57,8 @@ struct proc_dir_entry *xpp_proc_toplevel = NULL;
|
||||
#define DELAY_UNTIL_DIALTONE 3000
|
||||
|
||||
DEF_PARM(int, debug, 0, 0644, "Print DBG statements");
|
||||
static DEF_PARM_BOOL(prefmaster, 0, 0644, "Do we want to be dahdi preferred sync master");
|
||||
static DEF_PARM_BOOL(prefmaster, 0, 0644,
|
||||
"Do we want to be dahdi preferred sync master");
|
||||
// DEF_ARRAY(int, pcmtx, 4, 0, "Forced PCM values to transmit");
|
||||
|
||||
#include "dahdi_debug.h"
|
||||
@ -75,6 +76,7 @@ static void phonedev_cleanup(xpd_t *xpd);
|
||||
* echo "3,5" > /sys/module/xpp/parameters/parport_xbuses
|
||||
*/
|
||||
static int parport_xbuses[2] = { 0, 1 };
|
||||
|
||||
unsigned int parport_xbuses_num_values;
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 9)
|
||||
module_param_array(parport_xbuses, int, &parport_xbuses_num_values, 0577);
|
||||
@ -90,13 +92,14 @@ MODULE_PARM_DESC(parport_xbuses, "Id's of xbuses to sample (1-2)");
|
||||
*/
|
||||
void xbus_flip_bit(xbus_t *xbus, unsigned int bitnum0, unsigned int bitnum1)
|
||||
{
|
||||
int num = xbus->num;
|
||||
int num = xbus->num;
|
||||
|
||||
if (num == parport_xbuses[0])
|
||||
flip_parport_bit(bitnum0);
|
||||
if (num == parport_xbuses[1])
|
||||
flip_parport_bit(bitnum1);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(xbus_flip_bit);
|
||||
#endif
|
||||
|
||||
@ -108,7 +111,8 @@ int total_registered_spans(void)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data);
|
||||
static int xpd_read_proc(char *page, char **start, off_t off, int count,
|
||||
int *eof, void *data);
|
||||
#endif
|
||||
|
||||
/*------------------------- XPD Management -------------------------*/
|
||||
@ -118,7 +122,7 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
|
||||
*/
|
||||
static void xpd_destroy(struct kref *kref)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
xpd_t *xpd;
|
||||
|
||||
xpd = kref_to_xpd(kref);
|
||||
XPD_DBG(DEVICES, xpd, "%s\n", __func__);
|
||||
@ -134,16 +138,14 @@ int refcount_xpd(xpd_t *xpd)
|
||||
|
||||
xpd_t *get_xpd(const char *msg, xpd_t *xpd)
|
||||
{
|
||||
XPD_DBG(DEVICES, xpd, "%s: refcount_xpd=%d\n",
|
||||
msg, refcount_xpd(xpd));
|
||||
XPD_DBG(DEVICES, xpd, "%s: refcount_xpd=%d\n", msg, refcount_xpd(xpd));
|
||||
kref_get(&xpd->kref);
|
||||
return xpd;
|
||||
}
|
||||
|
||||
void put_xpd(const char *msg, xpd_t *xpd)
|
||||
{
|
||||
XPD_DBG(DEVICES, xpd, "%s: refcount_xpd=%d\n",
|
||||
msg, refcount_xpd(xpd));
|
||||
XPD_DBG(DEVICES, xpd, "%s: refcount_xpd=%d\n", msg, refcount_xpd(xpd));
|
||||
kref_put(&xpd->kref, xpd_destroy);
|
||||
}
|
||||
|
||||
@ -152,12 +154,13 @@ static void xpd_proc_remove(xbus_t *xbus, xpd_t *xpd)
|
||||
#ifdef CONFIG_PROC_FS
|
||||
if (xpd->proc_xpd_dir) {
|
||||
if (xpd->proc_xpd_summary) {
|
||||
XPD_DBG(PROC, xpd, "Removing proc '%s'\n", PROC_XPD_SUMMARY);
|
||||
XPD_DBG(PROC, xpd, "Removing proc '%s'\n",
|
||||
PROC_XPD_SUMMARY);
|
||||
remove_proc_entry(PROC_XPD_SUMMARY, xpd->proc_xpd_dir);
|
||||
xpd->proc_xpd_summary = NULL;
|
||||
}
|
||||
XPD_DBG(PROC, xpd, "Removing %s/%s proc directory\n",
|
||||
xbus->busname, xpd->xpdname);
|
||||
xbus->busname, xpd->xpdname);
|
||||
remove_proc_entry(xpd->xpdname, xbus->proc_xbus_dir);
|
||||
xpd->proc_xpd_dir = NULL;
|
||||
}
|
||||
@ -173,10 +176,12 @@ static int xpd_proc_create(xbus_t *xbus, xpd_t *xpd)
|
||||
XPD_ERR(xpd, "Failed to create proc directory\n");
|
||||
goto err;
|
||||
}
|
||||
xpd->proc_xpd_summary = create_proc_read_entry(PROC_XPD_SUMMARY, 0444, xpd->proc_xpd_dir,
|
||||
xpd_read_proc, xpd);
|
||||
xpd->proc_xpd_summary =
|
||||
create_proc_read_entry(PROC_XPD_SUMMARY, 0444, xpd->proc_xpd_dir,
|
||||
xpd_read_proc, xpd);
|
||||
if (!xpd->proc_xpd_summary) {
|
||||
XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_XPD_SUMMARY);
|
||||
XPD_ERR(xpd, "Failed to create proc file '%s'\n",
|
||||
PROC_XPD_SUMMARY);
|
||||
goto err;
|
||||
}
|
||||
SET_PROC_DIRENTRY_OWNER(xpd->proc_xpd_summary);
|
||||
@ -191,7 +196,7 @@ err:
|
||||
|
||||
void xpd_free(xpd_t *xpd)
|
||||
{
|
||||
xbus_t *xbus = NULL;
|
||||
xbus_t *xbus = NULL;
|
||||
|
||||
if (!xpd)
|
||||
return;
|
||||
@ -210,43 +215,41 @@ void xpd_free(xpd_t *xpd)
|
||||
/*
|
||||
* This must be last, so the xbus cannot be released before the xpd
|
||||
*/
|
||||
put_xbus(__func__, xbus); /* was taken in xpd_alloc() */
|
||||
put_xbus(__func__, xbus); /* was taken in xpd_alloc() */
|
||||
}
|
||||
|
||||
/*
|
||||
* Synchronous part of XPD detection.
|
||||
* Called from new_card()
|
||||
*/
|
||||
int create_xpd(xbus_t *xbus, const xproto_table_t *proto_table,
|
||||
int unit,
|
||||
int subunit,
|
||||
__u8 type,
|
||||
__u8 subtype,
|
||||
int subunits,
|
||||
int subunit_ports,
|
||||
__u8 port_dir)
|
||||
int create_xpd(xbus_t *xbus, const xproto_table_t *proto_table, int unit,
|
||||
int subunit, __u8 type, __u8 subtype, int subunits,
|
||||
int subunit_ports, __u8 port_dir)
|
||||
{
|
||||
xpd_t *xpd = NULL;
|
||||
bool to_phone;
|
||||
xpd_t *xpd = NULL;
|
||||
bool to_phone;
|
||||
|
||||
BUG_ON(type == XPD_TYPE_NOMODULE);
|
||||
to_phone = BIT(subunit) & port_dir;
|
||||
BUG_ON(!xbus);
|
||||
xpd = xpd_byaddr(xbus, unit, subunit);
|
||||
if (xpd) {
|
||||
XPD_NOTICE(xpd, "XPD at %d%d already exists\n",
|
||||
unit, subunit);
|
||||
XPD_NOTICE(xpd, "XPD at %d%d already exists\n", unit, subunit);
|
||||
return 0;
|
||||
}
|
||||
if (subunit_ports <= 0 || subunit_ports > CHANNELS_PERXPD) {
|
||||
XBUS_NOTICE(xbus, "Illegal number of ports %d for XPD %d%d\n",
|
||||
subunit_ports, unit, subunit);
|
||||
subunit_ports, unit, subunit);
|
||||
return 0;
|
||||
}
|
||||
xpd = proto_table->xops->card_new(xbus, unit, subunit, proto_table, subtype, subunits, subunit_ports, to_phone);
|
||||
xpd =
|
||||
proto_table->xops->card_new(xbus, unit, subunit, proto_table,
|
||||
subtype, subunits, subunit_ports,
|
||||
to_phone);
|
||||
if (!xpd) {
|
||||
XBUS_NOTICE(xbus, "card_new(%d,%d,%d,%d,%d) failed. Ignored.\n",
|
||||
unit, subunit, proto_table->type, subtype, to_phone);
|
||||
unit, subunit, proto_table->type, subtype,
|
||||
to_phone);
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
@ -263,43 +266,55 @@ int create_xpd(xbus_t *xbus, const xproto_table_t *proto_table,
|
||||
* @eof TODO: figure out procfs
|
||||
* @data an xbus_t pointer with the bus data.
|
||||
*/
|
||||
static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)
|
||||
static int xpd_read_proc(char *page, char **start, off_t off, int count,
|
||||
int *eof, void *data)
|
||||
{
|
||||
int len = 0;
|
||||
xpd_t *xpd = data;
|
||||
int i;
|
||||
int len = 0;
|
||||
xpd_t *xpd = data;
|
||||
int i;
|
||||
|
||||
if (!xpd)
|
||||
goto out;
|
||||
|
||||
len += sprintf(page + len, "%s (%s, card %s, span %d)\n"
|
||||
"timing_priority: %d\n"
|
||||
"timer_count: %d span->mainttimer=%d\n"
|
||||
,
|
||||
xpd->xpdname, xpd->type_name,
|
||||
(xpd->card_present) ? "present" : "missing",
|
||||
(SPAN_REGISTERED(xpd)) ? PHONEDEV(xpd).span.spanno : 0,
|
||||
PHONEDEV(xpd).timing_priority,
|
||||
xpd->timer_count, PHONEDEV(xpd).span.mainttimer
|
||||
);
|
||||
len += sprintf(page + len, "xpd_state: %s (%d)\n",
|
||||
xpd_statename(xpd->xpd_state), xpd->xpd_state);
|
||||
len += sprintf(page + len, "open_counter=%d refcount=%d\n",
|
||||
atomic_read(&PHONEDEV(xpd).open_counter), refcount_xpd(xpd));
|
||||
len += sprintf(page + len, "Address: U=%d S=%d\n", xpd->addr.unit, xpd->addr.subunit);
|
||||
len +=
|
||||
sprintf(page + len,
|
||||
"%s (%s, card %s, span %d)\n" "timing_priority: %d\n"
|
||||
"timer_count: %d span->mainttimer=%d\n", xpd->xpdname,
|
||||
xpd->type_name, (xpd->card_present) ? "present" : "missing",
|
||||
(SPAN_REGISTERED(xpd)) ? PHONEDEV(xpd).span.spanno : 0,
|
||||
PHONEDEV(xpd).timing_priority, xpd->timer_count,
|
||||
PHONEDEV(xpd).span.mainttimer);
|
||||
len +=
|
||||
sprintf(page + len, "xpd_state: %s (%d)\n",
|
||||
xpd_statename(xpd->xpd_state), xpd->xpd_state);
|
||||
len +=
|
||||
sprintf(page + len, "open_counter=%d refcount=%d\n",
|
||||
atomic_read(&PHONEDEV(xpd).open_counter),
|
||||
refcount_xpd(xpd));
|
||||
len +=
|
||||
sprintf(page + len, "Address: U=%d S=%d\n", xpd->addr.unit,
|
||||
xpd->addr.subunit);
|
||||
len += sprintf(page + len, "Subunits: %d\n", xpd->subunits);
|
||||
len += sprintf(page + len, "Type: %d.%d\n\n", xpd->type, xpd->subtype);
|
||||
len += sprintf(page + len, "pcm_len=%d\n\n", PHONEDEV(xpd).pcm_len);
|
||||
len += sprintf(page + len, "wanted_pcm_mask=0x%04X\n\n", PHONEDEV(xpd).wanted_pcm_mask);
|
||||
len += sprintf(page + len, "mute_dtmf=0x%04X\n\n", PHONEDEV(xpd).mute_dtmf);
|
||||
len +=
|
||||
sprintf(page + len, "wanted_pcm_mask=0x%04X\n\n",
|
||||
PHONEDEV(xpd).wanted_pcm_mask);
|
||||
len +=
|
||||
sprintf(page + len, "mute_dtmf=0x%04X\n\n",
|
||||
PHONEDEV(xpd).mute_dtmf);
|
||||
len += sprintf(page + len, "STATES:");
|
||||
len += sprintf(page + len, "\n\t%-17s: ", "output_relays");
|
||||
for_each_line(xpd, i) {
|
||||
len += sprintf(page + len, "%d ", IS_SET(PHONEDEV(xpd).digital_outputs, i));
|
||||
len +=
|
||||
sprintf(page + len, "%d ",
|
||||
IS_SET(PHONEDEV(xpd).digital_outputs, i));
|
||||
}
|
||||
len += sprintf(page + len, "\n\t%-17s: ", "input_relays");
|
||||
for_each_line(xpd, i) {
|
||||
len += sprintf(page + len, "%d ", IS_SET(PHONEDEV(xpd).digital_inputs, i));
|
||||
len +=
|
||||
sprintf(page + len, "%d ",
|
||||
IS_SET(PHONEDEV(xpd).digital_inputs, i));
|
||||
}
|
||||
len += sprintf(page + len, "\n\t%-17s: ", "offhook");
|
||||
for_each_line(xpd, i) {
|
||||
@ -307,7 +322,9 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
|
||||
}
|
||||
len += sprintf(page + len, "\n\t%-17s: ", "oht_pcm_pass");
|
||||
for_each_line(xpd, i) {
|
||||
len += sprintf(page + len, "%d ", IS_SET(PHONEDEV(xpd).oht_pcm_pass, i));
|
||||
len +=
|
||||
sprintf(page + len, "%d ",
|
||||
IS_SET(PHONEDEV(xpd).oht_pcm_pass, i));
|
||||
}
|
||||
len += sprintf(page + len, "\n\t%-17s: ", "msg_waiting");
|
||||
for_each_line(xpd, i) {
|
||||
@ -319,17 +336,20 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
|
||||
}
|
||||
len += sprintf(page + len, "\n\t%-17s: ", "no_pcm");
|
||||
for_each_line(xpd, i) {
|
||||
len += sprintf(page + len, "%d ", IS_SET(PHONEDEV(xpd).no_pcm, i));
|
||||
len +=
|
||||
sprintf(page + len, "%d ", IS_SET(PHONEDEV(xpd).no_pcm, i));
|
||||
}
|
||||
#if 1
|
||||
if (SPAN_REGISTERED(xpd)) {
|
||||
len += sprintf(page + len, "\nPCM:\n | [readchunk] | [writechunk] | W D");
|
||||
len +=
|
||||
sprintf(page + len,
|
||||
"\nPCM:\n | [readchunk] | [writechunk] | W D");
|
||||
for_each_line(xpd, i) {
|
||||
struct dahdi_chan *chan = XPD_CHAN(xpd, i);
|
||||
__u8 rchunk[DAHDI_CHUNKSIZE];
|
||||
__u8 wchunk[DAHDI_CHUNKSIZE];
|
||||
__u8 *rp;
|
||||
__u8 *wp;
|
||||
struct dahdi_chan *chan = XPD_CHAN(xpd, i);
|
||||
__u8 rchunk[DAHDI_CHUNKSIZE];
|
||||
__u8 wchunk[DAHDI_CHUNKSIZE];
|
||||
__u8 *rp;
|
||||
__u8 *wp;
|
||||
int j;
|
||||
|
||||
if (IS_SET(PHONEDEV(xpd).digital_outputs, i))
|
||||
@ -350,10 +370,14 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
|
||||
for (j = 0; j < DAHDI_CHUNKSIZE; j++) {
|
||||
len += sprintf(page + len, "%02X ", wchunk[j]);
|
||||
}
|
||||
len += sprintf(page + len, " | %c",
|
||||
(IS_SET(PHONEDEV(xpd).wanted_pcm_mask, i))?'+':' ');
|
||||
len += sprintf(page + len, " %c",
|
||||
(IS_SET(PHONEDEV(xpd).mute_dtmf, i))?'-':' ');
|
||||
len +=
|
||||
sprintf(page + len, " | %c",
|
||||
(IS_SET(PHONEDEV(xpd).wanted_pcm_mask, i)) ?
|
||||
'+' : ' ');
|
||||
len +=
|
||||
sprintf(page + len, " %c",
|
||||
(IS_SET(PHONEDEV(xpd).mute_dtmf, i)) ? '-' :
|
||||
' ');
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -362,18 +386,22 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
|
||||
len += sprintf(page + len, "\nSignalling:\n");
|
||||
for_each_line(xpd, i) {
|
||||
struct dahdi_chan *chan = XPD_CHAN(xpd, i);
|
||||
len += sprintf(page + len, "\t%2d> sigcap=0x%04X sig=0x%04X\n", i, chan->sigcap, chan->sig);
|
||||
len +=
|
||||
sprintf(page + len,
|
||||
"\t%2d> sigcap=0x%04X sig=0x%04X\n", i,
|
||||
chan->sigcap, chan->sig);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
len += sprintf(page + len, "\nCOUNTERS:\n");
|
||||
for (i = 0; i < XPD_COUNTER_MAX; i++) {
|
||||
len += sprintf(page + len, "\t\t%-20s = %d\n",
|
||||
xpd_counters[i].name, xpd->counters[i]);
|
||||
len +=
|
||||
sprintf(page + len, "\t\t%-20s = %d\n",
|
||||
xpd_counters[i].name, xpd->counters[i]);
|
||||
}
|
||||
len += sprintf(page + len, "<-- len=%d\n", len);
|
||||
out:
|
||||
if (len <= off+count)
|
||||
if (len <= off + count)
|
||||
*eof = 1;
|
||||
*start = page + off;
|
||||
len -= off;
|
||||
@ -390,10 +418,14 @@ out:
|
||||
const char *xpd_statename(enum xpd_state st)
|
||||
{
|
||||
switch (st) {
|
||||
case XPD_STATE_START: return "START";
|
||||
case XPD_STATE_INIT_REGS: return "INIT_REGS";
|
||||
case XPD_STATE_READY: return "READY";
|
||||
case XPD_STATE_NOHW: return "NOHW";
|
||||
case XPD_STATE_START:
|
||||
return "START";
|
||||
case XPD_STATE_INIT_REGS:
|
||||
return "INIT_REGS";
|
||||
case XPD_STATE_READY:
|
||||
return "READY";
|
||||
case XPD_STATE_NOHW:
|
||||
return "NOHW";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -412,8 +444,8 @@ bool xpd_setstate(xpd_t *xpd, enum xpd_state newstate)
|
||||
goto badstate;
|
||||
if (xpd->addr.subunit != 0) {
|
||||
XPD_NOTICE(xpd,
|
||||
"%s: Moving to %s allowed only for subunit 0\n",
|
||||
__func__, xpd_statename(newstate));
|
||||
"%s: Moving to %s allowed only for subunit 0\n",
|
||||
__func__, xpd_statename(newstate));
|
||||
goto badstate;
|
||||
}
|
||||
break;
|
||||
@ -435,21 +467,19 @@ bool xpd_setstate(xpd_t *xpd, enum xpd_state newstate)
|
||||
xpd->xpd_state = newstate;
|
||||
return 1;
|
||||
badstate:
|
||||
XPD_NOTICE(xpd, "%s: cannot transition: %s (%d) -> %s (%d)\n",
|
||||
__func__,
|
||||
xpd_statename(xpd->xpd_state), xpd->xpd_state,
|
||||
xpd_statename(newstate), newstate);
|
||||
XPD_NOTICE(xpd, "%s: cannot transition: %s (%d) -> %s (%d)\n", __func__,
|
||||
xpd_statename(xpd->xpd_state), xpd->xpd_state,
|
||||
xpd_statename(newstate), newstate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Cleanup/initialize phonedev
|
||||
*/
|
||||
static void phonedev_cleanup(xpd_t *xpd)
|
||||
{
|
||||
struct phonedev *phonedev = &PHONEDEV(xpd);
|
||||
unsigned int x;
|
||||
struct phonedev *phonedev = &PHONEDEV(xpd);
|
||||
unsigned int x;
|
||||
|
||||
for (x = 0; x < phonedev->channels; x++) {
|
||||
if (phonedev->chans[x]) {
|
||||
@ -460,11 +490,12 @@ static void phonedev_cleanup(xpd_t *xpd)
|
||||
}
|
||||
}
|
||||
|
||||
__must_check static int phonedev_init(xpd_t *xpd, const xproto_table_t *proto_table,
|
||||
int channels, xpp_line_t no_pcm)
|
||||
__must_check static int phonedev_init(xpd_t *xpd,
|
||||
const xproto_table_t *proto_table,
|
||||
int channels, xpp_line_t no_pcm)
|
||||
{
|
||||
struct phonedev *phonedev = &PHONEDEV(xpd);
|
||||
unsigned int x;
|
||||
struct phonedev *phonedev = &PHONEDEV(xpd);
|
||||
unsigned int x;
|
||||
|
||||
spin_lock_init(&phonedev->lock_recompute_pcm);
|
||||
phonedev->channels = channels;
|
||||
@ -476,15 +507,17 @@ __must_check static int phonedev_init(xpd_t *xpd, const xproto_table_t *proto_ta
|
||||
atomic_set(&phonedev->dahdi_registered, 0);
|
||||
atomic_set(&phonedev->open_counter, 0);
|
||||
for (x = 0; x < phonedev->channels; x++) {
|
||||
if (!(phonedev->chans[x] = KZALLOC(sizeof(*(phonedev->chans[x])), GFP_KERNEL))) {
|
||||
if (!
|
||||
(phonedev->chans[x] =
|
||||
KZALLOC(sizeof(*(phonedev->chans[x])), GFP_KERNEL))) {
|
||||
ERR("%s: Unable to allocate channel %d\n", __func__, x);
|
||||
goto err;
|
||||
}
|
||||
phonedev->ec[x] = KZALLOC(sizeof(*(phonedev->ec[x])),
|
||||
GFP_KERNEL);
|
||||
phonedev->ec[x] =
|
||||
KZALLOC(sizeof(*(phonedev->ec[x])), GFP_KERNEL);
|
||||
if (!phonedev->ec[x]) {
|
||||
ERR("%s: Unable to allocate ec state %d\n", __func__,
|
||||
x);
|
||||
x);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -498,28 +531,27 @@ err:
|
||||
* xpd_alloc - Allocator for new XPD's
|
||||
*
|
||||
*/
|
||||
__must_check xpd_t *xpd_alloc(xbus_t *xbus,
|
||||
int unit, int subunit,
|
||||
int subtype, int subunits,
|
||||
size_t privsize, const xproto_table_t *proto_table, int channels)
|
||||
__must_check xpd_t *xpd_alloc(xbus_t *xbus, int unit, int subunit, int subtype,
|
||||
int subunits, size_t privsize,
|
||||
const xproto_table_t *proto_table, int channels)
|
||||
{
|
||||
xpd_t *xpd = NULL;
|
||||
size_t alloc_size = sizeof(xpd_t) + privsize;
|
||||
int type = proto_table->type;
|
||||
xpp_line_t no_pcm = 0;
|
||||
xpd_t *xpd = NULL;
|
||||
size_t alloc_size = sizeof(xpd_t) + privsize;
|
||||
int type = proto_table->type;
|
||||
xpp_line_t no_pcm = 0;
|
||||
|
||||
BUG_ON(!proto_table);
|
||||
XBUS_DBG(DEVICES, xbus, "type=%d channels=%d (alloc_size=%zd)\n",
|
||||
type, channels, alloc_size);
|
||||
XBUS_DBG(DEVICES, xbus, "type=%d channels=%d (alloc_size=%zd)\n", type,
|
||||
channels, alloc_size);
|
||||
if (channels > CHANNELS_PERXPD) {
|
||||
XBUS_ERR(xbus, "%s: type=%d: too many channels %d\n",
|
||||
__func__, type, channels);
|
||||
XBUS_ERR(xbus, "%s: type=%d: too many channels %d\n", __func__,
|
||||
type, channels);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((xpd = KZALLOC(alloc_size, GFP_KERNEL)) == NULL) {
|
||||
XBUS_ERR(xbus, "%s: type=%d: Unable to allocate memory\n",
|
||||
__func__, type);
|
||||
__func__, type);
|
||||
goto err;
|
||||
}
|
||||
xpd->priv = (__u8 *)xpd + sizeof(xpd_t);
|
||||
@ -535,9 +567,12 @@ __must_check xpd_t *xpd_alloc(xbus_t *xbus,
|
||||
|
||||
/* For USB-1 disable some channels */
|
||||
if (MAX_SEND_SIZE(xbus) < RPACKET_SIZE(GLOBAL, PCM_WRITE)) {
|
||||
no_pcm = 0x7F | PHONEDEV(xpd).digital_outputs | PHONEDEV(xpd).digital_inputs;
|
||||
XBUS_NOTICE(xbus, "max xframe size = %d, disabling some PCM channels. no_pcm=0x%04X\n",
|
||||
MAX_SEND_SIZE(xbus), PHONEDEV(xpd).no_pcm);
|
||||
no_pcm =
|
||||
0x7F | PHONEDEV(xpd).digital_outputs | PHONEDEV(xpd).
|
||||
digital_inputs;
|
||||
XBUS_NOTICE(xbus,
|
||||
"max xframe size = %d, disabling some PCM channels. no_pcm=0x%04X\n",
|
||||
MAX_SEND_SIZE(xbus), PHONEDEV(xpd).no_pcm);
|
||||
}
|
||||
if (phonedev_init(xpd, proto_table, channels, no_pcm) < 0)
|
||||
goto err;
|
||||
@ -549,7 +584,7 @@ __must_check xpd_t *xpd_alloc(xbus_t *xbus,
|
||||
* is removed in xpd_free()
|
||||
*/
|
||||
xbus = get_xbus(__func__, xbus->num); /* returned in xpd_free() */
|
||||
xproto_get(type); /* will be returned in xpd_free() */
|
||||
xproto_get(type); /* will be returned in xpd_free() */
|
||||
return xpd;
|
||||
err:
|
||||
if (xpd) {
|
||||
@ -580,16 +615,17 @@ void update_xpd_status(xpd_t *xpd, int alarm_flag)
|
||||
return;
|
||||
}
|
||||
switch (alarm_flag) {
|
||||
case DAHDI_ALARM_NONE:
|
||||
xpd->last_response = jiffies;
|
||||
break;
|
||||
default:
|
||||
// Nothing
|
||||
break;
|
||||
case DAHDI_ALARM_NONE:
|
||||
xpd->last_response = jiffies;
|
||||
break;
|
||||
default:
|
||||
// Nothing
|
||||
break;
|
||||
}
|
||||
if (span->alarms == alarm_flag)
|
||||
return;
|
||||
XPD_DBG(GENERAL, xpd, "Update XPD alarms: %s -> %02X\n", PHONEDEV(xpd).span.name, alarm_flag);
|
||||
XPD_DBG(GENERAL, xpd, "Update XPD alarms: %s -> %02X\n",
|
||||
PHONEDEV(xpd).span.name, alarm_flag);
|
||||
span->alarms = alarm_flag;
|
||||
dahdi_alarm_notify(span);
|
||||
}
|
||||
@ -661,24 +697,24 @@ void hookstate_changed(xpd_t *xpd, int pos, bool to_offhook)
|
||||
*/
|
||||
BIT_SET(PHONEDEV(xpd).silence_pcm, pos);
|
||||
}
|
||||
notify_rxsig(xpd, pos, (to_offhook) ? DAHDI_RXSIG_OFFHOOK : DAHDI_RXSIG_ONHOOK);
|
||||
notify_rxsig(xpd, pos,
|
||||
(to_offhook) ? DAHDI_RXSIG_OFFHOOK : DAHDI_RXSIG_ONHOOK);
|
||||
}
|
||||
|
||||
#define XPP_MAX_LEN 512
|
||||
|
||||
/*------------------------- Dahdi Interfaces -----------------------*/
|
||||
|
||||
|
||||
/*
|
||||
* Called from dahdi with spinlock held on chan. Must not call back
|
||||
* dahdi functions.
|
||||
*/
|
||||
int xpp_open(struct dahdi_chan *chan)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
xbus_t *xbus;
|
||||
int pos;
|
||||
unsigned long flags;
|
||||
xpd_t *xpd;
|
||||
xbus_t *xbus;
|
||||
int pos;
|
||||
unsigned long flags;
|
||||
|
||||
if (!chan) {
|
||||
NOTICE("open called on a null chan\n");
|
||||
@ -701,9 +737,8 @@ int xpp_open(struct dahdi_chan *chan)
|
||||
}
|
||||
spin_lock_irqsave(&xbus->lock, flags);
|
||||
atomic_inc(&PHONEDEV(xpd).open_counter);
|
||||
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n",
|
||||
current->comm, current->pid,
|
||||
atomic_read(&PHONEDEV(xpd).open_counter));
|
||||
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm,
|
||||
current->pid, atomic_read(&PHONEDEV(xpd).open_counter));
|
||||
spin_unlock_irqrestore(&xbus->lock, flags);
|
||||
if (PHONE_METHOD(card_open, xpd))
|
||||
CALL_PHONE_METHOD(card_open, xpd, pos);
|
||||
@ -712,25 +747,24 @@ int xpp_open(struct dahdi_chan *chan)
|
||||
|
||||
int xpp_close(struct dahdi_chan *chan)
|
||||
{
|
||||
xpd_t *xpd = chan->pvt;
|
||||
xbus_t *xbus = xpd->xbus;
|
||||
int pos = chan->chanpos - 1;
|
||||
unsigned long flags;
|
||||
xpd_t *xpd = chan->pvt;
|
||||
xbus_t *xbus = xpd->xbus;
|
||||
int pos = chan->chanpos - 1;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&xbus->lock, flags);
|
||||
spin_unlock_irqrestore(&xbus->lock, flags);
|
||||
if (PHONE_METHOD(card_close, xpd))
|
||||
CALL_PHONE_METHOD(card_close, xpd, pos);
|
||||
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n",
|
||||
current->comm, current->pid,
|
||||
atomic_read(&PHONEDEV(xpd).open_counter));
|
||||
atomic_dec(&PHONEDEV(xpd).open_counter); /* from xpp_open() */
|
||||
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm,
|
||||
current->pid, atomic_read(&PHONEDEV(xpd).open_counter));
|
||||
atomic_dec(&PHONEDEV(xpd).open_counter); /* from xpp_open() */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void report_bad_ioctl(const char *msg, xpd_t *xpd, int pos, unsigned int cmd)
|
||||
{
|
||||
char *extra_msg = "";
|
||||
char *extra_msg = "";
|
||||
|
||||
if (_IOC_TYPE(cmd) == 'J')
|
||||
extra_msg = " (for old ZAPTEL)";
|
||||
@ -744,48 +778,51 @@ void report_bad_ioctl(const char *msg, xpd_t *xpd, int pos, unsigned int cmd)
|
||||
|
||||
int xpp_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
xpd_t *xpd = chan->pvt;
|
||||
int pos = chan->chanpos - 1;
|
||||
xpd_t *xpd = chan->pvt;
|
||||
int pos = chan->chanpos - 1;
|
||||
|
||||
if (!xpd) {
|
||||
ERR("%s: channel in pos %d, was already closed. Ignore.\n",
|
||||
__func__, pos);
|
||||
__func__, pos);
|
||||
return -ENODEV;
|
||||
}
|
||||
switch (cmd) {
|
||||
default:
|
||||
/* Some span-specific commands before we give up: */
|
||||
if (PHONE_METHOD(card_ioctl, xpd)) {
|
||||
return CALL_PHONE_METHOD(card_ioctl, xpd, pos, cmd, arg);
|
||||
}
|
||||
report_bad_ioctl(THIS_MODULE->name, xpd, pos, cmd);
|
||||
return -ENOTTY;
|
||||
default:
|
||||
/* Some span-specific commands before we give up: */
|
||||
if (PHONE_METHOD(card_ioctl, xpd)) {
|
||||
return CALL_PHONE_METHOD(card_ioctl, xpd, pos, cmd,
|
||||
arg);
|
||||
}
|
||||
report_bad_ioctl(THIS_MODULE->name, xpd, pos, cmd);
|
||||
return -ENOTTY;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xpp_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig)
|
||||
{
|
||||
xpd_t *xpd = chan->pvt;
|
||||
xbus_t *xbus;
|
||||
xpd_t *xpd = chan->pvt;
|
||||
xbus_t *xbus;
|
||||
int pos = chan->chanpos - 1;
|
||||
|
||||
if (!xpd) {
|
||||
ERR("%s: channel in pos %d, was already closed. Ignore.\n",
|
||||
__func__, pos);
|
||||
__func__, pos);
|
||||
return -ENODEV;
|
||||
}
|
||||
if (!PHONE_METHOD(card_hooksig, xpd)) {
|
||||
LINE_ERR(xpd, pos,
|
||||
"%s: No hooksig method for this channel. Ignore.\n",
|
||||
__func__);
|
||||
"%s: No hooksig method for this channel. Ignore.\n",
|
||||
__func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
xbus = xpd->xbus;
|
||||
BUG_ON(!xbus);
|
||||
DBG(SIGNAL, "Setting %s to %s (%d)\n", chan->name, txsig2str(txsig), txsig);
|
||||
DBG(SIGNAL, "Setting %s to %s (%d)\n", chan->name, txsig2str(txsig),
|
||||
txsig);
|
||||
return CALL_PHONE_METHOD(card_hooksig, xpd, pos, txsig);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(xpp_hooksig);
|
||||
|
||||
/* Req: Set the requested chunk size. This is the unit in which you must
|
||||
@ -795,34 +832,34 @@ int xpp_setchunksize(struct dahdi_span *span, int chunksize);
|
||||
/* Enable maintenance modes */
|
||||
int xpp_maint(struct dahdi_span *span, int cmd)
|
||||
{
|
||||
struct phonedev *phonedev = container_of(span, struct phonedev, span);
|
||||
xpd_t *xpd = container_of(phonedev, struct xpd, phonedev);
|
||||
int ret = 0;
|
||||
struct phonedev *phonedev = container_of(span, struct phonedev, span);
|
||||
xpd_t *xpd = container_of(phonedev, struct xpd, phonedev);
|
||||
int ret = 0;
|
||||
#if 0
|
||||
char loopback_data[] = "THE-QUICK-BROWN-FOX-JUMPED-OVER-THE-LAZY-DOG";
|
||||
char loopback_data[] = "THE-QUICK-BROWN-FOX-JUMPED-OVER-THE-LAZY-DOG";
|
||||
#endif
|
||||
|
||||
DBG(GENERAL, "span->mainttimer=%d\n", span->mainttimer);
|
||||
switch (cmd) {
|
||||
case DAHDI_MAINT_NONE:
|
||||
INFO("XXX Turn off local and remote loops XXX\n");
|
||||
break;
|
||||
case DAHDI_MAINT_LOCALLOOP:
|
||||
INFO("XXX Turn on local loopback XXX\n");
|
||||
break;
|
||||
case DAHDI_MAINT_REMOTELOOP:
|
||||
INFO("XXX Turn on remote loopback XXX\n");
|
||||
break;
|
||||
case DAHDI_MAINT_LOOPUP:
|
||||
INFO("XXX Send loopup code XXX\n");
|
||||
break;
|
||||
case DAHDI_MAINT_LOOPDOWN:
|
||||
INFO("XXX Send loopdown code XXX\n");
|
||||
break;
|
||||
default:
|
||||
ERR("XPP: Unknown maint command: %d\n", cmd);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
case DAHDI_MAINT_NONE:
|
||||
INFO("XXX Turn off local and remote loops XXX\n");
|
||||
break;
|
||||
case DAHDI_MAINT_LOCALLOOP:
|
||||
INFO("XXX Turn on local loopback XXX\n");
|
||||
break;
|
||||
case DAHDI_MAINT_REMOTELOOP:
|
||||
INFO("XXX Turn on remote loopback XXX\n");
|
||||
break;
|
||||
case DAHDI_MAINT_LOOPUP:
|
||||
INFO("XXX Send loopup code XXX\n");
|
||||
break;
|
||||
case DAHDI_MAINT_LOOPDOWN:
|
||||
INFO("XXX Send loopdown code XXX\n");
|
||||
break;
|
||||
default:
|
||||
ERR("XPP: Unknown maint command: %d\n", cmd);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
if (span->mainttimer || span->maintstat)
|
||||
update_xpd_status(xpd, DAHDI_ALARM_LOOPBACK);
|
||||
@ -836,7 +873,7 @@ int xpp_maint(struct dahdi_span *span, int cmd)
|
||||
*/
|
||||
static int xpp_watchdog(struct dahdi_span *span, int cause)
|
||||
{
|
||||
static int rate_limit;
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 1000) == 0)
|
||||
DBG(GENERAL, "\n");
|
||||
@ -848,12 +885,12 @@ static int xpp_watchdog(struct dahdi_span *span, int cause)
|
||||
* Hardware Echo Canceller management
|
||||
*/
|
||||
static void echocan_free(struct dahdi_chan *chan,
|
||||
struct dahdi_echocan_state *ec)
|
||||
struct dahdi_echocan_state *ec)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
xbus_t *xbus;
|
||||
int pos = chan->chanpos - 1;
|
||||
const struct echoops *echoops;
|
||||
xpd_t *xpd;
|
||||
xbus_t *xbus;
|
||||
int pos = chan->chanpos - 1;
|
||||
const struct echoops *echoops;
|
||||
|
||||
xpd = chan->pvt;
|
||||
xbus = xpd->xbus;
|
||||
@ -875,9 +912,9 @@ static const struct dahdi_echocan_ops xpp_ec_ops = {
|
||||
|
||||
const char *xpp_echocan_name(const struct dahdi_chan *chan)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
xbus_t *xbus;
|
||||
int pos;
|
||||
xpd_t *xpd;
|
||||
xbus_t *xbus;
|
||||
int pos;
|
||||
|
||||
if (!chan) {
|
||||
NOTICE("%s(NULL)\n", __func__);
|
||||
@ -893,37 +930,34 @@ const char *xpp_echocan_name(const struct dahdi_chan *chan)
|
||||
* quirks and limitations
|
||||
*/
|
||||
if (xbus->quirks.has_fxo) {
|
||||
if (
|
||||
xbus->quirks.has_digital_span &&
|
||||
xpd->type == XPD_TYPE_FXO) {
|
||||
if (xbus->quirks.has_digital_span && xpd->type == XPD_TYPE_FXO) {
|
||||
LINE_NOTICE(xpd, pos,
|
||||
"quirk: give up HWEC on FXO: "
|
||||
"AB has digital span\n");
|
||||
"quirk: give up HWEC on FXO: "
|
||||
"AB has digital span\n");
|
||||
return NULL;
|
||||
} else if (
|
||||
xbus->sync_mode != SYNC_MODE_AB &&
|
||||
xpd->type == XPD_TYPE_FXS) {
|
||||
} else if (xbus->sync_mode != SYNC_MODE_AB
|
||||
&& xpd->type == XPD_TYPE_FXS) {
|
||||
LINE_NOTICE(xpd, pos,
|
||||
"quirk: give up HWEC on FXS: "
|
||||
"AB has FXO and is sync slave\n");
|
||||
"quirk: give up HWEC on FXS: "
|
||||
"AB has FXO and is sync slave\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return "XPP";
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(xpp_echocan_name);
|
||||
|
||||
int xpp_echocan_create(struct dahdi_chan *chan,
|
||||
struct dahdi_echocanparams *ecp,
|
||||
struct dahdi_echocanparam *p,
|
||||
struct dahdi_echocan_state **ec)
|
||||
int xpp_echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
|
||||
struct dahdi_echocanparam *p,
|
||||
struct dahdi_echocan_state **ec)
|
||||
{
|
||||
xpd_t *xpd;
|
||||
xbus_t *xbus;
|
||||
int pos;
|
||||
struct phonedev *phonedev;
|
||||
const struct echoops *echoops;
|
||||
int ret;
|
||||
xpd_t *xpd;
|
||||
xbus_t *xbus;
|
||||
int pos;
|
||||
struct phonedev *phonedev;
|
||||
const struct echoops *echoops;
|
||||
int ret;
|
||||
|
||||
xpd = chan->pvt;
|
||||
xbus = xpd->xbus;
|
||||
@ -937,17 +971,18 @@ int xpp_echocan_create(struct dahdi_chan *chan,
|
||||
(*ec)->features = xpp_ec_features;
|
||||
xpd = get_xpd(__func__, xpd); /* Returned in echocan_free() */
|
||||
LINE_DBG(GENERAL, xpd, pos, "(tap=%d, param_count=%d)\n",
|
||||
ecp->tap_length, ecp->param_count);
|
||||
ecp->tap_length, ecp->param_count);
|
||||
ret = CALL_EC_METHOD(ec_set, xbus, xpd, pos, 1);
|
||||
CALL_EC_METHOD(ec_update, xbus, xbus);
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(xpp_echocan_create);
|
||||
|
||||
void xpp_span_assigned(struct dahdi_span *span)
|
||||
{
|
||||
struct phonedev *phonedev = container_of(span, struct phonedev, span);
|
||||
xpd_t *xpd = container_of(phonedev, struct xpd, phonedev);
|
||||
struct phonedev *phonedev = container_of(span, struct phonedev, span);
|
||||
xpd_t *xpd = container_of(phonedev, struct xpd, phonedev);
|
||||
|
||||
XPD_INFO(xpd, "Span assigned: %d\n", span->spanno);
|
||||
if (xpd->card_present) {
|
||||
@ -955,6 +990,7 @@ void xpp_span_assigned(struct dahdi_span *span)
|
||||
dahdi_alarm_notify(&phonedev->span);
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(xpp_span_assigned);
|
||||
|
||||
static const struct dahdi_span_ops xpp_span_ops = {
|
||||
@ -984,7 +1020,8 @@ void xpd_set_spanname(xpd_t *xpd)
|
||||
{
|
||||
struct dahdi_span *span = &PHONEDEV(xpd).span;
|
||||
|
||||
snprintf(span->name, MAX_SPANNAME, "%s/%s", xpd->xbus->busname, xpd->xpdname);
|
||||
snprintf(span->name, MAX_SPANNAME, "%s/%s", xpd->xbus->busname,
|
||||
xpd->xpdname);
|
||||
/*
|
||||
* The "Xorcom XPD" is a prefix in one of the regexes we
|
||||
* use in our dahdi_genconf to match for PRI cards.
|
||||
@ -992,14 +1029,15 @@ void xpd_set_spanname(xpd_t *xpd)
|
||||
* this horseshit.
|
||||
*/
|
||||
snprintf(span->desc, MAX_SPANDESC, "Xorcom XPD [%s].%d: %s",
|
||||
xpd->xbus->label, span->offset + 1, xpd->type_name);
|
||||
xpd->xbus->label, span->offset + 1, xpd->type_name);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(xpd_set_spanname);
|
||||
|
||||
static void xpd_init_span(xpd_t *xpd, unsigned offset, int cn)
|
||||
{
|
||||
struct dahdi_span *span;
|
||||
int i;
|
||||
struct dahdi_span *span;
|
||||
int i;
|
||||
|
||||
memset(&PHONEDEV(xpd).span, 0, sizeof(struct dahdi_span));
|
||||
for (i = 0; i < cn; i++)
|
||||
@ -1022,9 +1060,9 @@ static void xpd_init_span(xpd_t *xpd, unsigned offset, int cn)
|
||||
|
||||
int xpd_dahdi_preregister(xpd_t *xpd, unsigned offset)
|
||||
{
|
||||
xbus_t *xbus;
|
||||
int cn;
|
||||
struct phonedev *phonedev;
|
||||
xbus_t *xbus;
|
||||
int cn;
|
||||
struct phonedev *phonedev;
|
||||
|
||||
BUG_ON(!xpd);
|
||||
|
||||
@ -1052,7 +1090,7 @@ int xpd_dahdi_preregister(xpd_t *xpd, unsigned offset)
|
||||
|
||||
int xpd_dahdi_postregister(xpd_t *xpd)
|
||||
{
|
||||
int cn;
|
||||
int cn;
|
||||
|
||||
atomic_inc(&num_registered_spans);
|
||||
atomic_inc(&PHONEDEV(xpd).dahdi_registered);
|
||||
@ -1093,9 +1131,11 @@ void xpd_dahdi_preunregister(xpd_t *xpd)
|
||||
int j;
|
||||
|
||||
dahdi_alarm_notify(&PHONEDEV(xpd).span);
|
||||
XPD_DBG(DEVICES, xpd, "Queuing DAHDI_EVENT_REMOVED on all channels to ask user to release them\n");
|
||||
for (j=0; j<PHONEDEV(xpd).span.channels; j++) {
|
||||
dahdi_qevent_lock(XPD_CHAN(xpd, j), DAHDI_EVENT_REMOVED);
|
||||
XPD_DBG(DEVICES, xpd,
|
||||
"Queuing DAHDI_EVENT_REMOVED on all channels to ask user to release them\n");
|
||||
for (j = 0; j < PHONEDEV(xpd).span.channels; j++) {
|
||||
dahdi_qevent_lock(XPD_CHAN(xpd, j),
|
||||
DAHDI_EVENT_REMOVED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1125,11 +1165,11 @@ static void do_cleanup(void)
|
||||
|
||||
static int __init xpp_dahdi_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
void *top = NULL;
|
||||
int ret = 0;
|
||||
void *top = NULL;
|
||||
|
||||
INFO("revision %s MAX_XPDS=%d (%d*%d)\n", XPP_VERSION,
|
||||
MAX_XPDS, MAX_UNIT, MAX_SUBUNIT);
|
||||
INFO("revision %s MAX_XPDS=%d (%d*%d)\n", XPP_VERSION, MAX_XPDS,
|
||||
MAX_UNIT, MAX_SUBUNIT);
|
||||
#ifdef CONFIG_PROC_FS
|
||||
xpp_proc_toplevel = proc_mkdir(PROC_DIR, NULL);
|
||||
if (!xpp_proc_toplevel) {
|
||||
|
@ -30,17 +30,19 @@ int xpd_dahdi_preregister(xpd_t *xpd, unsigned offset);
|
||||
int xpd_dahdi_postregister(xpd_t *xpd);
|
||||
void xpd_dahdi_preunregister(xpd_t *xpd);
|
||||
void xpd_dahdi_postunregister(xpd_t *xpd);
|
||||
int create_xpd(xbus_t *xbus, const xproto_table_t *proto_table,
|
||||
int unit, int subunit, __u8 type, __u8 subtype, int subunits, int subunit_ports, __u8 port_dir);
|
||||
xpd_t *xpd_alloc(xbus_t *xbus, int unit, int subunit, int subtype, int subunits, size_t privsize, const xproto_table_t *proto_table, int channels);
|
||||
int create_xpd(xbus_t *xbus, const xproto_table_t *proto_table, int unit,
|
||||
int subunit, __u8 type, __u8 subtype, int subunits,
|
||||
int subunit_ports, __u8 port_dir);
|
||||
xpd_t *xpd_alloc(xbus_t *xbus, int unit, int subunit, int subtype, int subunits,
|
||||
size_t privsize, const xproto_table_t *proto_table,
|
||||
int channels);
|
||||
void xpd_free(xpd_t *xpd);
|
||||
void xpd_remove(xpd_t *xpd);
|
||||
void update_xpd_status(xpd_t *xpd, int alarm_flag);
|
||||
const char *xpp_echocan_name(const struct dahdi_chan *chan);
|
||||
int xpp_echocan_create(struct dahdi_chan *chan,
|
||||
struct dahdi_echocanparams *ecp,
|
||||
struct dahdi_echocanparam *p,
|
||||
struct dahdi_echocan_state **ec);
|
||||
int xpp_echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
|
||||
struct dahdi_echocanparam *p,
|
||||
struct dahdi_echocan_state **ec);
|
||||
void hookstate_changed(xpd_t *xpd, int pos, bool good);
|
||||
int xpp_open(struct dahdi_chan *chan);
|
||||
int xpp_close(struct dahdi_chan *chan);
|
||||
@ -58,9 +60,9 @@ void notify_rxsig(xpd_t *xpd, int pos, enum dahdi_rxsig rxsig);
|
||||
#ifdef CONFIG_PROC_FS
|
||||
#include <linux/proc_fs.h>
|
||||
|
||||
extern struct proc_dir_entry *xpp_proc_toplevel;
|
||||
extern struct proc_dir_entry *xpp_proc_toplevel;
|
||||
#endif
|
||||
|
||||
#define SPAN_REGISTERED(xpd) atomic_read(&PHONEDEV(xpd).dahdi_registered)
|
||||
|
||||
#endif /* XPP_DAHDI_H */
|
||||
#endif /* XPP_DAHDI_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,7 @@
|
||||
|
||||
static const char rcsid[] = "$Id$";
|
||||
|
||||
extern int debug;
|
||||
extern int debug;
|
||||
|
||||
static const xproto_table_t *xprotocol_tables[XPD_TYPE_NOMODULE];
|
||||
|
||||
@ -40,12 +40,14 @@ static const xproto_table_t *xprotocol_tables[XPD_TYPE_NOMODULE];
|
||||
|
||||
bool valid_xpd_addr(const struct xpd_addr *addr)
|
||||
{
|
||||
return ((addr->subunit & ~BITMASK(SUBUNIT_BITS)) == 0) && ((addr->unit & ~BITMASK(UNIT_BITS)) == 0);
|
||||
return ((addr->subunit & ~BITMASK(SUBUNIT_BITS)) == 0)
|
||||
&& ((addr->unit & ~BITMASK(UNIT_BITS)) == 0);
|
||||
}
|
||||
|
||||
/*---------------- General Protocol Management ----------------------------*/
|
||||
|
||||
const xproto_entry_t *xproto_card_entry(const xproto_table_t *table, __u8 opcode)
|
||||
const xproto_entry_t *xproto_card_entry(const xproto_table_t *table,
|
||||
__u8 opcode)
|
||||
{
|
||||
const xproto_entry_t *xe;
|
||||
|
||||
@ -82,11 +84,12 @@ const xproto_table_t *xproto_get(xpd_type_t cardtype)
|
||||
if (cardtype >= XPD_TYPE_NOMODULE)
|
||||
return NULL;
|
||||
xtable = xprotocol_tables[cardtype];
|
||||
if (!xtable) { /* Try to load the relevant module */
|
||||
if (!xtable) { /* Try to load the relevant module */
|
||||
int ret = request_module(XPD_TYPE_PREFIX "%d", cardtype);
|
||||
if (ret != 0) {
|
||||
NOTICE("%s: Failed to load module for type=%d. exit status=%d.\n",
|
||||
__func__, cardtype, ret);
|
||||
NOTICE
|
||||
("%s: Failed to load module for type=%d. exit status=%d.\n",
|
||||
__func__, cardtype, ret);
|
||||
/* Drop through: we may be lucky... */
|
||||
}
|
||||
xtable = xprotocol_tables[cardtype];
|
||||
@ -94,10 +97,12 @@ const xproto_table_t *xproto_get(xpd_type_t cardtype)
|
||||
if (xtable) {
|
||||
BUG_ON(!xtable->owner);
|
||||
#ifdef CONFIG_MODULE_UNLOAD
|
||||
DBG(GENERAL, "%s refcount was %d\n", xtable->name, module_refcount(xtable->owner));
|
||||
DBG(GENERAL, "%s refcount was %d\n", xtable->name,
|
||||
module_refcount(xtable->owner));
|
||||
#endif
|
||||
if (!try_module_get(xtable->owner)) {
|
||||
ERR("%s: try_module_get for %s failed.\n", __func__, xtable->name);
|
||||
ERR("%s: try_module_get for %s failed.\n", __func__,
|
||||
xtable->name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -108,7 +113,8 @@ void xproto_put(const xproto_table_t *xtable)
|
||||
{
|
||||
BUG_ON(!xtable);
|
||||
#ifdef CONFIG_MODULE_UNLOAD
|
||||
DBG(GENERAL, "%s refcount was %d\n", xtable->name, module_refcount(xtable->owner));
|
||||
DBG(GENERAL, "%s refcount was %d\n", xtable->name,
|
||||
module_refcount(xtable->owner));
|
||||
BUG_ON(module_refcount(xtable->owner) <= 0);
|
||||
#endif
|
||||
module_put(xtable->owner);
|
||||
@ -123,33 +129,37 @@ xproto_handler_t xproto_card_handler(const xproto_table_t *table, __u8 opcode)
|
||||
return xe->handler;
|
||||
}
|
||||
|
||||
void notify_bad_xpd(const char *funcname, xbus_t *xbus, const struct xpd_addr addr, const char *msg)
|
||||
void notify_bad_xpd(const char *funcname, xbus_t *xbus,
|
||||
const struct xpd_addr addr, const char *msg)
|
||||
{
|
||||
XBUS_NOTICE(xbus, "%s: non-existing address (%1d%1d): %s\n",
|
||||
funcname, addr.unit, addr.subunit, msg);
|
||||
XBUS_NOTICE(xbus, "%s: non-existing address (%1d%1d): %s\n", funcname,
|
||||
addr.unit, addr.subunit, msg);
|
||||
}
|
||||
|
||||
static int packet_process(xbus_t *xbus, xpacket_t *pack)
|
||||
{
|
||||
__u8 op;
|
||||
const xproto_entry_t *xe;
|
||||
xproto_handler_t handler;
|
||||
xproto_table_t *table;
|
||||
xpd_t *xpd;
|
||||
int ret = -EPROTO;
|
||||
__u8 op;
|
||||
const xproto_entry_t *xe;
|
||||
xproto_handler_t handler;
|
||||
xproto_table_t *table;
|
||||
xpd_t *xpd;
|
||||
int ret = -EPROTO;
|
||||
|
||||
BUG_ON(!pack);
|
||||
if (!valid_xpd_addr(&XPACKET_ADDR(pack))) {
|
||||
if (printk_ratelimit()) {
|
||||
XBUS_NOTICE(xbus, "%s: from %d%d: bad address.\n",
|
||||
__func__,
|
||||
XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack));
|
||||
dump_packet("packet_process -- bad address", pack, debug);
|
||||
__func__, XPACKET_ADDR_UNIT(pack),
|
||||
XPACKET_ADDR_SUBUNIT(pack));
|
||||
dump_packet("packet_process -- bad address", pack,
|
||||
debug);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
op = XPACKET_OP(pack);
|
||||
xpd = xpd_byaddr(xbus, XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack));
|
||||
xpd =
|
||||
xpd_byaddr(xbus, XPACKET_ADDR_UNIT(pack),
|
||||
XPACKET_ADDR_SUBUNIT(pack));
|
||||
/* XPD may be NULL (e.g: during bus polling */
|
||||
xe = xproto_global_entry(op);
|
||||
/*-------- Validations -----------*/
|
||||
@ -158,28 +168,32 @@ static int packet_process(xbus_t *xbus, xpacket_t *pack)
|
||||
|
||||
if (!xpd) {
|
||||
if (printk_ratelimit()) {
|
||||
XBUS_NOTICE(xbus, "%s: from %d%d opcode=0x%02X: no such global command.\n",
|
||||
__func__,
|
||||
XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack), op);
|
||||
dump_packet("packet_process -- no such global command", pack, 1);
|
||||
XBUS_NOTICE(xbus,
|
||||
"%s: from %d%d opcode=0x%02X: no such global command.\n",
|
||||
__func__, XPACKET_ADDR_UNIT(pack),
|
||||
XPACKET_ADDR_SUBUNIT(pack), op);
|
||||
dump_packet
|
||||
("packet_process -- no such global command",
|
||||
pack, 1);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
xtable = xproto_table(xpd->type);
|
||||
if (!xtable) {
|
||||
if (printk_ratelimit())
|
||||
XPD_ERR(xpd, "%s: no protocol table (type=%d)\n",
|
||||
__func__,
|
||||
xpd->type);
|
||||
XPD_ERR(xpd,
|
||||
"%s: no protocol table (type=%d)\n",
|
||||
__func__, xpd->type);
|
||||
goto out;
|
||||
}
|
||||
xe = xproto_card_entry(xtable, op);
|
||||
if (!xe) {
|
||||
if (printk_ratelimit()) {
|
||||
XPD_NOTICE(xpd, "%s: bad command (type=%d,opcode=0x%x)\n",
|
||||
__func__,
|
||||
xpd->type, op);
|
||||
dump_packet("packet_process -- bad command", pack, 1);
|
||||
XPD_NOTICE(xpd,
|
||||
"%s: bad command (type=%d,opcode=0x%x)\n",
|
||||
__func__, xpd->type, op);
|
||||
dump_packet("packet_process -- bad command",
|
||||
pack, 1);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
@ -189,12 +203,13 @@ static int packet_process(xbus_t *xbus, xpacket_t *pack)
|
||||
if (!table->packet_is_valid(pack)) {
|
||||
if (printk_ratelimit()) {
|
||||
ERR("xpp: %s: wrong size %d for opcode=0x%02X\n",
|
||||
__func__, XPACKET_LEN(pack), op);
|
||||
dump_packet("packet_process -- wrong size", pack, debug);
|
||||
__func__, XPACKET_LEN(pack), op);
|
||||
dump_packet("packet_process -- wrong size", pack,
|
||||
debug);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
ret = 0; /* All well */
|
||||
ret = 0; /* All well */
|
||||
handler = xe->handler;
|
||||
BUG_ON(!handler);
|
||||
XBUS_COUNTER(xbus, RX_BYTES) += XPACKET_LEN(pack);
|
||||
@ -205,11 +220,11 @@ out:
|
||||
|
||||
static int xframe_receive_cmd(xbus_t *xbus, xframe_t *xframe)
|
||||
{
|
||||
__u8 *xframe_end;
|
||||
xpacket_t *pack;
|
||||
__u8 *p;
|
||||
int len;
|
||||
int ret;
|
||||
__u8 *xframe_end;
|
||||
xpacket_t *pack;
|
||||
__u8 *p;
|
||||
int len;
|
||||
int ret;
|
||||
|
||||
if (debug & DBG_COMMANDS)
|
||||
dump_xframe("RX-CMD", xbus, xframe, DBG_ANY);
|
||||
@ -220,21 +235,24 @@ static int xframe_receive_cmd(xbus_t *xbus, xframe_t *xframe)
|
||||
len = XPACKET_LEN(pack);
|
||||
/* Sanity checks */
|
||||
if (unlikely(XPACKET_OP(pack) == XPROTO_NAME(GLOBAL, PCM_READ))) {
|
||||
static int rate_limit;
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 1003) == 0) {
|
||||
XBUS_DBG(GENERAL, xbus, "A PCM packet within a Non-PCM xframe\n");
|
||||
dump_xframe("In Non-PCM xframe", xbus, xframe, debug);
|
||||
XBUS_DBG(GENERAL, xbus,
|
||||
"A PCM packet within a Non-PCM xframe\n");
|
||||
dump_xframe("In Non-PCM xframe", xbus, xframe,
|
||||
debug);
|
||||
}
|
||||
ret = -EPROTO;
|
||||
goto out;
|
||||
}
|
||||
p += len;
|
||||
if (p > xframe_end || len < RPACKET_HEADERSIZE) {
|
||||
static int rate_limit;
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 1003) == 0) {
|
||||
XBUS_NOTICE(xbus, "Invalid packet length %d\n", len);
|
||||
XBUS_NOTICE(xbus, "Invalid packet length %d\n",
|
||||
len);
|
||||
dump_xframe("BAD LENGTH", xbus, xframe, debug);
|
||||
}
|
||||
ret = -EPROTO;
|
||||
@ -251,13 +269,13 @@ out:
|
||||
|
||||
int xframe_receive(xbus_t *xbus, xframe_t *xframe)
|
||||
{
|
||||
int ret = 0;
|
||||
struct timeval now;
|
||||
struct timeval tv_received;
|
||||
int usec;
|
||||
int ret = 0;
|
||||
struct timeval now;
|
||||
struct timeval tv_received;
|
||||
int usec;
|
||||
|
||||
if (XFRAME_LEN(xframe) < RPACKET_HEADERSIZE) {
|
||||
static int rate_limit;
|
||||
static int rate_limit;
|
||||
|
||||
if ((rate_limit++ % 1003) == 0) {
|
||||
XBUS_NOTICE(xbus, "short xframe\n");
|
||||
@ -285,8 +303,9 @@ int xframe_receive(xbus_t *xbus, xframe_t *xframe)
|
||||
}
|
||||
/* Calculate total processing time */
|
||||
do_gettimeofday(&now);
|
||||
usec = (now.tv_sec - tv_received.tv_sec) * 1000000 +
|
||||
now.tv_usec - tv_received.tv_usec;
|
||||
usec =
|
||||
(now.tv_sec - tv_received.tv_sec) * 1000000 + now.tv_usec -
|
||||
tv_received.tv_usec;
|
||||
if (usec > xbus->max_rx_process)
|
||||
xbus->max_rx_process = usec;
|
||||
return ret;
|
||||
@ -297,23 +316,19 @@ int xframe_receive(xbus_t *xbus, xframe_t *xframe)
|
||||
|
||||
void dump_packet(const char *msg, const xpacket_t *packet, bool debug)
|
||||
{
|
||||
__u8 op = XPACKET_OP(packet);
|
||||
__u8 *addr = (__u8 *)&XPACKET_ADDR(packet);
|
||||
__u8 op = XPACKET_OP(packet);
|
||||
__u8 *addr = (__u8 *)&XPACKET_ADDR(packet);
|
||||
|
||||
if (!debug)
|
||||
return;
|
||||
printk(KERN_DEBUG "%s: XPD=%1X-%1X%c (0x%X) OP=0x%02X LEN=%d",
|
||||
msg,
|
||||
XPACKET_ADDR_UNIT(packet),
|
||||
XPACKET_ADDR_SUBUNIT(packet),
|
||||
(XPACKET_ADDR_SYNC(packet))?'+':' ',
|
||||
*addr,
|
||||
op,
|
||||
XPACKET_LEN(packet));
|
||||
printk(KERN_DEBUG "%s: XPD=%1X-%1X%c (0x%X) OP=0x%02X LEN=%d", msg,
|
||||
XPACKET_ADDR_UNIT(packet), XPACKET_ADDR_SUBUNIT(packet),
|
||||
(XPACKET_ADDR_SYNC(packet)) ? '+' : ' ', *addr, op,
|
||||
XPACKET_LEN(packet));
|
||||
#if VERBOSE_DEBUG
|
||||
{
|
||||
int i;
|
||||
__u8 *p = (__u8 *)packet;
|
||||
__u8 *p = (__u8 *)packet;
|
||||
|
||||
printk(" BYTES: ");
|
||||
for (i = 0; i < XPACKET_LEN(packet); i++) {
|
||||
@ -321,11 +336,9 @@ void dump_packet(const char *msg, const xpacket_t *packet, bool debug)
|
||||
|
||||
if (i >= sizeof(xpacket_t)) {
|
||||
if (limiter < ERR_REPORT_LIMIT) {
|
||||
ERR("%s: length overflow i=%d > sizeof(xpacket_t)=%lu\n",
|
||||
__func__, i+1, (long)sizeof(xpacket_t));
|
||||
ERR("%s: length overflow i=%d > sizeof(xpacket_t)=%lu\n", __func__, i + 1, (long)sizeof(xpacket_t));
|
||||
} else if (limiter == ERR_REPORT_LIMIT) {
|
||||
ERR("%s: error packet #%d... squelsh reports.\n",
|
||||
__func__, limiter);
|
||||
ERR("%s: error packet #%d... squelsh reports.\n", __func__, limiter);
|
||||
}
|
||||
limiter++;
|
||||
break;
|
||||
@ -338,74 +351,74 @@ void dump_packet(const char *msg, const xpacket_t *packet, bool debug)
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus,
|
||||
__u8 unit, xportno_t port, const reg_cmd_t *regcmd)
|
||||
void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus, __u8 unit,
|
||||
xportno_t port, const reg_cmd_t *regcmd)
|
||||
{
|
||||
char action;
|
||||
char modifier;
|
||||
char port_buf[MAX_PROC_WRITE];
|
||||
char reg_buf[MAX_PROC_WRITE];
|
||||
char data_buf[MAX_PROC_WRITE];
|
||||
char action;
|
||||
char modifier;
|
||||
char port_buf[MAX_PROC_WRITE];
|
||||
char reg_buf[MAX_PROC_WRITE];
|
||||
char data_buf[MAX_PROC_WRITE];
|
||||
|
||||
if (regcmd->bytes > sizeof(*regcmd) - 1) { /* The size byte is not included */
|
||||
PORT_NOTICE(xbus, unit, port, "%s: %s: Too long: regcmd->bytes = %d\n",
|
||||
__func__, msg, regcmd->bytes);
|
||||
PORT_NOTICE(xbus, unit, port,
|
||||
"%s: %s: Too long: regcmd->bytes = %d\n", __func__,
|
||||
msg, regcmd->bytes);
|
||||
return;
|
||||
}
|
||||
if (regcmd->is_multibyte) {
|
||||
char buf[MAX_PROC_WRITE + 1];
|
||||
int i;
|
||||
int n = 0;
|
||||
size_t len = regcmd->bytes;
|
||||
const __u8 *p = REG_XDATA(regcmd);
|
||||
char buf[MAX_PROC_WRITE + 1];
|
||||
int i;
|
||||
int n = 0;
|
||||
size_t len = regcmd->bytes;
|
||||
const __u8 *p = REG_XDATA(regcmd);
|
||||
|
||||
buf[0] = '\0';
|
||||
for (i = 0; i < len && n < MAX_PROC_WRITE; i++)
|
||||
n += snprintf(&buf[n], MAX_PROC_WRITE - n, "%02X ", p[i]);
|
||||
n += snprintf(&buf[n], MAX_PROC_WRITE - n, "%02X ",
|
||||
p[i]);
|
||||
PORT_DBG(REGS, xbus, unit, port,
|
||||
"UNIT-%d PORT-%d: Multibyte(eoframe=%d) %s[0..%zd]: %s%s\n",
|
||||
unit, port, regcmd->eoframe,
|
||||
msg, len-1, buf, (n >= MAX_PROC_WRITE)?"...":"");
|
||||
"UNIT-%d PORT-%d: Multibyte(eoframe=%d) %s[0..%zd]: %s%s\n",
|
||||
unit, port, regcmd->eoframe, msg, len - 1, buf,
|
||||
(n >= MAX_PROC_WRITE) ? "..." : "");
|
||||
return;
|
||||
}
|
||||
if (regcmd->bytes != sizeof(*regcmd) - 1) { /* The size byte is not included */
|
||||
PORT_NOTICE(xbus, unit, port, "%s: %s: Wrong size: regcmd->bytes = %d\n",
|
||||
__func__, msg, regcmd->bytes);
|
||||
PORT_NOTICE(xbus, unit, port,
|
||||
"%s: %s: Wrong size: regcmd->bytes = %d\n",
|
||||
__func__, msg, regcmd->bytes);
|
||||
return;
|
||||
}
|
||||
snprintf(port_buf, MAX_PROC_WRITE, "%d%s",
|
||||
regcmd->portnum,
|
||||
(REG_FIELD(regcmd, all_ports_broadcast)) ? "*" : "");
|
||||
snprintf(port_buf, MAX_PROC_WRITE, "%d%s", regcmd->portnum,
|
||||
(REG_FIELD(regcmd, all_ports_broadcast)) ? "*" : "");
|
||||
action = (REG_FIELD(regcmd, read_request)) ? 'R' : 'W';
|
||||
modifier = 'D';
|
||||
if (REG_FIELD(regcmd, do_subreg)) {
|
||||
snprintf(reg_buf, MAX_PROC_WRITE, "%02X %02X",
|
||||
REG_FIELD(regcmd, regnum),
|
||||
REG_FIELD(regcmd, subreg));
|
||||
REG_FIELD(regcmd, regnum), REG_FIELD(regcmd, subreg));
|
||||
modifier = 'S';
|
||||
} else {
|
||||
snprintf(reg_buf, MAX_PROC_WRITE, "%02X",
|
||||
REG_FIELD(regcmd, regnum));
|
||||
REG_FIELD(regcmd, regnum));
|
||||
}
|
||||
if (REG_FIELD(regcmd, read_request)) {
|
||||
data_buf[0] = '\0';
|
||||
} else if (REG_FIELD(regcmd, do_datah)) {
|
||||
snprintf(data_buf, MAX_PROC_WRITE, "%02X %02X",
|
||||
REG_FIELD(regcmd, data_low),
|
||||
REG_FIELD(regcmd, data_high));
|
||||
REG_FIELD(regcmd, data_low), REG_FIELD(regcmd,
|
||||
data_high));
|
||||
modifier = 'I';
|
||||
} else {
|
||||
snprintf(data_buf, MAX_PROC_WRITE, "%02X",
|
||||
REG_FIELD(regcmd, data_low));
|
||||
REG_FIELD(regcmd, data_low));
|
||||
}
|
||||
PORT_DBG(REGS, xbus, unit, port, "%s: %s %c%c %s %s\n",
|
||||
msg, port_buf, action, modifier,
|
||||
reg_buf, data_buf);
|
||||
PORT_DBG(REGS, xbus, unit, port, "%s: %s %c%c %s %s\n", msg, port_buf,
|
||||
action, modifier, reg_buf, data_buf);
|
||||
}
|
||||
|
||||
const char *xproto_name(xpd_type_t xpd_type)
|
||||
{
|
||||
const xproto_table_t *proto_table;
|
||||
const xproto_table_t *proto_table;
|
||||
|
||||
BUG_ON(xpd_type >= XPD_TYPE_NOMODULE);
|
||||
proto_table = xprotocol_tables[xpd_type];
|
||||
@ -428,10 +441,10 @@ const char *xproto_name(xpd_type_t xpd_type)
|
||||
|
||||
int xproto_register(const xproto_table_t *proto_table)
|
||||
{
|
||||
int type;
|
||||
const char *name;
|
||||
const struct xops *xops;
|
||||
const struct phoneops *phoneops;
|
||||
int type;
|
||||
const char *name;
|
||||
const struct xops *xops;
|
||||
const struct phoneops *phoneops;
|
||||
|
||||
BUG_ON(!proto_table);
|
||||
type = proto_table->type;
|
||||
@ -442,7 +455,8 @@ int xproto_register(const xproto_table_t *proto_table)
|
||||
}
|
||||
DBG(GENERAL, "%s (%d)\n", name, type);
|
||||
if (xprotocol_tables[type])
|
||||
NOTICE("%s: overriding registration of %s (%d)\n", __func__, name, type);
|
||||
NOTICE("%s: overriding registration of %s (%d)\n", __func__,
|
||||
name, type);
|
||||
xops = proto_table->xops;
|
||||
CHECK_XOP(xops, card_new);
|
||||
CHECK_XOP(xops, card_init);
|
||||
@ -460,7 +474,7 @@ int xproto_register(const xproto_table_t *proto_table)
|
||||
CHECK_PHONEOP(phoneops, card_dahdi_preregistration);
|
||||
CHECK_PHONEOP(phoneops, card_dahdi_postregistration);
|
||||
/* optional method -- call after testing: */
|
||||
/*CHECK_PHONEOP(phoneops, card_ioctl);*/
|
||||
/*CHECK_PHONEOP(phoneops, card_ioctl); */
|
||||
}
|
||||
|
||||
xprotocol_tables[type] = proto_table;
|
||||
@ -469,8 +483,8 @@ int xproto_register(const xproto_table_t *proto_table)
|
||||
|
||||
void xproto_unregister(const xproto_table_t *proto_table)
|
||||
{
|
||||
int type;
|
||||
const char *name;
|
||||
int type;
|
||||
const char *name;
|
||||
|
||||
BUG_ON(!proto_table);
|
||||
type = proto_table->type;
|
||||
@ -481,7 +495,8 @@ void xproto_unregister(const xproto_table_t *proto_table)
|
||||
return;
|
||||
}
|
||||
if (!xprotocol_tables[type])
|
||||
NOTICE("%s: xproto type %s (%d) is already unregistered\n", __func__, name, type);
|
||||
NOTICE("%s: xproto type %s (%d) is already unregistered\n",
|
||||
__func__, name, type);
|
||||
xprotocol_tables[type] = NULL;
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,10 @@
|
||||
#define XPP_PROTOCOL_VERSION 30
|
||||
|
||||
struct xpd_addr {
|
||||
uint8_t subunit:SUBUNIT_BITS;
|
||||
uint8_t reserved:1;
|
||||
uint8_t unit:UNIT_BITS;
|
||||
uint8_t sync_master:1;
|
||||
uint8_t subunit:SUBUNIT_BITS;
|
||||
uint8_t reserved:1;
|
||||
uint8_t unit:UNIT_BITS;
|
||||
uint8_t sync_master:1;
|
||||
} PACKED;
|
||||
|
||||
#define MKADDR(p, u, s) do { \
|
||||
@ -48,12 +48,12 @@ struct xpd_addr {
|
||||
} while (0)
|
||||
|
||||
struct xpacket_header {
|
||||
uint16_t packet_len:10;
|
||||
uint16_t reserved:1;
|
||||
uint16_t is_pcm:1;
|
||||
uint16_t pcmslot:4;
|
||||
uint8_t opcode;
|
||||
struct xpd_addr addr;
|
||||
uint16_t packet_len:10;
|
||||
uint16_t reserved:1;
|
||||
uint16_t is_pcm:1;
|
||||
uint16_t pcmslot:4;
|
||||
uint8_t opcode;
|
||||
struct xpd_addr addr;
|
||||
} PACKED;
|
||||
|
||||
#define XPACKET_OP(p) ((p)->head.opcode)
|
||||
@ -81,7 +81,7 @@ struct xpacket_header {
|
||||
#define XPD_TYPE_ECHO 5 // Octasic echo canceller
|
||||
#define XPD_TYPE_NOMODULE 7
|
||||
|
||||
typedef byte xpd_type_t;
|
||||
typedef byte xpd_type_t;
|
||||
|
||||
#define XPD_TYPE_PREFIX "xpd-type-"
|
||||
|
||||
@ -167,25 +167,25 @@ bool valid_xpd_addr(const struct xpd_addr *addr);
|
||||
#define MULTIBYTE_MAX_LEN 5 /* FPGA firmware limitation */
|
||||
|
||||
typedef struct reg_cmd {
|
||||
byte bytes:3; /* Length (for Multibyte) */
|
||||
__u8 eoframe:1; /* For BRI -- end of frame */
|
||||
__u8 portnum:3; /* For port specific registers */
|
||||
__u8 is_multibyte:1;
|
||||
byte bytes:3; /* Length (for Multibyte) */
|
||||
__u8 eoframe:1; /* For BRI -- end of frame */
|
||||
__u8 portnum:3; /* For port specific registers */
|
||||
__u8 is_multibyte:1;
|
||||
union {
|
||||
struct {
|
||||
__u8 reserved:4;
|
||||
__u8 do_datah:1;
|
||||
__u8 do_subreg:1;
|
||||
__u8 read_request:1;
|
||||
__u8 all_ports_broadcast:1;
|
||||
__u8 regnum;
|
||||
__u8 subreg;
|
||||
__u8 data_low;
|
||||
__u8 data_high;
|
||||
__u8 reserved:4;
|
||||
__u8 do_datah:1;
|
||||
__u8 do_subreg:1;
|
||||
__u8 read_request:1;
|
||||
__u8 all_ports_broadcast:1;
|
||||
__u8 regnum;
|
||||
__u8 subreg;
|
||||
__u8 data_low;
|
||||
__u8 data_high;
|
||||
} PACKED r;
|
||||
/* For Write-Multibyte commands in BRI */
|
||||
struct {
|
||||
__u8 xdata[MULTIBYTE_MAX_LEN];
|
||||
__u8 xdata[MULTIBYTE_MAX_LEN];
|
||||
} PACKED d;
|
||||
} PACKED alt;
|
||||
} PACKED reg_cmd_t;
|
||||
@ -197,18 +197,16 @@ typedef struct reg_cmd {
|
||||
#ifdef __KERNEL__
|
||||
/*--------------------------- protocol tables ----------------------------------*/
|
||||
|
||||
typedef struct xproto_entry xproto_entry_t;
|
||||
typedef struct xproto_table xproto_table_t;
|
||||
typedef struct xproto_entry xproto_entry_t;
|
||||
typedef struct xproto_table xproto_table_t;
|
||||
|
||||
typedef int (*xproto_handler_t)(
|
||||
xbus_t *xbus,
|
||||
xpd_t *xpd,
|
||||
const xproto_entry_t *cmd,
|
||||
xpacket_t *pack);
|
||||
typedef int (*xproto_handler_t) (xbus_t *xbus, xpd_t *xpd,
|
||||
const xproto_entry_t *cmd, xpacket_t *pack);
|
||||
|
||||
const xproto_table_t *xproto_get(xpd_type_t cardtype);
|
||||
void xproto_put(const xproto_table_t *xtable);
|
||||
const xproto_entry_t *xproto_card_entry(const xproto_table_t *table, __u8 opcode);
|
||||
const xproto_entry_t *xproto_card_entry(const xproto_table_t *table,
|
||||
__u8 opcode);
|
||||
xproto_handler_t xproto_card_handler(const xproto_table_t *table, __u8 opcode);
|
||||
|
||||
const xproto_entry_t *xproto_global_entry(__u8 opcode);
|
||||
@ -231,49 +229,50 @@ xproto_handler_t xproto_global_handler(__u8 opcode);
|
||||
(PHONE_METHOD(name, (xpd))((xpd), ## __VA_ARGS__ ))
|
||||
|
||||
struct phoneops {
|
||||
void (*card_pcm_recompute)(xpd_t *xpd, xpp_line_t pcm_mask);
|
||||
void (*card_pcm_fromspan)(xpd_t *xpd, xpacket_t *pack);
|
||||
void (*card_pcm_tospan)(xpd_t *xpd, xpacket_t *pack);
|
||||
int (*echocancel_timeslot)(xpd_t *xpd, int pos);
|
||||
int (*echocancel_setmask)(xpd_t *xpd, xpp_line_t ec_mask);
|
||||
int (*card_timing_priority)(xpd_t *xpd);
|
||||
int (*card_dahdi_preregistration)(xpd_t *xpd, bool on);
|
||||
int (*card_dahdi_postregistration)(xpd_t *xpd, bool on);
|
||||
int (*card_hooksig)(xpd_t *xpd, int pos, enum dahdi_txsig txsig);
|
||||
int (*card_ioctl)(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg);
|
||||
int (*card_open)(xpd_t *xpd, lineno_t pos);
|
||||
int (*card_close)(xpd_t *xpd, lineno_t pos);
|
||||
int (*card_state)(xpd_t *xpd, bool on);
|
||||
void (*card_pcm_recompute) (xpd_t *xpd, xpp_line_t pcm_mask);
|
||||
void (*card_pcm_fromspan) (xpd_t *xpd, xpacket_t *pack);
|
||||
void (*card_pcm_tospan) (xpd_t *xpd, xpacket_t *pack);
|
||||
int (*echocancel_timeslot) (xpd_t *xpd, int pos);
|
||||
int (*echocancel_setmask) (xpd_t *xpd, xpp_line_t ec_mask);
|
||||
int (*card_timing_priority) (xpd_t *xpd);
|
||||
int (*card_dahdi_preregistration) (xpd_t *xpd, bool on);
|
||||
int (*card_dahdi_postregistration) (xpd_t *xpd, bool on);
|
||||
int (*card_hooksig) (xpd_t *xpd, int pos, enum dahdi_txsig txsig);
|
||||
int (*card_ioctl) (xpd_t *xpd, int pos, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
int (*card_open) (xpd_t *xpd, lineno_t pos);
|
||||
int (*card_close) (xpd_t *xpd, lineno_t pos);
|
||||
int (*card_state) (xpd_t *xpd, bool on);
|
||||
};
|
||||
|
||||
struct xops {
|
||||
xpd_t *(*card_new)(xbus_t *xbus, int unit, int subunit,
|
||||
const xproto_table_t *proto_table, __u8 subtype,
|
||||
int subunits, int subunit_ports, bool to_phone);
|
||||
int (*card_init)(xbus_t *xbus, xpd_t *xpd);
|
||||
int (*card_remove)(xbus_t *xbus, xpd_t *xpd);
|
||||
int (*card_tick)(xbus_t *xbus, xpd_t *xpd);
|
||||
int (*card_register_reply)(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *reg);
|
||||
xpd_t *(*card_new) (xbus_t *xbus, int unit, int subunit,
|
||||
const xproto_table_t *proto_table, __u8 subtype,
|
||||
int subunits, int subunit_ports, bool to_phone);
|
||||
int (*card_init) (xbus_t *xbus, xpd_t *xpd);
|
||||
int (*card_remove) (xbus_t *xbus, xpd_t *xpd);
|
||||
int (*card_tick) (xbus_t *xbus, xpd_t *xpd);
|
||||
int (*card_register_reply) (xbus_t *xbus, xpd_t *xpd, reg_cmd_t *reg);
|
||||
};
|
||||
|
||||
struct xproto_entry {
|
||||
xproto_handler_t handler;
|
||||
int datalen;
|
||||
const char *name;
|
||||
xproto_table_t *table;
|
||||
xproto_handler_t handler;
|
||||
int datalen;
|
||||
const char *name;
|
||||
xproto_table_t *table;
|
||||
};
|
||||
|
||||
struct xproto_table {
|
||||
struct module *owner;
|
||||
xproto_entry_t entries[256]; /* Indexed by opcode */
|
||||
const struct xops *xops; /* Card level operations */
|
||||
const struct phoneops *phoneops; /* DAHDI operations */
|
||||
const struct echoops *echoops; /* Echo Canceller operations */
|
||||
xpd_type_t type;
|
||||
__u8 ports_per_subunit;
|
||||
const char *name;
|
||||
bool (*packet_is_valid)(xpacket_t *pack);
|
||||
void (*packet_dump)(const char *msg, xpacket_t *pack);
|
||||
struct module *owner;
|
||||
xproto_entry_t entries[256]; /* Indexed by opcode */
|
||||
const struct xops *xops; /* Card level operations */
|
||||
const struct phoneops *phoneops; /* DAHDI operations */
|
||||
const struct echoops *echoops; /* Echo Canceller operations */
|
||||
xpd_type_t type;
|
||||
__u8 ports_per_subunit;
|
||||
const char *name;
|
||||
bool (*packet_is_valid) (xpacket_t *pack);
|
||||
void (*packet_dump) (const char *msg, xpacket_t *pack);
|
||||
};
|
||||
|
||||
#include "card_global.h"
|
||||
@ -282,11 +281,10 @@ struct xproto_table {
|
||||
#include "card_bri.h"
|
||||
#include "card_pri.h"
|
||||
|
||||
|
||||
#define MEMBER(card, op) RPACKET_TYPE(card, op) RPACKET_NAME(card, op)
|
||||
|
||||
struct xpacket {
|
||||
struct xpacket_header head;
|
||||
struct xpacket_header head;
|
||||
union {
|
||||
MEMBER(GLOBAL, NULL_REPLY);
|
||||
MEMBER(GLOBAL, PCM_WRITE);
|
||||
@ -297,20 +295,22 @@ struct xpacket {
|
||||
MEMBER(FXS, SIG_CHANGED);
|
||||
MEMBER(FXO, SIG_CHANGED);
|
||||
|
||||
__u8 data[0];
|
||||
__u8 data[0];
|
||||
};
|
||||
/* Last byte is chksum */
|
||||
} PACKED;
|
||||
|
||||
void dump_packet(const char *msg, const xpacket_t *packet, bool debug);
|
||||
void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus, __u8 unit, xportno_t port, const reg_cmd_t *regcmd);
|
||||
void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus, __u8 unit,
|
||||
xportno_t port, const reg_cmd_t *regcmd);
|
||||
int xframe_receive(xbus_t *xbus, xframe_t *xframe);
|
||||
void notify_bad_xpd(const char *funcname, xbus_t *xbus, const struct xpd_addr addr, const char *msg);
|
||||
void notify_bad_xpd(const char *funcname, xbus_t *xbus,
|
||||
const struct xpd_addr addr, const char *msg);
|
||||
int xproto_register(const xproto_table_t *proto_table);
|
||||
void xproto_unregister(const xproto_table_t *proto_table);
|
||||
const xproto_entry_t *xproto_global_entry(__u8 opcode);
|
||||
const char *xproto_name(xpd_type_t xpd_type);
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* XPROTO_H */
|
||||
#endif /* XPROTO_H */
|
||||
|
Loading…
Reference in New Issue
Block a user