1 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
4 #include <linux/errno.h>
5 #include <linux/kernel.h>
6 #include <linux/string.h>
8 #include <linux/module.h>
10 #include <linux/time.h>
14 #include <linux/atm.h>
25 #define dprintk(format, args...) \
26 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args)
28 #define dprintk(format, args...) \
30 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\
35 #define ddprintk(format, args...) \
36 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args)
38 #define ddprintk(format, args...) \
40 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\
44 #define STAT_FILE_NAME "mpc"
50 static ssize_t proc_mpc_write(
struct file *
file,
const char __user *buff,
51 size_t nbytes, loff_t *ppos);
53 static int parse_qos(
const char *buff);
60 .open = proc_mpc_open,
63 .write = proc_mpc_write,
70 static const char *ingress_state_string(
int state)
89 static const char *egress_state_string(
int state)
114 for (mpc = mpcs; mpc; mpc = mpc->
next)
120 static void *mpc_next(
struct seq_file *m,
void *
v, loff_t *pos)
127 static void mpc_stop(
struct seq_file *m,
void *
v)
134 static int mpc_show(
struct seq_file *m,
void *
v)
141 unsigned char ip_string[16];
149 seq_printf(m,
"Ingress Entries:\nIP address State Holding time Packets fwded VPI VCI\n");
152 for (in_entry = mpc->
in_cache; in_entry; in_entry = in_entry->
next) {
158 (now.tv_sec-in_entry->
tv.tv_sec),
168 seq_printf(m,
"Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n");
169 for (eg_entry = mpc->
eg_cache; eg_entry; eg_entry = eg_entry->
next) {
170 unsigned char *
p = eg_entry->
ctrl_info.in_MPC_data_ATM_addr;
177 (now.tv_sec-eg_entry->
tv.tv_sec)),
206 static ssize_t proc_mpc_write(
struct file *
file,
const char __user *buff,
207 size_t nbytes, loff_t *ppos)
222 for (p = page, len = 0; len <
nbytes; p++, len++) {
227 if (*p ==
'\0' || *p ==
'\n')
233 if (!parse_qos(page))
234 printk(
"mpoa: proc_mpc_write: could not parse '%s'\n", page);
241 static int parse_qos(
const char *buff)
247 int tx_pcr, tx_sdu, rx_pcr, rx_sdu;
253 if (
sscanf(buff,
"del %hhu.%hhu.%hhu.%hhu",
254 ip, ip+1, ip+2, ip+3) == 4) {
259 if (
sscanf(buff,
"add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=tx",
260 ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu) == 6) {
263 }
else if (
sscanf(buff,
"add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=%d,%d",
264 ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
268 qos.txtp.traffic_class =
ATM_CBR;
269 qos.txtp.max_pcr = tx_pcr;
270 qos.txtp.max_sdu = tx_sdu;
271 qos.rxtp.traffic_class =
ATM_CBR;
272 qos.rxtp.max_pcr = rx_pcr;
273 qos.rxtp.max_sdu = rx_sdu;
275 dprintk(
"parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
276 qos.txtp.max_pcr, qos.txtp.max_sdu,
277 qos.rxtp.max_pcr, qos.rxtp.max_sdu);
290 p = proc_create(STAT_FILE_NAME, 0, atm_proc_root, &mpc_file_operations);
292 pr_err(
"Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);