chsc.c 31 KB

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