Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Update the mpii(4) driver to the latest OpenBSD ...
details: https://anonhg.NetBSD.org/src/rev/429f16758e07
branches: trunk
changeset: 446388:429f16758e07
user: bouyer <bouyer%NetBSD.org@localhost>
date: Mon Dec 03 22:34:36 2018 +0000
description:
Update the mpii(4) driver to the latest OpenBSD version.
This adds support for the SAS3xxx LSI controllers, and this also makes the
driver MP-safe.
adjust mfii.c for changes in mpiireg.h
Tested with a
mpii0: SMC2008-IR, firmware 9.0.0.0 IR, MPI 2.0
diffstat:
sys/dev/pci/mfii.c | 18 +-
sys/dev/pci/mpii.c | 2445 ++++++++++++++++++++++++------------------------
sys/dev/pci/mpiireg.h | 257 ++--
3 files changed, 1396 insertions(+), 1324 deletions(-)
diffs (truncated from 4913 to 300 lines):
diff -r ffcf42e8ef15 -r 429f16758e07 sys/dev/pci/mfii.c
--- a/sys/dev/pci/mfii.c Mon Dec 03 20:00:16 2018 +0000
+++ b/sys/dev/pci/mfii.c Mon Dec 03 22:34:36 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.2 2018/11/24 18:37:16 bouyer Exp $ */
+/* $NetBSD: mfii.c,v 1.3 2018/12/03 22:34:36 bouyer Exp $ */
/* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
/*
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.2 2018/11/24 18:37:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.3 2018/12/03 22:34:36 bouyer Exp $");
#include "bio.h"
@@ -1935,11 +1935,15 @@
iiq->sense_buffer_address_high = htole32(
MFII_DMA_DVA(sc->sc_sense) >> 32);
- iiq->reply_descriptor_post_queue_address = htole64(
- MFII_DMA_DVA(sc->sc_reply_postq));
-
- iiq->system_request_frame_base_address =
- htole64(MFII_DMA_DVA(sc->sc_requests));
+ iiq->reply_descriptor_post_queue_address_lo =
+ htole32(MFII_DMA_DVA(sc->sc_reply_postq));
+ iiq->reply_descriptor_post_queue_address_hi =
+ htole32(MFII_DMA_DVA(sc->sc_reply_postq) >> 32);
+
+ iiq->system_request_frame_base_address_lo =
+ htole32(MFII_DMA_DVA(sc->sc_requests));
+ iiq->system_request_frame_base_address_hi =
+ htole32(MFII_DMA_DVA(sc->sc_requests) >> 32);
iiq->timestamp = htole64(time_uptime);
diff -r ffcf42e8ef15 -r 429f16758e07 sys/dev/pci/mpii.c
--- a/sys/dev/pci/mpii.c Mon Dec 03 20:00:16 2018 +0000
+++ b/sys/dev/pci/mpii.c Mon Dec 03 22:34:36 2018 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: mpii.c,v 1.14 2018/12/02 13:22:28 jdolecek Exp $ */
-/* OpenBSD: mpii.c,v 1.51 2012/04/11 13:29:14 naddy Exp */
+/* $NetBSD: mpii.c,v 1.15 2018/12/03 22:34:36 bouyer Exp $ */
+/* $OpenBSD: mpii.c,v 1.115 2018/08/14 05:22:21 jmatthew Exp $ */
/*
- * Copyright (c) 2010 Mike Belopuhov <mkb%crypt.org.ru@localhost>
+ * Copyright (c) 2010, 2012 Mike Belopuhov
* Copyright (c) 2009 James Giannoules
* Copyright (c) 2005 - 2010 David Gwynne <dlg%openbsd.org@localhost>
* Copyright (c) 2005 - 2010 Marco Peereboom <marco%openbsd.org@localhost>
@@ -20,7 +20,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.14 2018/12/02 13:22:28 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.15 2018/12/03 22:34:36 bouyer Exp $");
#include "bio.h"
@@ -44,15 +44,15 @@
#include <dev/scsipi/scsi_all.h>
#include <dev/scsipi/scsiconf.h>
-#include <dev/pci/mpiireg.h>
-
#if NBIO > 0
#include <dev/biovar.h>
-#include <dev/sysmon/sysmonvar.h>
+#include <dev/sysmon/sysmonvar.h>
#include <sys/envsys.h>
#endif
-/* #define MPII_DEBUG */
+#include <dev/pci/mpiireg.h>
+
+// #define MPII_DEBUG
#ifdef MPII_DEBUG
#define DPRINTF(x...) do { if (mpii_debug) printf(x); } while(0)
#define DNPRINTF(n,x...) do { if (mpii_debug & (n)) printf(x); } while(0)
@@ -69,42 +69,29 @@
#define MPII_D_EVT (0x0400)
#define MPII_D_CFG (0x0800)
#define MPII_D_MAP (0x1000)
-#if 0
+
u_int32_t mpii_debug = 0
- | MPII_D_CMD
- | MPII_D_INTR
- | MPII_D_MISC
- | MPII_D_DMA
- | MPII_D_IOCTL
- | MPII_D_RW
- | MPII_D_MEM
- | MPII_D_CCB
- | MPII_D_PPR
- | MPII_D_RAID
- | MPII_D_EVT
- | MPII_D_CFG
- | MPII_D_MAP
+// | MPII_D_CMD
+// | MPII_D_INTR
+// | MPII_D_MISC
+// | MPII_D_DMA
+// | MPII_D_IOCTL
+// | MPII_D_RW
+// | MPII_D_MEM
+// | MPII_D_CCB
+// | MPII_D_PPR
+// | MPII_D_RAID
+// | MPII_D_EVT
+// | MPII_D_CFG
+// | MPII_D_MAP
;
-#endif
-u_int32_t mpii_debug = MPII_D_MISC;
#else
#define DPRINTF(x...)
#define DNPRINTF(n,x...)
#endif
-#define MPII_REQUEST_SIZE (512)
-#define MPII_REPLY_SIZE (128)
-#define MPII_REPLY_COUNT PAGE_SIZE / MPII_REPLY_SIZE
-
-/*
- * this is the max number of sge's we can stuff in a request frame:
- * sizeof(scsi_io) + sizeof(sense) + sizeof(sge) * 32 = MPII_REQUEST_SIZE
- */
-#define MPII_MAX_SGL (32)
-
-#define MPII_MAX_REQUEST_CREDIT (128)
-
-#define MPII_MAXFER MAXPHYS /* XXX bogus */
+#define MPII_REQUEST_SIZE (512)
+#define MPII_REQUEST_CREDIT (128)
struct mpii_dmamem {
bus_dmamap_t mdm_map;
@@ -112,23 +99,14 @@
size_t mdm_size;
void *mdm_kva;
};
-#define MPII_DMA_MAP(_mdm) (_mdm)->mdm_map
-#define MPII_DMA_DVA(_mdm) (_mdm)->mdm_map->dm_segs[0].ds_addr
-#define MPII_DMA_KVA(_mdm) (void *)(_mdm)->mdm_kva
-
-struct mpii_ccb_bundle {
- struct mpii_msg_scsi_io mcb_io; /* sgl must follow */
- struct mpii_sge mcb_sgl[MPII_MAX_SGL];
- struct scsi_sense_data mcb_sense;
-} __packed;
+#define MPII_DMA_MAP(_mdm) ((_mdm)->mdm_map)
+#define MPII_DMA_DVA(_mdm) ((uint64_t)(_mdm)->mdm_map->dm_segs[0].ds_addr)
+#define MPII_DMA_KVA(_mdm) ((_mdm)->mdm_kva)
struct mpii_softc;
struct mpii_rcb {
- union {
- struct work rcb_wk; /* has to be first in struct */
- SIMPLEQ_ENTRY(mpii_rcb) rcb_link;
- } u;
+ SIMPLEQ_ENTRY(mpii_rcb) rcb_link;
void *rcb_reply;
u_int32_t rcb_reply_dva;
};
@@ -154,20 +132,19 @@
};
struct mpii_ccb {
- union {
- struct work ccb_wk; /* has to be first in struct */
- SIMPLEQ_ENTRY(mpii_ccb) ccb_link;
- } u;
struct mpii_softc *ccb_sc;
- int ccb_smid;
void * ccb_cookie;
+ kmutex_t ccb_mtx;
+ kcondvar_t ccb_cv;
+
bus_dmamap_t ccb_dmamap;
bus_addr_t ccb_offset;
void *ccb_cmd;
bus_addr_t ccb_cmd_dva;
u_int16_t ccb_dev_handle;
+ u_int16_t ccb_smid;
volatile enum {
MPII_CCB_FREE,
@@ -179,11 +156,7 @@
void (*ccb_done)(struct mpii_ccb *);
struct mpii_rcb *ccb_rcb;
-};
-
-struct mpii_ccb_wait {
- kmutex_t mpii_ccbw_mtx;
- kcondvar_t mpii_ccbw_cv;
+ SIMPLEQ_ENTRY(mpii_ccb) ccb_link;
};
SIMPLEQ_HEAD(mpii_ccb_list, mpii_ccb);
@@ -195,15 +168,18 @@
pcitag_t sc_tag;
void *sc_ih;
-
- int sc_flags;
-#define MPII_F_RAID (1<<1)
+ pci_intr_handle_t *sc_pihp;
struct scsipi_adapter sc_adapt;
struct scsipi_channel sc_chan;
device_t sc_child; /* our scsibus */
+ int sc_flags;
+#define MPII_F_RAID (1<<1)
+#define MPII_F_SAS3 (1<<2)
+
struct mpii_device **sc_devs;
+ kmutex_t sc_devs_mtx;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
@@ -213,42 +189,37 @@
kmutex_t sc_req_mtx;
kmutex_t sc_rep_mtx;
- u_int8_t sc_porttype;
- int sc_request_depth;
- int sc_num_reply_frames;
- int sc_reply_free_qdepth;
- int sc_reply_post_qdepth;
- int sc_maxchdepth;
- int sc_first_sgl_len;
- int sc_chain_len;
- int sc_max_sgl_len;
+ ushort sc_reply_size;
+ ushort sc_request_size;
+
+ ushort sc_max_cmds;
+ ushort sc_num_reply_frames;
+ u_int sc_reply_free_qdepth;
+ u_int sc_reply_post_qdepth;
+
+ ushort sc_chain_sge;
+ ushort sc_max_sgl;
u_int8_t sc_ioc_event_replay;
- u_int16_t sc_max_enclosures;
- u_int16_t sc_max_expanders;
+
+ u_int8_t sc_porttype;
u_int8_t sc_max_volumes;
u_int16_t sc_max_devices;
- u_int16_t sc_max_dpm_entries;
u_int16_t sc_vd_count;
u_int16_t sc_vd_id_low;
u_int16_t sc_pd_id_start;
- u_int8_t sc_num_channels;
int sc_ioc_number;
u_int8_t sc_vf_id;
- u_int8_t sc_num_ports;
struct mpii_ccb *sc_ccbs;
struct mpii_ccb_list sc_ccb_free;
kmutex_t sc_ccb_free_mtx;
kcondvar_t sc_ccb_free_cv;
- kmutex_t sc_ccb_mtx;
- /*
- * this protects the ccb state and list entry
- * between mpii_scsi_cmd and scsidone.
- */
-
+ struct mpii_ccb_list sc_ccb_tmos;
+ kmutex_t sc_ssb_tmomtx;
struct workqueue *sc_ssb_tmowk;
+ struct work sc_ssb_tmowork;
struct mpii_dmamem *sc_requests;
@@ -257,139 +228,149 @@
struct mpii_dmamem *sc_reply_postq;
struct mpii_reply_descr *sc_reply_postq_kva;
- int sc_reply_post_host_index;
+ u_int sc_reply_post_host_index;
struct mpii_dmamem *sc_reply_freeq;
- int sc_reply_free_host_index;
-
- struct workqueue *sc_ssb_evt_ackwk;
+ u_int sc_reply_free_host_index;
+ kmutex_t sc_reply_free_mtx;
Home |
Main Index |
Thread Index |
Old Index