Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_hal_queues.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, Emulex
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 are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 /**
34  * @file
35  *
36  */
37 
38 #ifndef __OCS_HAL_QUEUES_H__
39 #define __OCS_HAL_QUEUES_H__
40 
41 #define OCS_HAL_EQ_ENTRIES_MIN 1024
42 #define OCS_HAL_EQ_ENTRIES_DEF 1024
43 #define OCS_HAL_EQ_ENTRIES_MAX 4096
44 
45 #define OCS_HAL_CQ_ENTRIES_MIN 256
46 #define OCS_HAL_CQ_ENTRIES_DEF 4096
47 #define OCS_HAL_CQ_ENTRIES_MAX 4096
48 
49 #define OCS_HAL_WQ_ENTRIES_MIN 64
50 #define OCS_HAL_WQ_ENTRIES_DEF 2048
51 #define OCS_HAL_WQ_ENTRIES_MAX 2048
52 
53 #define OCS_HAL_RQ_ENTRIES_MIN 512
54 #define OCS_HAL_RQ_ENTRIES_DEF 1024
55 #define OCS_HAL_RQ_ENTRIES_MAX 4096
56 
57 #define OCS_HAL_MQ_ENTRIES_MIN 16
58 #define OCS_HAL_MQ_ENTRIES_DEF 128
59 #define OCS_HAL_MQ_ENTRIES_MAX 128
60 
61 typedef enum {
62  QTOP_EQ = 0,
69 
70 typedef struct {
72  uint8_t set_default;
73  uint32_t len;
74  uint8_t class;
75  uint8_t ulp;
76  uint8_t filter_mask;
77  uint8_t policy;
78  uint8_t nvmeq;
80  uint8_t protocol;
82 
83 typedef struct {
84  struct rq_config {
85  hal_eq_t *eq;
86  uint32_t len;
87  uint8_t class;
88  uint8_t ulp;
89  uint8_t filter_mask;
90  uint8_t policy;
91  uint8_t nvmeq;
93  uint8_t protocol;
94  } rq_cfg[OCS_HAL_MAX_RQ_PAIRS]; // 8 Filters
95  uint32_t num_pairs;
97 
98 typedef struct {
99  uint32_t num_pairs;
100  uint32_t len;
101  uint8_t class;
102  uint8_t ulp;
103  uint8_t filter_mask;
104  uint8_t policy;
105  uint8_t nvmeq;
107  uint8_t protocol;
110 
111 
112 #define MAX_TOKENS 256
113 #define OCS_HAL_MAX_QTOP_ENTRIES 200
114 
115 typedef struct {
116  ocs_os_handle_t os;
118  uint32_t alloc_count;
119  uint32_t inuse_count;
120  uint32_t entry_counts[QTOP_LAST];
121  uint32_t rptcount[10];
122  uint32_t rptcount_idx;
124 
125 extern ocs_hal_qtop_t *ocs_hal_qtop_parse(ocs_hal_t *hal, const char *qtop_string);
126 extern void ocs_hal_qtop_free(ocs_hal_qtop_t *qtop);
127 extern const char *ocs_hal_qtop_entry_name(ocs_hal_qtop_entry_e entry);
128 extern uint32_t ocs_hal_qtop_eq_count(ocs_hal_t *hal);
129 
130 extern ocs_hal_rtn_e ocs_hal_init_queues(ocs_hal_t *hal, ocs_hal_qtop_t *qtop);
131 extern void hal_thread_eq_handler(ocs_hal_t *hal, hal_eq_t *eq, uint32_t max_isr_time_msec);
132 extern void hal_thread_cq_handler(ocs_hal_t *hal, hal_cq_t *cq);
133 extern hal_wq_t *ocs_hal_queue_next_wq(ocs_hal_t *hal, ocs_hal_io_t *io);
134 
135 static inline bool
136 ocs_power_of_2(size_t len)
137 {
138  return ((len) && (0 == (len & (len-1))));
139 }
140 
141 static inline bool
142 ocs_qlen_valid(uint32_t qlen, uint32_t min, uint32_t max)
143 {
144  return ((qlen >= min) && (qlen <= max) && (ocs_power_of_2(qlen)));
145 }
146 
147 #endif /* __OCS_HAL_QUEUES_H__ */
uint32_t len
ocs_hal_qtop_entry_t * entries
ocs_hal_qtop_entry_e entry
uint32_t alloc_count
uint8_t nvmeq
uint8_t protocol
static bool ocs_power_of_2(size_t len)
uint32_t ocs_hal_qtop_eq_count(ocs_hal_t *hal)
Return count of EQs for a queue topology object.
ocs_hal_rtn_e ocs_hal_init_queues(ocs_hal_t *hal, ocs_hal_qtop_t *qtop)
Initialize queues.
uint8_t filter_mask
bool protocol_valid
ocs_hal_rtn_e
Definition: ocs_hal.h:159
ocs_hal_qtop_entry_e
uint32_t rptcount_idx
uint8_t ulp
hal_wq_t * ocs_hal_queue_next_wq(ocs_hal_t *hal, ocs_hal_io_t *io)
Allocate a WQ to an IO object.
void hal_thread_eq_handler(ocs_hal_t *hal, hal_eq_t *eq, uint32_t max_isr_time_msec)
uint8_t policy
void ocs_hal_qtop_free(ocs_hal_qtop_t *qtop)
free queue topology object
#define OCS_HAL_MAX_RQ_PAIRS
Definition: ocs_hal.h:119
ocs_os_handle_t os
void hal_thread_cq_handler(ocs_hal_t *hal, hal_cq_t *cq)
ocs_hal_qtop_t * ocs_hal_qtop_parse(ocs_hal_t *hal, const char *qtop_string)
Parse queue topology string.
const char * ocs_hal_qtop_entry_name(ocs_hal_qtop_entry_e entry)
#define OCE_HAL_MAX_NUM_MRQ_PAIRS
Definition: ocs_hal.h:123
static bool ocs_qlen_valid(uint32_t qlen, uint32_t min, uint32_t max)
uint32_t inuse_count
uint8_t set_default