extend information in /proc.

This commit is contained in:
Carsten Paeth 1999-06-21 15:24:26 +00:00
parent a3a95c6a4e
commit 31aa395794
8 changed files with 314 additions and 9 deletions

View File

@ -83,6 +83,50 @@ for example:
capidrv
capi20
/proc/capi/capidrv: statistics of capidrv.o (capi messages)
recvctlpkt recvdatapkt sentctlpkt sentdatapkt
recvctlpkt: capi messages received without DATA_B3_IND
recvdatapkt: capi DATA_B3_IND received
sendctlpkt: capi messages sent without DATA_B3_REQ
senddatapkt: capi DATA_B3_REQ sent
for example:
560 82 107 285
/proc/capi/capi20: statistics of capi.o (/dev/capi20)
minor nopen recvdroppkt recvctlpkt recvdatapkt sendctlpkt senddatapkt
minor: minor device number of capi device
nopen: number of calls to devices open
recvdroppkt: capi messages dropped (messages in recvqueue in close)
recvctlpkt: capi messages received without DATA_B3_IND
recvdatapkt: capi DATA_B3_IND received
sendctlpkt: capi messages sent without DATA_B3_REQ
senddatapkt: capi DATA_B3_REQ sent
for example:
1 2 0 18 0 16 2
/proc/capi/cardstats: statistics of kernelcapi's controllers
controller recvdroppkt recvctlpkt recvdatapkt sendctlpkt senddatapkt
controller: number of controller
recvdroppkt: capi messages dropped (no memory)
recvctlpkt: capi messages received without DATA_B3_IND
recvdatapkt: capi DATA_B3_IND received
sendctlpkt: capi messages sent without DATA_B3_REQ
senddatapkt: capi DATA_B3_REQ sent
for example:
1 0 578 82 123 287
Checking for memory leaks:
/proc/capi/capidrv: 560 82 107 285
/proc/capi/capi20: 1 2 0 18 0 16 2
========================================
578 82 123 287
/proc/capi/cardstats: 1 0 578 82 123 287
========================================
578 82 123 287
Questions
---------
Check out the FAQ (ftp.franken.de) or subscribe to the
@ -91,6 +135,8 @@ a mail to majordomo@calle.in-berlin.de with
subscribe linux-avmb1
in the body.
German documentaion can be found at ftp://ftp.avm.de/cardware/b1/linux/
Bugs
----
If you find any please let me know.

View File

