No logical code change in this pathc.
Only Style 9 changes for mrsas driver. Reviewed by: ambrisko MFC after: 2 weeks Sponsored by: AVAGO Technologies
This commit is contained in:
parent
5d28b9ed32
commit
8e72737119
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,34 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2014, LSI Corp.
|
||||
* All rights reserved.
|
||||
* Author: Marian Choy
|
||||
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
|
||||
* Support: freebsdraid@lsi.com
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of the <ORGANIZATION> nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* <ORGANIZATION> nor the names of its contributors may be used to endorse or
|
||||
* promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
@ -61,16 +57,18 @@ __FBSDID("$FreeBSD$");
|
||||
* Function prototypes
|
||||
*/
|
||||
int mrsas_cam_attach(struct mrsas_softc *sc);
|
||||
//int mrsas_ldio_inq(union ccb *ccb);
|
||||
int mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb);
|
||||
int mrsas_bus_scan(struct mrsas_softc *sc);
|
||||
int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim);
|
||||
int mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
|
||||
int mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
int
|
||||
mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
union ccb *ccb);
|
||||
int mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
int
|
||||
mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
union ccb *ccb, struct cam_sim *sim);
|
||||
int mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
int
|
||||
mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
union ccb *ccb, u_int32_t device_id,
|
||||
MRSAS_RAID_SCSI_IO_REQUEST * io_request);
|
||||
void mrsas_xpt_freeze(struct mrsas_softc *sc);
|
||||
@ -79,49 +77,59 @@ void mrsas_cam_detach(struct mrsas_softc *sc);
|
||||
void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd);
|
||||
void mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
|
||||
void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
|
||||
void mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo,
|
||||
void
|
||||
mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo,
|
||||
u_int32_t req_desc_hi);
|
||||
void mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST *io_request, u_int8_t cdb_len,
|
||||
struct IO_REQUEST_INFO *io_info, union ccb *ccb,
|
||||
void
|
||||
mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST * io_request,
|
||||
u_int8_t cdb_len, struct IO_REQUEST_INFO *io_info, union ccb *ccb,
|
||||
MR_DRV_RAID_MAP_ALL * local_map_ptr, u_int32_t ref_tag,
|
||||
u_int32_t ld_block_size);
|
||||
static void mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim);
|
||||
static void mrsas_cam_poll(struct cam_sim *sim);
|
||||
static void mrsas_action(struct cam_sim *sim, union ccb *ccb);
|
||||
static void mrsas_scsiio_timeout(void *data);
|
||||
static void mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs,
|
||||
static void
|
||||
mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs,
|
||||
int nseg, int error);
|
||||
static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
static int32_t
|
||||
mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
union ccb *ccb);
|
||||
struct mrsas_mpt_cmd *mrsas_get_mpt_cmd(struct mrsas_softc *sc);
|
||||
MRSAS_REQUEST_DESCRIPTOR_UNION *mrsas_get_request_desc(struct mrsas_softc *sc,
|
||||
u_int16_t index);
|
||||
MRSAS_REQUEST_DESCRIPTOR_UNION *
|
||||
mrsas_get_request_desc(struct mrsas_softc *sc, u_int16_t index);
|
||||
|
||||
extern u_int16_t MR_TargetIdToLdGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL * map);
|
||||
extern u_int32_t MR_LdBlockSizeGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL *map,
|
||||
extern u_int32_t
|
||||
MR_LdBlockSizeGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL * map,
|
||||
struct mrsas_softc *sc);
|
||||
extern void mrsas_isr(void *arg);
|
||||
extern void mrsas_aen_handler(struct mrsas_softc *sc);
|
||||
extern u_int8_t MR_BuildRaidContext(struct mrsas_softc *sc,
|
||||
extern u_int8_t
|
||||
MR_BuildRaidContext(struct mrsas_softc *sc,
|
||||
struct IO_REQUEST_INFO *io_info, RAID_CONTEXT * pRAID_Context,
|
||||
MR_DRV_RAID_MAP_ALL * map);
|
||||
extern u_int16_t MR_LdSpanArrayGet(u_int32_t ld, u_int32_t span,
|
||||
extern u_int16_t
|
||||
MR_LdSpanArrayGet(u_int32_t ld, u_int32_t span,
|
||||
MR_DRV_RAID_MAP_ALL * map);
|
||||
extern u_int16_t mrsas_get_updated_dev_handle(PLD_LOAD_BALANCE_INFO lbInfo,
|
||||
extern u_int16_t
|
||||
mrsas_get_updated_dev_handle(PLD_LOAD_BALANCE_INFO lbInfo,
|
||||
struct IO_REQUEST_INFO *io_info);
|
||||
extern u_int8_t megasas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm,
|
||||
extern u_int8_t
|
||||
megasas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm,
|
||||
u_int64_t block, u_int32_t count);
|
||||
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_cam_attach: Main entry to CAM subsystem
|
||||
* input: Adapter instance soft state
|
||||
*
|
||||
* This function is called from mrsas_attach() during initialization
|
||||
* to perform SIM allocations and XPT bus registration. If the kernel
|
||||
* version is 7.4 or earlier, it would also initiate a bus scan.
|
||||
* This function is called from mrsas_attach() during initialization to perform
|
||||
* SIM allocations and XPT bus registration. If the kernel version is 7.4 or
|
||||
* earlier, it would also initiate a bus scan.
|
||||
*/
|
||||
int mrsas_cam_attach(struct mrsas_softc *sc)
|
||||
int
|
||||
mrsas_cam_attach(struct mrsas_softc *sc)
|
||||
{
|
||||
struct cam_devq *devq;
|
||||
int mrsas_cam_depth;
|
||||
@ -132,8 +140,6 @@ int mrsas_cam_attach(struct mrsas_softc *sc)
|
||||
device_printf(sc->mrsas_dev, "Cannot allocate SIM queue\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create SIM for bus 0 and register, also create path
|
||||
*/
|
||||
@ -154,17 +160,16 @@ int mrsas_cam_attach(struct mrsas_softc *sc)
|
||||
taskqueue_start_threads(&sc->ev_tq, 1, 255, "%s taskq",
|
||||
device_get_nameunit(sc->mrsas_dev));
|
||||
mtx_lock(&sc->sim_lock);
|
||||
if (xpt_bus_register(sc->sim_0, sc->mrsas_dev,0) != CAM_SUCCESS)
|
||||
{
|
||||
cam_sim_free(sc->sim_0, TRUE); // passing true frees the devq
|
||||
if (xpt_bus_register(sc->sim_0, sc->mrsas_dev, 0) != CAM_SUCCESS) {
|
||||
cam_sim_free(sc->sim_0, TRUE); /* passing true frees the devq */
|
||||
mtx_unlock(&sc->sim_lock);
|
||||
return (ENXIO);
|
||||
}
|
||||
if (xpt_create_path(&sc->path_0, NULL, cam_sim_path(sc->sim_0),
|
||||
CAM_TARGET_WILDCARD,
|
||||
CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
|
||||
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
|
||||
xpt_bus_deregister(cam_sim_path(sc->sim_0));
|
||||
cam_sim_free(sc->sim_0, TRUE); // passing true will free the devq
|
||||
cam_sim_free(sc->sim_0, TRUE); /* passing true will free the
|
||||
* devq */
|
||||
mtx_unlock(&sc->sim_lock);
|
||||
return (ENXIO);
|
||||
}
|
||||
@ -181,10 +186,9 @@ int mrsas_cam_attach(struct mrsas_softc *sc)
|
||||
device_printf(sc->mrsas_dev, "Cannot register SIM\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
mtx_lock(&sc->sim_lock);
|
||||
if (xpt_bus_register(sc->sim_1, sc->mrsas_dev, 1) != CAM_SUCCESS) {
|
||||
cam_sim_free(sc->sim_1, TRUE); // passing true frees the devq
|
||||
cam_sim_free(sc->sim_1, TRUE); /* passing true frees the devq */
|
||||
mtx_unlock(&sc->sim_lock);
|
||||
return (ENXIO);
|
||||
}
|
||||
@ -207,13 +211,14 @@ int mrsas_cam_attach(struct mrsas_softc *sc)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_cam_detach: De-allocates and teardown CAM
|
||||
* input: Adapter instance soft state
|
||||
*
|
||||
* De-registers and frees the paths and SIMs.
|
||||
*/
|
||||
void mrsas_cam_detach(struct mrsas_softc *sc)
|
||||
void
|
||||
mrsas_cam_detach(struct mrsas_softc *sc)
|
||||
{
|
||||
if (sc->ev_tq != NULL)
|
||||
taskqueue_free(sc->ev_tq);
|
||||
@ -233,17 +238,16 @@ void mrsas_cam_detach(struct mrsas_softc *sc)
|
||||
mtx_unlock(&sc->sim_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_action: SIM callback entry point
|
||||
* input: pointer to SIM
|
||||
* pointer to CAM Control Block
|
||||
* input: pointer to SIM pointer to CAM Control Block
|
||||
*
|
||||
* This function processes CAM subsystem requests. The type of request is
|
||||
* stored in ccb->ccb_h.func_code. The preprocessor #ifdef is necessary
|
||||
* because ccb->cpi.maxio is not supported for FreeBSD version 7.4 or
|
||||
* earlier.
|
||||
* This function processes CAM subsystem requests. The type of request is stored
|
||||
* in ccb->ccb_h.func_code. The preprocessor #ifdef is necessary because
|
||||
* ccb->cpi.maxio is not supported for FreeBSD version 7.4 or earlier.
|
||||
*/
|
||||
static void mrsas_action(struct cam_sim *sim, union ccb *ccb)
|
||||
static void
|
||||
mrsas_action(struct cam_sim *sim, union ccb *ccb)
|
||||
{
|
||||
struct mrsas_softc *sc = (struct mrsas_softc *)cam_sim_softc(sim);
|
||||
struct ccb_hdr *ccb_h = &(ccb->ccb_h);
|
||||
@ -261,8 +265,7 @@ static void mrsas_action(struct cam_sim *sim, union ccb *ccb)
|
||||
sc->pd_list[device_id].driveState != MR_PD_STATE_SYSTEM) {
|
||||
ccb->ccb_h.status |= CAM_DEV_NOT_THERE;
|
||||
xpt_done(ccb);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (mrsas_startio(sc, sim, ccb)) {
|
||||
ccb->ccb_h.status |= CAM_REQ_INVALID;
|
||||
xpt_done(ccb);
|
||||
@ -346,16 +349,15 @@ static void mrsas_action(struct cam_sim *sim, union ccb *ccb)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* mrsas_scsiio_timeout Callback function for IO timed out
|
||||
/*
|
||||
* mrsas_scsiio_timeout: Callback function for IO timed out
|
||||
* input: mpt command context
|
||||
*
|
||||
* This function will execute after timeout value
|
||||
* provided by ccb header from CAM layer, if timer expires.
|
||||
* Driver will run timer for all DCDM and LDIO comming from CAM layer.
|
||||
* This function is callback function for IO timeout and it runs in
|
||||
* no-sleep context. Set do_timedout_reset in Adapter context so that
|
||||
* it will execute OCR/Kill adpter from ocr_thread context.
|
||||
* This function will execute after timeout value provided by ccb header from
|
||||
* CAM layer, if timer expires. Driver will run timer for all DCDM and LDIO
|
||||
* comming from CAM layer. This function is callback function for IO timeout
|
||||
* and it runs in no-sleep context. Set do_timedout_reset in Adapter context
|
||||
* so that it will execute OCR/Kill adpter from ocr_thread context.
|
||||
*/
|
||||
static void
|
||||
mrsas_scsiio_timeout(void *data)
|
||||
@ -370,11 +372,11 @@ mrsas_scsiio_timeout(void *data)
|
||||
printf("command timeout with NULL ccb\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Below callout is dummy entry so that it will be
|
||||
* cancelled from mrsas_cmd_done(). Now Controller will
|
||||
* go to OCR/Kill Adapter based on OCR enable/disable
|
||||
* property of Controller from ocr_thread context.
|
||||
/*
|
||||
* Below callout is dummy entry so that it will be cancelled from
|
||||
* mrsas_cmd_done(). Now Controller will go to OCR/Kill Adapter based
|
||||
* on OCR enable/disable property of Controller from ocr_thread
|
||||
* context.
|
||||
*/
|
||||
callout_reset(&cmd->cm_callout, (600000 * hz) / 1000,
|
||||
mrsas_scsiio_timeout, cmd);
|
||||
@ -383,17 +385,18 @@ mrsas_scsiio_timeout(void *data)
|
||||
wakeup(&sc->ocr_chan);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_startio: SCSI IO entry point
|
||||
* input: Adapter instance soft state
|
||||
* pointer to CAM Control Block
|
||||
*
|
||||
* This function is the SCSI IO entry point and it initiates IO processing.
|
||||
* It copies the IO and depending if the IO is read/write or inquiry, it would
|
||||
* call mrsas_build_ldio() or mrsas_build_dcdb(), respectively. It returns
|
||||
* 0 if the command is sent to firmware successfully, otherwise it returns 1.
|
||||
* This function is the SCSI IO entry point and it initiates IO processing. It
|
||||
* copies the IO and depending if the IO is read/write or inquiry, it would
|
||||
* call mrsas_build_ldio() or mrsas_build_dcdb(), respectively. It returns 0
|
||||
* if the command is sent to firmware successfully, otherwise it returns 1.
|
||||
*/
|
||||
static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
static int32_t
|
||||
mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
union ccb *ccb)
|
||||
{
|
||||
struct mrsas_mpt_cmd *cmd;
|
||||
@ -406,7 +409,6 @@ static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
xpt_done(ccb);
|
||||
return (0);
|
||||
}
|
||||
|
||||
ccb_h->status |= CAM_SIM_QUEUED;
|
||||
cmd = mrsas_get_mpt_cmd(sc);
|
||||
|
||||
@ -415,32 +417,30 @@ static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
xpt_done(ccb);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if ((ccb_h->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
|
||||
if (ccb_h->flags & CAM_DIR_IN)
|
||||
cmd->flags |= MRSAS_DIR_IN;
|
||||
if (ccb_h->flags & CAM_DIR_OUT)
|
||||
cmd->flags |= MRSAS_DIR_OUT;
|
||||
}
|
||||
else
|
||||
} else
|
||||
cmd->flags = MRSAS_DIR_NONE; /* no data */
|
||||
|
||||
/* For FreeBSD 10.0 and higher */
|
||||
#if (__FreeBSD_version >= 1000000)
|
||||
/*
|
||||
* * XXX We don't yet support physical addresses here.
|
||||
* XXX We don't yet support physical addresses here.
|
||||
*/
|
||||
switch ((ccb->ccb_h.flags & CAM_DATA_MASK)) {
|
||||
case CAM_DATA_PADDR:
|
||||
case CAM_DATA_SG_PADDR:
|
||||
printf("%s: physical addresses not supported\n",
|
||||
device_printf(sc->mrsas_dev, "%s: physical addresses not supported\n",
|
||||
__func__);
|
||||
mrsas_release_mpt_cmd(cmd);
|
||||
ccb_h->status = CAM_REQ_INVALID;
|
||||
ccb_h->status &= ~CAM_SIM_QUEUED;
|
||||
goto done;
|
||||
case CAM_DATA_SG:
|
||||
printf("%s: scatter gather is not supported\n",
|
||||
device_printf(sc->mrsas_dev, "%s: scatter gather is not supported\n",
|
||||
__func__);
|
||||
mrsas_release_mpt_cmd(cmd);
|
||||
ccb_h->status = CAM_REQ_INVALID;
|
||||
@ -460,7 +460,7 @@ static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
goto done;
|
||||
}
|
||||
#else
|
||||
if (!(ccb_h->flags & CAM_DATA_PHYS)) { //Virtual data address
|
||||
if (!(ccb_h->flags & CAM_DATA_PHYS)) { /* Virtual data address */
|
||||
if (!(ccb_h->flags & CAM_SCATTER_VALID)) {
|
||||
if (csio->dxfer_len > MRSAS_MAX_IO_SIZE) {
|
||||
mrsas_release_mpt_cmd(cmd);
|
||||
@ -470,14 +470,12 @@ static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
cmd->length = csio->dxfer_len;
|
||||
if (cmd->length)
|
||||
cmd->data = csio->data_ptr;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mrsas_release_mpt_cmd(cmd);
|
||||
ccb_h->status = CAM_REQ_INVALID;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else { //Data addresses are physical.
|
||||
} else { /* Data addresses are physical. */
|
||||
mrsas_release_mpt_cmd(cmd);
|
||||
ccb_h->status = CAM_REQ_INVALID;
|
||||
ccb_h->status &= ~CAM_SIM_QUEUED;
|
||||
@ -507,8 +505,7 @@ static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
mtx_unlock(&sc->raidmap_lock);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (mrsas_build_dcdb(sc, cmd, ccb, sim)) {
|
||||
device_printf(sc->mrsas_dev, "Build DCDB failed.\n");
|
||||
mtx_unlock(&sc->raidmap_lock);
|
||||
@ -517,9 +514,9 @@ static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
|
||||
}
|
||||
mtx_unlock(&sc->raidmap_lock);
|
||||
|
||||
if (cmd->flags == MRSAS_DIR_IN) //from device
|
||||
if (cmd->flags == MRSAS_DIR_IN) /* from device */
|
||||
cmd->io_request->Control |= MPI2_SCSIIO_CONTROL_READ;
|
||||
else if (cmd->flags == MRSAS_DIR_OUT) //to device
|
||||
else if (cmd->flags == MRSAS_DIR_OUT) /* to device */
|
||||
cmd->io_request->Control |= MPI2_SCSIIO_CONTROL_WRITE;
|
||||
|
||||
cmd->io_request->SGLFlags = MPI2_SGE_FLAGS_64_BIT_ADDRESSING;
|
||||
@ -548,14 +545,15 @@ done:
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_ldio_inq: Determines if IO is read/write or inquiry
|
||||
* input: pointer to CAM Control Block
|
||||
*
|
||||
* This function determines if the IO is read/write or inquiry. It returns a
|
||||
* 1 if the IO is read/write and 0 if it is inquiry.
|
||||
* This function determines if the IO is read/write or inquiry. It returns a 1
|
||||
* if the IO is read/write and 0 if it is inquiry.
|
||||
*/
|
||||
int mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb)
|
||||
int
|
||||
mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb)
|
||||
{
|
||||
struct ccb_scsiio *csio = &(ccb->csio);
|
||||
|
||||
@ -577,14 +575,15 @@ int mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_get_mpt_cmd: Get a cmd from free command pool
|
||||
* input: Adapter instance soft state
|
||||
*
|
||||
* This function removes an MPT command from the command free list and
|
||||
* initializes it.
|
||||
*/
|
||||
struct mrsas_mpt_cmd* mrsas_get_mpt_cmd(struct mrsas_softc *sc)
|
||||
struct mrsas_mpt_cmd *
|
||||
mrsas_get_mpt_cmd(struct mrsas_softc *sc)
|
||||
{
|
||||
struct mrsas_mpt_cmd *cmd = NULL;
|
||||
|
||||
@ -605,13 +604,14 @@ struct mrsas_mpt_cmd* mrsas_get_mpt_cmd(struct mrsas_softc *sc)
|
||||
return cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_release_mpt_cmd: Return a cmd to free command pool
|
||||
* input: Command packet for return to free command pool
|
||||
*
|
||||
* This function returns an MPT command to the free command list.
|
||||
*/
|
||||
void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd)
|
||||
void
|
||||
mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd)
|
||||
{
|
||||
struct mrsas_softc *sc = cmd->sc;
|
||||
|
||||
@ -623,7 +623,7 @@ void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd)
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_get_request_desc: Get request descriptor from array
|
||||
* input: Adapter instance soft state
|
||||
* SMID index
|
||||
@ -644,16 +644,17 @@ mrsas_get_request_desc(struct mrsas_softc *sc, u_int16_t index)
|
||||
return (MRSAS_REQUEST_DESCRIPTOR_UNION *) p;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_build_ldio: Builds an LDIO command
|
||||
* input: Adapter instance soft state
|
||||
* Pointer to command packet
|
||||
* Pointer to CCB
|
||||
*
|
||||
* This function builds the LDIO command packet. It returns 0 if the
|
||||
* command is built successfully, otherwise it returns a 1.
|
||||
* This function builds the LDIO command packet. It returns 0 if the command is
|
||||
* built successfully, otherwise it returns a 1.
|
||||
*/
|
||||
int mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
int
|
||||
mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
union ccb *ccb)
|
||||
{
|
||||
struct ccb_hdr *ccb_h = &(ccb->ccb_h);
|
||||
@ -683,24 +684,24 @@ int mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
return (FAIL);
|
||||
}
|
||||
io_request->RaidContext.numSGE = cmd->sge_count;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
device_printf(sc->mrsas_dev, "Data map/load failed.\n");
|
||||
return (FAIL);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_setup_io: Set up data including Fast Path I/O
|
||||
* input: Adapter instance soft state
|
||||
* Pointer to command packet
|
||||
* Pointer to CCB
|
||||
*
|
||||
* This function builds the DCDB inquiry command. It returns 0 if the
|
||||
* command is built successfully, otherwise it returns a 1.
|
||||
* This function builds the DCDB inquiry command. It returns 0 if the command
|
||||
* is built successfully, otherwise it returns a 1.
|
||||
*/
|
||||
int mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
int
|
||||
mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
union ccb *ccb, u_int32_t device_id,
|
||||
MRSAS_RAID_SCSI_IO_REQUEST * io_request)
|
||||
{
|
||||
@ -767,7 +768,6 @@ int mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
(u_int32_t)csio->cdb_io.cdb_bytes[4] << 8 |
|
||||
((u_int32_t)csio->cdb_io.cdb_bytes[5]);
|
||||
}
|
||||
|
||||
memset(&io_info, 0, sizeof(struct IO_REQUEST_INFO));
|
||||
io_info.ldStartBlock = ((u_int64_t)start_lba_hi << 32) | start_lba_lo;
|
||||
io_info.numBlocks = datalength;
|
||||
@ -793,9 +793,7 @@ int mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
(!sc->fast_path_io)) {
|
||||
io_request->RaidContext.regLockFlags = 0;
|
||||
fp_possible = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (MR_BuildRaidContext(sc, &io_info, &io_request->RaidContext, map_ptr))
|
||||
fp_possible = io_info.fpOkForIo;
|
||||
}
|
||||
@ -809,36 +807,45 @@ int mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
start_lba_lo, ld_block_size);
|
||||
io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
|
||||
cmd->request_desc->SCSIIO.RequestFlags =
|
||||
(MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY
|
||||
<< MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
(MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY <<
|
||||
MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
|
||||
if (io_request->RaidContext.regLockFlags == REGION_TYPE_UNUSED)
|
||||
cmd->request_desc->SCSIIO.RequestFlags = (MRSAS_REQ_DESCRIPT_FLAGS_NO_LOCK << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
cmd->request_desc->SCSIIO.RequestFlags =
|
||||
(MRSAS_REQ_DESCRIPT_FLAGS_NO_LOCK <<
|
||||
MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
io_request->RaidContext.Type = MPI2_TYPE_CUDA;
|
||||
io_request->RaidContext.nseg = 0x1;
|
||||
io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
|
||||
io_request->RaidContext.regLockFlags |= (MR_RL_FLAGS_GRANT_DESTINATION_CUDA | MR_RL_FLAGS_SEQ_NUM_ENABLE);
|
||||
io_request->RaidContext.regLockFlags |=
|
||||
(MR_RL_FLAGS_GRANT_DESTINATION_CUDA |
|
||||
MR_RL_FLAGS_SEQ_NUM_ENABLE);
|
||||
}
|
||||
if ((sc->load_balance_info[device_id].loadBalanceFlag) && (io_info.isRead)) {
|
||||
io_info.devHandle = mrsas_get_updated_dev_handle(&sc->load_balance_info[device_id],
|
||||
if ((sc->load_balance_info[device_id].loadBalanceFlag) &&
|
||||
(io_info.isRead)) {
|
||||
io_info.devHandle =
|
||||
mrsas_get_updated_dev_handle(&sc->load_balance_info[device_id],
|
||||
&io_info);
|
||||
cmd->load_balance = MRSAS_LOAD_BALANCE_FLAG;
|
||||
}
|
||||
else
|
||||
} else
|
||||
cmd->load_balance = 0;
|
||||
cmd->request_desc->SCSIIO.DevHandle = io_info.devHandle;
|
||||
io_request->DevHandle = io_info.devHandle;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Not FP IO */
|
||||
io_request->RaidContext.timeoutValue = map_ptr->raidMap.fpPdIoTimeoutSec;
|
||||
cmd->request_desc->SCSIIO.RequestFlags =
|
||||
(MRSAS_REQ_DESCRIPT_FLAGS_LD_IO << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
(MRSAS_REQ_DESCRIPT_FLAGS_LD_IO <<
|
||||
MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
|
||||
if (io_request->RaidContext.regLockFlags == REGION_TYPE_UNUSED)
|
||||
cmd->request_desc->SCSIIO.RequestFlags = (MRSAS_REQ_DESCRIPT_FLAGS_NO_LOCK << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
cmd->request_desc->SCSIIO.RequestFlags =
|
||||
(MRSAS_REQ_DESCRIPT_FLAGS_NO_LOCK <<
|
||||
MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
io_request->RaidContext.Type = MPI2_TYPE_CUDA;
|
||||
io_request->RaidContext.regLockFlags |= (MR_RL_FLAGS_GRANT_DESTINATION_CPU0 | MR_RL_FLAGS_SEQ_NUM_ENABLE);
|
||||
io_request->RaidContext.regLockFlags |=
|
||||
(MR_RL_FLAGS_GRANT_DESTINATION_CPU0 |
|
||||
MR_RL_FLAGS_SEQ_NUM_ENABLE);
|
||||
io_request->RaidContext.nseg = 0x1;
|
||||
}
|
||||
io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
|
||||
@ -847,16 +854,17 @@ int mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_build_dcdb: Builds an DCDB command
|
||||
* input: Adapter instance soft state
|
||||
* Pointer to command packet
|
||||
* Pointer to CCB
|
||||
*
|
||||
* This function builds the DCDB inquiry command. It returns 0 if the
|
||||
* command is built successfully, otherwise it returns a 1.
|
||||
* This function builds the DCDB inquiry command. It returns 0 if the command
|
||||
* is built successfully, otherwise it returns a 1.
|
||||
*/
|
||||
int mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
int
|
||||
mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
union ccb *ccb, struct cam_sim *sim)
|
||||
{
|
||||
struct ccb_hdr *ccb_h = &(ccb->ccb_h);
|
||||
@ -872,18 +880,15 @@ int mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
if (cam_sim_bus(sim) == 1 &&
|
||||
sc->pd_list[device_id].driveState == MR_PD_STATE_SYSTEM) {
|
||||
io_request->Function = 0;
|
||||
io_request->DevHandle = map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
|
||||
io_request->DevHandle = map_ptr->raidMap.devHndlInfo[device_id].
|
||||
curDevHdl;
|
||||
io_request->RaidContext.timeoutValue = map_ptr->raidMap.fpPdIoTimeoutSec;
|
||||
io_request->RaidContext.regLockFlags = 0;
|
||||
io_request->RaidContext.regLockRowLBA = 0;
|
||||
io_request->RaidContext.regLockLength = 0;
|
||||
|
||||
// LSI TEST
|
||||
//printf("LSI Debug bus %d device_id %d map_ptr->raidMap.devHndlInfo[device_id].curDevHdl %d \n",
|
||||
// cam_sim_bus(sim), device_id, map_ptr->raidMap.devHndlInfo[device_id].curDevHdl);
|
||||
|
||||
io_request->RaidContext.RAIDFlags = MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD <<
|
||||
MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
|
||||
io_request->RaidContext.RAIDFlags = MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD
|
||||
<< MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
|
||||
if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY))
|
||||
io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
|
||||
cmd->request_desc->SCSIIO.RequestFlags =
|
||||
@ -894,12 +899,12 @@ int mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
cmd->request_desc->SCSIIO.MSIxIndex =
|
||||
sc->msix_vectors ? smp_processor_id() % sc->msix_vectors : 0;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
|
||||
io_request->DevHandle = device_id;
|
||||
cmd->request_desc->SCSIIO.RequestFlags =
|
||||
(MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
(MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO <<
|
||||
MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
||||
}
|
||||
|
||||
io_request->RaidContext.VirtualDiskTgtId = device_id;
|
||||
@ -913,25 +918,24 @@ int mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
|
||||
return (1);
|
||||
}
|
||||
io_request->RaidContext.numSGE = cmd->sge_count;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
device_printf(sc->mrsas_dev, "Data map/load failed.\n");
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_map_request: Map and load data
|
||||
* input: Adapter instance soft state
|
||||
* Pointer to command packet
|
||||
*
|
||||
* For data from OS, map and load the data buffer into bus space. The
|
||||
* SG list is built in the callback. If the bus dmamap load is not
|
||||
* successful, cmd->error_code will contain the error code and a 1 is
|
||||
* returned.
|
||||
* For data from OS, map and load the data buffer into bus space. The SG list
|
||||
* is built in the callback. If the bus dmamap load is not successful,
|
||||
* cmd->error_code will contain the error code and a 1 is returned.
|
||||
*/
|
||||
int mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
int
|
||||
mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
{
|
||||
u_int32_t retcode = 0;
|
||||
struct cam_sim *sim;
|
||||
@ -957,14 +961,15 @@ int mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
return (retcode);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_unmap_request: Unmap and unload data
|
||||
* input: Adapter instance soft state
|
||||
* Pointer to command packet
|
||||
*
|
||||
* This function unmaps and unloads data from OS.
|
||||
*/
|
||||
void mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
void
|
||||
mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
{
|
||||
if (cmd->data != NULL) {
|
||||
if (cmd->flags & MRSAS_DIR_IN)
|
||||
@ -977,15 +982,14 @@ void mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_data_load_cb: Callback entry point
|
||||
* input: Pointer to command packet as argument
|
||||
* Pointer to segment
|
||||
* Number of segments
|
||||
* Error
|
||||
* Number of segments Error
|
||||
*
|
||||
* This is the callback function of the bus dma map load. It builds
|
||||
* the SG list.
|
||||
* This is the callback function of the bus dma map load. It builds the SG
|
||||
* list.
|
||||
*/
|
||||
static void
|
||||
mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
||||
@ -996,8 +1000,7 @@ mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
||||
pMpi25IeeeSgeChain64_t sgl_ptr;
|
||||
int i = 0, sg_processed = 0;
|
||||
|
||||
if (error)
|
||||
{
|
||||
if (error) {
|
||||
cmd->error_code = error;
|
||||
device_printf(sc->mrsas_dev, "mrsas_data_load_cb: error=%d\n", error);
|
||||
if (error == EFBIG) {
|
||||
@ -1005,7 +1008,6 @@ mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd->flags & MRSAS_DIR_IN)
|
||||
bus_dmamap_sync(cmd->sc->data_tag, cmd->data_dmamap,
|
||||
BUS_DMASYNC_PREREAD);
|
||||
@ -1016,16 +1018,15 @@ mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
||||
device_printf(sc->mrsas_dev, "SGE count is too large or 0.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
io_request = cmd->io_request;
|
||||
sgl_ptr = (pMpi25IeeeSgeChain64_t)&io_request->SGL;
|
||||
|
||||
if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
|
||||
pMpi25IeeeSgeChain64_t sgl_ptr_end = sgl_ptr;
|
||||
|
||||
sgl_ptr_end += sc->max_sge_in_main_msg - 1;
|
||||
sgl_ptr_end->Flags = 0;
|
||||
}
|
||||
|
||||
if (nseg != 0) {
|
||||
for (i = 0; i < nseg; i++) {
|
||||
sgl_ptr->Address = segs[i].ds_addr;
|
||||
@ -1037,12 +1038,10 @@ mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
||||
}
|
||||
sgl_ptr++;
|
||||
sg_processed = i + 1;
|
||||
/*
|
||||
* Prepare chain element
|
||||
*/
|
||||
if ((sg_processed == (sc->max_sge_in_main_msg - 1)) &&
|
||||
(nseg > sc->max_sge_in_main_msg)) {
|
||||
pMpi25IeeeSgeChain64_t sg_chain;
|
||||
|
||||
if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
|
||||
if ((cmd->io_request->IoFlags & MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
|
||||
!= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
|
||||
@ -1065,14 +1064,15 @@ mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
||||
cmd->sge_count = nseg;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_freeze_simq: Freeze SIM queue
|
||||
* input: Pointer to command packet
|
||||
* Pointer to SIM
|
||||
*
|
||||
* This function freezes the sim queue.
|
||||
*/
|
||||
static void mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim)
|
||||
static void
|
||||
mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim)
|
||||
{
|
||||
union ccb *ccb = (union ccb *)(cmd->ccb_ptr);
|
||||
|
||||
@ -1081,24 +1081,28 @@ static void mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim)
|
||||
ccb->ccb_h.status |= CAM_REQUEUE_REQ;
|
||||
}
|
||||
|
||||
void mrsas_xpt_freeze(struct mrsas_softc *sc) {
|
||||
void
|
||||
mrsas_xpt_freeze(struct mrsas_softc *sc)
|
||||
{
|
||||
xpt_freeze_simq(sc->sim_0, 1);
|
||||
xpt_freeze_simq(sc->sim_1, 1);
|
||||
}
|
||||
|
||||
void mrsas_xpt_release(struct mrsas_softc *sc) {
|
||||
void
|
||||
mrsas_xpt_release(struct mrsas_softc *sc)
|
||||
{
|
||||
xpt_release_simq(sc->sim_0, 1);
|
||||
xpt_release_simq(sc->sim_1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_cmd_done: Perform remaining command completion
|
||||
* input: Adapter instance soft state
|
||||
* Pointer to command packet
|
||||
* input: Adapter instance soft state Pointer to command packet
|
||||
*
|
||||
* This function calls ummap request and releases the MPT command.
|
||||
*/
|
||||
void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
void
|
||||
mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
{
|
||||
callout_stop(&cmd->cm_callout);
|
||||
mrsas_unmap_request(sc, cmd);
|
||||
@ -1109,15 +1113,17 @@ void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
|
||||
mrsas_release_mpt_cmd(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_cam_poll: Polling entry point
|
||||
* input: Pointer to SIM
|
||||
*
|
||||
* This is currently a stub function.
|
||||
*/
|
||||
static void mrsas_cam_poll(struct cam_sim *sim)
|
||||
static void
|
||||
mrsas_cam_poll(struct cam_sim *sim)
|
||||
{
|
||||
struct mrsas_softc *sc = (struct mrsas_softc *)cam_sim_softc(sim);
|
||||
|
||||
mrsas_isr((void *)sc);
|
||||
}
|
||||
|
||||
@ -1125,11 +1131,12 @@ static void mrsas_cam_poll(struct cam_sim *sim)
|
||||
* mrsas_bus_scan: Perform bus scan
|
||||
* input: Adapter instance soft state
|
||||
*
|
||||
* This mrsas_bus_scan function is needed for FreeBSD 7.x. Also, it should
|
||||
* not be called in FreeBSD 8.x and later versions, where the bus scan is
|
||||
* This mrsas_bus_scan function is needed for FreeBSD 7.x. Also, it should not
|
||||
* be called in FreeBSD 8.x and later versions, where the bus scan is
|
||||
* automatic.
|
||||
*/
|
||||
int mrsas_bus_scan(struct mrsas_softc *sc)
|
||||
int
|
||||
mrsas_bus_scan(struct mrsas_softc *sc)
|
||||
{
|
||||
union ccb *ccb_0;
|
||||
union ccb *ccb_1;
|
||||
@ -1137,12 +1144,10 @@ int mrsas_bus_scan(struct mrsas_softc *sc)
|
||||
if ((ccb_0 = xpt_alloc_ccb()) == NULL) {
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
if ((ccb_1 = xpt_alloc_ccb()) == NULL) {
|
||||
xpt_free_ccb(ccb_0);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
mtx_lock(&sc->sim_lock);
|
||||
if (xpt_create_path(&ccb_0->ccb_h.path, xpt_periph, cam_sim_path(sc->sim_0),
|
||||
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
|
||||
@ -1151,7 +1156,6 @@ int mrsas_bus_scan(struct mrsas_softc *sc)
|
||||
mtx_unlock(&sc->sim_lock);
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
if (xpt_create_path(&ccb_1->ccb_h.path, xpt_periph, cam_sim_path(sc->sim_1),
|
||||
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
|
||||
xpt_free_ccb(ccb_0);
|
||||
@ -1159,7 +1163,6 @@ int mrsas_bus_scan(struct mrsas_softc *sc)
|
||||
mtx_unlock(&sc->sim_lock);
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
mtx_unlock(&sc->sim_lock);
|
||||
xpt_rescan(ccb_0);
|
||||
xpt_rescan(ccb_1);
|
||||
@ -1169,11 +1172,13 @@ int mrsas_bus_scan(struct mrsas_softc *sc)
|
||||
|
||||
/*
|
||||
* mrsas_bus_scan_sim: Perform bus scan per SIM
|
||||
* input: Adapter instance soft state
|
||||
* This function will be called from Event handler
|
||||
* on LD creation/deletion, JBOD on/off.
|
||||
* input: adapter instance soft state
|
||||
*
|
||||
* This function will be called from Event handler on LD creation/deletion,
|
||||
* JBOD on/off.
|
||||
*/
|
||||
int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim)
|
||||
int
|
||||
mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim)
|
||||
{
|
||||
union ccb *ccb;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,43 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2014, LSI Corp.
|
||||
* All rights reserved.
|
||||
* Author: Marian Choy
|
||||
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
|
||||
* Support: freebsdraid@lsi.com
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of the <ORGANIZATION> nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* <ORGANIZATION> nor the names of its contributors may be used to endorse or
|
||||
* promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation
|
||||
* are those of the authors and should not be interpreted as representing
|
||||
* The views and conclusions contained in the software and documentation are
|
||||
* those of the authors and should not be interpreted as representing
|
||||
* official policies,either expressed or implied, of the FreeBSD Project.
|
||||
*
|
||||
* Send feedback to: <megaraidfbsd@lsi.com>
|
||||
* Mail to: LSI Corporation, 1621 Barber Lane, Milpitas, CA 95035
|
||||
* ATTN: MegaRaid FreeBSD
|
||||
* Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
|
||||
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
|
||||
*
|
||||
*/
|
||||
|
||||
@ -56,34 +51,38 @@ void mrsas_free_ioc_cmd(struct mrsas_softc *sc);
|
||||
void mrsas_free_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd);
|
||||
void *mrsas_alloc_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd);
|
||||
static int mrsas_create_frame_pool(struct mrsas_softc *sc);
|
||||
static void mrsas_alloc_cb(void *arg, bus_dma_segment_t *segs,
|
||||
static void
|
||||
mrsas_alloc_cb(void *arg, bus_dma_segment_t *segs,
|
||||
int nsegs, int error);
|
||||
|
||||
extern struct mrsas_mfi_cmd *mrsas_get_mfi_cmd(struct mrsas_softc *sc);
|
||||
extern void mrsas_release_mfi_cmd(struct mrsas_mfi_cmd *cmd);
|
||||
extern int mrsas_issue_blocked_cmd(struct mrsas_softc *sc,
|
||||
extern int
|
||||
mrsas_issue_blocked_cmd(struct mrsas_softc *sc,
|
||||
struct mrsas_mfi_cmd *cmd);
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_passthru: Handle pass-through commands
|
||||
* input: Adapter instance soft state
|
||||
* argument pointer
|
||||
* input: Adapter instance soft state argument pointer
|
||||
*
|
||||
* This function is called from mrsas_ioctl() to handle pass-through and
|
||||
* ioctl commands to Firmware.
|
||||
* This function is called from mrsas_ioctl() to handle pass-through and ioctl
|
||||
* commands to Firmware.
|
||||
*/
|
||||
int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
int
|
||||
mrsas_passthru(struct mrsas_softc *sc, void *arg, u_long ioctlCmd)
|
||||
{
|
||||
struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg;
|
||||
|
||||
#ifdef COMPAT_FREEBSD32
|
||||
struct mrsas_iocpacket32 *user_ioc32 = (struct mrsas_iocpacket32 *)arg;
|
||||
|
||||
#endif
|
||||
union mrsas_frame *in_cmd = (union mrsas_frame *)&(user_ioc->frame.raw);
|
||||
struct mrsas_mfi_cmd *cmd = NULL;
|
||||
bus_dma_tag_t ioctl_data_tag[MAX_IOCTL_SGE];
|
||||
bus_dmamap_t ioctl_data_dmamap[MAX_IOCTL_SGE];
|
||||
void *ioctl_data_mem[MAX_IOCTL_SGE]; // ioctl data virtual addr
|
||||
bus_addr_t ioctl_data_phys_addr[MAX_IOCTL_SGE]; // ioctl data phys addr
|
||||
void *ioctl_data_mem[MAX_IOCTL_SGE];
|
||||
bus_addr_t ioctl_data_phys_addr[MAX_IOCTL_SGE];
|
||||
bus_dma_tag_t ioctl_sense_tag = 0;
|
||||
bus_dmamap_t ioctl_sense_dmamap = 0;
|
||||
void *ioctl_sense_mem = 0;
|
||||
@ -95,34 +94,31 @@ int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
size_t iov_len = 0;
|
||||
|
||||
/*
|
||||
* Check for NOP from MegaCli... MegaCli can issue a DCMD of 0. In this
|
||||
* case do nothing and return 0 to it as status.
|
||||
* Check for NOP from MegaCli... MegaCli can issue a DCMD of 0. In
|
||||
* this case do nothing and return 0 to it as status.
|
||||
*/
|
||||
if (in_cmd->dcmd.opcode == 0) {
|
||||
device_printf(sc->mrsas_dev, "In %s() Got a NOP\n", __func__);
|
||||
user_ioc->frame.hdr.cmd_status = MFI_STAT_OK;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Validate SGL length */
|
||||
if (user_ioc->sge_count > MAX_IOCTL_SGE) {
|
||||
device_printf(sc->mrsas_dev, "In %s() SGL is too long (%d > 8).\n",
|
||||
__func__, user_ioc->sge_count);
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
/* Get a command */
|
||||
cmd = mrsas_get_mfi_cmd(sc);
|
||||
if (!cmd) {
|
||||
device_printf(sc->mrsas_dev, "Failed to get a free cmd for IOCTL\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
/*
|
||||
* User's IOCTL packet has 2 frames (maximum). Copy those two
|
||||
* frames into our cmd's frames. cmd->frame's context will get
|
||||
* overwritten when we copy from user's frames. So set that value
|
||||
* alone separately
|
||||
* User's IOCTL packet has 2 frames (maximum). Copy those two frames
|
||||
* into our cmd's frames. cmd->frame's context will get overwritten
|
||||
* when we copy from user's frames. So set that value alone
|
||||
* separately
|
||||
*/
|
||||
memcpy(cmd->frame, user_ioc->frame.raw, 2 * MEGAMFI_FRAME_SIZE);
|
||||
cmd->frame->hdr.context = cmd->index;
|
||||
@ -131,12 +127,12 @@ int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
MFI_FRAME_SENSE64);
|
||||
|
||||
/*
|
||||
* The management interface between applications and the fw uses
|
||||
* MFI frames. E.g, RAID configuration changes, LD property changes
|
||||
* etc are accomplishes through different kinds of MFI frames. The
|
||||
* driver needs to care only about substituting user buffers with
|
||||
* kernel buffers in SGLs. The location of SGL is embedded in the
|
||||
* struct iocpacket itself.
|
||||
* The management interface between applications and the fw uses MFI
|
||||
* frames. E.g, RAID configuration changes, LD property changes etc
|
||||
* are accomplishes through different kinds of MFI frames. The driver
|
||||
* needs to care only about substituting user buffers with kernel
|
||||
* buffers in SGLs. The location of SGL is embedded in the struct
|
||||
* iocpacket itself.
|
||||
*/
|
||||
kern_sge32 = (struct mrsas_sge32 *)
|
||||
((unsigned long)cmd->frame + user_ioc->sgl_off);
|
||||
@ -156,16 +152,16 @@ int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
ioctl_data_size = user_ioc32->sgl[i].iov_len;
|
||||
#endif
|
||||
}
|
||||
if (bus_dma_tag_create( sc->mrsas_parent_tag, // parent
|
||||
1, 0, // algnmnt, boundary
|
||||
BUS_SPACE_MAXADDR_32BIT,// lowaddr
|
||||
BUS_SPACE_MAXADDR, // highaddr
|
||||
NULL, NULL, // filter, filterarg
|
||||
ioctl_data_size, // maxsize
|
||||
1, // msegments
|
||||
ioctl_data_size, // maxsegsize
|
||||
BUS_DMA_ALLOCNOW, // flags
|
||||
NULL, NULL, // lockfunc, lockarg
|
||||
if (bus_dma_tag_create(sc->mrsas_parent_tag,
|
||||
1, 0,
|
||||
BUS_SPACE_MAXADDR_32BIT,
|
||||
BUS_SPACE_MAXADDR,
|
||||
NULL, NULL,
|
||||
ioctl_data_size,
|
||||
1,
|
||||
ioctl_data_size,
|
||||
BUS_DMA_ALLOCNOW,
|
||||
NULL, NULL,
|
||||
&ioctl_data_tag[i])) {
|
||||
device_printf(sc->mrsas_dev, "Cannot allocate ioctl data tag\n");
|
||||
ret = ENOMEM;
|
||||
@ -184,7 +180,6 @@ int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Save the physical address and length */
|
||||
kern_sge32[i].phys_addr = (u_int32_t)ioctl_data_phys_addr[i];
|
||||
|
||||
@ -213,16 +208,16 @@ int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
ioctl_sense_size = user_ioc->sense_len;
|
||||
|
||||
if (user_ioc->sense_len) {
|
||||
if (bus_dma_tag_create( sc->mrsas_parent_tag, // parent
|
||||
1, 0, // algnmnt, boundary
|
||||
BUS_SPACE_MAXADDR_32BIT,// lowaddr
|
||||
BUS_SPACE_MAXADDR, // highaddr
|
||||
NULL, NULL, // filter, filterarg
|
||||
ioctl_sense_size, // maxsize
|
||||
1, // msegments
|
||||
ioctl_sense_size, // maxsegsize
|
||||
BUS_DMA_ALLOCNOW, // flags
|
||||
NULL, NULL, // lockfunc, lockarg
|
||||
if (bus_dma_tag_create(sc->mrsas_parent_tag,
|
||||
1, 0,
|
||||
BUS_SPACE_MAXADDR_32BIT,
|
||||
BUS_SPACE_MAXADDR,
|
||||
NULL, NULL,
|
||||
ioctl_sense_size,
|
||||
1,
|
||||
ioctl_sense_size,
|
||||
BUS_DMA_ALLOCNOW,
|
||||
NULL, NULL,
|
||||
&ioctl_sense_tag)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot allocate ioctl sense tag\n");
|
||||
ret = ENOMEM;
|
||||
@ -245,7 +240,6 @@ int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
(unsigned long *)((unsigned long)cmd->frame + user_ioc->sense_off);
|
||||
sense_ptr = ioctl_sense_mem;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the sync_cmd flag so that the ISR knows not to complete this
|
||||
* cmd to the SCSI mid-layer
|
||||
@ -280,8 +274,8 @@ int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
*/
|
||||
if (user_ioc->sense_len) {
|
||||
/*
|
||||
* sense_buff points to the location that has the user
|
||||
* sense buffer address
|
||||
* sense_buff points to the location that has the user sense
|
||||
* buffer address
|
||||
*/
|
||||
sense_ptr = (unsigned long *)((unsigned long)user_ioc->frame.raw +
|
||||
user_ioc->sense_off);
|
||||
@ -292,7 +286,6 @@ int mrsas_passthru( struct mrsas_softc *sc, void *arg, u_long ioctlCmd )
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return command status to user space
|
||||
*/
|
||||
@ -337,7 +330,7 @@ out:
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_alloc_mfi_cmds: Allocates the command packets
|
||||
* input: Adapter instance soft state
|
||||
*
|
||||
@ -347,7 +340,8 @@ out:
|
||||
* mrsas_mfi_cmd given the context. The free commands are maintained in a
|
||||
* linked list.
|
||||
*/
|
||||
int mrsas_alloc_mfi_cmds(struct mrsas_softc *sc)
|
||||
int
|
||||
mrsas_alloc_mfi_cmds(struct mrsas_softc *sc)
|
||||
{
|
||||
int i, j;
|
||||
u_int32_t max_cmd;
|
||||
@ -356,8 +350,9 @@ int mrsas_alloc_mfi_cmds(struct mrsas_softc *sc)
|
||||
max_cmd = MRSAS_MAX_MFI_CMDS;
|
||||
|
||||
/*
|
||||
* sc->mfi_cmd_list is an array of struct mrsas_mfi_cmd pointers. Allocate the
|
||||
* dynamic array first and then allocate individual commands.
|
||||
* sc->mfi_cmd_list is an array of struct mrsas_mfi_cmd pointers.
|
||||
* Allocate the dynamic array first and then allocate individual
|
||||
* commands.
|
||||
*/
|
||||
sc->mfi_cmd_list = malloc(sizeof(struct mrsas_mfi_cmd *) * max_cmd, M_MRSAS, M_NOWAIT);
|
||||
if (!sc->mfi_cmd_list) {
|
||||
@ -389,7 +384,8 @@ int mrsas_alloc_mfi_cmds(struct mrsas_softc *sc)
|
||||
/* create a frame pool and assign one frame to each command */
|
||||
if (mrsas_create_frame_pool(sc)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot allocate DMA frame pool.\n");
|
||||
for (i = 0; i < MRSAS_MAX_MFI_CMDS; i++) { // Free the frames
|
||||
/* Free the frames */
|
||||
for (i = 0; i < MRSAS_MAX_MFI_CMDS; i++) {
|
||||
cmd = sc->mfi_cmd_list[i];
|
||||
mrsas_free_frame(sc, cmd);
|
||||
}
|
||||
@ -397,12 +393,11 @@ int mrsas_alloc_mfi_cmds(struct mrsas_softc *sc)
|
||||
bus_dma_tag_destroy(sc->mficmd_frame_tag);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* mrsas_create_frame_pool - Creates DMA pool for cmd frames
|
||||
/*
|
||||
* mrsas_create_frame_pool: Creates DMA pool for cmd frames
|
||||
* input: Adapter soft state
|
||||
*
|
||||
* Each command packet has an embedded DMA memory buffer that is used for
|
||||
@ -411,26 +406,26 @@ int mrsas_alloc_mfi_cmds(struct mrsas_softc *sc)
|
||||
* PCI pool facility. pad_0 is initialized to 0 to prevent corrupting value
|
||||
* of context and could cause FW crash.
|
||||
*/
|
||||
static int mrsas_create_frame_pool(struct mrsas_softc *sc)
|
||||
static int
|
||||
mrsas_create_frame_pool(struct mrsas_softc *sc)
|
||||
{
|
||||
int i;
|
||||
struct mrsas_mfi_cmd *cmd;
|
||||
|
||||
if (bus_dma_tag_create( sc->mrsas_parent_tag, // parent
|
||||
1, 0, // algnmnt, boundary
|
||||
BUS_SPACE_MAXADDR_32BIT,// lowaddr
|
||||
BUS_SPACE_MAXADDR, // highaddr
|
||||
NULL, NULL, // filter, filterarg
|
||||
MRSAS_MFI_FRAME_SIZE, // maxsize
|
||||
1, // msegments
|
||||
MRSAS_MFI_FRAME_SIZE, // maxsegsize
|
||||
BUS_DMA_ALLOCNOW, // flags
|
||||
NULL, NULL, // lockfunc, lockarg
|
||||
if (bus_dma_tag_create(sc->mrsas_parent_tag,
|
||||
1, 0,
|
||||
BUS_SPACE_MAXADDR_32BIT,
|
||||
BUS_SPACE_MAXADDR,
|
||||
NULL, NULL,
|
||||
MRSAS_MFI_FRAME_SIZE,
|
||||
1,
|
||||
MRSAS_MFI_FRAME_SIZE,
|
||||
BUS_DMA_ALLOCNOW,
|
||||
NULL, NULL,
|
||||
&sc->mficmd_frame_tag)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot create MFI frame tag\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
for (i = 0; i < MRSAS_MAX_MFI_CMDS; i++) {
|
||||
cmd = sc->mfi_cmd_list[i];
|
||||
cmd->frame = mrsas_alloc_frame(sc, cmd);
|
||||
@ -446,14 +441,15 @@ static int mrsas_create_frame_pool(struct mrsas_softc *sc)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* mrsas_alloc_frame - Allocates MFI Frames
|
||||
/*
|
||||
* mrsas_alloc_frame: Allocates MFI Frames
|
||||
* input: Adapter soft state
|
||||
*
|
||||
* Create bus DMA memory tag and dmamap and load memory for MFI frames.
|
||||
* Returns virtual memory pointer to allocated region.
|
||||
* Create bus DMA memory tag and dmamap and load memory for MFI frames. Returns
|
||||
* virtual memory pointer to allocated region.
|
||||
*/
|
||||
void *mrsas_alloc_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
|
||||
void *
|
||||
mrsas_alloc_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
|
||||
{
|
||||
u_int32_t frame_size = MRSAS_MFI_FRAME_SIZE;
|
||||
|
||||
@ -468,7 +464,6 @@ void *mrsas_alloc_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
|
||||
device_printf(sc->mrsas_dev, "Cannot load IO request memory\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
return (cmd->frame_mem);
|
||||
}
|
||||
|
||||
@ -479,11 +474,12 @@ void *mrsas_alloc_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
|
||||
* number of segments,
|
||||
* error code.
|
||||
*
|
||||
* This function is for the driver to receive mapping information resultant
|
||||
* of the bus_dmamap_load(). The information is actually not being used,
|
||||
* but the address is saved anyway.
|
||||
* This function is for the driver to receive mapping information resultant of
|
||||
* the bus_dmamap_load(). The information is actually not being used, but the
|
||||
* address is saved anyway.
|
||||
*/
|
||||
static void mrsas_alloc_cb(void *arg, bus_dma_segment_t *segs,
|
||||
static void
|
||||
mrsas_alloc_cb(void *arg, bus_dma_segment_t *segs,
|
||||
int nsegs, int error)
|
||||
{
|
||||
bus_addr_t *addr;
|
||||
@ -492,14 +488,15 @@ static void mrsas_alloc_cb(void *arg, bus_dma_segment_t *segs,
|
||||
*addr = segs[0].ds_addr;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* mrsas_free_frames: Frees memory for MFI frames
|
||||
* input: Adapter soft state
|
||||
*
|
||||
* Deallocates MFI frames memory. Called from mrsas_free_mem() during
|
||||
* detach and error case during creation of frame pool.
|
||||
* Deallocates MFI frames memory. Called from mrsas_free_mem() during detach
|
||||
* and error case during creation of frame pool.
|
||||
*/
|
||||
void mrsas_free_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
|
||||
void
|
||||
mrsas_free_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
|
||||
{
|
||||
if (cmd->frame_phys_addr)
|
||||
bus_dmamap_unload(sc->mficmd_frame_tag, cmd->frame_dmamap);
|
||||
|
@ -1,43 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2014, LSI Corp.
|
||||
* All rights reserved.
|
||||
* Author: Marian Choy
|
||||
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
|
||||
* Support: freebsdraid@lsi.com
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of the <ORGANIZATION> nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* <ORGANIZATION> nor the names of its contributors may be used to endorse or
|
||||
* promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation
|
||||
* are those of the authors and should not be interpreted as representing
|
||||
* The views and conclusions contained in the software and documentation are
|
||||
* those of the authors and should not be interpreted as representing
|
||||
* official policies,either expressed or implied, of the FreeBSD Project.
|
||||
*
|
||||
* Send feedback to: <megaraidfbsd@lsi.com>
|
||||
* Mail to: LSI Corporation, 1621 Barber Lane, Milpitas, CA 95035
|
||||
* ATTN: MegaRaid FreeBSD
|
||||
* Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
|
||||
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
|
||||
*
|
||||
*/
|
||||
|
||||
@ -62,12 +57,11 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* We need to use the same values as the mfi driver until MegaCli adds
|
||||
* support for this (mrsas) driver:
|
||||
* M is for MegaRAID. (This is typically the vendor or product initial)
|
||||
* 1 arbitrary. (This may be used to segment kinds of commands.
|
||||
* (1-9 status, 10-20 policy, etc.)
|
||||
* struct mrsas_iocpacket (sizeof() this parameter will be used.)
|
||||
* These three values are encoded into a somewhat unique, 32-bit value.
|
||||
* support for this (mrsas) driver: M is for MegaRAID. (This is typically the
|
||||
* vendor or product initial) 1 arbitrary. (This may be used to segment kinds
|
||||
* of commands. (1-9 status, 10-20 policy, etc.) struct mrsas_iocpacket
|
||||
* (sizeof() this parameter will be used.) These three values are encoded
|
||||
* into a somewhat unique, 32-bit value.
|
||||
*/
|
||||
|
||||
#define MRSAS_IOC_FIRMWARE_PASS_THROUGH64 _IOWR('M', 1, struct mrsas_iocpacket)
|
||||
@ -86,7 +80,8 @@ __FBSDID("$FreeBSD$");
|
||||
#define INQUIRY_CMD 0x12
|
||||
#define INQUIRY_CMDLEN 6
|
||||
#define INQUIRY_REPLY_LEN 96
|
||||
#define INQUIRY_VENDOR 8 /* Offset in reply data to vendor name */
|
||||
#define INQUIRY_VENDOR 8 /* Offset in reply data to
|
||||
* vendor name */
|
||||
#define SCSI_SENSE_BUFFERSIZE 96
|
||||
|
||||
#define MEGAMFI_RAW_FRAME_SIZE 128
|
||||
@ -106,6 +101,7 @@ struct mrsas_iocpacket {
|
||||
} frame;
|
||||
struct iovec sgl[MAX_IOCTL_SGE];
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#ifdef COMPAT_FREEBSD32
|
||||
@ -123,6 +119,7 @@ struct mrsas_iocpacket32 {
|
||||
} frame;
|
||||
struct iovec32 sgl[MAX_IOCTL_SGE];
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
#endif /* COMPAT_FREEBSD32 */
|
||||
|
||||
|
@ -1,48 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2014, LSI Corp.
|
||||
* All rights reserved.
|
||||
* Author: Kashyap Desai, Sibananda Sahu
|
||||
* Support: freebsdraid@lsi.com
|
||||
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Kashyap Desai,
|
||||
* Sibananda Sahu Support: freebsdraid@lsi.com
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of the <ORGANIZATION> nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions
|
||||
* in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of the
|
||||
* <ORGANIZATION> nor the names of its contributors may be used to endorse or
|
||||
* promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation
|
||||
* are those of the authors and should not be interpreted as representing
|
||||
* The views and conclusions contained in the software and documentation are
|
||||
* those of the authors and should not be interpreted as representing
|
||||
* official policies,either expressed or implied, of the FreeBSD Project.
|
||||
*
|
||||
* Send feedback to: <megaraidfbsd@lsi.com>
|
||||
* Mail to: LSI Corporation, 1621 Barber Lane, Milpitas, CA 95035
|
||||
* ATTN: MegaRaid FreeBSD
|
||||
* Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
|
||||
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -99,11 +94,19 @@ mrsas_linux_modevent(module_t mod __unused, int cmd __unused, void *data __unuse
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* mrsas_linux_ioctl: linux emulator IOCtl commands entry point.
|
||||
*
|
||||
* This function is the entry point for IOCtls from linux binaries.
|
||||
* It calls the mrsas_ioctl function for processing
|
||||
* depending on the IOCTL command received.
|
||||
*/
|
||||
static int
|
||||
mrsas_linux_ioctl(struct thread *p, struct linux_ioctl_args *args)
|
||||
{
|
||||
#if (__FreeBSD_version >= 1000000)
|
||||
cap_rights_t rights;
|
||||
|
||||
#endif
|
||||
struct file *fp;
|
||||
int error;
|
||||
@ -113,12 +116,12 @@ mrsas_linux_ioctl(struct thread *p, struct linux_ioctl_args *args)
|
||||
error = ENOTSUP;
|
||||
goto END;
|
||||
}
|
||||
|
||||
#if (__FreeBSD_version >= 1000000)
|
||||
error = fget(p, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp);
|
||||
#elif (__FreeBSD_version <= 900000)
|
||||
error = fget(p, args->fd, &fp);
|
||||
#else /* For FreeBSD version greater than 9.0.0 but less than 10.0.0 */
|
||||
#else /* For FreeBSD version greater than
|
||||
* 9.0.0 but less than 10.0.0 */
|
||||
error = fget(p, args->fd, CAP_IOCTL, &fp);
|
||||
#endif
|
||||
if (error != 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user