2 * drivers/s390/char/tape_3590.c
3 * tape device discipline for 3590 tapes.
5 * Copyright IBM Corp. 2001,2006
6 * Author(s): Stefan Bader <shbader@de.ibm.com>
7 * Michael Holzheu <holzheu@de.ibm.com>
8 * Martin Schwidefsky <schwidefsky@de.ibm.com>
11 #define KMSG_COMPONENT "tape"
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/bio.h>
16 #include <asm/ebcdic.h>
18 #define TAPE_DBF_AREA tape_3590_dbf
19 #define BUFSIZE 512 /* size of buffers for dynamic generated messages */
23 #include "tape_3590.h"
26 * Pointer to debug area.
28 debug_info_t *TAPE_DBF_AREA = NULL;
29 EXPORT_SYMBOL(TAPE_DBF_AREA);
31 /*******************************************************************
32 * Error Recovery fuctions:
33 * - Read Opposite: implemented
34 * - Read Device (buffered) log: BRA
35 * - Read Library log: BRA
37 * - Long Busy: implemented
38 * - Special Intercept: BRA
39 * - Read Alternate: implemented
40 *******************************************************************/
42 #define KMSG_COMPONENT "tape"
44 static const char *tape_3590_msg[TAPE_3590_MAX_MSG] = {
46 [0x10] = "Lost Sense",
47 [0x11] = "Assigned Elsewhere",
48 [0x12] = "Allegiance Reset",
49 [0x13] = "Shared Access Violation",
50 [0x20] = "Command Reject",
51 [0x21] = "Configuration Error",
52 [0x22] = "Protection Exception",
53 [0x23] = "Write Protect",
54 [0x24] = "Write Length",
55 [0x25] = "Read-Only Format",
56 [0x31] = "Beginning of Partition",
57 [0x33] = "End of Partition",
58 [0x34] = "End of Data",
59 [0x35] = "Block not found",
60 [0x40] = "Device Intervention",
61 [0x41] = "Loader Intervention",
62 [0x42] = "Library Intervention",
63 [0x50] = "Write Error",
64 [0x51] = "Erase Error",
65 [0x52] = "Formatting Error",
66 [0x53] = "Read Error",
67 [0x54] = "Unsupported Format",
68 [0x55] = "No Formatting",
69 [0x56] = "Positioning lost",
70 [0x57] = "Read Length",
71 [0x60] = "Unsupported Medium",
72 [0x61] = "Medium Length Error",
73 [0x62] = "Medium removed",
74 [0x64] = "Load Check",
75 [0x65] = "Unload Check",
76 [0x70] = "Equipment Check",
77 [0x71] = "Bus out Check",
78 [0x72] = "Protocol Error",
79 [0x73] = "Interface Error",
81 [0x75] = "Halt Signal",
82 [0x90] = "Device fenced",
83 [0x91] = "Device Path fenced",
84 [0xa0] = "Volume misplaced",
85 [0xa1] = "Volume inaccessible",
86 [0xa2] = "Volume in input",
87 [0xa3] = "Volume ejected",
88 [0xa4] = "All categories reserved",
89 [0xa5] = "Duplicate Volume",
90 [0xa6] = "Library Manager Offline",
91 [0xa7] = "Library Output Station full",
92 [0xa8] = "Vision System non-operational",
93 [0xa9] = "Library Manager Equipment Check",
94 [0xaa] = "Library Equipment Check",
95 [0xab] = "All Library Cells full",
96 [0xac] = "No Cleaner Volumes in Library",
97 [0xad] = "I/O Station door open",
98 [0xae] = "Subsystem environmental alert",
101 static int crypt_supported(struct tape_device *device)
103 return TAPE390_CRYPT_SUPPORTED(TAPE_3590_CRYPT_INFO(device));
106 static int crypt_enabled(struct tape_device *device)
108 return TAPE390_CRYPT_ON(TAPE_3590_CRYPT_INFO(device));
111 static void ext_to_int_kekl(struct tape390_kekl *in,
112 struct tape3592_kekl *out)
116 memset(out, 0, sizeof(*out));
117 if (in->type == TAPE390_KEKL_TYPE_HASH)
119 if (in->type_on_tape == TAPE390_KEKL_TYPE_HASH)
121 strncpy(out->label, in->label, 64);
122 for (i = strlen(in->label); i < sizeof(out->label); i++)
124 ASCEBC(out->label, sizeof(out->label));
127 static void int_to_ext_kekl(struct tape3592_kekl *in,
128 struct tape390_kekl *out)
130 memset(out, 0, sizeof(*out));
132 out->type = TAPE390_KEKL_TYPE_HASH;
134 out->type = TAPE390_KEKL_TYPE_LABEL;
136 out->type_on_tape = TAPE390_KEKL_TYPE_HASH;
138 out->type_on_tape = TAPE390_KEKL_TYPE_LABEL;
139 memcpy(out->label, in->label, sizeof(in->label));
140 EBCASC(out->label, sizeof(in->label));
141 strstrip(out->label);
144 static void int_to_ext_kekl_pair(struct tape3592_kekl_pair *in,
145 struct tape390_kekl_pair *out)
147 if (in->count == 0) {
148 out->kekl[0].type = TAPE390_KEKL_TYPE_NONE;
149 out->kekl[0].type_on_tape = TAPE390_KEKL_TYPE_NONE;
150 out->kekl[1].type = TAPE390_KEKL_TYPE_NONE;
151 out->kekl[1].type_on_tape = TAPE390_KEKL_TYPE_NONE;
152 } else if (in->count == 1) {
153 int_to_ext_kekl(&in->kekl[0], &out->kekl[0]);
154 out->kekl[1].type = TAPE390_KEKL_TYPE_NONE;
155 out->kekl[1].type_on_tape = TAPE390_KEKL_TYPE_NONE;
156 } else if (in->count == 2) {
157 int_to_ext_kekl(&in->kekl[0], &out->kekl[0]);
158 int_to_ext_kekl(&in->kekl[1], &out->kekl[1]);
160 printk("Invalid KEKL number: %d\n", in->count);
165 static int check_ext_kekl(struct tape390_kekl *kekl)
167 if (kekl->type == TAPE390_KEKL_TYPE_NONE)
169 if (kekl->type > TAPE390_KEKL_TYPE_HASH)
171 if (kekl->type_on_tape == TAPE390_KEKL_TYPE_NONE)
173 if (kekl->type_on_tape > TAPE390_KEKL_TYPE_HASH)
175 if ((kekl->type == TAPE390_KEKL_TYPE_HASH) &&
176 (kekl->type_on_tape == TAPE390_KEKL_TYPE_LABEL))
184 static int check_ext_kekl_pair(struct tape390_kekl_pair *kekls)
186 if (check_ext_kekl(&kekls->kekl[0]))
188 if (check_ext_kekl(&kekls->kekl[1]))
199 static int tape_3592_kekl_query(struct tape_device *device,
200 struct tape390_kekl_pair *ext_kekls)
202 struct tape_request *request;
203 struct tape3592_kekl_query_order *order;
204 struct tape3592_kekl_query_data *int_kekls;
207 DBF_EVENT(6, "tape3592_kekl_query\n");
208 int_kekls = kmalloc(sizeof(*int_kekls), GFP_KERNEL|GFP_DMA);
211 request = tape_alloc_request(2, sizeof(*order));
212 if (IS_ERR(request)) {
213 rc = PTR_ERR(request);
216 order = request->cpdata;
217 memset(order,0,sizeof(*order));
219 order->max_count = 2;
220 request->op = TO_KEKL_QUERY;
221 tape_ccw_cc(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order);
222 tape_ccw_end(request->cpaddr + 1, READ_SS_DATA, sizeof(*int_kekls),
224 rc = tape_do_io(device, request);
227 int_to_ext_kekl_pair(&int_kekls->kekls, ext_kekls);
231 tape_free_request(request);
240 static int tape_3592_ioctl_kekl_query(struct tape_device *device,
244 struct tape390_kekl_pair *ext_kekls;
246 DBF_EVENT(6, "tape_3592_ioctl_kekl_query\n");
247 if (!crypt_supported(device))
249 if (!crypt_enabled(device))
251 ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL);
254 rc = tape_3592_kekl_query(device, ext_kekls);
257 if (copy_to_user((char __user *) arg, ext_kekls, sizeof(*ext_kekls))) {
267 static int tape_3590_mttell(struct tape_device *device, int mt_count);
272 static int tape_3592_kekl_set(struct tape_device *device,
273 struct tape390_kekl_pair *ext_kekls)
275 struct tape_request *request;
276 struct tape3592_kekl_set_order *order;
278 DBF_EVENT(6, "tape3592_kekl_set\n");
279 if (check_ext_kekl_pair(ext_kekls)) {
280 DBF_EVENT(6, "invalid kekls\n");
283 if (tape_3590_mttell(device, 0) != 0)
285 request = tape_alloc_request(1, sizeof(*order));
287 return PTR_ERR(request);
288 order = request->cpdata;
289 memset(order, 0, sizeof(*order));
291 order->kekls.count = 2;
292 ext_to_int_kekl(&ext_kekls->kekl[0], &order->kekls.kekl[0]);
293 ext_to_int_kekl(&ext_kekls->kekl[1], &order->kekls.kekl[1]);
294 request->op = TO_KEKL_SET;
295 tape_ccw_end(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order);
297 return tape_do_io_free(device, request);
303 static int tape_3592_ioctl_kekl_set(struct tape_device *device,
307 struct tape390_kekl_pair *ext_kekls;
309 DBF_EVENT(6, "tape_3592_ioctl_kekl_set\n");
310 if (!crypt_supported(device))
312 if (!crypt_enabled(device))
314 ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL);
317 if (copy_from_user(ext_kekls, (char __user *)arg, sizeof(*ext_kekls))) {
321 rc = tape_3592_kekl_set(device, ext_kekls);
330 static int tape_3592_enable_crypt(struct tape_device *device)
332 struct tape_request *request;
335 DBF_EVENT(6, "tape_3592_enable_crypt\n");
336 if (!crypt_supported(device))
338 request = tape_alloc_request(2, 72);
340 return PTR_ERR(request);
341 data = request->cpdata;
349 data[36 + 14] = 0x2f;
350 data[36 + 18] = 0xc3;
351 data[36 + 35] = 0x72;
352 request->op = TO_CRYPT_ON;
353 tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data);
354 tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36);
355 return tape_do_io_free(device, request);
361 static int tape_3592_disable_crypt(struct tape_device *device)
363 struct tape_request *request;
366 DBF_EVENT(6, "tape_3592_disable_crypt\n");
367 if (!crypt_supported(device))
369 request = tape_alloc_request(2, 72);
371 return PTR_ERR(request);
372 data = request->cpdata;
378 data[36 + 35] = 0x32;
380 request->op = TO_CRYPT_OFF;
381 tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data);
382 tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36);
384 return tape_do_io_free(device, request);
388 * IOCTL: Set encryption status
390 static int tape_3592_ioctl_crypt_set(struct tape_device *device,
393 struct tape390_crypt_info info;
395 DBF_EVENT(6, "tape_3592_ioctl_crypt_set\n");
396 if (!crypt_supported(device))
398 if (copy_from_user(&info, (char __user *)arg, sizeof(info)))
400 if (info.status & ~TAPE390_CRYPT_ON_MASK)
402 if (info.status & TAPE390_CRYPT_ON_MASK)
403 return tape_3592_enable_crypt(device);
405 return tape_3592_disable_crypt(device);
408 static int tape_3590_sense_medium(struct tape_device *device);
411 * IOCTL: Query enryption status
413 static int tape_3592_ioctl_crypt_query(struct tape_device *device,
416 DBF_EVENT(6, "tape_3592_ioctl_crypt_query\n");
417 if (!crypt_supported(device))
419 tape_3590_sense_medium(device);
420 if (copy_to_user((char __user *) arg, &TAPE_3590_CRYPT_INFO(device),
421 sizeof(TAPE_3590_CRYPT_INFO(device))))
428 * 3590 IOCTL Overload
431 tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
434 case TAPE390_DISPLAY: {
435 struct display_struct disp;
437 if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)))
440 return tape_std_display(device, &disp);
442 case TAPE390_KEKL_SET:
443 return tape_3592_ioctl_kekl_set(device, arg);
444 case TAPE390_KEKL_QUERY:
445 return tape_3592_ioctl_kekl_query(device, arg);
446 case TAPE390_CRYPT_SET:
447 return tape_3592_ioctl_crypt_set(device, arg);
448 case TAPE390_CRYPT_QUERY:
449 return tape_3592_ioctl_crypt_query(device, arg);
451 return -EINVAL; /* no additional ioctls */
456 * SENSE Medium: Get Sense data about medium state
459 tape_3590_sense_medium(struct tape_device *device)
461 struct tape_request *request;
463 request = tape_alloc_request(1, 128);
465 return PTR_ERR(request);
466 request->op = TO_MSEN;
467 tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata);
468 return tape_do_io_free(device, request);
472 * MTTELL: Tell block. Return the number of block relative to current file.
475 tape_3590_mttell(struct tape_device *device, int mt_count)
480 rc = tape_std_read_block_id(device, &block_id);
483 return block_id >> 32;
487 * MTSEEK: seek to the specified block.
490 tape_3590_mtseek(struct tape_device *device, int count)
492 struct tape_request *request;
494 DBF_EVENT(6, "xsee id: %x\n", count);
495 request = tape_alloc_request(3, 4);
497 return PTR_ERR(request);
498 request->op = TO_LBL;
499 tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
500 *(__u32 *) request->cpdata = count;
501 tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
502 tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
503 return tape_do_io_free(device, request);
507 * Read Opposite Error Recovery Function:
508 * Used, when Read Forward does not work
511 tape_3590_read_opposite(struct tape_device *device,
512 struct tape_request *request)
514 struct tape_3590_disc_data *data;
517 * We have allocated 4 ccws in tape_std_read, so we can now
518 * transform the request to a read backward, followed by a
519 * forward space block.
521 request->op = TO_RBA;
522 tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
523 data = device->discdata;
524 tape_ccw_cc_idal(request->cpaddr + 1, data->read_back_op,
525 device->char_data.idal_buf);
526 tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL);
527 tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL);
528 DBF_EVENT(6, "xrop ccwg\n");
533 * This should be done after an interrupt with attention bit (0x80)
536 * After a "read attention message" request there are two possible
539 * 1. A unit check is presented, when attention sense is present (e.g. when
540 * a medium has been unloaded). The attention sense comes then
541 * together with the unit check. The recovery action is either "retry"
542 * (in case there is an attention message pending) or "permanent error".
544 * 2. The attention msg is written to the "read subsystem data" buffer.
545 * In this case we probably should print it to the console.
548 tape_3590_read_attmsg(struct tape_device *device)
550 struct tape_request *request;
553 request = tape_alloc_request(3, 4096);
555 return PTR_ERR(request);
556 request->op = TO_READ_ATTMSG;
557 buf = request->cpdata;
558 buf[0] = PREP_RD_SS_DATA;
559 buf[6] = RD_ATTMSG; /* read att msg */
560 tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf);
561 tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12);
562 tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
563 return tape_do_io_free(device, request);
567 * These functions are used to schedule follow-up actions from within an
568 * interrupt context (like unsolicited interrupts).
570 struct work_handler_data {
571 struct tape_device *device;
573 struct work_struct work;
577 tape_3590_work_handler(struct work_struct *work)
579 struct work_handler_data *p =
580 container_of(work, struct work_handler_data, work);
584 tape_3590_sense_medium(p->device);
587 tape_3590_read_attmsg(p->device);
590 tape_3592_enable_crypt(p->device);
593 tape_3592_disable_crypt(p->device);
596 DBF_EVENT(3, "T3590: work handler undefined for "
597 "operation 0x%02x\n", p->op);
599 tape_put_device(p->device);
604 tape_3590_schedule_work(struct tape_device *device, enum tape_op op)
606 struct work_handler_data *p;
608 if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
611 INIT_WORK(&p->work, tape_3590_work_handler);
613 p->device = tape_get_device_reference(device);
616 schedule_work(&p->work);
620 #ifdef CONFIG_S390_TAPE_BLOCK
624 static struct tape_request *
625 tape_3590_bread(struct tape_device *device, struct request *req)
627 struct tape_request *request;
629 int count = 0, start_block;
633 struct req_iterator iter;
635 DBF_EVENT(6, "xBREDid:");
636 start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
637 DBF_EVENT(6, "start_block = %i\n", start_block);
639 rq_for_each_segment(bv, req, iter)
640 count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
642 request = tape_alloc_request(2 + count + 1, 4);
645 request->op = TO_BLOCK;
646 *(__u32 *) request->cpdata = start_block;
647 ccw = request->cpaddr;
648 ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
651 * We always setup a nop after the mode set ccw. This slot is
652 * used in tape_std_check_locate to insert a locate ccw if the
653 * current tape position doesn't match the start block to be read.
655 ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
657 rq_for_each_segment(bv, req, iter) {
658 dst = page_address(bv->bv_page) + bv->bv_offset;
659 for (off = 0; off < bv->bv_len; off += TAPEBLOCK_HSEC_SIZE) {
660 ccw->flags = CCW_FLAG_CC;
661 ccw->cmd_code = READ_FORWARD;
662 ccw->count = TAPEBLOCK_HSEC_SIZE;
663 set_normalized_cda(ccw, (void *) __pa(dst));
665 dst += TAPEBLOCK_HSEC_SIZE;
667 if (off > bv->bv_len)
670 ccw = tape_ccw_end(ccw, NOP, 0, NULL);
671 DBF_EVENT(6, "xBREDccwg\n");
676 tape_3590_free_bread(struct tape_request *request)
680 /* Last ccw is a nop and doesn't need clear_normalized_cda */
681 for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
682 if (ccw->cmd_code == READ_FORWARD)
683 clear_normalized_cda(ccw);
684 tape_free_request(request);
688 * check_locate is called just before the tape request is passed to
689 * the common io layer for execution. It has to check the current
690 * tape position and insert a locate ccw if it doesn't match the
691 * start block for the request.
694 tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
698 start_block = (__u32 *) request->cpdata;
699 if (*start_block != device->blk_data.block_position) {
700 /* Add the start offset of the file to get the real block. */
701 *start_block += device->bof;
702 tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
707 static void tape_3590_med_state_set(struct tape_device *device,
708 struct tape_3590_med_sense *sense)
710 struct tape390_crypt_info *c_info;
712 c_info = &TAPE_3590_CRYPT_INFO(device);
714 DBF_EVENT(6, "medium state: %x:%x\n", sense->macst, sense->masst);
715 switch (sense->macst) {
719 tape_med_state_set(device, MS_UNLOADED);
720 TAPE_3590_CRYPT_INFO(device).medium_status = 0;
724 tape_med_state_set(device, MS_LOADED);
727 tape_med_state_set(device, MS_UNKNOWN);
730 c_info->medium_status |= TAPE390_MEDIUM_LOADED_MASK;
731 if (sense->flags & MSENSE_CRYPT_MASK) {
732 DBF_EVENT(6, "Medium is encrypted (%04x)\n", sense->flags);
733 c_info->medium_status |= TAPE390_MEDIUM_ENCRYPTED_MASK;
735 DBF_EVENT(6, "Medium is not encrypted %04x\n", sense->flags);
736 c_info->medium_status &= ~TAPE390_MEDIUM_ENCRYPTED_MASK;
741 * The done handler is called at device/channel end and wakes up the sleeping
745 tape_3590_done(struct tape_device *device, struct tape_request *request)
747 struct tape_3590_disc_data *disc_data;
749 DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
750 disc_data = device->discdata;
752 switch (request->op) {
766 tape_med_state_set(device, MS_LOADED);
769 tape_med_state_set(device, MS_UNLOADED);
770 tape_3590_schedule_work(device, TO_CRYPT_OFF);
773 tape_3590_med_state_set(device, request->cpdata);
776 TAPE_3590_CRYPT_INFO(device).status
777 |= TAPE390_CRYPT_ON_MASK;
778 *(device->modeset_byte) |= 0x03;
781 TAPE_3590_CRYPT_INFO(device).status
782 &= ~TAPE390_CRYPT_ON_MASK;
783 *(device->modeset_byte) &= ~0x03;
785 case TO_RBI: /* RBI seems to succeed even without medium loaded. */
786 case TO_NOP: /* Same to NOP. */
798 return TAPE_IO_SUCCESS;
802 * This fuction is called, when error recovery was successfull
805 tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
807 DBF_EVENT(3, "Error Recovery successful for %s\n",
808 tape_op_verbose[request->op]);
809 return tape_3590_done(device, request);
813 * This fuction is called, when error recovery was not successfull
816 tape_3590_erp_failed(struct tape_device *device, struct tape_request *request,
817 struct irb *irb, int rc)
819 DBF_EVENT(3, "Error Recovery failed for %s\n",
820 tape_op_verbose[request->op]);
821 tape_dump_sense_dbf(device, request, irb);
826 * Error Recovery do retry
829 tape_3590_erp_retry(struct tape_device *device, struct tape_request *request,
832 DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]);
833 tape_dump_sense_dbf(device, request, irb);
834 return TAPE_IO_RETRY;
838 * Handle unsolicited interrupts
841 tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
843 if (irb->scsw.cmd.dstat == DEV_STAT_CHN_END)
844 /* Probably result of halt ssch */
845 return TAPE_IO_PENDING;
846 else if (irb->scsw.cmd.dstat == 0x85)
848 DBF_EVENT(3, "unsol.irq! tape ready: %08x\n", device->cdev_id);
849 else if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) {
850 tape_3590_schedule_work(device, TO_READ_ATTMSG);
852 DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
853 tape_dump_sense_dbf(device, NULL, irb);
855 /* check medium state */
856 tape_3590_schedule_work(device, TO_MSEN);
857 return TAPE_IO_SUCCESS;
861 * Basic Recovery routine
864 tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
865 struct irb *irb, int rc)
867 struct tape_3590_sense *sense;
869 sense = (struct tape_3590_sense *) irb->ecw;
871 switch (sense->bra) {
873 return tape_3590_erp_failed(device, request, irb, rc);
875 return tape_3590_erp_succeded(device, request);
877 return tape_3590_erp_retry(device, request, irb);
879 return tape_3590_erp_failed(device, request, irb, rc);
887 * RDL: Read Device (buffered) log
890 tape_3590_erp_read_buf_log(struct tape_device *device,
891 struct tape_request *request, struct irb *irb)
894 * We just do the basic error recovery at the moment (retry).
895 * Perhaps in the future, we read the log and dump it somewhere...
897 return tape_3590_erp_basic(device, request, irb, -EIO);
904 tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
908 * This error recovery should swap the tapes
909 * if the original has a problem. The operation
910 * should proceed with the new tape... this
911 * should probably be done in user space!
913 dev_warn (&device->cdev->dev, "The tape medium must be loaded into a "
914 "different tape unit\n");
915 return tape_3590_erp_basic(device, request, irb, -EIO);
922 tape_3590_erp_long_busy(struct tape_device *device,
923 struct tape_request *request, struct irb *irb)
925 DBF_EVENT(6, "Device is busy\n");
926 return TAPE_IO_LONG_BUSY;
930 * SPI: Special Intercept
933 tape_3590_erp_special_interrupt(struct tape_device *device,
934 struct tape_request *request, struct irb *irb)
936 return tape_3590_erp_basic(device, request, irb, -EIO);
940 * RDA: Read Alternate
943 tape_3590_erp_read_alternate(struct tape_device *device,
944 struct tape_request *request, struct irb *irb)
946 struct tape_3590_disc_data *data;
949 * The issued Read Backward or Read Previous command is not
950 * supported by the device
951 * The recovery action should be to issue another command:
952 * Read Revious: if Read Backward is not supported
953 * Read Backward: if Read Previous is not supported
955 data = device->discdata;
956 if (data->read_back_op == READ_PREVIOUS) {
957 DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
959 data->read_back_op = READ_BACKWARD;
961 DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
963 data->read_back_op = READ_PREVIOUS;
965 tape_3590_read_opposite(device, request);
966 return tape_3590_erp_retry(device, request, irb);
970 * Error Recovery read opposite
973 tape_3590_erp_read_opposite(struct tape_device *device,
974 struct tape_request *request, struct irb *irb)
976 switch (request->op) {
979 * We did read forward, but the data could not be read.
980 * We will read backward and then skip forward again.
982 tape_3590_read_opposite(device, request);
983 return tape_3590_erp_retry(device, request, irb);
985 /* We tried to read forward and backward, but hat no success */
986 return tape_3590_erp_failed(device, request, irb, -EIO);
989 return tape_3590_erp_failed(device, request, irb, -EIO);
994 * Print an MIM (Media Information Message) (message code f0)
997 tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
999 struct tape_3590_sense *sense;
1000 char *exception, *service;
1002 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1003 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1005 if (!exception || !service)
1008 sense = (struct tape_3590_sense *) irb->ecw;
1009 /* Exception Message */
1010 switch (sense->fmt.f70.emc) {
1012 snprintf(exception, BUFSIZE, "Data degraded");
1015 snprintf(exception, BUFSIZE, "Data degraded in partion %i",
1019 snprintf(exception, BUFSIZE, "Medium degraded");
1022 snprintf(exception, BUFSIZE, "Medium degraded in partition %i",
1026 snprintf(exception, BUFSIZE, "Block 0 Error");
1029 snprintf(exception, BUFSIZE, "Medium Exception 0x%02x",
1033 snprintf(exception, BUFSIZE, "0x%02x",
1034 sense->fmt.f70.emc);
1037 /* Service Message */
1038 switch (sense->fmt.f70.smc) {
1040 snprintf(service, BUFSIZE, "Reference Media maintenance "
1041 "procedure %i", sense->fmt.f70.md);
1044 snprintf(service, BUFSIZE, "0x%02x",
1045 sense->fmt.f70.smc);
1049 dev_warn (&device->cdev->dev, "Tape media information: exception %s, "
1050 "service %s\n", exception, service);
1058 * Print an I/O Subsystem Service Information Message (message code f1)
1061 tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
1063 struct tape_3590_sense *sense;
1064 char *exception, *service;
1066 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1067 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1069 if (!exception || !service)
1072 sense = (struct tape_3590_sense *) irb->ecw;
1073 /* Exception Message */
1074 switch (sense->fmt.f71.emc) {
1076 snprintf(exception, BUFSIZE, "Effect of failure is unknown");
1079 snprintf(exception, BUFSIZE, "CU Exception - no performance "
1083 snprintf(exception, BUFSIZE, "CU Exception on channel "
1084 "interface 0x%02x", sense->fmt.f71.md[0]);
1087 snprintf(exception, BUFSIZE, "CU Exception on device path "
1088 "0x%02x", sense->fmt.f71.md[0]);
1091 snprintf(exception, BUFSIZE, "CU Exception on library path "
1092 "0x%02x", sense->fmt.f71.md[0]);
1095 snprintf(exception, BUFSIZE, "CU Exception on node 0x%02x",
1096 sense->fmt.f71.md[0]);
1099 snprintf(exception, BUFSIZE, "CU Exception on partition "
1100 "0x%02x", sense->fmt.f71.md[0]);
1103 snprintf(exception, BUFSIZE, "0x%02x",
1104 sense->fmt.f71.emc);
1106 /* Service Message */
1107 switch (sense->fmt.f71.smc) {
1109 snprintf(service, BUFSIZE, "Repair impact is unknown");
1112 snprintf(service, BUFSIZE, "Repair will not impact cu "
1116 if (sense->fmt.f71.mdf == 0)
1117 snprintf(service, BUFSIZE, "Repair will disable node "
1118 "0x%x on CU", sense->fmt.f71.md[1]);
1120 snprintf(service, BUFSIZE, "Repair will disable "
1121 "nodes (0x%x-0x%x) on CU", sense->fmt.f71.md[1],
1122 sense->fmt.f71.md[2]);
1125 if (sense->fmt.f71.mdf == 0)
1126 snprintf(service, BUFSIZE, "Repair will disable "
1127 "channel path 0x%x on CU",
1128 sense->fmt.f71.md[1]);
1130 snprintf(service, BUFSIZE, "Repair will disable cannel"
1131 " paths (0x%x-0x%x) on CU",
1132 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1135 if (sense->fmt.f71.mdf == 0)
1136 snprintf(service, BUFSIZE, "Repair will disable device"
1137 " path 0x%x on CU", sense->fmt.f71.md[1]);
1139 snprintf(service, BUFSIZE, "Repair will disable device"
1140 " paths (0x%x-0x%x) on CU",
1141 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1144 if (sense->fmt.f71.mdf == 0)
1145 snprintf(service, BUFSIZE, "Repair will disable "
1146 "library path 0x%x on CU",
1147 sense->fmt.f71.md[1]);
1149 snprintf(service, BUFSIZE, "Repair will disable "
1150 "library paths (0x%x-0x%x) on CU",
1151 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1154 snprintf(service, BUFSIZE, "Repair will disable access to CU");
1157 snprintf(service, BUFSIZE, "0x%02x",
1158 sense->fmt.f71.smc);
1161 dev_warn (&device->cdev->dev, "I/O subsystem information: exception"
1162 " %s, service %s\n", exception, service);
1169 * Print an Device Subsystem Service Information Message (message code f2)
1172 tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
1174 struct tape_3590_sense *sense;
1175 char *exception, *service;
1177 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1178 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1180 if (!exception || !service)
1183 sense = (struct tape_3590_sense *) irb->ecw;
1184 /* Exception Message */
1185 switch (sense->fmt.f71.emc) {
1187 snprintf(exception, BUFSIZE, "Effect of failure is unknown");
1190 snprintf(exception, BUFSIZE, "DV Exception - no performance"
1194 snprintf(exception, BUFSIZE, "DV Exception on channel "
1195 "interface 0x%02x", sense->fmt.f71.md[0]);
1198 snprintf(exception, BUFSIZE, "DV Exception on loader 0x%02x",
1199 sense->fmt.f71.md[0]);
1202 snprintf(exception, BUFSIZE, "DV Exception on message display"
1203 " 0x%02x", sense->fmt.f71.md[0]);
1206 snprintf(exception, BUFSIZE, "DV Exception in tape path");
1209 snprintf(exception, BUFSIZE, "DV Exception in drive");
1212 snprintf(exception, BUFSIZE, "0x%02x",
1213 sense->fmt.f71.emc);
1215 /* Service Message */
1216 switch (sense->fmt.f71.smc) {
1218 snprintf(service, BUFSIZE, "Repair impact is unknown");
1221 snprintf(service, BUFSIZE, "Repair will not impact device "
1225 if (sense->fmt.f71.mdf == 0)
1226 snprintf(service, BUFSIZE, "Repair will disable "
1227 "channel path 0x%x on DV",
1228 sense->fmt.f71.md[1]);
1230 snprintf(service, BUFSIZE, "Repair will disable "
1231 "channel path (0x%x-0x%x) on DV",
1232 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1235 if (sense->fmt.f71.mdf == 0)
1236 snprintf(service, BUFSIZE, "Repair will disable "
1237 "interface 0x%x on DV", sense->fmt.f71.md[1]);
1239 snprintf(service, BUFSIZE, "Repair will disable "
1240 "interfaces (0x%x-0x%x) on DV",
1241 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1244 if (sense->fmt.f71.mdf == 0)
1245 snprintf(service, BUFSIZE, "Repair will disable loader"
1246 " 0x%x on DV", sense->fmt.f71.md[1]);
1248 snprintf(service, BUFSIZE, "Repair will disable loader"
1249 " (0x%x-0x%x) on DV",
1250 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1253 snprintf(service, BUFSIZE, "Repair will disable access to DV");
1256 if (sense->fmt.f71.mdf == 0)
1257 snprintf(service, BUFSIZE, "Repair will disable "
1258 "message display 0x%x on DV",
1259 sense->fmt.f71.md[1]);
1261 snprintf(service, BUFSIZE, "Repair will disable "
1262 "message displays (0x%x-0x%x) on DV",
1263 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1266 snprintf(service, BUFSIZE, "Clean DV");
1269 snprintf(service, BUFSIZE, "0x%02x",
1270 sense->fmt.f71.smc);
1273 dev_warn (&device->cdev->dev, "Device subsystem information: exception"
1274 " %s, service %s\n", exception, service);
1281 * Print standard ERA Message
1284 tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
1286 struct tape_3590_sense *sense;
1288 sense = (struct tape_3590_sense *) irb->ecw;
1291 if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
1292 if (tape_3590_msg[sense->mc] != NULL)
1293 dev_warn (&device->cdev->dev, "The tape unit has "
1294 "issued sense message %s\n",
1295 tape_3590_msg[sense->mc]);
1297 dev_warn (&device->cdev->dev, "The tape unit has "
1298 "issued an unknown sense message code 0x%x\n",
1302 if (sense->mc == 0xf0) {
1303 /* Standard Media Information Message */
1304 dev_warn (&device->cdev->dev, "MIM SEV=%i, MC=%02x, ES=%x/%x, "
1305 "RC=%02x-%04x-%02x\n", sense->fmt.f70.sev, sense->mc,
1306 sense->fmt.f70.emc, sense->fmt.f70.smc,
1307 sense->fmt.f70.refcode, sense->fmt.f70.mid,
1308 sense->fmt.f70.fid);
1309 tape_3590_print_mim_msg_f0(device, irb);
1312 if (sense->mc == 0xf1) {
1313 /* Standard I/O Subsystem Service Information Message */
1314 dev_warn (&device->cdev->dev, "IOSIM SEV=%i, DEVTYPE=3590/%02x,"
1315 " MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
1316 sense->fmt.f71.sev, device->cdev->id.dev_model,
1317 sense->mc, sense->fmt.f71.emc, sense->fmt.f71.smc,
1318 sense->fmt.f71.refcode1, sense->fmt.f71.refcode2,
1319 sense->fmt.f71.refcode3);
1320 tape_3590_print_io_sim_msg_f1(device, irb);
1323 if (sense->mc == 0xf2) {
1324 /* Standard Device Service Information Message */
1325 dev_warn (&device->cdev->dev, "DEVSIM SEV=%i, DEVTYPE=3590/%02x"
1326 ", MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
1327 sense->fmt.f71.sev, device->cdev->id.dev_model,
1328 sense->mc, sense->fmt.f71.emc, sense->fmt.f71.smc,
1329 sense->fmt.f71.refcode1, sense->fmt.f71.refcode2,
1330 sense->fmt.f71.refcode3);
1331 tape_3590_print_dev_sim_msg_f2(device, irb);
1334 if (sense->mc == 0xf3) {
1335 /* Standard Library Service Information Message */
1338 dev_warn (&device->cdev->dev, "The tape unit has issued an unknown "
1339 "sense message code %x\n", sense->mc);
1342 static int tape_3590_crypt_error(struct tape_device *device,
1343 struct tape_request *request, struct irb *irb)
1351 sense = ((struct tape_3590_sense *) irb->ecw)->fmt.data;
1352 bus_id = dev_name(&device->cdev->dev);
1354 drv_rc = *((u32*) &sense[5]) & 0xffffff;
1356 ekm_rc2 = *((u16*) &sense[10]);
1357 if ((cu_rc == 0) && (ekm_rc2 == 0xee31))
1358 /* key not defined on EKM */
1359 return tape_3590_erp_basic(device, request, irb, -EKEYREJECTED);
1360 if ((cu_rc == 1) || (cu_rc == 2))
1361 /* No connection to EKM */
1362 return tape_3590_erp_basic(device, request, irb, -ENOTCONN);
1364 dev_err (&device->cdev->dev, "The tape unit failed to obtain the "
1365 "encryption key from EKM\n");
1367 return tape_3590_erp_basic(device, request, irb, -ENOKEY);
1371 * 3590 error Recovery routine:
1372 * If possible, it tries to recover from the error. If this is not possible,
1373 * inform the user about the problem.
1376 tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
1379 struct tape_3590_sense *sense;
1382 #ifdef CONFIG_S390_TAPE_BLOCK
1383 if (request->op == TO_BLOCK) {
1385 * Recovery for block device requests. Set the block_position
1386 * to something invalid and retry.
1388 device->blk_data.block_position = -1;
1389 if (request->retries-- <= 0)
1390 return tape_3590_erp_failed(device, request, irb, -EIO);
1392 return tape_3590_erp_retry(device, request, irb);
1396 sense = (struct tape_3590_sense *) irb->ecw;
1398 DBF_EVENT(6, "Unit Check: RQC = %x\n", sense->rc_rqc);
1401 * First check all RC-QRCs where we want to do something special
1402 * - "break": basic error recovery is done
1403 * - "goto out:": just print error message if available
1406 switch (sense->rc_rqc) {
1409 tape_3590_print_era_msg(device, irb);
1410 return tape_3590_erp_read_buf_log(device, request, irb);
1413 tape_3590_print_era_msg(device, irb);
1414 return tape_3590_erp_read_alternate(device, request, irb);
1418 tape_3590_print_era_msg(device, irb);
1419 return tape_3590_erp_special_interrupt(device, request, irb);
1421 return tape_3590_crypt_error(device, request, irb);
1424 DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
1426 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1428 DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
1430 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1432 DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
1433 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1436 DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
1438 return tape_3590_erp_basic(device, request, irb, -EIO);
1440 DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
1442 tape_med_state_set(device, MS_UNLOADED);
1443 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1444 return tape_3590_erp_basic(device, request, irb, 0);
1448 * print additional msg since default msg
1449 * "device intervention" is not very meaningfull
1451 tape_med_state_set(device, MS_UNLOADED);
1452 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1453 return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
1454 case 0x4012: /* Device Long Busy */
1455 /* XXX: Also use long busy handling here? */
1456 DBF_EVENT(6, "(%08x): LONG BUSY\n", device->cdev_id);
1457 tape_3590_print_era_msg(device, irb);
1458 return tape_3590_erp_basic(device, request, irb, -EBUSY);
1460 DBF_EVENT(6, "(%08x): Crypto LONG BUSY\n", device->cdev_id);
1461 return tape_3590_erp_long_busy(device, request, irb);
1464 if (sense->rac == 0xd0) {
1466 tape_3590_print_era_msg(device, irb);
1467 return tape_3590_erp_swap(device, request, irb);
1469 if (sense->rac == 0x26) {
1471 tape_3590_print_era_msg(device, irb);
1472 return tape_3590_erp_read_opposite(device, request,
1475 return tape_3590_erp_basic(device, request, irb, -EIO);
1482 tape_3590_print_era_msg(device, irb);
1483 return tape_3590_erp_swap(device, request, irb);
1487 return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
1491 tape_med_state_set(device, MS_UNLOADED);
1492 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1493 return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
1496 return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
1499 return tape_3590_erp_basic(device, request, irb, -EPERM);
1501 dev_warn (&device->cdev->dev, "A different host has privileged"
1502 " access to the tape unit\n");
1503 return tape_3590_erp_basic(device, request, irb, -EPERM);
1505 return tape_3590_erp_basic(device, request, irb, -EIO);
1510 * 3590 interrupt handler:
1513 tape_3590_irq(struct tape_device *device, struct tape_request *request,
1516 if (request == NULL)
1517 return tape_3590_unsolicited_irq(device, irb);
1519 if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) &&
1520 (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) &&
1521 (request->op == TO_WRI)) {
1522 /* Write at end of volume */
1523 DBF_EVENT(2, "End of volume\n");
1524 return tape_3590_erp_failed(device, request, irb, -ENOSPC);
1527 if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)
1528 return tape_3590_unit_check(device, request, irb);
1530 if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) {
1531 if (irb->scsw.cmd.dstat == DEV_STAT_UNIT_EXCEP) {
1532 if (request->op == TO_FSB || request->op == TO_BSB)
1535 DBF_EVENT(5, "Unit Exception!\n");
1538 return tape_3590_done(device, request);
1541 if (irb->scsw.cmd.dstat & DEV_STAT_CHN_END) {
1542 DBF_EVENT(2, "cannel end\n");
1543 return TAPE_IO_PENDING;
1546 if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) {
1547 DBF_EVENT(2, "Unit Attention when busy..\n");
1548 return TAPE_IO_PENDING;
1551 DBF_EVENT(6, "xunknownirq\n");
1552 tape_dump_sense_dbf(device, request, irb);
1553 return TAPE_IO_STOP;
1557 static int tape_3590_read_dev_chars(struct tape_device *device,
1558 struct tape_3590_rdc_data *rdc_data)
1561 struct tape_request *request;
1563 request = tape_alloc_request(1, sizeof(*rdc_data));
1564 if (IS_ERR(request))
1565 return PTR_ERR(request);
1566 request->op = TO_RDC;
1567 tape_ccw_end(request->cpaddr, CCW_CMD_RDC, sizeof(*rdc_data),
1569 rc = tape_do_io(device, request);
1571 memcpy(rdc_data, request->cpdata, sizeof(*rdc_data));
1572 tape_free_request(request);
1577 * Setup device function
1580 tape_3590_setup_device(struct tape_device *device)
1583 struct tape_3590_disc_data *data;
1584 struct tape_3590_rdc_data *rdc_data;
1586 DBF_EVENT(6, "3590 device setup\n");
1587 data = kzalloc(sizeof(struct tape_3590_disc_data), GFP_KERNEL | GFP_DMA);
1590 data->read_back_op = READ_PREVIOUS;
1591 device->discdata = data;
1593 rdc_data = kmalloc(sizeof(*rdc_data), GFP_KERNEL | GFP_DMA);
1598 rc = tape_3590_read_dev_chars(device, rdc_data);
1600 DBF_LH(3, "Read device characteristics failed!\n");
1603 rc = tape_std_assign(device);
1606 if (rdc_data->data[31] == 0x13) {
1607 data->crypt_info.capability |= TAPE390_CRYPT_SUPPORTED_MASK;
1608 tape_3592_disable_crypt(device);
1610 DBF_EVENT(6, "Device has NO crypto support\n");
1612 /* Try to find out if medium is loaded */
1613 rc = tape_3590_sense_medium(device);
1615 DBF_LH(3, "3590 medium sense returned %d\n", rc);
1628 * Cleanup device function
1631 tape_3590_cleanup_device(struct tape_device *device)
1633 flush_scheduled_work();
1634 tape_std_unassign(device);
1636 kfree(device->discdata);
1637 device->discdata = NULL;
1641 * List of 3590 magnetic tape commands.
1643 static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
1644 [MTRESET] = tape_std_mtreset,
1645 [MTFSF] = tape_std_mtfsf,
1646 [MTBSF] = tape_std_mtbsf,
1647 [MTFSR] = tape_std_mtfsr,
1648 [MTBSR] = tape_std_mtbsr,
1649 [MTWEOF] = tape_std_mtweof,
1650 [MTREW] = tape_std_mtrew,
1651 [MTOFFL] = tape_std_mtoffl,
1652 [MTNOP] = tape_std_mtnop,
1653 [MTRETEN] = tape_std_mtreten,
1654 [MTBSFM] = tape_std_mtbsfm,
1655 [MTFSFM] = tape_std_mtfsfm,
1656 [MTEOM] = tape_std_mteom,
1657 [MTERASE] = tape_std_mterase,
1661 [MTSETBLK] = tape_std_mtsetblk,
1662 [MTSETDENSITY] = NULL,
1663 [MTSEEK] = tape_3590_mtseek,
1664 [MTTELL] = tape_3590_mttell,
1665 [MTSETDRVBUFFER] = NULL,
1671 [MTLOAD] = tape_std_mtload,
1672 [MTUNLOAD] = tape_std_mtunload,
1673 [MTCOMPRESSION] = tape_std_mtcompression,
1679 * Tape discipline structure for 3590.
1681 static struct tape_discipline tape_discipline_3590 = {
1682 .owner = THIS_MODULE,
1683 .setup_device = tape_3590_setup_device,
1684 .cleanup_device = tape_3590_cleanup_device,
1685 .process_eov = tape_std_process_eov,
1686 .irq = tape_3590_irq,
1687 .read_block = tape_std_read_block,
1688 .write_block = tape_std_write_block,
1689 #ifdef CONFIG_S390_TAPE_BLOCK
1690 .bread = tape_3590_bread,
1691 .free_bread = tape_3590_free_bread,
1692 .check_locate = tape_3590_check_locate,
1694 .ioctl_fn = tape_3590_ioctl,
1695 .mtop_array = tape_3590_mtop
1698 static struct ccw_device_id tape_3590_ids[] = {
1699 {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
1700 {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592},
1701 { /* end of list */ }
1705 tape_3590_online(struct ccw_device *cdev)
1707 return tape_generic_online(cdev->dev.driver_data,
1708 &tape_discipline_3590);
1712 tape_3590_offline(struct ccw_device *cdev)
1714 return tape_generic_offline(cdev->dev.driver_data);
1717 static struct ccw_driver tape_3590_driver = {
1718 .name = "tape_3590",
1719 .owner = THIS_MODULE,
1720 .ids = tape_3590_ids,
1721 .probe = tape_generic_probe,
1722 .remove = tape_generic_remove,
1723 .set_offline = tape_3590_offline,
1724 .set_online = tape_3590_online,
1728 * Setup discipline structure.
1731 tape_3590_init(void)
1735 TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
1736 debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
1737 #ifdef DBF_LIKE_HELL
1738 debug_set_level(TAPE_DBF_AREA, 6);
1741 DBF_EVENT(3, "3590 init\n");
1742 /* Register driver for 3590 tapes. */
1743 rc = ccw_driver_register(&tape_3590_driver);
1745 DBF_EVENT(3, "3590 init failed\n");
1747 DBF_EVENT(3, "3590 registered\n");
1752 tape_3590_exit(void)
1754 ccw_driver_unregister(&tape_3590_driver);
1756 debug_unregister(TAPE_DBF_AREA);
1759 MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
1760 MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
1761 MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
1762 MODULE_LICENSE("GPL");
1764 module_init(tape_3590_init);
1765 module_exit(tape_3590_exit);