@ -6,8 +6,11 @@
* (c) Copyright 1997 by Carsten Paeth (calle@calle.in-berlin.de)
*
* $Log$
* Revision 1.16 1999/06/10 16:53:51 calle
* Removing of module b1pci will now remove card from lower level.
*
* Revision 1.15 1999/05/25 14:51:42 calle
* Added /proc/capi/* to track states in kernelcapi.
* Added /proc/capi/ to track states in kernelcapi.
*
* Revision 1.14 1999/04/15 19:49:29 calle
* fix fuer die B1-PCI. Jetzt geht z.B. auch IRQ 17 ...
@ -370,6 +373,44 @@ endloop:
return ((count < begin+len-off) ? count : begin+len-off);
}
/*
* /proc/capi/cardstats:
* cnr nrecvdroppkt nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt
*/
static int proc_cardstats_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
avmb1_card *cp;
int i;
int len = 0;
off_t begin = 0;
for (i=0; i < CAPI_MAXCONTR; i++) {
cp = &cards[i];
if (cp->cardstate == CARD_FREE) continue;
len += sprintf(page+len, "%d %lu %lu %lu %lu %lu\n",
cp->cnr,
cp->nrecvdroppkt,
cp->nrecvctlpkt,
cp->nrecvdatapkt,
cp->nsentctlpkt,
cp->nsentdatapkt);
if (len+begin > off+count)
goto endloop;
if (len+begin < off) {
begin += len;
len = 0;
}
}
endloop:
if (i >= CAPI_MAXCONTR)
*eof = 1;
if (off >= len+begin)
return 0;
*start = page + (begin-off);
return ((count < begin+len-off) ? count : begin+len-off);
}
/*
* /proc/capi/users:
* name
@ -411,6 +452,7 @@ static struct procfsentries {
{ "capi/ncci", 0 , proc_ncci_read_proc },
{ "capi/cards", 0 , proc_cards_read_proc },
{ "capi/users", 0 , proc_users_read_proc },
{ "capi/cardstats", 0 , proc_cardstats_read_proc },
};
static void proc_capi_init(void)
@ -1039,7 +1081,7 @@ static __u16 capi_put_message(__u16 applid, struct sk_buff *skb)
&& mq_enqueue(np, CAPIMSG_MSGID(skb->data)) == 0)
return CAPI_SENDQUEUEFULL;
B1_send_message(CARD(contr)->port, skb);
B1_send_message(CARD(contr), skb);
return CAPI_NOERROR;
}

View File

@ -6,6 +6,11 @@
* (c) Copyright 1997 by Carsten Paeth (calle@calle.in-berlin.de)
*
* $Log$
* Revision 1.11 1999/05/25 21:18:44 calle
* - Made loading of firmware safer, will not longer go into endless loop,
* even if t4 file is corrupt or user load a non t4 file.
* - Changed and added error messages if load failed.
*
* Revision 1.10 1999/04/15 19:49:31 calle
* fix fuer die B1-PCI. Jetzt geht z.B. auch IRQ 17 ...
*
@ -180,6 +185,10 @@ extern int showcapimsgs;
* int32 tasknr
* int32 Length Taskname ...
*/
#define RECEIVE_DEBUGMSG 0x71 /*
* int32 Length message
*
*/
#define WRITE_REGISTER 0x00
#define READ_REGISTER 0x01
@ -891,8 +900,9 @@ void B1_send_release(unsigned int port,
restore_flags(flags);
}
void B1_send_message(unsigned int port, struct sk_buff *skb)
void B1_send_message(avmb1_card * card, struct sk_buff *skb)
{
unsigned int port = card->port;
unsigned long flags;
__u16 len = CAPIMSG_LEN(skb->data);
__u8 cmd = CAPIMSG_COMMAND(skb->data);
@ -921,6 +931,8 @@ void B1_send_message(unsigned int port, struct sk_buff *skb)
B1_put_slice(port, skb->data, len);
B1_put_slice(port, skb->data + len, dlen);
restore_flags(flags);
dev_kfree_skb(skb);
card->nsentdatapkt++;
} else {
if (showcapimsgs) {
@ -938,8 +950,9 @@ void B1_send_message(unsigned int port, struct sk_buff *skb)
B1_put_byte(port, SEND_MESSAGE);
B1_put_slice(port, skb->data, len);
restore_flags(flags);
dev_kfree_skb(skb);
card->nsentctlpkt++;
}
dev_kfree_skb(skb);
}
/*
@ -988,11 +1001,13 @@ t1retry:
}
if (!(skb = dev_alloc_skb(DataB3Len + MsgLen))) {
printk(KERN_ERR "b1lli: incoming packet dropped\n");
card->nrecvdroppkt++;
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
CAPIMSG_SETDATA(skb->data, skb->data + MsgLen);
avmb1_handle_capimsg(card, ApplId, skb);
card->nrecvdatapkt++;
}
break;
@ -1019,9 +1034,11 @@ t1retry:
}
if (!(skb = dev_alloc_skb(MsgLen))) {
printk(KERN_ERR "b1lli: incoming packet dropped\n");
card->nrecvdroppkt++;
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
avmb1_handle_capimsg(card, ApplId, skb);
card->nrecvctlpkt++;
}
break;
@ -1082,10 +1099,20 @@ t1retry:
printk(KERN_INFO "b1lli(0x%x): Task %d \"%s\" ready.\n",
card->port, ApplId, card->msgbuf);
break;
case RECEIVE_DEBUGMSG:
MsgLen = B1_get_slice(card->port, card->msgbuf);
card->msgbuf[MsgLen--] = 0;
while ( MsgLen >= 0
&& ( card->msgbuf[MsgLen] == '\n'
|| card->msgbuf[MsgLen] == '\r')
card->msgbuf[MsgLen--] = 0;
printk(KERN_INFO "b1lli(0x%x): DEBUG: %s\n",
card->port, card->msgbuf);
break;
default:
printk(KERN_ERR "b1lli(0x%x): B1_handle_interrupt: 0x%x ???\n",
card->port, b1cmd);
break;
return;
}
if (card->cardtype == AVM_CARDTYPE_T1)
goto t1retry;

View File

@ -6,6 +6,9 @@
* Copyright 1996 by Carsten Paeth (calle@calle.in-berlin.de)
*
* $Log$
* Revision 1.14 1999/06/10 16:51:03 calle
* Bugfix: open/release of control device was not handled correct.
*
* Revision 1.13 1998/08/28 04:32:25 calle
* Added patch send by Michael.Mueller4@post.rwth-aachen.de, to get AVM B1
* driver running with 2.1.118.
@ -80,6 +83,7 @@
#include <linux/timer.h>
#include <linux/wait.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include <linux/capi.h>
#include <linux/kernelcapi.h>
@ -178,7 +182,10 @@ static ssize_t capi_read(struct file *file, char *buf,
}
copied = skb->len;
if (CAPIMSG_COMMAND(skb->data) == CAPI_DATA_B3
&& CAPIMSG_SUBCOMMAND(skb->data) == CAPI_IND)
cdev->nrecvdatapkt++;
else cdev->nrecvctlpkt++;
kfree_skb(skb);
return copied;
@ -231,6 +238,9 @@ static ssize_t capi_write(struct file *file, const char *buf,
dev_kfree_skb(skb);
return -EIO;
}
if (cmd == CAPI_DATA_B3 && subcmd == CAPI_REQ)
cdev->nsentdatapkt++;
else cdev->nsentctlpkt++;
return count;
}
@ -426,13 +436,13 @@ static int capi_open(struct inode *inode, struct file *file)
capidevs[minor].is_open = 1;
skb_queue_head_init(&capidevs[minor].recv_queue);
MOD_INC_USE_COUNT;
capidevs[minor].nopen++;
} else {
capidevs[minor].is_open++;
MOD_INC_USE_COUNT;
}
return 0;
}
@ -457,8 +467,10 @@ capi_release(struct inode *inode, struct file *file)
cdev->is_registered = 0;
cdev->applid = 0;
while ((skb = skb_dequeue(&cdev->recv_queue)) != 0)
while ((skb = skb_dequeue(&cdev->recv_queue)) != 0) {
kfree_skb(skb);
cdev->nrecvdroppkt++;
}
cdev->is_open = 0;
} else {
cdev->is_open--;
@ -486,7 +498,84 @@ static struct file_operations capi_fops =
NULL, /* capi_fasync */
};
/* -------- /proc functions ----------------------------------- */
/*
* /proc/capi/capi20:
* minor opencount
* nrecvdroppkt nrecvctlpkt nrecvdatapkt nsendctlpkt nsenddatapkt
*/
static int proc_capidev_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct capidev *cp;
int i;
int len = 0;
off_t begin = 0;
for (i=0; i < CAPI_MAXMINOR; i++) {
cp = &capidevs[i+1];
if (cp->nopen == 0) continue;
len += sprintf(page+len, "%d %lu %lu %lu %lu %lu %lu\n",
i+1,
cp->nopen,
cp->nrecvdroppkt,
cp->nrecvctlpkt,
cp->nrecvdatapkt,
cp->nsentctlpkt,
cp->nsentdatapkt);
if (len+begin > off+count)
goto endloop;
if (len+begin < off) {
begin += len;
len = 0;
}
}
endloop:
if (i >= CAPI_MAXMINOR)
*eof = 1;
if (off >= len+begin)
return 0;
*start = page + (begin-off);
return ((count < begin+len-off) ? count : begin+len-off);
}
static struct procfsentries {
char *name;
mode_t mode;
int (*read_proc)(char *page, char **start, off_t off,
int count, int *eof, void *data);
struct proc_dir_entry *procent;
} procfsentries[] = {
/* { "capi", S_IFDIR, 0 }, */
{ "capi/capi20", 0 , proc_capidev_read_proc },
};
static void proc_init(void)
{
int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]);
int i;
for (i=0; i < nelem; i++) {
struct procfsentries *p = procfsentries + i;
p->procent = create_proc_entry(p->name, p->mode, 0);
if (p->procent) p->procent->read_proc = p->read_proc;
}
}
static void proc_exit(void)
{
int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]);
int i;
for (i=nelem-1; i >= 0; i--) {
struct procfsentries *p = procfsentries + i;
if (p->procent) {
remove_proc_entry(p->name, 0);
p->procent = 0;
}
}
}
/* -------- init function and module interface ---------------------- */
#ifdef MODULE
@ -512,12 +601,14 @@ int capi_init(void)
unregister_chrdev(capi_major, "capi20");
return -EIO;
}
(void)proc_init();
return 0;
}
#ifdef MODULE
void cleanup_module(void)
{
(void)proc_exit();
unregister_chrdev(capi_major, "capi20");
(void) detach_capi_interface(&cuser);
}

