ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / s390 / scsi / zfcp_aux.c
1 /*
2  *
3  * linux/drivers/s390/scsi/zfcp_aux.c
4  *
5  * FCP adapter driver for IBM eServer zSeries
6  *
7  * (C) Copyright IBM Corp. 2002, 2004
8  *
9  * Author(s): Martin Peschke <mpeschke@de.ibm.com>
10  *            Raimund Schroeder <raimund.schroeder@de.ibm.com>
11  *            Aron Zeh
12  *            Wolfgang Taphorn
13  *            Stefan Bader <stefan.bader@de.ibm.com>
14  *            Heiko Carstens <heiko.carstens@de.ibm.com>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2, or (at your option)
19  * any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29  */
30
31 /* this drivers version (do not edit !!! generated and updated by cvs) */
32 #define ZFCP_AUX_REVISION "$Revision: 1.107 $"
33
34 #include "zfcp_ext.h"
35
36 /* accumulated log level (module parameter) */
37 static u32 loglevel = ZFCP_LOG_LEVEL_DEFAULTS;
38 static char *device;
39 /*********************** FUNCTION PROTOTYPES *********************************/
40
41 /* written against the module interface */
42 static int __init  zfcp_module_init(void);
43
44 int zfcp_reboot_handler(struct notifier_block *, unsigned long, void *);
45
46 /* FCP related */
47 static void zfcp_ns_gid_pn_handler(unsigned long);
48
49 /* miscellaneous */
50 #ifdef ZFCP_STAT_REQSIZES
51 static int zfcp_statistics_init_all(void);
52 static int zfcp_statistics_clear_all(void);
53 static int zfcp_statistics_clear(struct list_head *);
54 static int zfcp_statistics_new(struct list_head *, u32);
55 #endif
56
57 static inline int zfcp_sg_list_alloc(struct zfcp_sg_list *, size_t);
58 static inline int zfcp_sg_list_free(struct zfcp_sg_list *);
59 static inline int zfcp_sg_list_copy_from_user(struct zfcp_sg_list *, void *,
60                                               size_t);
61 static inline int zfcp_sg_list_copy_to_user(void *, struct zfcp_sg_list *,
62                                             size_t);
63
64 static int zfcp_cfdc_dev_ioctl(struct inode *, struct file *,
65         unsigned int, unsigned long);
66
67 #define ZFCP_CFDC_IOC_MAGIC                     0xDD
68 #define ZFCP_CFDC_IOC \
69         _IOWR(ZFCP_CFDC_IOC_MAGIC, 0, struct zfcp_cfdc_sense_data)
70
71 #ifdef CONFIG_S390_SUPPORT
72 static struct ioctl_trans zfcp_ioctl_trans = {ZFCP_CFDC_IOC, (void*) sys_ioctl};
73 #endif
74
75 static struct file_operations zfcp_cfdc_fops = {
76         .ioctl = zfcp_cfdc_dev_ioctl
77 };
78
79 static struct miscdevice zfcp_cfdc_misc = {
80         .minor = ZFCP_CFDC_DEV_MINOR,
81         .name = ZFCP_CFDC_DEV_NAME,
82         .fops = &zfcp_cfdc_fops
83 };
84
85 /*********************** KERNEL/MODULE PARAMETERS  ***************************/
86
87 /* declare driver module init/cleanup functions */
88 module_init(zfcp_module_init);
89
90 MODULE_AUTHOR("Heiko Carstens <heiko.carstens@de.ibm.com>, "
91               "Martin Peschke <mpeschke@de.ibm.com>, "
92               "Raimund Schroeder <raimund.schroeder@de.ibm.com>, "
93               "Wolfgang Taphorn <taphorn@de.ibm.com>, "
94               "Aron Zeh <arzeh@de.ibm.com>, "
95               "IBM Deutschland Entwicklung GmbH");
96 MODULE_DESCRIPTION
97     ("FCP (SCSI over Fibre Channel) HBA driver for IBM eServer zSeries");
98 MODULE_LICENSE("GPL");
99
100 module_param(device, charp, 0);
101 MODULE_PARM_DESC(device, "specify initial device");
102
103 module_param(loglevel, uint, 0);
104 MODULE_PARM_DESC(loglevel,
105                  "log levels, 8 nibbles: "
106                  "(unassigned) ERP QDIO DIO Config FSF SCSI Other, "
107                  "levels: 0=none 1=normal 2=devel 3=trace");
108
109 #ifdef ZFCP_PRINT_FLAGS
110 u32 flags_dump = 0;
111 module_param(flags_dump, uint, 0);
112 #endif
113
114 /****************************************************************/
115 /************** Functions without logging ***********************/
116 /****************************************************************/
117
118 void
119 _zfcp_hex_dump(char *addr, int count)
120 {
121         int i;
122         for (i = 0; i < count; i++) {
123                 printk("%02x", addr[i]);
124                 if ((i % 4) == 3)
125                         printk(" ");
126                 if ((i % 32) == 31)
127                         printk("\n");
128         }
129         if (((i-1) % 32) != 31)
130                 printk("\n");
131 }
132
133 /****************************************************************/
134 /************** Uncategorised Functions *************************/
135 /****************************************************************/
136
137 #define ZFCP_LOG_AREA                   ZFCP_LOG_AREA_OTHER
138
139 #ifdef ZFCP_STAT_REQSIZES
140
141 static int
142 zfcp_statistics_clear(struct list_head *head)
143 {
144         int retval = 0;
145         unsigned long flags;
146         struct zfcp_statistics *stat, *tmp;
147
148         write_lock_irqsave(&zfcp_data.stat_lock, flags);
149         list_for_each_entry_safe(stat, tmp, head, list) {
150                 list_del(&stat->list);
151                 kfree(stat);
152         }
153         write_unlock_irqrestore(&zfcp_data.stat_lock, flags);
154
155         return retval;
156 }
157
158 /* Add new statistics entry */
159 static int
160 zfcp_statistics_new(struct list_head *head, u32 num)
161 {
162         int retval = 0;
163         struct zfcp_statistics *stat;
164
165         stat = kmalloc(sizeof (struct zfcp_statistics), GFP_ATOMIC);
166         if (stat) {
167                 memset(stat, 0, sizeof (struct zfcp_statistics));
168                 stat->num = num;
169                 stat->occurrence = 1;
170                 list_add_tail(&stat->list, head);
171         } else
172                 zfcp_data.stat_errors++;
173
174         return retval;
175 }
176
177 int
178 zfcp_statistics_inc(struct list_head *head, u32 num)
179 {
180         int retval = 0;
181         unsigned long flags;
182         struct zfcp_statistics *stat;
183
184         write_lock_irqsave(&zfcp_data.stat_lock, flags);
185         list_for_each_entry(stat, head, list) {
186                 if (stat->num == num) {
187                         stat->occurrence++;
188                         goto unlock;
189                 }
190         }
191         /* occurrence must be initialized to 1 */
192         zfcp_statistics_new(head, num);
193  unlock:
194         write_unlock_irqrestore(&zfcp_data.stat_lock, flags);
195         return retval;
196 }
197
198 static int
199 zfcp_statistics_init_all(void)
200 {
201         int retval = 0;
202
203         rwlock_init(&zfcp_data.stat_lock);
204         INIT_LIST_HEAD(&zfcp_data.read_req_head);
205         INIT_LIST_HEAD(&zfcp_data.write_req_head);
206         INIT_LIST_HEAD(&zfcp_data.read_sg_head);
207         INIT_LIST_HEAD(&zfcp_data.write_sg_head);
208         INIT_LIST_HEAD(&zfcp_data.read_sguse_head);
209         INIT_LIST_HEAD(&zfcp_data.write_sguse_head);
210         return retval;
211 }
212
213 static int
214 zfcp_statistics_clear_all(void)
215 {
216         int retval = 0;
217
218         zfcp_statistics_clear(&zfcp_data.read_req_head);
219         zfcp_statistics_clear(&zfcp_data.write_req_head);
220         zfcp_statistics_clear(&zfcp_data.read_sg_head);
221         zfcp_statistics_clear(&zfcp_data.write_sg_head);
222         zfcp_statistics_clear(&zfcp_data.read_sguse_head);
223         zfcp_statistics_clear(&zfcp_data.write_sguse_head);
224         return retval;
225 }
226
227 #endif /* ZFCP_STAT_REQSIZES */
228
229 static inline int
230 zfcp_fsf_req_is_scsi_cmnd(struct zfcp_fsf_req *fsf_req)
231 {
232         return ((fsf_req->fsf_command == FSF_QTCB_FCP_CMND) &&
233                 !(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT));
234 }
235
236 void
237 zfcp_cmd_dbf_event_fsf(const char *text, struct zfcp_fsf_req *fsf_req,
238                        void *add_data, int add_length)
239 {
240         struct zfcp_adapter *adapter = fsf_req->adapter;
241         struct scsi_cmnd *scsi_cmnd;
242         int level = 3;
243         int i;
244         unsigned long flags;
245
246         write_lock_irqsave(&adapter->cmd_dbf_lock, flags);
247         if (zfcp_fsf_req_is_scsi_cmnd(fsf_req)) {
248                 scsi_cmnd = fsf_req->data.send_fcp_command_task.scsi_cmnd;
249                 debug_text_event(adapter->cmd_dbf, level, "fsferror");
250                 debug_text_event(adapter->cmd_dbf, level, text);
251                 debug_event(adapter->cmd_dbf, level, &fsf_req,
252                             sizeof (unsigned long));
253                 debug_event(adapter->cmd_dbf, level, &fsf_req->seq_no,
254                             sizeof (u32));
255                 debug_event(adapter->cmd_dbf, level, &scsi_cmnd,
256                             sizeof (unsigned long));
257                 debug_event(adapter->cmd_dbf, level, &scsi_cmnd->cmnd,
258                             min(ZFCP_CMD_DBF_LENGTH, (int)scsi_cmnd->cmd_len));
259                 for (i = 0; i < add_length; i += ZFCP_CMD_DBF_LENGTH)
260                         debug_event(adapter->cmd_dbf,
261                                     level,
262                                     (char *) add_data + i,
263                                     min(ZFCP_CMD_DBF_LENGTH, add_length - i));
264         }
265         write_unlock_irqrestore(&adapter->cmd_dbf_lock, flags);
266 }
267
268 /* XXX additionally log unit if available */
269 /* ---> introduce new parameter for unit, see 2.4 code */
270 void
271 zfcp_cmd_dbf_event_scsi(const char *text, struct scsi_cmnd *scsi_cmnd)
272 {
273         struct zfcp_adapter *adapter;
274         union zfcp_req_data *req_data;
275         struct zfcp_fsf_req *fsf_req;
276         int level = ((host_byte(scsi_cmnd->result) != 0) ? 1 : 5);
277         unsigned long flags;
278
279         adapter = (struct zfcp_adapter *) scsi_cmnd->device->host->hostdata[0];
280         req_data = (union zfcp_req_data *) scsi_cmnd->host_scribble;
281         fsf_req = (req_data ? req_data->send_fcp_command_task.fsf_req : NULL);
282         write_lock_irqsave(&adapter->cmd_dbf_lock, flags);
283         debug_text_event(adapter->cmd_dbf, level, "hostbyte");
284         debug_text_event(adapter->cmd_dbf, level, text);
285         debug_event(adapter->cmd_dbf, level, &scsi_cmnd->result, sizeof (u32));
286         debug_event(adapter->cmd_dbf, level, &scsi_cmnd,
287                     sizeof (unsigned long));
288         debug_event(adapter->cmd_dbf, level, &scsi_cmnd->cmnd,
289                     min(ZFCP_CMD_DBF_LENGTH, (int)scsi_cmnd->cmd_len));
290         if (likely(fsf_req)) {
291                 debug_event(adapter->cmd_dbf, level, &fsf_req,
292                             sizeof (unsigned long));
293                 debug_event(adapter->cmd_dbf, level, &fsf_req->seq_no,
294                             sizeof (u32));
295         } else {
296                 debug_text_event(adapter->cmd_dbf, level, "");
297                 debug_text_event(adapter->cmd_dbf, level, "");
298         }
299         write_unlock_irqrestore(&adapter->cmd_dbf_lock, flags);
300 }
301
302 void
303 zfcp_in_els_dbf_event(struct zfcp_adapter *adapter, const char *text,
304                       struct fsf_status_read_buffer *status_buffer, int length)
305 {
306         int level = 1;
307         int i;
308
309         debug_text_event(adapter->in_els_dbf, level, text);
310         debug_event(adapter->in_els_dbf, level, &status_buffer->d_id, 8);
311         for (i = 0; i < length; i += ZFCP_IN_ELS_DBF_LENGTH)
312                 debug_event(adapter->in_els_dbf,
313                             level,
314                             (char *) status_buffer->payload + i,
315                             min(ZFCP_IN_ELS_DBF_LENGTH, length - i));
316 }
317
318 /**
319  * zfcp_device_setup - setup function
320  * @str: pointer to parameter string
321  *
322  * Parse "device=..." parameter string.
323  */
324 static int __init
325 zfcp_device_setup(char *str)
326 {
327         char *tmp;
328
329         if (!str)
330                 return 0;
331
332         tmp = strchr(str, ',');
333         if (!tmp)
334                 goto err_out;
335         *tmp++ = '\0';
336         strncpy(zfcp_data.init_busid, str, BUS_ID_SIZE);
337         zfcp_data.init_busid[BUS_ID_SIZE-1] = '\0';
338
339         zfcp_data.init_wwpn = simple_strtoull(tmp, &tmp, 0);
340         if (*tmp++ != ',')
341                 goto err_out;
342         if (*tmp == '\0')
343                 goto err_out;
344
345         zfcp_data.init_fcp_lun = simple_strtoull(tmp, &tmp, 0);
346         if (*tmp != '\0')
347                 goto err_out;
348         return 1;
349
350  err_out:
351         ZFCP_LOG_NORMAL("Parse error for device parameter string %s\n", str);
352         return 0;
353 }
354
355 static void __init
356 zfcp_init_device_configure(void)
357 {
358         int found = 0;
359         struct zfcp_adapter *adapter;
360         struct zfcp_port *port;
361         struct zfcp_unit *unit;
362
363         down(&zfcp_data.config_sema);
364         read_lock_irq(&zfcp_data.config_lock);
365         list_for_each_entry(adapter, &zfcp_data.adapter_list_head, list)
366                 if (strcmp(zfcp_data.init_busid,
367                            zfcp_get_busid_by_adapter(adapter)) == 0) {
368                         zfcp_adapter_get(adapter);
369                         found = 1;
370                         break;
371                 }
372         read_unlock_irq(&zfcp_data.config_lock);
373         if (!found)
374                 goto out_adapter;
375         port = zfcp_port_enqueue(adapter, zfcp_data.init_wwpn, 0);
376         if (!port)
377                 goto out_port;
378         unit = zfcp_unit_enqueue(port, zfcp_data.init_fcp_lun);
379         if (!unit)
380                 goto out_unit;
381         up(&zfcp_data.config_sema);
382         ccw_device_set_online(adapter->ccw_device);
383         wait_event(unit->scsi_add_wq, atomic_read(&unit->scsi_add_work) == 0);
384         down(&zfcp_data.config_sema);
385         zfcp_unit_put(unit);
386  out_unit:
387         zfcp_port_put(port);
388  out_port:
389         zfcp_adapter_put(adapter);
390  out_adapter:
391         up(&zfcp_data.config_sema);
392         return;
393 }
394
395 static int __init
396 zfcp_module_init(void)
397 {
398
399         int retval = 0;
400
401         atomic_set(&zfcp_data.loglevel, loglevel);
402
403         /* initialize adapter list */
404         INIT_LIST_HEAD(&zfcp_data.adapter_list_head);
405
406         /* initialize adapters to be removed list head */
407         INIT_LIST_HEAD(&zfcp_data.adapter_remove_lh);
408
409 #ifdef ZFCP_STAT_REQSIZES
410         zfcp_statistics_init_all();
411 #endif
412
413 #ifdef CONFIG_S390_SUPPORT
414         retval = register_ioctl32_conversion(zfcp_ioctl_trans.cmd,
415                                              zfcp_ioctl_trans.handler);
416         if (retval != 0) {
417                 ZFCP_LOG_INFO("registration of ioctl32 conversion failed\n");
418                 goto out_ioctl32;
419         }
420 #endif
421         retval = misc_register(&zfcp_cfdc_misc);
422         if (retval != 0) {
423                 ZFCP_LOG_INFO("registration of misc device "
424                               "zfcp_cfdc failed\n");
425                 goto out_misc_register;
426         } else {
427                 ZFCP_LOG_TRACE("major/minor for zfcp_cfdc: %d/%d\n",
428                                ZFCP_CFDC_DEV_MAJOR, zfcp_cfdc_misc.minor);
429         }
430
431         /* Initialise proc semaphores */
432         sema_init(&zfcp_data.config_sema, 1);
433
434         /* initialise configuration rw lock */
435         rwlock_init(&zfcp_data.config_lock);
436
437         zfcp_data.reboot_notifier.notifier_call = zfcp_reboot_handler;
438         register_reboot_notifier(&zfcp_data.reboot_notifier);
439
440         /* save address of data structure managing the driver module */
441         zfcp_data.scsi_host_template.module = THIS_MODULE;
442
443         /* setup dynamic I/O */
444         retval = zfcp_ccw_register();
445         if (retval) {
446                 ZFCP_LOG_NORMAL("registration with common I/O layer failed\n");
447                 goto out_ccw_register;
448         }
449
450         if (zfcp_device_setup(device))
451                 zfcp_init_device_configure();
452
453         goto out;
454
455  out_ccw_register:
456         unregister_reboot_notifier(&zfcp_data.reboot_notifier);
457         misc_deregister(&zfcp_cfdc_misc);
458  out_misc_register:
459 #ifdef CONFIG_S390_SUPPORT
460         unregister_ioctl32_conversion(zfcp_ioctl_trans.cmd);
461  out_ioctl32:
462 #endif
463 #ifdef ZFCP_STAT_REQSIZES
464         zfcp_statistics_clear_all();
465 #endif
466
467  out:
468         return retval;
469 }
470
471 /*
472  * This function is called automatically by the kernel whenever a reboot or a 
473  * shut-down is initiated and zfcp is still loaded
474  *
475  * locks:       zfcp_data.config_sema is taken prior to shutting down the module
476  *              and removing all structures
477  * returns:     NOTIFY_DONE in all cases
478  */
479 int
480 zfcp_reboot_handler(struct notifier_block *notifier, unsigned long code,
481                     void *ptr)
482 {
483         zfcp_ccw_unregister();
484         return NOTIFY_DONE;
485 }
486
487
488 /*
489  * function:    zfcp_cfdc_dev_ioctl
490  *
491  * purpose:     Handle control file upload/download transaction via IOCTL
492  *              interface
493  *
494  * returns:     0           - Operation completed successfuly
495  *              -ENOTTY     - Unknown IOCTL command
496  *              -EINVAL     - Invalid sense data record
497  *              -ENXIO      - The FCP adapter is not available
498  *              -EOPNOTSUPP - The FCP adapter does not have CFDC support
499  *              -ENOMEM     - Insufficient memory
500  *              -EFAULT     - User space memory I/O operation fault
501  *              -EPERM      - Cannot create or queue FSF request or create SBALs
502  */
503 static int
504 zfcp_cfdc_dev_ioctl(struct inode *inode, struct file *file,
505                     unsigned int command, unsigned long buffer)
506 {
507         struct zfcp_cfdc_sense_data sense_data, *sense_data_user;
508         struct zfcp_adapter *adapter = NULL;
509         struct zfcp_fsf_req *fsf_req = NULL;
510         struct zfcp_sg_list *sg_list = NULL;
511         u32 fsf_command, option;
512         char *bus_id = NULL;
513         int retval = 0;
514
515         sg_list = kmalloc(sizeof(struct zfcp_sg_list), GFP_KERNEL);
516         if (sg_list == NULL) {
517                 retval = -ENOMEM;
518                 goto out;
519         }
520         sg_list->count = 0;
521
522         if (command != ZFCP_CFDC_IOC) {
523                 ZFCP_LOG_INFO("IOC request code 0x%x invalid\n", command);
524                 retval = -ENOTTY;
525                 goto out;
526         }
527
528         if ((sense_data_user = (struct zfcp_cfdc_sense_data*)buffer) == NULL) {
529                 ZFCP_LOG_INFO("sense data record is required\n");
530                 retval = -EINVAL;
531                 goto out;
532         }
533
534         retval = copy_from_user(&sense_data, sense_data_user,
535                                 sizeof(struct zfcp_cfdc_sense_data));
536         if (retval) {
537                 retval = -EFAULT;
538                 goto out;
539         }
540
541         if (sense_data.signature != ZFCP_CFDC_SIGNATURE) {
542                 ZFCP_LOG_INFO("invalid sense data request signature 0x%08x\n",
543                               ZFCP_CFDC_SIGNATURE);
544                 retval = -EINVAL;
545                 goto out;
546         }
547
548         switch (sense_data.command) {
549
550         case ZFCP_CFDC_CMND_DOWNLOAD_NORMAL:
551                 fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;
552                 option = FSF_CFDC_OPTION_NORMAL_MODE;
553                 break;
554
555         case ZFCP_CFDC_CMND_DOWNLOAD_FORCE:
556                 fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;
557                 option = FSF_CFDC_OPTION_FORCE;
558                 break;
559
560         case ZFCP_CFDC_CMND_FULL_ACCESS:
561                 fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;
562                 option = FSF_CFDC_OPTION_FULL_ACCESS;
563                 break;
564
565         case ZFCP_CFDC_CMND_RESTRICTED_ACCESS:
566                 fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;
567                 option = FSF_CFDC_OPTION_RESTRICTED_ACCESS;
568                 break;
569
570         case ZFCP_CFDC_CMND_UPLOAD:
571                 fsf_command = FSF_QTCB_UPLOAD_CONTROL_FILE;
572                 option = 0;
573                 break;
574
575         default:
576                 ZFCP_LOG_INFO("invalid command code 0x%08x\n",
577                               sense_data.command);
578                 retval = -EINVAL;
579                 goto out;
580         }
581
582         bus_id = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
583         if (bus_id == NULL) {
584                 retval = -ENOMEM;
585                 goto out;
586         }
587         snprintf(bus_id, BUS_ID_SIZE, "%d.%d.%04x",
588                 (sense_data.devno >> 24),
589                 (sense_data.devno >> 16) & 0xFF,
590                 (sense_data.devno & 0xFFFF));
591
592         retval = -ENXIO;
593         read_lock_irq(&zfcp_data.config_lock);
594         list_for_each_entry(adapter, &zfcp_data.adapter_list_head, list) {
595                 if (strncmp(bus_id, zfcp_get_busid_by_adapter(adapter),
596                     BUS_ID_SIZE) == 0) {
597                         zfcp_adapter_get(adapter);
598                         retval = 0;
599                         break;
600                 }
601         }
602         read_unlock_irq(&zfcp_data.config_lock);
603
604         kfree(bus_id);
605
606         if (retval != 0) {
607                 ZFCP_LOG_INFO("invalid adapter\n");
608                 goto out;
609         }
610
611         if (sense_data.command & ZFCP_CFDC_WITH_CONTROL_FILE) {
612                 retval = zfcp_sg_list_alloc(sg_list,
613                                             ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);
614                 if (retval) {
615                         retval = -ENOMEM;
616                         goto out;
617                 }
618         }
619
620         if ((sense_data.command & ZFCP_CFDC_DOWNLOAD) &&
621             (sense_data.command & ZFCP_CFDC_WITH_CONTROL_FILE)) {
622                 retval = zfcp_sg_list_copy_from_user(
623                         sg_list, &sense_data_user->control_file,
624                         ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);
625                 if (retval) {
626                         retval = -EFAULT;
627                         goto out;
628                 }
629         }
630
631         retval = zfcp_fsf_control_file(
632                 adapter, &fsf_req, fsf_command, option, sg_list);
633         if (retval == -EOPNOTSUPP) {
634                 ZFCP_LOG_INFO("adapter does not support cfdc\n");
635                 goto out;
636         } else if (retval != 0) {
637                 ZFCP_LOG_INFO("initiation of cfdc up/download failed\n");
638                 retval = -EPERM;
639                 goto out;
640         }
641
642         wait_event(fsf_req->completion_wq,
643                    fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
644
645         sense_data.fsf_status = fsf_req->qtcb->header.fsf_status;
646         memcpy(&sense_data.fsf_status_qual,
647                &fsf_req->qtcb->header.fsf_status_qual,
648                sizeof(union fsf_status_qual));
649         memcpy(&sense_data.payloads, &fsf_req->qtcb->bottom.support.els, 256);
650
651         retval = copy_to_user(sense_data_user, &sense_data,
652                 sizeof(struct zfcp_cfdc_sense_data));
653         if (retval) {
654                 retval = -EFAULT;
655                 goto out;
656         }
657
658         if (sense_data.command & ZFCP_CFDC_UPLOAD) {
659                 retval = zfcp_sg_list_copy_to_user(
660                         &sense_data_user->control_file, sg_list,
661                         ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);
662                 if (retval) {
663                         retval = -EFAULT;
664                         goto out;
665                 }
666         }
667
668  out:
669         if (fsf_req != NULL)
670                 zfcp_fsf_req_cleanup(fsf_req);
671
672         if ((adapter != NULL) && (retval != -ENXIO))
673                 zfcp_adapter_put(adapter);
674
675         if (sg_list != NULL) {
676                 zfcp_sg_list_free(sg_list);
677                 kfree(sg_list);
678         }
679
680         return retval;
681 }
682
683
684 /*
685  * function:    zfcp_sg_list_alloc
686  *
687  * purpose:     Create a scatter-gather list of the specified size
688  *
689  * returns:     0       - Scatter gather list is created
690  *              -ENOMEM - Insufficient memory (*list_ptr is then set to NULL)
691  */
692 static inline int
693 zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size)
694 {
695         struct scatterlist *sg;
696         unsigned int i;
697         int retval = 0;
698
699         sg_list->count = size >> PAGE_SHIFT;
700         if (size & ~PAGE_MASK)
701                 sg_list->count++;
702         sg_list->sg = kmalloc(sg_list->count * sizeof(struct scatterlist),
703                               GFP_KERNEL);
704         if (sg_list->sg == NULL) {
705                 retval = -ENOMEM;
706                 goto out;
707         }
708
709         for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) {
710                 sg->length = min(size, PAGE_SIZE);
711                 sg->offset = 0;
712                 sg->page = alloc_pages(GFP_KERNEL, 0);
713                 if (sg->page == NULL) {
714                         sg_list->count = i;
715                         zfcp_sg_list_free(sg_list);
716                         retval = -ENOMEM;
717                         goto out;
718                 }
719                 size -= sg->length;
720         }
721
722  out:
723         return retval;
724 }
725
726
727 /*
728  * function:    zfcp_sg_list_free
729  *
730  * purpose:     Destroy a scatter-gather list and release memory
731  *
732  * returns:     Always 0
733  */
734 static inline int
735 zfcp_sg_list_free(struct zfcp_sg_list *sg_list)
736 {
737         struct scatterlist *sg;
738         unsigned int i;
739         int retval = 0;
740
741         BUG_ON((sg_list->sg == NULL) || (sg_list == NULL));
742
743         for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++)
744                 __free_pages(sg->page, 0);
745
746         return retval;
747 }
748
749
750 /*
751  * function:    zfcp_sg_list_copy_from_user
752  *
753  * purpose:     Copy data from user space memory to the scatter-gather list
754  *
755  * returns:     0       - The data has been copied from user
756  *              -EFAULT - Memory I/O operation fault
757  */
758 static inline int
759 zfcp_sg_list_copy_from_user(struct zfcp_sg_list *sg_list, void *user_buffer,
760                             size_t size)
761 {
762         struct scatterlist *sg;
763         unsigned int length;
764         void *zfcp_buffer;
765         int retval = 0;
766
767         for (sg = sg_list->sg; size > 0; sg++) {
768                 length = min((unsigned int)size, sg->length);
769                 zfcp_buffer = (void*)
770                         ((page_to_pfn(sg->page) << PAGE_SHIFT) + sg->offset);
771                 if (copy_from_user(zfcp_buffer, user_buffer, length)) {
772                         retval = -EFAULT;
773                         goto out;
774                 }
775                 user_buffer += length;
776                 size -= length;
777         }
778
779  out:
780         return retval;
781 }
782
783
784 /*
785  * function:    zfcp_sg_list_copy_to_user
786  *
787  * purpose:     Copy data from the scatter-gather list to user space memory
788  *
789  * returns:     0       - The data has been copied to user
790  *              -EFAULT - Memory I/O operation fault
791  */
792 static inline int
793 zfcp_sg_list_copy_to_user(void *user_buffer, struct zfcp_sg_list *sg_list,
794                           size_t size)
795 {
796         struct scatterlist *sg;
797         unsigned int length;
798         void *zfcp_buffer;
799         int retval = 0;
800
801         for (sg = sg_list->sg; size > 0; sg++) {
802                 length = min((unsigned int)size, sg->length);
803                 zfcp_buffer = (void*)
804                         ((page_to_pfn(sg->page) << PAGE_SHIFT) + sg->offset);
805                 if (copy_to_user(user_buffer, zfcp_buffer, length)) {
806                         retval = -EFAULT;
807                         goto out;
808                 }
809                 user_buffer += length;
810                 size -= length;
811         }
812
813  out:
814         return retval;
815 }
816
817
818 #undef ZFCP_LOG_AREA
819
820 /****************************************************************/
821 /****** Functions for configuration/set-up of structures ********/
822 /****************************************************************/
823
824 #define ZFCP_LOG_AREA                   ZFCP_LOG_AREA_CONFIG
825
826 /**
827  * zfcp_get_unit_by_lun - find unit in unit list of port by fcp lun
828  * @port: pointer to port to search for unit
829  * @fcp_lun: lun to search for
830  * Traverses list of all units of a port and returns pointer to a unit
831  * if lun of a unit matches.
832  */
833
834 struct zfcp_unit *
835 zfcp_get_unit_by_lun(struct zfcp_port *port, fcp_lun_t fcp_lun)
836 {
837         struct zfcp_unit *unit;
838         int found = 0;
839
840         list_for_each_entry(unit, &port->unit_list_head, list) {
841                 if ((unit->fcp_lun == fcp_lun) &&
842                     !atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status))
843                 {
844                         found = 1;
845                         break;
846                 }
847         }
848         return found ? unit : NULL;
849 }
850
851 /**
852  * zfcp_get_port_by_wwpn - find unit in unit list of port by fcp lun
853  * @adapter: pointer to adapter to search for port
854  * @wwpn: wwpn to search for
855  * Traverses list of all ports of an adapter and returns a pointer to a port
856  * if wwpn of a port matches.
857  */
858
859 struct zfcp_port *
860 zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter, wwn_t wwpn)
861 {
862         struct zfcp_port *port;
863         int found = 0;
864
865         list_for_each_entry(port, &adapter->port_list_head, list) {
866                 if ((port->wwpn == wwpn) &&
867                     !atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status))
868                 {
869                         found = 1;
870                         break;
871                 }
872         }
873         return found ? port : NULL;
874 }
875
876 /*
877  * Enqueues a logical unit at the end of the unit list associated with the 
878  * specified port. Also sets up some unit internal structures.
879  *
880  * returns:     pointer to unit with a usecount of 1 if a new unit was
881  *              successfully enqueued
882  *              NULL otherwise
883  * locks:       config_sema must be held to serialise changes to the unit list
884  */
885 struct zfcp_unit *
886 zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun)
887 {
888         struct zfcp_unit *unit, *tmp_unit;
889         scsi_lun_t scsi_lun;
890         int found;
891
892         /*
893          * check that there is no unit with this FCP_LUN already in list
894          * and enqueue it.
895          * Note: Unlike for the adapter and the port, this is an error
896          */
897         read_lock_irq(&zfcp_data.config_lock);
898         unit = zfcp_get_unit_by_lun(port, fcp_lun);
899         read_unlock_irq(&zfcp_data.config_lock);
900         if (unit)
901                 return NULL;
902
903         unit = kmalloc(sizeof (struct zfcp_unit), GFP_KERNEL);
904         if (!unit)
905                 return NULL;
906         memset(unit, 0, sizeof (struct zfcp_unit));
907
908         init_waitqueue_head(&unit->scsi_add_wq);
909         /* initialise reference count stuff */
910         atomic_set(&unit->refcount, 0);
911         init_waitqueue_head(&unit->remove_wq);
912
913         unit->port = port;
914         unit->fcp_lun = fcp_lun;
915
916         /* setup for sysfs registration */
917         snprintf(unit->sysfs_device.bus_id, BUS_ID_SIZE, "0x%016llx", fcp_lun);
918         unit->sysfs_device.parent = &port->sysfs_device;
919         unit->sysfs_device.release = zfcp_sysfs_unit_release;
920         dev_set_drvdata(&unit->sysfs_device, unit);
921
922         /* mark unit unusable as long as sysfs registration is not complete */
923         atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
924
925         if (device_register(&unit->sysfs_device)) {
926                 kfree(unit);
927                 return NULL;
928         }
929
930         if (zfcp_sysfs_unit_create_files(&unit->sysfs_device)) {
931                 device_unregister(&unit->sysfs_device);
932                 return NULL;
933         }
934
935         zfcp_unit_get(unit);
936
937         scsi_lun = 0;
938         found = 0;
939         write_lock_irq(&zfcp_data.config_lock);
940         list_for_each_entry(tmp_unit, &port->unit_list_head, list) {
941                 if (tmp_unit->scsi_lun != scsi_lun) {
942                         found = 1;
943                         break;
944                 }
945                 scsi_lun++;
946         }
947         unit->scsi_lun = scsi_lun;
948         if (found)
949                 list_add_tail(&unit->list, &tmp_unit->list);
950         else
951                 list_add_tail(&unit->list, &port->unit_list_head);
952         atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
953         atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &unit->status);
954         write_unlock_irq(&zfcp_data.config_lock);
955
956         port->units++;
957         zfcp_port_get(port);
958
959         return unit;
960 }
961
962 void
963 zfcp_unit_dequeue(struct zfcp_unit *unit)
964 {
965         zfcp_unit_wait(unit);
966         write_lock_irq(&zfcp_data.config_lock);
967         list_del(&unit->list);
968         write_unlock_irq(&zfcp_data.config_lock);
969         unit->port->units--;
970         zfcp_port_put(unit->port);
971         zfcp_sysfs_unit_remove_files(&unit->sysfs_device);
972         device_unregister(&unit->sysfs_device);
973 }
974
975 static void *
976 zfcp_mempool_alloc(int gfp_mask, void *size)
977 {
978         return kmalloc((size_t) size, gfp_mask);
979 }
980
981 static void
982 zfcp_mempool_free(void *element, void *size)
983 {
984         kfree(element);
985 }
986
987 /*
988  * Allocates a combined QTCB/fsf_req buffer for erp actions and fcp/SCSI
989  * commands.
990  * It also genrates fcp-nameserver request/response buffer and unsolicited 
991  * status read fsf_req buffers.
992  *
993  * locks:       must only be called with zfcp_data.config_sema taken
994  */
995 static int
996 zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)
997 {
998         adapter->pool.fsf_req_erp =
999                 mempool_create(ZFCP_POOL_FSF_REQ_ERP_NR,
1000                                zfcp_mempool_alloc, zfcp_mempool_free, (void *)
1001                                sizeof(struct zfcp_fsf_req_pool_element));
1002
1003         if (NULL == adapter->pool.fsf_req_erp)
1004                 return -ENOMEM;
1005
1006         adapter->pool.fsf_req_scsi =
1007                 mempool_create(ZFCP_POOL_FSF_REQ_SCSI_NR,
1008                                zfcp_mempool_alloc, zfcp_mempool_free, (void *)
1009                                sizeof(struct zfcp_fsf_req_pool_element));
1010
1011         if (NULL == adapter->pool.fsf_req_scsi)
1012                 return -ENOMEM;
1013
1014         adapter->pool.fsf_req_abort =
1015                 mempool_create(ZFCP_POOL_FSF_REQ_ABORT_NR,
1016                                zfcp_mempool_alloc, zfcp_mempool_free, (void *)
1017                                sizeof(struct zfcp_fsf_req_pool_element));
1018
1019         if (NULL == adapter->pool.fsf_req_abort)
1020                 return -ENOMEM;
1021
1022         adapter->pool.fsf_req_status_read =
1023                 mempool_create(ZFCP_POOL_STATUS_READ_NR,
1024                                zfcp_mempool_alloc, zfcp_mempool_free,
1025                                (void *) sizeof(struct zfcp_fsf_req));
1026
1027         if (NULL == adapter->pool.fsf_req_status_read)
1028                 return -ENOMEM;
1029
1030         adapter->pool.data_status_read =
1031                 mempool_create(ZFCP_POOL_STATUS_READ_NR,
1032                                zfcp_mempool_alloc, zfcp_mempool_free,
1033                                (void *) sizeof(struct fsf_status_read_buffer));
1034
1035         if (NULL == adapter->pool.data_status_read)
1036                 return -ENOMEM;
1037
1038         adapter->pool.data_gid_pn =
1039                 mempool_create(ZFCP_POOL_DATA_GID_PN_NR,
1040                                zfcp_mempool_alloc, zfcp_mempool_free, (void *)
1041                                sizeof(struct zfcp_gid_pn_data));
1042
1043         if (NULL == adapter->pool.data_gid_pn)
1044                 return -ENOMEM;
1045
1046         return 0;
1047 }
1048
1049 /**
1050  * zfcp_free_low_mem_buffers - free memory pools of an adapter
1051  * @adapter: pointer to zfcp_adapter for which memory pools should be freed
1052  * locking:  zfcp_data.config_sema must be held
1053  */
1054 static void
1055 zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter)
1056 {
1057         if (adapter->pool.fsf_req_erp)
1058                 mempool_destroy(adapter->pool.fsf_req_erp);
1059         if (adapter->pool.fsf_req_scsi)
1060                 mempool_destroy(adapter->pool.fsf_req_scsi);
1061         if (adapter->pool.fsf_req_abort)
1062                 mempool_destroy(adapter->pool.fsf_req_abort);
1063         if (adapter->pool.fsf_req_status_read)
1064                 mempool_destroy(adapter->pool.fsf_req_status_read);
1065         if (adapter->pool.data_status_read)
1066                 mempool_destroy(adapter->pool.data_status_read);
1067         if (adapter->pool.data_gid_pn)
1068                 mempool_destroy(adapter->pool.data_gid_pn);
1069 }
1070
1071 /**
1072  * zfcp_adapter_debug_register - registers debug feature for an adapter
1073  * @adapter: pointer to adapter for which debug features should be registered
1074  * return: -ENOMEM on error, 0 otherwise
1075  */
1076 int
1077 zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
1078 {
1079         char dbf_name[20];
1080
1081         /* debug feature area which records SCSI command failures (hostbyte) */
1082         rwlock_init(&adapter->cmd_dbf_lock);
1083         sprintf(dbf_name, ZFCP_CMD_DBF_NAME "%s",
1084                 zfcp_get_busid_by_adapter(adapter));
1085         adapter->cmd_dbf = debug_register(dbf_name,
1086                                           ZFCP_CMD_DBF_INDEX,
1087                                           ZFCP_CMD_DBF_AREAS,
1088                                           ZFCP_CMD_DBF_LENGTH);
1089         debug_register_view(adapter->cmd_dbf, &debug_hex_ascii_view);
1090         debug_set_level(adapter->cmd_dbf, ZFCP_CMD_DBF_LEVEL);
1091
1092         /* debug feature area which records SCSI command aborts */
1093         sprintf(dbf_name, ZFCP_ABORT_DBF_NAME "%s",
1094                 zfcp_get_busid_by_adapter(adapter));
1095         adapter->abort_dbf = debug_register(dbf_name,
1096                                             ZFCP_ABORT_DBF_INDEX,
1097                                             ZFCP_ABORT_DBF_AREAS,
1098                                             ZFCP_ABORT_DBF_LENGTH);
1099         debug_register_view(adapter->abort_dbf, &debug_hex_ascii_view);
1100         debug_set_level(adapter->abort_dbf, ZFCP_ABORT_DBF_LEVEL);
1101
1102         /* debug feature area which records SCSI command aborts */
1103         sprintf(dbf_name, ZFCP_IN_ELS_DBF_NAME "%s",
1104                 zfcp_get_busid_by_adapter(adapter));
1105         adapter->in_els_dbf = debug_register(dbf_name,
1106                                              ZFCP_IN_ELS_DBF_INDEX,
1107                                              ZFCP_IN_ELS_DBF_AREAS,
1108                                              ZFCP_IN_ELS_DBF_LENGTH);
1109         debug_register_view(adapter->in_els_dbf, &debug_hex_ascii_view);
1110         debug_set_level(adapter->in_els_dbf, ZFCP_IN_ELS_DBF_LEVEL);
1111
1112
1113         /* debug feature area which records erp events */
1114         sprintf(dbf_name, ZFCP_ERP_DBF_NAME "%s",
1115                 zfcp_get_busid_by_adapter(adapter));
1116         adapter->erp_dbf = debug_register(dbf_name,
1117                                           ZFCP_ERP_DBF_INDEX,
1118                                           ZFCP_ERP_DBF_AREAS,
1119                                           ZFCP_ERP_DBF_LENGTH);
1120         debug_register_view(adapter->erp_dbf, &debug_hex_ascii_view);
1121         debug_set_level(adapter->erp_dbf, ZFCP_ERP_DBF_LEVEL);
1122
1123         if (adapter->cmd_dbf && adapter->abort_dbf &&
1124             adapter->in_els_dbf && adapter->erp_dbf)
1125                 return 0;
1126
1127         zfcp_adapter_debug_unregister(adapter);
1128         return -ENOMEM;
1129 }
1130
1131 /**
1132  * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
1133  * @adapter: pointer to adapter for which debug features should be unregistered
1134  */
1135 void
1136 zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter)
1137 {
1138         debug_unregister(adapter->erp_dbf);
1139         debug_unregister(adapter->cmd_dbf);
1140         debug_unregister(adapter->abort_dbf);
1141         debug_unregister(adapter->in_els_dbf);
1142 }
1143
1144 /*
1145  * Enqueues an adapter at the end of the adapter list in the driver data.
1146  * All adapter internal structures are set up.
1147  * Proc-fs entries are also created.
1148  *
1149  * returns:     0             if a new adapter was successfully enqueued
1150  *              ZFCP_KNOWN    if an adapter with this devno was already present
1151  *              -ENOMEM       if alloc failed
1152  * locks:       config_sema must be held to serialise changes to the adapter list
1153  */
1154 struct zfcp_adapter *
1155 zfcp_adapter_enqueue(struct ccw_device *ccw_device)
1156 {
1157         int retval = 0;
1158         struct zfcp_adapter *adapter;
1159
1160         /*
1161          * Note: It is safe to release the list_lock, as any list changes 
1162          * are protected by the config_sema, which must be held to get here
1163          */
1164
1165         /* try to allocate new adapter data structure (zeroed) */
1166         adapter = kmalloc(sizeof (struct zfcp_adapter), GFP_KERNEL);
1167         if (!adapter) {
1168                 ZFCP_LOG_INFO("error: allocation of base adapter "
1169                               "structure failed\n");
1170                 goto out;
1171         }
1172         memset(adapter, 0, sizeof (struct zfcp_adapter));
1173
1174         ccw_device->handler = NULL;
1175
1176         /* save ccw_device pointer */
1177         adapter->ccw_device = ccw_device;
1178
1179         retval = zfcp_qdio_allocate_queues(adapter);
1180         if (retval)
1181                 goto queues_alloc_failed;
1182
1183         retval = zfcp_qdio_allocate(adapter);
1184         if (retval)
1185                 goto qdio_allocate_failed;
1186
1187         retval = zfcp_allocate_low_mem_buffers(adapter);
1188         if (retval) {
1189                 ZFCP_LOG_INFO("error: pool allocation failed\n");
1190                 goto failed_low_mem_buffers;
1191         }
1192
1193         /* initialise reference count stuff */
1194         atomic_set(&adapter->refcount, 0);
1195         init_waitqueue_head(&adapter->remove_wq);
1196
1197         /* initialise list of ports */
1198         INIT_LIST_HEAD(&adapter->port_list_head);
1199
1200         /* initialise list of ports to be removed */
1201         INIT_LIST_HEAD(&adapter->port_remove_lh);
1202
1203         /* initialize list of fsf requests */
1204         rwlock_init(&adapter->fsf_req_list_lock);
1205         INIT_LIST_HEAD(&adapter->fsf_req_list_head);
1206
1207         /* initialize abort lock */
1208         rwlock_init(&adapter->abort_lock);
1209
1210         /* initialise some erp stuff */
1211         init_waitqueue_head(&adapter->erp_thread_wqh);
1212         init_waitqueue_head(&adapter->erp_done_wqh);
1213
1214         /* initialize lock of associated request queue */
1215         rwlock_init(&adapter->request_queue.queue_lock);
1216
1217         /* intitialise SCSI ER timer */
1218         init_timer(&adapter->scsi_er_timer);
1219
1220         /* set FC service class used per default */
1221         adapter->fc_service_class = ZFCP_FC_SERVICE_CLASS_DEFAULT;
1222
1223         sprintf(adapter->name, "%s", zfcp_get_busid_by_adapter(adapter));
1224         ASCEBC(adapter->name, strlen(adapter->name));
1225
1226         /* mark adapter unusable as long as sysfs registration is not complete */
1227         atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
1228
1229         adapter->ccw_device = ccw_device;
1230         dev_set_drvdata(&ccw_device->dev, adapter);
1231
1232         if (zfcp_sysfs_adapter_create_files(&ccw_device->dev))
1233                 goto sysfs_failed;
1234
1235         /* put allocated adapter at list tail */
1236         write_lock_irq(&zfcp_data.config_lock);
1237         atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
1238         list_add_tail(&adapter->list, &zfcp_data.adapter_list_head);
1239         write_unlock_irq(&zfcp_data.config_lock);
1240
1241         zfcp_data.adapters++;
1242
1243         goto out;
1244
1245  sysfs_failed:
1246         dev_set_drvdata(&ccw_device->dev, NULL);
1247  failed_low_mem_buffers:
1248         zfcp_free_low_mem_buffers(adapter);
1249         if (qdio_free(ccw_device) != 0)
1250                 ZFCP_LOG_NORMAL("bug: qdio_free for adapter %s failed\n",
1251                                 zfcp_get_busid_by_adapter(adapter));
1252  qdio_allocate_failed:
1253         zfcp_qdio_free_queues(adapter);
1254  queues_alloc_failed:
1255         kfree(adapter);
1256         adapter = NULL;
1257  out:
1258         return adapter;
1259 }
1260
1261 /*
1262  * returns:     0 - struct zfcp_adapter  data structure successfully removed
1263  *              !0 - struct zfcp_adapter  data structure could not be removed
1264  *                      (e.g. still used)
1265  * locks:       adapter list write lock is assumed to be held by caller
1266  *              adapter->fsf_req_list_lock is taken and released within this 
1267  *              function and must not be held on entry
1268  */
1269 void
1270 zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
1271 {
1272         int retval = 0;
1273         unsigned long flags;
1274
1275         zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev);
1276         dev_set_drvdata(&adapter->ccw_device->dev, NULL);
1277         /* sanity check: no pending FSF requests */
1278         read_lock_irqsave(&adapter->fsf_req_list_lock, flags);
1279         retval = !list_empty(&adapter->fsf_req_list_head);
1280         read_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
1281         if (retval) {
1282                 ZFCP_LOG_NORMAL("bug: adapter %s (%p) still in use, "
1283                                 "%i requests outstanding\n",
1284                                 zfcp_get_busid_by_adapter(adapter), adapter,
1285                                 atomic_read(&adapter->fsf_reqs_active));
1286                 retval = -EBUSY;
1287                 goto out;
1288         }
1289
1290         /* remove specified adapter data structure from list */
1291         write_lock_irq(&zfcp_data.config_lock);
1292         list_del(&adapter->list);
1293         write_unlock_irq(&zfcp_data.config_lock);
1294
1295         /* decrease number of adapters in list */
1296         zfcp_data.adapters--;
1297
1298         ZFCP_LOG_TRACE("adapter %s (%p) removed from list, "
1299                        "%i adapters still in list\n",
1300                        zfcp_get_busid_by_adapter(adapter),
1301                        adapter, zfcp_data.adapters);
1302
1303         retval = qdio_free(adapter->ccw_device);
1304         if (retval)
1305                 ZFCP_LOG_NORMAL("bug: qdio_free for adapter %s failed\n",
1306                                 zfcp_get_busid_by_adapter(adapter));
1307
1308         zfcp_free_low_mem_buffers(adapter);
1309         /* free memory of adapter data structure and queues */
1310         zfcp_qdio_free_queues(adapter);
1311         ZFCP_LOG_TRACE("freeing adapter structure\n");
1312         kfree(adapter);
1313  out:
1314         return;
1315 }
1316
1317 /*
1318  * Enqueues a remote port to the port list. All port internal structures
1319  * are set up and the sysfs entry is also generated.
1320  *
1321  * returns:     pointer to port or NULL
1322  * locks:       config_sema must be held to serialise changes to the port list
1323  */
1324 struct zfcp_port *
1325 zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, u32 status)
1326 {
1327         struct zfcp_port *port, *tmp_port;
1328         int check_wwpn;
1329         scsi_id_t scsi_id;
1330         int found;
1331
1332         check_wwpn = !(status & ZFCP_STATUS_PORT_NO_WWPN);
1333
1334         /*
1335          * check that there is no port with this WWPN already in list
1336          */
1337         if (check_wwpn) {
1338                 read_lock_irq(&zfcp_data.config_lock);
1339                 port = zfcp_get_port_by_wwpn(adapter, wwpn);
1340                 read_unlock_irq(&zfcp_data.config_lock);
1341                 if (port)
1342                         return NULL;
1343         }
1344
1345         port = kmalloc(sizeof (struct zfcp_port), GFP_KERNEL);
1346         if (!port)
1347                 return NULL;
1348         memset(port, 0, sizeof (struct zfcp_port));
1349
1350         /* initialise reference count stuff */
1351         atomic_set(&port->refcount, 0);
1352         init_waitqueue_head(&port->remove_wq);
1353
1354         INIT_LIST_HEAD(&port->unit_list_head);
1355         INIT_LIST_HEAD(&port->unit_remove_lh);
1356
1357         port->adapter = adapter;
1358
1359         if (check_wwpn)
1360                 port->wwpn = wwpn;
1361
1362         atomic_set_mask(status, &port->status);
1363
1364         /* setup for sysfs registration */
1365         if (status & ZFCP_STATUS_PORT_NAMESERVER)
1366                 snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE, "nameserver");
1367         else
1368                 snprintf(port->sysfs_device.bus_id,
1369                          BUS_ID_SIZE, "0x%016llx", wwpn);
1370         port->sysfs_device.parent = &adapter->ccw_device->dev;
1371         port->sysfs_device.release = zfcp_sysfs_port_release;
1372         dev_set_drvdata(&port->sysfs_device, port);
1373
1374         /* mark port unusable as long as sysfs registration is not complete */
1375         atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
1376
1377         if (device_register(&port->sysfs_device)) {
1378                 kfree(port);
1379                 return NULL;
1380         }
1381
1382         if (zfcp_sysfs_port_create_files(&port->sysfs_device, status)) {
1383                 device_unregister(&port->sysfs_device);
1384                 return NULL;
1385         }
1386
1387         zfcp_port_get(port);
1388
1389         scsi_id = 1;
1390         found = 0;
1391         write_lock_irq(&zfcp_data.config_lock);
1392         list_for_each_entry(tmp_port, &adapter->port_list_head, list) {
1393                 if (atomic_test_mask(ZFCP_STATUS_PORT_NO_SCSI_ID,
1394                                      &tmp_port->status))
1395                         continue;
1396                 if (tmp_port->scsi_id != scsi_id) {
1397                         found = 1;
1398                         break;
1399                 }
1400                 scsi_id++;
1401         }
1402         port->scsi_id = scsi_id;
1403         if (found)
1404                 list_add_tail(&port->list, &tmp_port->list);
1405         else
1406                 list_add_tail(&port->list, &adapter->port_list_head);
1407         atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
1408         atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &port->status);
1409         write_unlock_irq(&zfcp_data.config_lock);
1410
1411         adapter->ports++;
1412         zfcp_adapter_get(adapter);
1413
1414         return port;
1415 }
1416
1417 void
1418 zfcp_port_dequeue(struct zfcp_port *port)
1419 {
1420         zfcp_port_wait(port);
1421         write_lock_irq(&zfcp_data.config_lock);
1422         list_del(&port->list);
1423         write_unlock_irq(&zfcp_data.config_lock);
1424         port->adapter->ports--;
1425         zfcp_adapter_put(port->adapter);
1426         zfcp_sysfs_port_remove_files(&port->sysfs_device,
1427                                      atomic_read(&port->status));
1428         device_unregister(&port->sysfs_device);
1429 }
1430
1431 /* Enqueues a nameserver port */
1432 int
1433 zfcp_nameserver_enqueue(struct zfcp_adapter *adapter)
1434 {
1435         struct zfcp_port *port;
1436
1437         /* generate port structure */
1438         port = zfcp_port_enqueue(adapter, 0, ZFCP_STATUS_PORT_NAMESERVER);
1439         if (!port) {
1440                 ZFCP_LOG_INFO("error: enqueue of nameserver port for "
1441                               "adapter %s failed\n",
1442                               zfcp_get_busid_by_adapter(adapter));
1443                 return -ENXIO;
1444         }
1445         /* set special D_ID */
1446         port->d_id = ZFCP_DID_NAMESERVER;
1447         adapter->nameserver_port = port;
1448         zfcp_port_put(port);
1449
1450         return 0;
1451 }
1452
1453 #undef ZFCP_LOG_AREA
1454
1455 /****************************************************************/
1456 /******* Fibre Channel Standard related Functions  **************/
1457 /****************************************************************/
1458
1459 #define ZFCP_LOG_AREA                   ZFCP_LOG_AREA_FC
1460
1461 void
1462 zfcp_fsf_incoming_els_rscn(struct zfcp_adapter *adapter,
1463                            struct fsf_status_read_buffer *status_buffer)
1464 {
1465         struct fcp_rscn_head *fcp_rscn_head;
1466         struct fcp_rscn_element *fcp_rscn_element;
1467         struct zfcp_port *port;
1468         u16 i;
1469         u16 no_entries;
1470         u32 range_mask;
1471         unsigned long flags;
1472
1473         fcp_rscn_head = (struct fcp_rscn_head *) status_buffer->payload;
1474         fcp_rscn_element = (struct fcp_rscn_element *) status_buffer->payload;
1475
1476         /* see FC-FS */
1477         no_entries = (fcp_rscn_head->payload_len / 4);
1478
1479         zfcp_in_els_dbf_event(adapter, "##rscn", status_buffer,
1480                               fcp_rscn_head->payload_len);
1481
1482         debug_text_event(adapter->erp_dbf, 1, "unsol_els_rscn:");
1483         for (i = 1; i < no_entries; i++) {
1484                 /* skip head and start with 1st element */
1485                 fcp_rscn_element++;
1486                 switch (fcp_rscn_element->addr_format) {
1487                 case ZFCP_PORT_ADDRESS:
1488                         ZFCP_LOG_FLAGS(1, "ZFCP_PORT_ADDRESS\n");
1489                         range_mask = ZFCP_PORTS_RANGE_PORT;
1490                         break;
1491                 case ZFCP_AREA_ADDRESS:
1492                         ZFCP_LOG_FLAGS(1, "ZFCP_AREA_ADDRESS\n");
1493                         range_mask = ZFCP_PORTS_RANGE_AREA;
1494                         break;
1495                 case ZFCP_DOMAIN_ADDRESS:
1496                         ZFCP_LOG_FLAGS(1, "ZFCP_DOMAIN_ADDRESS\n");
1497                         range_mask = ZFCP_PORTS_RANGE_DOMAIN;
1498                         break;
1499                 case ZFCP_FABRIC_ADDRESS:
1500                         ZFCP_LOG_FLAGS(1, "ZFCP_FABRIC_ADDRESS\n");
1501                         range_mask = ZFCP_PORTS_RANGE_FABRIC;
1502                         break;
1503                 default:
1504                         ZFCP_LOG_INFO("incoming RSCN with unknown "
1505                                       "address format\n");
1506                         continue;
1507                 }
1508                 read_lock_irqsave(&zfcp_data.config_lock, flags);
1509                 list_for_each_entry(port, &adapter->port_list_head, list) {
1510                         if (atomic_test_mask
1511                             (ZFCP_STATUS_PORT_NAMESERVER, &port->status))
1512                                 continue;
1513                         /* Do we know this port? If not skip it. */
1514                         if (!atomic_test_mask
1515                             (ZFCP_STATUS_PORT_DID_DID, &port->status)) {
1516                                 ZFCP_LOG_INFO("incoming RSCN, trying to open "
1517                                               "port 0x%016Lx\n", port->wwpn);
1518                                 debug_text_event(adapter->erp_dbf, 1,
1519                                                  "unsol_els_rscnu:");
1520                                 zfcp_erp_port_reopen(port,
1521                                                      ZFCP_STATUS_COMMON_ERP_FAILED);
1522                                 continue;
1523                         }
1524
1525                         /*
1526                          * FIXME: race: d_id might being invalidated
1527                          * (...DID_DID reset)
1528                          */
1529                         if ((port->d_id & range_mask)
1530                             == (fcp_rscn_element->nport_did & range_mask)) {
1531                                 ZFCP_LOG_TRACE("reopen did 0x%08x\n",
1532                                                fcp_rscn_element->nport_did);
1533                                 /*
1534                                  * Unfortunately, an RSCN does not specify the
1535                                  * type of change a target underwent. We assume
1536                                  * that it makes sense to reopen the link.
1537                                  * FIXME: Shall we try to find out more about
1538                                  * the target and link state before closing it?
1539                                  * How to accomplish this? (nameserver?)
1540                                  * Where would such code be put in?
1541                                  * (inside or outside erp)
1542                                  */
1543                                 ZFCP_LOG_INFO("incoming RSCN, trying to open "
1544                                               "port 0x%016Lx\n", port->wwpn);
1545                                 debug_text_event(adapter->erp_dbf, 1,
1546                                                  "unsol_els_rscnk:");
1547                                 zfcp_test_link(port);
1548                         }
1549                 }
1550                 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1551         }
1552 }
1553
1554 static void
1555 zfcp_fsf_incoming_els_plogi(struct zfcp_adapter *adapter,
1556                             struct fsf_status_read_buffer *status_buffer)
1557 {
1558         logi *els_logi = (logi *) status_buffer->payload;
1559         struct zfcp_port *port;
1560         unsigned long flags;
1561
1562         zfcp_in_els_dbf_event(adapter, "##plogi", status_buffer, 28);
1563
1564         read_lock_irqsave(&zfcp_data.config_lock, flags);
1565         list_for_each_entry(port, &adapter->port_list_head, list) {
1566                 if (port->wwpn == (*(wwn_t *) & els_logi->nport_wwn))
1567                         break;
1568         }
1569         read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1570
1571         if (!port || (port->wwpn != (*(wwn_t *) & els_logi->nport_wwn))) {
1572                 ZFCP_LOG_DEBUG("ignored incoming PLOGI for nonexisting port "
1573                                "with d_id 0x%08x on adapter %s\n",
1574                                status_buffer->d_id,
1575                                zfcp_get_busid_by_adapter(adapter));
1576         } else {
1577                 debug_text_event(adapter->erp_dbf, 1, "unsol_els_plogi:");
1578                 debug_event(adapter->erp_dbf, 1, &els_logi->nport_wwn, 8);
1579                 zfcp_erp_port_forced_reopen(port, 0);
1580         }
1581 }
1582
1583 static void
1584 zfcp_fsf_incoming_els_logo(struct zfcp_adapter *adapter,
1585                            struct fsf_status_read_buffer *status_buffer)
1586 {
1587         struct fcp_logo *els_logo = (struct fcp_logo *) status_buffer->payload;
1588         struct zfcp_port *port;
1589         unsigned long flags;
1590
1591         zfcp_in_els_dbf_event(adapter, "##logo", status_buffer, 16);
1592
1593         read_lock_irqsave(&zfcp_data.config_lock, flags);
1594         list_for_each_entry(port, &adapter->port_list_head, list) {
1595                 if (port->wwpn == els_logo->nport_wwpn)
1596                         break;
1597         }
1598         read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1599
1600         if (!port || (port->wwpn != els_logo->nport_wwpn)) {
1601                 ZFCP_LOG_DEBUG("ignored incoming LOGO for nonexisting port "
1602                                "with d_id 0x%08x on adapter %s\n",
1603                                status_buffer->d_id,
1604                                zfcp_get_busid_by_adapter(adapter));
1605         } else {
1606                 debug_text_event(adapter->erp_dbf, 1, "unsol_els_logo:");
1607                 debug_event(adapter->erp_dbf, 1, &els_logo->nport_wwpn, 8);
1608                 zfcp_erp_port_forced_reopen(port, 0);
1609         }
1610 }
1611
1612 static void
1613 zfcp_fsf_incoming_els_unknown(struct zfcp_adapter *adapter,
1614                               struct fsf_status_read_buffer *status_buffer)
1615 {
1616         zfcp_in_els_dbf_event(adapter, "##undef", status_buffer, 24);
1617         ZFCP_LOG_NORMAL("warning: unknown incoming ELS 0x%08x "
1618                         "for adapter %s\n", *(u32 *) (status_buffer->payload),
1619                         zfcp_get_busid_by_adapter(adapter));
1620
1621 }
1622
1623 void
1624 zfcp_fsf_incoming_els(struct zfcp_fsf_req *fsf_req)
1625 {
1626         struct fsf_status_read_buffer *status_buffer;
1627         u32 els_type;
1628         struct zfcp_adapter *adapter;
1629
1630         status_buffer = fsf_req->data.status_read.buffer;
1631         els_type = *(u32 *) (status_buffer->payload);
1632         adapter = fsf_req->adapter;
1633
1634         if (els_type == LS_PLOGI)
1635                 zfcp_fsf_incoming_els_plogi(adapter, status_buffer);
1636         else if (els_type == LS_LOGO)
1637                 zfcp_fsf_incoming_els_logo(adapter, status_buffer);
1638         else if ((els_type & 0xffff0000) == LS_RSCN)
1639                 /* we are only concerned with the command, not the length */
1640                 zfcp_fsf_incoming_els_rscn(adapter, status_buffer);
1641         else
1642                 zfcp_fsf_incoming_els_unknown(adapter, status_buffer);
1643
1644 }
1645
1646
1647 /**
1648  * zfcp_gid_pn_buffers_alloc - allocate buffers for GID_PN nameserver request
1649  * @gid_pn: pointer to return pointer to struct zfcp_gid_pn_data
1650  * @pool: pointer to mempool_t if non-null memory pool is used for allocation
1651  */
1652 static int
1653 zfcp_gid_pn_buffers_alloc(struct zfcp_gid_pn_data **gid_pn, mempool_t *pool)
1654 {
1655         struct zfcp_gid_pn_data *data;
1656
1657         if (pool != NULL) {
1658                 data = mempool_alloc(pool, GFP_ATOMIC);
1659                 if (likely(data != NULL)) {
1660                         data->ct.pool = pool;
1661                 }
1662         } else {
1663                 data = kmalloc(sizeof(struct zfcp_gid_pn_data), GFP_ATOMIC);
1664         }
1665
1666         if (NULL == data)
1667                 return -ENOMEM;
1668
1669         memset(data, 0, sizeof(*data));
1670         data->ct.req = &data->req;
1671         data->ct.resp = &data->resp;
1672         data->ct.req_count = data->ct.resp_count = 1;
1673         zfcp_address_to_sg(&data->ct_iu_req, &data->req);
1674         zfcp_address_to_sg(&data->ct_iu_resp, &data->resp);
1675         data->req.length = sizeof(struct ct_iu_gid_pn_req);
1676         data->resp.length = sizeof(struct ct_iu_gid_pn_resp);
1677
1678         *gid_pn = data;
1679         return 0;
1680 }
1681
1682 /**
1683  * zfcp_gid_pn_buffers_free - free buffers for GID_PN nameserver request
1684  * @gid_pn: pointer to struct zfcp_gid_pn_data which has to be freed
1685  */
1686 static void
1687 zfcp_gid_pn_buffers_free(struct zfcp_gid_pn_data *gid_pn)
1688 {
1689         if ((gid_pn->ct.pool != 0))
1690                 mempool_free(gid_pn, gid_pn->ct.pool);
1691         else
1692                 kfree(gid_pn);
1693
1694         return;
1695 }
1696
1697 /**
1698  * zfcp_ns_gid_pn_request - initiate GID_PN nameserver request
1699  * @erp_action: pointer to zfcp_erp_action where GID_PN request is needed
1700  */
1701 int
1702 zfcp_ns_gid_pn_request(struct zfcp_erp_action *erp_action)
1703 {
1704         int ret;
1705         struct ct_iu_gid_pn_req *ct_iu_req;
1706         struct zfcp_gid_pn_data *gid_pn;
1707         struct zfcp_adapter *adapter = erp_action->adapter;
1708
1709         ret = zfcp_gid_pn_buffers_alloc(&gid_pn, adapter->pool.data_gid_pn);
1710         if (ret < 0) {
1711                 ZFCP_LOG_INFO("error: buffer allocation for gid_pn nameserver "
1712                               "request failed for adapter %s\n",
1713                               zfcp_get_busid_by_adapter(adapter));
1714                 goto out;
1715         }
1716
1717         /* setup nameserver request */
1718         ct_iu_req = zfcp_sg_to_address(gid_pn->ct.req);
1719         ct_iu_req->header.revision = ZFCP_CT_REVISION;
1720         ct_iu_req->header.gs_type = ZFCP_CT_DIRECTORY_SERVICE;
1721         ct_iu_req->header.gs_subtype = ZFCP_CT_NAME_SERVER;
1722         ct_iu_req->header.options = ZFCP_CT_SYNCHRONOUS;
1723         ct_iu_req->header.cmd_rsp_code = ZFCP_CT_GID_PN;
1724         ct_iu_req->header.max_res_size = ZFCP_CT_MAX_SIZE;
1725         ct_iu_req->wwpn = erp_action->port->wwpn;
1726
1727         /* setup parameters for send generic command */
1728         gid_pn->ct.port = adapter->nameserver_port;
1729         gid_pn->ct.handler = zfcp_ns_gid_pn_handler;
1730         gid_pn->ct.handler_data = (unsigned long) gid_pn;
1731         gid_pn->ct.timeout = ZFCP_NS_GID_PN_TIMEOUT;
1732         gid_pn->ct.timer = &erp_action->timer;
1733         gid_pn->port = erp_action->port;
1734
1735         ret = zfcp_fsf_send_ct(&gid_pn->ct, adapter->pool.fsf_req_erp,
1736                                erp_action);
1737         if (ret) {
1738                 ZFCP_LOG_INFO("error: initiation of gid_pn nameserver request "
1739                               "failed for adapter %s\n",
1740                               zfcp_get_busid_by_adapter(adapter));
1741
1742                 zfcp_gid_pn_buffers_free(gid_pn);
1743         }
1744
1745  out:
1746         return ret;
1747 }
1748
1749 /**
1750  * zfcp_ns_gid_pn_handler - handler for GID_PN nameserver request
1751  * @data: unsigned long, contains pointer to struct zfcp_gid_pn_data
1752  */
1753 static void zfcp_ns_gid_pn_handler(unsigned long data)
1754 {
1755         struct zfcp_port *port;
1756         struct zfcp_send_ct *ct;
1757         struct ct_iu_gid_pn_req *ct_iu_req;
1758         struct ct_iu_gid_pn_resp *ct_iu_resp;
1759         struct zfcp_gid_pn_data *gid_pn;
1760
1761
1762         gid_pn = (struct zfcp_gid_pn_data *) data;
1763         port = gid_pn->port;
1764         ct = &gid_pn->ct;
1765         ct_iu_req = zfcp_sg_to_address(ct->req);
1766         ct_iu_resp = zfcp_sg_to_address(ct->resp);
1767
1768         if (ct_iu_resp->header.revision != ZFCP_CT_REVISION)
1769                 goto failed;
1770         if (ct_iu_resp->header.gs_type != ZFCP_CT_DIRECTORY_SERVICE)
1771                 goto failed;
1772         if (ct_iu_resp->header.gs_subtype != ZFCP_CT_NAME_SERVER)
1773                 goto failed;
1774         if (ct_iu_resp->header.options != ZFCP_CT_SYNCHRONOUS)
1775                 goto failed;
1776         if (ct_iu_resp->header.cmd_rsp_code != ZFCP_CT_ACCEPT) {
1777                 /* FIXME: do we need some specific erp entry points */
1778                 atomic_set_mask(ZFCP_STATUS_PORT_INVALID_WWPN, &port->status);
1779                 goto failed;
1780         }
1781         /* paranoia */
1782         if (ct_iu_req->wwpn != port->wwpn) {
1783                 ZFCP_LOG_NORMAL("bug: wwpn 0x%016Lx returned by nameserver "
1784                                 "lookup does not match expected wwpn 0x%016Lx "
1785                                 "for adapter %s\n", ct_iu_req->wwpn, port->wwpn,
1786                                 zfcp_get_busid_by_port(port));
1787                 goto failed;
1788         }
1789
1790         /* looks like a valid d_id */
1791         port->d_id = ct_iu_resp->d_id & ZFCP_DID_MASK;
1792         atomic_set_mask(ZFCP_STATUS_PORT_DID_DID, &port->status);
1793         ZFCP_LOG_DEBUG("adapter %s:  wwpn=0x%016Lx ---> d_id=0x%08x\n",
1794                        zfcp_get_busid_by_port(port), port->wwpn, port->d_id);
1795         goto out;
1796
1797 failed:
1798         ZFCP_LOG_NORMAL("warning: failed gid_pn nameserver request for wwpn "
1799                         "0x%016Lx for adapter %s\n",
1800                         port->wwpn, zfcp_get_busid_by_port(port));
1801         ZFCP_LOG_DEBUG("CT IUs do not match:\n");
1802         ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, (char *) ct_iu_req,
1803                       sizeof(struct ct_iu_gid_pn_req));
1804         ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, (char *) ct_iu_resp,
1805                       sizeof(struct ct_iu_gid_pn_resp));
1806
1807  out:
1808         zfcp_gid_pn_buffers_free(gid_pn);
1809         return;
1810 }
1811
1812 #undef ZFCP_LOG_AREA