1999-10-07 02:23:12 +00:00
|
|
|
/*-
|
2000-08-30 07:52:50 +00:00
|
|
|
* Copyright (c) 1999,2000 Michael Smith
|
|
|
|
* Copyright (c) 2000 BSDi
|
1999-10-07 02:23:12 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*
|
2002-10-30 22:00:11 +00:00
|
|
|
* Copyright (c) 2002 Eric Moore
|
|
|
|
* Copyright (c) 2002 LSI Logic Corporation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
2002-10-18 21:29:14 +00:00
|
|
|
* 3. The party using or redistributing the source code and binary forms
|
2002-10-30 22:00:11 +00:00
|
|
|
* agrees to the disclaimer below and the terms and conditions set forth
|
2002-10-18 21:29:14 +00:00
|
|
|
* herein.
|
|
|
|
*
|
2002-10-30 22:00:11 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*
|
2002-10-18 21:29:14 +00:00
|
|
|
*
|
1999-10-07 02:23:12 +00:00
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
2005-08-07 23:53:00 +00:00
|
|
|
#include <geom/geom_disk.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
1999-10-07 02:23:12 +00:00
|
|
|
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
#define LSI_DESC_PCI "LSILogic MegaRAID 1.53"
|
2005-01-23 23:25:41 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
#ifdef AMR_DEBUG
|
2001-12-10 08:09:49 +00:00
|
|
|
# define debug(level, fmt, args...) do {if (level <= AMR_DEBUG) printf("%s: " fmt "\n", __func__ , ##args);} while(0)
|
|
|
|
# define debug_called(level) do {if (level <= AMR_DEBUG) printf("%s: called\n", __func__);} while(0)
|
2000-08-30 07:52:50 +00:00
|
|
|
#else
|
2010-07-28 16:24:11 +00:00
|
|
|
# define debug(level, fmt, args...) do {} while (0)
|
|
|
|
# define debug_called(level) do {} while (0)
|
2000-08-30 07:52:50 +00:00
|
|
|
#endif
|
2001-12-10 08:09:49 +00:00
|
|
|
#define xdebug(fmt, args...) printf("%s: " fmt "\n", __func__ , ##args)
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Per-logical-drive datastructure
|
|
|
|
*/
|
|
|
|
struct amr_logdrive
|
|
|
|
{
|
|
|
|
u_int32_t al_size;
|
|
|
|
int al_state;
|
|
|
|
int al_properties;
|
|
|
|
|
|
|
|
/* synthetic geometry */
|
|
|
|
int al_cylinders;
|
|
|
|
int al_heads;
|
|
|
|
int al_sectors;
|
|
|
|
|
|
|
|
/* driver */
|
|
|
|
device_t al_disk;
|
|
|
|
};
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Due to the difficulty of using the zone allocator to create a new
|
|
|
|
* zone from within a module, we use our own clustering to reduce
|
|
|
|
* memory wastage due to allocating lots of these small structures.
|
|
|
|
*
|
|
|
|
* 16k gives us a little under 200 command structures, which should
|
|
|
|
* normally be plenty. We will grab more if we need them.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define AMR_CMD_CLUSTERSIZE (16 * 1024)
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
typedef STAILQ_HEAD(, amr_command) ac_qhead_t;
|
|
|
|
typedef STAILQ_ENTRY(amr_command) ac_link_t;
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
union amr_ccb {
|
|
|
|
struct amr_passthrough ccb_pthru;
|
|
|
|
struct amr_ext_passthrough ccb_epthru;
|
|
|
|
uint8_t bytes[128];
|
|
|
|
};
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
|
|
|
* Per-command control structure.
|
|
|
|
*/
|
|
|
|
struct amr_command
|
|
|
|
{
|
2008-01-24 07:26:53 +00:00
|
|
|
ac_link_t ac_link;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
struct amr_softc *ac_sc;
|
|
|
|
u_int8_t ac_slot;
|
2000-08-30 07:52:50 +00:00
|
|
|
int ac_status; /* command completion status */
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
union {
|
|
|
|
struct amr_sgentry *sg32;
|
|
|
|
struct amr_sg64entry *sg64;
|
|
|
|
} ac_sg;
|
|
|
|
u_int32_t ac_sgbusaddr;
|
|
|
|
u_int32_t ac_sg64_lo;
|
|
|
|
u_int32_t ac_sg64_hi;
|
1999-10-07 02:23:12 +00:00
|
|
|
struct amr_mailbox ac_mailbox;
|
|
|
|
int ac_flags;
|
|
|
|
#define AMR_CMD_DATAIN (1<<0)
|
|
|
|
#define AMR_CMD_DATAOUT (1<<1)
|
2007-12-12 05:55:03 +00:00
|
|
|
#define AMR_CMD_CCB (1<<2)
|
2000-08-30 07:52:50 +00:00
|
|
|
#define AMR_CMD_PRIORITY (1<<4)
|
|
|
|
#define AMR_CMD_MAPPED (1<<5)
|
|
|
|
#define AMR_CMD_SLEEP (1<<6)
|
|
|
|
#define AMR_CMD_BUSY (1<<7)
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
#define AMR_CMD_SG64 (1<<8)
|
|
|
|
#define AC_IS_SG64(ac) ((ac)->ac_flags & AMR_CMD_SG64)
|
2008-01-24 07:26:53 +00:00
|
|
|
u_int ac_retries;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
struct bio *ac_bio;
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
void (* ac_complete)(struct amr_command *ac);
|
|
|
|
void *ac_private;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
void *ac_data;
|
|
|
|
size_t ac_length;
|
|
|
|
bus_dmamap_t ac_dmamap;
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
bus_dmamap_t ac_dma64map;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
bus_dma_tag_t ac_tag;
|
|
|
|
bus_dmamap_t ac_datamap;
|
|
|
|
int ac_nsegments;
|
|
|
|
uint32_t ac_mb_physaddr;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
union amr_ccb *ac_ccb;
|
|
|
|
uint32_t ac_ccb_busaddr;
|
1999-10-07 02:23:12 +00:00
|
|
|
};
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_command_cluster
|
|
|
|
{
|
|
|
|
TAILQ_ENTRY(amr_command_cluster) acc_link;
|
|
|
|
struct amr_command acc_command[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define AMR_CMD_CLUSTERCOUNT ((AMR_CMD_CLUSTERSIZE - sizeof(struct amr_command_cluster)) / \
|
|
|
|
sizeof(struct amr_command))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Per-controller-instance data
|
|
|
|
*/
|
1999-10-07 02:23:12 +00:00
|
|
|
struct amr_softc
|
|
|
|
{
|
|
|
|
/* bus attachments */
|
|
|
|
device_t amr_dev;
|
|
|
|
struct resource *amr_reg; /* control registers */
|
|
|
|
bus_space_handle_t amr_bhandle;
|
|
|
|
bus_space_tag_t amr_btag;
|
|
|
|
bus_dma_tag_t amr_parent_dmat; /* parent DMA tag */
|
|
|
|
bus_dma_tag_t amr_buffer_dmat; /* data buffer DMA tag */
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
bus_dma_tag_t amr_buffer64_dmat;
|
1999-10-07 02:23:12 +00:00
|
|
|
struct resource *amr_irq; /* interrupt */
|
|
|
|
void *amr_intr;
|
|
|
|
|
|
|
|
/* mailbox */
|
2000-03-23 18:33:19 +00:00
|
|
|
volatile struct amr_mailbox *amr_mailbox;
|
|
|
|
volatile struct amr_mailbox64 *amr_mailbox64;
|
1999-10-07 02:23:12 +00:00
|
|
|
u_int32_t amr_mailboxphys;
|
|
|
|
bus_dma_tag_t amr_mailbox_dmat;
|
|
|
|
bus_dmamap_t amr_mailbox_dmamap;
|
|
|
|
|
|
|
|
/* scatter/gather lists and their controller-visible mappings */
|
|
|
|
struct amr_sgentry *amr_sgtable; /* s/g lists */
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
struct amr_sg64entry *amr_sg64table; /* 64bit s/g lists */
|
1999-10-07 02:23:12 +00:00
|
|
|
u_int32_t amr_sgbusaddr; /* s/g table base address in bus space */
|
|
|
|
bus_dma_tag_t amr_sg_dmat; /* s/g buffer DMA tag */
|
|
|
|
bus_dmamap_t amr_sg_dmamap; /* map for s/g buffers */
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
union amr_ccb *amr_ccb;
|
|
|
|
uint32_t amr_ccb_busaddr;
|
|
|
|
bus_dma_tag_t amr_ccb_dmat;
|
|
|
|
bus_dmamap_t amr_ccb_dmamap;
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/* controller limits and features */
|
2005-01-16 07:34:26 +00:00
|
|
|
int amr_nextslot; /* Next slot to use for newly allocated commands */
|
1999-10-07 02:23:12 +00:00
|
|
|
int amr_maxio; /* maximum number of I/O transactions */
|
|
|
|
int amr_maxdrives; /* max number of logical drives */
|
2000-08-30 07:52:50 +00:00
|
|
|
int amr_maxchan; /* count of SCSI channels */
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/* connected logical drives */
|
|
|
|
struct amr_logdrive amr_drive[AMR_MAXLD];
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* controller state */
|
1999-10-07 02:23:12 +00:00
|
|
|
int amr_state;
|
|
|
|
#define AMR_STATE_OPEN (1<<0)
|
|
|
|
#define AMR_STATE_SUSPEND (1<<1)
|
|
|
|
#define AMR_STATE_INTEN (1<<2)
|
|
|
|
#define AMR_STATE_SHUTDOWN (1<<3)
|
2004-07-01 06:56:10 +00:00
|
|
|
#define AMR_STATE_CRASHDUMP (1<<4)
|
2004-12-05 23:48:17 +00:00
|
|
|
#define AMR_STATE_QUEUE_FRZN (1<<5)
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
#define AMR_STATE_LD_DELETE (1<<6)
|
|
|
|
#define AMR_STATE_REMAP_LD (1<<7)
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/* per-controller queues */
|
2000-08-30 07:52:50 +00:00
|
|
|
struct bio_queue_head amr_bioq; /* pending I/O with no commands */
|
2008-01-24 07:26:53 +00:00
|
|
|
ac_qhead_t amr_ready; /* commands ready to be submitted */
|
1999-10-07 02:23:12 +00:00
|
|
|
struct amr_command *amr_busycmd[AMR_MAXCMD];
|
2000-08-30 07:52:50 +00:00
|
|
|
int amr_busyslots;
|
2008-01-24 07:26:53 +00:00
|
|
|
ac_qhead_t amr_freecmds;
|
2000-08-30 07:52:50 +00:00
|
|
|
TAILQ_HEAD(,amr_command_cluster) amr_cmd_clusters;
|
|
|
|
|
|
|
|
/* CAM attachments for passthrough */
|
|
|
|
struct cam_sim *amr_cam_sim[AMR_MAX_CHANNELS];
|
|
|
|
TAILQ_HEAD(, ccb_hdr) amr_cam_ccbq;
|
2005-01-10 02:34:26 +00:00
|
|
|
struct cam_devq *amr_cam_devq;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* control device */
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
struct cdev *amr_dev_t;
|
|
|
|
struct mtx amr_list_lock;
|
2000-04-01 00:35:15 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/* controller type-specific support */
|
|
|
|
int amr_type;
|
2000-08-30 07:52:50 +00:00
|
|
|
#define AMR_TYPE_QUARTZ (1<<0)
|
|
|
|
#define AMR_IS_QUARTZ(sc) ((sc)->amr_type & AMR_TYPE_QUARTZ)
|
|
|
|
#define AMR_TYPE_40LD (1<<1)
|
|
|
|
#define AMR_IS_40LD(sc) ((sc)->amr_type & AMR_TYPE_40LD)
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
#define AMR_TYPE_SG64 (1<<2)
|
|
|
|
#define AMR_IS_SG64(sc) ((sc)->amr_type & AMR_TYPE_SG64)
|
2006-02-02 17:50:59 +00:00
|
|
|
int (* amr_submit_command)(struct amr_command *ac);
|
1999-10-07 02:23:12 +00:00
|
|
|
int (* amr_get_work)(struct amr_softc *sc, struct amr_mailbox *mbsave);
|
2002-12-11 20:59:46 +00:00
|
|
|
int (*amr_poll_command)(struct amr_command *ac);
|
2004-12-05 23:48:17 +00:00
|
|
|
int (*amr_poll_command1)(struct amr_softc *sc, struct amr_command *ac);
|
2002-12-11 20:59:46 +00:00
|
|
|
int support_ext_cdb; /* greater than 10 byte cdb support */
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/* misc glue */
|
2008-11-03 00:53:54 +00:00
|
|
|
device_t amr_pass;
|
|
|
|
int (*amr_cam_command)(struct amr_softc *sc, struct amr_command **acp);
|
2000-08-30 07:52:50 +00:00
|
|
|
struct intr_config_hook amr_ich; /* wait-for-interrupts probe hook */
|
|
|
|
struct callout_handle amr_timeout; /* periodic status check */
|
Mega update to the LSI MegaRAID driver:
1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.
2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.
3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.
4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.
Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.
Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.
2005-12-14 03:26:49 +00:00
|
|
|
int amr_allow_vol_config;
|
|
|
|
int amr_linux_no_adapters;
|
|
|
|
int amr_ld_del_supported;
|
|
|
|
struct mtx amr_hw_lock;
|
1999-10-07 02:23:12 +00:00
|
|
|
};
|
|
|
|
|
2000-04-01 00:35:15 +00:00
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Interface between bus connections and driver core.
|
2000-04-01 00:35:15 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
extern int amr_attach(struct amr_softc *sc);
|
|
|
|
extern void amr_free(struct amr_softc *sc);
|
|
|
|
extern int amr_flush(struct amr_softc *sc);
|
|
|
|
extern int amr_done(struct amr_softc *sc);
|
|
|
|
extern void amr_startio(struct amr_softc *sc);
|
2000-04-01 00:35:15 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Command buffer allocation.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
extern struct amr_command *amr_alloccmd(struct amr_softc *sc);
|
|
|
|
extern void amr_releasecmd(struct amr_command *ac);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* MegaRAID logical disk driver
|
|
|
|
*/
|
|
|
|
struct amrd_softc
|
|
|
|
{
|
|
|
|
device_t amrd_dev;
|
|
|
|
struct amr_softc *amrd_controller;
|
|
|
|
struct amr_logdrive *amrd_drive;
|
2004-02-18 21:36:53 +00:00
|
|
|
struct disk *amrd_disk;
|
1999-10-07 02:23:12 +00:00
|
|
|
int amrd_unit;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface between driver core and disk driver (should be using a bus?)
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
extern int amr_submit_bio(struct amr_softc *sc, struct bio *bio);
|
2003-10-10 22:49:40 +00:00
|
|
|
extern int amr_dump_blocks(struct amr_softc *sc, int unit, u_int32_t lba, void *data, int blks);
|
1999-10-07 02:23:12 +00:00
|
|
|
extern void amrd_intr(void *data);
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Enqueue/dequeue functions
|
|
|
|
*/
|
|
|
|
static __inline void
|
|
|
|
amr_enqueue_bio(struct amr_softc *sc, struct bio *bio)
|
|
|
|
{
|
|
|
|
|
|
|
|
bioq_insert_tail(&sc->amr_bioq, bio);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline struct bio *
|
|
|
|
amr_dequeue_bio(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
struct bio *bio;
|
|
|
|
|
|
|
|
if ((bio = bioq_first(&sc->amr_bioq)) != NULL)
|
|
|
|
bioq_remove(&sc->amr_bioq, bio);
|
|
|
|
return(bio);
|
|
|
|
}
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
static __inline void
|
|
|
|
amr_init_qhead(ac_qhead_t *head)
|
|
|
|
{
|
|
|
|
|
|
|
|
STAILQ_INIT(head);
|
|
|
|
}
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
static __inline void
|
|
|
|
amr_enqueue_ready(struct amr_command *ac)
|
|
|
|
{
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
STAILQ_INSERT_TAIL(&ac->ac_sc->amr_ready, ac, ac_link);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
amr_requeue_ready(struct amr_command *ac)
|
|
|
|
{
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
STAILQ_INSERT_HEAD(&ac->ac_sc->amr_ready, ac, ac_link);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline struct amr_command *
|
|
|
|
amr_dequeue_ready(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
if ((ac = STAILQ_FIRST(&sc->amr_ready)) != NULL)
|
|
|
|
STAILQ_REMOVE_HEAD(&sc->amr_ready, ac_link);
|
2000-08-30 07:52:50 +00:00
|
|
|
return(ac);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2008-01-24 07:26:53 +00:00
|
|
|
amr_enqueue_completed(struct amr_command *ac, ac_qhead_t *head)
|
2000-08-30 07:52:50 +00:00
|
|
|
{
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
STAILQ_INSERT_TAIL(head, ac, ac_link);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline struct amr_command *
|
2008-01-24 07:26:53 +00:00
|
|
|
amr_dequeue_completed(struct amr_softc *sc, ac_qhead_t *head)
|
2000-08-30 07:52:50 +00:00
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
if ((ac = STAILQ_FIRST(head)) != NULL)
|
|
|
|
STAILQ_REMOVE_HEAD(head, ac_link);
|
2000-08-30 07:52:50 +00:00
|
|
|
return(ac);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
amr_enqueue_free(struct amr_command *ac)
|
|
|
|
{
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
STAILQ_INSERT_HEAD(&ac->ac_sc->amr_freecmds, ac, ac_link);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline struct amr_command *
|
|
|
|
amr_dequeue_free(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
if ((ac = STAILQ_FIRST(&sc->amr_freecmds)) != NULL)
|
|
|
|
STAILQ_REMOVE_HEAD(&sc->amr_freecmds, ac_link);
|
2000-08-30 07:52:50 +00:00
|
|
|
return(ac);
|
|
|
|
}
|