9506 Want support for QLogic QL41000/45000 series devices
[unleashed.git] / usr / src / uts / common / io / qede / qede_cfg.c
blob1b52c27d93b0680765edd9958e3b5ce31e1f761a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, v.1, (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2014-2017 Cavium, Inc.
24 * The contents of this file are subject to the terms of the Common Development
25 * and Distribution License, v.1, (the "License").
27 * You may not use this file except in compliance with the License.
29 * You can obtain a copy of the License at available
30 * at http://opensource.org/licenses/CDDL-1.0
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
37 #include "qede.h"
39 qede_link_props_t qede_def_link_props =
41 GLDM_FIBER,
42 B_TRUE,
43 B_TRUE,
44 B_TRUE,
45 B_TRUE,
46 B_TRUE,
47 B_TRUE,
48 B_TRUE,
49 B_TRUE,
50 B_FALSE
52 static void
53 qede_cfg_get_val(qede_t *qede,
54 char * pName,
55 void * pVal,
56 int defaultVal,
57 boolean_t boolVal)
59 int val;
60 #define QEDE_CFG_NAME_LEN_MAX 128
62 char name[QEDE_CFG_NAME_LEN_MAX];
64 /* first check if the hardcoded default has been overridden */
66 snprintf(name, QEDE_CFG_NAME_LEN_MAX, "default_%s", pName);
68 val = ddi_prop_get_int(DDI_DEV_T_ANY,
69 qede->dip,
70 (DDI_PROP_NOTPROM | DDI_PROP_DONTPASS),
71 name,
72 defaultVal);
73 /* now check for a config for this specific instance */
75 snprintf(name, QEDE_CFG_NAME_LEN_MAX, "qede%d_%s", qede->instance,
76 pName);
78 val = ddi_prop_get_int(DDI_DEV_T_ANY,
79 qede->dip,
80 (DDI_PROP_NOTPROM | DDI_PROP_DONTPASS),
81 name,
82 val);
84 if (boolVal) {
85 *((boolean_t *)pVal) = (val) ? B_TRUE : B_FALSE;
86 } else {
87 *((int *)pVal) = val;
91 void
92 qede_cfg_init(qede_t *qede)
95 int option;
97 qede->checksum = DEFAULT_CKSUM_OFFLOAD;
98 qede->enabled_offloads = QEDE_OFFLOAD_NONE;
99 qede->mtu = DEFAULT_MTU;
100 qede->num_fp = DEFAULT_FASTPATH_COUNT;
101 qede->rx_ring_size = DEFAULT_RX_RING_SIZE;
102 qede->tx_ring_size = DEFAULT_TX_RING_SIZE;
103 qede->tx_recycle_threshold = DEFAULT_TX_RECYCLE_THRESHOLD;
104 qede->rx_copy_threshold = DEFAULT_RX_COPY_THRESHOLD;
105 qede->tx_bcopy_threshold = DEFAULT_TX_COPY_THRESHOLD;
106 qede->lso_enable = B_TRUE;
107 qede->lro_enable = B_TRUE;
108 qede->log_enable = B_TRUE;
109 qede->ecore_debug_level = DEFAULT_ECORE_DEBUG_LEVEL;
110 qede->ecore_debug_module = DEFAULT_ECORE_DEBUG_MODULE;
112 qede_cfg_get_val(qede, "checksum",
113 &qede->checksum,
114 qede->checksum,
115 B_FALSE);
116 switch(qede->checksum) {
117 case USER_OPTION_CKSUM_L3:
118 case USER_OPTION_CKSUM_L3_L4:
119 qede->checksum = DEFAULT_CKSUM_OFFLOAD;
120 break;
123 qede_cfg_get_val(qede, "mtu", &option,
124 qede->mtu,
125 B_FALSE);
127 if (option != DEFAULT_JUMBO_MTU &&
128 option != DEFAULT_MTU) {
129 qede->mtu = DEFAULT_MTU;
130 qede->jumbo_enable = B_FALSE;
131 } else {
132 if (qede->mtu != option) {
133 qede->mtu = option;
135 if (option == DEFAULT_JUMBO_MTU) {
136 qede->jumbo_enable = B_TRUE;
140 qede_cfg_get_val(qede, "num_fp", &option,
141 qede->num_fp,
142 B_FALSE);
143 qede->num_fp = (option < MIN_FASTPATH_COUNT) ?
144 MIN_FASTPATH_COUNT :
145 (option > MAX_FASTPATH_COUNT) ?
146 MAX_FASTPATH_COUNT :
147 option;
149 qede_cfg_get_val(qede, "rx_ring_size", &option,
150 qede->rx_ring_size,
151 B_FALSE);
152 qede->rx_ring_size = (option < MIN_RX_RING_SIZE) ?
153 MIN_RX_RING_SIZE :
154 (option > MAX_RX_RING_SIZE) ?
155 MAX_RX_RING_SIZE :
156 option;
157 qede_cfg_get_val(qede, "tx_ring_size", &option,
158 qede->tx_ring_size,
159 B_FALSE);
160 qede->tx_ring_size = (option < MIN_TX_RING_SIZE) ?
161 MIN_TX_RING_SIZE :
162 (option > MAX_TX_RING_SIZE) ?
163 MAX_TX_RING_SIZE :
164 option;
165 qede_cfg_get_val(qede, "rx_copy_threshold", &option,
166 qede->rx_copy_threshold,
167 B_FALSE);
168 qede_cfg_get_val(qede, "tx_copy_threshold", &option,
169 qede->tx_bcopy_threshold,
170 B_FALSE);
171 qede_cfg_get_val(qede, "tx_recycle_threshold", &option,
172 qede->tx_bcopy_threshold,
173 B_FALSE);
174 qede->tx_recycle_threshold =
175 (option < 0) ? 0:
176 (option > qede->tx_ring_size) ?
177 qede->tx_ring_size : option;
178 qede_cfg_get_val(qede, "lso_enable", &option,
179 qede->lso_enable,
180 B_TRUE);
181 qede->lso_enable = option;
182 qede_cfg_get_val(qede, "lro_enable", &option,
183 qede->lro_enable,
184 B_TRUE);
185 qede->lro_enable = option;
187 if(qede->checksum != DEFAULT_CKSUM_OFFLOAD) {
188 qede->lso_enable = B_FALSE;
189 qede->lro_enable = B_FALSE;
192 qede_cfg_get_val(qede, "log_enable", &option,
193 qede->log_enable,
194 B_TRUE);
195 qede_cfg_get_val(qede, "debug_level", &option,
196 qede->ecore_debug_level,
197 B_FALSE);
198 qede->ecore_debug_level = (uint32_t)((option < 0) ? 0 : option);
200 qede_cfg_get_val(qede, "debug_module", &option,
201 qede->ecore_debug_module,
202 B_FALSE);
203 qede->ecore_debug_module = (uint32_t)((option < 0) ? 0 : option);
207 void
208 qede_cfg_reset(qede_t *qede)
210 qede->params.link_state = 0;
211 /* reset the link status */
212 qede->props.link_speed = 0;
213 qede->props.link_duplex = B_FALSE;
214 qede->props.tx_pause = B_FALSE;
215 qede->props.rx_pause = B_FALSE;
216 qede->props.uptime = 0;