Back to home page

OSCL-LXR

 
 

    


0001 /* This file is part of the Emulex RoCE Device Driver for
0002  * RoCE (RDMA over Converged Ethernet) adapters.
0003  * Copyright (C) 2012-2015 Emulex. All rights reserved.
0004  * EMULEX and SLI are trademarks of Emulex.
0005  * www.emulex.com
0006  *
0007  * This software is available to you under a choice of one of two licenses.
0008  * You may choose to be licensed under the terms of the GNU General Public
0009  * License (GPL) Version 2, available from the file COPYING in the main
0010  * directory of this source tree, or the BSD license below:
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  *
0016  * - Redistributions of source code must retain the above copyright notice,
0017  *   this list of conditions and the following disclaimer.
0018  *
0019  * - Redistributions in binary form must reproduce the above copyright
0020  *   notice, this list of conditions and the following disclaimer in
0021  *   the documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
0030  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
0031  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
0032  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
0033  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0034  *
0035  * Contact Information:
0036  * linux-drivers@emulex.com
0037  *
0038  * Emulex
0039  * 3333 Susan Street
0040  * Costa Mesa, CA 92626
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 /* verbs specific mailbox commands */
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              /* __OCRDMA_HW_H__ */