aboutsummaryrefslogtreecommitdiffstats
path: root/net/atm/mpoa_proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/atm/mpoa_proc.c')
-rw-r--r--net/atm/mpoa_proc.c90
1 files changed, 50 insertions, 40 deletions
diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 1a0f5ccea9c4..53e500292271 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -1,3 +1,4 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
1 2
2#ifdef CONFIG_PROC_FS 3#ifdef CONFIG_PROC_FS
3#include <linux/errno.h> 4#include <linux/errno.h>
@@ -8,9 +9,10 @@
8#include <linux/proc_fs.h> 9#include <linux/proc_fs.h>
9#include <linux/time.h> 10#include <linux/time.h>
10#include <linux/seq_file.h> 11#include <linux/seq_file.h>
11#include <asm/uaccess.h> 12#include <linux/uaccess.h>
12#include <linux/atmmpc.h> 13#include <linux/atmmpc.h>
13#include <linux/atm.h> 14#include <linux/atm.h>
15#include <linux/gfp.h>
14#include "mpc.h" 16#include "mpc.h"
15#include "mpoa_caches.h" 17#include "mpoa_caches.h"
16 18
@@ -20,9 +22,23 @@
20 */ 22 */
21 23
22#if 1 24#if 1
23#define dprintk printk /* debug */ 25#define dprintk(format, args...) \
26 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args) /* debug */
24#else 27#else
25#define dprintk(format,args...) 28#define dprintk(format, args...) \
29 do { if (0) \
30 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\
31 } while (0)
32#endif
33
34#if 0
35#define ddprintk(format, args...) \
36 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args) /* debug */
37#else
38#define ddprintk(format, args...) \
39 do { if (0) \
40 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\
41 } while (0)
26#endif 42#endif
27 43
28#define STAT_FILE_NAME "mpc" /* Our statistic file's name */ 44#define STAT_FILE_NAME "mpc" /* Our statistic file's name */
@@ -51,42 +67,37 @@ static const struct file_operations mpc_file_operations = {
51/* 67/*
52 * Returns the state of an ingress cache entry as a string 68 * Returns the state of an ingress cache entry as a string
53 */ 69 */
54static const char *ingress_state_string(int state){ 70static const char *ingress_state_string(int state)
55 switch(state) { 71{
72 switch (state) {
56 case INGRESS_RESOLVING: 73 case INGRESS_RESOLVING:
57 return "resolving "; 74 return "resolving ";
58 break;
59 case INGRESS_RESOLVED: 75 case INGRESS_RESOLVED:
60 return "resolved "; 76 return "resolved ";
61 break;
62 case INGRESS_INVALID: 77 case INGRESS_INVALID:
63 return "invalid "; 78 return "invalid ";
64 break;
65 case INGRESS_REFRESHING: 79 case INGRESS_REFRESHING:
66 return "refreshing "; 80 return "refreshing ";
67 break;
68 default:
69 return "";
70 } 81 }
82
83 return "";
71} 84}
72 85
73/* 86/*
74 * Returns the state of an egress cache entry as a string 87 * Returns the state of an egress cache entry as a string
75 */ 88 */
76static const char *egress_state_string(int state){ 89static const char *egress_state_string(int state)
77 switch(state) { 90{
91 switch (state) {
78 case EGRESS_RESOLVED: 92 case EGRESS_RESOLVED:
79 return "resolved "; 93 return "resolved ";
80 break;
81 case EGRESS_PURGE: 94 case EGRESS_PURGE:
82 return "purge "; 95 return "purge ";
83 break;
84 case EGRESS_INVALID: 96 case EGRESS_INVALID:
85 return "invalid "; 97 return "invalid ";
86 break;
87 default:
88 return "";
89 } 98 }
99
100 return "";
90} 101}
91 102
92/* 103/*
@@ -123,7 +134,6 @@ static void mpc_stop(struct seq_file *m, void *v)
123static int mpc_show(struct seq_file *m, void *v) 134static int mpc_show(struct seq_file *m, void *v)
124{ 135{
125 struct mpoa_client *mpc = v; 136 struct mpoa_client *mpc = v;
126 unsigned char *temp;
127 int i; 137 int i;
128 in_cache_entry *in_entry; 138 in_cache_entry *in_entry;
129 eg_cache_entry *eg_entry; 139 eg_cache_entry *eg_entry;
@@ -140,15 +150,17 @@ static int mpc_show(struct seq_file *m, void *v)
140 do_gettimeofday(&now); 150 do_gettimeofday(&now);
141 151
142 for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) { 152 for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) {
143 temp = (unsigned char *)&in_entry->ctrl_info.in_dst_ip; 153 sprintf(ip_string, "%pI4", &in_entry->ctrl_info.in_dst_ip);
144 sprintf(ip_string,"%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]);
145 seq_printf(m, "%-16s%s%-14lu%-12u", 154 seq_printf(m, "%-16s%s%-14lu%-12u",
146 ip_string, 155 ip_string,
147 ingress_state_string(in_entry->entry_state), 156 ingress_state_string(in_entry->entry_state),
148 in_entry->ctrl_info.holding_time-(now.tv_sec-in_entry->tv.tv_sec), 157 in_entry->ctrl_info.holding_time -
149 in_entry->packets_fwded); 158 (now.tv_sec-in_entry->tv.tv_sec),
159 in_entry->packets_fwded);
150 if (in_entry->shortcut) 160 if (in_entry->shortcut)
151 seq_printf(m, " %-3d %-3d",in_entry->shortcut->vpi,in_entry->shortcut->vci); 161 seq_printf(m, " %-3d %-3d",
162 in_entry->shortcut->vpi,
163 in_entry->shortcut->vci);
152 seq_printf(m, "\n"); 164 seq_printf(m, "\n");
153 } 165 }
154 166
@@ -156,21 +168,23 @@ static int mpc_show(struct seq_file *m, void *v)
156 seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n"); 168 seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n");
157 for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) { 169 for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) {
158 unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr; 170 unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr;
159 for(i = 0; i < ATM_ESA_LEN; i++) 171 for (i = 0; i < ATM_ESA_LEN; i++)
160 seq_printf(m, "%02x", p[i]); 172 seq_printf(m, "%02x", p[i]);
161 seq_printf(m, "\n%-16lu%s%-14lu%-15u", 173 seq_printf(m, "\n%-16lu%s%-14lu%-15u",
162 (unsigned long)ntohl(eg_entry->ctrl_info.cache_id), 174 (unsigned long)ntohl(eg_entry->ctrl_info.cache_id),
163 egress_state_string(eg_entry->entry_state), 175 egress_state_string(eg_entry->entry_state),
164 (eg_entry->ctrl_info.holding_time-(now.tv_sec-eg_entry->tv.tv_sec)), 176 (eg_entry->ctrl_info.holding_time -
177 (now.tv_sec-eg_entry->tv.tv_sec)),
165 eg_entry->packets_rcvd); 178 eg_entry->packets_rcvd);
166 179
167 /* latest IP address */ 180 /* latest IP address */
168 temp = (unsigned char *)&eg_entry->latest_ip_addr; 181 sprintf(ip_string, "%pI4", &eg_entry->latest_ip_addr);
169 sprintf(ip_string, "%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]);
170 seq_printf(m, "%-16s", ip_string); 182 seq_printf(m, "%-16s", ip_string);
171 183
172 if (eg_entry->shortcut) 184 if (eg_entry->shortcut)
173 seq_printf(m, " %-3d %-3d",eg_entry->shortcut->vpi,eg_entry->shortcut->vci); 185 seq_printf(m, " %-3d %-3d",
186 eg_entry->shortcut->vpi,
187 eg_entry->shortcut->vci);
174 seq_printf(m, "\n"); 188 seq_printf(m, "\n");
175 } 189 }
176 seq_printf(m, "\n"); 190 seq_printf(m, "\n");
@@ -258,12 +272,9 @@ static int parse_qos(const char *buff)
258 qos.rxtp.max_pcr = rx_pcr; 272 qos.rxtp.max_pcr = rx_pcr;
259 qos.rxtp.max_sdu = rx_sdu; 273 qos.rxtp.max_sdu = rx_sdu;
260 qos.aal = ATM_AAL5; 274 qos.aal = ATM_AAL5;
261 dprintk("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n", 275 dprintk("parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
262 qos.txtp.max_pcr, 276 qos.txtp.max_pcr, qos.txtp.max_sdu,
263 qos.txtp.max_sdu, 277 qos.rxtp.max_pcr, qos.rxtp.max_sdu);
264 qos.rxtp.max_pcr,
265 qos.rxtp.max_sdu
266 );
267 278
268 atm_mpoa_add_qos(ipaddr, &qos); 279 atm_mpoa_add_qos(ipaddr, &qos);
269 return 1; 280 return 1;
@@ -278,7 +289,7 @@ int mpc_proc_init(void)
278 289
279 p = proc_create(STAT_FILE_NAME, 0, atm_proc_root, &mpc_file_operations); 290 p = proc_create(STAT_FILE_NAME, 0, atm_proc_root, &mpc_file_operations);
280 if (!p) { 291 if (!p) {
281 printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME); 292 pr_err("Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);
282 return -ENOMEM; 293 return -ENOMEM;
283 } 294 }
284 return 0; 295 return 0;
@@ -289,10 +300,9 @@ int mpc_proc_init(void)
289 */ 300 */
290void mpc_proc_clean(void) 301void mpc_proc_clean(void)
291{ 302{
292 remove_proc_entry(STAT_FILE_NAME,atm_proc_root); 303 remove_proc_entry(STAT_FILE_NAME, atm_proc_root);
293} 304}
294 305
295
296#endif /* CONFIG_PROC_FS */ 306#endif /* CONFIG_PROC_FS */
297 307
298 308