blob: 71d68b56c25c635fadce30812421f4e9f13831bf [file] [log] [blame]
girish44961712006-11-22 11:47:19 -08001/*
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/*
Santwona Behera7b26d9f2009-01-30 11:54:57 -080022 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
girish44961712006-11-22 11:47:19 -080023 * Use is subject to license terms.
24 */
25
girish44961712006-11-22 11:47:19 -080026#include <sys/nxge/nxge_impl.h>
speer678453a2008-04-27 19:50:44 -070027#include <sys/nxge/nxge_hio.h>
28
girish44961712006-11-22 11:47:19 -080029#include <inet/common.h>
30#include <inet/mi.h>
31#include <inet/nd.h>
32
33extern uint64_t npi_debug_level;
34
speera3c5bd62007-01-30 11:29:19 -080035#define NXGE_PARAM_MAC_RW \
36 NXGE_PARAM_RW | NXGE_PARAM_MAC | \
girish44961712006-11-22 11:47:19 -080037 NXGE_PARAM_NDD_WR_OK | NXGE_PARAM_READ_PROP
38
speera3c5bd62007-01-30 11:29:19 -080039#define NXGE_PARAM_MAC_DONT_SHOW \
40 NXGE_PARAM_RW | NXGE_PARAM_MAC | NXGE_PARAM_DONT_SHOW
girish44961712006-11-22 11:47:19 -080041
speera3c5bd62007-01-30 11:29:19 -080042#define NXGE_PARAM_RXDMA_RW \
43 NXGE_PARAM_RWP | NXGE_PARAM_RXDMA | NXGE_PARAM_NDD_WR_OK | \
girish44961712006-11-22 11:47:19 -080044 NXGE_PARAM_READ_PROP
45
speera3c5bd62007-01-30 11:29:19 -080046#define NXGE_PARAM_RXDMA_RWC \
47 NXGE_PARAM_RWP | NXGE_PARAM_RXDMA | NXGE_PARAM_INIT_ONLY | \
48 NXGE_PARAM_READ_PROP
49
50#define NXGE_PARAM_L2CLASS_CFG \
51 NXGE_PARAM_RW | NXGE_PARAM_PROP_ARR32 | NXGE_PARAM_READ_PROP | \
52 NXGE_PARAM_NDD_WR_OK
53
54#define NXGE_PARAM_CLASS_RWS \
55 NXGE_PARAM_RWS | NXGE_PARAM_READ_PROP
56
girish44961712006-11-22 11:47:19 -080057#define NXGE_PARAM_ARRAY_INIT_SIZE 0x20ULL
58
59#define SET_RX_INTR_TIME_DISABLE 0
60#define SET_RX_INTR_TIME_ENABLE 1
61#define SET_RX_INTR_PKTS 2
62
63#define BASE_ANY 0
speera3c5bd62007-01-30 11:29:19 -080064#define BASE_BINARY 2
girish44961712006-11-22 11:47:19 -080065#define BASE_HEX 16
66#define BASE_DECIMAL 10
67#define ALL_FF_64 0xFFFFFFFFFFFFFFFFULL
68#define ALL_FF_32 0xFFFFFFFFUL
69
70#define NXGE_NDD_INFODUMP_BUFF_SIZE 2048 /* is 2k enough? */
girish44961712006-11-22 11:47:19 -080071#define NXGE_NDD_INFODUMP_BUFF_8K 8192
72#define NXGE_NDD_INFODUMP_BUFF_16K 0x2000
73#define NXGE_NDD_INFODUMP_BUFF_64K 0x8000
74
75#define PARAM_OUTOF_RANGE(vptr, eptr, rval, pa) \
76 ((vptr == eptr) || (rval < pa->minimum) || (rval > pa->maximum))
77
78#define ADVANCE_PRINT_BUFFER(pmp, plen, rlen) { \
79 ((mblk_t *)pmp)->b_wptr += plen; \
80 rlen -= plen; \
speera3c5bd62007-01-30 11:29:19 -080081}
girish44961712006-11-22 11:47:19 -080082
sowmini4045d942008-04-29 11:20:32 -070083int nxge_param_set_mac(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -080084 mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -080085static int nxge_param_set_port_rdc(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -080086 mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -080087static int nxge_param_set_grp_rdc(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -080088 mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -080089static int nxge_param_set_ether_usr(p_nxge_t,
speera3c5bd62007-01-30 11:29:19 -080090 queue_t *, mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -080091static int nxge_param_set_ip_usr(p_nxge_t,
speera3c5bd62007-01-30 11:29:19 -080092 queue_t *, mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -080093static int nxge_param_set_vlan_rdcgrp(p_nxge_t,
speera3c5bd62007-01-30 11:29:19 -080094 queue_t *, mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -080095static int nxge_param_set_mac_rdcgrp(p_nxge_t,
speera3c5bd62007-01-30 11:29:19 -080096 queue_t *, mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -080097static int nxge_param_fflp_hash_init(p_nxge_t,
speera3c5bd62007-01-30 11:29:19 -080098 queue_t *, mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -080099static int nxge_param_llc_snap_enable(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -0800100 mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -0800101static int nxge_param_hash_lookup_enable(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -0800102 mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -0800103static int nxge_param_tcam_enable(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -0800104 mblk_t *, char *, caddr_t);
speer56d930a2007-05-08 14:19:59 -0700105static int nxge_param_get_fw_ver(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
raghus2e591292007-08-31 16:49:49 -0700106static int nxge_param_get_port_mode(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800107static int nxge_param_get_rxdma_info(p_nxge_t, queue_t *q,
speera3c5bd62007-01-30 11:29:19 -0800108 p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800109static int nxge_param_get_txdma_info(p_nxge_t, queue_t *q,
speera3c5bd62007-01-30 11:29:19 -0800110 p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800111static int nxge_param_get_vlan_rdcgrp(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -0800112 p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800113static int nxge_param_get_mac_rdcgrp(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -0800114 p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800115static int nxge_param_get_rxdma_rdcgrp_info(p_nxge_t, queue_t *,
speera3c5bd62007-01-30 11:29:19 -0800116 p_mblk_t, caddr_t);
Santwona Beherac1f9c6e2009-03-10 11:26:53 -0700117static int nxge_param_get_rx_intr_time(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
118static int nxge_param_get_rx_intr_pkts(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800119static int nxge_param_get_ip_opt(p_nxge_t, queue_t *, mblk_t *, caddr_t);
speera3c5bd62007-01-30 11:29:19 -0800120static int nxge_param_get_mac(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800121static int nxge_param_get_debug_flag(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800122static int nxge_param_set_nxge_debug_flag(p_nxge_t, queue_t *, mblk_t *,
speera3c5bd62007-01-30 11:29:19 -0800123 char *, caddr_t);
girish44961712006-11-22 11:47:19 -0800124static int nxge_param_set_npi_debug_flag(p_nxge_t,
speera3c5bd62007-01-30 11:29:19 -0800125 queue_t *, mblk_t *, char *, caddr_t);
girish44961712006-11-22 11:47:19 -0800126static int nxge_param_dump_rdc(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800127static int nxge_param_dump_tdc(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800128static int nxge_param_dump_mac_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800129static int nxge_param_dump_ipp_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800130static int nxge_param_dump_fflp_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800131static int nxge_param_dump_vlan_table(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800132static int nxge_param_dump_rdc_table(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
girish44961712006-11-22 11:47:19 -0800133static int nxge_param_dump_ptrs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
ml296231bd68252008-04-14 17:03:10 -0700134static void nxge_param_sync(p_nxge_t);
girish44961712006-11-22 11:47:19 -0800135
136/*
137 * Global array of Neptune changable parameters.
138 * This array is initialized to correspond to the default
139 * Neptune 4 port configuration. This array would be copied
140 * into each port's parameter structure and modifed per
141 * fcode and nxge.conf configuration. Later, the parameters are
142 * exported to ndd to display and run-time configuration (at least
143 * some of them).
144 *
yc14809700161852008-06-09 20:15:04 -0700145 * Parameters with DONT_SHOW are not shown by ndd.
146 *
girish44961712006-11-22 11:47:19 -0800147 */
148
speera3c5bd62007-01-30 11:29:19 -0800149static nxge_param_t nxge_param_arr[] = {
150 /*
151 * min max value old hw-name conf-name
152 */
ml29623846a9032007-06-11 17:24:13 -0700153 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800154 0, 999, 1000, 0, "instance", "instance"},
girish44961712006-11-22 11:47:19 -0800155
ml29623846a9032007-06-11 17:24:13 -0700156 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800157 0, 999, 1000, 0, "main-instance", "main_instance"},
girish44961712006-11-22 11:47:19 -0800158
speera3c5bd62007-01-30 11:29:19 -0800159 { nxge_param_get_generic, NULL, NXGE_PARAM_READ,
160 0, 3, 0, 0, "function-number", "function_number"},
girish44961712006-11-22 11:47:19 -0800161
speera3c5bd62007-01-30 11:29:19 -0800162 /* Partition Id */
ml29623846a9032007-06-11 17:24:13 -0700163 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800164 0, 8, 0, 0, "partition-id", "partition_id"},
girish44961712006-11-22 11:47:19 -0800165
speera3c5bd62007-01-30 11:29:19 -0800166 /* Read Write Permission Mode */
ml29623846a9032007-06-11 17:24:13 -0700167 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800168 0, 2, 0, 0, "read-write-mode", "read_write_mode"},
girish44961712006-11-22 11:47:19 -0800169
speer56d930a2007-05-08 14:19:59 -0700170 { nxge_param_get_fw_ver, NULL, NXGE_PARAM_READ,
171 0, 32, 0, 0, "version", "fw_version"},
172
raghus2e591292007-08-31 16:49:49 -0700173 { nxge_param_get_port_mode, NULL, NXGE_PARAM_READ,
174 0, 32, 0, 0, "port-mode", "port_mode"},
175
speera3c5bd62007-01-30 11:29:19 -0800176 /* hw cfg types */
177 /* control the DMA config of Neptune/NIU */
ml29623846a9032007-06-11 17:24:13 -0700178 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800179 CFG_DEFAULT, CFG_CUSTOM, CFG_DEFAULT, CFG_DEFAULT,
180 "niu-cfg-type", "niu_cfg_type"},
girish44961712006-11-22 11:47:19 -0800181
speera3c5bd62007-01-30 11:29:19 -0800182 /* control the TXDMA config of the Port controlled by tx-quick-cfg */
ml29623846a9032007-06-11 17:24:13 -0700183 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800184 CFG_DEFAULT, CFG_CUSTOM, CFG_NOT_SPECIFIED, CFG_DEFAULT,
185 "tx-qcfg-type", "tx_qcfg_type"},
girish44961712006-11-22 11:47:19 -0800186
speera3c5bd62007-01-30 11:29:19 -0800187 /* control the RXDMA config of the Port controlled by rx-quick-cfg */
ml29623846a9032007-06-11 17:24:13 -0700188 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800189 CFG_DEFAULT, CFG_CUSTOM, CFG_NOT_SPECIFIED, CFG_DEFAULT,
190 "rx-qcfg-type", "rx_qcfg_type"},
girish44961712006-11-22 11:47:19 -0800191
speera3c5bd62007-01-30 11:29:19 -0800192 { nxge_param_get_mac, nxge_param_set_mac,
193 NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW,
194 0, 1, 0, 0, "master-cfg-enable", "master_cfg_enable"},
girish44961712006-11-22 11:47:19 -0800195
speera3c5bd62007-01-30 11:29:19 -0800196 { nxge_param_get_mac, nxge_param_set_mac,
ml29623846a9032007-06-11 17:24:13 -0700197 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800198 0, 1, 0, 0, "master-cfg-value", "master_cfg_value"},
girish44961712006-11-22 11:47:19 -0800199
speera3c5bd62007-01-30 11:29:19 -0800200 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
201 0, 1, 1, 1, "adv-autoneg-cap", "adv_autoneg_cap"},
girish44961712006-11-22 11:47:19 -0800202
speera3c5bd62007-01-30 11:29:19 -0800203 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
204 0, 1, 1, 1, "adv-10gfdx-cap", "adv_10gfdx_cap"},
girish44961712006-11-22 11:47:19 -0800205
speera3c5bd62007-01-30 11:29:19 -0800206 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
207 0, 1, 0, 0, "adv-10ghdx-cap", "adv_10ghdx_cap"},
girish44961712006-11-22 11:47:19 -0800208
speera3c5bd62007-01-30 11:29:19 -0800209 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
210 0, 1, 1, 1, "adv-1000fdx-cap", "adv_1000fdx_cap"},
girish44961712006-11-22 11:47:19 -0800211
speera3c5bd62007-01-30 11:29:19 -0800212 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
213 0, 1, 0, 0, "adv-1000hdx-cap", "adv_1000hdx_cap"},
girish44961712006-11-22 11:47:19 -0800214
speera3c5bd62007-01-30 11:29:19 -0800215 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
216 0, 1, 0, 0, "adv-100T4-cap", "adv_100T4_cap"},
girish44961712006-11-22 11:47:19 -0800217
speera3c5bd62007-01-30 11:29:19 -0800218 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
219 0, 1, 1, 1, "adv-100fdx-cap", "adv_100fdx_cap"},
girish44961712006-11-22 11:47:19 -0800220
speera3c5bd62007-01-30 11:29:19 -0800221 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
222 0, 1, 0, 0, "adv-100hdx-cap", "adv_100hdx_cap"},
girish44961712006-11-22 11:47:19 -0800223
speera3c5bd62007-01-30 11:29:19 -0800224 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
225 0, 1, 1, 1, "adv-10fdx-cap", "adv_10fdx_cap"},
girish44961712006-11-22 11:47:19 -0800226
speera3c5bd62007-01-30 11:29:19 -0800227 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
228 0, 1, 0, 0, "adv-10hdx-cap", "adv_10hdx_cap"},
girish44961712006-11-22 11:47:19 -0800229
ml29623846a9032007-06-11 17:24:13 -0700230 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800231 0, 1, 0, 0, "adv-asmpause-cap", "adv_asmpause_cap"},
girish44961712006-11-22 11:47:19 -0800232
speera3c5bd62007-01-30 11:29:19 -0800233 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
234 0, 1, 0, 0, "adv-pause-cap", "adv_pause_cap"},
girish44961712006-11-22 11:47:19 -0800235
ml29623846a9032007-06-11 17:24:13 -0700236 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800237 0, 1, 0, 0, "use-int-xcvr", "use_int_xcvr"},
girish44961712006-11-22 11:47:19 -0800238
ml29623846a9032007-06-11 17:24:13 -0700239 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800240 0, 1, 1, 1, "enable-ipg0", "enable_ipg0"},
girish44961712006-11-22 11:47:19 -0800241
ml29623846a9032007-06-11 17:24:13 -0700242 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800243 0, 255, 8, 8, "ipg0", "ipg0"},
girish44961712006-11-22 11:47:19 -0800244
ml29623846a9032007-06-11 17:24:13 -0700245 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800246 0, 255, 8, 8, "ipg1", "ipg1"},
girish44961712006-11-22 11:47:19 -0800247
ml29623846a9032007-06-11 17:24:13 -0700248 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800249 0, 255, 4, 4, "ipg2", "ipg2"},
girish44961712006-11-22 11:47:19 -0800250
speera3c5bd62007-01-30 11:29:19 -0800251 /* Transmit DMA channels */
ml29623846a9032007-06-11 17:24:13 -0700252 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
253 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800254 0, 3, 0, 0, "tx-dma-weight", "tx_dma_weight"},
girish44961712006-11-22 11:47:19 -0800255
ml29623846a9032007-06-11 17:24:13 -0700256 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
257 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800258 0, 31, 0, 0, "tx-dma-channels-begin", "tx_dma_channels_begin"},
girish44961712006-11-22 11:47:19 -0800259
ml29623846a9032007-06-11 17:24:13 -0700260 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
261 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800262 0, 32, 0, 0, "tx-dma-channels", "tx_dma_channels"},
263 { nxge_param_get_txdma_info, NULL,
ml29623846a9032007-06-11 17:24:13 -0700264 NXGE_PARAM_READ | NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800265 0, 32, 0, 0, "tx-dma-info", "tx_dma_info"},
girish44961712006-11-22 11:47:19 -0800266
speera3c5bd62007-01-30 11:29:19 -0800267 /* Receive DMA channels */
268 { nxge_param_get_generic, NULL,
ml29623846a9032007-06-11 17:24:13 -0700269 NXGE_PARAM_READ | NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800270 0, 31, 0, 0, "rx-dma-channels-begin", "rx_dma_channels_begin"},
girish44961712006-11-22 11:47:19 -0800271
ml29623846a9032007-06-11 17:24:13 -0700272 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
273 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800274 0, 32, 0, 0, "rx-dma-channels", "rx_dma_channels"},
girish44961712006-11-22 11:47:19 -0800275
ml29623846a9032007-06-11 17:24:13 -0700276 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
277 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800278 0, 65535, PT_DRR_WT_DEFAULT_10G, 0,
279 "rx-drr-weight", "rx_drr_weight"},
girish44961712006-11-22 11:47:19 -0800280
ml29623846a9032007-06-11 17:24:13 -0700281 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
282 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800283 0, 1, 1, 0, "rx-full-header", "rx_full_header"},
girish44961712006-11-22 11:47:19 -0800284
ml29623846a9032007-06-11 17:24:13 -0700285 { nxge_param_get_rxdma_info, NULL, NXGE_PARAM_READ |
286 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800287 0, 32, 0, 0, "rx-dma-info", "rx_dma_info"},
girish44961712006-11-22 11:47:19 -0800288
speera3c5bd62007-01-30 11:29:19 -0800289 { nxge_param_get_rxdma_info, NULL,
290 NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
291 NXGE_RBR_RBB_MIN, NXGE_RBR_RBB_MAX, NXGE_RBR_RBB_DEFAULT, 0,
292 "rx-rbr-size", "rx_rbr_size"},
girish44961712006-11-22 11:47:19 -0800293
speera3c5bd62007-01-30 11:29:19 -0800294 { nxge_param_get_rxdma_info, NULL,
295 NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
296 NXGE_RCR_MIN, NXGE_RCR_MAX, NXGE_RCR_DEFAULT, 0,
297 "rx-rcr-size", "rx_rcr_size"},
girish44961712006-11-22 11:47:19 -0800298
ml29623846a9032007-06-11 17:24:13 -0700299 { nxge_param_get_generic, nxge_param_set_port_rdc,
300 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800301 0, 15, 0, 0, "default-port-rdc", "default_port_rdc"},
302
Santwona Beherac1f9c6e2009-03-10 11:26:53 -0700303 { nxge_param_get_rx_intr_time, nxge_param_rx_intr_time,
304 NXGE_PARAM_RXDMA_RW,
speera3c5bd62007-01-30 11:29:19 -0800305 NXGE_RDC_RCR_TIMEOUT_MIN, NXGE_RDC_RCR_TIMEOUT_MAX,
Santwona Behera7b26d9f2009-01-30 11:54:57 -0800306 NXGE_RDC_RCR_TIMEOUT, 0, "rxdma-intr-time", "rxdma_intr_time"},
speera3c5bd62007-01-30 11:29:19 -0800307
Santwona Beherac1f9c6e2009-03-10 11:26:53 -0700308 { nxge_param_get_rx_intr_pkts, nxge_param_rx_intr_pkts,
309 NXGE_PARAM_RXDMA_RW,
speera3c5bd62007-01-30 11:29:19 -0800310 NXGE_RDC_RCR_THRESHOLD_MIN, NXGE_RDC_RCR_THRESHOLD_MAX,
Santwona Behera7b26d9f2009-01-30 11:54:57 -0800311 NXGE_RDC_RCR_THRESHOLD, 0,
speera3c5bd62007-01-30 11:29:19 -0800312 "rxdma-intr-pkts", "rxdma_intr_pkts"},
313
ml29623846a9032007-06-11 17:24:13 -0700314 { nxge_param_get_generic, NULL, NXGE_PARAM_READ_PROP |
315 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800316 0, 8, 0, 0, "rx-rdc-grps-begin", "rx_rdc_grps_begin"},
317
ml29623846a9032007-06-11 17:24:13 -0700318 { nxge_param_get_generic, NULL, NXGE_PARAM_READ_PROP |
319 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800320 0, 8, 0, 0, "rx-rdc-grps", "rx_rdc_grps"},
321
ml29623846a9032007-06-11 17:24:13 -0700322 { nxge_param_get_generic, nxge_param_set_grp_rdc,
323 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800324 0, 15, 0, 0, "default-grp0-rdc", "default_grp0_rdc"},
325
ml29623846a9032007-06-11 17:24:13 -0700326 { nxge_param_get_generic, nxge_param_set_grp_rdc,
327 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800328 0, 15, 2, 0, "default-grp1-rdc", "default_grp1_rdc"},
329
ml29623846a9032007-06-11 17:24:13 -0700330 { nxge_param_get_generic, nxge_param_set_grp_rdc,
331 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800332 0, 15, 4, 0, "default-grp2-rdc", "default_grp2_rdc"},
333
ml29623846a9032007-06-11 17:24:13 -0700334 { nxge_param_get_generic, nxge_param_set_grp_rdc,
335 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800336 0, 15, 6, 0, "default-grp3-rdc", "default_grp3_rdc"},
337
ml29623846a9032007-06-11 17:24:13 -0700338 { nxge_param_get_generic, nxge_param_set_grp_rdc,
339 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800340 0, 15, 8, 0, "default-grp4-rdc", "default_grp4_rdc"},
341
ml29623846a9032007-06-11 17:24:13 -0700342 { nxge_param_get_generic, nxge_param_set_grp_rdc,
343 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800344 0, 15, 10, 0, "default-grp5-rdc", "default_grp5_rdc"},
345
ml29623846a9032007-06-11 17:24:13 -0700346 { nxge_param_get_generic, nxge_param_set_grp_rdc,
347 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800348 0, 15, 12, 0, "default-grp6-rdc", "default_grp6_rdc"},
349
ml29623846a9032007-06-11 17:24:13 -0700350 { nxge_param_get_generic, nxge_param_set_grp_rdc,
351 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800352 0, 15, 14, 0, "default-grp7-rdc", "default_grp7_rdc"},
353
354 { nxge_param_get_rxdma_rdcgrp_info, NULL,
ml29623846a9032007-06-11 17:24:13 -0700355 NXGE_PARAM_READ | NXGE_PARAM_CMPLX | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800356 0, 8, 0, 0, "rdc-groups-info", "rdc_groups_info"},
357
358 /* Logical device groups */
ml29623846a9032007-06-11 17:24:13 -0700359 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800360 0, 63, 0, 0, "start-ldg", "start_ldg"},
361
ml29623846a9032007-06-11 17:24:13 -0700362 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800363 0, 64, 0, 0, "max-ldg", "max_ldg" },
364
365 /* MAC table information */
366 { nxge_param_get_mac_rdcgrp, nxge_param_set_mac_rdcgrp,
ml29623846a9032007-06-11 17:24:13 -0700367 NXGE_PARAM_L2CLASS_CFG | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800368 0, 31, 0, 0, "mac-2rdc-grp", "mac_2rdc_grp"},
369
370 /* VLAN table information */
371 { nxge_param_get_vlan_rdcgrp, nxge_param_set_vlan_rdcgrp,
ml29623846a9032007-06-11 17:24:13 -0700372 NXGE_PARAM_L2CLASS_CFG | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800373 0, 31, 0, 0, "vlan-2rdc-grp", "vlan_2rdc_grp"},
374
375 { nxge_param_get_generic, NULL,
ml29623846a9032007-06-11 17:24:13 -0700376 NXGE_PARAM_READ_PROP | NXGE_PARAM_READ |
377 NXGE_PARAM_PROP_ARR32 | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800378 0, 0x0ffff, 0x0ffff, 0, "fcram-part-cfg", "fcram_part_cfg"},
379
ml29623846a9032007-06-11 17:24:13 -0700380 { nxge_param_get_generic, NULL, NXGE_PARAM_CLASS_RWS |
381 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800382 0, 0x10, 0xa, 0, "fcram-access-ratio", "fcram_access_ratio"},
383
ml29623846a9032007-06-11 17:24:13 -0700384 { nxge_param_get_generic, NULL, NXGE_PARAM_CLASS_RWS |
385 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800386 0, 0x10, 0xa, 0, "tcam-access-ratio", "tcam_access_ratio"},
387
388 { nxge_param_get_generic, nxge_param_tcam_enable,
ml29623846a9032007-06-11 17:24:13 -0700389 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800390 0, 0x1, 0x0, 0, "tcam-enable", "tcam_enable"},
391
392 { nxge_param_get_generic, nxge_param_hash_lookup_enable,
ml29623846a9032007-06-11 17:24:13 -0700393 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800394 0, 0x01, 0x0, 0, "hash-lookup-enable", "hash_lookup_enable"},
395
396 { nxge_param_get_generic, nxge_param_llc_snap_enable,
ml29623846a9032007-06-11 17:24:13 -0700397 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800398 0, 0x01, 0x01, 0, "llc-snap-enable", "llc_snap_enable"},
399
400 { nxge_param_get_generic, nxge_param_fflp_hash_init,
ml29623846a9032007-06-11 17:24:13 -0700401 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800402 0, ALL_FF_32, ALL_FF_32, 0, "h1-init-value", "h1_init_value"},
403
404 { nxge_param_get_generic, nxge_param_fflp_hash_init,
ml29623846a9032007-06-11 17:24:13 -0700405 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800406 0, 0x0ffff, 0x0ffff, 0, "h2-init-value", "h2_init_value"},
407
408 { nxge_param_get_generic, nxge_param_set_ether_usr,
409 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
410 0, ALL_FF_32, 0x0, 0,
411 "class-cfg-ether-usr1", "class_cfg_ether_usr1"},
412
413 { nxge_param_get_generic, nxge_param_set_ether_usr,
414 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
415 0, ALL_FF_32, 0x0, 0,
416 "class-cfg-ether-usr2", "class_cfg_ether_usr2"},
417
418 { nxge_param_get_generic, nxge_param_set_ip_usr,
419 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
420 0, ALL_FF_32, 0x0, 0,
421 "class-cfg-ip-usr4", "class_cfg_ip_usr4"},
422
423 { nxge_param_get_generic, nxge_param_set_ip_usr,
424 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
425 0, ALL_FF_32, 0x0, 0,
426 "class-cfg-ip-usr5", "class_cfg_ip_usr5"},
427
428 { nxge_param_get_generic, nxge_param_set_ip_usr,
429 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
430 0, ALL_FF_32, 0x0, 0,
431 "class-cfg-ip-usr6", "class_cfg_ip_usr6"},
432
433 { nxge_param_get_generic, nxge_param_set_ip_usr,
434 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
435 0, ALL_FF_32, 0x0, 0,
436 "class-cfg-ip-usr7", "class_cfg_ip_usr7"},
437
438 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
439 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
440 0, ALL_FF_32, 0x0, 0,
441 "class-opt-ip-usr4", "class_opt_ip_usr4"},
442
443 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
444 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
445 0, ALL_FF_32, 0x0, 0,
446 "class-opt-ip-usr5", "class_opt_ip_usr5"},
447
448 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
449 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
450 0, ALL_FF_32, 0x0, 0,
451 "class-opt-ip-usr6", "class_opt_ip_usr6"},
452
453 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
454 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
455 0, ALL_FF_32, 0x0, 0,
456 "class-opt-ip-usr7", "class_opt_ip_usr7"},
457
458 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
459 NXGE_PARAM_CLASS_RWS,
460 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
461 "class-opt-ipv4-tcp", "class_opt_ipv4_tcp"},
462
463 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
464 NXGE_PARAM_CLASS_RWS,
465 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
466 "class-opt-ipv4-udp", "class_opt_ipv4_udp"},
467
468 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
469 NXGE_PARAM_CLASS_RWS,
470 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
471 "class-opt-ipv4-ah", "class_opt_ipv4_ah"},
472
473 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
474 NXGE_PARAM_CLASS_RWS,
475 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
476 "class-opt-ipv4-sctp", "class_opt_ipv4_sctp"},
477
478 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
479 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
480 "class-opt-ipv6-tcp", "class_opt_ipv6_tcp"},
481
482 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
483 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
484 "class-opt-ipv6-udp", "class_opt_ipv6_udp"},
485
486 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
487 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
488 "class-opt-ipv6-ah", "class_opt_ipv6_ah"},
489
490 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
491 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
492 "class-opt-ipv6-sctp", "class_opt_ipv6_sctp"},
493
494 { nxge_param_get_debug_flag, nxge_param_set_nxge_debug_flag,
ml29623846a9032007-06-11 17:24:13 -0700495 NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800496 0ULL, ALL_FF_64, 0ULL, 0ULL,
497 "nxge-debug-flag", "nxge_debug_flag"},
498
499 { nxge_param_get_debug_flag, nxge_param_set_npi_debug_flag,
ml29623846a9032007-06-11 17:24:13 -0700500 NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800501 0ULL, ALL_FF_64, 0ULL, 0ULL,
502 "npi-debug-flag", "npi_debug_flag"},
503
ml29623846a9032007-06-11 17:24:13 -0700504 { nxge_param_dump_tdc, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800505 0, 0x0fffffff, 0x0fffffff, 0, "dump-tdc", "dump_tdc"},
506
ml29623846a9032007-06-11 17:24:13 -0700507 { nxge_param_dump_rdc, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800508 0, 0x0fffffff, 0x0fffffff, 0, "dump-rdc", "dump_rdc"},
509
ml29623846a9032007-06-11 17:24:13 -0700510 { nxge_param_dump_mac_regs, NULL, NXGE_PARAM_READ |
511 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800512 0, 0x0fffffff, 0x0fffffff, 0, "dump-mac-regs", "dump_mac_regs"},
513
ml29623846a9032007-06-11 17:24:13 -0700514 { nxge_param_dump_ipp_regs, NULL, NXGE_PARAM_READ |
515 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800516 0, 0x0fffffff, 0x0fffffff, 0, "dump-ipp-regs", "dump_ipp_regs"},
517
ml29623846a9032007-06-11 17:24:13 -0700518 { nxge_param_dump_fflp_regs, NULL, NXGE_PARAM_READ |
519 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800520 0, 0x0fffffff, 0x0fffffff, 0,
521 "dump-fflp-regs", "dump_fflp_regs"},
522
ml29623846a9032007-06-11 17:24:13 -0700523 { nxge_param_dump_vlan_table, NULL, NXGE_PARAM_READ |
524 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800525 0, 0x0fffffff, 0x0fffffff, 0,
526 "dump-vlan-table", "dump_vlan_table"},
527
ml29623846a9032007-06-11 17:24:13 -0700528 { nxge_param_dump_rdc_table, NULL, NXGE_PARAM_READ |
529 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800530 0, 0x0fffffff, 0x0fffffff, 0,
531 "dump-rdc-table", "dump_rdc_table"},
532
ml29623846a9032007-06-11 17:24:13 -0700533 { nxge_param_dump_ptrs, NULL, NXGE_PARAM_READ |
534 NXGE_PARAM_DONT_SHOW,
speera3c5bd62007-01-30 11:29:19 -0800535 0, 0x0fffffff, 0x0fffffff, 0, "dump-ptrs", "dump_ptrs"},
536
537 { NULL, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
538 0, 0x0fffffff, 0x0fffffff, 0, "end", "end"},
girish44961712006-11-22 11:47:19 -0800539};
540
541extern void *nxge_list;
542
girish44961712006-11-22 11:47:19 -0800543void
544nxge_get_param_soft_properties(p_nxge_t nxgep)
545{
546
547 p_nxge_param_t param_arr;
548 uint_t prop_len;
549 int i, j;
speera3c5bd62007-01-30 11:29:19 -0800550 uint32_t param_count;
551 uint32_t *int_prop_val;
girish44961712006-11-22 11:47:19 -0800552
553 NXGE_DEBUG_MSG((nxgep, DDI_CTL, " ==> nxge_get_param_soft_properties"));
554
555 param_arr = nxgep->param_arr;
556 param_count = nxgep->param_count;
557 for (i = 0; i < param_count; i++) {
girish44961712006-11-22 11:47:19 -0800558 if ((param_arr[i].type & NXGE_PARAM_READ_PROP) == 0)
559 continue;
girish44961712006-11-22 11:47:19 -0800560 if ((param_arr[i].type & NXGE_PARAM_PROP_STR))
561 continue;
girish44961712006-11-22 11:47:19 -0800562 if ((param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
sowmini4045d942008-04-29 11:20:32 -0700563 (param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
girish44961712006-11-22 11:47:19 -0800564 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY,
sowmini4045d942008-04-29 11:20:32 -0700565 nxgep->dip, 0, param_arr[i].fcode_name,
566 (int **)&int_prop_val,
567 (uint_t *)&prop_len)
568 == DDI_PROP_SUCCESS) {
girish44961712006-11-22 11:47:19 -0800569 uint32_t *cfg_value;
570 uint64_t prop_count;
speera3c5bd62007-01-30 11:29:19 -0800571
girish44961712006-11-22 11:47:19 -0800572 if (prop_len > NXGE_PARAM_ARRAY_INIT_SIZE)
573 prop_len = NXGE_PARAM_ARRAY_INIT_SIZE;
joyceyadfcba52007-09-24 21:51:25 -0700574#if defined(__i386)
575 cfg_value =
sowmini4045d942008-04-29 11:20:32 -0700576 (uint32_t *)(int32_t)param_arr[i].value;
joyceyadfcba52007-09-24 21:51:25 -0700577#else
girish44961712006-11-22 11:47:19 -0800578 cfg_value = (uint32_t *)param_arr[i].value;
joyceyadfcba52007-09-24 21:51:25 -0700579#endif
girish44961712006-11-22 11:47:19 -0800580 for (j = 0; j < prop_len; j++) {
581 cfg_value[j] = int_prop_val[j];
582 }
583 prop_count = prop_len;
584 param_arr[i].type |=
585 (prop_count << NXGE_PARAM_ARRAY_CNT_SHIFT);
girish44961712006-11-22 11:47:19 -0800586 ddi_prop_free(int_prop_val);
587 }
girish44961712006-11-22 11:47:19 -0800588 continue;
589 }
590
591 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
sowmini4045d942008-04-29 11:20:32 -0700592 param_arr[i].fcode_name,
593 (int **)&int_prop_val,
594 &prop_len) == DDI_PROP_SUCCESS) {
girish44961712006-11-22 11:47:19 -0800595 if ((*int_prop_val >= param_arr[i].minimum) &&
sowmini4045d942008-04-29 11:20:32 -0700596 (*int_prop_val <= param_arr[i].maximum))
girish44961712006-11-22 11:47:19 -0800597 param_arr[i].value = *int_prop_val;
598#ifdef NXGE_DEBUG_ERROR
599 else {
600 NXGE_DEBUG_MSG((nxgep, OBP_CTL,
sowmini4045d942008-04-29 11:20:32 -0700601 "nxge%d: 'prom' file parameter error\n",
602 nxgep->instance));
girish44961712006-11-22 11:47:19 -0800603 NXGE_DEBUG_MSG((nxgep, OBP_CTL,
sowmini4045d942008-04-29 11:20:32 -0700604 "Parameter keyword '%s'"
605 " is outside valid range\n",
606 param_arr[i].name));
girish44961712006-11-22 11:47:19 -0800607 }
608#endif
609 ddi_prop_free(int_prop_val);
610 }
611
612 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
sowmini4045d942008-04-29 11:20:32 -0700613 param_arr[i].name,
614 (int **)&int_prop_val,
615 &prop_len) == DDI_PROP_SUCCESS) {
girish44961712006-11-22 11:47:19 -0800616 if ((*int_prop_val >= param_arr[i].minimum) &&
sowmini4045d942008-04-29 11:20:32 -0700617 (*int_prop_val <= param_arr[i].maximum))
girish44961712006-11-22 11:47:19 -0800618 param_arr[i].value = *int_prop_val;
619#ifdef NXGE_DEBUG_ERROR
620 else {
621 NXGE_DEBUG_MSG((nxgep, OBP_CTL,
sowmini4045d942008-04-29 11:20:32 -0700622 "nxge%d: 'conf' file parameter error\n",
623 nxgep->instance));
girish44961712006-11-22 11:47:19 -0800624 NXGE_DEBUG_MSG((nxgep, OBP_CTL,
sowmini4045d942008-04-29 11:20:32 -0700625 "Parameter keyword '%s'"
626 "is outside valid range\n",
627 param_arr[i].name));
girish44961712006-11-22 11:47:19 -0800628 }
629#endif
630 ddi_prop_free(int_prop_val);
631 }
632 }
633}
634
girish44961712006-11-22 11:47:19 -0800635static int
636nxge_private_param_register(p_nxge_t nxgep, p_nxge_param_t param_arr)
637{
girish44961712006-11-22 11:47:19 -0800638 int status = B_TRUE;
639 int channel;
640 uint8_t grp;
641 char *prop_name;
642 char *end;
643 uint32_t name_chars;
644
645 NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
sowmini4045d942008-04-29 11:20:32 -0700646 "nxge_private_param_register %s", param_arr->name));
girish44961712006-11-22 11:47:19 -0800647
648 if ((param_arr->type & NXGE_PARAM_PRIV) != NXGE_PARAM_PRIV)
649 return (B_TRUE);
speera3c5bd62007-01-30 11:29:19 -0800650
girish44961712006-11-22 11:47:19 -0800651 prop_name = param_arr->name;
652 if (param_arr->type & NXGE_PARAM_RXDMA) {
653 if (strncmp("rxdma_intr", prop_name, 10) == 0)
654 return (B_TRUE);
655 name_chars = strlen("default_grp");
656 if (strncmp("default_grp", prop_name, name_chars) == 0) {
657 prop_name += name_chars;
658 grp = mi_strtol(prop_name, &end, 10);
659 /* now check if this rdcgrp is in config */
660 return (nxge_check_rdcgrp_port_member(nxgep, grp));
661 }
662 name_chars = strlen(prop_name);
663 if (strncmp("default_port_rdc", prop_name, name_chars) == 0) {
664 return (B_TRUE);
665 }
girish44961712006-11-22 11:47:19 -0800666 return (B_FALSE);
667 }
668
669 if (param_arr->type & NXGE_PARAM_TXDMA) {
670 name_chars = strlen("txdma");
671 if (strncmp("txdma", prop_name, name_chars) == 0) {
672 prop_name += name_chars;
673 channel = mi_strtol(prop_name, &end, 10);
674 /* now check if this rdc is in config */
675 NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
sowmini4045d942008-04-29 11:20:32 -0700676 " nxge_private_param_register: %d",
677 channel));
girish44961712006-11-22 11:47:19 -0800678 return (nxge_check_txdma_port_member(nxgep, channel));
679 }
680 return (B_FALSE);
681 }
682
683 status = B_FALSE;
684 NXGE_DEBUG_MSG((nxgep, NDD2_CTL, "<== nxge_private_param_register"));
685
686 return (status);
687}
688
689void
690nxge_setup_param(p_nxge_t nxgep)
691{
692 p_nxge_param_t param_arr;
693 int i;
694 pfi_t set_pfi;
695
696 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_setup_param"));
speera3c5bd62007-01-30 11:29:19 -0800697
girish44961712006-11-22 11:47:19 -0800698 /*
699 * Make sure the param_instance is set to a valid device instance.
700 */
701 if (nxge_param_arr[param_instance].value == 1000)
702 nxge_param_arr[param_instance].value = nxgep->instance;
703
704 param_arr = nxgep->param_arr;
705 param_arr[param_instance].value = nxgep->instance;
706 param_arr[param_function_number].value = nxgep->function_num;
707
708 for (i = 0; i < nxgep->param_count; i++) {
709 if ((param_arr[i].type & NXGE_PARAM_PRIV) &&
sowmini4045d942008-04-29 11:20:32 -0700710 (nxge_private_param_register(nxgep,
711 &param_arr[i]) == B_FALSE)) {
girish44961712006-11-22 11:47:19 -0800712 param_arr[i].setf = NULL;
713 param_arr[i].getf = NULL;
714 }
715
716 if (param_arr[i].type & NXGE_PARAM_CMPLX)
717 param_arr[i].setf = NULL;
718
719 if (param_arr[i].type & NXGE_PARAM_DONT_SHOW) {
720 param_arr[i].setf = NULL;
721 param_arr[i].getf = NULL;
722 }
723
724 set_pfi = (pfi_t)param_arr[i].setf;
725
speera3c5bd62007-01-30 11:29:19 -0800726 if ((set_pfi) && (param_arr[i].type & NXGE_PARAM_INIT_ONLY)) {
girish44961712006-11-22 11:47:19 -0800727 set_pfi = NULL;
728 }
729
girish44961712006-11-22 11:47:19 -0800730 }
girish44961712006-11-22 11:47:19 -0800731 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_setup_param"));
732}
733
girish44961712006-11-22 11:47:19 -0800734void
735nxge_init_param(p_nxge_t nxgep)
736{
737 p_nxge_param_t param_arr;
738 int i, alloc_size;
739 uint64_t alloc_count;
740 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_init_param"));
741 /*
742 * Make sure the param_instance is set to a valid device instance.
743 */
744 if (nxge_param_arr[param_instance].value == 1000)
745 nxge_param_arr[param_instance].value = nxgep->instance;
746
747 param_arr = nxgep->param_arr;
748 if (param_arr == NULL) {
speera3c5bd62007-01-30 11:29:19 -0800749 param_arr = (p_nxge_param_t)
sowmini4045d942008-04-29 11:20:32 -0700750 KMEM_ZALLOC(sizeof (nxge_param_arr), KM_SLEEP);
girish44961712006-11-22 11:47:19 -0800751 }
speera3c5bd62007-01-30 11:29:19 -0800752
girish44961712006-11-22 11:47:19 -0800753 for (i = 0; i < sizeof (nxge_param_arr)/sizeof (nxge_param_t); i++) {
754 param_arr[i] = nxge_param_arr[i];
755 if ((param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
sowmini4045d942008-04-29 11:20:32 -0700756 (param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
girish44961712006-11-22 11:47:19 -0800757 alloc_count = NXGE_PARAM_ARRAY_INIT_SIZE;
758 alloc_size = alloc_count * sizeof (uint64_t);
759 param_arr[i].value =
joyceyadfcba52007-09-24 21:51:25 -0700760#if defined(__i386)
sowmini4045d942008-04-29 11:20:32 -0700761 (uint64_t)(uint32_t)KMEM_ZALLOC(alloc_size,
762 KM_SLEEP);
joyceyadfcba52007-09-24 21:51:25 -0700763#else
ml296231bd68252008-04-14 17:03:10 -0700764 (uint64_t)KMEM_ZALLOC(alloc_size, KM_SLEEP);
joyceyadfcba52007-09-24 21:51:25 -0700765#endif
girish44961712006-11-22 11:47:19 -0800766 param_arr[i].old_value =
joyceyadfcba52007-09-24 21:51:25 -0700767#if defined(__i386)
sowmini4045d942008-04-29 11:20:32 -0700768 (uint64_t)(uint32_t)KMEM_ZALLOC(alloc_size,
769 KM_SLEEP);
joyceyadfcba52007-09-24 21:51:25 -0700770#else
sowmini4045d942008-04-29 11:20:32 -0700771 (uint64_t)KMEM_ZALLOC(alloc_size, KM_SLEEP);
joyceyadfcba52007-09-24 21:51:25 -0700772#endif
girish44961712006-11-22 11:47:19 -0800773 param_arr[i].type |=
sowmini4045d942008-04-29 11:20:32 -0700774 (alloc_count << NXGE_PARAM_ARRAY_ALLOC_SHIFT);
girish44961712006-11-22 11:47:19 -0800775 }
776 }
777
778 nxgep->param_arr = param_arr;
779 nxgep->param_count = sizeof (nxge_param_arr)/sizeof (nxge_param_t);
ml296231bd68252008-04-14 17:03:10 -0700780
781 nxge_param_sync(nxgep);
782
girish44961712006-11-22 11:47:19 -0800783 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_init_param: count %d",
sowmini4045d942008-04-29 11:20:32 -0700784 nxgep->param_count));
girish44961712006-11-22 11:47:19 -0800785}
786
787void
788nxge_destroy_param(p_nxge_t nxgep)
789{
790 int i;
791 uint64_t free_size, free_count;
792
793 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_destroy_param"));
speera3c5bd62007-01-30 11:29:19 -0800794
davemq59ac0c12007-07-25 18:20:14 -0700795 if (nxgep->param_arr == NULL)
796 return;
girish44961712006-11-22 11:47:19 -0800797 /*
798 * Make sure the param_instance is set to a valid device instance.
799 */
800 if (nxge_param_arr[param_instance].value == nxgep->instance) {
801 for (i = 0; i <= nxge_param_arr[param_instance].maximum; i++) {
802 if ((ddi_get_soft_state(nxge_list, i) != NULL) &&
sowmini4045d942008-04-29 11:20:32 -0700803 (i != nxgep->instance))
girish44961712006-11-22 11:47:19 -0800804 break;
805 }
806 nxge_param_arr[param_instance].value = i;
807 }
808
girish44961712006-11-22 11:47:19 -0800809 for (i = 0; i < nxgep->param_count; i++)
810 if ((nxgep->param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
sowmini4045d942008-04-29 11:20:32 -0700811 (nxgep->param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
girish44961712006-11-22 11:47:19 -0800812 free_count = ((nxgep->param_arr[i].type &
sowmini4045d942008-04-29 11:20:32 -0700813 NXGE_PARAM_ARRAY_ALLOC_MASK) >>
814 NXGE_PARAM_ARRAY_ALLOC_SHIFT);
girish44961712006-11-22 11:47:19 -0800815 free_count = NXGE_PARAM_ARRAY_INIT_SIZE;
816 free_size = sizeof (uint64_t) * free_count;
joyceyadfcba52007-09-24 21:51:25 -0700817#if defined(__i386)
818 KMEM_FREE((void *)(uint32_t)nxgep->param_arr[i].value,
sowmini4045d942008-04-29 11:20:32 -0700819 free_size);
joyceyadfcba52007-09-24 21:51:25 -0700820#else
girish44961712006-11-22 11:47:19 -0800821 KMEM_FREE((void *)nxgep->param_arr[i].value, free_size);
joyceyadfcba52007-09-24 21:51:25 -0700822#endif
823#if defined(__i386)
824 KMEM_FREE((void *)(uint32_t)
sowmini4045d942008-04-29 11:20:32 -0700825 nxgep->param_arr[i].old_value, free_size);
joyceyadfcba52007-09-24 21:51:25 -0700826#else
girish44961712006-11-22 11:47:19 -0800827 KMEM_FREE((void *)nxgep->param_arr[i].old_value,
sowmini4045d942008-04-29 11:20:32 -0700828 free_size);
joyceyadfcba52007-09-24 21:51:25 -0700829#endif
girish44961712006-11-22 11:47:19 -0800830 }
831
832 KMEM_FREE(nxgep->param_arr, sizeof (nxge_param_arr));
833 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_destroy_param"));
834}
835
836/*
837 * Extracts the value from the 'nxge' parameter array and prints the
838 * parameter value. cp points to the required parameter.
839 */
speera3c5bd62007-01-30 11:29:19 -0800840
girish44961712006-11-22 11:47:19 -0800841/* ARGSUSED */
842int
girish44961712006-11-22 11:47:19 -0800843nxge_param_get_generic(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
844{
845 p_nxge_param_t pa = (p_nxge_param_t)cp;
846
speera3c5bd62007-01-30 11:29:19 -0800847 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
sowmini4045d942008-04-29 11:20:32 -0700848 "==> nxge_param_get_generic name %s ", pa->name));
girish44961712006-11-22 11:47:19 -0800849
850 if (pa->value > 0xffffffff)
speera3c5bd62007-01-30 11:29:19 -0800851 (void) mi_mpprintf(mp, "%x%x",
sowmini4045d942008-04-29 11:20:32 -0700852 (int)(pa->value >> 32), (int)(pa->value & 0xffffffff));
girish44961712006-11-22 11:47:19 -0800853 else
854 (void) mi_mpprintf(mp, "%x", (int)pa->value);
855
girish44961712006-11-22 11:47:19 -0800856 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_generic"));
857 return (0);
858}
859
girish44961712006-11-22 11:47:19 -0800860/* ARGSUSED */
861static int
862nxge_param_get_mac(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
863{
864 p_nxge_param_t pa = (p_nxge_param_t)cp;
865
866 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_mac"));
867
868 (void) mi_mpprintf(mp, "%d", (uint32_t)pa->value);
869 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_mac"));
870 return (0);
871}
872
girish44961712006-11-22 11:47:19 -0800873/* ARGSUSED */
speer56d930a2007-05-08 14:19:59 -0700874static int
875nxge_param_get_fw_ver(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
876{
877 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_fw_ver"));
878
879 (void) mi_mpprintf(mp, "Firmware version for nxge%d: %s\n",
880 nxgep->instance, nxgep->vpd_info.ver);
881
882 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_fw_ver"));
883 return (0);
884}
885
886/* ARGSUSED */
raghus2e591292007-08-31 16:49:49 -0700887static int
888nxge_param_get_port_mode(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
889{
890 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_port_mode"));
891
892 switch (nxgep->mac.portmode) {
893 case PORT_1G_COPPER:
sbehera2d172802007-11-30 18:51:47 -0800894 (void) mi_mpprintf(mp, "Port mode for nxge%d: 1G Copper %s\n",
895 nxgep->instance,
896 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
raghus2e591292007-08-31 16:49:49 -0700897 break;
898 case PORT_1G_FIBER:
sbehera2d172802007-11-30 18:51:47 -0800899 (void) mi_mpprintf(mp, "Port mode for nxge%d: 1G Fiber %s\n",
900 nxgep->instance,
901 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
raghus2e591292007-08-31 16:49:49 -0700902 break;
903 case PORT_10G_COPPER:
sbehera2d172802007-11-30 18:51:47 -0800904 (void) mi_mpprintf(mp, "Port mode for nxge%d: 10G Copper "
905 "%s\n", nxgep->instance,
906 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
raghus2e591292007-08-31 16:49:49 -0700907 break;
908 case PORT_10G_FIBER:
sbehera2d172802007-11-30 18:51:47 -0800909 (void) mi_mpprintf(mp, "Port mode for nxge%d: 10G Fiber %s\n",
910 nxgep->instance,
911 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
raghus2e591292007-08-31 16:49:49 -0700912 break;
913 case PORT_10G_SERDES:
sbehera2d172802007-11-30 18:51:47 -0800914 (void) mi_mpprintf(mp, "Port mode for nxge%d: 10G Serdes "
915 "%s\n", nxgep->instance,
916 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
raghus2e591292007-08-31 16:49:49 -0700917 break;
918 case PORT_1G_SERDES:
sbehera2d172802007-11-30 18:51:47 -0800919 (void) mi_mpprintf(mp, "Port mode for nxge%d: 1G Serdes %s\n",
920 nxgep->instance,
921 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
raghus2e591292007-08-31 16:49:49 -0700922 break;
923 case PORT_1G_RGMII_FIBER:
924 (void) mi_mpprintf(mp, "Port mode for nxge%d: 1G RGMII "
sbehera2d172802007-11-30 18:51:47 -0800925 "Fiber %s\n", nxgep->instance,
926 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
927 break;
928 case PORT_HSP_MODE:
929 (void) mi_mpprintf(mp, "Port mode for nxge%d: Hot Swappable "
930 "PHY, Currently NOT present\n", nxgep->instance);
raghus2e591292007-08-31 16:49:49 -0700931 break;
yc14809700161852008-06-09 20:15:04 -0700932 case PORT_10G_TN1010:
933 (void) mi_mpprintf(mp, "Port mode for nxge%d:"
934 " 10G Copper with TN1010 %s\n", nxgep->instance,
935 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
936 break;
937 case PORT_1G_TN1010:
yc148097c6e5ef52008-06-09 22:52:41 -0700938 (void) mi_mpprintf(mp, "Port mode for nxge%d:"
yc14809700161852008-06-09 20:15:04 -0700939 " 1G Copper with TN1010 %s\n", nxgep->instance,
940 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
941 break;
raghus2e591292007-08-31 16:49:49 -0700942 default:
sbehera2d172802007-11-30 18:51:47 -0800943 (void) mi_mpprintf(mp, "Port mode for nxge%d: Unknown %s\n",
944 nxgep->instance,
945 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
raghus2e591292007-08-31 16:49:49 -0700946 break;
947 }
948
ml296233d16f8e2008-02-13 13:10:16 -0800949 (void) mi_mpprintf(mp, "Software LSO for nxge%d: %s\n",
950 nxgep->instance,
951 nxgep->soft_lso_enable ? "enable" : "disable");
952
raghus2e591292007-08-31 16:49:49 -0700953 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_port_mode"));
954 return (0);
955}
956
957/* ARGSUSED */
Santwona Beherac1f9c6e2009-03-10 11:26:53 -0700958static int
959nxge_param_get_rx_intr_time(p_nxge_t nxgep, queue_t *q, mblk_t *mp, caddr_t cp)
960{
961 p_nxge_param_t pa = (p_nxge_param_t)cp;
962
963 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_rx_intr_time"));
964
965 pa->value = (uint32_t)nxgep->intr_timeout;
966 (void) mi_mpprintf(mp, "%d", (uint32_t)nxgep->intr_timeout);
967
968 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_rx_intr_time"));
969 return (0);
970}
971
972/* ARGSUSED */
973static int
974nxge_param_get_rx_intr_pkts(p_nxge_t nxgep, queue_t *q, mblk_t *mp, caddr_t cp)
975{
976 p_nxge_param_t pa = (p_nxge_param_t)cp;
977
978 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_rx_intr_pkts"));
979
980 pa->value = (uint32_t)nxgep->intr_threshold;
981 (void) mi_mpprintf(mp, "%d", (uint32_t)nxgep->intr_threshold);
982
983 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_rx_intr_pkts"));
984 return (0);
985}
986
987/* ARGSUSED */
girish44961712006-11-22 11:47:19 -0800988int
989nxge_param_get_txdma_info(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
990{
991
speer678453a2008-04-27 19:50:44 -0700992 uint_t print_len, buf_len;
girish44961712006-11-22 11:47:19 -0800993 p_mblk_t np;
girish44961712006-11-22 11:47:19 -0800994
995 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
speer678453a2008-04-27 19:50:44 -0700996 int tdc;
997
998 nxge_grp_set_t *set;
999
girish44961712006-11-22 11:47:19 -08001000 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_txdma_info"));
1001
speera3c5bd62007-01-30 11:29:19 -08001002 (void) mi_mpprintf(mp, "TXDMA Information for Port\t %d \n",
sowmini4045d942008-04-29 11:20:32 -07001003 nxgep->function_num);
girish44961712006-11-22 11:47:19 -08001004
girish44961712006-11-22 11:47:19 -08001005 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
1006 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
1007 return (0);
1008 }
1009
1010 buf_len = buff_alloc_size;
girish44961712006-11-22 11:47:19 -08001011 mp->b_cont = np;
speer678453a2008-04-27 19:50:44 -07001012 print_len = 0;
girish44961712006-11-22 11:47:19 -08001013
girish44961712006-11-22 11:47:19 -08001014 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
sowmini4045d942008-04-29 11:20:32 -07001015 "TDC\t HW TDC\t\n");
girish44961712006-11-22 11:47:19 -08001016 ((mblk_t *)np)->b_wptr += print_len;
1017 buf_len -= print_len;
speer678453a2008-04-27 19:50:44 -07001018
1019 set = &nxgep->tx_set;
Eric Chengda14ceb2008-12-04 18:16:10 -08001020 for (tdc = 0; tdc < NXGE_MAX_TDCS; tdc++) {
speer678453a2008-04-27 19:50:44 -07001021 if ((1 << tdc) & set->owned.map) {
1022 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
1023 buf_len, "%d\n", tdc);
1024 ((mblk_t *)np)->b_wptr += print_len;
1025 buf_len -= print_len;
1026 }
girish44961712006-11-22 11:47:19 -08001027 }
speera3c5bd62007-01-30 11:29:19 -08001028
girish44961712006-11-22 11:47:19 -08001029 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_txdma_info"));
1030 return (0);
1031}
1032
girish44961712006-11-22 11:47:19 -08001033/* ARGSUSED */
1034int
1035nxge_param_get_rxdma_info(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
1036{
speera3c5bd62007-01-30 11:29:19 -08001037 uint_t print_len, buf_len;
1038 p_mblk_t np;
1039 int rdc;
girish44961712006-11-22 11:47:19 -08001040 p_nxge_dma_pt_cfg_t p_dma_cfgp;
1041 p_nxge_hw_pt_cfg_t p_cfgp;
speera3c5bd62007-01-30 11:29:19 -08001042 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
girish44961712006-11-22 11:47:19 -08001043 p_rx_rcr_rings_t rx_rcr_rings;
1044 p_rx_rcr_ring_t *rcr_rings;
1045 p_rx_rbr_rings_t rx_rbr_rings;
1046 p_rx_rbr_ring_t *rbr_rings;
speer678453a2008-04-27 19:50:44 -07001047 nxge_grp_set_t *set;
girish44961712006-11-22 11:47:19 -08001048
1049 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_rxdma_info"));
1050
speera3c5bd62007-01-30 11:29:19 -08001051 (void) mi_mpprintf(mp, "RXDMA Information for Port\t %d \n",
sowmini4045d942008-04-29 11:20:32 -07001052 nxgep->function_num);
girish44961712006-11-22 11:47:19 -08001053
1054 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
1055 /* The following may work even if we cannot get a large buf. */
1056 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
1057 return (0);
1058 }
1059
1060 buf_len = buff_alloc_size;
girish44961712006-11-22 11:47:19 -08001061 mp->b_cont = np;
girish44961712006-11-22 11:47:19 -08001062 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
1063 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
1064
1065 rx_rcr_rings = nxgep->rx_rcr_rings;
1066 rcr_rings = rx_rcr_rings->rcr_rings;
1067 rx_rbr_rings = nxgep->rx_rbr_rings;
1068 rbr_rings = rx_rbr_rings->rbr_rings;
1069
1070 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
sowmini4045d942008-04-29 11:20:32 -07001071 "Total RDCs\t %d\n", p_cfgp->max_rdcs);
girish44961712006-11-22 11:47:19 -08001072
1073 ((mblk_t *)np)->b_wptr += print_len;
1074 buf_len -= print_len;
1075 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
sowmini4045d942008-04-29 11:20:32 -07001076 "RDC\t HW RDC\t Timeout\t Packets RBR ptr \t"
1077 "chunks\t RCR ptr\n");
speera3c5bd62007-01-30 11:29:19 -08001078
girish44961712006-11-22 11:47:19 -08001079 ((mblk_t *)np)->b_wptr += print_len;
1080 buf_len -= print_len;
speer678453a2008-04-27 19:50:44 -07001081
1082 set = &nxgep->rx_set;
1083 for (rdc = 0; rdc < NXGE_MAX_RDCS; rdc++) {
1084 if ((1 << rdc) & set->owned.map) {
1085 print_len = snprintf((char *)
1086 ((mblk_t *)np)->b_wptr, buf_len,
1087 " %d\t %x\t\t %x\t $%p\t 0x%x\t $%p\n",
1088 rdc,
1089 p_dma_cfgp->rcr_timeout[rdc],
1090 p_dma_cfgp->rcr_threshold[rdc],
Nick Todd8793b362008-09-18 20:50:09 +01001091 (void *)rbr_rings[rdc],
1092 rbr_rings[rdc]->num_blocks, (void *)rcr_rings[rdc]);
speera3c5bd62007-01-30 11:29:19 -08001093 ((mblk_t *)np)->b_wptr += print_len;
1094 buf_len -= print_len;
speer678453a2008-04-27 19:50:44 -07001095 }
girish44961712006-11-22 11:47:19 -08001096 }
speera3c5bd62007-01-30 11:29:19 -08001097
girish44961712006-11-22 11:47:19 -08001098 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_rxdma_info"));
1099 return (0);
1100}
1101
girish44961712006-11-22 11:47:19 -08001102/* ARGSUSED */
1103int
1104nxge_param_get_rxdma_rdcgrp_info(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001105 p_mblk_t mp, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001106{
speera3c5bd62007-01-30 11:29:19 -08001107 uint_t print_len, buf_len;
1108 p_mblk_t np;
1109 int offset, rdc, i, rdc_grp;
girish44961712006-11-22 11:47:19 -08001110 p_nxge_rdc_grp_t rdc_grp_p;
1111 p_nxge_dma_pt_cfg_t p_dma_cfgp;
1112 p_nxge_hw_pt_cfg_t p_cfgp;
1113
1114 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
1115 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
sowmini4045d942008-04-29 11:20:32 -07001116 "==> nxge_param_get_rxdma_rdcgrp_info"));
girish44961712006-11-22 11:47:19 -08001117
1118 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
1119 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
1120
speera3c5bd62007-01-30 11:29:19 -08001121 (void) mi_mpprintf(mp, "RXDMA RDC Group Information for Port\t %d \n",
sowmini4045d942008-04-29 11:20:32 -07001122 nxgep->function_num);
girish44961712006-11-22 11:47:19 -08001123
speer678453a2008-04-27 19:50:44 -07001124 rdc_grp = p_cfgp->def_mac_rxdma_grpid;
girish44961712006-11-22 11:47:19 -08001125 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
1126 /* The following may work even if we cannot get a large buf. */
1127 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
1128 return (0);
1129 }
1130
1131 buf_len = buff_alloc_size;
girish44961712006-11-22 11:47:19 -08001132 mp->b_cont = np;
1133 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
sowmini4045d942008-04-29 11:20:32 -07001134 "Total RDC Groups\t %d \n"
1135 "default RDC group\t %d\n",
1136 p_cfgp->max_rdc_grpids,
1137 p_cfgp->def_mac_rxdma_grpid);
girish44961712006-11-22 11:47:19 -08001138
1139 ((mblk_t *)np)->b_wptr += print_len;
1140 buf_len -= print_len;
1141
Santwona Behera7b26d9f2009-01-30 11:54:57 -08001142 for (i = 0; i < NXGE_MAX_RDC_GROUPS; i++) {
speer678453a2008-04-27 19:50:44 -07001143 if (p_cfgp->grpids[i]) {
1144 rdc_grp_p = &p_dma_cfgp->rdc_grps[i];
girish44961712006-11-22 11:47:19 -08001145 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
speer678453a2008-04-27 19:50:44 -07001146 buf_len,
1147 "\nRDC Group Info for Group [%d] %d\n"
1148 "RDC Count %d\tstart RDC %d\n"
1149 "RDC Group Population Information"
1150 " (offsets 0 - 15)\n",
1151 i, rdc_grp, rdc_grp_p->max_rdcs,
1152 rdc_grp_p->start_rdc);
1153
1154 ((mblk_t *)np)->b_wptr += print_len;
1155 buf_len -= print_len;
1156 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
1157 buf_len, "\n");
1158 ((mblk_t *)np)->b_wptr += print_len;
1159 buf_len -= print_len;
1160
1161 for (rdc = 0; rdc < rdc_grp_p->max_rdcs; rdc++) {
1162 print_len = snprintf(
sowmini4045d942008-04-29 11:20:32 -07001163 (char *)((mblk_t *)np)->b_wptr,
1164 buf_len, "[%d]=%d ", rdc,
1165 rdc_grp_p->start_rdc + rdc);
speer678453a2008-04-27 19:50:44 -07001166 ((mblk_t *)np)->b_wptr += print_len;
1167 buf_len -= print_len;
1168 }
1169 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
1170 buf_len, "\n");
1171 ((mblk_t *)np)->b_wptr += print_len;
1172 buf_len -= print_len;
1173
1174 for (offset = 0; offset < 16; offset++) {
1175 print_len = snprintf(
sowmini4045d942008-04-29 11:20:32 -07001176 (char *)((mblk_t *)np)->b_wptr,
1177 buf_len, " %c",
1178 rdc_grp_p->map & (1 << offset) ?
1179 '1' : '0');
speer678453a2008-04-27 19:50:44 -07001180 ((mblk_t *)np)->b_wptr += print_len;
1181 buf_len -= print_len;
1182 }
1183 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
1184 buf_len, "\n");
girish44961712006-11-22 11:47:19 -08001185 ((mblk_t *)np)->b_wptr += print_len;
1186 buf_len -= print_len;
1187 }
girish44961712006-11-22 11:47:19 -08001188 }
1189 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
sowmini4045d942008-04-29 11:20:32 -07001190 "<== nxge_param_get_rxdma_rdcgrp_info"));
girish44961712006-11-22 11:47:19 -08001191 return (0);
1192}
1193
girish44961712006-11-22 11:47:19 -08001194int
1195nxge_mk_mblk_tail_space(p_mblk_t mp, p_mblk_t *nmp, size_t size)
1196{
1197 p_mblk_t tmp;
1198
1199 tmp = mp;
1200 while (tmp->b_cont)
1201 tmp = tmp->b_cont;
1202 if ((tmp->b_wptr + size) >= tmp->b_datap->db_lim) {
1203 tmp->b_cont = allocb(1024, BPRI_HI);
1204 tmp = tmp->b_cont;
1205 if (!tmp)
1206 return (ENOMEM);
1207 }
speera3c5bd62007-01-30 11:29:19 -08001208
girish44961712006-11-22 11:47:19 -08001209 *nmp = tmp;
1210 return (0);
1211}
1212
speera3c5bd62007-01-30 11:29:19 -08001213
girish44961712006-11-22 11:47:19 -08001214/* ARGSUSED */
1215int
1216nxge_param_set_generic(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
Toomas Soomefe054a62017-08-08 22:36:50 +03001217 char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001218{
1219 char *end;
1220 uint32_t new_value;
1221 p_nxge_param_t pa = (p_nxge_param_t)cp;
1222
1223 NXGE_DEBUG_MSG((nxgep, IOC_CTL, " ==> nxge_param_set_generic"));
1224 new_value = (uint32_t)mi_strtol(value, &end, 10);
1225 if (end == value || new_value < pa->minimum ||
sowmini4045d942008-04-29 11:20:32 -07001226 new_value > pa->maximum) {
girish44961712006-11-22 11:47:19 -08001227 return (EINVAL);
1228 }
1229 pa->value = new_value;
1230 NXGE_DEBUG_MSG((nxgep, IOC_CTL, " <== nxge_param_set_generic"));
1231 return (0);
1232}
1233
speera3c5bd62007-01-30 11:29:19 -08001234
girish44961712006-11-22 11:47:19 -08001235/* ARGSUSED */
girish44961712006-11-22 11:47:19 -08001236int
speera3c5bd62007-01-30 11:29:19 -08001237nxge_param_set_instance(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
Toomas Soomefe054a62017-08-08 22:36:50 +03001238 char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001239{
girish44961712006-11-22 11:47:19 -08001240 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " ==> nxge_param_set_instance"));
girish44961712006-11-22 11:47:19 -08001241 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_set_instance"));
1242 return (0);
1243}
1244
girish44961712006-11-22 11:47:19 -08001245
speera3c5bd62007-01-30 11:29:19 -08001246/* ARGSUSED */
girish44961712006-11-22 11:47:19 -08001247int
speera3c5bd62007-01-30 11:29:19 -08001248nxge_param_set_mac(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
Toomas Soomefe054a62017-08-08 22:36:50 +03001249 char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001250{
speera3c5bd62007-01-30 11:29:19 -08001251 char *end;
1252 uint32_t new_value;
1253 int status = 0;
1254 p_nxge_param_t pa = (p_nxge_param_t)cp;
girish44961712006-11-22 11:47:19 -08001255
1256 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_mac"));
1257 new_value = (uint32_t)mi_strtol(value, &end, BASE_DECIMAL);
1258 if (PARAM_OUTOF_RANGE(value, end, new_value, pa)) {
1259 return (EINVAL);
1260 }
1261
1262 if (pa->value != new_value) {
1263 pa->old_value = pa->value;
1264 pa->value = new_value;
1265 }
1266
1267 if (!nxge_param_link_update(nxgep)) {
1268 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
sowmini4045d942008-04-29 11:20:32 -07001269 " false ret from nxge_param_link_update"));
girish44961712006-11-22 11:47:19 -08001270 status = EINVAL;
1271 }
1272
1273 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_mac"));
1274 return (status);
1275}
1276
1277/* ARGSUSED */
ml296231bd68252008-04-14 17:03:10 -07001278int
speera3c5bd62007-01-30 11:29:19 -08001279nxge_param_rx_intr_pkts(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
Toomas Soomefe054a62017-08-08 22:36:50 +03001280 char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001281{
speera3c5bd62007-01-30 11:29:19 -08001282 char *end;
1283 uint32_t cfg_value;
1284 p_nxge_param_t pa = (p_nxge_param_t)cp;
sd7746814ea4bb2006-12-22 12:42:28 -08001285
girish44961712006-11-22 11:47:19 -08001286 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_rx_intr_pkts"));
1287
sd7746814ea4bb2006-12-22 12:42:28 -08001288 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
girish44961712006-11-22 11:47:19 -08001289
sd7746814ea4bb2006-12-22 12:42:28 -08001290 if ((cfg_value > NXGE_RDC_RCR_THRESHOLD_MAX) ||
sowmini4045d942008-04-29 11:20:32 -07001291 (cfg_value < NXGE_RDC_RCR_THRESHOLD_MIN)) {
girish44961712006-11-22 11:47:19 -08001292 return (EINVAL);
1293 }
sd7746814ea4bb2006-12-22 12:42:28 -08001294
1295 if ((pa->value != cfg_value)) {
1296 pa->old_value = pa->value;
1297 pa->value = cfg_value;
1298 nxgep->intr_threshold = pa->value;
girish44961712006-11-22 11:47:19 -08001299 }
sd7746814ea4bb2006-12-22 12:42:28 -08001300
girish44961712006-11-22 11:47:19 -08001301 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_rx_intr_pkts"));
1302 return (0);
1303}
1304
girish44961712006-11-22 11:47:19 -08001305/* ARGSUSED */
ml296231bd68252008-04-14 17:03:10 -07001306int
speera3c5bd62007-01-30 11:29:19 -08001307nxge_param_rx_intr_time(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
Toomas Soomefe054a62017-08-08 22:36:50 +03001308 char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001309{
speera3c5bd62007-01-30 11:29:19 -08001310 char *end;
1311 uint32_t cfg_value;
1312 p_nxge_param_t pa = (p_nxge_param_t)cp;
girish44961712006-11-22 11:47:19 -08001313
1314 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_rx_intr_time"));
1315
sd7746814ea4bb2006-12-22 12:42:28 -08001316 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
girish44961712006-11-22 11:47:19 -08001317
sd7746814ea4bb2006-12-22 12:42:28 -08001318 if ((cfg_value > NXGE_RDC_RCR_TIMEOUT_MAX) ||
sowmini4045d942008-04-29 11:20:32 -07001319 (cfg_value < NXGE_RDC_RCR_TIMEOUT_MIN)) {
girish44961712006-11-22 11:47:19 -08001320 return (EINVAL);
1321 }
1322
sd7746814ea4bb2006-12-22 12:42:28 -08001323 if ((pa->value != cfg_value)) {
1324 pa->old_value = pa->value;
1325 pa->value = cfg_value;
1326 nxgep->intr_timeout = pa->value;
girish44961712006-11-22 11:47:19 -08001327 }
1328
1329 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_rx_intr_time"));
1330 return (0);
1331}
1332
1333/* ARGSUSED */
1334static int
1335nxge_param_set_mac_rdcgrp(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001336 mblk_t *mp, char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001337{
speera3c5bd62007-01-30 11:29:19 -08001338 char *end;
1339 uint32_t status = 0, cfg_value;
1340 p_nxge_param_t pa = (p_nxge_param_t)cp;
1341 uint32_t cfg_it = B_FALSE;
girish44961712006-11-22 11:47:19 -08001342 p_nxge_dma_pt_cfg_t p_dma_cfgp;
1343 p_nxge_hw_pt_cfg_t p_cfgp;
speera3c5bd62007-01-30 11:29:19 -08001344 uint32_t *val_ptr, *old_val_ptr;
1345 nxge_param_map_t *mac_map;
1346 p_nxge_class_pt_cfg_t p_class_cfgp;
1347 nxge_mv_cfg_t *mac_host_info;
girish44961712006-11-22 11:47:19 -08001348
1349 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_mac_rdcgrp "));
1350
1351 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
1352 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
1353 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
1354 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0];
1355 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
speera3c5bd62007-01-30 11:29:19 -08001356
1357 /*
1358 * now do decoding
1359 */
girish44961712006-11-22 11:47:19 -08001360 mac_map = (nxge_param_map_t *)&cfg_value;
speera3c5bd62007-01-30 11:29:19 -08001361 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " cfg_value %x id %x map_to %x",
sowmini4045d942008-04-29 11:20:32 -07001362 cfg_value, mac_map->param_id, mac_map->map_to));
girish44961712006-11-22 11:47:19 -08001363
1364 if ((mac_map->param_id < p_cfgp->max_macs) &&
speer678453a2008-04-27 19:50:44 -07001365 p_cfgp->grpids[mac_map->map_to]) {
girish44961712006-11-22 11:47:19 -08001366 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
speer678453a2008-04-27 19:50:44 -07001367 " nxge_param_set_mac_rdcgrp mapping"
1368 " id %d grp %d", mac_map->param_id, mac_map->map_to));
joyceyadfcba52007-09-24 21:51:25 -07001369#if defined(__i386)
1370 val_ptr = (uint32_t *)(uint32_t)pa->value;
1371#else
girish44961712006-11-22 11:47:19 -08001372 val_ptr = (uint32_t *)pa->value;
joyceyadfcba52007-09-24 21:51:25 -07001373#endif
1374#if defined(__i386)
1375 old_val_ptr = (uint32_t *)(uint32_t)pa->old_value;
1376#else
girish44961712006-11-22 11:47:19 -08001377 old_val_ptr = (uint32_t *)pa->old_value;
joyceyadfcba52007-09-24 21:51:25 -07001378#endif
girish44961712006-11-22 11:47:19 -08001379 if (val_ptr[mac_map->param_id] != cfg_value) {
1380 old_val_ptr[mac_map->param_id] =
speer678453a2008-04-27 19:50:44 -07001381 val_ptr[mac_map->param_id];
girish44961712006-11-22 11:47:19 -08001382 val_ptr[mac_map->param_id] = cfg_value;
1383 mac_host_info[mac_map->param_id].mpr_npr =
speer678453a2008-04-27 19:50:44 -07001384 mac_map->pref;
girish44961712006-11-22 11:47:19 -08001385 mac_host_info[mac_map->param_id].flag = 1;
1386 mac_host_info[mac_map->param_id].rdctbl =
speer678453a2008-04-27 19:50:44 -07001387 mac_map->map_to;
girish44961712006-11-22 11:47:19 -08001388 cfg_it = B_TRUE;
1389 }
girish44961712006-11-22 11:47:19 -08001390 } else {
1391 return (EINVAL);
1392 }
1393
1394 if (cfg_it == B_TRUE) {
1395 status = nxge_logical_mac_assign_rdc_table(nxgep,
speer678453a2008-04-27 19:50:44 -07001396 (uint8_t)mac_map->param_id);
girish44961712006-11-22 11:47:19 -08001397 if (status != NXGE_OK)
1398 return (EINVAL);
1399 }
1400
1401 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_mac_rdcgrp"));
1402 return (0);
1403}
1404
1405/* ARGSUSED */
1406static int
1407nxge_param_set_vlan_rdcgrp(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001408 mblk_t *mp, char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001409{
speera3c5bd62007-01-30 11:29:19 -08001410 char *end;
1411 uint32_t status = 0, cfg_value;
1412 p_nxge_param_t pa = (p_nxge_param_t)cp;
1413 uint32_t cfg_it = B_FALSE;
girish44961712006-11-22 11:47:19 -08001414 p_nxge_dma_pt_cfg_t p_dma_cfgp;
1415 p_nxge_hw_pt_cfg_t p_cfgp;
speera3c5bd62007-01-30 11:29:19 -08001416 uint32_t *val_ptr, *old_val_ptr;
1417 nxge_param_map_t *vmap, *old_map;
1418 p_nxge_class_pt_cfg_t p_class_cfgp;
1419 uint64_t cfgd_vlans;
1420 int i, inc = 0, cfg_position;
1421 nxge_mv_cfg_t *vlan_tbl;
girish44961712006-11-22 11:47:19 -08001422
1423 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_vlan_rdcgrp "));
1424
1425 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
1426 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
1427 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
1428 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0];
1429
1430 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
speera3c5bd62007-01-30 11:29:19 -08001431
1432 /* now do decoding */
girish44961712006-11-22 11:47:19 -08001433 cfgd_vlans = ((pa->type & NXGE_PARAM_ARRAY_CNT_MASK) >>
sowmini4045d942008-04-29 11:20:32 -07001434 NXGE_PARAM_ARRAY_CNT_SHIFT);
girish44961712006-11-22 11:47:19 -08001435
1436 if (cfgd_vlans == NXGE_PARAM_ARRAY_INIT_SIZE) {
1437 /*
1438 * for now, we process only upto max
1439 * NXGE_PARAM_ARRAY_INIT_SIZE parameters
1440 * In the future, we may want to expand
1441 * the storage array and continue
1442 */
1443 return (EINVAL);
1444 }
speera3c5bd62007-01-30 11:29:19 -08001445
girish44961712006-11-22 11:47:19 -08001446 vmap = (nxge_param_map_t *)&cfg_value;
1447 if ((vmap->param_id) &&
sowmini4045d942008-04-29 11:20:32 -07001448 (vmap->param_id < NXGE_MAX_VLANS) &&
1449 (vmap->map_to < p_cfgp->max_rdc_grpids)) {
girish44961712006-11-22 11:47:19 -08001450 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
sowmini4045d942008-04-29 11:20:32 -07001451 "nxge_param_set_vlan_rdcgrp mapping"
1452 " id %d grp %d",
1453 vmap->param_id, vmap->map_to));
joyceyadfcba52007-09-24 21:51:25 -07001454#if defined(__i386)
1455 val_ptr = (uint32_t *)(uint32_t)pa->value;
1456#else
girish44961712006-11-22 11:47:19 -08001457 val_ptr = (uint32_t *)pa->value;
joyceyadfcba52007-09-24 21:51:25 -07001458#endif
1459#if defined(__i386)
1460 old_val_ptr = (uint32_t *)(uint32_t)pa->old_value;
1461#else
girish44961712006-11-22 11:47:19 -08001462 old_val_ptr = (uint32_t *)pa->old_value;
joyceyadfcba52007-09-24 21:51:25 -07001463#endif
girish44961712006-11-22 11:47:19 -08001464
1465 /* search to see if this vlan id is already configured */
1466 for (i = 0; i < cfgd_vlans; i++) {
1467 old_map = (nxge_param_map_t *)&val_ptr[i];
1468 if ((old_map->param_id == 0) ||
sowmini4045d942008-04-29 11:20:32 -07001469 (vmap->param_id == old_map->param_id) ||
1470 (vlan_tbl[vmap->param_id].flag)) {
girish44961712006-11-22 11:47:19 -08001471 cfg_position = i;
1472 break;
1473 }
1474 }
1475
1476 if (cfgd_vlans == 0) {
1477 cfg_position = 0;
1478 inc++;
1479 }
1480
1481 if (i == cfgd_vlans) {
1482 cfg_position = i;
1483 inc++;
1484 }
1485
1486 NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
sowmini4045d942008-04-29 11:20:32 -07001487 "set_vlan_rdcgrp mapping"
1488 " i %d cfgd_vlans %llx position %d ",
1489 i, cfgd_vlans, cfg_position));
girish44961712006-11-22 11:47:19 -08001490 if (val_ptr[cfg_position] != cfg_value) {
1491 old_val_ptr[cfg_position] = val_ptr[cfg_position];
1492 val_ptr[cfg_position] = cfg_value;
1493 vlan_tbl[vmap->param_id].mpr_npr = vmap->pref;
1494 vlan_tbl[vmap->param_id].flag = 1;
1495 vlan_tbl[vmap->param_id].rdctbl =
speer678453a2008-04-27 19:50:44 -07001496 vmap->map_to + p_cfgp->def_mac_rxdma_grpid;
girish44961712006-11-22 11:47:19 -08001497 cfg_it = B_TRUE;
1498 if (inc) {
1499 cfgd_vlans++;
1500 pa->type &= ~NXGE_PARAM_ARRAY_CNT_MASK;
1501 pa->type |= (cfgd_vlans <<
sowmini4045d942008-04-29 11:20:32 -07001502 NXGE_PARAM_ARRAY_CNT_SHIFT);
girish44961712006-11-22 11:47:19 -08001503
1504 }
1505 NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
sowmini4045d942008-04-29 11:20:32 -07001506 "after: param_set_vlan_rdcgrp "
1507 " cfg_vlans %llx position %d \n",
1508 cfgd_vlans, cfg_position));
girish44961712006-11-22 11:47:19 -08001509 }
girish44961712006-11-22 11:47:19 -08001510 } else {
1511 return (EINVAL);
1512 }
1513
1514 if (cfg_it == B_TRUE) {
1515 status = nxge_fflp_config_vlan_table(nxgep,
sowmini4045d942008-04-29 11:20:32 -07001516 (uint16_t)vmap->param_id);
girish44961712006-11-22 11:47:19 -08001517 if (status != NXGE_OK)
1518 return (EINVAL);
1519 }
1520
1521 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_vlan_rdcgrp"));
1522 return (0);
1523}
1524
girish44961712006-11-22 11:47:19 -08001525/* ARGSUSED */
1526static int
1527nxge_param_get_vlan_rdcgrp(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001528 mblk_t *mp, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001529{
1530
speera3c5bd62007-01-30 11:29:19 -08001531 uint_t print_len, buf_len;
1532 p_mblk_t np;
1533 int i;
1534 uint32_t *val_ptr;
1535 nxge_param_map_t *vmap;
1536 p_nxge_param_t pa = (p_nxge_param_t)cp;
girish44961712006-11-22 11:47:19 -08001537 p_nxge_class_pt_cfg_t p_class_cfgp;
1538 p_nxge_dma_pt_cfg_t p_dma_cfgp;
1539 p_nxge_hw_pt_cfg_t p_cfgp;
speera3c5bd62007-01-30 11:29:19 -08001540 uint64_t cfgd_vlans = 0;
1541 nxge_mv_cfg_t *vlan_tbl;
1542 int buff_alloc_size =
sowmini4045d942008-04-29 11:20:32 -07001543 NXGE_NDD_INFODUMP_BUFF_SIZE * 32;
girish44961712006-11-22 11:47:19 -08001544
girish44961712006-11-22 11:47:19 -08001545 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_vlan_rdcgrp "));
speera3c5bd62007-01-30 11:29:19 -08001546 (void) mi_mpprintf(mp, "VLAN RDC Mapping Information for Port\t %d \n",
sowmini4045d942008-04-29 11:20:32 -07001547 nxgep->function_num);
girish44961712006-11-22 11:47:19 -08001548
1549 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
1550 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
1551 return (0);
1552 }
speera3c5bd62007-01-30 11:29:19 -08001553
girish44961712006-11-22 11:47:19 -08001554 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
1555 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
1556
1557 buf_len = buff_alloc_size;
1558 mp->b_cont = np;
1559 cfgd_vlans = (pa->type & NXGE_PARAM_ARRAY_CNT_MASK) >>
sowmini4045d942008-04-29 11:20:32 -07001560 NXGE_PARAM_ARRAY_CNT_SHIFT;
girish44961712006-11-22 11:47:19 -08001561
1562 i = (int)cfgd_vlans;
1563 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
1564 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0];
1565 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
sowmini4045d942008-04-29 11:20:32 -07001566 "Configured VLANs %d\n"
1567 "VLAN ID\t RDC GRP (Actual/Port)\t"
1568 " Prefernce\n", i);
girish44961712006-11-22 11:47:19 -08001569 ((mblk_t *)np)->b_wptr += print_len;
1570 buf_len -= print_len;
joyceyadfcba52007-09-24 21:51:25 -07001571#if defined(__i386)
1572 val_ptr = (uint32_t *)(uint32_t)pa->value;
1573#else
girish44961712006-11-22 11:47:19 -08001574 val_ptr = (uint32_t *)pa->value;
joyceyadfcba52007-09-24 21:51:25 -07001575#endif
girish44961712006-11-22 11:47:19 -08001576
1577 for (i = 0; i < cfgd_vlans; i++) {
1578 vmap = (nxge_param_map_t *)&val_ptr[i];
1579 if (p_class_cfgp->vlan_tbl[vmap->param_id].flag) {
1580 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
sowmini4045d942008-04-29 11:20:32 -07001581 buf_len,
1582 " %d\t\t %d/%d\t\t %d\n",
1583 vmap->param_id,
1584 vlan_tbl[vmap->param_id].rdctbl,
1585 vlan_tbl[vmap->param_id].rdctbl -
1586 p_cfgp->def_mac_rxdma_grpid,
1587 vlan_tbl[vmap->param_id].mpr_npr);
girish44961712006-11-22 11:47:19 -08001588 ((mblk_t *)np)->b_wptr += print_len;
1589 buf_len -= print_len;
1590 }
1591 }
1592
1593 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_vlan_rdcgrp"));
1594 return (0);
1595}
1596
girish44961712006-11-22 11:47:19 -08001597/* ARGSUSED */
1598static int
1599nxge_param_get_mac_rdcgrp(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001600 mblk_t *mp, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001601{
speera3c5bd62007-01-30 11:29:19 -08001602 uint_t print_len, buf_len;
1603 p_mblk_t np;
1604 int i;
girish44961712006-11-22 11:47:19 -08001605 p_nxge_class_pt_cfg_t p_class_cfgp;
1606 p_nxge_dma_pt_cfg_t p_dma_cfgp;
1607 p_nxge_hw_pt_cfg_t p_cfgp;
speera3c5bd62007-01-30 11:29:19 -08001608 nxge_mv_cfg_t *mac_host_info;
girish44961712006-11-22 11:47:19 -08001609
1610 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE * 32;
1611 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_mac_rdcgrp "));
1612 (void) mi_mpprintf(mp,
sowmini4045d942008-04-29 11:20:32 -07001613 "MAC ADDR RDC Mapping Information for Port\t %d\n",
1614 nxgep->function_num);
girish44961712006-11-22 11:47:19 -08001615
1616 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
1617 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
1618 return (0);
1619 }
1620
1621 buf_len = buff_alloc_size;
1622 mp->b_cont = np;
1623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
1624 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
1625 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
1626 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0];
1627 print_len = snprintf((char *)np->b_wptr, buf_len,
sowmini4045d942008-04-29 11:20:32 -07001628 "MAC ID\t RDC GRP (Actual/Port)\t"
1629 " Prefernce\n");
girish44961712006-11-22 11:47:19 -08001630 ((mblk_t *)np)->b_wptr += print_len;
1631 buf_len -= print_len;
1632 for (i = 0; i < p_cfgp->max_macs; i++) {
1633 if (mac_host_info[i].flag) {
1634 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
sowmini4045d942008-04-29 11:20:32 -07001635 buf_len,
1636 " %d\t %d/%d\t\t %d\n",
1637 i, mac_host_info[i].rdctbl,
1638 mac_host_info[i].rdctbl -
1639 p_cfgp->def_mac_rxdma_grpid,
1640 mac_host_info[i].mpr_npr);
girish44961712006-11-22 11:47:19 -08001641 ((mblk_t *)np)->b_wptr += print_len;
1642 buf_len -= print_len;
1643 }
1644 }
1645 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
sowmini4045d942008-04-29 11:20:32 -07001646 "Done Info Dumping \n");
girish44961712006-11-22 11:47:19 -08001647 ((mblk_t *)np)->b_wptr += print_len;
1648 buf_len -= print_len;
1649 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_macrdcgrp"));
1650 return (0);
1651}
1652
girish44961712006-11-22 11:47:19 -08001653/* ARGSUSED */
1654static int
1655nxge_param_tcam_enable(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001656 mblk_t *mp, char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001657{
speera3c5bd62007-01-30 11:29:19 -08001658 uint32_t status = 0, cfg_value;
1659 p_nxge_param_t pa = (p_nxge_param_t)cp;
1660 uint32_t cfg_it = B_FALSE;
1661 char *end;
girish44961712006-11-22 11:47:19 -08001662
1663 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_tcam_enable"));
1664
1665 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
1666 if (pa->value != cfg_value) {
1667 pa->old_value = pa->value;
1668 pa->value = cfg_value;
1669 cfg_it = B_TRUE;
1670 }
1671
1672 if (cfg_it == B_TRUE) {
1673 if (pa->value)
1674 status = nxge_fflp_config_tcam_enable(nxgep);
1675 else
1676 status = nxge_fflp_config_tcam_disable(nxgep);
1677 if (status != NXGE_OK)
1678 return (EINVAL);
1679 }
1680
1681 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_tcam_enable"));
1682 return (0);
1683}
1684
1685/* ARGSUSED */
1686static int
1687nxge_param_hash_lookup_enable(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001688 mblk_t *mp, char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001689{
speera3c5bd62007-01-30 11:29:19 -08001690 uint32_t status = 0, cfg_value;
1691 p_nxge_param_t pa = (p_nxge_param_t)cp;
1692 uint32_t cfg_it = B_FALSE;
1693 char *end;
girish44961712006-11-22 11:47:19 -08001694
1695 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_hash_lookup_enable"));
1696
1697 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
1698 if (pa->value != cfg_value) {
1699 pa->old_value = pa->value;
1700 pa->value = cfg_value;
1701 cfg_it = B_TRUE;
1702 }
1703
1704 if (cfg_it == B_TRUE) {
1705 if (pa->value)
1706 status = nxge_fflp_config_hash_lookup_enable(nxgep);
1707 else
1708 status = nxge_fflp_config_hash_lookup_disable(nxgep);
1709 if (status != NXGE_OK)
1710 return (EINVAL);
1711 }
1712
1713 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_hash_lookup_enable"));
1714 return (0);
1715}
1716
1717/* ARGSUSED */
1718static int
1719nxge_param_llc_snap_enable(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001720 mblk_t *mp, char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001721{
speera3c5bd62007-01-30 11:29:19 -08001722 char *end;
1723 uint32_t status = 0, cfg_value;
1724 p_nxge_param_t pa = (p_nxge_param_t)cp;
1725 uint32_t cfg_it = B_FALSE;
girish44961712006-11-22 11:47:19 -08001726
1727 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_llc_snap_enable"));
1728
1729 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
1730 if (pa->value != cfg_value) {
1731 pa->old_value = pa->value;
1732 pa->value = cfg_value;
1733 cfg_it = B_TRUE;
1734 }
1735
1736 if (cfg_it == B_TRUE) {
1737 if (pa->value)
1738 status = nxge_fflp_config_tcam_enable(nxgep);
1739 else
1740 status = nxge_fflp_config_tcam_disable(nxgep);
1741 if (status != NXGE_OK)
1742 return (EINVAL);
1743 }
1744
1745 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_llc_snap_enable"));
1746 return (0);
1747}
1748
girish44961712006-11-22 11:47:19 -08001749/* ARGSUSED */
girish44961712006-11-22 11:47:19 -08001750static int
1751nxge_param_set_ether_usr(p_nxge_t nxgep, queue_t *q,
Toomas Soomefe054a62017-08-08 22:36:50 +03001752 mblk_t *mp, char *value, caddr_t cp)
girish44961712006-11-22 11:47:19 -08001753{
speera3c5bd62007-01-30 11:29:19 -0800