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 BUG_ON(off > bv->bv_len);
669 ccw = tape_ccw_end(ccw, NOP, 0, NULL);
670 DBF_EVENT(6, "xBREDccwg\n");
675 tape_3590_free_bread(struct tape_request *request)
679 /* Last ccw is a nop and doesn't need clear_normalized_cda */
680 for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
681 if (ccw->cmd_code == READ_FORWARD)
682 clear_normalized_cda(ccw);
683 tape_free_request(request);
687 * check_locate is called just before the tape request is passed to
688 * the common io layer for execution. It has to check the current
689 * tape position and insert a locate ccw if it doesn't match the
690 * start block for the request.
693 tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
697 start_block = (__u32 *) request->cpdata;
698 if (*start_block != device->blk_data.block_position) {
699 /* Add the start offset of the file to get the real block. */
700 *start_block += device->bof;
701 tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
706 static void tape_3590_med_state_set(struct tape_device *device,
707 struct tape_3590_med_sense *sense)
709 struct tape390_crypt_info *c_info;
711 c_info = &TAPE_3590_CRYPT_INFO(device);
713 DBF_EVENT(6, "medium state: %x:%x\n", sense->macst, sense->masst);
714 switch (sense->macst) {
718 tape_med_state_set(device, MS_UNLOADED);
719 TAPE_3590_CRYPT_INFO(device).medium_status = 0;
723 tape_med_state_set(device, MS_LOADED);
726 tape_med_state_set(device, MS_UNKNOWN);
729 c_info->medium_status |= TAPE390_MEDIUM_LOADED_MASK;
730 if (sense->flags & MSENSE_CRYPT_MASK) {
731 DBF_EVENT(6, "Medium is encrypted (%04x)\n", sense->flags);
732 c_info->medium_status |= TAPE390_MEDIUM_ENCRYPTED_MASK;
734 DBF_EVENT(6, "Medium is not encrypted %04x\n", sense->flags);
735 c_info->medium_status &= ~TAPE390_MEDIUM_ENCRYPTED_MASK;
740 * The done handler is called at device/channel end and wakes up the sleeping
744 tape_3590_done(struct tape_device *device, struct tape_request *request)
746 struct tape_3590_disc_data *disc_data;
748 DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
749 disc_data = device->discdata;
751 switch (request->op) {
765 tape_med_state_set(device, MS_LOADED);
768 tape_med_state_set(device, MS_UNLOADED);
769 tape_3590_schedule_work(device, TO_CRYPT_OFF);
772 tape_3590_med_state_set(device, request->cpdata);
775 TAPE_3590_CRYPT_INFO(device).status
776 |= TAPE390_CRYPT_ON_MASK;
777 *(device->modeset_byte) |= 0x03;
780 TAPE_3590_CRYPT_INFO(device).status
781 &= ~TAPE390_CRYPT_ON_MASK;
782 *(device->modeset_byte) &= ~0x03;
784 case TO_RBI: /* RBI seems to succeed even without medium loaded. */
785 case TO_NOP: /* Same to NOP. */
797 return TAPE_IO_SUCCESS;
801 * This fuction is called, when error recovery was successfull
804 tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
806 DBF_EVENT(3, "Error Recovery successful for %s\n",
807 tape_op_verbose[request->op]);
808 return tape_3590_done(device, request);
812 * This fuction is called, when error recovery was not successfull
815 tape_3590_erp_failed(struct tape_device *device, struct tape_request *request,
816 struct irb *irb, int rc)
818 DBF_EVENT(3, "Error Recovery failed for %s\n",
819 tape_op_verbose[request->op]);
820 tape_dump_sense_dbf(device, request, irb);
825 * Error Recovery do retry
828 tape_3590_erp_retry(struct tape_device *device, struct tape_request *request,
831 DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]);
832 tape_dump_sense_dbf(device, request, irb);
833 return TAPE_IO_RETRY;
837 * Handle unsolicited interrupts
840 tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
842 if (irb->scsw.cmd.dstat == DEV_STAT_CHN_END)
843 /* Probably result of halt ssch */
844 return TAPE_IO_PENDING;
845 else if (irb->scsw.cmd.dstat == 0x85)
847 DBF_EVENT(3, "unsol.irq! tape ready: %08x\n", device->cdev_id);
848 else if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) {
849 tape_3590_schedule_work(device, TO_READ_ATTMSG);
851 DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
852 tape_dump_sense_dbf(device, NULL, irb);
854 /* check medium state */
855 tape_3590_schedule_work(device, TO_MSEN);
856 return TAPE_IO_SUCCESS;
860 * Basic Recovery routine
863 tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
864 struct irb *irb, int rc)
866 struct tape_3590_sense *sense;
868 sense = (struct tape_3590_sense *) irb->ecw;
870 switch (sense->bra) {
872 return tape_3590_erp_failed(device, request, irb, rc);
874 return tape_3590_erp_succeded(device, request);
876 return tape_3590_erp_retry(device, request, irb);
878 return tape_3590_erp_failed(device, request, irb, rc);
886 * RDL: Read Device (buffered) log
889 tape_3590_erp_read_buf_log(struct tape_device *device,
890 struct tape_request *request, struct irb *irb)
893 * We just do the basic error recovery at the moment (retry).
894 * Perhaps in the future, we read the log and dump it somewhere...
896 return tape_3590_erp_basic(device, request, irb, -EIO);
903 tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
907 * This error recovery should swap the tapes
908 * if the original has a problem. The operation
909 * should proceed with the new tape... this
910 * should probably be done in user space!
912 dev_warn (&device->cdev->dev, "The tape medium must be loaded into a "
913 "different tape unit\n");
914 return tape_3590_erp_basic(device, request, irb, -EIO);
921 tape_3590_erp_long_busy(struct tape_device *device,
922 struct tape_request *request, struct irb *irb)
924 DBF_EVENT(6, "Device is busy\n");
925 return TAPE_IO_LONG_BUSY;
929 * SPI: Special Intercept
932 tape_3590_erp_special_interrupt(struct tape_device *device,
933 struct tape_request *request, struct irb *irb)
935 return tape_3590_erp_basic(device, request, irb, -EIO);
939 * RDA: Read Alternate
942 tape_3590_erp_read_alternate(struct tape_device *device,
943 struct tape_request *request, struct irb *irb)
945 struct tape_3590_disc_data *data;
948 * The issued Read Backward or Read Previous command is not
949 * supported by the device
950 * The recovery action should be to issue another command:
951 * Read Revious: if Read Backward is not supported
952 * Read Backward: if Read Previous is not supported
954 data = device->discdata;
955 if (data->read_back_op == READ_PREVIOUS) {
956 DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
958 data->read_back_op = READ_BACKWARD;
960 DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
962 data->read_back_op = READ_PREVIOUS;
964 tape_3590_read_opposite(device, request);
965 return tape_3590_erp_retry(device, request, irb);
969 * Error Recovery read opposite
972 tape_3590_erp_read_opposite(struct tape_device *device,
973 struct tape_request *request, struct irb *irb)
975 switch (request->op) {
978 * We did read forward, but the data could not be read.
979 * We will read backward and then skip forward again.
981 tape_3590_read_opposite(device, request);
982 return tape_3590_erp_retry(device, request, irb);
984 /* We tried to read forward and backward, but hat no success */
985 return tape_3590_erp_failed(device, request, irb, -EIO);
988 return tape_3590_erp_failed(device, request, irb, -EIO);
993 * Print an MIM (Media Information Message) (message code f0)
996 tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
998 struct tape_3590_sense *sense;
999 char *exception, *service;
1001 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1002 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1004 if (!exception || !service)
1007 sense = (struct tape_3590_sense *) irb->ecw;
1008 /* Exception Message */
1009 switch (sense->fmt.f70.emc) {
1011 snprintf(exception, BUFSIZE, "Data degraded");
1014 snprintf(exception, BUFSIZE, "Data degraded in partion %i",
1018 snprintf(exception, BUFSIZE, "Medium degraded");
1021 snprintf(exception, BUFSIZE, "Medium degraded in partition %i",
1025 snprintf(exception, BUFSIZE, "Block 0 Error");
1028 snprintf(exception, BUFSIZE, "Medium Exception 0x%02x",
1032 snprintf(exception, BUFSIZE, "0x%02x",
1033 sense->fmt.f70.emc);
1036 /* Service Message */
1037 switch (sense->fmt.f70.smc) {
1039 snprintf(service, BUFSIZE, "Reference Media maintenance "
1040 "procedure %i", sense->fmt.f70.md);
1043 snprintf(service, BUFSIZE, "0x%02x",
1044 sense->fmt.f70.smc);
1048 dev_warn (&device->cdev->dev, "Tape media information: exception %s, "
1049 "service %s\n", exception, service);
1057 * Print an I/O Subsystem Service Information Message (message code f1)
1060 tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
1062 struct tape_3590_sense *sense;
1063 char *exception, *service;
1065 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1066 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1068 if (!exception || !service)
1071 sense = (struct tape_3590_sense *) irb->ecw;
1072 /* Exception Message */
1073 switch (sense->fmt.f71.emc) {
1075 snprintf(exception, BUFSIZE, "Effect of failure is unknown");
1078 snprintf(exception, BUFSIZE, "CU Exception - no performance "
1082 snprintf(exception, BUFSIZE, "CU Exception on channel "
1083 "interface 0x%02x", sense->fmt.f71.md[0]);
1086 snprintf(exception, BUFSIZE, "CU Exception on device path "
1087 "0x%02x", sense->fmt.f71.md[0]);
1090 snprintf(exception, BUFSIZE, "CU Exception on library path "
1091 "0x%02x", sense->fmt.f71.md[0]);
1094 snprintf(exception, BUFSIZE, "CU Exception on node 0x%02x",
1095 sense->fmt.f71.md[0]);
1098 snprintf(exception, BUFSIZE, "CU Exception on partition "
1099 "0x%02x", sense->fmt.f71.md[0]);
1102 snprintf(exception, BUFSIZE, "0x%02x",
1103 sense->fmt.f71.emc);
1105 /* Service Message */
1106 switch (sense->fmt.f71.smc) {
1108 snprintf(service, BUFSIZE, "Repair impact is unknown");
1111 snprintf(service, BUFSIZE, "Repair will not impact cu "
1115 if (sense->fmt.f71.mdf == 0)
1116 snprintf(service, BUFSIZE, "Repair will disable node "
1117 "0x%x on CU", sense->fmt.f71.md[1]);
1119 snprintf(service, BUFSIZE, "Repair will disable "
1120 "nodes (0x%x-0x%x) on CU", sense->fmt.f71.md[1],
1121 sense->fmt.f71.md[2]);
1124 if (sense->fmt.f71.mdf == 0)
1125 snprintf(service, BUFSIZE, "Repair will disable "
1126 "channel path 0x%x on CU",
1127 sense->fmt.f71.md[1]);
1129 snprintf(service, BUFSIZE, "Repair will disable cannel"
1130 " paths (0x%x-0x%x) on CU",
1131 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1134 if (sense->fmt.f71.mdf == 0)
1135 snprintf(service, BUFSIZE, "Repair will disable device"
1136 " path 0x%x on CU", sense->fmt.f71.md[1]);
1138 snprintf(service, BUFSIZE, "Repair will disable device"
1139 " paths (0x%x-0x%x) on CU",
1140 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1143 if (sense->fmt.f71.mdf == 0)
1144 snprintf(service, BUFSIZE, "Repair will disable "
1145 "library path 0x%x on CU",
1146 sense->fmt.f71.md[1]);
1148 snprintf(service, BUFSIZE, "Repair will disable "
1149 "library paths (0x%x-0x%x) on CU",
1150 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1153 snprintf(service, BUFSIZE, "Repair will disable access to CU");
1156 snprintf(service, BUFSIZE, "0x%02x",
1157 sense->fmt.f71.smc);
1160 dev_warn (&device->cdev->dev, "I/O subsystem information: exception"
1161 " %s, service %s\n", exception, service);
1168 * Print an Device Subsystem Service Information Message (message code f2)
1171 tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
1173 struct tape_3590_sense *sense;
1174 char *exception, *service;
1176 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1177 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1179 if (!exception || !service)
1182 sense = (struct tape_3590_sense *) irb->ecw;
1183 /* Exception Message */
1184 switch (sense->fmt.f71.emc) {
1186 snprintf(exception, BUFSIZE, "Effect of failure is unknown");
1189 snprintf(exception, BUFSIZE, "DV Exception - no performance"
1193 snprintf(exception, BUFSIZE, "DV Exception on channel "
1194 "interface 0x%02x", sense->fmt.f71.md[0]);
1197 snprintf(exception, BUFSIZE, "DV Exception on loader 0x%02x",
1198 sense->fmt.f71.md[0]);
1201 snprintf(exception, BUFSIZE, "DV Exception on message display"
1202 " 0x%02x", sense->fmt.f71.md[0]);
1205 snprintf(exception, BUFSIZE, "DV Exception in tape path");
1208 snprintf(exception, BUFSIZE, "DV Exception in drive");
1211 snprintf(exception, BUFSIZE, "0x%02x",
1212 sense->fmt.f71.emc);
1214 /* Service Message */
1215 switch (sense->fmt.f71.smc) {
1217 snprintf(service, BUFSIZE, "Repair impact is unknown");
1220 snprintf(service, BUFSIZE, "Repair will not impact device "
1224 if (sense->fmt.f71.mdf == 0)
1225 snprintf(service, BUFSIZE, "Repair will disable "
1226 "channel path 0x%x on DV",
1227 sense->fmt.f71.md[1]);
1229 snprintf(service, BUFSIZE, "Repair will disable "
1230 "channel path (0x%x-0x%x) on DV",
1231 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1234 if (sense->fmt.f71.mdf == 0)
1235 snprintf(service, BUFSIZE, "Repair will disable "
1236 "interface 0x%x on DV", sense->fmt.f71.md[1]);
1238 snprintf(service, BUFSIZE, "Repair will disable "
1239 "interfaces (0x%x-0x%x) on DV",
1240 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1243 if (sense->fmt.f71.mdf == 0)
1244 snprintf(service, BUFSIZE, "Repair will disable loader"
1245 " 0x%x on DV", sense->fmt.f71.md[1]);
1247 snprintf(service, BUFSIZE, "Repair will disable loader"
1248 " (0x%x-0x%x) on DV",
1249 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1252 snprintf(service, BUFSIZE, "Repair will disable access to DV");
1255 if (sense->fmt.f71.mdf == 0)
1256 snprintf(service, BUFSIZE, "Repair will disable "
1257 "message display 0x%x on DV",
1258 sense->fmt.f71.md[1]);
1260 snprintf(service, BUFSIZE, "Repair will disable "
1261 "message displays (0x%x-0x%x) on DV",
1262 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1265 snprintf(service, BUFSIZE, "Clean DV");
1268 snprintf(service, BUFSIZE, "0x%02x",
1269 sense->fmt.f71.smc);
1272 dev_warn (&device->cdev->dev, "Device subsystem information: exception"
1273 " %s, service %s\n", exception, service);
1280 * Print standard ERA Message
1283 tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
1285 struct tape_3590_sense *sense;
1287 sense = (struct tape_3590_sense *) irb->ecw;
1290 if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
1291 if (tape_3590_msg[sense->mc] != NULL)
1292 dev_warn (&device->cdev->dev, "The tape unit has "
1293 "issued sense message %s\n",
1294 tape_3590_msg[sense->mc]);
1296 dev_warn (&device->cdev->dev, "The tape unit has "
1297 "issued an unknown sense message code 0x%x\n",
1301 if (sense->mc == 0xf0) {
1302 /* Standard Media Information Message */
1303 dev_warn (&device->cdev->dev, "MIM SEV=%i, MC=%02x, ES=%x/%x, "
1304 "RC=%02x-%04x-%02x\n", sense->fmt.f70.sev, sense->mc,
1305 sense->fmt.f70.emc, sense->fmt.f70.smc,
1306 sense->fmt.f70.refcode, sense->fmt.f70.mid,
1307 sense->fmt.f70.fid);
1308 tape_3590_print_mim_msg_f0(device, irb);
1311 if (sense->mc == 0xf1) {
1312 /* Standard I/O Subsystem Service Information Message */
1313 dev_warn (&device->cdev->dev, "IOSIM SEV=%i, DEVTYPE=3590/%02x,"
1314 " MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
1315 sense->fmt.f71.sev, device->cdev->id.dev_model,
1316 sense->mc, sense->fmt.f71.emc, sense->fmt.f71.smc,
1317 sense->fmt.f71.refcode1, sense->fmt.f71.refcode2,
1318 sense->fmt.f71.refcode3);
1319 tape_3590_print_io_sim_msg_f1(device, irb);
1322 if (sense->mc == 0xf2) {
1323 /* Standard Device Service Information Message */
1324 dev_warn (&device->cdev->dev, "DEVSIM SEV=%i, DEVTYPE=3590/%02x"
1325 ", MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
1326 sense->fmt.f71.sev, device->cdev->id.dev_model,
1327 sense->mc, sense->fmt.f71.emc, sense->fmt.f71.smc,
1328 sense->fmt.f71.refcode1, sense->fmt.f71.refcode2,
1329 sense->fmt.f71.refcode3);
1330 tape_3590_print_dev_sim_msg_f2(device, irb);
1333 if (sense->mc == 0xf3) {
1334 /* Standard Library Service Information Message */
1337 dev_warn (&device->cdev->dev, "The tape unit has issued an unknown "
1338 "sense message code %x\n", sense->mc);
1341 static int tape_3590_crypt_error(struct tape_device *device,
1342 struct tape_request *request, struct irb *irb)
1350 sense = ((struct tape_3590_sense *) irb->ecw)->fmt.data;
1351 bus_id = dev_name(&device->cdev->dev);
1353 drv_rc = *((u32*) &sense[5]) & 0xffffff;
1355 ekm_rc2 = *((u16*) &sense[10]);
1356 if ((cu_rc == 0) && (ekm_rc2 == 0xee31))
1357 /* key not defined on EKM */
1358 return tape_3590_erp_basic(device, request, irb, -EKEYREJECTED);
1359 if ((cu_rc == 1) || (cu_rc == 2))
1360 /* No connection to EKM */
1361 return tape_3590_erp_basic(device, request, irb, -ENOTCONN);
1363 dev_err (&device->cdev->dev, "The tape unit failed to obtain the "
1364 "encryption key from EKM\n");
1366 return tape_3590_erp_basic(device, request, irb, -ENOKEY);
1370 * 3590 error Recovery routine:
1371 * If possible, it tries to recover from the error. If this is not possible,
1372 * inform the user about the problem.
1375 tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
1378 struct tape_3590_sense *sense;
1381 #ifdef CONFIG_S390_TAPE_BLOCK
1382 if (request->op == TO_BLOCK) {
1384 * Recovery for block device requests. Set the block_position
1385 * to something invalid and retry.
1387 device->blk_data.block_position = -1;
1388 if (request->retries-- <= 0)
1389 return tape_3590_erp_failed(device, request, irb, -EIO);
1391 return tape_3590_erp_retry(device, request, irb);
1395 sense = (struct tape_3590_sense *) irb->ecw;
1397 DBF_EVENT(6, "Unit Check: RQC = %x\n", sense->rc_rqc);
1400 * First check all RC-QRCs where we want to do something special
1401 * - "break": basic error recovery is done
1402 * - "goto out:": just print error message if available
1405 switch (sense->rc_rqc) {
1408 tape_3590_print_era_msg(device, irb);
1409 return tape_3590_erp_read_buf_log(device, request, irb);
1412 tape_3590_print_era_msg(device, irb);
1413 return tape_3590_erp_read_alternate(device, request, irb);
1417 tape_3590_print_era_msg(device, irb);
1418 return tape_3590_erp_special_interrupt(device, request, irb);
1420 return tape_3590_crypt_error(device, request, irb);
1423 DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
1425 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1427 DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
1429 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1431 DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
1432 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1435 DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
1437 return tape_3590_erp_basic(device, request, irb, -EIO);
1439 DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
1441 tape_med_state_set(device, MS_UNLOADED);
1442 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1443 return tape_3590_erp_basic(device, request, irb, 0);
1447 * print additional msg since default msg
1448 * "device intervention" is not very meaningfull
1450 tape_med_state_set(device, MS_UNLOADED);
1451 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1452 return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
1453 case 0x4012: /* Device Long Busy */
1454 /* XXX: Also use long busy handling here? */
1455 DBF_EVENT(6, "(%08x): LONG BUSY\n", device->cdev_id);
1456 tape_3590_print_era_msg(device, irb);
1457 return tape_3590_erp_basic(device, request, irb, -EBUSY);
1459 DBF_EVENT(6, "(%08x): Crypto LONG BUSY\n", device->cdev_id);
1460 return tape_3590_erp_long_busy(device, request, irb);
1463 if (sense->rac == 0xd0) {
1465 tape_3590_print_era_msg(device, irb);
1466 return tape_3590_erp_swap(device, request, irb);
1468 if (sense->rac == 0x26) {
1470 tape_3590_print_era_msg(device, irb);
1471 return tape_3590_erp_read_opposite(device, request,
1474 return tape_3590_erp_basic(device, request, irb, -EIO);
1481 tape_3590_print_era_msg(device, irb);
1482 return tape_3590_erp_swap(device, request, irb);
1486 return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
1490 tape_med_state_set(device, MS_UNLOADED);
1491 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1492 return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
1495 return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
1498 return tape_3590_erp_basic(device, request, irb, -EPERM);
1500 dev_warn (&device->cdev->dev, "A different host has privileged"
1501 " access to the tape unit\n");
1502 return tape_3590_erp_basic(device, request, irb, -EPERM);
1504 return tape_3590_erp_basic(device, request, irb, -EIO);
1509 * 3590 interrupt handler:
1512 tape_3590_irq(struct tape_device *device, struct tape_request *request,
1515 if (request == NULL)
1516 return tape_3590_unsolicited_irq(device, irb);
1518 if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) &&
1519 (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) &&
1520 (request->op == TO_WRI)) {
1521 /* Write at end of volume */
1522 DBF_EVENT(2, "End of volume\n");
1523 return tape_3590_erp_failed(device, request, irb, -ENOSPC);
1526 if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)
1527 return tape_3590_unit_check(device, request, irb);
1529 if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) {
1530 if (irb->scsw.cmd.dstat == DEV_STAT_UNIT_EXCEP) {
1531 if (request->op == TO_FSB || request->op == TO_BSB)
1534 DBF_EVENT(5, "Unit Exception!\n");
1537 return tape_3590_done(device, request);
1540 if (irb->scsw.cmd.dstat & DEV_STAT_CHN_END) {
1541 DBF_EVENT(2, "cannel end\n");
1542 return TAPE_IO_PENDING;
1545 if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) {
1546 DBF_EVENT(2, "Unit Attention when busy..\n");
1547 return TAPE_IO_PENDING;
1550 DBF_EVENT(6, "xunknownirq\n");
1551 tape_dump_sense_dbf(device, request, irb);
1552 return TAPE_IO_STOP;
1556 static int tape_3590_read_dev_chars(struct tape_device *device,
1557 struct tape_3590_rdc_data *rdc_data)
1560 struct tape_request *request;
1562 request = tape_alloc_request(1, sizeof(*rdc_data));
1563 if (IS_ERR(request))
1564 return PTR_ERR(request);
1565 request->op = TO_RDC;
1566 tape_ccw_end(request->cpaddr, CCW_CMD_RDC, sizeof(*rdc_data),
1568 rc = tape_do_io(device, request);
1570 memcpy(rdc_data, request->cpdata, sizeof(*rdc_data));
1571 tape_free_request(request);
1576 * Setup device function
1579 tape_3590_setup_device(struct tape_device *device)
1582 struct tape_3590_disc_data *data;
1583 struct tape_3590_rdc_data *rdc_data;
1585 DBF_EVENT(6, "3590 device setup\n");
1586 data = kzalloc(sizeof(struct tape_3590_disc_data), GFP_KERNEL | GFP_DMA);
1589 data->read_back_op = READ_PREVIOUS;
1590 device->discdata = data;
1592 rdc_data = kmalloc(sizeof(*rdc_data), GFP_KERNEL | GFP_DMA);
1597 rc = tape_3590_read_dev_chars(device, rdc_data);
1599 DBF_LH(3, "Read device characteristics failed!\n");
1602 rc = tape_std_assign(device);
1605 if (rdc_data->data[31] == 0x13) {
1606 data->crypt_info.capability |= TAPE390_CRYPT_SUPPORTED_MASK;
1607 tape_3592_disable_crypt(device);
1609 DBF_EVENT(6, "Device has NO crypto support\n");
1611 /* Try to find out if medium is loaded */
1612 rc = tape_3590_sense_medium(device);
1614 DBF_LH(3, "3590 medium sense returned %d\n", rc);
1627 * Cleanup device function
1630 tape_3590_cleanup_device(struct tape_device *device)
1632 flush_scheduled_work();
1633 tape_std_unassign(device);
1635 kfree(device->discdata);
1636 device->discdata = NULL;
1640 * List of 3590 magnetic tape commands.
1642 static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
1643 [MTRESET] = tape_std_mtreset,
1644 [MTFSF] = tape_std_mtfsf,
1645 [MTBSF] = tape_std_mtbsf,
1646 [MTFSR] = tape_std_mtfsr,
1647 [MTBSR] = tape_std_mtbsr,
1648 [MTWEOF] = tape_std_mtweof,
1649 [MTREW] = tape_std_mtrew,
1650 [MTOFFL] = tape_std_mtoffl,
1651 [MTNOP] = tape_std_mtnop,
1652 [MTRETEN] = tape_std_mtreten,
1653 [MTBSFM] = tape_std_mtbsfm,
1654 [MTFSFM] = tape_std_mtfsfm,
1655 [MTEOM] = tape_std_mteom,
1656 [MTERASE] = tape_std_mterase,
1660 [MTSETBLK] = tape_std_mtsetblk,
1661 [MTSETDENSITY] = NULL,
1662 [MTSEEK] = tape_3590_mtseek,
1663 [MTTELL] = tape_3590_mttell,
1664 [MTSETDRVBUFFER] = NULL,
1670 [MTLOAD] = tape_std_mtload,
1671 [MTUNLOAD] = tape_std_mtunload,
1672 [MTCOMPRESSION] = tape_std_mtcompression,
1678 * Tape discipline structure for 3590.
1680 static struct tape_discipline tape_discipline_3590 = {
1681 .owner = THIS_MODULE,
1682 .setup_device = tape_3590_setup_device,
1683 .cleanup_device = tape_3590_cleanup_device,
1684 .process_eov = tape_std_process_eov,
1685 .irq = tape_3590_irq,
1686 .read_block = tape_std_read_block,
1687 .write_block = tape_std_write_block,
1688 #ifdef CONFIG_S390_TAPE_BLOCK
1689 .bread = tape_3590_bread,
1690 .free_bread = tape_3590_free_bread,
1691 .check_locate = tape_3590_check_locate,
1693 .ioctl_fn = tape_3590_ioctl,
1694 .mtop_array = tape_3590_mtop
1697 static struct ccw_device_id tape_3590_ids[] = {
1698 {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
1699 {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592},
1700 { /* end of list */ }
1704 tape_3590_online(struct ccw_device *cdev)
1706 return tape_generic_online(cdev->dev.driver_data,
1707 &tape_discipline_3590);
1711 tape_3590_offline(struct ccw_device *cdev)
1713 return tape_generic_offline(cdev->dev.driver_data);
1716 static struct ccw_driver tape_3590_driver = {
1717 .name = "tape_3590",
1718 .owner = THIS_MODULE,
1719 .ids = tape_3590_ids,
1720 .probe = tape_generic_probe,
1721 .remove = tape_generic_remove,
1722 .set_offline = tape_3590_offline,
1723 .set_online = tape_3590_online,
1727 * Setup discipline structure.
1730 tape_3590_init(void)
1734 TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
1735 debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
1736 #ifdef DBF_LIKE_HELL
1737 debug_set_level(TAPE_DBF_AREA, 6);
1740 DBF_EVENT(3, "3590 init\n");
1741 /* Register driver for 3590 tapes. */
1742 rc = ccw_driver_register(&tape_3590_driver);
1744 DBF_EVENT(3, "3590 init failed\n");
1746 DBF_EVENT(3, "3590 registered\n");
1751 tape_3590_exit(void)
1753 ccw_driver_unregister(&tape_3590_driver);
1755 debug_unregister(TAPE_DBF_AREA);
1758 MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
1759 MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
1760 MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
1761 MODULE_LICENSE("GPL");
1763 module_init(tape_3590_init);
1764 module_exit(tape_3590_exit);