View File

@ -6,6 +6,9 @@
* (c) Copyright 1996 by Carsten Paeth (calle@calle.in-berlin.de)
*
* $Log$
* Revision 1.1 1997/03/04 21:50:30 calle
* Frirst version in isdn4linux
*
* Revision 2.2 1997/02/12 09:31:39 calle
* new version
*
@ -21,6 +24,13 @@ struct capidev {
struct sk_buff_head recv_queue;
struct wait_queue *recv_wait;
__u16 errcode;
/* Statistic */
unsigned long nopen;
unsigned long nrecvdroppkt;
unsigned long nrecvctlpkt;
unsigned long nrecvdatapkt;
unsigned long nsentctlpkt;
unsigned long nsentdatapkt;
};
#define CAPI_MAXMINOR CAPI_MAXAPPL

View File

@ -6,6 +6,9 @@
* Copyright 1997 by Carsten Paeth (calle@calle.in-berlin.de)
*
* $Log$
* Revision 1.17 1999/06/10 16:53:55 calle
* Removing of module b1pci will now remove card from lower level.
*
* Revision 1.16 1999/05/31 11:50:33 calle
* Bugfix: In if_sendbuf, skb_push'ed DATA_B3 header was not skb_pull'ed
* on failure, result in data block with DATA_B3 header transmitted
@ -106,6 +109,7 @@
#include <linux/skbuff.h>
#include <linux/isdn.h>
#include <linux/isdnif.h>
#include <linux/proc_fs.h>
#include <linux/capi.h>
#include <linux/kernelcapi.h>
#include <linux/ctype.h>
@ -206,6 +210,12 @@ struct capidrv_data {
__u16 appid;
int ncontr;
struct capidrv_contr *contr_list;
/* statistic */
unsigned long nrecvctlpkt;
unsigned long nrecvdatapkt;
unsigned long nsentctlpkt;
unsigned long nsentdatapkt;
};
typedef struct capidrv_plci capidrv_plci;
@ -579,6 +589,7 @@ static void send_message(capidrv_contr * card, _cmsg * cmsg)
skb = dev_alloc_skb(len);
memcpy(skb_put(skb, len), cmsg->buf, len);
(*capifuncs->capi_put_message) (global.appid, skb);
global.nsentctlpkt++;
}
/* -------- state machine -------------------------------------------- */
@ -1407,6 +1418,7 @@ static void handle_data(_cmsg * cmsg, struct sk_buff *skb)
printk(KERN_ERR "capidrv: %s from unknown controller 0x%x\n",
capi_cmd2str(cmsg->Command, cmsg->Subcommand),
cmsg->adr.adrController & 0x7f);
kfree_skb(skb);
return;
}
if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI))) {
@ -1438,9 +1450,11 @@ static void capidrv_signal(__u16 applid, __u32 dummy)
if (s_cmsg.Command == CAPI_DATA_B3
&& s_cmsg.Subcommand == CAPI_IND) {
handle_data(&s_cmsg, skb);
global.nrecvdatapkt++;
continue;
}
kfree_skb(skb);
global.nrecvctlpkt++;
if ((s_cmsg.adr.adrController & 0xffffff00) == 0)
handle_controller(&s_cmsg);
else if ((s_cmsg.adr.adrPLCI & 0xffff0000) == 0)
@ -1950,6 +1964,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)
if (errcode == CAPI_NOERROR) {
dev_kfree_skb(skb);
nccip->datahandle++;
global.nsentdatapkt++;
return len;
}
(void)capidrv_del_ack(nccip, datahandle);
@ -1960,6 +1975,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)
errcode = (*capifuncs->capi_put_message) (global.appid, skb);
if (errcode == CAPI_NOERROR) {
nccip->datahandle++;
global.nsentdatapkt++;
return len;
}
skb_pull(skb, msglen);
@ -2185,6 +2201,64 @@ static void lower_callback(unsigned int cmd, __u16 contr, void *data)
}
}
/*
* /proc/capi/capidrv:
* nrecvctlpkt nrecvdatapkt nsendctlpkt nsenddatapkt
*/
static int proc_capidrv_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = 0;
len += sprintf(page+len, "%lu %lu %lu %lu\n",
global.nrecvctlpkt,
global.nrecvdatapkt,
global.nsentctlpkt,
global.nsentdatapkt);
if (len < off)
return 0;
*eof = 1;
*start = page -off;
return ((count < len-off) ? count : len-off);
}
static struct procfsentries {
char *name;
mode_t mode;
int (*read_proc)(char *page, char **start, off_t off,
int count, int *eof, void *data);
struct proc_dir_entry *procent;
} procfsentries[] = {
/* { "capi", S_IFDIR, 0 }, */
{ "capi/capidrv", 0 , proc_capidrv_read_proc },
};
static void proc_init(void)
{
int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]);
int i;
for (i=0; i < nelem; i++) {
struct procfsentries *p = procfsentries + i;
p->procent = create_proc_entry(p->name, p->mode, 0);
if (p->procent) p->procent->read_proc = p->read_proc;
}
}
static void proc_exit(void)
{
int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]);
int i;
for (i=nelem-1; i >= 0; i--) {
struct procfsentries *p = procfsentries + i;
if (p->procent) {
remove_proc_entry(p->name, 0);
p->procent = 0;
}
}
}
static struct capi_interface_user cuser = {
"capidrv",
lower_callback
@ -2240,6 +2314,7 @@ int capidrv_init(void)
continue;
(void) capidrv_addcontr(contr, &profile);
}
proc_init();
return 0;
}
@ -2266,6 +2341,7 @@ void cleanup_module(void)
(void) (*capifuncs->capi_release) (global.appid);
detach_capi_interface(&cuser);
proc_exit();
printk(KERN_NOTICE "capidrv: Rev%s: unloaded\n", rev);
}

