2 * S/390 common I/O routines -- channel subsystem call
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)
10 #define KMSG_COMPONENT "cio"
11 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/init.h>
16 #include <linux/device.h>
17 #include <linux/pci.h>
20 #include <asm/chpid.h>
24 #include <asm/ebcdic.h>
28 #include "cio_debug.h"
33 static void *sei_page
;
34 static void *chsc_page
;
35 static DEFINE_SPINLOCK(chsc_page_lock
);
38 * chsc_error_from_response() - convert a chsc response to an error
39 * @response: chsc response code
41 * Returns an appropriate Linux error code for @response.
43 int chsc_error_from_response(int response
)
59 case 0x0107: /* "Channel busy" for the op 0x003d */
68 EXPORT_SYMBOL_GPL(chsc_error_from_response
);
70 struct chsc_ssd_area
{
71 struct chsc_header request
;
75 u16 f_sch
; /* first subchannel */
77 u16 l_sch
; /* last subchannel */
79 struct chsc_header response
;
83 u8 st
: 3; /* subchannel type */
85 u8 unit_addr
; /* unit address */
86 u16 devno
; /* device number */
89 u16 sch
; /* subchannel */
90 u8 chpid
[8]; /* chpids 0-7 */
91 u16 fla
[8]; /* full link addresses 0-7 */
92 } __attribute__ ((packed
));
94 int chsc_get_ssd_info(struct subchannel_id schid
, struct chsc_ssd_info
*ssd
)
96 struct chsc_ssd_area
*ssd_area
;
102 spin_lock_irq(&chsc_page_lock
);
103 memset(chsc_page
, 0, PAGE_SIZE
);
104 ssd_area
= chsc_page
;
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
;
111 ccode
= chsc(ssd_area
);
112 /* Check response. */
114 ret
= (ccode
== 3) ? -ENODEV
: -EBUSY
;
117 ret
= chsc_error_from_response(ssd_area
->response
.code
);
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
);
124 if (!ssd_area
->sch_valid
) {
130 memset(ssd
, 0, sizeof(struct chsc_ssd_info
));
131 if ((ssd_area
->st
!= SUBCHANNEL_TYPE_IO
) &&
132 (ssd_area
->st
!= SUBCHANNEL_TYPE_MSG
))
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
++) {
138 if (ssd_area
->path_mask
& mask
) {
139 chp_id_init(&ssd
->chpid
[i
]);
140 ssd
->chpid
[i
].id
= ssd_area
->chpid
[i
];
142 if (ssd_area
->fla_valid_mask
& mask
)
143 ssd
->fla
[i
] = ssd_area
->fla
[i
];
146 spin_unlock_irq(&chsc_page_lock
);
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
155 * Returns 0 on success.
157 int chsc_ssqd(struct subchannel_id schid
, struct chsc_ssqd_area
*ssqd
)
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
;
169 return chsc_error_from_response(ssqd
->response
.code
);
171 EXPORT_SYMBOL_GPL(chsc_ssqd
);
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
180 * Returns 0 on success.
182 int chsc_sadc(struct subchannel_id schid
, struct chsc_scssc_area
*scssc
,
183 u64 summary_indicator_addr
, u64 subchannel_indicator_addr
)
185 memset(scssc
, 0, sizeof(*scssc
));
186 scssc
->request
.length
= 0x0fe0;
187 scssc
->request
.code
= 0x0021;
188 scssc
->operation_code
= 0;
190 scssc
->summary_indicator_addr
= summary_indicator_addr
;
191 scssc
->subchannel_indicator_addr
= subchannel_indicator_addr
;
193 scssc
->ks
= PAGE_DEFAULT_KEY
>> 4;
194 scssc
->kc
= PAGE_DEFAULT_KEY
>> 4;
195 scssc
->isc
= QDIO_AIRQ_ISC
;
196 scssc
->schid
= schid
;
198 /* enable the time delay disablement facility */
199 if (css_general_characteristics
.aif_tdd
)
200 scssc
->word_with_d_bit
= 0x10000000;
205 return chsc_error_from_response(scssc
->response
.code
);
207 EXPORT_SYMBOL_GPL(chsc_sadc
);
209 static int s390_subchannel_remove_chpid(struct subchannel
*sch
, void *data
)
211 spin_lock_irq(sch
->lock
);
212 if (sch
->driver
&& sch
->driver
->chp_event
)
213 if (sch
->driver
->chp_event(sch
, data
, CHP_OFFLINE
) != 0)
215 spin_unlock_irq(sch
->lock
);
220 spin_unlock_irq(sch
->lock
);
221 css_schedule_eval(sch
->schid
);
225 void chsc_chp_offline(struct chp_id chpid
)
228 struct chp_link link
;
230 sprintf(dbf_txt
, "chpr%x.%02x", chpid
.cssid
, chpid
.id
);
231 CIO_TRACE_EVENT(2, dbf_txt
);
233 if (chp_get_status(chpid
) <= 0)
235 memset(&link
, 0, sizeof(struct chp_link
));
237 /* Wait until previous actions have settled. */
238 css_wait_for_slow_path();
239 for_each_subchannel_staged(s390_subchannel_remove_chpid
, NULL
, &link
);
242 static int __s390_process_res_acc(struct subchannel
*sch
, void *data
)
244 spin_lock_irq(sch
->lock
);
245 if (sch
->driver
&& sch
->driver
->chp_event
)
246 sch
->driver
->chp_event(sch
, data
, CHP_ONLINE
);
247 spin_unlock_irq(sch
->lock
);
252 static void s390_process_res_acc(struct chp_link
*link
)
256 sprintf(dbf_txt
, "accpr%x.%02x", link
->chpid
.cssid
,
258 CIO_TRACE_EVENT( 2, dbf_txt
);
259 if (link
->fla
!= 0) {
260 sprintf(dbf_txt
, "fla%x", link
->fla
);
261 CIO_TRACE_EVENT( 2, dbf_txt
);
263 /* Wait until previous actions have settled. */
264 css_wait_for_slow_path();
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.
272 for_each_subchannel_staged(__s390_process_res_acc
, NULL
, link
);
273 css_schedule_reprobe();
276 struct chsc_sei_nt0_area
{
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 */
285 /* ccdf has to be big enough for a link-incident record */
286 u8 ccdf
[PAGE_SIZE
- 24 - 16]; /* content-code dependent field */
289 struct chsc_sei_nt2_area
{
290 u8 flags
; /* p and v bit */
293 u8 cc
; /* content code */
295 u8 ccdf
[PAGE_SIZE
- 24 - 56]; /* content-code dependent field */
298 #define CHSC_SEI_NT0 (1ULL << 63)
299 #define CHSC_SEI_NT2 (1ULL << 61)
302 struct chsc_header request
;
304 u64 ntsm
; /* notification type mask */
305 struct chsc_header response
;
309 struct chsc_sei_nt0_area nt0_area
;
310 struct chsc_sei_nt2_area nt2_area
;
311 u8 nt_area
[PAGE_SIZE
- 24];
316 * Node Descriptor as defined in SA22-7204, "Common I/O-Device Commands"
319 #define ND_VALIDITY_VALID 0
320 #define ND_VALIDITY_OUTDATED 1
321 #define ND_VALIDITY_INVALID 2
323 struct node_descriptor
{
333 /* Node parameters. */
339 char manufacturer
[3];
346 * Link Incident Record as defined in SA22-7202, "ESCON I/O Interface"
349 #define LIR_IQ_CLASS_INFO 0
350 #define LIR_IQ_CLASS_DEGRADED 1
351 #define LIR_IQ_CLASS_NOT_OPERATIONAL 2
362 struct node_descriptor incident_node
;
363 struct node_descriptor attached_node
;
367 #define PARAMS_LEN 10 /* PARAMS=xx,xxxxxx */
368 #define NODEID_LEN 35 /* NODEID=tttttt/mdl,mmm.ppssssssssssss,xxxx */
370 /* Copy EBCIDC text, convert to ASCII and optionally add delimiter. */
371 static char *store_ebcdic(char *dest
, const char *src
, unsigned long len
,
374 memcpy(dest
, src
, len
);
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
)
386 memset(params
, 0, PARAMS_LEN
);
387 memset(id
, 0, NODEID_LEN
);
389 if (nd
->validity
!= ND_VALIDITY_VALID
) {
390 strncpy(params
, "n/a", PARAMS_LEN
- 1);
391 strncpy(id
, "n/a", NODEID_LEN
- 1);
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
);
406 static void chsc_process_sei_link_incident(struct chsc_sei_nt0_area
*sei_area
)
408 struct lir
*lir
= (struct lir
*) &sei_area
->ccdf
;
409 char iuparams
[PARAMS_LEN
], iunodeid
[NODEID_LEN
], auparams
[PARAMS_LEN
],
410 aunodeid
[NODEID_LEN
];
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]);
415 /* Ignore NULL Link Incident Records. */
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. */
423 format_node_data(iuparams
, iunodeid
, &lir
->incident_node
);
424 format_node_data(auparams
, aunodeid
, &lir
->attached_node
);
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
);
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
);
444 static void chsc_process_sei_res_acc(struct chsc_sei_nt0_area
*sei_area
)
446 struct chp_link link
;
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)
455 chpid
.id
= sei_area
->rsid
;
456 /* allocate a new channel path structure, if needed */
457 status
= chp_get_status(chpid
);
462 memset(&link
, 0, sizeof(struct chp_link
));
464 if ((sei_area
->vf
& 0xc0) != 0) {
465 link
.fla
= sei_area
->fla
;
466 if ((sei_area
->vf
& 0xc0) == 0xc0)
467 /* full link address */
468 link
.fla_mask
= 0xffff;
471 link
.fla_mask
= 0xff00;
473 s390_process_res_acc(&link
);
476 static void chsc_process_sei_chp_avail(struct chsc_sei_nt0_area
*sei_area
)
478 struct channel_path
*chp
;
483 CIO_CRW_EVENT(4, "chsc: channel path availability information\n");
484 if (sei_area
->rs
!= 0)
486 data
= sei_area
->ccdf
;
488 for (num
= 0; num
<= __MAX_CHPID
; num
++) {
489 if (!chp_test_bit(data
, num
))
493 CIO_CRW_EVENT(4, "Update information for channel path "
494 "%x.%02x\n", chpid
.cssid
, chpid
.id
);
495 chp
= chpid_to_chp(chpid
);
500 mutex_lock(&chp
->lock
);
501 chp_update_desc(chp
);
502 mutex_unlock(&chp
->lock
);
506 struct chp_config_data
{
512 static void chsc_process_sei_chp_config(struct chsc_sei_nt0_area
*sei_area
)
514 struct chp_config_data
*data
;
517 char *events
[3] = {"configure", "deconfigure", "cancel deconfigure"};
519 CIO_CRW_EVENT(4, "chsc: channel-path-configuration notification\n");
520 if (sei_area
->rs
!= 0)
522 data
= (struct chp_config_data
*) &(sei_area
->ccdf
);
524 for (num
= 0; num
<= __MAX_CHPID
; num
++) {
525 if (!chp_test_bit(data
->map
, num
))
528 pr_notice("Processing %s for channel path %x.%02x\n",
529 events
[data
->op
], chpid
.cssid
, chpid
.id
);
532 chp_cfg_schedule(chpid
, 1);
535 chp_cfg_schedule(chpid
, 0);
538 chp_cfg_cancel_deconfigure(chpid
);
544 static void chsc_process_sei_scm_change(struct chsc_sei_nt0_area
*sei_area
)
548 CIO_CRW_EVENT(4, "chsc: scm change notification\n");
549 if (sei_area
->rs
!= 7)
552 ret
= scm_update_information();
554 CIO_CRW_EVENT(0, "chsc: updating change notification"
555 " failed (rc=%d).\n", ret
);
558 static void chsc_process_sei_scm_avail(struct chsc_sei_nt0_area
*sei_area
)
562 CIO_CRW_EVENT(4, "chsc: scm available information\n");
563 if (sei_area
->rs
!= 7)
566 ret
= scm_process_availability_information();
568 CIO_CRW_EVENT(0, "chsc: process availability information"
569 " failed (rc=%d).\n", ret
);
572 static void chsc_process_sei_nt2(struct chsc_sei_nt2_area
*sei_area
)
574 switch (sei_area
->cc
) {
576 zpci_event_error(sei_area
->ccdf
);
579 zpci_event_availability(sei_area
->ccdf
);
582 CIO_CRW_EVENT(2, "chsc: sei nt2 unhandled cc=%d\n",
588 static void chsc_process_sei_nt0(struct chsc_sei_nt0_area
*sei_area
)
590 /* which kind of information was stored? */
591 switch (sei_area
->cc
) {
592 case 1: /* link incident*/
593 chsc_process_sei_link_incident(sei_area
);
595 case 2: /* i/o resource accessibility */
596 chsc_process_sei_res_acc(sei_area
);
598 case 7: /* channel-path-availability information */
599 chsc_process_sei_chp_avail(sei_area
);
601 case 8: /* channel-path-configuration notification */
602 chsc_process_sei_chp_config(sei_area
);
604 case 12: /* scm change notification */
605 chsc_process_sei_scm_change(sei_area
);
607 case 14: /* scm available notification */
608 chsc_process_sei_scm_avail(sei_area
);
610 default: /* other stuff */
611 CIO_CRW_EVENT(2, "chsc: sei nt0 unhandled cc=%d\n",
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();
623 static void chsc_process_event_information(struct chsc_sei
*sei
, u64 ntsm
)
625 static int ntsm_unsupported
;
628 memset(sei
, 0, sizeof(*sei
));
629 sei
->request
.length
= 0x0010;
630 sei
->request
.code
= 0x000e;
631 if (!ntsm_unsupported
)
637 if (sei
->response
.code
!= 0x0001) {
638 CIO_CRW_EVENT(2, "chsc: sei failed (rc=%04x, ntsm=%llx)\n",
639 sei
->response
.code
, sei
->ntsm
);
641 if (sei
->response
.code
== 3 && sei
->ntsm
) {
642 /* Fallback for old firmware. */
643 ntsm_unsupported
= 1;
649 CIO_CRW_EVENT(2, "chsc: sei successful (nt=%d)\n", sei
->nt
);
652 chsc_process_sei_nt0(&sei
->u
.nt0_area
);
655 chsc_process_sei_nt2(&sei
->u
.nt2_area
);
658 CIO_CRW_EVENT(2, "chsc: unhandled nt: %d\n", sei
->nt
);
662 if (!(sei
->u
.nt0_area
.flags
& 0x80))
668 * Handle channel subsystem related CRWs.
669 * Use store event information to find out what's going on.
671 * Note: Access to sei_page is serialized through machine check handler
672 * thread, so no need for locking.
674 static void chsc_process_crw(struct crw
*crw0
, struct crw
*crw1
, int overflow
)
676 struct chsc_sei
*sei
= sei_page
;
679 css_schedule_eval_all();
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
);
687 CIO_TRACE_EVENT(2, "prcss");
688 chsc_process_event_information(sei
, CHSC_SEI_NT0
| CHSC_SEI_NT2
);
691 void chsc_chp_online(struct chp_id chpid
)
694 struct chp_link link
;
696 sprintf(dbf_txt
, "cadd%x.%02x", chpid
.cssid
, chpid
.id
);
697 CIO_TRACE_EVENT(2, dbf_txt
);
699 if (chp_get_status(chpid
) != 0) {
700 memset(&link
, 0, sizeof(struct chp_link
));
702 /* Wait until previous actions have settled. */
703 css_wait_for_slow_path();
704 for_each_subchannel_staged(__s390_process_res_acc
, NULL
,
706 css_schedule_reprobe();
710 static void __s390_subchannel_vary_chpid(struct subchannel
*sch
,
711 struct chp_id chpid
, int on
)
714 struct chp_link link
;
716 memset(&link
, 0, sizeof(struct chp_link
));
718 spin_lock_irqsave(sch
->lock
, flags
);
719 if (sch
->driver
&& sch
->driver
->chp_event
)
720 sch
->driver
->chp_event(sch
, &link
,
721 on
? CHP_VARY_ON
: CHP_VARY_OFF
);
722 spin_unlock_irqrestore(sch
->lock
, flags
);
725 static int s390_subchannel_vary_chpid_off(struct subchannel
*sch
, void *data
)
727 struct chp_id
*chpid
= data
;
729 __s390_subchannel_vary_chpid(sch
, *chpid
, 0);
733 static int s390_subchannel_vary_chpid_on(struct subchannel
*sch
, void *data
)
735 struct chp_id
*chpid
= data
;
737 __s390_subchannel_vary_chpid(sch
, *chpid
, 1);
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
746 int chsc_chp_vary(struct chp_id chpid
, int on
)
748 struct channel_path
*chp
= chpid_to_chp(chpid
);
750 /* Wait until previous actions have settled. */
751 css_wait_for_slow_path();
753 * Redo PathVerification on the devices the chpid connects to
756 /* Try to update the channel path description. */
757 chp_update_desc(chp
);
758 for_each_subchannel_staged(s390_subchannel_vary_chpid_on
,
760 css_schedule_reprobe();
762 for_each_subchannel_staged(s390_subchannel_vary_chpid_off
,
769 chsc_remove_cmg_attr(struct channel_subsystem
*css
)
773 for (i
= 0; i
<= __MAX_CHPID
; i
++) {
776 chp_remove_cmg_attr(css
->chps
[i
]);
781 chsc_add_cmg_attr(struct channel_subsystem
*css
)
786 for (i
= 0; i
<= __MAX_CHPID
; i
++) {
789 ret
= chp_add_cmg_attr(css
->chps
[i
]);
795 for (--i
; i
>= 0; i
--) {
798 chp_remove_cmg_attr(css
->chps
[i
]);
803 int __chsc_do_secm(struct channel_subsystem
*css
, int enable
)
806 struct chsc_header request
;
807 u32 operation_code
: 2;
816 struct chsc_header response
;
821 } __attribute__ ((packed
)) *secm_area
;
824 spin_lock_irq(&chsc_page_lock
);
825 memset(chsc_page
, 0, PAGE_SIZE
);
826 secm_area
= chsc_page
;
827 secm_area
->request
.length
= 0x0050;
828 secm_area
->request
.code
= 0x0016;
830 secm_area
->key
= PAGE_DEFAULT_KEY
>> 4;
831 secm_area
->cub_addr1
= (u64
)(unsigned long)css
->cub_addr1
;
832 secm_area
->cub_addr2
= (u64
)(unsigned long)css
->cub_addr2
;
834 secm_area
->operation_code
= enable
? 0 : 1;
836 ccode
= chsc(secm_area
);
838 ret
= (ccode
== 3) ? -ENODEV
: -EBUSY
;
842 switch (secm_area
->response
.code
) {
848 ret
= chsc_error_from_response(secm_area
->response
.code
);
851 CIO_CRW_EVENT(2, "chsc: secm failed (rc=%04x)\n",
852 secm_area
->response
.code
);
854 spin_unlock_irq(&chsc_page_lock
);
859 chsc_secm(struct channel_subsystem
*css
, int enable
)
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
);
872 ret
= __chsc_do_secm(css
, enable
);
874 css
->cm_enabled
= enable
;
875 if (css
->cm_enabled
) {
876 ret
= chsc_add_cmg_attr(css
);
878 __chsc_do_secm(css
, 0);
882 chsc_remove_cmg_attr(css
);
884 if (!css
->cm_enabled
) {
885 free_page((unsigned long)css
->cub_addr1
);
886 free_page((unsigned long)css
->cub_addr2
);
891 int chsc_determine_channel_path_desc(struct chp_id chpid
, int fmt
, int rfmt
,
892 int c
, int m
, void *page
)
894 struct chsc_scpd
*scpd_area
;
897 if ((rfmt
== 1) && !css_general_characteristics
.fcs
)
899 if ((rfmt
== 2) && !css_general_characteristics
.cib
)
902 memset(page
, 0, PAGE_SIZE
);
904 scpd_area
->request
.length
= 0x0010;
905 scpd_area
->request
.code
= 0x0002;
906 scpd_area
->cssid
= chpid
.cssid
;
907 scpd_area
->first_chpid
= chpid
.id
;
908 scpd_area
->last_chpid
= chpid
.id
;
911 scpd_area
->fmt
= fmt
;
912 scpd_area
->rfmt
= rfmt
;
914 ccode
= chsc(scpd_area
);
916 return (ccode
== 3) ? -ENODEV
: -EBUSY
;
918 ret
= chsc_error_from_response(scpd_area
->response
.code
);
920 CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
921 scpd_area
->response
.code
);
924 EXPORT_SYMBOL_GPL(chsc_determine_channel_path_desc
);
926 int chsc_determine_base_channel_path_desc(struct chp_id chpid
,
927 struct channel_path_desc
*desc
)
929 struct chsc_response_struct
*chsc_resp
;
930 struct chsc_scpd
*scpd_area
;
934 spin_lock_irqsave(&chsc_page_lock
, flags
);
935 scpd_area
= chsc_page
;
936 ret
= chsc_determine_channel_path_desc(chpid
, 0, 0, 0, 0, scpd_area
);
939 chsc_resp
= (void *)&scpd_area
->response
;
940 memcpy(desc
, &chsc_resp
->data
, sizeof(*desc
));
942 spin_unlock_irqrestore(&chsc_page_lock
, flags
);
946 int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid
,
947 struct channel_path_desc_fmt1
*desc
)
949 struct chsc_response_struct
*chsc_resp
;
950 struct chsc_scpd
*scpd_area
;
954 spin_lock_irqsave(&chsc_page_lock
, flags
);
955 scpd_area
= chsc_page
;
956 ret
= chsc_determine_channel_path_desc(chpid
, 0, 0, 1, 0, scpd_area
);
959 chsc_resp
= (void *)&scpd_area
->response
;
960 memcpy(desc
, &chsc_resp
->data
, sizeof(*desc
));
962 spin_unlock_irqrestore(&chsc_page_lock
, flags
);
967 chsc_initialize_cmg_chars(struct channel_path
*chp
, u8 cmcv
,
968 struct cmg_chars
*chars
)
970 struct cmg_chars
*cmg_chars
;
973 cmg_chars
= chp
->cmg_chars
;
974 for (i
= 0; i
< NR_MEASUREMENT_CHARS
; i
++) {
975 mask
= 0x80 >> (i
+ 3);
977 cmg_chars
->values
[i
] = chars
->values
[i
];
979 cmg_chars
->values
[i
] = 0;
983 int chsc_get_channel_measurement_chars(struct channel_path
*chp
)
985 struct cmg_chars
*cmg_chars
;
989 struct chsc_header request
;
995 struct chsc_header response
;
1006 u32 data
[NR_MEASUREMENT_CHARS
];
1007 } __attribute__ ((packed
)) *scmc_area
;
1009 chp
->cmg_chars
= NULL
;
1010 cmg_chars
= kmalloc(sizeof(*cmg_chars
), GFP_KERNEL
);
1014 spin_lock_irq(&chsc_page_lock
);
1015 memset(chsc_page
, 0, PAGE_SIZE
);
1016 scmc_area
= chsc_page
;
1017 scmc_area
->request
.length
= 0x0010;
1018 scmc_area
->request
.code
= 0x0022;
1019 scmc_area
->first_chpid
= chp
->chpid
.id
;
1020 scmc_area
->last_chpid
= chp
->chpid
.id
;
1022 ccode
= chsc(scmc_area
);
1024 ret
= (ccode
== 3) ? -ENODEV
: -EBUSY
;
1028 ret
= chsc_error_from_response(scmc_area
->response
.code
);
1030 CIO_CRW_EVENT(2, "chsc: scmc failed (rc=%04x)\n",
1031 scmc_area
->response
.code
);
1034 if (scmc_area
->not_valid
) {
1039 chp
->cmg
= scmc_area
->cmg
;
1040 chp
->shared
= scmc_area
->shared
;
1041 if (chp
->cmg
!= 2 && chp
->cmg
!= 3) {
1042 /* No cmg-dependent data. */
1045 chp
->cmg_chars
= cmg_chars
;
1046 chsc_initialize_cmg_chars(chp
, scmc_area
->cmcv
,
1047 (struct cmg_chars
*) &scmc_area
->data
);
1049 spin_unlock_irq(&chsc_page_lock
);
1050 if (!chp
->cmg_chars
)
1056 int __init
chsc_init(void)
1060 sei_page
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
1061 chsc_page
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
1062 if (!sei_page
|| !chsc_page
) {
1066 ret
= crw_register_handler(CRW_RSC_CSS
, chsc_process_crw
);
1071 free_page((unsigned long)chsc_page
);
1072 free_page((unsigned long)sei_page
);
1076 void __init
chsc_init_cleanup(void)
1078 crw_unregister_handler(CRW_RSC_CSS
);
1079 free_page((unsigned long)chsc_page
);
1080 free_page((unsigned long)sei_page
);
1083 int __chsc_enable_facility(struct chsc_sda_area
*sda_area
, int operation_code
)
1087 sda_area
->request
.length
= 0x0400;
1088 sda_area
->request
.code
= 0x0031;
1089 sda_area
->operation_code
= operation_code
;
1091 ret
= chsc(sda_area
);
1093 ret
= (ret
== 3) ? -ENODEV
: -EBUSY
;
1097 switch (sda_area
->response
.code
) {
1102 ret
= chsc_error_from_response(sda_area
->response
.code
);
1108 int chsc_enable_facility(int operation_code
)
1110 struct chsc_sda_area
*sda_area
;
1111 unsigned long flags
;
1114 spin_lock_irqsave(&chsc_page_lock
, flags
);
1115 memset(chsc_page
, 0, PAGE_SIZE
);
1116 sda_area
= chsc_page
;
1118 ret
= __chsc_enable_facility(sda_area
, operation_code
);
1120 CIO_CRW_EVENT(2, "chsc: sda (oc=%x) failed (rc=%04x)\n",
1121 operation_code
, sda_area
->response
.code
);
1123 spin_unlock_irqrestore(&chsc_page_lock
, flags
);
1127 struct css_general_char css_general_characteristics
;
1128 struct css_chsc_char css_chsc_characteristics
;
1131 chsc_determine_css_characteristics(void)
1135 struct chsc_header request
;
1139 struct chsc_header response
;
1141 u32 general_char
[510];
1143 } __attribute__ ((packed
)) *scsc_area
;
1145 spin_lock_irq(&chsc_page_lock
);
1146 memset(chsc_page
, 0, PAGE_SIZE
);
1147 scsc_area
= chsc_page
;
1148 scsc_area
->request
.length
= 0x0010;
1149 scsc_area
->request
.code
= 0x0010;
1151 result
= chsc(scsc_area
);
1153 result
= (result
== 3) ? -ENODEV
: -EBUSY
;
1157 result
= chsc_error_from_response(scsc_area
->response
.code
);
1159 memcpy(&css_general_characteristics
, scsc_area
->general_char
,
1160 sizeof(css_general_characteristics
));
1161 memcpy(&css_chsc_characteristics
, scsc_area
->chsc_char
,
1162 sizeof(css_chsc_characteristics
));
1164 CIO_CRW_EVENT(2, "chsc: scsc failed (rc=%04x)\n",
1165 scsc_area
->response
.code
);
1167 spin_unlock_irq(&chsc_page_lock
);
1171 EXPORT_SYMBOL_GPL(css_general_characteristics
);
1172 EXPORT_SYMBOL_GPL(css_chsc_characteristics
);
1174 int chsc_sstpc(void *page
, unsigned int op
, u16 ctrl
)
1177 struct chsc_header request
;
1179 unsigned int op
: 8;
1180 unsigned int rsvd1
: 8;
1181 unsigned int ctrl
: 16;
1182 unsigned int rsvd2
[5];
1183 struct chsc_header response
;
1184 unsigned int rsvd3
[7];
1185 } __attribute__ ((packed
)) *rr
;
1188 memset(page
, 0, PAGE_SIZE
);
1190 rr
->request
.length
= 0x0020;
1191 rr
->request
.code
= 0x0033;
1197 rc
= (rr
->response
.code
== 0x0001) ? 0 : -EIO
;
1201 int chsc_sstpi(void *page
, void *result
, size_t size
)
1204 struct chsc_header request
;
1205 unsigned int rsvd0
[3];
1206 struct chsc_header response
;
1208 } __attribute__ ((packed
)) *rr
;
1211 memset(page
, 0, PAGE_SIZE
);
1213 rr
->request
.length
= 0x0010;
1214 rr
->request
.code
= 0x0038;
1218 memcpy(result
, &rr
->data
, size
);
1219 return (rr
->response
.code
== 0x0001) ? 0 : -EIO
;
1222 int chsc_siosl(struct subchannel_id schid
)
1225 struct chsc_header request
;
1227 struct subchannel_id sid
;
1229 struct chsc_header response
;
1231 } __attribute__ ((packed
)) *siosl_area
;
1232 unsigned long flags
;
1236 spin_lock_irqsave(&chsc_page_lock
, flags
);
1237 memset(chsc_page
, 0, PAGE_SIZE
);
1238 siosl_area
= chsc_page
;
1239 siosl_area
->request
.length
= 0x0010;
1240 siosl_area
->request
.code
= 0x0046;
1241 siosl_area
->word1
= 0x80000000;
1242 siosl_area
->sid
= schid
;
1244 ccode
= chsc(siosl_area
);
1250 CIO_MSG_EVENT(2, "chsc: chsc failed for 0.%x.%04x (ccode=%d)\n",
1251 schid
.ssid
, schid
.sch_no
, ccode
);
1254 rc
= chsc_error_from_response(siosl_area
->response
.code
);
1256 CIO_MSG_EVENT(2, "chsc: siosl failed for 0.%x.%04x (rc=%04x)\n",
1257 schid
.ssid
, schid
.sch_no
,
1258 siosl_area
->response
.code
);
1260 CIO_MSG_EVENT(4, "chsc: siosl succeeded for 0.%x.%04x\n",
1261 schid
.ssid
, schid
.sch_no
);
1263 spin_unlock_irqrestore(&chsc_page_lock
, flags
);
1266 EXPORT_SYMBOL_GPL(chsc_siosl
);
1269 * chsc_scm_info() - store SCM information (SSI)
1270 * @scm_area: request and response block for SSI
1271 * @token: continuation token
1273 * Returns 0 on success.
1275 int chsc_scm_info(struct chsc_scm_info
*scm_area
, u64 token
)
1279 memset(scm_area
, 0, sizeof(*scm_area
));
1280 scm_area
->request
.length
= 0x0020;
1281 scm_area
->request
.code
= 0x004C;
1282 scm_area
->reqtok
= token
;
1284 ccode
= chsc(scm_area
);
1286 ret
= (ccode
== 3) ? -ENODEV
: -EBUSY
;
1289 ret
= chsc_error_from_response(scm_area
->response
.code
);
1291 CIO_MSG_EVENT(2, "chsc: scm info failed (rc=%04x)\n",
1292 scm_area
->response
.code
);
1296 EXPORT_SYMBOL_GPL(chsc_scm_info
);
1299 * chsc_pnso_brinfo() - Perform Network-Subchannel Operation, Bridge Info.
1300 * @schid: id of the subchannel on which PNSO is performed
1301 * @brinfo_area: request and response block for the operation
1302 * @resume_token: resume token for multiblock response
1303 * @cnc: Boolean change-notification control
1305 * brinfo_area must be allocated by the caller with get_zeroed_page(GFP_KERNEL)
1307 * Returns 0 on success.
1309 int chsc_pnso_brinfo(struct subchannel_id schid
,
1310 struct chsc_pnso_area
*brinfo_area
,
1311 struct chsc_brinfo_resume_token resume_token
,
1314 memset(brinfo_area
, 0, sizeof(*brinfo_area
));
1315 brinfo_area
->request
.length
= 0x0030;
1316 brinfo_area
->request
.code
= 0x003d; /* network-subchannel operation */
1317 brinfo_area
->m
= schid
.m
;
1318 brinfo_area
->ssid
= schid
.ssid
;
1319 brinfo_area
->sch
= schid
.sch_no
;
1320 brinfo_area
->cssid
= schid
.cssid
;
1321 brinfo_area
->oc
= 0; /* Store-network-bridging-information list */
1322 brinfo_area
->resume_token
= resume_token
;
1323 brinfo_area
->n
= (cnc
!= 0);
1324 if (chsc(brinfo_area
))
1326 return chsc_error_from_response(brinfo_area
->response
.code
);
1328 EXPORT_SYMBOL_GPL(chsc_pnso_brinfo
);