0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #ifndef _HNS_ROCE_COMMON_H
0034 #define _HNS_ROCE_COMMON_H
0035 #include <linux/bitfield.h>
0036
0037 #define roce_write(dev, reg, val) writel((val), (dev)->reg_base + (reg))
0038 #define roce_read(dev, reg) readl((dev)->reg_base + (reg))
0039 #define roce_raw_write(value, addr) \
0040 __raw_writel((__force u32)cpu_to_le32(value), (addr))
0041
0042 #define roce_get_field(origin, mask, shift) \
0043 ((le32_to_cpu(origin) & (mask)) >> (u32)(shift))
0044
0045 #define roce_get_bit(origin, shift) \
0046 roce_get_field((origin), (1ul << (shift)), (shift))
0047
0048 #define roce_set_field(origin, mask, shift, val) \
0049 do { \
0050 (origin) &= ~cpu_to_le32(mask); \
0051 (origin) |= \
0052 cpu_to_le32(((u32)(val) << (u32)(shift)) & (mask)); \
0053 } while (0)
0054
0055 #define roce_set_bit(origin, shift, val) \
0056 roce_set_field((origin), (1ul << (shift)), (shift), (val))
0057
0058 #define FIELD_LOC(field_type, field_h, field_l) field_type, field_h, field_l
0059
0060 #define _hr_reg_enable(ptr, field_type, field_h, field_l) \
0061 ({ \
0062 const field_type *_ptr = ptr; \
0063 *((__le32 *)_ptr + (field_h) / 32) |= cpu_to_le32( \
0064 BIT((field_l) % 32) + \
0065 BUILD_BUG_ON_ZERO((field_h) != (field_l))); \
0066 })
0067
0068 #define hr_reg_enable(ptr, field) _hr_reg_enable(ptr, field)
0069
0070 #define _hr_reg_clear(ptr, field_type, field_h, field_l) \
0071 ({ \
0072 const field_type *_ptr = ptr; \
0073 BUILD_BUG_ON(((field_h) / 32) != ((field_l) / 32)); \
0074 *((__le32 *)_ptr + (field_h) / 32) &= \
0075 ~cpu_to_le32(GENMASK((field_h) % 32, (field_l) % 32)); \
0076 })
0077
0078 #define hr_reg_clear(ptr, field) _hr_reg_clear(ptr, field)
0079
0080 #define _hr_reg_write_bool(ptr, field_type, field_h, field_l, val) \
0081 ({ \
0082 (val) ? _hr_reg_enable(ptr, field_type, field_h, field_l) : \
0083 _hr_reg_clear(ptr, field_type, field_h, field_l); \
0084 })
0085
0086 #define hr_reg_write_bool(ptr, field, val) _hr_reg_write_bool(ptr, field, val)
0087
0088 #define _hr_reg_write(ptr, field_type, field_h, field_l, val) \
0089 ({ \
0090 _hr_reg_clear(ptr, field_type, field_h, field_l); \
0091 *((__le32 *)ptr + (field_h) / 32) |= cpu_to_le32(FIELD_PREP( \
0092 GENMASK((field_h) % 32, (field_l) % 32), val)); \
0093 })
0094
0095 #define hr_reg_write(ptr, field, val) _hr_reg_write(ptr, field, val)
0096
0097 #define _hr_reg_read(ptr, field_type, field_h, field_l) \
0098 ({ \
0099 const field_type *_ptr = ptr; \
0100 BUILD_BUG_ON(((field_h) / 32) != ((field_l) / 32)); \
0101 FIELD_GET(GENMASK((field_h) % 32, (field_l) % 32), \
0102 le32_to_cpu(*((__le32 *)_ptr + (field_h) / 32))); \
0103 })
0104
0105 #define hr_reg_read(ptr, field) _hr_reg_read(ptr, field)
0106
0107
0108 #define ROCEE_VENDOR_ID_REG 0x0
0109 #define ROCEE_VENDOR_PART_ID_REG 0x4
0110
0111 #define ROCEE_SYS_IMAGE_GUID_L_REG 0xC
0112 #define ROCEE_SYS_IMAGE_GUID_H_REG 0x10
0113
0114 #define ROCEE_PORT_GID_L_0_REG 0x50
0115 #define ROCEE_PORT_GID_ML_0_REG 0x54
0116 #define ROCEE_PORT_GID_MH_0_REG 0x58
0117 #define ROCEE_PORT_GID_H_0_REG 0x5C
0118
0119 #define ROCEE_BT_CMD_H_REG 0x204
0120
0121 #define ROCEE_SMAC_L_0_REG 0x240
0122 #define ROCEE_SMAC_H_0_REG 0x244
0123
0124 #define ROCEE_QP1C_CFG3_0_REG 0x27C
0125
0126 #define ROCEE_CAEP_AEQE_CONS_IDX_REG 0x3AC
0127 #define ROCEE_CAEP_CEQC_CONS_IDX_0_REG 0x3BC
0128
0129 #define ROCEE_ECC_UCERR_ALM1_REG 0xB38
0130 #define ROCEE_ECC_UCERR_ALM2_REG 0xB3C
0131 #define ROCEE_ECC_CERR_ALM1_REG 0xB44
0132 #define ROCEE_ECC_CERR_ALM2_REG 0xB48
0133
0134 #define ROCEE_ACK_DELAY_REG 0x14
0135 #define ROCEE_GLB_CFG_REG 0x18
0136
0137 #define ROCEE_DMAE_USER_CFG1_REG 0x40
0138 #define ROCEE_DMAE_USER_CFG2_REG 0x44
0139
0140 #define ROCEE_DB_SQ_WL_REG 0x154
0141 #define ROCEE_DB_OTHERS_WL_REG 0x158
0142 #define ROCEE_RAQ_WL_REG 0x15C
0143 #define ROCEE_WRMS_POL_TIME_INTERVAL_REG 0x160
0144 #define ROCEE_EXT_DB_SQ_REG 0x164
0145 #define ROCEE_EXT_DB_SQ_H_REG 0x168
0146 #define ROCEE_EXT_DB_OTH_REG 0x16C
0147
0148 #define ROCEE_EXT_DB_OTH_H_REG 0x170
0149 #define ROCEE_EXT_DB_SQ_WL_EMPTY_REG 0x174
0150 #define ROCEE_EXT_DB_SQ_WL_REG 0x178
0151 #define ROCEE_EXT_DB_OTHERS_WL_EMPTY_REG 0x17C
0152 #define ROCEE_EXT_DB_OTHERS_WL_REG 0x180
0153 #define ROCEE_EXT_RAQ_REG 0x184
0154 #define ROCEE_EXT_RAQ_H_REG 0x188
0155
0156 #define ROCEE_CAEP_CE_INTERVAL_CFG_REG 0x190
0157 #define ROCEE_CAEP_CE_BURST_NUM_CFG_REG 0x194
0158 #define ROCEE_BT_CMD_L_REG 0x200
0159
0160 #define ROCEE_MB1_REG 0x210
0161 #define ROCEE_MB6_REG 0x224
0162 #define ROCEE_DB_SQ_L_0_REG 0x230
0163 #define ROCEE_DB_OTHERS_L_0_REG 0x238
0164 #define ROCEE_QP1C_CFG0_0_REG 0x270
0165
0166 #define ROCEE_CAEP_AEQC_AEQE_SHIFT_REG 0x3A0
0167 #define ROCEE_CAEP_CEQC_SHIFT_0_REG 0x3B0
0168 #define ROCEE_CAEP_CE_IRQ_MASK_0_REG 0x3C0
0169 #define ROCEE_CAEP_CEQ_ALM_OVF_0_REG 0x3C4
0170 #define ROCEE_CAEP_AE_MASK_REG 0x6C8
0171 #define ROCEE_CAEP_AE_ST_REG 0x6CC
0172
0173 #define ROCEE_CAEP_CQE_WCMD_EMPTY 0x850
0174 #define ROCEE_SCAEP_WR_CQE_CNT 0x8D0
0175 #define ROCEE_ECC_UCERR_ALM0_REG 0xB34
0176 #define ROCEE_ECC_CERR_ALM0_REG 0xB40
0177
0178
0179 #define ROCEE_TX_CMQ_BASEADDR_L_REG 0x07000
0180 #define ROCEE_TX_CMQ_BASEADDR_H_REG 0x07004
0181 #define ROCEE_TX_CMQ_DEPTH_REG 0x07008
0182 #define ROCEE_TX_CMQ_PI_REG 0x07010
0183 #define ROCEE_TX_CMQ_CI_REG 0x07014
0184
0185 #define ROCEE_RX_CMQ_BASEADDR_L_REG 0x07018
0186 #define ROCEE_RX_CMQ_BASEADDR_H_REG 0x0701c
0187 #define ROCEE_RX_CMQ_DEPTH_REG 0x07020
0188 #define ROCEE_RX_CMQ_TAIL_REG 0x07024
0189 #define ROCEE_RX_CMQ_HEAD_REG 0x07028
0190
0191 #define ROCEE_VF_EQ_DB_CFG0_REG 0x238
0192 #define ROCEE_VF_EQ_DB_CFG1_REG 0x23C
0193
0194 #define ROCEE_VF_ABN_INT_CFG_REG 0x13000
0195 #define ROCEE_VF_ABN_INT_ST_REG 0x13004
0196 #define ROCEE_VF_ABN_INT_EN_REG 0x13008
0197 #define ROCEE_VF_EVENT_INT_EN_REG 0x1300c
0198
0199 #endif