Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[safe/jmp/linux-2.6] / drivers / s390 / scsi / zfcp_fsf.c
index 8a0705a..b3b1d2f 100644 (file)
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/blktrace_api.h>
+#include <linux/slab.h>
 #include <scsi/fc/fc_els.h>
 #include "zfcp_ext.h"
 #include "zfcp_fc.h"
 #include "zfcp_dbf.h"
+#include "zfcp_qdio.h"
 #include "zfcp_reqlist.h"
 
 static void zfcp_fsf_request_timeout_handler(unsigned long data)
@@ -723,12 +725,12 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
        req->adapter = adapter;
        req->fsf_command = fsf_cmd;
        req->req_id = adapter->req_no;
-       req->queue_req.sbal_number = 1;
-       req->queue_req.sbal_first = req_q->first;
-       req->queue_req.sbal_last = req_q->first;
-       req->queue_req.sbale_curr = 1;
+       req->qdio_req.sbal_number = 1;
+       req->qdio_req.sbal_first = req_q->first;
+       req->qdio_req.sbal_last = req_q->first;
+       req->qdio_req.sbale_curr = 1;
 
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].addr = (void *) req->req_id;
        sbale[0].flags |= SBAL_FLAGS0_COMMAND;
 
@@ -772,9 +774,9 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
 
        zfcp_reqlist_add(adapter->req_list, req);
 
-       req->queue_req.qdio_outb_usage = atomic_read(&qdio->req_q.count);
+       req->qdio_req.qdio_outb_usage = atomic_read(&qdio->req_q.count);
        req->issued = get_clock();
-       if (zfcp_qdio_send(qdio, &req->queue_req)) {
+       if (zfcp_qdio_send(qdio, &req->qdio_req)) {
                del_timer(&req->timer);
                /* lookup request again, list might have changed */
                zfcp_reqlist_find_rm(adapter->req_list, req_id);
@@ -815,9 +817,9 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
                goto out;
        }
 
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
-       req->queue_req.sbale_curr = 2;
+       req->qdio_req.sbale_curr = 2;
 
        sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC);
        if (!sr_buf) {
@@ -826,7 +828,7 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
        }
        memset(sr_buf, 0, sizeof(*sr_buf));
        req->data = sr_buf;
-       sbale = zfcp_qdio_sbale_curr(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_curr(qdio, &req->qdio_req);
        sbale->addr = (void *) sr_buf;
        sbale->length = sizeof(*sr_buf);
 
@@ -923,7 +925,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
                       ZFCP_STATUS_COMMON_UNBLOCKED)))
                goto out_error_free;
 
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1018,7 +1020,7 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
 {
        struct zfcp_adapter *adapter = req->adapter;
        struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(adapter->qdio,
-                                                              &req->queue_req);
+                                                              &req->qdio_req);
        u32 feat = adapter->adapter_features;
        int bytes;
 
@@ -1036,15 +1038,15 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
                return 0;
        }
 
-       bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->queue_req,
+       bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req,
                                        SBAL_FLAGS0_TYPE_WRITE_READ,
                                        sg_req, max_sbals);
        if (bytes <= 0)
                return -EIO;
        req->qtcb->bottom.support.req_buf_length = bytes;
-       req->queue_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
+       req->qdio_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
 
-       bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->queue_req,
+       bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req,
                                        SBAL_FLAGS0_TYPE_WRITE_READ,
                                        sg_resp, max_sbals);
        req->qtcb->bottom.support.resp_buf_length = bytes;
@@ -1240,7 +1242,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1282,7 +1284,7 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio,
                goto out_unlock;
        }
 
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
        req->handler = zfcp_fsf_exchange_config_data_handler;
@@ -1338,7 +1340,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1387,7 +1389,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
        if (data)
                req->data = data;
 
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1502,7 +1504,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
         sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
         sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1572,7 +1574,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1649,7 +1651,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1704,7 +1706,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1798,7 +1800,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -1971,7 +1973,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
         sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
         sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -2057,7 +2059,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
        }
 
        req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -2100,10 +2102,11 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
        blktrc.magic = ZFCP_BLK_DRV_DATA_MAGIC;
        if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
                blktrc.flags |= ZFCP_BLK_REQ_ERROR;
-       blktrc.inb_usage = req->queue_req.qdio_inb_usage;
-       blktrc.outb_usage = req->queue_req.qdio_outb_usage;
+       blktrc.inb_usage = req->qdio_req.qdio_inb_usage;
+       blktrc.outb_usage = req->qdio_req.qdio_outb_usage;
 
-       if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA) {
+       if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA &&
+           !(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
                blktrc.flags |= ZFCP_BLK_LAT_VALID;
                blktrc.channel_lat = lat_in->channel_lat * ticks;
                blktrc.fabric_lat = lat_in->fabric_lat * ticks;
@@ -2155,9 +2158,8 @@ static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req)
        fcp_rsp = (struct fcp_resp_with_ext *) &req->qtcb->bottom.io.fcp_rsp;
        zfcp_fc_eval_fcp_rsp(fcp_rsp, scpnt);
 
-       zfcp_fsf_req_trace(req, scpnt);
-
 skip_fsfstatus:
+       zfcp_fsf_req_trace(req, scpnt);
        zfcp_dbf_scsi_result(req->adapter->dbf, scpnt, req);
 
        scpnt->host_scribble = NULL;
@@ -2330,11 +2332,11 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
        fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
        zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd);
 
-       real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->queue_req, sbtype,
+       real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sbtype,
                                             scsi_sglist(scsi_cmnd),
                                             FSF_MAX_SBALS_PER_REQ);
        if (unlikely(real_bytes < 0)) {
-               if (req->queue_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) {
+               if (req->qdio_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) {
                        dev_err(&adapter->ccw_device->dev,
                                "Oversize data package, unit 0x%016Lx "
                                "on port 0x%016Lx closed\n",
@@ -2399,7 +2401,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
        req->qtcb->bottom.io.service_class = FSF_CLASS_3;
        req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
 
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
@@ -2462,14 +2464,14 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
 
        req->handler = zfcp_fsf_control_file_handler;
 
-       sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
+       sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
        sbale[0].flags |= direction;
 
        bottom = &req->qtcb->bottom.support;
        bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
        bottom->option = fsf_cfdc->option;
 
-       bytes = zfcp_qdio_sbals_from_sg(qdio, &req->queue_req,
+       bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
                                        direction, fsf_cfdc->sg,
                                        FSF_MAX_SBALS_PER_REQ);
        if (bytes != ZFCP_CFDC_MAX_SIZE) {
@@ -2517,8 +2519,8 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
                        panic("error: unknown req_id (%lx) on adapter %s.\n",
                              req_id, dev_name(&adapter->ccw_device->dev));
 
-               fsf_req->queue_req.sbal_response = sbal_idx;
-               fsf_req->queue_req.qdio_inb_usage =
+               fsf_req->qdio_req.sbal_response = sbal_idx;
+               fsf_req->qdio_req.qdio_inb_usage =
                        atomic_read(&qdio->resp_q.count);
                zfcp_fsf_req_complete(fsf_req);