aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_fsf.c
diff options
context:
space:
mode:
authorSwen Schillig <swen@vnet.ibm.com>2008-06-10 12:20:57 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-07-12 09:22:25 -0400
commit00bab91066a49468bfa4f6d5c8ad5e9ec53b7ea3 (patch)
treea5ce7bfe5ad290c339f669b3596b75f5238157c6 /drivers/s390/scsi/zfcp_fsf.c
parentfa04c2816883a49ec518514f6c19767d54be20b5 (diff)
[SCSI] zfcp: Cleanup qdio code
Cleanup the interface code from zfcp to qdio. Also move code that belongs to the qdio interface from the erp to the qdio file. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/s390/scsi/zfcp_fsf.c')
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c178
1 files changed, 67 insertions, 111 deletions
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index de42a01fc4b1..cc48a6462e6c 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -171,7 +171,6 @@ void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
171 171
172 BUG_ON(atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)); 172 BUG_ON(atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status));
173 spin_lock_irqsave(&adapter->req_list_lock, flags); 173 spin_lock_irqsave(&adapter->req_list_lock, flags);
174 atomic_set(&adapter->reqs_active, 0);
175 for (i = 0; i < REQUEST_LIST_SIZE; i++) 174 for (i = 0; i < REQUEST_LIST_SIZE; i++)
176 list_splice_init(&adapter->req_list[i], &remove_queue); 175 list_splice_init(&adapter->req_list[i], &remove_queue);
177 spin_unlock_irqrestore(&adapter->req_list_lock, flags); 176 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
@@ -726,7 +725,7 @@ zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags)
726 goto failed_req_create; 725 goto failed_req_create;
727 } 726 }
728 727
729 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 728 sbale = zfcp_qdio_sbale_req(fsf_req);
730 sbale[0].flags |= SBAL_FLAGS0_TYPE_STATUS; 729 sbale[0].flags |= SBAL_FLAGS0_TYPE_STATUS;
731 sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY; 730 sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
732 fsf_req->sbale_curr = 2; 731 fsf_req->sbale_curr = 2;
@@ -763,7 +762,7 @@ zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags)
763 failed_req_create: 762 failed_req_create:
764 zfcp_hba_dbf_event_fsf_unsol("fail", adapter, NULL); 763 zfcp_hba_dbf_event_fsf_unsol("fail", adapter, NULL);
765 out: 764 out:
766 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 765 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
767 return retval; 766 return retval;
768} 767}
769 768
@@ -1075,7 +1074,7 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
1075 &unit->status))) 1074 &unit->status)))
1076 goto unit_blocked; 1075 goto unit_blocked;
1077 1076
1078 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 1077 sbale = zfcp_qdio_sbale_req(fsf_req);
1079 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1078 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1080 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1079 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1081 1080
@@ -1098,7 +1097,7 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
1098 fsf_req = NULL; 1097 fsf_req = NULL;
1099 1098
1100 out: 1099 out:
1101 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 1100 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
1102 return fsf_req; 1101 return fsf_req;
1103} 1102}
1104 1103
@@ -1295,7 +1294,7 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1295 goto failed_req; 1294 goto failed_req;
1296 } 1295 }
1297 1296
1298 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 1297 sbale = zfcp_qdio_sbale_req(fsf_req);
1299 if (zfcp_use_one_sbal(ct->req, ct->req_count, 1298 if (zfcp_use_one_sbal(ct->req, ct->req_count,
1300 ct->resp, ct->resp_count)){ 1299 ct->resp, ct->resp_count)){
1301 /* both request buffer and response buffer 1300 /* both request buffer and response buffer
@@ -1311,7 +1310,7 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1311 /* try to use chained SBALs */ 1310 /* try to use chained SBALs */
1312 bytes = zfcp_qdio_sbals_from_sg(fsf_req, 1311 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
1313 SBAL_FLAGS0_TYPE_WRITE_READ, 1312 SBAL_FLAGS0_TYPE_WRITE_READ,
1314 ct->req, ct->req_count, 1313 ct->req,
1315 ZFCP_MAX_SBALS_PER_CT_REQ); 1314 ZFCP_MAX_SBALS_PER_CT_REQ);
1316 if (bytes <= 0) { 1315 if (bytes <= 0) {
1317 ZFCP_LOG_INFO("error: creation of CT request failed " 1316 ZFCP_LOG_INFO("error: creation of CT request failed "
@@ -1328,7 +1327,7 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1328 fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; 1327 fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
1329 bytes = zfcp_qdio_sbals_from_sg(fsf_req, 1328 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
1330 SBAL_FLAGS0_TYPE_WRITE_READ, 1329 SBAL_FLAGS0_TYPE_WRITE_READ,
1331 ct->resp, ct->resp_count, 1330 ct->resp,
1332 ZFCP_MAX_SBALS_PER_CT_REQ); 1331 ZFCP_MAX_SBALS_PER_CT_REQ);
1333 if (bytes <= 0) { 1332 if (bytes <= 0) {
1334 ZFCP_LOG_INFO("error: creation of CT request failed " 1333 ZFCP_LOG_INFO("error: creation of CT request failed "
@@ -1387,8 +1386,7 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1387 } 1386 }
1388 failed_req: 1387 failed_req:
1389 out: 1388 out:
1390 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 1389 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
1391 lock_flags);
1392 return ret; 1390 return ret;
1393} 1391}
1394 1392
@@ -1593,7 +1591,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1593 goto port_blocked; 1591 goto port_blocked;
1594 } 1592 }
1595 1593
1596 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 1594 sbale = zfcp_qdio_sbale_req(fsf_req);
1597 if (zfcp_use_one_sbal(els->req, els->req_count, 1595 if (zfcp_use_one_sbal(els->req, els->req_count,
1598 els->resp, els->resp_count)){ 1596 els->resp, els->resp_count)){
1599 /* both request buffer and response buffer 1597 /* both request buffer and response buffer
@@ -1609,7 +1607,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1609 /* try to use chained SBALs */ 1607 /* try to use chained SBALs */
1610 bytes = zfcp_qdio_sbals_from_sg(fsf_req, 1608 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
1611 SBAL_FLAGS0_TYPE_WRITE_READ, 1609 SBAL_FLAGS0_TYPE_WRITE_READ,
1612 els->req, els->req_count, 1610 els->req,
1613 ZFCP_MAX_SBALS_PER_ELS_REQ); 1611 ZFCP_MAX_SBALS_PER_ELS_REQ);
1614 if (bytes <= 0) { 1612 if (bytes <= 0) {
1615 ZFCP_LOG_INFO("error: creation of ELS request failed " 1613 ZFCP_LOG_INFO("error: creation of ELS request failed "
@@ -1626,7 +1624,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1626 fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; 1624 fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
1627 bytes = zfcp_qdio_sbals_from_sg(fsf_req, 1625 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
1628 SBAL_FLAGS0_TYPE_WRITE_READ, 1626 SBAL_FLAGS0_TYPE_WRITE_READ,
1629 els->resp, els->resp_count, 1627 els->resp,
1630 ZFCP_MAX_SBALS_PER_ELS_REQ); 1628 ZFCP_MAX_SBALS_PER_ELS_REQ);
1631 if (bytes <= 0) { 1629 if (bytes <= 0) {
1632 ZFCP_LOG_INFO("error: creation of ELS request failed " 1630 ZFCP_LOG_INFO("error: creation of ELS request failed "
@@ -1657,7 +1655,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1657 fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT; 1655 fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT;
1658 fsf_req->data = (unsigned long) els; 1656 fsf_req->data = (unsigned long) els;
1659 1657
1660 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 1658 sbale = zfcp_qdio_sbale_req(fsf_req);
1661 1659
1662 zfcp_san_dbf_event_els_request(fsf_req); 1660 zfcp_san_dbf_event_els_request(fsf_req);
1663 1661
@@ -1680,8 +1678,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1680 1678
1681 failed_req: 1679 failed_req:
1682 out: 1680 out:
1683 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 1681 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
1684 lock_flags);
1685 1682
1686 return ret; 1683 return ret;
1687} 1684}
@@ -1863,12 +1860,11 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1863 ZFCP_LOG_INFO("error: Could not create exchange configuration " 1860 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1864 "data request for adapter %s.\n", 1861 "data request for adapter %s.\n",
1865 zfcp_get_busid_by_adapter(adapter)); 1862 zfcp_get_busid_by_adapter(adapter));
1866 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 1863 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
1867 lock_flags);
1868 return retval; 1864 return retval;
1869 } 1865 }
1870 1866
1871 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 1867 sbale = zfcp_qdio_sbale_req(fsf_req);
1872 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1868 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1873 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1869 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1874 1870
@@ -1882,8 +1878,7 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1882 1878
1883 zfcp_erp_start_timer(fsf_req); 1879 zfcp_erp_start_timer(fsf_req);
1884 retval = zfcp_fsf_req_send(fsf_req); 1880 retval = zfcp_fsf_req_send(fsf_req);
1885 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 1881 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
1886 lock_flags);
1887 if (retval) { 1882 if (retval) {
1888 ZFCP_LOG_INFO("error: Could not send exchange configuration " 1883 ZFCP_LOG_INFO("error: Could not send exchange configuration "
1889 "data command on the adapter %s\n", 1884 "data command on the adapter %s\n",
@@ -1916,12 +1911,11 @@ zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
1916 ZFCP_LOG_INFO("error: Could not create exchange configuration " 1911 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1917 "data request for adapter %s.\n", 1912 "data request for adapter %s.\n",
1918 zfcp_get_busid_by_adapter(adapter)); 1913 zfcp_get_busid_by_adapter(adapter));
1919 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 1914 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
1920 lock_flags);
1921 return retval; 1915 return retval;
1922 } 1916 }
1923 1917
1924 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 1918 sbale = zfcp_qdio_sbale_req(fsf_req);
1925 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1919 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1926 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1920 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1927 1921
@@ -1936,8 +1930,7 @@ zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
1936 1930
1937 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT); 1931 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
1938 retval = zfcp_fsf_req_send(fsf_req); 1932 retval = zfcp_fsf_req_send(fsf_req);
1939 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 1933 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
1940 lock_flags);
1941 if (retval) 1934 if (retval)
1942 ZFCP_LOG_INFO("error: Could not send exchange configuration " 1935 ZFCP_LOG_INFO("error: Could not send exchange configuration "
1943 "data command on the adapter %s\n", 1936 "data command on the adapter %s\n",
@@ -2178,12 +2171,11 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
2178 "exchange port data request for " 2171 "exchange port data request for "
2179 "the adapter %s.\n", 2172 "the adapter %s.\n",
2180 zfcp_get_busid_by_adapter(adapter)); 2173 zfcp_get_busid_by_adapter(adapter));
2181 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2174 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
2182 lock_flags);
2183 return retval; 2175 return retval;
2184 } 2176 }
2185 2177
2186 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 2178 sbale = zfcp_qdio_sbale_req(fsf_req);
2187 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2179 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2188 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2180 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2189 2181
@@ -2192,7 +2184,7 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
2192 zfcp_erp_start_timer(fsf_req); 2184 zfcp_erp_start_timer(fsf_req);
2193 2185
2194 retval = zfcp_fsf_req_send(fsf_req); 2186 retval = zfcp_fsf_req_send(fsf_req);
2195 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 2187 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
2196 2188
2197 if (retval) { 2189 if (retval) {
2198 ZFCP_LOG_INFO("error: Could not send an exchange port data " 2190 ZFCP_LOG_INFO("error: Could not send an exchange port data "
@@ -2237,21 +2229,20 @@ zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter,
2237 "exchange port data request for " 2229 "exchange port data request for "
2238 "the adapter %s.\n", 2230 "the adapter %s.\n",
2239 zfcp_get_busid_by_adapter(adapter)); 2231 zfcp_get_busid_by_adapter(adapter));
2240 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2232 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
2241 lock_flags);
2242 return retval; 2233 return retval;
2243 } 2234 }
2244 2235
2245 if (data) 2236 if (data)
2246 fsf_req->data = (unsigned long) data; 2237 fsf_req->data = (unsigned long) data;
2247 2238
2248 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 2239 sbale = zfcp_qdio_sbale_req(fsf_req);
2249 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2240 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2250 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2241 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2251 2242
2252 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT); 2243 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
2253 retval = zfcp_fsf_req_send(fsf_req); 2244 retval = zfcp_fsf_req_send(fsf_req);
2254 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 2245 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
2255 2246
2256 if (retval) 2247 if (retval)
2257 ZFCP_LOG_INFO("error: Could not send an exchange port data " 2248 ZFCP_LOG_INFO("error: Could not send an exchange port data "
@@ -2355,7 +2346,7 @@ zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
2355 goto out; 2346 goto out;
2356 } 2347 }
2357 2348
2358 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 2349 sbale = zfcp_qdio_sbale_req(fsf_req);
2359 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2350 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2360 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2351 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2361 2352
@@ -2382,8 +2373,7 @@ zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
2382 zfcp_get_busid_by_adapter(erp_action->adapter), 2373 zfcp_get_busid_by_adapter(erp_action->adapter),
2383 erp_action->port->wwpn); 2374 erp_action->port->wwpn);
2384 out: 2375 out:
2385 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, 2376 write_unlock_irqrestore(&erp_action->adapter->req_q.lock, lock_flags);
2386 lock_flags);
2387 return retval; 2377 return retval;
2388} 2378}
2389 2379
@@ -2587,7 +2577,7 @@ zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
2587 goto out; 2577 goto out;
2588 } 2578 }
2589 2579
2590 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 2580 sbale = zfcp_qdio_sbale_req(fsf_req);
2591 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2581 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2592 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2582 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2593 2583
@@ -2615,8 +2605,7 @@ zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
2615 zfcp_get_busid_by_adapter(erp_action->adapter), 2605 zfcp_get_busid_by_adapter(erp_action->adapter),
2616 erp_action->port->wwpn); 2606 erp_action->port->wwpn);
2617 out: 2607 out:
2618 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, 2608 write_unlock_irqrestore(&erp_action->adapter->req_q.lock, lock_flags);
2619 lock_flags);
2620 return retval; 2609 return retval;
2621} 2610}
2622 2611
@@ -2716,7 +2705,7 @@ zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
2716 goto out; 2705 goto out;
2717 } 2706 }
2718 2707
2719 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 2708 sbale = zfcp_qdio_sbale_req(fsf_req);
2720 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2709 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2721 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2710 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2722 2711
@@ -2746,8 +2735,7 @@ zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
2746 zfcp_get_busid_by_adapter(erp_action->adapter), 2735 zfcp_get_busid_by_adapter(erp_action->adapter),
2747 erp_action->port->wwpn); 2736 erp_action->port->wwpn);
2748 out: 2737 out:
2749 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, 2738 write_unlock_irqrestore(&erp_action->adapter->req_q.lock, lock_flags);
2750 lock_flags);
2751 return retval; 2739 return retval;
2752} 2740}
2753 2741
@@ -2911,7 +2899,7 @@ zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
2911 goto out; 2899 goto out;
2912 } 2900 }
2913 2901
2914 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 2902 sbale = zfcp_qdio_sbale_req(fsf_req);
2915 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2903 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2916 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2904 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2917 2905
@@ -2944,8 +2932,7 @@ zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
2944 zfcp_get_busid_by_adapter(erp_action->adapter), 2932 zfcp_get_busid_by_adapter(erp_action->adapter),
2945 erp_action->port->wwpn, erp_action->unit->fcp_lun); 2933 erp_action->port->wwpn, erp_action->unit->fcp_lun);
2946 out: 2934 out:
2947 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, 2935 write_unlock_irqrestore(&erp_action->adapter->req_q.lock, lock_flags);
2948 lock_flags);
2949 return retval; 2936 return retval;
2950} 2937}
2951 2938
@@ -3226,7 +3213,7 @@ zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
3226 goto out; 3213 goto out;
3227 } 3214 }
3228 3215
3229 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 3216 sbale = zfcp_qdio_sbale_req(fsf_req);
3230 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 3217 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
3231 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 3218 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
3232 3219
@@ -3255,8 +3242,7 @@ zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
3255 zfcp_get_busid_by_adapter(erp_action->adapter), 3242 zfcp_get_busid_by_adapter(erp_action->adapter),
3256 erp_action->port->wwpn, erp_action->unit->fcp_lun); 3243 erp_action->port->wwpn, erp_action->unit->fcp_lun);
3257 out: 3244 out:
3258 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, 3245 write_unlock_irqrestore(&erp_action->adapter->req_q.lock, lock_flags);
3259 lock_flags);
3260 return retval; 3246 return retval;
3261} 3247}
3262 3248
@@ -3498,7 +3484,9 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
3498 fcp_cmnd_iu->add_fcp_cdb_length + sizeof (fcp_dl_t); 3484 fcp_cmnd_iu->add_fcp_cdb_length + sizeof (fcp_dl_t);
3499 3485
3500 /* generate SBALEs from data buffer */ 3486 /* generate SBALEs from data buffer */
3501 real_bytes = zfcp_qdio_sbals_from_scsicmnd(fsf_req, sbtype, scsi_cmnd); 3487 real_bytes = zfcp_qdio_sbals_from_sg(fsf_req, sbtype,
3488 scsi_sglist(scsi_cmnd),
3489 ZFCP_MAX_SBALS_PER_REQ);
3502 if (unlikely(real_bytes < 0)) { 3490 if (unlikely(real_bytes < 0)) {
3503 if (fsf_req->sbal_number < ZFCP_MAX_SBALS_PER_REQ) { 3491 if (fsf_req->sbal_number < ZFCP_MAX_SBALS_PER_REQ) {
3504 ZFCP_LOG_DEBUG( 3492 ZFCP_LOG_DEBUG(
@@ -3556,7 +3544,7 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
3556 scsi_cmnd->host_scribble = NULL; 3544 scsi_cmnd->host_scribble = NULL;
3557 success: 3545 success:
3558 failed_req_create: 3546 failed_req_create:
3559 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 3547 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
3560 return retval; 3548 return retval;
3561} 3549}
3562 3550
@@ -3609,7 +3597,7 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
3609 fsf_req->qtcb->bottom.io.fcp_cmnd_length = 3597 fsf_req->qtcb->bottom.io.fcp_cmnd_length =
3610 sizeof (struct fcp_cmnd_iu) + sizeof (fcp_dl_t); 3598 sizeof (struct fcp_cmnd_iu) + sizeof (fcp_dl_t);
3611 3599
3612 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 3600 sbale = zfcp_qdio_sbale_req(fsf_req);
3613 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE; 3601 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
3614 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 3602 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
3615 3603
@@ -3629,7 +3617,7 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
3629 fsf_req = NULL; 3617 fsf_req = NULL;
3630 3618
3631 out: 3619 out:
3632 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 3620 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
3633 return fsf_req; 3621 return fsf_req;
3634} 3622}
3635 3623
@@ -4216,7 +4204,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4216 goto unlock_queue_lock; 4204 goto unlock_queue_lock;
4217 } 4205 }
4218 4206
4219 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 4207 sbale = zfcp_qdio_sbale_req(fsf_req);
4220 sbale[0].flags |= direction; 4208 sbale[0].flags |= direction;
4221 4209
4222 bottom = &fsf_req->qtcb->bottom.support; 4210 bottom = &fsf_req->qtcb->bottom.support;
@@ -4224,7 +4212,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4224 bottom->option = fsf_cfdc->option; 4212 bottom->option = fsf_cfdc->option;
4225 4213
4226 bytes = zfcp_qdio_sbals_from_sg(fsf_req, direction, 4214 bytes = zfcp_qdio_sbals_from_sg(fsf_req, direction,
4227 fsf_cfdc->sg, ZFCP_CFDC_PAGES, 4215 fsf_cfdc->sg,
4228 ZFCP_MAX_SBALS_PER_REQ); 4216 ZFCP_MAX_SBALS_PER_REQ);
4229 if (bytes != ZFCP_CFDC_MAX_SIZE) { 4217 if (bytes != ZFCP_CFDC_MAX_SIZE) {
4230 retval = -ENOMEM; 4218 retval = -ENOMEM;
@@ -4237,7 +4225,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4237 retval = -EPERM; 4225 retval = -EPERM;
4238 goto free_fsf_req; 4226 goto free_fsf_req;
4239 } 4227 }
4240 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 4228 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
4241 4229
4242 wait_event(fsf_req->completion_wq, 4230 wait_event(fsf_req->completion_wq,
4243 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 4231 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
@@ -4247,7 +4235,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4247 free_fsf_req: 4235 free_fsf_req:
4248 zfcp_fsf_req_free(fsf_req); 4236 zfcp_fsf_req_free(fsf_req);
4249 unlock_queue_lock: 4237 unlock_queue_lock:
4250 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 4238 write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
4251 return ERR_PTR(retval); 4239 return ERR_PTR(retval);
4252} 4240}
4253 4241
@@ -4261,10 +4249,10 @@ static inline int
4261zfcp_fsf_req_sbal_check(unsigned long *flags, 4249zfcp_fsf_req_sbal_check(unsigned long *flags,
4262 struct zfcp_qdio_queue *queue, int needed) 4250 struct zfcp_qdio_queue *queue, int needed)
4263{ 4251{
4264 write_lock_irqsave(&queue->queue_lock, *flags); 4252 write_lock_irqsave(&queue->lock, *flags);
4265 if (likely(atomic_read(&queue->free_count) >= needed)) 4253 if (likely(atomic_read(&queue->count) >= needed))
4266 return 1; 4254 return 1;
4267 write_unlock_irqrestore(&queue->queue_lock, *flags); 4255 write_unlock_irqrestore(&queue->lock, *flags);
4268 return 0; 4256 return 0;
4269} 4257}
4270 4258
@@ -4293,24 +4281,24 @@ zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req *fsf_req)
4293 * @req_flags: flags indicating whether to wait for needed SBAL or not 4281 * @req_flags: flags indicating whether to wait for needed SBAL or not
4294 * @lock_flags: lock_flags if queue_lock is taken 4282 * @lock_flags: lock_flags if queue_lock is taken
4295 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS 4283 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
4296 * Locks: lock adapter->request_queue->queue_lock on success 4284 * Locks: lock adapter->req_q->lock on success
4297 */ 4285 */
4298static int 4286static int
4299zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter, int req_flags, 4287zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter, int req_flags,
4300 unsigned long *lock_flags) 4288 unsigned long *lock_flags)
4301{ 4289{
4302 long ret; 4290 long ret;
4303 struct zfcp_qdio_queue *req_queue = &adapter->request_queue; 4291 struct zfcp_qdio_queue *req_q = &adapter->req_q;
4304 4292
4305 if (unlikely(req_flags & ZFCP_WAIT_FOR_SBAL)) { 4293 if (unlikely(req_flags & ZFCP_WAIT_FOR_SBAL)) {
4306 ret = wait_event_interruptible_timeout(adapter->request_wq, 4294 ret = wait_event_interruptible_timeout(adapter->request_wq,
4307 zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1), 4295 zfcp_fsf_req_sbal_check(lock_flags, req_q, 1),
4308 ZFCP_SBAL_TIMEOUT); 4296 ZFCP_SBAL_TIMEOUT);
4309 if (ret < 0) 4297 if (ret < 0)
4310 return ret; 4298 return ret;
4311 if (!ret) 4299 if (!ret)
4312 return -EIO; 4300 return -EIO;
4313 } else if (!zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1)) 4301 } else if (!zfcp_fsf_req_sbal_check(lock_flags, req_q, 1))
4314 return -EIO; 4302 return -EIO;
4315 4303
4316 return 0; 4304 return 0;
@@ -4340,7 +4328,7 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4340 volatile struct qdio_buffer_element *sbale; 4328 volatile struct qdio_buffer_element *sbale;
4341 struct zfcp_fsf_req *fsf_req = NULL; 4329 struct zfcp_fsf_req *fsf_req = NULL;
4342 int ret = 0; 4330 int ret = 0;
4343 struct zfcp_qdio_queue *req_queue = &adapter->request_queue; 4331 struct zfcp_qdio_queue *req_q = &adapter->req_q;
4344 4332
4345 /* allocate new FSF request */ 4333 /* allocate new FSF request */
4346 fsf_req = zfcp_fsf_req_alloc(pool, req_flags); 4334 fsf_req = zfcp_fsf_req_alloc(pool, req_flags);
@@ -4377,7 +4365,7 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4377 */ 4365 */
4378 4366
4379 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) { 4367 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
4380 write_unlock_irqrestore(&req_queue->queue_lock, *lock_flags); 4368 write_unlock_irqrestore(&req_q->lock, *lock_flags);
4381 ret = -EIO; 4369 ret = -EIO;
4382 goto failed_sbals; 4370 goto failed_sbals;
4383 } 4371 }
@@ -4387,15 +4375,15 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4387 fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no; 4375 fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
4388 } 4376 }
4389 fsf_req->sbal_number = 1; 4377 fsf_req->sbal_number = 1;
4390 fsf_req->sbal_first = req_queue->free_index; 4378 fsf_req->sbal_first = req_q->first;
4391 fsf_req->sbal_last = req_queue->free_index; 4379 fsf_req->sbal_last = req_q->first;
4392 fsf_req->sbale_curr = 1; 4380 fsf_req->sbale_curr = 1;
4393 4381
4394 if (likely(req_flags & ZFCP_REQ_AUTO_CLEANUP)) { 4382 if (likely(req_flags & ZFCP_REQ_AUTO_CLEANUP)) {
4395 fsf_req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 4383 fsf_req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
4396 } 4384 }
4397 4385
4398 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_last, 0); 4386 sbale = zfcp_qdio_sbale_req(fsf_req);
4399 4387
4400 /* setup common SBALE fields */ 4388 /* setup common SBALE fields */
4401 sbale[0].addr = (void *) fsf_req->req_id; 4389 sbale[0].addr = (void *) fsf_req->req_id;
@@ -4416,7 +4404,7 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4416 fsf_req = NULL; 4404 fsf_req = NULL;
4417 4405
4418 failed_fsf_req: 4406 failed_fsf_req:
4419 write_lock_irqsave(&req_queue->queue_lock, *lock_flags); 4407 write_lock_irqsave(&req_q->lock, *lock_flags);
4420 success: 4408 success:
4421 *fsf_req_p = fsf_req; 4409 *fsf_req_p = fsf_req;
4422 return ret; 4410 return ret;
@@ -4433,18 +4421,17 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4433static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req) 4421static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req)
4434{ 4422{
4435 struct zfcp_adapter *adapter; 4423 struct zfcp_adapter *adapter;
4436 struct zfcp_qdio_queue *req_queue; 4424 struct zfcp_qdio_queue *req_q;
4437 volatile struct qdio_buffer_element *sbale; 4425 volatile struct qdio_buffer_element *sbale;
4438 int inc_seq_no; 4426 int inc_seq_no;
4439 int new_distance_from_int;
4440 int retval = 0; 4427 int retval = 0;
4441 4428
4442 adapter = fsf_req->adapter; 4429 adapter = fsf_req->adapter;
4443 req_queue = &adapter->request_queue, 4430 req_q = &adapter->req_q;
4444 4431
4445 4432
4446 /* FIXME(debug): remove it later */ 4433 /* FIXME(debug): remove it later */
4447 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_first, 0); 4434 sbale = zfcp_qdio_sbale_req(fsf_req);
4448 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale[0].flags); 4435 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale[0].flags);
4449 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n"); 4436 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
4450 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, (char *) sbale[1].addr, 4437 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, (char *) sbale[1].addr,
@@ -4457,52 +4444,24 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req)
4457 4444
4458 inc_seq_no = (fsf_req->qtcb != NULL); 4445 inc_seq_no = (fsf_req->qtcb != NULL);
4459 4446
4460 ZFCP_LOG_TRACE("request queue of adapter %s: "
4461 "next free SBAL is %i, %i free SBALs\n",
4462 zfcp_get_busid_by_adapter(adapter),
4463 req_queue->free_index,
4464 atomic_read(&req_queue->free_count));
4465
4466 ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
4467 "index_in_queue=%i, count=%i, buffers=%p\n",
4468 zfcp_get_busid_by_adapter(adapter),
4469 QDIO_FLAG_SYNC_OUTPUT,
4470 0, fsf_req->sbal_first, fsf_req->sbal_number,
4471 &req_queue->buffer[fsf_req->sbal_first]);
4472
4473 /*
4474 * adjust the number of free SBALs in request queue as well as
4475 * position of first one
4476 */
4477 atomic_sub(fsf_req->sbal_number, &req_queue->free_count);
4478 ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue->free_count));
4479 req_queue->free_index += fsf_req->sbal_number; /* increase */
4480 req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap if needed */
4481 new_distance_from_int = zfcp_qdio_determine_pci(req_queue, fsf_req);
4482
4483 fsf_req->issued = get_clock(); 4447 fsf_req->issued = get_clock();
4484 4448
4485 retval = do_QDIO(adapter->ccw_device, 4449 retval = zfcp_qdio_send(fsf_req);
4486 QDIO_FLAG_SYNC_OUTPUT,
4487 0, fsf_req->sbal_first, fsf_req->sbal_number, NULL);
4488 4450
4489 if (unlikely(retval)) { 4451 if (unlikely(retval)) {
4490 /* Queues are down..... */ 4452 /* Queues are down..... */
4491 retval = -EIO;
4492 del_timer(&fsf_req->timer); 4453 del_timer(&fsf_req->timer);
4493 spin_lock(&adapter->req_list_lock); 4454 spin_lock(&adapter->req_list_lock);
4494 zfcp_reqlist_remove(adapter, fsf_req); 4455 zfcp_reqlist_remove(adapter, fsf_req);
4495 spin_unlock(&adapter->req_list_lock); 4456 spin_unlock(&adapter->req_list_lock);
4496 /* undo changes in request queue made for this request */ 4457 /* undo changes in request queue made for this request */
4497 zfcp_qdio_zero_sbals(req_queue->buffer, 4458 atomic_add(fsf_req->sbal_number, &req_q->count);
4498 fsf_req->sbal_first, fsf_req->sbal_number); 4459 req_q->first -= fsf_req->sbal_number;
4499 atomic_add(fsf_req->sbal_number, &req_queue->free_count); 4460 req_q->first += QDIO_MAX_BUFFERS_PER_Q;
4500 req_queue->free_index -= fsf_req->sbal_number; 4461 req_q->first %= QDIO_MAX_BUFFERS_PER_Q;
4501 req_queue->free_index += QDIO_MAX_BUFFERS_PER_Q;
4502 req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap */
4503 zfcp_erp_adapter_reopen(adapter, 0, 116, fsf_req); 4462 zfcp_erp_adapter_reopen(adapter, 0, 116, fsf_req);
4463 retval = -EIO;
4504 } else { 4464 } else {
4505 req_queue->distance_from_int = new_distance_from_int;
4506 /* 4465 /*
4507 * increase FSF sequence counter - 4466 * increase FSF sequence counter -
4508 * this must only be done for request successfully enqueued to 4467 * this must only be done for request successfully enqueued to
@@ -4514,9 +4473,6 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req)
4514 /* Don't increase for unsolicited status */ 4473 /* Don't increase for unsolicited status */
4515 if (inc_seq_no) 4474 if (inc_seq_no)
4516 adapter->fsf_req_seq_no++; 4475 adapter->fsf_req_seq_no++;
4517
4518 /* count FSF requests pending */
4519 atomic_inc(&adapter->reqs_active);
4520 } 4476 }
4521 return retval; 4477 return retval;
4522} 4478}