4 * Module interface and handling of zfcp data structures.
6 * Copyright IBM Corporation 2002, 2008
11 * Martin Peschke (originator of the driver)
16 * Heiko Carstens (kernel 2.6 port of the driver)
28 #include <linux/miscdevice.h>
32 /*********************** FUNCTION PROTOTYPES *********************************/
34 /* written against the module interface */
35 static int __init zfcp_module_init(void);
37 /*********************** KERNEL/MODULE PARAMETERS ***************************/
39 /* declare driver module init/cleanup functions */
40 module_init(zfcp_module_init);
42 MODULE_AUTHOR("IBM Deutschland Entwicklung GmbH - linux390@de.ibm.com");
44 ("FCP (SCSI over Fibre Channel) HBA driver for IBM System z9 and zSeries");
45 MODULE_LICENSE("GPL");
47 module_param(device, charp, 0400);
48 MODULE_PARM_DESC(device, "specify initial device");
50 /****************************************************************/
51 /************** Functions without logging ***********************/
52 /****************************************************************/
55 _zfcp_hex_dump(char *addr, int count)
58 for (i = 0; i < count; i++) {
59 printk("%02x", addr[i]);
65 if (((i-1) % 32) != 31)
70 /****************************************************************/
71 /****** Functions to handle the request ID hash table ********/
72 /****************************************************************/
74 static int zfcp_reqlist_alloc(struct zfcp_adapter *adapter)
78 adapter->req_list = kcalloc(REQUEST_LIST_SIZE, sizeof(struct list_head),
80 if (!adapter->req_list)
83 for (idx = 0; idx < REQUEST_LIST_SIZE; idx++)
84 INIT_LIST_HEAD(&adapter->req_list[idx]);
88 static void zfcp_reqlist_free(struct zfcp_adapter *adapter)
90 kfree(adapter->req_list);
93 int zfcp_reqlist_isempty(struct zfcp_adapter *adapter)
97 for (idx = 0; idx < REQUEST_LIST_SIZE; idx++)
98 if (!list_empty(&adapter->req_list[idx]))
103 /****************************************************************/
104 /************** Uncategorised Functions *************************/
105 /****************************************************************/
108 * zfcp_device_setup - setup function
109 * @str: pointer to parameter string
111 * Parse "device=..." parameter string.
114 zfcp_device_setup(char *devstr)
122 len = strlen(devstr) + 1;
123 str = kmalloc(len, GFP_KERNEL);
125 pr_err("zfcp: Could not allocate memory for "
126 "device parameter string, device not attached.\n");
129 memcpy(str, devstr, len);
131 tmp = strchr(str, ',');
135 strncpy(zfcp_data.init_busid, str, BUS_ID_SIZE);
136 zfcp_data.init_busid[BUS_ID_SIZE-1] = '\0';
138 zfcp_data.init_wwpn = simple_strtoull(tmp, &tmp, 0);
144 zfcp_data.init_fcp_lun = simple_strtoull(tmp, &tmp, 0);
151 pr_err("zfcp: Parse error for device parameter string %s, "
152 "device not attached.\n", str);
158 zfcp_init_device_configure(void)
160 struct zfcp_adapter *adapter;
161 struct zfcp_port *port;
162 struct zfcp_unit *unit;
164 down(&zfcp_data.config_sema);
165 read_lock_irq(&zfcp_data.config_lock);
166 adapter = zfcp_get_adapter_by_busid(zfcp_data.init_busid);
168 zfcp_adapter_get(adapter);
169 read_unlock_irq(&zfcp_data.config_lock);
173 port = zfcp_port_enqueue(adapter, zfcp_data.init_wwpn, 0, 0);
176 unit = zfcp_unit_enqueue(port, zfcp_data.init_fcp_lun);
179 up(&zfcp_data.config_sema);
180 ccw_device_set_online(adapter->ccw_device);
181 zfcp_erp_wait(adapter);
182 down(&zfcp_data.config_sema);
187 zfcp_adapter_put(adapter);
189 up(&zfcp_data.config_sema);
193 static int calc_alignment(int size)
200 while ((size - align) > 0)
207 zfcp_module_init(void)
209 int retval = -ENOMEM;
212 size = sizeof(struct zfcp_fsf_req_qtcb);
213 align = calc_alignment(size);
214 zfcp_data.fsf_req_qtcb_cache =
215 kmem_cache_create("zfcp_fsf", size, align, 0, NULL);
216 if (!zfcp_data.fsf_req_qtcb_cache)
219 size = sizeof(struct fsf_status_read_buffer);
220 align = calc_alignment(size);
221 zfcp_data.sr_buffer_cache =
222 kmem_cache_create("zfcp_sr", size, align, 0, NULL);
223 if (!zfcp_data.sr_buffer_cache)
226 size = sizeof(struct zfcp_gid_pn_data);
227 align = calc_alignment(size);
228 zfcp_data.gid_pn_cache =
229 kmem_cache_create("zfcp_gid", size, align, 0, NULL);
230 if (!zfcp_data.gid_pn_cache)
233 /* initialize adapter list */
234 INIT_LIST_HEAD(&zfcp_data.adapter_list_head);
236 /* initialize adapters to be removed list head */
237 INIT_LIST_HEAD(&zfcp_data.adapter_remove_lh);
239 zfcp_data.scsi_transport_template =
240 fc_attach_transport(&zfcp_transport_functions);
241 if (!zfcp_data.scsi_transport_template)
244 retval = misc_register(&zfcp_cfdc_misc);
246 pr_err("zfcp: registration of misc device zfcp_cfdc failed\n");
250 /* Initialise proc semaphores */
251 sema_init(&zfcp_data.config_sema, 1);
253 /* initialise configuration rw lock */
254 rwlock_init(&zfcp_data.config_lock);
256 /* setup dynamic I/O */
257 retval = zfcp_ccw_register();
259 pr_err("zfcp: Registration with common I/O layer failed.\n");
260 goto out_ccw_register;
263 if (zfcp_device_setup(device))
264 zfcp_init_device_configure();
269 misc_deregister(&zfcp_cfdc_misc);
271 fc_release_transport(zfcp_data.scsi_transport_template);
273 kmem_cache_destroy(zfcp_data.gid_pn_cache);
275 kmem_cache_destroy(zfcp_data.sr_buffer_cache);
277 kmem_cache_destroy(zfcp_data.fsf_req_qtcb_cache);
282 /****************************************************************/
283 /****** Functions for configuration/set-up of structures ********/
284 /****************************************************************/
287 * zfcp_get_unit_by_lun - find unit in unit list of port by FCP LUN
288 * @port: pointer to port to search for unit
289 * @fcp_lun: FCP LUN to search for
290 * Traverse list of all units of a port and return pointer to a unit
291 * with the given FCP LUN.
294 zfcp_get_unit_by_lun(struct zfcp_port *port, fcp_lun_t fcp_lun)
296 struct zfcp_unit *unit;
299 list_for_each_entry(unit, &port->unit_list_head, list) {
300 if ((unit->fcp_lun == fcp_lun) &&
301 !atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status))
307 return found ? unit : NULL;
311 * zfcp_get_port_by_wwpn - find port in port list of adapter by wwpn
312 * @adapter: pointer to adapter to search for port
313 * @wwpn: wwpn to search for
314 * Traverse list of all ports of an adapter and return pointer to a port
315 * with the given wwpn.
318 zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter, wwn_t wwpn)
320 struct zfcp_port *port;
323 list_for_each_entry(port, &adapter->port_list_head, list) {
324 if ((port->wwpn == wwpn) &&
325 !(atomic_read(&port->status) &
326 (ZFCP_STATUS_PORT_NO_WWPN | ZFCP_STATUS_COMMON_REMOVE))) {
331 return found ? port : NULL;
335 * zfcp_get_port_by_did - find port in port list of adapter by d_id
336 * @adapter: pointer to adapter to search for port
337 * @d_id: d_id to search for
338 * Traverse list of all ports of an adapter and return pointer to a port
339 * with the given d_id.
342 zfcp_get_port_by_did(struct zfcp_adapter *adapter, u32 d_id)
344 struct zfcp_port *port;
347 list_for_each_entry(port, &adapter->port_list_head, list) {
348 if ((port->d_id == d_id) &&
349 !atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status))
355 return found ? port : NULL;
359 * zfcp_get_adapter_by_busid - find adpater in adapter list by bus_id
360 * @bus_id: bus_id to search for
361 * Traverse list of all adapters and return pointer to an adapter
362 * with the given bus_id.
364 struct zfcp_adapter *
365 zfcp_get_adapter_by_busid(char *bus_id)
367 struct zfcp_adapter *adapter;
370 list_for_each_entry(adapter, &zfcp_data.adapter_list_head, list) {
371 if ((strncmp(bus_id, zfcp_get_busid_by_adapter(adapter),
372 BUS_ID_SIZE) == 0) &&
373 !atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE,
379 return found ? adapter : NULL;
383 * zfcp_unit_enqueue - enqueue unit to unit list of a port.
384 * @port: pointer to port where unit is added
385 * @fcp_lun: FCP LUN of unit to be enqueued
386 * Return: pointer to enqueued unit on success, NULL on error
387 * Locks: config_sema must be held to serialize changes to the unit list
389 * Sets up some unit internal structures and creates sysfs entry.
392 zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun)
394 struct zfcp_unit *unit;
397 * check that there is no unit with this FCP_LUN already in list
399 * Note: Unlike for the adapter and the port, this is an error
401 read_lock_irq(&zfcp_data.config_lock);
402 unit = zfcp_get_unit_by_lun(port, fcp_lun);
403 read_unlock_irq(&zfcp_data.config_lock);
407 unit = kzalloc(sizeof (struct zfcp_unit), GFP_KERNEL);
411 /* initialise reference count stuff */
412 atomic_set(&unit->refcount, 0);
413 init_waitqueue_head(&unit->remove_wq);
416 unit->fcp_lun = fcp_lun;
418 /* setup for sysfs registration */
419 snprintf(unit->sysfs_device.bus_id, BUS_ID_SIZE, "0x%016llx", fcp_lun);
420 unit->sysfs_device.parent = &port->sysfs_device;
421 unit->sysfs_device.release = zfcp_sysfs_unit_release;
422 dev_set_drvdata(&unit->sysfs_device, unit);
424 /* mark unit unusable as long as sysfs registration is not complete */
425 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
427 spin_lock_init(&unit->latencies.lock);
428 unit->latencies.write.channel.min = 0xFFFFFFFF;
429 unit->latencies.write.fabric.min = 0xFFFFFFFF;
430 unit->latencies.read.channel.min = 0xFFFFFFFF;
431 unit->latencies.read.fabric.min = 0xFFFFFFFF;
432 unit->latencies.cmd.channel.min = 0xFFFFFFFF;
433 unit->latencies.cmd.fabric.min = 0xFFFFFFFF;
435 if (device_register(&unit->sysfs_device)) {
440 if (zfcp_sysfs_unit_create_files(&unit->sysfs_device)) {
441 device_unregister(&unit->sysfs_device);
446 unit->scsi_lun = scsilun_to_int((struct scsi_lun *)&unit->fcp_lun);
448 write_lock_irq(&zfcp_data.config_lock);
449 list_add_tail(&unit->list, &port->unit_list_head);
450 atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
451 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &unit->status);
452 write_unlock_irq(&zfcp_data.config_lock);
461 zfcp_unit_dequeue(struct zfcp_unit *unit)
463 zfcp_unit_wait(unit);
464 write_lock_irq(&zfcp_data.config_lock);
465 list_del(&unit->list);
466 write_unlock_irq(&zfcp_data.config_lock);
468 zfcp_port_put(unit->port);
469 zfcp_sysfs_unit_remove_files(&unit->sysfs_device);
470 device_unregister(&unit->sysfs_device);
474 * Allocates a combined QTCB/fsf_req buffer for erp actions and fcp/SCSI
476 * It also genrates fcp-nameserver request/response buffer and unsolicited
477 * status read fsf_req buffers.
479 * locks: must only be called with zfcp_data.config_sema taken
482 zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)
484 adapter->pool.fsf_req_erp =
485 mempool_create_slab_pool(ZFCP_POOL_FSF_REQ_ERP_NR,
486 zfcp_data.fsf_req_qtcb_cache);
487 if (!adapter->pool.fsf_req_erp)
490 adapter->pool.fsf_req_scsi =
491 mempool_create_slab_pool(ZFCP_POOL_FSF_REQ_SCSI_NR,
492 zfcp_data.fsf_req_qtcb_cache);
493 if (!adapter->pool.fsf_req_scsi)
496 adapter->pool.fsf_req_abort =
497 mempool_create_slab_pool(ZFCP_POOL_FSF_REQ_ABORT_NR,
498 zfcp_data.fsf_req_qtcb_cache);
499 if (!adapter->pool.fsf_req_abort)
502 adapter->pool.fsf_req_status_read =
503 mempool_create_kmalloc_pool(ZFCP_POOL_STATUS_READ_NR,
504 sizeof(struct zfcp_fsf_req));
505 if (!adapter->pool.fsf_req_status_read)
508 adapter->pool.data_status_read =
509 mempool_create_slab_pool(ZFCP_POOL_STATUS_READ_NR,
510 zfcp_data.sr_buffer_cache);
511 if (!adapter->pool.data_status_read)
514 adapter->pool.data_gid_pn =
515 mempool_create_slab_pool(ZFCP_POOL_DATA_GID_PN_NR,
516 zfcp_data.gid_pn_cache);
517 if (!adapter->pool.data_gid_pn)
524 * zfcp_free_low_mem_buffers - free memory pools of an adapter
525 * @adapter: pointer to zfcp_adapter for which memory pools should be freed
526 * locking: zfcp_data.config_sema must be held
529 zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter)
531 if (adapter->pool.fsf_req_erp)
532 mempool_destroy(adapter->pool.fsf_req_erp);
533 if (adapter->pool.fsf_req_scsi)
534 mempool_destroy(adapter->pool.fsf_req_scsi);
535 if (adapter->pool.fsf_req_abort)
536 mempool_destroy(adapter->pool.fsf_req_abort);
537 if (adapter->pool.fsf_req_status_read)
538 mempool_destroy(adapter->pool.fsf_req_status_read);
539 if (adapter->pool.data_status_read)
540 mempool_destroy(adapter->pool.data_status_read);
541 if (adapter->pool.data_gid_pn)
542 mempool_destroy(adapter->pool.data_gid_pn);
545 static void zfcp_dummy_release(struct device *dev)
550 int zfcp_status_read_refill(struct zfcp_adapter *adapter)
552 while (atomic_read(&adapter->stat_miss) > 0)
553 if (zfcp_fsf_status_read(adapter, ZFCP_WAIT_FOR_SBAL))
556 atomic_dec(&adapter->stat_miss);
558 if (ZFCP_STATUS_READS_RECOM <= atomic_read(&adapter->stat_miss)) {
559 zfcp_erp_adapter_reopen(adapter, 0, 103, NULL);
565 static void _zfcp_status_read_scheduler(struct work_struct *work)
567 zfcp_status_read_refill(container_of(work, struct zfcp_adapter,
572 * Enqueues an adapter at the end of the adapter list in the driver data.
573 * All adapter internal structures are set up.
574 * Proc-fs entries are also created.
576 * FIXME: Use -ENOMEM as return code for allocation failures
578 * returns: 0 if a new adapter was successfully enqueued
579 * ZFCP_KNOWN if an adapter with this devno was already present
580 * -ENOMEM if alloc failed
581 * locks: config_sema must be held to serialise changes to the adapter list
583 struct zfcp_adapter *
584 zfcp_adapter_enqueue(struct ccw_device *ccw_device)
586 struct zfcp_adapter *adapter;
589 * Note: It is safe to release the list_lock, as any list changes
590 * are protected by the config_sema, which must be held to get here
593 /* try to allocate new adapter data structure (zeroed) */
594 adapter = kzalloc(sizeof (struct zfcp_adapter), GFP_KERNEL);
598 ccw_device->handler = NULL;
600 /* save ccw_device pointer */
601 adapter->ccw_device = ccw_device;
603 if (zfcp_qdio_allocate(adapter))
604 goto qdio_allocate_failed;
606 if (zfcp_allocate_low_mem_buffers(adapter))
607 goto failed_low_mem_buffers;
609 /* initialise reference count stuff */
610 atomic_set(&adapter->refcount, 0);
611 init_waitqueue_head(&adapter->remove_wq);
613 /* initialise list of ports */
614 INIT_LIST_HEAD(&adapter->port_list_head);
616 /* initialise list of ports to be removed */
617 INIT_LIST_HEAD(&adapter->port_remove_lh);
619 /* initialize list of fsf requests */
620 spin_lock_init(&adapter->req_list_lock);
621 if (zfcp_reqlist_alloc(adapter))
622 goto failed_low_mem_buffers;
624 /* initialize debug locks */
626 spin_lock_init(&adapter->hba_dbf_lock);
627 spin_lock_init(&adapter->san_dbf_lock);
628 spin_lock_init(&adapter->scsi_dbf_lock);
629 spin_lock_init(&adapter->rec_dbf_lock);
631 if (zfcp_adapter_debug_register(adapter))
632 goto debug_register_failed;
634 /* initialize error recovery stuff */
636 rwlock_init(&adapter->erp_lock);
637 sema_init(&adapter->erp_ready_sem, 0);
638 INIT_LIST_HEAD(&adapter->erp_ready_head);
639 INIT_LIST_HEAD(&adapter->erp_running_head);
641 /* initialize abort lock */
642 rwlock_init(&adapter->abort_lock);
644 /* initialise some erp stuff */
645 init_waitqueue_head(&adapter->erp_thread_wqh);
646 init_waitqueue_head(&adapter->erp_done_wqh);
648 /* initialize lock of associated request queue */
649 rwlock_init(&adapter->req_q.lock);
650 INIT_WORK(&adapter->stat_work, _zfcp_status_read_scheduler);
652 /* mark adapter unusable as long as sysfs registration is not complete */
653 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
655 dev_set_drvdata(&ccw_device->dev, adapter);
657 if (zfcp_sysfs_adapter_create_files(&ccw_device->dev))
660 adapter->generic_services.parent = &adapter->ccw_device->dev;
661 adapter->generic_services.release = zfcp_dummy_release;
662 snprintf(adapter->generic_services.bus_id, BUS_ID_SIZE,
665 if (device_register(&adapter->generic_services))
666 goto generic_services_failed;
668 /* put allocated adapter at list tail */
669 write_lock_irq(&zfcp_data.config_lock);
670 atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
671 list_add_tail(&adapter->list, &zfcp_data.adapter_list_head);
672 write_unlock_irq(&zfcp_data.config_lock);
674 zfcp_data.adapters++;
678 generic_services_failed:
679 zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev);
681 zfcp_adapter_debug_unregister(adapter);
682 debug_register_failed:
683 dev_set_drvdata(&ccw_device->dev, NULL);
684 zfcp_reqlist_free(adapter);
685 failed_low_mem_buffers:
686 zfcp_free_low_mem_buffers(adapter);
687 qdio_allocate_failed:
688 zfcp_qdio_free(adapter);
696 * returns: 0 - struct zfcp_adapter data structure successfully removed
697 * !0 - struct zfcp_adapter data structure could not be removed
699 * locks: adapter list write lock is assumed to be held by caller
702 zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
707 cancel_work_sync(&adapter->stat_work);
708 zfcp_adapter_scsi_unregister(adapter);
709 device_unregister(&adapter->generic_services);
710 zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev);
711 dev_set_drvdata(&adapter->ccw_device->dev, NULL);
712 /* sanity check: no pending FSF requests */
713 spin_lock_irqsave(&adapter->req_list_lock, flags);
714 retval = zfcp_reqlist_isempty(adapter);
715 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
721 zfcp_adapter_debug_unregister(adapter);
723 /* remove specified adapter data structure from list */
724 write_lock_irq(&zfcp_data.config_lock);
725 list_del(&adapter->list);
726 write_unlock_irq(&zfcp_data.config_lock);
728 /* decrease number of adapters in list */
729 zfcp_data.adapters--;
731 zfcp_qdio_free(adapter);
733 zfcp_free_low_mem_buffers(adapter);
734 zfcp_reqlist_free(adapter);
735 kfree(adapter->fc_stats);
736 kfree(adapter->stats_reset_data);
743 * zfcp_port_enqueue - enqueue port to port list of adapter
744 * @adapter: adapter where remote port is added
745 * @wwpn: WWPN of the remote port to be enqueued
746 * @status: initial status for the port
747 * @d_id: destination id of the remote port to be enqueued
748 * Return: pointer to enqueued port on success, NULL on error
749 * Locks: config_sema must be held to serialize changes to the port list
751 * All port internal structures are set up and the sysfs entry is generated.
752 * d_id is used to enqueue ports with a well known address like the Directory
753 * Service for nameserver lookup.
756 zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, u32 status,
759 struct zfcp_port *port;
762 check_wwpn = !(status & ZFCP_STATUS_PORT_NO_WWPN);
764 * check that there is no port with this WWPN already in list
767 read_lock_irq(&zfcp_data.config_lock);
768 port = zfcp_get_port_by_wwpn(adapter, wwpn);
769 read_unlock_irq(&zfcp_data.config_lock);
774 port = kzalloc(sizeof (struct zfcp_port), GFP_KERNEL);
778 /* initialise reference count stuff */
779 atomic_set(&port->refcount, 0);
780 init_waitqueue_head(&port->remove_wq);
782 INIT_LIST_HEAD(&port->unit_list_head);
783 INIT_LIST_HEAD(&port->unit_remove_lh);
785 port->adapter = adapter;
790 atomic_set_mask(status, &port->status);
792 /* setup for sysfs registration */
793 if (status & ZFCP_STATUS_PORT_WKA) {
795 case ZFCP_DID_DIRECTORY_SERVICE:
796 snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE,
799 case ZFCP_DID_MANAGEMENT_SERVICE:
800 snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE,
803 case ZFCP_DID_KEY_DISTRIBUTION_SERVICE:
804 snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE,
807 case ZFCP_DID_ALIAS_SERVICE:
808 snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE,
811 case ZFCP_DID_TIME_SERVICE:
812 snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE,
820 port->sysfs_device.parent = &adapter->generic_services;
822 snprintf(port->sysfs_device.bus_id,
823 BUS_ID_SIZE, "0x%016llx", wwpn);
824 port->sysfs_device.parent = &adapter->ccw_device->dev;
826 port->sysfs_device.release = zfcp_sysfs_port_release;
827 dev_set_drvdata(&port->sysfs_device, port);
829 /* mark port unusable as long as sysfs registration is not complete */
830 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
832 if (device_register(&port->sysfs_device)) {
837 if (zfcp_sysfs_port_create_files(&port->sysfs_device, status)) {
838 device_unregister(&port->sysfs_device);
844 write_lock_irq(&zfcp_data.config_lock);
845 list_add_tail(&port->list, &adapter->port_list_head);
846 atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
847 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &port->status);
848 if (d_id == ZFCP_DID_DIRECTORY_SERVICE)
849 if (!adapter->nameserver_port)
850 adapter->nameserver_port = port;
852 write_unlock_irq(&zfcp_data.config_lock);
854 zfcp_adapter_get(adapter);
860 zfcp_port_dequeue(struct zfcp_port *port)
862 zfcp_port_wait(port);
863 write_lock_irq(&zfcp_data.config_lock);
864 list_del(&port->list);
865 port->adapter->ports--;
866 write_unlock_irq(&zfcp_data.config_lock);
868 fc_remote_port_delete(port->rport);
870 zfcp_adapter_put(port->adapter);
871 zfcp_sysfs_port_remove_files(&port->sysfs_device,
872 atomic_read(&port->status));
873 device_unregister(&port->sysfs_device);
876 /* Enqueues a nameserver port */
878 zfcp_nameserver_enqueue(struct zfcp_adapter *adapter)
880 struct zfcp_port *port;
882 port = zfcp_port_enqueue(adapter, 0, ZFCP_STATUS_PORT_WKA,
883 ZFCP_DID_DIRECTORY_SERVICE);
891 void zfcp_sg_free_table(struct scatterlist *sg, int count)
895 for (i = 0; i < count; i++, sg++)
897 free_page((unsigned long) sg_virt(sg));
902 int zfcp_sg_setup_table(struct scatterlist *sg, int count)
907 sg_init_table(sg, count);
908 for (i = 0; i < count; i++, sg++) {
909 addr = (void *) get_zeroed_page(GFP_KERNEL);
911 zfcp_sg_free_table(sg, i);
914 sg_set_buf(sg, addr, PAGE_SIZE);