/* * Copyright (c) 2011-2015, Emulex * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT 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 SUCH DAMAGE. * */ #if !defined(__ELXU_MBOX_H__) #define __ELXU_MBOX_H__ #include #include #include #define min(x,y) (((x) < (y)) ? (x) : (y)) /* A section of DMA-able memory */ typedef struct { elxu_device_t *device; void *vaddr; uintptr_t paddr; size_t size; int tag; } memref_t; /** * @brief CLP string used in the DMTF_CLP_CMD mailbox command. */ #define CLP_LINKCFG_4X10G "ELX_4x10G" #define CLP_LINKCFG_1X40G "ELX_1x40G" #define CLP_LINKCFG_2X16G "ELX_2x16G" #define CLP_LINKCFG_4X8G "ELX_4x8G" #define CLP_LINKCFG_4X1G "ELX_4x1G" #define CLP_LINKCFG_2X10G "ELX_2x10G" #define CLP_LINKCFG_2X10G_2X8G "ELX_2x10G_2x8G" /** * @brief mgmt link config string to CLP string mapping. * * This structure provides a mapping from the management string(exposed * to set-linkcfg) to the CLP string that is used in the DMTF_CLP_CMD * mailbox command. */ typedef struct mbox_linkcfg_map_s { char *mgmt_str; char *clp_str; } mbox_linkcfg_map_t; #define ENABLE 1 #define DISABLE 0 #define INTERNAL_LOOPBACK 0x1 #define EXTERNAL_LOOPBACK 0x2 #define PCI_LOOPBACK 0x3 #define LOOPBACK_BUF_SIZE 512 // O/S specific extern int mbox_common(elxu_device_t *device, mbox_command_t *mbxcmd, uint32_t mbxcmdLength, void *inbuf, uint32_t inbufLength, void *outbuf, uint32_t outbufLength); // Common mailbox command API extern int mbox_read_flashrom(elxu_device_t *device, uint32_t opcode, uint32_t optype, uint32_t offset, void *outbuf, uint32_t outbufLength); extern int mbox_write_flashrom(elxu_device_t *device, uint32_t opcode, uint32_t optype, uint32_t offset, void *outbuf, uint32_t outbufLength); extern int mbox_read_status(elxu_device_t *device, uint32_t clear_counter); extern int mbox_read_link_status(elxu_device_t *device, int clof, int clrc); extern int mbox_get_dport_stats(elxu_device_t *device); extern int mbox_query_dynamic_dport_status(elxu_device_t *device); extern int mbox_set_dynamic_dport(elxu_device_t *device, char *state); extern int mbox_diag_loopback_tests(elxu_device_t *device, int loopback_type, int retry_count); extern int mbox_read_rev(elxu_device_t *device); extern int mbox_enable_nagle(elxu_device_t *device, int enable); extern int mbox_tcp_parameters(elxu_device_t *device, uint32_t request_flags, uint32_t delayedAckValue, uint32_t delayedAckTimerValue); extern int mbox_connection_update(elxu_device_t *device, uint32_t request_flags, uint16_t connectionId, uint32_t constrainWindowValue); extern int mbox_get_connection_info(elxu_device_t *device, uint32_t connectionHandle); extern int mbox_soft_assign_mac(elxu_device_t *device, int *macaddr); extern int mbox_manage_fat(elxu_device_t *device, uint32_t fat_operation, uint32_t read_log_offset, void *buffer, uint32_t bufferLength); extern int mbox_ext_fat(elxu_device_t *device, uint32_t opcode, void *mbox, uint32_t mboxLength); extern int create_vport(elxu_device_t *device_p, uint64_t wwnn, uint64_t wwpn, int targetFlag, int initiatorFlag); extern int remove_vport(elxu_device_t *device_p, uint64_t wwnn, uint64_t wwpn, int targetFlag, int initiatorFlag); extern memref_t *elx_pt_dma_alloc(elxu_device_t *device, int size); extern void elx_pt_dma_free(memref_t* memref); extern int mbox_fw_reset_pt(elxu_device_t *device, int dd); extern int mbox_sli4_init_pt(elxu_device_t *device); extern int mbox_set_nv_mac_pt(elxu_device_t *device, int *macaddr); extern int mbox_get_serialnum_pt(elxu_device_t *device, char *serial_num, int serial_num_size); extern int mbox_set_nv_wwn_pt(elxu_device_t *device, char *wwpn_p, char *wwnn_p); extern void mbox_get_mac_pt(elxu_device_t *device, uint8_t *mac_addr); extern void mbox_get_wwn_pt(int fd, uint8_t *wwnn, uint8_t *wwpn); extern int mbox_get_profile_list_pt(elxu_device_t *device, char *result, int result_len); extern int mbox_get_active_profile_pt(elxu_device_t *device, char *result, int result_len); extern int mbox_set_active_profile_pt(elxu_device_t *device, char *new_profile_id); extern char *mbox_get_linkcfg_pt(elxu_device_t *device); extern int mbox_set_linkcfg_pt(elxu_device_t *device, char *config); #endif // __ELXU_MBOX_H__