Add mrsas(4) driver from LSI official support of newer MegaRAID SAS
cards. LSI has been maintaining this driver outside of the FreeBSD tree. It overlaps support of ThunderBolt and Invader cards that mfi(4) supports. By default mfi(4) will attach to cards. If the tunable: hw.mfi.mrsas_enable=1 is set then mfi(4) will not probe and attach to these newer cards and allow mrsas(4) to attach. So by default this driver will not effect a FreeBSD system unless mfi(4) is removed from the kernel or the tunable is enabled. mrsas(4) attaches disks to the CAM layer so it depends on CAM and devices show up as /dev/daX. mfiutil(8) does not work with mrsas. The FreeBSD version of MegaCli and StorCli from LSI do work with mrsas. It appears that StorCli only works with mrsas. MegaCli appears to work with mfi(4) and mrsas(4). It would be good to add mfiutil(4) support to mrsas, emulations modes, kernel logging, device aliases to ease the transition between mfi(4) and mrsas(4). Style issues should be resolved by LSI when they get committers approved. The plan is get this driver in FreeBSD 9.3 to improve HW support. Thanks to LSI for developing, testing and working with FreeBSD to make this driver co-exist in FreeBSD. This improves the overall support of MegaRAID SAS. Submitted by: Kashyap Desai <Kashyap.Desai@lsi.com> Reviewed by: scottl MFC after: 3 days Sponsored by: LSI
This commit is contained in:
parent
4efec7a83d
commit
665484d8f0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=265555
@ -265,6 +265,7 @@ MAN= aac.4 \
|
||||
mpr.4 \
|
||||
mps.4 \
|
||||
mpt.4 \
|
||||
mrsas.4 \
|
||||
msk.4 \
|
||||
mtio.4 \
|
||||
multicast.4 \
|
||||
|
374
share/man/man4/mrsas.4
Normal file
374
share/man/man4/mrsas.4
Normal file
@ -0,0 +1,374 @@
|
||||
.\" Copyright (c) 2014 LSI Corp
|
||||
.\" All rights reserved.
|
||||
.\" Author: Kashyap Desai
|
||||
.\" 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:
|
||||
.\" 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
|
||||
.\" 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
|
||||
.\" official policies,either expressed or implied, of the FreeBSD Project
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
|
||||
|
||||
.Dd Apr 12, 2013
|
||||
.Dt MRSAS 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm mrsas
|
||||
.Nd "LSI MegaRAID 6Gb/s and 12Gb/s SAS+SATA Raid controller driver"
|
||||
.Sh SYNOPSIS
|
||||
To compile this driver into the kernel,
|
||||
place the following lines in your
|
||||
kernel configuration file:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "device pci"
|
||||
.Cd "device mrsas"
|
||||
.Ed
|
||||
.Pp
|
||||
Alternatively, to load the driver as a
|
||||
module at boot time, place the following line in
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
mrsas_load="YES"
|
||||
.Ed
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver will detect LSI's next generation (6Gb/s and 12Gb/s) PCI Express
|
||||
SAS/SATA RAID controllers.
|
||||
See the
|
||||
.Nm HARDWARE
|
||||
section for the supported devices list.
|
||||
A disk (virtual disk/physical disk) attached to the
|
||||
.Nm
|
||||
driver will be visible to the user through
|
||||
.Xr camcontrol 8 as
|
||||
.Pa /dev/da?
|
||||
device nodes.
|
||||
A simple management interface is also provided on a per-controller basis via the
|
||||
.Pa /dev/mrsas?
|
||||
device node.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
name is derived from the phrase "MegaRAID SAS HBA", which is
|
||||
substantially different than the old "MegaRAID" Driver
|
||||
.Xr mfi 4
|
||||
which does not connect targets
|
||||
to the
|
||||
.Xr cam 4
|
||||
layer and thus requires a new driver which attaches targets to the
|
||||
.Xr cam 4
|
||||
layer. Older MegaRAID controllers are supported by
|
||||
.Xr mfi 4
|
||||
and will not work with
|
||||
.Nm ,
|
||||
but both the
|
||||
.Xr mfi 4
|
||||
and
|
||||
.Nm
|
||||
drivers can detect and manage the LSI MegaRAID SAS 2208/2308/3008/3108 series of
|
||||
controllers.
|
||||
.Pp
|
||||
The
|
||||
.Nm device.hints
|
||||
option is provided to tune the
|
||||
.Nm
|
||||
driver's behavior for LSI MegaRAID SAS 2208/2308/3008/3108 controllers.
|
||||
By default, the
|
||||
.Xr mfi 4
|
||||
driver will detect these controllers. See the
|
||||
.Nm PRIORITY
|
||||
section to know more about driver priority for MR-Fusion devices.
|
||||
.Pp
|
||||
.Nm
|
||||
will provide a priority of (-30) (between BUS_PROBE_DEFAULT and
|
||||
BUS_PROBE_LOW_PRIORITY) at probe call for device id's 0x005B, 0x005D, and
|
||||
0x005F so that
|
||||
.Nm
|
||||
does not take control of these devices without user intervention.
|
||||
.Sh HARDWARE
|
||||
The
|
||||
.Nm
|
||||
driver supports the following hardware:
|
||||
.Pp
|
||||
.Bl -bullet -compact
|
||||
[ Thunderbolt 6Gbp/s MR controller ]
|
||||
.It
|
||||
LSI MegaRAID SAS 9265
|
||||
.It
|
||||
LSI MegaRAID SAS 9266
|
||||
.It
|
||||
LSI MegaRAID SAS 9267
|
||||
.It
|
||||
LSI MegaRAID SAS 9270
|
||||
.It
|
||||
LSI MegaRAID SAS 9271
|
||||
.It
|
||||
LSI MegaRAID SAS 9272
|
||||
.It
|
||||
LSI MegaRAID SAS 9285
|
||||
.It
|
||||
LSI MegaRAID SAS 9286
|
||||
.It
|
||||
DELL PERC H810
|
||||
.It
|
||||
DELL PERC H710/P
|
||||
.El
|
||||
.Pp
|
||||
.Bl -bullet -compact
|
||||
[ Invader/Fury 12Gpb/s MR controller ]
|
||||
.It
|
||||
LSI MegaRAID SAS 9380
|
||||
.It
|
||||
LSI MegaRAID SAS 9361
|
||||
.It
|
||||
LSI MegaRAID SAS 9341
|
||||
.It
|
||||
DELL PERC H830
|
||||
.It
|
||||
DELL PERC H730/P
|
||||
.It
|
||||
DELL PERC H330
|
||||
.El
|
||||
.Sh CONFIGURATION
|
||||
To disable Online Controller Reset(OCR) for a specific
|
||||
.Nm
|
||||
driver instance, set the
|
||||
following tunable value in
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
dev.mrsas.X.disable_ocr=1
|
||||
.Ed
|
||||
.Pp
|
||||
where X is the adapter number.
|
||||
.Pp
|
||||
To change the IO timeout value for a specific
|
||||
.Nm
|
||||
driver instance, set the following tunable value in
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
dev.mrsas.X.mrsas_io_timeout=NNNNNN
|
||||
.Ed
|
||||
.Pp
|
||||
where NNNNNN is the timeout value in milli-seconds.
|
||||
.Pp
|
||||
To change the firmware fault check timer value for a specific
|
||||
.Nm
|
||||
driver instance, set the following tunable value in
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
dev.mrsas.X.mrsas_fw_fault_check_delay=NN
|
||||
.Ed
|
||||
.Pp
|
||||
where NN is the fault check delay value in seconds.
|
||||
.Pp
|
||||
The current number of active I/O commands is shown in the
|
||||
dev.mrsas.X.fw_outstanding
|
||||
.Xr sysctl 8
|
||||
variable.
|
||||
.Sh DEBUGGING
|
||||
To enable debugging prints from the
|
||||
.Nm
|
||||
driver, set the
|
||||
.Bd -literal -offset indent
|
||||
hw.mrsas.X.debug_level
|
||||
.Ed
|
||||
.Pp
|
||||
variable, where X is the adapter number, either in
|
||||
.Xr loader.conf 5
|
||||
or via
|
||||
.Xr sysctl 8 .
|
||||
The following bits have the described effects:
|
||||
.Bl -tag -offset indent
|
||||
.It 0x01
|
||||
Enable informational prints.
|
||||
.It 0x02
|
||||
Enable tracing prints.
|
||||
.It 0x04
|
||||
Enable prints for driver faults.
|
||||
.It 0x08
|
||||
Enable prints for OCR and IO timeout.
|
||||
.It 0x10
|
||||
Enable prints for AEN events.
|
||||
.El
|
||||
.Sh PRIORITY
|
||||
The
|
||||
.Nm
|
||||
driver will always set a default (-30) priority in the pci subsystem for
|
||||
selection of MR-Fusion cards. (It is between BUS_PROBE_DEFAULT and
|
||||
BUS_PROBE_LOW_PRIORITY). MR-Fusion Controllers include all cards with the
|
||||
Device IDs -
|
||||
0x005B,
|
||||
0x005D,
|
||||
0x005F.
|
||||
.Pp
|
||||
The
|
||||
.Xr mfi 4
|
||||
driver will set a priority of either BUS_PROBE_DEFAULT or
|
||||
BUS_PROBE_LOW_PRIORITY (depending on the device.hint setting) in the pci
|
||||
subsystem for selection of MR-Fusion cards. With the above design in place, the
|
||||
.Xr mfi 4
|
||||
driver will attach to a MR-Fusion card given that it has a higher priority than
|
||||
.Nm .
|
||||
.Pp
|
||||
Using /boot/device.hints (as mentioned below), the user can provide a preference
|
||||
for the
|
||||
.Nm
|
||||
driver to detect a MR-Fusion card instead of the
|
||||
.Xr mfi 4
|
||||
driver.
|
||||
.Bd -ragged -offset indent
|
||||
.Cd hw.mfi.mrsas_enable="1"
|
||||
.Ed
|
||||
.Pp
|
||||
At boot time, the
|
||||
.Xr mfi 4
|
||||
driver will get priority to detect MR-Fusion controllers by default. Before
|
||||
changing this default driver selection policy, LSI advises users to understand
|
||||
how the driver selection policy works. LSI's policy is to provide priority to
|
||||
the
|
||||
.Xr mfi 4
|
||||
driver to detect MR-Fusion cards, but allow for the ability to choose the
|
||||
.Nm
|
||||
driver to detect MR-Fusion cards.
|
||||
.Pp
|
||||
LSI recommends setting hw.mfi.mrsas_enable="0" for customers who are using the
|
||||
older
|
||||
.Xr mfi 4
|
||||
driver and do not want to switch to
|
||||
.Nm .
|
||||
For those customers who are using a MR-Fusion controller for the first time, LSI
|
||||
recommends using the
|
||||
.Nm
|
||||
driver and setting hw.mfi.mrsas_enable="1".
|
||||
.Pp
|
||||
Changing the default behavior is well tested under most conditions, but
|
||||
unexpected behavior may pop up if more complex and unrealistic operations are
|
||||
executed by switching between the
|
||||
.Xr mfi 4 and
|
||||
.Nm
|
||||
drivers for MR-Fusion.
|
||||
Switching drivers is designed to happen only one time. Although multiple
|
||||
switching is possible, it is not recommended. The user should decide from
|
||||
.Nm Start of Day
|
||||
which driver they want to use for the MR-Fusion card.
|
||||
.Pp
|
||||
The user may see different device names when switching from
|
||||
.Xr mfi 4
|
||||
to
|
||||
.Nm .
|
||||
This behavior is
|
||||
.Nm Functions As Designed
|
||||
and the user needs to change the fstab
|
||||
entry manually if they are doing any experiments with
|
||||
.Xr mfi 4
|
||||
and
|
||||
.Nm
|
||||
interoperability.
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".Pa /dev/mrsas?" -compact
|
||||
.It /dev/da?
|
||||
array/logical disk interface
|
||||
.It /dev/mrsas?
|
||||
management interface
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr pci 4 ,
|
||||
.Xr mfi 4 ,
|
||||
.Xr cam 4 ,
|
||||
.Xr device.hints 5 ,
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
driver first appeared in
|
||||
.Fx 10.0 .
|
||||
.Bd -ragged
|
||||
.Cd "mfi Driver:"
|
||||
.Xr mfi 4
|
||||
is the old FreeBSD driver which started with support for Gen-1 Controllers and
|
||||
was extended to support up to MR-Fusion (Device ID = 0x005B, 0x005D, 0x005F).
|
||||
.Ed
|
||||
.Bd -ragged
|
||||
.Cd "mrsas Driver:"
|
||||
.Nm
|
||||
is the new driver reworked by LSI which supports Thunderbolt and onward
|
||||
products. The SAS+SATA RAID controller with device id 0x005b is referred to as
|
||||
the Thunderbolt controller throughout in this man page.
|
||||
.Ed
|
||||
.Bd -ragged
|
||||
.Nm cam aware HBA drivers:
|
||||
FreeBSD has a
|
||||
.Xr cam 4
|
||||
layer which attaches storage devices and provides a common access mechanism to
|
||||
storage controllers and attached devices. The
|
||||
.Nm
|
||||
driver is
|
||||
.Xr cam 4 aware and devices associated with
|
||||
.Nm
|
||||
can be seen using
|
||||
.Xr camcontrol 8 .
|
||||
The
|
||||
.Xr mfi 4
|
||||
driver does not understand the
|
||||
.Xr cam 4
|
||||
layer and it directly associates storage disks to the block layer.
|
||||
.Pp
|
||||
.Nm Thunderbolt Controller:
|
||||
This is the 6Gb/s MegaRAID HBA card which has device id 0x005B.
|
||||
.Pp
|
||||
.Nm Invader Controller:
|
||||
This is 12Gb/s MegaRAID HBA card which has device id 0x005D.
|
||||
.Pp
|
||||
.Nm Fury Controller:
|
||||
This is the 12Gb/s MegaRAID HBA card which has device id 0x005F.
|
||||
.Ed
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
driver and this manual page were written by
|
||||
.An Kashyap Desai Aq Kashyap.Desai@lsi.com .
|
||||
.Sh TODO
|
||||
The driver does not support big-endian architectures at this time.
|
||||
.Pp
|
||||
The driver does not support alias for device name (it is required when the user
|
||||
switches between two drivers and does not want to edit /etc/fstab manually).
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver exposes devices as /dev/da?, whereas
|
||||
.Xr mfi 4
|
||||
exposes deivces as /dev/mfid?
|
||||
.Pp
|
||||
.Nm
|
||||
does not support the Linux Emulator interface.
|
||||
.Pp
|
||||
.Nm
|
||||
will not work with
|
||||
.Xr mfiutil 8
|
@ -1832,6 +1832,10 @@ dev/mpt/mpt_debug.c optional mpt
|
||||
dev/mpt/mpt_pci.c optional mpt pci
|
||||
dev/mpt/mpt_raid.c optional mpt
|
||||
dev/mpt/mpt_user.c optional mpt
|
||||
dev/mrsas/mrsas.c optional mrsas
|
||||
dev/mrsas/mrsas_cam.c optional mrsas
|
||||
dev/mrsas/mrsas_ioctl.c optional mrsas
|
||||
dev/mrsas/mrsas_fp.c optional mrsas
|
||||
dev/msk/if_msk.c optional msk
|
||||
dev/mvs/mvs.c optional mvs
|
||||
dev/mvs/mvs_if.m optional mvs
|
||||
|
3672
sys/dev/mrsas/mrsas.c
Normal file
3672
sys/dev/mrsas/mrsas.c
Normal file
File diff suppressed because it is too large
Load Diff
2464
sys/dev/mrsas/mrsas.h
Normal file
2464
sys/dev/mrsas/mrsas.h
Normal file
File diff suppressed because it is too large
Load Diff
1179
sys/dev/mrsas/mrsas_cam.c
Normal file
1179
sys/dev/mrsas/mrsas_cam.c
Normal file
File diff suppressed because it is too large
Load Diff
1451
sys/dev/mrsas/mrsas_fp.c
Normal file
1451
sys/dev/mrsas/mrsas_fp.c
Normal file
File diff suppressed because it is too large
Load Diff
546
sys/dev/mrsas/mrsas_ioctl.c
Normal file
546
sys/dev/mrsas/mrsas_ioctl.c
Normal file
@ -0,0 +1,546 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <dev/mrsas/mrsas.h>
|
||||
#include <dev/mrsas/mrsas_ioctl.h>
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
int mrsas_alloc_mfi_cmds(struct mrsas_softc *sc);
|
||||
int mrsas_passthru(struct mrsas_softc *sc, void *arg);
|
||||
void mrsas_free_ioc_cmd(struct mrsas_softc *sc);
|
||||
void mrsas_free_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd);
|
||||
void mrsas_dump_dcmd(struct mrsas_softc *sc, struct mrsas_dcmd_frame* dcmd);
|
||||
void mrsas_dump_ioctl(struct mrsas_softc *sc, struct mrsas_iocpacket *user_ioc);
|
||||
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,
|
||||
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,
|
||||
struct mrsas_mfi_cmd *cmd);
|
||||
|
||||
|
||||
/**
|
||||
* mrsas_dump_ioctl: Print debug output for DCMDs
|
||||
* input: Adapter instance soft state
|
||||
* DCMD frame structure
|
||||
*
|
||||
* This function is called from mrsas_passthru() to print out debug information
|
||||
* in the handling and routing of DCMD commands.
|
||||
*/
|
||||
void mrsas_dump_dcmd( struct mrsas_softc *sc, struct mrsas_dcmd_frame* dcmd )
|
||||
{
|
||||
int i;
|
||||
|
||||
device_printf(sc->mrsas_dev, "dcmd->cmd: 0x%02hhx\n", dcmd->cmd);
|
||||
device_printf(sc->mrsas_dev, "dcmd->cmd_status: 0x%02hhx\n", dcmd->cmd_status);
|
||||
device_printf(sc->mrsas_dev, "dcmd->sge_count: 0x%02hhx\n", dcmd->sge_count);
|
||||
device_printf(sc->mrsas_dev, "dcmd->context: 0x%08x\n", dcmd->context);
|
||||
device_printf(sc->mrsas_dev, "dcmd->flags: 0x%04hx\n", dcmd->flags);
|
||||
device_printf(sc->mrsas_dev, "dcmd->timeout: 0x%04hx\n", dcmd->timeout);
|
||||
device_printf(sc->mrsas_dev, "dcmd->data_xfer_len: 0x%08x\n", dcmd->data_xfer_len);
|
||||
device_printf(sc->mrsas_dev, "dcmd->opcode: 0x%08x\n", dcmd->opcode);
|
||||
device_printf(sc->mrsas_dev, "dcmd->mbox.w[0]: 0x%08x\n", dcmd->mbox.w[0]);
|
||||
device_printf(sc->mrsas_dev, "dcmd->mbox.w[1]: 0x%08x\n", dcmd->mbox.w[1]);
|
||||
device_printf(sc->mrsas_dev, "dcmd->mbox.w[2]: 0x%08x\n", dcmd->mbox.w[2]);
|
||||
for (i=0; i< MIN(MAX_IOCTL_SGE, dcmd->sge_count); i++) {
|
||||
device_printf(sc->mrsas_dev, "sgl[%02d]\n", i);
|
||||
device_printf(sc->mrsas_dev, " sge32[%02d].phys_addr: 0x%08x\n",
|
||||
i, dcmd->sgl.sge32[i].phys_addr);
|
||||
device_printf(sc->mrsas_dev, " sge32[%02d].length: 0x%08x\n",
|
||||
i, dcmd->sgl.sge32[i].length);
|
||||
device_printf(sc->mrsas_dev, " sge64[%02d].phys_addr: 0x%08llx\n",
|
||||
i, (long long unsigned int) dcmd->sgl.sge64[i].phys_addr);
|
||||
device_printf(sc->mrsas_dev, " sge64[%02d].length: 0x%08x\n",
|
||||
i, dcmd->sgl.sge64[i].length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* mrsas_dump_ioctl: Print debug output for ioctl
|
||||
* input: Adapter instance soft state
|
||||
* iocpacket structure
|
||||
*
|
||||
* This function is called from mrsas_passthru() to print out debug information
|
||||
* in the handling and routing of ioctl commands.
|
||||
*/
|
||||
void mrsas_dump_ioctl(struct mrsas_softc *sc, struct mrsas_iocpacket *user_ioc)
|
||||
{
|
||||
union mrsas_frame *in_cmd = (union mrsas_frame *) &(user_ioc->frame.raw);
|
||||
struct mrsas_dcmd_frame* dcmd = (struct mrsas_dcmd_frame *) &(in_cmd->dcmd);
|
||||
int i;
|
||||
|
||||
device_printf(sc->mrsas_dev,
|
||||
"====== In %s() ======================================\n", __func__);
|
||||
device_printf(sc->mrsas_dev, "host_no: 0x%04hx\n", user_ioc->host_no);
|
||||
device_printf(sc->mrsas_dev, " __pad1: 0x%04hx\n", user_ioc->__pad1);
|
||||
device_printf(sc->mrsas_dev, "sgl_off: 0x%08x\n", user_ioc->sgl_off);
|
||||
device_printf(sc->mrsas_dev, "sge_count: 0x%08x\n", user_ioc->sge_count);
|
||||
device_printf(sc->mrsas_dev, "sense_off: 0x%08x\n", user_ioc->sense_off);
|
||||
device_printf(sc->mrsas_dev, "sense_len: 0x%08x\n", user_ioc->sense_len);
|
||||
|
||||
mrsas_dump_dcmd(sc, dcmd);
|
||||
|
||||
for (i=0; i< MIN(MAX_IOCTL_SGE, user_ioc->sge_count); i++) {
|
||||
device_printf(sc->mrsas_dev, "sge[%02d]\n", i);
|
||||
device_printf(sc->mrsas_dev,
|
||||
" iov_base: %p\n", user_ioc->sgl[i].iov_base);
|
||||
device_printf(sc->mrsas_dev, " iov_len: %p\n",
|
||||
(void*)user_ioc->sgl[i].iov_len);
|
||||
}
|
||||
device_printf(sc->mrsas_dev,
|
||||
"==================================================================\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* mrsas_passthru: Handle pass-through commands
|
||||
* input: Adapter instance soft state
|
||||
* argument pointer
|
||||
*
|
||||
* 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 )
|
||||
{
|
||||
struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg;
|
||||
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
|
||||
bus_dma_tag_t ioctl_sense_tag = 0;
|
||||
bus_dmamap_t ioctl_sense_dmamap = 0;
|
||||
void *ioctl_sense_mem = 0;
|
||||
bus_addr_t ioctl_sense_phys_addr = 0;
|
||||
int i, adapter, ioctl_data_size, ioctl_sense_size, ret=0;
|
||||
struct mrsas_sge32 *kern_sge32;
|
||||
unsigned long *sense_ptr;
|
||||
|
||||
/* For debug - uncomment the following line for debug output */
|
||||
//mrsas_dump_ioctl(sc, user_ioc);
|
||||
|
||||
/*
|
||||
* 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 host_no */
|
||||
adapter = user_ioc->host_no;
|
||||
if (adapter != device_get_unit(sc->mrsas_dev)) {
|
||||
device_printf(sc->mrsas_dev, "In %s() IOCTL not for me!\n", __func__);
|
||||
return(ENOENT);
|
||||
}
|
||||
|
||||
/* 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
|
||||
*/
|
||||
memcpy(cmd->frame, user_ioc->frame.raw, 2 * MEGAMFI_FRAME_SIZE);
|
||||
cmd->frame->hdr.context = cmd->index;
|
||||
cmd->frame->hdr.pad_0 = 0;
|
||||
cmd->frame->hdr.flags &= ~(MFI_FRAME_IEEE | MFI_FRAME_SGL64 |
|
||||
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.
|
||||
*/
|
||||
kern_sge32 = (struct mrsas_sge32 *)
|
||||
((unsigned long)cmd->frame + user_ioc->sgl_off);
|
||||
|
||||
/*
|
||||
* For each user buffer, create a mirror buffer and copy in
|
||||
*/
|
||||
for (i=0; i < user_ioc->sge_count; i++) {
|
||||
if (!user_ioc->sgl[i].iov_len)
|
||||
continue;
|
||||
ioctl_data_size = user_ioc->sgl[i].iov_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_data_size, // maxsize
|
||||
1, // msegments
|
||||
ioctl_data_size, // maxsegsize
|
||||
BUS_DMA_ALLOCNOW, // flags
|
||||
NULL, NULL, // lockfunc, lockarg
|
||||
&ioctl_data_tag[i])) {
|
||||
device_printf(sc->mrsas_dev, "Cannot allocate ioctl data tag\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
if (bus_dmamem_alloc(ioctl_data_tag[i], (void **)&ioctl_data_mem[i],
|
||||
(BUS_DMA_NOWAIT | BUS_DMA_ZERO), &ioctl_data_dmamap[i])) {
|
||||
device_printf(sc->mrsas_dev, "Cannot allocate ioctl data mem\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
if (bus_dmamap_load(ioctl_data_tag[i], ioctl_data_dmamap[i],
|
||||
ioctl_data_mem[i], ioctl_data_size, mrsas_alloc_cb,
|
||||
&ioctl_data_phys_addr[i], BUS_DMA_NOWAIT)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot load ioctl data mem\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
/* Save the physical address and length */
|
||||
kern_sge32[i].phys_addr = (u_int32_t)ioctl_data_phys_addr[i];
|
||||
kern_sge32[i].length = user_ioc->sgl[i].iov_len;
|
||||
|
||||
/* Copy in data from user space */
|
||||
ret = copyin(user_ioc->sgl[i].iov_base, ioctl_data_mem[i],
|
||||
user_ioc->sgl[i].iov_len);
|
||||
if (ret) {
|
||||
device_printf(sc->mrsas_dev, "IOCTL copyin failed!\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
&ioctl_sense_tag)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot allocate ioctl sense tag\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
if (bus_dmamem_alloc(ioctl_sense_tag, (void **)&ioctl_sense_mem,
|
||||
(BUS_DMA_NOWAIT | BUS_DMA_ZERO), &ioctl_sense_dmamap)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot allocate ioctl data mem\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
if (bus_dmamap_load(ioctl_sense_tag, ioctl_sense_dmamap,
|
||||
ioctl_sense_mem, ioctl_sense_size, mrsas_alloc_cb,
|
||||
&ioctl_sense_phys_addr, BUS_DMA_NOWAIT)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot load ioctl sense mem\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
sense_ptr =
|
||||
(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
|
||||
*/
|
||||
cmd->sync_cmd = 1;
|
||||
mrsas_issue_blocked_cmd(sc, cmd);
|
||||
cmd->sync_cmd = 0;
|
||||
|
||||
/*
|
||||
* copy out the kernel buffers to user buffers
|
||||
*/
|
||||
for (i = 0; i < user_ioc->sge_count; i++) {
|
||||
ret = copyout(ioctl_data_mem[i], user_ioc->sgl[i].iov_base,
|
||||
user_ioc->sgl[i].iov_len);
|
||||
if (ret) {
|
||||
device_printf(sc->mrsas_dev, "IOCTL copyout failed!\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* copy out the sense
|
||||
*/
|
||||
if (user_ioc->sense_len) {
|
||||
/*
|
||||
* 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);
|
||||
ret = copyout(ioctl_sense_mem, (unsigned long*)*sense_ptr,
|
||||
user_ioc->sense_len);
|
||||
if (ret) {
|
||||
device_printf(sc->mrsas_dev, "IOCTL sense copyout failed!\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return command status to user space
|
||||
*/
|
||||
memcpy(&user_ioc->frame.hdr.cmd_status, &cmd->frame->hdr.cmd_status,
|
||||
sizeof(u_int8_t));
|
||||
|
||||
out:
|
||||
/*
|
||||
* Release sense buffer
|
||||
*/
|
||||
if (ioctl_sense_phys_addr)
|
||||
bus_dmamap_unload(ioctl_sense_tag, ioctl_sense_dmamap);
|
||||
if (ioctl_sense_mem)
|
||||
bus_dmamem_free(ioctl_sense_tag, ioctl_sense_mem, ioctl_sense_dmamap);
|
||||
if (ioctl_sense_tag)
|
||||
bus_dma_tag_destroy(ioctl_sense_tag);
|
||||
|
||||
/*
|
||||
* Release data buffers
|
||||
*/
|
||||
for (i = 0; i < user_ioc->sge_count; i++) {
|
||||
if (!user_ioc->sgl[i].iov_len)
|
||||
continue;
|
||||
if (ioctl_data_phys_addr[i])
|
||||
bus_dmamap_unload(ioctl_data_tag[i], ioctl_data_dmamap[i]);
|
||||
if (ioctl_data_mem[i] != NULL)
|
||||
bus_dmamem_free(ioctl_data_tag[i], ioctl_data_mem[i],
|
||||
ioctl_data_dmamap[i]);
|
||||
if (ioctl_data_tag[i] != NULL)
|
||||
bus_dma_tag_destroy(ioctl_data_tag[i]);
|
||||
}
|
||||
|
||||
/* Free command */
|
||||
mrsas_release_mfi_cmd(cmd);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* mrsas_alloc_mfi_cmds: Allocates the command packets
|
||||
* input: Adapter instance soft state
|
||||
*
|
||||
* Each IOCTL or passthru command that is issued to the FW are wrapped in a
|
||||
* local data structure called mrsas_mfi_cmd. The frame embedded in this
|
||||
* mrsas_mfi is issued to FW. The array is used only to look up the
|
||||
* 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 i, j;
|
||||
u_int32_t max_cmd;
|
||||
struct mrsas_mfi_cmd *cmd;
|
||||
|
||||
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 = malloc(sizeof(struct mrsas_mfi_cmd*)*max_cmd, M_MRSAS, M_NOWAIT);
|
||||
if (!sc->mfi_cmd_list) {
|
||||
device_printf(sc->mrsas_dev, "Cannot alloc memory for mfi_cmd cmd_list.\n");
|
||||
return(ENOMEM);
|
||||
}
|
||||
memset(sc->mfi_cmd_list, 0, sizeof(struct mrsas_mfi_cmd *)*max_cmd);
|
||||
for (i = 0; i < max_cmd; i++) {
|
||||
sc->mfi_cmd_list[i] = malloc(sizeof(struct mrsas_mfi_cmd),
|
||||
M_MRSAS, M_NOWAIT);
|
||||
if (!sc->mfi_cmd_list[i]) {
|
||||
for (j = 0; j < i; j++)
|
||||
free(sc->mfi_cmd_list[j],M_MRSAS);
|
||||
free(sc->mfi_cmd_list, M_MRSAS);
|
||||
sc->mfi_cmd_list = NULL;
|
||||
return(ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < max_cmd; i++) {
|
||||
cmd = sc->mfi_cmd_list[i];
|
||||
memset(cmd, 0, sizeof(struct mrsas_mfi_cmd));
|
||||
cmd->index = i;
|
||||
cmd->ccb_ptr = NULL;
|
||||
cmd->sc = sc;
|
||||
TAILQ_INSERT_TAIL(&(sc->mrsas_mfi_cmd_list_head), cmd, next);
|
||||
}
|
||||
|
||||
/* 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
|
||||
cmd = sc->mfi_cmd_list[i];
|
||||
mrsas_free_frame(sc, cmd);
|
||||
}
|
||||
if (sc->mficmd_frame_tag != NULL)
|
||||
bus_dma_tag_destroy(sc->mficmd_frame_tag);
|
||||
return(ENOMEM);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* filling MFI frame and the SG list that immediately follows the frame. This
|
||||
* function creates those DMA memory buffers for each command packet by using
|
||||
* 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)
|
||||
{
|
||||
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
|
||||
&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);
|
||||
if (cmd->frame == NULL) {
|
||||
device_printf(sc->mrsas_dev, "Cannot alloc MFI frame memory\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
memset(cmd->frame, 0, MRSAS_MFI_FRAME_SIZE);
|
||||
cmd->frame->io.context = cmd->index;
|
||||
cmd->frame->io.pad_0 = 0;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void *mrsas_alloc_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
|
||||
{
|
||||
u_int32_t frame_size = MRSAS_MFI_FRAME_SIZE;
|
||||
|
||||
if (bus_dmamem_alloc(sc->mficmd_frame_tag, (void **)&cmd->frame_mem,
|
||||
BUS_DMA_NOWAIT, &cmd->frame_dmamap)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot alloc MFI frame memory\n");
|
||||
return (NULL);
|
||||
}
|
||||
if (bus_dmamap_load(sc->mficmd_frame_tag, cmd->frame_dmamap,
|
||||
cmd->frame_mem, frame_size, mrsas_alloc_cb,
|
||||
&cmd->frame_phys_addr, BUS_DMA_NOWAIT)) {
|
||||
device_printf(sc->mrsas_dev, "Cannot load IO request memory\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
return(cmd->frame_mem);
|
||||
}
|
||||
|
||||
/*
|
||||
* mrsas_alloc_cb: Callback function of bus_dmamap_load()
|
||||
* input: callback argument,
|
||||
* machine dependent type that describes DMA segments,
|
||||
* 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.
|
||||
*/
|
||||
static void mrsas_alloc_cb(void *arg, bus_dma_segment_t *segs,
|
||||
int nsegs, int error)
|
||||
{
|
||||
bus_addr_t *addr;
|
||||
|
||||
addr = arg;
|
||||
*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.
|
||||
*/
|
||||
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);
|
||||
if (cmd->frame_mem != NULL)
|
||||
bus_dmamem_free(sc->mficmd_frame_tag, cmd->frame_mem, cmd->frame_dmamap);
|
||||
}
|
97
sys/dev/mrsas/mrsas_ioctl.h
Normal file
97
sys/dev/mrsas/mrsas_ioctl.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifndef MRSAS_IOCTL_H
|
||||
#define MRSAS_IOCTL_H
|
||||
|
||||
#ifndef _IOWR
|
||||
#include <sys/ioccom.h>
|
||||
#endif /* !_IOWR */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define MRSAS_IOC_FIRMWARE_PASS_THROUGH _IOWR('M', 1, struct mrsas_iocpacket)
|
||||
|
||||
#define MRSAS_IOC_SCAN_BUS _IO('M', 10)
|
||||
|
||||
#define MAX_IOCTL_SGE 16
|
||||
#define MFI_FRAME_DIR_READ 0x0010
|
||||
#define MFI_CMD_LD_SCSI_IO 0x03
|
||||
|
||||
#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 SCSI_SENSE_BUFFERSIZE 96
|
||||
|
||||
#define MEGAMFI_RAW_FRAME_SIZE 128
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
struct mrsas_iocpacket {
|
||||
u_int16_t host_no;
|
||||
u_int16_t __pad1;
|
||||
u_int32_t sgl_off;
|
||||
u_int32_t sge_count;
|
||||
u_int32_t sense_off;
|
||||
u_int32_t sense_len;
|
||||
union {
|
||||
u_int8_t raw[MEGAMFI_RAW_FRAME_SIZE];
|
||||
struct mrsas_header hdr;
|
||||
} frame;
|
||||
struct iovec sgl[MAX_IOCTL_SGE];
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
#endif /* MRSAS_IOCTL_H */
|
@ -219,6 +219,7 @@ SUBDIR= \
|
||||
mps \
|
||||
mpt \
|
||||
mqueue \
|
||||
mrsas \
|
||||
msdosfs \
|
||||
msdosfs_iconv \
|
||||
${_mse} \
|
||||
|
20
sys/modules/mrsas/Makefile
Normal file
20
sys/modules/mrsas/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../dev/mrsas
|
||||
|
||||
KMOD= mrsas
|
||||
SRCS= mrsas.c mrsas_cam.c mrsas_ioctl.c mrsas_fp.c
|
||||
SRCS+= device_if.h bus_if.h pci_if.h opt_cam.h opt_scsi.h
|
||||
|
||||
#CFLAGS+= -MRSAS_DEBUG
|
||||
.include <bsd.kmod.mk>
|
||||
#CFLAGS+= -fgnu89-inline
|
||||
|
||||
clean_cscope:
|
||||
rm -f cscope*
|
||||
|
||||
cscope: clean_cscope
|
||||
/usr/local/bin/cscope -b *.[ch]
|
||||
|
||||
cleanall: clean clean_cscope
|
||||
rm -f '@' machine
|
Loading…
Reference in New Issue
Block a user