aboutsummaryrefslogtreecommitdiffstats
path: root/net/atm/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/atm/proc.c')
-rw-r--r--net/atm/proc.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/net/atm/proc.c b/net/atm/proc.c
index ab8419a324b6..696e218436e5 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -22,17 +22,18 @@
22#include <linux/netdevice.h> 22#include <linux/netdevice.h>
23#include <linux/atmclip.h> 23#include <linux/atmclip.h>
24#include <linux/init.h> /* for __init */ 24#include <linux/init.h> /* for __init */
25#include <linux/slab.h>
25#include <net/net_namespace.h> 26#include <net/net_namespace.h>
26#include <net/atmclip.h> 27#include <net/atmclip.h>
27#include <asm/uaccess.h> 28#include <linux/uaccess.h>
29#include <linux/param.h> /* for HZ */
28#include <asm/atomic.h> 30#include <asm/atomic.h>
29#include <asm/param.h> /* for HZ */
30#include "resources.h" 31#include "resources.h"
31#include "common.h" /* atm_proc_init prototype */ 32#include "common.h" /* atm_proc_init prototype */
32#include "signaling.h" /* to get sigd - ugly too */ 33#include "signaling.h" /* to get sigd - ugly too */
33 34
34static ssize_t proc_dev_atm_read(struct file *file,char __user *buf,size_t count, 35static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,
35 loff_t *pos); 36 size_t count, loff_t *pos);
36 37
37static const struct file_operations proc_atm_dev_ops = { 38static const struct file_operations proc_atm_dev_ops = {
38 .owner = THIS_MODULE, 39 .owner = THIS_MODULE,
@@ -43,9 +44,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
43 const struct k_atm_aal_stats *stats) 44 const struct k_atm_aal_stats *stats)
44{ 45{
45 seq_printf(seq, "%s ( %d %d %d %d %d )", aal, 46 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
46 atomic_read(&stats->tx),atomic_read(&stats->tx_err), 47 atomic_read(&stats->tx), atomic_read(&stats->tx_err),
47 atomic_read(&stats->rx),atomic_read(&stats->rx_err), 48 atomic_read(&stats->rx), atomic_read(&stats->rx_err),
48 atomic_read(&stats->rx_drop)); 49 atomic_read(&stats->rx_drop));
49} 50}
50 51
51static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev) 52static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
@@ -151,8 +152,8 @@ static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
151 152
152static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) 153static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc)
153{ 154{
154 static const char *const class_name[] = 155 static const char *const class_name[] = {
155 {"off","UBR","CBR","VBR","ABR"}; 156 "off", "UBR", "CBR", "VBR", "ABR"};
156 static const char *const aal_name[] = { 157 static const char *const aal_name[] = {
157 "---", "1", "2", "3/4", /* 0- 3 */ 158 "---", "1", "2", "3/4", /* 0- 3 */
158 "???", "5", "???", "???", /* 4- 7 */ 159 "???", "5", "???", "???", /* 4- 7 */
@@ -160,11 +161,12 @@ static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc)
160 "???", "0", "???", "???"}; /* 12-15 */ 161 "???", "0", "???", "???"}; /* 12-15 */
161 162
162 seq_printf(seq, "%3d %3d %5d %-3s %7d %-5s %7d %-6s", 163 seq_printf(seq, "%3d %3d %5d %-3s %7d %-5s %7d %-6s",
163 vcc->dev->number,vcc->vpi,vcc->vci, 164 vcc->dev->number, vcc->vpi, vcc->vci,
164 vcc->qos.aal >= ARRAY_SIZE(aal_name) ? "err" : 165 vcc->qos.aal >= ARRAY_SIZE(aal_name) ? "err" :
165 aal_name[vcc->qos.aal],vcc->qos.rxtp.min_pcr, 166 aal_name[vcc->qos.aal], vcc->qos.rxtp.min_pcr,
166 class_name[vcc->qos.rxtp.traffic_class],vcc->qos.txtp.min_pcr, 167 class_name[vcc->qos.rxtp.traffic_class],
167 class_name[vcc->qos.txtp.traffic_class]); 168 vcc->qos.txtp.min_pcr,
169 class_name[vcc->qos.txtp.traffic_class]);
168 if (test_bit(ATM_VF_IS_CLIP, &vcc->flags)) { 170 if (test_bit(ATM_VF_IS_CLIP, &vcc->flags)) {
169 struct clip_vcc *clip_vcc = CLIP_VCC(vcc); 171 struct clip_vcc *clip_vcc = CLIP_VCC(vcc);
170 struct net_device *dev; 172 struct net_device *dev;
@@ -195,19 +197,20 @@ static void vcc_info(struct seq_file *seq, struct atm_vcc *vcc)
195 seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi, 197 seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi,
196 vcc->vci); 198 vcc->vci);
197 switch (sk->sk_family) { 199 switch (sk->sk_family) {
198 case AF_ATMPVC: 200 case AF_ATMPVC:
199 seq_printf(seq, "PVC"); 201 seq_printf(seq, "PVC");
200 break; 202 break;
201 case AF_ATMSVC: 203 case AF_ATMSVC:
202 seq_printf(seq, "SVC"); 204 seq_printf(seq, "SVC");
203 break; 205 break;
204 default: 206 default:
205 seq_printf(seq, "%3d", sk->sk_family); 207 seq_printf(seq, "%3d", sk->sk_family);
206 } 208 }
207 seq_printf(seq, " %04lx %5d %7d/%7d %7d/%7d [%d]\n", vcc->flags, sk->sk_err, 209 seq_printf(seq, " %04lx %5d %7d/%7d %7d/%7d [%d]\n",
208 sk_wmem_alloc_get(sk), sk->sk_sndbuf, 210 vcc->flags, sk->sk_err,
209 sk_rmem_alloc_get(sk), sk->sk_rcvbuf, 211 sk_wmem_alloc_get(sk), sk->sk_sndbuf,
210 atomic_read(&sk->sk_refcnt)); 212 sk_rmem_alloc_get(sk), sk->sk_rcvbuf,
213 atomic_read(&sk->sk_refcnt));
211} 214}
212 215
213static void svc_info(struct seq_file *seq, struct atm_vcc *vcc) 216static void svc_info(struct seq_file *seq, struct atm_vcc *vcc)
@@ -236,7 +239,7 @@ static int atm_dev_seq_show(struct seq_file *seq, void *v)
236 "Itf Type ESI/\"MAC\"addr " 239 "Itf Type ESI/\"MAC\"addr "
237 "AAL(TX,err,RX,err,drop) ... [refcnt]\n"; 240 "AAL(TX,err,RX,err,drop) ... [refcnt]\n";
238 241
239 if (v == SEQ_START_TOKEN) 242 if (v == &atm_devs)
240 seq_puts(seq, atm_dev_banner); 243 seq_puts(seq, atm_dev_banner);
241 else { 244 else {
242 struct atm_dev *dev = list_entry(v, struct atm_dev, dev_list); 245 struct atm_dev *dev = list_entry(v, struct atm_dev, dev_list);
@@ -376,32 +379,35 @@ static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,
376 unsigned long page; 379 unsigned long page;
377 int length; 380 int length;
378 381
379 if (count == 0) return 0; 382 if (count == 0)
383 return 0;
380 page = get_zeroed_page(GFP_KERNEL); 384 page = get_zeroed_page(GFP_KERNEL);
381 if (!page) return -ENOMEM; 385 if (!page)
386 return -ENOMEM;
382 dev = PDE(file->f_path.dentry->d_inode)->data; 387 dev = PDE(file->f_path.dentry->d_inode)->data;
383 if (!dev->ops->proc_read) 388 if (!dev->ops->proc_read)
384 length = -EINVAL; 389 length = -EINVAL;
385 else { 390 else {
386 length = dev->ops->proc_read(dev,pos,(char *) page); 391 length = dev->ops->proc_read(dev, pos, (char *)page);
387 if (length > count) length = -EINVAL; 392 if (length > count)
393 length = -EINVAL;
388 } 394 }
389 if (length >= 0) { 395 if (length >= 0) {
390 if (copy_to_user(buf,(char *) page,length)) length = -EFAULT; 396 if (copy_to_user(buf, (char *)page, length))
397 length = -EFAULT;
391 (*pos)++; 398 (*pos)++;
392 } 399 }
393 free_page(page); 400 free_page(page);
394 return length; 401 return length;
395} 402}
396 403
397
398struct proc_dir_entry *atm_proc_root; 404struct proc_dir_entry *atm_proc_root;
399EXPORT_SYMBOL(atm_proc_root); 405EXPORT_SYMBOL(atm_proc_root);
400 406
401 407
402int atm_proc_dev_register(struct atm_dev *dev) 408int atm_proc_dev_register(struct atm_dev *dev)
403{ 409{
404 int digits,num; 410 int digits, num;
405 int error; 411 int error;
406 412
407 /* No proc info */ 413 /* No proc info */
@@ -410,26 +416,28 @@ int atm_proc_dev_register(struct atm_dev *dev)
410 416
411 error = -ENOMEM; 417 error = -ENOMEM;
412 digits = 0; 418 digits = 0;
413 for (num = dev->number; num; num /= 10) digits++; 419 for (num = dev->number; num; num /= 10)
414 if (!digits) digits++; 420 digits++;
421 if (!digits)
422 digits++;
415 423
416 dev->proc_name = kmalloc(strlen(dev->type) + digits + 2, GFP_KERNEL); 424 dev->proc_name = kmalloc(strlen(dev->type) + digits + 2, GFP_KERNEL);
417 if (!dev->proc_name) 425 if (!dev->proc_name)
418 goto err_out; 426 goto err_out;
419 sprintf(dev->proc_name,"%s:%d",dev->type, dev->number); 427 sprintf(dev->proc_name, "%s:%d", dev->type, dev->number);
420 428
421 dev->proc_entry = proc_create_data(dev->proc_name, 0, atm_proc_root, 429 dev->proc_entry = proc_create_data(dev->proc_name, 0, atm_proc_root,
422 &proc_atm_dev_ops, dev); 430 &proc_atm_dev_ops, dev);
423 if (!dev->proc_entry) 431 if (!dev->proc_entry)
424 goto err_free_name; 432 goto err_free_name;
425 return 0; 433 return 0;
434
426err_free_name: 435err_free_name:
427 kfree(dev->proc_name); 436 kfree(dev->proc_name);
428err_out: 437err_out:
429 return error; 438 return error;
430} 439}
431 440
432
433void atm_proc_dev_deregister(struct atm_dev *dev) 441void atm_proc_dev_deregister(struct atm_dev *dev)
434{ 442{
435 if (!dev->ops->proc_read) 443 if (!dev->ops->proc_read)