Deleted Added
full compact
mrsas_cam.c (282532) mrsas_cam.c (282533)
1/*
2 * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Marian Choy
3 * Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
4 * Support: freebsdraid@avagotech.com
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:

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

26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Marian Choy
3 * Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
4 * Support: freebsdraid@avagotech.com
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:

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

26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/dev/mrsas/mrsas_cam.c 282532 2015-05-06 10:45:56Z kadesai $");
34__FBSDID("$FreeBSD: head/sys/dev/mrsas/mrsas_cam.c 282533 2015-05-06 10:46:28Z kadesai $");
35
36#include "dev/mrsas/mrsas.h"
37
38#include <cam/cam.h>
39#include <cam/cam_ccb.h>
40#include <cam/cam_sim.h>
41#include <cam/cam_xpt_sim.h>
42#include <cam/cam_debug.h>

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

53#include <sys/pcpu.h> /* XXX for PCPU_GET */
54
55#define smp_processor_id() PCPU_GET(cpuid)
56
57/*
58 * Function prototypes
59 */
60int mrsas_cam_attach(struct mrsas_softc *sc);
35
36#include "dev/mrsas/mrsas.h"
37
38#include <cam/cam.h>
39#include <cam/cam_ccb.h>
40#include <cam/cam_sim.h>
41#include <cam/cam_xpt_sim.h>
42#include <cam/cam_debug.h>

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

