xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_roce.h (revision 315ee00fa9616b0a192b6834911f98bcf5316a6b)
1 /*
2  * Copyright (c) 2017-2018 Cavium, Inc.
3  * All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *  1. Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  *  2. Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  *  POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef __ECORE_ROCE_H__
30 #define __ECORE_ROCE_H__
31 
32 #include "ecore_status.h"
33 
34 #define ECORE_ROCE_QP_TO_ICID(qp_idx)		((qp_idx)*2)
35 #define ECORE_ROCE_ICID_TO_QP(icid)		((icid)/2)
36 
37 /* functions for enabling/disabling edpm in rdma PFs according to existence of
38  * qps during DCBx update or bar size
39  */
40 void
41 ecore_roce_dpm_dcbx(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
42 
43 void
44 ecore_rdma_dpm_bar(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
45 
46 enum _ecore_status_t
47 ecore_roce_dcqcn_cfg(struct ecore_hwfn *p_hwfn,
48 		     struct ecore_roce_dcqcn_params *params,
49 		     struct roce_init_func_ramrod_data *p_ramrod,
50 		     struct ecore_ptt *p_ptt);
51 
52 enum _ecore_status_t
53 ecore_roce_setup(struct ecore_hwfn *p_hwfn);
54 
55 enum _ecore_status_t
56 ecore_roce_stop_rl(struct ecore_hwfn *p_hwfn);
57 
58 enum _ecore_status_t
59 ecore_roce_stop(struct ecore_hwfn *p_hwfn);
60 
61 enum _ecore_status_t
62 ecore_roce_query_qp(struct ecore_hwfn *p_hwfn,
63 		    struct ecore_rdma_qp *qp,
64 		    struct ecore_rdma_query_qp_out_params *out_params);
65 
66 enum _ecore_status_t
67 ecore_roce_destroy_qp(struct ecore_hwfn *p_hwfn,
68 		      struct ecore_rdma_qp *qp,
69 		      struct ecore_rdma_destroy_qp_out_params *out_params);
70 
71 enum _ecore_status_t
72 ecore_roce_alloc_qp_idx(struct ecore_hwfn *p_hwfn,
73 			u16 *qp_idx16);
74 
75 #define IS_ECORE_DCQCN(p_hwfn)	\
76 	(!!(p_hwfn->pf_params.rdma_pf_params.enable_dcqcn))
77 
78 struct ecore_roce_info {
79 	struct roce_events_stats	event_stats;
80 	struct roce_dcqcn_received_stats dcqcn_rx_stats;
81 	struct roce_dcqcn_sent_stats	dcqcn_tx_stats;
82 
83 	u8				dcqcn_enabled;
84 	u8				dcqcn_reaction_point;
85 };
86 
87 enum _ecore_status_t
88 ecore_roce_modify_qp(struct ecore_hwfn *p_hwfn,
89 		     struct ecore_rdma_qp *qp,
90 		     enum ecore_roce_qp_state prev_state,
91 		     struct ecore_rdma_modify_qp_in_params *params);
92 
93 #endif /*__ECORE_ROCE_H__*/
94