svn commit: r232949 - projects/head_mfi/sys/dev/mfi
Sean Bruno
sbruno at FreeBSD.org
Tue Mar 13 23:45:31 UTC 2012
Author: sbruno
Date: Tue Mar 13 23:45:30 2012
New Revision: 232949
URL: http://svn.freebsd.org/changeset/base/232949
Log:
Updates for compatibility and merging.
No functional changes here, just fixups for changes to CAM and other API
evolutions over the years. This should allow mfi(4) to be MFC'd to all
stable/X branches.
Reviewed by: ambrisko@
Obtained from: Yahoo! Inc.
Modified:
projects/head_mfi/sys/dev/mfi/mfi.c
projects/head_mfi/sys/dev/mfi/mfi_cam.c
projects/head_mfi/sys/dev/mfi/mfi_linux.c
projects/head_mfi/sys/dev/mfi/mfi_tbolt.c
projects/head_mfi/sys/dev/mfi/mfivar.h
Modified: projects/head_mfi/sys/dev/mfi/mfi.c
==============================================================================
--- projects/head_mfi/sys/dev/mfi/mfi.c Tue Mar 13 22:04:27 2012 (r232948)
+++ projects/head_mfi/sys/dev/mfi/mfi.c Tue Mar 13 23:45:30 2012 (r232949)
@@ -690,7 +690,11 @@ mfi_attach(struct mfi_softc *sc)
if ((error = mfi_tbolt_alloc_cmd(sc)) != 0)
return error;
if (bus_setup_intr(sc->mfi_dev, sc->mfi_irq,
+#if __FreeBSD_version < 700000
+ INTR_MPSAFE|INTR_TYPE_BIO, mfi_intr_tbolt, sc,
+#else
INTR_MPSAFE|INTR_TYPE_BIO, NULL, mfi_intr_tbolt, sc,
+#endif
&sc->mfi_intr)) {
device_printf(sc->mfi_dev, "Cannot set up interrupt\n");
return (EINVAL);
@@ -702,7 +706,11 @@ mfi_attach(struct mfi_softc *sc)
return (error);
if (bus_setup_intr(sc->mfi_dev, sc->mfi_irq,
+#if __FreeBSD_version < 700000
+ INTR_MPSAFE|INTR_TYPE_BIO, mfi_intr, sc, &sc->mfi_intr)) {
+#else
INTR_MPSAFE|INTR_TYPE_BIO, NULL, mfi_intr, sc, &sc->mfi_intr)) {
+#endif
device_printf(sc->mfi_dev, "Cannot set up interrupt\n");
return (EINVAL);
}
@@ -1676,7 +1684,11 @@ mfi_aen_complete(struct mfi_command *cm)
TAILQ_REMOVE(&sc->mfi_aen_pids, mfi_aen_entry,
aen_link);
PROC_LOCK(mfi_aen_entry->p);
+#if __FreeBSD_version < 900000
+ psignal(mfi_aen_entry->p, SIGIO);
+#else
kern_psignal(mfi_aen_entry->p, SIGIO);
+#endif
PROC_UNLOCK(mfi_aen_entry->p);
free(mfi_aen_entry, M_MFIBUF);
}
Modified: projects/head_mfi/sys/dev/mfi/mfi_cam.c
==============================================================================
--- projects/head_mfi/sys/dev/mfi/mfi_cam.c Tue Mar 13 22:04:27 2012 (r232948)
+++ projects/head_mfi/sys/dev/mfi/mfi_cam.c Tue Mar 13 23:45:30 2012 (r232949)
@@ -123,7 +123,11 @@ mfip_attach(device_t dev)
if ((sc->devq = cam_simq_alloc(MFI_SCSI_MAX_CMDS)) == NULL)
return (ENOMEM);
+#if __FreeBSD_version < 700000
+ sc->sim = cam_sim_alloc_mtx(mfip_cam_action, mfip_cam_poll, "mfi", sc,
+#else
sc->sim = cam_sim_alloc(mfip_cam_action, mfip_cam_poll, "mfi", sc,
+#endif
device_get_unit(dev), &mfisc->mfi_io_lock, 1,
MFI_SCSI_MAX_CMDS, sc->devq);
if (sc->sim == NULL) {
@@ -133,7 +137,11 @@ mfip_attach(device_t dev)
}
mtx_lock(&mfisc->mfi_io_lock);
+#if __FreeBSD_version < 700000
+ if (xpt_bus_register(sc->sim, 0) != 0) {
+#else
if (xpt_bus_register(sc->sim, dev, 0) != 0) {
+#endif
device_printf(dev, "XPT bus registration failed\n");
cam_sim_free(sc->sim, FALSE);
cam_simq_free(sc->devq);
@@ -194,10 +202,12 @@ mfip_cam_action(struct cam_sim *sim, uni
cpi->unit_number = cam_sim_unit(sim);
cpi->bus_id = cam_sim_bus(sim);
cpi->base_transfer_speed = 150000;
+#if __FreeBSD_version > 700000
cpi->transport = XPORT_SAS;
cpi->transport_version = 0;
cpi->protocol = PROTO_SCSI;
cpi->protocol_version = SCSI_REV_2;
+#endif
cpi->ccb_h.status = CAM_REQ_CMP;
break;
}
@@ -209,6 +219,10 @@ mfip_cam_action(struct cam_sim *sim, uni
break;
case XPT_GET_TRAN_SETTINGS:
{
+#if __FreeBSD_version < 700000
+ ccb->cts.flags &= ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB);
+ ccb->cts.valid = CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID;
+#else
struct ccb_trans_settings_sas *sas =
&ccb->cts.xport_specific.sas;
@@ -221,6 +235,7 @@ mfip_cam_action(struct cam_sim *sim, uni
sas->bitrate = 150000;
ccb->ccb_h.status = CAM_REQ_CMP;
+#endif
break;
}
case XPT_SET_TRAN_SETTINGS:
Modified: projects/head_mfi/sys/dev/mfi/mfi_linux.c
==============================================================================
--- projects/head_mfi/sys/dev/mfi/mfi_linux.c Tue Mar 13 22:04:27 2012 (r232948)
+++ projects/head_mfi/sys/dev/mfi/mfi_linux.c Tue Mar 13 23:45:30 2012 (r232949)
@@ -29,7 +29,9 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#if __FreeBSD_version > 999999
#include <sys/capability.h>
+#endif
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/module.h>
@@ -97,7 +99,11 @@ mfi_linux_ioctl(struct thread *p, struct
break;
}
+#if __FreeBSD_version > 999999
if ((error = fget(p, args->fd, CAP_IOCTL, &fp)) != 0)
+#else
+ if ((error = fget(p, args->fd, &fp)) != 0)
+#endif
return (error);
error = fo_ioctl(fp, cmd, (caddr_t)args->arg, p->td_ucred, p);
fdrop(fp, p);
Modified: projects/head_mfi/sys/dev/mfi/mfi_tbolt.c
==============================================================================
--- projects/head_mfi/sys/dev/mfi/mfi_tbolt.c Tue Mar 13 22:04:27 2012 (r232948)
+++ projects/head_mfi/sys/dev/mfi/mfi_tbolt.c Tue Mar 13 23:45:30 2012 (r232949)
@@ -620,7 +620,18 @@ map_tbolt_cmd_status(struct mfi_command
}
}
+/**
+ * mfi_tbolt_return_cmd - Return a cmd to free command pool
+ * @instance: Adapter soft state
+ * @cmd: Command packet to be returned to free command pool
+ */
+static inline void
+mfi_tbolt_return_cmd(struct mfi_softc *sc, struct mfi_cmd_tbolt *cmd)
+{
+ mtx_assert(&sc->mfi_io_lock, MA_OWNED);
+ TAILQ_INSERT_TAIL(&sc->mfi_cmd_tbolt_tqh, cmd, next);
+}
void mfi_tbolt_complete_cmd(struct mfi_softc *sc)
{
@@ -780,19 +791,6 @@ struct mfi_cmd_tbolt *mfi_tbolt_get_cmd(
return cmd;
}
-/**
- * mfi_tbolt_return_cmd - Return a cmd to free command pool
- * @instance: Adapter soft state
- * @cmd: Command packet to be returned to free command pool
- */
-static inline void
-mfi_tbolt_return_cmd(struct mfi_softc *sc, struct mfi_cmd_tbolt *cmd)
-{
- mtx_assert(&sc->mfi_io_lock, MA_OWNED);
-
- TAILQ_INSERT_TAIL(&sc->mfi_cmd_tbolt_tqh, cmd, next);
-}
-
union mfi_mpi2_request_descriptor *
mfi_tbolt_get_request_descriptor(struct mfi_softc *sc, uint16_t index)
{
Modified: projects/head_mfi/sys/dev/mfi/mfivar.h
==============================================================================
--- projects/head_mfi/sys/dev/mfi/mfivar.h Tue Mar 13 22:04:27 2012 (r232948)
+++ projects/head_mfi/sys/dev/mfi/mfivar.h Tue Mar 13 23:45:30 2012 (r232949)
@@ -533,6 +533,7 @@ mfi_dequeue_bio(struct mfi_softc *sc)
return (bp);
}
+#if __FreeBSD_version > 999999
/*
* This is from the original scsi_extract_sense() in CAM. It's copied
* here because CAM now uses a non-inline version that follows more complex
@@ -549,13 +550,18 @@ mfi_extract_sense(struct scsi_sense_data
*asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;
*ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;
}
+#endif
static __inline void
mfi_print_sense(struct mfi_softc *sc, void *sense)
{
int error, key, asc, ascq;
+#if __FreeBSD_version > 999999
mfi_extract_sense((struct scsi_sense_data_fixed *)sense,
+#else
+ scsi_extract_sense((struct scsi_sense_data *)sense,
+#endif
&error, &key, &asc, &ascq);
device_printf(sc->mfi_dev, "sense error %d, sense_key %d, "
"asc %d, ascq %d\n", error, key, asc, ascq);
More information about the svn-src-projects
mailing list