Deleted Added
full compact
tws_cam.c (240901) tws_cam.c (241753)
1/*
2 * Copyright (c) 2010 LSI Corp.
3 * All rights reserved.
4 * Author : Manjunath Ranganathaiah <manjunath.ranganathaiah@lsi.com>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*
2 * Copyright (c) 2010 LSI Corp.
3 * All rights reserved.
4 * Author : Manjunath Ranganathaiah <manjunath.ranganathaiah@lsi.com>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/tws/tws_cam.c 240901 2012-09-24 21:45:41Z jimharris $
27 * $FreeBSD: head/sys/dev/tws/tws_cam.c 241753 2012-10-19 22:07:40Z delphij $
28 */
29
30#include <dev/tws/tws.h>
31#include <dev/tws/tws_services.h>
32#include <dev/tws/tws_hdm.h>
33#include <dev/tws/tws_user.h>
34#include <cam/cam.h>
35#include <cam/cam_ccb.h>

--- 929 unchanged lines hidden (view full) ---

965 req->data, req->length,
966 tws_dmamap_data_load_cbfn, req,
967 my_flags);
968 mtx_unlock(&sc->io_lock);
969
970 if (error == EINPROGRESS) {
971 TWS_TRACE(sc, "in progress", 0, error);
972 tws_freeze_simq(sc, req);
28 */
29
30#include <dev/tws/tws.h>
31#include <dev/tws/tws_services.h>
32#include <dev/tws/tws_hdm.h>
33#include <dev/tws/tws_user.h>
34#include <cam/cam.h>
35#include <cam/cam_ccb.h>

--- 929 unchanged lines hidden (view full) ---

965 req->data, req->length,
966 tws_dmamap_data_load_cbfn, req,
967 my_flags);
968 mtx_unlock(&sc->io_lock);
969
970 if (error == EINPROGRESS) {
971 TWS_TRACE(sc, "in progress", 0, error);
972 tws_freeze_simq(sc, req);
973 error = 0; // EINPROGRESS is not a fatal error.
973 }
974 } else { /* no data involved */
975 error = tws_submit_command(sc, req);
976 }
977 return(error);
978}
979
980
981static void
982tws_dmamap_data_load_cbfn(void *arg, bus_dma_segment_t *segs,
983 int nseg, int error)
984{
985 struct tws_request *req = (struct tws_request *)arg;
986 struct tws_softc *sc = req->sc;
987 u_int16_t sgls = nseg;
988 void *sgl_ptr;
989 struct tws_cmd_generic *gcmd;
990
991
974 }
975 } else { /* no data involved */
976 error = tws_submit_command(sc, req);
977 }
978 return(error);
979}
980
981
982static void
983tws_dmamap_data_load_cbfn(void *arg, bus_dma_segment_t *segs,
984 int nseg, int error)
985{
986 struct tws_request *req = (struct tws_request *)arg;
987 struct tws_softc *sc = req->sc;
988 u_int16_t sgls = nseg;
989 void *sgl_ptr;
990 struct tws_cmd_generic *gcmd;
991
992
993 if ( error ) {
994 TWS_TRACE(sc, "SOMETHING BAD HAPPENED! error = %d\n", error, 0);
995 }
996
992 if ( error == EFBIG ) {
993 TWS_TRACE(sc, "not enough data segs", 0, nseg);
994 req->error_code = error;
995 req->ccb_ptr->ccb_h.status = CAM_REQ_TOO_BIG;
996 return;
997 }
998
999 if ( req->flags & TWS_DIR_IN )

--- 5 unchanged lines hidden (view full) ---

1005 if ( segs ) {
1006 if ( (req->type == TWS_REQ_TYPE_PASSTHRU &&
1007 GET_OPCODE(req->cmd_pkt->cmd.pkt_a.res__opcode) !=
1008 TWS_FW_CMD_EXECUTE_SCSI) ||
1009 req->type == TWS_REQ_TYPE_GETSET_PARAM) {
1010 gcmd = &req->cmd_pkt->cmd.pkt_g.generic;
1011 sgl_ptr = (u_int32_t *)(gcmd) + gcmd->size;
1012 gcmd->size += sgls *
997 if ( error == EFBIG ) {
998 TWS_TRACE(sc, "not enough data segs", 0, nseg);
999 req->error_code = error;
1000 req->ccb_ptr->ccb_h.status = CAM_REQ_TOO_BIG;
1001 return;
1002 }
1003
1004 if ( req->flags & TWS_DIR_IN )

--- 5 unchanged lines hidden (view full) ---

1010 if ( segs ) {
1011 if ( (req->type == TWS_REQ_TYPE_PASSTHRU &&
1012 GET_OPCODE(req->cmd_pkt->cmd.pkt_a.res__opcode) !=
1013 TWS_FW_CMD_EXECUTE_SCSI) ||
1014 req->type == TWS_REQ_TYPE_GETSET_PARAM) {
1015 gcmd = &req->cmd_pkt->cmd.pkt_g.generic;
1016 sgl_ptr = (u_int32_t *)(gcmd) + gcmd->size;
1017 gcmd->size += sgls *
1013 ((req->sc->is64bit && !tws_use_32bit_sgls) ? 4 :2 );
1018 ((req->sc->is64bit && !tws_use_32bit_sgls) ? 4 : 2 );
1014 tws_fill_sg_list(req->sc, (void *)segs, sgl_ptr, sgls);
1015
1016 } else {
1017 tws_fill_sg_list(req->sc, (void *)segs,
1019 tws_fill_sg_list(req->sc, (void *)segs, sgl_ptr, sgls);
1020
1021 } else {
1022 tws_fill_sg_list(req->sc, (void *)segs,
1018 (void *)req->cmd_pkt->cmd.pkt_a.sg_list, sgls);
1023 (void *)&(req->cmd_pkt->cmd.pkt_a.sg_list), sgls);
1019 req->cmd_pkt->cmd.pkt_a.lun_h4__sgl_entries |= sgls ;
1020 }
1021 }
1022
1023
1024 req->error_code = tws_submit_command(req->sc, req);
1025
1026}

--- 286 unchanged lines hidden (view full) ---

1313// device_printf(sc->tws_dev, "Sending initConnect\n");
1314 if ( tws_init_connect(sc, tws_queue_depth) ) {
1315 TWS_TRACE_DEBUG(sc, "initConnect failed", 0, sc->is64bit);
1316 }
1317 tws_init_obfl_q(sc);
1318
1319 tws_turn_on_interrupts(sc);
1320
1024 req->cmd_pkt->cmd.pkt_a.lun_h4__sgl_entries |= sgls ;
1025 }
1026 }
1027
1028
1029 req->error_code = tws_submit_command(req->sc, req);
1030
1031}