53#include <sys/pcpu.h> /* XXX for PCPU_GET */
54
55#define smp_processor_id() PCPU_GET(cpuid)
56
57/*
58 * Function prototypes
59 */
60int mrsas_cam_attach(struct mrsas_softc *sc);
61int mrsas_find_io_type(struct cam_sim *sim, union ccb *ccb);
61int mrsas_find_io_type(struct cam_sim *sim, union ccb *ccb);
62int mrsas_bus_scan(struct mrsas_softc *sc);
63int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim);
62int mrsas_bus_scan(struct mrsas_softc *sc);
63int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim);
64int mrsas_map_request(struct mrsas_softc *sc,
65 struct mrsas_mpt_cmd *cmd, union ccb *ccb);
66int
64int
65mrsas_map_request(struct mrsas_softc *sc,
66 struct mrsas_mpt_cmd *cmd, union ccb *ccb);
67int
67mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
68 union ccb *ccb);
68mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
69 union ccb *ccb);
69int
70int
70mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
71 union ccb *ccb, struct cam_sim *sim);
71mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
72 union ccb *ccb, struct cam_sim *sim);
72int
73int
73mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
74 union ccb *ccb, u_int32_t device_id,
75 MRSAS_RAID_SCSI_IO_REQUEST * io_request);
76void mrsas_xpt_freeze(struct mrsas_softc *sc);
77void mrsas_xpt_release(struct mrsas_softc *sc);
78void mrsas_cam_detach(struct mrsas_softc *sc);
79void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd);
80void mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
81void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
74mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
75 union ccb *ccb, u_int32_t device_id,
76 MRSAS_RAID_SCSI_IO_REQUEST * io_request);
77void mrsas_xpt_freeze(struct mrsas_softc *sc);
78void mrsas_xpt_release(struct mrsas_softc *sc);
79void mrsas_cam_detach(struct mrsas_softc *sc);
80void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd);
81void mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
82void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
82void
83void
83mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo,
84 u_int32_t req_desc_hi);
84mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo,
85 u_int32_t req_desc_hi);
85void
86void
86mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST * io_request,
87 u_int8_t cdb_len, struct IO_REQUEST_INFO *io_info, union ccb *ccb,
88 MR_DRV_RAID_MAP_ALL * local_map_ptr, u_int32_t ref_tag,
89 u_int32_t ld_block_size);
90static void mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim);
91static void mrsas_cam_poll(struct cam_sim *sim);
92static void mrsas_action(struct cam_sim *sim, union ccb *ccb);
93static void mrsas_scsiio_timeout(void *data);
87mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST * io_request,
88 u_int8_t cdb_len, struct IO_REQUEST_INFO *io_info, union ccb *ccb,
89 MR_DRV_RAID_MAP_ALL * local_map_ptr, u_int32_t ref_tag,
90 u_int32_t ld_block_size);
91static void mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim);
92static void mrsas_cam_poll(struct cam_sim *sim);
93static void mrsas_action(struct cam_sim *sim, union ccb *ccb);
94static void mrsas_scsiio_timeout(void *data);
94static void
95static void
95mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs,
96 int nseg, int error);
96mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs,
97 int nseg, int error);
97static int32_t
98static int32_t
98mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
99 union ccb *ccb);
100struct mrsas_mpt_cmd *mrsas_get_mpt_cmd(struct mrsas_softc *sc);
101MRSAS_REQUEST_DESCRIPTOR_UNION *
102 mrsas_get_request_desc(struct mrsas_softc *sc, u_int16_t index);
103
104extern u_int16_t MR_TargetIdToLdGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL * map);
105extern u_int32_t
106MR_LdBlockSizeGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL * map,
107 struct mrsas_softc *sc);
108extern void mrsas_isr(void *arg);
109extern void mrsas_aen_handler(struct mrsas_softc *sc);
110extern u_int8_t
111MR_BuildRaidContext(struct mrsas_softc *sc,
112 struct IO_REQUEST_INFO *io_info, RAID_CONTEXT * pRAID_Context,
113 MR_DRV_RAID_MAP_ALL * map);
114extern u_int16_t
115MR_LdSpanArrayGet(u_int32_t ld, u_int32_t span,
116 MR_DRV_RAID_MAP_ALL * map);
99mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
100 union ccb *ccb);
101struct mrsas_mpt_cmd *mrsas_get_mpt_cmd(struct mrsas_softc *sc);
102MRSAS_REQUEST_DESCRIPTOR_UNION *
103 mrsas_get_request_desc(struct mrsas_softc *sc, u_int16_t index);
104
105extern u_int16_t MR_TargetIdToLdGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL * map);
106extern u_int32_t
107MR_LdBlockSizeGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL * map,
108 struct mrsas_softc *sc);
109extern void mrsas_isr(void *arg);
110extern void mrsas_aen_handler(struct mrsas_softc *sc);
111extern u_int8_t
112MR_BuildRaidContext(struct mrsas_softc *sc,
113 struct IO_REQUEST_INFO *io_info, RAID_CONTEXT * pRAID_Context,
114 MR_DRV_RAID_MAP_ALL * map);
115extern u_int16_t
116MR_LdSpanArrayGet(u_int32_t ld, u_int32_t span,
117 MR_DRV_RAID_MAP_ALL * map);
117extern u_int16_t mrsas_get_updated_dev_handle(struct mrsas_softc *sc,
118 PLD_LOAD_BALANCE_INFO lbInfo, struct IO_REQUEST_INFO *io_info);
118extern u_int16_t
119mrsas_get_updated_dev_handle(struct mrsas_softc *sc,
120 PLD_LOAD_BALANCE_INFO lbInfo, struct IO_REQUEST_INFO *io_info);
119extern u_int8_t
120megasas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm,
121 u_int64_t block, u_int32_t count);
122
123
124/*
125 * mrsas_cam_attach: Main entry to CAM subsystem
126 * input: Adapter instance soft state

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

380 /*
381 * Below callout is dummy entry so that it will be cancelled from
382 * mrsas_cmd_done(). Now Controller will go to OCR/Kill Adapter based
383 * on OCR enable/disable property of Controller from ocr_thread
384 * context.
385 */
386#if (__FreeBSD_version >= 1000510)
387 callout_reset_sbt(&cmd->cm_callout, SBT_1S * 600, 0,
121extern u_int8_t
122megasas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm,
123 u_int64_t block, u_int32_t count);
124
125
126/*
127 * mrsas_cam_attach: Main entry to CAM subsystem
128 * input: Adapter instance soft state

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

382 /*
383 * Below callout is dummy entry so that it will be cancelled from
384 * mrsas_cmd_done(). Now Controller will go to OCR/Kill Adapter based
385 * on OCR enable/disable property of Controller from ocr_thread
386 * context.
387 */
388#if (__FreeBSD_version >= 1000510)
389 callout_reset_sbt(&cmd->cm_callout, SBT_1S * 600, 0,
388 mrsas_scsiio_timeout, cmd, 0);
390 mrsas_scsiio_timeout, cmd, 0);
389#else
390 callout_reset(&cmd->cm_callout, (600000 * hz) / 1000,
391#else
392 callout_reset(&cmd->cm_callout, (600000 * hz) / 1000,
391 mrsas_scsiio_timeout, cmd);
393 mrsas_scsiio_timeout, cmd);
392#endif
393 sc->do_timedout_reset = 1;
394 if (sc->ocr_thread_active)
395 wakeup(&sc->ocr_chan);
396}
397
398/*
399 * mrsas_startio: SCSI IO entry point

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

544 req_desc = cmd->request_desc;
545 req_desc->SCSIIO.SMID = cmd->index;
546
547 /*
548 * Start timer for IO timeout. Default timeout value is 90 second.
549 */
550#if (__FreeBSD_version >= 1000510)
551 callout_reset_sbt(&cmd->cm_callout, SBT_1S * 600, 0,
394#endif
395 sc->do_timedout_reset = 1;
396 if (sc->ocr_thread_active)
397 wakeup(&sc->ocr_chan);
398}
399
400/*
401 * mrsas_startio: SCSI IO entry point

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

546 req_desc = cmd->request_desc;
547 req_desc->SCSIIO.SMID = cmd->index;
548
549 /*
550 * Start timer for IO timeout. Default timeout value is 90 second.
551 */
552#if (__FreeBSD_version >= 1000510)
553 callout_reset_sbt(&cmd->cm_callout, SBT_1S * 600, 0,
552 mrsas_scsiio_timeout, cmd, 0);
554 mrsas_scsiio_timeout, cmd, 0);
553#else
554 callout_reset(&cmd->cm_callout, (600000 * hz) / 1000,
555#else
556 callout_reset(&cmd->cm_callout, (600000 * hz) / 1000,
555 mrsas_scsiio_timeout, cmd);
557 mrsas_scsiio_timeout, cmd);
556#endif
557 mrsas_atomic_inc(&sc->fw_outstanding);
558
559 if (mrsas_atomic_read(&sc->fw_outstanding) > sc->io_cmds_highwater)
560 sc->io_cmds_highwater++;
561
562 mrsas_fire_cmd(sc, req_desc->addr.u.low, req_desc->addr.u.high);
563 return (0);

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

