提交 949a895b 编写于 作者: C Chenguangli 提交者: Yang Yingliang

scsi/hifc: add hifc driver port resource module

driver inclusion
category: feature
bugzilla: NA

-----------------------------------------------------------------------

This module maintains hifc driver port resources, including HBA, Lport,
Rport, queue, and npiv.
Signed-off-by: NChenguangli <chenguangli2@huawei.com>
Reviewed-by: NZengweiliang <zengweiliang.zengweiliang@huawei.com>
Acked-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 79d2dfad
此差异已折叠。
/* SPDX-License-Identifier: GPL-2.0 */
/* Huawei Hifc PCI Express Linux driver
* Copyright(c) 2017 Huawei Technologies Co., Ltd
*
*/
#ifndef __HIFC_CHIPITF_H__
#define __HIFC_CHIPITF_H__
#include "unf_log.h"
#include "hifc_utils.h"
#include "hifc_module.h"
#include "hifc_service.h"
/* CONF_API_CMND */
#define HIFC_MBOX_CONFIG_API 0x00
#define HIFC_MBOX_CONFIG_API_STS 0xA0
/* GET_CHIP_INFO_API_CMD */
#define HIFC_MBOX_GET_CHIP_INFO 0x01
#define HIFC_MBOX_GET_CHIP_INFO_STS 0xA1
/* PORT_RESET */
#define HIFC_MBOX_PORT_RESET 0x02
#define HIFC_MBOX_PORT_RESET_STS 0xA2
/* SFP_SWITCH_API_CMND */
#define HIFC_MBOX_PORT_SWITCH 0x03
#define HIFC_MBOX_PORT_SWITCH_STS 0xA3
/* GET_SFP_INFO */
#define HIFC_MBOX_GET_SFP_INFO 0x04
#define HIFC_MBOX_GET_SFP_INFO_STS 0xA4
/* CONF_AF_LOGIN_API_CMND */
#define HIFC_MBOX_CONFIG_LOGIN_API 0x06
#define HIFC_MBOX_CONFIG_LOGIN_API_STS 0xA6
/* BUFFER_CLEAR_DONE_CMND */
#define HIFC_MBOX_BUFFER_CLEAR_DONE 0x07
#define HIFC_MBOX_BUFFER_CLEAR_DONE_STS 0xA7
#define HIFC_MBOX_GET_ERR_CODE 0x08
#define HIFC_MBOX_GET_ERR_CODE_STS 0xA8
#define HIFC_MBOX_GET_UP_STATE 0x09
#define HIFC_MBOX_GET_UP_STATE_STS 0xA9
/* LOOPBACK MODE */
#define HIFC_MBOX_LOOPBACK_MODE 0x0A
#define HIFC_MBOX_LOOPBACK_MODE_STS 0xAA
/* REG RW MODE */
#define HIFC_MBOX_REG_RW_MODE 0x0B
#define HIFC_MBOX_REG_RW_MODE_STS 0xAB
/* GET CLEAR DONE STATE */
#define HIFC_MBOX_GET_CLEAR_STATE 0x0E
#define HIFC_MBOX_GET_CLEAR_STATE_STS 0xAE
/* GET UP & UCODE VER */
#define HIFC_MBOX_GET_FW_VERSION 0x0F
#define HIFC_MBOX_GET_FW_VERSION_STS 0xAF
/* CONFIG TIMER */
#define HIFC_MBOX_CONFIG_TIMER 0x10
#define HIFC_MBOX_CONFIG_TIMER_STS 0xB0
/* CONFIG SRQC */
#define HIFC_MBOX_CONFIG_SRQC 0x11
#define HIFC_MBOX_CONFIG_SRQC_STS 0xB1
/* Led Test */
#define HIFC_MBOX_LED_TEST 0x12
#define HIFC_MBOX_LED_TEST_STS 0xB2
/* set esch */
#define HIFC_MBOX_SET_ESCH 0x13
#define HIFC_MBOX_SET_ESCH_STS 0xB3
/* set get tx serdes */
#define HIFC_MBOX_SET_GET_SERDES_TX 0x14
#define HIFC_MBOX_SET_GET_SERDES_TX_STS 0xB4
/* get rx serdes */
#define HIFC_MBOX_GET_SERDES_RX 0x15
#define HIFC_MBOX_GET_SERDES_RX_STS 0xB5
/* i2c read write */
#define HIFC_MBOX_I2C_WR_RD 0x16
#define HIFC_MBOX_I2C_WR_RD_STS 0xB6
/* Set FEC Enable */
#define HIFC_MBOX_CONFIG_FEC 0x17
#define HIFC_MBOX_CONFIG_FEC_STS 0xB7
/* GET UCODE STATS CMD */
#define HIFC_MBOX_GET_UCODE_STAT 0x18
#define HIFC_MBOX_GET_UCODE_STAT_STS 0xB8
/* gpio read write */
#define HIFC_MBOX_GPIO_WR_RD 0x19
#define HIFC_MBOX_GPIO_WR_RD_STS 0xB9
/* GET PORT INFO CMD */
#define HIFC_MBOX_GET_PORT_INFO 0x20
#define HIFC_MBOX_GET_PORT_INFO_STS 0xC0
/* save hba info CMD */
#define HIFC_MBOX_SAVE_HBA_INFO 0x24
#define HIFC_MBOX_SAVE_HBA_INFO_STS 0xc4
#define HIFC_MBOX_FLASH_DATA_MGMT 0x25
#define HIFC_MBOX_FLASH_DATA_MGMT_STS 0xc5
/* FCOE: DRV->UP */
#define HIFC_MBOX_SEND_ELS_CMD 0x2A
#define HIFC_MBOX_SEND_VPORT_INFO 0x2B
/* FC: UP->DRV */
#define HIFC_MBOX_RECV_FC_LINKUP 0x40
#define HIFC_MBOX_RECV_FC_LINKDOWN 0x41
#define HIFC_MBOX_RECV_FC_DELCMD 0x42
#define HIFC_MBOX_RECV_FC_ERROR 0x43
#define LOOP_MAP_VALID 1
#define LOOP_MAP_INVALID 0
#define HIFC_MBOX_SIZE 1024
#define HIFC_MBOX_HEADER_SIZE 4
#define ATUOSPEED 1
#define FIXEDSPEED 0
#define UNDEFINEOPCODE 0
#define VALUEMASK_L 0x00000000FFFFFFFF
#define VALUEMASK_H 0xFFFFFFFF00000000
#define STATUS_OK 0
#define STATUS_FAIL 1
enum hifc_drv_2_up_unblock_msg_cmd_code_e {
HIFC_SEND_ELS_CMD,
HIFC_SEND_ELS_CMD_FAIL,
HIFC_RCV_ELS_CMD_RSP,
HIFC_SEND_CONFIG_LOGINAPI,
HIFC_SEND_CONFIG_LOGINAPI_FAIL,
HIFC_RCV_CONFIG_LOGIN_API_RSP,
HIFC_SEND_CLEAR_DONE,
HIFC_SEND_CLEAR_DONE_FAIL,
HIFC_RCV_CLEAR_DONE_RSP,
HIFC_SEND_VPORT_INFO_DONE,
HIFC_SEND_VPORT_INFO_FAIL,
HIFC_SEND_VPORT_INFO_RSP,
HIFC_MBOX_CMD_BUTT
};
/* up to driver handle templete */
struct hifc_up_2_drv_msg_handle_s {
unsigned char cmd;
unsigned int (*pfn_hifc_msg_up2drv_handler)(struct hifc_hba_s *v_hba,
void *v_buf_in);
};
/* Mbox Common Header */
struct hifc_mbox_header_s {
unsigned char cmnd_type;
unsigned char length;
unsigned char port_id;
unsigned char reserved;
};
/* open or close the sfp */
struct hifc_inbox_port_switch_s {
struct hifc_mbox_header_s header;
unsigned char op_code;
unsigned char port_type;
unsigned short reserved;
unsigned char host_id;
unsigned char pf_id;
unsigned char fcoe_mode;
unsigned char reserved2;
unsigned short conf_vlan;
unsigned short reserved3;
unsigned long long sys_port_wwn;
unsigned long long sys_node_name;
};
struct hifc_outbox_port_switch_sts_s {
struct hifc_mbox_header_s header;
unsigned short reserved;
unsigned char reserved2;
unsigned char status;
};
/* config API */
struct hifc_inbox_config_api_s {
struct hifc_mbox_header_s header;
unsigned int op_code : 8;
unsigned int reserved1 : 24;
unsigned char topy_mode;
unsigned char sfp_speed;
unsigned char max_speed;
unsigned char hard_alpa;
unsigned char port_name[UNF_WWN_LEN];
unsigned int slave : 1;
unsigned int auto_sneg : 1;
unsigned int reserved2 : 30;
unsigned int rx_bbcredit_32g : 16; /* 160 */
unsigned int rx_bbcredit_16g : 16; /* 80 */
unsigned int rx_bbcredit_842g : 16; /* 50 */
unsigned int rdy_cnt_bf_fst_frm : 16; /* 8 */
unsigned int esch_value_32g;
unsigned int esch_value_16g;
unsigned int esch_value_8g;
unsigned int esch_value_4g;
unsigned int esch_value_2g;
unsigned int esch_bust_size;
};
struct hifc_outbox_config_api_sts_s {
struct hifc_mbox_header_s header;
unsigned short reserved;
unsigned char reserved2;
unsigned char status;
};
/* Get chip info */
struct hifc_inbox_get_chip_info_s {
struct hifc_mbox_header_s header;
};
struct hifc_outbox_get_chip_info_sts_s {
struct hifc_mbox_header_s header;
unsigned char status;
unsigned char board_type;
unsigned char rvsd;
unsigned char tape_support : 1;
unsigned char reserved : 7;
unsigned long long wwpn;
unsigned long long wwnn;
unsigned long long sys_mac;
};
/* Get reg info */
struct hifc_inmbox_get_reg_info_s {
struct hifc_mbox_header_s header;
unsigned int op_code : 1;
unsigned int reg_len : 8;
unsigned int rsvd : 23;
unsigned int reg_addr;
unsigned int reg_value_l32;
unsigned int reg_value_h32;
unsigned int rvsd[27];
};
/* Get reg info sts */
struct hifc_outmbox_get_reg_info_sts_s {
struct hifc_mbox_header_s header;
unsigned short rvsd0;
unsigned char rvsd1;
unsigned char status;
unsigned int reg_value_l32;
unsigned int reg_value_h32;
unsigned int rvsd[28];
};
/* Config login API */
struct hifc_inmbox_config_login_s {
struct hifc_mbox_header_s header;
unsigned int op_code : 8;
unsigned int reserved1 : 24;
unsigned short tx_bb_credit;
unsigned short reserved2;
unsigned int rtov;
unsigned int etov;
unsigned int rt_tov_tag : 1;
unsigned int ed_tov_tag : 1;
unsigned int bb_credit : 6;
unsigned int bbscn : 8;
unsigned int lr_flag : 16;
};
struct hifc_outmbox_config_login_sts_s {
struct hifc_mbox_header_s header;
unsigned short reserved;
unsigned char reserved2;
unsigned char status;
};
/* port reset */
#define HIFC_MBOX_SUBTYPE_LIGHT_RESET 0x0
#define HIFC_MBOX_SUBTYPE_HEAVY_RESET 0x1
struct hifc_inmbox_port_reset_s {
struct hifc_mbox_header_s header;
unsigned int op_code : 8;
unsigned int reserved1 : 24;
};
struct hifc_outmbox_port_reset_sts_s {
struct hifc_mbox_header_s header;
unsigned short reserved;
unsigned char reserved2;
unsigned char status;
};
struct hifc_inmbox_get_sfp_info_s {
struct hifc_mbox_header_s header;
};
struct hifc_outmbox_get_sfp_info_sts_s {
struct hifc_mbox_header_s header;
unsigned int rcvd : 8;
unsigned int length : 16;
unsigned int status : 8;
};
/* get and clear error code */
struct hifc_inmbox_get_err_code_s {
struct hifc_mbox_header_s header;
};
struct hifc_outmbox_get_err_code_sts_s {
struct hifc_mbox_header_s header;
unsigned short rsvd;
unsigned char rsvd2;
unsigned char status;
unsigned int err_code[8];
};
/* uP-->Driver asyn event API */
struct hifc_link_event_s {
struct hifc_mbox_header_s header;
unsigned char link_event;
unsigned char reason;
unsigned char speed;
unsigned char top_type;
unsigned char alpa_value;
unsigned char reserved1;
unsigned short paticpate : 1;
unsigned short acled : 1;
unsigned short yellow_speed_led : 1;
unsigned short green_speed_led : 1;
unsigned short reserved : 12;
unsigned char loop_map_info[128];
};
enum hifc_up_err_type_e {
HIFC_UP_ERR_DRV_PARA = 0,
HIFC_UP_ERR_SFP = 1,
HIFC_UP_ERR_32G_PUB = 2,
HIFC_UP_ERR_32G_UA = 3,
HIFC_UP_ERR_32G_MAC = 4,
HIFC_UP_ERR_NON32G_DFX = 5,
HIFC_UP_ERR_NON32G_MAC = 6,
HIFC_UP_ERR_BUTT
};
enum hifc_up_err_value_e {
/* ERR type 0 */
HIFC_DRV_2_UP_PARA_ERR = 0,
/* ERR type 1 */
HIFC_SFP_SPEED_ERR,
/* ERR type 2 */
HIFC_32GPUB_UA_RXESCH_FIFO_OF,
HIFC_32GPUB_UA_RXESCH_FIFO_UCERR,
/* ERR type 3 */
HIFC_32G_UA_UATX_LEN_ABN,
HIFC_32G_UA_RXAFIFO_OF,
HIFC_32G_UA_TXAFIFO_OF,
HIFC_32G_UA_RXAFIFO_UCERR,
HIFC_32G_UA_TXAFIFO_UCERR,
/* ERR type 4 */
HIFC_32G_MAC_RX_BBC_FATAL,
HIFC_32G_MAC_TX_BBC_FATAL,
HIFC_32G_MAC_TXFIFO_UF,
HIFC_32G_MAC_PCS_TXFIFO_UF,
HIFC_32G_MAC_RXBBC_CRDT_TO,
HIFC_32G_MAC_PCS_RXAFIFO_OF,
HIFC_32G_MAC_PCS_TXFIFO_OF,
HIFC_32G_MAC_FC2P_RXFIFO_OF,
HIFC_32G_MAC_FC2P_TXFIFO_OF,
HIFC_32G_MAC_FC2P_CAFIFO_OF,
HIFC_32G_MAC_PCS_RXRSFECM_UCEER,
HIFC_32G_MAC_PCS_RXAFIFO_UCEER,
HIFC_32G_MAC_PCS_TXFIFO_UCEER,
HIFC_32G_MAC_FC2P_RXFIFO_UCEER,
HIFC_32G_MAC_FC2P_TXFIFO_UCEER,
/* ERR type 5 */
HIFC_NON32G_DFX_FC1_DFX_BF_FIFO,
HIFC_NON32G_DFX_FC1_DFX_BP_FIFO,
HIFC_NON32G_DFX_FC1_DFX_RX_AFIFO_ERR,
HIFC_NON32G_DFX_FC1_DFX_TX_AFIFO_ERR,
HIFC_NON32G_DFX_FC1_DFX_DIRQ_RXBUF_FIFO1,
HIFC_NON32G_DFX_FC1_DFX_DIRQ_RXBBC_TO,
HIFC_NON32G_DFX_FC1_DFX_DIRQ_TXDAT_FIFO,
HIFC_NON32G_DFX_FC1_DFX_DIRQ_TXCMD_FIFO,
HIFC_NON32G_DFX_FC1_ERR_R_RDY,
/* ERR type 6 */
HIFC_NON32G_MAC_FC1_FAIRNESS_ERROR,
HIFC_ERR_VALUE_BUTT
};
struct hifc_up_error_event_s {
struct hifc_mbox_header_s header;
unsigned char link_event;
unsigned char error_level;
unsigned char error_type;
unsigned char error_value;
};
struct hifc_inmbx_clear_node_s {
struct hifc_mbox_header_s header;
};
struct hifc_inmbox_get_clear_state_s {
struct hifc_mbox_header_s header;
unsigned int resvd[31];
};
struct hifc_outmbox_get_clear_state_sts_s {
struct hifc_mbox_header_s header;
unsigned short rsvd;
unsigned char state; /* 1--clear doing. 0---clear done. */
unsigned char status; /* 0--ok,!0---fail */
unsigned int resvd[30];
};
#define HIFC_FIP_MODE_VN2VF 0
#define HIFC_FIP_MODE_VN2VN 1
/* get port state */
struct hifc_inmbox_get_port_info_s {
struct hifc_mbox_header_s header;
};
/* save hba info */
struct hifc_inmbox_save_hba_info_s {
struct hifc_mbox_header_s header;
unsigned int hba_save_info[254];
};
struct hifc_outmbox_get_port_info_sts_s {
struct hifc_mbox_header_s header;
unsigned int status : 8;
unsigned int fec_vis_tts_16g : 8;
unsigned int bbscn : 8;
unsigned int loop_credit : 8;
unsigned int non_loop_rx_credit : 8;
unsigned int non_loop_tx_credit : 8;
unsigned int sfp_speed : 8;
unsigned int present : 8;
};
struct hifc_outmbox_save_hba_info_sts_s {
struct hifc_mbox_header_s header;
unsigned short rsvd1;
unsigned char rsvd2;
unsigned char status;
unsigned int rsvd3;
unsigned int save_hba_info[252];
};
#define HIFC_VER_ADDR_OFFSET (8)
struct hifc_inmbox_get_fw_version_s {
struct hifc_mbox_header_s header;
};
struct hifc_outmbox_get_fw_version_sts_s {
struct hifc_mbox_header_s header;
unsigned char status;
unsigned char rsv[3];
unsigned char ucode_ver[HIFC_VER_LEN];
unsigned char ucode_compile_time[HIFC_COMPILE_TIME_LEN];
unsigned char up_ver[HIFC_VER_LEN];
unsigned char up_compile_time[HIFC_COMPILE_TIME_LEN];
unsigned char boot_ver[HIFC_VER_LEN];
unsigned char boot_compile_time[HIFC_COMPILE_TIME_LEN];
};
/* Set Fec Enable */
struct hifc_inmbox_config_fec_s {
struct hifc_mbox_header_s header;
unsigned char fec_op_code;
unsigned char rsv0;
unsigned short rsv1;
};
struct hifc_outmbox_config_fec_sts_s {
struct hifc_mbox_header_s header;
unsigned short usrsv0;
unsigned char ucrsv1;
unsigned char status;
};
struct hifc_inmbox_config_timer_s {
struct hifc_mbox_header_s header;
unsigned short op_code;
unsigned short fun_id;
unsigned int user_data;
};
struct hifc_outmbox_config_timer_sts_s {
struct hifc_mbox_header_s header;
unsigned char status;
unsigned char rsv[3];
};
union hifc_outmbox_generic_u {
struct {
struct hifc_mbox_header_s header;
unsigned int rsvd[(HIFC_MBOX_SIZE - HIFC_MBOX_HEADER_SIZE) /
sizeof(unsigned int)];
} generic;
struct hifc_outbox_port_switch_sts_s port_switch_sts;
struct hifc_outbox_config_api_sts_s config_api_sts;
struct hifc_outbox_get_chip_info_sts_s get_chip_info_sts;
struct hifc_outmbox_get_reg_info_sts_s get_reg_info_sts;
struct hifc_outmbox_config_login_sts_s config_login_sts;
struct hifc_outmbox_port_reset_sts_s port_reset_sts;
struct hifc_outmbox_get_sfp_info_sts_s get_sfp_info_sts;
struct hifc_outmbox_get_err_code_sts_s get_err_code_sts;
struct hifc_outmbox_get_clear_state_sts_s get_clr_state_sts;
struct hifc_outmbox_get_fw_version_sts_s get_fw_ver_sts;
struct hifc_outmbox_config_fec_sts_s config_fec_sts;
struct hifc_outmbox_config_timer_sts_s timer_config_sts;
struct hifc_outmbox_get_port_info_sts_s get_port_info_sts;
struct unf_flash_data_mgmt_sts_s flash_data_sts;
};
unsigned int hifc_get_chip_msg(void *v_hba, void *v_mac);
unsigned int hifc_config_port_table(struct hifc_hba_s *v_hba);
unsigned int hifc_port_switch(struct hifc_hba_s *v_hba, int turn_on);
unsigned int hifc_get_speed_act(void *v_hba, void *v_speed_act);
unsigned int hifc_get_speed_cfg(void *v_hba, void *v_speed_cfg);
unsigned int hifc_get_loop_map(void *v_hba, void *v_buf);
unsigned int hifc_get_firmware_version(void *v_fc_port, void *v_ver);
unsigned int hifc_get_work_bale_bbcredit(void *v_hba, void *v_bb_credit);
unsigned int hifc_get_work_bale_bbscn(void *v_hba, void *v_bbscn);
unsigned int hifc_get_and_clear_port_error_code(void *v_hba, void *v_err_code);
unsigned int hifc_get_port_current_info(void *v_hba, void *v_port_info);
unsigned int hifc_get_port_fec(void *v_hba, void *v_para_out);
unsigned int hifc_get_software_version(void *v_fc_port, void *v_ver);
unsigned int hifc_get_port_info(void *v_hba);
unsigned int hifc_rw_reg(void *v_hba, void *v_params);
unsigned int hifc_clear_port_error_code(void *v_hba, void *v_err_code);
unsigned int hifc_get_sfp_info(void *v_fc_port, void *v_sfp_info);
unsigned int hifc_get_hardware_version(void *v_fc_port, void *v_ver);
unsigned int hifc_get_lport_led(void *v_hba, void *v_led_state);
unsigned int hifc_get_loop_alpa(void *v_hba, void *v_alpa);
unsigned int hifc_get_topo_act(void *v_hba, void *v_topo_act);
unsigned int hifc_get_topo_cfg(void *v_hba, void *v_topo_cfg);
unsigned int hifc_config_login_api(
struct hifc_hba_s *v_hba,
struct unf_port_login_parms_s *v_login_parms);
unsigned int hifc_mb_send_and_wait_mbox(struct hifc_hba_s *v_hba,
const void *v_in_mbox,
unsigned short in_size,
union hifc_outmbox_generic_u
*v_out_mbox);
void hifc_up_msg_2_driver_proc(void *v_hwdev_handle,
void *v_pri_handle,
unsigned char v_cmd,
void *v_buf_in,
unsigned short v_in_size,
void *v_buf_out,
unsigned short *v_out_size);
unsigned int hifc_mbox_reset_chip(struct hifc_hba_s *v_hba,
unsigned char v_sub_type);
unsigned int hifc_clear_sq_wqe_done(struct hifc_hba_s *v_hba);
unsigned int hifc_update_fabric_param(void *v_hba, void *v_para_in);
unsigned int hifc_update_port_param(void *v_hba, void *v_para_in);
unsigned int hifc_mbx_get_fw_clear_stat(struct hifc_hba_s *v_hba,
unsigned int *v_clear_state);
unsigned short hifc_get_global_base_qpn(void *v_handle);
unsigned int hifc_mbx_set_fec(struct hifc_hba_s *v_hba,
unsigned int v_fec_opcode);
unsigned int hifc_notify_up_config_timer(struct hifc_hba_s *v_hba,
int v_opcode,
unsigned int v_user_data);
unsigned int hifc_save_hba_info(void *v_hba, void *v_para_in);
unsigned int hifc_get_chip_capability(void *hw_dev_handle,
struct hifc_chip_info_s *v_chip_info);
unsigned int hifc_get_flash_data(void *v_hba, void *v_flash_data);
unsigned int hifc_set_flash_data(void *v_hba, void *v_flash_data);
#endif
此差异已折叠。
/* SPDX-License-Identifier: GPL-2.0 */
/* Huawei Hifc PCI Express Linux driver
* Copyright(c) 2017 Huawei Technologies Co., Ltd
*
*/
#ifndef __HIFC_HBA_H__
#define __HIFC_HBA_H__
#include "unf_common.h"
#include "hifc_queue.h"
#include "hifc_api_cmd.h"
#include "hifc_mgmt.h"
#define HIFC_PCI_VENDOR_ID_MASK (0xffff)
#define HIFC_LOWLEVEL_DEFAULT_LOOP_BB_CREDIT 8
#define HIFC_LOWLEVEL_DEFAULT_32G_BB_CREDIT 255
#define HIFC_LOWLEVEL_DEFAULT_16G_BB_CREDIT 255
#define HIFC_LOWLEVEL_DEFAULT_842G_BB_CREDIT 255
#define HIFC_LOWLEVEL_DEFAULT_BB_SCN 0
#define HIFC_LOWLEVEL_DEFAULT_32G_ESCH_VALUE 28081
#define HIFC_LOWLEVEL_DEFAULT_16G_ESCH_VALUE 14100
#define HIFC_LOWLEVEL_DEFAULT_842G_ESCH_VALUE 7000
#define HIFC_LOWLEVEL_DEFAULT_ESCH_BUS_SIZE 0x2000
#define HIFC_SMARTIO_WORK_MODE_FC 0x1
#define UNF_FUN_ID_MASK 0x07
#define UNF_HIFC_FC 0x01
#define UNF_HIFC_MAXNPIV_NUM 64
#define HIFC_MAX_COS_NUM 8
#define HIFC_PCI_VENDOR_ID_HUAWEI 0x19e5
#define HIFC_SCQ_CNTX_SIZE 32
#define HIFC_SRQ_CNTX_SIZE 64
#define HIFC_PORT_INIT_TIME_SEC_MAX 1
#define HIFC_PORT_NAME_LABEL "hifc"
#define HIFC_PORT_NAME_STR_LEN 16
#define HIFC_MAX_PROBE_PORT_NUM 64
#define HIFC_PORT_NUM_PER_TABLE 64
#define HIFC_MAX_CARD_NUM 32
#define HIFC_HBA_PORT_MAX_NUM HIFC_MAX_PROBE_PORT_NUM
/* Heart Lost Flag */
#define HIFC_EVENT_HEART_LOST 0
#define HIFC_GET_HBA_PORT_ID(__hba) ((__hba)->port_index)
#define HIFC_HBA_NOT_PRESENT(__hba) ((__hba)->dev_present == UNF_FALSE)
struct hifc_port_cfg_s {
unsigned int port_id; /* Port ID */
unsigned int port_mode; /* Port mode:INI(0x20) TGT(0x10) BOTH(0x30) */
unsigned int port_topology; /* Port topo:0x3:loop,0xc:p2p,0xf:auto */
unsigned int port_alpa; /* Port ALPA */
unsigned int max_queue_depth;/* Max Queue depth Registration to SCSI */
unsigned int sest_num; /* IO burst num:512-4096 */
unsigned int max_login; /* Max Login Session. */
unsigned int node_name_hi; /* nodename high 32 bits */
unsigned int node_name_lo; /* nodename low 32 bits */
unsigned int port_name_hi; /* portname high 32 bits */
unsigned int port_name_lo; /* portname low 32 bits */
/* Port speed 0:auto 4:4Gbps 8:8Gbps 16:16Gbps */
unsigned int port_speed;
unsigned int interrupt_delay; /* Delay times(ms) in interrupt */
unsigned int tape_support; /* tape support */
};
#define HIFC_VER_INFO_SIZE 128
struct hifc_drv_version_s {
char ver[HIFC_VER_INFO_SIZE];
};
struct hifc_card_info_s {
unsigned int card_num : 8;
unsigned int func_num : 8;
unsigned int base_func : 8;
/*
* Card type:UNF_FC_SERVER_BOARD_32_G(6) 32G mode,
* UNF_FC_SERVER_BOARD_16_G(7)16G mode
*/
unsigned int card_type : 8;
};
struct hifc_card_num_manage_s {
int is_removing;
unsigned int port_count;
unsigned long long card_number;
};
struct hifc_led_state_s {
unsigned char green_speed_led;
unsigned char yellow_speed_led;
unsigned char ac_led;
unsigned char reserved;
};
enum hifc_queue_set_stage_e {
HIFC_QUEUE_SET_STAGE_INIT = 0,
HIFC_QUEUE_SET_STAGE_SCANNING,
HIFC_QUEUE_SET_STAGE_FLUSHING,
HIFC_QUEUE_SET_STAGE_FLUSHDONE,
HIFC_QUEUE_SET_STAGE_BUTT
};
struct hifc_srq_delay_info_s {
unsigned char srq_delay_flag; /* Check whether need to delay */
unsigned char root_rq_rcvd_flag;
unsigned short rsd;
spinlock_t srq_lock;
struct unf_frame_pkg_s pkg;
struct delayed_work del_work;
};
struct hifc_fw_ver_detail_s {
unsigned char ucode_ver[HIFC_VER_LEN];
unsigned char ucode_compile_time[HIFC_COMPILE_TIME_LEN];
unsigned char up_ver[HIFC_VER_LEN];
unsigned char up_compile_time[HIFC_COMPILE_TIME_LEN];
unsigned char boot_ver[HIFC_VER_LEN];
unsigned char boot_compile_time[HIFC_COMPILE_TIME_LEN];
};
/* get wwpn and wwnn */
struct hifc_chip_info_s {
unsigned char work_mode;
unsigned char tape_support;
unsigned long long wwpn;
unsigned long long wwnn;
};
struct hifc_hba_s {
struct pci_dev *pci_dev;
void *hw_dev_handle;
struct fc_service_cap fc_service_cap;
struct hifc_scq_info_s scq_info[HIFC_TOTAL_SCQ_NUM];
struct hifc_srq_info_s els_srq_info;
/* PCI IO Memory */
void __iomem *bar0;
unsigned int bar0_len;
struct hifc_root_info_s root_info;
struct hifc_parent_queue_mgr_s *parent_queue_mgr;
/* Link list Sq WqePage Pool */
struct hifc_sq_wqe_page_pool_s sq_wpg_pool;
enum hifc_queue_set_stage_e q_set_stage;
unsigned int next_clearing_sq;
unsigned int default_sq_id;
/* Port parameters, Obtained through firmware */
unsigned short q_s_max_count;
unsigned char port_type; /* FC Port */
unsigned char port_index; /* Phy Port */
unsigned int default_scqn;
unsigned char chip_type; /* chiptype:Smart or fc */
unsigned char work_mode;
struct hifc_card_info_s card_info;
char port_name[HIFC_PORT_NAME_STR_LEN];
unsigned int probe_index;
unsigned short exit_base;
unsigned short exit_count;
unsigned short image_count;
unsigned char vpid_start;
unsigned char vpid_end;
spinlock_t flush_state_lock;
int in_flushing;
struct hifc_port_cfg_s port_cfg; /* Obtained through Config */
void *lport; /* Used in UNF level */
unsigned char sys_node_name[UNF_WWN_LEN];
unsigned char sys_port_name[UNF_WWN_LEN];
struct completion hba_init_complete;
struct completion mbox_complete;
unsigned short removing;
int sfp_on;
int dev_present;
int heart_status;
spinlock_t hba_lock;
unsigned int port_topo_cfg;
unsigned int port_bbscn_cfg;
unsigned int port_loop_role;
unsigned int port_speed_cfg;
unsigned int max_support_speed;
unsigned char remote_rttov_tag;
unsigned char remote_edtov_tag;
unsigned short compared_bbscn;
unsigned short remote_bbcredit;
unsigned int compared_edtov_val;
unsigned int compared_ratov_val;
enum unf_act_topo_e active_topo;
unsigned int active_port_speed;
unsigned int active_rx_bb_credit;
unsigned int active_bb_scn;
unsigned int phy_link;
unsigned int fcp_conf_cfg;
/* loop */
unsigned char active_al_pa;
unsigned char loop_map_valid;
unsigned char loop_map[UNF_LOOPMAP_COUNT];
unsigned int cos_bit_map;
atomic_t cos_rport_cnt[HIFC_MAX_COS_NUM];
struct hifc_led_state_s led_states;
unsigned int fec_status;
struct workqueue_struct *work_queue;
unsigned long long reset_time;
struct hifc_srq_delay_info_s delay_info;
};
enum drv_port_entity_type_e {
DRV_PORT_ENTITY_TYPE_PHYSICAL = 0,
DRV_PORT_ENTITY_TYPE_VIRTUAL = 1,
DRV_PORT_ENTITY_TYPE_BUTT
};
extern struct hifc_hba_s *hifc_hba[HIFC_HBA_PORT_MAX_NUM];
extern spinlock_t probe_spin_lock;
extern unsigned long probe_bit_map[HIFC_MAX_PROBE_PORT_NUM /
HIFC_PORT_NUM_PER_TABLE];
unsigned int hifc_port_reset(struct hifc_hba_s *v_hba);
void hifc_flush_scq_ctx(struct hifc_hba_s *v_hba);
void hifc_set_hba_flush_state(struct hifc_hba_s *v_hba, int in_flush);
void hifc_get_total_probed_num(unsigned int *v_probe_cnt);
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
/* SPDX-License-Identifier: GPL-2.0 */
/* Huawei Hifc PCI Express Linux driver
* Copyright(c) 2017 Huawei Technologies Co., Ltd
*
*/
#ifndef __NPIV_H__
#define __NPIV_H__
/* product VPORT configure */
struct vport_config_s {
unsigned long long node_name;
unsigned long long port_name;
unsigned int port_mode; /* INI, TGT or both */
};
/* product Vport function */
#define PORTID_VPINDEX_MASK 0xff000000
#define PORTID_VPINDEX_SHIT 24
unsigned int unf_npiv_conf(unsigned int v_port_id, unsigned long long v_wwpn);
struct unf_lport_s *unf_create_vport(struct unf_lport_s *v_lport,
struct vport_config_s *v_vport_config);
unsigned int unf_delete_vport(unsigned int v_port_id, unsigned int v_vp_index);
/* Vport pool creat and release function */
unsigned int unf_init_vport_pool(struct unf_lport_s *v_lport);
void unf_free_vport_pool(struct unf_lport_s *v_lport);
/* Lport resigster stLPortMgTemp function */
void unf_vport_remove(void *v_vport);
void unf_vport_ref_dec(struct unf_lport_s *v_vport);
/* linkdown all Vport after receive linkdown event */
void unf_linkdown_all_vports(void *v_lport);
/* Lport receive Flogi Acc linkup all Vport */
void unf_linkup_all_vports(struct unf_lport_s *v_lport);
/* Lport remove delete all Vport */
void unf_destroy_all_vports(struct unf_lport_s *v_lport);
void unf_vport_fabric_logo(struct unf_lport_s *v_vport);
unsigned int unf_destroy_one_vport(struct unf_lport_s *v_vport);
struct unf_lport_s *unf_alloc_vport(struct unf_lport_s *v_lport,
unsigned long long v_wwpn);
unsigned int unf_drop_vport(struct unf_lport_s *v_vport);
void unf_link_down_one_vport(struct unf_lport_s *v_vport);
void *unf_lookup_vport_by_vp_index(void *v_lport, unsigned short v_vp_index);
void *unf_lookup_vport_by_port_id(void *v_lport, unsigned int v_port_id);
void *unf_lookup_vport_by_did(void *v_lport, unsigned int v_did);
void *unf_lookup_vport_by_wwpn(void *v_lport, unsigned long long v_wwpn);
#endif
此差异已折叠。
/* SPDX-License-Identifier: GPL-2.0 */
/* Huawei Hifc PCI Express Linux driver
* Copyright(c) 2017 Huawei Technologies Co., Ltd
*
*/
#ifndef __UNF_RPORT_H
#define __UNF_RPORT_H
#define UNF_MAX_SCSI_ID 2048
#define UNF_LOSE_TMO 30
#define UNF_RPORT_INVALID_INDEX 0xffff
/* RSCN compare DISC list with local RPort macro */
#define UNF_RPORT_NEED_PROCESS 0x1
#define UNF_RPORT_ONLY_IN_DISC_PROCESS 0x2
#define UNF_RPORT_ONLY_IN_LOCAL_PROCESS 0x3
#define UNF_RPORT_IN_DISC_AND_LOCAL_PROCESS 0x4
#define UNF_RPORT_NOT_NEED_PROCESS 0x5
#define UNF_ECHO_SEND_MAX_TIMES 1
extern struct unf_rport_feature_pool_s *port_fea_pool;
enum unf_rport_login_state_e {
UNF_RPORT_ST_INIT = 0x1000, /* initialized */
UNF_RPORT_ST_PLOGI_WAIT, /* waiting for PLOGI completion */
UNF_RPORT_ST_PRLI_WAIT, /* waiting for PRLI completion */
UNF_RPORT_ST_READY, /* ready for use */
UNF_RPORT_ST_LOGO, /* port logout sent */
UNF_RPORT_ST_CLOSING, /* being closed */
UNF_RPORT_ST_DELETE, /* port being deleted */
UNF_RPORT_ST_BUTT
};
enum unf_rport_event_e {
UNF_EVENT_RPORT_NORMAL_ENTER = 0x9000,
UNF_EVENT_RPORT_ENTER_PLOGI = 0x9001,
UNF_EVENT_RPORT_ENTER_PRLI = 0x9002,
UNF_EVENT_RPORT_READY = 0x9003,
UNF_EVENT_RPORT_LOGO = 0x9004,
UNF_EVENT_RPORT_CLS_TIMEOUT = 0x9005,
UNF_EVENT_RPORT_RECOVERY = 0x9006,
UNF_EVENT_RPORT_RELOGIN = 0x9007,
UNF_EVENT_RPORT_LINK_DOWN = 0x9008,
UNF_EVENT_RPORT_BUTT
};
/* RPort local link state */
enum unf_port_state_e {
UNF_PORT_STATE_LINKUP = 0x1001,
UNF_PORT_STATE_LINKDOWN = 0x1002
};
enum unf_rport_reuse_flag_e {
UNF_RPORT_REUSE_ONLY = 0x1001,
UNF_RPORT_REUSE_INIT = 0x1002,
UNF_RPORT_REUSE_RECOVER = 0x1003
};
struct unf_disc_rport_s {
/* RPort entry */
struct list_head entry_rport;
unsigned int nport_id; /* Remote port NPortID */
unsigned int disc_done; /* 1:Disc done */
};
struct unf_rport_feature_pool_s {
struct list_head list_busy_head;
struct list_head list_free_head;
void *p_port_feature_pool_addr;
spinlock_t port_fea_pool_lock;
};
struct unf_rport_feature_recard_s {
struct list_head entry_feature;
unsigned long long wwpn;
unsigned int port_feature;
unsigned int reserved;
};
struct unf_os_thread_private_data_s {
struct list_head list;
spinlock_t spin_lock;
struct task_struct *thread;
unsigned int in_process;
unsigned int cpu_id;
atomic_t user_count;
};
/* Remote Port struct */
struct unf_rport_s {
unsigned int max_frame_size;
unsigned int supported_classes;
/* Dynamic Attributes */
/* Remote Port loss timeout in seconds. */
unsigned int dev_loss_tmo;
unsigned long long node_name;
unsigned long long port_name;
unsigned int nport_id; /* Remote port NPortID */
unsigned int local_nport_id;
unsigned int roles;
/* Remote port local INI state */
enum unf_port_state_e lport_ini_state;
enum unf_port_state_e last_lport_ini_state;
/* Remote port local TGT state */
enum unf_port_state_e lport_tgt_state;
enum unf_port_state_e last_lport_tgt_state;
/* Port Type:fc */
unsigned int port_type;
/* RPort reference counter */
atomic_t rport_ref_cnt;
/* Pending IO count */
atomic_t pending_io_cnt;
/* RPort entry */
struct list_head entry_rport;
/* Port State,delay reclaim when uiRpState == complete. */
enum unf_rport_login_state_e rp_state;
unsigned int disc_done; /* 1:Disc done */
struct unf_lport_s *lport;
void *rport;
spinlock_t rport_state_lock;
/* Port attribution */
unsigned int ed_tov;
unsigned int ra_tov;
unsigned int options; /* ini or tgt */
unsigned int last_report_linkup_options;
unsigned int fcp_conf_needed; /* INI Rport send FCP CONF flag */
unsigned int tape_support_needed; /* INI tape support flag */
unsigned int retries; /* special req retry times */
unsigned int logo_retries; /* logo error recovery retry times */
unsigned int mas_retries; /* special req retry times */
/* Rport alloc jiffies */
unsigned long long rport_alloc_jifs;
void *session;
/* binding with SCSI */
unsigned int scsi_id;
/* disc list compare flag */
unsigned int rscn_position;
unsigned int rport_index;
/* RPort timer,closing status */
struct work_struct closing_work;
/* RPort timer,rport linkup */
struct work_struct start_work;
/* RPort timer,recovery */
struct delayed_work recovery_work;
/* RPort timer,TGT mode,PRLI waiting */
struct delayed_work open_work;
struct semaphore task_sema;
/* Callback after rport Ready/delete.[with state:ok/fail].
* Creat/free TGT session here
* input : L_Port,R_Port,state:ready
* --creat session/delete--free session
*/
void (*pfn_unf_rport_call_back)(void *, void *, unsigned int);
struct unf_os_thread_private_data_s *data_thread;
};
#define UNF_IO_RESULT_CNT(v_scsi_table, v_scsi_id, v_io_result) \
do { \
if (likely(((v_io_result) < UNF_MAX_IO_RETURN_VALUE) && \
((v_scsi_id) < UNF_MAX_SCSI_ID) && \
((v_scsi_table)->wwn_rport_info_table) && \
(v_scsi_table->wwn_rport_info_table[v_scsi_id].dfx_counter))) { \
atomic64_inc(&v_scsi_table->wwn_rport_info_table[v_scsi_id].dfx_counter->io_done_cnt[v_io_result]); \
} else { \
UNF_TRACE(UNF_EVTLOG_DRIVER_ERR, \
UNF_LOG_EQUIP_ATT, UNF_ERR, \
"[err] io return value(0x%x) or scsi_id(0x%x) is invalid", \
v_io_result, v_scsi_id); \
} \
} while (0)
#define UNF_SCSI_CMD_CNT(v_scsi_table, v_scsi_id, v_io_type) \
do { \
if (likely(((v_io_type) < UNF_MAX_SCSI_CMD) && \
((v_scsi_id) < UNF_MAX_SCSI_ID) && \
((v_scsi_table)->wwn_rport_info_table) && \
(v_scsi_table->wwn_rport_info_table[v_scsi_id].dfx_counter))) { \
atomic64_inc(&((v_scsi_table->wwn_rport_info_table[v_scsi_id]).dfx_counter->scsi_cmd_cnt[v_io_type])); \
} else { \
UNF_TRACE(UNF_EVTLOG_DRIVER_ERR, \
UNF_LOG_EQUIP_ATT, UNF_ERR, \
"[err] scsi_cmd(0x%x) or scsi_id(0x%x) is invalid", \
v_io_type, v_scsi_id); \
} \
} while (0)
#define UNF_SCSI_ERROR_HANDLE_CNT(v_scsi_table, v_scsi_id, v_io_type) \
do { \
if (likely(((v_io_type) < UNF_SCSI_ERROR_HANDLE_BUTT) && \
((v_scsi_id) < UNF_MAX_SCSI_ID) && \
((v_scsi_table)->wwn_rport_info_table) && \
(v_scsi_table->wwn_rport_info_table[v_scsi_id].dfx_counter))) { \
atomic_inc(&v_scsi_table->wwn_rport_info_table[v_scsi_id].dfx_counter->error_handle[v_io_type]); \
} else { \
UNF_TRACE(UNF_EVTLOG_DRIVER_ERR, \
UNF_LOG_EQUIP_ATT, UNF_ERR, \
"[err] scsi_cmd(0x%x) or scsi_id(0x%x) is invalid", \
v_io_type, v_scsi_id); \
} \
} while (0)
#define UNF_SCSI_ERROR_HANDLE_RESULT_CNT(v_scsi_table, v_scsi_id, v_io_type) \
do { \
if (likely(((v_io_type) < UNF_SCSI_ERROR_HANDLE_BUTT) && \
((v_scsi_id) < UNF_MAX_SCSI_ID) && \
((v_scsi_table)->wwn_rport_info_table) && \
(v_scsi_table->wwn_rport_info_table[v_scsi_id].dfx_counter))) { \
atomic_inc(&v_scsi_table->wwn_rport_info_table[v_scsi_id].dfx_counter->error_handle_result[v_io_type]); \
} else { \
UNF_TRACE(UNF_EVTLOG_DRIVER_ERR, \
UNF_LOG_EQUIP_ATT, UNF_ERR, \
"[err] scsi_cmd(0x%x) or scsi_id(0x%x) is invalid", \
v_io_type, v_scsi_id); \
} \
} while (0)
void unf_rport_state_ma(struct unf_rport_s *v_rport,
enum unf_rport_event_e v_event);
void unf_update_lport_state_by_linkup_event(struct unf_lport_s *v_lport,
struct unf_rport_s *v_rport,
unsigned int rport_att);
void unf_rport_enter_closing(struct unf_rport_s *v_rport);
void unf_clean_linkdown_rport(struct unf_lport_s *v_lport);
void unf_rport_error_recovery(struct unf_rport_s *v_rport);
struct unf_rport_s *unf_get_rport_by_nport_id(struct unf_lport_s *v_lport,
unsigned int nport_id);
void unf_rport_enter_logo(struct unf_lport_s *v_lport,
struct unf_rport_s *v_rport);
unsigned int unf_rport_ref_inc(struct unf_rport_s *v_rport);
void unf_rport_ref_dec(struct unf_rport_s *v_rport);
struct unf_rport_s *unf_rport_set_qualifier_key_reuse(
struct unf_lport_s *v_lport,
struct unf_rport_s *v_rport_by_nport_id,
struct unf_rport_s *v_rport_by_wwpn,
unsigned long long v_wwpn,
unsigned int v_sid);
void unf_rport_delay_login(struct unf_rport_s *v_rport);
struct unf_rport_s *unf_find_valid_rport(struct unf_lport_s *v_lport,
unsigned long long v_wwpn,
unsigned int v_sid);
void unf_rport_linkdown(struct unf_lport_s *v_lport,
struct unf_rport_s *v_rport);
struct unf_rport_s *unf_get_safe_rport(struct unf_lport_s *v_lport,
struct unf_rport_s *v_rport,
enum unf_rport_reuse_flag_e v_reuse_flag,
unsigned int v_nport_id);
void *unf_rport_get_free_and_init(void *v_lport,
unsigned int v_port_type,
unsigned int v_nport_id);
unsigned int unf_free_scsi_id(struct unf_lport_s *v_lport,
unsigned int v_scsi_id);
void unf_schedule_closing_work(struct unf_lport_s *v_lport,
struct unf_rport_s *v_rport);
void unf_sesion_loss_timeout(struct work_struct *v_work);
unsigned int unf_get_port_feature(unsigned long long v_wwpn);
void unf_update_port_feature(unsigned long long v_wwpn,
unsigned int v_port_feature);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册