xref: /illumos-gate/usr/src/uts/common/io/bnxe/bnxe_cfg.c (revision 0803869a9bc0aff1c81287ac6eae15943cbba545)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2014 QLogic Corporation
24  * The contents of this file are subject to the terms of the
25  * QLogic End User License (the "License").
26  * You may not use this file except in compliance with the License.
27  *
28  * You can obtain a copy of the License at
29  * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
30  * QLogic_End_User_Software_License.txt
31  * See the License for the specific language governing permissions
32  * and limitations under the License.
33  */
34 
35 /*
36  * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
37  */
38 
39 #include "bnxe.h"
40 
41 
42 /* these are the default phy link configs */
43 BnxeLinkCfg bnxeLinkCfg =
44 {
45     B_TRUE,  /* link_autoneg   */
46     B_TRUE,  /* param_20000fdx */
47     B_TRUE,  /* param_10000fdx */
48     B_TRUE,  /* param_2500fdx  */
49     B_TRUE,  /* param_1000fdx  */
50     B_FALSE, /* param_100fdx   */
51     B_FALSE, /* param_100hdx   */
52     B_FALSE, /* param_10fdx    */
53     B_FALSE, /* param_10hdx    */
54     B_TRUE,  /* param_txpause  */
55     B_TRUE   /* param_rxpause  */
56 };
57 
58 
59 static void BnxeCfgGetVal(um_device_t * pUM,
60                           char *        pName,
61                           void *        pVal,
62                           int           defaultVal,
63                           boolean_t     boolVal)
64 {
65     int val;
66     #define BNXE_CFG_NAME_LEN_MAX 128
67     char name[BNXE_CFG_NAME_LEN_MAX];
68 
69     /* first check if the hardcoded default has been overridden */
70 
71     snprintf(name, BNXE_CFG_NAME_LEN_MAX, "default_%s", pName);
72 
73     val = ddi_prop_get_int(DDI_DEV_T_ANY,
74                            pUM->pDev,
75                            (DDI_PROP_NOTPROM | DDI_PROP_DONTPASS),
76                            name,
77                            defaultVal);
78 
79     /* now check for a config for this specific instance */
80 
81     snprintf(name, BNXE_CFG_NAME_LEN_MAX, "bnxe%d_%s", pUM->instance, pName);
82 
83     val = ddi_prop_get_int(DDI_DEV_T_ANY,
84                            pUM->pDev,
85                            (DDI_PROP_NOTPROM | DDI_PROP_DONTPASS),
86                            name,
87                            val);
88 
89     if (boolVal)
90     {
91         *((boolean_t *)pVal) = (val) ? B_TRUE : B_FALSE;
92     }
93     else
94     {
95         *((int *)pVal) = val;
96     }
97 }
98 
99 
100 void BnxeCfg_LLDP_DCBX(um_device_t * pUM)
101 {
102     lm_device_t * pLM = &pUM->lm_dev;
103     char name[64];
104     int i;
105 
106     /* DCBX defaults configuration: DCBX not supported by default. */
107     pLM->params.dcbx_port_params.dcbx_enabled = FALSE;
108 
109     /* DCBX defaults configuration: PFC not supported. */
110     pLM->params.dcbx_port_params.pfc.enabled = FALSE;
111 
112     for (i = 0; i < LLFC_DRIVER_TRAFFIC_TYPE_MAX; i++)
113     {
114         pLM->params.dcbx_port_params.app.traffic_type_priority[i] =
115             INVALID_TRAFFIC_TYPE_PRIORITY;
116     }
117 
118     pLM->params.dcbx_port_params.pfc.priority_non_pauseable_mask = 0;
119 
120     memset(&pLM->params.lldp_config_params, 0xFF,
121            sizeof(pLM->params.lldp_config_params));
122     memset(&pLM->params.dcbx_config_params, 0xFF,
123            sizeof(pLM->params.dcbx_config_params));
124 
125     pLM->params.dcbx_config_params.dcb_enable        = 1;
126     pLM->params.dcbx_config_params.admin_dcbx_enable = 1;
127 
128     BnxeCfgGetVal(pUM, "lldp_overwrite_settings",
129                   &pLM->params.lldp_config_params.overwrite_settings,
130                   pLM->params.lldp_config_params.overwrite_settings,
131                   B_FALSE);
132 
133     BnxeCfgGetVal(pUM, "lldp_msg_tx_hold",
134                   &pLM->params.lldp_config_params.msg_tx_hold,
135                   pLM->params.lldp_config_params.msg_tx_hold,
136                   B_FALSE);
137 
138     BnxeCfgGetVal(pUM, "lldp_msg_fast_tx",
139                   &pLM->params.lldp_config_params.msg_fast_tx,
140                   pLM->params.lldp_config_params.msg_fast_tx,
141                   B_FALSE);
142 
143     BnxeCfgGetVal(pUM, "lldp_tx_credit_max",
144                   &pLM->params.lldp_config_params.tx_credit_max,
145                   pLM->params.lldp_config_params.tx_credit_max,
146                   B_FALSE);
147 
148     BnxeCfgGetVal(pUM, "lldp_msg_tx_interval",
149                   &pLM->params.lldp_config_params.msg_tx_interval,
150                   pLM->params.lldp_config_params.msg_tx_interval,
151                   B_FALSE);
152 
153     BnxeCfgGetVal(pUM, "lldp_tx_fast",
154                   &pLM->params.lldp_config_params.tx_fast,
155                   pLM->params.lldp_config_params.tx_fast,
156                   B_FALSE);
157 
158     BnxeCfgGetVal(pUM, "dcbx_dcb_enable",
159                   &pLM->params.dcbx_config_params.dcb_enable,
160                   pLM->params.dcbx_config_params.dcb_enable,
161                   B_FALSE);
162 
163     BnxeCfgGetVal(pUM, "dcbx_admin_dcbx_enable",
164                   &pLM->params.dcbx_config_params.admin_dcbx_enable,
165                   pLM->params.dcbx_config_params.admin_dcbx_enable,
166                   B_FALSE);
167 
168     BnxeCfgGetVal(pUM, "dcbx_overwrite_settings",
169                   &pLM->params.dcbx_config_params.overwrite_settings,
170                   pLM->params.dcbx_config_params.overwrite_settings,
171                   B_FALSE);
172 
173     BnxeCfgGetVal(pUM, "dcbx_admin_dcbx_version",
174                   &pLM->params.dcbx_config_params.admin_dcbx_version,
175                   pLM->params.dcbx_config_params.admin_dcbx_version,
176                   B_FALSE);
177 
178     BnxeCfgGetVal(pUM, "dcbx_admin_ets_enable",
179                   &pLM->params.dcbx_config_params.admin_ets_enable,
180                   pLM->params.dcbx_config_params.admin_ets_enable,
181                   B_FALSE);
182 
183     BnxeCfgGetVal(pUM, "dcbx_admin_pfc_enable",
184                   &pLM->params.dcbx_config_params.admin_pfc_enable,
185                   pLM->params.dcbx_config_params.admin_pfc_enable,
186                   B_FALSE);
187 
188     BnxeCfgGetVal(pUM, "dcbx_admin_tc_supported_tx_enable",
189                   &pLM->params.dcbx_config_params.admin_tc_supported_tx_enable,
190                   pLM->params.dcbx_config_params.admin_tc_supported_tx_enable,
191                   B_FALSE);
192 
193     BnxeCfgGetVal(pUM, "dcbx_admin_ets_configuration_tx_enable",
194                   &pLM->params.dcbx_config_params.admin_ets_configuration_tx_enable,
195                   pLM->params.dcbx_config_params.admin_ets_configuration_tx_enable,
196                   B_FALSE);
197 
198     BnxeCfgGetVal(pUM, "dcbx_admin_ets_recommendation_tx_enable",
199                   &pLM->params.dcbx_config_params.admin_ets_recommendation_tx_enable,
200                   pLM->params.dcbx_config_params.admin_ets_recommendation_tx_enable,
201                   B_FALSE);
202 
203     BnxeCfgGetVal(pUM, "dcbx_admin_pfc_tx_enable",
204                   &pLM->params.dcbx_config_params.admin_pfc_tx_enable,
205                   pLM->params.dcbx_config_params.admin_pfc_tx_enable,
206                   B_FALSE);
207 
208     BnxeCfgGetVal(pUM, "dcbx_admin_application_priority_tx_enable",
209                   &pLM->params.dcbx_config_params.admin_application_priority_tx_enable,
210                   pLM->params.dcbx_config_params.admin_application_priority_tx_enable,
211                   B_FALSE);
212 
213     BnxeCfgGetVal(pUM, "dcbx_admin_ets_willing",
214                   &pLM->params.dcbx_config_params.admin_ets_willing,
215                   pLM->params.dcbx_config_params.admin_ets_willing,
216                   B_FALSE);
217 
218     BnxeCfgGetVal(pUM, "dcbx_admin_pfc_willing",
219                   &pLM->params.dcbx_config_params.admin_pfc_willing,
220                   pLM->params.dcbx_config_params.admin_pfc_willing,
221                   B_FALSE);
222 
223     BnxeCfgGetVal(pUM, "dcbx_admin_ets_reco_valid",
224                   &pLM->params.dcbx_config_params.admin_ets_reco_valid,
225                   pLM->params.dcbx_config_params.admin_ets_reco_valid,
226                   B_FALSE);
227 
228     BnxeCfgGetVal(pUM, "dcbx_admin_app_priority_willing",
229                   &pLM->params.dcbx_config_params.admin_app_priority_willing,
230                   pLM->params.dcbx_config_params.admin_app_priority_willing,
231                   B_FALSE);
232 
233     for (i = 0; i < 8; i++)
234     {
235         snprintf(name, sizeof(name), "dcbx_admin_configuration_bw_percentage_%d", i);
236         BnxeCfgGetVal(pUM, name,
237                       &pLM->params.dcbx_config_params.admin_configuration_bw_percentage[i],
238                       pLM->params.dcbx_config_params.admin_configuration_bw_percentage[i],
239                       B_FALSE);
240     }
241 
242     for (i = 0; i < 8; i++)
243     {
244         snprintf(name, sizeof(name), "dcbx_admin_configuration_ets_pg_%d", i);
245         BnxeCfgGetVal(pUM, name,
246                       &pLM->params.dcbx_config_params.admin_configuration_ets_pg[i],
247                       pLM->params.dcbx_config_params.admin_configuration_ets_pg[i],
248                       B_FALSE);
249     }
250 
251     for (i = 0; i < 8; i++)
252     {
253         snprintf(name, sizeof(name), "dcbx_admin_recommendation_bw_percentage_%d", i);
254         BnxeCfgGetVal(pUM, name,
255                       &pLM->params.dcbx_config_params.admin_recommendation_bw_percentage[i],
256                       pLM->params.dcbx_config_params.admin_recommendation_bw_percentage[i],
257                       B_FALSE);
258     }
259 
260     for (i = 0; i < 8; i++)
261     {
262         snprintf(name, sizeof(name), "dcbx_admin_recommendation_ets_pg_%d", i);
263         BnxeCfgGetVal(pUM, name,
264                       &pLM->params.dcbx_config_params.admin_recommendation_ets_pg[i],
265                       pLM->params.dcbx_config_params.admin_recommendation_ets_pg[i],
266                       B_FALSE);
267     }
268 
269     BnxeCfgGetVal(pUM, "dcbx_admin_pfc_bitmap",
270                   &pLM->params.dcbx_config_params.admin_pfc_bitmap,
271                   pLM->params.dcbx_config_params.admin_pfc_bitmap,
272                   B_FALSE);
273 
274     for (i = 0; i < 4; i++)
275     {
276         snprintf(name, sizeof(name), "dcbx_admin_priority_app_table_%d_valid", i);
277         BnxeCfgGetVal(pUM, name,
278                       &pLM->params.dcbx_config_params.admin_priority_app_table[i].valid,
279                       pLM->params.dcbx_config_params.admin_priority_app_table[i].valid,
280                       B_FALSE);
281 
282         snprintf(name, sizeof(name), "dcbx_admin_priority_app_table_%d_priority", i);
283         BnxeCfgGetVal(pUM, name,
284                       &pLM->params.dcbx_config_params.admin_priority_app_table[i].priority,
285                       pLM->params.dcbx_config_params.admin_priority_app_table[i].priority,
286                       B_FALSE);
287 
288         snprintf(name, sizeof(name), "dcbx_admin_priority_app_table_%d_traffic_type", i);
289         BnxeCfgGetVal(pUM, name,
290                       &pLM->params.dcbx_config_params.admin_priority_app_table[i].traffic_type,
291                       pLM->params.dcbx_config_params.admin_priority_app_table[i].traffic_type,
292                       B_FALSE);
293 
294         snprintf(name, sizeof(name), "dcbx_admin_priority_app_table_%d_app_id", i);
295         BnxeCfgGetVal(pUM, name,
296                       &pLM->params.dcbx_config_params.admin_priority_app_table[i].app_id,
297                       pLM->params.dcbx_config_params.admin_priority_app_table[i].app_id,
298                       B_FALSE);
299     }
300 
301     BnxeCfgGetVal(pUM, "dcbx_admin_default_priority",
302                   &pLM->params.dcbx_config_params.admin_default_priority,
303                   pLM->params.dcbx_config_params.admin_default_priority,
304                   B_FALSE);
305 }
306 
307 
308 void BnxeCfgInit(um_device_t * pUM)
309 {
310     int option, i;
311 
312     /* set the defaults */
313     bcopy(&bnxeLinkCfg, &pUM->hwinit.lnkcfg, sizeof(BnxeLinkCfg));
314 
315     pUM->hwinit.flow_autoneg                  = B_TRUE;
316     pUM->devParams.checksum                   = USER_OPTION_CKSUM_DEFAULT;
317     pUM->devParams.enabled_oflds              = LM_OFFLOAD_NONE;
318     pUM->devParams.mtu[LM_CLI_IDX_NDIS]       = USER_OPTION_MTU_DEFAULT;
319     pUM->devParams.numRings                   = USER_OPTION_NUM_RINGS_DEFAULT;
320     pUM->devParams.numRxDesc[LM_CLI_IDX_NDIS] = USER_OPTION_RX_BDS_DEFAULT;
321     pUM->devParams.numTxDesc[LM_CLI_IDX_NDIS] = USER_OPTION_TX_BDS_DEFAULT;
322     pUM->devParams.maxRxFree                  = USER_OPTION_RX_MAX_FREE_DEFAULT;
323     pUM->devParams.maxTxFree                  = USER_OPTION_TX_MAX_FREE_DEFAULT;
324     pUM->devParams.rxCopyThreshold            = USER_OPTION_RX_DCOPY_THRESH_DEFAULT;
325     pUM->devParams.txCopyThreshold            = USER_OPTION_TX_DCOPY_THRESH_DEFAULT;
326     pUM->devParams.intrCoalesce               = B_TRUE;
327     pUM->devParams.intrRxPerSec               = USER_OPTION_INTR_COALESCE_RX_DEFAULT;
328     pUM->devParams.intrTxPerSec               = USER_OPTION_INTR_COALESCE_TX_DEFAULT;
329     pUM->devParams.disableMsix                = B_FALSE;
330     pUM->devParams.l2_fw_flow_ctrl            = B_FALSE;
331     pUM->devParams.autogreeenEnable           = B_TRUE;
332     pUM->devParams.lsoEnable                  = B_TRUE;
333     pUM->devParams.logEnable                  = B_TRUE;
334     pUM->devParams.routeTxRingPolicy          = BNXE_ROUTE_RING_TCPUDP;
335     pUM->devParams.fcoeEnable                 = B_FALSE;
336     pUM->devParams.linkRemoteFaultDetect      = B_TRUE;
337 
338     /* set the LLDP/DCBX defaults and get settings from bnxe.conf */
339     BnxeCfg_LLDP_DCBX(pUM);
340 
341     /* override the defaults based on what is set in bnxe.conf */
342 
343     BnxeCfgGetVal(pUM, "adv_autoneg_cap",
344                   &pUM->hwinit.lnkcfg.link_autoneg,
345                   pUM->hwinit.lnkcfg.link_autoneg,
346                   B_TRUE);
347 
348     BnxeCfgGetVal(pUM, "adv_20000fdx_cap",
349                   &pUM->hwinit.lnkcfg.param_20000fdx,
350                   pUM->hwinit.lnkcfg.param_20000fdx,
351                   B_TRUE);
352 
353     BnxeCfgGetVal(pUM, "adv_10000fdx_cap",
354                   &pUM->hwinit.lnkcfg.param_10000fdx,
355                   pUM->hwinit.lnkcfg.param_10000fdx,
356                   B_TRUE);
357 
358     BnxeCfgGetVal(pUM, "adv_2500fdx_cap",
359                   &pUM->hwinit.lnkcfg.param_2500fdx,
360                   pUM->hwinit.lnkcfg.param_2500fdx,
361                   B_TRUE);
362 
363     BnxeCfgGetVal(pUM, "adv_1000fdx_cap",
364                   &pUM->hwinit.lnkcfg.param_1000fdx,
365                   pUM->hwinit.lnkcfg.param_1000fdx,
366                   B_TRUE);
367 
368     BnxeCfgGetVal(pUM, "adv_100fdx_cap",
369                   &pUM->hwinit.lnkcfg.param_100fdx,
370                   pUM->hwinit.lnkcfg.param_100fdx,
371                   B_TRUE);
372 
373     BnxeCfgGetVal(pUM, "adv_100hdx_cap",
374                   &pUM->hwinit.lnkcfg.param_100hdx,
375                   pUM->hwinit.lnkcfg.param_100hdx,
376                   B_TRUE);
377 
378     BnxeCfgGetVal(pUM, "adv_10fdx_cap",
379                   &pUM->hwinit.lnkcfg.param_10fdx,
380                   pUM->hwinit.lnkcfg.param_10fdx,
381                   B_TRUE);
382 
383     BnxeCfgGetVal(pUM, "adv_10hdx_cap",
384                   &pUM->hwinit.lnkcfg.param_10hdx,
385                   pUM->hwinit.lnkcfg.param_10hdx,
386                   B_TRUE);
387 
388     BnxeCfgGetVal(pUM, "txpause_cap",
389                   &pUM->hwinit.lnkcfg.param_txpause,
390                   pUM->hwinit.lnkcfg.param_txpause,
391                   B_TRUE);
392 
393     BnxeCfgGetVal(pUM, "rxpause_cap",
394                   &pUM->hwinit.lnkcfg.param_rxpause,
395                   pUM->hwinit.lnkcfg.param_rxpause,
396                   B_TRUE);
397 
398     BnxeCfgGetVal(pUM, "autoneg_flow",
399                   &pUM->hwinit.flow_autoneg,
400                   pUM->hwinit.flow_autoneg,
401                   B_TRUE);
402 
403     BnxeCfgGetVal(pUM, "checksum",
404                   &pUM->devParams.checksum,
405                   pUM->devParams.checksum,
406                   B_FALSE);
407     switch (pUM->devParams.checksum)
408     {
409     case USER_OPTION_CKSUM_L3:
410         pUM->devParams.enabled_oflds = (LM_OFFLOAD_TX_IP_CKSUM |
411                                         LM_OFFLOAD_RX_IP_CKSUM);
412         break;
413 
414     case USER_OPTION_CKSUM_L3_L4:
415         pUM->devParams.enabled_oflds = (LM_OFFLOAD_TX_IP_CKSUM  |
416                                         LM_OFFLOAD_RX_IP_CKSUM  |
417                                         LM_OFFLOAD_TX_TCP_CKSUM |
418                                         LM_OFFLOAD_RX_TCP_CKSUM |
419                                         LM_OFFLOAD_TX_UDP_CKSUM |
420                                         LM_OFFLOAD_RX_UDP_CKSUM);
421         break;
422 
423     case USER_OPTION_CKSUM_NONE:
424     default:
425         pUM->devParams.enabled_oflds = LM_OFFLOAD_NONE;
426         break;
427     }
428 
429     BnxeCfgGetVal(pUM, "mtu",
430                   &option,
431                   pUM->devParams.mtu[LM_CLI_IDX_NDIS],
432                   B_FALSE);
433     pUM->devParams.mtu[LM_CLI_IDX_NDIS] =
434         (option < USER_OPTION_MTU_MIN) ?
435             USER_OPTION_MTU_MIN :
436             (option > USER_OPTION_MTU_MAX) ?
437                 USER_OPTION_MTU_MAX :
438                 option;
439     pUM->lm_dev.params.mtu[LM_CLI_IDX_NDIS] = pUM->devParams.mtu[LM_CLI_IDX_NDIS];
440 
441     pUM->devParams.mtu[LM_CLI_IDX_FCOE]     = LM_MTU_FCOE_DEFAULT;
442     pUM->lm_dev.params.mtu[LM_CLI_IDX_FCOE] = LM_MTU_FCOE_DEFAULT;
443 
444     pUM->lm_dev.params.mtu_max = (pUM->lm_dev.params.mtu[LM_CLI_IDX_NDIS] >
445                                   pUM->lm_dev.params.mtu[LM_CLI_IDX_FCOE]) ?
446                                      pUM->lm_dev.params.mtu[LM_CLI_IDX_NDIS] :
447                                      pUM->lm_dev.params.mtu[LM_CLI_IDX_FCOE];
448 
449     BnxeCfgGetVal(pUM, "route_tx_ring_policy",
450                   &pUM->devParams.routeTxRingPolicy,
451                   pUM->devParams.routeTxRingPolicy,
452                   B_FALSE);
453     if ((pUM->devParams.routeTxRingPolicy != BNXE_ROUTE_RING_NONE) &&
454         (pUM->devParams.routeTxRingPolicy != BNXE_ROUTE_RING_TCPUDP) &&
455         (pUM->devParams.routeTxRingPolicy != BNXE_ROUTE_RING_DEST_MAC) &&
456         (pUM->devParams.routeTxRingPolicy != BNXE_ROUTE_RING_MSG_PRIO))
457     {
458         pUM->devParams.routeTxRingPolicy = BNXE_ROUTE_RING_TCPUDP;
459     }
460 
461     BnxeCfgGetVal(pUM, "num_rings",
462                   &option,
463                   pUM->devParams.numRings,
464                   B_FALSE);
465     pUM->devParams.numRings = (option < USER_OPTION_NUM_RINGS_MIN) ?
466                                   USER_OPTION_NUM_RINGS_MIN :
467                                   (option > USER_OPTION_NUM_RINGS_MAX) ?
468                                       USER_OPTION_NUM_RINGS_MAX :
469                                       option;
470 
471     /* adjust for function mode defaults */
472     if (pUM->devParams.numRings == USER_OPTION_NUM_RINGS_DEFAULT)
473     {
474         pUM->devParams.numRings = (IS_MULTI_VNIC(&pUM->lm_dev)) ?
475                                       USER_OPTION_NUM_RINGS_DEFAULT_MF :
476                                       USER_OPTION_NUM_RINGS_DEFAULT_SF;
477     }
478 
479     /* numRings must be a power of two and <= max rss chains allowed */
480     for (i = 1; pUM->devParams.numRings >> i; i++) { ; }
481     pUM->devParams.numRings = (1 << (i - 1));
482     if (pUM->devParams.numRings > LM_MAX_RSS_CHAINS(&pUM->lm_dev))
483     {
484         pUM->devParams.numRings = LM_MAX_RSS_CHAINS(&pUM->lm_dev);
485     }
486 
487     BnxeCfgGetVal(pUM, "rx_descs",
488                   &option,
489                   pUM->devParams.numRxDesc[LM_CLI_IDX_NDIS],
490                   B_FALSE);
491     pUM->devParams.numRxDesc[LM_CLI_IDX_NDIS] =
492         (option < USER_OPTION_BDS_MIN) ?
493             USER_OPTION_BDS_MIN :
494             (option > USER_OPTION_BDS_MAX) ?
495                 USER_OPTION_BDS_MAX :
496                 option;
497 
498     BnxeCfgGetVal(pUM, "tx_descs",
499                   &option,
500                   pUM->devParams.numTxDesc[LM_CLI_IDX_NDIS],
501                   B_FALSE);
502     pUM->devParams.numTxDesc[LM_CLI_IDX_NDIS] =
503         (option < USER_OPTION_BDS_MIN) ?
504             USER_OPTION_BDS_MIN :
505             (option > USER_OPTION_BDS_MAX) ?
506                 USER_OPTION_BDS_MAX :
507                 option;
508 
509     BnxeCfgGetVal(pUM, "rx_free_reclaim",
510                   &option,
511                   pUM->devParams.maxRxFree,
512                   B_FALSE);
513     pUM->devParams.maxRxFree =
514         (option < 0) ?
515             0 :
516             (option > pUM->devParams.numRxDesc[LM_CLI_IDX_NDIS]) ?
517                 pUM->devParams.numRxDesc[LM_CLI_IDX_NDIS] :
518                 option;
519 
520     BnxeCfgGetVal(pUM, "tx_free_reclaim",
521                   &option,
522                   pUM->devParams.maxTxFree,
523                   B_FALSE);
524     pUM->devParams.maxTxFree =
525         (option < 0) ?
526             0 :
527             (option > pUM->devParams.numTxDesc[LM_CLI_IDX_NDIS]) ?
528                 pUM->devParams.numTxDesc[LM_CLI_IDX_NDIS] :
529                 option;
530 
531     /* threshold to enable double copy of receive packet */
532     BnxeCfgGetVal(pUM, "rx_copy_threshold",
533                   &pUM->devParams.rxCopyThreshold,
534                   pUM->devParams.rxCopyThreshold,
535                   B_FALSE);
536 
537     /* threshold to enable double copy of transmit packet */
538     BnxeCfgGetVal(pUM, "tx_copy_threshold",
539                   &pUM->devParams.txCopyThreshold,
540                   pUM->devParams.txCopyThreshold,
541                   B_FALSE);
542 
543     BnxeCfgGetVal(pUM, "interrupt_coalesce",
544                   &pUM->devParams.intrCoalesce,
545                   pUM->devParams.intrCoalesce,
546                   B_TRUE);
547 
548     BnxeCfgGetVal(pUM, "rx_interrupt_coalesce_usec",
549                   &option,
550                   pUM->devParams.intrRxPerSec,
551                   B_FALSE);
552     option = (option < USER_OPTION_INTR_COALESCE_MIN) ?
553                   USER_OPTION_INTR_COALESCE_MIN :
554                   (option > USER_OPTION_INTR_COALESCE_MAX) ?
555                       USER_OPTION_INTR_COALESCE_MAX :
556                       option;
557     pUM->devParams.intrRxPerSec = (1000000 / option); /* intrs per sec */
558 
559     BnxeCfgGetVal(pUM, "tx_interrupt_coalesce_usec",
560                   &option,
561                   pUM->devParams.intrTxPerSec,
562                   B_FALSE);
563     option = (option < USER_OPTION_INTR_COALESCE_MIN) ?
564                  USER_OPTION_INTR_COALESCE_MIN :
565                  (option > USER_OPTION_INTR_COALESCE_MAX) ?
566                      USER_OPTION_INTR_COALESCE_MAX :
567                      option;
568     pUM->devParams.intrTxPerSec = (1000000 / option); /* intrs per sec */
569 
570     BnxeCfgGetVal(pUM, "disable_msix",
571                   &pUM->devParams.disableMsix,
572                   pUM->devParams.disableMsix,
573                   B_TRUE);
574 
575     BnxeCfgGetVal(pUM, "l2_fw_flow_ctrl",
576                   &pUM->devParams.l2_fw_flow_ctrl,
577                   pUM->devParams.l2_fw_flow_ctrl,
578                   B_TRUE);
579 
580     BnxeCfgGetVal(pUM, "autogreeen_enable",
581                   &pUM->devParams.autogreeenEnable,
582                   pUM->devParams.autogreeenEnable,
583                   B_TRUE);
584     pUM->lm_dev.params.autogreeen =
585         (pUM->devParams.autogreeenEnable) ?
586             LM_AUTOGREEEN_NVRAM /* maybe enabled or disabled */ :
587             LM_AUTOGREEEN_DISABLED;
588 
589     BnxeCfgGetVal(pUM, "lso_enable",
590                   &pUM->devParams.lsoEnable,
591                   pUM->devParams.lsoEnable,
592                   B_TRUE);
593 
594     /* Only allow LSO if Tx TCP checksum is turned on. */
595     if (!(pUM->devParams.enabled_oflds & LM_OFFLOAD_TX_TCP_CKSUM))
596     {
597         pUM->devParams.lsoEnable = B_FALSE;
598     }
599 
600     BnxeCfgGetVal(pUM, "log_enable",
601                   &pUM->devParams.logEnable,
602                   pUM->devParams.logEnable,
603                   B_TRUE);
604 
605     BnxeCfgGetVal(pUM, "fcoe_enable",
606                   &pUM->devParams.fcoeEnable,
607                   pUM->devParams.fcoeEnable,
608                   B_TRUE);
609 
610     BnxeCfgGetVal(pUM, "link_remote_fault_detect",
611                   &pUM->devParams.linkRemoteFaultDetect,
612                   pUM->devParams.linkRemoteFaultDetect,
613                   B_TRUE);
614 
615     if (!pUM->devParams.linkRemoteFaultDetect)
616     {
617         SET_FLAGS(pUM->lm_dev.params.link.feature_config_flags,
618                   ELINK_FEATURE_CONFIG_DISABLE_REMOTE_FAULT_DET);
619     }
620 
621     BnxeCfgGetVal(pUM, "debug_level",
622                   &option,
623                   pUM->devParams.debug_level,
624                   B_FALSE);
625     pUM->devParams.debug_level =
626         (option < 0) ?
627             0 :
628             ((uint32_t)option > (CP_ALL | LV_MASK)) ?
629                 (CP_ALL | LV_MASK) :
630                 (uint32_t)option;
631 
632     /* Adjust the number of rx/tx descriptors if in multi-function mode. */
633 
634     if (IS_MULTI_VNIC(&pUM->lm_dev))
635     {
636         if (!(pUM->devParams.numRxDesc[LM_CLI_IDX_NDIS] /=
637               USER_OPTION_MF_BDS_DIVISOR))
638         {
639             pUM->devParams.numRxDesc[LM_CLI_IDX_NDIS] = USER_OPTION_BDS_MIN;
640         }
641 
642         if (!(pUM->devParams.numTxDesc[LM_CLI_IDX_NDIS] /=
643               USER_OPTION_MF_BDS_DIVISOR))
644         {
645             pUM->devParams.numTxDesc[LM_CLI_IDX_NDIS] = USER_OPTION_BDS_MIN;
646         }
647     }
648 }
649 
650 
651 void BnxeCfgReset(um_device_t * pUM)
652 {
653     /* reset the link status */
654     pUM->props.link_speed   = 0;
655     pUM->props.link_duplex  = B_FALSE;
656     pUM->props.link_txpause = B_FALSE;
657     pUM->props.link_rxpause = B_FALSE;
658 
659     /* reset the link partner status */
660     pUM->remote.link_autoneg   = B_FALSE;
661     pUM->remote.param_20000fdx = B_FALSE;
662     pUM->remote.param_10000fdx = B_FALSE;
663     pUM->remote.param_2500fdx  = B_FALSE;
664     pUM->remote.param_1000fdx  = B_FALSE;
665     pUM->remote.param_100fdx   = B_FALSE;
666     pUM->remote.param_100hdx   = B_FALSE;
667     pUM->remote.param_10fdx    = B_FALSE;
668     pUM->remote.param_10hdx    = B_FALSE;
669     pUM->remote.param_txpause  = B_FALSE;
670     pUM->remote.param_rxpause  = B_FALSE;
671 
672     /* reset the configuration from the configured hardware default */
673     bcopy(&pUM->hwinit, &pUM->curcfg, sizeof(BnxePhyCfg));
674 }
675 
676