Make a pass at style.9 compliance
This commit is contained in:
parent
4c92c3889c
commit
4059f1cc7d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174186
@ -88,7 +88,7 @@ static void amr_cam_complete(struct amr_command *ac);
|
||||
static void amr_cam_complete_extcdb(struct amr_command *ac);
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
/***********************************************************************
|
||||
* Enqueue/dequeue functions
|
||||
*/
|
||||
static __inline void
|
||||
@ -144,14 +144,8 @@ amr_cam_attach(struct amr_softc *sc)
|
||||
|
||||
/* allocate a sim */
|
||||
if ((sc->amr_cam_sim[chn] = cam_sim_alloc(amr_cam_action,
|
||||
amr_cam_poll,
|
||||
"amr",
|
||||
sc,
|
||||
device_get_unit(sc->amr_dev),
|
||||
&sc->amr_list_lock,
|
||||
1,
|
||||
AMR_MAX_SCSI_CMDS,
|
||||
devq)) == NULL) {
|
||||
amr_cam_poll, "amr", sc, device_get_unit(sc->amr_dev),
|
||||
&sc->amr_list_lock, 1, AMR_MAX_SCSI_CMDS, devq)) == NULL) {
|
||||
cam_simq_free(devq);
|
||||
device_printf(sc->amr_dev, "CAM SIM attach failed\n");
|
||||
return(ENOMEM);
|
||||
@ -159,16 +153,17 @@ amr_cam_attach(struct amr_softc *sc)
|
||||
|
||||
/* register the bus ID so we can get it later */
|
||||
mtx_lock(&sc->amr_list_lock);
|
||||
error = xpt_bus_register(sc->amr_cam_sim[chn], sc->amr_dev, chn);
|
||||
error = xpt_bus_register(sc->amr_cam_sim[chn], sc->amr_dev,chn);
|
||||
mtx_unlock(&sc->amr_list_lock);
|
||||
if (error) {
|
||||
device_printf(sc->amr_dev, "CAM XPT bus registration failed\n");
|
||||
device_printf(sc->amr_dev,
|
||||
"CAM XPT bus registration failed\n");
|
||||
return(ENXIO);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* XXX we should scan the config and work out which devices are actually
|
||||
* protected.
|
||||
* XXX we should scan the config and work out which devices are
|
||||
* actually protected.
|
||||
*/
|
||||
return(0);
|
||||
}
|
||||
@ -183,7 +178,6 @@ amr_cam_detach(struct amr_softc *sc)
|
||||
|
||||
mtx_lock(&sc->amr_list_lock);
|
||||
for (chn = 0; chn < sc->amr_maxchan; chn++) {
|
||||
|
||||
/*
|
||||
* If a sim was allocated for this channel, free it
|
||||
*/
|
||||
@ -199,13 +193,13 @@ amr_cam_detach(struct amr_softc *sc)
|
||||
cam_simq_free(sc->amr_cam_devq);
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
********************************************************************************
|
||||
/***********************************************************************
|
||||
***********************************************************************
|
||||
CAM passthrough interface
|
||||
********************************************************************************
|
||||
********************************************************************************/
|
||||
***********************************************************************
|
||||
***********************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
/***********************************************************************
|
||||
* Handle a request for action from CAM
|
||||
*/
|
||||
static void
|
||||
@ -230,25 +224,32 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb)
|
||||
if (csio->cdb_len > AMR_MAX_EXTCDB_LEN)
|
||||
ccbh->status = CAM_REQ_CMP_ERR;
|
||||
|
||||
if ((csio->cdb_len > AMR_MAX_CDB_LEN) && (sc->support_ext_cdb == 0 ))
|
||||
if ((csio->cdb_len > AMR_MAX_CDB_LEN) &&
|
||||
(sc->support_ext_cdb == 0))
|
||||
ccbh->status = CAM_REQ_CMP_ERR;
|
||||
|
||||
/* check that the CDB pointer is not to a physical address */
|
||||
if ((ccbh->flags & CAM_CDB_POINTER) && (ccbh->flags & CAM_CDB_PHYS))
|
||||
if ((ccbh->flags & CAM_CDB_POINTER) &&
|
||||
(ccbh->flags & CAM_CDB_PHYS))
|
||||
ccbh->status = CAM_REQ_CMP_ERR;
|
||||
|
||||
/* if there is data transfer, it must be to/from a virtual address */
|
||||
/*
|
||||
* if there is data transfer, it must be to/from a virtual
|
||||
* address
|
||||
*/
|
||||
if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
|
||||
if (ccbh->flags & CAM_DATA_PHYS) /* we can't map it */
|
||||
if (ccbh->flags & CAM_DATA_PHYS)
|
||||
/* we can't map it */
|
||||
ccbh->status = CAM_REQ_CMP_ERR;
|
||||
if (ccbh->flags & CAM_SCATTER_VALID) /* we want to do the s/g setup */
|
||||
if (ccbh->flags & CAM_SCATTER_VALID)
|
||||
/* we want to do the s/g setup */
|
||||
ccbh->status = CAM_REQ_CMP_ERR;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the command is to a LUN other than 0, fail it.
|
||||
* This is probably incorrect, but during testing the firmware did not
|
||||
* seem to respect the LUN field, and thus devices appear echoed.
|
||||
* This is probably incorrect, but during testing the
|
||||
* firmware did not seem to respect the LUN field, and thus
|
||||
* devices appear echoed.
|
||||
*/
|
||||
if (csio->ccb_h.target_lun != 0)
|
||||
ccbh->status = CAM_REQ_CMP_ERR;
|
||||
@ -257,7 +258,7 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb)
|
||||
if (ccbh->status == CAM_REQ_INPROG) {
|
||||
|
||||
/* save the channel number in the ccb */
|
||||
csio->ccb_h.sim_priv.entries[0].field = cam_sim_bus(sim);
|
||||
csio->ccb_h.sim_priv.entries[0].field= cam_sim_bus(sim);
|
||||
|
||||
amr_enqueue_ccb(sc, ccb);
|
||||
amr_startio(sc);
|
||||
@ -273,8 +274,7 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb)
|
||||
}
|
||||
|
||||
/*
|
||||
* Return path stats. Some of these should probably be
|
||||
* amended.
|
||||
* Return path stats. Some of these should probably be amended.
|
||||
*/
|
||||
case XPT_PATH_INQ:
|
||||
{
|
||||
@ -294,7 +294,7 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb)
|
||||
strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
|
||||
cpi->unit_number = cam_sim_unit(sim);
|
||||
cpi->bus_id = cam_sim_bus(sim);
|
||||
cpi->base_transfer_speed = 132 * 1024; /* XXX get from controller? */
|
||||
cpi->base_transfer_speed = 132 * 1024; /* XXX */
|
||||
cpi->transport = XPORT_SPI;
|
||||
cpi->transport_version = 2;
|
||||
cpi->protocol = PROTO_SCSI;
|
||||
@ -326,8 +326,11 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb)
|
||||
|
||||
debug(3, "XPT_GET_TRAN_SETTINGS");
|
||||
|
||||
struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi;
|
||||
struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi;
|
||||
struct ccb_trans_settings_scsi *scsi;
|
||||
struct ccb_trans_settings_spi *spi;
|
||||
|
||||
scsi = &cts->proto_specific.scsi;
|
||||
spi = &cts->xport_specific.spi;
|
||||
|
||||
cts->protocol = PROTO_SCSI;
|
||||
cts->protocol_version = SCSI_REV_2;
|
||||
@ -367,12 +370,14 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb)
|
||||
ccb->ccb_h.status = CAM_REQ_INVALID;
|
||||
break;
|
||||
}
|
||||
|
||||
mtx_assert(&sc->amr_list_lock, MA_OWNED);
|
||||
xpt_done(ccb);
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* Convert a CAM CCB off the top of the CCB queue to a passthrough SCSI command.
|
||||
/***********************************************************************
|
||||
* Convert a CAM CCB off the top of the CCB queue to a passthrough SCSI
|
||||
* command.
|
||||
*/
|
||||
int
|
||||
amr_cam_command(struct amr_softc *sc, struct amr_command **acp)
|
||||
@ -402,7 +407,8 @@ amr_cam_command(struct amr_softc *sc, struct amr_command **acp)
|
||||
|
||||
/* construct passthrough */
|
||||
if (sc->support_ext_cdb ) {
|
||||
if ((aep = malloc(sizeof(*aep), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) {
|
||||
if ((aep = malloc(sizeof(*aep), M_DEVBUF, M_NOWAIT | M_ZERO))
|
||||
== NULL) {
|
||||
error = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
@ -418,15 +424,21 @@ amr_cam_command(struct amr_softc *sc, struct amr_command **acp)
|
||||
if (csio->ccb_h.flags & CAM_CDB_POINTER) {
|
||||
bcopy(csio->cdb_io.cdb_ptr, aep->ap_cdb, csio->cdb_len);
|
||||
} else {
|
||||
bcopy(csio->cdb_io.cdb_bytes, aep->ap_cdb, csio->cdb_len);
|
||||
bcopy(csio->cdb_io.cdb_bytes, aep->ap_cdb,
|
||||
csio->cdb_len);
|
||||
}
|
||||
/* we leave the data s/g list and s/g count to the map routine later */
|
||||
/*
|
||||
* we leave the data s/g list and s/g count to the map routine
|
||||
* later
|
||||
*/
|
||||
|
||||
debug(2, " COMMAND %x/%d+%d to %d:%d:%d", aep->ap_cdb[0], aep->ap_cdb_length, csio->dxfer_len,
|
||||
aep->ap_channel, aep->ap_scsi_id, aep->ap_logical_drive_no);
|
||||
debug(2, " COMMAND %x/%d+%d to %d:%d:%d", aep->ap_cdb[0],
|
||||
aep->ap_cdb_length, csio->dxfer_len, aep->ap_channel,
|
||||
aep->ap_scsi_id, aep->ap_logical_drive_no);
|
||||
|
||||
} else {
|
||||
if ((ap = malloc(sizeof(*ap), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) {
|
||||
if ((ap = malloc(sizeof(*ap), M_DEVBUF, M_NOWAIT | M_ZERO))
|
||||
== NULL) {
|
||||
error = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
@ -442,12 +454,17 @@ amr_cam_command(struct amr_softc *sc, struct amr_command **acp)
|
||||
if (csio->ccb_h.flags & CAM_CDB_POINTER) {
|
||||
bcopy(csio->cdb_io.cdb_ptr, ap->ap_cdb, csio->cdb_len);
|
||||
} else {
|
||||
bcopy(csio->cdb_io.cdb_bytes, ap->ap_cdb, csio->cdb_len);
|
||||
bcopy(csio->cdb_io.cdb_bytes, ap->ap_cdb,
|
||||
csio->cdb_len);
|
||||
}
|
||||
/* we leave the data s/g list and s/g count to the map routine later */
|
||||
/*
|
||||
* we leave the data s/g list and s/g count to the map routine
|
||||
* later
|
||||
*/
|
||||
|
||||
debug(2, " COMMAND %x/%d+%d to %d:%d:%d", ap->ap_cdb[0], ap->ap_cdb_length, csio->dxfer_len,
|
||||
ap->ap_channel, ap->ap_scsi_id, ap->ap_logical_drive_no);
|
||||
debug(2, " COMMAND %x/%d+%d to %d:%d:%d", ap->ap_cdb[0],
|
||||
ap->ap_cdb_length, csio->dxfer_len, ap->ap_channel,
|
||||
ap->ap_scsi_id, ap->ap_logical_drive_no);
|
||||
}
|
||||
|
||||
/* construct command */
|
||||
@ -486,14 +503,15 @@ amr_cam_command(struct amr_softc *sc, struct amr_command **acp)
|
||||
free(ap, M_DEVBUF);
|
||||
if (aep != NULL)
|
||||
free(aep, M_DEVBUF);
|
||||
if (csio != NULL) /* put it back and try again later */
|
||||
if (csio != NULL)
|
||||
/* put it back and try again later */
|
||||
amr_requeue_ccb(sc, (union ccb *)csio);
|
||||
}
|
||||
*acp = ac;
|
||||
return(error);
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
/***********************************************************************
|
||||
* Check for interrupt status
|
||||
*/
|
||||
static void
|
||||
@ -503,25 +521,32 @@ amr_cam_poll(struct cam_sim *sim)
|
||||
amr_done(cam_sim_softc(sim));
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
/**********************************************************************
|
||||
* Handle completion of a command submitted via CAM.
|
||||
*/
|
||||
static void
|
||||
amr_cam_complete(struct amr_command *ac)
|
||||
{
|
||||
struct amr_passthrough *ap = (struct amr_passthrough *)ac->ac_data;
|
||||
struct ccb_scsiio *csio = (struct ccb_scsiio *)ac->ac_private;
|
||||
struct scsi_inquiry_data *inq = (struct scsi_inquiry_data *)csio->data_ptr;
|
||||
struct amr_passthrough *ap;
|
||||
struct ccb_scsiio *csio;
|
||||
struct scsi_inquiry_data *inq;
|
||||
|
||||
ap = (struct amr_passthrough *)ac->ac_data;
|
||||
csio = (struct ccb_scsiio *)ac->ac_private;
|
||||
inq = (struct scsi_inquiry_data *)csio->data_ptr;
|
||||
|
||||
/* XXX note that we're ignoring ac->ac_status - good idea? */
|
||||
|
||||
debug(1, "status 0x%x AP scsi_status 0x%x", ac->ac_status, ap->ap_scsi_status);
|
||||
debug(1, "status 0x%x AP scsi_status 0x%x", ac->ac_status,
|
||||
ap->ap_scsi_status);
|
||||
|
||||
/*
|
||||
* Hide disks from CAM so that they're not picked up and treated as 'normal' disks.
|
||||
* Hide disks from CAM so that they're not picked up and treated as
|
||||
* 'normal' disks.
|
||||
*
|
||||
* If the configuration provides a mechanism to mark a disk a "not managed", we
|
||||
* could add handling for that to allow disks to be selectively visible.
|
||||
* If the configuration provides a mechanism to mark a disk a "not
|
||||
* managed", we could add handling for that to allow disks to be
|
||||
* selectively visible.
|
||||
*/
|
||||
|
||||
/* handle passthrough SCSI status */
|
||||
@ -535,7 +560,8 @@ amr_cam_complete(struct amr_command *ac)
|
||||
case 0x02:
|
||||
csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
|
||||
csio->scsi_status = SCSI_STATUS_CHECK_COND;
|
||||
bcopy(ap->ap_request_sense_area, &csio->sense_data, AMR_MAX_REQ_SENSE_LEN);
|
||||
bcopy(ap->ap_request_sense_area, &csio->sense_data,
|
||||
AMR_MAX_REQ_SENSE_LEN);
|
||||
csio->sense_len = AMR_MAX_REQ_SENSE_LEN;
|
||||
csio->ccb_h.status |= CAM_AUTOSNS_VALID;
|
||||
break;
|
||||
@ -550,36 +576,45 @@ amr_cam_complete(struct amr_command *ac)
|
||||
csio->ccb_h.status = CAM_REQ_CMP_ERR;
|
||||
break;
|
||||
}
|
||||
|
||||
free(ap, M_DEVBUF);
|
||||
if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)
|
||||
debug(2, "%*D\n", imin(csio->dxfer_len, 16), csio->data_ptr, " ");
|
||||
debug(2, "%*D\n", imin(csio->dxfer_len, 16), csio->data_ptr,
|
||||
" ");
|
||||
xpt_done((union ccb *)csio);
|
||||
mtx_assert(&ac->ac_sc->amr_list_lock, MA_OWNED);
|
||||
amr_releasecmd(ac);
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
/***********************************************************************
|
||||
* Handle completion of a command submitted via CAM.
|
||||
* Completion for extended cdb
|
||||
*/
|
||||
static void
|
||||
amr_cam_complete_extcdb(struct amr_command *ac)
|
||||
{
|
||||
struct amr_ext_passthrough *aep = (struct amr_ext_passthrough *)ac->ac_data;
|
||||
struct ccb_scsiio *csio = (struct ccb_scsiio *)ac->ac_private;
|
||||
struct scsi_inquiry_data *inq = (struct scsi_inquiry_data *)csio->data_ptr;
|
||||
struct amr_ext_passthrough *aep;
|
||||
struct ccb_scsiio *csio;
|
||||
struct scsi_inquiry_data *inq;
|
||||
|
||||
debug(1, "status 0x%x AEP scsi_status 0x%x", ac->ac_status, aep->ap_scsi_status);
|
||||
aep = (struct amr_ext_passthrough *)ac->ac_data;
|
||||
csio = (struct ccb_scsiio *)ac->ac_private;
|
||||
inq = (struct scsi_inquiry_data *)csio->data_ptr;
|
||||
|
||||
debug(1, "status 0x%x AEP scsi_status 0x%x", ac->ac_status,
|
||||
aep->ap_scsi_status);
|
||||
if (ac->ac_status != AMR_STATUS_SUCCESS) {
|
||||
csio->ccb_h.status = CAM_REQ_CMP_ERR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hide disks from CAM so that they're not picked up and treated as 'normal' disks.
|
||||
* Hide disks from CAM so that they're not picked up and treated as
|
||||
* 'normal' disks.
|
||||
*
|
||||
* If the configuration provides a mechanism to mark a disk a "not managed", we
|
||||
* could add handling for that to allow disks to be selectively visible.
|
||||
* If the configuration provides a mechanism to mark a disk a "not
|
||||
* managed", we could add handling for that to allow disks to be
|
||||
* selectively visible.
|
||||
*/
|
||||
|
||||
/* handle passthrough SCSI status */
|
||||
@ -593,7 +628,8 @@ amr_cam_complete_extcdb(struct amr_command *ac)
|
||||
case 0x02:
|
||||
csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
|
||||
csio->scsi_status = SCSI_STATUS_CHECK_COND;
|
||||
bcopy(aep->ap_request_sense_area, &csio->sense_data, AMR_MAX_REQ_SENSE_LEN);
|
||||
bcopy(aep->ap_request_sense_area, &csio->sense_data,
|
||||
AMR_MAX_REQ_SENSE_LEN);
|
||||
csio->sense_len = AMR_MAX_REQ_SENSE_LEN;
|
||||
csio->ccb_h.status |= CAM_AUTOSNS_VALID;
|
||||
break;
|
||||
@ -612,7 +648,8 @@ amr_cam_complete_extcdb(struct amr_command *ac)
|
||||
out:
|
||||
free(aep, M_DEVBUF);
|
||||
if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)
|
||||
debug(2, "%*D\n", imin(csio->dxfer_len, 16), csio->data_ptr, " ");
|
||||
debug(2, "%*D\n", imin(csio->dxfer_len, 16), csio->data_ptr,
|
||||
" ");
|
||||
xpt_done((union ccb *)csio);
|
||||
mtx_assert(&ac->ac_sc->amr_list_lock, MA_OWNED);
|
||||
amr_releasecmd(ac);
|
||||
|
Loading…
Reference in New Issue
Block a user