View File

@ -6,6 +6,9 @@
* Copyright 1996 by Carsten Paeth (calle@calle.in-berlin.de)
*
* $Log$
* Revision 1.6 1999/04/15 19:49:36 calle
* fix fuer die B1-PCI. Jetzt geht z.B. auch IRQ 17 ...
*
* Revision 1.5 1998/10/25 14:50:28 fritz
* Backported from MIPS (Cobalt).
*
@ -153,6 +156,12 @@ typedef struct avmb1_card {
char databuf[2048]; /* capimsg data part */
capi_version cversion;
char name[10];
/* statistic */
unsigned long nrecvdroppkt;
unsigned long nrecvctlpkt;
unsigned long nrecvdatapkt;
unsigned long nsentctlpkt;
unsigned long nsentdatapkt;
} avmb1_card;
/*
@ -189,7 +198,7 @@ void B1_send_register(unsigned int port,
__u16 appid, __u32 nmsg,
__u32 nb3conn, __u32 nb3blocks, __u32 b3bsize);
void B1_send_release(unsigned int port, __u16 appid);
void B1_send_message(unsigned int port, struct sk_buff *skb);
void B1_send_message(avmb1_card * card, struct sk_buff *skb);
/* b1capi.c */
void avmb1_handle_new_ncci(avmb1_card * card,

View File

@ -6,6 +6,9 @@
* (c) Copyright 1997 by Carsten Paeth (calle@calle.in-berlin.de)
*
* $Log$
* Revision 1.1 1997/03/04 21:27:33 calle
* First version in isdn4linux
*
* Revision 2.2 1997/02/12 09:31:39 calle
* new version
*
@ -55,6 +58,7 @@ struct capi_interface {
struct capi_interface_user {
char name[20];
void (*callback) (unsigned int cmd, __u16 contr, void *data);
/* internal */
struct capi_interface_user *next;
};