Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * S/390 common I/O routines -- channel subsystem call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 4 | * Copyright IBM Corp. 1999,2012 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Author(s): Ingo Adlung (adlung@de.ibm.com) |
Cornelia Huck | 4ce3b30 | 2006-01-14 13:21:04 -0800 | [diff] [blame] | 6 | * Cornelia Huck (cornelia.huck@de.ibm.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * Arnd Bergmann (arndb@de.ibm.com) |
| 8 | */ |
| 9 | |
Michael Ernst | e6d5a42 | 2008-12-25 13:39:36 +0100 | [diff] [blame] | 10 | #define KMSG_COMPONENT "cio" |
| 11 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/slab.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/device.h> |
Sebastian Ott | 9f3d6d7 | 2016-01-25 10:32:51 +0100 | [diff] [blame] | 17 | #include <linux/mutex.h> |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 18 | #include <linux/pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #include <asm/cio.h> |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 21 | #include <asm/chpid.h> |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 22 | #include <asm/chsc.h> |
Heiko Carstens | f5daba1 | 2009-03-26 15:24:01 +0100 | [diff] [blame] | 23 | #include <asm/crw.h> |
Sebastian Ott | ca4ba15 | 2013-06-05 18:59:22 +0200 | [diff] [blame] | 24 | #include <asm/isc.h> |
Peter Oberparleiter | 1d2334c | 2015-07-15 14:04:18 +0200 | [diff] [blame] | 25 | #include <asm/ebcdic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | #include "css.h" |
| 28 | #include "cio.h" |
| 29 | #include "cio_debug.h" |
| 30 | #include "ioasm.h" |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 31 | #include "chp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include "chsc.h" |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | static void *sei_page; |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 35 | static void *chsc_page; |
| 36 | static DEFINE_SPINLOCK(chsc_page_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Cornelia Huck | dae3984 | 2008-07-17 17:16:47 +0200 | [diff] [blame] | 38 | /** |
| 39 | * chsc_error_from_response() - convert a chsc response to an error |
| 40 | * @response: chsc response code |
| 41 | * |
| 42 | * Returns an appropriate Linux error code for @response. |
| 43 | */ |
| 44 | int chsc_error_from_response(int response) |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 45 | { |
| 46 | switch (response) { |
| 47 | case 0x0001: |
| 48 | return 0; |
| 49 | case 0x0002: |
| 50 | case 0x0003: |
| 51 | case 0x0006: |
| 52 | case 0x0007: |
| 53 | case 0x0008: |
| 54 | case 0x000a: |
Michael Ernst | fd0457a | 2010-08-09 18:12:50 +0200 | [diff] [blame] | 55 | case 0x0104: |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 56 | return -EINVAL; |
| 57 | case 0x0004: |
| 58 | return -EOPNOTSUPP; |
Sebastian Ott | 184b08a | 2012-08-28 16:45:42 +0200 | [diff] [blame] | 59 | case 0x000b: |
Eugene Crosser | 1c59a86 | 2013-04-24 12:00:23 +0200 | [diff] [blame] | 60 | case 0x0107: /* "Channel busy" for the op 0x003d */ |
Sebastian Ott | 184b08a | 2012-08-28 16:45:42 +0200 | [diff] [blame] | 61 | return -EBUSY; |
| 62 | case 0x0100: |
| 63 | case 0x0102: |
| 64 | return -ENOMEM; |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 65 | default: |
| 66 | return -EIO; |
| 67 | } |
| 68 | } |
Cornelia Huck | dae3984 | 2008-07-17 17:16:47 +0200 | [diff] [blame] | 69 | EXPORT_SYMBOL_GPL(chsc_error_from_response); |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 70 | |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 71 | struct chsc_ssd_area { |
| 72 | struct chsc_header request; |
| 73 | u16 :10; |
| 74 | u16 ssid:2; |
| 75 | u16 :4; |
| 76 | u16 f_sch; /* first subchannel */ |
| 77 | u16 :16; |
| 78 | u16 l_sch; /* last subchannel */ |
| 79 | u32 :32; |
| 80 | struct chsc_header response; |
| 81 | u32 :32; |
| 82 | u8 sch_valid : 1; |
| 83 | u8 dev_valid : 1; |
| 84 | u8 st : 3; /* subchannel type */ |
| 85 | u8 zeroes : 3; |
| 86 | u8 unit_addr; /* unit address */ |
| 87 | u16 devno; /* device number */ |
| 88 | u8 path_mask; |
| 89 | u8 fla_valid_mask; |
| 90 | u16 sch; /* subchannel */ |
| 91 | u8 chpid[8]; /* chpids 0-7 */ |
| 92 | u16 fla[8]; /* full link addresses 0-7 */ |
| 93 | } __attribute__ ((packed)); |
| 94 | |
| 95 | int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | { |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 97 | struct chsc_ssd_area *ssd_area; |
| 98 | int ccode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | int ret; |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 100 | int i; |
| 101 | int mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 103 | spin_lock_irq(&chsc_page_lock); |
| 104 | memset(chsc_page, 0, PAGE_SIZE); |
| 105 | ssd_area = chsc_page; |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 106 | ssd_area->request.length = 0x0010; |
| 107 | ssd_area->request.code = 0x0004; |
| 108 | ssd_area->ssid = schid.ssid; |
| 109 | ssd_area->f_sch = schid.sch_no; |
| 110 | ssd_area->l_sch = schid.sch_no; |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 111 | |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 112 | ccode = chsc(ssd_area); |
| 113 | /* Check response. */ |
| 114 | if (ccode > 0) { |
| 115 | ret = (ccode == 3) ? -ENODEV : -EBUSY; |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 116 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | } |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 118 | ret = chsc_error_from_response(ssd_area->response.code); |
| 119 | if (ret != 0) { |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 120 | CIO_MSG_EVENT(2, "chsc: ssd failed for 0.%x.%04x (rc=%04x)\n", |
| 121 | schid.ssid, schid.sch_no, |
| 122 | ssd_area->response.code); |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 123 | goto out; |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 124 | } |
| 125 | if (!ssd_area->sch_valid) { |
| 126 | ret = -ENODEV; |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 127 | goto out; |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 128 | } |
| 129 | /* Copy data */ |
| 130 | ret = 0; |
| 131 | memset(ssd, 0, sizeof(struct chsc_ssd_info)); |
Cornelia Huck | b279a4f | 2008-01-26 14:10:45 +0100 | [diff] [blame] | 132 | if ((ssd_area->st != SUBCHANNEL_TYPE_IO) && |
| 133 | (ssd_area->st != SUBCHANNEL_TYPE_MSG)) |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 134 | goto out; |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 135 | ssd->path_mask = ssd_area->path_mask; |
| 136 | ssd->fla_valid_mask = ssd_area->fla_valid_mask; |
| 137 | for (i = 0; i < 8; i++) { |
| 138 | mask = 0x80 >> i; |
| 139 | if (ssd_area->path_mask & mask) { |
| 140 | chp_id_init(&ssd->chpid[i]); |
| 141 | ssd->chpid[i].id = ssd_area->chpid[i]; |
| 142 | } |
| 143 | if (ssd_area->fla_valid_mask & mask) |
| 144 | ssd->fla[i] = ssd_area->fla[i]; |
| 145 | } |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 146 | out: |
| 147 | spin_unlock_irq(&chsc_page_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | return ret; |
| 149 | } |
| 150 | |
Sebastian Ott | da5b6cb | 2013-06-05 18:58:35 +0200 | [diff] [blame] | 151 | /** |
| 152 | * chsc_ssqd() - store subchannel QDIO data (SSQD) |
| 153 | * @schid: id of the subchannel on which SSQD is performed |
| 154 | * @ssqd: request and response block for SSQD |
| 155 | * |
| 156 | * Returns 0 on success. |
| 157 | */ |
| 158 | int chsc_ssqd(struct subchannel_id schid, struct chsc_ssqd_area *ssqd) |
| 159 | { |
| 160 | memset(ssqd, 0, sizeof(*ssqd)); |
| 161 | ssqd->request.length = 0x0010; |
| 162 | ssqd->request.code = 0x0024; |
| 163 | ssqd->first_sch = schid.sch_no; |
| 164 | ssqd->last_sch = schid.sch_no; |
| 165 | ssqd->ssid = schid.ssid; |
| 166 | |
| 167 | if (chsc(ssqd)) |
| 168 | return -EIO; |
| 169 | |
| 170 | return chsc_error_from_response(ssqd->response.code); |
| 171 | } |
| 172 | EXPORT_SYMBOL_GPL(chsc_ssqd); |
| 173 | |
Sebastian Ott | ca4ba15 | 2013-06-05 18:59:22 +0200 | [diff] [blame] | 174 | /** |
| 175 | * chsc_sadc() - set adapter device controls (SADC) |
| 176 | * @schid: id of the subchannel on which SADC is performed |
| 177 | * @scssc: request and response block for SADC |
| 178 | * @summary_indicator_addr: summary indicator address |
| 179 | * @subchannel_indicator_addr: subchannel indicator address |
| 180 | * |
| 181 | * Returns 0 on success. |
| 182 | */ |
| 183 | int chsc_sadc(struct subchannel_id schid, struct chsc_scssc_area *scssc, |
| 184 | u64 summary_indicator_addr, u64 subchannel_indicator_addr) |
| 185 | { |
| 186 | memset(scssc, 0, sizeof(*scssc)); |
| 187 | scssc->request.length = 0x0fe0; |
| 188 | scssc->request.code = 0x0021; |
| 189 | scssc->operation_code = 0; |
| 190 | |
| 191 | scssc->summary_indicator_addr = summary_indicator_addr; |
| 192 | scssc->subchannel_indicator_addr = subchannel_indicator_addr; |
| 193 | |
| 194 | scssc->ks = PAGE_DEFAULT_KEY >> 4; |
| 195 | scssc->kc = PAGE_DEFAULT_KEY >> 4; |
| 196 | scssc->isc = QDIO_AIRQ_ISC; |
| 197 | scssc->schid = schid; |
| 198 | |
| 199 | /* enable the time delay disablement facility */ |
| 200 | if (css_general_characteristics.aif_tdd) |
| 201 | scssc->word_with_d_bit = 0x10000000; |
| 202 | |
| 203 | if (chsc(scssc)) |
| 204 | return -EIO; |
| 205 | |
| 206 | return chsc_error_from_response(scssc->response.code); |
| 207 | } |
| 208 | EXPORT_SYMBOL_GPL(chsc_sadc); |
| 209 | |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 210 | static int s390_subchannel_remove_chpid(struct subchannel *sch, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | { |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 212 | spin_lock_irq(sch->lock); |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 213 | if (sch->driver && sch->driver->chp_event) |
| 214 | if (sch->driver->chp_event(sch, data, CHP_OFFLINE) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | goto out_unreg; |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 216 | spin_unlock_irq(sch->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | return 0; |
Stefan Bader | 387b734 | 2007-04-27 16:01:33 +0200 | [diff] [blame] | 218 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | out_unreg: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | sch->lpm = 0; |
Stefan Bader | 387b734 | 2007-04-27 16:01:33 +0200 | [diff] [blame] | 221 | spin_unlock_irq(sch->lock); |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 222 | css_schedule_eval(sch->schid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | return 0; |
| 224 | } |
| 225 | |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 226 | void chsc_chp_offline(struct chp_id chpid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | { |
Sebastian Ott | 9f3d6d7 | 2016-01-25 10:32:51 +0100 | [diff] [blame] | 228 | struct channel_path *chp = chpid_to_chp(chpid); |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 229 | struct chp_link link; |
Sebastian Ott | 9f3d6d7 | 2016-01-25 10:32:51 +0100 | [diff] [blame] | 230 | char dbf_txt[15]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 232 | sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | CIO_TRACE_EVENT(2, dbf_txt); |
| 234 | |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 235 | if (chp_get_status(chpid) <= 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | return; |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 237 | memset(&link, 0, sizeof(struct chp_link)); |
| 238 | link.chpid = chpid; |
Cornelia Huck | 22806dc | 2008-04-17 07:45:59 +0200 | [diff] [blame] | 239 | /* Wait until previous actions have settled. */ |
| 240 | css_wait_for_slow_path(); |
Sebastian Ott | 9f3d6d7 | 2016-01-25 10:32:51 +0100 | [diff] [blame] | 241 | |
| 242 | mutex_lock(&chp->lock); |
| 243 | chp_update_desc(chp); |
| 244 | mutex_unlock(&chp->lock); |
| 245 | |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 246 | for_each_subchannel_staged(s390_subchannel_remove_chpid, NULL, &link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 249 | static int __s390_process_res_acc(struct subchannel *sch, void *data) |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 250 | { |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 251 | spin_lock_irq(sch->lock); |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 252 | if (sch->driver && sch->driver->chp_event) |
| 253 | sch->driver->chp_event(sch, data, CHP_ONLINE); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 254 | spin_unlock_irq(sch->lock); |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 255 | |
Peter Oberparleiter | dd9963f | 2006-09-20 15:59:54 +0200 | [diff] [blame] | 256 | return 0; |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 259 | static void s390_process_res_acc(struct chp_link *link) |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 260 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | char dbf_txt[15]; |
| 262 | |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 263 | sprintf(dbf_txt, "accpr%x.%02x", link->chpid.cssid, |
| 264 | link->chpid.id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | CIO_TRACE_EVENT( 2, dbf_txt); |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 266 | if (link->fla != 0) { |
| 267 | sprintf(dbf_txt, "fla%x", link->fla); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | CIO_TRACE_EVENT( 2, dbf_txt); |
| 269 | } |
Cornelia Huck | 22806dc | 2008-04-17 07:45:59 +0200 | [diff] [blame] | 270 | /* Wait until previous actions have settled. */ |
| 271 | css_wait_for_slow_path(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | /* |
| 273 | * I/O resources may have become accessible. |
| 274 | * Scan through all subchannels that may be concerned and |
| 275 | * do a validation on those. |
| 276 | * The more information we have (info), the less scanning |
| 277 | * will we have to do. |
| 278 | */ |
Peter Oberparleiter | 449666d | 2013-11-26 14:55:56 +0100 | [diff] [blame] | 279 | for_each_subchannel_staged(__s390_process_res_acc, NULL, link); |
| 280 | css_schedule_reprobe(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 283 | struct chsc_sei_nt0_area { |
| 284 | u8 flags; |
| 285 | u8 vf; /* validity flags */ |
| 286 | u8 rs; /* reporting source */ |
| 287 | u8 cc; /* content code */ |
| 288 | u16 fla; /* full link address */ |
| 289 | u16 rsid; /* reporting source id */ |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 290 | u32 reserved1; |
| 291 | u32 reserved2; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 292 | /* ccdf has to be big enough for a link-incident record */ |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 293 | u8 ccdf[PAGE_SIZE - 24 - 16]; /* content-code dependent field */ |
| 294 | } __packed; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 295 | |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 296 | struct chsc_sei_nt2_area { |
| 297 | u8 flags; /* p and v bit */ |
| 298 | u8 reserved1; |
| 299 | u8 reserved2; |
| 300 | u8 cc; /* content code */ |
| 301 | u32 reserved3[13]; |
| 302 | u8 ccdf[PAGE_SIZE - 24 - 56]; /* content-code dependent field */ |
| 303 | } __packed; |
| 304 | |
Sebastian Ott | 509d97b | 2013-01-15 19:02:01 +0100 | [diff] [blame] | 305 | #define CHSC_SEI_NT0 (1ULL << 63) |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 306 | #define CHSC_SEI_NT2 (1ULL << 61) |
| 307 | |
| 308 | struct chsc_sei { |
| 309 | struct chsc_header request; |
| 310 | u32 reserved1; |
| 311 | u64 ntsm; /* notification type mask */ |
| 312 | struct chsc_header response; |
Sebastian Ott | 509d97b | 2013-01-15 19:02:01 +0100 | [diff] [blame] | 313 | u32 :24; |
| 314 | u8 nt; |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 315 | union { |
| 316 | struct chsc_sei_nt0_area nt0_area; |
| 317 | struct chsc_sei_nt2_area nt2_area; |
| 318 | u8 nt_area[PAGE_SIZE - 24]; |
| 319 | } u; |
| 320 | } __packed; |
| 321 | |
Peter Oberparleiter | 1d2334c | 2015-07-15 14:04:18 +0200 | [diff] [blame] | 322 | /* |
| 323 | * Node Descriptor as defined in SA22-7204, "Common I/O-Device Commands" |
| 324 | */ |
| 325 | |
| 326 | #define ND_VALIDITY_VALID 0 |
| 327 | #define ND_VALIDITY_OUTDATED 1 |
| 328 | #define ND_VALIDITY_INVALID 2 |
| 329 | |
| 330 | struct node_descriptor { |
| 331 | /* Flags. */ |
| 332 | union { |
| 333 | struct { |
| 334 | u32 validity:3; |
| 335 | u32 reserved:5; |
| 336 | } __packed; |
| 337 | u8 byte0; |
| 338 | } __packed; |
| 339 | |
| 340 | /* Node parameters. */ |
| 341 | u32 params:24; |
| 342 | |
| 343 | /* Node ID. */ |
| 344 | char type[6]; |
| 345 | char model[3]; |
| 346 | char manufacturer[3]; |
| 347 | char plant[2]; |
| 348 | char seq[12]; |
| 349 | u16 tag; |
| 350 | } __packed; |
| 351 | |
| 352 | /* |
| 353 | * Link Incident Record as defined in SA22-7202, "ESCON I/O Interface" |
| 354 | */ |
| 355 | |
| 356 | #define LIR_IQ_CLASS_INFO 0 |
| 357 | #define LIR_IQ_CLASS_DEGRADED 1 |
| 358 | #define LIR_IQ_CLASS_NOT_OPERATIONAL 2 |
| 359 | |
| 360 | struct lir { |
| 361 | struct { |
| 362 | u32 null:1; |
| 363 | u32 reserved:3; |
| 364 | u32 class:2; |
| 365 | u32 reserved2:2; |
| 366 | } __packed iq; |
| 367 | u32 ic:8; |
| 368 | u32 reserved:16; |
| 369 | struct node_descriptor incident_node; |
| 370 | struct node_descriptor attached_node; |
| 371 | u8 reserved2[32]; |
| 372 | } __packed; |
| 373 | |
| 374 | #define PARAMS_LEN 10 /* PARAMS=xx,xxxxxx */ |
| 375 | #define NODEID_LEN 35 /* NODEID=tttttt/mdl,mmm.ppssssssssssss,xxxx */ |
| 376 | |
| 377 | /* Copy EBCIDC text, convert to ASCII and optionally add delimiter. */ |
| 378 | static char *store_ebcdic(char *dest, const char *src, unsigned long len, |
| 379 | char delim) |
| 380 | { |
| 381 | memcpy(dest, src, len); |
| 382 | EBCASC(dest, len); |
| 383 | |
| 384 | if (delim) |
| 385 | dest[len++] = delim; |
| 386 | |
| 387 | return dest + len; |
| 388 | } |
| 389 | |
| 390 | /* Format node ID and parameters for output in LIR log message. */ |
| 391 | static void format_node_data(char *params, char *id, struct node_descriptor *nd) |
| 392 | { |
| 393 | memset(params, 0, PARAMS_LEN); |
| 394 | memset(id, 0, NODEID_LEN); |
| 395 | |
| 396 | if (nd->validity != ND_VALIDITY_VALID) { |
| 397 | strncpy(params, "n/a", PARAMS_LEN - 1); |
| 398 | strncpy(id, "n/a", NODEID_LEN - 1); |
| 399 | return; |
| 400 | } |
| 401 | |
| 402 | /* PARAMS=xx,xxxxxx */ |
| 403 | snprintf(params, PARAMS_LEN, "%02x,%06x", nd->byte0, nd->params); |
| 404 | /* NODEID=tttttt/mdl,mmm.ppssssssssssss,xxxx */ |
| 405 | id = store_ebcdic(id, nd->type, sizeof(nd->type), '/'); |
| 406 | id = store_ebcdic(id, nd->model, sizeof(nd->model), ','); |
| 407 | id = store_ebcdic(id, nd->manufacturer, sizeof(nd->manufacturer), '.'); |
| 408 | id = store_ebcdic(id, nd->plant, sizeof(nd->plant), 0); |
| 409 | id = store_ebcdic(id, nd->seq, sizeof(nd->seq), ','); |
| 410 | sprintf(id, "%04X", nd->tag); |
| 411 | } |
| 412 | |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 413 | static void chsc_process_sei_link_incident(struct chsc_sei_nt0_area *sei_area) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | { |
Peter Oberparleiter | 1d2334c | 2015-07-15 14:04:18 +0200 | [diff] [blame] | 415 | struct lir *lir = (struct lir *) &sei_area->ccdf; |
| 416 | char iuparams[PARAMS_LEN], iunodeid[NODEID_LEN], auparams[PARAMS_LEN], |
| 417 | aunodeid[NODEID_LEN]; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 418 | |
Peter Oberparleiter | 1d2334c | 2015-07-15 14:04:18 +0200 | [diff] [blame] | 419 | CIO_CRW_EVENT(4, "chsc: link incident (rs=%02x, rs_id=%04x, iq=%02x)\n", |
| 420 | sei_area->rs, sei_area->rsid, sei_area->ccdf[0]); |
| 421 | |
| 422 | /* Ignore NULL Link Incident Records. */ |
| 423 | if (lir->iq.null) |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 424 | return; |
Peter Oberparleiter | 1d2334c | 2015-07-15 14:04:18 +0200 | [diff] [blame] | 425 | |
| 426 | /* Inform user that a link requires maintenance actions because it has |
| 427 | * become degraded or not operational. Note that this log message is |
| 428 | * the primary intention behind a Link Incident Record. */ |
| 429 | |
| 430 | format_node_data(iuparams, iunodeid, &lir->incident_node); |
| 431 | format_node_data(auparams, aunodeid, &lir->attached_node); |
| 432 | |
| 433 | switch (lir->iq.class) { |
| 434 | case LIR_IQ_CLASS_DEGRADED: |
| 435 | pr_warn("Link degraded: RS=%02x RSID=%04x IC=%02x " |
| 436 | "IUPARAMS=%s IUNODEID=%s AUPARAMS=%s AUNODEID=%s\n", |
| 437 | sei_area->rs, sei_area->rsid, lir->ic, iuparams, |
| 438 | iunodeid, auparams, aunodeid); |
| 439 | break; |
| 440 | case LIR_IQ_CLASS_NOT_OPERATIONAL: |
| 441 | pr_err("Link stopped: RS=%02x RSID=%04x IC=%02x " |
| 442 | "IUPARAMS=%s IUNODEID=%s AUPARAMS=%s AUNODEID=%s\n", |
| 443 | sei_area->rs, sei_area->rsid, lir->ic, iuparams, |
| 444 | iunodeid, auparams, aunodeid); |
| 445 | break; |
| 446 | default: |
| 447 | break; |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 448 | } |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 449 | } |
| 450 | |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 451 | static void chsc_process_sei_res_acc(struct chsc_sei_nt0_area *sei_area) |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 452 | { |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 453 | struct chp_link link; |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 454 | struct chp_id chpid; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 455 | int status; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 456 | |
| 457 | CIO_CRW_EVENT(4, "chsc: resource accessibility event (rs=%02x, " |
| 458 | "rs_id=%04x)\n", sei_area->rs, sei_area->rsid); |
| 459 | if (sei_area->rs != 4) |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 460 | return; |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 461 | chp_id_init(&chpid); |
| 462 | chpid.id = sei_area->rsid; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 463 | /* allocate a new channel path structure, if needed */ |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 464 | status = chp_get_status(chpid); |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 465 | if (status < 0) |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 466 | chp_new(chpid); |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 467 | else if (!status) |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 468 | return; |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 469 | memset(&link, 0, sizeof(struct chp_link)); |
| 470 | link.chpid = chpid; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 471 | if ((sei_area->vf & 0xc0) != 0) { |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 472 | link.fla = sei_area->fla; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 473 | if ((sei_area->vf & 0xc0) == 0xc0) |
| 474 | /* full link address */ |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 475 | link.fla_mask = 0xffff; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 476 | else |
| 477 | /* link address */ |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 478 | link.fla_mask = 0xff00; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 479 | } |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 480 | s390_process_res_acc(&link); |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 481 | } |
| 482 | |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 483 | static void chsc_process_sei_chp_avail(struct chsc_sei_nt0_area *sei_area) |
Sebastian Ott | fca894ed | 2011-05-23 10:24:41 +0200 | [diff] [blame] | 484 | { |
| 485 | struct channel_path *chp; |
| 486 | struct chp_id chpid; |
| 487 | u8 *data; |
| 488 | int num; |
| 489 | |
| 490 | CIO_CRW_EVENT(4, "chsc: channel path availability information\n"); |
| 491 | if (sei_area->rs != 0) |
| 492 | return; |
| 493 | data = sei_area->ccdf; |
| 494 | chp_id_init(&chpid); |
| 495 | for (num = 0; num <= __MAX_CHPID; num++) { |
| 496 | if (!chp_test_bit(data, num)) |
| 497 | continue; |
| 498 | chpid.id = num; |
| 499 | |
| 500 | CIO_CRW_EVENT(4, "Update information for channel path " |
| 501 | "%x.%02x\n", chpid.cssid, chpid.id); |
| 502 | chp = chpid_to_chp(chpid); |
| 503 | if (!chp) { |
| 504 | chp_new(chpid); |
| 505 | continue; |
| 506 | } |
| 507 | mutex_lock(&chp->lock); |
Peter Oberparleiter | cce0eac | 2013-03-11 12:58:18 +0100 | [diff] [blame] | 508 | chp_update_desc(chp); |
Sebastian Ott | fca894ed | 2011-05-23 10:24:41 +0200 | [diff] [blame] | 509 | mutex_unlock(&chp->lock); |
| 510 | } |
| 511 | } |
| 512 | |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 513 | struct chp_config_data { |
| 514 | u8 map[32]; |
| 515 | u8 op; |
| 516 | u8 pc; |
| 517 | }; |
| 518 | |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 519 | static void chsc_process_sei_chp_config(struct chsc_sei_nt0_area *sei_area) |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 520 | { |
| 521 | struct chp_config_data *data; |
| 522 | struct chp_id chpid; |
| 523 | int num; |
Michael Ernst | e6d5a42 | 2008-12-25 13:39:36 +0100 | [diff] [blame] | 524 | char *events[3] = {"configure", "deconfigure", "cancel deconfigure"}; |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 525 | |
| 526 | CIO_CRW_EVENT(4, "chsc: channel-path-configuration notification\n"); |
| 527 | if (sei_area->rs != 0) |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 528 | return; |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 529 | data = (struct chp_config_data *) &(sei_area->ccdf); |
| 530 | chp_id_init(&chpid); |
| 531 | for (num = 0; num <= __MAX_CHPID; num++) { |
| 532 | if (!chp_test_bit(data->map, num)) |
| 533 | continue; |
| 534 | chpid.id = num; |
Michael Ernst | e6d5a42 | 2008-12-25 13:39:36 +0100 | [diff] [blame] | 535 | pr_notice("Processing %s for channel path %x.%02x\n", |
| 536 | events[data->op], chpid.cssid, chpid.id); |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 537 | switch (data->op) { |
| 538 | case 0: |
| 539 | chp_cfg_schedule(chpid, 1); |
| 540 | break; |
| 541 | case 1: |
| 542 | chp_cfg_schedule(chpid, 0); |
| 543 | break; |
| 544 | case 2: |
| 545 | chp_cfg_cancel_deconfigure(chpid); |
| 546 | break; |
| 547 | } |
| 548 | } |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 549 | } |
| 550 | |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 551 | static void chsc_process_sei_scm_change(struct chsc_sei_nt0_area *sei_area) |
Sebastian Ott | 40ff4cc | 2012-08-28 16:47:02 +0200 | [diff] [blame] | 552 | { |
| 553 | int ret; |
| 554 | |
| 555 | CIO_CRW_EVENT(4, "chsc: scm change notification\n"); |
| 556 | if (sei_area->rs != 7) |
| 557 | return; |
| 558 | |
| 559 | ret = scm_update_information(); |
| 560 | if (ret) |
| 561 | CIO_CRW_EVENT(0, "chsc: updating change notification" |
| 562 | " failed (rc=%d).\n", ret); |
| 563 | } |
| 564 | |
Sebastian Ott | aebfa66 | 2013-02-28 12:07:55 +0100 | [diff] [blame] | 565 | static void chsc_process_sei_scm_avail(struct chsc_sei_nt0_area *sei_area) |
| 566 | { |
| 567 | int ret; |
| 568 | |
| 569 | CIO_CRW_EVENT(4, "chsc: scm available information\n"); |
| 570 | if (sei_area->rs != 7) |
| 571 | return; |
| 572 | |
| 573 | ret = scm_process_availability_information(); |
| 574 | if (ret) |
| 575 | CIO_CRW_EVENT(0, "chsc: process availability information" |
| 576 | " failed (rc=%d).\n", ret); |
| 577 | } |
| 578 | |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 579 | static void chsc_process_sei_nt2(struct chsc_sei_nt2_area *sei_area) |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 580 | { |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 581 | switch (sei_area->cc) { |
| 582 | case 1: |
| 583 | zpci_event_error(sei_area->ccdf); |
| 584 | break; |
| 585 | case 2: |
| 586 | zpci_event_availability(sei_area->ccdf); |
| 587 | break; |
| 588 | default: |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 589 | CIO_CRW_EVENT(2, "chsc: sei nt2 unhandled cc=%d\n", |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 590 | sei_area->cc); |
| 591 | break; |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 592 | } |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | static void chsc_process_sei_nt0(struct chsc_sei_nt0_area *sei_area) |
| 596 | { |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 597 | /* which kind of information was stored? */ |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 598 | switch (sei_area->cc) { |
| 599 | case 1: /* link incident*/ |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 600 | chsc_process_sei_link_incident(sei_area); |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 601 | break; |
Sebastian Ott | fca894ed | 2011-05-23 10:24:41 +0200 | [diff] [blame] | 602 | case 2: /* i/o resource accessibility */ |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 603 | chsc_process_sei_res_acc(sei_area); |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 604 | break; |
Sebastian Ott | fca894ed | 2011-05-23 10:24:41 +0200 | [diff] [blame] | 605 | case 7: /* channel-path-availability information */ |
| 606 | chsc_process_sei_chp_avail(sei_area); |
| 607 | break; |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 608 | case 8: /* channel-path-configuration notification */ |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 609 | chsc_process_sei_chp_config(sei_area); |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 610 | break; |
Sebastian Ott | 40ff4cc | 2012-08-28 16:47:02 +0200 | [diff] [blame] | 611 | case 12: /* scm change notification */ |
| 612 | chsc_process_sei_scm_change(sei_area); |
| 613 | break; |
Sebastian Ott | aebfa66 | 2013-02-28 12:07:55 +0100 | [diff] [blame] | 614 | case 14: /* scm available notification */ |
| 615 | chsc_process_sei_scm_avail(sei_area); |
| 616 | break; |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 617 | default: /* other stuff */ |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 618 | CIO_CRW_EVENT(2, "chsc: sei nt0 unhandled cc=%d\n", |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 619 | sei_area->cc); |
| 620 | break; |
| 621 | } |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 622 | |
| 623 | /* Check if we might have lost some information. */ |
| 624 | if (sei_area->flags & 0x40) { |
| 625 | CIO_CRW_EVENT(2, "chsc: event overflow\n"); |
| 626 | css_schedule_eval_all(); |
| 627 | } |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 628 | } |
| 629 | |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 630 | static void chsc_process_event_information(struct chsc_sei *sei, u64 ntsm) |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 631 | { |
Sebastian Ott | 06cd7a8 | 2014-04-15 20:08:01 +0200 | [diff] [blame] | 632 | static int ntsm_unsupported; |
| 633 | |
| 634 | while (true) { |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 635 | memset(sei, 0, sizeof(*sei)); |
| 636 | sei->request.length = 0x0010; |
| 637 | sei->request.code = 0x000e; |
Sebastian Ott | 06cd7a8 | 2014-04-15 20:08:01 +0200 | [diff] [blame] | 638 | if (!ntsm_unsupported) |
| 639 | sei->ntsm = ntsm; |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 640 | |
| 641 | if (chsc(sei)) |
| 642 | break; |
| 643 | |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 644 | if (sei->response.code != 0x0001) { |
Sebastian Ott | 06cd7a8 | 2014-04-15 20:08:01 +0200 | [diff] [blame] | 645 | CIO_CRW_EVENT(2, "chsc: sei failed (rc=%04x, ntsm=%llx)\n", |
| 646 | sei->response.code, sei->ntsm); |
| 647 | |
| 648 | if (sei->response.code == 3 && sei->ntsm) { |
| 649 | /* Fallback for old firmware. */ |
| 650 | ntsm_unsupported = 1; |
| 651 | continue; |
| 652 | } |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 653 | break; |
| 654 | } |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 655 | |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 656 | CIO_CRW_EVENT(2, "chsc: sei successful (nt=%d)\n", sei->nt); |
| 657 | switch (sei->nt) { |
| 658 | case 0: |
| 659 | chsc_process_sei_nt0(&sei->u.nt0_area); |
| 660 | break; |
| 661 | case 2: |
| 662 | chsc_process_sei_nt2(&sei->u.nt2_area); |
| 663 | break; |
| 664 | default: |
| 665 | CIO_CRW_EVENT(2, "chsc: unhandled nt: %d\n", sei->nt); |
| 666 | break; |
| 667 | } |
Sebastian Ott | 06cd7a8 | 2014-04-15 20:08:01 +0200 | [diff] [blame] | 668 | |
| 669 | if (!(sei->u.nt0_area.flags & 0x80)) |
| 670 | break; |
| 671 | } |
Jan Glauber | cbc0dd1 | 2012-11-29 14:34:48 +0100 | [diff] [blame] | 672 | } |
| 673 | |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 674 | /* |
| 675 | * Handle channel subsystem related CRWs. |
| 676 | * Use store event information to find out what's going on. |
| 677 | * |
| 678 | * Note: Access to sei_page is serialized through machine check handler |
| 679 | * thread, so no need for locking. |
| 680 | */ |
Cornelia Huck | c115618 | 2008-07-14 09:58:46 +0200 | [diff] [blame] | 681 | static void chsc_process_crw(struct crw *crw0, struct crw *crw1, int overflow) |
Peter Oberparleiter | 184357a | 2007-02-05 21:17:42 +0100 | [diff] [blame] | 682 | { |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 683 | struct chsc_sei *sei = sei_page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | |
Cornelia Huck | c115618 | 2008-07-14 09:58:46 +0200 | [diff] [blame] | 685 | if (overflow) { |
| 686 | css_schedule_eval_all(); |
| 687 | return; |
| 688 | } |
| 689 | CIO_CRW_EVENT(2, "CRW reports slct=%d, oflw=%d, " |
| 690 | "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n", |
| 691 | crw0->slct, crw0->oflw, crw0->chn, crw0->rsc, crw0->anc, |
| 692 | crw0->erc, crw0->rsid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | |
Cornelia Huck | c115618 | 2008-07-14 09:58:46 +0200 | [diff] [blame] | 694 | CIO_TRACE_EVENT(2, "prcss"); |
Sebastian Ott | 9a17e97 | 2013-01-15 19:04:39 +0100 | [diff] [blame] | 695 | chsc_process_event_information(sei, CHSC_SEI_NT0 | CHSC_SEI_NT2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | } |
| 697 | |
Peter Oberparleiter | 83b3370 | 2007-04-27 16:01:34 +0200 | [diff] [blame] | 698 | void chsc_chp_online(struct chp_id chpid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | { |
Sebastian Ott | 9f3d6d7 | 2016-01-25 10:32:51 +0100 | [diff] [blame] | 700 | struct channel_path *chp = chpid_to_chp(chpid); |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 701 | struct chp_link link; |
Sebastian Ott | 9f3d6d7 | 2016-01-25 10:32:51 +0100 | [diff] [blame] | 702 | char dbf_txt[15]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 704 | sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | CIO_TRACE_EVENT(2, dbf_txt); |
| 706 | |
Cornelia Huck | 22806dc | 2008-04-17 07:45:59 +0200 | [diff] [blame] | 707 | if (chp_get_status(chpid) != 0) { |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 708 | memset(&link, 0, sizeof(struct chp_link)); |
| 709 | link.chpid = chpid; |
Cornelia Huck | 22806dc | 2008-04-17 07:45:59 +0200 | [diff] [blame] | 710 | /* Wait until previous actions have settled. */ |
| 711 | css_wait_for_slow_path(); |
Sebastian Ott | 9f3d6d7 | 2016-01-25 10:32:51 +0100 | [diff] [blame] | 712 | |
| 713 | mutex_lock(&chp->lock); |
| 714 | chp_update_desc(chp); |
| 715 | mutex_unlock(&chp->lock); |
| 716 | |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 717 | for_each_subchannel_staged(__s390_process_res_acc, NULL, |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 718 | &link); |
Peter Oberparleiter | 9955e8d1 | 2014-02-19 17:43:04 +0100 | [diff] [blame] | 719 | css_schedule_reprobe(); |
Cornelia Huck | 22806dc | 2008-04-17 07:45:59 +0200 | [diff] [blame] | 720 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | } |
| 722 | |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 723 | static void __s390_subchannel_vary_chpid(struct subchannel *sch, |
| 724 | struct chp_id chpid, int on) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | unsigned long flags; |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 727 | struct chp_link link; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 729 | memset(&link, 0, sizeof(struct chp_link)); |
| 730 | link.chpid = chpid; |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 731 | spin_lock_irqsave(sch->lock, flags); |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 732 | if (sch->driver && sch->driver->chp_event) |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 733 | sch->driver->chp_event(sch, &link, |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 734 | on ? CHP_VARY_ON : CHP_VARY_OFF); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 735 | spin_unlock_irqrestore(sch->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | } |
| 737 | |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 738 | static int s390_subchannel_vary_chpid_off(struct subchannel *sch, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | { |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 740 | struct chp_id *chpid = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | |
| 742 | __s390_subchannel_vary_chpid(sch, *chpid, 0); |
| 743 | return 0; |
| 744 | } |
| 745 | |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 746 | static int s390_subchannel_vary_chpid_on(struct subchannel *sch, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | { |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 748 | struct chp_id *chpid = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | |
| 750 | __s390_subchannel_vary_chpid(sch, *chpid, 1); |
| 751 | return 0; |
| 752 | } |
| 753 | |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 754 | /** |
| 755 | * chsc_chp_vary - propagate channel-path vary operation to subchannels |
| 756 | * @chpid: channl-path ID |
| 757 | * @on: non-zero for vary online, zero for vary offline |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | */ |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 759 | int chsc_chp_vary(struct chp_id chpid, int on) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | { |
Sebastian Ott | c38a90a | 2010-10-25 16:10:31 +0200 | [diff] [blame] | 761 | struct channel_path *chp = chpid_to_chp(chpid); |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 762 | |
Cornelia Huck | 22806dc | 2008-04-17 07:45:59 +0200 | [diff] [blame] | 763 | /* Wait until previous actions have settled. */ |
| 764 | css_wait_for_slow_path(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | /* |
| 766 | * Redo PathVerification on the devices the chpid connects to |
| 767 | */ |
Sebastian Ott | c38a90a | 2010-10-25 16:10:31 +0200 | [diff] [blame] | 768 | if (on) { |
Peter Oberparleiter | cce0eac | 2013-03-11 12:58:18 +0100 | [diff] [blame] | 769 | /* Try to update the channel path description. */ |
| 770 | chp_update_desc(chp); |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 771 | for_each_subchannel_staged(s390_subchannel_vary_chpid_on, |
Peter Oberparleiter | 449666d | 2013-11-26 14:55:56 +0100 | [diff] [blame] | 772 | NULL, &chpid); |
| 773 | css_schedule_reprobe(); |
Sebastian Ott | c38a90a | 2010-10-25 16:10:31 +0200 | [diff] [blame] | 774 | } else |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 775 | for_each_subchannel_staged(s390_subchannel_vary_chpid_off, |
Sebastian Ott | 3b484ec | 2011-12-01 13:32:22 +0100 | [diff] [blame] | 776 | NULL, &chpid); |
Peter Oberparleiter | e82a156 | 2008-01-26 14:10:48 +0100 | [diff] [blame] | 777 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | return 0; |
| 779 | } |
| 780 | |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 781 | static void |
| 782 | chsc_remove_cmg_attr(struct channel_subsystem *css) |
| 783 | { |
| 784 | int i; |
| 785 | |
| 786 | for (i = 0; i <= __MAX_CHPID; i++) { |
| 787 | if (!css->chps[i]) |
| 788 | continue; |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 789 | chp_remove_cmg_attr(css->chps[i]); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 790 | } |
| 791 | } |
| 792 | |
| 793 | static int |
| 794 | chsc_add_cmg_attr(struct channel_subsystem *css) |
| 795 | { |
| 796 | int i, ret; |
| 797 | |
| 798 | ret = 0; |
| 799 | for (i = 0; i <= __MAX_CHPID; i++) { |
| 800 | if (!css->chps[i]) |
| 801 | continue; |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 802 | ret = chp_add_cmg_attr(css->chps[i]); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 803 | if (ret) |
| 804 | goto cleanup; |
| 805 | } |
| 806 | return ret; |
| 807 | cleanup: |
| 808 | for (--i; i >= 0; i--) { |
| 809 | if (!css->chps[i]) |
| 810 | continue; |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 811 | chp_remove_cmg_attr(css->chps[i]); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 812 | } |
| 813 | return ret; |
| 814 | } |
| 815 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 816 | int __chsc_do_secm(struct channel_subsystem *css, int enable) |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 817 | { |
| 818 | struct { |
| 819 | struct chsc_header request; |
| 820 | u32 operation_code : 2; |
| 821 | u32 : 30; |
| 822 | u32 key : 4; |
| 823 | u32 : 28; |
| 824 | u32 zeroes1; |
| 825 | u32 cub_addr1; |
| 826 | u32 zeroes2; |
| 827 | u32 cub_addr2; |
| 828 | u32 reserved[13]; |
| 829 | struct chsc_header response; |
| 830 | u32 status : 8; |
| 831 | u32 : 4; |
| 832 | u32 fmt : 4; |
| 833 | u32 : 16; |
Peter Oberparleiter | 0f008aa | 2007-02-05 21:17:40 +0100 | [diff] [blame] | 834 | } __attribute__ ((packed)) *secm_area; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 835 | int ret, ccode; |
| 836 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 837 | spin_lock_irq(&chsc_page_lock); |
| 838 | memset(chsc_page, 0, PAGE_SIZE); |
| 839 | secm_area = chsc_page; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 840 | secm_area->request.length = 0x0050; |
| 841 | secm_area->request.code = 0x0016; |
| 842 | |
Heiko Carstens | d1bf859 | 2010-02-26 22:37:30 +0100 | [diff] [blame] | 843 | secm_area->key = PAGE_DEFAULT_KEY >> 4; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 844 | secm_area->cub_addr1 = (u64)(unsigned long)css->cub_addr1; |
| 845 | secm_area->cub_addr2 = (u64)(unsigned long)css->cub_addr2; |
| 846 | |
| 847 | secm_area->operation_code = enable ? 0 : 1; |
| 848 | |
| 849 | ccode = chsc(secm_area); |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 850 | if (ccode > 0) { |
| 851 | ret = (ccode == 3) ? -ENODEV : -EBUSY; |
| 852 | goto out; |
| 853 | } |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 854 | |
| 855 | switch (secm_area->response.code) { |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 856 | case 0x0102: |
| 857 | case 0x0103: |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 858 | ret = -EINVAL; |
Sebastian Ott | 17e7d87 | 2009-03-26 15:24:17 +0100 | [diff] [blame] | 859 | break; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 860 | default: |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 861 | ret = chsc_error_from_response(secm_area->response.code); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 862 | } |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 863 | if (ret != 0) |
| 864 | CIO_CRW_EVENT(2, "chsc: secm failed (rc=%04x)\n", |
| 865 | secm_area->response.code); |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 866 | out: |
| 867 | spin_unlock_irq(&chsc_page_lock); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 868 | return ret; |
| 869 | } |
| 870 | |
| 871 | int |
| 872 | chsc_secm(struct channel_subsystem *css, int enable) |
| 873 | { |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 874 | int ret; |
| 875 | |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 876 | if (enable && !css->cm_enabled) { |
| 877 | css->cub_addr1 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); |
| 878 | css->cub_addr2 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); |
| 879 | if (!css->cub_addr1 || !css->cub_addr2) { |
| 880 | free_page((unsigned long)css->cub_addr1); |
| 881 | free_page((unsigned long)css->cub_addr2); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 882 | return -ENOMEM; |
| 883 | } |
| 884 | } |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 885 | ret = __chsc_do_secm(css, enable); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 886 | if (!ret) { |
| 887 | css->cm_enabled = enable; |
| 888 | if (css->cm_enabled) { |
| 889 | ret = chsc_add_cmg_attr(css); |
| 890 | if (ret) { |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 891 | __chsc_do_secm(css, 0); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 892 | css->cm_enabled = 0; |
| 893 | } |
| 894 | } else |
| 895 | chsc_remove_cmg_attr(css); |
| 896 | } |
Cornelia Huck | 8c4941c | 2007-04-27 16:01:38 +0200 | [diff] [blame] | 897 | if (!css->cm_enabled) { |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 898 | free_page((unsigned long)css->cub_addr1); |
| 899 | free_page((unsigned long)css->cub_addr2); |
| 900 | } |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 901 | return ret; |
| 902 | } |
| 903 | |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 904 | int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt, |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 905 | int c, int m, void *page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | { |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 907 | struct chsc_scpd *scpd_area; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | int ccode, ret; |
| 909 | |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 910 | if ((rfmt == 1) && !css_general_characteristics.fcs) |
| 911 | return -EINVAL; |
| 912 | if ((rfmt == 2) && !css_general_characteristics.cib) |
| 913 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 915 | memset(page, 0, PAGE_SIZE); |
| 916 | scpd_area = page; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 917 | scpd_area->request.length = 0x0010; |
| 918 | scpd_area->request.code = 0x0002; |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 919 | scpd_area->cssid = chpid.cssid; |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 920 | scpd_area->first_chpid = chpid.id; |
| 921 | scpd_area->last_chpid = chpid.id; |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 922 | scpd_area->m = m; |
| 923 | scpd_area->c = c; |
| 924 | scpd_area->fmt = fmt; |
| 925 | scpd_area->rfmt = rfmt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | |
| 927 | ccode = chsc(scpd_area); |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 928 | if (ccode > 0) |
| 929 | return (ccode == 3) ? -ENODEV : -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 931 | ret = chsc_error_from_response(scpd_area->response.code); |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 932 | if (ret) |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 933 | CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | scpd_area->response.code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | return ret; |
| 936 | } |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 937 | EXPORT_SYMBOL_GPL(chsc_determine_channel_path_desc); |
| 938 | |
| 939 | int chsc_determine_base_channel_path_desc(struct chp_id chpid, |
| 940 | struct channel_path_desc *desc) |
| 941 | { |
| 942 | struct chsc_response_struct *chsc_resp; |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 943 | struct chsc_scpd *scpd_area; |
Sebastian Ott | 62da177 | 2010-10-25 16:10:32 +0200 | [diff] [blame] | 944 | unsigned long flags; |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 945 | int ret; |
| 946 | |
Sebastian Ott | 62da177 | 2010-10-25 16:10:32 +0200 | [diff] [blame] | 947 | spin_lock_irqsave(&chsc_page_lock, flags); |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 948 | scpd_area = chsc_page; |
| 949 | ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, scpd_area); |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 950 | if (ret) |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 951 | goto out; |
| 952 | chsc_resp = (void *)&scpd_area->response; |
Sebastian Ott | 878c495 | 2010-07-19 09:22:37 +0200 | [diff] [blame] | 953 | memcpy(desc, &chsc_resp->data, sizeof(*desc)); |
Sebastian Ott | 906c976 | 2010-10-25 16:10:30 +0200 | [diff] [blame] | 954 | out: |
Sebastian Ott | 62da177 | 2010-10-25 16:10:32 +0200 | [diff] [blame] | 955 | spin_unlock_irqrestore(&chsc_page_lock, flags); |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 956 | return ret; |
| 957 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | |
Sebastian Ott | ce322cc | 2011-01-05 12:47:56 +0100 | [diff] [blame] | 959 | int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid, |
| 960 | struct channel_path_desc_fmt1 *desc) |
| 961 | { |
| 962 | struct chsc_response_struct *chsc_resp; |
| 963 | struct chsc_scpd *scpd_area; |
Peter Oberparleiter | cce0eac | 2013-03-11 12:58:18 +0100 | [diff] [blame] | 964 | unsigned long flags; |
Sebastian Ott | ce322cc | 2011-01-05 12:47:56 +0100 | [diff] [blame] | 965 | int ret; |
| 966 | |
Peter Oberparleiter | cce0eac | 2013-03-11 12:58:18 +0100 | [diff] [blame] | 967 | spin_lock_irqsave(&chsc_page_lock, flags); |
Sebastian Ott | ce322cc | 2011-01-05 12:47:56 +0100 | [diff] [blame] | 968 | scpd_area = chsc_page; |
| 969 | ret = chsc_determine_channel_path_desc(chpid, 0, 0, 1, 0, scpd_area); |
| 970 | if (ret) |
| 971 | goto out; |
| 972 | chsc_resp = (void *)&scpd_area->response; |
| 973 | memcpy(desc, &chsc_resp->data, sizeof(*desc)); |
| 974 | out: |
Peter Oberparleiter | cce0eac | 2013-03-11 12:58:18 +0100 | [diff] [blame] | 975 | spin_unlock_irqrestore(&chsc_page_lock, flags); |
Sebastian Ott | ce322cc | 2011-01-05 12:47:56 +0100 | [diff] [blame] | 976 | return ret; |
| 977 | } |
| 978 | |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 979 | static void |
| 980 | chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv, |
| 981 | struct cmg_chars *chars) |
| 982 | { |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 983 | int i, mask; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 984 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 985 | for (i = 0; i < NR_MEASUREMENT_CHARS; i++) { |
| 986 | mask = 0x80 >> (i + 3); |
| 987 | if (cmcv & mask) |
Sebastian Ott | 0d9bfe9 | 2016-01-25 10:30:27 +0100 | [diff] [blame] | 988 | chp->cmg_chars.values[i] = chars->values[i]; |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 989 | else |
Sebastian Ott | 0d9bfe9 | 2016-01-25 10:30:27 +0100 | [diff] [blame] | 990 | chp->cmg_chars.values[i] = 0; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 991 | } |
| 992 | } |
| 993 | |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 994 | int chsc_get_channel_measurement_chars(struct channel_path *chp) |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 995 | { |
| 996 | int ccode, ret; |
| 997 | |
| 998 | struct { |
| 999 | struct chsc_header request; |
| 1000 | u32 : 24; |
| 1001 | u32 first_chpid : 8; |
| 1002 | u32 : 24; |
| 1003 | u32 last_chpid : 8; |
| 1004 | u32 zeroes1; |
| 1005 | struct chsc_header response; |
| 1006 | u32 zeroes2; |
| 1007 | u32 not_valid : 1; |
| 1008 | u32 shared : 1; |
| 1009 | u32 : 22; |
| 1010 | u32 chpid : 8; |
| 1011 | u32 cmcv : 5; |
| 1012 | u32 : 11; |
| 1013 | u32 cmgq : 8; |
| 1014 | u32 cmg : 8; |
| 1015 | u32 zeroes3; |
| 1016 | u32 data[NR_MEASUREMENT_CHARS]; |
Peter Oberparleiter | 0f008aa | 2007-02-05 21:17:40 +0100 | [diff] [blame] | 1017 | } __attribute__ ((packed)) *scmc_area; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 1018 | |
Sebastian Ott | 61f0bfc | 2016-01-25 10:31:33 +0100 | [diff] [blame] | 1019 | chp->shared = -1; |
| 1020 | chp->cmg = -1; |
| 1021 | |
| 1022 | if (!css_chsc_characteristics.scmc || !css_chsc_characteristics.secm) |
| 1023 | return 0; |
| 1024 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1025 | spin_lock_irq(&chsc_page_lock); |
| 1026 | memset(chsc_page, 0, PAGE_SIZE); |
| 1027 | scmc_area = chsc_page; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 1028 | scmc_area->request.length = 0x0010; |
| 1029 | scmc_area->request.code = 0x0022; |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 1030 | scmc_area->first_chpid = chp->chpid.id; |
| 1031 | scmc_area->last_chpid = chp->chpid.id; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 1032 | |
| 1033 | ccode = chsc(scmc_area); |
| 1034 | if (ccode > 0) { |
| 1035 | ret = (ccode == 3) ? -ENODEV : -EBUSY; |
| 1036 | goto out; |
| 1037 | } |
| 1038 | |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 1039 | ret = chsc_error_from_response(scmc_area->response.code); |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1040 | if (ret) { |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 1041 | CIO_CRW_EVENT(2, "chsc: scmc failed (rc=%04x)\n", |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 1042 | scmc_area->response.code); |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1043 | goto out; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 1044 | } |
Sebastian Ott | 61f0bfc | 2016-01-25 10:31:33 +0100 | [diff] [blame] | 1045 | if (scmc_area->not_valid) |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1046 | goto out; |
Sebastian Ott | 61f0bfc | 2016-01-25 10:31:33 +0100 | [diff] [blame] | 1047 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1048 | chp->cmg = scmc_area->cmg; |
| 1049 | chp->shared = scmc_area->shared; |
| 1050 | if (chp->cmg != 2 && chp->cmg != 3) { |
| 1051 | /* No cmg-dependent data. */ |
| 1052 | goto out; |
| 1053 | } |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1054 | chsc_initialize_cmg_chars(chp, scmc_area->cmcv, |
| 1055 | (struct cmg_chars *) &scmc_area->data); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 1056 | out: |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1057 | spin_unlock_irq(&chsc_page_lock); |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 1058 | return ret; |
| 1059 | } |
| 1060 | |
Sebastian Ott | 34aec07 | 2010-10-25 16:10:28 +0200 | [diff] [blame] | 1061 | int __init chsc_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | { |
Cornelia Huck | c115618 | 2008-07-14 09:58:46 +0200 | [diff] [blame] | 1063 | int ret; |
| 1064 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | sei_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1066 | chsc_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); |
| 1067 | if (!sei_page || !chsc_page) { |
| 1068 | ret = -ENOMEM; |
| 1069 | goto out_err; |
Cornelia Huck | c115618 | 2008-07-14 09:58:46 +0200 | [diff] [blame] | 1070 | } |
Heiko Carstens | f5daba1 | 2009-03-26 15:24:01 +0100 | [diff] [blame] | 1071 | ret = crw_register_handler(CRW_RSC_CSS, chsc_process_crw); |
Cornelia Huck | c115618 | 2008-07-14 09:58:46 +0200 | [diff] [blame] | 1072 | if (ret) |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1073 | goto out_err; |
| 1074 | return ret; |
| 1075 | out_err: |
| 1076 | free_page((unsigned long)chsc_page); |
| 1077 | free_page((unsigned long)sei_page); |
Cornelia Huck | c115618 | 2008-07-14 09:58:46 +0200 | [diff] [blame] | 1078 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | } |
| 1080 | |
Sebastian Ott | 34aec07 | 2010-10-25 16:10:28 +0200 | [diff] [blame] | 1081 | void __init chsc_init_cleanup(void) |
Cornelia Huck | 4434a38 | 2007-07-27 12:29:21 +0200 | [diff] [blame] | 1082 | { |
Heiko Carstens | f5daba1 | 2009-03-26 15:24:01 +0100 | [diff] [blame] | 1083 | crw_unregister_handler(CRW_RSC_CSS); |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1084 | free_page((unsigned long)chsc_page); |
Sebastian Ott | 34aec07 | 2010-10-25 16:10:28 +0200 | [diff] [blame] | 1085 | free_page((unsigned long)sei_page); |
Cornelia Huck | 4434a38 | 2007-07-27 12:29:21 +0200 | [diff] [blame] | 1086 | } |
| 1087 | |
Sebastian Ott | 18e22a1 | 2015-06-29 18:39:54 +0200 | [diff] [blame] | 1088 | int __chsc_enable_facility(struct chsc_sda_area *sda_area, int operation_code) |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 1089 | { |
| 1090 | int ret; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 1091 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1092 | sda_area->request.length = 0x0400; |
| 1093 | sda_area->request.code = 0x0031; |
| 1094 | sda_area->operation_code = operation_code; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 1095 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1096 | ret = chsc(sda_area); |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 1097 | if (ret > 0) { |
| 1098 | ret = (ret == 3) ? -ENODEV : -EBUSY; |
| 1099 | goto out; |
| 1100 | } |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 1101 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1102 | switch (sda_area->response.code) { |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 1103 | case 0x0101: |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 1104 | ret = -EOPNOTSUPP; |
| 1105 | break; |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 1106 | default: |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1107 | ret = chsc_error_from_response(sda_area->response.code); |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 1108 | } |
Sebastian Ott | 18e22a1 | 2015-06-29 18:39:54 +0200 | [diff] [blame] | 1109 | out: |
| 1110 | return ret; |
| 1111 | } |
| 1112 | |
| 1113 | int chsc_enable_facility(int operation_code) |
| 1114 | { |
| 1115 | struct chsc_sda_area *sda_area; |
| 1116 | unsigned long flags; |
| 1117 | int ret; |
| 1118 | |
| 1119 | spin_lock_irqsave(&chsc_page_lock, flags); |
| 1120 | memset(chsc_page, 0, PAGE_SIZE); |
| 1121 | sda_area = chsc_page; |
| 1122 | |
| 1123 | ret = __chsc_enable_facility(sda_area, operation_code); |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 1124 | if (ret != 0) |
| 1125 | CIO_CRW_EVENT(2, "chsc: sda (oc=%x) failed (rc=%04x)\n", |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1126 | operation_code, sda_area->response.code); |
Sebastian Ott | 18e22a1 | 2015-06-29 18:39:54 +0200 | [diff] [blame] | 1127 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1128 | spin_unlock_irqrestore(&chsc_page_lock, flags); |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 1129 | return ret; |
| 1130 | } |
| 1131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | struct css_general_char css_general_characteristics; |
| 1133 | struct css_chsc_char css_chsc_characteristics; |
| 1134 | |
| 1135 | int __init |
| 1136 | chsc_determine_css_characteristics(void) |
| 1137 | { |
| 1138 | int result; |
| 1139 | struct { |
| 1140 | struct chsc_header request; |
| 1141 | u32 reserved1; |
| 1142 | u32 reserved2; |
| 1143 | u32 reserved3; |
| 1144 | struct chsc_header response; |
| 1145 | u32 reserved4; |
| 1146 | u32 general_char[510]; |
Sebastian Ott | 34aec07 | 2010-10-25 16:10:28 +0200 | [diff] [blame] | 1147 | u32 chsc_char[508]; |
Peter Oberparleiter | 0f008aa | 2007-02-05 21:17:40 +0100 | [diff] [blame] | 1148 | } __attribute__ ((packed)) *scsc_area; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1150 | spin_lock_irq(&chsc_page_lock); |
| 1151 | memset(chsc_page, 0, PAGE_SIZE); |
| 1152 | scsc_area = chsc_page; |
Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 1153 | scsc_area->request.length = 0x0010; |
| 1154 | scsc_area->request.code = 0x0010; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | |
| 1156 | result = chsc(scsc_area); |
| 1157 | if (result) { |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 1158 | result = (result == 3) ? -ENODEV : -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | goto exit; |
| 1160 | } |
| 1161 | |
Cornelia Huck | b9c9a21 | 2008-02-05 16:50:34 +0100 | [diff] [blame] | 1162 | result = chsc_error_from_response(scsc_area->response.code); |
| 1163 | if (result == 0) { |
| 1164 | memcpy(&css_general_characteristics, scsc_area->general_char, |
| 1165 | sizeof(css_general_characteristics)); |
| 1166 | memcpy(&css_chsc_characteristics, scsc_area->chsc_char, |
| 1167 | sizeof(css_chsc_characteristics)); |
| 1168 | } else |
| 1169 | CIO_CRW_EVENT(2, "chsc: scsc failed (rc=%04x)\n", |
| 1170 | scsc_area->response.code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | exit: |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1172 | spin_unlock_irq(&chsc_page_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | return result; |
| 1174 | } |
| 1175 | |
| 1176 | EXPORT_SYMBOL_GPL(css_general_characteristics); |
| 1177 | EXPORT_SYMBOL_GPL(css_chsc_characteristics); |
Martin Schwidefsky | d2fec59 | 2008-07-14 09:58:56 +0200 | [diff] [blame] | 1178 | |
| 1179 | int chsc_sstpc(void *page, unsigned int op, u16 ctrl) |
| 1180 | { |
| 1181 | struct { |
| 1182 | struct chsc_header request; |
| 1183 | unsigned int rsvd0; |
| 1184 | unsigned int op : 8; |
| 1185 | unsigned int rsvd1 : 8; |
| 1186 | unsigned int ctrl : 16; |
| 1187 | unsigned int rsvd2[5]; |
| 1188 | struct chsc_header response; |
| 1189 | unsigned int rsvd3[7]; |
| 1190 | } __attribute__ ((packed)) *rr; |
| 1191 | int rc; |
| 1192 | |
| 1193 | memset(page, 0, PAGE_SIZE); |
| 1194 | rr = page; |
| 1195 | rr->request.length = 0x0020; |
| 1196 | rr->request.code = 0x0033; |
| 1197 | rr->op = op; |
| 1198 | rr->ctrl = ctrl; |
| 1199 | rc = chsc(rr); |
| 1200 | if (rc) |
| 1201 | return -EIO; |
| 1202 | rc = (rr->response.code == 0x0001) ? 0 : -EIO; |
| 1203 | return rc; |
| 1204 | } |
| 1205 | |
| 1206 | int chsc_sstpi(void *page, void *result, size_t size) |
| 1207 | { |
| 1208 | struct { |
| 1209 | struct chsc_header request; |
| 1210 | unsigned int rsvd0[3]; |
| 1211 | struct chsc_header response; |
| 1212 | char data[size]; |
| 1213 | } __attribute__ ((packed)) *rr; |
| 1214 | int rc; |
| 1215 | |
| 1216 | memset(page, 0, PAGE_SIZE); |
| 1217 | rr = page; |
| 1218 | rr->request.length = 0x0010; |
| 1219 | rr->request.code = 0x0038; |
| 1220 | rc = chsc(rr); |
| 1221 | if (rc) |
| 1222 | return -EIO; |
| 1223 | memcpy(result, &rr->data, size); |
| 1224 | return (rr->response.code == 0x0001) ? 0 : -EIO; |
| 1225 | } |
| 1226 | |
Michael Ernst | fd0457a | 2010-08-09 18:12:50 +0200 | [diff] [blame] | 1227 | int chsc_siosl(struct subchannel_id schid) |
| 1228 | { |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1229 | struct { |
| 1230 | struct chsc_header request; |
| 1231 | u32 word1; |
| 1232 | struct subchannel_id sid; |
| 1233 | u32 word3; |
| 1234 | struct chsc_header response; |
| 1235 | u32 word[11]; |
| 1236 | } __attribute__ ((packed)) *siosl_area; |
Michael Ernst | fd0457a | 2010-08-09 18:12:50 +0200 | [diff] [blame] | 1237 | unsigned long flags; |
| 1238 | int ccode; |
| 1239 | int rc; |
| 1240 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1241 | spin_lock_irqsave(&chsc_page_lock, flags); |
| 1242 | memset(chsc_page, 0, PAGE_SIZE); |
| 1243 | siosl_area = chsc_page; |
| 1244 | siosl_area->request.length = 0x0010; |
| 1245 | siosl_area->request.code = 0x0046; |
| 1246 | siosl_area->word1 = 0x80000000; |
| 1247 | siosl_area->sid = schid; |
Michael Ernst | fd0457a | 2010-08-09 18:12:50 +0200 | [diff] [blame] | 1248 | |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1249 | ccode = chsc(siosl_area); |
Michael Ernst | fd0457a | 2010-08-09 18:12:50 +0200 | [diff] [blame] | 1250 | if (ccode > 0) { |
| 1251 | if (ccode == 3) |
| 1252 | rc = -ENODEV; |
| 1253 | else |
| 1254 | rc = -EBUSY; |
| 1255 | CIO_MSG_EVENT(2, "chsc: chsc failed for 0.%x.%04x (ccode=%d)\n", |
| 1256 | schid.ssid, schid.sch_no, ccode); |
| 1257 | goto out; |
| 1258 | } |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1259 | rc = chsc_error_from_response(siosl_area->response.code); |
Michael Ernst | fd0457a | 2010-08-09 18:12:50 +0200 | [diff] [blame] | 1260 | if (rc) |
| 1261 | CIO_MSG_EVENT(2, "chsc: siosl failed for 0.%x.%04x (rc=%04x)\n", |
| 1262 | schid.ssid, schid.sch_no, |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1263 | siosl_area->response.code); |
Michael Ernst | fd0457a | 2010-08-09 18:12:50 +0200 | [diff] [blame] | 1264 | else |
| 1265 | CIO_MSG_EVENT(4, "chsc: siosl succeeded for 0.%x.%04x\n", |
| 1266 | schid.ssid, schid.sch_no); |
| 1267 | out: |
Sebastian Ott | 34196f8 | 2010-10-25 16:10:29 +0200 | [diff] [blame] | 1268 | spin_unlock_irqrestore(&chsc_page_lock, flags); |
Michael Ernst | fd0457a | 2010-08-09 18:12:50 +0200 | [diff] [blame] | 1269 | return rc; |
| 1270 | } |
| 1271 | EXPORT_SYMBOL_GPL(chsc_siosl); |
Sebastian Ott | 184b08a | 2012-08-28 16:45:42 +0200 | [diff] [blame] | 1272 | |
| 1273 | /** |
| 1274 | * chsc_scm_info() - store SCM information (SSI) |
| 1275 | * @scm_area: request and response block for SSI |
| 1276 | * @token: continuation token |
| 1277 | * |
| 1278 | * Returns 0 on success. |
| 1279 | */ |
| 1280 | int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token) |
| 1281 | { |
| 1282 | int ccode, ret; |
| 1283 | |
| 1284 | memset(scm_area, 0, sizeof(*scm_area)); |
| 1285 | scm_area->request.length = 0x0020; |
| 1286 | scm_area->request.code = 0x004C; |
| 1287 | scm_area->reqtok = token; |
| 1288 | |
| 1289 | ccode = chsc(scm_area); |
| 1290 | if (ccode > 0) { |
| 1291 | ret = (ccode == 3) ? -ENODEV : -EBUSY; |
| 1292 | goto out; |
| 1293 | } |
| 1294 | ret = chsc_error_from_response(scm_area->response.code); |
| 1295 | if (ret != 0) |
| 1296 | CIO_MSG_EVENT(2, "chsc: scm info failed (rc=%04x)\n", |
| 1297 | scm_area->response.code); |
| 1298 | out: |
| 1299 | return ret; |
| 1300 | } |
| 1301 | EXPORT_SYMBOL_GPL(chsc_scm_info); |
Eugene Crosser | 1c59a86 | 2013-04-24 12:00:23 +0200 | [diff] [blame] | 1302 | |
| 1303 | /** |
| 1304 | * chsc_pnso_brinfo() - Perform Network-Subchannel Operation, Bridge Info. |
| 1305 | * @schid: id of the subchannel on which PNSO is performed |
| 1306 | * @brinfo_area: request and response block for the operation |
| 1307 | * @resume_token: resume token for multiblock response |
| 1308 | * @cnc: Boolean change-notification control |
| 1309 | * |
| 1310 | * brinfo_area must be allocated by the caller with get_zeroed_page(GFP_KERNEL) |
| 1311 | * |
| 1312 | * Returns 0 on success. |
| 1313 | */ |
| 1314 | int chsc_pnso_brinfo(struct subchannel_id schid, |
| 1315 | struct chsc_pnso_area *brinfo_area, |
| 1316 | struct chsc_brinfo_resume_token resume_token, |
| 1317 | int cnc) |
| 1318 | { |
| 1319 | memset(brinfo_area, 0, sizeof(*brinfo_area)); |
| 1320 | brinfo_area->request.length = 0x0030; |
| 1321 | brinfo_area->request.code = 0x003d; /* network-subchannel operation */ |
| 1322 | brinfo_area->m = schid.m; |
| 1323 | brinfo_area->ssid = schid.ssid; |
| 1324 | brinfo_area->sch = schid.sch_no; |
| 1325 | brinfo_area->cssid = schid.cssid; |
| 1326 | brinfo_area->oc = 0; /* Store-network-bridging-information list */ |
| 1327 | brinfo_area->resume_token = resume_token; |
| 1328 | brinfo_area->n = (cnc != 0); |
| 1329 | if (chsc(brinfo_area)) |
| 1330 | return -EIO; |
| 1331 | return chsc_error_from_response(brinfo_area->response.code); |
| 1332 | } |
| 1333 | EXPORT_SYMBOL_GPL(chsc_pnso_brinfo); |