xref: /onnv-gate/usr/src/uts/common/io/nxge/nxge_ndd.c (revision 4439:ba1f74c56e29)
13859Sml29623 /*
23859Sml29623  * CDDL HEADER START
33859Sml29623  *
43859Sml29623  * The contents of this file are subject to the terms of the
53859Sml29623  * Common Development and Distribution License (the "License").
63859Sml29623  * You may not use this file except in compliance with the License.
73859Sml29623  *
83859Sml29623  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93859Sml29623  * or http://www.opensolaris.org/os/licensing.
103859Sml29623  * See the License for the specific language governing permissions
113859Sml29623  * and limitations under the License.
123859Sml29623  *
133859Sml29623  * When distributing Covered Code, include this CDDL HEADER in each
143859Sml29623  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153859Sml29623  * If applicable, add the following below this CDDL HEADER, with the
163859Sml29623  * fields enclosed by brackets "[]" replaced with your own identifying
173859Sml29623  * information: Portions Copyright [yyyy] [name of copyright owner]
183859Sml29623  *
193859Sml29623  * CDDL HEADER END
203859Sml29623  */
213859Sml29623 /*
223859Sml29623  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
233859Sml29623  * Use is subject to license terms.
243859Sml29623  */
253859Sml29623 
263859Sml29623 #pragma ident	"%Z%%M%	%I%	%E% SMI"
273859Sml29623 
283859Sml29623 #include <sys/nxge/nxge_impl.h>
293859Sml29623 #include <inet/common.h>
303859Sml29623 #include <inet/mi.h>
313859Sml29623 #include <inet/nd.h>
323859Sml29623 
333859Sml29623 extern uint64_t npi_debug_level;
343859Sml29623 
353859Sml29623 #define	NXGE_PARAM_MAC_RW \
363859Sml29623 	NXGE_PARAM_RW | NXGE_PARAM_MAC | \
373859Sml29623 	NXGE_PARAM_NDD_WR_OK | NXGE_PARAM_READ_PROP
383859Sml29623 
393859Sml29623 #define	NXGE_PARAM_MAC_DONT_SHOW \
403859Sml29623 	NXGE_PARAM_RW | NXGE_PARAM_MAC | NXGE_PARAM_DONT_SHOW
413859Sml29623 
423859Sml29623 #define	NXGE_PARAM_RXDMA_RW \
433859Sml29623 	NXGE_PARAM_RWP | NXGE_PARAM_RXDMA | NXGE_PARAM_NDD_WR_OK | \
443859Sml29623 	NXGE_PARAM_READ_PROP
453859Sml29623 
463859Sml29623 #define	NXGE_PARAM_RXDMA_RWC \
473859Sml29623 	NXGE_PARAM_RWP | NXGE_PARAM_RXDMA | NXGE_PARAM_INIT_ONLY | \
483859Sml29623 	NXGE_PARAM_READ_PROP
493859Sml29623 
503859Sml29623 #define	NXGE_PARAM_L2CLASS_CFG \
513859Sml29623 	NXGE_PARAM_RW | NXGE_PARAM_PROP_ARR32 | NXGE_PARAM_READ_PROP | \
523859Sml29623 	NXGE_PARAM_NDD_WR_OK
533859Sml29623 
543859Sml29623 #define	NXGE_PARAM_CLASS_RWS \
553859Sml29623 	NXGE_PARAM_RWS |  NXGE_PARAM_READ_PROP
563859Sml29623 
573859Sml29623 #define	NXGE_PARAM_ARRAY_INIT_SIZE	0x20ULL
583859Sml29623 
593859Sml29623 #define	SET_RX_INTR_TIME_DISABLE 0
603859Sml29623 #define	SET_RX_INTR_TIME_ENABLE 1
613859Sml29623 #define	SET_RX_INTR_PKTS 2
623859Sml29623 
633859Sml29623 #define	BASE_ANY	0
643859Sml29623 #define	BASE_BINARY 	2
653859Sml29623 #define	BASE_HEX	16
663859Sml29623 #define	BASE_DECIMAL	10
673859Sml29623 #define	ALL_FF_64	0xFFFFFFFFFFFFFFFFULL
683859Sml29623 #define	ALL_FF_32	0xFFFFFFFFUL
693859Sml29623 
703859Sml29623 #define	NXGE_NDD_INFODUMP_BUFF_SIZE	2048 /* is 2k enough? */
713859Sml29623 #define	NXGE_NDD_INFODUMP_BUFF_8K	8192
723859Sml29623 #define	NXGE_NDD_INFODUMP_BUFF_16K	0x2000
733859Sml29623 #define	NXGE_NDD_INFODUMP_BUFF_64K	0x8000
743859Sml29623 
753859Sml29623 #define	PARAM_OUTOF_RANGE(vptr, eptr, rval, pa)	\
763859Sml29623 	((vptr == eptr) || (rval < pa->minimum) || (rval > pa->maximum))
773859Sml29623 
783859Sml29623 #define	ADVANCE_PRINT_BUFFER(pmp, plen, rlen) { \
793859Sml29623 	((mblk_t *)pmp)->b_wptr += plen; \
803859Sml29623 	rlen -= plen; \
813859Sml29623 }
823859Sml29623 
833859Sml29623 static int nxge_param_rx_intr_pkts(p_nxge_t, queue_t *,
843859Sml29623 	mblk_t *, char *, caddr_t);
853859Sml29623 static int nxge_param_rx_intr_time(p_nxge_t, queue_t *,
863859Sml29623 	mblk_t *, char *, caddr_t);
873859Sml29623 static int nxge_param_set_mac(p_nxge_t, queue_t *,
883859Sml29623 	mblk_t *, char *, caddr_t);
893859Sml29623 static int nxge_param_set_port_rdc(p_nxge_t, queue_t *,
903859Sml29623 	mblk_t *, char *, caddr_t);
913859Sml29623 static int nxge_param_set_grp_rdc(p_nxge_t, queue_t *,
923859Sml29623 	mblk_t *, char *, caddr_t);
933859Sml29623 static int nxge_param_set_ether_usr(p_nxge_t,
943859Sml29623 	queue_t *, mblk_t *, char *, caddr_t);
953859Sml29623 static int nxge_param_set_ip_usr(p_nxge_t,
963859Sml29623 	queue_t *, mblk_t *, char *, caddr_t);
973859Sml29623 static int nxge_param_set_ip_opt(p_nxge_t,
983859Sml29623 	queue_t *, mblk_t *, char *, caddr_t);
993859Sml29623 static int nxge_param_set_vlan_rdcgrp(p_nxge_t,
1003859Sml29623 	queue_t *, mblk_t *, char *, caddr_t);
1013859Sml29623 static int nxge_param_set_mac_rdcgrp(p_nxge_t,
1023859Sml29623 	queue_t *, mblk_t *, char *, caddr_t);
1033859Sml29623 static int nxge_param_fflp_hash_init(p_nxge_t,
1043859Sml29623 	queue_t *, mblk_t *, char *, caddr_t);
1053859Sml29623 static int nxge_param_llc_snap_enable(p_nxge_t, queue_t *,
1063859Sml29623 	mblk_t *, char *, caddr_t);
1073859Sml29623 static int nxge_param_hash_lookup_enable(p_nxge_t, queue_t *,
1083859Sml29623 	mblk_t *, char *, caddr_t);
1093859Sml29623 static int nxge_param_tcam_enable(p_nxge_t, queue_t *,
1103859Sml29623 	mblk_t *, char *, caddr_t);
1114185Sspeer static int nxge_param_get_fw_ver(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1123859Sml29623 static int nxge_param_get_rxdma_info(p_nxge_t, queue_t *q,
1133859Sml29623 	p_mblk_t, caddr_t);
1143859Sml29623 static int nxge_param_get_txdma_info(p_nxge_t, queue_t *q,
1153859Sml29623 	p_mblk_t, caddr_t);
1163859Sml29623 static int nxge_param_get_vlan_rdcgrp(p_nxge_t, queue_t *,
1173859Sml29623 	p_mblk_t, caddr_t);
1183859Sml29623 static int nxge_param_get_mac_rdcgrp(p_nxge_t, queue_t *,
1193859Sml29623 	p_mblk_t, caddr_t);
1203859Sml29623 static int nxge_param_get_rxdma_rdcgrp_info(p_nxge_t, queue_t *,
1213859Sml29623 	p_mblk_t, caddr_t);
1223859Sml29623 static int nxge_param_get_ip_opt(p_nxge_t, queue_t *, mblk_t *, caddr_t);
1233859Sml29623 static int nxge_param_get_mac(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
1243859Sml29623 static int nxge_param_get_debug_flag(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1253859Sml29623 static int nxge_param_set_nxge_debug_flag(p_nxge_t, queue_t *, mblk_t *,
1263859Sml29623 	char *, caddr_t);
1273859Sml29623 static int nxge_param_set_npi_debug_flag(p_nxge_t,
1283859Sml29623 	queue_t *, mblk_t *, char *, caddr_t);
1293859Sml29623 static int nxge_param_dump_rdc(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
1303859Sml29623 static int nxge_param_dump_tdc(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
1313859Sml29623 static int nxge_param_dump_mac_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1323859Sml29623 static int nxge_param_dump_ipp_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1333859Sml29623 static int nxge_param_dump_fflp_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1343859Sml29623 static int nxge_param_dump_vlan_table(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1353859Sml29623 static int nxge_param_dump_rdc_table(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1363859Sml29623 static int nxge_param_dump_ptrs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1373859Sml29623 static boolean_t nxge_param_link_update(p_nxge_t);
1383859Sml29623 
1393859Sml29623 /*
1403859Sml29623  * Global array of Neptune changable parameters.
1413859Sml29623  * This array is initialized to correspond to the default
1423859Sml29623  * Neptune 4 port configuration. This array would be copied
1433859Sml29623  * into each port's parameter structure and modifed per
1443859Sml29623  * fcode and nxge.conf configuration. Later, the parameters are
1453859Sml29623  * exported to ndd to display and run-time configuration (at least
1463859Sml29623  * some of them).
1473859Sml29623  *
1483859Sml29623  */
1493859Sml29623 
1503859Sml29623 static nxge_param_t	nxge_param_arr[] = {
1513859Sml29623 	/*
1523859Sml29623 	 * min	max	value	old	hw-name	conf-name
1533859Sml29623 	 */
154*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1553859Sml29623 		0, 999, 1000, 0, "instance", "instance"},
1563859Sml29623 
157*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1583859Sml29623 		0, 999, 1000, 0, "main-instance", "main_instance"},
1593859Sml29623 
1603859Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ,
1613859Sml29623 		0, 3, 0, 0, "function-number", "function_number"},
1623859Sml29623 
1633859Sml29623 	/* Partition Id */
164*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1653859Sml29623 		0, 8, 0, 0, "partition-id", "partition_id"},
1663859Sml29623 
1673859Sml29623 	/* Read Write Permission Mode */
168*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1693859Sml29623 		0, 2, 0, 0, "read-write-mode", "read_write_mode"},
1703859Sml29623 
1714185Sspeer 	{ nxge_param_get_fw_ver, NULL, NXGE_PARAM_READ,
1724185Sspeer 		0, 32, 0, 0, "version",	"fw_version"},
1734185Sspeer 
1743859Sml29623 	/* hw cfg types */
1753859Sml29623 	/* control the DMA config of Neptune/NIU */
176*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1773859Sml29623 		CFG_DEFAULT, CFG_CUSTOM, CFG_DEFAULT, CFG_DEFAULT,
1783859Sml29623 		"niu-cfg-type", "niu_cfg_type"},
1793859Sml29623 
1803859Sml29623 	/* control the TXDMA config of the Port controlled by tx-quick-cfg */
181*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1823859Sml29623 		CFG_DEFAULT, CFG_CUSTOM, CFG_NOT_SPECIFIED, CFG_DEFAULT,
1833859Sml29623 		"tx-qcfg-type", "tx_qcfg_type"},
1843859Sml29623 
1853859Sml29623 	/* control the RXDMA config of the Port controlled by rx-quick-cfg */
186*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1873859Sml29623 		CFG_DEFAULT, CFG_CUSTOM, CFG_NOT_SPECIFIED, CFG_DEFAULT,
1883859Sml29623 		"rx-qcfg-type", "rx_qcfg_type"},
1893859Sml29623 
1903859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac,
1913859Sml29623 		NXGE_PARAM_RW  | NXGE_PARAM_DONT_SHOW,
1923859Sml29623 		0, 1, 0, 0, "master-cfg-enable", "master_cfg_enable"},
1933859Sml29623 
1943859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac,
195*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
1963859Sml29623 		0, 1, 0, 0, "master-cfg-value", "master_cfg_value"},
1973859Sml29623 
1983859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
1993859Sml29623 		0, 1, 1, 1, "adv-autoneg-cap", "adv_autoneg_cap"},
2003859Sml29623 
2013859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2023859Sml29623 		0, 1, 1, 1, "adv-10gfdx-cap", "adv_10gfdx_cap"},
2033859Sml29623 
2043859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2053859Sml29623 		0, 1, 0, 0, "adv-10ghdx-cap", "adv_10ghdx_cap"},
2063859Sml29623 
2073859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2083859Sml29623 		0, 1, 1, 1, "adv-1000fdx-cap", "adv_1000fdx_cap"},
2093859Sml29623 
2103859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2113859Sml29623 		0, 1, 0, 0, "adv-1000hdx-cap",	"adv_1000hdx_cap"},
2123859Sml29623 
2133859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2143859Sml29623 		0, 1, 0, 0, "adv-100T4-cap", "adv_100T4_cap"},
2153859Sml29623 
2163859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2173859Sml29623 		0, 1, 1, 1, "adv-100fdx-cap", "adv_100fdx_cap"},
2183859Sml29623 
2193859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2203859Sml29623 		0, 1, 0, 0, "adv-100hdx-cap", "adv_100hdx_cap"},
2213859Sml29623 
2223859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2233859Sml29623 		0, 1, 1, 1, "adv-10fdx-cap", "adv_10fdx_cap"},
2243859Sml29623 
2253859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2263859Sml29623 		0, 1, 0, 0, "adv-10hdx-cap", "adv_10hdx_cap"},
2273859Sml29623 
228*4439Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2293859Sml29623 		0, 1, 0, 0, "adv-asmpause-cap",	"adv_asmpause_cap"},
2303859Sml29623 
2313859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2323859Sml29623 		0, 1, 0, 0, "adv-pause-cap", "adv_pause_cap"},
2333859Sml29623 
234*4439Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2353859Sml29623 		0, 1, 0, 0, "use-int-xcvr", "use_int_xcvr"},
2363859Sml29623 
237*4439Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2383859Sml29623 		0, 1, 1, 1, "enable-ipg0", "enable_ipg0"},
2393859Sml29623 
240*4439Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2413859Sml29623 		0, 255,	8, 8, "ipg0", "ipg0"},
2423859Sml29623 
243*4439Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2443859Sml29623 		0, 255,	8, 8, "ipg1", "ipg1"},
2453859Sml29623 
246*4439Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2473859Sml29623 		0, 255,	4, 4, "ipg2", "ipg2"},
2483859Sml29623 
2493859Sml29623 	{ nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2503859Sml29623 		0, 1, 0, 0, "accept-jumbo", "accept_jumbo"},
2513859Sml29623 
2523859Sml29623 	/* Transmit DMA channels */
253*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ |
254*4439Sml29623 		NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2553859Sml29623 		0, 3, 0, 0, "tx-dma-weight", "tx_dma_weight"},
2563859Sml29623 
257*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ |
258*4439Sml29623 		NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2593859Sml29623 		0, 31, 0, 0, "tx-dma-channels-begin", "tx_dma_channels_begin"},
2603859Sml29623 
261*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ |
262*4439Sml29623 		NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2633859Sml29623 		0, 32, 0, 0, "tx-dma-channels", "tx_dma_channels"},
2643859Sml29623 	{ nxge_param_get_txdma_info, NULL,
265*4439Sml29623 		NXGE_PARAM_READ | NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2663859Sml29623 		0, 32, 0, 0, "tx-dma-info", "tx_dma_info"},
2673859Sml29623 
2683859Sml29623 	/* Receive DMA channels */
2693859Sml29623 	{ nxge_param_get_generic, NULL,
270*4439Sml29623 		NXGE_PARAM_READ | NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2713859Sml29623 		0, 31, 0, 0, "rx-dma-channels-begin", "rx_dma_channels_begin"},
2723859Sml29623 
273*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ |
274*4439Sml29623 		NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2753859Sml29623 		0, 32, 0, 0, "rx-dma-channels",	"rx_dma_channels"},
2763859Sml29623 
277*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ |
278*4439Sml29623 		NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2793859Sml29623 		0, 65535, PT_DRR_WT_DEFAULT_10G, 0,
2803859Sml29623 		"rx-drr-weight", "rx_drr_weight"},
2813859Sml29623 
282*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ |
283*4439Sml29623 		NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2843859Sml29623 		0, 1, 1, 0, "rx-full-header", "rx_full_header"},
2853859Sml29623 
286*4439Sml29623 	{ nxge_param_get_rxdma_info, NULL, NXGE_PARAM_READ |
287*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
2883859Sml29623 		0, 32, 0, 0, "rx-dma-info", "rx_dma_info"},
2893859Sml29623 
2903859Sml29623 	{ nxge_param_get_rxdma_info, NULL,
2913859Sml29623 		NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
2923859Sml29623 		NXGE_RBR_RBB_MIN, NXGE_RBR_RBB_MAX, NXGE_RBR_RBB_DEFAULT, 0,
2933859Sml29623 		"rx-rbr-size", "rx_rbr_size"},
2943859Sml29623 
2953859Sml29623 	{ nxge_param_get_rxdma_info, NULL,
2963859Sml29623 		NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
2973859Sml29623 		NXGE_RCR_MIN, NXGE_RCR_MAX, NXGE_RCR_DEFAULT, 0,
2983859Sml29623 		"rx-rcr-size", "rx_rcr_size"},
2993859Sml29623 
300*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_port_rdc,
301*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3023859Sml29623 		0, 15, 0, 0, "default-port-rdc", "default_port_rdc"},
3033859Sml29623 
3043859Sml29623 	{ nxge_param_get_generic, nxge_param_rx_intr_time, NXGE_PARAM_RXDMA_RW,
3053859Sml29623 		NXGE_RDC_RCR_TIMEOUT_MIN, NXGE_RDC_RCR_TIMEOUT_MAX,
3063859Sml29623 		RXDMA_RCR_TO_DEFAULT, 0, "rxdma-intr-time", "rxdma_intr_time"},
3073859Sml29623 
3083859Sml29623 	{ nxge_param_get_generic, nxge_param_rx_intr_pkts, NXGE_PARAM_RXDMA_RW,
3093859Sml29623 		NXGE_RDC_RCR_THRESHOLD_MIN, NXGE_RDC_RCR_THRESHOLD_MAX,
3103859Sml29623 		RXDMA_RCR_PTHRES_DEFAULT, 0,
3113859Sml29623 		"rxdma-intr-pkts", "rxdma_intr_pkts"},
3123859Sml29623 
313*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ_PROP |
314*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
3153859Sml29623 		0, 8, 0, 0, "rx-rdc-grps-begin", "rx_rdc_grps_begin"},
3163859Sml29623 
317*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ_PROP |
318*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
3193859Sml29623 		0, 8, 0, 0, "rx-rdc-grps", "rx_rdc_grps"},
3203859Sml29623 
321*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_grp_rdc,
322*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3233859Sml29623 		0, 15, 0, 0, "default-grp0-rdc", "default_grp0_rdc"},
3243859Sml29623 
325*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_grp_rdc,
326*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3273859Sml29623 		0, 15,	2, 0, "default-grp1-rdc", "default_grp1_rdc"},
3283859Sml29623 
329*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_grp_rdc,
330*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3313859Sml29623 		0, 15, 4, 0, "default-grp2-rdc", "default_grp2_rdc"},
3323859Sml29623 
333*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_grp_rdc,
334*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3353859Sml29623 		0, 15, 6, 0, "default-grp3-rdc", "default_grp3_rdc"},
3363859Sml29623 
337*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_grp_rdc,
338*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3393859Sml29623 		0, 15, 8, 0, "default-grp4-rdc", "default_grp4_rdc"},
3403859Sml29623 
341*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_grp_rdc,
342*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3433859Sml29623 		0, 15, 10, 0, "default-grp5-rdc", "default_grp5_rdc"},
3443859Sml29623 
345*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_grp_rdc,
346*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3473859Sml29623 		0, 15, 12, 0, "default-grp6-rdc", "default_grp6_rdc"},
3483859Sml29623 
349*4439Sml29623 	{ nxge_param_get_generic, nxge_param_set_grp_rdc,
350*4439Sml29623 		NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3513859Sml29623 		0, 15, 14, 0, "default-grp7-rdc", "default_grp7_rdc"},
3523859Sml29623 
3533859Sml29623 	{ nxge_param_get_rxdma_rdcgrp_info, NULL,
354*4439Sml29623 		NXGE_PARAM_READ | NXGE_PARAM_CMPLX | NXGE_PARAM_DONT_SHOW,
3553859Sml29623 		0, 8, 0, 0, "rdc-groups-info", "rdc_groups_info"},
3563859Sml29623 
3573859Sml29623 	/* Logical device groups */
358*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
3593859Sml29623 		0, 63, 0, 0, "start-ldg", "start_ldg"},
3603859Sml29623 
361*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
3623859Sml29623 		0, 64, 0, 0, "max-ldg", "max_ldg" },
3633859Sml29623 
3643859Sml29623 	/* MAC table information */
3653859Sml29623 	{ nxge_param_get_mac_rdcgrp, nxge_param_set_mac_rdcgrp,
366*4439Sml29623 		NXGE_PARAM_L2CLASS_CFG | NXGE_PARAM_DONT_SHOW,
3673859Sml29623 		0, 31, 0, 0, "mac-2rdc-grp", "mac_2rdc_grp"},
3683859Sml29623 
3693859Sml29623 	/* VLAN table information */
3703859Sml29623 	{ nxge_param_get_vlan_rdcgrp, nxge_param_set_vlan_rdcgrp,
371*4439Sml29623 		NXGE_PARAM_L2CLASS_CFG | NXGE_PARAM_DONT_SHOW,
3723859Sml29623 		0, 31, 0, 0, "vlan-2rdc-grp", "vlan_2rdc_grp"},
3733859Sml29623 
3743859Sml29623 	{ nxge_param_get_generic, NULL,
375*4439Sml29623 		NXGE_PARAM_READ_PROP | NXGE_PARAM_READ |
376*4439Sml29623 		NXGE_PARAM_PROP_ARR32 | NXGE_PARAM_DONT_SHOW,
3773859Sml29623 		0, 0x0ffff, 0x0ffff, 0, "fcram-part-cfg", "fcram_part_cfg"},
3783859Sml29623 
379*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_CLASS_RWS |
380*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
3813859Sml29623 		0, 0x10, 0xa, 0, "fcram-access-ratio", "fcram_access_ratio"},
3823859Sml29623 
383*4439Sml29623 	{ nxge_param_get_generic, NULL, NXGE_PARAM_CLASS_RWS |
384*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
3853859Sml29623 		0, 0x10, 0xa, 0, "tcam-access-ratio", "tcam_access_ratio"},
3863859Sml29623 
3873859Sml29623 	{ nxge_param_get_generic, nxge_param_tcam_enable,
388*4439Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
3893859Sml29623 		0, 0x1, 0x0, 0, "tcam-enable", "tcam_enable"},
3903859Sml29623 
3913859Sml29623 	{ nxge_param_get_generic, nxge_param_hash_lookup_enable,
392*4439Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
3933859Sml29623 		0, 0x01, 0x0, 0, "hash-lookup-enable", "hash_lookup_enable"},
3943859Sml29623 
3953859Sml29623 	{ nxge_param_get_generic, nxge_param_llc_snap_enable,
396*4439Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
3973859Sml29623 		0, 0x01, 0x01, 0, "llc-snap-enable", "llc_snap_enable"},
3983859Sml29623 
3993859Sml29623 	{ nxge_param_get_generic, nxge_param_fflp_hash_init,
400*4439Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4013859Sml29623 		0, ALL_FF_32, ALL_FF_32, 0, "h1-init-value", "h1_init_value"},
4023859Sml29623 
4033859Sml29623 	{ nxge_param_get_generic,	nxge_param_fflp_hash_init,
404*4439Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4053859Sml29623 		0, 0x0ffff, 0x0ffff, 0, "h2-init-value", "h2_init_value"},
4063859Sml29623 
4073859Sml29623 	{ nxge_param_get_generic, nxge_param_set_ether_usr,
4083859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4093859Sml29623 		0, ALL_FF_32, 0x0, 0,
4103859Sml29623 		"class-cfg-ether-usr1", "class_cfg_ether_usr1"},
4113859Sml29623 
4123859Sml29623 	{ nxge_param_get_generic, nxge_param_set_ether_usr,
4133859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4143859Sml29623 		0, ALL_FF_32, 0x0, 0,
4153859Sml29623 		"class-cfg-ether-usr2", "class_cfg_ether_usr2"},
4163859Sml29623 
4173859Sml29623 	{ nxge_param_get_generic, nxge_param_set_ip_usr,
4183859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4193859Sml29623 		0, ALL_FF_32, 0x0, 0,
4203859Sml29623 		"class-cfg-ip-usr4", "class_cfg_ip_usr4"},
4213859Sml29623 
4223859Sml29623 	{ nxge_param_get_generic, nxge_param_set_ip_usr,
4233859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4243859Sml29623 		0, ALL_FF_32, 0x0, 0,
4253859Sml29623 		"class-cfg-ip-usr5", "class_cfg_ip_usr5"},
4263859Sml29623 
4273859Sml29623 	{ nxge_param_get_generic, nxge_param_set_ip_usr,
4283859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4293859Sml29623 		0, ALL_FF_32, 0x0, 0,
4303859Sml29623 		"class-cfg-ip-usr6", "class_cfg_ip_usr6"},
4313859Sml29623 
4323859Sml29623 	{ nxge_param_get_generic, nxge_param_set_ip_usr,
4333859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4343859Sml29623 		0, ALL_FF_32, 0x0, 0,
4353859Sml29623 		"class-cfg-ip-usr7", "class_cfg_ip_usr7"},
4363859Sml29623 
4373859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4383859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4393859Sml29623 		0, ALL_FF_32, 0x0, 0,
4403859Sml29623 		"class-opt-ip-usr4", "class_opt_ip_usr4"},
4413859Sml29623 
4423859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4433859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4443859Sml29623 		0, ALL_FF_32, 0x0, 0,
4453859Sml29623 		"class-opt-ip-usr5", "class_opt_ip_usr5"},
4463859Sml29623 
4473859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4483859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4493859Sml29623 		0, ALL_FF_32, 0x0, 0,
4503859Sml29623 		"class-opt-ip-usr6", "class_opt_ip_usr6"},
4513859Sml29623 
4523859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4533859Sml29623 		NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4543859Sml29623 		0, ALL_FF_32, 0x0, 0,
4553859Sml29623 		"class-opt-ip-usr7", "class_opt_ip_usr7"},
4563859Sml29623 
4573859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4583859Sml29623 		NXGE_PARAM_CLASS_RWS,
4593859Sml29623 		0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4603859Sml29623 		"class-opt-ipv4-tcp", "class_opt_ipv4_tcp"},
4613859Sml29623 
4623859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4633859Sml29623 		NXGE_PARAM_CLASS_RWS,
4643859Sml29623 		0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4653859Sml29623 		"class-opt-ipv4-udp", "class_opt_ipv4_udp"},
4663859Sml29623 
4673859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4683859Sml29623 		NXGE_PARAM_CLASS_RWS,
4693859Sml29623 		0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4703859Sml29623 		"class-opt-ipv4-ah", "class_opt_ipv4_ah"},
4713859Sml29623 
4723859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4733859Sml29623 		NXGE_PARAM_CLASS_RWS,
4743859Sml29623 		0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4753859Sml29623 		"class-opt-ipv4-sctp", "class_opt_ipv4_sctp"},
4763859Sml29623 
4773859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
4783859Sml29623 		0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4793859Sml29623 		"class-opt-ipv6-tcp", "class_opt_ipv6_tcp"},
4803859Sml29623 
4813859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
4823859Sml29623 		0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4833859Sml29623 		"class-opt-ipv6-udp", "class_opt_ipv6_udp"},
4843859Sml29623 
4853859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
4863859Sml29623 		0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4873859Sml29623 		"class-opt-ipv6-ah", "class_opt_ipv6_ah"},
4883859Sml29623 
4893859Sml29623 	{ nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
4903859Sml29623 		0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4913859Sml29623 		"class-opt-ipv6-sctp",	"class_opt_ipv6_sctp"},
4923859Sml29623 
4933859Sml29623 	{ nxge_param_get_debug_flag, nxge_param_set_nxge_debug_flag,
494*4439Sml29623 		NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW,
4953859Sml29623 		0ULL, ALL_FF_64, 0ULL, 0ULL,
4963859Sml29623 		"nxge-debug-flag", "nxge_debug_flag"},
4973859Sml29623 
4983859Sml29623 	{ nxge_param_get_debug_flag, nxge_param_set_npi_debug_flag,
499*4439Sml29623 		NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW,
5003859Sml29623 		0ULL, ALL_FF_64, 0ULL, 0ULL,
5013859Sml29623 		"npi-debug-flag", "npi_debug_flag"},
5023859Sml29623 
503*4439Sml29623 	{ nxge_param_dump_tdc, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
5043859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0, "dump-tdc", "dump_tdc"},
5053859Sml29623 
506*4439Sml29623 	{ nxge_param_dump_rdc, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
5073859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0, "dump-rdc", "dump_rdc"},
5083859Sml29623 
509*4439Sml29623 	{ nxge_param_dump_mac_regs, NULL, NXGE_PARAM_READ |
510*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
5113859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0, "dump-mac-regs", "dump_mac_regs"},
5123859Sml29623 
513*4439Sml29623 	{ nxge_param_dump_ipp_regs, NULL, NXGE_PARAM_READ |
514*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
5153859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0, "dump-ipp-regs", "dump_ipp_regs"},
5163859Sml29623 
517*4439Sml29623 	{ nxge_param_dump_fflp_regs, NULL, NXGE_PARAM_READ |
518*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
5193859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0,
5203859Sml29623 		"dump-fflp-regs", "dump_fflp_regs"},
5213859Sml29623 
522*4439Sml29623 	{ nxge_param_dump_vlan_table, NULL, NXGE_PARAM_READ |
523*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
5243859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0,
5253859Sml29623 		"dump-vlan-table", "dump_vlan_table"},
5263859Sml29623 
527*4439Sml29623 	{ nxge_param_dump_rdc_table, NULL, NXGE_PARAM_READ |
528*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
5293859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0,
5303859Sml29623 		"dump-rdc-table", "dump_rdc_table"},
5313859Sml29623 
532*4439Sml29623 	{ nxge_param_dump_ptrs,	NULL, NXGE_PARAM_READ |
533*4439Sml29623 		NXGE_PARAM_DONT_SHOW,
5343859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0, "dump-ptrs", "dump_ptrs"},
5353859Sml29623 
5363859Sml29623 	{  NULL, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
5373859Sml29623 		0, 0x0fffffff, 0x0fffffff, 0, "end", "end"},
5383859Sml29623 };
5393859Sml29623 
5403859Sml29623 extern void 		*nxge_list;
5413859Sml29623 
5423859Sml29623 void
5433859Sml29623 nxge_get_param_soft_properties(p_nxge_t nxgep)
5443859Sml29623 {
5453859Sml29623 
5463859Sml29623 	p_nxge_param_t 		param_arr;
5473859Sml29623 	uint_t 			prop_len;
5483859Sml29623 	int 			i, j;
5493859Sml29623 	uint32_t		param_count;
5503859Sml29623 	uint32_t		*int_prop_val;
5513859Sml29623 
5523859Sml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, " ==> nxge_get_param_soft_properties"));
5533859Sml29623 
5543859Sml29623 	param_arr = nxgep->param_arr;
5553859Sml29623 	param_count = nxgep->param_count;
5563859Sml29623 	for (i = 0; i < param_count; i++) {
5573859Sml29623 		if ((param_arr[i].type & NXGE_PARAM_READ_PROP) == 0)
5583859Sml29623 			continue;
5593859Sml29623 		if ((param_arr[i].type & NXGE_PARAM_PROP_STR))
5603859Sml29623 			continue;
5613859Sml29623 		if ((param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
5623859Sml29623 				(param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
5633859Sml29623 			if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY,
5643859Sml29623 					nxgep->dip, 0, param_arr[i].fcode_name,
5653859Sml29623 					(int **)&int_prop_val,
5663859Sml29623 					(uint_t *)&prop_len)
5673859Sml29623 					== DDI_PROP_SUCCESS) {
5683859Sml29623 				uint32_t *cfg_value;
5693859Sml29623 				uint64_t prop_count;
5703859Sml29623 
5713859Sml29623 				if (prop_len > NXGE_PARAM_ARRAY_INIT_SIZE)
5723859Sml29623 					prop_len = NXGE_PARAM_ARRAY_INIT_SIZE;
5733859Sml29623 				cfg_value = (uint32_t *)param_arr[i].value;
5743859Sml29623 				for (j = 0; j < prop_len; j++) {
5753859Sml29623 					cfg_value[j] = int_prop_val[j];
5763859Sml29623 				}
5773859Sml29623 				prop_count = prop_len;
5783859Sml29623 				param_arr[i].type |=
5793859Sml29623 				    (prop_count << NXGE_PARAM_ARRAY_CNT_SHIFT);
5803859Sml29623 				ddi_prop_free(int_prop_val);
5813859Sml29623 			}
5823859Sml29623 			continue;
5833859Sml29623 		}
5843859Sml29623 
5853859Sml29623 		if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
5863859Sml29623 				param_arr[i].fcode_name,
5873859Sml29623 				(int **)&int_prop_val,
5883859Sml29623 				&prop_len) == DDI_PROP_SUCCESS) {
5893859Sml29623 			if ((*int_prop_val >= param_arr[i].minimum) &&
5903859Sml29623 					(*int_prop_val <= param_arr[i].maximum))
5913859Sml29623 				param_arr[i].value = *int_prop_val;
5923859Sml29623 #ifdef NXGE_DEBUG_ERROR
5933859Sml29623 			else {
5943859Sml29623 				NXGE_DEBUG_MSG((nxgep, OBP_CTL,
5953859Sml29623 					"nxge%d: 'prom' file parameter error\n",
5963859Sml29623 					nxgep->instance));
5973859Sml29623 				NXGE_DEBUG_MSG((nxgep, OBP_CTL,
5983859Sml29623 					"Parameter keyword '%s'"
5993859Sml29623 					" is outside valid range\n",
6003859Sml29623 					param_arr[i].name));
6013859Sml29623 			}
6023859Sml29623 #endif
6033859Sml29623 			ddi_prop_free(int_prop_val);
6043859Sml29623 		}
6053859Sml29623 
6063859Sml29623 		if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
6073859Sml29623 				param_arr[i].name,
6083859Sml29623 				(int **)&int_prop_val,
6093859Sml29623 				&prop_len) == DDI_PROP_SUCCESS) {
6103859Sml29623 			if ((*int_prop_val >= param_arr[i].minimum) &&
6113859Sml29623 				(*int_prop_val <= param_arr[i].maximum))
6123859Sml29623 				param_arr[i].value = *int_prop_val;
6133859Sml29623 #ifdef NXGE_DEBUG_ERROR
6143859Sml29623 			else {
6153859Sml29623 				NXGE_DEBUG_MSG((nxgep, OBP_CTL,
6163859Sml29623 					"nxge%d: 'conf' file parameter error\n",
6173859Sml29623 					nxgep->instance));
6183859Sml29623 				NXGE_DEBUG_MSG((nxgep, OBP_CTL,
6193859Sml29623 					"Parameter keyword '%s'"
6203859Sml29623 					"is outside valid range\n",
6213859Sml29623 					param_arr[i].name));
6223859Sml29623 			}
6233859Sml29623 #endif
6243859Sml29623 			ddi_prop_free(int_prop_val);
6253859Sml29623 		}
6263859Sml29623 	}
6273859Sml29623 }
6283859Sml29623 
6293859Sml29623 static int
6303859Sml29623 nxge_private_param_register(p_nxge_t nxgep, p_nxge_param_t param_arr)
6313859Sml29623 {
6323859Sml29623 	int status = B_TRUE;
6333859Sml29623 	int channel;
6343859Sml29623 	uint8_t grp;
6353859Sml29623 	char *prop_name;
6363859Sml29623 	char *end;
6373859Sml29623 	uint32_t name_chars;
6383859Sml29623 
6393859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
6403859Sml29623 		"nxge_private_param_register %s", param_arr->name));
6413859Sml29623 
6423859Sml29623 	if ((param_arr->type & NXGE_PARAM_PRIV) != NXGE_PARAM_PRIV)
6433859Sml29623 		return (B_TRUE);
6443859Sml29623 
6453859Sml29623 	prop_name =  param_arr->name;
6463859Sml29623 	if (param_arr->type & NXGE_PARAM_RXDMA) {
6473859Sml29623 		if (strncmp("rxdma_intr", prop_name, 10) == 0)
6483859Sml29623 			return (B_TRUE);
6493859Sml29623 		name_chars = strlen("default_grp");
6503859Sml29623 		if (strncmp("default_grp", prop_name, name_chars) == 0) {
6513859Sml29623 			prop_name += name_chars;
6523859Sml29623 			grp = mi_strtol(prop_name, &end, 10);
6533859Sml29623 				/* now check if this rdcgrp is in config */
6543859Sml29623 			return (nxge_check_rdcgrp_port_member(nxgep, grp));
6553859Sml29623 		}
6563859Sml29623 		name_chars = strlen(prop_name);
6573859Sml29623 		if (strncmp("default_port_rdc", prop_name, name_chars) == 0) {
6583859Sml29623 			return (B_TRUE);
6593859Sml29623 		}
6603859Sml29623 		return (B_FALSE);
6613859Sml29623 	}
6623859Sml29623 
6633859Sml29623 	if (param_arr->type & NXGE_PARAM_TXDMA) {
6643859Sml29623 		name_chars = strlen("txdma");
6653859Sml29623 		if (strncmp("txdma", prop_name, name_chars) == 0) {
6663859Sml29623 			prop_name += name_chars;
6673859Sml29623 			channel = mi_strtol(prop_name, &end, 10);
6683859Sml29623 				/* now check if this rdc is in config */
6693859Sml29623 			NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
6703859Sml29623 					    " nxge_private_param_register: %d",
6713859Sml29623 					    channel));
6723859Sml29623 			return (nxge_check_txdma_port_member(nxgep, channel));
6733859Sml29623 		}
6743859Sml29623 		return (B_FALSE);
6753859Sml29623 	}
6763859Sml29623 
6773859Sml29623 	status = B_FALSE;
6783859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD2_CTL, "<== nxge_private_param_register"));
6793859Sml29623 
6803859Sml29623 	return (status);
6813859Sml29623 }
6823859Sml29623 
6833859Sml29623 void
6843859Sml29623 nxge_setup_param(p_nxge_t nxgep)
6853859Sml29623 {
6863859Sml29623 	p_nxge_param_t param_arr;
6873859Sml29623 	int i;
6883859Sml29623 	pfi_t set_pfi;
6893859Sml29623 
6903859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_setup_param"));
6913859Sml29623 
6923859Sml29623 	/*
6933859Sml29623 	 * Make sure the param_instance is set to a valid device instance.
6943859Sml29623 	 */
6953859Sml29623 	if (nxge_param_arr[param_instance].value == 1000)
6963859Sml29623 		nxge_param_arr[param_instance].value = nxgep->instance;
6973859Sml29623 
6983859Sml29623 	param_arr = nxgep->param_arr;
6993859Sml29623 	param_arr[param_instance].value = nxgep->instance;
7003859Sml29623 	param_arr[param_function_number].value = nxgep->function_num;
7013859Sml29623 
7023859Sml29623 	for (i = 0; i < nxgep->param_count; i++) {
7033859Sml29623 		if ((param_arr[i].type & NXGE_PARAM_PRIV) &&
7043859Sml29623 				(nxge_private_param_register(nxgep,
7053859Sml29623 				&param_arr[i]) == B_FALSE)) {
7063859Sml29623 			param_arr[i].setf = NULL;
7073859Sml29623 			param_arr[i].getf = NULL;
7083859Sml29623 		}
7093859Sml29623 
7103859Sml29623 		if (param_arr[i].type & NXGE_PARAM_CMPLX)
7113859Sml29623 			param_arr[i].setf = NULL;
7123859Sml29623 
7133859Sml29623 		if (param_arr[i].type & NXGE_PARAM_DONT_SHOW) {
7143859Sml29623 			param_arr[i].setf = NULL;
7153859Sml29623 			param_arr[i].getf = NULL;
7163859Sml29623 		}
7173859Sml29623 
7183859Sml29623 		set_pfi = (pfi_t)param_arr[i].setf;
7193859Sml29623 
7203859Sml29623 		if ((set_pfi) && (param_arr[i].type & NXGE_PARAM_INIT_ONLY)) {
7213859Sml29623 			set_pfi = NULL;
7223859Sml29623 		}
7233859Sml29623 
7243859Sml29623 		if (!nxge_nd_load(&nxgep->param_list, param_arr[i].name,
7253859Sml29623 				(pfi_t)param_arr[i].getf, set_pfi,
7263859Sml29623 				(caddr_t)&param_arr[i])) {
7273859Sml29623 			(void) nxge_nd_free(&nxgep->param_list);
7283859Sml29623 			break;
7293859Sml29623 		}
7303859Sml29623 	}
7313859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_setup_param"));
7323859Sml29623 }
7333859Sml29623 
7343859Sml29623 void
7353859Sml29623 nxge_init_param(p_nxge_t nxgep)
7363859Sml29623 {
7373859Sml29623 	p_nxge_param_t param_arr;
7383859Sml29623 	int i, alloc_size;
7393859Sml29623 	uint64_t alloc_count;
7403859Sml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_init_param"));
7413859Sml29623 	/*
7423859Sml29623 	 * Make sure the param_instance is set to a valid device instance.
7433859Sml29623 	 */
7443859Sml29623 	if (nxge_param_arr[param_instance].value == 1000)
7453859Sml29623 		nxge_param_arr[param_instance].value = nxgep->instance;
7463859Sml29623 
7473859Sml29623 	param_arr = nxgep->param_arr;
7483859Sml29623 	if (param_arr == NULL) {
7493859Sml29623 		param_arr = (p_nxge_param_t)
7503859Sml29623 			KMEM_ZALLOC(sizeof (nxge_param_arr), KM_SLEEP);
7513859Sml29623 	}
7523859Sml29623 
7533859Sml29623 	for (i = 0; i < sizeof (nxge_param_arr)/sizeof (nxge_param_t); i++) {
7543859Sml29623 		param_arr[i] = nxge_param_arr[i];
7553859Sml29623 		if ((param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
7563859Sml29623 			(param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
7573859Sml29623 			alloc_count = NXGE_PARAM_ARRAY_INIT_SIZE;
7583859Sml29623 			alloc_size = alloc_count * sizeof (uint64_t);
7593859Sml29623 			param_arr[i].value =
7603859Sml29623 			    (uint64_t)KMEM_ZALLOC(alloc_size, KM_SLEEP);
7613859Sml29623 			param_arr[i].old_value =
7623859Sml29623 				    (uint64_t)KMEM_ZALLOC(alloc_size, KM_SLEEP);
7633859Sml29623 			param_arr[i].type |=
7643859Sml29623 				(alloc_count << NXGE_PARAM_ARRAY_ALLOC_SHIFT);
7653859Sml29623 		}
7663859Sml29623 	}
7673859Sml29623 
7683859Sml29623 	nxgep->param_arr = param_arr;
7693859Sml29623 	nxgep->param_count = sizeof (nxge_param_arr)/sizeof (nxge_param_t);
7703859Sml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_init_param: count %d",
7713859Sml29623 		nxgep->param_count));
7723859Sml29623 }
7733859Sml29623 
7743859Sml29623 void
7753859Sml29623 nxge_destroy_param(p_nxge_t nxgep)
7763859Sml29623 {
7773859Sml29623 	int i;
7783859Sml29623 	uint64_t free_size, free_count;
7793859Sml29623 
7803859Sml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_destroy_param"));
7813859Sml29623 
7823859Sml29623 	/*
7833859Sml29623 	 * Make sure the param_instance is set to a valid device instance.
7843859Sml29623 	 */
7853859Sml29623 	if (nxge_param_arr[param_instance].value == nxgep->instance) {
7863859Sml29623 		for (i = 0; i <= nxge_param_arr[param_instance].maximum; i++) {
7873859Sml29623 			if ((ddi_get_soft_state(nxge_list, i) != NULL) &&
7883859Sml29623 				(i != nxgep->instance))
7893859Sml29623 				break;
7903859Sml29623 		}
7913859Sml29623 		nxge_param_arr[param_instance].value = i;
7923859Sml29623 	}
7933859Sml29623 
7943859Sml29623 	if (nxgep->param_list)
7953859Sml29623 		nxge_nd_free(&nxgep->param_list);
7963859Sml29623 	for (i = 0; i < nxgep->param_count; i++)
7973859Sml29623 		if ((nxgep->param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
7983859Sml29623 			(nxgep->param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
7993859Sml29623 			free_count = ((nxgep->param_arr[i].type &
8003859Sml29623 					    NXGE_PARAM_ARRAY_ALLOC_MASK) >>
8013859Sml29623 					    NXGE_PARAM_ARRAY_ALLOC_SHIFT);
8023859Sml29623 			free_count = NXGE_PARAM_ARRAY_INIT_SIZE;
8033859Sml29623 			free_size = sizeof (uint64_t) * free_count;
8043859Sml29623 			KMEM_FREE((void *)nxgep->param_arr[i].value, free_size);
8053859Sml29623 			KMEM_FREE((void *)nxgep->param_arr[i].old_value,
8063859Sml29623 				free_size);
8073859Sml29623 		}
8083859Sml29623 
8093859Sml29623 	KMEM_FREE(nxgep->param_arr, sizeof (nxge_param_arr));
8103859Sml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_destroy_param"));
8113859Sml29623 }
8123859Sml29623 
8133859Sml29623 /*
8143859Sml29623  * Extracts the value from the 'nxge' parameter array and prints the
8153859Sml29623  * parameter value. cp points to the required parameter.
8163859Sml29623  */
8173859Sml29623 
8183859Sml29623 /* ARGSUSED */
8193859Sml29623 int
8203859Sml29623 nxge_param_get_generic(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
8213859Sml29623 {
8223859Sml29623 	p_nxge_param_t pa = (p_nxge_param_t)cp;
8233859Sml29623 
8243859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL,
8253859Sml29623 		"==> nxge_param_get_generic name %s ", pa->name));
8263859Sml29623 
8273859Sml29623 	if (pa->value > 0xffffffff)
8283859Sml29623 		(void) mi_mpprintf(mp, "%x%x",
8293859Sml29623 			(int)(pa->value >> 32), (int)(pa->value & 0xffffffff));
8303859Sml29623 	else
8313859Sml29623 		(void) mi_mpprintf(mp, "%x", (int)pa->value);
8323859Sml29623 
8333859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_generic"));
8343859Sml29623 	return (0);
8353859Sml29623 }
8363859Sml29623 
8373859Sml29623 /* ARGSUSED */
8383859Sml29623 static int
8393859Sml29623 nxge_param_get_mac(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
8403859Sml29623 {
8413859Sml29623 	p_nxge_param_t pa = (p_nxge_param_t)cp;
8423859Sml29623 
8433859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_mac"));
8443859Sml29623 
8453859Sml29623 	(void) mi_mpprintf(mp, "%d", (uint32_t)pa->value);
8463859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_mac"));
8473859Sml29623 	return (0);
8483859Sml29623 }
8493859Sml29623 
8503859Sml29623 /* ARGSUSED */
8514185Sspeer static int
8524185Sspeer nxge_param_get_fw_ver(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
8534185Sspeer {
8544185Sspeer 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_fw_ver"));
8554185Sspeer 
8564185Sspeer 	(void) mi_mpprintf(mp, "Firmware version for nxge%d:  %s\n",
8574185Sspeer 	    nxgep->instance, nxgep->vpd_info.ver);
8584185Sspeer 
8594185Sspeer 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_fw_ver"));
8604185Sspeer 	return (0);
8614185Sspeer }
8624185Sspeer 
8634185Sspeer /* ARGSUSED */
8643859Sml29623 int
8653859Sml29623 nxge_param_get_txdma_info(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
8663859Sml29623 {
8673859Sml29623 
8683859Sml29623 	uint_t	print_len, buf_len;
8693859Sml29623 	p_mblk_t np;
8703859Sml29623 	int tdc;
8713859Sml29623 
8723859Sml29623 	int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
8733859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_txdma_info"));
8743859Sml29623 
8753859Sml29623 	(void) mi_mpprintf(mp, "TXDMA Information for Port\t %d \n",
8763859Sml29623 		nxgep->function_num);
8773859Sml29623 
8783859Sml29623 
8793859Sml29623 	if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
8803859Sml29623 		(void) mi_mpprintf(mp, "%s\n", "out of buffer");
8813859Sml29623 		return (0);
8823859Sml29623 	}
8833859Sml29623 
8843859Sml29623 	buf_len = buff_alloc_size;
8853859Sml29623 	mp->b_cont = np;
8863859Sml29623 
8873859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
8883859Sml29623 		"Total TDCs\t %d\n", nxgep->ntdc);
8893859Sml29623 
8903859Sml29623 	((mblk_t *)np)->b_wptr += print_len;
8913859Sml29623 	buf_len -= print_len;
8923859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
8933859Sml29623 		"TDC\t HW TDC\t\n");
8943859Sml29623 	((mblk_t *)np)->b_wptr += print_len;
8953859Sml29623 
8963859Sml29623 	buf_len -= print_len;
8973859Sml29623 	for (tdc = 0; tdc < nxgep->ntdc; tdc++) {
8983859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
8993859Sml29623 					    buf_len, "%d\t %d\n",
9003859Sml29623 					    tdc, nxgep->tdc[tdc]);
9013859Sml29623 		((mblk_t *)np)->b_wptr += print_len;
9023859Sml29623 		buf_len -= print_len;
9033859Sml29623 	}
9043859Sml29623 
9053859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_txdma_info"));
9063859Sml29623 	return (0);
9073859Sml29623 }
9083859Sml29623 
9093859Sml29623 /* ARGSUSED */
9103859Sml29623 int
9113859Sml29623 nxge_param_get_rxdma_info(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
9123859Sml29623 {
9133859Sml29623 	uint_t			print_len, buf_len;
9143859Sml29623 	p_mblk_t		np;
9153859Sml29623 	int			rdc;
9163859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
9173859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
9183859Sml29623 	int			buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
9193859Sml29623 	p_rx_rcr_rings_t 	rx_rcr_rings;
9203859Sml29623 	p_rx_rcr_ring_t		*rcr_rings;
9213859Sml29623 	p_rx_rbr_rings_t 	rx_rbr_rings;
9223859Sml29623 	p_rx_rbr_ring_t		*rbr_rings;
9233859Sml29623 
9243859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_rxdma_info"));
9253859Sml29623 
9263859Sml29623 	(void) mi_mpprintf(mp, "RXDMA Information for Port\t %d \n",
9273859Sml29623 		nxgep->function_num);
9283859Sml29623 
9293859Sml29623 	if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
9303859Sml29623 		/* The following may work even if we cannot get a large buf. */
9313859Sml29623 		(void) mi_mpprintf(mp, "%s\n", "out of buffer");
9323859Sml29623 		return (0);
9333859Sml29623 	}
9343859Sml29623 
9353859Sml29623 	buf_len = buff_alloc_size;
9363859Sml29623 	mp->b_cont = np;
9373859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
9383859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
9393859Sml29623 
9403859Sml29623 	rx_rcr_rings = nxgep->rx_rcr_rings;
9413859Sml29623 	rcr_rings = rx_rcr_rings->rcr_rings;
9423859Sml29623 	rx_rbr_rings = nxgep->rx_rbr_rings;
9433859Sml29623 	rbr_rings = rx_rbr_rings->rbr_rings;
9443859Sml29623 
9453859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
9463859Sml29623 		"Total RDCs\t %d\n", p_cfgp->max_rdcs);
9473859Sml29623 
9483859Sml29623 	((mblk_t *)np)->b_wptr += print_len;
9493859Sml29623 	buf_len -= print_len;
9503859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
9513859Sml29623 		"RDC\t HW RDC\t Timeout\t Packets RBR ptr \t"
9523859Sml29623 		"chunks\t RCR ptr\n");
9533859Sml29623 
9543859Sml29623 	((mblk_t *)np)->b_wptr += print_len;
9553859Sml29623 	buf_len -= print_len;
9563859Sml29623 	for (rdc = 0; rdc < p_cfgp->max_rdcs; rdc++) {
9573859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
9583859Sml29623 			" %d\t  %d\t   %x\t\t %x\t $%p\t 0x%x\t $%p\n",
9593859Sml29623 			rdc, nxgep->rdc[rdc],
9603859Sml29623 			p_dma_cfgp->rcr_timeout[rdc],
9613859Sml29623 			p_dma_cfgp->rcr_threshold[rdc],
9623859Sml29623 			rbr_rings[rdc],
9633859Sml29623 			rbr_rings[rdc]->num_blocks, rcr_rings[rdc]);
9643859Sml29623 			((mblk_t *)np)->b_wptr += print_len;
9653859Sml29623 			buf_len -= print_len;
9663859Sml29623 	}
9673859Sml29623 
9683859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_rxdma_info"));
9693859Sml29623 	return (0);
9703859Sml29623 }
9713859Sml29623 
9723859Sml29623 /* ARGSUSED */
9733859Sml29623 int
9743859Sml29623 nxge_param_get_rxdma_rdcgrp_info(p_nxge_t nxgep, queue_t *q,
9753859Sml29623 	p_mblk_t mp, caddr_t cp)
9763859Sml29623 {
9773859Sml29623 	uint_t			print_len, buf_len;
9783859Sml29623 	p_mblk_t		np;
9793859Sml29623 	int			offset, rdc, i, rdc_grp;
9803859Sml29623 	p_nxge_rdc_grp_t	rdc_grp_p;
9813859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
9823859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
9833859Sml29623 
9843859Sml29623 	int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
9853859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL,
9863859Sml29623 		"==> nxge_param_get_rxdma_rdcgrp_info"));
9873859Sml29623 
9883859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
9893859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
9903859Sml29623 
9913859Sml29623 	(void) mi_mpprintf(mp, "RXDMA RDC Group Information for Port\t %d \n",
9923859Sml29623 		nxgep->function_num);
9933859Sml29623 
9943859Sml29623 	rdc_grp = p_cfgp->start_rdc_grpid;
9953859Sml29623 	if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
9963859Sml29623 		/* The following may work even if we cannot get a large buf. */
9973859Sml29623 		(void) mi_mpprintf(mp, "%s\n", "out of buffer");
9983859Sml29623 		return (0);
9993859Sml29623 	}
10003859Sml29623 
10013859Sml29623 	buf_len = buff_alloc_size;
10023859Sml29623 	mp->b_cont = np;
10033859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
10043859Sml29623 		"Total RDC Groups\t %d \n"
10053859Sml29623 		"start RDC group\t %d\n",
10063859Sml29623 		p_cfgp->max_rdc_grpids,
10073859Sml29623 		p_cfgp->start_rdc_grpid);
10083859Sml29623 
10093859Sml29623 	((mblk_t *)np)->b_wptr += print_len;
10103859Sml29623 	buf_len -= print_len;
10113859Sml29623 
10123859Sml29623 	for (i = 0, rdc_grp = p_cfgp->start_rdc_grpid;
10133859Sml29623 	    rdc_grp < (p_cfgp->max_rdc_grpids + p_cfgp->start_rdc_grpid);
10143859Sml29623 	    rdc_grp++, i++) {
10153859Sml29623 		rdc_grp_p = &p_dma_cfgp->rdc_grps[i];
10163859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
10173859Sml29623 			"\nRDC Group Info for Group [%d] %d\n"
10183859Sml29623 			"RDC Count %d\tstart RDC %d\n"
10193859Sml29623 			"RDC Group Population Information"
10203859Sml29623 			" (offsets 0 - 15)\n",
10213859Sml29623 			i, rdc_grp, rdc_grp_p->max_rdcs,
10223859Sml29623 			rdc_grp_p->start_rdc);
10233859Sml29623 
10243859Sml29623 		((mblk_t *)np)->b_wptr += print_len;
10253859Sml29623 		buf_len -= print_len;
10263859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
10273859Sml29623 			buf_len, "\n");
10283859Sml29623 		((mblk_t *)np)->b_wptr += print_len;
10293859Sml29623 		buf_len -= print_len;
10303859Sml29623 
10313859Sml29623 		for (rdc = 0; rdc < rdc_grp_p->max_rdcs; rdc++) {
10323859Sml29623 			print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
10333859Sml29623 				buf_len, "[%d]=%d ", rdc,
10343859Sml29623 				rdc_grp_p->start_rdc + rdc);
10353859Sml29623 			((mblk_t *)np)->b_wptr += print_len;
10363859Sml29623 			buf_len -= print_len;
10373859Sml29623 		}
10383859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
10393859Sml29623 					    buf_len, "\n");
10403859Sml29623 		((mblk_t *)np)->b_wptr += print_len;
10413859Sml29623 		buf_len -= print_len;
10423859Sml29623 
10433859Sml29623 		for (offset = 0; offset < 16; offset++) {
10443859Sml29623 			print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
10453859Sml29623 				buf_len, " %2d ",
10463859Sml29623 				rdc_grp_p->rdc[offset]);
10473859Sml29623 			((mblk_t *)np)->b_wptr += print_len;
10483859Sml29623 			buf_len -= print_len;
10493859Sml29623 		}
10503859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
10513859Sml29623 			buf_len, "\n");
10523859Sml29623 		((mblk_t *)np)->b_wptr += print_len;
10533859Sml29623 		buf_len -= print_len;
10543859Sml29623 	}
10553859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL,
10563859Sml29623 		"<== nxge_param_get_rxdma_rdcgrp_info"));
10573859Sml29623 	return (0);
10583859Sml29623 }
10593859Sml29623 
10603859Sml29623 int
10613859Sml29623 nxge_mk_mblk_tail_space(p_mblk_t mp, p_mblk_t *nmp, size_t size)
10623859Sml29623 {
10633859Sml29623 	p_mblk_t tmp;
10643859Sml29623 
10653859Sml29623 	tmp = mp;
10663859Sml29623 	while (tmp->b_cont)
10673859Sml29623 		tmp = tmp->b_cont;
10683859Sml29623 	if ((tmp->b_wptr + size) >= tmp->b_datap->db_lim) {
10693859Sml29623 		tmp->b_cont = allocb(1024, BPRI_HI);
10703859Sml29623 		tmp = tmp->b_cont;
10713859Sml29623 		if (!tmp)
10723859Sml29623 			return (ENOMEM);
10733859Sml29623 	}
10743859Sml29623 
10753859Sml29623 	*nmp = tmp;
10763859Sml29623 	return (0);
10773859Sml29623 }
10783859Sml29623 
10793859Sml29623 /*
10803859Sml29623  * Sets the ge parameter to the value in the nxge_param_register using
10813859Sml29623  * nxge_nd_load().
10823859Sml29623  */
10833859Sml29623 
10843859Sml29623 /* ARGSUSED */
10853859Sml29623 int
10863859Sml29623 nxge_param_set_generic(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
10873859Sml29623 			    char *value, caddr_t cp)
10883859Sml29623 {
10893859Sml29623 	char *end;
10903859Sml29623 	uint32_t new_value;
10913859Sml29623 	p_nxge_param_t pa = (p_nxge_param_t)cp;
10923859Sml29623 
10933859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, " ==> nxge_param_set_generic"));
10943859Sml29623 	new_value = (uint32_t)mi_strtol(value, &end, 10);
10953859Sml29623 	if (end == value || new_value < pa->minimum ||
10963859Sml29623 		new_value > pa->maximum) {
10973859Sml29623 			return (EINVAL);
10983859Sml29623 	}
10993859Sml29623 	pa->value = new_value;
11003859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, " <== nxge_param_set_generic"));
11013859Sml29623 	return (0);
11023859Sml29623 }
11033859Sml29623 
11043859Sml29623 /*
11053859Sml29623  * Sets the ge parameter to the value in the nxge_param_register using
11063859Sml29623  * nxge_nd_load().
11073859Sml29623  */
11083859Sml29623 
11093859Sml29623 /* ARGSUSED */
11103859Sml29623 int
11113859Sml29623 nxge_param_set_instance(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
11123859Sml29623 	char *value, caddr_t cp)
11133859Sml29623 {
11143859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, " ==> nxge_param_set_instance"));
11153859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_set_instance"));
11163859Sml29623 	return (0);
11173859Sml29623 }
11183859Sml29623 
11193859Sml29623 /*
11203859Sml29623  * Sets the ge parameter to the value in the nxge_param_register using
11213859Sml29623  * nxge_nd_load().
11223859Sml29623  */
11233859Sml29623 
11243859Sml29623 /* ARGSUSED */
11253859Sml29623 int
11263859Sml29623 nxge_param_set_mac(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
11273859Sml29623 	char *value, caddr_t cp)
11283859Sml29623 {
11293859Sml29623 	char		*end;
11303859Sml29623 	uint32_t	new_value;
11313859Sml29623 	int		status = 0;
11323859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
11333859Sml29623 
11343859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_mac"));
11353859Sml29623 	new_value = (uint32_t)mi_strtol(value, &end, BASE_DECIMAL);
11363859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, new_value, pa)) {
11373859Sml29623 		return (EINVAL);
11383859Sml29623 	}
11393859Sml29623 
11403859Sml29623 	if (pa->value != new_value) {
11413859Sml29623 		pa->old_value = pa->value;
11423859Sml29623 		pa->value = new_value;
11433859Sml29623 	}
11443859Sml29623 
11453859Sml29623 	if (!nxge_param_link_update(nxgep)) {
11463859Sml29623 		NXGE_DEBUG_MSG((nxgep, NDD_CTL,
11473859Sml29623 				    " false ret from nxge_param_link_update"));
11483859Sml29623 		status = EINVAL;
11493859Sml29623 	}
11503859Sml29623 
11513859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_mac"));
11523859Sml29623 	return (status);
11533859Sml29623 }
11543859Sml29623 
11553859Sml29623 /* ARGSUSED */
11563859Sml29623 static int
11573859Sml29623 nxge_param_rx_intr_pkts(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
11583859Sml29623 	char *value, caddr_t cp)
11593859Sml29623 {
11603859Sml29623 	char		*end;
11613859Sml29623 	uint32_t	cfg_value;
11623859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
11633859Sml29623 
11643859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_rx_intr_pkts"));
11653859Sml29623 
11663859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
11673859Sml29623 
11683859Sml29623 	if ((cfg_value > NXGE_RDC_RCR_THRESHOLD_MAX) ||
11693859Sml29623 		(cfg_value < NXGE_RDC_RCR_THRESHOLD_MIN)) {
11703859Sml29623 		return (EINVAL);
11713859Sml29623 	}
11723859Sml29623 
11733859Sml29623 	if ((pa->value != cfg_value)) {
11743859Sml29623 		pa->old_value = pa->value;
11753859Sml29623 		pa->value = cfg_value;
11763859Sml29623 		nxgep->intr_threshold = pa->value;
11773859Sml29623 	}
11783859Sml29623 
11793859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_rx_intr_pkts"));
11803859Sml29623 	return (0);
11813859Sml29623 }
11823859Sml29623 
11833859Sml29623 /* ARGSUSED */
11843859Sml29623 static int
11853859Sml29623 nxge_param_rx_intr_time(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
11863859Sml29623 	char *value, caddr_t cp)
11873859Sml29623 {
11883859Sml29623 	char		*end;
11893859Sml29623 	uint32_t	cfg_value;
11903859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
11913859Sml29623 
11923859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_rx_intr_time"));
11933859Sml29623 
11943859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
11953859Sml29623 
11963859Sml29623 	if ((cfg_value > NXGE_RDC_RCR_TIMEOUT_MAX) ||
11973859Sml29623 		(cfg_value < NXGE_RDC_RCR_TIMEOUT_MIN)) {
11983859Sml29623 		return (EINVAL);
11993859Sml29623 	}
12003859Sml29623 
12013859Sml29623 	if ((pa->value != cfg_value)) {
12023859Sml29623 		pa->old_value = pa->value;
12033859Sml29623 		pa->value = cfg_value;
12043859Sml29623 		nxgep->intr_timeout = pa->value;
12053859Sml29623 	}
12063859Sml29623 
12073859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_rx_intr_time"));
12083859Sml29623 	return (0);
12093859Sml29623 }
12103859Sml29623 
12113859Sml29623 /* ARGSUSED */
12123859Sml29623 static int
12133859Sml29623 nxge_param_set_mac_rdcgrp(p_nxge_t nxgep, queue_t *q,
12143859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
12153859Sml29623 {
12163859Sml29623 	char			 *end;
12173859Sml29623 	uint32_t		status = 0, cfg_value;
12183859Sml29623 	p_nxge_param_t		pa = (p_nxge_param_t)cp;
12193859Sml29623 	uint32_t		cfg_it = B_FALSE;
12203859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
12213859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
12223859Sml29623 	uint32_t		*val_ptr, *old_val_ptr;
12233859Sml29623 	nxge_param_map_t	*mac_map;
12243859Sml29623 	p_nxge_class_pt_cfg_t	p_class_cfgp;
12253859Sml29623 	nxge_mv_cfg_t		*mac_host_info;
12263859Sml29623 
12273859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_mac_rdcgrp "));
12283859Sml29623 
12293859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
12303859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
12313859Sml29623 	p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
12323859Sml29623 	mac_host_info = (nxge_mv_cfg_t	*)&p_class_cfgp->mac_host_info[0];
12333859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
12343859Sml29623 
12353859Sml29623 	/*
12363859Sml29623 	 * now do decoding
12373859Sml29623 	 */
12383859Sml29623 	mac_map = (nxge_param_map_t *)&cfg_value;
12393859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, " cfg_value %x id %x map_to %x",
12403859Sml29623 		cfg_value, mac_map->param_id, mac_map->map_to));
12413859Sml29623 
12423859Sml29623 	if ((mac_map->param_id < p_cfgp->max_macs) &&
12433859Sml29623 			(mac_map->map_to < (p_cfgp->max_rdc_grpids +
12443859Sml29623 			p_cfgp->start_rdc_grpid)) && (mac_map->map_to >=
12453859Sml29623 			p_cfgp->start_rdc_grpid)) {
12463859Sml29623 		NXGE_DEBUG_MSG((nxgep, NDD_CTL,
12473859Sml29623 			" nxge_param_set_mac_rdcgrp mapping"
12483859Sml29623 			" id %d grp %d", mac_map->param_id, mac_map->map_to));
12493859Sml29623 		val_ptr = (uint32_t *)pa->value;
12503859Sml29623 		old_val_ptr = (uint32_t *)pa->old_value;
12513859Sml29623 		if (val_ptr[mac_map->param_id] != cfg_value) {
12523859Sml29623 			old_val_ptr[mac_map->param_id] =
12533859Sml29623 				    val_ptr[mac_map->param_id];
12543859Sml29623 			val_ptr[mac_map->param_id] = cfg_value;
12553859Sml29623 			mac_host_info[mac_map->param_id].mpr_npr =
12563859Sml29623 				    mac_map->pref;
12573859Sml29623 			mac_host_info[mac_map->param_id].flag = 1;
12583859Sml29623 			mac_host_info[mac_map->param_id].rdctbl =
12593859Sml29623 				    mac_map->map_to;
12603859Sml29623 			cfg_it = B_TRUE;
12613859Sml29623 		}
12623859Sml29623 	} else {
12633859Sml29623 		return (EINVAL);
12643859Sml29623 	}
12653859Sml29623 
12663859Sml29623 	if (cfg_it == B_TRUE) {
12673859Sml29623 		status = nxge_logical_mac_assign_rdc_table(nxgep,
12683859Sml29623 						    (uint8_t)mac_map->param_id);
12693859Sml29623 		if (status != NXGE_OK)
12703859Sml29623 			return (EINVAL);
12713859Sml29623 	}
12723859Sml29623 
12733859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_mac_rdcgrp"));
12743859Sml29623 	return (0);
12753859Sml29623 }
12763859Sml29623 
12773859Sml29623 /* ARGSUSED */
12783859Sml29623 static int
12793859Sml29623 nxge_param_set_vlan_rdcgrp(p_nxge_t nxgep, queue_t *q,
12803859Sml29623 	mblk_t	*mp, char *value, caddr_t cp)
12813859Sml29623 {
12823859Sml29623 	char			*end;
12833859Sml29623 	uint32_t		status = 0, cfg_value;
12843859Sml29623 	p_nxge_param_t		pa = (p_nxge_param_t)cp;
12853859Sml29623 	uint32_t		cfg_it = B_FALSE;
12863859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
12873859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
12883859Sml29623 	uint32_t		*val_ptr, *old_val_ptr;
12893859Sml29623 	nxge_param_map_t	*vmap, *old_map;
12903859Sml29623 	p_nxge_class_pt_cfg_t	p_class_cfgp;
12913859Sml29623 	uint64_t		cfgd_vlans;
12923859Sml29623 	int			i, inc = 0, cfg_position;
12933859Sml29623 	nxge_mv_cfg_t		*vlan_tbl;
12943859Sml29623 
12953859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_vlan_rdcgrp "));
12963859Sml29623 
12973859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
12983859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
12993859Sml29623 	p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
13003859Sml29623 	vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0];
13013859Sml29623 
13023859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
13033859Sml29623 
13043859Sml29623 	/* now do decoding */
13053859Sml29623 	cfgd_vlans = ((pa->type &  NXGE_PARAM_ARRAY_CNT_MASK) >>
13063859Sml29623 		NXGE_PARAM_ARRAY_CNT_SHIFT);
13073859Sml29623 
13083859Sml29623 	if (cfgd_vlans == NXGE_PARAM_ARRAY_INIT_SIZE) {
13093859Sml29623 		/*
13103859Sml29623 		 * for now, we process only upto max
13113859Sml29623 		 * NXGE_PARAM_ARRAY_INIT_SIZE parameters
13123859Sml29623 		 * In the future, we may want to expand
13133859Sml29623 		 * the storage array and continue
13143859Sml29623 		 */
13153859Sml29623 		return (EINVAL);
13163859Sml29623 	}
13173859Sml29623 
13183859Sml29623 	vmap = (nxge_param_map_t *)&cfg_value;
13193859Sml29623 	if ((vmap->param_id) &&
13203859Sml29623 		(vmap->param_id < NXGE_MAX_VLANS) &&
13213859Sml29623 		(vmap->map_to < p_cfgp->max_rdc_grpids)) {
13223859Sml29623 		NXGE_DEBUG_MSG((nxgep, NDD_CTL,
13233859Sml29623 			"nxge_param_set_vlan_rdcgrp mapping"
13243859Sml29623 			" id %d grp %d",
13253859Sml29623 			vmap->param_id, vmap->map_to));
13263859Sml29623 		val_ptr = (uint32_t *)pa->value;
13273859Sml29623 		old_val_ptr = (uint32_t *)pa->old_value;
13283859Sml29623 
13293859Sml29623 		/* search to see if this vlan id is already configured */
13303859Sml29623 		for (i = 0; i < cfgd_vlans; i++) {
13313859Sml29623 			old_map = (nxge_param_map_t *)&val_ptr[i];
13323859Sml29623 			if ((old_map->param_id == 0) ||
13333859Sml29623 				(vmap->param_id == old_map->param_id) ||
13343859Sml29623 				(vlan_tbl[vmap->param_id].flag)) {
13353859Sml29623 				cfg_position = i;
13363859Sml29623 				break;
13373859Sml29623 			}
13383859Sml29623 		}
13393859Sml29623 
13403859Sml29623 		if (cfgd_vlans == 0) {
13413859Sml29623 			cfg_position = 0;
13423859Sml29623 			inc++;
13433859Sml29623 		}
13443859Sml29623 
13453859Sml29623 		if (i == cfgd_vlans) {
13463859Sml29623 			cfg_position = i;
13473859Sml29623 			inc++;
13483859Sml29623 		}
13493859Sml29623 
13503859Sml29623 		NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
13513859Sml29623 			"set_vlan_rdcgrp mapping"
13523859Sml29623 			" i %d cfgd_vlans %llx position %d ",
13533859Sml29623 			i, cfgd_vlans, cfg_position));
13543859Sml29623 		if (val_ptr[cfg_position] != cfg_value) {
13553859Sml29623 			old_val_ptr[cfg_position] = val_ptr[cfg_position];
13563859Sml29623 			val_ptr[cfg_position] = cfg_value;
13573859Sml29623 			vlan_tbl[vmap->param_id].mpr_npr = vmap->pref;
13583859Sml29623 			vlan_tbl[vmap->param_id].flag = 1;
13593859Sml29623 			vlan_tbl[vmap->param_id].rdctbl =
13603859Sml29623 			    vmap->map_to + p_cfgp->start_rdc_grpid;
13613859Sml29623 			cfg_it = B_TRUE;
13623859Sml29623 			if (inc) {
13633859Sml29623 				cfgd_vlans++;
13643859Sml29623 				pa->type &= ~NXGE_PARAM_ARRAY_CNT_MASK;
13653859Sml29623 				pa->type |= (cfgd_vlans <<
13663859Sml29623 						    NXGE_PARAM_ARRAY_CNT_SHIFT);
13673859Sml29623 
13683859Sml29623 			}
13693859Sml29623 			NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
13703859Sml29623 				"after: param_set_vlan_rdcgrp "
13713859Sml29623 				" cfg_vlans %llx position %d \n",
13723859Sml29623 				cfgd_vlans, cfg_position));
13733859Sml29623 		}
13743859Sml29623 	} else {
13753859Sml29623 		return (EINVAL);
13763859Sml29623 	}
13773859Sml29623 
13783859Sml29623 	if (cfg_it == B_TRUE) {
13793859Sml29623 		status = nxge_fflp_config_vlan_table(nxgep,
13803859Sml29623 			(uint16_t)vmap->param_id);
13813859Sml29623 		if (status != NXGE_OK)
13823859Sml29623 			return (EINVAL);
13833859Sml29623 	}
13843859Sml29623 
13853859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_vlan_rdcgrp"));
13863859Sml29623 	return (0);
13873859Sml29623 }
13883859Sml29623 
13893859Sml29623 /* ARGSUSED */
13903859Sml29623 static int
13913859Sml29623 nxge_param_get_vlan_rdcgrp(p_nxge_t nxgep, queue_t *q,
13923859Sml29623 	mblk_t *mp, caddr_t cp)
13933859Sml29623 {
13943859Sml29623 
13953859Sml29623 	uint_t 			print_len, buf_len;
13963859Sml29623 	p_mblk_t		np;
13973859Sml29623 	int			i;
13983859Sml29623 	uint32_t		*val_ptr;
13993859Sml29623 	nxge_param_map_t	*vmap;
14003859Sml29623 	p_nxge_param_t		pa = (p_nxge_param_t)cp;
14013859Sml29623 	p_nxge_class_pt_cfg_t 	p_class_cfgp;
14023859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
14033859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
14043859Sml29623 	uint64_t		cfgd_vlans = 0;
14053859Sml29623 	nxge_mv_cfg_t		*vlan_tbl;
14063859Sml29623 	int			buff_alloc_size =
14073859Sml29623 					NXGE_NDD_INFODUMP_BUFF_SIZE * 32;
14083859Sml29623 
14093859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_vlan_rdcgrp "));
14103859Sml29623 	(void) mi_mpprintf(mp, "VLAN RDC Mapping Information for Port\t %d \n",
14113859Sml29623 		nxgep->function_num);
14123859Sml29623 
14133859Sml29623 	if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
14143859Sml29623 		(void) mi_mpprintf(mp, "%s\n", "out of buffer");
14153859Sml29623 		return (0);
14163859Sml29623 	}
14173859Sml29623 
14183859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
14193859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
14203859Sml29623 
14213859Sml29623 	buf_len = buff_alloc_size;
14223859Sml29623 	mp->b_cont = np;
14233859Sml29623 	cfgd_vlans = (pa->type &  NXGE_PARAM_ARRAY_CNT_MASK) >>
14243859Sml29623 		NXGE_PARAM_ARRAY_CNT_SHIFT;
14253859Sml29623 
14263859Sml29623 	i = (int)cfgd_vlans;
14273859Sml29623 	p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
14283859Sml29623 	vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0];
14293859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
14303859Sml29623 		"Configured VLANs %d\n"
14313859Sml29623 		"VLAN ID\t RDC GRP (Actual/Port)\t"
14323859Sml29623 		" Prefernce\n", i);
14333859Sml29623 	((mblk_t *)np)->b_wptr += print_len;
14343859Sml29623 	buf_len -= print_len;
14353859Sml29623 
14363859Sml29623 	val_ptr = (uint32_t *)pa->value;
14373859Sml29623 
14383859Sml29623 	for (i = 0; i < cfgd_vlans; i++) {
14393859Sml29623 		vmap = (nxge_param_map_t *)&val_ptr[i];
14403859Sml29623 		if (p_class_cfgp->vlan_tbl[vmap->param_id].flag) {
14413859Sml29623 			print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
14423859Sml29623 				buf_len,
14433859Sml29623 				"  %d\t\t %d/%d\t\t %d\n",
14443859Sml29623 				vmap->param_id,
14453859Sml29623 				vlan_tbl[vmap->param_id].rdctbl,
14463859Sml29623 				vlan_tbl[vmap->param_id].rdctbl -
14473859Sml29623 				p_cfgp->start_rdc_grpid,
14483859Sml29623 				vlan_tbl[vmap->param_id].mpr_npr);
14493859Sml29623 			((mblk_t *)np)->b_wptr += print_len;
14503859Sml29623 			buf_len -= print_len;
14513859Sml29623 		}
14523859Sml29623 	}
14533859Sml29623 
14543859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_vlan_rdcgrp"));
14553859Sml29623 	return (0);
14563859Sml29623 }
14573859Sml29623 
14583859Sml29623 /* ARGSUSED */
14593859Sml29623 static int
14603859Sml29623 nxge_param_get_mac_rdcgrp(p_nxge_t nxgep, queue_t *q,
14613859Sml29623 	mblk_t *mp, caddr_t cp)
14623859Sml29623 {
14633859Sml29623 	uint_t			print_len, buf_len;
14643859Sml29623 	p_mblk_t		np;
14653859Sml29623 	int			i;
14663859Sml29623 	p_nxge_class_pt_cfg_t 	p_class_cfgp;
14673859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
14683859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
14693859Sml29623 	nxge_mv_cfg_t		*mac_host_info;
14703859Sml29623 
14713859Sml29623 	int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE * 32;
14723859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_mac_rdcgrp "));
14733859Sml29623 	(void) mi_mpprintf(mp,
14743859Sml29623 		"MAC ADDR RDC Mapping Information for Port\t %d\n",
14753859Sml29623 		nxgep->function_num);
14763859Sml29623 
14773859Sml29623 	if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
14783859Sml29623 		(void) mi_mpprintf(mp, "%s\n", "out of buffer");
14793859Sml29623 		return (0);
14803859Sml29623 	}
14813859Sml29623 
14823859Sml29623 	buf_len = buff_alloc_size;
14833859Sml29623 	mp->b_cont = np;
14843859Sml29623 	p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
14853859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
14863859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
14873859Sml29623 	mac_host_info = (nxge_mv_cfg_t	*)&p_class_cfgp->mac_host_info[0];
14883859Sml29623 	print_len = snprintf((char *)np->b_wptr, buf_len,
14893859Sml29623 		"MAC ID\t RDC GRP (Actual/Port)\t"
14903859Sml29623 		" Prefernce\n");
14913859Sml29623 	((mblk_t *)np)->b_wptr += print_len;
14923859Sml29623 	buf_len -= print_len;
14933859Sml29623 	for (i = 0; i < p_cfgp->max_macs; i++) {
14943859Sml29623 		if (mac_host_info[i].flag) {
14953859Sml29623 			print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
14963859Sml29623 				buf_len,
14973859Sml29623 				"   %d\t  %d/%d\t\t %d\n",
14983859Sml29623 				i, mac_host_info[i].rdctbl,
14993859Sml29623 				mac_host_info[i].rdctbl -
15003859Sml29623 				p_cfgp->start_rdc_grpid,
15013859Sml29623 				mac_host_info[i].mpr_npr);
15023859Sml29623 			((mblk_t *)np)->b_wptr += print_len;
15033859Sml29623 			buf_len -= print_len;
15043859Sml29623 		}
15053859Sml29623 	}
15063859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
15073859Sml29623 		"Done Info Dumping \n");
15083859Sml29623 	((mblk_t *)np)->b_wptr += print_len;
15093859Sml29623 	buf_len -= print_len;
15103859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_macrdcgrp"));
15113859Sml29623 	return (0);
15123859Sml29623 }
15133859Sml29623 
15143859Sml29623 /* ARGSUSED */
15153859Sml29623 static int
15163859Sml29623 nxge_param_tcam_enable(p_nxge_t nxgep, queue_t *q,
15173859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
15183859Sml29623 {
15193859Sml29623 	uint32_t	status = 0, cfg_value;
15203859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
15213859Sml29623 	uint32_t	cfg_it = B_FALSE;
15223859Sml29623 	char		*end;
15233859Sml29623 
15243859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_tcam_enable"));
15253859Sml29623 
15263859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
15273859Sml29623 	if (pa->value != cfg_value) {
15283859Sml29623 		pa->old_value = pa->value;
15293859Sml29623 		pa->value = cfg_value;
15303859Sml29623 		cfg_it = B_TRUE;
15313859Sml29623 	}
15323859Sml29623 
15333859Sml29623 	if (cfg_it == B_TRUE) {
15343859Sml29623 		if (pa->value)
15353859Sml29623 			status = nxge_fflp_config_tcam_enable(nxgep);
15363859Sml29623 		else
15373859Sml29623 			status = nxge_fflp_config_tcam_disable(nxgep);
15383859Sml29623 		if (status != NXGE_OK)
15393859Sml29623 			return (EINVAL);
15403859Sml29623 	}
15413859Sml29623 
15423859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_tcam_enable"));
15433859Sml29623 	return (0);
15443859Sml29623 }
15453859Sml29623 
15463859Sml29623 /* ARGSUSED */
15473859Sml29623 static int
15483859Sml29623 nxge_param_hash_lookup_enable(p_nxge_t nxgep, queue_t *q,
15493859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
15503859Sml29623 {
15513859Sml29623 	uint32_t	status = 0, cfg_value;
15523859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
15533859Sml29623 	uint32_t	cfg_it = B_FALSE;
15543859Sml29623 	char		*end;
15553859Sml29623 
15563859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_hash_lookup_enable"));
15573859Sml29623 
15583859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
15593859Sml29623 	if (pa->value != cfg_value) {
15603859Sml29623 		pa->old_value = pa->value;
15613859Sml29623 		pa->value = cfg_value;
15623859Sml29623 		cfg_it = B_TRUE;
15633859Sml29623 	}
15643859Sml29623 
15653859Sml29623 	if (cfg_it == B_TRUE) {
15663859Sml29623 		if (pa->value)
15673859Sml29623 			status = nxge_fflp_config_hash_lookup_enable(nxgep);
15683859Sml29623 		else
15693859Sml29623 			status = nxge_fflp_config_hash_lookup_disable(nxgep);
15703859Sml29623 		if (status != NXGE_OK)
15713859Sml29623 			return (EINVAL);
15723859Sml29623 	}
15733859Sml29623 
15743859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_hash_lookup_enable"));
15753859Sml29623 	return (0);
15763859Sml29623 }
15773859Sml29623 
15783859Sml29623 /* ARGSUSED */
15793859Sml29623 static int
15803859Sml29623 nxge_param_llc_snap_enable(p_nxge_t nxgep, queue_t *q,
15813859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
15823859Sml29623 {
15833859Sml29623 	char		*end;
15843859Sml29623 	uint32_t	status = 0, cfg_value;
15853859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
15863859Sml29623 	uint32_t	cfg_it = B_FALSE;
15873859Sml29623 
15883859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_llc_snap_enable"));
15893859Sml29623 
15903859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
15913859Sml29623 	if (pa->value != cfg_value) {
15923859Sml29623 		pa->old_value = pa->value;
15933859Sml29623 		pa->value = cfg_value;
15943859Sml29623 		cfg_it = B_TRUE;
15953859Sml29623 	}
15963859Sml29623 
15973859Sml29623 	if (cfg_it == B_TRUE) {
15983859Sml29623 		if (pa->value)
15993859Sml29623 			status = nxge_fflp_config_tcam_enable(nxgep);
16003859Sml29623 		else
16013859Sml29623 			status = nxge_fflp_config_tcam_disable(nxgep);
16023859Sml29623 		if (status != NXGE_OK)
16033859Sml29623 			return (EINVAL);
16043859Sml29623 	}
16053859Sml29623 
16063859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_llc_snap_enable"));
16073859Sml29623 	return (0);
16083859Sml29623 }
16093859Sml29623 
16103859Sml29623 /* ARGSUSED */
16113859Sml29623 static int
16123859Sml29623 nxge_param_set_ether_usr(p_nxge_t nxgep, queue_t *q,
16133859Sml29623 	mblk_t	*mp, char *value, caddr_t cp)
16143859Sml29623 {
16153859Sml29623 	char		*end;
16163859Sml29623 	uint8_t		ether_class;
16173859Sml29623 	uint32_t	status = 0, cfg_value;
16183859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
16193859Sml29623 	uint8_t		cfg_it = B_FALSE;
16203859Sml29623 
16213859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ether_usr"));
16223859Sml29623 
16233859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
16243859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
16253859Sml29623 		return (EINVAL);
16263859Sml29623 	}
16273859Sml29623 
16283859Sml29623 	if (pa->value != cfg_value) {
16293859Sml29623 		pa->old_value = pa->value;
16303859Sml29623 		pa->value = cfg_value;
16313859Sml29623 		cfg_it = B_TRUE;
16323859Sml29623 	}
16333859Sml29623 
16343859Sml29623 	/* do the actual hw setup  */
16353859Sml29623 	if (cfg_it == B_TRUE) {
16363859Sml29623 		ether_class = mi_strtol(pa->name, &end, 10);
16373859Sml29623 #ifdef lint
16383859Sml29623 		ether_class = ether_class;
16393859Sml29623 #endif
16403859Sml29623 		NXGE_DEBUG_MSG((nxgep, NDD_CTL, " nxge_param_set_ether_usr"));
16413859Sml29623 	}
16423859Sml29623 
16433859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ether_usr"));
16443859Sml29623 	return (status);
16453859Sml29623 }
16463859Sml29623 
16473859Sml29623 /* ARGSUSED */
16483859Sml29623 static int
16493859Sml29623 nxge_param_set_ip_usr(p_nxge_t nxgep, queue_t *q,
16503859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
16513859Sml29623 {
16523859Sml29623 	char		*end;
16533859Sml29623 	tcam_class_t	class;
16543859Sml29623 	uint32_t	status, cfg_value;
16553859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
16563859Sml29623 	uint32_t	cfg_it = B_FALSE;
16573859Sml29623 
16583859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ip_usr"));
16593859Sml29623 
16603859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
16613859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
16623859Sml29623 		return (EINVAL);
16633859Sml29623 	}
16643859Sml29623 
16653859Sml29623 	if (pa->value != cfg_value) {
16663859Sml29623 		pa->old_value = pa->value;
16673859Sml29623 		pa->value = cfg_value;
16683859Sml29623 		cfg_it = B_TRUE;
16693859Sml29623 	}
16703859Sml29623 
16713859Sml29623 	/* do the actual hw setup with cfg_value. */
16723859Sml29623 	if (cfg_it == B_TRUE) {
16733859Sml29623 		class = mi_strtol(pa->name, &end, 10);
16743859Sml29623 		status = nxge_fflp_ip_usr_class_config(nxgep, class, pa->value);
16753859Sml29623 	}
16763859Sml29623 
16773859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ip_usr"));
16783859Sml29623 	return (status);
16793859Sml29623 }
16803859Sml29623 
16813859Sml29623 /* ARGSUSED */
16823859Sml29623 static int
16833859Sml29623 nxge_class_name_2value(p_nxge_t nxgep, char *name)
16843859Sml29623 {
16853859Sml29623 	int		i;
16863859Sml29623 	int		class_instance = param_class_opt_ip_usr4;
16873859Sml29623 	p_nxge_param_t	param_arr;
16883859Sml29623 
16893859Sml29623 	param_arr = nxgep->param_arr;
16903859Sml29623 	for (i = TCAM_CLASS_IP_USER_4; i <= TCAM_CLASS_SCTP_IPV6; i++) {
16913859Sml29623 		if (strcmp(param_arr[class_instance].name, name) == 0)
16923859Sml29623 			return (i);
16933859Sml29623 		class_instance++;
16943859Sml29623 	}
16953859Sml29623 	return (-1);
16963859Sml29623 }
16973859Sml29623 
16983859Sml29623 /* ARGSUSED */
16993859Sml29623 static int
17003859Sml29623 nxge_param_set_ip_opt(p_nxge_t nxgep, queue_t *q,
17013859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
17023859Sml29623 {
17033859Sml29623 	char		*end;
17043859Sml29623 	uint32_t	status, cfg_value;
17053859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
17063859Sml29623 	tcam_class_t	class;
17073859Sml29623 	uint32_t	cfg_it = B_FALSE;
17083859Sml29623 
17093859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ip_opt"));
17103859Sml29623 
17113859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
17123859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
17133859Sml29623 		return (EINVAL);
17143859Sml29623 	}
17153859Sml29623 
17163859Sml29623 	if (pa->value != cfg_value) {
17173859Sml29623 		pa->old_value = pa->value;
17183859Sml29623 		pa->value = cfg_value;
17193859Sml29623 		cfg_it = B_TRUE;
17203859Sml29623 	}
17213859Sml29623 
17223859Sml29623 	if (cfg_it == B_TRUE) {
17233859Sml29623 		/* do the actual hw setup  */
17243859Sml29623 		class = nxge_class_name_2value(nxgep, pa->name);
17253859Sml29623 		if (class == -1)
17263859Sml29623 			return (EINVAL);
17273859Sml29623 
17283859Sml29623 		status = nxge_fflp_ip_class_config(nxgep, class, pa->value);
17293859Sml29623 		if (status != NXGE_OK)
17303859Sml29623 			return (EINVAL);
17313859Sml29623 	}
17323859Sml29623 
17333859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ip_opt"));
17343859Sml29623 	return (0);
17353859Sml29623 }
17363859Sml29623 
17373859Sml29623 /* ARGSUSED */
17383859Sml29623 static int
17393859Sml29623 nxge_param_get_ip_opt(p_nxge_t nxgep, queue_t *q,
17403859Sml29623 	mblk_t *mp, caddr_t cp)
17413859Sml29623 {
17423859Sml29623 	uint32_t status, cfg_value;
17433859Sml29623 	p_nxge_param_t pa = (p_nxge_param_t)cp;
17443859Sml29623 	tcam_class_t class;
17453859Sml29623 
17463859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_ip_opt"));
17473859Sml29623 
17483859Sml29623 	/* do the actual hw setup  */
17493859Sml29623 	class = nxge_class_name_2value(nxgep, pa->name);
17503859Sml29623 	if (class == -1)
17513859Sml29623 		return (EINVAL);
17523859Sml29623 
17533859Sml29623 	cfg_value = 0;
17543859Sml29623 	status = nxge_fflp_ip_class_config_get(nxgep, class, &cfg_value);
17553859Sml29623 	if (status != NXGE_OK)
17563859Sml29623 		return (EINVAL);
17573859Sml29623 
17583859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL,
17593859Sml29623 		"nxge_param_get_ip_opt_get %x ", cfg_value));
17603859Sml29623 
17613859Sml29623 	pa->value = cfg_value;
17623859Sml29623 	(void) mi_mpprintf(mp, "%x", cfg_value);
17633859Sml29623 
17643859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_ip_opt status "));
17653859Sml29623 	return (0);
17663859Sml29623 }
17673859Sml29623 
17683859Sml29623 /* ARGSUSED */
17693859Sml29623 static int
17703859Sml29623 nxge_param_fflp_hash_init(p_nxge_t nxgep, queue_t *q,
17713859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
17723859Sml29623 {
17733859Sml29623 	char		*end;
17743859Sml29623 	uint32_t	status, cfg_value;
17753859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
17763859Sml29623 	tcam_class_t	class;
17773859Sml29623 	uint32_t	cfg_it = B_FALSE;
17783859Sml29623 
17793859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_fflp_hash_init"));
17803859Sml29623 
17813859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
17823859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
17833859Sml29623 		return (EINVAL);
17843859Sml29623 	}
17853859Sml29623 
17863859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL,
17873859Sml29623 		"nxge_param_fflp_hash_init value %x", cfg_value));
17883859Sml29623 
17893859Sml29623 	if (pa->value != cfg_value) {
17903859Sml29623 		pa->old_value = pa->value;
17913859Sml29623 		pa->value = cfg_value;
17923859Sml29623 		cfg_it = B_TRUE;
17933859Sml29623 	}
17943859Sml29623 
17953859Sml29623 	if (cfg_it == B_TRUE) {
17963859Sml29623 		char *h_name;
17973859Sml29623 
17983859Sml29623 		/* do the actual hw setup */
17993859Sml29623 		h_name = pa->name;
18003859Sml29623 		h_name++;
18013859Sml29623 		class = mi_strtol(h_name, &end, 10);
18023859Sml29623 		switch (class) {
18033859Sml29623 			case 1:
18043859Sml29623 				status = nxge_fflp_set_hash1(nxgep,
18053859Sml29623 					(uint32_t)pa->value);
18063859Sml29623 				break;
18073859Sml29623 			case 2:
18083859Sml29623 				status = nxge_fflp_set_hash2(nxgep,
18093859Sml29623 					(uint16_t)pa->value);
18103859Sml29623 				break;
18113859Sml29623 
18123859Sml29623 			default:
18133859Sml29623 			NXGE_DEBUG_MSG((nxgep, NDD_CTL,
18143859Sml29623 				" nxge_param_fflp_hash_init"
18153859Sml29623 				" %s Wrong hash var %d",
18163859Sml29623 				pa->name, class));
18173859Sml29623 			return (EINVAL);
18183859Sml29623 		}
18193859Sml29623 		if (status != NXGE_OK)
18203859Sml29623 			return (EINVAL);
18213859Sml29623 	}
18223859Sml29623 
18233859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_fflp_hash_init"));
18243859Sml29623 	return (0);
18253859Sml29623 }
18263859Sml29623 
18273859Sml29623 /* ARGSUSED */
18283859Sml29623 static int
18293859Sml29623 nxge_param_set_grp_rdc(p_nxge_t nxgep, queue_t *q,
18303859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
18313859Sml29623 {
18323859Sml29623 	char			*end;
18333859Sml29623 	uint32_t		status = 0, cfg_value;
18343859Sml29623 	p_nxge_param_t		pa = (p_nxge_param_t)cp;
18353859Sml29623 	uint32_t		cfg_it = B_FALSE;
18363859Sml29623 	int			rdc_grp;
18373859Sml29623 	uint8_t			real_rdc;
18383859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
18393859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
18403859Sml29623 	p_nxge_rdc_grp_t	rdc_grp_p;
18413859Sml29623 
18423859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
18433859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
18443859Sml29623 
18453859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_grp_rdc"));
18463859Sml29623 
18473859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
18483859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
18493859Sml29623 		return (EINVAL);
18503859Sml29623 	}
18513859Sml29623 
18523859Sml29623 	if (cfg_value >= p_cfgp->max_rdcs) {
18533859Sml29623 		return (EINVAL);
18543859Sml29623 	}
18553859Sml29623 
18563859Sml29623 	if (pa->value != cfg_value) {
18573859Sml29623 		pa->old_value = pa->value;
18583859Sml29623 		pa->value = cfg_value;
18593859Sml29623 		cfg_it = B_TRUE;
18603859Sml29623 	}
18613859Sml29623 
18623859Sml29623 	if (cfg_it == B_TRUE) {
18633859Sml29623 		char *grp_name;
18643859Sml29623 		grp_name = pa->name;
18653859Sml29623 		grp_name += strlen("default-grp");
18663859Sml29623 		rdc_grp = mi_strtol(grp_name, &end, 10);
18673859Sml29623 		rdc_grp_p = &p_dma_cfgp->rdc_grps[rdc_grp];
18683859Sml29623 		real_rdc = rdc_grp_p->start_rdc + cfg_value;
18693859Sml29623 		if (nxge_check_rxdma_rdcgrp_member(nxgep, rdc_grp,
18703859Sml29623 				cfg_value) == B_FALSE) {
18713859Sml29623 			pa->value = pa->old_value;
18723859Sml29623 			NXGE_DEBUG_MSG((nxgep, NDD_CTL,
18733859Sml29623 				" nxge_param_set_grp_rdc"
18743859Sml29623 				" %d read %d actual %d outof range",
18753859Sml29623 				rdc_grp, cfg_value, real_rdc));
18763859Sml29623 			return (EINVAL);
18773859Sml29623 		}
18783859Sml29623 		status = nxge_rxdma_cfg_rdcgrp_default_rdc(nxgep, rdc_grp,
18793859Sml29623 							    real_rdc);
18803859Sml29623 		if (status != NXGE_OK)
18813859Sml29623 			return (EINVAL);
18823859Sml29623 	}
18833859Sml29623 
18843859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_grp_rdc"));
18853859Sml29623 	return (0);
18863859Sml29623 }
18873859Sml29623 
18883859Sml29623 /* ARGSUSED */
18893859Sml29623 static int
18903859Sml29623 nxge_param_set_port_rdc(p_nxge_t nxgep, queue_t *q,
18913859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
18923859Sml29623 {
18933859Sml29623 	char		*end;
18943859Sml29623 	uint32_t	status = B_TRUE, cfg_value;
18953859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
18963859Sml29623 	uint32_t	cfg_it = B_FALSE;
18973859Sml29623 
18983859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
18993859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
19003859Sml29623 
19013859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_port_rdc"));
19023859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
19033859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
19043859Sml29623 
19053859Sml29623 	cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
19063859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
19073859Sml29623 		return (EINVAL);
19083859Sml29623 	}
19093859Sml29623 
19103859Sml29623 	if (pa->value != cfg_value) {
19113859Sml29623 		if (cfg_value >= p_cfgp->max_rdcs)
19123859Sml29623 			return (EINVAL);
19133859Sml29623 		pa->old_value = pa->value;
19143859Sml29623 		pa->value = cfg_value;
19153859Sml29623 		cfg_it = B_TRUE;
19163859Sml29623 	}
19173859Sml29623 
19183859Sml29623 	if (cfg_it == B_TRUE) {
19193859Sml29623 		status = nxge_rxdma_cfg_port_default_rdc(nxgep,
19203859Sml29623 			nxgep->function_num,
19213859Sml29623 			nxgep->rdc[cfg_value]);
19223859Sml29623 		if (status != NXGE_OK)
19233859Sml29623 			return (EINVAL);
19243859Sml29623 	}
19253859Sml29623 
19263859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_port_rdc"));
19273859Sml29623 	return (0);
19283859Sml29623 }
19293859Sml29623 
19303859Sml29623 /* ARGSUSED */
19313859Sml29623 static int
19323859Sml29623 nxge_param_set_nxge_debug_flag(p_nxge_t nxgep, queue_t *q,
19333859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
19343859Sml29623 {
19353859Sml29623 	char *end;
19363859Sml29623 	uint32_t status = 0;
19373859Sml29623 	uint64_t cfg_value = 0;
19383859Sml29623 	p_nxge_param_t pa = (p_nxge_param_t)cp;
19393859Sml29623 	uint32_t cfg_it = B_FALSE;
19403859Sml29623 
19413859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_nxge_debug_flag"));
19423859Sml29623 	cfg_value = mi_strtol(value, &end, BASE_HEX);
19433859Sml29623 
19443859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
19453859Sml29623 		NXGE_DEBUG_MSG((nxgep, NDD_CTL,
19463859Sml29623 			" nxge_param_set_nxge_debug_flag"
19473859Sml29623 			" outof range %llx", cfg_value));
19483859Sml29623 		return (EINVAL);
19493859Sml29623 	}
19503859Sml29623 	if (pa->value != cfg_value) {
19513859Sml29623 		pa->old_value = pa->value;
19523859Sml29623 		pa->value = cfg_value;
19533859Sml29623 		cfg_it = B_TRUE;
19543859Sml29623 	}
19553859Sml29623 
19563859Sml29623 	if (cfg_it == B_TRUE) {
19573859Sml29623 		nxgep->nxge_debug_level = pa->value;
19583859Sml29623 	}
19593859Sml29623 
19603859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_nxge_debug_flag"));
19613859Sml29623 	return (status);
19623859Sml29623 }
19633859Sml29623 
19643859Sml29623 /* ARGSUSED */
19653859Sml29623 static int
19663859Sml29623 nxge_param_get_debug_flag(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
19673859Sml29623 {
19683859Sml29623 	int		status = 0;
19693859Sml29623 	p_nxge_param_t	pa = (p_nxge_param_t)cp;
19703859Sml29623 
19713859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_debug_flag"));
19723859Sml29623 
19733859Sml29623 	if (pa->value > 0xffffffff)
19743859Sml29623 		(void) mi_mpprintf(mp, "%x%x",  (int)(pa->value >> 32),
19753859Sml29623 			(int)(pa->value & 0xffffffff));
19763859Sml29623 	else
19773859Sml29623 		(void) mi_mpprintf(mp, "%x", (int)pa->value);
19783859Sml29623 
19793859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_debug_flag"));
19803859Sml29623 	return (status);
19813859Sml29623 }
19823859Sml29623 
19833859Sml29623 /* ARGSUSED */
19843859Sml29623 static int
19853859Sml29623 nxge_param_set_npi_debug_flag(p_nxge_t nxgep, queue_t *q,
19863859Sml29623 	mblk_t *mp, char *value, caddr_t cp)
19873859Sml29623 {
19883859Sml29623 	char		*end;
19893859Sml29623 	uint32_t	status = 0;
19903859Sml29623 	uint64_t	 cfg_value = 0;
19913859Sml29623 	p_nxge_param_t	pa;
19923859Sml29623 	uint32_t	cfg_it = B_FALSE;
19933859Sml29623 
19943859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_npi_debug_flag"));
19953859Sml29623 	cfg_value = mi_strtol(value, &end, BASE_HEX);
19963859Sml29623 	pa = (p_nxge_param_t)cp;
19973859Sml29623 	if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
19983859Sml29623 		NXGE_DEBUG_MSG((nxgep, NDD_CTL, " nxge_param_set_npi_debug_flag"
19993859Sml29623 				    " outof range %llx", cfg_value));
20003859Sml29623 		return (EINVAL);
20013859Sml29623 	}
20023859Sml29623 	if (pa->value != cfg_value) {
20033859Sml29623 		pa->old_value = pa->value;
20043859Sml29623 		pa->value = cfg_value;
20053859Sml29623 		cfg_it = B_TRUE;
20063859Sml29623 	}
20073859Sml29623 
20083859Sml29623 	if (cfg_it == B_TRUE) {
20093859Sml29623 		npi_debug_level = pa->value;
20103859Sml29623 	}
20113859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_debug_flag"));
20123859Sml29623 	return (status);
20133859Sml29623 }
20143859Sml29623 
20153859Sml29623 /* ARGSUSED */
20163859Sml29623 static int
20173859Sml29623 nxge_param_dump_rdc(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
20183859Sml29623 {
20193859Sml29623 	uint_t rdc;
20203859Sml29623 
20213859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_rdc"));
20223859Sml29623 
20233859Sml29623 	(void) npi_rxdma_dump_fzc_regs(NXGE_DEV_NPI_HANDLE(nxgep));
20243859Sml29623 	for (rdc = 0; rdc < nxgep->nrdc; rdc++)
20253859Sml29623 		(void) nxge_dump_rxdma_channel(nxgep, nxgep->rdc[rdc]);
20263859Sml29623 
20273859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_rdc"));
20283859Sml29623 	return (0);
20293859Sml29623 }
20303859Sml29623 
20313859Sml29623 /* ARGSUSED */
20323859Sml29623 static int
20333859Sml29623 nxge_param_dump_tdc(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
20343859Sml29623 {
20353859Sml29623 	uint_t	tdc;
20363859Sml29623 
20373859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_tdc"));
20383859Sml29623 
20393859Sml29623 	for (tdc = 0; tdc < nxgep->ntdc; tdc++)
20403859Sml29623 		(void) nxge_txdma_regs_dump(nxgep, nxgep->tdc[tdc]);
20413859Sml29623 
20423859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_tdc"));
20433859Sml29623 	return (0);
20443859Sml29623 }
20453859Sml29623 
20463859Sml29623 /* ARGSUSED */
20473859Sml29623 static int
20483859Sml29623 nxge_param_dump_fflp_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
20493859Sml29623 {
20503859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_fflp_regs"));
20513859Sml29623 
20523859Sml29623 	(void) npi_fflp_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep));
20533859Sml29623 
20543859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_fflp_regs"));
20553859Sml29623 	return (0);
20563859Sml29623 }
20573859Sml29623 
20583859Sml29623 /* ARGSUSED */
20593859Sml29623 static int
20603859Sml29623 nxge_param_dump_mac_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
20613859Sml29623 {
20623859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_mac_regs"));
20633859Sml29623 
20643859Sml29623 	(void) npi_mac_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep),
20653859Sml29623 		nxgep->function_num);
20663859Sml29623 
20673859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_mac_regs"));
20683859Sml29623 	return (0);
20693859Sml29623 }
20703859Sml29623 
20713859Sml29623 /* ARGSUSED */
20723859Sml29623 static int
20733859Sml29623 nxge_param_dump_ipp_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
20743859Sml29623 {
20753859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_ipp_regs"));
20763859Sml29623 
20773859Sml29623 	(void) npi_ipp_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep),
20783859Sml29623 		nxgep->function_num);
20793859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_ipp_regs"));
20803859Sml29623 	return (0);
20813859Sml29623 }
20823859Sml29623 
20833859Sml29623 /* ARGSUSED */
20843859Sml29623 static int
20853859Sml29623 nxge_param_dump_vlan_table(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
20863859Sml29623 {
20873859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_dump_vlan_table"));
20883859Sml29623 
20893859Sml29623 	(void) npi_fflp_vlan_tbl_dump(NXGE_DEV_NPI_HANDLE(nxgep));
20903859Sml29623 
20913859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_dump_vlan_table"));
20923859Sml29623 	return (0);
20933859Sml29623 }
20943859Sml29623 
20953859Sml29623 /* ARGSUSED */
20963859Sml29623 static int
20973859Sml29623 nxge_param_dump_rdc_table(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
20983859Sml29623 {
20993859Sml29623 	uint8_t	table;
21003859Sml29623 
21013859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_dump_rdc_table"));
21023859Sml29623 	for (table = 0; table < NXGE_MAX_RDC_GROUPS; table++) {
21033859Sml29623 		(void) npi_rxdma_dump_rdc_table(NXGE_DEV_NPI_HANDLE(nxgep),
21043859Sml29623 					    table);
21053859Sml29623 	}
21063859Sml29623 
21073859Sml29623 	NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_dump_rdc_table"));
21083859Sml29623 	return (0);
21093859Sml29623 }
21103859Sml29623 
21113859Sml29623 typedef struct block_info {
21123859Sml29623 	char		*name;
21133859Sml29623 	uint32_t	offset;
21143859Sml29623 } block_info_t;
21153859Sml29623 
21163859Sml29623 block_info_t reg_block[] = {
21173859Sml29623 	{"PIO",		PIO},
21183859Sml29623 	{"FZC_PIO",	FZC_PIO},
21193859Sml29623 	{"FZC_XMAC",	FZC_MAC},
21203859Sml29623 	{"FZC_IPP",	FZC_IPP},
21213859Sml29623 	{"FFLP",	FFLP},
21223859Sml29623 	{"FZC_FFLP",	FZC_FFLP},
21233859Sml29623 	{"PIO_VADDR",	PIO_VADDR},
21243859Sml29623 	{"ZCP",	ZCP},
21253859Sml29623 	{"FZC_ZCP",	FZC_ZCP},
21263859Sml29623 	{"DMC",	DMC},
21273859Sml29623 	{"FZC_DMC",	FZC_DMC},
21283859Sml29623 	{"TXC",	TXC},
21293859Sml29623 	{"FZC_TXC",	FZC_TXC},
21303859Sml29623 	{"PIO_LDSV",	PIO_LDSV},
21313859Sml29623 	{"PIO_LDGIM",	PIO_LDGIM},
21323859Sml29623 	{"PIO_IMASK0",	PIO_IMASK0},
21333859Sml29623 	{"PIO_IMASK1",	PIO_IMASK1},
21343859Sml29623 	{"FZC_PROM",	FZC_PROM},
21353859Sml29623 	{"END",	ALL_FF_32},
21363859Sml29623 };
21373859Sml29623 
21383859Sml29623 /* ARGSUSED */
21393859Sml29623 static int
21403859Sml29623 nxge_param_dump_ptrs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
21413859Sml29623 {
21423859Sml29623 	uint_t			print_len, buf_len;
21433859Sml29623 	p_mblk_t		np;
21443859Sml29623 	int			rdc, tdc, block;
21453859Sml29623 	uint64_t		base;
21463859Sml29623 	p_nxge_dma_pt_cfg_t	p_dma_cfgp;
21473859Sml29623 	p_nxge_hw_pt_cfg_t	p_cfgp;
21483859Sml29623 	int			buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_8K;
21493859Sml29623 	p_tx_ring_t 		*tx_rings;
21503859Sml29623 	p_rx_rcr_rings_t 	rx_rcr_rings;
21513859Sml29623 	p_rx_rcr_ring_t		*rcr_rings;
21523859Sml29623 	p_rx_rbr_rings_t 	rx_rbr_rings;
21533859Sml29623 	p_rx_rbr_ring_t		*rbr_rings;
21543859Sml29623 
21553859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL,
21563859Sml29623 		"==> nxge_param_dump_ptrs"));
21573859Sml29623 
21583859Sml29623 	(void) mi_mpprintf(mp, "ptr information for Port\t %d \n",
21593859Sml29623 		nxgep->function_num);
21603859Sml29623 
21613859Sml29623 	if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
21623859Sml29623 		/* The following may work even if we cannot get a large buf. */
21633859Sml29623 		(void) mi_mpprintf(mp, "%s\n", "out of buffer");
21643859Sml29623 		return (0);
21653859Sml29623 	}
21663859Sml29623 
21673859Sml29623 	buf_len = buff_alloc_size;
21683859Sml29623 	mp->b_cont = np;
21693859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
21703859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
21713859Sml29623 
21723859Sml29623 	rx_rcr_rings = nxgep->rx_rcr_rings;
21733859Sml29623 	rcr_rings = rx_rcr_rings->rcr_rings;
21743859Sml29623 	rx_rbr_rings = nxgep->rx_rbr_rings;
21753859Sml29623 	rbr_rings = rx_rbr_rings->rbr_rings;
21763859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
21773859Sml29623 		"nxgep (nxge_t) $%p\n"
21783859Sml29623 		"dev_regs (dev_regs_t) $%p\n",
21793859Sml29623 		nxgep, nxgep->dev_regs);
21803859Sml29623 
21813859Sml29623 	ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
21823859Sml29623 
21833859Sml29623 	/* do register pointers */
21843859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
21853859Sml29623 		"reg base (npi_reg_ptr_t) $%p\t "
21863859Sml29623 		"pci reg (npi_reg_ptr_t) $%p\n",
21873859Sml29623 		nxgep->dev_regs->nxge_regp,
21883859Sml29623 		nxgep->dev_regs->nxge_pciregp);
21893859Sml29623 
21903859Sml29623 	ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
21913859Sml29623 
21923859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
21933859Sml29623 		"\nBlock \t Offset \n");
21943859Sml29623 
21953859Sml29623 	ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
21963859Sml29623 	block = 0;
21973859Sml29623 	base = (uint64_t)nxgep->dev_regs->nxge_regp;
21983859Sml29623 	while (reg_block[block].offset != ALL_FF_32) {
21993859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
22003859Sml29623 			"%9s\t 0x%llx\n",
22013859Sml29623 			reg_block[block].name,
22023859Sml29623 			(unsigned long long)(reg_block[block].offset + base));
22033859Sml29623 		ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
22043859Sml29623 		block++;
22053859Sml29623 	}
22063859Sml29623 
22073859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
22083859Sml29623 		"\nRDC\t rcrp (rx_rcr_ring_t)\t "
22093859Sml29623 		"rbrp (rx_rbr_ring_t)\n");
22103859Sml29623 
22113859Sml29623 	ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
22123859Sml29623 
22133859Sml29623 	for (rdc = 0; rdc < p_cfgp->max_rdcs; rdc++) {
22143859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
22153859Sml29623 			" %d\t  $%p\t\t   $%p\n",
22163859Sml29623 			rdc, rcr_rings[rdc],
22173859Sml29623 			rbr_rings[rdc]);
22183859Sml29623 		ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
22193859Sml29623 	}
22203859Sml29623 
22213859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
22223859Sml29623 			    "\nTDC\t tdcp (tx_ring_t)\n");
22233859Sml29623 
22243859Sml29623 	ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
22253859Sml29623 	tx_rings = nxgep->tx_rings->rings;
22263859Sml29623 	for (tdc = 0; tdc < p_cfgp->max_tdcs; tdc++) {
22273859Sml29623 		print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
22283859Sml29623 			" %d\t  $%p\n", tdc, tx_rings[tdc]);
22293859Sml29623 		ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
22303859Sml29623 	}
22313859Sml29623 
22323859Sml29623 	print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, "\n\n");
22333859Sml29623 
22343859Sml29623 	ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
22353859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_ptrs"));
22363859Sml29623 	return (0);
22373859Sml29623 }
22383859Sml29623 
22393859Sml29623 /*
22403859Sml29623  * Load 'name' into the named dispatch table pointed to by 'ndp'.
22413859Sml29623  * 'ndp' should be the address of a char pointer cell.  If the table
22423859Sml29623  * does not exist (*ndp == 0), a new table is allocated and 'ndp'
22433859Sml29623  * is stuffed.  If there is not enough space in the table for a new
22443859Sml29623  * entry, more space is allocated.
22453859Sml29623  */
22463859Sml29623 /* ARGSUSED */
22473859Sml29623 boolean_t
22483859Sml29623 nxge_nd_load(caddr_t *pparam, char *name,
22493859Sml29623 	pfi_t get_pfi, pfi_t set_pfi, caddr_t data)
22503859Sml29623 {
22513859Sml29623 	ND	*nd;
22523859Sml29623 	NDE	*nde;
22533859Sml29623 
22543859Sml29623 	NXGE_DEBUG_MSG((NULL, NDD2_CTL, " ==> nxge_nd_load"));
22553859Sml29623 	if (!pparam)
22563859Sml29623 		return (B_FALSE);
22573859Sml29623 
22583859Sml29623 	if ((nd = (ND *)*pparam) == NULL) {
22593859Sml29623 		if ((nd = (ND *)KMEM_ZALLOC(sizeof (ND), KM_NOSLEEP)) == NULL)
22603859Sml29623 			return (B_FALSE);
22613859Sml29623 		*pparam = (caddr_t)nd;
22623859Sml29623 	}
22633859Sml29623 
22643859Sml29623 	if (nd->nd_tbl) {
22653859Sml29623 		for (nde = nd->nd_tbl; nde->nde_name; nde++) {
22663859Sml29623 			if (strcmp(name, nde->nde_name) == 0)
22673859Sml29623 				goto fill_it;
22683859Sml29623 		}
22693859Sml29623 	}
22703859Sml29623 
22713859Sml29623 	if (nd->nd_free_count <= 1) {
22723859Sml29623 		if ((nde = (NDE *)KMEM_ZALLOC(nd->nd_size +
22733859Sml29623 					NDE_ALLOC_SIZE, KM_NOSLEEP)) == NULL)
22743859Sml29623 			return (B_FALSE);
22753859Sml29623 		nd->nd_free_count += NDE_ALLOC_COUNT;
22763859Sml29623 		if (nd->nd_tbl) {
22773859Sml29623 			bcopy((char *)nd->nd_tbl, (char *)nde, nd->nd_size);
22783859Sml29623 			KMEM_FREE((char *)nd->nd_tbl, nd->nd_size);
22793859Sml29623 		} else {
22803859Sml29623 			nd->nd_free_count--;
22813859Sml29623 			nde->nde_name = "?";
22823859Sml29623 			nde->nde_get_pfi = nxge_nd_get_names;
22833859Sml29623 			nde->nde_set_pfi = nxge_set_default;
22843859Sml29623 		}
22853859Sml29623 		nde->nde_data = (caddr_t)nd;
22863859Sml29623 		nd->nd_tbl = nde;
22873859Sml29623 		nd->nd_size += NDE_ALLOC_SIZE;
22883859Sml29623 	}
22893859Sml29623 	for (nde = nd->nd_tbl; nde->nde_name; nde++)
22903859Sml29623 		noop;
22913859Sml29623 	nd->nd_free_count--;
22923859Sml29623 fill_it:
22933859Sml29623 	nde->nde_name = name;
22943859Sml29623 	nde->nde_get_pfi = get_pfi;
22953859Sml29623 	nde->nde_set_pfi = set_pfi;
22963859Sml29623 	nde->nde_data = data;
22973859Sml29623 	NXGE_DEBUG_MSG((NULL, NDD2_CTL, " <== nxge_nd_load"));
22983859Sml29623 
22993859Sml29623 	return (B_TRUE);
23003859Sml29623 }
23013859Sml29623 
23023859Sml29623 /*
23033859Sml29623  * Free the table pointed to by 'pparam'
23043859Sml29623  */
23053859Sml29623 void
23063859Sml29623 nxge_nd_free(caddr_t *pparam)
23073859Sml29623 {
23083859Sml29623 	ND *nd;
23093859Sml29623 
23103859Sml29623 	if ((nd = (ND *)*pparam) != NULL) {
23113859Sml29623 		if (nd->nd_tbl)
23123859Sml29623 			KMEM_FREE((char *)nd->nd_tbl, nd->nd_size);
23133859Sml29623 		KMEM_FREE((char *)nd, sizeof (ND));
23143859Sml29623 		*pparam = nil(caddr_t);
23153859Sml29623 	}
23163859Sml29623 }
23173859Sml29623 
23183859Sml29623 int
23193859Sml29623 nxge_nd_getset(p_nxge_t nxgep, queue_t *q, caddr_t param, p_mblk_t mp)
23203859Sml29623 {
23213859Sml29623 	int		err;
23223859Sml29623 	IOCP		iocp;
23233859Sml29623 	p_mblk_t	mp1, mp2;
23243859Sml29623 	ND		*nd;
23253859Sml29623 	NDE		*nde;
23263859Sml29623 	char		*valp;
23273859Sml29623 	size_t		avail;
23283859Sml29623 
23293859Sml29623 	if (!param) {
23303859Sml29623 		return (B_FALSE);
23313859Sml29623 	}
23323859Sml29623 
23333859Sml29623 	nd = (ND *)param;
23343859Sml29623 	iocp = (IOCP)mp->b_rptr;
23353859Sml29623 	if ((iocp->ioc_count == 0) || !(mp1 = mp->b_cont)) {
23363859Sml29623 		mp->b_datap->db_type = M_IOCACK;
23373859Sml29623 		iocp->ioc_count = 0;
23383859Sml29623 		iocp->ioc_error = EINVAL;
23393859Sml29623 		return (B_FALSE);
23403859Sml29623 	}
23413859Sml29623 
23423859Sml29623 	/*
23433859Sml29623 	 * NOTE - logic throughout nd_xxx assumes single data block for ioctl.
23443859Sml29623 	 *	However, existing code sends in some big buffers.
23453859Sml29623 	 */
23463859Sml29623 	avail = iocp->ioc_count;
23473859Sml29623 	if (mp1->b_cont) {
23483859Sml29623 		freemsg(mp1->b_cont);
23493859Sml29623 		mp1->b_cont = NULL;
23503859Sml29623 	}
23513859Sml29623 
23523859Sml29623 	mp1->b_datap->db_lim[-1] = '\0';	/* Force null termination */
23533859Sml29623 	for (valp = (char *)mp1->b_rptr; *valp != '\0'; valp++) {
23543859Sml29623 		if (*valp == '-')
23553859Sml29623 			*valp = '_';
23563859Sml29623 	}
23573859Sml29623 
23583859Sml29623 	valp = (char *)mp1->b_rptr;
23593859Sml29623 
23603859Sml29623 	for (nde = nd->nd_tbl; /* */; nde++) {
23613859Sml29623 		if (!nde->nde_name)
23623859Sml29623 			return (B_FALSE);
23633859Sml29623 		if (strcmp(nde->nde_name, valp) == 0)
23643859Sml29623 			break;
23653859Sml29623 	}
23663859Sml29623 	err = EINVAL;
23673859Sml29623 	while (*valp++)
23683859Sml29623 		noop;
23693859Sml29623 	if (!*valp || valp >= (char *)mp1->b_wptr)
23703859Sml29623 		valp = nilp(char);
23713859Sml29623 	switch (iocp->ioc_cmd) {
23723859Sml29623 	case ND_GET:
23733859Sml29623 		/*
23743859Sml29623 		 * (temporary) hack: "*valp" is size of user buffer for
23753859Sml29623 		 * copyout. If result of action routine is too big, free
23763859Sml29623 		 * excess and return ioc_rval as buffer size needed.
23773859Sml29623 		 * Return as many mblocks as will fit, free the rest.  For
23783859Sml29623 		 * backward compatibility, assume size of original ioctl
23793859Sml29623 		 * buffer if "*valp" bad or not given.
23803859Sml29623 		 */
23813859Sml29623 		if (valp)
23823859Sml29623 			avail = mi_strtol(valp, (char **)0, 10);
23833859Sml29623 		/*
23843859Sml29623 		 * We overwrite the name/value with the reply data
23853859Sml29623 		 */
23863859Sml29623 		mp2 = mp1;
23873859Sml29623 		while (mp2) {
23883859Sml29623 			mp2->b_wptr = mp2->b_rptr;
23893859Sml29623 			mp2 = mp2->b_cont;
23903859Sml29623 		}
23913859Sml29623 
2392*4439Sml29623 		if (nde->nde_get_pfi) {
2393*4439Sml29623 			err = (*nde->nde_get_pfi)(nxgep, q, mp1, nde->nde_data);
2394*4439Sml29623 		}
23953859Sml29623 
23963859Sml29623 		if (!err) {
23973859Sml29623 			size_t	size_out = 0;
23983859Sml29623 			size_t	excess;
23993859Sml29623 
24003859Sml29623 			iocp->ioc_rval = 0;
24013859Sml29623 
24023859Sml29623 			/* Tack on the null */
24033859Sml29623 			err = nxge_mk_mblk_tail_space(mp1, &mp2, 1);
24043859Sml29623 			if (!err) {
24053859Sml29623 				*mp2->b_wptr++ = '\0';
24063859Sml29623 				size_out = msgdsize(mp1);
24073859Sml29623 				excess = size_out - avail;
24083859Sml29623 				if (excess > 0) {
24093859Sml29623 					iocp->ioc_rval = (int)size_out;
24103859Sml29623 					size_out -= excess;
24113859Sml29623 					(void) adjmsg(mp1, -(excess + 1));
24123859Sml29623 					err = nxge_mk_mblk_tail_space(
24133859Sml29623 							mp1, &mp2, 1);
24143859Sml29623 					if (!err)
24153859Sml29623 						*mp2->b_wptr++ = '\0';
24163859Sml29623 					else
24173859Sml29623 						size_out = 0;
24183859Sml29623 				}
24193859Sml29623 			} else
24203859Sml29623 				size_out = 0;
24213859Sml29623 			iocp->ioc_count = size_out;
24223859Sml29623 		}
24233859Sml29623 		break;
24243859Sml29623 
24253859Sml29623 	case ND_SET:
24263859Sml29623 		if (valp) {
24273859Sml29623 			if (nde->nde_set_pfi) {
24283859Sml29623 				err = (*nde->nde_set_pfi)(nxgep, q, mp1, valp,
24293859Sml29623 							    nde->nde_data);
24303859Sml29623 				iocp->ioc_count = 0;
24313859Sml29623 				freemsg(mp1);
24323859Sml29623 				mp->b_cont = NULL;
24333859Sml29623 			}
24343859Sml29623 		}
24353859Sml29623 		break;
24363859Sml29623 
24373859Sml29623 	default:
24383859Sml29623 		break;
24393859Sml29623 	}
24403859Sml29623 	iocp->ioc_error = err;
24413859Sml29623 	mp->b_datap->db_type = M_IOCACK;
24423859Sml29623 	return (B_TRUE);
24433859Sml29623 }
24443859Sml29623 
24453859Sml29623 /* ARGSUSED */
24463859Sml29623 int
24473859Sml29623 nxge_nd_get_names(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t param)
24483859Sml29623 {
24493859Sml29623 	ND		*nd;
24503859Sml29623 	NDE		*nde;
24513859Sml29623 	char		*rwtag;
24523859Sml29623 	boolean_t	get_ok, set_ok;
24533859Sml29623 	size_t		param_len;
24543859Sml29623 	int		status = 0;
24553859Sml29623 
24563859Sml29623 	nd = (ND *)param;
24573859Sml29623 	if (!nd)
24583859Sml29623 		return (ENOENT);
24593859Sml29623 
24603859Sml29623 	for (nde = nd->nd_tbl; nde->nde_name; nde++) {
24613859Sml29623 		get_ok = (nde->nde_get_pfi != nxge_get_default) &&
24623859Sml29623 				(nde->nde_get_pfi != NULL);
24633859Sml29623 		set_ok = (nde->nde_set_pfi != nxge_set_default) &&
24643859Sml29623 				(nde->nde_set_pfi != NULL);
24653859Sml29623 		if (get_ok) {
24663859Sml29623 			if (set_ok)
24673859Sml29623 				rwtag = "read and write";
24683859Sml29623 			else
24693859Sml29623 				rwtag = "read only";
24703859Sml29623 		} else if (set_ok)
24713859Sml29623 			rwtag = "write only";
24723859Sml29623 		else {
24733859Sml29623 			continue;
24743859Sml29623 		}
24753859Sml29623 		param_len = strlen(rwtag);
24763859Sml29623 		param_len += strlen(nde->nde_name);
24773859Sml29623 		param_len += 4;
24783859Sml29623 
24793859Sml29623 		(void) mi_mpprintf(mp, "%s (%s)", nde->nde_name, rwtag);
24803859Sml29623 	}
24813859Sml29623 	return (status);
24823859Sml29623 }
24833859Sml29623 
24843859Sml29623 /* ARGSUSED */
24853859Sml29623 int
24863859Sml29623 nxge_get_default(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t data)
24873859Sml29623 {
24883859Sml29623 	return (EACCES);
24893859Sml29623 }
24903859Sml29623 
24913859Sml29623 /* ARGSUSED */
24923859Sml29623 int
24933859Sml29623 nxge_set_default(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, char *value,
24943859Sml29623 	caddr_t data)
24953859Sml29623 {
24963859Sml29623 	return (EACCES);
24973859Sml29623 }
24983859Sml29623 
24993859Sml29623 void
25003859Sml29623 nxge_param_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, struct iocblk *iocp)
25013859Sml29623 {
25023859Sml29623 	int		cmd;
25033859Sml29623 	int		status = B_FALSE;
25043859Sml29623 
25053859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_ioctl"));
25063859Sml29623 	cmd = iocp->ioc_cmd;
25073859Sml29623 
25083859Sml29623 	switch (cmd) {
25093859Sml29623 	default:
25103859Sml29623 		NXGE_DEBUG_MSG((nxgep, IOC_CTL,
25113859Sml29623 			"nxge_param_ioctl: bad cmd 0x%0x", cmd));
25123859Sml29623 		break;
25133859Sml29623 
25143859Sml29623 	case ND_GET:
25153859Sml29623 	case ND_SET:
25163859Sml29623 		NXGE_DEBUG_MSG((nxgep, IOC_CTL,
25173859Sml29623 			"nxge_param_ioctl: cmd 0x%0x", cmd));
25183859Sml29623 		if (!nxge_nd_getset(nxgep, wq, nxgep->param_list, mp)) {
25193859Sml29623 			NXGE_DEBUG_MSG((nxgep, IOC_CTL,
25203859Sml29623 				"false ret from nxge_nd_getset"));
25213859Sml29623 			break;
25223859Sml29623 		}
25233859Sml29623 		status = B_TRUE;
25243859Sml29623 		break;
25253859Sml29623 	}
25263859Sml29623 
25273859Sml29623 	if (status) {
25283859Sml29623 		qreply(wq, mp);
25293859Sml29623 	} else {
25303859Sml29623 		miocnak(wq, mp, 0, EINVAL);
25313859Sml29623 	}
25323859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_ioctl"));
25333859Sml29623 }
25343859Sml29623 
25353859Sml29623 /* ARGSUSED */
25363859Sml29623 static boolean_t
25373859Sml29623 nxge_param_link_update(p_nxge_t nxgep)
25383859Sml29623 {
25393859Sml29623 	p_nxge_param_t 		param_arr;
25403859Sml29623 	nxge_param_index_t 	i;
25413859Sml29623 	boolean_t 		update_xcvr;
25423859Sml29623 	boolean_t 		update_dev;
25433859Sml29623 	int 			instance;
25443859Sml29623 	boolean_t 		status = B_TRUE;
25453859Sml29623 
25463859Sml29623 	NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_link_update"));
25473859Sml29623 
25483859Sml29623 	param_arr = nxgep->param_arr;
25493859Sml29623 	instance = nxgep->instance;
25503859Sml29623 	update_xcvr = B_FALSE;
25513859Sml29623 	for (i = param_anar_1000fdx; i < param_anar_asmpause; i++) {
25523859Sml29623 		update_xcvr |= param_arr[i].value;
25533859Sml29623 	}
25543859Sml29623 
25553859Sml29623 	if (update_xcvr) {
25563859Sml29623 		update_xcvr = B_FALSE;
25573859Sml29623 		for (i = param_autoneg; i < param_enable_ipg0; i++) {
25583859Sml29623 			update_xcvr |=
25593859Sml29623 				(param_arr[i].value != param_arr[i].old_value);
25603859Sml29623 			param_arr[i].old_value = param_arr[i].value;
25613859Sml29623 		}
25623859Sml29623 		if (update_xcvr) {
25633859Sml29623 			RW_ENTER_WRITER(&nxgep->filter_lock);
25643859Sml29623 			(void) nxge_link_monitor(nxgep, LINK_MONITOR_STOP);
25653859Sml29623 			(void) nxge_link_init(nxgep);
25663859Sml29623 			(void) nxge_mac_init(nxgep);
25673859Sml29623 			(void) nxge_link_monitor(nxgep, LINK_MONITOR_START);
25683859Sml29623 			RW_EXIT(&nxgep->filter_lock);
25693859Sml29623 		}
25703859Sml29623 	} else {
25713859Sml29623 		cmn_err(CE_WARN, " Last setting will leave nxge%d with "
25723859Sml29623 				" no link capabilities.", instance);
25733859Sml29623 		cmn_err(CE_WARN, " Restoring previous setting.");
25743859Sml29623 		for (i = param_anar_1000fdx; i < param_anar_asmpause; i++)
25753859Sml29623 			param_arr[i].value = param_arr[i].old_value;
25763859Sml29623 	}
25773859Sml29623 
25783859Sml29623 	update_dev = B_FALSE;
25793859Sml29623 
25803859Sml29623 	if (update_dev) {
25813859Sml29623 		RW_ENTER_WRITER(&nxgep->filter_lock);
25823859Sml29623 		(void) nxge_rx_mac_disable(nxgep);
25833859Sml29623 		(void) nxge_tx_mac_disable(nxgep);
25843859Sml29623 		(void) nxge_tx_mac_enable(nxgep);
25853859Sml29623 		(void) nxge_rx_mac_enable(nxgep);
25863859Sml29623 		RW_EXIT(&nxgep->filter_lock);
25873859Sml29623 	}
25883859Sml29623 
25893859Sml29623 nxge_param_hw_update_exit:
25903859Sml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL,
25913859Sml29623 			"<== nxge_param_link_update status = 0x%08x", status));
25923859Sml29623 	return (status);
25933859Sml29623 }
2594