2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2009 Yahoo! Inc.
5 * Copyright (c) 2011-2015 LSI Corp.
6 * Copyright (c) 2013-2015 Avago Technologies
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
38 #define MPS_DRIVER_VERSION "21.02.00.00-fbsd"
40 #define MPS_DB_MAX_WAIT 2500
42 #define MPS_REQ_FRAMES 2048
43 #define MPS_PRI_REQ_FRAMES 128
44 #define MPS_EVT_REPLY_FRAMES 32
45 #define MPS_REPLY_FRAMES MPS_REQ_FRAMES
46 #define MPS_CHAIN_FRAMES 2048
47 #define MPS_MAXIO_PAGES (-1)
48 #define MPS_SENSE_LEN SSD_FULL_SIZE
50 #define MPS_MSIX_MAX 16
51 #define MPS_SGE64_SIZE 12
52 #define MPS_SGE32_SIZE 8
53 #define MPS_SGC_SIZE 8
58 #define MPS_PERIODIC_DELAY 1 /* 1 second heartbeat/watchdog check */
59 #define MPS_ATA_ID_TIMEOUT 5 /* 5 second timeout for SATA ID cmd */
60 #define MPS_MISSING_CHECK_DELAY 10 /* 10 seconds between missing check */
62 #define MPS_SCSI_RI_INVALID_FRAME (0x00000002)
64 #define DEFAULT_SPINUP_WAIT 3 /* seconds to wait for spinup */
66 #include <sys/endian.h>
69 * host mapping related macro definitions
71 #define MPS_MAPTABLE_BAD_IDX 0xFFFFFFFF
72 #define MPS_DPM_BAD_IDX 0xFFFF
73 #define MPS_ENCTABLE_BAD_IDX 0xFF
74 #define MPS_MAX_MISSING_COUNT 0x0F
75 #define MPS_DEV_RESERVED 0x20000000
76 #define MPS_MAP_IN_USE 0x10000000
77 #define MPS_MAP_BAD_ID 0xFFFFFFFF
80 * WarpDrive controller
82 #define MPS_CHIP_WD_DEVICE_ID 0x007E
83 #define MPS_WD_LSI_OEM 0x80
84 #define MPS_WD_HIDE_EXPOSE_MASK 0x03
85 #define MPS_WD_HIDE_ALWAYS 0x00
86 #define MPS_WD_EXPOSE_ALWAYS 0x01
87 #define MPS_WD_HIDE_IF_VOLUME 0x02
88 #define MPS_WD_RETRY 0x01
89 #define MPS_MAN_PAGE10_SIZE 0x5C /* Hardcode for now */
90 #define MPS_MAX_DISKS_IN_VOL 10
93 * WarpDrive Event Logging
95 #define MPI2_WD_LOG_ENTRY 0x8002
96 #define MPI2_WD_SSD_THROTTLING 0x0041
97 #define MPI2_WD_DRIVE_LIFE_WARN 0x0043
98 #define MPI2_WD_DRIVE_LIFE_DEAD 0x0044
99 #define MPI2_WD_RAIL_MON_FAIL 0x004D
102 typedef uint16_t u16;
103 typedef uint32_t u32;
104 typedef uint64_t u64;
107 * struct dev_mapping_table - device mapping information
108 * @physical_id: SAS address for drives or WWID for RAID volumes
109 * @device_info: bitfield provides detailed info about the device
110 * @phy_bits: bitfields indicating controller phys
111 * @dpm_entry_num: index of this device in device persistent map table
112 * @dev_handle: device handle for the device pointed by this entry
114 * @missing_count: number of times the device not detected by driver
115 * @hide_flag: Hide this physical disk/not (foreign configuration)
116 * @init_complete: Whether the start of the day checks completed or not
118 struct dev_mapping_table {
133 * struct enc_mapping_table - mapping information about an enclosure
134 * @enclosure_id: Logical ID of this enclosure
135 * @start_index: index to the entry in dev_mapping_table
136 * @phy_bits: bitfields indicating controller phys
137 * @dpm_entry_num: index of this enclosure in device persistent map table
138 * @enc_handle: device handle for the enclosure pointed by this entry
139 * @num_slots: number of slots in the enclosure
140 * @start_slot: Starting slot id
141 * @missing_count: number of times the device not detected by driver
142 * @removal_flag: used to mark the device for removal
143 * @skip_search: used as a flag to include/exclude enclosure for search
144 * @init_complete: Whether the start of the day checks completed or not
146 struct enc_mapping_table {
161 * struct map_removal_table - entries to be removed from mapping table
162 * @dpm_entry_num: index of this device in device persistent map table
163 * @dev_handle: device handle for the device pointed by this entry
165 struct map_removal_table{
170 typedef struct mps_fw_diagnostic_buffer {
172 uint8_t extended_type;
174 uint8_t force_release;
175 uint32_t product_specific[23];
179 uint8_t owned_by_firmware;
181 } mps_fw_diagnostic_buffer_t;
187 struct mpssas_target;
188 struct mps_column_map;
190 MALLOC_DECLARE(M_MPT2);
192 typedef void mps_evt_callback_t(struct mps_softc *, uintptr_t,
193 MPI2_EVENT_NOTIFICATION_REPLY *reply);
194 typedef void mps_command_callback_t(struct mps_softc *, struct mps_command *cm);
197 TAILQ_ENTRY(mps_chain) chain_link;
198 MPI2_SGE_IO_UNION *chain;
199 uint32_t chain_busaddr;
203 * This needs to be at least 2 to support SMP passthrough.
205 #define MPS_IOVEC_COUNT 2
208 TAILQ_ENTRY(mps_command) cm_link;
209 TAILQ_ENTRY(mps_command) cm_recovery;
210 struct mps_softc *cm_sc;
216 struct iovec cm_iovec[MPS_IOVEC_COUNT];
219 MPI2_SGE_IO_UNION *cm_sge;
222 uint32_t cm_reply_data;
223 mps_command_callback_t *cm_complete;
224 void *cm_complete_data;
225 struct mpssas_target *cm_targ;
226 MPI2_REQUEST_DESCRIPTOR_UNION cm_desc;
229 #define MPS_CM_FLAGS_POLLED (1 << 0)
230 #define MPS_CM_FLAGS_COMPLETE (1 << 1)
231 #define MPS_CM_FLAGS_SGE_SIMPLE (1 << 2)
232 #define MPS_CM_FLAGS_DATAOUT (1 << 3)
233 #define MPS_CM_FLAGS_DATAIN (1 << 4)
234 #define MPS_CM_FLAGS_WAKEUP (1 << 5)
235 #define MPS_CM_FLAGS_DD_IO (1 << 6)
236 #define MPS_CM_FLAGS_USE_UIO (1 << 7)
237 #define MPS_CM_FLAGS_SMP_PASS (1 << 8)
238 #define MPS_CM_FLAGS_CHAIN_FAILED (1 << 9)
239 #define MPS_CM_FLAGS_ERROR_MASK MPS_CM_FLAGS_CHAIN_FAILED
240 #define MPS_CM_FLAGS_USE_CCB (1 << 10)
241 #define MPS_CM_FLAGS_SATA_ID_TIMEOUT (1 << 11)
243 #define MPS_CM_STATE_FREE 0
244 #define MPS_CM_STATE_BUSY 1
245 #define MPS_CM_STATE_TIMEDOUT 2
246 bus_dmamap_t cm_dmamap;
247 struct scsi_sense_data *cm_sense;
248 TAILQ_HEAD(, mps_chain) cm_chain_list;
249 uint32_t cm_req_busaddr;
250 uint32_t cm_sense_busaddr;
251 struct callout cm_callout;
254 struct mps_column_map {
256 uint8_t phys_disk_num;
259 struct mps_event_handle {
260 TAILQ_ENTRY(mps_event_handle) eh_list;
261 mps_evt_callback_t *callback;
263 u32 mask[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
267 struct mps_softc *sc;
269 MPI2_REPLY_DESCRIPTORS_UNION *post_queue;
272 ck_ring_buffer_t *ringmem;
273 ck_ring_buffer_t *chainmem;
275 ck_ring_t chain_ring;
277 bus_dma_tag_t buffer_dmat;
278 int io_cmds_highwater;
279 int chain_free_lowwater;
280 int chain_alloc_fail;
281 struct resource *irq;
288 struct cdev *mps_cdev;
290 #define MPS_FLAGS_INTX (1 << 0)
291 #define MPS_FLAGS_MSI (1 << 1)
292 #define MPS_FLAGS_BUSY (1 << 2)
293 #define MPS_FLAGS_SHUTDOWN (1 << 3)
294 #define MPS_FLAGS_DIAGRESET (1 << 4)
295 #define MPS_FLAGS_ATTACH_DONE (1 << 5)
296 #define MPS_FLAGS_WD_AVAILABLE (1 << 6)
297 #define MPS_FLAGS_REALLOCATED (1 << 7)
302 int io_cmds_highwater;
306 int chain_free_lowwater;
308 int spinup_wait_time;
310 uint64_t chain_alloc_fail;
311 struct sysctl_ctx_list sysctl_ctx;
312 struct sysctl_oid *sysctl_tree;
314 struct mps_command *commands;
315 struct mps_chain *chains;
316 struct callout periodic;
317 struct callout device_check_callout;
318 struct mps_queue *queues;
320 struct mpssas_softc *sassc;
321 TAILQ_HEAD(, mps_command) req_list;
322 TAILQ_HEAD(, mps_command) high_priority_req_list;
323 TAILQ_HEAD(, mps_chain) chain_list;
324 TAILQ_HEAD(, mps_command) tm_list;
328 struct resource *mps_regs_resource;
329 bus_space_handle_t mps_bhandle;
330 bus_space_tag_t mps_btag;
333 bus_dma_tag_t mps_parent_dmat;
334 bus_dma_tag_t buffer_dmat;
336 MPI2_IOC_FACTS_REPLY *facts;
339 int fqdepth; /* Free queue */
340 int pqdepth; /* Post queue */
342 u32 event_mask[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
343 TAILQ_HEAD(, mps_event_handle) event_list;
344 struct mps_event_handle *mps_log_eh;
347 struct intr_config_hook mps_ich;
350 bus_addr_t req_busaddr;
351 bus_dma_tag_t req_dmat;
352 bus_dmamap_t req_map;
354 uint8_t *reply_frames;
355 bus_addr_t reply_busaddr;
356 bus_dma_tag_t reply_dmat;
357 bus_dmamap_t reply_map;
359 struct scsi_sense_data *sense_frames;
360 bus_addr_t sense_busaddr;
361 bus_dma_tag_t sense_dmat;
362 bus_dmamap_t sense_map;
364 uint8_t *chain_frames;
365 bus_addr_t chain_busaddr;
366 bus_dma_tag_t chain_dmat;
367 bus_dmamap_t chain_map;
369 MPI2_REPLY_DESCRIPTORS_UNION *post_queue;
370 bus_addr_t post_busaddr;
371 uint32_t *free_queue;
372 bus_addr_t free_busaddr;
373 bus_dma_tag_t queues_dmat;
374 bus_dmamap_t queues_map;
376 uint8_t *fw_diag_buffer;
377 bus_addr_t fw_diag_busaddr;
378 bus_dma_tag_t fw_diag_dmat;
379 bus_dmamap_t fw_diag_map;
383 /* static config pages */
384 Mpi2IOCPage8_t ioc_pg8;
386 /* host mapping support */
387 struct dev_mapping_table *mapping_table;
388 struct enc_mapping_table *enclosure_table;
389 struct map_removal_table *removal_table;
390 uint8_t *dpm_entry_used;
391 uint8_t *dpm_flush_entry;
392 Mpi2DriverMappingPage0_t *dpm_pg0;
393 uint16_t max_devices;
394 uint16_t max_enclosures;
395 uint16_t max_expanders;
397 uint8_t num_enc_table_entries;
398 uint8_t num_rsvd_entries;
399 uint16_t max_dpm_entries;
400 uint8_t is_dpm_enable;
401 uint8_t track_mapping_events;
402 uint32_t pending_map_events;
404 /* FW diag Buffer List */
405 mps_fw_diagnostic_buffer_t
406 fw_diag_buffer_list[MPI2_DIAG_BUF_TYPE_COUNT];
408 /* Event Recording IOCTL support */
409 uint32_t events_to_record[4];
410 mps_event_entry_t recorded_events[MPS_EVENT_QUEUE_SIZE];
412 uint32_t event_number;
414 /* EEDP and TLR support */
415 uint8_t eedp_enabled;
418 /* Shutdown Event Handler */
419 eventhandler_tag shutdown_eh;
421 /* To track topo events during reset */
422 #define MPS_DIAG_RESET_TIMEOUT 300000
423 uint8_t wait_for_port_enable;
424 uint8_t port_enable_complete;
425 uint8_t msleep_fake_chan;
428 uint8_t WD_available;
429 uint8_t WD_valid_config;
430 uint8_t WD_hide_expose;
432 /* Direct Drive for WarpDrive */
433 uint8_t DD_num_phys_disks;
434 uint16_t DD_dev_handle;
435 uint32_t DD_stripe_size;
436 uint32_t DD_stripe_exponent;
437 uint32_t DD_block_size;
438 uint16_t DD_block_exponent;
440 struct mps_column_map DD_column_map[MPS_MAX_DISKS_IN_VOL];
442 /* StartStopUnit command handling at shutdown */
443 uint32_t SSU_refcount;
446 /* Configuration tunables */
451 u_int max_prireqframes;
452 u_int max_replyframes;
454 char exclude_ids[80];
456 struct timeval lastfail;
459 struct mps_config_params {
460 MPI2_CONFIG_EXT_PAGE_HEADER_UNION hdr;
462 u_int page_address; /* Attributes, not a phys address */
467 void (*callback)(struct mps_softc *, struct mps_config_params *);
471 struct scsi_read_capacity_eedp
478 static __inline uint32_t
479 mps_regread(struct mps_softc *sc, uint32_t offset)
481 return (bus_space_read_4(sc->mps_btag, sc->mps_bhandle, offset));
485 mps_regwrite(struct mps_softc *sc, uint32_t offset, uint32_t val)
487 bus_space_write_4(sc->mps_btag, sc->mps_bhandle, offset, val);
490 /* free_queue must have Little Endian address
491 * TODO- cm_reply_data is unwanted. We can remove it.
494 mps_free_reply(struct mps_softc *sc, uint32_t busaddr)
496 if (++sc->replyfreeindex >= sc->fqdepth)
497 sc->replyfreeindex = 0;
498 sc->free_queue[sc->replyfreeindex] = htole32(busaddr);
499 mps_regwrite(sc, MPI2_REPLY_FREE_HOST_INDEX_OFFSET, sc->replyfreeindex);
502 static __inline struct mps_chain *
503 mps_alloc_chain(struct mps_softc *sc)
505 struct mps_chain *chain;
507 if ((chain = TAILQ_FIRST(&sc->chain_list)) != NULL) {
508 TAILQ_REMOVE(&sc->chain_list, chain, chain_link);
510 if (sc->chain_free < sc->chain_free_lowwater)
511 sc->chain_free_lowwater = sc->chain_free;
513 sc->chain_alloc_fail++;
518 mps_free_chain(struct mps_softc *sc, struct mps_chain *chain)
521 TAILQ_INSERT_TAIL(&sc->chain_list, chain, chain_link);
525 mps_free_command(struct mps_softc *sc, struct mps_command *cm)
527 struct mps_chain *chain, *chain_temp;
529 if (cm->cm_reply != NULL)
530 mps_free_reply(sc, cm->cm_reply_data);
533 cm->cm_complete = NULL;
534 cm->cm_complete_data = NULL;
539 cm->cm_state = MPS_CM_STATE_FREE;
546 TAILQ_FOREACH_SAFE(chain, &cm->cm_chain_list, chain_link, chain_temp) {
547 TAILQ_REMOVE(&cm->cm_chain_list, chain, chain_link);
548 mps_free_chain(sc, chain);
550 TAILQ_INSERT_TAIL(&sc->req_list, cm, cm_link);
553 static __inline struct mps_command *
554 mps_alloc_command(struct mps_softc *sc)
556 struct mps_command *cm;
558 cm = TAILQ_FIRST(&sc->req_list);
562 TAILQ_REMOVE(&sc->req_list, cm, cm_link);
563 KASSERT(cm->cm_state == MPS_CM_STATE_FREE, ("mps: Allocating busy command\n"));
564 cm->cm_state = MPS_CM_STATE_BUSY;
569 mps_free_high_priority_command(struct mps_softc *sc, struct mps_command *cm)
571 struct mps_chain *chain, *chain_temp;
573 if (cm->cm_reply != NULL)
574 mps_free_reply(sc, cm->cm_reply_data);
577 cm->cm_complete = NULL;
578 cm->cm_complete_data = NULL;
582 cm->cm_state = MPS_CM_STATE_FREE;
583 TAILQ_FOREACH_SAFE(chain, &cm->cm_chain_list, chain_link, chain_temp) {
584 TAILQ_REMOVE(&cm->cm_chain_list, chain, chain_link);
585 mps_free_chain(sc, chain);
587 TAILQ_INSERT_TAIL(&sc->high_priority_req_list, cm, cm_link);
590 static __inline struct mps_command *
591 mps_alloc_high_priority_command(struct mps_softc *sc)
593 struct mps_command *cm;
595 cm = TAILQ_FIRST(&sc->high_priority_req_list);
599 TAILQ_REMOVE(&sc->high_priority_req_list, cm, cm_link);
600 KASSERT(cm->cm_state == MPS_CM_STATE_FREE, ("mps: Allocating busy command\n"));
601 cm->cm_state = MPS_CM_STATE_BUSY;
606 mps_lock(struct mps_softc *sc)
608 mtx_lock(&sc->mps_mtx);
612 mps_unlock(struct mps_softc *sc)
614 mtx_unlock(&sc->mps_mtx);
617 #define MPS_INFO (1 << 0) /* Basic info */
618 #define MPS_FAULT (1 << 1) /* Hardware faults */
619 #define MPS_EVENT (1 << 2) /* Event data from the controller */
620 #define MPS_LOG (1 << 3) /* Log data from the controller */
621 #define MPS_RECOVERY (1 << 4) /* Command error recovery tracing */
622 #define MPS_ERROR (1 << 5) /* Parameter errors, programming bugs */
623 #define MPS_INIT (1 << 6) /* Things related to system init */
624 #define MPS_XINFO (1 << 7) /* More detailed/noisy info */
625 #define MPS_USER (1 << 8) /* Trace user-generated commands */
626 #define MPS_MAPPING (1 << 9) /* Trace device mappings */
627 #define MPS_TRACE (1 << 10) /* Function-by-function trace */
629 #define MPS_SSU_DISABLE_SSD_DISABLE_HDD 0
630 #define MPS_SSU_ENABLE_SSD_DISABLE_HDD 1
631 #define MPS_SSU_DISABLE_SSD_ENABLE_HDD 2
632 #define MPS_SSU_ENABLE_SSD_ENABLE_HDD 3
634 #define mps_printf(sc, args...) \
635 device_printf((sc)->mps_dev, ##args)
637 #define mps_print_field(sc, msg, args...) \
638 printf("\t" msg, ##args)
640 #define mps_vprintf(sc, args...) \
643 mps_printf(sc, ##args); \
646 #define mps_dprint(sc, level, msg, args...) \
648 if ((sc)->mps_debug & (level)) \
649 device_printf((sc)->mps_dev, msg, ##args); \
652 #define MPS_PRINTFIELD_START(sc, tag...) \
653 mps_printf((sc), ##tag); \
654 mps_print_field((sc), ":\n")
655 #define MPS_PRINTFIELD_END(sc, tag) \
656 mps_printf((sc), tag "\n")
657 #define MPS_PRINTFIELD(sc, facts, attr, fmt) \
658 mps_print_field((sc), #attr ": " #fmt "\n", (facts)->attr)
660 #define MPS_FUNCTRACE(sc) \
661 mps_dprint((sc), MPS_TRACE, "%s\n", __func__)
667 mps_from_u64(uint64_t data, U64 *mps)
669 (mps)->High = htole32((uint32_t)((data) >> 32));
670 (mps)->Low = htole32((uint32_t)((data) & 0xffffffff));
673 static __inline uint64_t
674 mps_to_u64(U64 *data)
677 return (((uint64_t)le32toh(data->High) << 32) | le32toh(data->Low));
681 mps_mask_intr(struct mps_softc *sc)
685 mask = mps_regread(sc, MPI2_HOST_INTERRUPT_MASK_OFFSET);
686 mask |= MPI2_HIM_REPLY_INT_MASK;
687 mps_regwrite(sc, MPI2_HOST_INTERRUPT_MASK_OFFSET, mask);
691 mps_unmask_intr(struct mps_softc *sc)
695 mask = mps_regread(sc, MPI2_HOST_INTERRUPT_MASK_OFFSET);
696 mask &= ~MPI2_HIM_REPLY_INT_MASK;
697 mps_regwrite(sc, MPI2_HOST_INTERRUPT_MASK_OFFSET, mask);
700 int mps_pci_setup_interrupts(struct mps_softc *sc);
701 void mps_pci_free_interrupts(struct mps_softc *sc);
702 int mps_pci_restore(struct mps_softc *sc);
704 void mps_get_tunables(struct mps_softc *sc);
705 int mps_attach(struct mps_softc *sc);
706 int mps_free(struct mps_softc *sc);
707 void mps_intr(void *);
708 void mps_intr_msi(void *);
709 void mps_intr_locked(void *);
710 int mps_register_events(struct mps_softc *, u32 *, mps_evt_callback_t *,
711 void *, struct mps_event_handle **);
712 int mps_restart(struct mps_softc *);
713 int mps_update_events(struct mps_softc *, struct mps_event_handle *, u32 *);
714 void mps_deregister_events(struct mps_softc *, struct mps_event_handle *);
715 int mps_push_sge(struct mps_command *, void *, size_t, int);
716 int mps_add_dmaseg(struct mps_command *, vm_paddr_t, size_t, u_int, int);
717 int mps_attach_sas(struct mps_softc *sc);
718 int mps_detach_sas(struct mps_softc *sc);
719 int mps_read_config_page(struct mps_softc *, struct mps_config_params *);
720 int mps_write_config_page(struct mps_softc *, struct mps_config_params *);
721 void mps_memaddr_cb(void *, bus_dma_segment_t *, int , int );
722 void mpi_init_sge(struct mps_command *cm, void *req, void *sge);
723 int mps_attach_user(struct mps_softc *);
724 void mps_detach_user(struct mps_softc *);
725 void mpssas_record_event(struct mps_softc *sc,
726 MPI2_EVENT_NOTIFICATION_REPLY *event_reply);
728 int mps_map_command(struct mps_softc *sc, struct mps_command *cm);
729 int mps_wait_command(struct mps_softc *sc, struct mps_command **cm, int timeout,
732 int mps_config_get_bios_pg3(struct mps_softc *sc, Mpi2ConfigReply_t
733 *mpi_reply, Mpi2BiosPage3_t *config_page);
734 int mps_config_get_raid_volume_pg0(struct mps_softc *sc, Mpi2ConfigReply_t
735 *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 page_address);
736 int mps_config_get_ioc_pg8(struct mps_softc *sc, Mpi2ConfigReply_t *,
738 int mps_config_get_man_pg10(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply);
739 int mps_config_get_sas_device_pg0(struct mps_softc *, Mpi2ConfigReply_t *,
740 Mpi2SasDevicePage0_t *, u32 , u16 );
741 int mps_config_get_dpm_pg0(struct mps_softc *, Mpi2ConfigReply_t *,
742 Mpi2DriverMappingPage0_t *, u16 );
743 int mps_config_get_raid_volume_pg1(struct mps_softc *sc,
744 Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form,
746 int mps_config_get_volume_wwid(struct mps_softc *sc, u16 volume_handle,
748 int mps_config_get_raid_pd_pg0(struct mps_softc *sc,
749 Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page,
751 void mpssas_ir_shutdown(struct mps_softc *sc);
753 int mps_reinit(struct mps_softc *sc);
754 void mpssas_handle_reinit(struct mps_softc *sc);
756 void mps_base_static_config_pages(struct mps_softc *sc);
757 void mps_wd_config_pages(struct mps_softc *sc);
759 int mps_mapping_initialize(struct mps_softc *);
760 void mps_mapping_topology_change_event(struct mps_softc *,
761 Mpi2EventDataSasTopologyChangeList_t *);
762 void mps_mapping_free_memory(struct mps_softc *sc);
763 int mps_config_set_dpm_pg0(struct mps_softc *, Mpi2ConfigReply_t *,
764 Mpi2DriverMappingPage0_t *, u16 );
765 void mps_mapping_exit(struct mps_softc *);
766 void mps_mapping_check_devices(void *);
767 int mps_mapping_allocate_memory(struct mps_softc *sc);
768 unsigned int mps_mapping_get_tid(struct mps_softc *, uint64_t , u16);
769 unsigned int mps_mapping_get_tid_from_handle(struct mps_softc *sc,
771 unsigned int mps_mapping_get_raid_tid(struct mps_softc *sc, u64 wwid,
773 unsigned int mps_mapping_get_raid_tid_from_handle(struct mps_softc *sc,
775 void mps_mapping_enclosure_dev_status_change_event(struct mps_softc *,
776 Mpi2EventDataSasEnclDevStatusChange_t *event_data);
777 void mps_mapping_ir_config_change_event(struct mps_softc *sc,
778 Mpi2EventDataIrConfigChangeList_t *event_data);
779 int mps_mapping_dump(SYSCTL_HANDLER_ARGS);
780 int mps_mapping_encl_dump(SYSCTL_HANDLER_ARGS);
782 void mpssas_evt_handler(struct mps_softc *sc, uintptr_t data,
783 MPI2_EVENT_NOTIFICATION_REPLY *event);
784 void mpssas_prepare_remove(struct mpssas_softc *sassc, uint16_t handle);
785 void mpssas_prepare_volume_remove(struct mpssas_softc *sassc, uint16_t handle);
786 int mpssas_startup(struct mps_softc *sc);
787 struct mpssas_target * mpssas_find_target_by_handle(struct mpssas_softc *, int, uint16_t);
788 void mpssas_realloc_targets(struct mps_softc *sc, int maxtargets);
789 struct mps_command * mpssas_alloc_tm(struct mps_softc *sc);
790 void mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm);
791 void mpssas_release_simq_reinit(struct mpssas_softc *sassc);
792 int mpssas_send_reset(struct mps_softc *sc, struct mps_command *tm,
795 SYSCTL_DECL(_hw_mps);
797 /* Compatibility shims for different OS versions */
798 #if __FreeBSD_version >= 800001
799 #define mps_kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
800 kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
801 #define mps_kproc_exit(arg) kproc_exit(arg)
803 #define mps_kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
804 kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
805 #define mps_kproc_exit(arg) kthread_exit(arg)
808 #if defined(CAM_PRIORITY_XPT)
809 #define MPS_PRIORITY_XPT CAM_PRIORITY_XPT
811 #define MPS_PRIORITY_XPT 5
814 #if __FreeBSD_version < 800107
815 // Prior to FreeBSD-8.0 scp3_flags was not defined.
816 #define spc3_flags reserved
818 #define SPC3_SID_PROTECT 0x01
819 #define SPC3_SID_3PC 0x08
820 #define SPC3_SID_TPGS_MASK 0x30
821 #define SPC3_SID_TPGS_IMPLICIT 0x10
822 #define SPC3_SID_TPGS_EXPLICIT 0x20
823 #define SPC3_SID_ACC 0x40
824 #define SPC3_SID_SCCS 0x80
826 #define CAM_PRIORITY_NORMAL CAM_PRIORITY_NONE