Lines Matching defs:mpt

131 #include <dev/mpt/mpt_reg.h>
134 #include <dev/mpt/mpilib/mpi_type.h>
135 #include <dev/mpt/mpilib/mpi.h>
136 #include <dev/mpt/mpilib/mpi_cnfg.h>
137 #include <dev/mpt/mpilib/mpi_ioc.h>
138 #include <dev/mpt/mpilib/mpi_raid.h>
141 #include <dev/mpt/mpilib/mpi_init.h>
220 #define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary, \
227 busdma_lock_mutex, &(mpt)->mpt_lock, \
230 struct mpt_softc *mpt;
356 * it as an RX_ID. We can use it to index into mpt->tgt_cmd_ptrs, which
362 #define MPT_MAKE_TAGID(mpt, req, ioindex) \
363 ((ioindex << 18) | (((mpt->sequence++) & 0x3f) << 12) | (req->index & 0xfff))
368 #define MPT_TAG_2_REQ(mpt, tag) mpt->tgt_cmd_ptrs[tag >> 18]
371 #define MPT_TGT_STATE(mpt, req) ((mpt_tgt_state_t *) \
372 (&((uint8_t *)req->req_vbuf)[MPT_RQSL(mpt) - sizeof (mpt_tgt_state_t)]))
408 typedef int mpt_reply_handler_t(struct mpt_softc *mpt, request_t *request,
749 mpt_assign_serno(struct mpt_softc *mpt, request_t *req)
751 if ((req->serno = mpt->sequence++) == 0) {
752 req->serno = mpt->sequence++;
758 #define MPT_LOCK_SETUP(mpt) \
759 mtx_init(&mpt->mpt_lock, "mpt", NULL, MTX_DEF); \
760 mpt->mpt_locksetup = 1
761 #define MPT_LOCK_DESTROY(mpt) \
762 if (mpt->mpt_locksetup) { \
763 mtx_destroy(&mpt->mpt_lock); \
764 mpt->mpt_locksetup = 0; \
767 #define MPT_LOCK(mpt) mtx_lock(&(mpt)->mpt_lock)
768 #define MPT_UNLOCK(mpt) mtx_unlock(&(mpt)->mpt_lock)
769 #define MPT_OWNED(mpt) mtx_owned(&(mpt)->mpt_lock)
770 #define MPT_LOCK_ASSERT(mpt) mtx_assert(&(mpt)->mpt_lock, MA_OWNED)
771 #define mpt_sleep(mpt, ident, priority, wmesg, sbt) \
772 msleep_sbt(ident, &(mpt)->mpt_lock, priority, wmesg, sbt, 0, 0)
777 #define mpt_callout_init(mpt, c) \
778 callout_init_mtx(c, &(mpt)->mpt_lock, 0)
779 #define mpt_callout_drain(mpt, c) \
790 mpt_write(struct mpt_softc *mpt, size_t offset, uint32_t val)
792 bus_space_write_4(mpt->pci_st, mpt->pci_sh, offset, val);
796 mpt_write_stream(struct mpt_softc *mpt, size_t offset, uint32_t val)
798 bus_space_write_stream_4(mpt->pci_st, mpt->pci_sh, offset, val);
802 mpt_read(struct mpt_softc *mpt, int offset)
804 return (bus_space_read_4(mpt->pci_st, mpt->pci_sh, offset));
813 mpt_pio_write(struct mpt_softc *mpt, size_t offset, uint32_t val)
815 KASSERT(mpt->pci_pio_reg != NULL, ("no PIO resource"));
816 bus_space_write_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset, val);
820 mpt_pio_read(struct mpt_softc *mpt, int offset)
822 KASSERT(mpt->pci_pio_reg != NULL, ("no PIO resource"));
823 return (bus_space_read_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset));
833 #define MPT_MAX_REQUESTS(mpt) 512
836 #define MPT_REQ_MEM_SIZE(mpt) (MPT_MAX_REQUESTS(mpt) * MPT_REQUEST_AREA)
857 #define MPT_DUMP_REPLY_FRAME(mpt, reply_frame) \
859 if (mpt->verbose > MPT_PRT_DEBUG) \
860 mpt_dump_reply_frame(mpt, reply_frame); \
863 static __inline uint32_t mpt_pop_reply_queue(struct mpt_softc *mpt);
864 static __inline void mpt_free_reply(struct mpt_softc *mpt, uint32_t ptr);
871 mpt_free_reply(struct mpt_softc *mpt, uint32_t ptr)
873 mpt_write(mpt, MPT_OFFSET_REPLY_Q, ptr);
878 mpt_pop_reply_queue(struct mpt_softc *mpt)
880 return mpt_read(mpt, MPT_OFFSET_REPLY_Q);
888 #define MPT_RQSL(mpt) (mpt->ioc_facts.RequestFrameSize << 2)
891 #define MPT_NSGL(mpt) (MPT_RQSL(mpt) / sizeof (SGE_IO_UNION))
894 #define MPT_NRFM(mpt) (MPT_REQUEST_AREA / MPT_RQSL(mpt))
903 #define MPT_NSGL_FIRST(mpt) \
904 ((MPT_RQSL(mpt) - sizeof (MSG_SCSI_IO_REQUEST) + sizeof (SGE_IO_UNION)) / \
929 #define mpt_lprt(mpt, level, ...) \
931 if ((level) <= (mpt)->verbose) \
932 mpt_prt(mpt, __VA_ARGS__); \
936 #define mpt_lprtc(mpt, level, ...) \
938 if ((level) <= (mpt)->verbose) \
939 mpt_prtc(mpt, __VA_ARGS__); \
952 mpt_tag_2_req(struct mpt_softc *mpt, uint32_t tag)
955 KASSERT(rtg < mpt->tgt_cmds_allocated, ("bad tag %d", tag));
956 KASSERT(mpt->tgt_cmd_ptrs, ("no cmd backpointer array"));
957 KASSERT(mpt->tgt_cmd_ptrs[rtg], ("no cmd backpointer"));
958 return (mpt->tgt_cmd_ptrs[rtg]);
971 mpt_req_on_free_list(struct mpt_softc *mpt, request_t *req)
975 TAILQ_FOREACH(lrq, &mpt->request_free_list, links) {
987 mpt_req_on_pending_list(struct mpt_softc *mpt, request_t *req)
991 TAILQ_FOREACH(lrq, &mpt->request_pending_list, links) {
1009 mpt_req_spcl(struct mpt_softc *mpt, request_t *req, const char *s, int line)
1012 for (i = 0; i < mpt->els_cmds_allocated; i++) {
1013 if (req == mpt->els_cmd_ptrs[i]) {
1017 for (i = 0; i < mpt->tgt_cmds_allocated; i++) {
1018 if (req == mpt->tgt_cmd_ptrs[i]) {
1031 mpt_req_not_spcl(struct mpt_softc *mpt, request_t *req, const char *s, int line)
1034 for (i = 0; i < mpt->els_cmds_allocated; i++) {
1035 KASSERT(req != mpt->els_cmd_ptrs[i],
1040 for (i = 0; i < mpt->tgt_cmds_allocated; i++) {
1041 KASSERT(req != mpt->tgt_cmd_ptrs[i],
1064 void mpt_send_cmd(struct mpt_softc *mpt, request_t *req);
1065 int mpt_recv_handshake_reply(struct mpt_softc *mpt,
1067 int mpt_wait_req(struct mpt_softc *mpt, request_t *req,
1070 void mpt_enable_ints(struct mpt_softc *mpt);
1071 void mpt_disable_ints(struct mpt_softc *mpt);
1072 int mpt_attach(struct mpt_softc *mpt);
1073 int mpt_shutdown(struct mpt_softc *mpt);
1074 int mpt_detach(struct mpt_softc *mpt);
1075 int mpt_send_handshake_cmd(struct mpt_softc *mpt,
1077 request_t * mpt_get_request(struct mpt_softc *mpt, int sleep_ok);
1078 void mpt_free_request(struct mpt_softc *mpt, request_t *req);
1080 void mpt_check_doorbell(struct mpt_softc *mpt);
1081 void mpt_dump_reply_frame(struct mpt_softc *mpt,
1084 int mpt_issue_cfg_req(struct mpt_softc */*mpt*/, request_t */*req*/,
1088 int mpt_read_extcfg_header(struct mpt_softc *mpt, int PageVersion,
1093 int mpt_read_extcfg_page(struct mpt_softc *mpt, int Action,
1112 mpt_read_cur_cfg_page(struct mpt_softc *mpt, uint32_t PageAddress,
1116 return (mpt_read_cfg_page(mpt, MPI_CONFIG_ACTION_PAGE_READ_CURRENT,
1121 mpt_write_cur_cfg_page(struct mpt_softc *mpt, uint32_t PageAddress,
1125 return (mpt_write_cfg_page(mpt, MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT,