Changeset View
Changeset View
Standalone View
Standalone View
mpr_user.c
Show All 25 Lines | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * 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 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD userland interface | * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD userland interface | ||||
*/ | */ | ||||
/*- | /*- | ||||
* Copyright (c) 2011-2015 LSI Corp. | * Copyright (c) 2011-2015 LSI Corp. | ||||
* Copyright (c) 2013-2015 Avago Technologies | * Copyright (c) 2013-2016 Avago Technologies | ||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
static mpr_user_f mpi_pre_fw_download; | static mpr_user_f mpi_pre_fw_download; | ||||
static mpr_user_f mpi_pre_fw_upload; | static mpr_user_f mpi_pre_fw_upload; | ||||
static mpr_user_f mpi_pre_sata_passthrough; | static mpr_user_f mpi_pre_sata_passthrough; | ||||
static mpr_user_f mpi_pre_smp_passthrough; | static mpr_user_f mpi_pre_smp_passthrough; | ||||
static mpr_user_f mpi_pre_config; | static mpr_user_f mpi_pre_config; | ||||
static mpr_user_f mpi_pre_sas_io_unit_control; | static mpr_user_f mpi_pre_sas_io_unit_control; | ||||
static int mpr_user_read_cfg_header(struct mpr_softc *, | static int mpr_user_read_cfg_header(struct mpr_softc *, | ||||
struct mpr_cfg_page_req *); | struct mpr_cfg_page_req *); | ||||
static int mpr_user_read_cfg_page(struct mpr_softc *, | static int mpr_user_read_cfg_page(struct mpr_softc *, | ||||
struct mpr_cfg_page_req *, void *); | struct mpr_cfg_page_req *, void *); | ||||
static int mpr_user_read_extcfg_header(struct mpr_softc *, | static int mpr_user_read_extcfg_header(struct mpr_softc *, | ||||
struct mpr_ext_cfg_page_req *); | struct mpr_ext_cfg_page_req *); | ||||
static int mpr_user_read_extcfg_page(struct mpr_softc *, | static int mpr_user_read_extcfg_page(struct mpr_softc *, | ||||
struct mpr_ext_cfg_page_req *, void *); | struct mpr_ext_cfg_page_req *, void *); | ||||
static int mpr_user_write_cfg_page(struct mpr_softc *, | static int mpr_user_write_cfg_page(struct mpr_softc *, | ||||
struct mpr_cfg_page_req *, void *); | struct mpr_cfg_page_req *, void *); | ||||
static int mpr_user_setup_request(struct mpr_command *, | static int mpr_user_setup_request(struct mpr_command *, | ||||
struct mpr_usr_command *); | struct mpr_usr_command *); | ||||
static int mpr_user_command(struct mpr_softc *, struct mpr_usr_command *); | static int mpr_user_command(struct mpr_softc *, struct mpr_usr_command *); | ||||
static int mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru_t *data); | static int mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru_t *data); | ||||
static void mpr_user_get_adapter_data(struct mpr_softc *sc, | static void mpr_user_get_adapter_data(struct mpr_softc *sc, | ||||
mpr_adapter_data_t *data); | mpr_adapter_data_t *data); | ||||
static void mpr_user_read_pci_info(struct mpr_softc *sc, | static void mpr_user_read_pci_info(struct mpr_softc *sc, mpr_pci_info_t *data); | ||||
mpr_pci_info_t *data); | |||||
static uint8_t mpr_get_fw_diag_buffer_number(struct mpr_softc *sc, | static uint8_t mpr_get_fw_diag_buffer_number(struct mpr_softc *sc, | ||||
uint32_t unique_id); | uint32_t unique_id); | ||||
static int mpr_post_fw_diag_buffer(struct mpr_softc *sc, | static int mpr_post_fw_diag_buffer(struct mpr_softc *sc, | ||||
mpr_fw_diagnostic_buffer_t *pBuffer, uint32_t *return_code); | mpr_fw_diagnostic_buffer_t *pBuffer, uint32_t *return_code); | ||||
static int mpr_release_fw_diag_buffer(struct mpr_softc *sc, | static int mpr_release_fw_diag_buffer(struct mpr_softc *sc, | ||||
mpr_fw_diagnostic_buffer_t *pBuffer, uint32_t *return_code, | mpr_fw_diagnostic_buffer_t *pBuffer, uint32_t *return_code, | ||||
uint32_t diag_type); | uint32_t diag_type); | ||||
static int mpr_diag_register(struct mpr_softc *sc, | static int mpr_diag_register(struct mpr_softc *sc, | ||||
mpr_fw_diag_register_t *diag_register, uint32_t *return_code); | mpr_fw_diag_register_t *diag_register, uint32_t *return_code); | ||||
static int mpr_diag_unregister(struct mpr_softc *sc, | static int mpr_diag_unregister(struct mpr_softc *sc, | ||||
mpr_fw_diag_unregister_t *diag_unregister, uint32_t *return_code); | mpr_fw_diag_unregister_t *diag_unregister, uint32_t *return_code); | ||||
static int mpr_diag_query(struct mpr_softc *sc, | static int mpr_diag_query(struct mpr_softc *sc, mpr_fw_diag_query_t *diag_query, | ||||
mpr_fw_diag_query_t *diag_query, uint32_t *return_code); | uint32_t *return_code); | ||||
static int mpr_diag_read_buffer(struct mpr_softc *sc, | static int mpr_diag_read_buffer(struct mpr_softc *sc, | ||||
mpr_diag_read_buffer_t *diag_read_buffer, uint8_t *ioctl_buf, | mpr_diag_read_buffer_t *diag_read_buffer, uint8_t *ioctl_buf, | ||||
uint32_t *return_code); | uint32_t *return_code); | ||||
static int mpr_diag_release(struct mpr_softc *sc, | static int mpr_diag_release(struct mpr_softc *sc, | ||||
mpr_fw_diag_release_t *diag_release, uint32_t *return_code); | mpr_fw_diag_release_t *diag_release, uint32_t *return_code); | ||||
static int mpr_do_diag_action(struct mpr_softc *sc, uint32_t action, | static int mpr_do_diag_action(struct mpr_softc *sc, uint32_t action, | ||||
uint8_t *diag_action, uint32_t length, uint32_t *return_code); | uint8_t *diag_action, uint32_t length, uint32_t *return_code); | ||||
static int mpr_user_diag_action(struct mpr_softc *sc, | static int mpr_user_diag_action(struct mpr_softc *sc, mpr_diag_action_t *data); | ||||
mpr_diag_action_t *data); | static void mpr_user_event_query(struct mpr_softc *sc, mpr_event_query_t *data); | ||||
static void mpr_user_event_query(struct mpr_softc *sc, | |||||
mpr_event_query_t *data); | |||||
static void mpr_user_event_enable(struct mpr_softc *sc, | static void mpr_user_event_enable(struct mpr_softc *sc, | ||||
mpr_event_enable_t *data); | mpr_event_enable_t *data); | ||||
static int mpr_user_event_report(struct mpr_softc *sc, | static int mpr_user_event_report(struct mpr_softc *sc, | ||||
mpr_event_report_t *data); | mpr_event_report_t *data); | ||||
static int mpr_user_reg_access(struct mpr_softc *sc, mpr_reg_access_t *data); | static int mpr_user_reg_access(struct mpr_softc *sc, mpr_reg_access_t *data); | ||||
static int mpr_user_btdh(struct mpr_softc *sc, mpr_btdh_mapping_t *data); | static int mpr_user_btdh(struct mpr_softc *sc, mpr_btdh_mapping_t *data); | ||||
static MALLOC_DEFINE(M_MPRUSER, "mpr_user", "Buffers for mpr(4) ioctls"); | static MALLOC_DEFINE(M_MPRUSER, "mpr_user", "Buffers for mpr(4) ioctls"); | ||||
Show All 24 Lines | |||||
}; | }; | ||||
int | int | ||||
mpr_attach_user(struct mpr_softc *sc) | mpr_attach_user(struct mpr_softc *sc) | ||||
{ | { | ||||
int unit; | int unit; | ||||
unit = device_get_unit(sc->mpr_dev); | unit = device_get_unit(sc->mpr_dev); | ||||
sc->mpr_cdev = make_dev(&mpr_cdevsw, unit, UID_ROOT, GID_OPERATOR, | sc->mpr_cdev = make_dev(&mpr_cdevsw, unit, UID_ROOT, GID_OPERATOR, 0640, | ||||
0640, "mpr%d", unit); | "mpr%d", unit); | ||||
if (sc->mpr_cdev == NULL) { | |||||
if (sc->mpr_cdev == NULL) | |||||
return (ENOMEM); | return (ENOMEM); | ||||
} | |||||
sc->mpr_cdev->si_drv1 = sc; | sc->mpr_cdev->si_drv1 = sc; | ||||
return (0); | return (0); | ||||
} | } | ||||
void | void | ||||
mpr_detach_user(struct mpr_softc *sc) | mpr_detach_user(struct mpr_softc *sc) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if ((page_req->ioc_status & MPI2_IOCSTATUS_MASK) == | ||||
MPI2_IOCSTATUS_SUCCESS) { | MPI2_IOCSTATUS_SUCCESS) { | ||||
bcopy(hdr, &page_req->header, sizeof(page_req->header)); | bcopy(hdr, &page_req->header, sizeof(page_req->header)); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
mpr_user_read_cfg_page(struct mpr_softc *sc, | mpr_user_read_cfg_page(struct mpr_softc *sc, struct mpr_cfg_page_req *page_req, | ||||
struct mpr_cfg_page_req *page_req, void *buf) | void *buf) | ||||
{ | { | ||||
MPI2_CONFIG_PAGE_HEADER *reqhdr, *hdr; | MPI2_CONFIG_PAGE_HEADER *reqhdr, *hdr; | ||||
struct mpr_config_params params; | struct mpr_config_params params; | ||||
int error; | int error; | ||||
reqhdr = buf; | reqhdr = buf; | ||||
hdr = ¶ms.hdr.Struct; | hdr = ¶ms.hdr.Struct; | ||||
hdr->PageVersion = reqhdr->PageVersion; | hdr->PageVersion = reqhdr->PageVersion; | ||||
▲ Show 20 Lines • Show All 1,416 Lines • ▼ Show 20 Lines | mpr_diag_release(struct mpr_softc *sc, mpr_fw_diag_release_t *diag_release, | ||||
* Release the buffer. | * Release the buffer. | ||||
*/ | */ | ||||
status = mpr_release_fw_diag_buffer(sc, pBuffer, return_code, | status = mpr_release_fw_diag_buffer(sc, pBuffer, return_code, | ||||
MPR_FW_DIAG_TYPE_RELEASE); | MPR_FW_DIAG_TYPE_RELEASE); | ||||
return (status); | return (status); | ||||
} | } | ||||
static int | static int | ||||
mpr_do_diag_action(struct mpr_softc *sc, uint32_t action, | mpr_do_diag_action(struct mpr_softc *sc, uint32_t action, uint8_t *diag_action, | ||||
uint8_t *diag_action, uint32_t length, uint32_t *return_code) | uint32_t length, uint32_t *return_code) | ||||
{ | { | ||||
mpr_fw_diag_register_t diag_register; | mpr_fw_diag_register_t diag_register; | ||||
mpr_fw_diag_unregister_t diag_unregister; | mpr_fw_diag_unregister_t diag_unregister; | ||||
mpr_fw_diag_query_t diag_query; | mpr_fw_diag_query_t diag_query; | ||||
mpr_diag_read_buffer_t diag_read_buffer; | mpr_diag_read_buffer_t diag_read_buffer; | ||||
mpr_fw_diag_release_t diag_release; | mpr_fw_diag_release_t diag_release; | ||||
int status = MPR_DIAG_SUCCESS; | int status = MPR_DIAG_SUCCESS; | ||||
uint32_t original_return_code; | uint32_t original_return_code; | ||||
▲ Show 20 Lines • Show All 740 Lines • Show Last 20 Lines |