xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_roce.h (revision b9f654b163bce26de79705e77b872427c9f2afa1)
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  * $FreeBSD$
28  *
29  */
30 
31 #ifndef __ECORE_ROCE_H__
32 #define __ECORE_ROCE_H__
33 
34 #include "ecore_status.h"
35 
36 #define ECORE_ROCE_QP_TO_ICID(qp_idx)		((qp_idx)*2)
37 #define ECORE_ROCE_ICID_TO_QP(icid)		((icid)/2)
38 
39 /* functions for enabling/disabling edpm in rdma PFs according to existence of
40  * qps during DCBx update or bar size
41  */
42 void
43 ecore_roce_dpm_dcbx(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
44 
45 void
46 ecore_rdma_dpm_bar(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
47 
48 enum _ecore_status_t
49 ecore_roce_dcqcn_cfg(struct ecore_hwfn *p_hwfn,
50 		     struct ecore_roce_dcqcn_params *params,
51 		     struct roce_init_func_ramrod_data *p_ramrod,
52 		     struct ecore_ptt *p_ptt);
53 
54 enum _ecore_status_t
55 ecore_roce_setup(struct ecore_hwfn *p_hwfn);
56 
57 enum _ecore_status_t
58 ecore_roce_stop_rl(struct ecore_hwfn *p_hwfn);
59 
60 enum _ecore_status_t
61 ecore_roce_stop(struct ecore_hwfn *p_hwfn);
62 
63 enum _ecore_status_t
64 ecore_roce_query_qp(struct ecore_hwfn *p_hwfn,
65 		    struct ecore_rdma_qp *qp,
66 		    struct ecore_rdma_query_qp_out_params *out_params);
67 
68 enum _ecore_status_t
69 ecore_roce_destroy_qp(struct ecore_hwfn *p_hwfn,
70 		      struct ecore_rdma_qp *qp,
71 		      struct ecore_rdma_destroy_qp_out_params *out_params);
72 
73 enum _ecore_status_t
74 ecore_roce_alloc_qp_idx(struct ecore_hwfn *p_hwfn,
75 			u16 *qp_idx16);
76 
77 #define IS_ECORE_DCQCN(p_hwfn)	\
78 	(!!(p_hwfn->pf_params.rdma_pf_params.enable_dcqcn))
79 
80 struct ecore_roce_info {
81 	struct roce_events_stats	event_stats;
82 	struct roce_dcqcn_received_stats dcqcn_rx_stats;
83 	struct roce_dcqcn_sent_stats	dcqcn_tx_stats;
84 
85 	u8				dcqcn_enabled;
86 	u8				dcqcn_reaction_point;
87 };
88 
89 enum _ecore_status_t
90 ecore_roce_modify_qp(struct ecore_hwfn *p_hwfn,
91 		     struct ecore_rdma_qp *qp,
92 		     enum ecore_roce_qp_state prev_state,
93 		     struct ecore_rdma_modify_qp_in_params *params);
94 
95 #endif /*__ECORE_ROCE_H__*/
96