xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_ooo.h (revision 42249ef2)
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_OOO_H__
32 #define __ECORE_OOO_H__
33 
34 #include "ecore.h"
35 
36 #define ECORE_MAX_NUM_ISLES	256
37 #define ECORE_MAX_NUM_OOO_HISTORY_ENTRIES	512
38 
39 #define ECORE_OOO_LEFT_BUF	0
40 #define ECORE_OOO_RIGHT_BUF	1
41 
42 struct ecore_ooo_buffer {
43 	osal_list_entry_t	list_entry;
44 	void			*rx_buffer_virt_addr;
45 	dma_addr_t		rx_buffer_phys_addr;
46 	u32			rx_buffer_size;
47 	u16			packet_length;
48 	u16			parse_flags;
49 	u16			vlan;
50 	u8			placement_offset;
51 };
52 
53 struct ecore_ooo_isle {
54 	osal_list_entry_t	list_entry;
55 	osal_list_t		buffers_list;
56 };
57 
58 struct ecore_ooo_archipelago {
59 	osal_list_t		isles_list;
60 };
61 
62 struct ecore_ooo_history {
63 	struct ooo_opaque	*p_cqes;
64 	u32			head_idx;
65 	u32			num_of_cqes;
66 };
67 
68 struct ecore_ooo_info {
69 	osal_list_t	 free_buffers_list;
70 	osal_list_t	 ready_buffers_list;
71 	osal_list_t	 free_isles_list;
72 	struct ecore_ooo_archipelago	*p_archipelagos_mem;
73 	struct ecore_ooo_isle	*p_isles_mem;
74 	struct ecore_ooo_history	ooo_history;
75 	u32		cur_isles_number;
76 	u32		max_isles_number;
77 	u32		gen_isles_number;
78 	u16		max_num_archipelagos;
79 	u16		cid_base;
80 };
81 
82 #if defined(CONFIG_ECORE_ISCSI) || defined(CONFIG_ECORE_IWARP)
83 enum _ecore_status_t ecore_ooo_alloc(struct ecore_hwfn *p_hwfn);
84 
85 void ecore_ooo_setup(struct ecore_hwfn *p_hwfn);
86 
87 void ecore_ooo_free(struct ecore_hwfn *p_hwfn);
88 #else
89 static inline enum _ecore_status_t
90 ecore_ooo_alloc(struct ecore_hwfn OSAL_UNUSED *p_hwfn)
91 {
92 	return ECORE_INVAL;
93 }
94 
95 static inline void
96 ecore_ooo_setup(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {}
97 
98 static inline void
99 ecore_ooo_free(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {}
100 #endif
101 
102 
103 void ecore_ooo_save_history_entry(struct ecore_ooo_info *p_ooo_info,
104 				  struct ooo_opaque *p_cqe);
105 
106 void ecore_ooo_release_connection_isles(struct ecore_ooo_info *p_ooo_info,
107 					u32 cid);
108 
109 void ecore_ooo_release_all_isles(struct ecore_ooo_info *p_ooo_info);
110 
111 void ecore_ooo_put_free_buffer(struct ecore_ooo_info *p_ooo_info,
112 			       struct ecore_ooo_buffer *p_buffer);
113 
114 struct ecore_ooo_buffer *
115 ecore_ooo_get_free_buffer(struct ecore_ooo_info *p_ooo_info);
116 
117 void ecore_ooo_put_ready_buffer(struct ecore_ooo_info *p_ooo_info,
118 				struct ecore_ooo_buffer *p_buffer, u8 on_tail);
119 
120 struct ecore_ooo_buffer *
121 ecore_ooo_get_ready_buffer(struct ecore_ooo_info *p_ooo_info);
122 
123 void ecore_ooo_delete_isles(struct ecore_hwfn	*p_hwfn,
124 			   struct ecore_ooo_info *p_ooo_info,
125 			   u32 cid,
126 			   u8 drop_isle,
127 			   u8 drop_size);
128 
129 void ecore_ooo_add_new_isle(struct ecore_hwfn	*p_hwfn,
130 			   struct ecore_ooo_info *p_ooo_info,
131 			   u32 cid,
132 			   u8 ooo_isle,
133 			   struct ecore_ooo_buffer *p_buffer);
134 
135 void ecore_ooo_add_new_buffer(struct ecore_hwfn	*p_hwfn,
136 			     struct ecore_ooo_info *p_ooo_info,
137 			     u32 cid,
138 			     u8 ooo_isle,
139 			     struct ecore_ooo_buffer *p_buffer,
140 		             u8 buffer_side);
141 
142 void ecore_ooo_join_isles(struct ecore_hwfn	*p_hwfn,
143 			 struct ecore_ooo_info *p_ooo_info,
144 			 u32 cid,
145 			 u8 left_isle);
146 
147 void ecore_ooo_dump_rx_event(struct ecore_hwfn	*p_hwfn,
148 			     struct ooo_opaque *iscsi_ooo,
149 			     struct ecore_ooo_buffer *p_buffer);
150 
151 #endif  /*__ECORE_OOO_H__*/
152 
153