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
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 #ifndef __OCRDMA_HW_H__
0044 #define __OCRDMA_HW_H__
0045
0046 #include "ocrdma_sli.h"
0047
0048 static inline void ocrdma_cpu_to_le32(void *dst, u32 len)
0049 {
0050 #ifdef __BIG_ENDIAN
0051 int i = 0;
0052 u32 *src_ptr = dst;
0053 u32 *dst_ptr = dst;
0054 for (; i < (len / 4); i++)
0055 *(dst_ptr + i) = cpu_to_le32p(src_ptr + i);
0056 #endif
0057 }
0058
0059 static inline void ocrdma_le32_to_cpu(void *dst, u32 len)
0060 {
0061 #ifdef __BIG_ENDIAN
0062 int i = 0;
0063 u32 *src_ptr = dst;
0064 u32 *dst_ptr = dst;
0065 for (; i < (len / sizeof(u32)); i++)
0066 *(dst_ptr + i) = le32_to_cpu(*(src_ptr + i));
0067 #endif
0068 }
0069
0070 static inline void ocrdma_copy_cpu_to_le32(void *dst, void *src, u32 len)
0071 {
0072 #ifdef __BIG_ENDIAN
0073 int i = 0;
0074 u32 *src_ptr = src;
0075 u32 *dst_ptr = dst;
0076 for (; i < (len / sizeof(u32)); i++)
0077 *(dst_ptr + i) = cpu_to_le32p(src_ptr + i);
0078 #else
0079 memcpy(dst, src, len);
0080 #endif
0081 }
0082
0083 static inline void ocrdma_copy_le32_to_cpu(void *dst, void *src, u32 len)
0084 {
0085 #ifdef __BIG_ENDIAN
0086 int i = 0;
0087 u32 *src_ptr = src;
0088 u32 *dst_ptr = dst;
0089 for (; i < len / sizeof(u32); i++)
0090 *(dst_ptr + i) = le32_to_cpu(*(src_ptr + i));
0091 #else
0092 memcpy(dst, src, len);
0093 #endif
0094 }
0095
0096 static inline u64 ocrdma_get_db_addr(struct ocrdma_dev *dev, u32 pdid)
0097 {
0098 return dev->nic_info.unmapped_db + (pdid * dev->nic_info.db_page_size);
0099 }
0100
0101 int ocrdma_init_hw(struct ocrdma_dev *);
0102 void ocrdma_cleanup_hw(struct ocrdma_dev *);
0103
0104 enum ib_qp_state get_ibqp_state(enum ocrdma_qp_state qps);
0105 void ocrdma_ring_cq_db(struct ocrdma_dev *, u16 cq_id, bool armed,
0106 bool solicited, u16 cqe_popped);
0107
0108
0109 int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed,
0110 u8 *lnk_st);
0111 int ocrdma_query_config(struct ocrdma_dev *,
0112 struct ocrdma_mbx_query_config *config);
0113
0114 int ocrdma_mbx_alloc_pd(struct ocrdma_dev *, struct ocrdma_pd *);
0115 int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *, struct ocrdma_pd *);
0116
0117 int ocrdma_mbx_alloc_lkey(struct ocrdma_dev *, struct ocrdma_hw_mr *hwmr,
0118 u32 pd_id, int addr_check);
0119 int ocrdma_mbx_dealloc_lkey(struct ocrdma_dev *, int fmr, u32 lkey);
0120
0121 int ocrdma_reg_mr(struct ocrdma_dev *, struct ocrdma_hw_mr *hwmr,
0122 u32 pd_id, int acc);
0123 int ocrdma_mbx_create_cq(struct ocrdma_dev *, struct ocrdma_cq *,
0124 int entries, int dpp_cq, u16 pd_id);
0125 void ocrdma_mbx_destroy_cq(struct ocrdma_dev *dev, struct ocrdma_cq *cq);
0126
0127 int ocrdma_mbx_create_qp(struct ocrdma_qp *, struct ib_qp_init_attr *attrs,
0128 u8 enable_dpp_cq, u16 dpp_cq_id, u16 *dpp_offset,
0129 u16 *dpp_credit_lmt);
0130 int ocrdma_mbx_modify_qp(struct ocrdma_dev *, struct ocrdma_qp *,
0131 struct ib_qp_attr *attrs, int attr_mask);
0132 int ocrdma_mbx_query_qp(struct ocrdma_dev *, struct ocrdma_qp *,
0133 struct ocrdma_qp_params *param);
0134 int ocrdma_mbx_destroy_qp(struct ocrdma_dev *, struct ocrdma_qp *);
0135 int ocrdma_mbx_create_srq(struct ocrdma_dev *, struct ocrdma_srq *,
0136 struct ib_srq_init_attr *,
0137 struct ocrdma_pd *);
0138 int ocrdma_mbx_modify_srq(struct ocrdma_srq *, struct ib_srq_attr *);
0139 int ocrdma_mbx_query_srq(struct ocrdma_srq *, struct ib_srq_attr *);
0140 void ocrdma_mbx_destroy_srq(struct ocrdma_dev *dev, struct ocrdma_srq *srq);
0141
0142 int ocrdma_alloc_av(struct ocrdma_dev *dev, struct ocrdma_ah *ah);
0143 void ocrdma_free_av(struct ocrdma_dev *dev, struct ocrdma_ah *ah);
0144
0145 int ocrdma_qp_state_change(struct ocrdma_qp *, enum ib_qp_state new_state,
0146 enum ib_qp_state *old_ib_state);
0147 bool ocrdma_is_qp_in_sq_flushlist(struct ocrdma_cq *, struct ocrdma_qp *);
0148 bool ocrdma_is_qp_in_rq_flushlist(struct ocrdma_cq *, struct ocrdma_qp *);
0149 void ocrdma_flush_qp(struct ocrdma_qp *);
0150 int ocrdma_get_irq(struct ocrdma_dev *dev, struct ocrdma_eq *eq);
0151
0152 int ocrdma_mbx_rdma_stats(struct ocrdma_dev *, bool reset);
0153 char *port_speed_string(struct ocrdma_dev *dev);
0154 void ocrdma_init_service_level(struct ocrdma_dev *);
0155 void ocrdma_alloc_pd_pool(struct ocrdma_dev *dev);
0156 void ocrdma_free_pd_range(struct ocrdma_dev *dev);
0157 void ocrdma_update_link_state(struct ocrdma_dev *dev, u8 lstate);
0158
0159 #endif