569
570/*
571 * mrsas_find_io_type: Determines if IO is read/write or inquiry
572 * input: pointer to CAM Control Block
573 *
574 * This function determines if the IO is read/write or inquiry. It returns a 1
575 * if the IO is read/write and 0 if it is inquiry.
576 */
558#endif
559 mrsas_atomic_inc(&sc->fw_outstanding);
560
561 if (mrsas_atomic_read(&sc->fw_outstanding) > sc->io_cmds_highwater)
562 sc->io_cmds_highwater++;
563
564 mrsas_fire_cmd(sc, req_desc->addr.u.low, req_desc->addr.u.high);
565 return (0);

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

571
572/*
573 * mrsas_find_io_type: Determines if IO is read/write or inquiry
574 * input: pointer to CAM Control Block
575 *
576 * This function determines if the IO is read/write or inquiry. It returns a 1
577 * if the IO is read/write and 0 if it is inquiry.
578 */
577int mrsas_find_io_type(struct cam_sim *sim, union ccb *ccb)
579int
580mrsas_find_io_type(struct cam_sim *sim, union ccb *ccb)
578{
579 struct ccb_scsiio *csio = &(ccb->csio);
580
581 switch (csio->cdb_io.cdb_bytes[0]) {
582 case READ_10:
583 case WRITE_10:
584 case READ_12:
585 case WRITE_12:
586 case READ_6:
587 case WRITE_6:
588 case READ_16:
589 case WRITE_16:
590 return (cam_sim_bus(sim) ?
581{
582 struct ccb_scsiio *csio = &(ccb->csio);
583
584 switch (csio->cdb_io.cdb_bytes[0]) {
585 case READ_10:
586 case WRITE_10:
587 case READ_12:
588 case WRITE_12:
589 case READ_6:
590 case WRITE_6:
591 case READ_16:
592 case WRITE_16:
593 return (cam_sim_bus(sim) ?
591 READ_WRITE_SYSPDIO : READ_WRITE_LDIO);
594 READ_WRITE_SYSPDIO : READ_WRITE_LDIO);
592 default:
593 return (cam_sim_bus(sim) ?
595 default:
596 return (cam_sim_bus(sim) ?
594 NON_READ_WRITE_SYSPDIO : NON_READ_WRITE_LDIO);
597 NON_READ_WRITE_SYSPDIO : NON_READ_WRITE_LDIO);
595 }
596}
597
598/*
599 * mrsas_get_mpt_cmd: Get a cmd from free command pool
600 * input: Adapter instance soft state
601 *
602 * This function removes an MPT command from the command free list and

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

839 io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
840 io_request->RaidContext.regLockFlags |=
841 (MR_RL_FLAGS_GRANT_DESTINATION_CUDA |
842 MR_RL_FLAGS_SEQ_NUM_ENABLE);
843 }
844 if ((sc->load_balance_info[device_id].loadBalanceFlag) &&
845 (io_info.isRead)) {
846 io_info.devHandle =
598 }
599}
600
601/*
602 * mrsas_get_mpt_cmd: Get a cmd from free command pool
603 * input: Adapter instance soft state
604 *
605 * This function removes an MPT command from the command free list and

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

842 io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
843 io_request->RaidContext.regLockFlags |=
844 (MR_RL_FLAGS_GRANT_DESTINATION_CUDA |
845 MR_RL_FLAGS_SEQ_NUM_ENABLE);
846 }
847 if ((sc->load_balance_info[device_id].loadBalanceFlag) &&
848 (io_info.isRead)) {
849 io_info.devHandle =
847 mrsas_get_updated_dev_handle(sc,
848 &sc->load_balance_info[device_id], &io_info);
850 mrsas_get_updated_dev_handle(sc,
851 &sc->load_balance_info[device_id], &io_info);
849 cmd->load_balance = MRSAS_LOAD_BALANCE_FLAG;
850 cmd->pd_r1_lb = io_info.pd_after_lb;
851 } else
852 cmd->load_balance = 0;
853 cmd->request_desc->SCSIIO.DevHandle = io_info.devHandle;
854 io_request->DevHandle = io_info.devHandle;
855 } else {
856 /* Not FP IO */

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

892 u_int32_t device_id;
893 MR_DRV_RAID_MAP_ALL *map_ptr;
894 MRSAS_RAID_SCSI_IO_REQUEST *io_request;
895
896 io_request = cmd->io_request;
897 device_id = ccb_h->target_id;
898 map_ptr = sc->ld_drv_map[(sc->map_id & 1)];
899
852 cmd->load_balance = MRSAS_LOAD_BALANCE_FLAG;
853 cmd->pd_r1_lb = io_info.pd_after_lb;
854 } else
855 cmd->load_balance = 0;
856 cmd->request_desc->SCSIIO.DevHandle = io_info.devHandle;
857 io_request->DevHandle = io_info.devHandle;
858 } else {
859 /* Not FP IO */

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

895 u_int32_t device_id;
896 MR_DRV_RAID_MAP_ALL *map_ptr;
897 MRSAS_RAID_SCSI_IO_REQUEST *io_request;
898
899 io_request = cmd->io_request;
900 device_id = ccb_h->target_id;
901 map_ptr = sc->ld_drv_map[(sc->map_id & 1)];
902
900 /*
901 * Check if this is RW for system PD or
902 * it's a NON RW for sys PD and there is NO secure jbod FW support
903 */
903 /*
904 * Check if this is RW for system PD or
905 * it's a NON RW for sys PD and there is NO secure jbod FW support
906 */
904 if (cam_sim_bus(sim) == 1 &&
907 if (cam_sim_bus(sim) == 1 &&
905 sc->pd_list[device_id].driveState == MR_PD_STATE_SYSTEM){
908 sc->pd_list[device_id].driveState == MR_PD_STATE_SYSTEM) {
906
907 io_request->DevHandle =
909
910 io_request->DevHandle =
908 map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
911 map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
909 io_request->RaidContext.RAIDFlags =
912 io_request->RaidContext.RAIDFlags =
910 MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD <<
911 MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
913 MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD <<
914 MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
912 cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle;
913 cmd->request_desc->SCSIIO.MSIxIndex =
915 cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle;
916 cmd->request_desc->SCSIIO.MSIxIndex =
914 sc->msix_vectors ? smp_processor_id() % sc->msix_vectors : 0;
917 sc->msix_vectors ? smp_processor_id() % sc->msix_vectors : 0;
915
918
916 if(sc->secure_jbod_support && (mrsas_find_io_type(sim, ccb) == NON_READ_WRITE_SYSPDIO)) {
919 if (sc->secure_jbod_support && (mrsas_find_io_type(sim, ccb) == NON_READ_WRITE_SYSPDIO)) {
917 /* system pd firmware path */
920 /* system pd firmware path */
918 io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
921 io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
919 cmd->request_desc->SCSIIO.RequestFlags =
922 cmd->request_desc->SCSIIO.RequestFlags =
920 (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
923 (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
921 } else {
922 /* system pd fast path */
923 io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
924 io_request->RaidContext.timeoutValue = map_ptr->raidMap.fpPdIoTimeoutSec;
925 io_request->RaidContext.regLockFlags = 0;
926 io_request->RaidContext.regLockRowLBA = 0;
927 io_request->RaidContext.regLockLength = 0;
928
929 cmd->request_desc->SCSIIO.RequestFlags =
924 } else {
925 /* system pd fast path */
926 io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
927 io_request->RaidContext.timeoutValue = map_ptr->raidMap.fpPdIoTimeoutSec;
928 io_request->RaidContext.regLockFlags = 0;
929 io_request->RaidContext.regLockRowLBA = 0;
930 io_request->RaidContext.regLockLength = 0;
931
932 cmd->request_desc->SCSIIO.RequestFlags =
930 (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY <<
931 MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
933 (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY <<
934 MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
932
933 /*
934 * NOTE - For system pd RW cmds only IoFlags will be FAST_PATH
935 * Because the NON RW cmds will now go via FW Queue
936 * and not the Exception queue
937 */
938 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY))
939 io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
935
936 /*
937 * NOTE - For system pd RW cmds only IoFlags will be FAST_PATH
938 * Because the NON RW cmds will now go via FW Queue
939 * and not the Exception queue
940 */
941 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY))
942 io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
940 }
943 }
941 } else {
944 } else {
942 /* FW path for SysPD or LD Non-RW (SCSI management commands)*/
943 io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
945 /* FW path for SysPD or LD Non-RW (SCSI management commands) */
946 io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
944 io_request->DevHandle = device_id;
945 cmd->request_desc->SCSIIO.RequestFlags =
947 io_request->DevHandle = device_id;
948 cmd->request_desc->SCSIIO.RequestFlags =
946 (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO <<
947 MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
949 (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO <<
950 MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
948 }
949
950 io_request->RaidContext.VirtualDiskTgtId = device_id;
951 io_request->LUN[1] = ccb_h->target_lun & 0xF;
952 io_request->DataLength = cmd->length;
953
954 if (mrsas_map_request(sc, cmd, ccb) == SUCCESS) {
955 if (cmd->sge_count > sc->max_num_sge) {

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

969 * mrsas_map_request: Map and load data
970 * input: Adapter instance soft state
971 * Pointer to command packet
972 *
973 * For data from OS, map and load the data buffer into bus space. The SG list
974 * is built in the callback. If the bus dmamap load is not successful,
975 * cmd->error_code will contain the error code and a 1 is returned.
976 */
951 }
952
953 io_request->RaidContext.VirtualDiskTgtId = device_id;
954 io_request->LUN[1] = ccb_h->target_lun & 0xF;
955 io_request->DataLength = cmd->length;
956
957 if (mrsas_map_request(sc, cmd, ccb) == SUCCESS) {
958 if (cmd->sge_count > sc->max_num_sge) {

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

972 * mrsas_map_request: Map and load data
973 * input: Adapter instance soft state
974 * Pointer to command packet
975 *
976 * For data from OS, map and load the data buffer into bus space. The SG list
977 * is built in the callback. If the bus dmamap load is not successful,
978 * cmd->error_code will contain the error code and a 1 is returned.
979 */
977int mrsas_map_request(struct mrsas_softc *sc,
978 struct mrsas_mpt_cmd *cmd, union ccb *ccb)
980int
981mrsas_map_request(struct mrsas_softc *sc,
982 struct mrsas_mpt_cmd *cmd, union ccb *ccb)
979{
980 u_int32_t retcode = 0;
981 struct cam_sim *sim;
982
983 sim = xpt_path_sim(cmd->ccb_ptr->ccb_h.path);
984
985 if (cmd->data != NULL) {
986 /* Map data buffer into bus space */
987 mtx_lock(&sc->io_lock);
988#if (__FreeBSD_version >= 902001)
989 retcode = bus_dmamap_load_ccb(sc->data_tag, cmd->data_dmamap, ccb,
983{
984 u_int32_t retcode = 0;
985 struct cam_sim *sim;
986
987 sim = xpt_path_sim(cmd->ccb_ptr->ccb_h.path);
988
989 if (cmd->data != NULL) {
990 /* Map data buffer into bus space */
991 mtx_lock(&sc->io_lock);
992#if (__FreeBSD_version >= 902001)
993 retcode = bus_dmamap_load_ccb(sc->data_tag, cmd->data_dmamap, ccb,
990 mrsas_data_load_cb, cmd, 0);
994 mrsas_data_load_cb, cmd, 0);
991#else
992 retcode = bus_dmamap_load(sc->data_tag, cmd->data_dmamap, cmd->data,
995#else
996 retcode = bus_dmamap_load(sc->data_tag, cmd->data_dmamap, cmd->data,
993 cmd->length, mrsas_data_load_cb, cmd, BUS_DMA_NOWAIT);
997 cmd->length, mrsas_data_load_cb, cmd, BUS_DMA_NOWAIT);
994#endif
995 mtx_unlock(&sc->io_lock);
996 if (retcode)
997 device_printf(sc->mrsas_dev, "bus_dmamap_load(): retcode = %d\n", retcode);
998 if (retcode == EINPROGRESS) {
999 device_printf(sc->mrsas_dev, "request load in progress\n");
1000 mrsas_freeze_simq(cmd, sim);
1001 }

--- 242 unchanged lines hidden ---
998#endif
999 mtx_unlock(&sc->io_lock);
1000 if (retcode)
1001 device_printf(sc->mrsas_dev, "bus_dmamap_load(): retcode = %d\n", retcode);
1002 if (retcode == EINPROGRESS) {
1003 device_printf(sc->mrsas_dev, "request load in progress\n");
1004 mrsas_freeze_simq(cmd, sim);
1005 }

--- 242 unchanged lines hidden ---