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