diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2007-09-29 16:03:44 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2007-09-29 16:03:44 +0000 |
commit | ccc35bca5fbf1b9596d9d84e7a86bc0132dc7abb (patch) | |
tree | 9cee8829067dc3a0ba02f1edf9c6ba74c8e3b474 /sys/dev | |
parent | a99402a30cb18c71b3ee1e4447b53e95f24a3948 (diff) |
Add first part of queue magic to attach.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/qli_pci.c | 45 | ||||
-rw-r--r-- | sys/dev/pci/qlireg.h | 19 |
2 files changed, 57 insertions, 7 deletions
diff --git a/sys/dev/pci/qli_pci.c b/sys/dev/pci/qli_pci.c index 75bfd4c4790..bc6e845b5b5 100644 --- a/sys/dev/pci/qli_pci.c +++ b/sys/dev/pci/qli_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qli_pci.c,v 1.9 2007/09/09 18:02:30 marco Exp $ */ +/* $OpenBSD: qli_pci.c,v 1.10 2007/09/29 16:03:43 marco Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2007 David Collins <dave@davec.name> @@ -76,6 +76,12 @@ struct qli_softc { /* firmware control block */ struct qli_mem *sc_fw_cb; + + /* queues */ + unsigned int sc_queues_len; + struct qli_mem *sc_queues; + bus_addr_t sc_request_dva; + struct qli_queue_entry *sc_request_ring; }; /* #define QLI_DEBUG */ @@ -123,6 +129,8 @@ struct qli_mem { #define QLIMEM_MAP(_am) ((_am)->am_map) #define QLIMEM_DVA(_am) ((_am)->am_map->dm_segs[0].ds_addr) #define QLIMEM_KVA(_am) ((void *)(_am)->am_kva) +#define QLIMEM_ALIGN (MAX(QLI_REQUESTQ_DEPTH, QLI_RESPONSEQ_DEPTH) *\ + sizeof(struct qli_queue_entry)) struct qli_mem *qli_allocmem(struct qli_softc *, size_t); void qli_freemem(struct qli_softc *, struct qli_mem *); @@ -887,6 +895,7 @@ qli_attach(struct qli_softc *sc) /* struct scsibus_attach_args saa; */ int rv = 1; u_int32_t f, mbox[QLI_MBOX_SIZE]; + unsigned int align; DNPRINTF(QLI_D_MISC, "%s: qli_attach\n", DEVNAME(sc)); @@ -929,19 +938,41 @@ qli_attach(struct qli_softc *sc) if (sc->sc_fw_cb == NULL) { printf("%s: unable to allocate firmware control block memory\n", DEVNAME(sc)); - goto nofwcb; + goto done; } bzero(mbox, sizeof(mbox)); mbox[0] = QLI_MBOX_OPC_GET_INITIAL_FW_CB; - mbox[2] = htole32((u_int32_t)QLIMEM_DVA(sc->sc_fw_cb)); - mbox[3] = htole32((u_int32_t)((u_int64_t)QLIMEM_DVA(sc->sc_fw_cb) >> - 32)); + mbox[2] = (u_int32_t)QLIMEM_DVA(sc->sc_fw_cb); + mbox[3] = (u_int32_t)((u_int64_t)QLIMEM_DVA(sc->sc_fw_cb) >> 32); if (qli_mgmt(sc, 4, mbox)) { printf("%s: get initial firmware control block failed\n", DEVNAME(sc)); - goto done; + goto nofwcb; + } + + /* setup queues & shadow registers */ + sc->sc_queues_len = (QLI_REQUESTQ_DEPTH * QLI_QUEUE_SIZE) + + (QLI_RESPONSEQ_DEPTH * QLI_QUEUE_SIZE) + + sizeof(struct qli_shadow_regs) + + QLIMEM_ALIGN + PAGE_SIZE - 1; + sc->sc_queues_len &= ~(PAGE_SIZE - 1); + + sc->sc_queues = qli_allocmem(sc, sc->sc_queues_len); + if (sc->sc_queues == NULL) { + printf("%s: unable to allocate firmware control block memory\n", + DEVNAME(sc)); + goto nofwcb; } + if (QLIMEM_DVA(sc->sc_queues) & (QLIMEM_ALIGN - 1)) + align = QLIMEM_ALIGN - + (QLIMEM_DVA(sc->sc_queues) & (QLIMEM_ALIGN - 1)); + else + align = 0; + + sc->sc_request_dva = QLIMEM_DVA(sc->sc_queues) + align; + sc->sc_request_ring = QLIMEM_KVA(sc->sc_queues) + align; + #if 0 /* enable interrupts */ qli_enable_interrupts(sc); @@ -961,6 +992,8 @@ qli_attach(struct qli_softc *sc) done: return (rv); +/* noqueues: */ + qli_freemem(sc, sc->sc_queues); nofwcb: qli_freemem(sc, sc->sc_fw_cb); return (rv); diff --git a/sys/dev/pci/qlireg.h b/sys/dev/pci/qlireg.h index 001a88e3c3c..1bae226d679 100644 --- a/sys/dev/pci/qlireg.h +++ b/sys/dev/pci/qlireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: qlireg.h,v 1.7 2007/09/09 18:02:30 marco Exp $ */ +/* $OpenBSD: qlireg.h,v 1.8 2007/09/29 16:03:43 marco Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2007 David Collins <dave@davec.name> @@ -321,6 +321,7 @@ struct qli_reg { /* mailbox commands */ #define QLI_MBOX_OPC_ABOUT_FIRMWARE (0x09) +#define QLI_MBOX_OPC_GET_FW_STATUS (0x1f) #define QLI_MBOX_OPC_GET_INITIAL_FW_CB (0x61) #define QLI_MBOX_OPC_GET_FW_STATE (0x69) /* mbox 1 firmware state */ @@ -628,3 +629,19 @@ struct qli_cb { u_int8_t qcb_ipv6_router_ad_lnk_mtu[4]; u_int8_t qcb_ipv6_res1[140]; } __packed; + +/* queues */ +#define QLI_REQUESTQ_DEPTH (1024) +#define QLI_QUEUE_SIZE (64) +#define QLI_RESPONSEQ_DEPTH (64) + +struct qli_queue_entry { + u_int8_t qqe_data[60]; + u_int32_t qqe_signature; +} __packed; + +/* shadow regs */ +struct qli_shadow_regs { + u_int32_t qsr_req_q; + u_int32_t qsr_resp_q; +} __packed; |