aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2010-04-30 12:09:34 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-05-02 15:42:30 -0400
commit1674b4054744c2cfd6573e43eca45d86ff581d0e (patch)
tree6a59f4f00b15b30313c330e9636b36c88c93a1c9 /drivers
parent683229845f1780b10041ee7a1043fc8f10061455 (diff)
[SCSI] zfcp: Move sbale handling to zfcp_qdio files
Move the code accessing the qdio sbales and zfcp_qdio_req struct to the zfcp_qdio files and provide helper functions for accessing the qdio related parts. Reviewed-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/s390/scsi/zfcp_def.h17
-rw-r--r--drivers/s390/scsi/zfcp_ext.h5
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c180
-rw-r--r--drivers/s390/scsi/zfcp_fsf.h9
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c25
-rw-r--r--drivers/s390/scsi/zfcp_qdio.h102
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c4
7 files changed, 191 insertions, 151 deletions
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 72132c13f45b..0b2ae60a6f9f 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -44,23 +44,6 @@ struct zfcp_reqlist;
44/********************* SCSI SPECIFIC DEFINES *********************************/ 44/********************* SCSI SPECIFIC DEFINES *********************************/
45#define ZFCP_SCSI_ER_TIMEOUT (10*HZ) 45#define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
46 46
47/********************* CIO/QDIO SPECIFIC DEFINES *****************************/
48
49/* DMQ bug workaround: don't use last SBALE */
50#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
51
52/* index of last SBALE (with respect to DMQ bug workaround) */
53#define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
54
55/* max. number of (data buffer) SBALEs in largest SBAL chain */
56#define ZFCP_MAX_SBALES_PER_REQ \
57 (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
58 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
59
60#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
61 /* max. number of (data buffer) SBALEs in largest SBAL chain
62 multiplied with number of sectors per 4k block */
63
64/********************* FSF SPECIFIC DEFINES *********************************/ 47/********************* FSF SPECIFIC DEFINES *********************************/
65 48
66/* ATTENTION: value must not be used by hardware */ 49/* ATTENTION: value must not be used by hardware */
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index 8786a79c7f8f..172da12a2d02 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * External function declarations. 4 * External function declarations.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2009 6 * Copyright IBM Corporation 2002, 2010
7 */ 7 */
8 8
9#ifndef ZFCP_EXT_H 9#ifndef ZFCP_EXT_H
@@ -144,8 +144,7 @@ extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int);
144extern int zfcp_qdio_setup(struct zfcp_adapter *); 144extern int zfcp_qdio_setup(struct zfcp_adapter *);
145extern void zfcp_qdio_destroy(struct zfcp_qdio *); 145extern void zfcp_qdio_destroy(struct zfcp_qdio *);
146extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_qdio_req *); 146extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_qdio_req *);
147extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, 147extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, struct zfcp_qdio_req *,
148 struct zfcp_qdio_req *, unsigned long,
149 struct scatterlist *, int); 148 struct scatterlist *, int);
150extern int zfcp_qdio_open(struct zfcp_qdio *); 149extern int zfcp_qdio_open(struct zfcp_qdio *);
151extern void zfcp_qdio_close(struct zfcp_qdio *); 150extern void zfcp_qdio_close(struct zfcp_qdio *);
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 18564891ea61..ec1b49a75532 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -705,10 +705,9 @@ static struct fsf_qtcb *zfcp_qtcb_alloc(mempool_t *pool)
705} 705}
706 706
707static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio, 707static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
708 u32 fsf_cmd, mempool_t *pool) 708 u32 fsf_cmd, u32 sbtype,
709 mempool_t *pool)
709{ 710{
710 struct qdio_buffer_element *sbale;
711 struct zfcp_qdio_queue *req_q = &qdio->req_q;
712 struct zfcp_adapter *adapter = qdio->adapter; 711 struct zfcp_adapter *adapter = qdio->adapter;
713 struct zfcp_fsf_req *req = zfcp_fsf_alloc(pool); 712 struct zfcp_fsf_req *req = zfcp_fsf_alloc(pool);
714 713
@@ -725,14 +724,6 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
725 req->adapter = adapter; 724 req->adapter = adapter;
726 req->fsf_command = fsf_cmd; 725 req->fsf_command = fsf_cmd;
727 req->req_id = adapter->req_no; 726 req->req_id = adapter->req_no;
728 req->qdio_req.sbal_number = 1;
729 req->qdio_req.sbal_first = req_q->first;
730 req->qdio_req.sbal_last = req_q->first;
731 req->qdio_req.sbale_curr = 1;
732
733 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
734 sbale[0].addr = (void *) req->req_id;
735 sbale[0].flags |= SBAL_FLAGS0_COMMAND;
736 727
737 if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) { 728 if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) {
738 if (likely(pool)) 729 if (likely(pool))
@@ -753,10 +744,11 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
753 req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION; 744 req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION;
754 req->qtcb->header.req_handle = req->req_id; 745 req->qtcb->header.req_handle = req->req_id;
755 req->qtcb->header.fsf_command = req->fsf_command; 746 req->qtcb->header.fsf_command = req->fsf_command;
756 sbale[1].addr = (void *) req->qtcb;
757 sbale[1].length = sizeof(struct fsf_qtcb);
758 } 747 }
759 748
749 zfcp_qdio_req_init(adapter->qdio, &req->qdio_req, req->req_id, sbtype,
750 req->qtcb, sizeof(struct fsf_qtcb));
751
760 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) { 752 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) {
761 zfcp_fsf_req_free(req); 753 zfcp_fsf_req_free(req);
762 return ERR_PTR(-EIO); 754 return ERR_PTR(-EIO);
@@ -803,24 +795,19 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
803 struct zfcp_adapter *adapter = qdio->adapter; 795 struct zfcp_adapter *adapter = qdio->adapter;
804 struct zfcp_fsf_req *req; 796 struct zfcp_fsf_req *req;
805 struct fsf_status_read_buffer *sr_buf; 797 struct fsf_status_read_buffer *sr_buf;
806 struct qdio_buffer_element *sbale;
807 int retval = -EIO; 798 int retval = -EIO;
808 799
809 spin_lock_bh(&qdio->req_q_lock); 800 spin_lock_bh(&qdio->req_q_lock);
810 if (zfcp_fsf_req_sbal_get(qdio)) 801 if (zfcp_fsf_req_sbal_get(qdio))
811 goto out; 802 goto out;
812 803
813 req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS, 804 req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS, 0,
814 adapter->pool.status_read_req); 805 adapter->pool.status_read_req);
815 if (IS_ERR(req)) { 806 if (IS_ERR(req)) {
816 retval = PTR_ERR(req); 807 retval = PTR_ERR(req);
817 goto out; 808 goto out;
818 } 809 }
819 810
820 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
821 sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
822 req->qdio_req.sbale_curr = 2;
823
824 sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC); 811 sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC);
825 if (!sr_buf) { 812 if (!sr_buf) {
826 retval = -ENOMEM; 813 retval = -ENOMEM;
@@ -828,9 +815,9 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
828 } 815 }
829 memset(sr_buf, 0, sizeof(*sr_buf)); 816 memset(sr_buf, 0, sizeof(*sr_buf));
830 req->data = sr_buf; 817 req->data = sr_buf;
831 sbale = zfcp_qdio_sbale_curr(qdio, &req->qdio_req); 818
832 sbale->addr = (void *) sr_buf; 819 zfcp_qdio_fill_next(qdio, &req->qdio_req, sr_buf, sizeof(*sr_buf));
833 sbale->length = sizeof(*sr_buf); 820 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
834 821
835 retval = zfcp_fsf_req_send(req); 822 retval = zfcp_fsf_req_send(req);
836 if (retval) 823 if (retval)
@@ -907,7 +894,6 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
907struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, 894struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
908 struct zfcp_unit *unit) 895 struct zfcp_unit *unit)
909{ 896{
910 struct qdio_buffer_element *sbale;
911 struct zfcp_fsf_req *req = NULL; 897 struct zfcp_fsf_req *req = NULL;
912 struct zfcp_qdio *qdio = unit->port->adapter->qdio; 898 struct zfcp_qdio *qdio = unit->port->adapter->qdio;
913 899
@@ -915,6 +901,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
915 if (zfcp_fsf_req_sbal_get(qdio)) 901 if (zfcp_fsf_req_sbal_get(qdio))
916 goto out; 902 goto out;
917 req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND, 903 req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND,
904 SBAL_FLAGS0_TYPE_READ,
918 qdio->adapter->pool.scsi_abort); 905 qdio->adapter->pool.scsi_abort);
919 if (IS_ERR(req)) { 906 if (IS_ERR(req)) {
920 req = NULL; 907 req = NULL;
@@ -925,9 +912,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
925 ZFCP_STATUS_COMMON_UNBLOCKED))) 912 ZFCP_STATUS_COMMON_UNBLOCKED)))
926 goto out_error_free; 913 goto out_error_free;
927 914
928 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 915 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
929 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
930 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
931 916
932 req->data = unit; 917 req->data = unit;
933 req->handler = zfcp_fsf_abort_fcp_command_handler; 918 req->handler = zfcp_fsf_abort_fcp_command_handler;
@@ -996,21 +981,14 @@ skip_fsfstatus:
996 ct->handler(ct->handler_data); 981 ct->handler(ct->handler_data);
997} 982}
998 983
999static void zfcp_fsf_setup_ct_els_unchained(struct qdio_buffer_element *sbale, 984static void zfcp_fsf_setup_ct_els_unchained(struct zfcp_qdio *qdio,
985 struct zfcp_qdio_req *q_req,
1000 struct scatterlist *sg_req, 986 struct scatterlist *sg_req,
1001 struct scatterlist *sg_resp) 987 struct scatterlist *sg_resp)
1002{ 988{
1003 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ; 989 zfcp_qdio_fill_next(qdio, q_req, sg_virt(sg_req), sg_req->length);
1004 sbale[2].addr = sg_virt(sg_req); 990 zfcp_qdio_fill_next(qdio, q_req, sg_virt(sg_resp), sg_resp->length);
1005 sbale[2].length = sg_req->length; 991 zfcp_qdio_set_sbale_last(qdio, q_req);
1006 sbale[3].addr = sg_virt(sg_resp);
1007 sbale[3].length = sg_resp->length;
1008 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
1009}
1010
1011static int zfcp_fsf_one_sbal(struct scatterlist *sg)
1012{
1013 return sg_is_last(sg) && sg->length <= PAGE_SIZE;
1014} 992}
1015 993
1016static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, 994static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
@@ -1019,35 +997,34 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
1019 int max_sbals) 997 int max_sbals)
1020{ 998{
1021 struct zfcp_adapter *adapter = req->adapter; 999 struct zfcp_adapter *adapter = req->adapter;
1022 struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(adapter->qdio,
1023 &req->qdio_req);
1024 u32 feat = adapter->adapter_features; 1000 u32 feat = adapter->adapter_features;
1025 int bytes; 1001 int bytes;
1026 1002
1027 if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) { 1003 if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) {
1028 if (!zfcp_fsf_one_sbal(sg_req) || !zfcp_fsf_one_sbal(sg_resp)) 1004 if (!zfcp_qdio_sg_one_sbale(sg_req) ||
1005 !zfcp_qdio_sg_one_sbale(sg_resp))
1029 return -EOPNOTSUPP; 1006 return -EOPNOTSUPP;
1030 1007
1031 zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp); 1008 zfcp_fsf_setup_ct_els_unchained(adapter->qdio, &req->qdio_req,
1009 sg_req, sg_resp);
1032 return 0; 1010 return 0;
1033 } 1011 }
1034 1012
1035 /* use single, unchained SBAL if it can hold the request */ 1013 /* use single, unchained SBAL if it can hold the request */
1036 if (zfcp_fsf_one_sbal(sg_req) && zfcp_fsf_one_sbal(sg_resp)) { 1014 if (zfcp_qdio_sg_one_sbale(sg_req) || zfcp_qdio_sg_one_sbale(sg_resp)) {
1037 zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp); 1015 zfcp_fsf_setup_ct_els_unchained(adapter->qdio, &req->qdio_req,
1016 sg_req, sg_resp);
1038 return 0; 1017 return 0;
1039 } 1018 }
1040 1019
1041 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, 1020 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req,
1042 SBAL_FLAGS0_TYPE_WRITE_READ,
1043 sg_req, max_sbals); 1021 sg_req, max_sbals);
1044 if (bytes <= 0) 1022 if (bytes <= 0)
1045 return -EIO; 1023 return -EIO;
1046 req->qtcb->bottom.support.req_buf_length = bytes; 1024 req->qtcb->bottom.support.req_buf_length = bytes;
1047 req->qdio_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; 1025 zfcp_qdio_skip_to_last_sbale(&req->qdio_req);
1048 1026
1049 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, 1027 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req,
1050 SBAL_FLAGS0_TYPE_WRITE_READ,
1051 sg_resp, max_sbals); 1028 sg_resp, max_sbals);
1052 req->qtcb->bottom.support.resp_buf_length = bytes; 1029 req->qtcb->bottom.support.resp_buf_length = bytes;
1053 if (bytes <= 0) 1030 if (bytes <= 0)
@@ -1094,7 +1071,8 @@ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port,
1094 if (zfcp_fsf_req_sbal_get(qdio)) 1071 if (zfcp_fsf_req_sbal_get(qdio))
1095 goto out; 1072 goto out;
1096 1073
1097 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC, pool); 1074 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC,
1075 SBAL_FLAGS0_TYPE_WRITE_READ, pool);
1098 1076
1099 if (IS_ERR(req)) { 1077 if (IS_ERR(req)) {
1100 ret = PTR_ERR(req); 1078 ret = PTR_ERR(req);
@@ -1103,7 +1081,7 @@ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port,
1103 1081
1104 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1082 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1105 ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp, 1083 ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp,
1106 FSF_MAX_SBALS_PER_REQ, timeout); 1084 ZFCP_FSF_MAX_SBALS_PER_REQ, timeout);
1107 if (ret) 1085 if (ret)
1108 goto failed_send; 1086 goto failed_send;
1109 1087
@@ -1190,7 +1168,8 @@ int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id,
1190 if (zfcp_fsf_req_sbal_get(qdio)) 1168 if (zfcp_fsf_req_sbal_get(qdio))
1191 goto out; 1169 goto out;
1192 1170
1193 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS, NULL); 1171 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS,
1172 SBAL_FLAGS0_TYPE_WRITE_READ, NULL);
1194 1173
1195 if (IS_ERR(req)) { 1174 if (IS_ERR(req)) {
1196 ret = PTR_ERR(req); 1175 ret = PTR_ERR(req);
@@ -1224,7 +1203,6 @@ out:
1224 1203
1225int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) 1204int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1226{ 1205{
1227 struct qdio_buffer_element *sbale;
1228 struct zfcp_fsf_req *req; 1206 struct zfcp_fsf_req *req;
1229 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1207 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1230 int retval = -EIO; 1208 int retval = -EIO;
@@ -1234,6 +1212,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1234 goto out; 1212 goto out;
1235 1213
1236 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, 1214 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
1215 SBAL_FLAGS0_TYPE_READ,
1237 qdio->adapter->pool.erp_req); 1216 qdio->adapter->pool.erp_req);
1238 1217
1239 if (IS_ERR(req)) { 1218 if (IS_ERR(req)) {
@@ -1242,9 +1221,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1242 } 1221 }
1243 1222
1244 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1223 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1245 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1224 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1246 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1247 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1248 1225
1249 req->qtcb->bottom.config.feature_selection = 1226 req->qtcb->bottom.config.feature_selection =
1250 FSF_FEATURE_CFDC | 1227 FSF_FEATURE_CFDC |
@@ -1269,7 +1246,6 @@ out:
1269int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio, 1246int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio,
1270 struct fsf_qtcb_bottom_config *data) 1247 struct fsf_qtcb_bottom_config *data)
1271{ 1248{
1272 struct qdio_buffer_element *sbale;
1273 struct zfcp_fsf_req *req = NULL; 1249 struct zfcp_fsf_req *req = NULL;
1274 int retval = -EIO; 1250 int retval = -EIO;
1275 1251
@@ -1277,16 +1253,15 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio,
1277 if (zfcp_fsf_req_sbal_get(qdio)) 1253 if (zfcp_fsf_req_sbal_get(qdio))
1278 goto out_unlock; 1254 goto out_unlock;
1279 1255
1280 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, NULL); 1256 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
1257 SBAL_FLAGS0_TYPE_READ, NULL);
1281 1258
1282 if (IS_ERR(req)) { 1259 if (IS_ERR(req)) {
1283 retval = PTR_ERR(req); 1260 retval = PTR_ERR(req);
1284 goto out_unlock; 1261 goto out_unlock;
1285 } 1262 }
1286 1263
1287 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1264 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1288 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1289 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1290 req->handler = zfcp_fsf_exchange_config_data_handler; 1265 req->handler = zfcp_fsf_exchange_config_data_handler;
1291 1266
1292 req->qtcb->bottom.config.feature_selection = 1267 req->qtcb->bottom.config.feature_selection =
@@ -1320,7 +1295,6 @@ out_unlock:
1320int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) 1295int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1321{ 1296{
1322 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1297 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1323 struct qdio_buffer_element *sbale;
1324 struct zfcp_fsf_req *req; 1298 struct zfcp_fsf_req *req;
1325 int retval = -EIO; 1299 int retval = -EIO;
1326 1300
@@ -1332,6 +1306,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1332 goto out; 1306 goto out;
1333 1307
1334 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, 1308 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
1309 SBAL_FLAGS0_TYPE_READ,
1335 qdio->adapter->pool.erp_req); 1310 qdio->adapter->pool.erp_req);
1336 1311
1337 if (IS_ERR(req)) { 1312 if (IS_ERR(req)) {
@@ -1340,9 +1315,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1340 } 1315 }
1341 1316
1342 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1317 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1343 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1318 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1344 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1345 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1346 1319
1347 req->handler = zfcp_fsf_exchange_port_data_handler; 1320 req->handler = zfcp_fsf_exchange_port_data_handler;
1348 req->erp_action = erp_action; 1321 req->erp_action = erp_action;
@@ -1368,7 +1341,6 @@ out:
1368int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio, 1341int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
1369 struct fsf_qtcb_bottom_port *data) 1342 struct fsf_qtcb_bottom_port *data)
1370{ 1343{
1371 struct qdio_buffer_element *sbale;
1372 struct zfcp_fsf_req *req = NULL; 1344 struct zfcp_fsf_req *req = NULL;
1373 int retval = -EIO; 1345 int retval = -EIO;
1374 1346
@@ -1379,7 +1351,8 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
1379 if (zfcp_fsf_req_sbal_get(qdio)) 1351 if (zfcp_fsf_req_sbal_get(qdio))
1380 goto out_unlock; 1352 goto out_unlock;
1381 1353
1382 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, NULL); 1354 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
1355 SBAL_FLAGS0_TYPE_READ, NULL);
1383 1356
1384 if (IS_ERR(req)) { 1357 if (IS_ERR(req)) {
1385 retval = PTR_ERR(req); 1358 retval = PTR_ERR(req);
@@ -1389,9 +1362,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
1389 if (data) 1362 if (data)
1390 req->data = data; 1363 req->data = data;
1391 1364
1392 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1365 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1393 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1394 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1395 1366
1396 req->handler = zfcp_fsf_exchange_port_data_handler; 1367 req->handler = zfcp_fsf_exchange_port_data_handler;
1397 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); 1368 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
@@ -1485,7 +1456,6 @@ out:
1485 */ 1456 */
1486int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) 1457int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1487{ 1458{
1488 struct qdio_buffer_element *sbale;
1489 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1459 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1490 struct zfcp_port *port = erp_action->port; 1460 struct zfcp_port *port = erp_action->port;
1491 struct zfcp_fsf_req *req; 1461 struct zfcp_fsf_req *req;
@@ -1496,6 +1466,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1496 goto out; 1466 goto out;
1497 1467
1498 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, 1468 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
1469 SBAL_FLAGS0_TYPE_READ,
1499 qdio->adapter->pool.erp_req); 1470 qdio->adapter->pool.erp_req);
1500 1471
1501 if (IS_ERR(req)) { 1472 if (IS_ERR(req)) {
@@ -1504,9 +1475,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1504 } 1475 }
1505 1476
1506 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1477 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1507 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1478 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1508 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1509 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1510 1479
1511 req->handler = zfcp_fsf_open_port_handler; 1480 req->handler = zfcp_fsf_open_port_handler;
1512 hton24(req->qtcb->bottom.support.d_id, port->d_id); 1481 hton24(req->qtcb->bottom.support.d_id, port->d_id);
@@ -1556,7 +1525,6 @@ static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
1556 */ 1525 */
1557int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) 1526int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1558{ 1527{
1559 struct qdio_buffer_element *sbale;
1560 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1528 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1561 struct zfcp_fsf_req *req; 1529 struct zfcp_fsf_req *req;
1562 int retval = -EIO; 1530 int retval = -EIO;
@@ -1566,6 +1534,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1566 goto out; 1534 goto out;
1567 1535
1568 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, 1536 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
1537 SBAL_FLAGS0_TYPE_READ,
1569 qdio->adapter->pool.erp_req); 1538 qdio->adapter->pool.erp_req);
1570 1539
1571 if (IS_ERR(req)) { 1540 if (IS_ERR(req)) {
@@ -1574,9 +1543,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1574 } 1543 }
1575 1544
1576 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1545 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1577 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1546 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1578 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1579 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1580 1547
1581 req->handler = zfcp_fsf_close_port_handler; 1548 req->handler = zfcp_fsf_close_port_handler;
1582 req->data = erp_action->port; 1549 req->data = erp_action->port;
@@ -1633,7 +1600,6 @@ out:
1633 */ 1600 */
1634int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port) 1601int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
1635{ 1602{
1636 struct qdio_buffer_element *sbale;
1637 struct zfcp_qdio *qdio = wka_port->adapter->qdio; 1603 struct zfcp_qdio *qdio = wka_port->adapter->qdio;
1638 struct zfcp_fsf_req *req; 1604 struct zfcp_fsf_req *req;
1639 int retval = -EIO; 1605 int retval = -EIO;
@@ -1643,6 +1609,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
1643 goto out; 1609 goto out;
1644 1610
1645 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, 1611 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
1612 SBAL_FLAGS0_TYPE_READ,
1646 qdio->adapter->pool.erp_req); 1613 qdio->adapter->pool.erp_req);
1647 1614
1648 if (unlikely(IS_ERR(req))) { 1615 if (unlikely(IS_ERR(req))) {
@@ -1651,9 +1618,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
1651 } 1618 }
1652 1619
1653 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1620 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1654 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1621 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1655 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1656 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1657 1622
1658 req->handler = zfcp_fsf_open_wka_port_handler; 1623 req->handler = zfcp_fsf_open_wka_port_handler;
1659 hton24(req->qtcb->bottom.support.d_id, wka_port->d_id); 1624 hton24(req->qtcb->bottom.support.d_id, wka_port->d_id);
@@ -1688,7 +1653,6 @@ static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
1688 */ 1653 */
1689int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port) 1654int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
1690{ 1655{
1691 struct qdio_buffer_element *sbale;
1692 struct zfcp_qdio *qdio = wka_port->adapter->qdio; 1656 struct zfcp_qdio *qdio = wka_port->adapter->qdio;
1693 struct zfcp_fsf_req *req; 1657 struct zfcp_fsf_req *req;
1694 int retval = -EIO; 1658 int retval = -EIO;
@@ -1698,6 +1662,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
1698 goto out; 1662 goto out;
1699 1663
1700 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, 1664 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
1665 SBAL_FLAGS0_TYPE_READ,
1701 qdio->adapter->pool.erp_req); 1666 qdio->adapter->pool.erp_req);
1702 1667
1703 if (unlikely(IS_ERR(req))) { 1668 if (unlikely(IS_ERR(req))) {
@@ -1706,9 +1671,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
1706 } 1671 }
1707 1672
1708 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1673 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1709 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1674 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1710 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1711 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1712 1675
1713 req->handler = zfcp_fsf_close_wka_port_handler; 1676 req->handler = zfcp_fsf_close_wka_port_handler;
1714 req->data = wka_port; 1677 req->data = wka_port;
@@ -1782,7 +1745,6 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1782 */ 1745 */
1783int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) 1746int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1784{ 1747{
1785 struct qdio_buffer_element *sbale;
1786 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1748 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1787 struct zfcp_fsf_req *req; 1749 struct zfcp_fsf_req *req;
1788 int retval = -EIO; 1750 int retval = -EIO;
@@ -1792,6 +1754,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1792 goto out; 1754 goto out;
1793 1755
1794 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT, 1756 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT,
1757 SBAL_FLAGS0_TYPE_READ,
1795 qdio->adapter->pool.erp_req); 1758 qdio->adapter->pool.erp_req);
1796 1759
1797 if (IS_ERR(req)) { 1760 if (IS_ERR(req)) {
@@ -1800,9 +1763,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1800 } 1763 }
1801 1764
1802 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1765 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1803 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1766 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1804 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1805 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1806 1767
1807 req->data = erp_action->port; 1768 req->data = erp_action->port;
1808 req->qtcb->header.port_handle = erp_action->port->handle; 1769 req->qtcb->header.port_handle = erp_action->port->handle;
@@ -1954,7 +1915,6 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1954 */ 1915 */
1955int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) 1916int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1956{ 1917{
1957 struct qdio_buffer_element *sbale;
1958 struct zfcp_adapter *adapter = erp_action->adapter; 1918 struct zfcp_adapter *adapter = erp_action->adapter;
1959 struct zfcp_qdio *qdio = adapter->qdio; 1919 struct zfcp_qdio *qdio = adapter->qdio;
1960 struct zfcp_fsf_req *req; 1920 struct zfcp_fsf_req *req;
@@ -1965,6 +1925,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1965 goto out; 1925 goto out;
1966 1926
1967 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN, 1927 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN,
1928 SBAL_FLAGS0_TYPE_READ,
1968 adapter->pool.erp_req); 1929 adapter->pool.erp_req);
1969 1930
1970 if (IS_ERR(req)) { 1931 if (IS_ERR(req)) {
@@ -1973,9 +1934,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1973 } 1934 }
1974 1935
1975 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1936 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1976 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1937 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1977 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1978 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1979 1938
1980 req->qtcb->header.port_handle = erp_action->port->handle; 1939 req->qtcb->header.port_handle = erp_action->port->handle;
1981 req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun; 1940 req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun;
@@ -2041,7 +2000,6 @@ static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req)
2041 */ 2000 */
2042int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) 2001int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
2043{ 2002{
2044 struct qdio_buffer_element *sbale;
2045 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 2003 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
2046 struct zfcp_fsf_req *req; 2004 struct zfcp_fsf_req *req;
2047 int retval = -EIO; 2005 int retval = -EIO;
@@ -2051,6 +2009,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
2051 goto out; 2009 goto out;
2052 2010
2053 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN, 2011 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN,
2012 SBAL_FLAGS0_TYPE_READ,
2054 qdio->adapter->pool.erp_req); 2013 qdio->adapter->pool.erp_req);
2055 2014
2056 if (IS_ERR(req)) { 2015 if (IS_ERR(req)) {
@@ -2059,9 +2018,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
2059 } 2018 }
2060 2019
2061 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 2020 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2062 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 2021 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2063 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2064 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2065 2022
2066 req->qtcb->header.port_handle = erp_action->port->handle; 2023 req->qtcb->header.port_handle = erp_action->port->handle;
2067 req->qtcb->header.lun_handle = erp_action->unit->handle; 2024 req->qtcb->header.lun_handle = erp_action->unit->handle;
@@ -2289,8 +2246,11 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2289 goto out; 2246 goto out;
2290 } 2247 }
2291 2248
2249 if (scsi_cmnd->sc_data_direction == DMA_TO_DEVICE)
2250 sbtype = SBAL_FLAGS0_TYPE_WRITE;
2251
2292 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND, 2252 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
2293 adapter->pool.scsi_req); 2253 sbtype, adapter->pool.scsi_req);
2294 2254
2295 if (IS_ERR(req)) { 2255 if (IS_ERR(req)) {
2296 retval = PTR_ERR(req); 2256 retval = PTR_ERR(req);
@@ -2298,7 +2258,6 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2298 } 2258 }
2299 2259
2300 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 2260 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2301 get_device(&unit->dev);
2302 req->unit = unit; 2261 req->unit = unit;
2303 req->data = scsi_cmnd; 2262 req->data = scsi_cmnd;
2304 req->handler = zfcp_fsf_send_fcp_command_handler; 2263 req->handler = zfcp_fsf_send_fcp_command_handler;
@@ -2323,20 +2282,21 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2323 break; 2282 break;
2324 case DMA_TO_DEVICE: 2283 case DMA_TO_DEVICE:
2325 req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE; 2284 req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE;
2326 sbtype = SBAL_FLAGS0_TYPE_WRITE;
2327 break; 2285 break;
2328 case DMA_BIDIRECTIONAL: 2286 case DMA_BIDIRECTIONAL:
2329 goto failed_scsi_cmnd; 2287 goto failed_scsi_cmnd;
2330 } 2288 }
2331 2289
2290 get_device(&unit->dev);
2291
2332 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; 2292 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
2333 zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); 2293 zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd);
2334 2294
2335 real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sbtype, 2295 real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
2336 scsi_sglist(scsi_cmnd), 2296 scsi_sglist(scsi_cmnd),
2337 FSF_MAX_SBALS_PER_REQ); 2297 ZFCP_FSF_MAX_SBALS_PER_REQ);
2338 if (unlikely(real_bytes < 0)) { 2298 if (unlikely(real_bytes < 0)) {
2339 if (req->qdio_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) { 2299 if (req->qdio_req.sbal_number >= ZFCP_FSF_MAX_SBALS_PER_REQ) {
2340 dev_err(&adapter->ccw_device->dev, 2300 dev_err(&adapter->ccw_device->dev,
2341 "Oversize data package, unit 0x%016Lx " 2301 "Oversize data package, unit 0x%016Lx "
2342 "on port 0x%016Lx closed\n", 2302 "on port 0x%016Lx closed\n",
@@ -2371,7 +2331,6 @@ out:
2371 */ 2331 */
2372struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) 2332struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2373{ 2333{
2374 struct qdio_buffer_element *sbale;
2375 struct zfcp_fsf_req *req = NULL; 2334 struct zfcp_fsf_req *req = NULL;
2376 struct fcp_cmnd *fcp_cmnd; 2335 struct fcp_cmnd *fcp_cmnd;
2377 struct zfcp_qdio *qdio = unit->port->adapter->qdio; 2336 struct zfcp_qdio *qdio = unit->port->adapter->qdio;
@@ -2385,6 +2344,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2385 goto out; 2344 goto out;
2386 2345
2387 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND, 2346 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
2347 SBAL_FLAGS0_TYPE_WRITE,
2388 qdio->adapter->pool.scsi_req); 2348 qdio->adapter->pool.scsi_req);
2389 2349
2390 if (IS_ERR(req)) { 2350 if (IS_ERR(req)) {
@@ -2401,9 +2361,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2401 req->qtcb->bottom.io.service_class = FSF_CLASS_3; 2361 req->qtcb->bottom.io.service_class = FSF_CLASS_3;
2402 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; 2362 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
2403 2363
2404 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 2364 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2405 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
2406 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2407 2365
2408 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; 2366 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
2409 zfcp_fc_fcp_tm(fcp_cmnd, unit->device, tm_flags); 2367 zfcp_fc_fcp_tm(fcp_cmnd, unit->device, tm_flags);
@@ -2432,7 +2390,6 @@ static void zfcp_fsf_control_file_handler(struct zfcp_fsf_req *req)
2432struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, 2390struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2433 struct zfcp_fsf_cfdc *fsf_cfdc) 2391 struct zfcp_fsf_cfdc *fsf_cfdc)
2434{ 2392{
2435 struct qdio_buffer_element *sbale;
2436 struct zfcp_qdio *qdio = adapter->qdio; 2393 struct zfcp_qdio *qdio = adapter->qdio;
2437 struct zfcp_fsf_req *req = NULL; 2394 struct zfcp_fsf_req *req = NULL;
2438 struct fsf_qtcb_bottom_support *bottom; 2395 struct fsf_qtcb_bottom_support *bottom;
@@ -2456,7 +2413,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2456 if (zfcp_fsf_req_sbal_get(qdio)) 2413 if (zfcp_fsf_req_sbal_get(qdio))
2457 goto out; 2414 goto out;
2458 2415
2459 req = zfcp_fsf_req_create(qdio, fsf_cfdc->command, NULL); 2416 req = zfcp_fsf_req_create(qdio, fsf_cfdc->command, direction, NULL);
2460 if (IS_ERR(req)) { 2417 if (IS_ERR(req)) {
2461 retval = -EPERM; 2418 retval = -EPERM;
2462 goto out; 2419 goto out;
@@ -2464,16 +2421,13 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2464 2421
2465 req->handler = zfcp_fsf_control_file_handler; 2422 req->handler = zfcp_fsf_control_file_handler;
2466 2423
2467 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
2468 sbale[0].flags |= direction;
2469
2470 bottom = &req->qtcb->bottom.support; 2424 bottom = &req->qtcb->bottom.support;
2471 bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE; 2425 bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
2472 bottom->option = fsf_cfdc->option; 2426 bottom->option = fsf_cfdc->option;
2473 2427
2474 bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, 2428 bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
2475 direction, fsf_cfdc->sg, 2429 fsf_cfdc->sg,
2476 FSF_MAX_SBALS_PER_REQ); 2430 ZFCP_FSF_MAX_SBALS_PER_REQ);
2477 if (bytes != ZFCP_CFDC_MAX_SIZE) { 2431 if (bytes != ZFCP_CFDC_MAX_SIZE) {
2478 zfcp_fsf_req_free(req); 2432 zfcp_fsf_req_free(req);
2479 goto out; 2433 goto out;
diff --git a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h
index b3de682b64cf..4008bd786793 100644
--- a/drivers/s390/scsi/zfcp_fsf.h
+++ b/drivers/s390/scsi/zfcp_fsf.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Interface to the FSF support functions. 4 * Interface to the FSF support functions.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2009 6 * Copyright IBM Corporation 2002, 2010
7 */ 7 */
8 8
9#ifndef FSF_H 9#ifndef FSF_H
@@ -152,7 +152,12 @@
152#define FSF_CLASS_3 0x00000003 152#define FSF_CLASS_3 0x00000003
153 153
154/* SBAL chaining */ 154/* SBAL chaining */
155#define FSF_MAX_SBALS_PER_REQ 36 155#define ZFCP_FSF_MAX_SBALS_PER_REQ 36
156
157/* max. number of (data buffer) SBALEs in largest SBAL chain
158 * request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
159#define ZFCP_FSF_MAX_SBALES_PER_REQ \
160 (ZFCP_FSF_MAX_SBALS_PER_REQ * ZFCP_QDIO_MAX_SBALES_PER_SBAL - 2)
156 161
157/* logging space behind QTCB */ 162/* logging space behind QTCB */
158#define FSF_QTCB_LOG_SIZE 1024 163#define FSF_QTCB_LOG_SIZE 1024
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index aa68515abe21..98d54a9cd563 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Setup and helper functions to access QDIO. 4 * Setup and helper functions to access QDIO.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2009 6 * Copyright IBM Corporation 2002, 2010
7 */ 7 */
8 8
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
@@ -151,8 +151,7 @@ static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio,
151} 151}
152 152
153static struct qdio_buffer_element * 153static struct qdio_buffer_element *
154zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, 154zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
155 unsigned long sbtype)
156{ 155{
157 struct qdio_buffer_element *sbale; 156 struct qdio_buffer_element *sbale;
158 157
@@ -180,17 +179,16 @@ zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
180 179
181 /* set storage-block type for new SBAL */ 180 /* set storage-block type for new SBAL */
182 sbale = zfcp_qdio_sbale_curr(qdio, q_req); 181 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
183 sbale->flags |= sbtype; 182 sbale->flags |= q_req->sbtype;
184 183
185 return sbale; 184 return sbale;
186} 185}
187 186
188static struct qdio_buffer_element * 187static struct qdio_buffer_element *
189zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, 188zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
190 unsigned int sbtype)
191{ 189{
192 if (q_req->sbale_curr == ZFCP_LAST_SBALE_PER_SBAL) 190 if (q_req->sbale_curr == ZFCP_QDIO_LAST_SBALE_PER_SBAL)
193 return zfcp_qdio_sbal_chain(qdio, q_req, sbtype); 191 return zfcp_qdio_sbal_chain(qdio, q_req);
194 q_req->sbale_curr++; 192 q_req->sbale_curr++;
195 return zfcp_qdio_sbale_curr(qdio, q_req); 193 return zfcp_qdio_sbale_curr(qdio, q_req);
196} 194}
@@ -208,15 +206,14 @@ static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio,
208 206
209/** 207/**
210 * zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list 208 * zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list
211 * @fsf_req: request to be processed 209 * @qdio: pointer to struct zfcp_qdio
212 * @sbtype: SBALE flags 210 * @q_req: pointer to struct zfcp_qdio_req
213 * @sg: scatter-gather list 211 * @sg: scatter-gather list
214 * @max_sbals: upper bound for number of SBALs to be used 212 * @max_sbals: upper bound for number of SBALs to be used
215 * Returns: number of bytes, or error (negativ) 213 * Returns: number of bytes, or error (negativ)
216 */ 214 */
217int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, 215int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
218 unsigned long sbtype, struct scatterlist *sg, 216 struct scatterlist *sg, int max_sbals)
219 int max_sbals)
220{ 217{
221 struct qdio_buffer_element *sbale; 218 struct qdio_buffer_element *sbale;
222 int bytes = 0; 219 int bytes = 0;
@@ -226,10 +223,10 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
226 223
227 /* set storage-block type for this request */ 224 /* set storage-block type for this request */
228 sbale = zfcp_qdio_sbale_req(qdio, q_req); 225 sbale = zfcp_qdio_sbale_req(qdio, q_req);
229 sbale->flags |= sbtype; 226 sbale->flags |= q_req->sbtype;
230 227
231 for (; sg; sg = sg_next(sg)) { 228 for (; sg; sg = sg_next(sg)) {
232 sbale = zfcp_qdio_sbale_next(qdio, q_req, sbtype); 229 sbale = zfcp_qdio_sbale_next(qdio, q_req);
233 if (!sbale) { 230 if (!sbale) {
234 atomic_inc(&qdio->req_q_full); 231 atomic_inc(&qdio->req_q_full);
235 zfcp_qdio_undo_sbals(qdio, q_req); 232 zfcp_qdio_undo_sbals(qdio, q_req);
diff --git a/drivers/s390/scsi/zfcp_qdio.h b/drivers/s390/scsi/zfcp_qdio.h
index f2b5a363bb84..138fba577b48 100644
--- a/drivers/s390/scsi/zfcp_qdio.h
+++ b/drivers/s390/scsi/zfcp_qdio.h
@@ -13,6 +13,12 @@
13 13
14#define ZFCP_QDIO_SBALE_LEN PAGE_SIZE 14#define ZFCP_QDIO_SBALE_LEN PAGE_SIZE
15 15
16/* DMQ bug workaround: don't use last SBALE */
17#define ZFCP_QDIO_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
18
19/* index of last SBALE (with respect to DMQ bug workaround) */
20#define ZFCP_QDIO_LAST_SBALE_PER_SBAL (ZFCP_QDIO_MAX_SBALES_PER_SBAL - 1)
21
16/** 22/**
17 * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count 23 * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count
18 * @sbal: qdio buffers 24 * @sbal: qdio buffers
@@ -51,6 +57,7 @@ struct zfcp_qdio {
51 57
52/** 58/**
53 * struct zfcp_qdio_req - qdio queue related values for a request 59 * struct zfcp_qdio_req - qdio queue related values for a request
60 * @sbtype: sbal type flags for sbale 0
54 * @sbal_number: number of free sbals 61 * @sbal_number: number of free sbals
55 * @sbal_first: first sbal for this request 62 * @sbal_first: first sbal for this request
56 * @sbal_last: last sbal for this request 63 * @sbal_last: last sbal for this request
@@ -61,6 +68,7 @@ struct zfcp_qdio {
61 * @qdio_inb_usage: usage of inbound queue 68 * @qdio_inb_usage: usage of inbound queue
62 */ 69 */
63struct zfcp_qdio_req { 70struct zfcp_qdio_req {
71 u32 sbtype;
64 u8 sbal_number; 72 u8 sbal_number;
65 u8 sbal_first; 73 u8 sbal_first;
66 u8 sbal_last; 74 u8 sbal_last;
@@ -108,4 +116,98 @@ zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
108 q_req->sbale_curr); 116 q_req->sbale_curr);
109} 117}
110 118
119/**
120 * zfcp_qdio_req_init - initialize qdio request
121 * @qdio: request queue where to start putting the request
122 * @q_req: the qdio request to start
123 * @req_id: The request id
124 * @sbtype: type flags to set for all sbals
125 * @data: First data block
126 * @len: Length of first data block
127 *
128 * This is the start of putting the request into the queue, the last
129 * step is passing the request to zfcp_qdio_send. The request queue
130 * lock must be held during the whole process from init to send.
131 */
132static inline
133void zfcp_qdio_req_init(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
134 unsigned long req_id, u32 sbtype, void *data, u32 len)
135{
136 struct qdio_buffer_element *sbale;
137
138 q_req->sbal_first = q_req->sbal_last = qdio->req_q.first;
139 q_req->sbal_number = 1;
140 q_req->sbtype = sbtype;
141
142 sbale = zfcp_qdio_sbale_req(qdio, q_req);
143 sbale->addr = (void *) req_id;
144 sbale->flags |= SBAL_FLAGS0_COMMAND;
145 sbale->flags |= sbtype;
146
147 q_req->sbale_curr = 1;
148 sbale++;
149 sbale->addr = data;
150 if (likely(data))
151 sbale->length = len;
152}
153
154/**
155 * zfcp_qdio_fill_next - Fill next sbale, only for single sbal requests
156 * @qdio: pointer to struct zfcp_qdio
157 * @q_req: pointer to struct zfcp_queue_req
158 *
159 * This is only required for single sbal requests, calling it when
160 * wrapping around to the next sbal is a bug.
161 */
162static inline
163void zfcp_qdio_fill_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
164 void *data, u32 len)
165{
166 struct qdio_buffer_element *sbale;
167
168 BUG_ON(q_req->sbale_curr == ZFCP_QDIO_LAST_SBALE_PER_SBAL);
169 q_req->sbale_curr++;
170 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
171 sbale->addr = data;
172 sbale->length = len;
173}
174
175/**
176 * zfcp_qdio_set_sbale_last - set last entry flag in current sbale
177 * @qdio: pointer to struct zfcp_qdio
178 * @q_req: pointer to struct zfcp_queue_req
179 */
180static inline
181void zfcp_qdio_set_sbale_last(struct zfcp_qdio *qdio,
182 struct zfcp_qdio_req *q_req)
183{
184 struct qdio_buffer_element *sbale;
185
186 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
187 sbale->flags |= SBAL_FLAGS_LAST_ENTRY;
188}
189
190/**
191 * zfcp_qdio_sg_one_sbal - check if one sbale is enough for sg data
192 * @sg: The scatterlist where to check the data size
193 *
194 * Returns: 1 when one sbale is enough for the data in the scatterlist,
195 * 0 if not.
196 */
197static inline
198int zfcp_qdio_sg_one_sbale(struct scatterlist *sg)
199{
200 return sg_is_last(sg) && sg->length <= ZFCP_QDIO_SBALE_LEN;
201}
202
203/**
204 * zfcp_qdio_skip_to_last_sbale - skip to last sbale in sbal
205 * @q_req: The current zfcp_qdio_req
206 */
207static inline
208void zfcp_qdio_skip_to_last_sbale(struct zfcp_qdio_req *q_req)
209{
210 q_req->sbale_curr = ZFCP_QDIO_LAST_SBALE_PER_SBAL;
211}
212
111#endif /* ZFCP_QDIO_H */ 213#endif /* ZFCP_QDIO_H */
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 066b0507a639..be5d2c60453d 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -677,11 +677,11 @@ struct zfcp_data zfcp_data = {
677 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, 677 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler,
678 .can_queue = 4096, 678 .can_queue = 4096,
679 .this_id = -1, 679 .this_id = -1,
680 .sg_tablesize = ZFCP_MAX_SBALES_PER_REQ, 680 .sg_tablesize = ZFCP_FSF_MAX_SBALES_PER_REQ,
681 .cmd_per_lun = 1, 681 .cmd_per_lun = 1,
682 .use_clustering = 1, 682 .use_clustering = 1,
683 .sdev_attrs = zfcp_sysfs_sdev_attrs, 683 .sdev_attrs = zfcp_sysfs_sdev_attrs,
684 .max_sectors = (ZFCP_MAX_SBALES_PER_REQ * 8), 684 .max_sectors = (ZFCP_FSF_MAX_SBALES_PER_REQ * 8),
685 .dma_boundary = ZFCP_QDIO_SBALE_LEN - 1, 685 .dma_boundary = ZFCP_QDIO_SBALE_LEN - 1,
686 .shost_attrs = zfcp_sysfs_shost_attrs, 686 .shost_attrs = zfcp_sysfs_shost_attrs,
687 }, 687 },