2 * drivers/s390/net/ctcm_sysfs.c
4 * Copyright IBM Corp. 2007, 2007
5 * Authors: Peter Tiedemann (ptiedem@de.ibm.com)
13 #include <linux/sysfs.h>
14 #include "ctcm_main.h"
20 static ssize_t
ctcm_buffer_show(struct device
*dev
,
21 struct device_attribute
*attr
, char *buf
)
23 struct ctcm_priv
*priv
= dev_get_drvdata(dev
);
27 return sprintf(buf
, "%d\n", priv
->buffer_size
);
30 static ssize_t
ctcm_buffer_write(struct device
*dev
,
31 struct device_attribute
*attr
, const char *buf
, size_t count
)
33 struct net_device
*ndev
;
35 struct ctcm_priv
*priv
= dev_get_drvdata(dev
);
37 if (!(priv
&& priv
->channel
[READ
] &&
38 (ndev
= priv
->channel
[READ
]->netdev
))) {
39 CTCM_DBF_TEXT(SETUP
, CTC_DBF_ERROR
, "bfnondev");
43 sscanf(buf
, "%u", &bs1
);
44 if (bs1
> CTCM_BUFSIZE_LIMIT
)
46 if (bs1
< (576 + LL_HEADER_LENGTH
+ 2))
48 priv
->buffer_size
= bs1
; /* just to overwrite the default */
50 if ((ndev
->flags
& IFF_RUNNING
) &&
51 (bs1
< (ndev
->mtu
+ LL_HEADER_LENGTH
+ 2)))
54 priv
->channel
[READ
]->max_bufsize
= bs1
;
55 priv
->channel
[WRITE
]->max_bufsize
= bs1
;
56 if (!(ndev
->flags
& IFF_RUNNING
))
57 ndev
->mtu
= bs1
- LL_HEADER_LENGTH
- 2;
58 priv
->channel
[READ
]->flags
|= CHANNEL_FLAGS_BUFSIZE_CHANGED
;
59 priv
->channel
[WRITE
]->flags
|= CHANNEL_FLAGS_BUFSIZE_CHANGED
;
61 CTCM_DBF_DEV(SETUP
, ndev
, buf
);
65 CTCM_DBF_DEV(SETUP
, ndev
, "buff_err");
69 static void ctcm_print_statistics(struct ctcm_priv
*priv
)
76 sbuf
= kmalloc(2048, GFP_KERNEL
);
81 p
+= sprintf(p
, " Device FSM state: %s\n",
82 fsm_getstate_str(priv
->fsm
));
83 p
+= sprintf(p
, " RX channel FSM state: %s\n",
84 fsm_getstate_str(priv
->channel
[READ
]->fsm
));
85 p
+= sprintf(p
, " TX channel FSM state: %s\n",
86 fsm_getstate_str(priv
->channel
[WRITE
]->fsm
));
87 p
+= sprintf(p
, " Max. TX buffer used: %ld\n",
88 priv
->channel
[WRITE
]->prof
.maxmulti
);
89 p
+= sprintf(p
, " Max. chained SKBs: %ld\n",
90 priv
->channel
[WRITE
]->prof
.maxcqueue
);
91 p
+= sprintf(p
, " TX single write ops: %ld\n",
92 priv
->channel
[WRITE
]->prof
.doios_single
);
93 p
+= sprintf(p
, " TX multi write ops: %ld\n",
94 priv
->channel
[WRITE
]->prof
.doios_multi
);
95 p
+= sprintf(p
, " Netto bytes written: %ld\n",
96 priv
->channel
[WRITE
]->prof
.txlen
);
97 p
+= sprintf(p
, " Max. TX IO-time: %ld\n",
98 priv
->channel
[WRITE
]->prof
.tx_time
);
100 printk(KERN_INFO
"Statistics for %s:\n%s",
101 priv
->channel
[WRITE
]->netdev
->name
, sbuf
);
106 static ssize_t
stats_show(struct device
*dev
,
107 struct device_attribute
*attr
, char *buf
)
109 struct ctcm_priv
*priv
= dev_get_drvdata(dev
);
112 ctcm_print_statistics(priv
);
113 return sprintf(buf
, "0\n");
116 static ssize_t
stats_write(struct device
*dev
, struct device_attribute
*attr
,
117 const char *buf
, size_t count
)
119 struct ctcm_priv
*priv
= dev_get_drvdata(dev
);
122 /* Reset statistics */
123 memset(&priv
->channel
[WRITE
]->prof
, 0,
124 sizeof(priv
->channel
[WRITE
]->prof
));
128 static ssize_t
ctcm_proto_show(struct device
*dev
,
129 struct device_attribute
*attr
, char *buf
)
131 struct ctcm_priv
*priv
= dev_get_drvdata(dev
);
135 return sprintf(buf
, "%d\n", priv
->protocol
);
138 static ssize_t
ctcm_proto_store(struct device
*dev
,
139 struct device_attribute
*attr
, const char *buf
, size_t count
)
142 struct ctcm_priv
*priv
= dev_get_drvdata(dev
);
146 sscanf(buf
, "%u", &value
);
147 if (!((value
== CTCM_PROTO_S390
) ||
148 (value
== CTCM_PROTO_LINUX
) ||
149 (value
== CTCM_PROTO_MPC
) ||
150 (value
== CTCM_PROTO_OS390
)))
152 priv
->protocol
= value
;
153 CTCM_DBF_DEV(SETUP
, dev
, buf
);
158 static ssize_t
ctcm_type_show(struct device
*dev
,
159 struct device_attribute
*attr
, char *buf
)
161 struct ccwgroup_device
*cgdev
;
163 cgdev
= to_ccwgroupdev(dev
);
167 return sprintf(buf
, "%s\n",
168 cu3088_type
[cgdev
->cdev
[0]->id
.driver_info
]);
171 static DEVICE_ATTR(buffer
, 0644, ctcm_buffer_show
, ctcm_buffer_write
);
172 static DEVICE_ATTR(protocol
, 0644, ctcm_proto_show
, ctcm_proto_store
);
173 static DEVICE_ATTR(type
, 0444, ctcm_type_show
, NULL
);
174 static DEVICE_ATTR(stats
, 0644, stats_show
, stats_write
);
176 static struct attribute
*ctcm_attr
[] = {
177 &dev_attr_protocol
.attr
,
179 &dev_attr_buffer
.attr
,
183 static struct attribute_group ctcm_attr_group
= {
187 int ctcm_add_attributes(struct device
*dev
)
191 rc
= device_create_file(dev
, &dev_attr_stats
);
196 void ctcm_remove_attributes(struct device
*dev
)
198 device_remove_file(dev
, &dev_attr_stats
);
201 int ctcm_add_files(struct device
*dev
)
203 return sysfs_create_group(&dev
->kobj
, &ctcm_attr_group
);
206 void ctcm_remove_files(struct device
*dev
)
208 sysfs_remove_group(&dev
->kobj
, &ctcm_attr_group
);