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