Lines Matching refs:req
80 static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req)
82 dev_err(&req->adapter->ccw_device->dev, "FCP device not "
84 zfcp_erp_adapter_shutdown(req->adapter, 0, "fscns_1");
85 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
90 * @req: pointer to struct zfcp_fsf_req
92 void zfcp_fsf_req_free(struct zfcp_fsf_req *req)
94 if (likely(req->pool)) {
95 if (likely(!zfcp_fsf_req_is_status_read_buffer(req)))
96 mempool_free(req->qtcb, req->adapter->pool.qtcb_pool);
97 mempool_free(req, req->pool);
101 if (likely(!zfcp_fsf_req_is_status_read_buffer(req)))
102 kmem_cache_free(zfcp_fsf_qtcb_cache, req->qtcb);
103 kfree(req);
106 static void zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *req)
109 struct fsf_status_read_buffer *sr_buf = req->data;
110 struct zfcp_adapter *adapter = req->adapter;
144 static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req,
147 struct zfcp_adapter *adapter = req->adapter;
163 dev_warn(&req->adapter->ccw_device->dev,
168 dev_warn(&req->adapter->ccw_device->dev,
173 dev_warn(&req->adapter->ccw_device->dev,
178 dev_warn(&req->adapter->ccw_device->dev,
183 dev_warn(&req->adapter->ccw_device->dev,
188 dev_warn(&req->adapter->ccw_device->dev,
192 dev_warn(&req->adapter->ccw_device->dev,
196 dev_warn(&req->adapter->ccw_device->dev,
201 dev_warn(&req->adapter->ccw_device->dev,
206 dev_warn(&req->adapter->ccw_device->dev,
211 dev_warn(&req->adapter->ccw_device->dev,
216 dev_warn(&req->adapter->ccw_device->dev,
221 dev_warn(&req->adapter->ccw_device->dev,
229 static void zfcp_fsf_status_read_link_down(struct zfcp_fsf_req *req)
231 struct fsf_status_read_buffer *sr_buf = req->data;
238 zfcp_fsf_link_down_info_eval(req, ldi);
241 zfcp_fsf_link_down_info_eval(req, NULL);
258 static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
260 struct zfcp_adapter *adapter = req->adapter;
261 struct fsf_status_read_buffer *sr_buf = req->data;
263 if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
264 zfcp_dbf_hba_fsf_uss("fssrh_1", req);
266 zfcp_fsf_req_free(req);
270 zfcp_dbf_hba_fsf_uss("fssrh_4", req);
274 zfcp_fsf_status_read_port_closed(req);
277 zfcp_fc_incoming_els(req);
282 zfcp_dbf_hba_bit_err("fssrh_3", req);
293 zfcp_fsf_status_read_link_down(req);
325 zfcp_fsf_req_free(req);
331 static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)
333 switch (req->qtcb->header.fsf_status_qual.word[0]) {
342 dev_err(&req->adapter->ccw_device->dev,
345 zfcp_qdio_siosl(req->adapter);
346 zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfsqe1");
350 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
353 static void zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *req)
355 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
358 switch (req->qtcb->header.fsf_status) {
360 dev_err(&req->adapter->ccw_device->dev,
362 req->qtcb->header.fsf_command);
363 zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfse_1");
364 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
367 zfcp_fsf_fsfstatus_qual_eval(req);
372 static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
374 struct zfcp_adapter *adapter = req->adapter;
375 struct fsf_qtcb *qtcb = req->qtcb;
378 zfcp_dbf_hba_fsf_response(req);
380 if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
381 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
399 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
417 zfcp_fsf_link_down_info_eval(req, &psq->link_down_info);
437 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
442 * @req: The FSF request that has been completed.
452 static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req)
456 if (unlikely(zfcp_fsf_req_is_status_read_buffer(req))) {
457 zfcp_fsf_status_read_handler(req);
461 del_timer_sync(&req->timer);
462 zfcp_fsf_protstatus_eval(req);
463 zfcp_fsf_fsfstatus_eval(req);
464 req->handler(req);
466 erp_action = req->erp_action;
470 if (likely(req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
471 zfcp_fsf_req_free(req);
473 complete(&req->completion);
487 struct zfcp_fsf_req *req, *tmp;
493 list_for_each_entry_safe(req, tmp, &remove_queue, list) {
494 list_del(&req->list);
495 req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
496 zfcp_fsf_req_complete(req);
537 static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
539 struct fsf_qtcb_bottom_config *bottom = &req->qtcb->bottom.config;
540 struct zfcp_adapter *adapter = req->adapter;
547 if (req->data)
548 memcpy(req->data, bottom, sizeof(*bottom));
556 if (req->qtcb->header.fsf_status == FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE)
581 static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
583 struct zfcp_adapter *adapter = req->adapter;
586 struct fsf_qtcb *qtcb = req->qtcb;
589 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
608 if (zfcp_fsf_exchange_config_evaluate(req))
624 req->status |= ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE;
630 zfcp_fsf_link_down_info_eval(req,
634 if (zfcp_fsf_exchange_config_evaluate(req))
738 struct zfcp_fsf_req *req)
746 zfcp_dbf_hba_fsf_fces("fsfcesa", req, ZFCP_DBF_INVALID_WWPN,
753 static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
755 struct zfcp_adapter *adapter = req->adapter;
756 struct fsf_qtcb_bottom_port *bottom = &req->qtcb->bottom.port;
758 if (req->data)
759 memcpy(req->data, bottom, sizeof(*bottom));
766 zfcp_fsf_dbf_adapter_fc_security(adapter, req);
769 static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
772 &req->adapter->diagnostics->port_data.header;
773 struct fsf_qtcb *qtcb = req->qtcb;
776 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
787 zfcp_scsi_shost_update_port_data(req->adapter, bottom);
788 zfcp_fsf_exchange_port_evaluate(req);
792 req->status |= ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE;
794 zfcp_fsf_link_down_info_eval(req,
797 zfcp_scsi_shost_update_port_data(req->adapter, bottom);
798 zfcp_fsf_exchange_port_evaluate(req);
805 struct zfcp_fsf_req *req;
808 req = mempool_alloc(pool, GFP_ATOMIC);
810 req = kmalloc(sizeof(*req), GFP_ATOMIC);
812 if (unlikely(!req))
815 memset(req, 0, sizeof(*req));
816 req->pool = pool;
817 return req;
841 struct zfcp_fsf_req *req = zfcp_fsf_alloc(pool);
843 if (unlikely(!req))
849 timer_setup(&req->timer, NULL, 0);
850 init_completion(&req->completion);
852 req->adapter = adapter;
853 req->req_id = adapter->req_no;
857 req->qtcb = zfcp_fsf_qtcb_alloc(
860 req->qtcb = zfcp_fsf_qtcb_alloc(NULL);
862 if (unlikely(!req->qtcb)) {
863 zfcp_fsf_req_free(req);
867 req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
868 req->qtcb->prefix.req_id = req->req_id;
869 req->qtcb->prefix.ulp_info = 26;
870 req->qtcb->prefix.qtcb_type = fsf_qtcb_type[fsf_cmd];
871 req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION;
872 req->qtcb->header.req_handle = req->req_id;
873 req->qtcb->header.fsf_command = fsf_cmd;
876 zfcp_qdio_req_init(adapter->qdio, &req->qdio_req, req->req_id, sbtype,
877 req->qtcb, sizeof(struct fsf_qtcb));
879 return req;
882 static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
884 const bool is_srb = zfcp_fsf_req_is_status_read_buffer(req);
885 struct zfcp_adapter *adapter = req->adapter;
887 u64 req_id = req->req_id;
889 zfcp_reqlist_add(adapter->req_list, req);
891 req->qdio_req.qdio_outb_usage = atomic_read(&qdio->req_q_free);
892 req->issued = get_tod_clock();
893 if (zfcp_qdio_send(qdio, &req->qdio_req)) {
894 del_timer_sync(&req->timer);
905 * NOTE: DO NOT TOUCH ASYNC req PAST THIS POINT.
906 * ONLY TOUCH SYNC req AGAIN ON req->completion.
912 * when it is completed via req->completion, is it safe to use req
932 struct zfcp_fsf_req *req;
941 req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS,
944 if (IS_ERR(req)) {
945 retval = PTR_ERR(req);
956 req->data = sr_buf;
958 zfcp_qdio_fill_next(qdio, &req->qdio_req, sr_buf, sizeof(*sr_buf));
959 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
961 retval = zfcp_fsf_req_send(req);
964 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
969 req->data = NULL;
972 zfcp_dbf_hba_fsf_uss("fssr__1", req);
973 zfcp_fsf_req_free(req);
979 static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
981 struct scsi_device *sdev = req->data;
983 union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual;
985 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
990 switch (req->qtcb->header.fsf_status) {
995 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1001 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1005 req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
1012 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1018 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1026 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1031 req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED;
1044 struct zfcp_fsf_req *req = NULL;
1053 req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND,
1056 if (IS_ERR(req)) {
1057 req = NULL;
1065 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1067 req->data = sdev;
1068 req->handler = zfcp_fsf_abort_fcp_command_handler;
1069 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
1070 req->qtcb->header.port_handle = zfcp_sdev->port->handle;
1071 req->qtcb->bottom.support.req_handle = old_req_id;
1073 zfcp_fsf_start_timer(req, ZFCP_FSF_SCSI_ER_TIMEOUT);
1074 if (!zfcp_fsf_req_send(req)) {
1075 /* NOTE: DO NOT TOUCH req, UNTIL IT COMPLETES! */
1080 zfcp_fsf_req_free(req);
1081 req = NULL;
1084 return req;
1087 static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
1089 struct zfcp_adapter *adapter = req->adapter;
1090 struct zfcp_fsf_ct_els *ct = req->data;
1091 struct fsf_qtcb_header *header = &req->qtcb->header;
1095 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1101 zfcp_dbf_san_res("fsscth2", req);
1104 zfcp_fsf_class_not_supp(req);
1110 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1115 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1125 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1144 static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
1148 struct zfcp_adapter *adapter = req->adapter;
1150 struct fsf_qtcb *qtcb = req->qtcb;
1154 if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_req))
1158 if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_resp))
1163 zfcp_qdio_set_data_div(qdio, &req->qdio_req, sg_nents(sg_req));
1164 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1165 zfcp_qdio_set_scount(qdio, &req->qdio_req);
1171 zfcp_fsf_setup_ct_els_unchained(qdio, &req->qdio_req,
1179 if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_req))
1184 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1185 zfcp_qdio_skip_to_last_sbale(qdio, &req->qdio_req);
1187 if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_resp))
1192 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1197 static int zfcp_fsf_setup_ct_els(struct zfcp_fsf_req *req,
1204 ret = zfcp_fsf_setup_ct_els_sbals(req, sg_req, sg_resp);
1211 req->qtcb->bottom.support.service_class = FSF_CLASS_3;
1212 req->qtcb->bottom.support.timeout = timeout;
1213 zfcp_fsf_start_timer(req, (timeout + 10) * HZ);
1230 struct zfcp_fsf_req *req;
1237 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC,
1240 if (IS_ERR(req)) {
1241 ret = PTR_ERR(req);
1245 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1246 ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp, timeout);
1250 req->handler = zfcp_fsf_send_ct_handler;
1251 req->qtcb->header.port_handle = wka_port->handle;
1253 req->data = ct;
1255 zfcp_dbf_san_req("fssct_1", req, wka_port->d_id);
1257 ret = zfcp_fsf_req_send(req);
1260 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
1265 zfcp_fsf_req_free(req);
1271 static void zfcp_fsf_send_els_handler(struct zfcp_fsf_req *req)
1273 struct zfcp_fsf_ct_els *send_els = req->data;
1274 struct fsf_qtcb_header *header = &req->qtcb->header;
1278 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1284 zfcp_dbf_san_res("fsselh1", req);
1287 zfcp_fsf_class_not_supp(req);
1294 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1307 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1325 struct zfcp_fsf_req *req;
1333 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS,
1336 if (IS_ERR(req)) {
1337 ret = PTR_ERR(req);
1341 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1344 zfcp_qdio_sbal_limit(qdio, &req->qdio_req, 2);
1346 ret = zfcp_fsf_setup_ct_els(req, els->req, els->resp, timeout);
1351 hton24(req->qtcb->bottom.support.d_id, d_id);
1352 req->handler = zfcp_fsf_send_els_handler;
1354 req->data = els;
1356 zfcp_dbf_san_req("fssels1", req, d_id);
1358 ret = zfcp_fsf_req_send(req);
1361 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
1366 zfcp_fsf_req_free(req);
1374 struct zfcp_fsf_req *req;
1382 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
1386 if (IS_ERR(req)) {
1387 retval = PTR_ERR(req);
1391 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1392 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1394 req->qtcb->bottom.config.feature_selection =
1399 req->erp_action = erp_action;
1400 req->handler = zfcp_fsf_exchange_config_data_handler;
1401 erp_action->fsf_req_id = req->req_id;
1403 zfcp_fsf_start_erp_timer(req);
1404 retval = zfcp_fsf_req_send(req);
1406 zfcp_fsf_req_free(req);
1409 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
1431 struct zfcp_fsf_req *req = NULL;
1438 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
1441 if (IS_ERR(req)) {
1442 retval = PTR_ERR(req);
1446 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1447 req->handler = zfcp_fsf_exchange_config_data_handler;
1449 req->qtcb->bottom.config.feature_selection =
1456 req->data = data;
1458 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1459 retval = zfcp_fsf_req_send(req);
1463 /* NOTE: ONLY TOUCH SYNC req AGAIN ON req->completion. */
1464 wait_for_completion(&req->completion);
1466 if (req->status &
1469 else if (req->status & ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE)
1473 zfcp_fsf_req_free(req);
1489 struct zfcp_fsf_req *req;
1499 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
1503 if (IS_ERR(req)) {
1504 retval = PTR_ERR(req);
1508 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1509 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1511 req->handler = zfcp_fsf_exchange_port_data_handler;
1512 req->erp_action = erp_action;
1513 erp_action->fsf_req_id = req->req_id;
1515 zfcp_fsf_start_erp_timer(req);
1516 retval = zfcp_fsf_req_send(req);
1518 zfcp_fsf_req_free(req);
1521 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
1543 struct zfcp_fsf_req *req = NULL;
1553 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
1556 if (IS_ERR(req)) {
1557 retval = PTR_ERR(req);
1562 req->data = data;
1564 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1566 req->handler = zfcp_fsf_exchange_port_data_handler;
1567 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1568 retval = zfcp_fsf_req_send(req);
1572 /* NOTE: ONLY TOUCH SYNC req AGAIN ON req->completion. */
1573 wait_for_completion(&req->completion);
1575 if (req->status &
1578 else if (req->status & ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE)
1582 zfcp_fsf_req_free(req);
1591 struct zfcp_fsf_req *req)
1601 zfcp_dbf_hba_fsf_fces("fsfcesp", req, port->wwpn,
1695 static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
1697 struct zfcp_adapter *adapter = req->adapter;
1698 struct zfcp_port *port = req->data;
1699 struct fsf_qtcb_header *header = &req->qtcb->header;
1700 struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support;
1703 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1716 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1719 zfcp_fsf_log_security_error(&req->adapter->ccw_device->dev,
1722 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1731 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1741 zfcp_fsf_log_port_fc_security(port, req);
1766 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1783 struct zfcp_fsf_req *req;
1790 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
1794 if (IS_ERR(req)) {
1795 retval = PTR_ERR(req);
1799 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1800 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1802 req->handler = zfcp_fsf_open_port_handler;
1803 hton24(req->qtcb->bottom.support.d_id, port->d_id);
1804 req->data = port;
1805 req->erp_action = erp_action;
1806 erp_action->fsf_req_id = req->req_id;
1809 zfcp_fsf_start_erp_timer(req);
1810 retval = zfcp_fsf_req_send(req);
1812 zfcp_fsf_req_free(req);
1816 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
1822 static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
1824 struct zfcp_port *port = req->data;
1826 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1829 switch (req->qtcb->header.fsf_status) {
1832 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1850 struct zfcp_fsf_req *req;
1857 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
1861 if (IS_ERR(req)) {
1862 retval = PTR_ERR(req);
1866 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1867 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1869 req->handler = zfcp_fsf_close_port_handler;
1870 req->data = erp_action->port;
1871 req->erp_action = erp_action;
1872 req->qtcb->header.port_handle = erp_action->port->handle;
1873 erp_action->fsf_req_id = req->req_id;
1875 zfcp_fsf_start_erp_timer(req);
1876 retval = zfcp_fsf_req_send(req);
1878 zfcp_fsf_req_free(req);
1881 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
1887 static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
1889 struct zfcp_fc_wka_port *wka_port = req->data;
1890 struct fsf_qtcb_header *header = &req->qtcb->header;
1892 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) {
1899 dev_warn(&req->adapter->ccw_device->dev,
1903 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1924 struct zfcp_fsf_req *req;
1932 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
1936 if (IS_ERR(req)) {
1937 retval = PTR_ERR(req);
1941 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1942 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1944 req->handler = zfcp_fsf_open_wka_port_handler;
1945 hton24(req->qtcb->bottom.support.d_id, wka_port->d_id);
1946 req->data = wka_port;
1948 req_id = req->req_id;
1950 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1951 retval = zfcp_fsf_req_send(req);
1953 zfcp_fsf_req_free(req);
1954 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
1962 static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
1964 struct zfcp_fc_wka_port *wka_port = req->data;
1966 if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) {
1967 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1983 struct zfcp_fsf_req *req;
1991 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
1995 if (IS_ERR(req)) {
1996 retval = PTR_ERR(req);
2000 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2001 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2003 req->handler = zfcp_fsf_close_wka_port_handler;
2004 req->data = wka_port;
2005 req->qtcb->header.port_handle = wka_port->handle;
2007 req_id = req->req_id;
2009 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
2010 retval = zfcp_fsf_req_send(req);
2012 zfcp_fsf_req_free(req);
2013 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
2021 static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
2023 struct zfcp_port *port = req->data;
2024 struct fsf_qtcb_header *header = &req->qtcb->header;
2027 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2033 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2046 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2052 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2077 struct zfcp_fsf_req *req;
2084 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT,
2088 if (IS_ERR(req)) {
2089 retval = PTR_ERR(req);
2093 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2094 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2096 req->data = erp_action->port;
2097 req->qtcb->header.port_handle = erp_action->port->handle;
2098 req->erp_action = erp_action;
2099 req->handler = zfcp_fsf_close_physical_port_handler;
2100 erp_action->fsf_req_id = req->req_id;
2102 zfcp_fsf_start_erp_timer(req);
2103 retval = zfcp_fsf_req_send(req);
2105 zfcp_fsf_req_free(req);
2108 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
2114 static void zfcp_fsf_open_lun_handler(struct zfcp_fsf_req *req)
2116 struct zfcp_adapter *adapter = req->adapter;
2117 struct scsi_device *sdev = req->data;
2119 struct fsf_qtcb_header *header = &req->qtcb->header;
2122 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2143 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2157 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2168 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2176 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2197 struct zfcp_fsf_req *req;
2204 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN,
2208 if (IS_ERR(req)) {
2209 retval = PTR_ERR(req);
2213 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2214 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2216 req->qtcb->header.port_handle = erp_action->port->handle;
2217 req->qtcb->bottom.support.fcp_lun = zfcp_scsi_dev_lun(erp_action->sdev);
2218 req->handler = zfcp_fsf_open_lun_handler;
2219 req->data = erp_action->sdev;
2220 req->erp_action = erp_action;
2221 erp_action->fsf_req_id = req->req_id;
2224 req->qtcb->bottom.support.option = FSF_OPEN_LUN_SUPPRESS_BOXING;
2226 zfcp_fsf_start_erp_timer(req);
2227 retval = zfcp_fsf_req_send(req);
2229 zfcp_fsf_req_free(req);
2232 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
2238 static void zfcp_fsf_close_lun_handler(struct zfcp_fsf_req *req)
2240 struct scsi_device *sdev = req->data;
2243 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2248 switch (req->qtcb->header.fsf_status) {
2251 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2255 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2262 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2265 switch (req->qtcb->header.fsf_status_qual.word[0]) {
2270 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2289 struct zfcp_fsf_req *req;
2296 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN,
2300 if (IS_ERR(req)) {
2301 retval = PTR_ERR(req);
2305 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2306 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2308 req->qtcb->header.port_handle = erp_action->port->handle;
2309 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
2310 req->handler = zfcp_fsf_close_lun_handler;
2311 req->data = erp_action->sdev;
2312 req->erp_action = erp_action;
2313 erp_action->fsf_req_id = req->req_id;
2315 zfcp_fsf_start_erp_timer(req);
2316 retval = zfcp_fsf_req_send(req);
2318 zfcp_fsf_req_free(req);
2321 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
2334 static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
2340 int ticks = req->adapter->timer_ticks;
2342 lat_in = &req->qtcb->prefix.prot_status_qual.latency_info;
2346 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2349 blktrc.outb_usage = req->qdio_req.qdio_outb_usage;
2351 if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA &&
2352 !(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
2358 switch (req->qtcb->bottom.io.data_direction) {
2388 * @req: Pointer to FSF request.
2391 static void zfcp_fsf_fcp_handler_common(struct zfcp_fsf_req *req,
2395 struct fsf_qtcb_header *header = &req->qtcb->header;
2397 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
2405 zfcp_erp_adapter_reopen(req->adapter, 0, "fssfch1");
2406 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2411 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2414 zfcp_fsf_class_not_supp(req);
2417 dev_err(&req->adapter->ccw_device->dev,
2420 req->qtcb->bottom.io.data_direction,
2423 zfcp_erp_adapter_shutdown(req->adapter, 0, "fssfch3");
2424 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2427 dev_err(&req->adapter->ccw_device->dev,
2429 req->qtcb->bottom.io.fcp_cmnd_length);
2430 zfcp_erp_adapter_shutdown(req->adapter, 0, "fssfch4");
2431 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2438 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2444 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2450 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2453 zfcp_fsf_log_security_error(&req->adapter->ccw_device->dev,
2457 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2462 static void zfcp_fsf_fcp_cmnd_handler(struct zfcp_fsf_req *req)
2468 read_lock_irqsave(&req->adapter->abort_lock, flags);
2470 scpnt = req->data;
2472 read_unlock_irqrestore(&req->adapter->abort_lock, flags);
2476 zfcp_fsf_fcp_handler_common(req, scpnt->device);
2478 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
2483 switch (req->qtcb->header.fsf_status) {
2499 fcp_rsp = &req->qtcb->bottom.io.fcp_rsp.iu;
2503 zfcp_fsf_req_trace(req, scpnt);
2504 zfcp_dbf_scsi_result(scpnt, req);
2514 read_unlock_irqrestore(&req->adapter->abort_lock, flags);
2561 struct zfcp_fsf_req *req;
2585 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
2588 if (IS_ERR(req)) {
2589 retval = PTR_ERR(req);
2593 BUILD_BUG_ON(sizeof(scsi_cmnd->host_scribble) < sizeof(req->req_id));
2594 scsi_cmnd->host_scribble = (unsigned char *) req->req_id;
2596 io = &req->qtcb->bottom.io;
2597 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2598 req->data = scsi_cmnd;
2599 req->handler = zfcp_fsf_fcp_cmnd_handler;
2600 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
2601 req->qtcb->header.port_handle = zfcp_sdev->port->handle;
2614 fcp_cmnd = &req->qtcb->bottom.io.fcp_cmnd.iu;
2619 zfcp_qdio_set_data_div(qdio, &req->qdio_req,
2621 retval = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
2629 retval = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
2634 zfcp_qdio_set_sbale_last(adapter->qdio, &req->qdio_req);
2636 zfcp_qdio_set_scount(qdio, &req->qdio_req);
2638 retval = zfcp_fsf_req_send(req);
2641 /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
2646 zfcp_fsf_req_free(req);
2653 static void zfcp_fsf_fcp_task_mgmt_handler(struct zfcp_fsf_req *req)
2655 struct scsi_device *sdev = req->data;
2659 zfcp_fsf_fcp_handler_common(req, sdev);
2661 fcp_rsp = &req->qtcb->bottom.io.fcp_rsp.iu;
2665 (req->status & ZFCP_STATUS_FSFREQ_ERROR))
2666 req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
2679 struct zfcp_fsf_req *req = NULL;
2692 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
2696 if (IS_ERR(req)) {
2697 req = NULL;
2701 req->data = sdev;
2703 req->handler = zfcp_fsf_fcp_task_mgmt_handler;
2704 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
2705 req->qtcb->header.port_handle = zfcp_sdev->port->handle;
2706 req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
2707 req->qtcb->bottom.io.service_class = FSF_CLASS_3;
2708 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
2710 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2712 fcp_cmnd = &req->qtcb->bottom.io.fcp_cmnd.iu;
2715 zfcp_fsf_start_timer(req, ZFCP_FSF_SCSI_ER_TIMEOUT);
2716 if (!zfcp_fsf_req_send(req)) {
2717 /* NOTE: DO NOT TOUCH req, UNTIL IT COMPLETES! */
2721 zfcp_fsf_req_free(req);
2722 req = NULL;
2725 return req;