xref: /onnv-gate/usr/src/uts/common/io/nxge/nxge_virtual.c (revision 7466:25741b6dec4e)
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 /*
226003Sml29623  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
233859Sml29623  * Use is subject to license terms.
243859Sml29623  */
253859Sml29623 
263859Sml29623 #include <sys/nxge/nxge_impl.h>
273859Sml29623 #include <sys/nxge/nxge_mac.h>
286495Sspeer #include <sys/nxge/nxge_hio.h>
293859Sml29623 
303859Sml29623 static void nxge_get_niu_property(dev_info_t *, niu_type_t *);
313859Sml29623 static nxge_status_t nxge_get_mac_addr_properties(p_nxge_t);
323859Sml29623 static nxge_status_t nxge_use_cfg_n2niu_properties(p_nxge_t);
333859Sml29623 static void nxge_use_cfg_neptune_properties(p_nxge_t);
343859Sml29623 static void nxge_use_cfg_dma_config(p_nxge_t);
353859Sml29623 static void nxge_use_cfg_vlan_class_config(p_nxge_t);
363859Sml29623 static void nxge_use_cfg_mac_class_config(p_nxge_t);
373859Sml29623 static void nxge_use_cfg_class_config(p_nxge_t);
383859Sml29623 static void nxge_use_cfg_link_cfg(p_nxge_t);
393859Sml29623 static void nxge_set_hw_dma_config(p_nxge_t);
403859Sml29623 static void nxge_set_hw_vlan_class_config(p_nxge_t);
413859Sml29623 static void nxge_set_hw_mac_class_config(p_nxge_t);
423859Sml29623 static void nxge_set_hw_class_config(p_nxge_t);
433859Sml29623 static nxge_status_t nxge_use_default_dma_config_n2(p_nxge_t);
443859Sml29623 static void nxge_ldgv_setup(p_nxge_ldg_t *, p_nxge_ldv_t *, uint8_t,
453859Sml29623 	uint8_t, int *);
464732Sdavemq static void nxge_init_mmac(p_nxge_t, boolean_t);
476495Sspeer static void nxge_set_rdc_intr_property(p_nxge_t);
483859Sml29623 
493859Sml29623 uint32_t nxge_use_hw_property = 1;
503859Sml29623 uint32_t nxge_groups_per_port = 2;
513859Sml29623 
523859Sml29623 extern uint32_t nxge_use_partition;
533859Sml29623 extern uint32_t nxge_dma_obp_props_only;
543859Sml29623 
553859Sml29623 extern uint16_t nxge_rcr_timeout;
563859Sml29623 extern uint16_t nxge_rcr_threshold;
573859Sml29623 
583859Sml29623 extern uint_t nxge_rx_intr(void *, void *);
593859Sml29623 extern uint_t nxge_tx_intr(void *, void *);
603859Sml29623 extern uint_t nxge_mif_intr(void *, void *);
613859Sml29623 extern uint_t nxge_mac_intr(void *, void *);
623859Sml29623 extern uint_t nxge_syserr_intr(void *, void *);
633859Sml29623 extern void *nxge_list;
643859Sml29623 
653859Sml29623 #define	NXGE_SHARED_REG_SW_SIM
663859Sml29623 
673859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
683859Sml29623 uint64_t global_dev_ctrl = 0;
693859Sml29623 #endif
703859Sml29623 
713859Sml29623 #define	MAX_SIBLINGS	NXGE_MAX_PORTS
723859Sml29623 
733859Sml29623 extern uint32_t nxge_rbr_size;
743859Sml29623 extern uint32_t nxge_rcr_size;
753859Sml29623 extern uint32_t nxge_tx_ring_size;
763859Sml29623 extern uint32_t nxge_rbr_spare_size;
773859Sml29623 
783859Sml29623 extern npi_status_t npi_mac_altaddr_disable(npi_handle_t, uint8_t, uint8_t);
793859Sml29623 
803859Sml29623 static uint8_t p2_tx_fair[2] = {12, 12};
813859Sml29623 static uint8_t p2_tx_equal[2] = {12, 12};
823859Sml29623 static uint8_t p4_tx_fair[4] = {6, 6, 6, 6};
833859Sml29623 static uint8_t p4_tx_equal[4] = {6, 6, 6, 6};
843859Sml29623 static uint8_t p2_rx_fair[2] = {8, 8};
853859Sml29623 static uint8_t p2_rx_equal[2] = {8, 8};
863859Sml29623 static uint8_t p4_rx_fair[4] = {4, 4, 4, 4};
873859Sml29623 static uint8_t p4_rx_equal[4] = {4, 4, 4, 4};
883859Sml29623 
893859Sml29623 static uint8_t p2_rdcgrp_fair[2] = {4, 4};
903859Sml29623 static uint8_t p2_rdcgrp_equal[2] = {4, 4};
913859Sml29623 static uint8_t p4_rdcgrp_fair[4] = {2, 2, 1, 1};
923859Sml29623 static uint8_t p4_rdcgrp_equal[4] = {2, 2, 2, 2};
933859Sml29623 static uint8_t p2_rdcgrp_cls[2] = {1, 1};
943859Sml29623 static uint8_t p4_rdcgrp_cls[4] = {1, 1, 1, 1};
953859Sml29623 
964732Sdavemq static uint8_t rx_4_1G[4] = {4, 4, 4, 4};
974732Sdavemq static uint8_t rx_2_10G[2] = {8, 8};
984732Sdavemq static uint8_t rx_2_10G_2_1G[4] = {6, 6, 2, 2};
994732Sdavemq static uint8_t rx_1_10G_3_1G[4] = {10, 2, 2, 2};
1004732Sdavemq static uint8_t rx_1_1G_1_10G_2_1G[4] = {2, 10, 2, 2};
1014732Sdavemq 
1024732Sdavemq static uint8_t tx_4_1G[4] = {6, 6, 6, 6};
1034732Sdavemq static uint8_t tx_2_10G[2] = {12, 12};
1044732Sdavemq static uint8_t tx_2_10G_2_1G[4] = {10, 10, 2, 2};
1054732Sdavemq static uint8_t tx_1_10G_3_1G[4] = {12, 4, 4, 4};
1064732Sdavemq static uint8_t tx_1_1G_1_10G_2_1G[4] = {4, 12, 4, 4};
1074732Sdavemq 
1083859Sml29623 typedef enum {
1093859Sml29623 	DEFAULT = 0,
1103859Sml29623 	EQUAL,
1113859Sml29623 	FAIR,
1123859Sml29623 	CUSTOM,
1133859Sml29623 	CLASSIFY,
1143859Sml29623 	L2_CLASSIFY,
1153859Sml29623 	L3_DISTRIBUTE,
1163859Sml29623 	L3_CLASSIFY,
1173859Sml29623 	L3_TCAM,
1183859Sml29623 	CONFIG_TOKEN_NONE
1193859Sml29623 } config_token_t;
1203859Sml29623 
1213859Sml29623 static char *token_names[] = {
1223859Sml29623 	"default",
1233859Sml29623 	"equal",
1243859Sml29623 	"fair",
1253859Sml29623 	"custom",
1263859Sml29623 	"classify",
1273859Sml29623 	"l2_classify",
1283859Sml29623 	"l3_distribute",
1293859Sml29623 	"l3_classify",
1303859Sml29623 	"l3_tcam",
1313859Sml29623 	"none",
1323859Sml29623 };
1333859Sml29623 
1343859Sml29623 void nxge_virint_regs_dump(p_nxge_t nxgep);
1353859Sml29623 
1363859Sml29623 void
1373859Sml29623 nxge_virint_regs_dump(p_nxge_t nxgep)
1383859Sml29623 {
1393859Sml29623 	npi_handle_t handle;
1403859Sml29623 
1413859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_virint_regs_dump"));
1423859Sml29623 	handle = NXGE_DEV_NPI_HANDLE(nxgep);
1433859Sml29623 	(void) npi_vir_dump_pio_fzc_regs_one(handle);
1443859Sml29623 	(void) npi_vir_dump_ldgnum(handle);
1453859Sml29623 	(void) npi_vir_dump_ldsv(handle);
1463859Sml29623 	(void) npi_vir_dump_imask0(handle);
1473859Sml29623 	(void) npi_vir_dump_sid(handle);
1483859Sml29623 	(void) npi_mac_dump_regs(handle, nxgep->function_num);
1493859Sml29623 	(void) npi_ipp_dump_regs(handle, nxgep->function_num);
1503859Sml29623 	(void) npi_fflp_dump_regs(handle);
1513859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_virint_regs_dump"));
1523859Sml29623 }
1533859Sml29623 
1543859Sml29623 /*
1553859Sml29623  * For now: we hard coded the DMA configurations.
1563859Sml29623  *	    and assume for one partition only.
1573859Sml29623  *
1583859Sml29623  *       OBP. Then OBP will pass this partition's
1593859Sml29623  *	 Neptune configurations to fcode to create
1603859Sml29623  *	 properties for them.
1613859Sml29623  *
1623859Sml29623  *	Since Neptune(PCI-E) and NIU (Niagara-2) has
1633859Sml29623  *	different bus interfaces, the driver needs
1643859Sml29623  *	to know which bus it is connected to.
1653859Sml29623  *  	Ravinder suggested: create a device property.
1663859Sml29623  *	In partitioning environment, we cannot
1673859Sml29623  *	use .conf file (need to check). If conf changes,
1683859Sml29623  *	need to reboot the system.
1693859Sml29623  *	The following function assumes that we will
1703859Sml29623  *	retrieve its properties from a virtualized nexus driver.
1713859Sml29623  */
1723859Sml29623 
1733859Sml29623 nxge_status_t
1743859Sml29623 nxge_cntlops(dev_info_t *dip, nxge_ctl_enum_t ctlop, void *arg, void *result)
1753859Sml29623 {
1763859Sml29623 	nxge_status_t status = NXGE_OK;
1773859Sml29623 	int instance;
1783859Sml29623 	p_nxge_t nxgep;
1793859Sml29623 
1803859Sml29623 #ifndef NXGE_SHARED_REG_SW_SIM
1813859Sml29623 	npi_handle_t handle;
1823859Sml29623 	uint16_t sr16, cr16;
1833859Sml29623 #endif
1843859Sml29623 	instance = ddi_get_instance(dip);
1853859Sml29623 	NXGE_DEBUG_MSG((NULL, VIR_CTL, "Instance %d ", instance));
1863859Sml29623 
1873859Sml29623 	if (nxge_list == NULL) {
1883859Sml29623 		NXGE_ERROR_MSG((NULL, NXGE_ERR_CTL,
1896929Smisaki 		    "nxge_cntlops: nxge_list null"));
1903859Sml29623 		return (NXGE_ERROR);
1913859Sml29623 	}
1923859Sml29623 	nxgep = (p_nxge_t)ddi_get_soft_state(nxge_list, instance);
1933859Sml29623 	if (nxgep == NULL) {
1943859Sml29623 		NXGE_ERROR_MSG((NULL, NXGE_ERR_CTL,
1956929Smisaki 		    "nxge_cntlops: nxgep null"));
1963859Sml29623 		return (NXGE_ERROR);
1973859Sml29623 	}
1983859Sml29623 #ifndef NXGE_SHARED_REG_SW_SIM
1993859Sml29623 	handle = nxgep->npi_reg_handle;
2003859Sml29623 #endif
2013859Sml29623 	switch (ctlop) {
2023859Sml29623 	case NXGE_CTLOPS_NIUTYPE:
2033859Sml29623 		nxge_get_niu_property(dip, (niu_type_t *)result);
2043859Sml29623 		return (status);
2053859Sml29623 
2063859Sml29623 	case NXGE_CTLOPS_GET_SHARED_REG:
2073859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
2083859Sml29623 		*(uint64_t *)result = global_dev_ctrl;
2093859Sml29623 		return (0);
2103859Sml29623 #else
2113859Sml29623 		status = npi_dev_func_sr_sr_get(handle, &sr16);
2123859Sml29623 		*(uint16_t *)result = sr16;
2133859Sml29623 		NXGE_DEBUG_MSG((NULL, VIR_CTL,
2146929Smisaki 		    "nxge_cntlops: NXGE_CTLOPS_GET_SHARED_REG"));
2153859Sml29623 		return (0);
2163859Sml29623 #endif
2173859Sml29623 
2183859Sml29623 	case NXGE_CTLOPS_SET_SHARED_REG_LOCK:
2193859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
2203859Sml29623 		global_dev_ctrl = *(uint64_t *)arg;
2213859Sml29623 		return (0);
2223859Sml29623 #else
2233859Sml29623 		status = NPI_FAILURE;
2243859Sml29623 		while (status != NPI_SUCCESS)
2253859Sml29623 			status = npi_dev_func_sr_lock_enter(handle);
2263859Sml29623 
2273859Sml29623 		sr16 = *(uint16_t *)arg;
2283859Sml29623 		status = npi_dev_func_sr_sr_set_only(handle, &sr16);
2293859Sml29623 		status = npi_dev_func_sr_lock_free(handle);
2303859Sml29623 		NXGE_DEBUG_MSG((NULL, VIR_CTL,
2316929Smisaki 		    "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG"));
2323859Sml29623 		return (0);
2333859Sml29623 #endif
2343859Sml29623 
2353859Sml29623 	case NXGE_CTLOPS_UPDATE_SHARED_REG:
2363859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
2373859Sml29623 		global_dev_ctrl |= *(uint64_t *)arg;
2383859Sml29623 		return (0);
2393859Sml29623 #else
2403859Sml29623 		status = NPI_FAILURE;
2413859Sml29623 		while (status != NPI_SUCCESS)
2423859Sml29623 			status = npi_dev_func_sr_lock_enter(handle);
2433859Sml29623 		status = npi_dev_func_sr_sr_get(handle, &sr16);
2443859Sml29623 		sr16 |= *(uint16_t *)arg;
2453859Sml29623 		status = npi_dev_func_sr_sr_set_only(handle, &sr16);
2463859Sml29623 		status = npi_dev_func_sr_lock_free(handle);
2473859Sml29623 		NXGE_DEBUG_MSG((NULL, VIR_CTL,
2486929Smisaki 		    "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG"));
2493859Sml29623 		return (0);
2503859Sml29623 #endif
2513859Sml29623 
2523859Sml29623 	case NXGE_CTLOPS_CLEAR_BIT_SHARED_REG_UL:
2533859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
2543859Sml29623 		global_dev_ctrl |= *(uint64_t *)arg;
2553859Sml29623 		return (0);
2563859Sml29623 #else
2573859Sml29623 		status = npi_dev_func_sr_sr_get(handle, &sr16);
2583859Sml29623 		cr16 = *(uint16_t *)arg;
2593859Sml29623 		sr16 &= ~cr16;
2603859Sml29623 		status = npi_dev_func_sr_sr_set_only(handle, &sr16);
2613859Sml29623 		NXGE_DEBUG_MSG((NULL, VIR_CTL,
2626929Smisaki 		    "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG"));
2633859Sml29623 		return (0);
2643859Sml29623 #endif
2653859Sml29623 
2663859Sml29623 	case NXGE_CTLOPS_CLEAR_BIT_SHARED_REG:
2673859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
2683859Sml29623 		global_dev_ctrl |= *(uint64_t *)arg;
2693859Sml29623 		return (0);
2703859Sml29623 #else
2713859Sml29623 		status = NPI_FAILURE;
2723859Sml29623 		while (status != NPI_SUCCESS)
2733859Sml29623 			status = npi_dev_func_sr_lock_enter(handle);
2743859Sml29623 		status = npi_dev_func_sr_sr_get(handle, &sr16);
2753859Sml29623 		cr16 = *(uint16_t *)arg;
2763859Sml29623 		sr16 &= ~cr16;
2773859Sml29623 		status = npi_dev_func_sr_sr_set_only(handle, &sr16);
2783859Sml29623 		status = npi_dev_func_sr_lock_free(handle);
2793859Sml29623 		NXGE_DEBUG_MSG((NULL, VIR_CTL,
2806929Smisaki 		    "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG"));
2813859Sml29623 		return (0);
2823859Sml29623 #endif
2833859Sml29623 
2843859Sml29623 	case NXGE_CTLOPS_GET_LOCK_BLOCK:
2853859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
2863859Sml29623 		global_dev_ctrl |= *(uint64_t *)arg;
2873859Sml29623 		return (0);
2883859Sml29623 #else
2893859Sml29623 		status = NPI_FAILURE;
2903859Sml29623 		while (status != NPI_SUCCESS)
2913859Sml29623 			status = npi_dev_func_sr_lock_enter(handle);
2923859Sml29623 		NXGE_DEBUG_MSG((NULL, VIR_CTL,
2936929Smisaki 		    "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_BLOCK"));
2943859Sml29623 		return (0);
2953859Sml29623 #endif
2963859Sml29623 	case NXGE_CTLOPS_GET_LOCK_TRY:
2973859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
2983859Sml29623 		global_dev_ctrl |= *(uint64_t *)arg;
2993859Sml29623 		return (0);
3003859Sml29623 #else
3013859Sml29623 		status = npi_dev_func_sr_lock_enter(handle);
3023859Sml29623 		NXGE_DEBUG_MSG((NULL, VIR_CTL,
3036929Smisaki 		    "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_TRY"));
3043859Sml29623 		if (status == NPI_SUCCESS)
3053859Sml29623 			return (NXGE_OK);
3063859Sml29623 		else
3073859Sml29623 			return (NXGE_ERROR);
3083859Sml29623 #endif
3093859Sml29623 	case NXGE_CTLOPS_FREE_LOCK:
3103859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM
3113859Sml29623 		global_dev_ctrl |= *(uint64_t *)arg;
3123859Sml29623 		return (0);
3133859Sml29623 #else
3143859Sml29623 		status = npi_dev_func_sr_lock_free(handle);
3153859Sml29623 		NXGE_DEBUG_MSG((NULL, VIR_CTL,
3166929Smisaki 		    "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_FREE"));
3173859Sml29623 		if (status == NPI_SUCCESS)
3183859Sml29623 			return (NXGE_OK);
3193859Sml29623 		else
3203859Sml29623 			return (NXGE_ERROR);
3213859Sml29623 #endif
3223859Sml29623 
3233859Sml29623 	default:
3243859Sml29623 		status = NXGE_ERROR;
3253859Sml29623 	}
3263859Sml29623 
3273859Sml29623 	return (status);
3283859Sml29623 }
3293859Sml29623 
3303859Sml29623 void
3313859Sml29623 nxge_common_lock_get(p_nxge_t nxgep)
3323859Sml29623 {
3333859Sml29623 	uint32_t status = NPI_FAILURE;
3343859Sml29623 	npi_handle_t handle;
3353859Sml29623 
3363859Sml29623 #if	defined(NXGE_SHARE_REG_SW_SIM)
3373859Sml29623 	return;
3383859Sml29623 #endif
3393859Sml29623 	handle = nxgep->npi_reg_handle;
3403859Sml29623 	while (status != NPI_SUCCESS)
3413859Sml29623 		status = npi_dev_func_sr_lock_enter(handle);
3423859Sml29623 }
3433859Sml29623 
3443859Sml29623 void
3453859Sml29623 nxge_common_lock_free(p_nxge_t nxgep)
3463859Sml29623 {
3473859Sml29623 	npi_handle_t handle;
3483859Sml29623 
3493859Sml29623 #if	defined(NXGE_SHARE_REG_SW_SIM)
3503859Sml29623 	return;
3513859Sml29623 #endif
3523859Sml29623 	handle = nxgep->npi_reg_handle;
3533859Sml29623 	(void) npi_dev_func_sr_lock_free(handle);
3543859Sml29623 }
3553859Sml29623 
3564185Sspeer 
3573859Sml29623 static void
3583859Sml29623 nxge_get_niu_property(dev_info_t *dip, niu_type_t *niu_type)
3593859Sml29623 {
3603859Sml29623 	uchar_t *prop_val;
3613859Sml29623 	uint_t prop_len;
3623859Sml29623 
3634732Sdavemq 	*niu_type = NIU_TYPE_NONE;
3643859Sml29623 	if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0,
3656929Smisaki 	    "niu-type", (uchar_t **)&prop_val,
3666929Smisaki 	    &prop_len) == DDI_PROP_SUCCESS) {
3673859Sml29623 		if (strncmp("niu", (caddr_t)prop_val, (size_t)prop_len) == 0) {
3683859Sml29623 			*niu_type = N2_NIU;
3693859Sml29623 		}
3703859Sml29623 		ddi_prop_free(prop_val);
3713859Sml29623 	}
3723859Sml29623 }
3733859Sml29623 
3743859Sml29623 static config_token_t
3753859Sml29623 nxge_get_config_token(char *prop)
3763859Sml29623 {
3773859Sml29623 	config_token_t token = DEFAULT;
3783859Sml29623 
3793859Sml29623 	while (token < CONFIG_TOKEN_NONE) {
3803859Sml29623 		if (strncmp(prop, token_names[token], 4) == 0)
3813859Sml29623 			break;
3823859Sml29623 		token++;
3833859Sml29623 	}
3843859Sml29623 	return (token);
3853859Sml29623 }
3863859Sml29623 
3873859Sml29623 /* per port */
3883859Sml29623 
3893859Sml29623 static nxge_status_t
3903859Sml29623 nxge_update_rxdma_grp_properties(p_nxge_t nxgep, config_token_t token,
3913859Sml29623 	dev_info_t *s_dip[])
3923859Sml29623 {
3933859Sml29623 	nxge_status_t status = NXGE_OK;
3943859Sml29623 	int ddi_status;
3953859Sml29623 	int num_ports = nxgep->nports;
3963859Sml29623 	int port, bits, j;
3973859Sml29623 	uint8_t start_grp = 0, num_grps = 0;
3983859Sml29623 	p_nxge_param_t param_arr;
3993859Sml29623 	uint32_t grp_bitmap[MAX_SIBLINGS];
4003859Sml29623 	int custom_start_grp[MAX_SIBLINGS];
4013859Sml29623 	int custom_num_grp[MAX_SIBLINGS];
4023859Sml29623 	uint8_t bad_config = B_FALSE;
4033859Sml29623 	char *start_prop, *num_prop, *cfg_prop;
4043859Sml29623 
4053859Sml29623 	start_grp = 0;
4063859Sml29623 	param_arr = nxgep->param_arr;
4073859Sml29623 	start_prop = param_arr[param_rdc_grps_start].fcode_name;
4083859Sml29623 	num_prop = param_arr[param_rx_rdc_grps].fcode_name;
4093859Sml29623 
4103859Sml29623 	switch (token) {
4113859Sml29623 	case FAIR:
4123859Sml29623 		cfg_prop = "fair";
4133859Sml29623 		for (port = 0; port < num_ports; port++) {
4143859Sml29623 			custom_num_grp[port] =
4156929Smisaki 			    (num_ports == 4) ?
4166929Smisaki 			    p4_rdcgrp_fair[port] :
4176929Smisaki 			    p2_rdcgrp_fair[port];
4183859Sml29623 			custom_start_grp[port] = start_grp;
4193859Sml29623 			start_grp += custom_num_grp[port];
4203859Sml29623 		}
4213859Sml29623 		break;
4223859Sml29623 
4233859Sml29623 	case EQUAL:
4243859Sml29623 		cfg_prop = "equal";
4253859Sml29623 		for (port = 0; port < num_ports; port++) {
4263859Sml29623 			custom_num_grp[port] =
4276929Smisaki 			    (num_ports == 4) ?
4286929Smisaki 			    p4_rdcgrp_equal[port] :
4296929Smisaki 			    p2_rdcgrp_equal[port];
4303859Sml29623 			custom_start_grp[port] = start_grp;
4313859Sml29623 			start_grp += custom_num_grp[port];
4323859Sml29623 		}
4333859Sml29623 		break;
4343859Sml29623 
4353859Sml29623 
4363859Sml29623 	case CLASSIFY:
4373859Sml29623 		cfg_prop = "classify";
4383859Sml29623 		for (port = 0; port < num_ports; port++) {
4393859Sml29623 			custom_num_grp[port] = (num_ports == 4) ?
4406929Smisaki 			    p4_rdcgrp_cls[port] : p2_rdcgrp_cls[port];
4413859Sml29623 			custom_start_grp[port] = start_grp;
4423859Sml29623 			start_grp += custom_num_grp[port];
4433859Sml29623 		}
4443859Sml29623 		break;
4453859Sml29623 
4463859Sml29623 	case CUSTOM:
4473859Sml29623 		cfg_prop = "custom";
4483859Sml29623 		/* See if it is good config */
4493859Sml29623 		num_grps = 0;
4503859Sml29623 		for (port = 0; port < num_ports; port++) {
4513859Sml29623 			custom_start_grp[port] =
4526929Smisaki 			    ddi_prop_get_int(DDI_DEV_T_NONE, s_dip[port],
4536929Smisaki 			    DDI_PROP_DONTPASS, start_prop, -1);
4543859Sml29623 			if ((custom_start_grp[port] == -1) ||
4556929Smisaki 			    (custom_start_grp[port] >=
4566929Smisaki 			    NXGE_MAX_RDC_GRPS)) {
4573859Sml29623 				bad_config = B_TRUE;
4583859Sml29623 				break;
4593859Sml29623 			}
4603859Sml29623 			custom_num_grp[port] = ddi_prop_get_int(
4616929Smisaki 			    DDI_DEV_T_NONE,
4626929Smisaki 			    s_dip[port],
4636929Smisaki 			    DDI_PROP_DONTPASS,
4646929Smisaki 			    num_prop, -1);
4653859Sml29623 
4663859Sml29623 			if ((custom_num_grp[port] == -1) ||
4676929Smisaki 			    (custom_num_grp[port] >
4686929Smisaki 			    NXGE_MAX_RDC_GRPS) ||
4696929Smisaki 			    ((custom_num_grp[port] +
4706929Smisaki 			    custom_start_grp[port]) >=
4716929Smisaki 			    NXGE_MAX_RDC_GRPS)) {
4723859Sml29623 				bad_config = B_TRUE;
4733859Sml29623 				break;
4743859Sml29623 			}
4753859Sml29623 			num_grps += custom_num_grp[port];
4763859Sml29623 			if (num_grps > NXGE_MAX_RDC_GRPS) {
4773859Sml29623 				bad_config = B_TRUE;
4783859Sml29623 				break;
4793859Sml29623 			}
4803859Sml29623 			grp_bitmap[port] = 0;
4813859Sml29623 			for (bits = 0;
4826929Smisaki 			    bits < custom_num_grp[port];
4836929Smisaki 			    bits++) {
4843859Sml29623 				grp_bitmap[port] |=
4856929Smisaki 				    (1 << (bits + custom_start_grp[port]));
4863859Sml29623 			}
4873859Sml29623 
4883859Sml29623 		}
4893859Sml29623 
4903859Sml29623 		if (bad_config == B_FALSE) {
4913859Sml29623 			/* check for overlap */
4923859Sml29623 			for (port = 0; port < num_ports - 1; port++) {
4933859Sml29623 				for (j = port + 1; j < num_ports; j++) {
4943859Sml29623 					if (grp_bitmap[port] &
4956929Smisaki 					    grp_bitmap[j]) {
4963859Sml29623 						bad_config = B_TRUE;
4973859Sml29623 						break;
4983859Sml29623 					}
4993859Sml29623 				}
5003859Sml29623 				if (bad_config == B_TRUE)
5013859Sml29623 					break;
5023859Sml29623 			}
5033859Sml29623 		}
5043859Sml29623 		if (bad_config == B_TRUE) {
5053859Sml29623 			/* use default config */
5063859Sml29623 			for (port = 0; port < num_ports; port++) {
5073859Sml29623 				custom_num_grp[port] =
5086929Smisaki 				    (num_ports == 4) ?
5096929Smisaki 				    p4_rx_fair[port] : p2_rx_fair[port];
5103859Sml29623 				custom_start_grp[port] = start_grp;
5113859Sml29623 				start_grp += custom_num_grp[port];
5123859Sml29623 			}
5133859Sml29623 		}
5143859Sml29623 		break;
5153859Sml29623 
5163859Sml29623 	default:
5173859Sml29623 		/* use default config */
5183859Sml29623 		cfg_prop = "fair";
5193859Sml29623 		for (port = 0; port < num_ports; port++) {
5203859Sml29623 			custom_num_grp[port] = (num_ports == 4) ?
5216929Smisaki 			    p4_rx_fair[port] : p2_rx_fair[port];
5223859Sml29623 			custom_start_grp[port] = start_grp;
5233859Sml29623 			start_grp += custom_num_grp[port];
5243859Sml29623 		}
5253859Sml29623 		break;
5263859Sml29623 	}
5273859Sml29623 
5283859Sml29623 	/* Now Update the rx properties */
5293859Sml29623 	for (port = 0; port < num_ports; port++) {
5303859Sml29623 		ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port],
5316929Smisaki 		    "rxdma-grp-cfg", cfg_prop);
5323859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
5333859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
5346929Smisaki 			    " property %s not updating",
5356929Smisaki 			    cfg_prop));
5363859Sml29623 			status |= NXGE_DDI_FAILED;
5373859Sml29623 		}
5383859Sml29623 		ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port],
5396929Smisaki 		    num_prop, custom_num_grp[port]);
5403859Sml29623 
5413859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
5423859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
5436929Smisaki 			    " property %s not updating",
5446929Smisaki 			    num_prop));
5453859Sml29623 			status |= NXGE_DDI_FAILED;
5463859Sml29623 		}
5473859Sml29623 		ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port],
5486929Smisaki 		    start_prop, custom_start_grp[port]);
5493859Sml29623 
5503859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
5513859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
5526929Smisaki 			    " property %s not updating",
5536929Smisaki 			    start_prop));
5543859Sml29623 			status |= NXGE_DDI_FAILED;
5553859Sml29623 		}
5563859Sml29623 	}
5573859Sml29623 	if (status & NXGE_DDI_FAILED)
5583859Sml29623 		status |= NXGE_ERROR;
5593859Sml29623 
5603859Sml29623 	return (status);
5613859Sml29623 }
5623859Sml29623 
5633859Sml29623 static nxge_status_t
5643859Sml29623 nxge_update_rxdma_properties(p_nxge_t nxgep, config_token_t token,
5653859Sml29623 	dev_info_t *s_dip[])
5663859Sml29623 {
5673859Sml29623 	nxge_status_t status = NXGE_OK;
5683859Sml29623 	int ddi_status;
5693859Sml29623 	int num_ports = nxgep->nports;
5703859Sml29623 	int port, bits, j;
5713859Sml29623 	uint8_t start_rdc = 0, num_rdc = 0;
5723859Sml29623 	p_nxge_param_t param_arr;
5733859Sml29623 	uint32_t rdc_bitmap[MAX_SIBLINGS];
5743859Sml29623 	int custom_start_rdc[MAX_SIBLINGS];
5753859Sml29623 	int custom_num_rdc[MAX_SIBLINGS];
5763859Sml29623 	uint8_t bad_config = B_FALSE;
5773859Sml29623 	int *prop_val;
5783859Sml29623 	uint_t prop_len;
5793859Sml29623 	char *start_rdc_prop, *num_rdc_prop, *cfg_prop;
5803859Sml29623 
5813859Sml29623 	start_rdc = 0;
5823859Sml29623 	param_arr = nxgep->param_arr;
5833859Sml29623 	start_rdc_prop = param_arr[param_rxdma_channels_begin].fcode_name;
5843859Sml29623 	num_rdc_prop = param_arr[param_rxdma_channels].fcode_name;
5853859Sml29623 
5863859Sml29623 	switch (token) {
5873859Sml29623 	case FAIR:
5883859Sml29623 		cfg_prop = "fair";
5893859Sml29623 		for (port = 0; port < num_ports; port++) {
5903859Sml29623 			custom_num_rdc[port] = (num_ports == 4) ?
5916929Smisaki 			    p4_rx_fair[port] : p2_rx_fair[port];
5923859Sml29623 			custom_start_rdc[port] = start_rdc;
5933859Sml29623 			start_rdc += custom_num_rdc[port];
5943859Sml29623 		}
5953859Sml29623 		break;
5963859Sml29623 
5973859Sml29623 	case EQUAL:
5983859Sml29623 		cfg_prop = "equal";
5993859Sml29623 		for (port = 0; port < num_ports; port++) {
6003859Sml29623 			custom_num_rdc[port] = (num_ports == 4) ?
6016929Smisaki 			    p4_rx_equal[port] :
6026929Smisaki 			    p2_rx_equal[port];
6033859Sml29623 			custom_start_rdc[port] = start_rdc;
6043859Sml29623 			start_rdc += custom_num_rdc[port];
6053859Sml29623 		}
6063859Sml29623 		break;
6073859Sml29623 
6083859Sml29623 	case CUSTOM:
6093859Sml29623 		cfg_prop = "custom";
6103859Sml29623 		/* See if it is good config */
6113859Sml29623 		num_rdc = 0;
6123859Sml29623 		for (port = 0; port < num_ports; port++) {
6133859Sml29623 			ddi_status = ddi_prop_lookup_int_array(
6146929Smisaki 			    DDI_DEV_T_ANY,
6156929Smisaki 			    s_dip[port], 0,
6166929Smisaki 			    start_rdc_prop,
6176929Smisaki 			    &prop_val,
6186929Smisaki 			    &prop_len);
6193859Sml29623 			if (ddi_status == DDI_SUCCESS)
6203859Sml29623 				custom_start_rdc[port] = *prop_val;
6213859Sml29623 			else {
6223859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
6236929Smisaki 				    " %s custom start port %d"
6246929Smisaki 				    " read failed ",
6256929Smisaki 				    " rxdma-cfg", port));
6263859Sml29623 				bad_config = B_TRUE;
6273859Sml29623 				status |= NXGE_DDI_FAILED;
6283859Sml29623 			}
6293859Sml29623 			if ((custom_start_rdc[port] == -1) ||
6306929Smisaki 			    (custom_start_rdc[port] >=
6316929Smisaki 			    NXGE_MAX_RDCS)) {
6323859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
6336929Smisaki 				    " %s custom start %d"
6346929Smisaki 				    " out of range %x ",
6356929Smisaki 				    " rxdma-cfg",
6366929Smisaki 				    port,
6376929Smisaki 				    custom_start_rdc[port]));
6383859Sml29623 				bad_config = B_TRUE;
6393859Sml29623 				break;
6403859Sml29623 			}
6413859Sml29623 			ddi_status = ddi_prop_lookup_int_array(
6426929Smisaki 			    DDI_DEV_T_ANY,
6436929Smisaki 			    s_dip[port],
6446929Smisaki 			    0,
6456929Smisaki 			    num_rdc_prop,
6466929Smisaki 			    &prop_val,
6476929Smisaki 			    &prop_len);
6483859Sml29623 
6493859Sml29623 			if (ddi_status == DDI_SUCCESS)
6503859Sml29623 				custom_num_rdc[port] = *prop_val;
6513859Sml29623 			else {
6523859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
6536929Smisaki 				    " %s custom num port %d"
6546929Smisaki 				    " read failed ",
6556929Smisaki 				    "rxdma-cfg", port));
6563859Sml29623 				bad_config = B_TRUE;
6573859Sml29623 				status |= NXGE_DDI_FAILED;
6583859Sml29623 			}
6593859Sml29623 
6603859Sml29623 			if ((custom_num_rdc[port] == -1) ||
6616929Smisaki 			    (custom_num_rdc[port] >
6626929Smisaki 			    NXGE_MAX_RDCS) ||
6636929Smisaki 			    ((custom_num_rdc[port] +
6646929Smisaki 			    custom_start_rdc[port]) >
6656929Smisaki 			    NXGE_MAX_RDCS)) {
6663859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
6676929Smisaki 				    " %s custom num %d"
6686929Smisaki 				    " out of range %x ",
6696929Smisaki 				    " rxdma-cfg",
6706929Smisaki 				    port, custom_num_rdc[port]));
6713859Sml29623 				bad_config = B_TRUE;
6723859Sml29623 				break;
6733859Sml29623 			}
6743859Sml29623 			num_rdc += custom_num_rdc[port];
6753859Sml29623 			if (num_rdc > NXGE_MAX_RDCS) {
6763859Sml29623 				bad_config = B_TRUE;
6773859Sml29623 				break;
6783859Sml29623 			}
6793859Sml29623 			rdc_bitmap[port] = 0;
6803859Sml29623 			for (bits = 0;
6816929Smisaki 			    bits < custom_num_rdc[port]; bits++) {
6823859Sml29623 				rdc_bitmap[port] |=
6836929Smisaki 				    (1 << (bits + custom_start_rdc[port]));
6843859Sml29623 			}
6853859Sml29623 		}
6863859Sml29623 
6873859Sml29623 		if (bad_config == B_FALSE) {
6883859Sml29623 			/* check for overlap */
6893859Sml29623 			for (port = 0; port < num_ports - 1; port++) {
6903859Sml29623 				for (j = port + 1; j < num_ports; j++) {
6913859Sml29623 					if (rdc_bitmap[port] &
6926929Smisaki 					    rdc_bitmap[j]) {
6933859Sml29623 						NXGE_DEBUG_MSG((nxgep,
6946929Smisaki 						    CFG_CTL,
6956929Smisaki 						    " rxdma-cfg"
6966929Smisaki 						    " property custom"
6976929Smisaki 						    " bit overlap"
6986929Smisaki 						    " %d %d ",
6996929Smisaki 						    port, j));
7003859Sml29623 						bad_config = B_TRUE;
7013859Sml29623 						break;
7023859Sml29623 					}
7033859Sml29623 				}
7043859Sml29623 				if (bad_config == B_TRUE)
7053859Sml29623 					break;
7063859Sml29623 			}
7073859Sml29623 		}
7083859Sml29623 		if (bad_config == B_TRUE) {
7093859Sml29623 			/* use default config */
7103859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
7116929Smisaki 			    " rxdma-cfg property:"
7126929Smisaki 			    " bad custom config:"
7136929Smisaki 			    " use default"));
7143859Sml29623 			for (port = 0; port < num_ports; port++) {
7153859Sml29623 				custom_num_rdc[port] =
7166929Smisaki 				    (num_ports == 4) ?
7176929Smisaki 				    p4_rx_fair[port] :
7186929Smisaki 				    p2_rx_fair[port];
7193859Sml29623 				custom_start_rdc[port] = start_rdc;
7203859Sml29623 				start_rdc += custom_num_rdc[port];
7213859Sml29623 			}
7223859Sml29623 		}
7233859Sml29623 		break;
7243859Sml29623 
7253859Sml29623 	default:
7263859Sml29623 		/* use default config */
7273859Sml29623 		cfg_prop = "fair";
7283859Sml29623 		for (port = 0; port < num_ports; port++) {
7293859Sml29623 			custom_num_rdc[port] = (num_ports == 4) ?
7306929Smisaki 			    p4_rx_fair[port] : p2_rx_fair[port];
7313859Sml29623 			custom_start_rdc[port] = start_rdc;
7323859Sml29623 			start_rdc += custom_num_rdc[port];
7333859Sml29623 		}
7343859Sml29623 		break;
7353859Sml29623 	}
7363859Sml29623 
7373859Sml29623 	/* Now Update the rx properties */
7383859Sml29623 	for (port = 0; port < num_ports; port++) {
7393859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL,
7406929Smisaki 		    " update property rxdma-cfg with %s ", cfg_prop));
7413859Sml29623 		ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port],
7426929Smisaki 		    "rxdma-cfg", cfg_prop);
7433859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
7443859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
7456929Smisaki 			    " property rxdma-cfg is not updating to %s",
7466929Smisaki 			    cfg_prop));
7473859Sml29623 			status |= NXGE_DDI_FAILED;
7483859Sml29623 		}
7493859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ",
7506929Smisaki 		    num_rdc_prop, custom_num_rdc[port]));
7513859Sml29623 
7523859Sml29623 		ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port],
7536929Smisaki 		    num_rdc_prop, custom_num_rdc[port]);
7543859Sml29623 
7553859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
7563859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
7576929Smisaki 			    " property %s not updating with %d",
7586929Smisaki 			    num_rdc_prop, custom_num_rdc[port]));
7593859Sml29623 			status |= NXGE_DDI_FAILED;
7603859Sml29623 		}
7613859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ",
7626929Smisaki 		    start_rdc_prop, custom_start_rdc[port]));
7633859Sml29623 		ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port],
7646929Smisaki 		    start_rdc_prop, custom_start_rdc[port]);
7653859Sml29623 
7663859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
7673859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
7686929Smisaki 			    " property %s not updating with %d ",
7696929Smisaki 			    start_rdc_prop, custom_start_rdc[port]));
7703859Sml29623 			status |= NXGE_DDI_FAILED;
7713859Sml29623 		}
7723859Sml29623 	}
7733859Sml29623 	if (status & NXGE_DDI_FAILED)
7743859Sml29623 		status |= NXGE_ERROR;
7753859Sml29623 	return (status);
7763859Sml29623 }
7773859Sml29623 
7783859Sml29623 static nxge_status_t
7793859Sml29623 nxge_update_txdma_properties(p_nxge_t nxgep, config_token_t token,
7803859Sml29623 	dev_info_t *s_dip[])
7813859Sml29623 {
7823859Sml29623 	nxge_status_t status = NXGE_OK;
7833859Sml29623 	int ddi_status = DDI_SUCCESS;
7843859Sml29623 	int num_ports = nxgep->nports;
7853859Sml29623 	int port, bits, j;
7863859Sml29623 	uint8_t start_tdc = 0, num_tdc = 0;
7873859Sml29623 	p_nxge_param_t param_arr;
7883859Sml29623 	uint32_t tdc_bitmap[MAX_SIBLINGS];
7893859Sml29623 	int custom_start_tdc[MAX_SIBLINGS];
7903859Sml29623 	int custom_num_tdc[MAX_SIBLINGS];
7913859Sml29623 	uint8_t bad_config = B_FALSE;
7923859Sml29623 	int *prop_val;
7933859Sml29623 	uint_t prop_len;
7943859Sml29623 	char *start_tdc_prop, *num_tdc_prop, *cfg_prop;
7953859Sml29623 
7963859Sml29623 	start_tdc = 0;
7973859Sml29623 	param_arr = nxgep->param_arr;
7983859Sml29623 	start_tdc_prop = param_arr[param_txdma_channels_begin].fcode_name;
7993859Sml29623 	num_tdc_prop = param_arr[param_txdma_channels].fcode_name;
8003859Sml29623 
8013859Sml29623 	switch (token) {
8023859Sml29623 	case FAIR:
8033859Sml29623 		cfg_prop = "fair";
8043859Sml29623 		for (port = 0; port < num_ports; port++) {
8053859Sml29623 			custom_num_tdc[port] = (num_ports == 4) ?
8066929Smisaki 			    p4_tx_fair[port] : p2_tx_fair[port];
8073859Sml29623 			custom_start_tdc[port] = start_tdc;
8083859Sml29623 			start_tdc += custom_num_tdc[port];
8093859Sml29623 		}
8103859Sml29623 		break;
8113859Sml29623 
8123859Sml29623 	case EQUAL:
8133859Sml29623 		cfg_prop = "equal";
8143859Sml29623 		for (port = 0; port < num_ports; port++) {
8153859Sml29623 			custom_num_tdc[port] = (num_ports == 4) ?
8166929Smisaki 			    p4_tx_equal[port] : p2_tx_equal[port];
8173859Sml29623 			custom_start_tdc[port] = start_tdc;
8183859Sml29623 			start_tdc += custom_num_tdc[port];
8193859Sml29623 		}
8203859Sml29623 		break;
8213859Sml29623 
8223859Sml29623 	case CUSTOM:
8233859Sml29623 		cfg_prop = "custom";
8243859Sml29623 		/* See if it is good config */
8253859Sml29623 		num_tdc = 0;
8263859Sml29623 		for (port = 0; port < num_ports; port++) {
8273859Sml29623 			ddi_status = ddi_prop_lookup_int_array(
8286929Smisaki 			    DDI_DEV_T_ANY, s_dip[port], 0, start_tdc_prop,
8296929Smisaki 			    &prop_val, &prop_len);
8303859Sml29623 			if (ddi_status == DDI_SUCCESS)
8313859Sml29623 				custom_start_tdc[port] = *prop_val;
8323859Sml29623 			else {
8333859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
8346929Smisaki 				    " %s custom start port %d"
8356929Smisaki 				    " read failed ", " txdma-cfg", port));
8363859Sml29623 				bad_config = B_TRUE;
8373859Sml29623 				status |= NXGE_DDI_FAILED;
8383859Sml29623 			}
8393859Sml29623 
8403859Sml29623 			if ((custom_start_tdc[port] == -1) ||
8416929Smisaki 			    (custom_start_tdc[port] >=
8426929Smisaki 			    NXGE_MAX_RDCS)) {
8433859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
8446929Smisaki 				    " %s custom start %d"
8456929Smisaki 				    " out of range %x ", " txdma-cfg",
8466929Smisaki 				    port, custom_start_tdc[port]));
8473859Sml29623 				bad_config = B_TRUE;
8483859Sml29623 				break;
8493859Sml29623 			}
8503859Sml29623 
8513859Sml29623 			ddi_status = ddi_prop_lookup_int_array(
8526929Smisaki 			    DDI_DEV_T_ANY, s_dip[port], 0, num_tdc_prop,
8536929Smisaki 			    &prop_val, &prop_len);
8543859Sml29623 			if (ddi_status == DDI_SUCCESS)
8553859Sml29623 				custom_num_tdc[port] = *prop_val;
8563859Sml29623 			else {
8573859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
8586929Smisaki 				    " %s custom num port %d"
8596929Smisaki 				    " read failed ", " txdma-cfg", port));
8603859Sml29623 				bad_config = B_TRUE;
8613859Sml29623 				status |= NXGE_DDI_FAILED;
8623859Sml29623 			}
8633859Sml29623 
8643859Sml29623 			if ((custom_num_tdc[port] == -1) ||
8656929Smisaki 			    (custom_num_tdc[port] >
8666929Smisaki 			    NXGE_MAX_TDCS) ||
8676929Smisaki 			    ((custom_num_tdc[port] +
8686929Smisaki 			    custom_start_tdc[port]) >
8696929Smisaki 			    NXGE_MAX_TDCS)) {
8703859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
8716929Smisaki 				    " %s custom num %d"
8726929Smisaki 				    " out of range %x ", " rxdma-cfg",
8736929Smisaki 				    port, custom_num_tdc[port]));
8743859Sml29623 				bad_config = B_TRUE;
8753859Sml29623 				break;
8763859Sml29623 			}
8773859Sml29623 			num_tdc += custom_num_tdc[port];
8783859Sml29623 			if (num_tdc > NXGE_MAX_TDCS) {
8793859Sml29623 				bad_config = B_TRUE;
8803859Sml29623 				break;
8813859Sml29623 			}
8823859Sml29623 			tdc_bitmap[port] = 0;
8833859Sml29623 			for (bits = 0;
8846929Smisaki 			    bits < custom_num_tdc[port]; bits++) {
8853859Sml29623 				tdc_bitmap[port] |=
8866929Smisaki 				    (1 <<
8876929Smisaki 				    (bits + custom_start_tdc[port]));
8883859Sml29623 			}
8893859Sml29623 
8903859Sml29623 		}
8913859Sml29623 
8923859Sml29623 		if (bad_config == B_FALSE) {
8933859Sml29623 			/* check for overlap */
8943859Sml29623 			for (port = 0; port < num_ports - 1; port++) {
8953859Sml29623 				for (j = port + 1; j < num_ports; j++) {
8963859Sml29623 					if (tdc_bitmap[port] &
8976929Smisaki 					    tdc_bitmap[j]) {
8983859Sml29623 						NXGE_DEBUG_MSG((nxgep, CFG_CTL,
8996929Smisaki 						    " rxdma-cfg"
9006929Smisaki 						    " property custom"
9016929Smisaki 						    " bit overlap"
9026929Smisaki 						    " %d %d ",
9036929Smisaki 						    port, j));
9043859Sml29623 						bad_config = B_TRUE;
9053859Sml29623 						break;
9063859Sml29623 					}
9073859Sml29623 				}
9083859Sml29623 				if (bad_config == B_TRUE)
9093859Sml29623 					break;
9103859Sml29623 			}
9113859Sml29623 		}
9123859Sml29623 		if (bad_config == B_TRUE) {
9133859Sml29623 			/* use default config */
9143859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
9156929Smisaki 			    " txdma-cfg property:"
9166929Smisaki 			    " bad custom config:" " use default"));
9173859Sml29623 
9183859Sml29623 			for (port = 0; port < num_ports; port++) {
9193859Sml29623 				custom_num_tdc[port] = (num_ports == 4) ?
9206929Smisaki 				    p4_tx_fair[port] : p2_tx_fair[port];
9213859Sml29623 				custom_start_tdc[port] = start_tdc;
9223859Sml29623 				start_tdc += custom_num_tdc[port];
9233859Sml29623 			}
9243859Sml29623 		}
9253859Sml29623 		break;
9263859Sml29623 
9273859Sml29623 	default:
9283859Sml29623 		/* use default config */
9293859Sml29623 		cfg_prop = "fair";
9303859Sml29623 		for (port = 0; port < num_ports; port++) {
9313859Sml29623 			custom_num_tdc[port] = (num_ports == 4) ?
9326929Smisaki 			    p4_tx_fair[port] : p2_tx_fair[port];
9333859Sml29623 			custom_start_tdc[port] = start_tdc;
9343859Sml29623 			start_tdc += custom_num_tdc[port];
9353859Sml29623 		}
9363859Sml29623 		break;
9373859Sml29623 	}
9383859Sml29623 
9393859Sml29623 	/* Now Update the tx properties */
9403859Sml29623 	for (port = 0; port < num_ports; port++) {
9413859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL,
9426929Smisaki 		    " update property txdma-cfg with %s ", cfg_prop));
9433859Sml29623 		ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port],
9446929Smisaki 		    "txdma-cfg", cfg_prop);
9453859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
9463859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
9476929Smisaki 			    " property txdma-cfg is not updating to %s",
9486929Smisaki 			    cfg_prop));
9493859Sml29623 			status |= NXGE_DDI_FAILED;
9503859Sml29623 		}
9513859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ",
9526929Smisaki 		    num_tdc_prop, custom_num_tdc[port]));
9533859Sml29623 
9543859Sml29623 		ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port],
9556929Smisaki 		    num_tdc_prop, custom_num_tdc[port]);
9563859Sml29623 
9573859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
9583859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
9596929Smisaki 			    " property %s not updating with %d",
9606929Smisaki 			    num_tdc_prop,
9616929Smisaki 			    custom_num_tdc[port]));
9623859Sml29623 			status |= NXGE_DDI_FAILED;
9633859Sml29623 		}
9643859Sml29623 
9653859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ",
9666929Smisaki 		    start_tdc_prop, custom_start_tdc[port]));
9673859Sml29623 
9683859Sml29623 		ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port],
9696929Smisaki 		    start_tdc_prop, custom_start_tdc[port]);
9703859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS) {
9713859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
9726929Smisaki 			    " property %s not updating with %d ",
9736929Smisaki 			    start_tdc_prop, custom_start_tdc[port]));
9743859Sml29623 			status |= NXGE_DDI_FAILED;
9753859Sml29623 		}
9763859Sml29623 	}
9773859Sml29623 	if (status & NXGE_DDI_FAILED)
9783859Sml29623 		status |= NXGE_ERROR;
9793859Sml29623 	return (status);
9803859Sml29623 }
9813859Sml29623 
9823859Sml29623 static nxge_status_t
9833859Sml29623 nxge_update_cfg_properties(p_nxge_t nxgep, uint32_t flags,
9843859Sml29623 	config_token_t token, dev_info_t *s_dip[])
9853859Sml29623 {
9863859Sml29623 	nxge_status_t status = NXGE_OK;
9873859Sml29623 
9883859Sml29623 	switch (flags) {
9893859Sml29623 	case COMMON_TXDMA_CFG:
9903859Sml29623 		if (nxge_dma_obp_props_only == 0)
9913859Sml29623 			status = nxge_update_txdma_properties(nxgep,
9926929Smisaki 			    token, s_dip);
9933859Sml29623 		break;
9943859Sml29623 	case COMMON_RXDMA_CFG:
9953859Sml29623 		if (nxge_dma_obp_props_only == 0)
9963859Sml29623 			status = nxge_update_rxdma_properties(nxgep,
9976929Smisaki 			    token, s_dip);
9983859Sml29623 
9993859Sml29623 		break;
10003859Sml29623 	case COMMON_RXDMA_GRP_CFG:
10013859Sml29623 		status = nxge_update_rxdma_grp_properties(nxgep,
10026929Smisaki 		    token, s_dip);
10033859Sml29623 		break;
10043859Sml29623 	default:
10053859Sml29623 		return (NXGE_ERROR);
10063859Sml29623 	}
10073859Sml29623 	return (status);
10083859Sml29623 }
10093859Sml29623 
10103859Sml29623 /*
10113859Sml29623  * verify consistence.
10123859Sml29623  * (May require publishing the properties on all the ports.
10133859Sml29623  *
10143859Sml29623  * What if properties are published on function 0 device only?
10153859Sml29623  *
10163859Sml29623  *
10173859Sml29623  * rxdma-cfg, txdma-cfg, rxdma-grp-cfg (required )
10183859Sml29623  * What about class configs?
10193859Sml29623  *
10203859Sml29623  * If consistent, update the property on all the siblings.
10213859Sml29623  * set  a flag on hardware shared register
10223859Sml29623  * The rest of the siblings will check the flag
10233859Sml29623  * if the flag is set, they will use the updated property
10243859Sml29623  * without doing any validation.
10253859Sml29623  */
10263859Sml29623 
10273859Sml29623 nxge_status_t
10283859Sml29623 nxge_cfg_verify_set_classify_prop(p_nxge_t nxgep, char *prop,
10293859Sml29623 	uint64_t known_cfg, uint32_t override, dev_info_t *c_dip[])
10303859Sml29623 {
10313859Sml29623 	nxge_status_t status = NXGE_OK;
10323859Sml29623 	int ddi_status = DDI_SUCCESS;
10333859Sml29623 	int i = 0, found = 0, update_prop = B_TRUE;
10343859Sml29623 	int *cfg_val;
10353859Sml29623 	uint_t new_value, cfg_value[MAX_SIBLINGS];
10363859Sml29623 	uint_t prop_len;
10373859Sml29623 	uint_t known_cfg_value;
10383859Sml29623 
10393859Sml29623 	known_cfg_value = (uint_t)known_cfg;
10403859Sml29623 
10413859Sml29623 	if (override == B_TRUE) {
10423859Sml29623 		new_value = known_cfg_value;
10433859Sml29623 		for (i = 0; i < nxgep->nports; i++) {
10443859Sml29623 			ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE,
10456929Smisaki 			    c_dip[i], prop, new_value);
10463859Sml29623 #ifdef NXGE_DEBUG_ERROR
10473859Sml29623 			if (ddi_status != DDI_PROP_SUCCESS)
10483859Sml29623 				NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
10496929Smisaki 				    " property %s failed update ", prop));
10503859Sml29623 #endif
10513859Sml29623 		}
10523859Sml29623 		if (ddi_status != DDI_PROP_SUCCESS)
10533859Sml29623 			return (NXGE_ERROR | NXGE_DDI_FAILED);
10543859Sml29623 	}
10553859Sml29623 	for (i = 0; i < nxgep->nports; i++) {
10563859Sml29623 		cfg_value[i] = known_cfg_value;
10573859Sml29623 		if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, c_dip[i], 0,
10586929Smisaki 		    prop, &cfg_val,
10596929Smisaki 		    &prop_len) == DDI_PROP_SUCCESS) {
10603859Sml29623 			cfg_value[i] = *cfg_val;
10613859Sml29623 			ddi_prop_free(cfg_val);
10623859Sml29623 			found++;
10633859Sml29623 		}
10643859Sml29623 	}
10653859Sml29623 
10663859Sml29623 	if (found != i) {
10673859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL,
10686929Smisaki 		    " property %s not specified on all ports", prop));
10693859Sml29623 		if (found == 0) {
10703859Sml29623 			/* not specified: Use default */
10713859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
10726929Smisaki 			    " property %s not specified on any port:"
10736929Smisaki 			    " Using default", prop));
10743859Sml29623 			new_value = known_cfg_value;
10753859Sml29623 		} else {
10763859Sml29623 			/* specified on some */
10773859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
10786929Smisaki 			    " property %s not specified"
10796929Smisaki 			    " on some ports: Using default", prop));
10803859Sml29623 			/* ? use p0 value instead ? */
10813859Sml29623 			new_value = known_cfg_value;
10823859Sml29623 		}
10833859Sml29623 	} else {
10843859Sml29623 		/* check type and consistence */
10853859Sml29623 		/* found on all devices */
10863859Sml29623 		for (i = 1; i < found; i++) {
10873859Sml29623 			if (cfg_value[i] != cfg_value[i - 1]) {
10883859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG_CTL,
10896929Smisaki 				    " property %s inconsistent:"
10906929Smisaki 				    " Using default", prop));
10913859Sml29623 				new_value = known_cfg_value;
10923859Sml29623 				break;
10933859Sml29623 			}
10943859Sml29623 			/*
10953859Sml29623 			 * Found on all the ports and consistent. Nothing to
10963859Sml29623 			 * do.
10973859Sml29623 			 */
10983859Sml29623 			update_prop = B_FALSE;
10993859Sml29623 		}
11003859Sml29623 	}
11013859Sml29623 
11023859Sml29623 	if (update_prop == B_TRUE) {
11033859Sml29623 		for (i = 0; i < nxgep->nports; i++) {
11043859Sml29623 			ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE,
11056929Smisaki 			    c_dip[i], prop, new_value);
11063859Sml29623 #ifdef NXGE_DEBUG_ERROR
11073859Sml29623 			if (ddi_status != DDI_SUCCESS)
11083859Sml29623 				NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
11096929Smisaki 				    " property %s not updating with %d"
11106929Smisaki 				    " Using default",
11116929Smisaki 				    prop, new_value));
11123859Sml29623 #endif
11133859Sml29623 			if (ddi_status != DDI_PROP_SUCCESS)
11143859Sml29623 				status |= NXGE_DDI_FAILED;
11153859Sml29623 		}
11163859Sml29623 	}
11173859Sml29623 	if (status & NXGE_DDI_FAILED)
11183859Sml29623 		status |= NXGE_ERROR;
11193859Sml29623 
11203859Sml29623 	return (status);
11213859Sml29623 }
11223859Sml29623 
11233859Sml29623 static uint64_t
11243859Sml29623 nxge_class_get_known_cfg(p_nxge_t nxgep, int class_prop, int rx_quick_cfg)
11253859Sml29623 {
11263859Sml29623 	int start_prop;
11273859Sml29623 	uint64_t cfg_value;
11283859Sml29623 	p_nxge_param_t param_arr;
11293859Sml29623 
11303859Sml29623 	param_arr = nxgep->param_arr;
11313859Sml29623 	cfg_value = param_arr[class_prop].value;
11323859Sml29623 	start_prop = param_h1_init_value;
11333859Sml29623 
11343859Sml29623 	/* update the properties per quick config */
11353859Sml29623 	switch (rx_quick_cfg) {
11363859Sml29623 	case CFG_L3_WEB:
11373859Sml29623 	case CFG_L3_DISTRIBUTE:
11383859Sml29623 		cfg_value = nxge_classify_get_cfg_value(nxgep,
11396929Smisaki 		    rx_quick_cfg, class_prop - start_prop);
11403859Sml29623 		break;
11413859Sml29623 	default:
11423859Sml29623 		cfg_value = param_arr[class_prop].value;
11433859Sml29623 		break;
11443859Sml29623 	}
11453859Sml29623 	return (cfg_value);
11463859Sml29623 }
11473859Sml29623 
11483859Sml29623 static nxge_status_t
11493859Sml29623 nxge_cfg_verify_set_classify(p_nxge_t nxgep, dev_info_t *c_dip[])
11503859Sml29623 {
11513859Sml29623 	nxge_status_t status = NXGE_OK;
11523859Sml29623 	int rx_quick_cfg, class_prop, start_prop, end_prop;
11533859Sml29623 	char *prop_name;
11543859Sml29623 	int override = B_TRUE;
11553859Sml29623 	uint64_t cfg_value;
11563859Sml29623 	p_nxge_param_t param_arr;
11573859Sml29623 
11583859Sml29623 	param_arr = nxgep->param_arr;
11593859Sml29623 	rx_quick_cfg = param_arr[param_rx_quick_cfg].value;
11603859Sml29623 	start_prop = param_h1_init_value;
11613859Sml29623 	end_prop = param_class_opt_ipv6_sctp;
11623859Sml29623 
11633859Sml29623 	/* update the properties per quick config */
11643859Sml29623 	if (rx_quick_cfg == CFG_NOT_SPECIFIED)
11653859Sml29623 		override = B_FALSE;
11663859Sml29623 
11673859Sml29623 	/*
11683859Sml29623 	 * these parameter affect the classification outcome.
11693859Sml29623 	 * these parameters are used to configure the Flow key and
11703859Sml29623 	 * the TCAM key for each of the IP classes.
11713859Sml29623 	 * Included here are also the H1 and H2 initial values
11723859Sml29623 	 * which affect the distribution as well as final hash value
11733859Sml29623 	 * (hence the offset into RDC table and FCRAM bucket location)
11743859Sml29623 	 *
11753859Sml29623 	 */
11763859Sml29623 	for (class_prop = start_prop; class_prop <= end_prop; class_prop++) {
11773859Sml29623 		prop_name = param_arr[class_prop].fcode_name;
11783859Sml29623 		cfg_value = nxge_class_get_known_cfg(nxgep,
11796929Smisaki 		    class_prop, rx_quick_cfg);
11803859Sml29623 		status = nxge_cfg_verify_set_classify_prop(nxgep, prop_name,
11816929Smisaki 		    cfg_value, override, c_dip);
11823859Sml29623 	}
11833859Sml29623 
11843859Sml29623 	/*
11853859Sml29623 	 * these properties do not affect the actual classification outcome.
11863859Sml29623 	 * used to enable/disable or tune the fflp hardware
11873859Sml29623 	 *
11883859Sml29623 	 * fcram_access_ratio, tcam_access_ratio, tcam_enable, llc_snap_enable
11893859Sml29623 	 *
11903859Sml29623 	 */
11913859Sml29623 	override = B_FALSE;
11923859Sml29623 	for (class_prop = param_fcram_access_ratio;
11936929Smisaki 	    class_prop <= param_llc_snap_enable; class_prop++) {
11943859Sml29623 		prop_name = param_arr[class_prop].fcode_name;
11953859Sml29623 		cfg_value = param_arr[class_prop].value;
11963859Sml29623 		status = nxge_cfg_verify_set_classify_prop(nxgep, prop_name,
11976929Smisaki 		    cfg_value, override, c_dip);
11983859Sml29623 	}
11993859Sml29623 
12003859Sml29623 	return (status);
12013859Sml29623 }
12023859Sml29623 
12033859Sml29623 nxge_status_t
12043859Sml29623 nxge_cfg_verify_set(p_nxge_t nxgep, uint32_t flag)
12053859Sml29623 {
12063859Sml29623 	nxge_status_t status = NXGE_OK;
12073859Sml29623 	int i = 0, found = 0;
12083859Sml29623 	int num_siblings;
12093859Sml29623 	dev_info_t *c_dip[MAX_SIBLINGS + 1];
12103859Sml29623 	char *prop_val[MAX_SIBLINGS];
12113859Sml29623 	config_token_t c_token[MAX_SIBLINGS];
12123859Sml29623 	char *prop;
12133859Sml29623 
12143859Sml29623 	if (nxge_dma_obp_props_only)
12153859Sml29623 		return (NXGE_OK);
12163859Sml29623 
12173859Sml29623 	num_siblings = 0;
12183859Sml29623 	c_dip[num_siblings] = ddi_get_child(nxgep->p_dip);
12193859Sml29623 	while (c_dip[num_siblings]) {
12203859Sml29623 		c_dip[num_siblings + 1] =
12216929Smisaki 		    ddi_get_next_sibling(c_dip[num_siblings]);
12223859Sml29623 		num_siblings++;
12233859Sml29623 	}
12243859Sml29623 
12253859Sml29623 	switch (flag) {
12263859Sml29623 	case COMMON_TXDMA_CFG:
12273859Sml29623 		prop = "txdma-cfg";
12283859Sml29623 		break;
12293859Sml29623 	case COMMON_RXDMA_CFG:
12303859Sml29623 		prop = "rxdma-cfg";
12313859Sml29623 		break;
12323859Sml29623 	case COMMON_RXDMA_GRP_CFG:
12333859Sml29623 		prop = "rxdma-grp-cfg";
12343859Sml29623 		break;
12353859Sml29623 	case COMMON_CLASS_CFG:
12363859Sml29623 		status = nxge_cfg_verify_set_classify(nxgep, c_dip);
12373859Sml29623 		return (status);
12383859Sml29623 	default:
12393859Sml29623 		return (NXGE_ERROR);
12403859Sml29623 	}
12413859Sml29623 
12423859Sml29623 	i = 0;
12433859Sml29623 	while (i < num_siblings) {
12443859Sml29623 		if (ddi_prop_lookup_string(DDI_DEV_T_ANY, c_dip[i], 0, prop,
12456929Smisaki 		    (char **)&prop_val[i]) == DDI_PROP_SUCCESS) {
12463859Sml29623 			c_token[i] = nxge_get_config_token(prop_val[i]);
12473859Sml29623 			ddi_prop_free(prop_val[i]);
12483859Sml29623 			found++;
12493859Sml29623 		} else
12503859Sml29623 			c_token[i] = CONFIG_TOKEN_NONE;
12513859Sml29623 		i++;
12523859Sml29623 	}
12533859Sml29623 
12543859Sml29623 	if (found != i) {
12553859Sml29623 		if (found == 0) {
12563859Sml29623 			/* not specified: Use default */
12573859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
12586929Smisaki 			    " property %s not specified on any port:"
12596929Smisaki 			    " Using default", prop));
12603859Sml29623 
12613859Sml29623 			status = nxge_update_cfg_properties(nxgep,
12626929Smisaki 			    flag, FAIR, c_dip);
12633859Sml29623 			return (status);
12643859Sml29623 		} else {
12653859Sml29623 			/*
12663859Sml29623 			 * if  the convention is to use function 0 device then
12673859Sml29623 			 * populate the other devices with this configuration.
12683859Sml29623 			 *
12693859Sml29623 			 * The other alternative is to use the default config.
12703859Sml29623 			 */
12713859Sml29623 			/* not specified: Use default */
12723859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
12736929Smisaki 			    " property %s not specified on some ports:"
12746929Smisaki 			    " Using default", prop));
12753859Sml29623 			status = nxge_update_cfg_properties(nxgep,
12766929Smisaki 			    flag, FAIR, c_dip);
12773859Sml29623 			return (status);
12783859Sml29623 		}
12793859Sml29623 	}
12803859Sml29623 
12813859Sml29623 	/* check type and consistence */
12823859Sml29623 	/* found on all devices */
12833859Sml29623 	for (i = 1; i < found; i++) {
12843859Sml29623 		if (c_token[i] != c_token[i - 1]) {
12853859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
12866929Smisaki 			    " property %s inconsistent:"
12876929Smisaki 			    " Using default", prop));
12883859Sml29623 			status = nxge_update_cfg_properties(nxgep,
12896929Smisaki 			    flag, FAIR, c_dip);
12903859Sml29623 			return (status);
12913859Sml29623 		}
12923859Sml29623 	}
12933859Sml29623 
12943859Sml29623 	/*
12953859Sml29623 	 * Found on all the ports check if it is custom configuration. if
12963859Sml29623 	 * custom, then verify consistence
12973859Sml29623 	 *
12983859Sml29623 	 * finally create soft properties
12993859Sml29623 	 */
13003859Sml29623 	status = nxge_update_cfg_properties(nxgep, flag, c_token[0], c_dip);
13013859Sml29623 	return (status);
13023859Sml29623 }
13033859Sml29623 
13043859Sml29623 nxge_status_t
13053859Sml29623 nxge_cfg_verify_set_quick_config(p_nxge_t nxgep)
13063859Sml29623 {
13073859Sml29623 	nxge_status_t status = NXGE_OK;
13083859Sml29623 	int ddi_status = DDI_SUCCESS;
13093859Sml29623 	char *prop_val;
13103859Sml29623 	char *rx_prop;
13113859Sml29623 	char *prop;
13123859Sml29623 	uint32_t cfg_value = CFG_NOT_SPECIFIED;
13133859Sml29623 	p_nxge_param_t param_arr;
13143859Sml29623 
13153859Sml29623 	param_arr = nxgep->param_arr;
13163859Sml29623 	rx_prop = param_arr[param_rx_quick_cfg].fcode_name;
13173859Sml29623 
13183859Sml29623 	prop = "rx-quick-cfg";
13193859Sml29623 
13203859Sml29623 	/*
13213859Sml29623 	 * good value are
13223859Sml29623 	 *
13233859Sml29623 	 * "web-server" "generic-server" "l3-classify" "flow-classify"
13243859Sml29623 	 */
13253859Sml29623 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, nxgep->dip, 0,
13266929Smisaki 	    prop, (char **)&prop_val) != DDI_PROP_SUCCESS) {
13273859Sml29623 		NXGE_DEBUG_MSG((nxgep, VPD_CTL,
13286929Smisaki 		    " property %s not specified: using default ", prop));
13293859Sml29623 		cfg_value = CFG_NOT_SPECIFIED;
13303859Sml29623 	} else {
13313859Sml29623 		cfg_value = CFG_L3_DISTRIBUTE;
13323859Sml29623 		if (strncmp("web-server", (caddr_t)prop_val, 8) == 0) {
13333859Sml29623 			cfg_value = CFG_L3_WEB;
13343859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
13356929Smisaki 			    " %s: web server ", prop));
13363859Sml29623 		}
13373859Sml29623 		if (strncmp("generic-server", (caddr_t)prop_val, 8) == 0) {
13383859Sml29623 			cfg_value = CFG_L3_DISTRIBUTE;
13393859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
13406929Smisaki 			    " %s: distribute ", prop));
13413859Sml29623 		}
13423859Sml29623 		/* more */
13433859Sml29623 		ddi_prop_free(prop_val);
13443859Sml29623 	}
13453859Sml29623 
13463859Sml29623 	ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
13476929Smisaki 	    rx_prop, cfg_value);
13483859Sml29623 	if (ddi_status != DDI_PROP_SUCCESS)
13493859Sml29623 		status |= NXGE_DDI_FAILED;
13503859Sml29623 
13513859Sml29623 	/* now handle specified cases: */
13523859Sml29623 	if (status & NXGE_DDI_FAILED)
13533859Sml29623 		status |= NXGE_ERROR;
13543859Sml29623 	return (status);
13553859Sml29623 }
13563859Sml29623 
13576835Syc148097 /*
13586835Syc148097  * Device properties adv-autoneg-cap etc are defined by FWARC
13596835Syc148097  * http://sac.sfbay/FWARC/2002/345/20020610_asif.haswarey
13606835Syc148097  */
13613859Sml29623 static void
13623859Sml29623 nxge_use_cfg_link_cfg(p_nxge_t nxgep)
13633859Sml29623 {
13643859Sml29623 	int *prop_val;
13653859Sml29623 	uint_t prop_len;
13663859Sml29623 	dev_info_t *dip;
13673859Sml29623 	int speed;
13683859Sml29623 	int duplex;
13693859Sml29623 	int adv_autoneg_cap;
13703859Sml29623 	int adv_10gfdx_cap;
13713859Sml29623 	int adv_10ghdx_cap;
13723859Sml29623 	int adv_1000fdx_cap;
13733859Sml29623 	int adv_1000hdx_cap;
13743859Sml29623 	int adv_100fdx_cap;
13753859Sml29623 	int adv_100hdx_cap;
13763859Sml29623 	int adv_10fdx_cap;
13773859Sml29623 	int adv_10hdx_cap;
13783859Sml29623 	int status = DDI_SUCCESS;
13793859Sml29623 
13803859Sml29623 	dip = nxgep->dip;
13813859Sml29623 
13823859Sml29623 	/*
13833859Sml29623 	 * first find out the card type and the supported link speeds and
13843859Sml29623 	 * features
13853859Sml29623 	 */
13863859Sml29623 	/* add code for card type */
13873859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-autoneg-cap",
13886929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
13893859Sml29623 		ddi_prop_free(prop_val);
13903859Sml29623 		return;
13913859Sml29623 	}
13923859Sml29623 
13933859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10gfdx-cap",
13946929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
13953859Sml29623 		ddi_prop_free(prop_val);
13963859Sml29623 		return;
13973859Sml29623 	}
13983859Sml29623 
13993859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-1000hdx-cap",
14006929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
14013859Sml29623 		ddi_prop_free(prop_val);
14023859Sml29623 		return;
14033859Sml29623 	}
14043859Sml29623 
14053859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-1000fdx-cap",
14066929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
14073859Sml29623 		ddi_prop_free(prop_val);
14083859Sml29623 		return;
14093859Sml29623 	}
14103859Sml29623 
14113859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-100fdx-cap",
14126929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
14133859Sml29623 		ddi_prop_free(prop_val);
14143859Sml29623 		return;
14153859Sml29623 	}
14163859Sml29623 
14173859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-100hdx-cap",
14186929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
14193859Sml29623 		ddi_prop_free(prop_val);
14203859Sml29623 		return;
14213859Sml29623 	}
14223859Sml29623 
14233859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10fdx-cap",
14246929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
14253859Sml29623 		ddi_prop_free(prop_val);
14263859Sml29623 		return;
14273859Sml29623 	}
14283859Sml29623 
14293859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10hdx-cap",
14306929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
14313859Sml29623 		ddi_prop_free(prop_val);
14323859Sml29623 		return;
14333859Sml29623 	}
14343859Sml29623 
14353859Sml29623 	if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, "speed",
14366929Smisaki 	    (uchar_t **)&prop_val, &prop_len) == DDI_PROP_SUCCESS) {
14373859Sml29623 		if (strncmp("10000", (caddr_t)prop_val,
14386929Smisaki 		    (size_t)prop_len) == 0) {
14393859Sml29623 			speed = 10000;
14403859Sml29623 		} else if (strncmp("1000", (caddr_t)prop_val,
14416929Smisaki 		    (size_t)prop_len) == 0) {
14423859Sml29623 			speed = 1000;
14433859Sml29623 		} else if (strncmp("100", (caddr_t)prop_val,
14446929Smisaki 		    (size_t)prop_len) == 0) {
14453859Sml29623 			speed = 100;
14463859Sml29623 		} else if (strncmp("10", (caddr_t)prop_val,
14476929Smisaki 		    (size_t)prop_len) == 0) {
14483859Sml29623 			speed = 10;
14493859Sml29623 		} else if (strncmp("auto", (caddr_t)prop_val,
14506929Smisaki 		    (size_t)prop_len) == 0) {
14513859Sml29623 			speed = 0;
14523859Sml29623 		} else {
14533859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_NOTE,
14546929Smisaki 			    "speed property is invalid reverting to auto"));
14553859Sml29623 			speed = 0;
14563859Sml29623 		}
14573859Sml29623 		ddi_prop_free(prop_val);
14583859Sml29623 	} else
14593859Sml29623 		speed = 0;
14603859Sml29623 
14613859Sml29623 	if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, "duplex",
14626929Smisaki 	    (uchar_t **)&prop_val, &prop_len) == DDI_PROP_SUCCESS) {
14633859Sml29623 		if (strncmp("full", (caddr_t)prop_val,
14646929Smisaki 		    (size_t)prop_len) == 0) {
14653859Sml29623 			duplex = 2;
14663859Sml29623 		} else if (strncmp("half", (caddr_t)prop_val,
14676929Smisaki 		    (size_t)prop_len) == 0) {
14683859Sml29623 			duplex = 1;
14693859Sml29623 		} else if (strncmp("auto", (caddr_t)prop_val,
14706929Smisaki 		    (size_t)prop_len) == 0) {
14713859Sml29623 			duplex = 0;
14723859Sml29623 		} else {
14733859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_NOTE,
14746929Smisaki 			    "duplex property is invalid"
14756929Smisaki 			    " reverting to auto"));
14763859Sml29623 			duplex = 0;
14773859Sml29623 		}
14783859Sml29623 		ddi_prop_free(prop_val);
14793859Sml29623 	} else
14803859Sml29623 		duplex = 0;
14813859Sml29623 
14826835Syc148097 	/* speed == 0 or duplex == 0 means auto negotiation. */
14833859Sml29623 	adv_autoneg_cap = (speed == 0) || (duplex == 0);
14843859Sml29623 	if (adv_autoneg_cap == 0) {
14853859Sml29623 		adv_10gfdx_cap = ((speed == 10000) && (duplex == 2));
14863859Sml29623 		adv_10ghdx_cap = adv_10gfdx_cap;
14873859Sml29623 		adv_10ghdx_cap |= ((speed == 10000) && (duplex == 1));
14883859Sml29623 		adv_1000fdx_cap = adv_10ghdx_cap;
14893859Sml29623 		adv_1000fdx_cap |= ((speed == 1000) && (duplex == 2));
14903859Sml29623 		adv_1000hdx_cap = adv_1000fdx_cap;
14913859Sml29623 		adv_1000hdx_cap |= ((speed == 1000) && (duplex == 1));
14923859Sml29623 		adv_100fdx_cap = adv_1000hdx_cap;
14933859Sml29623 		adv_100fdx_cap |= ((speed == 100) && (duplex == 2));
14943859Sml29623 		adv_100hdx_cap = adv_100fdx_cap;
14953859Sml29623 		adv_100hdx_cap |= ((speed == 100) && (duplex == 1));
14963859Sml29623 		adv_10fdx_cap = adv_100hdx_cap;
14973859Sml29623 		adv_10fdx_cap |= ((speed == 10) && (duplex == 2));
14983859Sml29623 		adv_10hdx_cap = adv_10fdx_cap;
14993859Sml29623 		adv_10hdx_cap |= ((speed == 10) && (duplex == 1));
15003859Sml29623 	} else if (speed == 0) {
15013859Sml29623 		adv_10gfdx_cap = (duplex == 2);
15023859Sml29623 		adv_10ghdx_cap = (duplex == 1);
15033859Sml29623 		adv_1000fdx_cap = (duplex == 2);
15043859Sml29623 		adv_1000hdx_cap = (duplex == 1);
15053859Sml29623 		adv_100fdx_cap = (duplex == 2);
15063859Sml29623 		adv_100hdx_cap = (duplex == 1);
15073859Sml29623 		adv_10fdx_cap = (duplex == 2);
15083859Sml29623 		adv_10hdx_cap = (duplex == 1);
15093859Sml29623 	}
15103859Sml29623 	if (duplex == 0) {
15113859Sml29623 		adv_10gfdx_cap = (speed == 0);
15123859Sml29623 		adv_10gfdx_cap |= (speed == 10000);
15133859Sml29623 		adv_10ghdx_cap = adv_10gfdx_cap;
15143859Sml29623 		adv_10ghdx_cap |= (speed == 10000);
15153859Sml29623 		adv_1000fdx_cap = adv_10ghdx_cap;
15163859Sml29623 		adv_1000fdx_cap |= (speed == 1000);
15173859Sml29623 		adv_1000hdx_cap = adv_1000fdx_cap;
15183859Sml29623 		adv_1000hdx_cap |= (speed == 1000);
15193859Sml29623 		adv_100fdx_cap = adv_1000hdx_cap;
15203859Sml29623 		adv_100fdx_cap |= (speed == 100);
15213859Sml29623 		adv_100hdx_cap = adv_100fdx_cap;
15223859Sml29623 		adv_100hdx_cap |= (speed == 100);
15233859Sml29623 		adv_10fdx_cap = adv_100hdx_cap;
15243859Sml29623 		adv_10fdx_cap |= (speed == 10);
15253859Sml29623 		adv_10hdx_cap = adv_10fdx_cap;
15263859Sml29623 		adv_10hdx_cap |= (speed == 10);
15273859Sml29623 	}
15283859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15296929Smisaki 	    "adv-autoneg-cap", &adv_autoneg_cap, 1);
15303859Sml29623 	if (status)
15313859Sml29623 		return;
15323859Sml29623 
15333859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15346929Smisaki 	    "adv-10gfdx-cap", &adv_10gfdx_cap, 1);
15353859Sml29623 	if (status)
15363859Sml29623 		goto nxge_map_myargs_to_gmii_fail1;
15373859Sml29623 
15383859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15396929Smisaki 	    "adv-10ghdx-cap", &adv_10ghdx_cap, 1);
15403859Sml29623 	if (status)
15413859Sml29623 		goto nxge_map_myargs_to_gmii_fail2;
15423859Sml29623 
15433859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15446929Smisaki 	    "adv-1000fdx-cap", &adv_1000fdx_cap, 1);
15453859Sml29623 	if (status)
15463859Sml29623 		goto nxge_map_myargs_to_gmii_fail3;
15473859Sml29623 
15483859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15496929Smisaki 	    "adv-1000hdx-cap", &adv_1000hdx_cap, 1);
15503859Sml29623 	if (status)
15513859Sml29623 		goto nxge_map_myargs_to_gmii_fail4;
15523859Sml29623 
15533859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15546929Smisaki 	    "adv-100fdx-cap", &adv_100fdx_cap, 1);
15553859Sml29623 	if (status)
15563859Sml29623 		goto nxge_map_myargs_to_gmii_fail5;
15573859Sml29623 
15583859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15596929Smisaki 	    "adv-100hdx-cap", &adv_100hdx_cap, 1);
15603859Sml29623 	if (status)
15613859Sml29623 		goto nxge_map_myargs_to_gmii_fail6;
15623859Sml29623 
15633859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15646929Smisaki 	    "adv-10fdx-cap", &adv_10fdx_cap, 1);
15653859Sml29623 	if (status)
15663859Sml29623 		goto nxge_map_myargs_to_gmii_fail7;
15673859Sml29623 
15683859Sml29623 	status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
15696929Smisaki 	    "adv-10hdx-cap", &adv_10hdx_cap, 1);
15703859Sml29623 	if (status)
15713859Sml29623 		goto nxge_map_myargs_to_gmii_fail8;
15723859Sml29623 
15733859Sml29623 	return;
15743859Sml29623 
15753859Sml29623 nxge_map_myargs_to_gmii_fail9:
15763859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10hdx-cap");
15773859Sml29623 
15783859Sml29623 nxge_map_myargs_to_gmii_fail8:
15793859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10fdx-cap");
15803859Sml29623 
15813859Sml29623 nxge_map_myargs_to_gmii_fail7:
15823859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-100hdx-cap");
15833859Sml29623 
15843859Sml29623 nxge_map_myargs_to_gmii_fail6:
15853859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-100fdx-cap");
15863859Sml29623 
15873859Sml29623 nxge_map_myargs_to_gmii_fail5:
15883859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-1000hdx-cap");
15893859Sml29623 
15903859Sml29623 nxge_map_myargs_to_gmii_fail4:
15913859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-1000fdx-cap");
15923859Sml29623 
15933859Sml29623 nxge_map_myargs_to_gmii_fail3:
15943859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10ghdx-cap");
15953859Sml29623 
15963859Sml29623 nxge_map_myargs_to_gmii_fail2:
15973859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10gfdx-cap");
15983859Sml29623 
15993859Sml29623 nxge_map_myargs_to_gmii_fail1:
16003859Sml29623 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-autoneg-cap");
16013859Sml29623 }
16023859Sml29623 
16033859Sml29623 nxge_status_t
16043859Sml29623 nxge_get_config_properties(p_nxge_t nxgep)
16053859Sml29623 {
16063859Sml29623 	nxge_status_t status = NXGE_OK;
16073859Sml29623 	p_nxge_hw_list_t hw_p;
16083859Sml29623 
16093859Sml29623 	NXGE_DEBUG_MSG((nxgep, VPD_CTL, " ==> nxge_get_config_properties"));
16103859Sml29623 
16113859Sml29623 	if ((hw_p = nxgep->nxge_hw_p) == NULL) {
16123859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
16136929Smisaki 		    " nxge_get_config_properties:"
16146929Smisaki 		    " common hardware not set", nxgep->niu_type));
16153859Sml29623 		return (NXGE_ERROR);
16163859Sml29623 	}
16173859Sml29623 
16183859Sml29623 	/*
16193859Sml29623 	 * Get info on how many ports Neptune card has.
16203859Sml29623 	 */
16214977Sraghus 	nxgep->nports = nxge_get_nports(nxgep);
16224732Sdavemq 	if (nxgep->nports <= 0) {
16234732Sdavemq 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
16244732Sdavemq 		    "<==nxge_get_config_properties: Invalid Neptune type 0x%x",
16254732Sdavemq 		    nxgep->niu_type));
16264732Sdavemq 		return (NXGE_ERROR);
16274732Sdavemq 	}
16284732Sdavemq 	nxgep->classifier.tcam_size = TCAM_NIU_TCAM_MAX_ENTRY;
16294977Sraghus 	if (NXGE_IS_VALID_NEPTUNE_TYPE(nxgep)) {
16304977Sraghus 		nxgep->classifier.tcam_size = TCAM_NXGE_TCAM_MAX_ENTRY;
16314977Sraghus 	}
16324732Sdavemq 	if (nxgep->function_num >= nxgep->nports) {
16334732Sdavemq 		return (NXGE_ERROR);
16343859Sml29623 	}
16353859Sml29623 
16363859Sml29623 	status = nxge_get_mac_addr_properties(nxgep);
16373859Sml29623 	if (status != NXGE_OK)
16383859Sml29623 		return (NXGE_ERROR);
16393859Sml29623 
16403859Sml29623 	/*
16413859Sml29623 	 * read the configuration type. If none is specified, used default.
16423859Sml29623 	 * Config types: equal: (default) DMA channels, RDC groups, TCAM, FCRAM
16433859Sml29623 	 * are shared equally across all the ports.
16443859Sml29623 	 *
16453859Sml29623 	 * Fair: DMA channels, RDC groups, TCAM, FCRAM are shared proportional
16463859Sml29623 	 * to the port speed.
16473859Sml29623 	 *
16483859Sml29623 	 *
16493859Sml29623 	 * custom: DMA channels, RDC groups, TCAM, FCRAM partition is
16503859Sml29623 	 * specified in nxge.conf. Need to read each parameter and set
16513859Sml29623 	 * up the parameters in nxge structures.
16523859Sml29623 	 *
16533859Sml29623 	 */
16543859Sml29623 	switch (nxgep->niu_type) {
16553859Sml29623 	case N2_NIU:
16563859Sml29623 		NXGE_DEBUG_MSG((nxgep, VPD_CTL,
16576929Smisaki 		    " ==> nxge_get_config_properties: N2"));
16583859Sml29623 		MUTEX_ENTER(&hw_p->nxge_cfg_lock);
16593859Sml29623 		if ((hw_p->flags & COMMON_CFG_VALID) !=
16606929Smisaki 		    COMMON_CFG_VALID) {
16613859Sml29623 			status = nxge_cfg_verify_set(nxgep,
16626929Smisaki 			    COMMON_RXDMA_GRP_CFG);
16633859Sml29623 			status = nxge_cfg_verify_set(nxgep,
16646929Smisaki 			    COMMON_CLASS_CFG);
16653859Sml29623 			hw_p->flags |= COMMON_CFG_VALID;
16663859Sml29623 		}
16673859Sml29623 		MUTEX_EXIT(&hw_p->nxge_cfg_lock);
16683859Sml29623 		status = nxge_use_cfg_n2niu_properties(nxgep);
16693859Sml29623 		break;
16704732Sdavemq 	default:
16714977Sraghus 		if (!NXGE_IS_VALID_NEPTUNE_TYPE(nxgep)) {
16724732Sdavemq 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
16734732Sdavemq 			    " nxge_get_config_properties:"
16744732Sdavemq 			    " unknown NIU type 0x%x", nxgep->niu_type));
16754732Sdavemq 			return (NXGE_ERROR);
16764732Sdavemq 		}
16774732Sdavemq 
16783859Sml29623 		NXGE_DEBUG_MSG((nxgep, VPD_CTL,
16796929Smisaki 		    " ==> nxge_get_config_properties: Neptune"));
16803859Sml29623 		status = nxge_cfg_verify_set_quick_config(nxgep);
16813859Sml29623 		MUTEX_ENTER(&hw_p->nxge_cfg_lock);
16823859Sml29623 		if ((hw_p->flags & COMMON_CFG_VALID) !=
16836929Smisaki 		    COMMON_CFG_VALID) {
16843859Sml29623 			status = nxge_cfg_verify_set(nxgep,
16856929Smisaki 			    COMMON_TXDMA_CFG);
16863859Sml29623 			status = nxge_cfg_verify_set(nxgep,
16876929Smisaki 			    COMMON_RXDMA_CFG);
16883859Sml29623 			status = nxge_cfg_verify_set(nxgep,
16896929Smisaki 			    COMMON_RXDMA_GRP_CFG);
16903859Sml29623 			status = nxge_cfg_verify_set(nxgep,
16916929Smisaki 			    COMMON_CLASS_CFG);
16923859Sml29623 			hw_p->flags |= COMMON_CFG_VALID;
16933859Sml29623 		}
16943859Sml29623 		MUTEX_EXIT(&hw_p->nxge_cfg_lock);
16953859Sml29623 		nxge_use_cfg_neptune_properties(nxgep);
16963859Sml29623 		status = NXGE_OK;
16973859Sml29623 		break;
16983859Sml29623 	}
16993859Sml29623 
17006003Sml29623 	/*
17016003Sml29623 	 * Get the software LSO enable flag property from the
17026003Sml29623 	 * driver configuration file (nxge.conf).
17036003Sml29623 	 * This flag will be set to disable (0) if this property
17046003Sml29623 	 * does not exist.
17056003Sml29623 	 */
17066003Sml29623 	nxgep->soft_lso_enable = ddi_prop_get_int(DDI_DEV_T_ANY, nxgep->dip,
17076003Sml29623 	    DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "soft-lso-enable", 0);
17086003Sml29623 	NXGE_DEBUG_MSG((nxgep, VPD_CTL,
17096003Sml29623 	    "nxge_get_config_properties: software lso %d\n",
17106003Sml29623 	    nxgep->soft_lso_enable));
17116003Sml29623 
17123859Sml29623 	NXGE_DEBUG_MSG((nxgep, VPD_CTL, " <== nxge_get_config_properties"));
17133859Sml29623 	return (status);
17143859Sml29623 }
17153859Sml29623 
17163859Sml29623 static nxge_status_t
17173859Sml29623 nxge_use_cfg_n2niu_properties(p_nxge_t nxgep)
17183859Sml29623 {
17193859Sml29623 	nxge_status_t status = NXGE_OK;
17203859Sml29623 
17213859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_n2niu_properties"));
17223859Sml29623 
17233859Sml29623 	status = nxge_use_default_dma_config_n2(nxgep);
17243859Sml29623 	if (status != NXGE_OK) {
17253859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
17266929Smisaki 		    " ==> nxge_use_cfg_n2niu_properties (err 0x%x)",
17276929Smisaki 		    status));
17283859Sml29623 		return (status | NXGE_ERROR);
17293859Sml29623 	}
17303859Sml29623 
17313859Sml29623 	(void) nxge_use_cfg_vlan_class_config(nxgep);
17323859Sml29623 	(void) nxge_use_cfg_mac_class_config(nxgep);
17333859Sml29623 	(void) nxge_use_cfg_class_config(nxgep);
17343859Sml29623 	(void) nxge_use_cfg_link_cfg(nxgep);
17353859Sml29623 
17363859Sml29623 	/*
17373859Sml29623 	 * Read in the hardware (fcode) properties. Use the ndd array to read
17383859Sml29623 	 * each property.
17393859Sml29623 	 */
17403859Sml29623 	(void) nxge_get_param_soft_properties(nxgep);
17413859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_n2niu_properties"));
17423859Sml29623 
17433859Sml29623 	return (status);
17443859Sml29623 }
17453859Sml29623 
17463859Sml29623 static void
17473859Sml29623 nxge_use_cfg_neptune_properties(p_nxge_t nxgep)
17483859Sml29623 {
17493859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_neptune_properties"));
17503859Sml29623 
17513859Sml29623 	(void) nxge_use_cfg_dma_config(nxgep);
17523859Sml29623 	(void) nxge_use_cfg_vlan_class_config(nxgep);
17533859Sml29623 	(void) nxge_use_cfg_mac_class_config(nxgep);
17543859Sml29623 	(void) nxge_use_cfg_class_config(nxgep);
17553859Sml29623 	(void) nxge_use_cfg_link_cfg(nxgep);
17563859Sml29623 
17573859Sml29623 	/*
17583859Sml29623 	 * Read in the hardware (fcode) properties. Use the ndd array to read
17593859Sml29623 	 * each property.
17603859Sml29623 	 */
17613859Sml29623 	(void) nxge_get_param_soft_properties(nxgep);
17623859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_neptune_properties"));
17633859Sml29623 }
17643859Sml29623 
17653859Sml29623 /*
17663859Sml29623  * FWARC 2006/556
17673859Sml29623  */
17683859Sml29623 
17693859Sml29623 static nxge_status_t
17703859Sml29623 nxge_use_default_dma_config_n2(p_nxge_t nxgep)
17713859Sml29623 {
17723859Sml29623 	int ndmas;
17733859Sml29623 	uint8_t func;
17743859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
17753859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
17763859Sml29623 	int *prop_val;
17773859Sml29623 	uint_t prop_len;
17783859Sml29623 	int i;
17793859Sml29623 	nxge_status_t status = NXGE_OK;
17803859Sml29623 
17813859Sml29623 	NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2"));
17823859Sml29623 
17833859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
17843859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
17853859Sml29623 
17863859Sml29623 	func = nxgep->function_num;
17873859Sml29623 	p_cfgp->function_number = func;
17883859Sml29623 	ndmas = NXGE_TDMA_PER_NIU_PORT;
17893859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
17906929Smisaki 	    "tx-dma-channels", (int **)&prop_val,
17916929Smisaki 	    &prop_len) == DDI_PROP_SUCCESS) {
17926495Sspeer 		p_cfgp->tdc.start = prop_val[0];
17933859Sml29623 		NXGE_DEBUG_MSG((nxgep, OBP_CTL,
17946929Smisaki 		    "==> nxge_use_default_dma_config_n2: tdc starts %d "
17956929Smisaki 		    "(#%d)", p_cfgp->tdc.start, prop_len));
17963859Sml29623 
17973859Sml29623 		ndmas = prop_val[1];
17983859Sml29623 		NXGE_DEBUG_MSG((nxgep, OBP_CTL,
17996929Smisaki 		    "==> nxge_use_default_dma_config_n2: #tdc %d (#%d)",
18006929Smisaki 		    ndmas, prop_len));
18013859Sml29623 		ddi_prop_free(prop_val);
18023859Sml29623 	} else {
18033859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
18046929Smisaki 		    "==> nxge_use_default_dma_config_n2: "
18056929Smisaki 		    "get tx-dma-channels failed"));
18063859Sml29623 		return (NXGE_DDI_FAILED);
18073859Sml29623 	}
18083859Sml29623 
18096495Sspeer 	p_cfgp->tdc.count = nxgep->max_tdcs = ndmas;
18106495Sspeer 	p_cfgp->tdc.owned = p_cfgp->tdc.count;
18113859Sml29623 
18123859Sml29623 	NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: "
18136929Smisaki 	    "p_cfgp 0x%llx max_tdcs %d nxgep->max_tdcs %d start %d",
18146929Smisaki 	    p_cfgp, p_cfgp->tdc.count, nxgep->max_tdcs, p_cfgp->tdc.start));
18153859Sml29623 
18163859Sml29623 	/* Receive DMA */
18173859Sml29623 	ndmas = NXGE_RDMA_PER_NIU_PORT;
18183859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
18196929Smisaki 	    "rx-dma-channels", (int **)&prop_val,
18206929Smisaki 	    &prop_len) == DDI_PROP_SUCCESS) {
18213859Sml29623 		p_cfgp->start_rdc = prop_val[0];
18223859Sml29623 		NXGE_DEBUG_MSG((nxgep, OBP_CTL,
18236929Smisaki 		    "==> nxge_use_default_dma_config_n2(obp): rdc start %d"
18246929Smisaki 		    " (#%d)", p_cfgp->start_rdc, prop_len));
18253859Sml29623 		ndmas = prop_val[1];
18263859Sml29623 		NXGE_DEBUG_MSG((nxgep, OBP_CTL,
18276929Smisaki 		    "==> nxge_use_default_dma_config_n2(obp):#rdc %d (#%d)",
18286929Smisaki 		    ndmas, prop_len));
18293859Sml29623 		ddi_prop_free(prop_val);
18303859Sml29623 	} else {
18313859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
18326929Smisaki 		    "==> nxge_use_default_dma_config_n2: "
18336929Smisaki 		    "get rx-dma-channel failed"));
18343859Sml29623 		return (NXGE_DDI_FAILED);
18353859Sml29623 	}
18363859Sml29623 
18373859Sml29623 	p_cfgp->max_rdcs = nxgep->max_rdcs = ndmas;
18383859Sml29623 	nxgep->rdc_mask = (ndmas - 1);
18393859Sml29623 
18403859Sml29623 	/* Hypervisor: rdc # and group # use the same # !! */
18416495Sspeer 	p_cfgp->max_grpids = p_cfgp->max_rdcs + p_cfgp->tdc.owned;
18423859Sml29623 	p_cfgp->start_grpid = 0;
18433859Sml29623 	p_cfgp->mif_ldvid = p_cfgp->mac_ldvid = p_cfgp->ser_ldvid = 0;
18443859Sml29623 
18453859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
18466929Smisaki 	    "interrupts", (int **)&prop_val,
18476929Smisaki 	    &prop_len) == DDI_PROP_SUCCESS) {
18483859Sml29623 		/*
18493859Sml29623 		 * For each device assigned, the content of each interrupts
18503859Sml29623 		 * property is its logical device group.
18513859Sml29623 		 *
18523859Sml29623 		 * Assignment of interrupts property is in the the following
18533859Sml29623 		 * order:
18543859Sml29623 		 *
18553859Sml29623 		 * MAC MIF (if configured) SYSTEM ERROR (if configured) first
18563859Sml29623 		 * receive channel next channel...... last receive channel
18573859Sml29623 		 * first transmit channel next channel...... last transmit
18583859Sml29623 		 * channel
18593859Sml29623 		 *
18603859Sml29623 		 * prop_len should be at least for one mac and total # of rx and
18613859Sml29623 		 * tx channels. Function 0 owns MIF and ERROR
18623859Sml29623 		 */
18633859Sml29623 		NXGE_DEBUG_MSG((nxgep, OBP_CTL,
18646929Smisaki 		    "==> nxge_use_default_dma_config_n2(obp): "
18656929Smisaki 		    "# interrupts %d", prop_len));
18663859Sml29623 
18673859Sml29623 		switch (func) {
18683859Sml29623 		case 0:
18693859Sml29623 			p_cfgp->ldg_chn_start = 3;
18703859Sml29623 			p_cfgp->mac_ldvid = NXGE_MAC_LD_PORT0;
18713859Sml29623 			p_cfgp->mif_ldvid = NXGE_MIF_LD;
18723859Sml29623 			p_cfgp->ser_ldvid = NXGE_SYS_ERROR_LD;
18733859Sml29623 
18743859Sml29623 			break;
18753859Sml29623 		case 1:
18763859Sml29623 			p_cfgp->ldg_chn_start = 1;
18773859Sml29623 			p_cfgp->mac_ldvid = NXGE_MAC_LD_PORT1;
18783859Sml29623 
18793859Sml29623 			break;
18803859Sml29623 		default:
18813859Sml29623 			status = NXGE_DDI_FAILED;
18823859Sml29623 			break;
18833859Sml29623 		}
18843859Sml29623 
18853859Sml29623 		if (status != NXGE_OK)
18863859Sml29623 			return (status);
18873859Sml29623 
18883859Sml29623 		for (i = 0; i < prop_len; i++) {
18893859Sml29623 			p_cfgp->ldg[i] = prop_val[i];
18903859Sml29623 			NXGE_DEBUG_MSG((nxgep, OBP_CTL,
18916929Smisaki 			    "==> nxge_use_default_dma_config_n2(obp): "
18926929Smisaki 			    "F%d: interrupt #%d, ldg %d",
18936929Smisaki 			    nxgep->function_num, i, p_cfgp->ldg[i]));
18943859Sml29623 		}
18953859Sml29623 
18963859Sml29623 		p_cfgp->max_grpids = prop_len;
18973859Sml29623 		NXGE_DEBUG_MSG((nxgep, OBP_CTL,
18986929Smisaki 		    "==> nxge_use_default_dma_config_n2(obp): %d "
18996929Smisaki 		    "(#%d) maxgrpids %d channel starts %d",
19006929Smisaki 		    p_cfgp->mac_ldvid, i, p_cfgp->max_grpids,
19016929Smisaki 		    p_cfgp->ldg_chn_start));
19023859Sml29623 		ddi_prop_free(prop_val);
19033859Sml29623 	} else {
19043859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
19056929Smisaki 		    "==> nxge_use_default_dma_config_n2: "
19066929Smisaki 		    "get interrupts failed"));
19073859Sml29623 		return (NXGE_DDI_FAILED);
19083859Sml29623 	}
19093859Sml29623 
19103859Sml29623 	p_cfgp->max_ldgs = p_cfgp->max_grpids;
19113859Sml29623 	NXGE_DEBUG_MSG((nxgep, OBP_CTL,
19126929Smisaki 	    "==> nxge_use_default_dma_config_n2: "
19136929Smisaki 	    "p_cfgp 0x%llx max_rdcs %d nxgep->max_rdcs %d max_grpids %d"
19146929Smisaki 	    "start_grpid %d macid %d mifid %d serrid %d",
19156929Smisaki 	    p_cfgp, p_cfgp->max_rdcs, nxgep->max_rdcs, p_cfgp->max_grpids,
19166929Smisaki 	    p_cfgp->start_grpid,
19176929Smisaki 	    p_cfgp->mac_ldvid, p_cfgp->mif_ldvid, p_cfgp->ser_ldvid));
19183859Sml29623 
19193859Sml29623 	NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: "
19206929Smisaki 	    "p_cfgp p%p start_ldg %d nxgep->max_ldgs %d",
19216929Smisaki 	    p_cfgp, p_cfgp->start_ldg, p_cfgp->max_ldgs));
19223859Sml29623 
19233859Sml29623 	/*
19243859Sml29623 	 * RDC groups and the beginning RDC group assigned to this function.
19253859Sml29623 	 */
19266495Sspeer 	p_cfgp->max_rdc_grpids = 1;
19276495Sspeer 	p_cfgp->def_mac_rxdma_grpid = (nxgep->function_num * 1);
19286495Sspeer 
19296495Sspeer 	if ((p_cfgp->def_mac_rxdma_grpid = nxge_fzc_rdc_tbl_bind
19306929Smisaki 	    (nxgep, p_cfgp->def_mac_rxdma_grpid, B_TRUE))
19316495Sspeer 	    >= NXGE_MAX_RDC_GRPS) {
19326495Sspeer 		NXGE_ERROR_MSG((nxgep, CFG_CTL,
19336495Sspeer 		    "nxge_use_default_dma_config_n2(): "
19346495Sspeer 		    "nxge_fzc_rdc_tbl_bind failed"));
19356495Sspeer 		return (NXGE_DDI_FAILED);
19366495Sspeer 	}
19373859Sml29623 
19383859Sml29623 	status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
19396495Sspeer 	    "rx-rdc-grps", p_cfgp->max_rdc_grpids);
19403859Sml29623 	if (status) {
19413859Sml29623 		return (NXGE_DDI_FAILED);
19423859Sml29623 	}
19433859Sml29623 	status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
19446929Smisaki 	    "rx-rdc-grps-begin", p_cfgp->def_mac_rxdma_grpid);
19453859Sml29623 	if (status) {
19463859Sml29623 		(void) ddi_prop_remove(DDI_DEV_T_NONE, nxgep->dip,
19476929Smisaki 		    "rx-rdc-grps");
19483859Sml29623 		return (NXGE_DDI_FAILED);
19493859Sml29623 	}
19503859Sml29623 	NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: "
19516929Smisaki 	    "p_cfgp $%p # rdc groups %d start rdc group id %d",
19526929Smisaki 	    p_cfgp, p_cfgp->max_rdc_grpids,
19536929Smisaki 	    p_cfgp->def_mac_rxdma_grpid));
19543859Sml29623 
19553859Sml29623 	nxge_set_hw_dma_config(nxgep);
19563859Sml29623 	NXGE_DEBUG_MSG((nxgep, OBP_CTL, "<== nxge_use_default_dma_config_n2"));
19573859Sml29623 	return (status);
19583859Sml29623 }
19593859Sml29623 
19603859Sml29623 static void
19613859Sml29623 nxge_use_cfg_dma_config(p_nxge_t nxgep)
19623859Sml29623 {
19634732Sdavemq 	int tx_ndmas, rx_ndmas, nrxgp, st_txdma, st_rxdma;
19643859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
19653859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
19663859Sml29623 	dev_info_t *dip;
19673859Sml29623 	p_nxge_param_t param_arr;
19683859Sml29623 	char *prop;
19693859Sml29623 	int *prop_val;
19703859Sml29623 	uint_t prop_len;
19714732Sdavemq 	int i;
19724732Sdavemq 	uint8_t *ch_arr_p;
19733859Sml29623 
19743859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_dma_config"));
19753859Sml29623 	param_arr = nxgep->param_arr;
19763859Sml29623 
19773859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
19783859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
19793859Sml29623 	dip = nxgep->dip;
19803859Sml29623 	p_cfgp->function_number = nxgep->function_num;
19813859Sml29623 	prop = param_arr[param_txdma_channels_begin].fcode_name;
19823859Sml29623 
19833859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop,
19846929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
19856495Sspeer 		p_cfgp->tdc.start = *prop_val;
19863859Sml29623 		ddi_prop_free(prop_val);
19873859Sml29623 	} else {
19884732Sdavemq 		switch (nxgep->niu_type) {
19894732Sdavemq 		case NEPTUNE_4_1GC:
19904732Sdavemq 			ch_arr_p = &tx_4_1G[0];
19914732Sdavemq 			break;
19924732Sdavemq 		case NEPTUNE_2_10GF:
19934732Sdavemq 			ch_arr_p = &tx_2_10G[0];
19944732Sdavemq 			break;
19954732Sdavemq 		case NEPTUNE_2_10GF_2_1GC:
19966261Sjoycey 		case NEPTUNE_2_10GF_2_1GRF:
19974732Sdavemq 			ch_arr_p = &tx_2_10G_2_1G[0];
19984732Sdavemq 			break;
19994732Sdavemq 		case NEPTUNE_1_10GF_3_1GC:
20004732Sdavemq 			ch_arr_p = &tx_1_10G_3_1G[0];
20014732Sdavemq 			break;
20024732Sdavemq 		case NEPTUNE_1_1GC_1_10GF_2_1GC:
20034732Sdavemq 			ch_arr_p = &tx_1_1G_1_10G_2_1G[0];
20044732Sdavemq 			break;
20054732Sdavemq 		default:
20065196Ssbehera 			switch (nxgep->platform_type) {
20075196Ssbehera 			case P_NEPTUNE_ALONSO:
20085196Ssbehera 				ch_arr_p = &tx_2_10G_2_1G[0];
20095196Ssbehera 				break;
20105196Ssbehera 			default:
20115196Ssbehera 				ch_arr_p = &p4_tx_equal[0];
20125196Ssbehera 				break;
20135196Ssbehera 			}
20144732Sdavemq 			break;
20153859Sml29623 		}
20164732Sdavemq 		st_txdma = 0;
20174732Sdavemq 		for (i = 0; i < nxgep->function_num; i++, ch_arr_p++)
20184732Sdavemq 			st_txdma += *ch_arr_p;
20194732Sdavemq 
20203859Sml29623 		(void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
20214732Sdavemq 		    prop, st_txdma);
20226495Sspeer 		p_cfgp->tdc.start = st_txdma;
20233859Sml29623 	}
20243859Sml29623 
20253859Sml29623 	prop = param_arr[param_txdma_channels].fcode_name;
20263859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop,
20276929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
20283859Sml29623 		tx_ndmas = *prop_val;
20293859Sml29623 		ddi_prop_free(prop_val);
20303859Sml29623 	} else {
20314732Sdavemq 		switch (nxgep->niu_type) {
20324732Sdavemq 		case NEPTUNE_4_1GC:
20334732Sdavemq 			tx_ndmas = tx_4_1G[nxgep->function_num];
20344732Sdavemq 			break;
20354732Sdavemq 		case NEPTUNE_2_10GF:
20364732Sdavemq 			tx_ndmas = tx_2_10G[nxgep->function_num];
20374732Sdavemq 			break;
20384732Sdavemq 		case NEPTUNE_2_10GF_2_1GC:
20396261Sjoycey 		case NEPTUNE_2_10GF_2_1GRF:
20404732Sdavemq 			tx_ndmas = tx_2_10G_2_1G[nxgep->function_num];
20414732Sdavemq 			break;
20424732Sdavemq 		case NEPTUNE_1_10GF_3_1GC:
20434732Sdavemq 			tx_ndmas = tx_1_10G_3_1G[nxgep->function_num];
20444732Sdavemq 			break;
20454732Sdavemq 		case NEPTUNE_1_1GC_1_10GF_2_1GC:
20464732Sdavemq 			tx_ndmas = tx_1_1G_1_10G_2_1G[nxgep->function_num];
20474732Sdavemq 			break;
20484732Sdavemq 		default:
20495196Ssbehera 			switch (nxgep->platform_type) {
20505196Ssbehera 			case P_NEPTUNE_ALONSO:
20515196Ssbehera 				tx_ndmas = tx_2_10G_2_1G[nxgep->function_num];
20525196Ssbehera 				break;
20535196Ssbehera 			default:
20545196Ssbehera 				tx_ndmas = p4_tx_equal[nxgep->function_num];
20555196Ssbehera 				break;
20565196Ssbehera 			}
20574732Sdavemq 			break;
20583859Sml29623 		}
20593859Sml29623 		(void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
20606929Smisaki 		    prop, tx_ndmas);
20613859Sml29623 	}
20623859Sml29623 
20636495Sspeer 	p_cfgp->tdc.count = nxgep->max_tdcs = tx_ndmas;
20646495Sspeer 	p_cfgp->tdc.owned = p_cfgp->tdc.count;
20653859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_dma_config: "
20666929Smisaki 	    "p_cfgp 0x%llx max_tdcs %d nxgep->max_tdcs %d",
20676929Smisaki 	    p_cfgp, p_cfgp->tdc.count, nxgep->max_tdcs));
20683859Sml29623 
20693859Sml29623 	prop = param_arr[param_rxdma_channels_begin].fcode_name;
20703859Sml29623 
20713859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop,
20726929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
20733859Sml29623 		p_cfgp->start_rdc = *prop_val;
20743859Sml29623 		ddi_prop_free(prop_val);
20753859Sml29623 	} else {
20764732Sdavemq 		switch (nxgep->niu_type) {
20774732Sdavemq 		case NEPTUNE_4_1GC:
20784732Sdavemq 			ch_arr_p = &rx_4_1G[0];
20794732Sdavemq 			break;
20804732Sdavemq 		case NEPTUNE_2_10GF:
20814732Sdavemq 			ch_arr_p = &rx_2_10G[0];
20824732Sdavemq 			break;
20834732Sdavemq 		case NEPTUNE_2_10GF_2_1GC:
20846261Sjoycey 		case NEPTUNE_2_10GF_2_1GRF:
20854732Sdavemq 			ch_arr_p = &rx_2_10G_2_1G[0];
20864732Sdavemq 			break;
20874732Sdavemq 		case NEPTUNE_1_10GF_3_1GC:
20884732Sdavemq 			ch_arr_p = &rx_1_10G_3_1G[0];
20894732Sdavemq 			break;
20904732Sdavemq 		case NEPTUNE_1_1GC_1_10GF_2_1GC:
20914732Sdavemq 			ch_arr_p = &rx_1_1G_1_10G_2_1G[0];
20924732Sdavemq 			break;
20934732Sdavemq 		default:
20945196Ssbehera 			switch (nxgep->platform_type) {
20955196Ssbehera 			case P_NEPTUNE_ALONSO:
20965196Ssbehera 				ch_arr_p = &rx_2_10G_2_1G[0];
20975196Ssbehera 				break;
20985196Ssbehera 			default:
20995196Ssbehera 				ch_arr_p = &p4_rx_equal[0];
21005196Ssbehera 				break;
21015196Ssbehera 			}
21024732Sdavemq 			break;
21033859Sml29623 		}
21044732Sdavemq 		st_rxdma = 0;
21054732Sdavemq 		for (i = 0; i < nxgep->function_num; i++, ch_arr_p++)
21064732Sdavemq 			st_rxdma += *ch_arr_p;
21074732Sdavemq 
21083859Sml29623 		(void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
21094732Sdavemq 		    prop, st_rxdma);
21104732Sdavemq 		p_cfgp->start_rdc = st_rxdma;
21113859Sml29623 	}
21123859Sml29623 
21133859Sml29623 	prop = param_arr[param_rxdma_channels].fcode_name;
21143859Sml29623 
21153859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop,
21166929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
21173859Sml29623 		rx_ndmas = *prop_val;
21183859Sml29623 		ddi_prop_free(prop_val);
21193859Sml29623 	} else {
21204732Sdavemq 		switch (nxgep->niu_type) {
21214732Sdavemq 		case NEPTUNE_4_1GC:
21224732Sdavemq 			rx_ndmas = rx_4_1G[nxgep->function_num];
21234732Sdavemq 			break;
21244732Sdavemq 		case NEPTUNE_2_10GF:
21254732Sdavemq 			rx_ndmas = rx_2_10G[nxgep->function_num];
21264732Sdavemq 			break;
21274732Sdavemq 		case NEPTUNE_2_10GF_2_1GC:
21286261Sjoycey 		case NEPTUNE_2_10GF_2_1GRF:
21294732Sdavemq 			rx_ndmas = rx_2_10G_2_1G[nxgep->function_num];
21304732Sdavemq 			break;
21314732Sdavemq 		case NEPTUNE_1_10GF_3_1GC:
21324732Sdavemq 			rx_ndmas = rx_1_10G_3_1G[nxgep->function_num];
21334732Sdavemq 			break;
21344732Sdavemq 		case NEPTUNE_1_1GC_1_10GF_2_1GC:
21354732Sdavemq 			rx_ndmas = rx_1_1G_1_10G_2_1G[nxgep->function_num];
21364732Sdavemq 			break;
21374732Sdavemq 		default:
21385196Ssbehera 			switch (nxgep->platform_type) {
21395196Ssbehera 			case P_NEPTUNE_ALONSO:
21405196Ssbehera 				rx_ndmas = rx_2_10G_2_1G[nxgep->function_num];
21415196Ssbehera 				break;
21425196Ssbehera 			default:
21435196Ssbehera 				rx_ndmas = p4_rx_equal[nxgep->function_num];
21445196Ssbehera 				break;
21455196Ssbehera 			}
21464732Sdavemq 			break;
21473859Sml29623 		}
21483859Sml29623 		(void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
21496929Smisaki 		    prop, rx_ndmas);
21503859Sml29623 	}
21513859Sml29623 
21523859Sml29623 	p_cfgp->max_rdcs = nxgep->max_rdcs = rx_ndmas;
21533859Sml29623 
21543859Sml29623 	prop = param_arr[param_rdc_grps_start].fcode_name;
21553859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop,
21566929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
21576495Sspeer 		p_cfgp->def_mac_rxdma_grpid = *prop_val;
21583859Sml29623 		ddi_prop_free(prop_val);
21596495Sspeer 		if ((p_cfgp->def_mac_rxdma_grpid = nxge_fzc_rdc_tbl_bind
21606929Smisaki 		    (nxgep, p_cfgp->def_mac_rxdma_grpid, B_TRUE))
21616495Sspeer 		    >= NXGE_MAX_RDC_GRPS) {
21626495Sspeer 			NXGE_ERROR_MSG((nxgep, CFG_CTL,
21636495Sspeer 			    "nxge_use_cfg_dma_config(): "
21646495Sspeer 			    "nxge_fzc_rdc_tbl_bind failed"));
21656495Sspeer 			cmn_err(CE_CONT, "nxge%d: group not available!\n",
21666495Sspeer 			    nxgep->instance);
21676495Sspeer 			goto nxge_use_cfg_dma_config_exit;
21686495Sspeer 		}
21696495Sspeer 
21703859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL,
21716495Sspeer 		    "==> nxge_use_default_dma_config: "
21726495Sspeer 		    "use property " "start_grpid %d ",
21736929Smisaki 		    p_cfgp->start_grpid));
21743859Sml29623 	} else {
21756495Sspeer 		p_cfgp->def_mac_rxdma_grpid = nxgep->function_num;
21766495Sspeer 		if ((p_cfgp->def_mac_rxdma_grpid = nxge_fzc_rdc_tbl_bind(
21776495Sspeer 		    nxgep, p_cfgp->def_mac_rxdma_grpid, B_TRUE)) >=
21786495Sspeer 		    NXGE_MAX_RDC_GRPS) {
21796495Sspeer 			cmn_err(CE_CONT, "nxge%d: group not available!\n",
21806495Sspeer 			    nxgep->instance);
21816495Sspeer 			goto nxge_use_cfg_dma_config_exit;
21826495Sspeer 		}
21833859Sml29623 		(void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
21846929Smisaki 		    prop, p_cfgp->def_mac_rxdma_grpid);
21853859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL,
21866929Smisaki 		    "==> nxge_use_default_dma_config: "
21876929Smisaki 		    "use default "
21886929Smisaki 		    "start_grpid %d (same as function #)",
21896929Smisaki 		    p_cfgp->start_grpid));
21903859Sml29623 	}
21913859Sml29623 
21923859Sml29623 	prop = param_arr[param_rx_rdc_grps].fcode_name;
21933859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop,
21946929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
21953859Sml29623 		nrxgp = *prop_val;
21963859Sml29623 		ddi_prop_free(prop_val);
21973859Sml29623 	} else {
21983859Sml29623 		nrxgp = 1;
21993859Sml29623 		(void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip,
22006929Smisaki 		    prop, nrxgp);
22013859Sml29623 		NXGE_DEBUG_MSG((nxgep, CFG_CTL,
22026929Smisaki 		    "==> nxge_use_default_dma_config: "
22036929Smisaki 		    "num_rdc_grpid not found: use def:# of "
22046929Smisaki 		    "rdc groups %d\n", nrxgp));
22053859Sml29623 	}
22063859Sml29623 
22073859Sml29623 	p_cfgp->max_rdc_grpids = nrxgp;
22083859Sml29623 
22093859Sml29623 	/*
22103859Sml29623 	 * 2/4 ports have the same hard-wired logical groups assigned.
22113859Sml29623 	 */
22123859Sml29623 	p_cfgp->start_ldg = nxgep->function_num * NXGE_LDGRP_PER_4PORTS;
22133859Sml29623 	p_cfgp->max_ldgs = NXGE_LDGRP_PER_4PORTS;
22143859Sml29623 
22153859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_default_dma_config: "
22166929Smisaki 	    "p_cfgp 0x%llx max_rdcs %d nxgep->max_rdcs %d max_grpids %d"
22176929Smisaki 	    "start_grpid %d",
22186929Smisaki 	    p_cfgp, p_cfgp->max_rdcs, nxgep->max_rdcs, p_cfgp->max_grpids,
22196929Smisaki 	    p_cfgp->start_grpid));
22203859Sml29623 
22213859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_dma_config: "
22226929Smisaki 	    "p_cfgp 0x%016llx start_ldg %d nxgep->max_ldgs %d "
22236929Smisaki 	    "def_mac_rxdma_grpid %d",
22246929Smisaki 	    p_cfgp, p_cfgp->start_ldg, p_cfgp->max_ldgs,
22256929Smisaki 	    p_cfgp->def_mac_rxdma_grpid));
22263859Sml29623 
22273859Sml29623 	prop = param_arr[param_rxdma_intr_time].fcode_name;
22283859Sml29623 
22293859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop,
22306929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
22313859Sml29623 		if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) {
22323859Sml29623 			(void) ddi_prop_update_int_array(DDI_DEV_T_NONE,
22336929Smisaki 			    nxgep->dip, prop, prop_val, prop_len);
22343859Sml29623 		}
22353859Sml29623 		ddi_prop_free(prop_val);
22363859Sml29623 	}
22373859Sml29623 	prop = param_arr[param_rxdma_intr_pkts].fcode_name;
22383859Sml29623 
22393859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop,
22406929Smisaki 	    &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
22413859Sml29623 		if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) {
22423859Sml29623 			(void) ddi_prop_update_int_array(DDI_DEV_T_NONE,
22436929Smisaki 			    nxgep->dip, prop, prop_val, prop_len);
22443859Sml29623 		}
22453859Sml29623 		ddi_prop_free(prop_val);
22463859Sml29623 	}
22473859Sml29623 	nxge_set_hw_dma_config(nxgep);
22483859Sml29623 
22494732Sdavemq 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_dma_config: "
22504732Sdavemq 	    "sTDC[%d] nTDC[%d] sRDC[%d] nRDC[%d]",
22516495Sspeer 	    p_cfgp->tdc.start, p_cfgp->tdc.count,
22524732Sdavemq 	    p_cfgp->start_rdc, p_cfgp->max_rdcs));
22534732Sdavemq 
22546495Sspeer nxge_use_cfg_dma_config_exit:
22553859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_dma_config"));
22563859Sml29623 }
22573859Sml29623 
22586495Sspeer void
22596495Sspeer nxge_get_logical_props(p_nxge_t nxgep)
22606495Sspeer {
22616495Sspeer 	nxge_dma_pt_cfg_t *port = &nxgep->pt_config;
22626495Sspeer 	nxge_hw_pt_cfg_t *hardware;
22636495Sspeer 	nxge_rdc_grp_t *group;
22646495Sspeer 
22656495Sspeer 	(void) memset(port, 0, sizeof (*port));
22666495Sspeer 
22676495Sspeer 	port->mac_port = 0;	/* := function number */
22686495Sspeer 
22696495Sspeer 	/*
22706495Sspeer 	 * alloc_buf_size:
22716495Sspeer 	 * dead variables.
22726495Sspeer 	 */
22736495Sspeer 	port->rbr_size = nxge_rbr_size;
22746495Sspeer 	port->rcr_size = nxge_rcr_size;
22756495Sspeer 
22766495Sspeer 	port->tx_dma_map = 0;	/* Transmit DMA channel bit map */
22776495Sspeer 
22786495Sspeer 	nxge_set_rdc_intr_property(nxgep);
22796495Sspeer 
22806495Sspeer 	port->rcr_full_header = NXGE_RCR_FULL_HEADER;
22816495Sspeer 	port->rx_drr_weight = PT_DRR_WT_DEFAULT_10G;
22826495Sspeer 
22836495Sspeer 	/* ----------------------------------------------------- */
22846495Sspeer 	hardware = &port->hw_config;
22856495Sspeer 
22866495Sspeer 	(void) memset(hardware, 0, sizeof (*hardware));
22876495Sspeer 
22886495Sspeer 	/*
22896495Sspeer 	 * partition_id, read_write_mode:
22906495Sspeer 	 * dead variables.
22916495Sspeer 	 */
22926495Sspeer 
22936495Sspeer 	/*
22946495Sspeer 	 * drr_wt, rx_full_header, *_ldg?, start_mac_entry,
22956495Sspeer 	 * mac_pref, def_mac_rxdma_grpid, start_vlan, max_vlans,
22966495Sspeer 	 * start_ldgs, max_ldgs, max_ldvs,
22976495Sspeer 	 * vlan_pref, def_vlan_rxdma_grpid are meaningful only
22986495Sspeer 	 * in the service domain.
22996495Sspeer 	 */
23006495Sspeer 
23016495Sspeer 	group = &port->rdc_grps[0];
23026495Sspeer 
23036495Sspeer 	group->flag = 1;	/* configured */
23046495Sspeer 	group->config_method = RDC_TABLE_ENTRY_METHOD_REP;
23056495Sspeer 
23066495Sspeer 	/* HIO futures: this is still an open question. */
23076495Sspeer 	hardware->max_macs = 1;
23086495Sspeer }
23096495Sspeer 
23103859Sml29623 static void
23113859Sml29623 nxge_use_cfg_vlan_class_config(p_nxge_t nxgep)
23123859Sml29623 {
23133859Sml29623 	uint_t vlan_cnt;
23143859Sml29623 	int *vlan_cfg_val;
23153859Sml29623 	int status;
23163859Sml29623 	p_nxge_param_t param_arr;
23173859Sml29623 	char *prop;
23183859Sml29623 
23193859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_vlan_config"));
23203859Sml29623 	param_arr = nxgep->param_arr;
23213859Sml29623 	prop = param_arr[param_vlan_2rdc_grp].fcode_name;
23223859Sml29623 
23233859Sml29623 	status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop,
23246929Smisaki 	    &vlan_cfg_val, &vlan_cnt);
23253859Sml29623 	if (status == DDI_PROP_SUCCESS) {
23263859Sml29623 		status = ddi_prop_update_int_array(DDI_DEV_T_NONE,
23276929Smisaki 		    nxgep->dip, prop, vlan_cfg_val, vlan_cnt);
23283859Sml29623 		ddi_prop_free(vlan_cfg_val);
23293859Sml29623 	}
23303859Sml29623 	nxge_set_hw_vlan_class_config(nxgep);
23313859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_vlan_config"));
23323859Sml29623 }
23333859Sml29623 
23343859Sml29623 static void
23353859Sml29623 nxge_use_cfg_mac_class_config(p_nxge_t nxgep)
23363859Sml29623 {
23373859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
23383859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
23393859Sml29623 	uint_t mac_cnt;
23403859Sml29623 	int *mac_cfg_val;
23413859Sml29623 	int status;
23423859Sml29623 	p_nxge_param_t param_arr;
23433859Sml29623 	char *prop;
23443859Sml29623 
23453859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_mac_class_config"));
23463859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
23473859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
23483859Sml29623 	p_cfgp->start_mac_entry = 0;
23493859Sml29623 	param_arr = nxgep->param_arr;
23503859Sml29623 	prop = param_arr[param_mac_2rdc_grp].fcode_name;
23513859Sml29623 
23523859Sml29623 	switch (nxgep->function_num) {
23533859Sml29623 	case 0:
23543859Sml29623 	case 1:
23553859Sml29623 		/* 10G ports */
23563859Sml29623 		p_cfgp->max_macs = NXGE_MAX_MACS_XMACS;
23573859Sml29623 		break;
23583859Sml29623 	case 2:
23593859Sml29623 	case 3:
23603859Sml29623 		/* 1G ports */
23613859Sml29623 	default:
23623859Sml29623 		p_cfgp->max_macs = NXGE_MAX_MACS_BMACS;
23633859Sml29623 		break;
23643859Sml29623 	}
23653859Sml29623 
23663859Sml29623 	p_cfgp->mac_pref = 1;
23673859Sml29623 	NXGE_DEBUG_MSG((nxgep, OBP_CTL,
23686929Smisaki 	    "== nxge_use_cfg_mac_class_config: "
23696929Smisaki 	    " mac_pref bit set def_mac_rxdma_grpid %d",
23706929Smisaki 	    p_cfgp->def_mac_rxdma_grpid));
23713859Sml29623 
23723859Sml29623 	status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop,
23736929Smisaki 	    &mac_cfg_val, &mac_cnt);
23743859Sml29623 	if (status == DDI_PROP_SUCCESS) {
23753859Sml29623 		if (mac_cnt <= p_cfgp->max_macs)
23763859Sml29623 			status = ddi_prop_update_int_array(DDI_DEV_T_NONE,
23776929Smisaki 			    nxgep->dip, prop, mac_cfg_val, mac_cnt);
23783859Sml29623 		ddi_prop_free(mac_cfg_val);
23793859Sml29623 	}
23803859Sml29623 	nxge_set_hw_mac_class_config(nxgep);
23813859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_mac_class_config"));
23823859Sml29623 }
23833859Sml29623 
23843859Sml29623 static void
23853859Sml29623 nxge_use_cfg_class_config(p_nxge_t nxgep)
23863859Sml29623 {
23873859Sml29623 	nxge_set_hw_class_config(nxgep);
23883859Sml29623 }
23893859Sml29623 
23903859Sml29623 static void
23913859Sml29623 nxge_set_rdc_intr_property(p_nxge_t nxgep)
23923859Sml29623 {
23933859Sml29623 	int i;
23943859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
23953859Sml29623 
23963859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_rdc_intr_property"));
23973859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
23983859Sml29623 
23993859Sml29623 	for (i = 0; i < NXGE_MAX_RDCS; i++) {
24003859Sml29623 		p_dma_cfgp->rcr_timeout[i] = nxge_rcr_timeout;
24013859Sml29623 		p_dma_cfgp->rcr_threshold[i] = nxge_rcr_threshold;
24023859Sml29623 	}
24033859Sml29623 
24043859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_rdc_intr_property"));
24053859Sml29623 }
24063859Sml29623 
24073859Sml29623 static void
24083859Sml29623 nxge_set_hw_dma_config(p_nxge_t nxgep)
24093859Sml29623 {
24106495Sspeer 	int i, ndmas, ngrps, bitmap, end, st_rdc;
24113859Sml29623 	int32_t status;
24123859Sml29623 	uint8_t rdcs_per_grp;
24133859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
24143859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
24153859Sml29623 	p_nxge_rdc_grp_t rdc_grp_p;
24163859Sml29623 	int rdcgrp_cfg = CFG_NOT_SPECIFIED, rx_quick_cfg;
24173859Sml29623 	char *prop, *prop_val;
24183859Sml29623 	p_nxge_param_t param_arr;
24193859Sml29623 	config_token_t token;
24206495Sspeer 	nxge_grp_t *group;
24213859Sml29623 
24223859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_set_hw_dma_config"));
24233859Sml29623 
24243859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
24253859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
24263859Sml29623 	rdc_grp_p = p_dma_cfgp->rdc_grps;
24273859Sml29623 
24283859Sml29623 	bitmap = 0;
24296495Sspeer 	end = p_cfgp->tdc.start + p_cfgp->tdc.owned;
24303859Sml29623 	p_dma_cfgp->tx_dma_map = 0;
24316495Sspeer 	for (i = p_cfgp->tdc.start; i < end; i++) {
24323859Sml29623 		bitmap |= (1 << i);
24333859Sml29623 	}
24343859Sml29623 
24356495Sspeer 	nxgep->tx_set.owned.map |= bitmap; /* Owned, & not shared. */
24366495Sspeer 
24376495Sspeer 	group = (nxge_grp_t *)nxge_grp_add(nxgep, NXGE_TRANSMIT_GROUP);
24386495Sspeer 	group->map = bitmap;
24396495Sspeer 
24403859Sml29623 	p_dma_cfgp->tx_dma_map = bitmap;
24413859Sml29623 	param_arr = nxgep->param_arr;
24423859Sml29623 
24433859Sml29623 	/* Assume RDCs are evenly distributed */
24443859Sml29623 	rx_quick_cfg = param_arr[param_rx_quick_cfg].value;
24453859Sml29623 	switch (rx_quick_cfg) {
24463859Sml29623 	case CFG_NOT_SPECIFIED:
24473859Sml29623 		prop = "rxdma-grp-cfg";
24483859Sml29623 		status = ddi_prop_lookup_string(DDI_DEV_T_NONE,
24496929Smisaki 		    nxgep->dip, 0, prop, (char **)&prop_val);
24503859Sml29623 		if (status != DDI_PROP_SUCCESS) {
24513859Sml29623 			NXGE_DEBUG_MSG((nxgep, CFG_CTL,
24526929Smisaki 			    " property %s not found", prop));
24533859Sml29623 			rdcgrp_cfg = CFG_L3_DISTRIBUTE;
24543859Sml29623 		} else {
24553859Sml29623 			token = nxge_get_config_token(prop_val);
24563859Sml29623 			switch (token) {
24573859Sml29623 			case L2_CLASSIFY:
24583859Sml29623 				break;
24593859Sml29623 			case CLASSIFY:
24603859Sml29623 			case L3_CLASSIFY:
24613859Sml29623 			case L3_DISTRIBUTE:
24623859Sml29623 			case L3_TCAM:
24633859Sml29623 				rdcgrp_cfg = CFG_L3_DISTRIBUTE;
24643859Sml29623 				break;
24653859Sml29623 			default:
24663859Sml29623 				rdcgrp_cfg = CFG_L3_DISTRIBUTE;
24673859Sml29623 				break;
24683859Sml29623 			}
24693859Sml29623 			ddi_prop_free(prop_val);
24703859Sml29623 		}
24713859Sml29623 		break;
24723859Sml29623 	case CFG_L3_WEB:
24733859Sml29623 	case CFG_L3_DISTRIBUTE:
24743859Sml29623 	case CFG_L2_CLASSIFY:
24753859Sml29623 	case CFG_L3_TCAM:
24763859Sml29623 		rdcgrp_cfg = rx_quick_cfg;
24773859Sml29623 		break;
24783859Sml29623 	default:
24793859Sml29623 		rdcgrp_cfg = CFG_L3_DISTRIBUTE;
24803859Sml29623 		break;
24813859Sml29623 	}
24823859Sml29623 
24833859Sml29623 	st_rdc = p_cfgp->start_rdc;
24843859Sml29623 
24853859Sml29623 	switch (rdcgrp_cfg) {
24863859Sml29623 	case CFG_L3_DISTRIBUTE:
24873859Sml29623 	case CFG_L3_WEB:
24883859Sml29623 	case CFG_L3_TCAM:
24893859Sml29623 		ndmas = p_cfgp->max_rdcs;
24903859Sml29623 		ngrps = 1;
24913859Sml29623 		rdcs_per_grp = ndmas / ngrps;
24923859Sml29623 		break;
24933859Sml29623 	case CFG_L2_CLASSIFY:
24943859Sml29623 		ndmas = p_cfgp->max_rdcs / 2;
24953859Sml29623 		if (p_cfgp->max_rdcs < 2)
24963859Sml29623 			ndmas = 1;
24973859Sml29623 		ngrps = 1;
24983859Sml29623 		rdcs_per_grp = ndmas / ngrps;
24993859Sml29623 		break;
25003859Sml29623 	default:
25013859Sml29623 		ngrps = p_cfgp->max_rdc_grpids;
25023859Sml29623 		ndmas = p_cfgp->max_rdcs;
25033859Sml29623 		rdcs_per_grp = ndmas / ngrps;
25043859Sml29623 		break;
25053859Sml29623 	}
25063859Sml29623 
25073859Sml29623 	for (i = 0; i < ngrps; i++) {
25086495Sspeer 		uint8_t count = rdcs_per_grp;
25096495Sspeer 		dc_map_t map = 0;
25106495Sspeer 
25116495Sspeer 		rdc_grp_p = &p_dma_cfgp->rdc_grps[
25126929Smisaki 		    p_cfgp->def_mac_rxdma_grpid + i];
25133859Sml29623 		rdc_grp_p->start_rdc = st_rdc + i * rdcs_per_grp;
25143859Sml29623 		rdc_grp_p->max_rdcs = rdcs_per_grp;
25156495Sspeer 		rdc_grp_p->def_rdc = rdc_grp_p->start_rdc;
25163859Sml29623 
25173859Sml29623 		/* default to: 0, 1, 2, 3, ...., 0, 1, 2, 3.... */
25186495Sspeer 		while (count) {
25196495Sspeer 			map |= (1 << count);
25206495Sspeer 			count--;
25216495Sspeer 		}
25226495Sspeer 		map >>= 1;	/* In case <start_rdc> is zero (0) */
25236495Sspeer 		map <<= rdc_grp_p->start_rdc;
25246495Sspeer 		rdc_grp_p->map = map;
25256495Sspeer 
25266495Sspeer 		nxgep->rx_set.owned.map |= map; /* Owned, & not shared. */
25276495Sspeer 
25286495Sspeer 		group = (nxge_grp_t *)nxge_grp_add(nxgep, NXGE_RECEIVE_GROUP);
25296495Sspeer 		group->map = rdc_grp_p->map;
25306495Sspeer 
25313859Sml29623 		rdc_grp_p->config_method = RDC_TABLE_ENTRY_METHOD_SEQ;
25326495Sspeer 		rdc_grp_p->flag = 1; /* This group has been configured. */
25333859Sml29623 	}
25343859Sml29623 
25356495Sspeer 
25363859Sml29623 	/* default RDC */
25373859Sml29623 	p_cfgp->def_rdc = p_cfgp->start_rdc;
25383859Sml29623 	nxgep->def_rdc = p_cfgp->start_rdc;
25393859Sml29623 
25403859Sml29623 	/* full 18 byte header ? */
25413859Sml29623 	p_dma_cfgp->rcr_full_header = NXGE_RCR_FULL_HEADER;
25423859Sml29623 	p_dma_cfgp->rx_drr_weight = PT_DRR_WT_DEFAULT_10G;
25433859Sml29623 	if (nxgep->function_num > 1)
25443859Sml29623 		p_dma_cfgp->rx_drr_weight = PT_DRR_WT_DEFAULT_1G;
25453859Sml29623 	p_dma_cfgp->rbr_size = nxge_rbr_size;
25463859Sml29623 	p_dma_cfgp->rcr_size = nxge_rcr_size;
25473859Sml29623 
25483859Sml29623 	nxge_set_rdc_intr_property(nxgep);
25493859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_hw_dma_config"));
25503859Sml29623 }
25513859Sml29623 
25523859Sml29623 boolean_t
25533859Sml29623 nxge_check_rxdma_port_member(p_nxge_t nxgep, uint8_t rdc)
25543859Sml29623 {
25553859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
25563859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
25573859Sml29623 	int status = B_TRUE;
25583859Sml29623 
25593859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rxdma_port_member"));
25603859Sml29623 
25613859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
25623859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
25633859Sml29623 
25643859Sml29623 	/* Receive DMA Channels */
25653859Sml29623 	if (rdc < p_cfgp->max_rdcs)
25663859Sml29623 		status = B_TRUE;
25673859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rxdma_port_member"));
25683859Sml29623 	return (status);
25693859Sml29623 }
25703859Sml29623 
25713859Sml29623 boolean_t
25723859Sml29623 nxge_check_txdma_port_member(p_nxge_t nxgep, uint8_t tdc)
25733859Sml29623 {
25743859Sml29623 	int status = B_FALSE;
25753859Sml29623 
25766495Sspeer 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_txdma_port_member"));
25776495Sspeer 
25786495Sspeer 	if (tdc >= nxgep->pt_config.hw_config.tdc.start &&
25796495Sspeer 	    tdc < nxgep->pt_config.hw_config.tdc.count)
25803859Sml29623 		status = B_TRUE;
25816495Sspeer 
25826495Sspeer 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_txdma_port_member"));
25833859Sml29623 	return (status);
25843859Sml29623 }
25853859Sml29623 
25863859Sml29623 boolean_t
25873859Sml29623 nxge_check_rxdma_rdcgrp_member(p_nxge_t nxgep, uint8_t rdc_grp, uint8_t rdc)
25883859Sml29623 {
25893859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
25903859Sml29623 	int status = B_TRUE;
25913859Sml29623 	p_nxge_rdc_grp_t rdc_grp_p;
25923859Sml29623 
25933859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL,
25946929Smisaki 	    " ==> nxge_check_rxdma_rdcgrp_member"));
25953859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "  nxge_check_rxdma_rdcgrp_member"
25966929Smisaki 	    " rdc  %d group %d", rdc, rdc_grp));
25973859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
25983859Sml29623 
25993859Sml29623 	rdc_grp_p = &p_dma_cfgp->rdc_grps[rdc_grp];
26003859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "  max  %d ", rdc_grp_p->max_rdcs));
26013859Sml29623 	if (rdc >= rdc_grp_p->max_rdcs) {
26023859Sml29623 		status = B_FALSE;
26033859Sml29623 	}
26043859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL,
26056929Smisaki 	    " <== nxge_check_rxdma_rdcgrp_member"));
26063859Sml29623 	return (status);
26073859Sml29623 }
26083859Sml29623 
26093859Sml29623 boolean_t
26103859Sml29623 nxge_check_rdcgrp_port_member(p_nxge_t nxgep, uint8_t rdc_grp)
26113859Sml29623 {
26123859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
26133859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
26143859Sml29623 	int status = B_TRUE;
26153859Sml29623 
26163859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rdcgrp_port_member"));
26173859Sml29623 
26183859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
26193859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
26203859Sml29623 
26213859Sml29623 	if (rdc_grp >= p_cfgp->max_rdc_grpids)
26223859Sml29623 		status = B_FALSE;
26233859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rdcgrp_port_member"));
26243859Sml29623 	return (status);
26253859Sml29623 }
26263859Sml29623 
26273859Sml29623 static void
26283859Sml29623 nxge_set_hw_vlan_class_config(p_nxge_t nxgep)
26293859Sml29623 {
26303859Sml29623 	int i;
26313859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
26323859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
26333859Sml29623 	p_nxge_param_t param_arr;
26343859Sml29623 	uint_t vlan_cnt;
26353859Sml29623 	int *vlan_cfg_val;
26363859Sml29623 	nxge_param_map_t *vmap;
26373859Sml29623 	char *prop;
26383859Sml29623 	p_nxge_class_pt_cfg_t p_class_cfgp;
26393859Sml29623 	uint32_t good_cfg[32];
26403859Sml29623 	int good_count = 0;
26413859Sml29623 	nxge_mv_cfg_t *vlan_tbl;
26423859Sml29623 
26433859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_hw_vlan_config"));
26443859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
26453859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
26463859Sml29623 	p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
26473859Sml29623 
26483859Sml29623 	param_arr = nxgep->param_arr;
26493859Sml29623 	prop = param_arr[param_vlan_2rdc_grp].fcode_name;
26503859Sml29623 
26513859Sml29623 	/*
26523859Sml29623 	 * By default, VLAN to RDC group mapping is disabled Need to read HW or
26533859Sml29623 	 * .conf properties to find out if mapping is required
26543859Sml29623 	 *
26553859Sml29623 	 * Format
26563859Sml29623 	 *
26573859Sml29623 	 * uint32_t array, each array entry specifying the VLAN id and the
26583859Sml29623 	 * mapping
26593859Sml29623 	 *
26603859Sml29623 	 * bit[30] = add bit[29] = remove bit[28]  = preference bits[23-16] =
26613859Sml29623 	 * rdcgrp bits[15-0] = VLAN ID ( )
26623859Sml29623 	 */
26633859Sml29623 
26643859Sml29623 	for (i = 0; i < NXGE_MAX_VLANS; i++) {
26653859Sml29623 		p_class_cfgp->vlan_tbl[i].flag = 0;
26663859Sml29623 	}
26673859Sml29623 
26683859Sml29623 	vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0];
26693859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop,
26706929Smisaki 	    &vlan_cfg_val, &vlan_cnt) == DDI_PROP_SUCCESS) {
26713859Sml29623 		for (i = 0; i < vlan_cnt; i++) {
26723859Sml29623 			vmap = (nxge_param_map_t *)&vlan_cfg_val[i];
26733859Sml29623 			if ((vmap->param_id) &&
26746929Smisaki 			    (vmap->param_id < NXGE_MAX_VLANS) &&
26756929Smisaki 			    (vmap->map_to <
26766929Smisaki 			    p_cfgp->max_rdc_grpids) &&
26776929Smisaki 			    (vmap->map_to >= (uint8_t)0)) {
26783859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG2_CTL,
26796929Smisaki 				    " nxge_vlan_config mapping"
26806929Smisaki 				    " id %d grp %d",
26816929Smisaki 				    vmap->param_id, vmap->map_to));
26823859Sml29623 				good_cfg[good_count] = vlan_cfg_val[i];
26833859Sml29623 				if (vlan_tbl[vmap->param_id].flag == 0)
26843859Sml29623 					good_count++;
26853859Sml29623 				vlan_tbl[vmap->param_id].flag = 1;
26863859Sml29623 				vlan_tbl[vmap->param_id].rdctbl =
26876495Sspeer 				    vmap->map_to + p_cfgp->def_mac_rxdma_grpid;
26883859Sml29623 				vlan_tbl[vmap->param_id].mpr_npr = vmap->pref;
26893859Sml29623 			}
26903859Sml29623 		}
26913859Sml29623 		ddi_prop_free(vlan_cfg_val);
26923859Sml29623 		if (good_count != vlan_cnt) {
26933859Sml29623 			(void) ddi_prop_update_int_array(DDI_DEV_T_NONE,
26946929Smisaki 			    nxgep->dip, prop, (int *)good_cfg, good_count);
26953859Sml29623 		}
26963859Sml29623 	}
26973859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_set_hw_vlan_config"));
26983859Sml29623 }
26993859Sml29623 
27003859Sml29623 static void
27013859Sml29623 nxge_set_hw_mac_class_config(p_nxge_t nxgep)
27023859Sml29623 {
27033859Sml29623 	int i;
27043859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
27053859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
27063859Sml29623 	p_nxge_param_t param_arr;
27073859Sml29623 	uint_t mac_cnt;
27083859Sml29623 	int *mac_cfg_val;
27093859Sml29623 	nxge_param_map_t *mac_map;
27103859Sml29623 	char *prop;
27113859Sml29623 	p_nxge_class_pt_cfg_t p_class_cfgp;
27123859Sml29623 	int good_count = 0;
27133859Sml29623 	int good_cfg[NXGE_MAX_MACS];
27143859Sml29623 	nxge_mv_cfg_t *mac_host_info;
27153859Sml29623 
27163859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_set_hw_mac_config"));
27173859Sml29623 
27183859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
27193859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
27203859Sml29623 	p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
27213859Sml29623 	mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0];
27223859Sml29623 
27233859Sml29623 	param_arr = nxgep->param_arr;
27243859Sml29623 	prop = param_arr[param_mac_2rdc_grp].fcode_name;
27253859Sml29623 
27263859Sml29623 	for (i = 0; i < NXGE_MAX_MACS; i++) {
27273859Sml29623 		p_class_cfgp->mac_host_info[i].flag = 0;
27284484Sspeer 		p_class_cfgp->mac_host_info[i].rdctbl =
27294484Sspeer 		    p_cfgp->def_mac_rxdma_grpid;
27303859Sml29623 	}
27313859Sml29623 
27323859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop,
27336929Smisaki 	    &mac_cfg_val, &mac_cnt) == DDI_PROP_SUCCESS) {
27343859Sml29623 		for (i = 0; i < mac_cnt; i++) {
27353859Sml29623 			mac_map = (nxge_param_map_t *)&mac_cfg_val[i];
27363859Sml29623 			if ((mac_map->param_id < p_cfgp->max_macs) &&
27376929Smisaki 			    (mac_map->map_to <
27386929Smisaki 			    p_cfgp->max_rdc_grpids) &&
27396929Smisaki 			    (mac_map->map_to >= (uint8_t)0)) {
27403859Sml29623 				NXGE_DEBUG_MSG((nxgep, CFG2_CTL,
27416929Smisaki 				    " nxge_mac_config mapping"
27426929Smisaki 				    " id %d grp %d",
27436929Smisaki 				    mac_map->param_id, mac_map->map_to));
27443859Sml29623 				mac_host_info[mac_map->param_id].mpr_npr =
27456929Smisaki 				    mac_map->pref;
27463859Sml29623 				mac_host_info[mac_map->param_id].rdctbl =
27476929Smisaki 				    mac_map->map_to +
27486929Smisaki 				    p_cfgp->def_mac_rxdma_grpid;
27493859Sml29623 				good_cfg[good_count] = mac_cfg_val[i];
27503859Sml29623 				if (mac_host_info[mac_map->param_id].flag == 0)
27513859Sml29623 					good_count++;
27523859Sml29623 				mac_host_info[mac_map->param_id].flag = 1;
27533859Sml29623 			}
27543859Sml29623 		}
27553859Sml29623 		ddi_prop_free(mac_cfg_val);
27563859Sml29623 		if (good_count != mac_cnt) {
27573859Sml29623 			(void) ddi_prop_update_int_array(DDI_DEV_T_NONE,
27586929Smisaki 			    nxgep->dip, prop, good_cfg, good_count);
27593859Sml29623 		}
27603859Sml29623 	}
27613859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_set_hw_mac_config"));
27623859Sml29623 }
27633859Sml29623 
27643859Sml29623 static void
27653859Sml29623 nxge_set_hw_class_config(p_nxge_t nxgep)
27663859Sml29623 {
27673859Sml29623 	int i;
27683859Sml29623 	p_nxge_param_t param_arr;
27693859Sml29623 	int *int_prop_val;
27703859Sml29623 	uint32_t cfg_value;
27713859Sml29623 	char *prop;
27723859Sml29623 	p_nxge_class_pt_cfg_t p_class_cfgp;
27733859Sml29623 	int start_prop, end_prop;
27743859Sml29623 	uint_t prop_cnt;
27753859Sml29623 
27763859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_hw_class_config"));
27773859Sml29623 
27783859Sml29623 	p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
27793859Sml29623 	param_arr = nxgep->param_arr;
27803859Sml29623 	start_prop = param_class_opt_ip_usr4;
27813859Sml29623 	end_prop = param_class_opt_ipv6_sctp;
27823859Sml29623 
27833859Sml29623 	for (i = start_prop; i <= end_prop; i++) {
27843859Sml29623 		prop = param_arr[i].fcode_name;
27853859Sml29623 		if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip,
27866929Smisaki 		    0, prop, &int_prop_val,
27876929Smisaki 		    &prop_cnt) == DDI_PROP_SUCCESS) {
27883859Sml29623 			cfg_value = (uint32_t)*int_prop_val;
27893859Sml29623 			ddi_prop_free(int_prop_val);
27903859Sml29623 		} else {
27913859Sml29623 			cfg_value = (uint32_t)param_arr[i].value;
27923859Sml29623 		}
27933859Sml29623 		p_class_cfgp->class_cfg[i - start_prop] = cfg_value;
27943859Sml29623 	}
27953859Sml29623 
27963859Sml29623 	prop = param_arr[param_h1_init_value].fcode_name;
27973859Sml29623 
27983859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop,
27996929Smisaki 	    &int_prop_val, &prop_cnt) == DDI_PROP_SUCCESS) {
28003859Sml29623 		cfg_value = (uint32_t)*int_prop_val;
28013859Sml29623 		ddi_prop_free(int_prop_val);
28023859Sml29623 	} else {
28033859Sml29623 		cfg_value = (uint32_t)param_arr[param_h1_init_value].value;
28043859Sml29623 	}
28053859Sml29623 
28063859Sml29623 	p_class_cfgp->init_h1 = (uint32_t)cfg_value;
28073859Sml29623 	prop = param_arr[param_h2_init_value].fcode_name;
28083859Sml29623 
28093859Sml29623 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop,
28106929Smisaki 	    &int_prop_val, &prop_cnt) == DDI_PROP_SUCCESS) {
28113859Sml29623 		cfg_value = (uint32_t)*int_prop_val;
28123859Sml29623 		ddi_prop_free(int_prop_val);
28133859Sml29623 	} else {
28143859Sml29623 		cfg_value = (uint32_t)param_arr[param_h2_init_value].value;
28153859Sml29623 	}
28163859Sml29623 
28173859Sml29623 	p_class_cfgp->init_h2 = (uint16_t)cfg_value;
28183859Sml29623 	NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_hw_class_config"));
28193859Sml29623 }
28203859Sml29623 
28213859Sml29623 nxge_status_t
28223859Sml29623 nxge_ldgv_init_n2(p_nxge_t nxgep, int *navail_p, int *nrequired_p)
28233859Sml29623 {
28246495Sspeer 	int i, maxldvs, maxldgs, nldvs;
28253859Sml29623 	int ldv, endldg;
28263859Sml29623 	uint8_t func;
28273859Sml29623 	uint8_t channel;
28283859Sml29623 	uint8_t chn_start;
28293859Sml29623 	boolean_t own_sys_err = B_FALSE, own_fzc = B_FALSE;
28303859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
28313859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
28323859Sml29623 	p_nxge_ldgv_t ldgvp;
28333859Sml29623 	p_nxge_ldg_t ldgp, ptr;
2834*7466SMisaki.Kataoka@Sun.COM 	p_nxge_ldv_t ldvp, sysldvp;
28353859Sml29623 	nxge_status_t status = NXGE_OK;
28366495Sspeer 	nxge_grp_set_t *set;
28373859Sml29623 
28383859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2"));
28393859Sml29623 	if (!*navail_p) {
28403859Sml29623 		*nrequired_p = 0;
28413859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
28426929Smisaki 		    "<== nxge_ldgv_init:no avail"));
28433859Sml29623 		return (NXGE_ERROR);
28443859Sml29623 	}
28453859Sml29623 	/*
28463859Sml29623 	 * N2/NIU: one logical device owns one logical group. and each
28473859Sml29623 	 * device/group will be assigned one vector by Hypervisor.
28483859Sml29623 	 */
28493859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
28503859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
28513859Sml29623 	maxldgs = p_cfgp->max_ldgs;
28523859Sml29623 	if (!maxldgs) {
28533859Sml29623 		/* No devices configured. */
28543859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_init_n2: "
28556929Smisaki 		    "no logical groups configured."));
28563859Sml29623 		return (NXGE_ERROR);
28573859Sml29623 	} else {
28583859Sml29623 		maxldvs = maxldgs + 1;
28593859Sml29623 	}
28603859Sml29623 
28613859Sml29623 	/*
28623859Sml29623 	 * If function zero instance, it needs to handle the system and MIF
28633859Sml29623 	 * error interrupts. MIF interrupt may not be needed for N2/NIU.
28643859Sml29623 	 */
28653859Sml29623 	func = nxgep->function_num;
28663859Sml29623 	if (func == 0) {
28673859Sml29623 		own_sys_err = B_TRUE;
28683859Sml29623 		if (!p_cfgp->ser_ldvid) {
28693859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
28706929Smisaki 			    "nxge_ldgv_init_n2: func 0, ERR ID not set!"));
28713859Sml29623 		}
28723859Sml29623 		/* MIF interrupt */
28733859Sml29623 		if (!p_cfgp->mif_ldvid) {
28743859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
28756929Smisaki 			    "nxge_ldgv_init_n2: func 0, MIF ID not set!"));
28763859Sml29623 		}
28773859Sml29623 	}
28783859Sml29623 
28793859Sml29623 	/*
28803859Sml29623 	 * Assume single partition, each function owns mac.
28813859Sml29623 	 */
28823859Sml29623 	if (!nxge_use_partition)
28833859Sml29623 		own_fzc = B_TRUE;
28843859Sml29623 
28853859Sml29623 	ldgvp = nxgep->ldgvp;
28863859Sml29623 	if (ldgvp == NULL) {
28873859Sml29623 		ldgvp = KMEM_ZALLOC(sizeof (nxge_ldgv_t), KM_SLEEP);
28883859Sml29623 		nxgep->ldgvp = ldgvp;
28893859Sml29623 		ldgvp->maxldgs = (uint8_t)maxldgs;
28903859Sml29623 		ldgvp->maxldvs = (uint8_t)maxldvs;
28916495Sspeer 		ldgp = ldgvp->ldgp = KMEM_ZALLOC(
28926929Smisaki 		    sizeof (nxge_ldg_t) * maxldgs, KM_SLEEP);
28936495Sspeer 		ldvp = ldgvp->ldvp = KMEM_ZALLOC(
28946929Smisaki 		    sizeof (nxge_ldv_t) * maxldvs, KM_SLEEP);
28953859Sml29623 	} else {
28963859Sml29623 		ldgp = ldgvp->ldgp;
28973859Sml29623 		ldvp = ldgvp->ldvp;
28983859Sml29623 	}
28993859Sml29623 
29006495Sspeer 	ldgvp->ndma_ldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs;
29013859Sml29623 	ldgvp->tmres = NXGE_TIMER_RESO;
29023859Sml29623 
29033859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL,
29046929Smisaki 	    "==> nxge_ldgv_init_n2: maxldvs %d maxldgs %d",
29056929Smisaki 	    maxldvs, maxldgs));
29063859Sml29623 
29073859Sml29623 	/* logical start_ldg is ldv */
29083859Sml29623 	ptr = ldgp;
29093859Sml29623 	for (i = 0; i < maxldgs; i++) {
29103859Sml29623 		ptr->func = func;
29113859Sml29623 		ptr->arm = B_TRUE;
29123859Sml29623 		ptr->vldg_index = (uint8_t)i;
29133859Sml29623 		ptr->ldg_timer = NXGE_TIMER_LDG;
29143859Sml29623 		ptr->ldg = p_cfgp->ldg[i];
29153859Sml29623 		ptr->sys_intr_handler = nxge_intr;
29163859Sml29623 		ptr->nldvs = 0;
29173859Sml29623 		ptr->ldvp = NULL;
29183859Sml29623 		ptr->nxgep = nxgep;
29193859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
29206929Smisaki 		    "==> nxge_ldgv_init_n2: maxldvs %d maxldgs %d "
29216929Smisaki 		    "ldg %d ldgptr $%p",
29226929Smisaki 		    maxldvs, maxldgs, ptr->ldg, ptr));
29233859Sml29623 		ptr++;
29243859Sml29623 	}
29253859Sml29623 
29263859Sml29623 	endldg = NXGE_INT_MAX_LDG;
29273859Sml29623 	nldvs = 0;
29283859Sml29623 	ldgvp->nldvs = 0;
29293859Sml29623 	ldgp->ldvp = NULL;
29303859Sml29623 	*nrequired_p = 0;
29313859Sml29623 
29323859Sml29623 	/*
29333859Sml29623 	 * logical device group table is organized in the following order (same
29343859Sml29623 	 * as what interrupt property has). function 0: owns MAC, MIF, error,
29353859Sml29623 	 * rx, tx. function 1: owns MAC, rx, tx.
29363859Sml29623 	 */
29373859Sml29623 
29383859Sml29623 	if (own_fzc && p_cfgp->mac_ldvid) {
29393859Sml29623 		/* Each function should own MAC interrupt */
29403859Sml29623 		ldv = p_cfgp->mac_ldvid;
29413859Sml29623 		ldvp->ldv = (uint8_t)ldv;
29423859Sml29623 		ldvp->is_mac = B_TRUE;
29433859Sml29623 		ldvp->ldv_intr_handler = nxge_mac_intr;
29443859Sml29623 		ldvp->ldv_ldf_masks = 0;
29453859Sml29623 		ldvp->nxgep = nxgep;
29463859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
29476929Smisaki 		    "==> nxge_ldgv_init_n2(mac): maxldvs %d ldv %d "
29486929Smisaki 		    "ldg %d ldgptr $%p ldvptr $%p",
29496929Smisaki 		    maxldvs, ldv, ldgp->ldg, ldgp, ldvp));
29503859Sml29623 		nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p);
29513859Sml29623 		nldvs++;
29523859Sml29623 	}
29533859Sml29623 
29543859Sml29623 	if (own_fzc && p_cfgp->mif_ldvid) {
29553859Sml29623 		ldv = p_cfgp->mif_ldvid;
29563859Sml29623 		ldvp->ldv = (uint8_t)ldv;
29573859Sml29623 		ldvp->is_mif = B_TRUE;
29583859Sml29623 		ldvp->ldv_intr_handler = nxge_mif_intr;
29593859Sml29623 		ldvp->ldv_ldf_masks = 0;
29603859Sml29623 		ldvp->nxgep = nxgep;
29613859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
29626929Smisaki 		    "==> nxge_ldgv_init_n2(mif): maxldvs %d ldv %d "
29636929Smisaki 		    "ldg %d ldgptr $%p ldvptr $%p",
29646929Smisaki 		    maxldvs, ldv, ldgp->ldg, ldgp, ldvp));
29653859Sml29623 		nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p);
29663859Sml29623 		nldvs++;
29673859Sml29623 	}
29683859Sml29623 
2969*7466SMisaki.Kataoka@Sun.COM 	/*
2970*7466SMisaki.Kataoka@Sun.COM 	 * Port0 uses the HW based syserr interrupt, and port1 uses the
2971*7466SMisaki.Kataoka@Sun.COM 	 * SW based syserr interrupt. There is only one syserr and the
2972*7466SMisaki.Kataoka@Sun.COM 	 * function zero device gets it.
2973*7466SMisaki.Kataoka@Sun.COM 	 */
29743859Sml29623 	if (own_sys_err && p_cfgp->ser_ldvid) {
29753859Sml29623 		ldv = p_cfgp->ser_ldvid;
29763859Sml29623 		/*
2977*7466SMisaki.Kataoka@Sun.COM 		 * Port0 - HW based: use an intr vector
2978*7466SMisaki.Kataoka@Sun.COM 		 */
2979*7466SMisaki.Kataoka@Sun.COM 		/*
29803859Sml29623 		 * Unmask the system interrupt states.
29813859Sml29623 		 */
29823859Sml29623 		(void) nxge_fzc_sys_err_mask_set(nxgep, SYS_ERR_SMX_MASK |
29836929Smisaki 		    SYS_ERR_IPP_MASK | SYS_ERR_TXC_MASK |
29846929Smisaki 		    SYS_ERR_ZCP_MASK);
2985*7466SMisaki.Kataoka@Sun.COM 
2986*7466SMisaki.Kataoka@Sun.COM 		ldvp->use_timer = B_TRUE;
2987*7466SMisaki.Kataoka@Sun.COM 		ldvp->ldv = (uint8_t)ldv;
2988*7466SMisaki.Kataoka@Sun.COM 		ldvp->is_syserr = B_TRUE;
2989*7466SMisaki.Kataoka@Sun.COM 		ldvp->ldv_intr_handler = nxge_syserr_intr;
2990*7466SMisaki.Kataoka@Sun.COM 		ldvp->ldv_ldf_masks = 0;
2991*7466SMisaki.Kataoka@Sun.COM 		ldvp->nxgep = nxgep;
2992*7466SMisaki.Kataoka@Sun.COM 		ldgvp->ldvp_syserr = ldvp;
2993*7466SMisaki.Kataoka@Sun.COM 
2994*7466SMisaki.Kataoka@Sun.COM 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
2995*7466SMisaki.Kataoka@Sun.COM 		    "==> nxge_ldgv_init_n2(syserr): maxldvs %d ldv %d "
2996*7466SMisaki.Kataoka@Sun.COM 		    "ldg %d ldgptr $%p ldvptr p%p",
2997*7466SMisaki.Kataoka@Sun.COM 		    maxldvs, ldv, ldgp->ldg, ldgp, ldvp));
2998*7466SMisaki.Kataoka@Sun.COM 		nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p);
2999*7466SMisaki.Kataoka@Sun.COM 		nldvs++;
3000*7466SMisaki.Kataoka@Sun.COM 	} else {
3001*7466SMisaki.Kataoka@Sun.COM 		/*
3002*7466SMisaki.Kataoka@Sun.COM 		 * Port1 - SW based: allocate the ldv for the syserr since
3003*7466SMisaki.Kataoka@Sun.COM 		 * the vector should not be consumed for port1
3004*7466SMisaki.Kataoka@Sun.COM 		 */
3005*7466SMisaki.Kataoka@Sun.COM 		sysldvp = KMEM_ZALLOC(sizeof (nxge_ldv_t), KM_SLEEP);
3006*7466SMisaki.Kataoka@Sun.COM 		sysldvp->use_timer = B_TRUE;
3007*7466SMisaki.Kataoka@Sun.COM 		sysldvp->ldv = NXGE_SYS_ERROR_LD;
3008*7466SMisaki.Kataoka@Sun.COM 		sysldvp->is_syserr = B_TRUE;
3009*7466SMisaki.Kataoka@Sun.COM 		sysldvp->ldv_intr_handler = nxge_syserr_intr;
3010*7466SMisaki.Kataoka@Sun.COM 		sysldvp->ldv_ldf_masks = 0;
3011*7466SMisaki.Kataoka@Sun.COM 		sysldvp->nxgep = nxgep;
3012*7466SMisaki.Kataoka@Sun.COM 		ldgvp->ldvp_syserr = sysldvp;
3013*7466SMisaki.Kataoka@Sun.COM 		ldgvp->ldvp_syserr_allocated = B_TRUE;
30143859Sml29623 	}
30153859Sml29623 
30163859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: "
30176929Smisaki 	    "(before rx) func %d nldvs %d navail %d nrequired %d",
30186929Smisaki 	    func, nldvs, *navail_p, *nrequired_p));
30193859Sml29623 
30203859Sml29623 	/*
30213859Sml29623 	 * Start with RDC to configure logical devices for each group.
30223859Sml29623 	 */
30236495Sspeer 	chn_start = p_cfgp->ldg_chn_start;
30246495Sspeer 	set = &nxgep->rx_set;
30256495Sspeer 	for (channel = 0; channel < NXGE_MAX_RDCS; channel++) {
30266495Sspeer 		if ((1 << channel) & set->owned.map) {
30276495Sspeer 			ldvp->is_rxdma = B_TRUE;
30286495Sspeer 			ldvp->ldv = (uint8_t)channel + NXGE_RDMA_LD_START;
30296495Sspeer 			ldvp->channel = channel;
30306495Sspeer 			ldvp->vdma_index = (uint8_t)channel;
30316495Sspeer 			ldvp->ldv_intr_handler = nxge_rx_intr;
30326495Sspeer 			ldvp->ldv_ldf_masks = 0;
30336495Sspeer 			ldvp->nxgep = nxgep;
30346495Sspeer 			ldgp->ldg = p_cfgp->ldg[chn_start];
30356495Sspeer 
30366495Sspeer 			NXGE_DEBUG_MSG((nxgep, INT_CTL,
30376495Sspeer 			    "==> nxge_ldgv_init_n2(rx%d): maxldvs %d ldv %d "
30386495Sspeer 			    "ldg %d ldgptr 0x%016llx ldvptr 0x%016llx",
30396495Sspeer 			    i, maxldvs, ldv, ldgp->ldg, ldgp, ldvp));
30406495Sspeer 			nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv,
30416495Sspeer 			    endldg, nrequired_p);
30426495Sspeer 			nldvs++;
30436495Sspeer 			chn_start++;
30446495Sspeer 		}
30453859Sml29623 	}
30463859Sml29623 
30473859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: "
30486929Smisaki 	    "func %d nldvs %d navail %d nrequired %d",
30496929Smisaki 	    func, nldvs, *navail_p, *nrequired_p));
30503859Sml29623 
30513859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: "
30526929Smisaki 	    "func %d nldvs %d navail %d nrequired %d ldgp 0x%llx "
30536929Smisaki 	    "ldvp 0x%llx",
30546929Smisaki 	    func, nldvs, *navail_p, *nrequired_p, ldgp, ldvp));
30553859Sml29623 	/*
30563859Sml29623 	 * Transmit DMA channels.
30573859Sml29623 	 */
30586495Sspeer 	chn_start = p_cfgp->ldg_chn_start + 8;
30596495Sspeer 	set = &nxgep->tx_set;
30606495Sspeer 	for (channel = 0; channel < NXGE_MAX_TDCS; channel++) {
30616495Sspeer 		if ((1 << channel) & set->owned.map) {
30626495Sspeer 			ldvp->is_txdma = B_TRUE;
30636495Sspeer 			ldvp->ldv = (uint8_t)channel + NXGE_TDMA_LD_START;
30646495Sspeer 			ldvp->channel = channel;
30656495Sspeer 			ldvp->vdma_index = (uint8_t)channel;
30666495Sspeer 			ldvp->ldv_intr_handler = nxge_tx_intr;
30676495Sspeer 			ldvp->ldv_ldf_masks = 0;
30686495Sspeer 			ldgp->ldg = p_cfgp->ldg[chn_start];
30696495Sspeer 			ldvp->nxgep = nxgep;
30706495Sspeer 			NXGE_DEBUG_MSG((nxgep, INT_CTL,
30716495Sspeer 			    "==> nxge_ldgv_init_n2(tx%d): maxldvs %d ldv %d "
30726495Sspeer 			    "ldg %d ldgptr %p ldvptr %p",
30736495Sspeer 			    channel, maxldvs, ldv, ldgp->ldg, ldgp, ldvp));
30746495Sspeer 			nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv,
30756495Sspeer 			    endldg, nrequired_p);
30766495Sspeer 			nldvs++;
30776495Sspeer 			chn_start++;
30786495Sspeer 		}
30793859Sml29623 	}
30803859Sml29623 
30813859Sml29623 	ldgvp->ldg_intrs = *nrequired_p;
30823859Sml29623 	ldgvp->nldvs = (uint8_t)nldvs;
30833859Sml29623 
30843859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: "
30856929Smisaki 	    "func %d nldvs %d maxgrps %d navail %d nrequired %d",
30866929Smisaki 	    func, nldvs, maxldgs, *navail_p, *nrequired_p));
30873859Sml29623 
30883859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_init_n2"));
30893859Sml29623 	return (status);
30903859Sml29623 }
30913859Sml29623 
30923859Sml29623 /*
30933859Sml29623  * Interrupts related interface functions.
30943859Sml29623  */
30953859Sml29623 
30963859Sml29623 nxge_status_t
30973859Sml29623 nxge_ldgv_init(p_nxge_t nxgep, int *navail_p, int *nrequired_p)
30983859Sml29623 {
30996495Sspeer 	int i, maxldvs, maxldgs, nldvs;
31003859Sml29623 	int ldv, ldg, endldg, ngrps;
31013859Sml29623 	uint8_t func;
31023859Sml29623 	uint8_t channel;
31033859Sml29623 	boolean_t own_sys_err = B_FALSE, own_fzc = B_FALSE;
31043859Sml29623 	p_nxge_dma_pt_cfg_t p_dma_cfgp;
31053859Sml29623 	p_nxge_hw_pt_cfg_t p_cfgp;
31063859Sml29623 	p_nxge_ldgv_t ldgvp;
31073859Sml29623 	p_nxge_ldg_t ldgp, ptr;
31083859Sml29623 	p_nxge_ldv_t ldvp;
31096495Sspeer 	nxge_grp_set_t *set;
31106495Sspeer 
31113859Sml29623 	nxge_status_t status = NXGE_OK;
31123859Sml29623 
31133859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init"));
31143859Sml29623 	if (!*navail_p) {
31153859Sml29623 		*nrequired_p = 0;
31163859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
31176929Smisaki 		    "<== nxge_ldgv_init:no avail"));
31183859Sml29623 		return (NXGE_ERROR);
31193859Sml29623 	}
31203859Sml29623 	p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
31213859Sml29623 	p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
31223859Sml29623 
31236495Sspeer 	nldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs;
31243859Sml29623 
31253859Sml29623 	/*
31263859Sml29623 	 * If function zero instance, it needs to handle the system error
31273859Sml29623 	 * interrupts.
31283859Sml29623 	 */
31293859Sml29623 	func = nxgep->function_num;
31303859Sml29623 	if (func == 0) {
31313859Sml29623 		nldvs++;
31323859Sml29623 		own_sys_err = B_TRUE;
31333859Sml29623 	} else {
31343859Sml29623 		/* use timer */
31353859Sml29623 		nldvs++;
31363859Sml29623 	}
31373859Sml29623 
31383859Sml29623 	/*
31393859Sml29623 	 * Assume single partition, each function owns mac.
31403859Sml29623 	 */
31413859Sml29623 	if (!nxge_use_partition) {
31423859Sml29623 		/* mac */
31433859Sml29623 		nldvs++;
31443859Sml29623 		/* MIF */
31453859Sml29623 		nldvs++;
31463859Sml29623 		own_fzc = B_TRUE;
31473859Sml29623 	}
31483859Sml29623 	maxldvs = nldvs;
31493859Sml29623 	maxldgs = p_cfgp->max_ldgs;
31503859Sml29623 	if (!maxldvs || !maxldgs) {
31513859Sml29623 		/* No devices configured. */
31523859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_init: "
31536929Smisaki 		    "no logical devices or groups configured."));
31543859Sml29623 		return (NXGE_ERROR);
31553859Sml29623 	}
31563859Sml29623 	ldgvp = nxgep->ldgvp;
31573859Sml29623 	if (ldgvp == NULL) {
31583859Sml29623 		ldgvp = KMEM_ZALLOC(sizeof (nxge_ldgv_t), KM_SLEEP);
31593859Sml29623 		nxgep->ldgvp = ldgvp;
31603859Sml29623 		ldgvp->maxldgs = (uint8_t)maxldgs;
31613859Sml29623 		ldgvp->maxldvs = (uint8_t)maxldvs;
31623859Sml29623 		ldgp = ldgvp->ldgp = KMEM_ZALLOC(sizeof (nxge_ldg_t) * maxldgs,
31636929Smisaki 		    KM_SLEEP);
31643859Sml29623 		ldvp = ldgvp->ldvp = KMEM_ZALLOC(sizeof (nxge_ldv_t) * maxldvs,
31656929Smisaki 		    KM_SLEEP);
31663859Sml29623 	}
31676495Sspeer 	ldgvp->ndma_ldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs;
31683859Sml29623 	ldgvp->tmres = NXGE_TIMER_RESO;
31693859Sml29623 
31703859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL,
31716929Smisaki 	    "==> nxge_ldgv_init: maxldvs %d maxldgs %d nldvs %d",
31726929Smisaki 	    maxldvs, maxldgs, nldvs));
31733859Sml29623 	ldg = p_cfgp->start_ldg;
31743859Sml29623 	ptr = ldgp;
31753859Sml29623 	for (i = 0; i < maxldgs; i++) {
31763859Sml29623 		ptr->func = func;
31773859Sml29623 		ptr->arm = B_TRUE;
31783859Sml29623 		ptr->vldg_index = (uint8_t)i;
31793859Sml29623 		ptr->ldg_timer = NXGE_TIMER_LDG;
31803859Sml29623 		ptr->ldg = ldg++;
31813859Sml29623 		ptr->sys_intr_handler = nxge_intr;
31823859Sml29623 		ptr->nldvs = 0;
31833859Sml29623 		ptr->nxgep = nxgep;
31843859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
31856929Smisaki 		    "==> nxge_ldgv_init: maxldvs %d maxldgs %d ldg %d",
31866929Smisaki 		    maxldvs, maxldgs, ptr->ldg));
31873859Sml29623 		ptr++;
31883859Sml29623 	}
31893859Sml29623 
31903859Sml29623 	ldg = p_cfgp->start_ldg;
31913859Sml29623 	if (maxldgs > *navail_p) {
31923859Sml29623 		ngrps = *navail_p;
31933859Sml29623 	} else {
31943859Sml29623 		ngrps = maxldgs;
31953859Sml29623 	}
31963859Sml29623 	endldg = ldg + ngrps;
31973859Sml29623 
31983859Sml29623 	/*
31993859Sml29623 	 * Receive DMA channels.
32003859Sml29623 	 */
32013859Sml29623 	nldvs = 0;
32023859Sml29623 	ldgvp->nldvs = 0;
32033859Sml29623 	ldgp->ldvp = NULL;
32043859Sml29623 	*nrequired_p = 0;
32053859Sml29623 
32063859Sml29623 	/*
32073859Sml29623 	 * Start with RDC to configure logical devices for each group.
32083859Sml29623 	 */
32096495Sspeer 	set = &nxgep->rx_set;
32106495Sspeer 	for (channel = 0; channel < NXGE_MAX_RDCS; channel++) {
32116495Sspeer 		if ((1 << channel) & set->owned.map) {
32126495Sspeer 			/* For now, <channel & <vdma_index> are the same. */
32136495Sspeer 			ldvp->is_rxdma = B_TRUE;
32146495Sspeer 			ldvp->ldv = (uint8_t)channel + NXGE_RDMA_LD_START;
32156495Sspeer 			ldvp->channel = channel;
32166495Sspeer 			ldvp->vdma_index = (uint8_t)channel;
32176495Sspeer 			ldvp->ldv_intr_handler = nxge_rx_intr;
32186495Sspeer 			ldvp->ldv_ldf_masks = 0;
32196495Sspeer 			ldvp->use_timer = B_FALSE;
32206495Sspeer 			ldvp->nxgep = nxgep;
32216495Sspeer 			nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv,
32226495Sspeer 			    endldg, nrequired_p);
32236495Sspeer 			nldvs++;
32246495Sspeer 		}
32253859Sml29623 	}
32263859Sml29623 
32273859Sml29623 	/*
32283859Sml29623 	 * Transmit DMA channels.
32293859Sml29623 	 */
32306495Sspeer 	set = &nxgep->tx_set;
32316495Sspeer 	for (channel = 0; channel < NXGE_MAX_TDCS; channel++) {
32326495Sspeer 		if ((1 << channel) & set->owned.map) {
32336495Sspeer 			/* For now, <channel & <vdma_index> are the same. */
32346495Sspeer 			ldvp->is_txdma = B_TRUE;
32356495Sspeer 			ldvp->ldv = (uint8_t)channel + NXGE_TDMA_LD_START;
32366495Sspeer 			ldvp->channel = channel;
32376495Sspeer 			ldvp->vdma_index = (uint8_t)channel;
32386495Sspeer 			ldvp->ldv_intr_handler = nxge_tx_intr;
32396495Sspeer 			ldvp->ldv_ldf_masks = 0;
32406495Sspeer 			ldvp->use_timer = B_FALSE;
32416495Sspeer 			ldvp->nxgep = nxgep;
32426495Sspeer 			nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv,
32436495Sspeer 			    endldg, nrequired_p);
32446495Sspeer 			nldvs++;
32456495Sspeer 		}
32463859Sml29623 	}
32473859Sml29623 
32483859Sml29623 	if (own_fzc) {
32493859Sml29623 		ldv = NXGE_MIF_LD;
32503859Sml29623 		ldvp->ldv = (uint8_t)ldv;
32513859Sml29623 		ldvp->is_mif = B_TRUE;
32523859Sml29623 		ldvp->ldv_intr_handler = nxge_mif_intr;
32533859Sml29623 		ldvp->ldv_ldf_masks = 0;
32543859Sml29623 		ldvp->use_timer = B_FALSE;
32553859Sml29623 		ldvp->nxgep = nxgep;
32563859Sml29623 		nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p);
32573859Sml29623 		nldvs++;
32583859Sml29623 	}
32593859Sml29623 	/*
32603859Sml29623 	 * MAC port (function zero control)
32613859Sml29623 	 */
32623859Sml29623 	if (own_fzc) {
32633859Sml29623 		ldvp->is_mac = B_TRUE;
32643859Sml29623 		ldvp->ldv_intr_handler = nxge_mac_intr;
32653859Sml29623 		ldvp->ldv_ldf_masks = 0;
32663859Sml29623 		ldv = func + NXGE_MAC_LD_START;
32673859Sml29623 		ldvp->ldv = (uint8_t)ldv;
32683859Sml29623 		ldvp->use_timer = B_FALSE;
32693859Sml29623 		ldvp->nxgep = nxgep;
32703859Sml29623 		nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p);
32713859Sml29623 		nldvs++;
32723859Sml29623 	}
32733859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init: "
32746929Smisaki 	    "func %d nldvs %d navail %d nrequired %d",
32756929Smisaki 	    func, nldvs, *navail_p, *nrequired_p));
32763859Sml29623 	/*
32773859Sml29623 	 * Function 0 owns system error interrupts.
32783859Sml29623 	 */
32793859Sml29623 	ldvp->use_timer = B_TRUE;
32803859Sml29623 	if (own_sys_err) {
32813859Sml29623 		ldv = NXGE_SYS_ERROR_LD;
32823859Sml29623 		ldvp->ldv = (uint8_t)ldv;
32833859Sml29623 		ldvp->is_syserr = B_TRUE;
32843859Sml29623 		ldvp->ldv_intr_handler = nxge_syserr_intr;
32853859Sml29623 		ldvp->ldv_ldf_masks = 0;
32863859Sml29623 		ldvp->nxgep = nxgep;
32873859Sml29623 		ldgvp->ldvp_syserr = ldvp;
32883859Sml29623 		/*
32893859Sml29623 		 * Unmask the system interrupt states.
32903859Sml29623 		 */
32913859Sml29623 		(void) nxge_fzc_sys_err_mask_set(nxgep, SYS_ERR_SMX_MASK |
32926929Smisaki 		    SYS_ERR_IPP_MASK | SYS_ERR_TXC_MASK |
32936929Smisaki 		    SYS_ERR_ZCP_MASK);
32943859Sml29623 
32953859Sml29623 		(void) nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p);
32963859Sml29623 		nldvs++;
32973859Sml29623 	} else {
32983859Sml29623 		ldv = NXGE_SYS_ERROR_LD;
32993859Sml29623 		ldvp->ldv = (uint8_t)ldv;
33003859Sml29623 		ldvp->is_syserr = B_TRUE;
33013859Sml29623 		ldvp->ldv_intr_handler = nxge_syserr_intr;
33023859Sml29623 		ldvp->nxgep = nxgep;
33033859Sml29623 		ldvp->ldv_ldf_masks = 0;
33043859Sml29623 		ldgvp->ldvp_syserr = ldvp;
33053859Sml29623 	}
33063859Sml29623 
33073859Sml29623 	ldgvp->ldg_intrs = *nrequired_p;
33083859Sml29623 
33093859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init: "
33106929Smisaki 	    "func %d nldvs %d navail %d nrequired %d",
33116929Smisaki 	    func, nldvs, *navail_p, *nrequired_p));
33123859Sml29623 
33133859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_init"));
33143859Sml29623 	return (status);
33153859Sml29623 }
33163859Sml29623 
33173859Sml29623 nxge_status_t
33183859Sml29623 nxge_ldgv_uninit(p_nxge_t nxgep)
33193859Sml29623 {
33203859Sml29623 	p_nxge_ldgv_t ldgvp;
33213859Sml29623 
33223859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_uninit"));
33233859Sml29623 	ldgvp = nxgep->ldgvp;
33243859Sml29623 	if (ldgvp == NULL) {
33253859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_uninit: "
33266929Smisaki 		    "no logical group configured."));
33273859Sml29623 		return (NXGE_OK);
33283859Sml29623 	}
3329*7466SMisaki.Kataoka@Sun.COM 	if (ldgvp->ldvp_syserr_allocated == B_TRUE) {
3330*7466SMisaki.Kataoka@Sun.COM 		KMEM_FREE(ldgvp->ldvp_syserr, sizeof (nxge_ldv_t));
3331*7466SMisaki.Kataoka@Sun.COM 	}
33323859Sml29623 	if (ldgvp->ldgp) {
33333859Sml29623 		KMEM_FREE(ldgvp->ldgp, sizeof (nxge_ldg_t) * ldgvp->maxldgs);
33343859Sml29623 	}
33353859Sml29623 	if (ldgvp->ldvp) {
33363859Sml29623 		KMEM_FREE(ldgvp->ldvp, sizeof (nxge_ldv_t) * ldgvp->maxldvs);
33373859Sml29623 	}
33383859Sml29623 	KMEM_FREE(ldgvp, sizeof (nxge_ldgv_t));
33393859Sml29623 	nxgep->ldgvp = NULL;
33403859Sml29623 
33413859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_uninit"));
33423859Sml29623 	return (NXGE_OK);
33433859Sml29623 }
33443859Sml29623 
33453859Sml29623 nxge_status_t
33463859Sml29623 nxge_intr_ldgv_init(p_nxge_t nxgep)
33473859Sml29623 {
33483859Sml29623 	nxge_status_t status = NXGE_OK;
33493859Sml29623 
33503859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_ldgv_init"));
33513859Sml29623 	/*
33523859Sml29623 	 * Configure the logical device group numbers, state vectors and
33533859Sml29623 	 * interrupt masks for each logical device.
33543859Sml29623 	 */
33553859Sml29623 	status = nxge_fzc_intr_init(nxgep);
33563859Sml29623 
33573859Sml29623 	/*
33583859Sml29623 	 * Configure logical device masks and timers.
33593859Sml29623 	 */
33603859Sml29623 	status = nxge_intr_mask_mgmt(nxgep);
33613859Sml29623 
33623859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_ldgv_init"));
33633859Sml29623 	return (status);
33643859Sml29623 }
33653859Sml29623 
33663859Sml29623 nxge_status_t
33673859Sml29623 nxge_intr_mask_mgmt(p_nxge_t nxgep)
33683859Sml29623 {
33693859Sml29623 	p_nxge_ldgv_t ldgvp;
33703859Sml29623 	p_nxge_ldg_t ldgp;
33713859Sml29623 	p_nxge_ldv_t ldvp;
33723859Sml29623 	npi_handle_t handle;
33733859Sml29623 	int i, j;
33743859Sml29623 	npi_status_t rs = NPI_SUCCESS;
33753859Sml29623 
33763859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_mask_mgmt"));
33773859Sml29623 
33783859Sml29623 	if ((ldgvp = nxgep->ldgvp) == NULL) {
33793859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
33806929Smisaki 		    "<== nxge_intr_mask_mgmt: Null ldgvp"));
33813859Sml29623 		return (NXGE_ERROR);
33823859Sml29623 	}
33833859Sml29623 	handle = NXGE_DEV_NPI_HANDLE(nxgep);
33843859Sml29623 	ldgp = ldgvp->ldgp;
33853859Sml29623 	ldvp = ldgvp->ldvp;
33863859Sml29623 	if (ldgp == NULL || ldvp == NULL) {
33873859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
33886929Smisaki 		    "<== nxge_intr_mask_mgmt: Null ldgp or ldvp"));
33893859Sml29623 		return (NXGE_ERROR);
33903859Sml29623 	}
33913859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL,
33926929Smisaki 	    "==> nxge_intr_mask_mgmt: # of intrs %d ", ldgvp->ldg_intrs));
33933859Sml29623 	/* Initialize masks. */
33943859Sml29623 	if (nxgep->niu_type != N2_NIU) {
33953859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
33966929Smisaki 		    "==> nxge_intr_mask_mgmt(Neptune): # intrs %d ",
33976929Smisaki 		    ldgvp->ldg_intrs));
33983859Sml29623 		for (i = 0; i < ldgvp->ldg_intrs; i++, ldgp++) {
33993859Sml29623 			NXGE_DEBUG_MSG((nxgep, INT_CTL,
34006929Smisaki 			    "==> nxge_intr_mask_mgmt(Neptune): # ldv %d "
34016929Smisaki 			    "in group %d", ldgp->nldvs, ldgp->ldg));
34023859Sml29623 			for (j = 0; j < ldgp->nldvs; j++, ldvp++) {
34033859Sml29623 				NXGE_DEBUG_MSG((nxgep, INT_CTL,
34046929Smisaki 				    "==> nxge_intr_mask_mgmt: set ldv # %d "
34056929Smisaki 				    "for ldg %d", ldvp->ldv, ldgp->ldg));
34063859Sml29623 				rs = npi_intr_mask_set(handle, ldvp->ldv,
34076929Smisaki 				    ldvp->ldv_ldf_masks);
34083859Sml29623 				if (rs != NPI_SUCCESS) {
34093859Sml29623 					NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
34106929Smisaki 					    "<== nxge_intr_mask_mgmt: "
34116929Smisaki 					    "set mask failed "
34126929Smisaki 					    " rs 0x%x ldv %d mask 0x%x",
34136929Smisaki 					    rs, ldvp->ldv,
34146929Smisaki 					    ldvp->ldv_ldf_masks));
34153859Sml29623 					return (NXGE_ERROR | rs);
34163859Sml29623 				}
34173859Sml29623 				NXGE_DEBUG_MSG((nxgep, INT_CTL,
34186929Smisaki 				    "==> nxge_intr_mask_mgmt: "
34196929Smisaki 				    "set mask OK "
34206929Smisaki 				    " rs 0x%x ldv %d mask 0x%x",
34216929Smisaki 				    rs, ldvp->ldv,
34226929Smisaki 				    ldvp->ldv_ldf_masks));
34233859Sml29623 			}
34243859Sml29623 		}
34253859Sml29623 	}
34263859Sml29623 	ldgp = ldgvp->ldgp;
34273859Sml29623 	/* Configure timer and arm bit */
34283859Sml29623 	for (i = 0; i < nxgep->ldgvp->ldg_intrs; i++, ldgp++) {
34293859Sml29623 		rs = npi_intr_ldg_mgmt_set(handle, ldgp->ldg,
34306929Smisaki 		    ldgp->arm, ldgp->ldg_timer);
34313859Sml29623 		if (rs != NPI_SUCCESS) {
34323859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
34336929Smisaki 			    "<== nxge_intr_mask_mgmt: "
34346929Smisaki 			    "set timer failed "
34356929Smisaki 			    " rs 0x%x dg %d timer 0x%x",
34366929Smisaki 			    rs, ldgp->ldg, ldgp->ldg_timer));
34373859Sml29623 			return (NXGE_ERROR | rs);
34383859Sml29623 		}
34393859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
34406929Smisaki 		    "==> nxge_intr_mask_mgmt: "
34416929Smisaki 		    "set timer OK "
34426929Smisaki 		    " rs 0x%x ldg %d timer 0x%x",
34436929Smisaki 		    rs, ldgp->ldg, ldgp->ldg_timer));
34443859Sml29623 	}
34453859Sml29623 
34463859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_fzc_intr_mask_mgmt"));
34473859Sml29623 	return (NXGE_OK);
34483859Sml29623 }
34493859Sml29623 
34503859Sml29623 nxge_status_t
34513859Sml29623 nxge_intr_mask_mgmt_set(p_nxge_t nxgep, boolean_t on)
34523859Sml29623 {
34533859Sml29623 	p_nxge_ldgv_t ldgvp;
34543859Sml29623 	p_nxge_ldg_t ldgp;
34553859Sml29623 	p_nxge_ldv_t ldvp;
34563859Sml29623 	npi_handle_t handle;
34573859Sml29623 	int i, j;
34583859Sml29623 	npi_status_t rs = NPI_SUCCESS;
34593859Sml29623 
34603859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL,
34616929Smisaki 	    "==> nxge_intr_mask_mgmt_set (%d)", on));
34623859Sml29623 
34633859Sml29623 	if (nxgep->niu_type == N2_NIU) {
34643859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
34656929Smisaki 		    "<== nxge_intr_mask_mgmt_set (%d) not set (N2/NIU)",
34666929Smisaki 		    on));
34673859Sml29623 		return (NXGE_ERROR);
34683859Sml29623 	}
34693859Sml29623 
34703859Sml29623 	if ((ldgvp = nxgep->ldgvp) == NULL) {
34713859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
34726929Smisaki 		    "==> nxge_intr_mask_mgmt_set: Null ldgvp"));
34733859Sml29623 		return (NXGE_ERROR);
34743859Sml29623 	}
34753859Sml29623 
34763859Sml29623 	handle = NXGE_DEV_NPI_HANDLE(nxgep);
34773859Sml29623 	ldgp = ldgvp->ldgp;
34783859Sml29623 	ldvp = ldgvp->ldvp;
34793859Sml29623 	if (ldgp == NULL || ldvp == NULL) {
34803859Sml29623 		NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
34816929Smisaki 		    "<== nxge_intr_mask_mgmt_set: Null ldgp or ldvp"));
34823859Sml29623 		return (NXGE_ERROR);
34833859Sml29623 	}
34843859Sml29623 	/* set masks. */
34853859Sml29623 	for (i = 0; i < ldgvp->ldg_intrs; i++, ldgp++) {
34863859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
34876929Smisaki 		    "==> nxge_intr_mask_mgmt_set: flag %d ldg %d"
34886929Smisaki 		    "set mask nldvs %d", on, ldgp->ldg, ldgp->nldvs));
34893859Sml29623 		for (j = 0; j < ldgp->nldvs; j++, ldvp++) {
34903859Sml29623 			NXGE_DEBUG_MSG((nxgep, INT_CTL,
34916929Smisaki 			    "==> nxge_intr_mask_mgmt_set: "
34926929Smisaki 			    "for %d %d flag %d", i, j, on));
34933859Sml29623 			if (on) {
34943859Sml29623 				ldvp->ldv_ldf_masks = 0;
34953859Sml29623 				NXGE_DEBUG_MSG((nxgep, INT_CTL,
34966929Smisaki 				    "==> nxge_intr_mask_mgmt_set: "
34976929Smisaki 				    "ON mask off"));
34983859Sml29623 			} else if (!on) {
34993859Sml29623 				ldvp->ldv_ldf_masks = (uint8_t)LD_IM1_MASK;
35003859Sml29623 				NXGE_DEBUG_MSG((nxgep, INT_CTL,
35016929Smisaki 				    "==> nxge_intr_mask_mgmt_set:mask on"));
35023859Sml29623 			}
35033859Sml29623 			rs = npi_intr_mask_set(handle, ldvp->ldv,
35046929Smisaki 			    ldvp->ldv_ldf_masks);
35053859Sml29623 			if (rs != NPI_SUCCESS) {
35063859Sml29623 				NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
35076929Smisaki 				    "==> nxge_intr_mask_mgmt_set: "
35086929Smisaki 				    "set mask failed "
35096929Smisaki 				    " rs 0x%x ldv %d mask 0x%x",
35106929Smisaki 				    rs, ldvp->ldv, ldvp->ldv_ldf_masks));
35113859Sml29623 				return (NXGE_ERROR | rs);
35123859Sml29623 			}
35133859Sml29623 			NXGE_DEBUG_MSG((nxgep, INT_CTL,
35146929Smisaki 			    "==> nxge_intr_mask_mgmt_set: flag %d"
35156929Smisaki 			    "set mask OK "
35166929Smisaki 			    " ldv %d mask 0x%x",
35176929Smisaki 			    on, ldvp->ldv, ldvp->ldv_ldf_masks));
35183859Sml29623 		}
35193859Sml29623 	}
35203859Sml29623 
35213859Sml29623 	ldgp = ldgvp->ldgp;
35223859Sml29623 	/* set the arm bit */
35233859Sml29623 	for (i = 0; i < nxgep->ldgvp->ldg_intrs; i++, ldgp++) {
35243859Sml29623 		if (on && !ldgp->arm) {
35253859Sml29623 			ldgp->arm = B_TRUE;
35263859Sml29623 		} else if (!on && ldgp->arm) {
35273859Sml29623 			ldgp->arm = B_FALSE;
35283859Sml29623 		}
35293859Sml29623 		rs = npi_intr_ldg_mgmt_set(handle, ldgp->ldg,
35306929Smisaki 		    ldgp->arm, ldgp->ldg_timer);
35313859Sml29623 		if (rs != NPI_SUCCESS) {
35323859Sml29623 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
35336929Smisaki 			    "<== nxge_intr_mask_mgmt_set: "
35346929Smisaki 			    "set timer failed "
35356929Smisaki 			    " rs 0x%x ldg %d timer 0x%x",
35366929Smisaki 			    rs, ldgp->ldg, ldgp->ldg_timer));
35373859Sml29623 			return (NXGE_ERROR | rs);
35383859Sml29623 		}
35393859Sml29623 		NXGE_DEBUG_MSG((nxgep, INT_CTL,
35406929Smisaki 		    "==> nxge_intr_mask_mgmt_set: OK (flag %d) "
35416929Smisaki 		    "set timer "
35426929Smisaki 		    " ldg %d timer 0x%x",
35436929Smisaki 		    on, ldgp->ldg, ldgp->ldg_timer));
35443859Sml29623 	}
35453859Sml29623 
35463859Sml29623 	NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_mask_mgmt_set"));
35473859Sml29623 	return (NXGE_OK);
35483859Sml29623 }
35493859Sml29623 
35503859Sml29623 static nxge_status_t
35513859Sml29623 nxge_get_mac_addr_properties(p_nxge_t nxgep)
35523859Sml29623 {
35534732Sdavemq #if defined(_BIG_ENDIAN)
35543859Sml29623 	uchar_t *prop_val;
35553859Sml29623 	uint_t prop_len;
35564732Sdavemq 	uint_t j;
35574732Sdavemq #endif
35583859Sml29623 	uint_t i;
35593859Sml29623 	uint8_t func_num;
35604732Sdavemq 	boolean_t compute_macs = B_TRUE;
35613859Sml29623 
35623859Sml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_get_mac_addr_properties "));
35633859Sml29623 
35643859Sml29623 #if defined(_BIG_ENDIAN)
35653859Sml29623 	/*
35663859Sml29623 	 * Get the ethernet address.
35673859Sml29623 	 */
35683859Sml29623 	(void) localetheraddr((struct ether_addr *)NULL, &nxgep->ouraddr);
35693859Sml29623 
35703859Sml29623 	/*
35713859Sml29623 	 * Check if it is an adapter with its own local mac address If it is
35723859Sml29623 	 * present, override the system mac address.
35733859Sml29623 	 */
35743859Sml29623 	if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0,
35756929Smisaki 	    "local-mac-address", &prop_val,
35766929Smisaki 	    &prop_len) == DDI_PROP_SUCCESS) {
35773859Sml29623 		if (prop_len == ETHERADDRL) {
35783859Sml29623 			nxgep->factaddr = *(p_ether_addr_t)prop_val;
35793859Sml29623 			NXGE_DEBUG_MSG((nxgep, DDI_CTL, "Local mac address = "
35806929Smisaki 			    "%02x:%02x:%02x:%02x:%02x:%02x",
35816929Smisaki 			    prop_val[0], prop_val[1], prop_val[2],
35826929Smisaki 			    prop_val[3], prop_val[4], prop_val[5]));
35833859Sml29623 		}
35843859Sml29623 		ddi_prop_free(prop_val);
35853859Sml29623 	}
35863859Sml29623 	if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0,
35876929Smisaki 	    "local-mac-address?", &prop_val,
35886929Smisaki 	    &prop_len) == DDI_PROP_SUCCESS) {
35893859Sml29623 		if (strncmp("true", (caddr_t)prop_val, (size_t)prop_len) == 0) {
35903859Sml29623 			nxgep->ouraddr = nxgep->factaddr;
35913859Sml29623 			NXGE_DEBUG_MSG((nxgep, DDI_CTL,
35926929Smisaki 			    "Using local MAC address"));
35933859Sml29623 		}
35943859Sml29623 		ddi_prop_free(prop_val);
35953859Sml29623 	} else {
35963859Sml29623 		nxgep->ouraddr = nxgep->factaddr;
35973859Sml29623 	}
35984185Sspeer 
35994977Sraghus 	if ((!nxgep->vpd_info.present) ||
36004732Sdavemq 	    (nxge_is_valid_local_mac(nxgep->factaddr)))
36014185Sspeer 		goto got_mac_addr;
36024185Sspeer 
36034185Sspeer 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "nxge_get_mac_addr_properties: "
36044185Sspeer 	    "MAC address from properties is not valid...reading from PROM"));
36054185Sspeer 
36064185Sspeer #endif
36074185Sspeer 	if (!nxgep->vpd_info.ver_valid) {
36084185Sspeer 		(void) nxge_espc_mac_addrs_get(nxgep);
36094185Sspeer 		if (!nxge_is_valid_local_mac(nxgep->factaddr)) {
36104977Sraghus 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "Failed to get "
36114977Sraghus 			    "MAC address"));
36124185Sspeer 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "EEPROM version "
36134185Sspeer 			    "[%s] invalid...please update",
36144185Sspeer 			    nxgep->vpd_info.ver));
36154185Sspeer 			return (NXGE_ERROR);
36164185Sspeer 		}
36174185Sspeer 		nxgep->ouraddr = nxgep->factaddr;
36184185Sspeer 		goto got_mac_addr;
36194185Sspeer 	}
36204185Sspeer 	/*
36214185Sspeer 	 * First get the MAC address from the info in the VPD data read
36224185Sspeer 	 * from the EEPROM.
36234185Sspeer 	 */
36244185Sspeer 	nxge_espc_get_next_mac_addr(nxgep->vpd_info.mac_addr,
36254732Sdavemq 	    nxgep->function_num, &nxgep->factaddr);
36264185Sspeer 
36274185Sspeer 	if (!nxge_is_valid_local_mac(nxgep->factaddr)) {
36284185Sspeer 		NXGE_DEBUG_MSG((nxgep, DDI_CTL,
36294185Sspeer 		    "nxge_get_mac_addr_properties: "
36304185Sspeer 		    "MAC address in EEPROM VPD data not valid"
36314185Sspeer 		    "...reading from NCR registers"));
36324185Sspeer 		(void) nxge_espc_mac_addrs_get(nxgep);
36334185Sspeer 		if (!nxge_is_valid_local_mac(nxgep->factaddr)) {
36344977Sraghus 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "Failed to get "
36354977Sraghus 			    "MAC address"));
36364185Sspeer 			NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "EEPROM version "
36374185Sspeer 			    "[%s] invalid...please update",
36384185Sspeer 			    nxgep->vpd_info.ver));
36394185Sspeer 			return (NXGE_ERROR);
36404185Sspeer 		}
36414185Sspeer 	}
36424185Sspeer 
36433859Sml29623 	nxgep->ouraddr = nxgep->factaddr;
36444185Sspeer 
36454185Sspeer got_mac_addr:
36463859Sml29623 	func_num = nxgep->function_num;
36473859Sml29623 
36483859Sml29623 	/*
36494732Sdavemq 	 * Note: mac-addresses property is the list of mac addresses for a
36504732Sdavemq 	 * port. NXGE_MAX_MMAC_ADDRS is the total number of MAC addresses
36514732Sdavemq 	 * allocated for a board.
36523859Sml29623 	 */
36534732Sdavemq 	nxgep->nxge_mmac_info.total_factory_macs = NXGE_MAX_MMAC_ADDRS;
36544732Sdavemq 
36554732Sdavemq #if defined(_BIG_ENDIAN)
36564732Sdavemq 	if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0,
36574732Sdavemq 	    "mac-addresses", &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
36583859Sml29623 		/*
36594732Sdavemq 		 * XAUI may have up to 18 MACs, more than the XMAC can
36604732Sdavemq 		 * use (1 unique MAC plus 16 alternate MACs)
36613859Sml29623 		 */
36624732Sdavemq 		nxgep->nxge_mmac_info.num_factory_mmac =
36634732Sdavemq 		    prop_len / ETHERADDRL - 1;
36644732Sdavemq 		if (nxgep->nxge_mmac_info.num_factory_mmac >
36654732Sdavemq 		    XMAC_MAX_ALT_ADDR_ENTRY) {
36664185Sspeer 			nxgep->nxge_mmac_info.num_factory_mmac =
36674732Sdavemq 			    XMAC_MAX_ALT_ADDR_ENTRY;
36684732Sdavemq 		}
36694732Sdavemq 
36704732Sdavemq 		for (i = 1; i <= nxgep->nxge_mmac_info.num_factory_mmac; i++) {
36714732Sdavemq 			for (j = 0; j < ETHERADDRL; j++) {
36724732Sdavemq 				nxgep->nxge_mmac_info.factory_mac_pool[i][j] =
36734732Sdavemq 				    *(prop_val + (i * ETHERADDRL) + j);
36744732Sdavemq 			}
36754732Sdavemq 			NXGE_DEBUG_MSG((nxgep, DDI_CTL,
36764732Sdavemq 			    "nxge_get_mac_addr_properties: Alt mac[%d] from "
36774732Sdavemq 			    "mac-addresses property[%2x:%2x:%2x:%2x:%2x:%2x]",
36784732Sdavemq 			    i, nxgep->nxge_mmac_info.factory_mac_pool[i][0],
36794732Sdavemq 			    nxgep->nxge_mmac_info.factory_mac_pool[i][1],
36804732Sdavemq 			    nxgep->nxge_mmac_info.factory_mac_pool[i][2],
36814732Sdavemq 			    nxgep->nxge_mmac_info.factory_mac_pool[i][3],
36824732Sdavemq 			    nxgep->nxge_mmac_info.factory_mac_pool[i][4],
36834732Sdavemq 			    nxgep->nxge_mmac_info.factory_mac_pool[i][5]));
36844185Sspeer 		}
36854732Sdavemq 
36864732Sdavemq 		compute_macs = B_FALSE;
36874732Sdavemq 		ddi_prop_free(prop_val);
36884732Sdavemq 		goto got_mmac_info;
36893859Sml29623 	}
36904732Sdavemq #endif
36914732Sdavemq 	/*
36924732Sdavemq 	 * total_factory_macs = 32
36934732Sdavemq 	 * num_factory_mmac = (32 >> (nports/2)) - 1
36944732Sdavemq 	 * So if nports = 4, then num_factory_mmac =  7
36954732Sdavemq 	 *    if nports = 2, then num_factory_mmac = 15
36964732Sdavemq 	 */
36974732Sdavemq 	nxgep->nxge_mmac_info.num_factory_mmac =
36984732Sdavemq 	    ((nxgep->nxge_mmac_info.total_factory_macs >>
36994732Sdavemq 	    (nxgep->nports >> 1))) - 1;
37004732Sdavemq 
37014732Sdavemq got_mmac_info:
37024732Sdavemq 
37034732Sdavemq 	if ((nxgep->function_num < 2) &&
37044732Sdavemq 	    (nxgep->nxge_mmac_info.num_factory_mmac >
37054732Sdavemq 	    XMAC_MAX_ALT_ADDR_ENTRY)) {
37064732Sdavemq 		nxgep->nxge_mmac_info.num_factory_mmac =
37074732Sdavemq 		    XMAC_MAX_ALT_ADDR_ENTRY;
37084732Sdavemq 	} else if ((nxgep->function_num > 1) &&
37094732Sdavemq 	    (nxgep->nxge_mmac_info.num_factory_mmac >
37104732Sdavemq 	    BMAC_MAX_ALT_ADDR_ENTRY)) {
37114732Sdavemq 		nxgep->nxge_mmac_info.num_factory_mmac =
37124732Sdavemq 		    BMAC_MAX_ALT_ADDR_ENTRY;
37134185Sspeer 	}
37144185Sspeer 
37153859Sml29623 	for (i = 0; i <= nxgep->nxge_mmac_info.num_mmac; i++) {
37163859Sml29623 		(void) npi_mac_altaddr_disable(nxgep->npi_handle,
37176929Smisaki 		    NXGE_GET_PORT_NUM(func_num), i);
37183859Sml29623 	}
37193859Sml29623 
37204732Sdavemq 	(void) nxge_init_mmac(nxgep, compute_macs);
37213859Sml29623 	return (NXGE_OK);
37223859Sml29623 }
37233859Sml29623 
37243859Sml29623 void
37253859Sml29623 nxge_get_xcvr_properties(p_nxge_t nxgep)
37263859Sml29623 {
37273859Sml29623 	uchar_t *prop_val;
37283859Sml29623 	uint_t prop_len;
37293859Sml29623 
37303859Sml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_get_xcvr_properties"));
37313859Sml29623 
37323859Sml29623 	/*
37333859Sml29623 	 * Read the type of physical layer interface being used.
37343859Sml29623 	 */
37353859Sml29623 	nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR;
37363859Sml29623 	if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0,
37376929Smisaki 	    "phy-type", &prop_val, &prop_len) == DDI_PROP_SUCCESS) {
37383859Sml29623 		if (strncmp("pcs", (caddr_t)prop_val,
37396929Smisaki 		    (size_t)prop_len) == 0) {
37403859Sml29623 			nxgep->statsp->mac_stats.xcvr_inuse = PCS_XCVR;
37413859Sml29623 		} else {
37423859Sml29623 			nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR;
37433859Sml29623 		}
37443859Sml29623 		ddi_prop_free(prop_val);
37453859Sml29623 	} else if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0,
37466929Smisaki 	    "phy-interface", &prop_val,
37476929Smisaki 	    &prop_len) == DDI_PROP_SUCCESS) {
37483859Sml29623 		if (strncmp("pcs", (caddr_t)prop_val, (size_t)prop_len) == 0) {
37493859Sml29623 			nxgep->statsp->mac_stats.xcvr_inuse = PCS_XCVR;
37503859Sml29623 		} else {
37513859Sml29623 			nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR;
37523859Sml29623 		}
37533859Sml29623 		ddi_prop_free(prop_val);
37543859Sml29623 	}
37553859Sml29623 }
37563859Sml29623 
37573859Sml29623 /*
37583859Sml29623  * Static functions start here.
37593859Sml29623  */
37603859Sml29623 
37613859Sml29623 static void
37623859Sml29623 nxge_ldgv_setup(p_nxge_ldg_t *ldgp, p_nxge_ldv_t *ldvp, uint8_t ldv,
37633859Sml29623 	uint8_t endldg, int *ngrps)
37643859Sml29623 {
37653859Sml29623 	NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup"));
37663859Sml29623 	/* Assign the group number for each device. */
37673859Sml29623 	(*ldvp)->ldg_assigned = (*ldgp)->ldg;
37683859Sml29623 	(*ldvp)->ldgp = *ldgp;
37693859Sml29623 	(*ldvp)->ldv = ldv;
37703859Sml29623 
37713859Sml29623 	NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup: "
37726929Smisaki 	    "ldv %d endldg %d ldg %d, ldvp $%p",
37736929Smisaki 	    ldv, endldg, (*ldgp)->ldg, (*ldgp)->ldvp));
37743859Sml29623 
37753859Sml29623 	(*ldgp)->nldvs++;
37763859Sml29623 	if ((*ldgp)->ldg == (endldg - 1)) {
37773859Sml29623 		if ((*ldgp)->ldvp == NULL) {
37783859Sml29623 			(*ldgp)->ldvp = *ldvp;
37793859Sml29623 			*ngrps += 1;
37803859Sml29623 			NXGE_DEBUG_MSG((NULL, INT_CTL,
37816929Smisaki 			    "==> nxge_ldgv_setup: ngrps %d", *ngrps));
37823859Sml29623 		}
37833859Sml29623 		NXGE_DEBUG_MSG((NULL, INT_CTL,
37846929Smisaki 		    "==> nxge_ldgv_setup: ldvp $%p ngrps %d",
37856929Smisaki 		    *ldvp, *ngrps));
37863859Sml29623 		++*ldvp;
37873859Sml29623 	} else {
37883859Sml29623 		(*ldgp)->ldvp = *ldvp;
37893859Sml29623 		*ngrps += 1;
37903859Sml29623 		NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup(done): "
37916929Smisaki 		    "ldv %d endldg %d ldg %d, ldvp $%p",
37926929Smisaki 		    ldv, endldg, (*ldgp)->ldg, (*ldgp)->ldvp));
37933859Sml29623 		(*ldvp) = ++*ldvp;
37943859Sml29623 		(*ldgp) = ++*ldgp;
37953859Sml29623 		NXGE_DEBUG_MSG((NULL, INT_CTL,
37966929Smisaki 		    "==> nxge_ldgv_setup: new ngrps %d", *ngrps));
37973859Sml29623 	}
37983859Sml29623 
37993859Sml29623 	NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup: "
38006929Smisaki 	    "ldv %d ldvp $%p endldg %d ngrps %d",
38016929Smisaki 	    ldv, ldvp, endldg, *ngrps));
38023859Sml29623 
38033859Sml29623 	NXGE_DEBUG_MSG((NULL, INT_CTL, "<== nxge_ldgv_setup"));
38043859Sml29623 }
38053859Sml29623 
38063859Sml29623 /*
38073859Sml29623  * Note: This function assumes the following distribution of mac
38083859Sml29623  * addresses among 4 ports in neptune:
38093859Sml29623  *
38103859Sml29623  *      -------------
38113859Sml29623  *    0|            |0 - local-mac-address for fn 0
38123859Sml29623  *      -------------
38133859Sml29623  *    1|            |1 - local-mac-address for fn 1
38143859Sml29623  *      -------------
38153859Sml29623  *    2|            |2 - local-mac-address for fn 2
38163859Sml29623  *      -------------
38173859Sml29623  *    3|            |3 - local-mac-address for fn 3
38183859Sml29623  *      -------------
38193859Sml29623  *     |            |4 - Start of alt. mac addr. for fn 0
38203859Sml29623  *     |            |
38213859Sml29623  *     |            |
38223859Sml29623  *     |            |10
38233859Sml29623  *     --------------
38243859Sml29623  *     |            |11 - Start of alt. mac addr. for fn 1
38253859Sml29623  *     |            |
38263859Sml29623  *     |            |
38273859Sml29623  *     |            |17
38283859Sml29623  *     --------------
38293859Sml29623  *     |            |18 - Start of alt. mac addr. for fn 2
38303859Sml29623  *     |            |
38313859Sml29623  *     |            |
38323859Sml29623  *     |            |24
38333859Sml29623  *     --------------
38343859Sml29623  *     |            |25 - Start of alt. mac addr. for fn 3
38353859Sml29623  *     |            |
38363859Sml29623  *     |            |
38373859Sml29623  *     |            |31
38383859Sml29623  *     --------------
38393859Sml29623  *
38403859Sml29623  * For N2/NIU the mac addresses is from XAUI card.
38414732Sdavemq  *
38424732Sdavemq  * When 'compute_addrs' is true, the alternate mac addresses are computed
38434732Sdavemq  * using the unique mac address as base. Otherwise the alternate addresses
38444732Sdavemq  * are assigned from the list read off the 'mac-addresses' property.
38453859Sml29623  */
38463859Sml29623 
38473859Sml29623 static void
38484732Sdavemq nxge_init_mmac(p_nxge_t nxgep, boolean_t compute_addrs)
38493859Sml29623 {
38503859Sml29623 	int slot;
38513859Sml29623 	uint8_t func_num;
38523859Sml29623 	uint16_t *base_mmac_addr;
38533859Sml29623 	uint32_t alt_mac_ls4b;
38543859Sml29623 	uint16_t *mmac_addr;
38553859Sml29623 	uint32_t base_mac_ls4b; /* least significant 4 bytes */
38563859Sml29623 	nxge_mmac_t *mmac_info;
38573859Sml29623 	npi_mac_addr_t mac_addr;
38583859Sml29623 
38593859Sml29623 	func_num = nxgep->function_num;
38603859Sml29623 	base_mmac_addr = (uint16_t *)&nxgep->factaddr;
38613859Sml29623 	mmac_info = (nxge_mmac_t *)&nxgep->nxge_mmac_info;
38623859Sml29623 
38634732Sdavemq 	if (compute_addrs) {
38644732Sdavemq 		base_mac_ls4b = ((uint32_t)base_mmac_addr[1]) << 16 |
38654732Sdavemq 		    base_mmac_addr[2];
38664732Sdavemq 
38674732Sdavemq 		if (nxgep->niu_type == N2_NIU) {
38684732Sdavemq 			/* ls4b of 1st altmac */
38694732Sdavemq 			alt_mac_ls4b = base_mac_ls4b + 1;
38704732Sdavemq 		} else {			/* Neptune */
38714732Sdavemq 			alt_mac_ls4b = base_mac_ls4b +
38724732Sdavemq 			    (nxgep->nports - func_num) +
38734732Sdavemq 			    (func_num * (mmac_info->num_factory_mmac));
38744732Sdavemq 		}
38753859Sml29623 	}
38763859Sml29623 
38773859Sml29623 	/* Set flags for unique MAC */
38783859Sml29623 	mmac_info->mac_pool[0].flags |= MMAC_SLOT_USED | MMAC_VENDOR_ADDR;
38793859Sml29623 
38803859Sml29623 	/* Clear flags of all alternate MAC slots */
38813859Sml29623 	for (slot = 1; slot <= mmac_info->num_mmac; slot++) {
38823859Sml29623 		if (slot <= mmac_info->num_factory_mmac)
38833859Sml29623 			mmac_info->mac_pool[slot].flags = MMAC_VENDOR_ADDR;
38843859Sml29623 		else
38853859Sml29623 			mmac_info->mac_pool[slot].flags = 0;
38863859Sml29623 	}
38873859Sml29623 
38883859Sml29623 	/* Generate and store factory alternate MACs */
38893859Sml29623 	for (slot = 1; slot <= mmac_info->num_factory_mmac; slot++) {
38903859Sml29623 		mmac_addr = (uint16_t *)&mmac_info->factory_mac_pool[slot];
38914732Sdavemq 		if (compute_addrs) {
38924732Sdavemq 			mmac_addr[0] = base_mmac_addr[0];
38934732Sdavemq 			mac_addr.w2 = mmac_addr[0];
38944732Sdavemq 
38954732Sdavemq 			mmac_addr[1] = (alt_mac_ls4b >> 16) & 0x0FFFF;
38964732Sdavemq 			mac_addr.w1 = mmac_addr[1];
38974732Sdavemq 
38984732Sdavemq 			mmac_addr[2] = alt_mac_ls4b & 0x0FFFF;
38994732Sdavemq 			mac_addr.w0 = mmac_addr[2];
39004732Sdavemq 
39014732Sdavemq 			alt_mac_ls4b++;
39024732Sdavemq 		} else {
39034732Sdavemq 			mac_addr.w2 = mmac_addr[0];
39044732Sdavemq 			mac_addr.w1 = mmac_addr[1];
39054732Sdavemq 			mac_addr.w0 = mmac_addr[2];
39064732Sdavemq 		}
39074732Sdavemq 
39084732Sdavemq 		NXGE_DEBUG_MSG((nxgep, DDI_CTL,
39094732Sdavemq 		    "mac_pool_addr[%2x:%2x:%2x:%2x:%2x:%2x] npi_addr[%x%x%x]",
39104732Sdavemq 		    mmac_info->factory_mac_pool[slot][0],
39114732Sdavemq 		    mmac_info->factory_mac_pool[slot][1],
39124732Sdavemq 		    mmac_info->factory_mac_pool[slot][2],
39134732Sdavemq 		    mmac_info->factory_mac_pool[slot][3],
39144732Sdavemq 		    mmac_info->factory_mac_pool[slot][4],
39154732Sdavemq 		    mmac_info->factory_mac_pool[slot][5],
39164732Sdavemq 		    mac_addr.w0, mac_addr.w1, mac_addr.w2));
39173859Sml29623 		/*
39184732Sdavemq 		 * slot minus 1 because npi_mac_altaddr_entry expects 0
39193859Sml29623 		 * for the first alternate mac address.
39203859Sml29623 		 */
39213859Sml29623 		(void) npi_mac_altaddr_entry(nxgep->npi_handle, OP_SET,
39226929Smisaki 		    NXGE_GET_PORT_NUM(func_num), slot - 1, &mac_addr);
39233859Sml29623 	}
39243859Sml29623 	/* Initialize the first two parameters for mmac kstat */
39253859Sml29623 	nxgep->statsp->mmac_stats.mmac_max_cnt = mmac_info->num_mmac;
39263859Sml29623 	nxgep->statsp->mmac_stats.mmac_avail_cnt = mmac_info->num_mmac;
39273859Sml29623 }
3928