--- 286 unchanged lines hidden (view full) ---

1318// device_printf(sc->tws_dev, "Sending initConnect\n");
1319 if ( tws_init_connect(sc, tws_queue_depth) ) {
1320 TWS_TRACE_DEBUG(sc, "initConnect failed", 0, sc->is64bit);
1321 }
1322 tws_init_obfl_q(sc);
1323
1324 tws_turn_on_interrupts(sc);
1325
1321 if ( sc->chan ) {
1322 sc->chan = 0;
1323 wakeup_one((void *)&sc->chan);
1324 }
1326 wakeup_one(sc->chan);
1325}
1326
1327
1328static void
1329tws_freeze_simq(struct tws_softc *sc, struct tws_request *req)
1330{
1331 /* Only for IO commands */
1332 if (req->type == TWS_REQ_TYPE_SCSI_IO) {
1333 union ccb *ccb = (union ccb *)(req->ccb_ptr);
1334
1335 xpt_freeze_simq(sc->sim, 1);
1336 ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
1337 ccb->ccb_h.status |= CAM_REQUEUE_REQ;
1338 }
1339}
1340
1341
1342TUNABLE_INT("hw.tws.cam_depth", &tws_cam_depth);
1327}
1328
1329
1330static void
1331tws_freeze_simq(struct tws_softc *sc, struct tws_request *req)
1332{
1333 /* Only for IO commands */
1334 if (req->type == TWS_REQ_TYPE_SCSI_IO) {
1335 union ccb *ccb = (union ccb *)(req->ccb_ptr);
1336
1337 xpt_freeze_simq(sc->sim, 1);
1338 ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
1339 ccb->ccb_h.status |= CAM_REQUEUE_REQ;
1340 }
1341}
1342
1343
1344TUNABLE_INT("hw.tws.cam_depth", &tws_cam_depth);