2 * linux/drivers/s390/cio/cmf.c ($Revision: 1.15 $)
4 * Linux on zSeries Channel Measurement Facility support
6 * Copyright 2000,2003 IBM Corporation
8 * Author: Arnd Bergmann <arndb@de.ibm.com>
10 * original idea from Natarajan Krishnaswami <nkrishna@us.ibm.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <linux/bootmem.h>
28 #include <linux/device.h>
29 #include <linux/init.h>
30 #include <linux/list.h>
31 #include <linux/module.h>
32 #include <linux/moduleparam.h>
34 #include <asm/ccwdev.h>
44 /* parameter to enable cmf during boot, possible uses are:
45 * "s390cmf" -- enable cmf and allocate 2 MB of ram so measuring can be
46 * used on any subchannel
47 * "s390cmf=<num>" -- enable cmf and allocate enough memory to measure
48 * <num> subchannel, where <num> is an integer
49 * between 1 and 65535, default is 1024
51 #define ARGSTRING "s390cmf"
53 /* indices for READCMB */
55 /* basic and exended format: */
58 cmb_device_connect_time,
59 cmb_function_pending_time,
60 cmb_device_disconnect_time,
61 cmb_control_unit_queuing_time,
62 cmb_device_active_only_time,
63 /* extended format only: */
65 cmb_initial_command_response_time,
69 * enum cmb_format - types of supported measurement block formats
71 * @CMF_BASIC: traditional channel measurement blocks supported
72 * by all machines that we run on
73 * @CMF_EXTENDED: improved format that was introduced with the z990
75 * @CMF_AUTODETECT: default: use extended format when running on a z990
76 * or later machine, otherwise fall back to basic format
84 * format - actual format for all measurement blocks
86 * The format module parameter can be set to a value of 0 (zero)
87 * or 1, indicating basic or extended format as described for
90 static int format = CMF_AUTODETECT;
91 module_param(format, bool, 0444);
94 * struct cmb_operations - functions to use depending on cmb_format
96 * all these functions operate on a struct cmf_device. There is only
97 * one instance of struct cmb_operations because all cmf_device
98 * objects are guaranteed to be of the same type.
100 * @alloc: allocate memory for a channel measurement block,
101 * either with the help of a special pool or with kmalloc
102 * @free: free memory allocated with @alloc
103 * @set: enable or disable measurement
104 * @readall: read a measurement block in a common format
105 * @reset: clear the data in the associated measurement block and
106 * reset its time stamp
108 struct cmb_operations {
109 int (*alloc) (struct ccw_device*);
110 void(*free) (struct ccw_device*);
111 int (*set) (struct ccw_device*, u32);
112 u64 (*read) (struct ccw_device*, int);
113 int (*readall)(struct ccw_device*, struct cmbdata *);
114 void (*reset) (struct ccw_device*);
116 struct attribute_group *attr_group;
118 static struct cmb_operations *cmbops;
120 /* our user interface is designed in terms of nanoseconds,
121 * while the hardware measures total times in its own
123 static inline u64 time_to_nsec(u32 value)
125 return ((u64)value) * 128000ull;
129 * Users are usually interested in average times,
130 * not accumulated time.
131 * This also helps us with atomicity problems
132 * when reading sinlge values.
134 static inline u64 time_to_avg_nsec(u32 value, u32 count)
138 /* no samples yet, avoid division by 0 */
142 /* value comes in units of 128 µsec */
143 ret = time_to_nsec(value);
149 /* activate or deactivate the channel monitor. When area is NULL,
150 * the monitor is deactivated. The channel monitor needs to
151 * be active in order to measure subchannels, which also need
154 cmf_activate(void *area, unsigned int onoff)
156 register void * __gpr2 asm("2");
157 register long __gpr1 asm("1");
160 __gpr1 = onoff ? 2 : 0;
161 /* activate channel measurement */
162 asm("schm" : : "d" (__gpr2), "d" (__gpr1) );
166 set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address)
170 struct subchannel *sch;
173 sch = to_subchannel(cdev->dev.parent);
175 /* msch can silently fail, so do it again if necessary */
176 for (retry = 0; retry < 3; retry++) {
178 stsch(sch->irq, schib);
179 schib->pmcw.mme = mme;
180 schib->pmcw.mbfc = mbfc;
181 /* address can be either a block address or a block index */
183 schib->mba = address;
185 schib->pmcw.mbi = address;
187 /* try to submit it */
188 switch(ret = msch_err(sch->irq, schib)) {
192 case 2: /* in I/O or status pending */
195 case 3: /* subchannel is no longer valid */
198 default: /* msch caught an exception */
202 stsch(sch->irq, schib); /* restore the schib */
207 /* check if it worked */
208 if (schib->pmcw.mme == mme &&
209 schib->pmcw.mbfc == mbfc &&
210 (mbfc ? (schib->mba == address)
211 : (schib->pmcw.mbi == address)))
220 struct set_schib_struct {
223 unsigned long address;
224 wait_queue_head_t wait;
228 static int set_schib_wait(struct ccw_device *cdev, u32 mme,
229 int mbfc, unsigned long address)
231 struct set_schib_struct s = {
235 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s.wait),
238 spin_lock_irq(cdev->ccwlock);
239 s.ret = set_schib(cdev, mme, mbfc, address);
240 if (s.ret != -EBUSY) {
244 if (cdev->private->state != DEV_STATE_ONLINE) {
246 /* if the device is not online, don't even try again */
249 cdev->private->state = DEV_STATE_CMFCHANGE;
250 cdev->private->cmb_wait = &s;
253 spin_unlock_irq(cdev->ccwlock);
254 if (wait_event_interruptible(s.wait, s.ret != 1)) {
255 spin_lock_irq(cdev->ccwlock);
257 s.ret = -ERESTARTSYS;
258 cdev->private->cmb_wait = 0;
259 if (cdev->private->state == DEV_STATE_CMFCHANGE)
260 cdev->private->state = DEV_STATE_ONLINE;
262 spin_unlock_irq(cdev->ccwlock);
267 spin_unlock_irq(cdev->ccwlock);
271 void retry_set_schib(struct ccw_device *cdev)
273 struct set_schib_struct *s;
275 s = cdev->private->cmb_wait;
276 cdev->private->cmb_wait = 0;
281 s->ret = set_schib(cdev, s->mme, s->mbfc, s->address);
286 * struct cmb_area - container for global cmb data
288 * @mem: pointer to CMBs (only in basic measurement mode)
289 * @list: contains a linked list of all subchannels
290 * @lock: protect concurrent access to @mem and @list
294 struct list_head list;
299 static struct cmb_area cmb_area = {
300 .lock = SPIN_LOCK_UNLOCKED,
301 .list = LIST_HEAD_INIT(cmb_area.list),
302 .num_channels = 1024,
306 /* ****** old style CMB handling ********/
310 * Basic channel measurement blocks are allocated in one contiguous
311 * block of memory, which can not be moved as long as any channel
312 * is active. Therefore, a maximum number of subchannels needs to
313 * be defined somewhere. This is a module parameter, defaulting to
314 * a resonable value of 1024, or 32 kb of memory.
315 * Current kernels don't allow kmalloc with more than 128kb, so the
319 module_param_named(maxchannels, cmb_area.num_channels, uint, 0444);
322 * struct cmb - basic channel measurement block
324 * cmb as used by the hardware the fields are described in z/Architecture
325 * Principles of Operation, chapter 17.
326 * The area to be a contiguous array and may not be reallocated or freed.
327 * Only one cmb area can be present in the system.
332 u32 device_connect_time;
333 u32 function_pending_time;
334 u32 device_disconnect_time;
335 u32 control_unit_queuing_time;
336 u32 device_active_only_time;
340 /* insert a single device into the cmb_area list
341 * called with cmb_area.lock held from alloc_cmb
344 alloc_cmb_single (struct ccw_device *cdev)
347 struct ccw_device_private *node;
350 spin_lock_irq(cdev->ccwlock);
351 if (!list_empty(&cdev->private->cmb_list)) {
356 /* find first unused cmb in cmb_area.mem.
357 * this is a little tricky: cmb_area.list
358 * remains sorted by ->cmb pointers */
360 list_for_each_entry(node, &cmb_area.list, cmb_list) {
361 if ((struct cmb*)node->cmb > cmb)
365 if (cmb - cmb_area.mem >= cmb_area.num_channels) {
371 list_add_tail(&cdev->private->cmb_list, &node->cmb_list);
372 cdev->private->cmb = cmb;
375 spin_unlock_irq(cdev->ccwlock);
380 alloc_cmb (struct ccw_device *cdev)
386 spin_lock(&cmb_area.lock);
389 /* there is no user yet, so we need a new area */
390 size = sizeof(struct cmb) * cmb_area.num_channels;
391 WARN_ON(!list_empty(&cmb_area.list));
393 spin_unlock(&cmb_area.lock);
394 mem = (void*)__get_free_pages(GFP_KERNEL | GFP_DMA,
396 spin_lock(&cmb_area.lock);
399 /* ok, another thread was faster */
400 free_pages((unsigned long)mem, get_order(size));
407 memset(mem, 0, size);
409 cmf_activate(cmb_area.mem, 1);
413 /* do the actual allocation */
414 ret = alloc_cmb_single(cdev);
416 spin_unlock(&cmb_area.lock);
422 free_cmb(struct ccw_device *cdev)
424 struct ccw_device_private *priv;
426 priv = cdev->private;
428 spin_lock(&cmb_area.lock);
429 spin_lock_irq(cdev->ccwlock);
431 if (list_empty(&priv->cmb_list)) {
437 list_del_init(&priv->cmb_list);
439 if (list_empty(&cmb_area.list)) {
441 size = sizeof(struct cmb) * cmb_area.num_channels;
442 cmf_activate(NULL, 0);
443 free_pages((unsigned long)cmb_area.mem, get_order(size));
447 spin_unlock_irq(cdev->ccwlock);
448 spin_unlock(&cmb_area.lock);
452 set_cmb(struct ccw_device *cdev, u32 mme)
456 if (!cdev->private->cmb)
459 offset = mme ? (struct cmb *)cdev->private->cmb - cmb_area.mem : 0;
461 return set_schib_wait(cdev, mme, 0, offset);
465 read_cmb (struct ccw_device *cdev, int index)
467 /* yes, we have to put it on the stack
468 * because the cmb must only be accessed
469 * atomically, e.g. with mvc */
474 spin_lock_irqsave(cdev->ccwlock, flags);
475 if (!cdev->private->cmb) {
476 spin_unlock_irqrestore(cdev->ccwlock, flags);
480 cmb = *(struct cmb*)cdev->private->cmb;
481 spin_unlock_irqrestore(cdev->ccwlock, flags);
484 case cmb_ssch_rsch_count:
485 return cmb.ssch_rsch_count;
486 case cmb_sample_count:
487 return cmb.sample_count;
488 case cmb_device_connect_time:
489 val = cmb.device_connect_time;
491 case cmb_function_pending_time:
492 val = cmb.function_pending_time;
494 case cmb_device_disconnect_time:
495 val = cmb.device_disconnect_time;
497 case cmb_control_unit_queuing_time:
498 val = cmb.control_unit_queuing_time;
500 case cmb_device_active_only_time:
501 val = cmb.device_active_only_time;
506 return time_to_avg_nsec(val, cmb.sample_count);
510 readall_cmb (struct ccw_device *cdev, struct cmbdata *data)
512 /* yes, we have to put it on the stack
513 * because the cmb must only be accessed
514 * atomically, e.g. with mvc */
519 spin_lock_irqsave(cdev->ccwlock, flags);
520 if (!cdev->private->cmb) {
521 spin_unlock_irqrestore(cdev->ccwlock, flags);
525 cmb = *(struct cmb*)cdev->private->cmb;
526 time = get_clock() - cdev->private->cmb_start_time;
527 spin_unlock_irqrestore(cdev->ccwlock, flags);
529 *data = (struct cmbdata) {
530 /* we only know values before device_busy_time */
531 .size = offsetof(struct cmbdata, device_busy_time),
533 /* conver to nanoseconds */
534 .elapsed_time = (time * 1000) >> 12,
536 /* copy data to new structure */
537 .ssch_rsch_count = cmb.ssch_rsch_count,
538 .sample_count = cmb.sample_count,
540 /* time fields are converted to nanoseconds while copying */
542 = time_to_nsec(cmb.device_connect_time),
543 .function_pending_time
544 = time_to_nsec(cmb.function_pending_time),
545 .device_disconnect_time
546 = time_to_nsec(cmb.device_disconnect_time),
547 .control_unit_queuing_time
548 = time_to_nsec(cmb.control_unit_queuing_time),
549 .device_active_only_time
550 = time_to_nsec(cmb.device_active_only_time),
557 reset_cmb(struct ccw_device *cdev)
560 spin_lock_irq(cdev->ccwlock);
561 cmb = cdev->private->cmb;
563 memset (cmb, 0, sizeof (*cmb));
564 cdev->private->cmb_start_time = get_clock();
565 spin_unlock_irq(cdev->ccwlock);
568 static struct attribute_group cmf_attr_group;
570 static struct cmb_operations cmbops_basic = {
575 .readall = readall_cmb,
577 .attr_group = &cmf_attr_group,
580 /* ******** extended cmb handling ********/
583 * struct cmbe - extended channel measurement block
585 * cmb as used by the hardware, may be in any 64 bit physical location,
586 * the fields are described in z/Architecture Principles of Operation,
587 * third edition, chapter 17.
592 u32 device_connect_time;
593 u32 function_pending_time;
594 u32 device_disconnect_time;
595 u32 control_unit_queuing_time;
596 u32 device_active_only_time;
597 u32 device_busy_time;
598 u32 initial_command_response_time;
602 /* kmalloc only guarantees 8 byte alignment, but we need cmbe
603 * pointers to be naturally aligned. Make sure to allocate
604 * enough space for two cmbes */
605 static inline struct cmbe* cmbe_align(struct cmbe *c)
608 addr = ((unsigned long)c + sizeof (struct cmbe) - sizeof(long)) &
609 ~(sizeof (struct cmbe) - sizeof(long));
610 return (struct cmbe*)addr;
614 alloc_cmbe (struct ccw_device *cdev)
617 cmbe = kmalloc (sizeof (*cmbe) * 2, GFP_KERNEL);
621 spin_lock_irq(cdev->ccwlock);
622 if (cdev->private->cmb) {
624 spin_unlock_irq(cdev->ccwlock);
628 cdev->private->cmb = cmbe;
629 spin_unlock_irq(cdev->ccwlock);
631 /* activate global measurement if this is the first channel */
632 spin_lock(&cmb_area.lock);
633 if (list_empty(&cmb_area.list))
634 cmf_activate(NULL, 1);
635 list_add_tail(&cdev->private->cmb_list, &cmb_area.list);
636 spin_unlock(&cmb_area.lock);
642 free_cmbe (struct ccw_device *cdev)
644 spin_lock_irq(cdev->ccwlock);
645 if (cdev->private->cmb)
646 kfree(cdev->private->cmb);
647 cdev->private->cmb = NULL;
648 spin_unlock_irq(cdev->ccwlock);
650 /* deactivate global measurement if this is the last channel */
651 spin_lock(&cmb_area.lock);
652 list_del_init(&cdev->private->cmb_list);
653 if (list_empty(&cmb_area.list))
654 cmf_activate(NULL, 0);
655 spin_unlock(&cmb_area.lock);
659 set_cmbe(struct ccw_device *cdev, u32 mme)
663 if (!cdev->private->cmb)
665 mba = mme ? (unsigned long) cmbe_align(cdev->private->cmb) : 0;
667 return set_schib_wait(cdev, mme, 1, mba);
672 read_cmbe (struct ccw_device *cdev, int index)
674 /* yes, we have to put it on the stack
675 * because the cmb must only be accessed
676 * atomically, e.g. with mvc */
681 spin_lock_irqsave(cdev->ccwlock, flags);
682 if (!cdev->private->cmb) {
683 spin_unlock_irqrestore(cdev->ccwlock, flags);
687 cmb = *cmbe_align(cdev->private->cmb);
688 spin_unlock_irqrestore(cdev->ccwlock, flags);
691 case cmb_ssch_rsch_count:
692 return cmb.ssch_rsch_count;
693 case cmb_sample_count:
694 return cmb.sample_count;
695 case cmb_device_connect_time:
696 val = cmb.device_connect_time;
698 case cmb_function_pending_time:
699 val = cmb.function_pending_time;
701 case cmb_device_disconnect_time:
702 val = cmb.device_disconnect_time;
704 case cmb_control_unit_queuing_time:
705 val = cmb.control_unit_queuing_time;
707 case cmb_device_active_only_time:
708 val = cmb.device_active_only_time;
710 case cmb_device_busy_time:
711 val = cmb.device_busy_time;
713 case cmb_initial_command_response_time:
714 val = cmb.initial_command_response_time;
719 return time_to_avg_nsec(val, cmb.sample_count);
723 readall_cmbe (struct ccw_device *cdev, struct cmbdata *data)
725 /* yes, we have to put it on the stack
726 * because the cmb must only be accessed
727 * atomically, e.g. with mvc */
732 spin_lock_irqsave(cdev->ccwlock, flags);
733 if (!cdev->private->cmb) {
734 spin_unlock_irqrestore(cdev->ccwlock, flags);
738 cmb = *cmbe_align(cdev->private->cmb);
739 time = get_clock() - cdev->private->cmb_start_time;
740 spin_unlock_irqrestore(cdev->ccwlock, flags);
742 *data = (struct cmbdata) {
743 /* we only know values before device_busy_time */
744 .size = offsetof(struct cmbdata, device_busy_time),
746 /* conver to nanoseconds */
747 .elapsed_time = (time * 1000) >> 12,
749 /* copy data to new structure */
750 .ssch_rsch_count = cmb.ssch_rsch_count,
751 .sample_count = cmb.sample_count,
753 /* time fields are converted to nanoseconds while copying */
755 = time_to_nsec(cmb.device_connect_time),
756 .function_pending_time
757 = time_to_nsec(cmb.function_pending_time),
758 .device_disconnect_time
759 = time_to_nsec(cmb.device_disconnect_time),
760 .control_unit_queuing_time
761 = time_to_nsec(cmb.control_unit_queuing_time),
762 .device_active_only_time
763 = time_to_nsec(cmb.device_active_only_time),
765 = time_to_nsec(cmb.device_busy_time),
766 .initial_command_response_time
767 = time_to_nsec(cmb.initial_command_response_time),
774 reset_cmbe(struct ccw_device *cdev)
777 spin_lock_irq(cdev->ccwlock);
778 cmb = cmbe_align(cdev->private->cmb);
780 memset (cmb, 0, sizeof (*cmb));
781 cdev->private->cmb_start_time = get_clock();
782 spin_unlock_irq(cdev->ccwlock);
785 static struct attribute_group cmf_attr_group_ext;
787 static struct cmb_operations cmbops_extended = {
792 .readall = readall_cmbe,
794 .attr_group = &cmf_attr_group_ext,
799 cmb_show_attr(struct device *dev, char *buf, enum cmb_index idx)
801 return sprintf(buf, "%lld\n",
802 (unsigned long long) cmf_read(to_ccwdev(dev), idx));
806 cmb_show_avg_sample_interval(struct device *dev, char *buf)
808 struct ccw_device *cdev;
812 cdev = to_ccwdev(dev);
813 interval = get_clock() - cdev->private->cmb_start_time;
814 count = cmf_read(cdev, cmb_sample_count);
819 return sprintf(buf, "%ld\n", interval);
823 cmb_show_avg_utilization(struct device *dev, char *buf)
830 ret = cmf_readall(to_ccwdev(dev), &data);
834 utilization = data.device_connect_time +
835 data.function_pending_time +
836 data.device_disconnect_time;
838 /* shift to avoid long long division */
839 while (-1ul < (data.elapsed_time | utilization)) {
841 data.elapsed_time >>= 8;
844 /* calculate value in 0.1 percent units */
845 t = (unsigned long) data.elapsed_time / 1000;
846 u = (unsigned long) utilization / t;
848 return sprintf(buf, "%02ld.%01ld%%\n", u/ 10, u - (u/ 10) * 10);
851 #define cmf_attr(name) \
852 static ssize_t show_ ## name (struct device * dev, char * buf) \
853 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
854 static DEVICE_ATTR(name, 0444, show_ ## name, NULL);
856 #define cmf_attr_avg(name) \
857 static ssize_t show_avg_ ## name (struct device * dev, char * buf) \
858 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
859 static DEVICE_ATTR(avg_ ## name, 0444, show_avg_ ## name, NULL);
861 cmf_attr(ssch_rsch_count);
862 cmf_attr(sample_count);
863 cmf_attr_avg(device_connect_time);
864 cmf_attr_avg(function_pending_time);
865 cmf_attr_avg(device_disconnect_time);
866 cmf_attr_avg(control_unit_queuing_time);
867 cmf_attr_avg(device_active_only_time);
868 cmf_attr_avg(device_busy_time);
869 cmf_attr_avg(initial_command_response_time);
871 static DEVICE_ATTR(avg_sample_interval, 0444, cmb_show_avg_sample_interval, NULL);
872 static DEVICE_ATTR(avg_utilization, 0444, cmb_show_avg_utilization, NULL);
874 static struct attribute *cmf_attributes[] = {
875 &dev_attr_avg_sample_interval.attr,
876 &dev_attr_avg_utilization.attr,
877 &dev_attr_ssch_rsch_count.attr,
878 &dev_attr_sample_count.attr,
879 &dev_attr_avg_device_connect_time.attr,
880 &dev_attr_avg_function_pending_time.attr,
881 &dev_attr_avg_device_disconnect_time.attr,
882 &dev_attr_avg_control_unit_queuing_time.attr,
883 &dev_attr_avg_device_active_only_time.attr,
887 static struct attribute_group cmf_attr_group = {
889 .attrs = cmf_attributes,
892 static struct attribute *cmf_attributes_ext[] = {
893 &dev_attr_avg_sample_interval.attr,
894 &dev_attr_avg_utilization.attr,
895 &dev_attr_ssch_rsch_count.attr,
896 &dev_attr_sample_count.attr,
897 &dev_attr_avg_device_connect_time.attr,
898 &dev_attr_avg_function_pending_time.attr,
899 &dev_attr_avg_device_disconnect_time.attr,
900 &dev_attr_avg_control_unit_queuing_time.attr,
901 &dev_attr_avg_device_active_only_time.attr,
902 &dev_attr_avg_device_busy_time.attr,
903 &dev_attr_avg_initial_command_response_time.attr,
907 static struct attribute_group cmf_attr_group_ext = {
909 .attrs = cmf_attributes_ext,
912 static ssize_t cmb_enable_show(struct device *dev, char *buf)
914 return sprintf(buf, "%d\n", to_ccwdev(dev)->private->cmb ? 1 : 0);
917 static ssize_t cmb_enable_store(struct device *dev, const char *buf, size_t c)
919 struct ccw_device *cdev;
922 cdev = to_ccwdev(dev);
926 ret = disable_cmf(cdev);
928 printk(KERN_INFO "disable_cmf failed (%d)\n", ret);
931 ret = enable_cmf(cdev);
932 if (ret && ret != -EBUSY)
933 printk(KERN_INFO "enable_cmf failed (%d)\n", ret);
940 DEVICE_ATTR(cmb_enable, 0644, cmb_enable_show, cmb_enable_store);
942 /* enable_cmf/disable_cmf: module interface for cmf (de)activation */
944 enable_cmf(struct ccw_device *cdev)
948 ret = cmbops->alloc(cdev);
952 ret = cmbops->set(cdev, 2);
957 ret = sysfs_create_group(&cdev->dev.kobj, cmbops->attr_group);
960 cmbops->set(cdev, 0); //FIXME: this can fail
966 disable_cmf(struct ccw_device *cdev)
970 ret = cmbops->set(cdev, 0);
974 sysfs_remove_group(&cdev->dev.kobj, cmbops->attr_group);
979 cmf_read(struct ccw_device *cdev, int index)
981 return cmbops->read(cdev, index);
985 cmf_readall(struct ccw_device *cdev, struct cmbdata *data)
987 return cmbops->readall(cdev, data);
994 char *detect_string = "parameter";
996 /* We cannot really autoprobe this. If the user did not give a parameter,
997 see if we are running on z990 or up, otherwise fall back to basic mode. */
999 if (format == CMF_AUTODETECT) {
1000 if (!css_characteristics_avail ||
1001 !css_general_characteristics.ext_mb) {
1004 format = CMF_EXTENDED;
1006 detect_string = "autodetected";
1008 detect_string = "parameter";
1013 format_string = "basic";
1014 cmbops = &cmbops_basic;
1015 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) {
1016 printk(KERN_ERR "Basic channel measurement facility"
1017 " can only use 1 to 4096 devices\n"
1018 KERN_ERR "when the cmf driver is built"
1019 " as a loadable module\n");
1024 format_string = "extended";
1025 cmbops = &cmbops_extended;
1028 printk(KERN_ERR "Invalid format %d for channel "
1029 "measurement facility\n", format);
1033 printk(KERN_INFO "Channel measurement facility using %s format (%s)\n",
1034 format_string, detect_string);
1038 module_init(init_cmf);
1041 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
1042 MODULE_LICENSE("GPL");
1043 MODULE_DESCRIPTION("channel measurement facility base driver\n"
1044 "Copyright 2003 IBM Corporation\n");
1046 EXPORT_SYMBOL_GPL(enable_cmf);
1047 EXPORT_SYMBOL_GPL(disable_cmf);
1048 EXPORT_SYMBOL_GPL(cmf_read);
1049 EXPORT_SYMBOL_GPL(cmf_readall);