chsc.c 32 KB

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