| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 1 | /* | 
|  | 2 | * zfcp device driver | 
|  | 3 | * | 
|  | 4 | * Fibre Channel related functions for the zfcp device driver. | 
|  | 5 | * | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 6 | * Copyright IBM Corporation 2008, 2010 | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 7 | */ | 
|  | 8 |  | 
| Christof Schmitt | ecf39d4 | 2008-12-25 13:39:53 +0100 | [diff] [blame] | 9 | #define KMSG_COMPONENT "zfcp" | 
|  | 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 
|  | 11 |  | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 12 | #include <linux/types.h> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> | 
| Christof Schmitt | 038d944 | 2011-02-22 19:54:48 +0100 | [diff] [blame] | 14 | #include <linux/utsname.h> | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 15 | #include <scsi/fc/fc_els.h> | 
|  | 16 | #include <scsi/libfc.h> | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 17 | #include "zfcp_ext.h" | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 18 | #include "zfcp_fc.h" | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 19 |  | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 20 | struct kmem_cache *zfcp_fc_req_cache; | 
|  | 21 |  | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 22 | static u32 zfcp_fc_rscn_range_mask[] = { | 
|  | 23 | [ELS_ADDR_FMT_PORT]		= 0xFFFFFF, | 
|  | 24 | [ELS_ADDR_FMT_AREA]		= 0xFFFF00, | 
|  | 25 | [ELS_ADDR_FMT_DOM]		= 0xFF0000, | 
|  | 26 | [ELS_ADDR_FMT_FAB]		= 0x000000, | 
| Christof Schmitt | e0d7fcb | 2008-12-19 16:56:58 +0100 | [diff] [blame] | 27 | }; | 
|  | 28 |  | 
| Sven Schuetz | 2d1e547 | 2010-07-16 15:37:39 +0200 | [diff] [blame] | 29 | /** | 
|  | 30 | * zfcp_fc_post_event - post event to userspace via fc_transport | 
|  | 31 | * @work: work struct with enqueued events | 
|  | 32 | */ | 
|  | 33 | void zfcp_fc_post_event(struct work_struct *work) | 
|  | 34 | { | 
|  | 35 | struct zfcp_fc_event *event = NULL, *tmp = NULL; | 
|  | 36 | LIST_HEAD(tmp_lh); | 
|  | 37 | struct zfcp_fc_events *events = container_of(work, | 
|  | 38 | struct zfcp_fc_events, work); | 
|  | 39 | struct zfcp_adapter *adapter = container_of(events, struct zfcp_adapter, | 
|  | 40 | events); | 
|  | 41 |  | 
|  | 42 | spin_lock_bh(&events->list_lock); | 
|  | 43 | list_splice_init(&events->list, &tmp_lh); | 
|  | 44 | spin_unlock_bh(&events->list_lock); | 
|  | 45 |  | 
|  | 46 | list_for_each_entry_safe(event, tmp, &tmp_lh, list) { | 
|  | 47 | fc_host_post_event(adapter->scsi_host, fc_get_event_number(), | 
|  | 48 | event->code, event->data); | 
|  | 49 | list_del(&event->list); | 
|  | 50 | kfree(event); | 
|  | 51 | } | 
|  | 52 |  | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | /** | 
|  | 56 | * zfcp_fc_enqueue_event - safely enqueue FC HBA API event from irq context | 
|  | 57 | * @adapter: The adapter where to enqueue the event | 
|  | 58 | * @event_code: The event code (as defined in fc_host_event_code in | 
|  | 59 | *		scsi_transport_fc.h) | 
|  | 60 | * @event_data: The event data (e.g. n_port page in case of els) | 
|  | 61 | */ | 
|  | 62 | void zfcp_fc_enqueue_event(struct zfcp_adapter *adapter, | 
|  | 63 | enum fc_host_event_code event_code, u32 event_data) | 
|  | 64 | { | 
|  | 65 | struct zfcp_fc_event *event; | 
|  | 66 |  | 
|  | 67 | event = kmalloc(sizeof(struct zfcp_fc_event), GFP_ATOMIC); | 
|  | 68 | if (!event) | 
|  | 69 | return; | 
|  | 70 |  | 
|  | 71 | event->code = event_code; | 
|  | 72 | event->data = event_data; | 
|  | 73 |  | 
|  | 74 | spin_lock(&adapter->events.list_lock); | 
|  | 75 | list_add_tail(&event->list, &adapter->events.list); | 
|  | 76 | spin_unlock(&adapter->events.list_lock); | 
|  | 77 |  | 
|  | 78 | queue_work(adapter->work_queue, &adapter->events.work); | 
|  | 79 | } | 
|  | 80 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 81 | static int zfcp_fc_wka_port_get(struct zfcp_fc_wka_port *wka_port) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 82 | { | 
|  | 83 | if (mutex_lock_interruptible(&wka_port->mutex)) | 
|  | 84 | return -ERESTARTSYS; | 
|  | 85 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 86 | if (wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE || | 
|  | 87 | wka_port->status == ZFCP_FC_WKA_PORT_CLOSING) { | 
|  | 88 | wka_port->status = ZFCP_FC_WKA_PORT_OPENING; | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 89 | if (zfcp_fsf_open_wka_port(wka_port)) | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 90 | wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 91 | } | 
|  | 92 |  | 
|  | 93 | mutex_unlock(&wka_port->mutex); | 
|  | 94 |  | 
| Swen Schillig | 27f492c | 2009-07-13 15:06:13 +0200 | [diff] [blame] | 95 | wait_event(wka_port->completion_wq, | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 96 | wka_port->status == ZFCP_FC_WKA_PORT_ONLINE || | 
|  | 97 | wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE); | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 98 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 99 | if (wka_port->status == ZFCP_FC_WKA_PORT_ONLINE) { | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 100 | atomic_inc(&wka_port->refcount); | 
|  | 101 | return 0; | 
|  | 102 | } | 
|  | 103 | return -EIO; | 
|  | 104 | } | 
|  | 105 |  | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 106 | static void zfcp_fc_wka_port_offline(struct work_struct *work) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 107 | { | 
| Jean Delvare | bf6aede | 2009-04-02 16:56:54 -0700 | [diff] [blame] | 108 | struct delayed_work *dw = to_delayed_work(work); | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 109 | struct zfcp_fc_wka_port *wka_port = | 
|  | 110 | container_of(dw, struct zfcp_fc_wka_port, work); | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 111 |  | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 112 | mutex_lock(&wka_port->mutex); | 
|  | 113 | if ((atomic_read(&wka_port->refcount) != 0) || | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 114 | (wka_port->status != ZFCP_FC_WKA_PORT_ONLINE)) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 115 | goto out; | 
|  | 116 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 117 | wka_port->status = ZFCP_FC_WKA_PORT_CLOSING; | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 118 | if (zfcp_fsf_close_wka_port(wka_port)) { | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 119 | wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 120 | wake_up(&wka_port->completion_wq); | 
|  | 121 | } | 
|  | 122 | out: | 
|  | 123 | mutex_unlock(&wka_port->mutex); | 
|  | 124 | } | 
|  | 125 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 126 | static void zfcp_fc_wka_port_put(struct zfcp_fc_wka_port *wka_port) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 127 | { | 
|  | 128 | if (atomic_dec_return(&wka_port->refcount) != 0) | 
|  | 129 | return; | 
| Martin Olsson | 19af5cd | 2009-04-23 11:37:37 +0200 | [diff] [blame] | 130 | /* wait 10 milliseconds, other reqs might pop in */ | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 131 | schedule_delayed_work(&wka_port->work, HZ / 100); | 
|  | 132 | } | 
|  | 133 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 134 | static void zfcp_fc_wka_port_init(struct zfcp_fc_wka_port *wka_port, u32 d_id, | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 135 | struct zfcp_adapter *adapter) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 136 | { | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 137 | init_waitqueue_head(&wka_port->completion_wq); | 
|  | 138 |  | 
|  | 139 | wka_port->adapter = adapter; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 140 | wka_port->d_id = d_id; | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 141 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 142 | wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 143 | atomic_set(&wka_port->refcount, 0); | 
|  | 144 | mutex_init(&wka_port->mutex); | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 145 | INIT_DELAYED_WORK(&wka_port->work, zfcp_fc_wka_port_offline); | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 146 | } | 
|  | 147 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 148 | static void zfcp_fc_wka_port_force_offline(struct zfcp_fc_wka_port *wka) | 
| Swen Schillig | 828bc12 | 2009-04-17 15:08:05 +0200 | [diff] [blame] | 149 | { | 
|  | 150 | cancel_delayed_work_sync(&wka->work); | 
|  | 151 | mutex_lock(&wka->mutex); | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 152 | wka->status = ZFCP_FC_WKA_PORT_OFFLINE; | 
| Swen Schillig | 828bc12 | 2009-04-17 15:08:05 +0200 | [diff] [blame] | 153 | mutex_unlock(&wka->mutex); | 
|  | 154 | } | 
|  | 155 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 156 | void zfcp_fc_wka_ports_force_offline(struct zfcp_fc_wka_ports *gs) | 
| Christof Schmitt | 55c770f | 2009-08-18 15:43:12 +0200 | [diff] [blame] | 157 | { | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 158 | if (!gs) | 
|  | 159 | return; | 
| Christof Schmitt | 55c770f | 2009-08-18 15:43:12 +0200 | [diff] [blame] | 160 | zfcp_fc_wka_port_force_offline(&gs->ms); | 
|  | 161 | zfcp_fc_wka_port_force_offline(&gs->ts); | 
|  | 162 | zfcp_fc_wka_port_force_offline(&gs->ds); | 
|  | 163 | zfcp_fc_wka_port_force_offline(&gs->as); | 
| Christof Schmitt | 55c770f | 2009-08-18 15:43:12 +0200 | [diff] [blame] | 164 | } | 
|  | 165 |  | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 166 | static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range, | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 167 | struct fc_els_rscn_page *page) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 168 | { | 
|  | 169 | unsigned long flags; | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 170 | struct zfcp_adapter *adapter = fsf_req->adapter; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 171 | struct zfcp_port *port; | 
|  | 172 |  | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 173 | read_lock_irqsave(&adapter->port_list_lock, flags); | 
|  | 174 | list_for_each_entry(port, &adapter->port_list, list) { | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 175 | if ((port->d_id & range) == (ntoh24(page->rscn_fid) & range)) | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 176 | zfcp_fc_test_link(port); | 
| Swen Schillig | ea460a8 | 2009-05-15 13:18:20 +0200 | [diff] [blame] | 177 | if (!port->d_id) | 
|  | 178 | zfcp_erp_port_reopen(port, | 
|  | 179 | ZFCP_STATUS_COMMON_ERP_FAILED, | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 180 | "fcrscn1"); | 
| Swen Schillig | ea460a8 | 2009-05-15 13:18:20 +0200 | [diff] [blame] | 181 | } | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 182 | read_unlock_irqrestore(&adapter->port_list_lock, flags); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 183 | } | 
|  | 184 |  | 
|  | 185 | static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req) | 
|  | 186 | { | 
|  | 187 | struct fsf_status_read_buffer *status_buffer = (void *)fsf_req->data; | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 188 | struct fc_els_rscn *head; | 
|  | 189 | struct fc_els_rscn_page *page; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 190 | u16 i; | 
|  | 191 | u16 no_entries; | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 192 | unsigned int afmt; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 193 |  | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 194 | head = (struct fc_els_rscn *) status_buffer->payload.data; | 
|  | 195 | page = (struct fc_els_rscn_page *) head; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 196 |  | 
|  | 197 | /* see FC-FS */ | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 198 | no_entries = head->rscn_plen / sizeof(struct fc_els_rscn_page); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 199 |  | 
|  | 200 | for (i = 1; i < no_entries; i++) { | 
|  | 201 | /* skip head and start with 1st element */ | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 202 | page++; | 
|  | 203 | afmt = page->rscn_page_flags & ELS_RSCN_ADDR_FMT_MASK; | 
|  | 204 | _zfcp_fc_incoming_rscn(fsf_req, zfcp_fc_rscn_range_mask[afmt], | 
|  | 205 | page); | 
| Sven Schuetz | 2d1e547 | 2010-07-16 15:37:39 +0200 | [diff] [blame] | 206 | zfcp_fc_enqueue_event(fsf_req->adapter, FCH_EVT_RSCN, | 
|  | 207 | *(u32 *)page); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 208 | } | 
| Swen Schillig | 9eae07e | 2009-11-24 16:54:06 +0100 | [diff] [blame] | 209 | queue_work(fsf_req->adapter->work_queue, &fsf_req->adapter->scan_work); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 210 | } | 
|  | 211 |  | 
| Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 212 | static void zfcp_fc_incoming_wwpn(struct zfcp_fsf_req *req, u64 wwpn) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 213 | { | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 214 | unsigned long flags; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 215 | struct zfcp_adapter *adapter = req->adapter; | 
|  | 216 | struct zfcp_port *port; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 217 |  | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 218 | read_lock_irqsave(&adapter->port_list_lock, flags); | 
|  | 219 | list_for_each_entry(port, &adapter->port_list, list) | 
|  | 220 | if (port->wwpn == wwpn) { | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 221 | zfcp_erp_port_forced_reopen(port, 0, "fciwwp1"); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 222 | break; | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 223 | } | 
|  | 224 | read_unlock_irqrestore(&adapter->port_list_lock, flags); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 225 | } | 
|  | 226 |  | 
|  | 227 | static void zfcp_fc_incoming_plogi(struct zfcp_fsf_req *req) | 
|  | 228 | { | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 229 | struct fsf_status_read_buffer *status_buffer; | 
|  | 230 | struct fc_els_flogi *plogi; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 231 |  | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 232 | status_buffer = (struct fsf_status_read_buffer *) req->data; | 
|  | 233 | plogi = (struct fc_els_flogi *) status_buffer->payload.data; | 
|  | 234 | zfcp_fc_incoming_wwpn(req, plogi->fl_wwpn); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 235 | } | 
|  | 236 |  | 
|  | 237 | static void zfcp_fc_incoming_logo(struct zfcp_fsf_req *req) | 
|  | 238 | { | 
|  | 239 | struct fsf_status_read_buffer *status_buffer = | 
|  | 240 | (struct fsf_status_read_buffer *)req->data; | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 241 | struct fc_els_logo *logo = | 
|  | 242 | (struct fc_els_logo *) status_buffer->payload.data; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 243 |  | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 244 | zfcp_fc_incoming_wwpn(req, logo->fl_n_port_wwn); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 245 | } | 
|  | 246 |  | 
|  | 247 | /** | 
|  | 248 | * zfcp_fc_incoming_els - handle incoming ELS | 
|  | 249 | * @fsf_req - request which contains incoming ELS | 
|  | 250 | */ | 
|  | 251 | void zfcp_fc_incoming_els(struct zfcp_fsf_req *fsf_req) | 
|  | 252 | { | 
|  | 253 | struct fsf_status_read_buffer *status_buffer = | 
|  | 254 | (struct fsf_status_read_buffer *) fsf_req->data; | 
| Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 255 | unsigned int els_type = status_buffer->payload.data[0]; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 256 |  | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 257 | zfcp_dbf_san_in_els("fciels1", fsf_req); | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 258 | if (els_type == ELS_PLOGI) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 259 | zfcp_fc_incoming_plogi(fsf_req); | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 260 | else if (els_type == ELS_LOGO) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 261 | zfcp_fc_incoming_logo(fsf_req); | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 262 | else if (els_type == ELS_RSCN) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 263 | zfcp_fc_incoming_rscn(fsf_req); | 
|  | 264 | } | 
|  | 265 |  | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 266 | static void zfcp_fc_ns_gid_pn_eval(struct zfcp_fc_req *fc_req) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 267 | { | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 268 | struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; | 
|  | 269 | struct zfcp_fc_gid_pn_rsp *gid_pn_rsp = &fc_req->u.gid_pn.rsp; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 270 |  | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 271 | if (ct_els->status) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 272 | return; | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 273 | if (gid_pn_rsp->ct_hdr.ct_cmd != FC_FS_ACC) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 274 | return; | 
| Christof Schmitt | a5b11dd | 2009-03-02 13:08:54 +0100 | [diff] [blame] | 275 |  | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 276 | /* looks like a valid d_id */ | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 277 | ct_els->port->d_id = ntoh24(gid_pn_rsp->gid_pn.fp_fid); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 278 | } | 
|  | 279 |  | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 280 | static void zfcp_fc_complete(void *data) | 
|  | 281 | { | 
|  | 282 | complete(data); | 
|  | 283 | } | 
|  | 284 |  | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 285 | static void zfcp_fc_ct_ns_init(struct fc_ct_hdr *ct_hdr, u16 cmd, u16 mr_size) | 
|  | 286 | { | 
|  | 287 | ct_hdr->ct_rev = FC_CT_REV; | 
|  | 288 | ct_hdr->ct_fs_type = FC_FST_DIR; | 
|  | 289 | ct_hdr->ct_fs_subtype = FC_NS_SUBTYPE; | 
|  | 290 | ct_hdr->ct_cmd = cmd; | 
|  | 291 | ct_hdr->ct_mr_size = mr_size / 4; | 
|  | 292 | } | 
|  | 293 |  | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 294 | static int zfcp_fc_ns_gid_pn_request(struct zfcp_port *port, | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 295 | struct zfcp_fc_req *fc_req) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 296 | { | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 297 | struct zfcp_adapter *adapter = port->adapter; | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 298 | DECLARE_COMPLETION_ONSTACK(completion); | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 299 | struct zfcp_fc_gid_pn_req *gid_pn_req = &fc_req->u.gid_pn.req; | 
|  | 300 | struct zfcp_fc_gid_pn_rsp *gid_pn_rsp = &fc_req->u.gid_pn.rsp; | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 301 | int ret; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 302 |  | 
|  | 303 | /* setup parameters for send generic command */ | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 304 | fc_req->ct_els.port = port; | 
|  | 305 | fc_req->ct_els.handler = zfcp_fc_complete; | 
|  | 306 | fc_req->ct_els.handler_data = &completion; | 
|  | 307 | fc_req->ct_els.req = &fc_req->sg_req; | 
|  | 308 | fc_req->ct_els.resp = &fc_req->sg_rsp; | 
|  | 309 | sg_init_one(&fc_req->sg_req, gid_pn_req, sizeof(*gid_pn_req)); | 
|  | 310 | sg_init_one(&fc_req->sg_rsp, gid_pn_rsp, sizeof(*gid_pn_rsp)); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 311 |  | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 312 | zfcp_fc_ct_ns_init(&gid_pn_req->ct_hdr, | 
|  | 313 | FC_NS_GID_PN, ZFCP_FC_CT_SIZE_PAGE); | 
|  | 314 | gid_pn_req->gid_pn.fn_wwpn = port->wwpn; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 315 |  | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 316 | ret = zfcp_fsf_send_ct(&adapter->gs->ds, &fc_req->ct_els, | 
| Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 317 | adapter->pool.gid_pn_req, | 
|  | 318 | ZFCP_FC_CTELS_TMO); | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 319 | if (!ret) { | 
|  | 320 | wait_for_completion(&completion); | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 321 | zfcp_fc_ns_gid_pn_eval(fc_req); | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 322 | } | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 323 | return ret; | 
|  | 324 | } | 
|  | 325 |  | 
|  | 326 | /** | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 327 | * zfcp_fc_ns_gid_pn - initiate GID_PN nameserver request | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 328 | * @port: port where GID_PN request is needed | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 329 | * return: -ENOMEM on error, 0 otherwise | 
|  | 330 | */ | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 331 | static int zfcp_fc_ns_gid_pn(struct zfcp_port *port) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 332 | { | 
|  | 333 | int ret; | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 334 | struct zfcp_fc_req *fc_req; | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 335 | struct zfcp_adapter *adapter = port->adapter; | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 336 |  | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 337 | fc_req = mempool_alloc(adapter->pool.gid_pn, GFP_ATOMIC); | 
|  | 338 | if (!fc_req) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 339 | return -ENOMEM; | 
|  | 340 |  | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 341 | memset(fc_req, 0, sizeof(*fc_req)); | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 342 |  | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 343 | ret = zfcp_fc_wka_port_get(&adapter->gs->ds); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 344 | if (ret) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 345 | goto out; | 
|  | 346 |  | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 347 | ret = zfcp_fc_ns_gid_pn_request(port, fc_req); | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 348 |  | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 349 | zfcp_fc_wka_port_put(&adapter->gs->ds); | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 350 | out: | 
| Christof Schmitt | fcf7e61 | 2011-02-22 19:54:42 +0100 | [diff] [blame] | 351 | mempool_free(fc_req, adapter->pool.gid_pn); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 352 | return ret; | 
|  | 353 | } | 
|  | 354 |  | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 355 | void zfcp_fc_port_did_lookup(struct work_struct *work) | 
|  | 356 | { | 
|  | 357 | int ret; | 
|  | 358 | struct zfcp_port *port = container_of(work, struct zfcp_port, | 
|  | 359 | gid_pn_work); | 
|  | 360 |  | 
|  | 361 | ret = zfcp_fc_ns_gid_pn(port); | 
|  | 362 | if (ret) { | 
|  | 363 | /* could not issue gid_pn for some reason */ | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 364 | zfcp_erp_adapter_reopen(port->adapter, 0, "fcgpn_1"); | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 365 | goto out; | 
|  | 366 | } | 
|  | 367 |  | 
|  | 368 | if (!port->d_id) { | 
| Swen Schillig | edaed85 | 2010-09-08 14:40:01 +0200 | [diff] [blame] | 369 | zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_ERP_FAILED); | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 370 | goto out; | 
|  | 371 | } | 
|  | 372 |  | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 373 | zfcp_erp_port_reopen(port, 0, "fcgpn_3"); | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 374 | out: | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 375 | put_device(&port->dev); | 
| Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 376 | } | 
|  | 377 |  | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 378 | /** | 
| Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 379 | * zfcp_fc_trigger_did_lookup - trigger the d_id lookup using a GID_PN request | 
|  | 380 | * @port: The zfcp_port to lookup the d_id for. | 
|  | 381 | */ | 
|  | 382 | void zfcp_fc_trigger_did_lookup(struct zfcp_port *port) | 
|  | 383 | { | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 384 | get_device(&port->dev); | 
| Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 385 | if (!queue_work(port->adapter->work_queue, &port->gid_pn_work)) | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 386 | put_device(&port->dev); | 
| Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 387 | } | 
|  | 388 |  | 
|  | 389 | /** | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 390 | * zfcp_fc_plogi_evaluate - evaluate PLOGI playload | 
|  | 391 | * @port: zfcp_port structure | 
|  | 392 | * @plogi: plogi payload | 
|  | 393 | * | 
|  | 394 | * Evaluate PLOGI playload and copy important fields into zfcp_port structure | 
|  | 395 | */ | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 396 | void zfcp_fc_plogi_evaluate(struct zfcp_port *port, struct fc_els_flogi *plogi) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 397 | { | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 398 | if (plogi->fl_wwpn != port->wwpn) { | 
|  | 399 | port->d_id = 0; | 
|  | 400 | dev_warn(&port->adapter->ccw_device->dev, | 
|  | 401 | "A port opened with WWPN 0x%016Lx returned data that " | 
|  | 402 | "identifies it as WWPN 0x%016Lx\n", | 
|  | 403 | (unsigned long long) port->wwpn, | 
|  | 404 | (unsigned long long) plogi->fl_wwpn); | 
|  | 405 | return; | 
|  | 406 | } | 
|  | 407 |  | 
|  | 408 | port->wwnn = plogi->fl_wwnn; | 
|  | 409 | port->maxframe_size = plogi->fl_csp.sp_bb_data; | 
|  | 410 |  | 
|  | 411 | if (plogi->fl_cssp[0].cp_class & FC_CPC_VALID) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 412 | port->supported_classes |= FC_COS_CLASS1; | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 413 | if (plogi->fl_cssp[1].cp_class & FC_CPC_VALID) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 414 | port->supported_classes |= FC_COS_CLASS2; | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 415 | if (plogi->fl_cssp[2].cp_class & FC_CPC_VALID) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 416 | port->supported_classes |= FC_COS_CLASS3; | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 417 | if (plogi->fl_cssp[3].cp_class & FC_CPC_VALID) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 418 | port->supported_classes |= FC_COS_CLASS4; | 
|  | 419 | } | 
|  | 420 |  | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 421 | static void zfcp_fc_adisc_handler(void *data) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 422 | { | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 423 | struct zfcp_fc_req *fc_req = data; | 
|  | 424 | struct zfcp_port *port = fc_req->ct_els.port; | 
|  | 425 | struct fc_els_adisc *adisc_resp = &fc_req->u.adisc.rsp; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 426 |  | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 427 | if (fc_req->ct_els.status) { | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 428 | /* request rejected or timed out */ | 
| Swen Schillig | 5b43e71 | 2009-04-17 15:08:10 +0200 | [diff] [blame] | 429 | zfcp_erp_port_forced_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 430 | "fcadh_1"); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 431 | goto out; | 
|  | 432 | } | 
|  | 433 |  | 
|  | 434 | if (!port->wwnn) | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 435 | port->wwnn = adisc_resp->adisc_wwnn; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 436 |  | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 437 | if ((port->wwpn != adisc_resp->adisc_wwpn) || | 
| Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 438 | !(atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN)) { | 
| Swen Schillig | 2409549 | 2009-03-02 13:09:07 +0100 | [diff] [blame] | 439 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 440 | "fcadh_2"); | 
| Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 441 | goto out; | 
|  | 442 | } | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 443 |  | 
| Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 444 | /* port is good, unblock rport without going through erp */ | 
|  | 445 | zfcp_scsi_schedule_rport_register(port); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 446 | out: | 
| Christof Schmitt | 14e242e | 2009-08-18 15:43:11 +0200 | [diff] [blame] | 447 | atomic_clear_mask(ZFCP_STATUS_PORT_LINK_TEST, &port->status); | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 448 | put_device(&port->dev); | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 449 | kmem_cache_free(zfcp_fc_req_cache, fc_req); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 450 | } | 
|  | 451 |  | 
|  | 452 | static int zfcp_fc_adisc(struct zfcp_port *port) | 
|  | 453 | { | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 454 | struct zfcp_fc_req *fc_req; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 455 | struct zfcp_adapter *adapter = port->adapter; | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 456 | struct Scsi_Host *shost = adapter->scsi_host; | 
| Christof Schmitt | ee74462 | 2009-11-24 16:54:14 +0100 | [diff] [blame] | 457 | int ret; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 458 |  | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 459 | fc_req = kmem_cache_zalloc(zfcp_fc_req_cache, GFP_ATOMIC); | 
|  | 460 | if (!fc_req) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 461 | return -ENOMEM; | 
|  | 462 |  | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 463 | fc_req->ct_els.port = port; | 
|  | 464 | fc_req->ct_els.req = &fc_req->sg_req; | 
|  | 465 | fc_req->ct_els.resp = &fc_req->sg_rsp; | 
|  | 466 | sg_init_one(&fc_req->sg_req, &fc_req->u.adisc.req, | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 467 | sizeof(struct fc_els_adisc)); | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 468 | sg_init_one(&fc_req->sg_rsp, &fc_req->u.adisc.rsp, | 
| Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 469 | sizeof(struct fc_els_adisc)); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 470 |  | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 471 | fc_req->ct_els.handler = zfcp_fc_adisc_handler; | 
|  | 472 | fc_req->ct_els.handler_data = fc_req; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 473 |  | 
|  | 474 | /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports | 
|  | 475 | without FC-AL-2 capability, so we don't set it */ | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 476 | fc_req->u.adisc.req.adisc_wwpn = fc_host_port_name(shost); | 
|  | 477 | fc_req->u.adisc.req.adisc_wwnn = fc_host_node_name(shost); | 
|  | 478 | fc_req->u.adisc.req.adisc_cmd = ELS_ADISC; | 
|  | 479 | hton24(fc_req->u.adisc.req.adisc_port_id, fc_host_port_id(shost)); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 480 |  | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 481 | ret = zfcp_fsf_send_els(adapter, port->d_id, &fc_req->ct_els, | 
| Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 482 | ZFCP_FC_CTELS_TMO); | 
| Christof Schmitt | ee74462 | 2009-11-24 16:54:14 +0100 | [diff] [blame] | 483 | if (ret) | 
| Christof Schmitt | 087897e | 2011-02-22 19:54:41 +0100 | [diff] [blame] | 484 | kmem_cache_free(zfcp_fc_req_cache, fc_req); | 
| Christof Schmitt | ee74462 | 2009-11-24 16:54:14 +0100 | [diff] [blame] | 485 |  | 
|  | 486 | return ret; | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 487 | } | 
|  | 488 |  | 
| Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 489 | void zfcp_fc_link_test_work(struct work_struct *work) | 
|  | 490 | { | 
|  | 491 | struct zfcp_port *port = | 
|  | 492 | container_of(work, struct zfcp_port, test_link_work); | 
|  | 493 | int retval; | 
|  | 494 |  | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 495 | get_device(&port->dev); | 
| Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 496 | port->rport_task = RPORT_DEL; | 
|  | 497 | zfcp_scsi_rport_work(&port->rport_work); | 
|  | 498 |  | 
| Christof Schmitt | 14e242e | 2009-08-18 15:43:11 +0200 | [diff] [blame] | 499 | /* only issue one test command at one time per port */ | 
|  | 500 | if (atomic_read(&port->status) & ZFCP_STATUS_PORT_LINK_TEST) | 
|  | 501 | goto out; | 
|  | 502 |  | 
|  | 503 | atomic_set_mask(ZFCP_STATUS_PORT_LINK_TEST, &port->status); | 
|  | 504 |  | 
| Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 505 | retval = zfcp_fc_adisc(port); | 
|  | 506 | if (retval == 0) | 
|  | 507 | return; | 
|  | 508 |  | 
|  | 509 | /* send of ADISC was not possible */ | 
| Christof Schmitt | 14e242e | 2009-08-18 15:43:11 +0200 | [diff] [blame] | 510 | atomic_clear_mask(ZFCP_STATUS_PORT_LINK_TEST, &port->status); | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 511 | zfcp_erp_port_forced_reopen(port, 0, "fcltwk1"); | 
| Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 512 |  | 
| Christof Schmitt | 14e242e | 2009-08-18 15:43:11 +0200 | [diff] [blame] | 513 | out: | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 514 | put_device(&port->dev); | 
| Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 515 | } | 
|  | 516 |  | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 517 | /** | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 518 | * zfcp_fc_test_link - lightweight link test procedure | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 519 | * @port: port to be tested | 
|  | 520 | * | 
|  | 521 | * Test status of a link to a remote port using the ELS command ADISC. | 
|  | 522 | * If there is a problem with the remote port, error recovery steps | 
|  | 523 | * will be triggered. | 
|  | 524 | */ | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 525 | void zfcp_fc_test_link(struct zfcp_port *port) | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 526 | { | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 527 | get_device(&port->dev); | 
| Swen Schillig | 4544683 | 2009-08-18 15:43:17 +0200 | [diff] [blame] | 528 | if (!queue_work(port->adapter->work_queue, &port->test_link_work)) | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 529 | put_device(&port->dev); | 
| Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 530 | } | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 531 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 532 | static struct zfcp_fc_req *zfcp_alloc_sg_env(int buf_num) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 533 | { | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 534 | struct zfcp_fc_req *fc_req; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 535 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 536 | fc_req = kmem_cache_zalloc(zfcp_fc_req_cache, GFP_KERNEL); | 
|  | 537 | if (!fc_req) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 538 | return NULL; | 
|  | 539 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 540 | if (zfcp_sg_setup_table(&fc_req->sg_rsp, buf_num)) { | 
|  | 541 | kmem_cache_free(zfcp_fc_req_cache, fc_req); | 
|  | 542 | return NULL; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 543 | } | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 544 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 545 | sg_init_one(&fc_req->sg_req, &fc_req->u.gpn_ft.req, | 
|  | 546 | sizeof(struct zfcp_fc_gpn_ft_req)); | 
|  | 547 |  | 
|  | 548 | return fc_req; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 549 | } | 
|  | 550 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 551 | static int zfcp_fc_send_gpn_ft(struct zfcp_fc_req *fc_req, | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 552 | struct zfcp_adapter *adapter, int max_bytes) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 553 | { | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 554 | struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; | 
|  | 555 | struct zfcp_fc_gpn_ft_req *req = &fc_req->u.gpn_ft.req; | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 556 | DECLARE_COMPLETION_ONSTACK(completion); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 557 | int ret; | 
|  | 558 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 559 | zfcp_fc_ct_ns_init(&req->ct_hdr, FC_NS_GPN_FT, max_bytes); | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 560 | req->gpn_ft.fn_fc4_type = FC_TYPE_FCP; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 561 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 562 | ct_els->handler = zfcp_fc_complete; | 
|  | 563 | ct_els->handler_data = &completion; | 
|  | 564 | ct_els->req = &fc_req->sg_req; | 
|  | 565 | ct_els->resp = &fc_req->sg_rsp; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 566 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 567 | ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL, | 
| Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 568 | ZFCP_FC_CTELS_TMO); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 569 | if (!ret) | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 570 | wait_for_completion(&completion); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 571 | return ret; | 
|  | 572 | } | 
|  | 573 |  | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 574 | static void zfcp_fc_validate_port(struct zfcp_port *port, struct list_head *lh) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 575 | { | 
| Martin Petermann | 6ab35c0 | 2009-04-17 15:08:13 +0200 | [diff] [blame] | 576 | if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC)) | 
|  | 577 | return; | 
|  | 578 |  | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 579 | atomic_clear_mask(ZFCP_STATUS_COMMON_NOESC, &port->status); | 
|  | 580 |  | 
| Christof Schmitt | 0406289 | 2008-10-01 12:42:20 +0200 | [diff] [blame] | 581 | if ((port->supported_classes != 0) || | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 582 | !list_empty(&port->unit_list)) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 583 | return; | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 584 |  | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 585 | list_move_tail(&port->list, lh); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 586 | } | 
|  | 587 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 588 | static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_req *fc_req, | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 589 | struct zfcp_adapter *adapter, int max_entries) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 590 | { | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 591 | struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; | 
|  | 592 | struct scatterlist *sg = &fc_req->sg_rsp; | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 593 | struct fc_ct_hdr *hdr = sg_virt(sg); | 
|  | 594 | struct fc_gpn_ft_resp *acc = sg_virt(sg); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 595 | struct zfcp_port *port, *tmp; | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 596 | unsigned long flags; | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 597 | LIST_HEAD(remove_lh); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 598 | u32 d_id; | 
| Christof Schmitt | 47f7bba | 2008-08-21 13:43:33 +0200 | [diff] [blame] | 599 | int ret = 0, x, last = 0; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 600 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 601 | if (ct_els->status) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 602 | return -EIO; | 
|  | 603 |  | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 604 | if (hdr->ct_cmd != FC_FS_ACC) { | 
|  | 605 | if (hdr->ct_reason == FC_BA_RJT_UNABLE) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 606 | return -EAGAIN; /* might be a temporary condition */ | 
|  | 607 | return -EIO; | 
|  | 608 | } | 
|  | 609 |  | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 610 | if (hdr->ct_mr_size) { | 
| Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 611 | dev_warn(&adapter->ccw_device->dev, | 
|  | 612 | "The name server reported %d words residual data\n", | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 613 | hdr->ct_mr_size); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 614 | return -E2BIG; | 
| Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 615 | } | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 616 |  | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 617 | /* first entry is the header */ | 
| Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 618 | for (x = 1; x < max_entries && !last; x++) { | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 619 | if (x % (ZFCP_FC_GPN_FT_ENT_PAGE + 1)) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 620 | acc++; | 
|  | 621 | else | 
|  | 622 | acc = sg_virt(++sg); | 
|  | 623 |  | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 624 | last = acc->fp_flags & FC_NS_FID_LAST; | 
|  | 625 | d_id = ntoh24(acc->fp_fid); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 626 |  | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 627 | /* don't attach ports with a well known address */ | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 628 | if (d_id >= FC_FID_WELL_KNOWN_BASE) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 629 | continue; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 630 | /* skip the adapter's port and known remote ports */ | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 631 | if (acc->fp_wwpn == fc_host_port_name(adapter->scsi_host)) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 632 | continue; | 
|  | 633 |  | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 634 | port = zfcp_port_enqueue(adapter, acc->fp_wwpn, | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 635 | ZFCP_STATUS_COMMON_NOESC, d_id); | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 636 | if (!IS_ERR(port)) | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 637 | zfcp_erp_port_reopen(port, 0, "fcegpf1"); | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 638 | else if (PTR_ERR(port) != -EEXIST) | 
|  | 639 | ret = PTR_ERR(port); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 640 | } | 
|  | 641 |  | 
|  | 642 | zfcp_erp_wait(adapter); | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 643 | write_lock_irqsave(&adapter->port_list_lock, flags); | 
|  | 644 | list_for_each_entry_safe(port, tmp, &adapter->port_list, list) | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 645 | zfcp_fc_validate_port(port, &remove_lh); | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 646 | write_unlock_irqrestore(&adapter->port_list_lock, flags); | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 647 |  | 
|  | 648 | list_for_each_entry_safe(port, tmp, &remove_lh, list) { | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 649 | zfcp_erp_port_shutdown(port, 0, "fcegpf2"); | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 650 | zfcp_device_unregister(&port->dev, &zfcp_sysfs_port_attrs); | 
| Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 651 | } | 
|  | 652 |  | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 653 | return ret; | 
|  | 654 | } | 
|  | 655 |  | 
|  | 656 | /** | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 657 | * zfcp_fc_scan_ports - scan remote ports and attach new ports | 
| Swen Schillig | 9eae07e | 2009-11-24 16:54:06 +0100 | [diff] [blame] | 658 | * @work: reference to scheduled work | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 659 | */ | 
| Swen Schillig | 9eae07e | 2009-11-24 16:54:06 +0100 | [diff] [blame] | 660 | void zfcp_fc_scan_ports(struct work_struct *work) | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 661 | { | 
| Swen Schillig | 9eae07e | 2009-11-24 16:54:06 +0100 | [diff] [blame] | 662 | struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter, | 
|  | 663 | scan_work); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 664 | int ret, i; | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 665 | struct zfcp_fc_req *fc_req; | 
| Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 666 | int chain, max_entries, buf_num, max_bytes; | 
|  | 667 |  | 
|  | 668 | chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS; | 
| Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 669 | buf_num = chain ? ZFCP_FC_GPN_FT_NUM_BUFS : 1; | 
|  | 670 | max_entries = chain ? ZFCP_FC_GPN_FT_MAX_ENT : ZFCP_FC_GPN_FT_ENT_PAGE; | 
|  | 671 | max_bytes = chain ? ZFCP_FC_GPN_FT_MAX_SIZE : ZFCP_FC_CT_SIZE_PAGE; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 672 |  | 
| Swen Schillig | 306b6ed | 2009-04-17 15:08:02 +0200 | [diff] [blame] | 673 | if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT && | 
|  | 674 | fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) | 
| Swen Schillig | 9eae07e | 2009-11-24 16:54:06 +0100 | [diff] [blame] | 675 | return; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 676 |  | 
| Swen Schillig | 9eae07e | 2009-11-24 16:54:06 +0100 | [diff] [blame] | 677 | if (zfcp_fc_wka_port_get(&adapter->gs->ds)) | 
|  | 678 | return; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 679 |  | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 680 | fc_req = zfcp_alloc_sg_env(buf_num); | 
|  | 681 | if (!fc_req) | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 682 | goto out; | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 683 |  | 
|  | 684 | for (i = 0; i < 3; i++) { | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 685 | ret = zfcp_fc_send_gpn_ft(fc_req, adapter, max_bytes); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 686 | if (!ret) { | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 687 | ret = zfcp_fc_eval_gpn_ft(fc_req, adapter, max_entries); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 688 | if (ret == -EAGAIN) | 
|  | 689 | ssleep(1); | 
|  | 690 | else | 
|  | 691 | break; | 
|  | 692 | } | 
|  | 693 | } | 
| Christof Schmitt | f977322 | 2011-02-22 19:54:43 +0100 | [diff] [blame] | 694 | zfcp_sg_free_table(&fc_req->sg_rsp, buf_num); | 
|  | 695 | kmem_cache_free(zfcp_fc_req_cache, fc_req); | 
| Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 696 | out: | 
| Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 697 | zfcp_fc_wka_port_put(&adapter->gs->ds); | 
| Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 698 | } | 
|  | 699 |  | 
| Christof Schmitt | 038d944 | 2011-02-22 19:54:48 +0100 | [diff] [blame] | 700 | static int zfcp_fc_gspn(struct zfcp_adapter *adapter, | 
|  | 701 | struct zfcp_fc_req *fc_req) | 
|  | 702 | { | 
|  | 703 | DECLARE_COMPLETION_ONSTACK(completion); | 
|  | 704 | char devno[] = "DEVNO:"; | 
|  | 705 | struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; | 
|  | 706 | struct zfcp_fc_gspn_req *gspn_req = &fc_req->u.gspn.req; | 
|  | 707 | struct zfcp_fc_gspn_rsp *gspn_rsp = &fc_req->u.gspn.rsp; | 
|  | 708 | int ret; | 
|  | 709 |  | 
|  | 710 | zfcp_fc_ct_ns_init(&gspn_req->ct_hdr, FC_NS_GSPN_ID, | 
|  | 711 | FC_SYMBOLIC_NAME_SIZE); | 
|  | 712 | hton24(gspn_req->gspn.fp_fid, fc_host_port_id(adapter->scsi_host)); | 
|  | 713 |  | 
|  | 714 | sg_init_one(&fc_req->sg_req, gspn_req, sizeof(*gspn_req)); | 
|  | 715 | sg_init_one(&fc_req->sg_rsp, gspn_rsp, sizeof(*gspn_rsp)); | 
|  | 716 |  | 
|  | 717 | ct_els->handler = zfcp_fc_complete; | 
|  | 718 | ct_els->handler_data = &completion; | 
|  | 719 | ct_els->req = &fc_req->sg_req; | 
|  | 720 | ct_els->resp = &fc_req->sg_rsp; | 
|  | 721 |  | 
|  | 722 | ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL, | 
|  | 723 | ZFCP_FC_CTELS_TMO); | 
|  | 724 | if (ret) | 
|  | 725 | return ret; | 
|  | 726 |  | 
|  | 727 | wait_for_completion(&completion); | 
|  | 728 | if (ct_els->status) | 
|  | 729 | return ct_els->status; | 
|  | 730 |  | 
|  | 731 | if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_NPIV && | 
|  | 732 | !(strstr(gspn_rsp->gspn.fp_name, devno))) | 
|  | 733 | snprintf(fc_host_symbolic_name(adapter->scsi_host), | 
|  | 734 | FC_SYMBOLIC_NAME_SIZE, "%s%s %s NAME: %s", | 
|  | 735 | gspn_rsp->gspn.fp_name, devno, | 
|  | 736 | dev_name(&adapter->ccw_device->dev), | 
|  | 737 | init_utsname()->nodename); | 
|  | 738 | else | 
|  | 739 | strlcpy(fc_host_symbolic_name(adapter->scsi_host), | 
|  | 740 | gspn_rsp->gspn.fp_name, FC_SYMBOLIC_NAME_SIZE); | 
|  | 741 |  | 
|  | 742 | return 0; | 
|  | 743 | } | 
|  | 744 |  | 
|  | 745 | static void zfcp_fc_rspn(struct zfcp_adapter *adapter, | 
|  | 746 | struct zfcp_fc_req *fc_req) | 
|  | 747 | { | 
|  | 748 | DECLARE_COMPLETION_ONSTACK(completion); | 
|  | 749 | struct Scsi_Host *shost = adapter->scsi_host; | 
|  | 750 | struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; | 
|  | 751 | struct zfcp_fc_rspn_req *rspn_req = &fc_req->u.rspn.req; | 
|  | 752 | struct fc_ct_hdr *rspn_rsp = &fc_req->u.rspn.rsp; | 
|  | 753 | int ret, len; | 
|  | 754 |  | 
|  | 755 | zfcp_fc_ct_ns_init(&rspn_req->ct_hdr, FC_NS_RSPN_ID, | 
|  | 756 | FC_SYMBOLIC_NAME_SIZE); | 
|  | 757 | hton24(rspn_req->rspn.fr_fid.fp_fid, fc_host_port_id(shost)); | 
|  | 758 | len = strlcpy(rspn_req->rspn.fr_name, fc_host_symbolic_name(shost), | 
|  | 759 | FC_SYMBOLIC_NAME_SIZE); | 
|  | 760 | rspn_req->rspn.fr_name_len = len; | 
|  | 761 |  | 
|  | 762 | sg_init_one(&fc_req->sg_req, rspn_req, sizeof(*rspn_req)); | 
|  | 763 | sg_init_one(&fc_req->sg_rsp, rspn_rsp, sizeof(*rspn_rsp)); | 
|  | 764 |  | 
|  | 765 | ct_els->handler = zfcp_fc_complete; | 
|  | 766 | ct_els->handler_data = &completion; | 
|  | 767 | ct_els->req = &fc_req->sg_req; | 
|  | 768 | ct_els->resp = &fc_req->sg_rsp; | 
|  | 769 |  | 
|  | 770 | ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL, | 
|  | 771 | ZFCP_FC_CTELS_TMO); | 
|  | 772 | if (!ret) | 
|  | 773 | wait_for_completion(&completion); | 
|  | 774 | } | 
|  | 775 |  | 
|  | 776 | /** | 
|  | 777 | * zfcp_fc_sym_name_update - Retrieve and update the symbolic port name | 
|  | 778 | * @work: ns_up_work of the adapter where to update the symbolic port name | 
|  | 779 | * | 
|  | 780 | * Retrieve the current symbolic port name that may have been set by | 
|  | 781 | * the hardware using the GSPN request and update the fc_host | 
|  | 782 | * symbolic_name sysfs attribute. When running in NPIV mode (and hence | 
|  | 783 | * the port name is unique for this system), update the symbolic port | 
|  | 784 | * name to add Linux specific information and update the FC nameserver | 
|  | 785 | * using the RSPN request. | 
|  | 786 | */ | 
|  | 787 | void zfcp_fc_sym_name_update(struct work_struct *work) | 
|  | 788 | { | 
|  | 789 | struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter, | 
|  | 790 | ns_up_work); | 
|  | 791 | int ret; | 
|  | 792 | struct zfcp_fc_req *fc_req; | 
|  | 793 |  | 
|  | 794 | if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT && | 
|  | 795 | fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) | 
|  | 796 | return; | 
|  | 797 |  | 
|  | 798 | fc_req = kmem_cache_zalloc(zfcp_fc_req_cache, GFP_KERNEL); | 
|  | 799 | if (!fc_req) | 
|  | 800 | return; | 
|  | 801 |  | 
|  | 802 | ret = zfcp_fc_wka_port_get(&adapter->gs->ds); | 
|  | 803 | if (ret) | 
|  | 804 | goto out_free; | 
|  | 805 |  | 
|  | 806 | ret = zfcp_fc_gspn(adapter, fc_req); | 
|  | 807 | if (ret || fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) | 
|  | 808 | goto out_ds_put; | 
|  | 809 |  | 
|  | 810 | memset(fc_req, 0, sizeof(*fc_req)); | 
|  | 811 | zfcp_fc_rspn(adapter, fc_req); | 
|  | 812 |  | 
|  | 813 | out_ds_put: | 
|  | 814 | zfcp_fc_wka_port_put(&adapter->gs->ds); | 
|  | 815 | out_free: | 
|  | 816 | kmem_cache_free(zfcp_fc_req_cache, fc_req); | 
|  | 817 | } | 
|  | 818 |  | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 819 | static void zfcp_fc_ct_els_job_handler(void *data) | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 820 | { | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 821 | struct fc_bsg_job *job = data; | 
|  | 822 | struct zfcp_fsf_ct_els *zfcp_ct_els = job->dd_data; | 
| Swen Schillig | 7dec9cf | 2010-01-26 17:49:19 +0100 | [diff] [blame] | 823 | struct fc_bsg_reply *jr = job->reply; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 824 |  | 
| Swen Schillig | 7dec9cf | 2010-01-26 17:49:19 +0100 | [diff] [blame] | 825 | jr->reply_payload_rcv_len = job->reply_payload.payload_len; | 
|  | 826 | jr->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; | 
|  | 827 | jr->result = zfcp_ct_els->status ? -EIO : 0; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 828 | job->job_done(job); | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 829 | } | 
|  | 830 |  | 
| Christof Schmitt | f09d545 | 2010-01-13 17:52:36 +0100 | [diff] [blame] | 831 | static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port(struct fc_bsg_job *job) | 
|  | 832 | { | 
|  | 833 | u32 preamble_word1; | 
|  | 834 | u8 gs_type; | 
|  | 835 | struct zfcp_adapter *adapter; | 
|  | 836 |  | 
|  | 837 | preamble_word1 = job->request->rqst_data.r_ct.preamble_word1; | 
|  | 838 | gs_type = (preamble_word1 & 0xff000000) >> 24; | 
|  | 839 |  | 
|  | 840 | adapter = (struct zfcp_adapter *) job->shost->hostdata[0]; | 
|  | 841 |  | 
|  | 842 | switch (gs_type) { | 
|  | 843 | case FC_FST_ALIAS: | 
|  | 844 | return &adapter->gs->as; | 
|  | 845 | case FC_FST_MGMT: | 
|  | 846 | return &adapter->gs->ms; | 
|  | 847 | case FC_FST_TIME: | 
|  | 848 | return &adapter->gs->ts; | 
|  | 849 | break; | 
|  | 850 | case FC_FST_DIR: | 
|  | 851 | return &adapter->gs->ds; | 
|  | 852 | break; | 
|  | 853 | default: | 
|  | 854 | return NULL; | 
|  | 855 | } | 
|  | 856 | } | 
|  | 857 |  | 
|  | 858 | static void zfcp_fc_ct_job_handler(void *data) | 
|  | 859 | { | 
|  | 860 | struct fc_bsg_job *job = data; | 
|  | 861 | struct zfcp_fc_wka_port *wka_port; | 
|  | 862 |  | 
|  | 863 | wka_port = zfcp_fc_job_wka_port(job); | 
|  | 864 | zfcp_fc_wka_port_put(wka_port); | 
|  | 865 |  | 
|  | 866 | zfcp_fc_ct_els_job_handler(data); | 
|  | 867 | } | 
|  | 868 |  | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 869 | static int zfcp_fc_exec_els_job(struct fc_bsg_job *job, | 
|  | 870 | struct zfcp_adapter *adapter) | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 871 | { | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 872 | struct zfcp_fsf_ct_els *els = job->dd_data; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 873 | struct fc_rport *rport = job->rport; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 874 | struct zfcp_port *port; | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 875 | u32 d_id; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 876 |  | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 877 | if (rport) { | 
| Swen Schillig | ea945ff | 2009-08-18 15:43:24 +0200 | [diff] [blame] | 878 | port = zfcp_get_port_by_wwpn(adapter, rport->port_name); | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 879 | if (!port) | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 880 | return -EINVAL; | 
| Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 881 |  | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 882 | d_id = port->d_id; | 
| Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 883 | put_device(&port->dev); | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 884 | } else | 
|  | 885 | d_id = ntoh24(job->request->rqst_data.h_els.port_id); | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 886 |  | 
| Christof Schmitt | f09d545 | 2010-01-13 17:52:36 +0100 | [diff] [blame] | 887 | els->handler = zfcp_fc_ct_els_job_handler; | 
| Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 888 | return zfcp_fsf_send_els(adapter, d_id, els, job->req->timeout / HZ); | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 889 | } | 
|  | 890 |  | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 891 | static int zfcp_fc_exec_ct_job(struct fc_bsg_job *job, | 
|  | 892 | struct zfcp_adapter *adapter) | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 893 | { | 
|  | 894 | int ret; | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 895 | struct zfcp_fsf_ct_els *ct = job->dd_data; | 
|  | 896 | struct zfcp_fc_wka_port *wka_port; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 897 |  | 
| Christof Schmitt | f09d545 | 2010-01-13 17:52:36 +0100 | [diff] [blame] | 898 | wka_port = zfcp_fc_job_wka_port(job); | 
|  | 899 | if (!wka_port) | 
|  | 900 | return -EINVAL; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 901 |  | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 902 | ret = zfcp_fc_wka_port_get(wka_port); | 
|  | 903 | if (ret) | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 904 | return ret; | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 905 |  | 
| Christof Schmitt | f09d545 | 2010-01-13 17:52:36 +0100 | [diff] [blame] | 906 | ct->handler = zfcp_fc_ct_job_handler; | 
| Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 907 | ret = zfcp_fsf_send_ct(wka_port, ct, NULL, job->req->timeout / HZ); | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 908 | if (ret) | 
|  | 909 | zfcp_fc_wka_port_put(wka_port); | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 910 |  | 
| Sven Schuetz | 9d544f2 | 2009-04-06 18:31:47 +0200 | [diff] [blame] | 911 | return ret; | 
|  | 912 | } | 
| Swen Schillig | d5a282a | 2009-08-18 15:43:22 +0200 | [diff] [blame] | 913 |  | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 914 | int zfcp_fc_exec_bsg_job(struct fc_bsg_job *job) | 
|  | 915 | { | 
|  | 916 | struct Scsi_Host *shost; | 
|  | 917 | struct zfcp_adapter *adapter; | 
|  | 918 | struct zfcp_fsf_ct_els *ct_els = job->dd_data; | 
|  | 919 |  | 
|  | 920 | shost = job->rport ? rport_to_shost(job->rport) : job->shost; | 
|  | 921 | adapter = (struct zfcp_adapter *)shost->hostdata[0]; | 
|  | 922 |  | 
|  | 923 | if (!(atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_OPEN)) | 
|  | 924 | return -EINVAL; | 
|  | 925 |  | 
|  | 926 | ct_els->req = job->request_payload.sg_list; | 
|  | 927 | ct_els->resp = job->reply_payload.sg_list; | 
| Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 928 | ct_els->handler_data = job; | 
|  | 929 |  | 
|  | 930 | switch (job->request->msgcode) { | 
|  | 931 | case FC_BSG_RPT_ELS: | 
|  | 932 | case FC_BSG_HST_ELS_NOLOGIN: | 
|  | 933 | return zfcp_fc_exec_els_job(job, adapter); | 
|  | 934 | case FC_BSG_RPT_CT: | 
|  | 935 | case FC_BSG_HST_CT: | 
|  | 936 | return zfcp_fc_exec_ct_job(job, adapter); | 
|  | 937 | default: | 
|  | 938 | return -EINVAL; | 
|  | 939 | } | 
|  | 940 | } | 
|  | 941 |  | 
| Swen Schillig | 491ca44 | 2010-01-14 17:19:01 +0100 | [diff] [blame] | 942 | int zfcp_fc_timeout_bsg_job(struct fc_bsg_job *job) | 
|  | 943 | { | 
|  | 944 | /* hardware tracks timeout, reset bsg timeout to not interfere */ | 
|  | 945 | return -EAGAIN; | 
|  | 946 | } | 
|  | 947 |  | 
| Swen Schillig | d5a282a | 2009-08-18 15:43:22 +0200 | [diff] [blame] | 948 | int zfcp_fc_gs_setup(struct zfcp_adapter *adapter) | 
|  | 949 | { | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 950 | struct zfcp_fc_wka_ports *wka_ports; | 
| Swen Schillig | d5a282a | 2009-08-18 15:43:22 +0200 | [diff] [blame] | 951 |  | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 952 | wka_ports = kzalloc(sizeof(struct zfcp_fc_wka_ports), GFP_KERNEL); | 
| Swen Schillig | d5a282a | 2009-08-18 15:43:22 +0200 | [diff] [blame] | 953 | if (!wka_ports) | 
|  | 954 | return -ENOMEM; | 
|  | 955 |  | 
|  | 956 | adapter->gs = wka_ports; | 
|  | 957 | zfcp_fc_wka_port_init(&wka_ports->ms, FC_FID_MGMT_SERV, adapter); | 
|  | 958 | zfcp_fc_wka_port_init(&wka_ports->ts, FC_FID_TIME_SERV, adapter); | 
|  | 959 | zfcp_fc_wka_port_init(&wka_ports->ds, FC_FID_DIR_SERV, adapter); | 
|  | 960 | zfcp_fc_wka_port_init(&wka_ports->as, FC_FID_ALIASES, adapter); | 
| Swen Schillig | d5a282a | 2009-08-18 15:43:22 +0200 | [diff] [blame] | 961 |  | 
|  | 962 | return 0; | 
|  | 963 | } | 
|  | 964 |  | 
|  | 965 | void zfcp_fc_gs_destroy(struct zfcp_adapter *adapter) | 
|  | 966 | { | 
|  | 967 | kfree(adapter->gs); | 
|  | 968 | adapter->gs = NULL; | 
|  | 969 | } | 
|  | 970 |  |