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 /* 228661SSantwona.Behera@Sun.COM * Copyright 2009 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 309015SMichael.Speer@Sun.COM /* 319015SMichael.Speer@Sun.COM * Local defines for FWARC 2006/556 329015SMichael.Speer@Sun.COM */ 339015SMichael.Speer@Sun.COM #define NXGE_NIU_TDMA_PROP_LEN 2 349015SMichael.Speer@Sun.COM #define NXGE_NIU_RDMA_PROP_LEN 2 359015SMichael.Speer@Sun.COM #define NXGE_NIU_0_INTR_PROP_LEN 19 369015SMichael.Speer@Sun.COM #define NXGE_NIU_1_INTR_PROP_LEN 17 379015SMichael.Speer@Sun.COM 389015SMichael.Speer@Sun.COM /* 399015SMichael.Speer@Sun.COM * Local functions. 409015SMichael.Speer@Sun.COM */ 413859Sml29623 static void nxge_get_niu_property(dev_info_t *, niu_type_t *); 423859Sml29623 static nxge_status_t nxge_get_mac_addr_properties(p_nxge_t); 433859Sml29623 static nxge_status_t nxge_use_cfg_n2niu_properties(p_nxge_t); 443859Sml29623 static void nxge_use_cfg_neptune_properties(p_nxge_t); 453859Sml29623 static void nxge_use_cfg_dma_config(p_nxge_t); 463859Sml29623 static void nxge_use_cfg_vlan_class_config(p_nxge_t); 473859Sml29623 static void nxge_use_cfg_mac_class_config(p_nxge_t); 483859Sml29623 static void nxge_use_cfg_class_config(p_nxge_t); 493859Sml29623 static void nxge_use_cfg_link_cfg(p_nxge_t); 503859Sml29623 static void nxge_set_hw_dma_config(p_nxge_t); 513859Sml29623 static void nxge_set_hw_vlan_class_config(p_nxge_t); 523859Sml29623 static void nxge_set_hw_mac_class_config(p_nxge_t); 533859Sml29623 static void nxge_set_hw_class_config(p_nxge_t); 543859Sml29623 static nxge_status_t nxge_use_default_dma_config_n2(p_nxge_t); 553859Sml29623 static void nxge_ldgv_setup(p_nxge_ldg_t *, p_nxge_ldv_t *, uint8_t, 563859Sml29623 uint8_t, int *); 574732Sdavemq static void nxge_init_mmac(p_nxge_t, boolean_t); 586495Sspeer static void nxge_set_rdc_intr_property(p_nxge_t); 593859Sml29623 603859Sml29623 uint32_t nxge_use_hw_property = 1; 613859Sml29623 uint32_t nxge_groups_per_port = 2; 623859Sml29623 633859Sml29623 extern uint32_t nxge_use_partition; 643859Sml29623 extern uint32_t nxge_dma_obp_props_only; 653859Sml29623 663859Sml29623 extern uint_t nxge_rx_intr(void *, void *); 673859Sml29623 extern uint_t nxge_tx_intr(void *, void *); 683859Sml29623 extern uint_t nxge_mif_intr(void *, void *); 693859Sml29623 extern uint_t nxge_mac_intr(void *, void *); 703859Sml29623 extern uint_t nxge_syserr_intr(void *, void *); 713859Sml29623 extern void *nxge_list; 723859Sml29623 733859Sml29623 #define NXGE_SHARED_REG_SW_SIM 743859Sml29623 753859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 763859Sml29623 uint64_t global_dev_ctrl = 0; 773859Sml29623 #endif 783859Sml29623 793859Sml29623 #define MAX_SIBLINGS NXGE_MAX_PORTS 803859Sml29623 813859Sml29623 extern uint32_t nxge_rbr_size; 823859Sml29623 extern uint32_t nxge_rcr_size; 833859Sml29623 extern uint32_t nxge_tx_ring_size; 843859Sml29623 extern uint32_t nxge_rbr_spare_size; 853859Sml29623 863859Sml29623 extern npi_status_t npi_mac_altaddr_disable(npi_handle_t, uint8_t, uint8_t); 873859Sml29623 883859Sml29623 static uint8_t p2_tx_fair[2] = {12, 12}; 893859Sml29623 static uint8_t p2_tx_equal[2] = {12, 12}; 903859Sml29623 static uint8_t p4_tx_fair[4] = {6, 6, 6, 6}; 913859Sml29623 static uint8_t p4_tx_equal[4] = {6, 6, 6, 6}; 923859Sml29623 static uint8_t p2_rx_fair[2] = {8, 8}; 933859Sml29623 static uint8_t p2_rx_equal[2] = {8, 8}; 943859Sml29623 static uint8_t p4_rx_fair[4] = {4, 4, 4, 4}; 953859Sml29623 static uint8_t p4_rx_equal[4] = {4, 4, 4, 4}; 963859Sml29623 973859Sml29623 static uint8_t p2_rdcgrp_fair[2] = {4, 4}; 983859Sml29623 static uint8_t p2_rdcgrp_equal[2] = {4, 4}; 993859Sml29623 static uint8_t p4_rdcgrp_fair[4] = {2, 2, 1, 1}; 1003859Sml29623 static uint8_t p4_rdcgrp_equal[4] = {2, 2, 2, 2}; 1013859Sml29623 static uint8_t p2_rdcgrp_cls[2] = {1, 1}; 1023859Sml29623 static uint8_t p4_rdcgrp_cls[4] = {1, 1, 1, 1}; 1033859Sml29623 1044732Sdavemq static uint8_t rx_4_1G[4] = {4, 4, 4, 4}; 1054732Sdavemq static uint8_t rx_2_10G[2] = {8, 8}; 1064732Sdavemq static uint8_t rx_2_10G_2_1G[4] = {6, 6, 2, 2}; 1074732Sdavemq static uint8_t rx_1_10G_3_1G[4] = {10, 2, 2, 2}; 1084732Sdavemq static uint8_t rx_1_1G_1_10G_2_1G[4] = {2, 10, 2, 2}; 1094732Sdavemq 1104732Sdavemq static uint8_t tx_4_1G[4] = {6, 6, 6, 6}; 1114732Sdavemq static uint8_t tx_2_10G[2] = {12, 12}; 1124732Sdavemq static uint8_t tx_2_10G_2_1G[4] = {10, 10, 2, 2}; 1134732Sdavemq static uint8_t tx_1_10G_3_1G[4] = {12, 4, 4, 4}; 1144732Sdavemq static uint8_t tx_1_1G_1_10G_2_1G[4] = {4, 12, 4, 4}; 1154732Sdavemq 1163859Sml29623 typedef enum { 1173859Sml29623 DEFAULT = 0, 1183859Sml29623 EQUAL, 1193859Sml29623 FAIR, 1203859Sml29623 CUSTOM, 1213859Sml29623 CLASSIFY, 1223859Sml29623 L2_CLASSIFY, 1233859Sml29623 L3_DISTRIBUTE, 1243859Sml29623 L3_CLASSIFY, 1253859Sml29623 L3_TCAM, 1263859Sml29623 CONFIG_TOKEN_NONE 1273859Sml29623 } config_token_t; 1283859Sml29623 1293859Sml29623 static char *token_names[] = { 1303859Sml29623 "default", 1313859Sml29623 "equal", 1323859Sml29623 "fair", 1333859Sml29623 "custom", 1343859Sml29623 "classify", 1353859Sml29623 "l2_classify", 1363859Sml29623 "l3_distribute", 1373859Sml29623 "l3_classify", 1383859Sml29623 "l3_tcam", 1393859Sml29623 "none", 1403859Sml29623 }; 1413859Sml29623 1423859Sml29623 void nxge_virint_regs_dump(p_nxge_t nxgep); 1433859Sml29623 1443859Sml29623 void 1453859Sml29623 nxge_virint_regs_dump(p_nxge_t nxgep) 1463859Sml29623 { 1473859Sml29623 npi_handle_t handle; 1483859Sml29623 1493859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_virint_regs_dump")); 1503859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 1513859Sml29623 (void) npi_vir_dump_pio_fzc_regs_one(handle); 1523859Sml29623 (void) npi_vir_dump_ldgnum(handle); 1533859Sml29623 (void) npi_vir_dump_ldsv(handle); 1543859Sml29623 (void) npi_vir_dump_imask0(handle); 1553859Sml29623 (void) npi_vir_dump_sid(handle); 1563859Sml29623 (void) npi_mac_dump_regs(handle, nxgep->function_num); 1573859Sml29623 (void) npi_ipp_dump_regs(handle, nxgep->function_num); 1583859Sml29623 (void) npi_fflp_dump_regs(handle); 1593859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_virint_regs_dump")); 1603859Sml29623 } 1613859Sml29623 1623859Sml29623 /* 1633859Sml29623 * For now: we hard coded the DMA configurations. 1643859Sml29623 * and assume for one partition only. 1653859Sml29623 * 1663859Sml29623 * OBP. Then OBP will pass this partition's 1673859Sml29623 * Neptune configurations to fcode to create 1683859Sml29623 * properties for them. 1693859Sml29623 * 1703859Sml29623 * Since Neptune(PCI-E) and NIU (Niagara-2) has 1713859Sml29623 * different bus interfaces, the driver needs 1723859Sml29623 * to know which bus it is connected to. 1733859Sml29623 * Ravinder suggested: create a device property. 1743859Sml29623 * In partitioning environment, we cannot 1753859Sml29623 * use .conf file (need to check). If conf changes, 1763859Sml29623 * need to reboot the system. 1773859Sml29623 * The following function assumes that we will 1783859Sml29623 * retrieve its properties from a virtualized nexus driver. 1793859Sml29623 */ 1803859Sml29623 1813859Sml29623 nxge_status_t 1823859Sml29623 nxge_cntlops(dev_info_t *dip, nxge_ctl_enum_t ctlop, void *arg, void *result) 1833859Sml29623 { 1843859Sml29623 nxge_status_t status = NXGE_OK; 1853859Sml29623 int instance; 1863859Sml29623 p_nxge_t nxgep; 1873859Sml29623 1883859Sml29623 #ifndef NXGE_SHARED_REG_SW_SIM 1893859Sml29623 npi_handle_t handle; 1903859Sml29623 uint16_t sr16, cr16; 1913859Sml29623 #endif 1923859Sml29623 instance = ddi_get_instance(dip); 1933859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, "Instance %d ", instance)); 1943859Sml29623 1953859Sml29623 if (nxge_list == NULL) { 1963859Sml29623 NXGE_ERROR_MSG((NULL, NXGE_ERR_CTL, 1976929Smisaki "nxge_cntlops: nxge_list null")); 1983859Sml29623 return (NXGE_ERROR); 1993859Sml29623 } 2003859Sml29623 nxgep = (p_nxge_t)ddi_get_soft_state(nxge_list, instance); 2013859Sml29623 if (nxgep == NULL) { 2023859Sml29623 NXGE_ERROR_MSG((NULL, NXGE_ERR_CTL, 2036929Smisaki "nxge_cntlops: nxgep null")); 2043859Sml29623 return (NXGE_ERROR); 2053859Sml29623 } 2063859Sml29623 #ifndef NXGE_SHARED_REG_SW_SIM 2073859Sml29623 handle = nxgep->npi_reg_handle; 2083859Sml29623 #endif 2093859Sml29623 switch (ctlop) { 2103859Sml29623 case NXGE_CTLOPS_NIUTYPE: 2113859Sml29623 nxge_get_niu_property(dip, (niu_type_t *)result); 2123859Sml29623 return (status); 2133859Sml29623 2143859Sml29623 case NXGE_CTLOPS_GET_SHARED_REG: 2153859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2163859Sml29623 *(uint64_t *)result = global_dev_ctrl; 2173859Sml29623 return (0); 2183859Sml29623 #else 2193859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2203859Sml29623 *(uint16_t *)result = sr16; 2213859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2226929Smisaki "nxge_cntlops: NXGE_CTLOPS_GET_SHARED_REG")); 2233859Sml29623 return (0); 2243859Sml29623 #endif 2253859Sml29623 2263859Sml29623 case NXGE_CTLOPS_SET_SHARED_REG_LOCK: 2273859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2283859Sml29623 global_dev_ctrl = *(uint64_t *)arg; 2293859Sml29623 return (0); 2303859Sml29623 #else 2313859Sml29623 status = NPI_FAILURE; 2323859Sml29623 while (status != NPI_SUCCESS) 2333859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2343859Sml29623 2353859Sml29623 sr16 = *(uint16_t *)arg; 2363859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2373859Sml29623 status = npi_dev_func_sr_lock_free(handle); 2383859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2396929Smisaki "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2403859Sml29623 return (0); 2413859Sml29623 #endif 2423859Sml29623 2433859Sml29623 case NXGE_CTLOPS_UPDATE_SHARED_REG: 2443859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2453859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2463859Sml29623 return (0); 2473859Sml29623 #else 2483859Sml29623 status = NPI_FAILURE; 2493859Sml29623 while (status != NPI_SUCCESS) 2503859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2513859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2523859Sml29623 sr16 |= *(uint16_t *)arg; 2533859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2543859Sml29623 status = npi_dev_func_sr_lock_free(handle); 2553859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2566929Smisaki "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2573859Sml29623 return (0); 2583859Sml29623 #endif 2593859Sml29623 2603859Sml29623 case NXGE_CTLOPS_CLEAR_BIT_SHARED_REG_UL: 2613859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2623859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2633859Sml29623 return (0); 2643859Sml29623 #else 2653859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2663859Sml29623 cr16 = *(uint16_t *)arg; 2673859Sml29623 sr16 &= ~cr16; 2683859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2693859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2706929Smisaki "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2713859Sml29623 return (0); 2723859Sml29623 #endif 2733859Sml29623 2743859Sml29623 case NXGE_CTLOPS_CLEAR_BIT_SHARED_REG: 2753859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2763859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2773859Sml29623 return (0); 2783859Sml29623 #else 2793859Sml29623 status = NPI_FAILURE; 2803859Sml29623 while (status != NPI_SUCCESS) 2813859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2823859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2833859Sml29623 cr16 = *(uint16_t *)arg; 2843859Sml29623 sr16 &= ~cr16; 2853859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2863859Sml29623 status = npi_dev_func_sr_lock_free(handle); 2873859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2886929Smisaki "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2893859Sml29623 return (0); 2903859Sml29623 #endif 2913859Sml29623 2923859Sml29623 case NXGE_CTLOPS_GET_LOCK_BLOCK: 2933859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2943859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2953859Sml29623 return (0); 2963859Sml29623 #else 2973859Sml29623 status = NPI_FAILURE; 2983859Sml29623 while (status != NPI_SUCCESS) 2993859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 3003859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 3016929Smisaki "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_BLOCK")); 3023859Sml29623 return (0); 3033859Sml29623 #endif 3043859Sml29623 case NXGE_CTLOPS_GET_LOCK_TRY: 3053859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 3063859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 3073859Sml29623 return (0); 3083859Sml29623 #else 3093859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 3103859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 3116929Smisaki "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_TRY")); 3123859Sml29623 if (status == NPI_SUCCESS) 3133859Sml29623 return (NXGE_OK); 3143859Sml29623 else 3153859Sml29623 return (NXGE_ERROR); 3163859Sml29623 #endif 3173859Sml29623 case NXGE_CTLOPS_FREE_LOCK: 3183859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 3193859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 3203859Sml29623 return (0); 3213859Sml29623 #else 3223859Sml29623 status = npi_dev_func_sr_lock_free(handle); 3233859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 3246929Smisaki "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_FREE")); 3253859Sml29623 if (status == NPI_SUCCESS) 3263859Sml29623 return (NXGE_OK); 3273859Sml29623 else 3283859Sml29623 return (NXGE_ERROR); 3293859Sml29623 #endif 3303859Sml29623 3313859Sml29623 default: 3323859Sml29623 status = NXGE_ERROR; 3333859Sml29623 } 3343859Sml29623 3353859Sml29623 return (status); 3363859Sml29623 } 3373859Sml29623 3383859Sml29623 void 3393859Sml29623 nxge_common_lock_get(p_nxge_t nxgep) 3403859Sml29623 { 3413859Sml29623 uint32_t status = NPI_FAILURE; 3423859Sml29623 npi_handle_t handle; 3433859Sml29623 3443859Sml29623 #if defined(NXGE_SHARE_REG_SW_SIM) 3453859Sml29623 return; 3463859Sml29623 #endif 3473859Sml29623 handle = nxgep->npi_reg_handle; 3483859Sml29623 while (status != NPI_SUCCESS) 3493859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 3503859Sml29623 } 3513859Sml29623 3523859Sml29623 void 3533859Sml29623 nxge_common_lock_free(p_nxge_t nxgep) 3543859Sml29623 { 3553859Sml29623 npi_handle_t handle; 3563859Sml29623 3573859Sml29623 #if defined(NXGE_SHARE_REG_SW_SIM) 3583859Sml29623 return; 3593859Sml29623 #endif 3603859Sml29623 handle = nxgep->npi_reg_handle; 3613859Sml29623 (void) npi_dev_func_sr_lock_free(handle); 3623859Sml29623 } 3633859Sml29623 3644185Sspeer 3653859Sml29623 static void 3663859Sml29623 nxge_get_niu_property(dev_info_t *dip, niu_type_t *niu_type) 3673859Sml29623 { 3683859Sml29623 uchar_t *prop_val; 3693859Sml29623 uint_t prop_len; 3703859Sml29623 3714732Sdavemq *niu_type = NIU_TYPE_NONE; 3723859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, 3736929Smisaki "niu-type", (uchar_t **)&prop_val, 3746929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 3753859Sml29623 if (strncmp("niu", (caddr_t)prop_val, (size_t)prop_len) == 0) { 3763859Sml29623 *niu_type = N2_NIU; 3773859Sml29623 } 3783859Sml29623 ddi_prop_free(prop_val); 3793859Sml29623 } 3803859Sml29623 } 3813859Sml29623 3823859Sml29623 static config_token_t 3833859Sml29623 nxge_get_config_token(char *prop) 3843859Sml29623 { 3853859Sml29623 config_token_t token = DEFAULT; 3863859Sml29623 3873859Sml29623 while (token < CONFIG_TOKEN_NONE) { 3883859Sml29623 if (strncmp(prop, token_names[token], 4) == 0) 3893859Sml29623 break; 3903859Sml29623 token++; 3913859Sml29623 } 3923859Sml29623 return (token); 3933859Sml29623 } 3943859Sml29623 3953859Sml29623 /* per port */ 3963859Sml29623 3973859Sml29623 static nxge_status_t 3983859Sml29623 nxge_update_rxdma_grp_properties(p_nxge_t nxgep, config_token_t token, 3993859Sml29623 dev_info_t *s_dip[]) 4003859Sml29623 { 4013859Sml29623 nxge_status_t status = NXGE_OK; 4023859Sml29623 int ddi_status; 4033859Sml29623 int num_ports = nxgep->nports; 4043859Sml29623 int port, bits, j; 4053859Sml29623 uint8_t start_grp = 0, num_grps = 0; 4063859Sml29623 p_nxge_param_t param_arr; 4073859Sml29623 uint32_t grp_bitmap[MAX_SIBLINGS]; 4083859Sml29623 int custom_start_grp[MAX_SIBLINGS]; 4093859Sml29623 int custom_num_grp[MAX_SIBLINGS]; 4103859Sml29623 uint8_t bad_config = B_FALSE; 4113859Sml29623 char *start_prop, *num_prop, *cfg_prop; 4123859Sml29623 4133859Sml29623 start_grp = 0; 4143859Sml29623 param_arr = nxgep->param_arr; 4153859Sml29623 start_prop = param_arr[param_rdc_grps_start].fcode_name; 4163859Sml29623 num_prop = param_arr[param_rx_rdc_grps].fcode_name; 4173859Sml29623 4183859Sml29623 switch (token) { 4193859Sml29623 case FAIR: 4203859Sml29623 cfg_prop = "fair"; 4213859Sml29623 for (port = 0; port < num_ports; port++) { 4223859Sml29623 custom_num_grp[port] = 4236929Smisaki (num_ports == 4) ? 4246929Smisaki p4_rdcgrp_fair[port] : 4256929Smisaki p2_rdcgrp_fair[port]; 4263859Sml29623 custom_start_grp[port] = start_grp; 4273859Sml29623 start_grp += custom_num_grp[port]; 4283859Sml29623 } 4293859Sml29623 break; 4303859Sml29623 4313859Sml29623 case EQUAL: 4323859Sml29623 cfg_prop = "equal"; 4333859Sml29623 for (port = 0; port < num_ports; port++) { 4343859Sml29623 custom_num_grp[port] = 4356929Smisaki (num_ports == 4) ? 4366929Smisaki p4_rdcgrp_equal[port] : 4376929Smisaki p2_rdcgrp_equal[port]; 4383859Sml29623 custom_start_grp[port] = start_grp; 4393859Sml29623 start_grp += custom_num_grp[port]; 4403859Sml29623 } 4413859Sml29623 break; 4423859Sml29623 4433859Sml29623 4443859Sml29623 case CLASSIFY: 4453859Sml29623 cfg_prop = "classify"; 4463859Sml29623 for (port = 0; port < num_ports; port++) { 4473859Sml29623 custom_num_grp[port] = (num_ports == 4) ? 4486929Smisaki p4_rdcgrp_cls[port] : p2_rdcgrp_cls[port]; 4493859Sml29623 custom_start_grp[port] = start_grp; 4503859Sml29623 start_grp += custom_num_grp[port]; 4513859Sml29623 } 4523859Sml29623 break; 4533859Sml29623 4543859Sml29623 case CUSTOM: 4553859Sml29623 cfg_prop = "custom"; 4563859Sml29623 /* See if it is good config */ 4573859Sml29623 num_grps = 0; 4583859Sml29623 for (port = 0; port < num_ports; port++) { 4593859Sml29623 custom_start_grp[port] = 4606929Smisaki ddi_prop_get_int(DDI_DEV_T_NONE, s_dip[port], 4616929Smisaki DDI_PROP_DONTPASS, start_prop, -1); 4623859Sml29623 if ((custom_start_grp[port] == -1) || 4636929Smisaki (custom_start_grp[port] >= 4646929Smisaki NXGE_MAX_RDC_GRPS)) { 4653859Sml29623 bad_config = B_TRUE; 4663859Sml29623 break; 4673859Sml29623 } 4683859Sml29623 custom_num_grp[port] = ddi_prop_get_int( 4696929Smisaki DDI_DEV_T_NONE, 4706929Smisaki s_dip[port], 4716929Smisaki DDI_PROP_DONTPASS, 4726929Smisaki num_prop, -1); 4733859Sml29623 4743859Sml29623 if ((custom_num_grp[port] == -1) || 4756929Smisaki (custom_num_grp[port] > 4766929Smisaki NXGE_MAX_RDC_GRPS) || 4776929Smisaki ((custom_num_grp[port] + 4786929Smisaki custom_start_grp[port]) >= 4796929Smisaki NXGE_MAX_RDC_GRPS)) { 4803859Sml29623 bad_config = B_TRUE; 4813859Sml29623 break; 4823859Sml29623 } 4833859Sml29623 num_grps += custom_num_grp[port]; 4843859Sml29623 if (num_grps > NXGE_MAX_RDC_GRPS) { 4853859Sml29623 bad_config = B_TRUE; 4863859Sml29623 break; 4873859Sml29623 } 4883859Sml29623 grp_bitmap[port] = 0; 4893859Sml29623 for (bits = 0; 4906929Smisaki bits < custom_num_grp[port]; 4916929Smisaki bits++) { 4923859Sml29623 grp_bitmap[port] |= 4936929Smisaki (1 << (bits + custom_start_grp[port])); 4943859Sml29623 } 4953859Sml29623 4963859Sml29623 } 4973859Sml29623 4983859Sml29623 if (bad_config == B_FALSE) { 4993859Sml29623 /* check for overlap */ 5003859Sml29623 for (port = 0; port < num_ports - 1; port++) { 5013859Sml29623 for (j = port + 1; j < num_ports; j++) { 5023859Sml29623 if (grp_bitmap[port] & 5036929Smisaki grp_bitmap[j]) { 5043859Sml29623 bad_config = B_TRUE; 5053859Sml29623 break; 5063859Sml29623 } 5073859Sml29623 } 5083859Sml29623 if (bad_config == B_TRUE) 5093859Sml29623 break; 5103859Sml29623 } 5113859Sml29623 } 5123859Sml29623 if (bad_config == B_TRUE) { 5133859Sml29623 /* use default config */ 5143859Sml29623 for (port = 0; port < num_ports; port++) { 5153859Sml29623 custom_num_grp[port] = 5166929Smisaki (num_ports == 4) ? 5176929Smisaki p4_rx_fair[port] : p2_rx_fair[port]; 5183859Sml29623 custom_start_grp[port] = start_grp; 5193859Sml29623 start_grp += custom_num_grp[port]; 5203859Sml29623 } 5213859Sml29623 } 5223859Sml29623 break; 5233859Sml29623 5243859Sml29623 default: 5253859Sml29623 /* use default config */ 5263859Sml29623 cfg_prop = "fair"; 5273859Sml29623 for (port = 0; port < num_ports; port++) { 5283859Sml29623 custom_num_grp[port] = (num_ports == 4) ? 5296929Smisaki p4_rx_fair[port] : p2_rx_fair[port]; 5303859Sml29623 custom_start_grp[port] = start_grp; 5313859Sml29623 start_grp += custom_num_grp[port]; 5323859Sml29623 } 5333859Sml29623 break; 5343859Sml29623 } 5353859Sml29623 5363859Sml29623 /* Now Update the rx properties */ 5373859Sml29623 for (port = 0; port < num_ports; port++) { 5383859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 5396929Smisaki "rxdma-grp-cfg", cfg_prop); 5403859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5413859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5426929Smisaki " property %s not updating", 5436929Smisaki cfg_prop)); 5443859Sml29623 status |= NXGE_DDI_FAILED; 5453859Sml29623 } 5463859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 5476929Smisaki num_prop, custom_num_grp[port]); 5483859Sml29623 5493859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5503859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5516929Smisaki " property %s not updating", 5526929Smisaki num_prop)); 5533859Sml29623 status |= NXGE_DDI_FAILED; 5543859Sml29623 } 5553859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 5566929Smisaki start_prop, custom_start_grp[port]); 5573859Sml29623 5583859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5593859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5606929Smisaki " property %s not updating", 5616929Smisaki start_prop)); 5623859Sml29623 status |= NXGE_DDI_FAILED; 5633859Sml29623 } 5643859Sml29623 } 5653859Sml29623 if (status & NXGE_DDI_FAILED) 5663859Sml29623 status |= NXGE_ERROR; 5673859Sml29623 5683859Sml29623 return (status); 5693859Sml29623 } 5703859Sml29623 5713859Sml29623 static nxge_status_t 5723859Sml29623 nxge_update_rxdma_properties(p_nxge_t nxgep, config_token_t token, 5733859Sml29623 dev_info_t *s_dip[]) 5743859Sml29623 { 5753859Sml29623 nxge_status_t status = NXGE_OK; 5763859Sml29623 int ddi_status; 5773859Sml29623 int num_ports = nxgep->nports; 5783859Sml29623 int port, bits, j; 5793859Sml29623 uint8_t start_rdc = 0, num_rdc = 0; 5803859Sml29623 p_nxge_param_t param_arr; 5813859Sml29623 uint32_t rdc_bitmap[MAX_SIBLINGS]; 5823859Sml29623 int custom_start_rdc[MAX_SIBLINGS]; 5833859Sml29623 int custom_num_rdc[MAX_SIBLINGS]; 5843859Sml29623 uint8_t bad_config = B_FALSE; 5853859Sml29623 int *prop_val; 5863859Sml29623 uint_t prop_len; 5873859Sml29623 char *start_rdc_prop, *num_rdc_prop, *cfg_prop; 5883859Sml29623 5893859Sml29623 start_rdc = 0; 5903859Sml29623 param_arr = nxgep->param_arr; 5913859Sml29623 start_rdc_prop = param_arr[param_rxdma_channels_begin].fcode_name; 5923859Sml29623 num_rdc_prop = param_arr[param_rxdma_channels].fcode_name; 5933859Sml29623 5943859Sml29623 switch (token) { 5953859Sml29623 case FAIR: 5963859Sml29623 cfg_prop = "fair"; 5973859Sml29623 for (port = 0; port < num_ports; port++) { 5983859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 5996929Smisaki p4_rx_fair[port] : p2_rx_fair[port]; 6003859Sml29623 custom_start_rdc[port] = start_rdc; 6013859Sml29623 start_rdc += custom_num_rdc[port]; 6023859Sml29623 } 6033859Sml29623 break; 6043859Sml29623 6053859Sml29623 case EQUAL: 6063859Sml29623 cfg_prop = "equal"; 6073859Sml29623 for (port = 0; port < num_ports; port++) { 6083859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 6096929Smisaki p4_rx_equal[port] : 6106929Smisaki p2_rx_equal[port]; 6113859Sml29623 custom_start_rdc[port] = start_rdc; 6123859Sml29623 start_rdc += custom_num_rdc[port]; 6133859Sml29623 } 6143859Sml29623 break; 6153859Sml29623 6163859Sml29623 case CUSTOM: 6173859Sml29623 cfg_prop = "custom"; 6183859Sml29623 /* See if it is good config */ 6193859Sml29623 num_rdc = 0; 6203859Sml29623 for (port = 0; port < num_ports; port++) { 6213859Sml29623 ddi_status = ddi_prop_lookup_int_array( 6226929Smisaki DDI_DEV_T_ANY, 6236929Smisaki s_dip[port], 0, 6246929Smisaki start_rdc_prop, 6256929Smisaki &prop_val, 6266929Smisaki &prop_len); 6273859Sml29623 if (ddi_status == DDI_SUCCESS) 6283859Sml29623 custom_start_rdc[port] = *prop_val; 6293859Sml29623 else { 6303859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6316929Smisaki " %s custom start port %d" 6326929Smisaki " read failed ", 6336929Smisaki " rxdma-cfg", port)); 6343859Sml29623 bad_config = B_TRUE; 6353859Sml29623 status |= NXGE_DDI_FAILED; 6363859Sml29623 } 6373859Sml29623 if ((custom_start_rdc[port] == -1) || 6386929Smisaki (custom_start_rdc[port] >= 6396929Smisaki NXGE_MAX_RDCS)) { 6403859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6416929Smisaki " %s custom start %d" 6426929Smisaki " out of range %x ", 6436929Smisaki " rxdma-cfg", 6446929Smisaki port, 6456929Smisaki custom_start_rdc[port])); 6463859Sml29623 bad_config = B_TRUE; 6473859Sml29623 break; 6483859Sml29623 } 6493859Sml29623 ddi_status = ddi_prop_lookup_int_array( 6506929Smisaki DDI_DEV_T_ANY, 6516929Smisaki s_dip[port], 6526929Smisaki 0, 6536929Smisaki num_rdc_prop, 6546929Smisaki &prop_val, 6556929Smisaki &prop_len); 6563859Sml29623 6573859Sml29623 if (ddi_status == DDI_SUCCESS) 6583859Sml29623 custom_num_rdc[port] = *prop_val; 6593859Sml29623 else { 6603859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6616929Smisaki " %s custom num port %d" 6626929Smisaki " read failed ", 6636929Smisaki "rxdma-cfg", port)); 6643859Sml29623 bad_config = B_TRUE; 6653859Sml29623 status |= NXGE_DDI_FAILED; 6663859Sml29623 } 6673859Sml29623 6683859Sml29623 if ((custom_num_rdc[port] == -1) || 6696929Smisaki (custom_num_rdc[port] > 6706929Smisaki NXGE_MAX_RDCS) || 6716929Smisaki ((custom_num_rdc[port] + 6726929Smisaki custom_start_rdc[port]) > 6736929Smisaki NXGE_MAX_RDCS)) { 6743859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6756929Smisaki " %s custom num %d" 6766929Smisaki " out of range %x ", 6776929Smisaki " rxdma-cfg", 6786929Smisaki port, custom_num_rdc[port])); 6793859Sml29623 bad_config = B_TRUE; 6803859Sml29623 break; 6813859Sml29623 } 6823859Sml29623 num_rdc += custom_num_rdc[port]; 6833859Sml29623 if (num_rdc > NXGE_MAX_RDCS) { 6843859Sml29623 bad_config = B_TRUE; 6853859Sml29623 break; 6863859Sml29623 } 6873859Sml29623 rdc_bitmap[port] = 0; 6883859Sml29623 for (bits = 0; 6896929Smisaki bits < custom_num_rdc[port]; bits++) { 6903859Sml29623 rdc_bitmap[port] |= 6916929Smisaki (1 << (bits + custom_start_rdc[port])); 6923859Sml29623 } 6933859Sml29623 } 6943859Sml29623 6953859Sml29623 if (bad_config == B_FALSE) { 6963859Sml29623 /* check for overlap */ 6973859Sml29623 for (port = 0; port < num_ports - 1; port++) { 6983859Sml29623 for (j = port + 1; j < num_ports; j++) { 6993859Sml29623 if (rdc_bitmap[port] & 7006929Smisaki rdc_bitmap[j]) { 7013859Sml29623 NXGE_DEBUG_MSG((nxgep, 7026929Smisaki CFG_CTL, 7036929Smisaki " rxdma-cfg" 7046929Smisaki " property custom" 7056929Smisaki " bit overlap" 7066929Smisaki " %d %d ", 7076929Smisaki port, j)); 7083859Sml29623 bad_config = B_TRUE; 7093859Sml29623 break; 7103859Sml29623 } 7113859Sml29623 } 7123859Sml29623 if (bad_config == B_TRUE) 7133859Sml29623 break; 7143859Sml29623 } 7153859Sml29623 } 7163859Sml29623 if (bad_config == B_TRUE) { 7173859Sml29623 /* use default config */ 7183859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7196929Smisaki " rxdma-cfg property:" 7206929Smisaki " bad custom config:" 7216929Smisaki " use default")); 7223859Sml29623 for (port = 0; port < num_ports; port++) { 7233859Sml29623 custom_num_rdc[port] = 7246929Smisaki (num_ports == 4) ? 7256929Smisaki p4_rx_fair[port] : 7266929Smisaki p2_rx_fair[port]; 7273859Sml29623 custom_start_rdc[port] = start_rdc; 7283859Sml29623 start_rdc += custom_num_rdc[port]; 7293859Sml29623 } 7303859Sml29623 } 7313859Sml29623 break; 7323859Sml29623 7333859Sml29623 default: 7343859Sml29623 /* use default config */ 7353859Sml29623 cfg_prop = "fair"; 7363859Sml29623 for (port = 0; port < num_ports; port++) { 7373859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 7386929Smisaki p4_rx_fair[port] : p2_rx_fair[port]; 7393859Sml29623 custom_start_rdc[port] = start_rdc; 7403859Sml29623 start_rdc += custom_num_rdc[port]; 7413859Sml29623 } 7423859Sml29623 break; 7433859Sml29623 } 7443859Sml29623 7453859Sml29623 /* Now Update the rx properties */ 7463859Sml29623 for (port = 0; port < num_ports; port++) { 7473859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7486929Smisaki " update property rxdma-cfg with %s ", cfg_prop)); 7493859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 7506929Smisaki "rxdma-cfg", cfg_prop); 7513859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7523859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7536929Smisaki " property rxdma-cfg is not updating to %s", 7546929Smisaki cfg_prop)); 7553859Sml29623 status |= NXGE_DDI_FAILED; 7563859Sml29623 } 7573859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 7586929Smisaki num_rdc_prop, custom_num_rdc[port])); 7593859Sml29623 7603859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 7616929Smisaki num_rdc_prop, custom_num_rdc[port]); 7623859Sml29623 7633859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7643859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 7656929Smisaki " property %s not updating with %d", 7666929Smisaki num_rdc_prop, custom_num_rdc[port])); 7673859Sml29623 status |= NXGE_DDI_FAILED; 7683859Sml29623 } 7693859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 7706929Smisaki start_rdc_prop, custom_start_rdc[port])); 7713859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 7726929Smisaki start_rdc_prop, custom_start_rdc[port]); 7733859Sml29623 7743859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7753859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 7766929Smisaki " property %s not updating with %d ", 7776929Smisaki start_rdc_prop, custom_start_rdc[port])); 7783859Sml29623 status |= NXGE_DDI_FAILED; 7793859Sml29623 } 7803859Sml29623 } 7813859Sml29623 if (status & NXGE_DDI_FAILED) 7823859Sml29623 status |= NXGE_ERROR; 7833859Sml29623 return (status); 7843859Sml29623 } 7853859Sml29623 7863859Sml29623 static nxge_status_t 7873859Sml29623 nxge_update_txdma_properties(p_nxge_t nxgep, config_token_t token, 7883859Sml29623 dev_info_t *s_dip[]) 7893859Sml29623 { 7903859Sml29623 nxge_status_t status = NXGE_OK; 7913859Sml29623 int ddi_status = DDI_SUCCESS; 7923859Sml29623 int num_ports = nxgep->nports; 7933859Sml29623 int port, bits, j; 7948275SEric Cheng uint8_t start_tdc, num_tdc = 0; 7953859Sml29623 p_nxge_param_t param_arr; 7963859Sml29623 uint32_t tdc_bitmap[MAX_SIBLINGS]; 7973859Sml29623 int custom_start_tdc[MAX_SIBLINGS]; 7983859Sml29623 int custom_num_tdc[MAX_SIBLINGS]; 7993859Sml29623 uint8_t bad_config = B_FALSE; 8003859Sml29623 int *prop_val; 8013859Sml29623 uint_t prop_len; 8023859Sml29623 char *start_tdc_prop, *num_tdc_prop, *cfg_prop; 8033859Sml29623 8043859Sml29623 start_tdc = 0; 8053859Sml29623 param_arr = nxgep->param_arr; 8063859Sml29623 start_tdc_prop = param_arr[param_txdma_channels_begin].fcode_name; 8073859Sml29623 num_tdc_prop = param_arr[param_txdma_channels].fcode_name; 8083859Sml29623 8093859Sml29623 switch (token) { 8103859Sml29623 case FAIR: 8113859Sml29623 cfg_prop = "fair"; 8123859Sml29623 for (port = 0; port < num_ports; port++) { 8133859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 8146929Smisaki p4_tx_fair[port] : p2_tx_fair[port]; 8153859Sml29623 custom_start_tdc[port] = start_tdc; 8163859Sml29623 start_tdc += custom_num_tdc[port]; 8173859Sml29623 } 8183859Sml29623 break; 8193859Sml29623 8203859Sml29623 case EQUAL: 8213859Sml29623 cfg_prop = "equal"; 8223859Sml29623 for (port = 0; port < num_ports; port++) { 8233859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 8246929Smisaki p4_tx_equal[port] : p2_tx_equal[port]; 8253859Sml29623 custom_start_tdc[port] = start_tdc; 8263859Sml29623 start_tdc += custom_num_tdc[port]; 8273859Sml29623 } 8283859Sml29623 break; 8293859Sml29623 8303859Sml29623 case CUSTOM: 8313859Sml29623 cfg_prop = "custom"; 8323859Sml29623 /* See if it is good config */ 8333859Sml29623 num_tdc = 0; 8343859Sml29623 for (port = 0; port < num_ports; port++) { 8353859Sml29623 ddi_status = ddi_prop_lookup_int_array( 8366929Smisaki DDI_DEV_T_ANY, s_dip[port], 0, start_tdc_prop, 8376929Smisaki &prop_val, &prop_len); 8383859Sml29623 if (ddi_status == DDI_SUCCESS) 8393859Sml29623 custom_start_tdc[port] = *prop_val; 8403859Sml29623 else { 8413859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8426929Smisaki " %s custom start port %d" 8436929Smisaki " read failed ", " txdma-cfg", port)); 8443859Sml29623 bad_config = B_TRUE; 8453859Sml29623 status |= NXGE_DDI_FAILED; 8463859Sml29623 } 8473859Sml29623 8483859Sml29623 if ((custom_start_tdc[port] == -1) || 8496929Smisaki (custom_start_tdc[port] >= 8506929Smisaki NXGE_MAX_RDCS)) { 8513859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8526929Smisaki " %s custom start %d" 8536929Smisaki " out of range %x ", " txdma-cfg", 8546929Smisaki port, custom_start_tdc[port])); 8553859Sml29623 bad_config = B_TRUE; 8563859Sml29623 break; 8573859Sml29623 } 8583859Sml29623 8593859Sml29623 ddi_status = ddi_prop_lookup_int_array( 8606929Smisaki DDI_DEV_T_ANY, s_dip[port], 0, num_tdc_prop, 8616929Smisaki &prop_val, &prop_len); 8623859Sml29623 if (ddi_status == DDI_SUCCESS) 8633859Sml29623 custom_num_tdc[port] = *prop_val; 8643859Sml29623 else { 8653859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8666929Smisaki " %s custom num port %d" 8676929Smisaki " read failed ", " txdma-cfg", port)); 8683859Sml29623 bad_config = B_TRUE; 8693859Sml29623 status |= NXGE_DDI_FAILED; 8703859Sml29623 } 8713859Sml29623 8723859Sml29623 if ((custom_num_tdc[port] == -1) || 8736929Smisaki (custom_num_tdc[port] > 8746929Smisaki NXGE_MAX_TDCS) || 8756929Smisaki ((custom_num_tdc[port] + 8766929Smisaki custom_start_tdc[port]) > 8776929Smisaki NXGE_MAX_TDCS)) { 8783859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8796929Smisaki " %s custom num %d" 8806929Smisaki " out of range %x ", " rxdma-cfg", 8816929Smisaki port, custom_num_tdc[port])); 8823859Sml29623 bad_config = B_TRUE; 8833859Sml29623 break; 8843859Sml29623 } 8853859Sml29623 num_tdc += custom_num_tdc[port]; 8863859Sml29623 if (num_tdc > NXGE_MAX_TDCS) { 8873859Sml29623 bad_config = B_TRUE; 8883859Sml29623 break; 8893859Sml29623 } 8903859Sml29623 tdc_bitmap[port] = 0; 8913859Sml29623 for (bits = 0; 8926929Smisaki bits < custom_num_tdc[port]; bits++) { 8933859Sml29623 tdc_bitmap[port] |= 8946929Smisaki (1 << 8956929Smisaki (bits + custom_start_tdc[port])); 8963859Sml29623 } 8973859Sml29623 8983859Sml29623 } 8993859Sml29623 9003859Sml29623 if (bad_config == B_FALSE) { 9013859Sml29623 /* check for overlap */ 9023859Sml29623 for (port = 0; port < num_ports - 1; port++) { 9033859Sml29623 for (j = port + 1; j < num_ports; j++) { 9043859Sml29623 if (tdc_bitmap[port] & 9056929Smisaki tdc_bitmap[j]) { 9063859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9076929Smisaki " rxdma-cfg" 9086929Smisaki " property custom" 9096929Smisaki " bit overlap" 9106929Smisaki " %d %d ", 9116929Smisaki port, j)); 9123859Sml29623 bad_config = B_TRUE; 9133859Sml29623 break; 9143859Sml29623 } 9153859Sml29623 } 9163859Sml29623 if (bad_config == B_TRUE) 9173859Sml29623 break; 9183859Sml29623 } 9193859Sml29623 } 9203859Sml29623 if (bad_config == B_TRUE) { 9213859Sml29623 /* use default config */ 9223859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9236929Smisaki " txdma-cfg property:" 9246929Smisaki " bad custom config:" " use default")); 9253859Sml29623 9263859Sml29623 for (port = 0; port < num_ports; port++) { 9273859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 9286929Smisaki p4_tx_fair[port] : p2_tx_fair[port]; 9293859Sml29623 custom_start_tdc[port] = start_tdc; 9303859Sml29623 start_tdc += custom_num_tdc[port]; 9313859Sml29623 } 9323859Sml29623 } 9333859Sml29623 break; 9343859Sml29623 9353859Sml29623 default: 9363859Sml29623 /* use default config */ 9373859Sml29623 cfg_prop = "fair"; 9383859Sml29623 for (port = 0; port < num_ports; port++) { 9393859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 9406929Smisaki p4_tx_fair[port] : p2_tx_fair[port]; 9413859Sml29623 custom_start_tdc[port] = start_tdc; 9423859Sml29623 start_tdc += custom_num_tdc[port]; 9433859Sml29623 } 9443859Sml29623 break; 9453859Sml29623 } 9463859Sml29623 9473859Sml29623 /* Now Update the tx properties */ 9483859Sml29623 for (port = 0; port < num_ports; port++) { 9493859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9506929Smisaki " update property txdma-cfg with %s ", cfg_prop)); 9513859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 9526929Smisaki "txdma-cfg", cfg_prop); 9533859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9543859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9556929Smisaki " property txdma-cfg is not updating to %s", 9566929Smisaki cfg_prop)); 9573859Sml29623 status |= NXGE_DDI_FAILED; 9583859Sml29623 } 9593859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 9606929Smisaki num_tdc_prop, custom_num_tdc[port])); 9613859Sml29623 9623859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 9636929Smisaki num_tdc_prop, custom_num_tdc[port]); 9643859Sml29623 9653859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9663859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 9676929Smisaki " property %s not updating with %d", 9686929Smisaki num_tdc_prop, 9696929Smisaki custom_num_tdc[port])); 9703859Sml29623 status |= NXGE_DDI_FAILED; 9713859Sml29623 } 9723859Sml29623 9733859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 9746929Smisaki start_tdc_prop, custom_start_tdc[port])); 9753859Sml29623 9763859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 9776929Smisaki start_tdc_prop, custom_start_tdc[port]); 9783859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9793859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 9806929Smisaki " property %s not updating with %d ", 9816929Smisaki start_tdc_prop, custom_start_tdc[port])); 9823859Sml29623 status |= NXGE_DDI_FAILED; 9833859Sml29623 } 9843859Sml29623 } 9853859Sml29623 if (status & NXGE_DDI_FAILED) 9863859Sml29623 status |= NXGE_ERROR; 9873859Sml29623 return (status); 9883859Sml29623 } 9893859Sml29623 9903859Sml29623 static nxge_status_t 9913859Sml29623 nxge_update_cfg_properties(p_nxge_t nxgep, uint32_t flags, 9923859Sml29623 config_token_t token, dev_info_t *s_dip[]) 9933859Sml29623 { 9943859Sml29623 nxge_status_t status = NXGE_OK; 9953859Sml29623 9963859Sml29623 switch (flags) { 9973859Sml29623 case COMMON_TXDMA_CFG: 9983859Sml29623 if (nxge_dma_obp_props_only == 0) 9993859Sml29623 status = nxge_update_txdma_properties(nxgep, 10006929Smisaki token, s_dip); 10013859Sml29623 break; 10023859Sml29623 case COMMON_RXDMA_CFG: 10033859Sml29623 if (nxge_dma_obp_props_only == 0) 10043859Sml29623 status = nxge_update_rxdma_properties(nxgep, 10056929Smisaki token, s_dip); 10063859Sml29623 10073859Sml29623 break; 10083859Sml29623 case COMMON_RXDMA_GRP_CFG: 10093859Sml29623 status = nxge_update_rxdma_grp_properties(nxgep, 10106929Smisaki token, s_dip); 10113859Sml29623 break; 10123859Sml29623 default: 10133859Sml29623 return (NXGE_ERROR); 10143859Sml29623 } 10153859Sml29623 return (status); 10163859Sml29623 } 10173859Sml29623 10183859Sml29623 /* 10193859Sml29623 * verify consistence. 10203859Sml29623 * (May require publishing the properties on all the ports. 10213859Sml29623 * 10223859Sml29623 * What if properties are published on function 0 device only? 10233859Sml29623 * 10243859Sml29623 * 10253859Sml29623 * rxdma-cfg, txdma-cfg, rxdma-grp-cfg (required ) 10263859Sml29623 * What about class configs? 10273859Sml29623 * 10283859Sml29623 * If consistent, update the property on all the siblings. 10293859Sml29623 * set a flag on hardware shared register 10303859Sml29623 * The rest of the siblings will check the flag 10313859Sml29623 * if the flag is set, they will use the updated property 10323859Sml29623 * without doing any validation. 10333859Sml29623 */ 10343859Sml29623 10353859Sml29623 nxge_status_t 10363859Sml29623 nxge_cfg_verify_set_classify_prop(p_nxge_t nxgep, char *prop, 10373859Sml29623 uint64_t known_cfg, uint32_t override, dev_info_t *c_dip[]) 10383859Sml29623 { 10393859Sml29623 nxge_status_t status = NXGE_OK; 10403859Sml29623 int ddi_status = DDI_SUCCESS; 10413859Sml29623 int i = 0, found = 0, update_prop = B_TRUE; 10423859Sml29623 int *cfg_val; 10433859Sml29623 uint_t new_value, cfg_value[MAX_SIBLINGS]; 10443859Sml29623 uint_t prop_len; 10453859Sml29623 uint_t known_cfg_value; 10463859Sml29623 10473859Sml29623 known_cfg_value = (uint_t)known_cfg; 10483859Sml29623 10493859Sml29623 if (override == B_TRUE) { 10503859Sml29623 new_value = known_cfg_value; 10513859Sml29623 for (i = 0; i < nxgep->nports; i++) { 10523859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, 10536929Smisaki c_dip[i], prop, new_value); 10543859Sml29623 #ifdef NXGE_DEBUG_ERROR 10553859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 10563859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 10576929Smisaki " property %s failed update ", prop)); 10583859Sml29623 #endif 10593859Sml29623 } 10603859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 10613859Sml29623 return (NXGE_ERROR | NXGE_DDI_FAILED); 10623859Sml29623 } 10633859Sml29623 for (i = 0; i < nxgep->nports; i++) { 10643859Sml29623 cfg_value[i] = known_cfg_value; 10653859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, c_dip[i], 0, 10666929Smisaki prop, &cfg_val, 10676929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 10683859Sml29623 cfg_value[i] = *cfg_val; 10693859Sml29623 ddi_prop_free(cfg_val); 10703859Sml29623 found++; 10713859Sml29623 } 10723859Sml29623 } 10733859Sml29623 10743859Sml29623 if (found != i) { 10753859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10766929Smisaki " property %s not specified on all ports", prop)); 10773859Sml29623 if (found == 0) { 10783859Sml29623 /* not specified: Use default */ 10793859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10806929Smisaki " property %s not specified on any port:" 10816929Smisaki " Using default", prop)); 10823859Sml29623 new_value = known_cfg_value; 10833859Sml29623 } else { 10843859Sml29623 /* specified on some */ 10853859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10866929Smisaki " property %s not specified" 10876929Smisaki " on some ports: Using default", prop)); 10883859Sml29623 /* ? use p0 value instead ? */ 10893859Sml29623 new_value = known_cfg_value; 10903859Sml29623 } 10913859Sml29623 } else { 10923859Sml29623 /* check type and consistence */ 10933859Sml29623 /* found on all devices */ 10943859Sml29623 for (i = 1; i < found; i++) { 10953859Sml29623 if (cfg_value[i] != cfg_value[i - 1]) { 10963859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10976929Smisaki " property %s inconsistent:" 10986929Smisaki " Using default", prop)); 10993859Sml29623 new_value = known_cfg_value; 11003859Sml29623 break; 11013859Sml29623 } 11023859Sml29623 /* 11033859Sml29623 * Found on all the ports and consistent. Nothing to 11043859Sml29623 * do. 11053859Sml29623 */ 11063859Sml29623 update_prop = B_FALSE; 11073859Sml29623 } 11083859Sml29623 } 11093859Sml29623 11103859Sml29623 if (update_prop == B_TRUE) { 11113859Sml29623 for (i = 0; i < nxgep->nports; i++) { 11123859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, 11136929Smisaki c_dip[i], prop, new_value); 11143859Sml29623 #ifdef NXGE_DEBUG_ERROR 11153859Sml29623 if (ddi_status != DDI_SUCCESS) 11163859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 11176929Smisaki " property %s not updating with %d" 11186929Smisaki " Using default", 11196929Smisaki prop, new_value)); 11203859Sml29623 #endif 11213859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 11223859Sml29623 status |= NXGE_DDI_FAILED; 11233859Sml29623 } 11243859Sml29623 } 11253859Sml29623 if (status & NXGE_DDI_FAILED) 11263859Sml29623 status |= NXGE_ERROR; 11273859Sml29623 11283859Sml29623 return (status); 11293859Sml29623 } 11303859Sml29623 11313859Sml29623 static uint64_t 11323859Sml29623 nxge_class_get_known_cfg(p_nxge_t nxgep, int class_prop, int rx_quick_cfg) 11333859Sml29623 { 11343859Sml29623 int start_prop; 11353859Sml29623 uint64_t cfg_value; 11363859Sml29623 p_nxge_param_t param_arr; 11373859Sml29623 11383859Sml29623 param_arr = nxgep->param_arr; 11393859Sml29623 cfg_value = param_arr[class_prop].value; 11403859Sml29623 start_prop = param_h1_init_value; 11413859Sml29623 11423859Sml29623 /* update the properties per quick config */ 11433859Sml29623 switch (rx_quick_cfg) { 11443859Sml29623 case CFG_L3_WEB: 11453859Sml29623 case CFG_L3_DISTRIBUTE: 11463859Sml29623 cfg_value = nxge_classify_get_cfg_value(nxgep, 11476929Smisaki rx_quick_cfg, class_prop - start_prop); 11483859Sml29623 break; 11493859Sml29623 default: 11503859Sml29623 cfg_value = param_arr[class_prop].value; 11513859Sml29623 break; 11523859Sml29623 } 11533859Sml29623 return (cfg_value); 11543859Sml29623 } 11553859Sml29623 11563859Sml29623 static nxge_status_t 11573859Sml29623 nxge_cfg_verify_set_classify(p_nxge_t nxgep, dev_info_t *c_dip[]) 11583859Sml29623 { 11593859Sml29623 nxge_status_t status = NXGE_OK; 11603859Sml29623 int rx_quick_cfg, class_prop, start_prop, end_prop; 11613859Sml29623 char *prop_name; 11623859Sml29623 int override = B_TRUE; 11633859Sml29623 uint64_t cfg_value; 11643859Sml29623 p_nxge_param_t param_arr; 11653859Sml29623 11663859Sml29623 param_arr = nxgep->param_arr; 11673859Sml29623 rx_quick_cfg = param_arr[param_rx_quick_cfg].value; 11683859Sml29623 start_prop = param_h1_init_value; 11693859Sml29623 end_prop = param_class_opt_ipv6_sctp; 11703859Sml29623 11713859Sml29623 /* update the properties per quick config */ 11723859Sml29623 if (rx_quick_cfg == CFG_NOT_SPECIFIED) 11733859Sml29623 override = B_FALSE; 11743859Sml29623 11753859Sml29623 /* 11763859Sml29623 * these parameter affect the classification outcome. 11773859Sml29623 * these parameters are used to configure the Flow key and 11783859Sml29623 * the TCAM key for each of the IP classes. 11793859Sml29623 * Included here are also the H1 and H2 initial values 11803859Sml29623 * which affect the distribution as well as final hash value 11813859Sml29623 * (hence the offset into RDC table and FCRAM bucket location) 11823859Sml29623 * 11833859Sml29623 */ 11843859Sml29623 for (class_prop = start_prop; class_prop <= end_prop; class_prop++) { 11853859Sml29623 prop_name = param_arr[class_prop].fcode_name; 11863859Sml29623 cfg_value = nxge_class_get_known_cfg(nxgep, 11876929Smisaki class_prop, rx_quick_cfg); 11883859Sml29623 status = nxge_cfg_verify_set_classify_prop(nxgep, prop_name, 11896929Smisaki cfg_value, override, c_dip); 11903859Sml29623 } 11913859Sml29623 11923859Sml29623 /* 11933859Sml29623 * these properties do not affect the actual classification outcome. 11943859Sml29623 * used to enable/disable or tune the fflp hardware 11953859Sml29623 * 11963859Sml29623 * fcram_access_ratio, tcam_access_ratio, tcam_enable, llc_snap_enable 11973859Sml29623 * 11983859Sml29623 */ 11993859Sml29623 override = B_FALSE; 12003859Sml29623 for (class_prop = param_fcram_access_ratio; 12016929Smisaki class_prop <= param_llc_snap_enable; class_prop++) { 12023859Sml29623 prop_name = param_arr[class_prop].fcode_name; 12033859Sml29623 cfg_value = param_arr[class_prop].value; 12043859Sml29623 status = nxge_cfg_verify_set_classify_prop(nxgep, prop_name, 12056929Smisaki cfg_value, override, c_dip); 12063859Sml29623 } 12073859Sml29623 12083859Sml29623 return (status); 12093859Sml29623 } 12103859Sml29623 12113859Sml29623 nxge_status_t 12123859Sml29623 nxge_cfg_verify_set(p_nxge_t nxgep, uint32_t flag) 12133859Sml29623 { 12143859Sml29623 nxge_status_t status = NXGE_OK; 12153859Sml29623 int i = 0, found = 0; 12163859Sml29623 int num_siblings; 12173859Sml29623 dev_info_t *c_dip[MAX_SIBLINGS + 1]; 12183859Sml29623 char *prop_val[MAX_SIBLINGS]; 12193859Sml29623 config_token_t c_token[MAX_SIBLINGS]; 12203859Sml29623 char *prop; 12213859Sml29623 12223859Sml29623 if (nxge_dma_obp_props_only) 12233859Sml29623 return (NXGE_OK); 12243859Sml29623 12253859Sml29623 num_siblings = 0; 12263859Sml29623 c_dip[num_siblings] = ddi_get_child(nxgep->p_dip); 12273859Sml29623 while (c_dip[num_siblings]) { 12283859Sml29623 c_dip[num_siblings + 1] = 12296929Smisaki ddi_get_next_sibling(c_dip[num_siblings]); 12303859Sml29623 num_siblings++; 12313859Sml29623 } 12323859Sml29623 12333859Sml29623 switch (flag) { 12343859Sml29623 case COMMON_TXDMA_CFG: 12353859Sml29623 prop = "txdma-cfg"; 12363859Sml29623 break; 12373859Sml29623 case COMMON_RXDMA_CFG: 12383859Sml29623 prop = "rxdma-cfg"; 12393859Sml29623 break; 12403859Sml29623 case COMMON_RXDMA_GRP_CFG: 12413859Sml29623 prop = "rxdma-grp-cfg"; 12423859Sml29623 break; 12433859Sml29623 case COMMON_CLASS_CFG: 12443859Sml29623 status = nxge_cfg_verify_set_classify(nxgep, c_dip); 12453859Sml29623 return (status); 12463859Sml29623 default: 12473859Sml29623 return (NXGE_ERROR); 12483859Sml29623 } 12493859Sml29623 12503859Sml29623 i = 0; 12513859Sml29623 while (i < num_siblings) { 12523859Sml29623 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, c_dip[i], 0, prop, 12536929Smisaki (char **)&prop_val[i]) == DDI_PROP_SUCCESS) { 12543859Sml29623 c_token[i] = nxge_get_config_token(prop_val[i]); 12553859Sml29623 ddi_prop_free(prop_val[i]); 12563859Sml29623 found++; 12573859Sml29623 } else 12583859Sml29623 c_token[i] = CONFIG_TOKEN_NONE; 12593859Sml29623 i++; 12603859Sml29623 } 12613859Sml29623 12623859Sml29623 if (found != i) { 12633859Sml29623 if (found == 0) { 12643859Sml29623 /* not specified: Use default */ 12653859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12666929Smisaki " property %s not specified on any port:" 12676929Smisaki " Using default", prop)); 12683859Sml29623 12693859Sml29623 status = nxge_update_cfg_properties(nxgep, 12706929Smisaki flag, FAIR, c_dip); 12713859Sml29623 return (status); 12723859Sml29623 } else { 12733859Sml29623 /* 12743859Sml29623 * if the convention is to use function 0 device then 12753859Sml29623 * populate the other devices with this configuration. 12763859Sml29623 * 12773859Sml29623 * The other alternative is to use the default config. 12783859Sml29623 */ 12793859Sml29623 /* not specified: Use default */ 12803859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12816929Smisaki " property %s not specified on some ports:" 12826929Smisaki " Using default", prop)); 12833859Sml29623 status = nxge_update_cfg_properties(nxgep, 12846929Smisaki flag, FAIR, c_dip); 12853859Sml29623 return (status); 12863859Sml29623 } 12873859Sml29623 } 12883859Sml29623 12893859Sml29623 /* check type and consistence */ 12903859Sml29623 /* found on all devices */ 12913859Sml29623 for (i = 1; i < found; i++) { 12923859Sml29623 if (c_token[i] != c_token[i - 1]) { 12933859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12946929Smisaki " property %s inconsistent:" 12956929Smisaki " Using default", prop)); 12963859Sml29623 status = nxge_update_cfg_properties(nxgep, 12976929Smisaki flag, FAIR, c_dip); 12983859Sml29623 return (status); 12993859Sml29623 } 13003859Sml29623 } 13013859Sml29623 13023859Sml29623 /* 13033859Sml29623 * Found on all the ports check if it is custom configuration. if 13043859Sml29623 * custom, then verify consistence 13053859Sml29623 * 13063859Sml29623 * finally create soft properties 13073859Sml29623 */ 13083859Sml29623 status = nxge_update_cfg_properties(nxgep, flag, c_token[0], c_dip); 13093859Sml29623 return (status); 13103859Sml29623 } 13113859Sml29623 13123859Sml29623 nxge_status_t 13133859Sml29623 nxge_cfg_verify_set_quick_config(p_nxge_t nxgep) 13143859Sml29623 { 13153859Sml29623 nxge_status_t status = NXGE_OK; 13163859Sml29623 int ddi_status = DDI_SUCCESS; 13173859Sml29623 char *prop_val; 13183859Sml29623 char *rx_prop; 13193859Sml29623 char *prop; 13203859Sml29623 uint32_t cfg_value = CFG_NOT_SPECIFIED; 13213859Sml29623 p_nxge_param_t param_arr; 13223859Sml29623 13233859Sml29623 param_arr = nxgep->param_arr; 13243859Sml29623 rx_prop = param_arr[param_rx_quick_cfg].fcode_name; 13253859Sml29623 13263859Sml29623 prop = "rx-quick-cfg"; 13273859Sml29623 13283859Sml29623 /* 13293859Sml29623 * good value are 13303859Sml29623 * 13313859Sml29623 * "web-server" "generic-server" "l3-classify" "flow-classify" 13323859Sml29623 */ 13333859Sml29623 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, nxgep->dip, 0, 13346929Smisaki prop, (char **)&prop_val) != DDI_PROP_SUCCESS) { 13353859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 13366929Smisaki " property %s not specified: using default ", prop)); 13373859Sml29623 cfg_value = CFG_NOT_SPECIFIED; 13383859Sml29623 } else { 13393859Sml29623 cfg_value = CFG_L3_DISTRIBUTE; 13403859Sml29623 if (strncmp("web-server", (caddr_t)prop_val, 8) == 0) { 13413859Sml29623 cfg_value = CFG_L3_WEB; 13423859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 13436929Smisaki " %s: web server ", prop)); 13443859Sml29623 } 13453859Sml29623 if (strncmp("generic-server", (caddr_t)prop_val, 8) == 0) { 13463859Sml29623 cfg_value = CFG_L3_DISTRIBUTE; 13473859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 13486929Smisaki " %s: distribute ", prop)); 13493859Sml29623 } 13503859Sml29623 /* more */ 13513859Sml29623 ddi_prop_free(prop_val); 13523859Sml29623 } 13533859Sml29623 13543859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 13556929Smisaki rx_prop, cfg_value); 13563859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 13573859Sml29623 status |= NXGE_DDI_FAILED; 13583859Sml29623 13593859Sml29623 /* now handle specified cases: */ 13603859Sml29623 if (status & NXGE_DDI_FAILED) 13613859Sml29623 status |= NXGE_ERROR; 13623859Sml29623 return (status); 13633859Sml29623 } 13643859Sml29623 13656835Syc148097 /* 13666835Syc148097 * Device properties adv-autoneg-cap etc are defined by FWARC 13676835Syc148097 * http://sac.sfbay/FWARC/2002/345/20020610_asif.haswarey 13686835Syc148097 */ 13693859Sml29623 static void 13703859Sml29623 nxge_use_cfg_link_cfg(p_nxge_t nxgep) 13713859Sml29623 { 13723859Sml29623 int *prop_val; 13733859Sml29623 uint_t prop_len; 13743859Sml29623 dev_info_t *dip; 13753859Sml29623 int speed; 13763859Sml29623 int duplex; 13773859Sml29623 int adv_autoneg_cap; 13783859Sml29623 int adv_10gfdx_cap; 13793859Sml29623 int adv_10ghdx_cap; 13803859Sml29623 int adv_1000fdx_cap; 13813859Sml29623 int adv_1000hdx_cap; 13823859Sml29623 int adv_100fdx_cap; 13833859Sml29623 int adv_100hdx_cap; 13843859Sml29623 int adv_10fdx_cap; 13853859Sml29623 int adv_10hdx_cap; 13863859Sml29623 int status = DDI_SUCCESS; 13873859Sml29623 13883859Sml29623 dip = nxgep->dip; 13893859Sml29623 13903859Sml29623 /* 13913859Sml29623 * first find out the card type and the supported link speeds and 13923859Sml29623 * features 13933859Sml29623 */ 13943859Sml29623 /* add code for card type */ 13953859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-autoneg-cap", 13966929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 13973859Sml29623 ddi_prop_free(prop_val); 13983859Sml29623 return; 13993859Sml29623 } 14003859Sml29623 14013859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10gfdx-cap", 14026929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14033859Sml29623 ddi_prop_free(prop_val); 14043859Sml29623 return; 14053859Sml29623 } 14063859Sml29623 14073859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-1000hdx-cap", 14086929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14093859Sml29623 ddi_prop_free(prop_val); 14103859Sml29623 return; 14113859Sml29623 } 14123859Sml29623 14133859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-1000fdx-cap", 14146929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14153859Sml29623 ddi_prop_free(prop_val); 14163859Sml29623 return; 14173859Sml29623 } 14183859Sml29623 14193859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-100fdx-cap", 14206929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14213859Sml29623 ddi_prop_free(prop_val); 14223859Sml29623 return; 14233859Sml29623 } 14243859Sml29623 14253859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-100hdx-cap", 14266929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14273859Sml29623 ddi_prop_free(prop_val); 14283859Sml29623 return; 14293859Sml29623 } 14303859Sml29623 14313859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10fdx-cap", 14326929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14333859Sml29623 ddi_prop_free(prop_val); 14343859Sml29623 return; 14353859Sml29623 } 14363859Sml29623 14373859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10hdx-cap", 14386929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14393859Sml29623 ddi_prop_free(prop_val); 14403859Sml29623 return; 14413859Sml29623 } 14423859Sml29623 14433859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, "speed", 14446929Smisaki (uchar_t **)&prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14453859Sml29623 if (strncmp("10000", (caddr_t)prop_val, 14466929Smisaki (size_t)prop_len) == 0) { 14473859Sml29623 speed = 10000; 14483859Sml29623 } else if (strncmp("1000", (caddr_t)prop_val, 14496929Smisaki (size_t)prop_len) == 0) { 14503859Sml29623 speed = 1000; 14513859Sml29623 } else if (strncmp("100", (caddr_t)prop_val, 14526929Smisaki (size_t)prop_len) == 0) { 14533859Sml29623 speed = 100; 14543859Sml29623 } else if (strncmp("10", (caddr_t)prop_val, 14556929Smisaki (size_t)prop_len) == 0) { 14563859Sml29623 speed = 10; 14573859Sml29623 } else if (strncmp("auto", (caddr_t)prop_val, 14586929Smisaki (size_t)prop_len) == 0) { 14593859Sml29623 speed = 0; 14603859Sml29623 } else { 14613859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_NOTE, 14626929Smisaki "speed property is invalid reverting to auto")); 14633859Sml29623 speed = 0; 14643859Sml29623 } 14653859Sml29623 ddi_prop_free(prop_val); 14663859Sml29623 } else 14673859Sml29623 speed = 0; 14683859Sml29623 14693859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, "duplex", 14706929Smisaki (uchar_t **)&prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14713859Sml29623 if (strncmp("full", (caddr_t)prop_val, 14726929Smisaki (size_t)prop_len) == 0) { 14733859Sml29623 duplex = 2; 14743859Sml29623 } else if (strncmp("half", (caddr_t)prop_val, 14756929Smisaki (size_t)prop_len) == 0) { 14763859Sml29623 duplex = 1; 14773859Sml29623 } else if (strncmp("auto", (caddr_t)prop_val, 14786929Smisaki (size_t)prop_len) == 0) { 14793859Sml29623 duplex = 0; 14803859Sml29623 } else { 14813859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_NOTE, 14826929Smisaki "duplex property is invalid" 14836929Smisaki " reverting to auto")); 14843859Sml29623 duplex = 0; 14853859Sml29623 } 14863859Sml29623 ddi_prop_free(prop_val); 14873859Sml29623 } else 14883859Sml29623 duplex = 0; 14893859Sml29623 14906835Syc148097 /* speed == 0 or duplex == 0 means auto negotiation. */ 14913859Sml29623 adv_autoneg_cap = (speed == 0) || (duplex == 0); 14923859Sml29623 if (adv_autoneg_cap == 0) { 14933859Sml29623 adv_10gfdx_cap = ((speed == 10000) && (duplex == 2)); 14943859Sml29623 adv_10ghdx_cap = adv_10gfdx_cap; 14953859Sml29623 adv_10ghdx_cap |= ((speed == 10000) && (duplex == 1)); 14963859Sml29623 adv_1000fdx_cap = adv_10ghdx_cap; 14973859Sml29623 adv_1000fdx_cap |= ((speed == 1000) && (duplex == 2)); 14983859Sml29623 adv_1000hdx_cap = adv_1000fdx_cap; 14993859Sml29623 adv_1000hdx_cap |= ((speed == 1000) && (duplex == 1)); 15003859Sml29623 adv_100fdx_cap = adv_1000hdx_cap; 15013859Sml29623 adv_100fdx_cap |= ((speed == 100) && (duplex == 2)); 15023859Sml29623 adv_100hdx_cap = adv_100fdx_cap; 15033859Sml29623 adv_100hdx_cap |= ((speed == 100) && (duplex == 1)); 15043859Sml29623 adv_10fdx_cap = adv_100hdx_cap; 15053859Sml29623 adv_10fdx_cap |= ((speed == 10) && (duplex == 2)); 15063859Sml29623 adv_10hdx_cap = adv_10fdx_cap; 15073859Sml29623 adv_10hdx_cap |= ((speed == 10) && (duplex == 1)); 15083859Sml29623 } else if (speed == 0) { 15093859Sml29623 adv_10gfdx_cap = (duplex == 2); 15103859Sml29623 adv_10ghdx_cap = (duplex == 1); 15113859Sml29623 adv_1000fdx_cap = (duplex == 2); 15123859Sml29623 adv_1000hdx_cap = (duplex == 1); 15133859Sml29623 adv_100fdx_cap = (duplex == 2); 15143859Sml29623 adv_100hdx_cap = (duplex == 1); 15153859Sml29623 adv_10fdx_cap = (duplex == 2); 15163859Sml29623 adv_10hdx_cap = (duplex == 1); 15173859Sml29623 } 15183859Sml29623 if (duplex == 0) { 15193859Sml29623 adv_10gfdx_cap = (speed == 0); 15203859Sml29623 adv_10gfdx_cap |= (speed == 10000); 15213859Sml29623 adv_10ghdx_cap = adv_10gfdx_cap; 15223859Sml29623 adv_10ghdx_cap |= (speed == 10000); 15233859Sml29623 adv_1000fdx_cap = adv_10ghdx_cap; 15243859Sml29623 adv_1000fdx_cap |= (speed == 1000); 15253859Sml29623 adv_1000hdx_cap = adv_1000fdx_cap; 15263859Sml29623 adv_1000hdx_cap |= (speed == 1000); 15273859Sml29623 adv_100fdx_cap = adv_1000hdx_cap; 15283859Sml29623 adv_100fdx_cap |= (speed == 100); 15293859Sml29623 adv_100hdx_cap = adv_100fdx_cap; 15303859Sml29623 adv_100hdx_cap |= (speed == 100); 15313859Sml29623 adv_10fdx_cap = adv_100hdx_cap; 15323859Sml29623 adv_10fdx_cap |= (speed == 10); 15333859Sml29623 adv_10hdx_cap = adv_10fdx_cap; 15343859Sml29623 adv_10hdx_cap |= (speed == 10); 15353859Sml29623 } 15363859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15376929Smisaki "adv-autoneg-cap", &adv_autoneg_cap, 1); 15383859Sml29623 if (status) 15393859Sml29623 return; 15403859Sml29623 15413859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15426929Smisaki "adv-10gfdx-cap", &adv_10gfdx_cap, 1); 15433859Sml29623 if (status) 15443859Sml29623 goto nxge_map_myargs_to_gmii_fail1; 15453859Sml29623 15463859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15476929Smisaki "adv-10ghdx-cap", &adv_10ghdx_cap, 1); 15483859Sml29623 if (status) 15493859Sml29623 goto nxge_map_myargs_to_gmii_fail2; 15503859Sml29623 15513859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15526929Smisaki "adv-1000fdx-cap", &adv_1000fdx_cap, 1); 15533859Sml29623 if (status) 15543859Sml29623 goto nxge_map_myargs_to_gmii_fail3; 15553859Sml29623 15563859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15576929Smisaki "adv-1000hdx-cap", &adv_1000hdx_cap, 1); 15583859Sml29623 if (status) 15593859Sml29623 goto nxge_map_myargs_to_gmii_fail4; 15603859Sml29623 15613859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15626929Smisaki "adv-100fdx-cap", &adv_100fdx_cap, 1); 15633859Sml29623 if (status) 15643859Sml29623 goto nxge_map_myargs_to_gmii_fail5; 15653859Sml29623 15663859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15676929Smisaki "adv-100hdx-cap", &adv_100hdx_cap, 1); 15683859Sml29623 if (status) 15693859Sml29623 goto nxge_map_myargs_to_gmii_fail6; 15703859Sml29623 15713859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15726929Smisaki "adv-10fdx-cap", &adv_10fdx_cap, 1); 15733859Sml29623 if (status) 15743859Sml29623 goto nxge_map_myargs_to_gmii_fail7; 15753859Sml29623 15763859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15776929Smisaki "adv-10hdx-cap", &adv_10hdx_cap, 1); 15783859Sml29623 if (status) 15793859Sml29623 goto nxge_map_myargs_to_gmii_fail8; 15803859Sml29623 15813859Sml29623 return; 15823859Sml29623 15833859Sml29623 nxge_map_myargs_to_gmii_fail9: 15843859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10hdx-cap"); 15853859Sml29623 15863859Sml29623 nxge_map_myargs_to_gmii_fail8: 15873859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10fdx-cap"); 15883859Sml29623 15893859Sml29623 nxge_map_myargs_to_gmii_fail7: 15903859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-100hdx-cap"); 15913859Sml29623 15923859Sml29623 nxge_map_myargs_to_gmii_fail6: 15933859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-100fdx-cap"); 15943859Sml29623 15953859Sml29623 nxge_map_myargs_to_gmii_fail5: 15963859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-1000hdx-cap"); 15973859Sml29623 15983859Sml29623 nxge_map_myargs_to_gmii_fail4: 15993859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-1000fdx-cap"); 16003859Sml29623 16013859Sml29623 nxge_map_myargs_to_gmii_fail3: 16023859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10ghdx-cap"); 16033859Sml29623 16043859Sml29623 nxge_map_myargs_to_gmii_fail2: 16053859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10gfdx-cap"); 16063859Sml29623 16073859Sml29623 nxge_map_myargs_to_gmii_fail1: 16083859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-autoneg-cap"); 16093859Sml29623 } 16103859Sml29623 16113859Sml29623 nxge_status_t 16123859Sml29623 nxge_get_config_properties(p_nxge_t nxgep) 16133859Sml29623 { 16143859Sml29623 nxge_status_t status = NXGE_OK; 16153859Sml29623 p_nxge_hw_list_t hw_p; 16163859Sml29623 16173859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, " ==> nxge_get_config_properties")); 16183859Sml29623 16193859Sml29623 if ((hw_p = nxgep->nxge_hw_p) == NULL) { 16203859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 16216929Smisaki " nxge_get_config_properties:" 16226929Smisaki " common hardware not set", nxgep->niu_type)); 16233859Sml29623 return (NXGE_ERROR); 16243859Sml29623 } 16253859Sml29623 16263859Sml29623 /* 16273859Sml29623 * Get info on how many ports Neptune card has. 16283859Sml29623 */ 16294977Sraghus nxgep->nports = nxge_get_nports(nxgep); 16304732Sdavemq if (nxgep->nports <= 0) { 16314732Sdavemq NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 16324732Sdavemq "<==nxge_get_config_properties: Invalid Neptune type 0x%x", 16334732Sdavemq nxgep->niu_type)); 16344732Sdavemq return (NXGE_ERROR); 16354732Sdavemq } 16364732Sdavemq nxgep->classifier.tcam_size = TCAM_NIU_TCAM_MAX_ENTRY; 16374977Sraghus if (NXGE_IS_VALID_NEPTUNE_TYPE(nxgep)) { 16384977Sraghus nxgep->classifier.tcam_size = TCAM_NXGE_TCAM_MAX_ENTRY; 16394977Sraghus } 16404732Sdavemq if (nxgep->function_num >= nxgep->nports) { 16414732Sdavemq return (NXGE_ERROR); 16423859Sml29623 } 16433859Sml29623 16443859Sml29623 status = nxge_get_mac_addr_properties(nxgep); 16453859Sml29623 if (status != NXGE_OK) 16463859Sml29623 return (NXGE_ERROR); 16473859Sml29623 16483859Sml29623 /* 16493859Sml29623 * read the configuration type. If none is specified, used default. 16503859Sml29623 * Config types: equal: (default) DMA channels, RDC groups, TCAM, FCRAM 16513859Sml29623 * are shared equally across all the ports. 16523859Sml29623 * 16533859Sml29623 * Fair: DMA channels, RDC groups, TCAM, FCRAM are shared proportional 16543859Sml29623 * to the port speed. 16553859Sml29623 * 16563859Sml29623 * 16573859Sml29623 * custom: DMA channels, RDC groups, TCAM, FCRAM partition is 16583859Sml29623 * specified in nxge.conf. Need to read each parameter and set 16593859Sml29623 * up the parameters in nxge structures. 16603859Sml29623 * 16613859Sml29623 */ 16623859Sml29623 switch (nxgep->niu_type) { 16633859Sml29623 case N2_NIU: 16643859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 16656929Smisaki " ==> nxge_get_config_properties: N2")); 16663859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 16673859Sml29623 if ((hw_p->flags & COMMON_CFG_VALID) != 16686929Smisaki COMMON_CFG_VALID) { 16693859Sml29623 status = nxge_cfg_verify_set(nxgep, 16706929Smisaki COMMON_RXDMA_GRP_CFG); 16713859Sml29623 status = nxge_cfg_verify_set(nxgep, 16726929Smisaki COMMON_CLASS_CFG); 16733859Sml29623 hw_p->flags |= COMMON_CFG_VALID; 16743859Sml29623 } 16753859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 16763859Sml29623 status = nxge_use_cfg_n2niu_properties(nxgep); 16773859Sml29623 break; 16784732Sdavemq default: 16794977Sraghus if (!NXGE_IS_VALID_NEPTUNE_TYPE(nxgep)) { 16804732Sdavemq NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 16814732Sdavemq " nxge_get_config_properties:" 16824732Sdavemq " unknown NIU type 0x%x", nxgep->niu_type)); 16834732Sdavemq return (NXGE_ERROR); 16844732Sdavemq } 16854732Sdavemq 16863859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 16876929Smisaki " ==> nxge_get_config_properties: Neptune")); 16883859Sml29623 status = nxge_cfg_verify_set_quick_config(nxgep); 16893859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 16903859Sml29623 if ((hw_p->flags & COMMON_CFG_VALID) != 16916929Smisaki COMMON_CFG_VALID) { 16923859Sml29623 status = nxge_cfg_verify_set(nxgep, 16936929Smisaki COMMON_TXDMA_CFG); 16943859Sml29623 status = nxge_cfg_verify_set(nxgep, 16956929Smisaki COMMON_RXDMA_CFG); 16963859Sml29623 status = nxge_cfg_verify_set(nxgep, 16976929Smisaki COMMON_RXDMA_GRP_CFG); 16983859Sml29623 status = nxge_cfg_verify_set(nxgep, 16996929Smisaki COMMON_CLASS_CFG); 17003859Sml29623 hw_p->flags |= COMMON_CFG_VALID; 17013859Sml29623 } 17023859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 17033859Sml29623 nxge_use_cfg_neptune_properties(nxgep); 17043859Sml29623 status = NXGE_OK; 17053859Sml29623 break; 17063859Sml29623 } 17073859Sml29623 17086003Sml29623 /* 17096003Sml29623 * Get the software LSO enable flag property from the 17106003Sml29623 * driver configuration file (nxge.conf). 17116003Sml29623 * This flag will be set to disable (0) if this property 17126003Sml29623 * does not exist. 17136003Sml29623 */ 17146003Sml29623 nxgep->soft_lso_enable = ddi_prop_get_int(DDI_DEV_T_ANY, nxgep->dip, 17156003Sml29623 DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "soft-lso-enable", 0); 17166003Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 17176003Sml29623 "nxge_get_config_properties: software lso %d\n", 17186003Sml29623 nxgep->soft_lso_enable)); 17196003Sml29623 17203859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, " <== nxge_get_config_properties")); 17213859Sml29623 return (status); 17223859Sml29623 } 17233859Sml29623 17243859Sml29623 static nxge_status_t 17253859Sml29623 nxge_use_cfg_n2niu_properties(p_nxge_t nxgep) 17263859Sml29623 { 17273859Sml29623 nxge_status_t status = NXGE_OK; 17283859Sml29623 17293859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_n2niu_properties")); 17303859Sml29623 17313859Sml29623 status = nxge_use_default_dma_config_n2(nxgep); 17323859Sml29623 if (status != NXGE_OK) { 17333859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 17346929Smisaki " ==> nxge_use_cfg_n2niu_properties (err 0x%x)", 17356929Smisaki status)); 17363859Sml29623 return (status | NXGE_ERROR); 17373859Sml29623 } 17383859Sml29623 17393859Sml29623 (void) nxge_use_cfg_vlan_class_config(nxgep); 17403859Sml29623 (void) nxge_use_cfg_mac_class_config(nxgep); 17413859Sml29623 (void) nxge_use_cfg_class_config(nxgep); 17423859Sml29623 (void) nxge_use_cfg_link_cfg(nxgep); 17433859Sml29623 17443859Sml29623 /* 17453859Sml29623 * Read in the hardware (fcode) properties. Use the ndd array to read 17463859Sml29623 * each property. 17473859Sml29623 */ 17483859Sml29623 (void) nxge_get_param_soft_properties(nxgep); 17493859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_n2niu_properties")); 17503859Sml29623 17513859Sml29623 return (status); 17523859Sml29623 } 17533859Sml29623 17543859Sml29623 static void 17553859Sml29623 nxge_use_cfg_neptune_properties(p_nxge_t nxgep) 17563859Sml29623 { 17573859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_neptune_properties")); 17583859Sml29623 17593859Sml29623 (void) nxge_use_cfg_dma_config(nxgep); 17603859Sml29623 (void) nxge_use_cfg_vlan_class_config(nxgep); 17613859Sml29623 (void) nxge_use_cfg_mac_class_config(nxgep); 17623859Sml29623 (void) nxge_use_cfg_class_config(nxgep); 17633859Sml29623 (void) nxge_use_cfg_link_cfg(nxgep); 17643859Sml29623 17653859Sml29623 /* 17663859Sml29623 * Read in the hardware (fcode) properties. Use the ndd array to read 17673859Sml29623 * each property. 17683859Sml29623 */ 17693859Sml29623 (void) nxge_get_param_soft_properties(nxgep); 17703859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_neptune_properties")); 17713859Sml29623 } 17723859Sml29623 17733859Sml29623 /* 17749015SMichael.Speer@Sun.COM * FWARC 2006/556 for N2 NIU. Get the properties 17759015SMichael.Speer@Sun.COM * from the prom. 17763859Sml29623 */ 17773859Sml29623 static nxge_status_t 17783859Sml29623 nxge_use_default_dma_config_n2(p_nxge_t nxgep) 17793859Sml29623 { 17809015SMichael.Speer@Sun.COM int ndmas; 17819015SMichael.Speer@Sun.COM uint8_t func; 17829015SMichael.Speer@Sun.COM p_nxge_dma_pt_cfg_t p_dma_cfgp; 17839015SMichael.Speer@Sun.COM p_nxge_hw_pt_cfg_t p_cfgp; 17849015SMichael.Speer@Sun.COM int *prop_val; 17859015SMichael.Speer@Sun.COM uint_t prop_len; 17869015SMichael.Speer@Sun.COM int i; 17879015SMichael.Speer@Sun.COM nxge_status_t status = NXGE_OK; 17883859Sml29623 17893859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2")); 17903859Sml29623 17913859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 17923859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 17933859Sml29623 17943859Sml29623 func = nxgep->function_num; 17953859Sml29623 p_cfgp->function_number = func; 17963859Sml29623 ndmas = NXGE_TDMA_PER_NIU_PORT; 17973859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 17986929Smisaki "tx-dma-channels", (int **)&prop_val, 17996929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 18009015SMichael.Speer@Sun.COM if (prop_len != NXGE_NIU_TDMA_PROP_LEN) { 18019015SMichael.Speer@Sun.COM ddi_prop_free(prop_val); 18029015SMichael.Speer@Sun.COM NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18039015SMichael.Speer@Sun.COM "==> nxge_use_default_dma_config_n2: " 1804*10392SMichael.Speer@Sun.COM "invalid tx-dma-channels property for the NIU, " 1805*10392SMichael.Speer@Sun.COM "using defaults")); 1806*10392SMichael.Speer@Sun.COM /* 1807*10392SMichael.Speer@Sun.COM * Just failover to defaults 1808*10392SMichael.Speer@Sun.COM */ 1809*10392SMichael.Speer@Sun.COM p_cfgp->tdc.start = (func * NXGE_TDMA_PER_NIU_PORT); 1810*10392SMichael.Speer@Sun.COM ndmas = NXGE_TDMA_PER_NIU_PORT; 18119015SMichael.Speer@Sun.COM } else { 18129015SMichael.Speer@Sun.COM p_cfgp->tdc.start = prop_val[0]; 18139015SMichael.Speer@Sun.COM NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18149015SMichael.Speer@Sun.COM "==> nxge_use_default_dma_config_n2: tdc starts %d " 18159015SMichael.Speer@Sun.COM "(#%d)", p_cfgp->tdc.start, prop_len)); 18169015SMichael.Speer@Sun.COM 18179015SMichael.Speer@Sun.COM ndmas = prop_val[1]; 18189015SMichael.Speer@Sun.COM NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18199015SMichael.Speer@Sun.COM "==> nxge_use_default_dma_config_n2: #tdc %d (#%d)", 18209015SMichael.Speer@Sun.COM ndmas, prop_len)); 18219015SMichael.Speer@Sun.COM ddi_prop_free(prop_val); 18229015SMichael.Speer@Sun.COM } 18233859Sml29623 } else { 18243859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18256929Smisaki "==> nxge_use_default_dma_config_n2: " 18266929Smisaki "get tx-dma-channels failed")); 18273859Sml29623 return (NXGE_DDI_FAILED); 18283859Sml29623 } 18293859Sml29623 18308275SEric Cheng p_cfgp->tdc.count = ndmas; 18316495Sspeer p_cfgp->tdc.owned = p_cfgp->tdc.count; 18323859Sml29623 18333859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 18348275SEric Cheng "p_cfgp 0x%llx max_tdcs %d start %d", 18358275SEric Cheng p_cfgp, p_cfgp->tdc.count, p_cfgp->tdc.start)); 18363859Sml29623 18373859Sml29623 /* Receive DMA */ 18383859Sml29623 ndmas = NXGE_RDMA_PER_NIU_PORT; 18393859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 18406929Smisaki "rx-dma-channels", (int **)&prop_val, 18416929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 1842*10392SMichael.Speer@Sun.COM if (prop_len != NXGE_NIU_RDMA_PROP_LEN) { 18439015SMichael.Speer@Sun.COM ddi_prop_free(prop_val); 18449015SMichael.Speer@Sun.COM NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18459015SMichael.Speer@Sun.COM "==> nxge_use_default_dma_config_n2: " 1846*10392SMichael.Speer@Sun.COM "invalid rx-dma-channels property for the NIU, " 1847*10392SMichael.Speer@Sun.COM "using defaults")); 1848*10392SMichael.Speer@Sun.COM /* 1849*10392SMichael.Speer@Sun.COM * Just failover to defaults 1850*10392SMichael.Speer@Sun.COM */ 1851*10392SMichael.Speer@Sun.COM p_cfgp->start_rdc = (func * NXGE_RDMA_PER_NIU_PORT); 1852*10392SMichael.Speer@Sun.COM ndmas = NXGE_RDMA_PER_NIU_PORT; 18539015SMichael.Speer@Sun.COM } else { 18549015SMichael.Speer@Sun.COM p_cfgp->start_rdc = prop_val[0]; 18559015SMichael.Speer@Sun.COM NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18569015SMichael.Speer@Sun.COM "==> nxge_use_default_dma_config_n2(obp):" 18579015SMichael.Speer@Sun.COM " rdc start %d (#%d)", 18589015SMichael.Speer@Sun.COM p_cfgp->start_rdc, prop_len)); 18599015SMichael.Speer@Sun.COM ndmas = prop_val[1]; 18609015SMichael.Speer@Sun.COM NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18619015SMichael.Speer@Sun.COM "==> nxge_use_default_dma_config_n2(obp): " 18629015SMichael.Speer@Sun.COM "#rdc %d (#%d)", ndmas, prop_len)); 18639015SMichael.Speer@Sun.COM ddi_prop_free(prop_val); 18649015SMichael.Speer@Sun.COM } 18653859Sml29623 } else { 18663859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18676929Smisaki "==> nxge_use_default_dma_config_n2: " 18686929Smisaki "get rx-dma-channel failed")); 18693859Sml29623 return (NXGE_DDI_FAILED); 18703859Sml29623 } 18713859Sml29623 18728275SEric Cheng p_cfgp->max_rdcs = ndmas; 18733859Sml29623 nxgep->rdc_mask = (ndmas - 1); 18743859Sml29623 18753859Sml29623 /* Hypervisor: rdc # and group # use the same # !! */ 18766495Sspeer p_cfgp->max_grpids = p_cfgp->max_rdcs + p_cfgp->tdc.owned; 18773859Sml29623 p_cfgp->mif_ldvid = p_cfgp->mac_ldvid = p_cfgp->ser_ldvid = 0; 18783859Sml29623 18793859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 18806929Smisaki "interrupts", (int **)&prop_val, 18816929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 18829015SMichael.Speer@Sun.COM if ((prop_len != NXGE_NIU_0_INTR_PROP_LEN) && 18839015SMichael.Speer@Sun.COM (prop_len != NXGE_NIU_1_INTR_PROP_LEN)) { 18849015SMichael.Speer@Sun.COM ddi_prop_free(prop_val); 18859015SMichael.Speer@Sun.COM NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18869015SMichael.Speer@Sun.COM "==> nxge_use_default_dma_config_n2: " 18879015SMichael.Speer@Sun.COM "get interrupts failed")); 18889015SMichael.Speer@Sun.COM return (NXGE_DDI_FAILED); 18899015SMichael.Speer@Sun.COM } 18909015SMichael.Speer@Sun.COM 18913859Sml29623 /* 18923859Sml29623 * For each device assigned, the content of each interrupts 18933859Sml29623 * property is its logical device group. 18943859Sml29623 * 18953859Sml29623 * Assignment of interrupts property is in the the following 18963859Sml29623 * order: 18973859Sml29623 * 18983859Sml29623 * MAC MIF (if configured) SYSTEM ERROR (if configured) first 18993859Sml29623 * receive channel next channel...... last receive channel 19003859Sml29623 * first transmit channel next channel...... last transmit 19013859Sml29623 * channel 19023859Sml29623 * 19033859Sml29623 * prop_len should be at least for one mac and total # of rx and 19043859Sml29623 * tx channels. Function 0 owns MIF and ERROR 19053859Sml29623 */ 19063859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19076929Smisaki "==> nxge_use_default_dma_config_n2(obp): " 19086929Smisaki "# interrupts %d", prop_len)); 19093859Sml29623 19103859Sml29623 switch (func) { 19113859Sml29623 case 0: 19123859Sml29623 p_cfgp->ldg_chn_start = 3; 19133859Sml29623 p_cfgp->mac_ldvid = NXGE_MAC_LD_PORT0; 19143859Sml29623 p_cfgp->mif_ldvid = NXGE_MIF_LD; 19153859Sml29623 p_cfgp->ser_ldvid = NXGE_SYS_ERROR_LD; 19163859Sml29623 19173859Sml29623 break; 19183859Sml29623 case 1: 19193859Sml29623 p_cfgp->ldg_chn_start = 1; 19203859Sml29623 p_cfgp->mac_ldvid = NXGE_MAC_LD_PORT1; 19213859Sml29623 19223859Sml29623 break; 19233859Sml29623 default: 19243859Sml29623 status = NXGE_DDI_FAILED; 19253859Sml29623 break; 19263859Sml29623 } 19273859Sml29623 19283859Sml29623 if (status != NXGE_OK) 19293859Sml29623 return (status); 19303859Sml29623 19313859Sml29623 for (i = 0; i < prop_len; i++) { 19323859Sml29623 p_cfgp->ldg[i] = prop_val[i]; 19333859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19346929Smisaki "==> nxge_use_default_dma_config_n2(obp): " 19356929Smisaki "F%d: interrupt #%d, ldg %d", 19366929Smisaki nxgep->function_num, i, p_cfgp->ldg[i])); 19373859Sml29623 } 19383859Sml29623 19393859Sml29623 p_cfgp->max_grpids = prop_len; 19403859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19416929Smisaki "==> nxge_use_default_dma_config_n2(obp): %d " 19426929Smisaki "(#%d) maxgrpids %d channel starts %d", 19436929Smisaki p_cfgp->mac_ldvid, i, p_cfgp->max_grpids, 19446929Smisaki p_cfgp->ldg_chn_start)); 19453859Sml29623 ddi_prop_free(prop_val); 19463859Sml29623 } else { 19473859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 19486929Smisaki "==> nxge_use_default_dma_config_n2: " 19496929Smisaki "get interrupts failed")); 19503859Sml29623 return (NXGE_DDI_FAILED); 19513859Sml29623 } 19523859Sml29623 19533859Sml29623 p_cfgp->max_ldgs = p_cfgp->max_grpids; 19543859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19558275SEric Cheng "==> nxge_use_default_dma_config_n2: p_cfgp 0x%llx max_rdcs %d " 19568275SEric Cheng "max_grpids %d macid %d mifid %d serrid %d", 19578275SEric Cheng p_cfgp, p_cfgp->max_rdcs, p_cfgp->max_grpids, 19586929Smisaki p_cfgp->mac_ldvid, p_cfgp->mif_ldvid, p_cfgp->ser_ldvid)); 19593859Sml29623 19608275SEric Cheng 19613859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 19626929Smisaki "p_cfgp p%p start_ldg %d nxgep->max_ldgs %d", 19636929Smisaki p_cfgp, p_cfgp->start_ldg, p_cfgp->max_ldgs)); 19643859Sml29623 19653859Sml29623 /* 19663859Sml29623 * RDC groups and the beginning RDC group assigned to this function. 19673859Sml29623 */ 19688275SEric Cheng p_cfgp->max_rdc_grpids = NXGE_MAX_RDC_GROUPS / nxgep->nports; 19698275SEric Cheng p_cfgp->def_mac_rxdma_grpid = 19708275SEric Cheng nxgep->function_num * NXGE_MAX_RDC_GROUPS / nxgep->nports; 19718275SEric Cheng p_cfgp->def_mac_txdma_grpid = 19728275SEric Cheng nxgep->function_num * NXGE_MAX_TDC_GROUPS / nxgep->nports; 19738275SEric Cheng 19748275SEric Cheng if ((p_cfgp->def_mac_rxdma_grpid = nxge_fzc_rdc_tbl_bind(nxgep, 19758275SEric Cheng p_cfgp->def_mac_rxdma_grpid, B_TRUE)) >= NXGE_MAX_RDC_GRPS) { 19766495Sspeer NXGE_ERROR_MSG((nxgep, CFG_CTL, 19776495Sspeer "nxge_use_default_dma_config_n2(): " 19786495Sspeer "nxge_fzc_rdc_tbl_bind failed")); 19796495Sspeer return (NXGE_DDI_FAILED); 19806495Sspeer } 19813859Sml29623 19823859Sml29623 status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 19836495Sspeer "rx-rdc-grps", p_cfgp->max_rdc_grpids); 19843859Sml29623 if (status) { 19853859Sml29623 return (NXGE_DDI_FAILED); 19863859Sml29623 } 19873859Sml29623 status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 19886929Smisaki "rx-rdc-grps-begin", p_cfgp->def_mac_rxdma_grpid); 19893859Sml29623 if (status) { 19903859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, nxgep->dip, 19916929Smisaki "rx-rdc-grps"); 19923859Sml29623 return (NXGE_DDI_FAILED); 19933859Sml29623 } 19943859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 19956929Smisaki "p_cfgp $%p # rdc groups %d start rdc group id %d", 19966929Smisaki p_cfgp, p_cfgp->max_rdc_grpids, 19976929Smisaki p_cfgp->def_mac_rxdma_grpid)); 19983859Sml29623 19999005SSantwona.Behera@Sun.COM nxgep->intr_timeout = NXGE_RDC_RCR_TIMEOUT; 20009005SSantwona.Behera@Sun.COM if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 20019005SSantwona.Behera@Sun.COM "rxdma-intr-time", (int **)&prop_val, &prop_len) == 20029005SSantwona.Behera@Sun.COM DDI_PROP_SUCCESS) { 20039005SSantwona.Behera@Sun.COM if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) { 20049005SSantwona.Behera@Sun.COM nxgep->intr_timeout = prop_val[0]; 20059005SSantwona.Behera@Sun.COM (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 20069005SSantwona.Behera@Sun.COM nxgep->dip, "rxdma-intr-time", prop_val, prop_len); 20079005SSantwona.Behera@Sun.COM } 20089005SSantwona.Behera@Sun.COM ddi_prop_free(prop_val); 20099005SSantwona.Behera@Sun.COM } 20109005SSantwona.Behera@Sun.COM 20119005SSantwona.Behera@Sun.COM nxgep->intr_threshold = NXGE_RDC_RCR_THRESHOLD; 20129005SSantwona.Behera@Sun.COM if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 20139005SSantwona.Behera@Sun.COM "rxdma-intr-pkts", (int **)&prop_val, &prop_len) == 20149005SSantwona.Behera@Sun.COM DDI_PROP_SUCCESS) { 20159005SSantwona.Behera@Sun.COM if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) { 20169005SSantwona.Behera@Sun.COM nxgep->intr_threshold = prop_val[0]; 20179005SSantwona.Behera@Sun.COM (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 20189005SSantwona.Behera@Sun.COM nxgep->dip, "rxdma-intr-pkts", prop_val, prop_len); 20199005SSantwona.Behera@Sun.COM } 20209005SSantwona.Behera@Sun.COM ddi_prop_free(prop_val); 20219005SSantwona.Behera@Sun.COM } 20229005SSantwona.Behera@Sun.COM 20233859Sml29623 nxge_set_hw_dma_config(nxgep); 20243859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "<== nxge_use_default_dma_config_n2")); 20253859Sml29623 return (status); 20263859Sml29623 } 20273859Sml29623 20283859Sml29623 static void 20293859Sml29623 nxge_use_cfg_dma_config(p_nxge_t nxgep) 20303859Sml29623 { 20314732Sdavemq int tx_ndmas, rx_ndmas, nrxgp, st_txdma, st_rxdma; 20323859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 20333859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 20343859Sml29623 dev_info_t *dip; 20353859Sml29623 p_nxge_param_t param_arr; 20363859Sml29623 char *prop; 20373859Sml29623 int *prop_val; 20383859Sml29623 uint_t prop_len; 20394732Sdavemq int i; 20404732Sdavemq uint8_t *ch_arr_p; 20413859Sml29623 20423859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_dma_config")); 20433859Sml29623 param_arr = nxgep->param_arr; 20443859Sml29623 20453859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 20463859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 20473859Sml29623 dip = nxgep->dip; 20483859Sml29623 p_cfgp->function_number = nxgep->function_num; 20493859Sml29623 prop = param_arr[param_txdma_channels_begin].fcode_name; 20503859Sml29623 20513859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20526929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20536495Sspeer p_cfgp->tdc.start = *prop_val; 20543859Sml29623 ddi_prop_free(prop_val); 20553859Sml29623 } else { 20564732Sdavemq switch (nxgep->niu_type) { 20574732Sdavemq case NEPTUNE_4_1GC: 20584732Sdavemq ch_arr_p = &tx_4_1G[0]; 20594732Sdavemq break; 20604732Sdavemq case NEPTUNE_2_10GF: 20614732Sdavemq ch_arr_p = &tx_2_10G[0]; 20624732Sdavemq break; 20634732Sdavemq case NEPTUNE_2_10GF_2_1GC: 20646261Sjoycey case NEPTUNE_2_10GF_2_1GRF: 20654732Sdavemq ch_arr_p = &tx_2_10G_2_1G[0]; 20664732Sdavemq break; 20674732Sdavemq case NEPTUNE_1_10GF_3_1GC: 20684732Sdavemq ch_arr_p = &tx_1_10G_3_1G[0]; 20694732Sdavemq break; 20704732Sdavemq case NEPTUNE_1_1GC_1_10GF_2_1GC: 20714732Sdavemq ch_arr_p = &tx_1_1G_1_10G_2_1G[0]; 20724732Sdavemq break; 20734732Sdavemq default: 20745196Ssbehera switch (nxgep->platform_type) { 20755196Ssbehera case P_NEPTUNE_ALONSO: 20765196Ssbehera ch_arr_p = &tx_2_10G_2_1G[0]; 20775196Ssbehera break; 20785196Ssbehera default: 20795196Ssbehera ch_arr_p = &p4_tx_equal[0]; 20805196Ssbehera break; 20815196Ssbehera } 20824732Sdavemq break; 20833859Sml29623 } 20844732Sdavemq st_txdma = 0; 20854732Sdavemq for (i = 0; i < nxgep->function_num; i++, ch_arr_p++) 20864732Sdavemq st_txdma += *ch_arr_p; 20874732Sdavemq 20883859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 20894732Sdavemq prop, st_txdma); 20906495Sspeer p_cfgp->tdc.start = st_txdma; 20913859Sml29623 } 20923859Sml29623 20933859Sml29623 prop = param_arr[param_txdma_channels].fcode_name; 20943859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20956929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20963859Sml29623 tx_ndmas = *prop_val; 20973859Sml29623 ddi_prop_free(prop_val); 20983859Sml29623 } else { 20994732Sdavemq switch (nxgep->niu_type) { 21004732Sdavemq case NEPTUNE_4_1GC: 21014732Sdavemq tx_ndmas = tx_4_1G[nxgep->function_num]; 21024732Sdavemq break; 21034732Sdavemq case NEPTUNE_2_10GF: 21044732Sdavemq tx_ndmas = tx_2_10G[nxgep->function_num]; 21054732Sdavemq break; 21064732Sdavemq case NEPTUNE_2_10GF_2_1GC: 21076261Sjoycey case NEPTUNE_2_10GF_2_1GRF: 21084732Sdavemq tx_ndmas = tx_2_10G_2_1G[nxgep->function_num]; 21094732Sdavemq break; 21104732Sdavemq case NEPTUNE_1_10GF_3_1GC: 21114732Sdavemq tx_ndmas = tx_1_10G_3_1G[nxgep->function_num]; 21124732Sdavemq break; 21134732Sdavemq case NEPTUNE_1_1GC_1_10GF_2_1GC: 21144732Sdavemq tx_ndmas = tx_1_1G_1_10G_2_1G[nxgep->function_num]; 21154732Sdavemq break; 21164732Sdavemq default: 21175196Ssbehera switch (nxgep->platform_type) { 21185196Ssbehera case P_NEPTUNE_ALONSO: 21195196Ssbehera tx_ndmas = tx_2_10G_2_1G[nxgep->function_num]; 21205196Ssbehera break; 21215196Ssbehera default: 21225196Ssbehera tx_ndmas = p4_tx_equal[nxgep->function_num]; 21235196Ssbehera break; 21245196Ssbehera } 21254732Sdavemq break; 21263859Sml29623 } 21273859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 21286929Smisaki prop, tx_ndmas); 21293859Sml29623 } 21303859Sml29623 21318275SEric Cheng p_cfgp->tdc.count = tx_ndmas; 21326495Sspeer p_cfgp->tdc.owned = p_cfgp->tdc.count; 21333859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_dma_config: " 21348275SEric Cheng "p_cfgp 0x%llx max_tdcs %d", p_cfgp, p_cfgp->tdc.count)); 21353859Sml29623 21363859Sml29623 prop = param_arr[param_rxdma_channels_begin].fcode_name; 21373859Sml29623 21383859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 21396929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 21403859Sml29623 p_cfgp->start_rdc = *prop_val; 21413859Sml29623 ddi_prop_free(prop_val); 21423859Sml29623 } else { 21434732Sdavemq switch (nxgep->niu_type) { 21444732Sdavemq case NEPTUNE_4_1GC: 21454732Sdavemq ch_arr_p = &rx_4_1G[0]; 21464732Sdavemq break; 21474732Sdavemq case NEPTUNE_2_10GF: 21484732Sdavemq ch_arr_p = &rx_2_10G[0]; 21494732Sdavemq break; 21504732Sdavemq case NEPTUNE_2_10GF_2_1GC: 21516261Sjoycey case NEPTUNE_2_10GF_2_1GRF: 21524732Sdavemq ch_arr_p = &rx_2_10G_2_1G[0]; 21534732Sdavemq break; 21544732Sdavemq case NEPTUNE_1_10GF_3_1GC: 21554732Sdavemq ch_arr_p = &rx_1_10G_3_1G[0]; 21564732Sdavemq break; 21574732Sdavemq case NEPTUNE_1_1GC_1_10GF_2_1GC: 21584732Sdavemq ch_arr_p = &rx_1_1G_1_10G_2_1G[0]; 21594732Sdavemq break; 21604732Sdavemq default: 21615196Ssbehera switch (nxgep->platform_type) { 21625196Ssbehera case P_NEPTUNE_ALONSO: 21635196Ssbehera ch_arr_p = &rx_2_10G_2_1G[0]; 21645196Ssbehera break; 21655196Ssbehera default: 21665196Ssbehera ch_arr_p = &p4_rx_equal[0]; 21675196Ssbehera break; 21685196Ssbehera } 21694732Sdavemq break; 21703859Sml29623 } 21714732Sdavemq st_rxdma = 0; 21724732Sdavemq for (i = 0; i < nxgep->function_num; i++, ch_arr_p++) 21734732Sdavemq st_rxdma += *ch_arr_p; 21744732Sdavemq 21753859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 21764732Sdavemq prop, st_rxdma); 21774732Sdavemq p_cfgp->start_rdc = st_rxdma; 21783859Sml29623 } 21793859Sml29623 21803859Sml29623 prop = param_arr[param_rxdma_channels].fcode_name; 21813859Sml29623 21823859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 21836929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 21843859Sml29623 rx_ndmas = *prop_val; 21853859Sml29623 ddi_prop_free(prop_val); 21863859Sml29623 } else { 21874732Sdavemq switch (nxgep->niu_type) { 21884732Sdavemq case NEPTUNE_4_1GC: 21894732Sdavemq rx_ndmas = rx_4_1G[nxgep->function_num]; 21904732Sdavemq break; 21914732Sdavemq case NEPTUNE_2_10GF: 21924732Sdavemq rx_ndmas = rx_2_10G[nxgep->function_num]; 21934732Sdavemq break; 21944732Sdavemq case NEPTUNE_2_10GF_2_1GC: 21956261Sjoycey case NEPTUNE_2_10GF_2_1GRF: 21964732Sdavemq rx_ndmas = rx_2_10G_2_1G[nxgep->function_num]; 21974732Sdavemq break; 21984732Sdavemq case NEPTUNE_1_10GF_3_1GC: 21994732Sdavemq rx_ndmas = rx_1_10G_3_1G[nxgep->function_num]; 22004732Sdavemq break; 22014732Sdavemq case NEPTUNE_1_1GC_1_10GF_2_1GC: 22024732Sdavemq rx_ndmas = rx_1_1G_1_10G_2_1G[nxgep->function_num]; 22034732Sdavemq break; 22044732Sdavemq default: 22055196Ssbehera switch (nxgep->platform_type) { 22065196Ssbehera case P_NEPTUNE_ALONSO: 22075196Ssbehera rx_ndmas = rx_2_10G_2_1G[nxgep->function_num]; 22085196Ssbehera break; 22095196Ssbehera default: 22105196Ssbehera rx_ndmas = p4_rx_equal[nxgep->function_num]; 22115196Ssbehera break; 22125196Ssbehera } 22134732Sdavemq break; 22143859Sml29623 } 22153859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 22166929Smisaki prop, rx_ndmas); 22173859Sml29623 } 22183859Sml29623 22198275SEric Cheng p_cfgp->max_rdcs = rx_ndmas; 22208275SEric Cheng 22218275SEric Cheng /* 22228275SEric Cheng * RDC groups and the beginning RDC group assigned to this function. 22238275SEric Cheng * XXX: this may be wrong if prop value is used. 22248275SEric Cheng */ 22258275SEric Cheng p_cfgp->def_mac_rxdma_grpid = 22268275SEric Cheng nxgep->function_num * NXGE_MAX_RDC_GROUPS / nxgep->nports; 22278275SEric Cheng p_cfgp->def_mac_txdma_grpid = 22288275SEric Cheng nxgep->function_num * NXGE_MAX_TDC_GROUPS / nxgep->nports; 22298275SEric Cheng 22308275SEric Cheng if ((p_cfgp->def_mac_rxdma_grpid = nxge_fzc_rdc_tbl_bind(nxgep, 22318275SEric Cheng p_cfgp->def_mac_rxdma_grpid, B_TRUE)) >= NXGE_MAX_RDC_GRPS) { 22328275SEric Cheng NXGE_ERROR_MSG((nxgep, CFG_CTL, 22338275SEric Cheng "nxge_use_default_dma_config2(): " 22348275SEric Cheng "nxge_fzc_rdc_tbl_bind failed")); 22358275SEric Cheng goto nxge_use_cfg_dma_config_exit; 22363859Sml29623 } 22373859Sml29623 22383859Sml29623 prop = param_arr[param_rx_rdc_grps].fcode_name; 22393859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 22406929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 22413859Sml29623 nrxgp = *prop_val; 22423859Sml29623 ddi_prop_free(prop_val); 22433859Sml29623 } else { 22448275SEric Cheng nrxgp = NXGE_MAX_RDC_GRPS / nxgep->nports; 22453859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 22466929Smisaki prop, nrxgp); 22473859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 22486929Smisaki "==> nxge_use_default_dma_config: " 22496929Smisaki "num_rdc_grpid not found: use def:# of " 22506929Smisaki "rdc groups %d\n", nrxgp)); 22513859Sml29623 } 22523859Sml29623 p_cfgp->max_rdc_grpids = nrxgp; 22533859Sml29623 22543859Sml29623 /* 22553859Sml29623 * 2/4 ports have the same hard-wired logical groups assigned. 22563859Sml29623 */ 22573859Sml29623 p_cfgp->start_ldg = nxgep->function_num * NXGE_LDGRP_PER_4PORTS; 22583859Sml29623 p_cfgp->max_ldgs = NXGE_LDGRP_PER_4PORTS; 22593859Sml29623 22603859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_default_dma_config: " 22618275SEric Cheng "p_cfgp 0x%llx max_rdcs %d max_grpids %d default_grpid %d", 22628275SEric Cheng p_cfgp, p_cfgp->max_rdcs, p_cfgp->max_grpids, 22638275SEric Cheng p_cfgp->def_mac_rxdma_grpid)); 22643859Sml29623 22653859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_dma_config: " 22666929Smisaki "p_cfgp 0x%016llx start_ldg %d nxgep->max_ldgs %d " 22676929Smisaki "def_mac_rxdma_grpid %d", 22686929Smisaki p_cfgp, p_cfgp->start_ldg, p_cfgp->max_ldgs, 22696929Smisaki p_cfgp->def_mac_rxdma_grpid)); 22703859Sml29623 22719005SSantwona.Behera@Sun.COM nxgep->intr_timeout = NXGE_RDC_RCR_TIMEOUT; 22723859Sml29623 prop = param_arr[param_rxdma_intr_time].fcode_name; 22733859Sml29623 22743859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 22756929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 22763859Sml29623 if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) { 22779005SSantwona.Behera@Sun.COM nxgep->intr_timeout = prop_val[0]; 22783859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 22796929Smisaki nxgep->dip, prop, prop_val, prop_len); 22803859Sml29623 } 22813859Sml29623 ddi_prop_free(prop_val); 22823859Sml29623 } 22839005SSantwona.Behera@Sun.COM 22849005SSantwona.Behera@Sun.COM nxgep->intr_threshold = NXGE_RDC_RCR_THRESHOLD; 22853859Sml29623 prop = param_arr[param_rxdma_intr_pkts].fcode_name; 22863859Sml29623 22873859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 22886929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 22893859Sml29623 if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) { 22909005SSantwona.Behera@Sun.COM nxgep->intr_threshold = prop_val[0]; 22913859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 22926929Smisaki nxgep->dip, prop, prop_val, prop_len); 22933859Sml29623 } 22943859Sml29623 ddi_prop_free(prop_val); 22953859Sml29623 } 22963859Sml29623 nxge_set_hw_dma_config(nxgep); 22973859Sml29623 22984732Sdavemq NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_dma_config: " 22994732Sdavemq "sTDC[%d] nTDC[%d] sRDC[%d] nRDC[%d]", 23006495Sspeer p_cfgp->tdc.start, p_cfgp->tdc.count, 23014732Sdavemq p_cfgp->start_rdc, p_cfgp->max_rdcs)); 23024732Sdavemq 23036495Sspeer nxge_use_cfg_dma_config_exit: 23043859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_dma_config")); 23053859Sml29623 } 23063859Sml29623 23076495Sspeer void 23086495Sspeer nxge_get_logical_props(p_nxge_t nxgep) 23096495Sspeer { 23106495Sspeer nxge_dma_pt_cfg_t *port = &nxgep->pt_config; 23116495Sspeer nxge_hw_pt_cfg_t *hardware; 23126495Sspeer nxge_rdc_grp_t *group; 23136495Sspeer 23146495Sspeer (void) memset(port, 0, sizeof (*port)); 23156495Sspeer 23168275SEric Cheng port->mac_port = nxgep->function_num; /* := function number */ 23176495Sspeer 23186495Sspeer /* 23196495Sspeer * alloc_buf_size: 23206495Sspeer * dead variables. 23216495Sspeer */ 23226495Sspeer port->rbr_size = nxge_rbr_size; 23236495Sspeer port->rcr_size = nxge_rcr_size; 23246495Sspeer 23256495Sspeer port->tx_dma_map = 0; /* Transmit DMA channel bit map */ 23266495Sspeer 23276495Sspeer nxge_set_rdc_intr_property(nxgep); 23286495Sspeer 23296495Sspeer port->rcr_full_header = NXGE_RCR_FULL_HEADER; 23306495Sspeer port->rx_drr_weight = PT_DRR_WT_DEFAULT_10G; 23316495Sspeer 23326495Sspeer /* ----------------------------------------------------- */ 23336495Sspeer hardware = &port->hw_config; 23346495Sspeer 23356495Sspeer (void) memset(hardware, 0, sizeof (*hardware)); 23366495Sspeer 23376495Sspeer /* 23386495Sspeer * partition_id, read_write_mode: 23396495Sspeer * dead variables. 23406495Sspeer */ 23416495Sspeer 23426495Sspeer /* 23436495Sspeer * drr_wt, rx_full_header, *_ldg?, start_mac_entry, 23446495Sspeer * mac_pref, def_mac_rxdma_grpid, start_vlan, max_vlans, 23456495Sspeer * start_ldgs, max_ldgs, max_ldvs, 23466495Sspeer * vlan_pref, def_vlan_rxdma_grpid are meaningful only 23476495Sspeer * in the service domain. 23486495Sspeer */ 23496495Sspeer 23506495Sspeer group = &port->rdc_grps[0]; 23516495Sspeer 23528275SEric Cheng group->flag = B_TRUE; /* configured */ 23536495Sspeer group->config_method = RDC_TABLE_ENTRY_METHOD_REP; 23548275SEric Cheng group->port = NXGE_GET_PORT_NUM(nxgep->function_num); 23556495Sspeer 23566495Sspeer /* HIO futures: this is still an open question. */ 23576495Sspeer hardware->max_macs = 1; 23586495Sspeer } 23596495Sspeer 23603859Sml29623 static void 23613859Sml29623 nxge_use_cfg_vlan_class_config(p_nxge_t nxgep) 23623859Sml29623 { 23633859Sml29623 uint_t vlan_cnt; 23643859Sml29623 int *vlan_cfg_val; 23653859Sml29623 int status; 23663859Sml29623 p_nxge_param_t param_arr; 23673859Sml29623 char *prop; 23683859Sml29623 23693859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_vlan_config")); 23703859Sml29623 param_arr = nxgep->param_arr; 23713859Sml29623 prop = param_arr[param_vlan_2rdc_grp].fcode_name; 23723859Sml29623 23733859Sml29623 status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 23746929Smisaki &vlan_cfg_val, &vlan_cnt); 23753859Sml29623 if (status == DDI_PROP_SUCCESS) { 23763859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, 23776929Smisaki nxgep->dip, prop, vlan_cfg_val, vlan_cnt); 23783859Sml29623 ddi_prop_free(vlan_cfg_val); 23793859Sml29623 } 23803859Sml29623 nxge_set_hw_vlan_class_config(nxgep); 23813859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_vlan_config")); 23823859Sml29623 } 23833859Sml29623 23843859Sml29623 static void 23853859Sml29623 nxge_use_cfg_mac_class_config(p_nxge_t nxgep) 23863859Sml29623 { 23873859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 23883859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 23893859Sml29623 uint_t mac_cnt; 23903859Sml29623 int *mac_cfg_val; 23913859Sml29623 int status; 23923859Sml29623 p_nxge_param_t param_arr; 23933859Sml29623 char *prop; 23943859Sml29623 23953859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_mac_class_config")); 23963859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 23973859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 23983859Sml29623 p_cfgp->start_mac_entry = 0; 23993859Sml29623 param_arr = nxgep->param_arr; 24003859Sml29623 prop = param_arr[param_mac_2rdc_grp].fcode_name; 24013859Sml29623 24023859Sml29623 switch (nxgep->function_num) { 24033859Sml29623 case 0: 24043859Sml29623 case 1: 24053859Sml29623 /* 10G ports */ 24063859Sml29623 p_cfgp->max_macs = NXGE_MAX_MACS_XMACS; 24073859Sml29623 break; 24083859Sml29623 case 2: 24093859Sml29623 case 3: 24103859Sml29623 /* 1G ports */ 24113859Sml29623 default: 24123859Sml29623 p_cfgp->max_macs = NXGE_MAX_MACS_BMACS; 24133859Sml29623 break; 24143859Sml29623 } 24153859Sml29623 24163859Sml29623 p_cfgp->mac_pref = 1; 24173859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 24186929Smisaki "== nxge_use_cfg_mac_class_config: " 24196929Smisaki " mac_pref bit set def_mac_rxdma_grpid %d", 24206929Smisaki p_cfgp->def_mac_rxdma_grpid)); 24213859Sml29623 24223859Sml29623 status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 24236929Smisaki &mac_cfg_val, &mac_cnt); 24243859Sml29623 if (status == DDI_PROP_SUCCESS) { 24253859Sml29623 if (mac_cnt <= p_cfgp->max_macs) 24263859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, 24276929Smisaki nxgep->dip, prop, mac_cfg_val, mac_cnt); 24283859Sml29623 ddi_prop_free(mac_cfg_val); 24293859Sml29623 } 24303859Sml29623 nxge_set_hw_mac_class_config(nxgep); 24313859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_mac_class_config")); 24323859Sml29623 } 24333859Sml29623 24343859Sml29623 static void 24353859Sml29623 nxge_use_cfg_class_config(p_nxge_t nxgep) 24363859Sml29623 { 24373859Sml29623 nxge_set_hw_class_config(nxgep); 24383859Sml29623 } 24393859Sml29623 24403859Sml29623 static void 24413859Sml29623 nxge_set_rdc_intr_property(p_nxge_t nxgep) 24423859Sml29623 { 24433859Sml29623 int i; 24443859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 24453859Sml29623 24463859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_rdc_intr_property")); 24473859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 24483859Sml29623 24493859Sml29623 for (i = 0; i < NXGE_MAX_RDCS; i++) { 24509005SSantwona.Behera@Sun.COM p_dma_cfgp->rcr_timeout[i] = nxgep->intr_timeout; 24519005SSantwona.Behera@Sun.COM p_dma_cfgp->rcr_threshold[i] = nxgep->intr_threshold; 24523859Sml29623 } 24533859Sml29623 24543859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_rdc_intr_property")); 24553859Sml29623 } 24563859Sml29623 24573859Sml29623 static void 24583859Sml29623 nxge_set_hw_dma_config(p_nxge_t nxgep) 24593859Sml29623 { 24608275SEric Cheng int i, j, ngrps, bitmap, end, st_rdc; 24618275SEric Cheng p_nxge_dma_pt_cfg_t p_dma_cfgp; 24628275SEric Cheng p_nxge_hw_pt_cfg_t p_cfgp; 24638275SEric Cheng p_nxge_rdc_grp_t rdc_grp_p; 24648275SEric Cheng p_nxge_tdc_grp_t tdc_grp_p; 24658275SEric Cheng nxge_grp_t *group; 24668275SEric Cheng uint8_t nrdcs; 24678275SEric Cheng dc_map_t map = 0; 24683859Sml29623 24693859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_set_hw_dma_config")); 24703859Sml29623 24713859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 24723859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 24738275SEric Cheng 24748275SEric Cheng switch (nxgep->niu_type) { 24758275SEric Cheng case NEPTUNE_4_1GC: 24768275SEric Cheng case NEPTUNE_2_10GF_2_1GC: 24778275SEric Cheng case NEPTUNE_1_10GF_3_1GC: 24788275SEric Cheng case NEPTUNE_1_1GC_1_10GF_2_1GC: 24798275SEric Cheng case NEPTUNE_2_10GF_2_1GRF: 24808275SEric Cheng default: 24818275SEric Cheng ngrps = 2; 24828275SEric Cheng break; 24838275SEric Cheng case NEPTUNE_2_10GF: 24848275SEric Cheng case NEPTUNE_2_1GRF: 24858275SEric Cheng case N2_NIU: 24868275SEric Cheng ngrps = 4; 24878275SEric Cheng break; 24888275SEric Cheng } 24898275SEric Cheng 24908275SEric Cheng /* 24918275SEric Cheng * Setup TDC groups 24928275SEric Cheng */ 24933859Sml29623 bitmap = 0; 24946495Sspeer end = p_cfgp->tdc.start + p_cfgp->tdc.owned; 24956495Sspeer for (i = p_cfgp->tdc.start; i < end; i++) { 24963859Sml29623 bitmap |= (1 << i); 24973859Sml29623 } 24983859Sml29623 24996495Sspeer nxgep->tx_set.owned.map |= bitmap; /* Owned, & not shared. */ 25008275SEric Cheng nxgep->tx_set.owned.count = p_cfgp->tdc.owned; 25013859Sml29623 p_dma_cfgp->tx_dma_map = bitmap; 25028275SEric Cheng 25038275SEric Cheng for (i = 0; i < ngrps; i++) { 25048275SEric Cheng group = (nxge_grp_t *)nxge_grp_add(nxgep, 25058275SEric Cheng NXGE_TRANSMIT_GROUP); 25068275SEric Cheng tdc_grp_p = &p_dma_cfgp->tdc_grps[ 25078275SEric Cheng p_cfgp->def_mac_txdma_grpid + i]; 25088275SEric Cheng if (i == 0) 25098275SEric Cheng tdc_grp_p->map = bitmap; 25108275SEric Cheng else 25118275SEric Cheng tdc_grp_p->map = 0; 25128275SEric Cheng /* no ring is associated with a group initially */ 25138275SEric Cheng tdc_grp_p->start_tdc = 0; 25148275SEric Cheng tdc_grp_p->max_tdcs = 0; 25158275SEric Cheng tdc_grp_p->grp_index = group->index; 25168275SEric Cheng } 25178275SEric Cheng 25188275SEric Cheng for (i = 0; i < NXGE_MAX_RDCS; i++) { 25198275SEric Cheng nxgep->rx_channel_started[i] = B_FALSE; 25208275SEric Cheng } 25218275SEric Cheng 25228275SEric Cheng /* 25238275SEric Cheng * Setup RDC groups 25248275SEric Cheng */ 25258275SEric Cheng st_rdc = p_cfgp->start_rdc; 25268275SEric Cheng for (i = 0; i < ngrps; i++) { 25278275SEric Cheng /* 25288275SEric Cheng * All rings are associated with the default group initially 25298275SEric Cheng */ 25308275SEric Cheng if (i == 0) { 25318275SEric Cheng /* default group */ 25328275SEric Cheng switch (nxgep->niu_type) { 25338275SEric Cheng case NEPTUNE_4_1GC: 25348275SEric Cheng nrdcs = rx_4_1G[nxgep->function_num]; 25353859Sml29623 break; 25368275SEric Cheng case N2_NIU: 25378275SEric Cheng case NEPTUNE_2_10GF: 25388275SEric Cheng nrdcs = rx_2_10G[nxgep->function_num]; 25398275SEric Cheng break; 25408275SEric Cheng case NEPTUNE_2_10GF_2_1GC: 25418275SEric Cheng nrdcs = rx_2_10G_2_1G[nxgep->function_num]; 25428275SEric Cheng break; 25438275SEric Cheng case NEPTUNE_1_10GF_3_1GC: 25448275SEric Cheng nrdcs = rx_1_10G_3_1G[nxgep->function_num]; 25458275SEric Cheng break; 25468275SEric Cheng case NEPTUNE_1_1GC_1_10GF_2_1GC: 25478275SEric Cheng nrdcs = rx_1_1G_1_10G_2_1G[nxgep->function_num]; 25483859Sml29623 break; 25493859Sml29623 default: 25508275SEric Cheng switch (nxgep->platform_type) { 25518275SEric Cheng case P_NEPTUNE_ALONSO: 25528275SEric Cheng nrdcs = 25538275SEric Cheng rx_2_10G_2_1G[nxgep->function_num]; 25548275SEric Cheng break; 25558275SEric Cheng default: 25568275SEric Cheng nrdcs = rx_4_1G[nxgep->function_num]; 25578275SEric Cheng break; 25588275SEric Cheng } 25593859Sml29623 break; 25603859Sml29623 } 25618948SMichael.Speer@Sun.COM 25628948SMichael.Speer@Sun.COM if (p_cfgp->max_rdcs < nrdcs) 25638948SMichael.Speer@Sun.COM nrdcs = p_cfgp->max_rdcs; 25648275SEric Cheng } else { 25658275SEric Cheng nrdcs = 0; 25663859Sml29623 } 25676495Sspeer 25686495Sspeer rdc_grp_p = &p_dma_cfgp->rdc_grps[ 25696929Smisaki p_cfgp->def_mac_rxdma_grpid + i]; 25708275SEric Cheng rdc_grp_p->start_rdc = st_rdc; 25718275SEric Cheng rdc_grp_p->max_rdcs = nrdcs; 25726495Sspeer rdc_grp_p->def_rdc = rdc_grp_p->start_rdc; 25733859Sml29623 25743859Sml29623 /* default to: 0, 1, 2, 3, ...., 0, 1, 2, 3.... */ 25758275SEric Cheng if (nrdcs != 0) { 25768275SEric Cheng for (j = 0; j < nrdcs; j++) { 25778275SEric Cheng map |= (1 << j); 25788275SEric Cheng } 25798275SEric Cheng map <<= rdc_grp_p->start_rdc; 25808275SEric Cheng } else 25818275SEric Cheng map = 0; 25826495Sspeer rdc_grp_p->map = map; 25836495Sspeer 25846495Sspeer nxgep->rx_set.owned.map |= map; /* Owned, & not shared. */ 25858275SEric Cheng nxgep->rx_set.owned.count = nrdcs; 25866495Sspeer 25876495Sspeer group = (nxge_grp_t *)nxge_grp_add(nxgep, NXGE_RECEIVE_GROUP); 25886495Sspeer 25893859Sml29623 rdc_grp_p->config_method = RDC_TABLE_ENTRY_METHOD_SEQ; 25908275SEric Cheng rdc_grp_p->flag = B_TRUE; /* This group has been configured. */ 25918275SEric Cheng rdc_grp_p->grp_index = group->index; 25928275SEric Cheng rdc_grp_p->port = NXGE_GET_PORT_NUM(nxgep->function_num); 25938275SEric Cheng 25948275SEric Cheng map = 0; 25953859Sml29623 } 25963859Sml29623 25976495Sspeer 25983859Sml29623 /* default RDC */ 25993859Sml29623 p_cfgp->def_rdc = p_cfgp->start_rdc; 26003859Sml29623 nxgep->def_rdc = p_cfgp->start_rdc; 26013859Sml29623 26023859Sml29623 /* full 18 byte header ? */ 26033859Sml29623 p_dma_cfgp->rcr_full_header = NXGE_RCR_FULL_HEADER; 26043859Sml29623 p_dma_cfgp->rx_drr_weight = PT_DRR_WT_DEFAULT_10G; 26053859Sml29623 if (nxgep->function_num > 1) 26063859Sml29623 p_dma_cfgp->rx_drr_weight = PT_DRR_WT_DEFAULT_1G; 26073859Sml29623 p_dma_cfgp->rbr_size = nxge_rbr_size; 26083859Sml29623 p_dma_cfgp->rcr_size = nxge_rcr_size; 26093859Sml29623 26103859Sml29623 nxge_set_rdc_intr_property(nxgep); 26113859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_hw_dma_config")); 26123859Sml29623 } 26133859Sml29623 26143859Sml29623 boolean_t 26153859Sml29623 nxge_check_rxdma_port_member(p_nxge_t nxgep, uint8_t rdc) 26163859Sml29623 { 26173859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 26183859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 26193859Sml29623 int status = B_TRUE; 26203859Sml29623 26213859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rxdma_port_member")); 26223859Sml29623 26233859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 26243859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 26253859Sml29623 26263859Sml29623 /* Receive DMA Channels */ 26273859Sml29623 if (rdc < p_cfgp->max_rdcs) 26283859Sml29623 status = B_TRUE; 26293859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rxdma_port_member")); 26303859Sml29623 return (status); 26313859Sml29623 } 26323859Sml29623 26333859Sml29623 boolean_t 26343859Sml29623 nxge_check_txdma_port_member(p_nxge_t nxgep, uint8_t tdc) 26353859Sml29623 { 26363859Sml29623 int status = B_FALSE; 26373859Sml29623 26386495Sspeer NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_txdma_port_member")); 26396495Sspeer 26406495Sspeer if (tdc >= nxgep->pt_config.hw_config.tdc.start && 26416495Sspeer tdc < nxgep->pt_config.hw_config.tdc.count) 26423859Sml29623 status = B_TRUE; 26436495Sspeer 26446495Sspeer NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_txdma_port_member")); 26453859Sml29623 return (status); 26463859Sml29623 } 26473859Sml29623 26483859Sml29623 boolean_t 26493859Sml29623 nxge_check_rxdma_rdcgrp_member(p_nxge_t nxgep, uint8_t rdc_grp, uint8_t rdc) 26503859Sml29623 { 26513859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 26523859Sml29623 int status = B_TRUE; 26533859Sml29623 p_nxge_rdc_grp_t rdc_grp_p; 26543859Sml29623 26553859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 26566929Smisaki " ==> nxge_check_rxdma_rdcgrp_member")); 26573859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " nxge_check_rxdma_rdcgrp_member" 26586929Smisaki " rdc %d group %d", rdc, rdc_grp)); 26593859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 26603859Sml29623 26613859Sml29623 rdc_grp_p = &p_dma_cfgp->rdc_grps[rdc_grp]; 26623859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " max %d ", rdc_grp_p->max_rdcs)); 26633859Sml29623 if (rdc >= rdc_grp_p->max_rdcs) { 26643859Sml29623 status = B_FALSE; 26653859Sml29623 } 26663859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 26676929Smisaki " <== nxge_check_rxdma_rdcgrp_member")); 26683859Sml29623 return (status); 26693859Sml29623 } 26703859Sml29623 26713859Sml29623 boolean_t 26723859Sml29623 nxge_check_rdcgrp_port_member(p_nxge_t nxgep, uint8_t rdc_grp) 26733859Sml29623 { 26743859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 26753859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 26763859Sml29623 int status = B_TRUE; 26773859Sml29623 26783859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rdcgrp_port_member")); 26793859Sml29623 26803859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 26813859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 26823859Sml29623 26833859Sml29623 if (rdc_grp >= p_cfgp->max_rdc_grpids) 26843859Sml29623 status = B_FALSE; 26853859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rdcgrp_port_member")); 26863859Sml29623 return (status); 26873859Sml29623 } 26883859Sml29623 26893859Sml29623 static void 26903859Sml29623 nxge_set_hw_vlan_class_config(p_nxge_t nxgep) 26913859Sml29623 { 26923859Sml29623 int i; 26933859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 26943859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 26953859Sml29623 p_nxge_param_t param_arr; 26963859Sml29623 uint_t vlan_cnt; 26973859Sml29623 int *vlan_cfg_val; 26983859Sml29623 nxge_param_map_t *vmap; 26993859Sml29623 char *prop; 27003859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 27013859Sml29623 uint32_t good_cfg[32]; 27023859Sml29623 int good_count = 0; 27033859Sml29623 nxge_mv_cfg_t *vlan_tbl; 27043859Sml29623 27053859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_hw_vlan_config")); 27063859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 27073859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 27083859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 27093859Sml29623 27103859Sml29623 param_arr = nxgep->param_arr; 27113859Sml29623 prop = param_arr[param_vlan_2rdc_grp].fcode_name; 27123859Sml29623 27133859Sml29623 /* 27143859Sml29623 * By default, VLAN to RDC group mapping is disabled Need to read HW or 27153859Sml29623 * .conf properties to find out if mapping is required 27163859Sml29623 * 27173859Sml29623 * Format 27183859Sml29623 * 27193859Sml29623 * uint32_t array, each array entry specifying the VLAN id and the 27203859Sml29623 * mapping 27213859Sml29623 * 27223859Sml29623 * bit[30] = add bit[29] = remove bit[28] = preference bits[23-16] = 27233859Sml29623 * rdcgrp bits[15-0] = VLAN ID ( ) 27243859Sml29623 */ 27253859Sml29623 27263859Sml29623 for (i = 0; i < NXGE_MAX_VLANS; i++) { 27273859Sml29623 p_class_cfgp->vlan_tbl[i].flag = 0; 27283859Sml29623 } 27293859Sml29623 27303859Sml29623 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0]; 27313859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 27326929Smisaki &vlan_cfg_val, &vlan_cnt) == DDI_PROP_SUCCESS) { 27333859Sml29623 for (i = 0; i < vlan_cnt; i++) { 27343859Sml29623 vmap = (nxge_param_map_t *)&vlan_cfg_val[i]; 27353859Sml29623 if ((vmap->param_id) && 27366929Smisaki (vmap->param_id < NXGE_MAX_VLANS) && 27376929Smisaki (vmap->map_to < 27386929Smisaki p_cfgp->max_rdc_grpids) && 27396929Smisaki (vmap->map_to >= (uint8_t)0)) { 27403859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 27416929Smisaki " nxge_vlan_config mapping" 27426929Smisaki " id %d grp %d", 27436929Smisaki vmap->param_id, vmap->map_to)); 27443859Sml29623 good_cfg[good_count] = vlan_cfg_val[i]; 27453859Sml29623 if (vlan_tbl[vmap->param_id].flag == 0) 27463859Sml29623 good_count++; 27473859Sml29623 vlan_tbl[vmap->param_id].flag = 1; 27483859Sml29623 vlan_tbl[vmap->param_id].rdctbl = 27496495Sspeer vmap->map_to + p_cfgp->def_mac_rxdma_grpid; 27503859Sml29623 vlan_tbl[vmap->param_id].mpr_npr = vmap->pref; 27513859Sml29623 } 27523859Sml29623 } 27533859Sml29623 ddi_prop_free(vlan_cfg_val); 27543859Sml29623 if (good_count != vlan_cnt) { 27553859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 27566929Smisaki nxgep->dip, prop, (int *)good_cfg, good_count); 27573859Sml29623 } 27583859Sml29623 } 27593859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_set_hw_vlan_config")); 27603859Sml29623 } 27613859Sml29623 27623859Sml29623 static void 27633859Sml29623 nxge_set_hw_mac_class_config(p_nxge_t nxgep) 27643859Sml29623 { 27653859Sml29623 int i; 27663859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 27673859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 27683859Sml29623 p_nxge_param_t param_arr; 27693859Sml29623 uint_t mac_cnt; 27703859Sml29623 int *mac_cfg_val; 27713859Sml29623 nxge_param_map_t *mac_map; 27723859Sml29623 char *prop; 27733859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 27743859Sml29623 int good_count = 0; 27753859Sml29623 int good_cfg[NXGE_MAX_MACS]; 27763859Sml29623 nxge_mv_cfg_t *mac_host_info; 27773859Sml29623 27783859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_set_hw_mac_config")); 27793859Sml29623 27803859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 27813859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 27823859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 27833859Sml29623 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0]; 27843859Sml29623 27853859Sml29623 param_arr = nxgep->param_arr; 27863859Sml29623 prop = param_arr[param_mac_2rdc_grp].fcode_name; 27873859Sml29623 27883859Sml29623 for (i = 0; i < NXGE_MAX_MACS; i++) { 27893859Sml29623 p_class_cfgp->mac_host_info[i].flag = 0; 27904484Sspeer p_class_cfgp->mac_host_info[i].rdctbl = 27914484Sspeer p_cfgp->def_mac_rxdma_grpid; 27923859Sml29623 } 27933859Sml29623 27943859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 27956929Smisaki &mac_cfg_val, &mac_cnt) == DDI_PROP_SUCCESS) { 27963859Sml29623 for (i = 0; i < mac_cnt; i++) { 27973859Sml29623 mac_map = (nxge_param_map_t *)&mac_cfg_val[i]; 27983859Sml29623 if ((mac_map->param_id < p_cfgp->max_macs) && 27996929Smisaki (mac_map->map_to < 28006929Smisaki p_cfgp->max_rdc_grpids) && 28016929Smisaki (mac_map->map_to >= (uint8_t)0)) { 28023859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 28036929Smisaki " nxge_mac_config mapping" 28046929Smisaki " id %d grp %d", 28056929Smisaki mac_map->param_id, mac_map->map_to)); 28063859Sml29623 mac_host_info[mac_map->param_id].mpr_npr = 28078275SEric Cheng p_cfgp->mac_pref; 28083859Sml29623 mac_host_info[mac_map->param_id].rdctbl = 28096929Smisaki mac_map->map_to + 28106929Smisaki p_cfgp->def_mac_rxdma_grpid; 28113859Sml29623 good_cfg[good_count] = mac_cfg_val[i]; 28123859Sml29623 if (mac_host_info[mac_map->param_id].flag == 0) 28133859Sml29623 good_count++; 28143859Sml29623 mac_host_info[mac_map->param_id].flag = 1; 28153859Sml29623 } 28163859Sml29623 } 28173859Sml29623 ddi_prop_free(mac_cfg_val); 28183859Sml29623 if (good_count != mac_cnt) { 28193859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 28206929Smisaki nxgep->dip, prop, good_cfg, good_count); 28213859Sml29623 } 28223859Sml29623 } 28233859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_set_hw_mac_config")); 28243859Sml29623 } 28253859Sml29623 28263859Sml29623 static void 28273859Sml29623 nxge_set_hw_class_config(p_nxge_t nxgep) 28283859Sml29623 { 28293859Sml29623 int i; 28303859Sml29623 p_nxge_param_t param_arr; 28313859Sml29623 int *int_prop_val; 28323859Sml29623 uint32_t cfg_value; 28333859Sml29623 char *prop; 28343859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 28353859Sml29623 int start_prop, end_prop; 28363859Sml29623 uint_t prop_cnt; 28379005SSantwona.Behera@Sun.COM int start_class, j = 0; 28383859Sml29623 28393859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_hw_class_config")); 28403859Sml29623 28413859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 28423859Sml29623 param_arr = nxgep->param_arr; 28439005SSantwona.Behera@Sun.COM start_prop = param_class_opt_ipv4_tcp; 28443859Sml29623 end_prop = param_class_opt_ipv6_sctp; 28459005SSantwona.Behera@Sun.COM start_class = TCAM_CLASS_TCP_IPV4; 28469005SSantwona.Behera@Sun.COM 28479005SSantwona.Behera@Sun.COM for (i = start_prop, j = 0; i <= end_prop; i++, j++) { 28483859Sml29623 prop = param_arr[i].fcode_name; 28493859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 28506929Smisaki 0, prop, &int_prop_val, 28516929Smisaki &prop_cnt) == DDI_PROP_SUCCESS) { 28523859Sml29623 cfg_value = (uint32_t)*int_prop_val; 28533859Sml29623 ddi_prop_free(int_prop_val); 28543859Sml29623 } else { 28553859Sml29623 cfg_value = (uint32_t)param_arr[i].value; 28563859Sml29623 } 28579005SSantwona.Behera@Sun.COM p_class_cfgp->class_cfg[start_class + j] = cfg_value; 28583859Sml29623 } 28593859Sml29623 28603859Sml29623 prop = param_arr[param_h1_init_value].fcode_name; 28613859Sml29623 28623859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 28636929Smisaki &int_prop_val, &prop_cnt) == DDI_PROP_SUCCESS) { 28643859Sml29623 cfg_value = (uint32_t)*int_prop_val; 28653859Sml29623 ddi_prop_free(int_prop_val); 28663859Sml29623 } else { 28673859Sml29623 cfg_value = (uint32_t)param_arr[param_h1_init_value].value; 28683859Sml29623 } 28693859Sml29623 28703859Sml29623 p_class_cfgp->init_h1 = (uint32_t)cfg_value; 28713859Sml29623 prop = param_arr[param_h2_init_value].fcode_name; 28723859Sml29623 28733859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 28746929Smisaki &int_prop_val, &prop_cnt) == DDI_PROP_SUCCESS) { 28753859Sml29623 cfg_value = (uint32_t)*int_prop_val; 28763859Sml29623 ddi_prop_free(int_prop_val); 28773859Sml29623 } else { 28783859Sml29623 cfg_value = (uint32_t)param_arr[param_h2_init_value].value; 28793859Sml29623 } 28803859Sml29623 28813859Sml29623 p_class_cfgp->init_h2 = (uint16_t)cfg_value; 28823859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_hw_class_config")); 28833859Sml29623 } 28843859Sml29623 28853859Sml29623 nxge_status_t 28863859Sml29623 nxge_ldgv_init_n2(p_nxge_t nxgep, int *navail_p, int *nrequired_p) 28873859Sml29623 { 28886495Sspeer int i, maxldvs, maxldgs, nldvs; 28893859Sml29623 int ldv, endldg; 28903859Sml29623 uint8_t func; 28913859Sml29623 uint8_t channel; 28923859Sml29623 uint8_t chn_start; 28933859Sml29623 boolean_t own_sys_err = B_FALSE, own_fzc = B_FALSE; 28943859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 28953859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 28963859Sml29623 p_nxge_ldgv_t ldgvp; 28973859Sml29623 p_nxge_ldg_t ldgp, ptr; 28987466SMisaki.Kataoka@Sun.COM p_nxge_ldv_t ldvp, sysldvp; 28993859Sml29623 nxge_status_t status = NXGE_OK; 29006495Sspeer nxge_grp_set_t *set; 29013859Sml29623 29023859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2")); 29033859Sml29623 if (!*navail_p) { 29043859Sml29623 *nrequired_p = 0; 29053859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 29066929Smisaki "<== nxge_ldgv_init:no avail")); 29073859Sml29623 return (NXGE_ERROR); 29083859Sml29623 } 29093859Sml29623 /* 29103859Sml29623 * N2/NIU: one logical device owns one logical group. and each 29113859Sml29623 * device/group will be assigned one vector by Hypervisor. 29123859Sml29623 */ 29133859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 29143859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 29153859Sml29623 maxldgs = p_cfgp->max_ldgs; 29163859Sml29623 if (!maxldgs) { 29173859Sml29623 /* No devices configured. */ 29183859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_init_n2: " 29196929Smisaki "no logical groups configured.")); 29203859Sml29623 return (NXGE_ERROR); 29213859Sml29623 } else { 29223859Sml29623 maxldvs = maxldgs + 1; 29233859Sml29623 } 29243859Sml29623 29253859Sml29623 /* 29263859Sml29623 * If function zero instance, it needs to handle the system and MIF 29273859Sml29623 * error interrupts. MIF interrupt may not be needed for N2/NIU. 29283859Sml29623 */ 29293859Sml29623 func = nxgep->function_num; 29303859Sml29623 if (func == 0) { 29313859Sml29623 own_sys_err = B_TRUE; 29323859Sml29623 if (!p_cfgp->ser_ldvid) { 29333859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 29346929Smisaki "nxge_ldgv_init_n2: func 0, ERR ID not set!")); 29353859Sml29623 } 29363859Sml29623 /* MIF interrupt */ 29373859Sml29623 if (!p_cfgp->mif_ldvid) { 29383859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 29396929Smisaki "nxge_ldgv_init_n2: func 0, MIF ID not set!")); 29403859Sml29623 } 29413859Sml29623 } 29423859Sml29623 29433859Sml29623 /* 29443859Sml29623 * Assume single partition, each function owns mac. 29453859Sml29623 */ 29463859Sml29623 if (!nxge_use_partition) 29473859Sml29623 own_fzc = B_TRUE; 29483859Sml29623 29493859Sml29623 ldgvp = nxgep->ldgvp; 29503859Sml29623 if (ldgvp == NULL) { 29513859Sml29623 ldgvp = KMEM_ZALLOC(sizeof (nxge_ldgv_t), KM_SLEEP); 29523859Sml29623 nxgep->ldgvp = ldgvp; 29533859Sml29623 ldgvp->maxldgs = (uint8_t)maxldgs; 29543859Sml29623 ldgvp->maxldvs = (uint8_t)maxldvs; 29556495Sspeer ldgp = ldgvp->ldgp = KMEM_ZALLOC( 29566929Smisaki sizeof (nxge_ldg_t) * maxldgs, KM_SLEEP); 29576495Sspeer ldvp = ldgvp->ldvp = KMEM_ZALLOC( 29586929Smisaki sizeof (nxge_ldv_t) * maxldvs, KM_SLEEP); 29593859Sml29623 } else { 29603859Sml29623 ldgp = ldgvp->ldgp; 29613859Sml29623 ldvp = ldgvp->ldvp; 29623859Sml29623 } 29633859Sml29623 29646495Sspeer ldgvp->ndma_ldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs; 29653859Sml29623 ldgvp->tmres = NXGE_TIMER_RESO; 29663859Sml29623 29673859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 29686929Smisaki "==> nxge_ldgv_init_n2: maxldvs %d maxldgs %d", 29696929Smisaki maxldvs, maxldgs)); 29703859Sml29623 29713859Sml29623 /* logical start_ldg is ldv */ 29723859Sml29623 ptr = ldgp; 29733859Sml29623 for (i = 0; i < maxldgs; i++) { 29743859Sml29623 ptr->func = func; 29753859Sml29623 ptr->arm = B_TRUE; 29763859Sml29623 ptr->vldg_index = (uint8_t)i; 29773859Sml29623 ptr->ldg_timer = NXGE_TIMER_LDG; 29783859Sml29623 ptr->ldg = p_cfgp->ldg[i]; 29793859Sml29623 ptr->sys_intr_handler = nxge_intr; 29803859Sml29623 ptr->nldvs = 0; 29813859Sml29623 ptr->ldvp = NULL; 29823859Sml29623 ptr->nxgep = nxgep; 29833859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 29846929Smisaki "==> nxge_ldgv_init_n2: maxldvs %d maxldgs %d " 29856929Smisaki "ldg %d ldgptr $%p", 29866929Smisaki maxldvs, maxldgs, ptr->ldg, ptr)); 29873859Sml29623 ptr++; 29883859Sml29623 } 29893859Sml29623 29903859Sml29623 endldg = NXGE_INT_MAX_LDG; 29913859Sml29623 nldvs = 0; 29923859Sml29623 ldgvp->nldvs = 0; 29933859Sml29623 ldgp->ldvp = NULL; 29943859Sml29623 *nrequired_p = 0; 29953859Sml29623 29963859Sml29623 /* 29973859Sml29623 * logical device group table is organized in the following order (same 29983859Sml29623 * as what interrupt property has). function 0: owns MAC, MIF, error, 29993859Sml29623 * rx, tx. function 1: owns MAC, rx, tx. 30003859Sml29623 */ 30013859Sml29623 30023859Sml29623 if (own_fzc && p_cfgp->mac_ldvid) { 30033859Sml29623 /* Each function should own MAC interrupt */ 30043859Sml29623 ldv = p_cfgp->mac_ldvid; 30053859Sml29623 ldvp->ldv = (uint8_t)ldv; 30063859Sml29623 ldvp->is_mac = B_TRUE; 30073859Sml29623 ldvp->ldv_intr_handler = nxge_mac_intr; 30083859Sml29623 ldvp->ldv_ldf_masks = 0; 30093859Sml29623 ldvp->nxgep = nxgep; 30103859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 30116929Smisaki "==> nxge_ldgv_init_n2(mac): maxldvs %d ldv %d " 30126929Smisaki "ldg %d ldgptr $%p ldvptr $%p", 30136929Smisaki maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 30143859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 30153859Sml29623 nldvs++; 30163859Sml29623 } 30173859Sml29623 30183859Sml29623 if (own_fzc && p_cfgp->mif_ldvid) { 30193859Sml29623 ldv = p_cfgp->mif_ldvid; 30203859Sml29623 ldvp->ldv = (uint8_t)ldv; 30213859Sml29623 ldvp->is_mif = B_TRUE; 30223859Sml29623 ldvp->ldv_intr_handler = nxge_mif_intr; 30233859Sml29623 ldvp->ldv_ldf_masks = 0; 30243859Sml29623 ldvp->nxgep = nxgep; 30253859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 30266929Smisaki "==> nxge_ldgv_init_n2(mif): maxldvs %d ldv %d " 30276929Smisaki "ldg %d ldgptr $%p ldvptr $%p", 30286929Smisaki maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 30293859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 30303859Sml29623 nldvs++; 30313859Sml29623 } 30323859Sml29623 30337466SMisaki.Kataoka@Sun.COM /* 30348275SEric Cheng * HW based syserr interrupt for port0, and SW based syserr interrupt 30358275SEric Cheng * for port1 30367466SMisaki.Kataoka@Sun.COM */ 30373859Sml29623 if (own_sys_err && p_cfgp->ser_ldvid) { 30383859Sml29623 ldv = p_cfgp->ser_ldvid; 30393859Sml29623 /* 30403859Sml29623 * Unmask the system interrupt states. 30413859Sml29623 */ 30423859Sml29623 (void) nxge_fzc_sys_err_mask_set(nxgep, SYS_ERR_SMX_MASK | 30436929Smisaki SYS_ERR_IPP_MASK | SYS_ERR_TXC_MASK | 30446929Smisaki SYS_ERR_ZCP_MASK); 30457466SMisaki.Kataoka@Sun.COM 30467466SMisaki.Kataoka@Sun.COM ldvp->use_timer = B_TRUE; 30477466SMisaki.Kataoka@Sun.COM ldvp->ldv = (uint8_t)ldv; 30487466SMisaki.Kataoka@Sun.COM ldvp->is_syserr = B_TRUE; 30497466SMisaki.Kataoka@Sun.COM ldvp->ldv_intr_handler = nxge_syserr_intr; 30507466SMisaki.Kataoka@Sun.COM ldvp->ldv_ldf_masks = 0; 30517466SMisaki.Kataoka@Sun.COM ldvp->nxgep = nxgep; 30527466SMisaki.Kataoka@Sun.COM ldgvp->ldvp_syserr = ldvp; 30537466SMisaki.Kataoka@Sun.COM 30547466SMisaki.Kataoka@Sun.COM NXGE_DEBUG_MSG((nxgep, INT_CTL, 30557466SMisaki.Kataoka@Sun.COM "==> nxge_ldgv_init_n2(syserr): maxldvs %d ldv %d " 30567466SMisaki.Kataoka@Sun.COM "ldg %d ldgptr $%p ldvptr p%p", 30577466SMisaki.Kataoka@Sun.COM maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 30587466SMisaki.Kataoka@Sun.COM nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 30597466SMisaki.Kataoka@Sun.COM nldvs++; 30607466SMisaki.Kataoka@Sun.COM } else { 30617466SMisaki.Kataoka@Sun.COM /* 30628275SEric Cheng * SW based: allocate the ldv for the syserr since the vector 30638275SEric Cheng * should not be consumed for port1 30647466SMisaki.Kataoka@Sun.COM */ 30657466SMisaki.Kataoka@Sun.COM sysldvp = KMEM_ZALLOC(sizeof (nxge_ldv_t), KM_SLEEP); 30667466SMisaki.Kataoka@Sun.COM sysldvp->use_timer = B_TRUE; 30677466SMisaki.Kataoka@Sun.COM sysldvp->ldv = NXGE_SYS_ERROR_LD; 30687466SMisaki.Kataoka@Sun.COM sysldvp->is_syserr = B_TRUE; 30697466SMisaki.Kataoka@Sun.COM sysldvp->ldv_intr_handler = nxge_syserr_intr; 30707466SMisaki.Kataoka@Sun.COM sysldvp->ldv_ldf_masks = 0; 30717466SMisaki.Kataoka@Sun.COM sysldvp->nxgep = nxgep; 30727466SMisaki.Kataoka@Sun.COM ldgvp->ldvp_syserr = sysldvp; 30738275SEric Cheng ldgvp->ldvp_syserr_alloced = B_TRUE; 30743859Sml29623 } 30753859Sml29623 30768275SEric Cheng 30773859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 30786929Smisaki "(before rx) func %d nldvs %d navail %d nrequired %d", 30796929Smisaki func, nldvs, *navail_p, *nrequired_p)); 30803859Sml29623 30813859Sml29623 /* 30823859Sml29623 * Start with RDC to configure logical devices for each group. 30833859Sml29623 */ 30846495Sspeer chn_start = p_cfgp->ldg_chn_start; 30856495Sspeer set = &nxgep->rx_set; 30866495Sspeer for (channel = 0; channel < NXGE_MAX_RDCS; channel++) { 30876495Sspeer if ((1 << channel) & set->owned.map) { 30886495Sspeer ldvp->is_rxdma = B_TRUE; 30896495Sspeer ldvp->ldv = (uint8_t)channel + NXGE_RDMA_LD_START; 30906495Sspeer ldvp->channel = channel; 30916495Sspeer ldvp->vdma_index = (uint8_t)channel; 30926495Sspeer ldvp->ldv_intr_handler = nxge_rx_intr; 30936495Sspeer ldvp->ldv_ldf_masks = 0; 30946495Sspeer ldvp->nxgep = nxgep; 30956495Sspeer ldgp->ldg = p_cfgp->ldg[chn_start]; 30966495Sspeer 30976495Sspeer NXGE_DEBUG_MSG((nxgep, INT_CTL, 30986495Sspeer "==> nxge_ldgv_init_n2(rx%d): maxldvs %d ldv %d " 30996495Sspeer "ldg %d ldgptr 0x%016llx ldvptr 0x%016llx", 31006495Sspeer i, maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 31016495Sspeer nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv, 31026495Sspeer endldg, nrequired_p); 31036495Sspeer nldvs++; 31046495Sspeer chn_start++; 31056495Sspeer } 31063859Sml29623 } 31073859Sml29623 31083859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 31096929Smisaki "func %d nldvs %d navail %d nrequired %d", 31106929Smisaki func, nldvs, *navail_p, *nrequired_p)); 31113859Sml29623 31123859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 31136929Smisaki "func %d nldvs %d navail %d nrequired %d ldgp 0x%llx " 31146929Smisaki "ldvp 0x%llx", 31156929Smisaki func, nldvs, *navail_p, *nrequired_p, ldgp, ldvp)); 31163859Sml29623 /* 31173859Sml29623 * Transmit DMA channels. 31183859Sml29623 */ 31196495Sspeer chn_start = p_cfgp->ldg_chn_start + 8; 31206495Sspeer set = &nxgep->tx_set; 31216495Sspeer for (channel = 0; channel < NXGE_MAX_TDCS; channel++) { 31226495Sspeer if ((1 << channel) & set->owned.map) { 31236495Sspeer ldvp->is_txdma = B_TRUE; 31246495Sspeer ldvp->ldv = (uint8_t)channel + NXGE_TDMA_LD_START; 31256495Sspeer ldvp->channel = channel; 31266495Sspeer ldvp->vdma_index = (uint8_t)channel; 31276495Sspeer ldvp->ldv_intr_handler = nxge_tx_intr; 31286495Sspeer ldvp->ldv_ldf_masks = 0; 31296495Sspeer ldgp->ldg = p_cfgp->ldg[chn_start]; 31306495Sspeer ldvp->nxgep = nxgep; 31316495Sspeer NXGE_DEBUG_MSG((nxgep, INT_CTL, 31326495Sspeer "==> nxge_ldgv_init_n2(tx%d): maxldvs %d ldv %d " 31336495Sspeer "ldg %d ldgptr %p ldvptr %p", 31346495Sspeer channel, maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 31356495Sspeer nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv, 31366495Sspeer endldg, nrequired_p); 31376495Sspeer nldvs++; 31386495Sspeer chn_start++; 31396495Sspeer } 31403859Sml29623 } 31413859Sml29623 31423859Sml29623 ldgvp->ldg_intrs = *nrequired_p; 31433859Sml29623 ldgvp->nldvs = (uint8_t)nldvs; 31443859Sml29623 31453859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 31466929Smisaki "func %d nldvs %d maxgrps %d navail %d nrequired %d", 31476929Smisaki func, nldvs, maxldgs, *navail_p, *nrequired_p)); 31483859Sml29623 31493859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_init_n2")); 31503859Sml29623 return (status); 31513859Sml29623 } 31523859Sml29623 31533859Sml29623 /* 31543859Sml29623 * Interrupts related interface functions. 31553859Sml29623 */ 31563859Sml29623 31573859Sml29623 nxge_status_t 31583859Sml29623 nxge_ldgv_init(p_nxge_t nxgep, int *navail_p, int *nrequired_p) 31593859Sml29623 { 31606495Sspeer int i, maxldvs, maxldgs, nldvs; 31613859Sml29623 int ldv, ldg, endldg, ngrps; 31623859Sml29623 uint8_t func; 31633859Sml29623 uint8_t channel; 31643859Sml29623 boolean_t own_sys_err = B_FALSE, own_fzc = B_FALSE; 31653859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 31663859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 31673859Sml29623 p_nxge_ldgv_t ldgvp; 31683859Sml29623 p_nxge_ldg_t ldgp, ptr; 31693859Sml29623 p_nxge_ldv_t ldvp; 31706495Sspeer nxge_grp_set_t *set; 31716495Sspeer 31723859Sml29623 nxge_status_t status = NXGE_OK; 31733859Sml29623 31743859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init")); 31753859Sml29623 if (!*navail_p) { 31763859Sml29623 *nrequired_p = 0; 31773859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 31786929Smisaki "<== nxge_ldgv_init:no avail")); 31793859Sml29623 return (NXGE_ERROR); 31803859Sml29623 } 31813859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 31823859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 31833859Sml29623 31846495Sspeer nldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs; 31853859Sml29623 31863859Sml29623 /* 31873859Sml29623 * If function zero instance, it needs to handle the system error 31883859Sml29623 * interrupts. 31893859Sml29623 */ 31903859Sml29623 func = nxgep->function_num; 31913859Sml29623 if (func == 0) { 31923859Sml29623 nldvs++; 31933859Sml29623 own_sys_err = B_TRUE; 31943859Sml29623 } else { 31953859Sml29623 /* use timer */ 31963859Sml29623 nldvs++; 31973859Sml29623 } 31983859Sml29623 31993859Sml29623 /* 32003859Sml29623 * Assume single partition, each function owns mac. 32013859Sml29623 */ 32023859Sml29623 if (!nxge_use_partition) { 32033859Sml29623 /* mac */ 32043859Sml29623 nldvs++; 32053859Sml29623 /* MIF */ 32063859Sml29623 nldvs++; 32073859Sml29623 own_fzc = B_TRUE; 32083859Sml29623 } 32093859Sml29623 maxldvs = nldvs; 32103859Sml29623 maxldgs = p_cfgp->max_ldgs; 32113859Sml29623 if (!maxldvs || !maxldgs) { 32123859Sml29623 /* No devices configured. */ 32133859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_init: " 32146929Smisaki "no logical devices or groups configured.")); 32153859Sml29623 return (NXGE_ERROR); 32163859Sml29623 } 32173859Sml29623 ldgvp = nxgep->ldgvp; 32183859Sml29623 if (ldgvp == NULL) { 32193859Sml29623 ldgvp = KMEM_ZALLOC(sizeof (nxge_ldgv_t), KM_SLEEP); 32203859Sml29623 nxgep->ldgvp = ldgvp; 32213859Sml29623 ldgvp->maxldgs = (uint8_t)maxldgs; 32223859Sml29623 ldgvp->maxldvs = (uint8_t)maxldvs; 32233859Sml29623 ldgp = ldgvp->ldgp = KMEM_ZALLOC(sizeof (nxge_ldg_t) * maxldgs, 32246929Smisaki KM_SLEEP); 32253859Sml29623 ldvp = ldgvp->ldvp = KMEM_ZALLOC(sizeof (nxge_ldv_t) * maxldvs, 32266929Smisaki KM_SLEEP); 32273859Sml29623 } 32286495Sspeer ldgvp->ndma_ldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs; 32293859Sml29623 ldgvp->tmres = NXGE_TIMER_RESO; 32303859Sml29623 32313859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32326929Smisaki "==> nxge_ldgv_init: maxldvs %d maxldgs %d nldvs %d", 32336929Smisaki maxldvs, maxldgs, nldvs)); 32343859Sml29623 ldg = p_cfgp->start_ldg; 32353859Sml29623 ptr = ldgp; 32363859Sml29623 for (i = 0; i < maxldgs; i++) { 32373859Sml29623 ptr->func = func; 32383859Sml29623 ptr->arm = B_TRUE; 32393859Sml29623 ptr->vldg_index = (uint8_t)i; 32403859Sml29623 ptr->ldg_timer = NXGE_TIMER_LDG; 32413859Sml29623 ptr->ldg = ldg++; 32423859Sml29623 ptr->sys_intr_handler = nxge_intr; 32433859Sml29623 ptr->nldvs = 0; 32443859Sml29623 ptr->nxgep = nxgep; 32453859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32466929Smisaki "==> nxge_ldgv_init: maxldvs %d maxldgs %d ldg %d", 32476929Smisaki maxldvs, maxldgs, ptr->ldg)); 32483859Sml29623 ptr++; 32493859Sml29623 } 32503859Sml29623 32513859Sml29623 ldg = p_cfgp->start_ldg; 32523859Sml29623 if (maxldgs > *navail_p) { 32533859Sml29623 ngrps = *navail_p; 32543859Sml29623 } else { 32553859Sml29623 ngrps = maxldgs; 32563859Sml29623 } 32573859Sml29623 endldg = ldg + ngrps; 32583859Sml29623 32593859Sml29623 /* 32603859Sml29623 * Receive DMA channels. 32613859Sml29623 */ 32623859Sml29623 nldvs = 0; 32633859Sml29623 ldgvp->nldvs = 0; 32643859Sml29623 ldgp->ldvp = NULL; 32653859Sml29623 *nrequired_p = 0; 32663859Sml29623 32673859Sml29623 /* 32683859Sml29623 * Start with RDC to configure logical devices for each group. 32693859Sml29623 */ 32706495Sspeer set = &nxgep->rx_set; 32716495Sspeer for (channel = 0; channel < NXGE_MAX_RDCS; channel++) { 32726495Sspeer if ((1 << channel) & set->owned.map) { 32736495Sspeer /* For now, <channel & <vdma_index> are the same. */ 32746495Sspeer ldvp->is_rxdma = B_TRUE; 32756495Sspeer ldvp->ldv = (uint8_t)channel + NXGE_RDMA_LD_START; 32766495Sspeer ldvp->channel = channel; 32776495Sspeer ldvp->vdma_index = (uint8_t)channel; 32786495Sspeer ldvp->ldv_intr_handler = nxge_rx_intr; 32796495Sspeer ldvp->ldv_ldf_masks = 0; 32806495Sspeer ldvp->use_timer = B_FALSE; 32816495Sspeer ldvp->nxgep = nxgep; 32826495Sspeer nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv, 32836495Sspeer endldg, nrequired_p); 32846495Sspeer nldvs++; 32856495Sspeer } 32863859Sml29623 } 32873859Sml29623 32883859Sml29623 /* 32893859Sml29623 * Transmit DMA channels. 32903859Sml29623 */ 32916495Sspeer set = &nxgep->tx_set; 32926495Sspeer for (channel = 0; channel < NXGE_MAX_TDCS; channel++) { 32936495Sspeer if ((1 << channel) & set->owned.map) { 32946495Sspeer /* For now, <channel & <vdma_index> are the same. */ 32956495Sspeer ldvp->is_txdma = B_TRUE; 32966495Sspeer ldvp->ldv = (uint8_t)channel + NXGE_TDMA_LD_START; 32976495Sspeer ldvp->channel = channel; 32986495Sspeer ldvp->vdma_index = (uint8_t)channel; 32996495Sspeer ldvp->ldv_intr_handler = nxge_tx_intr; 33006495Sspeer ldvp->ldv_ldf_masks = 0; 33016495Sspeer ldvp->use_timer = B_FALSE; 33026495Sspeer ldvp->nxgep = nxgep; 33036495Sspeer nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv, 33046495Sspeer endldg, nrequired_p); 33056495Sspeer nldvs++; 33066495Sspeer } 33073859Sml29623 } 33083859Sml29623 33093859Sml29623 if (own_fzc) { 33103859Sml29623 ldv = NXGE_MIF_LD; 33113859Sml29623 ldvp->ldv = (uint8_t)ldv; 33123859Sml29623 ldvp->is_mif = B_TRUE; 33133859Sml29623 ldvp->ldv_intr_handler = nxge_mif_intr; 33143859Sml29623 ldvp->ldv_ldf_masks = 0; 33153859Sml29623 ldvp->use_timer = B_FALSE; 33163859Sml29623 ldvp->nxgep = nxgep; 33173859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 33183859Sml29623 nldvs++; 33193859Sml29623 } 33203859Sml29623 /* 33213859Sml29623 * MAC port (function zero control) 33223859Sml29623 */ 33233859Sml29623 if (own_fzc) { 33243859Sml29623 ldvp->is_mac = B_TRUE; 33253859Sml29623 ldvp->ldv_intr_handler = nxge_mac_intr; 33263859Sml29623 ldvp->ldv_ldf_masks = 0; 33273859Sml29623 ldv = func + NXGE_MAC_LD_START; 33283859Sml29623 ldvp->ldv = (uint8_t)ldv; 33293859Sml29623 ldvp->use_timer = B_FALSE; 33303859Sml29623 ldvp->nxgep = nxgep; 33313859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 33323859Sml29623 nldvs++; 33333859Sml29623 } 33343859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init: " 33356929Smisaki "func %d nldvs %d navail %d nrequired %d", 33366929Smisaki func, nldvs, *navail_p, *nrequired_p)); 33373859Sml29623 /* 33383859Sml29623 * Function 0 owns system error interrupts. 33393859Sml29623 */ 33403859Sml29623 ldvp->use_timer = B_TRUE; 33413859Sml29623 if (own_sys_err) { 33423859Sml29623 ldv = NXGE_SYS_ERROR_LD; 33433859Sml29623 ldvp->ldv = (uint8_t)ldv; 33443859Sml29623 ldvp->is_syserr = B_TRUE; 33453859Sml29623 ldvp->ldv_intr_handler = nxge_syserr_intr; 33463859Sml29623 ldvp->ldv_ldf_masks = 0; 33473859Sml29623 ldvp->nxgep = nxgep; 33483859Sml29623 ldgvp->ldvp_syserr = ldvp; 33493859Sml29623 /* 33503859Sml29623 * Unmask the system interrupt states. 33513859Sml29623 */ 33523859Sml29623 (void) nxge_fzc_sys_err_mask_set(nxgep, SYS_ERR_SMX_MASK | 33536929Smisaki SYS_ERR_IPP_MASK | SYS_ERR_TXC_MASK | 33546929Smisaki SYS_ERR_ZCP_MASK); 33553859Sml29623 33563859Sml29623 (void) nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 33573859Sml29623 nldvs++; 33583859Sml29623 } else { 33593859Sml29623 ldv = NXGE_SYS_ERROR_LD; 33603859Sml29623 ldvp->ldv = (uint8_t)ldv; 33613859Sml29623 ldvp->is_syserr = B_TRUE; 33623859Sml29623 ldvp->ldv_intr_handler = nxge_syserr_intr; 33633859Sml29623 ldvp->nxgep = nxgep; 33643859Sml29623 ldvp->ldv_ldf_masks = 0; 33653859Sml29623 ldgvp->ldvp_syserr = ldvp; 33663859Sml29623 } 33673859Sml29623 33683859Sml29623 ldgvp->ldg_intrs = *nrequired_p; 33693859Sml29623 33703859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init: " 33716929Smisaki "func %d nldvs %d navail %d nrequired %d", 33726929Smisaki func, nldvs, *navail_p, *nrequired_p)); 33733859Sml29623 33743859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_init")); 33753859Sml29623 return (status); 33763859Sml29623 } 33773859Sml29623 33783859Sml29623 nxge_status_t 33793859Sml29623 nxge_ldgv_uninit(p_nxge_t nxgep) 33803859Sml29623 { 33813859Sml29623 p_nxge_ldgv_t ldgvp; 33823859Sml29623 33833859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_uninit")); 33843859Sml29623 ldgvp = nxgep->ldgvp; 33853859Sml29623 if (ldgvp == NULL) { 33863859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_uninit: " 33876929Smisaki "no logical group configured.")); 33883859Sml29623 return (NXGE_OK); 33893859Sml29623 } 33908275SEric Cheng if (ldgvp->ldvp_syserr_alloced == B_TRUE) { 33917466SMisaki.Kataoka@Sun.COM KMEM_FREE(ldgvp->ldvp_syserr, sizeof (nxge_ldv_t)); 33927466SMisaki.Kataoka@Sun.COM } 33933859Sml29623 if (ldgvp->ldgp) { 33943859Sml29623 KMEM_FREE(ldgvp->ldgp, sizeof (nxge_ldg_t) * ldgvp->maxldgs); 33953859Sml29623 } 33963859Sml29623 if (ldgvp->ldvp) { 33973859Sml29623 KMEM_FREE(ldgvp->ldvp, sizeof (nxge_ldv_t) * ldgvp->maxldvs); 33983859Sml29623 } 33993859Sml29623 KMEM_FREE(ldgvp, sizeof (nxge_ldgv_t)); 34003859Sml29623 nxgep->ldgvp = NULL; 34013859Sml29623 34023859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_uninit")); 34033859Sml29623 return (NXGE_OK); 34043859Sml29623 } 34053859Sml29623 34063859Sml29623 nxge_status_t 34073859Sml29623 nxge_intr_ldgv_init(p_nxge_t nxgep) 34083859Sml29623 { 34093859Sml29623 nxge_status_t status = NXGE_OK; 34103859Sml29623 34113859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_ldgv_init")); 34123859Sml29623 /* 34133859Sml29623 * Configure the logical device group numbers, state vectors and 34143859Sml29623 * interrupt masks for each logical device. 34153859Sml29623 */ 34163859Sml29623 status = nxge_fzc_intr_init(nxgep); 34173859Sml29623 34183859Sml29623 /* 34193859Sml29623 * Configure logical device masks and timers. 34203859Sml29623 */ 34213859Sml29623 status = nxge_intr_mask_mgmt(nxgep); 34223859Sml29623 34233859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_ldgv_init")); 34243859Sml29623 return (status); 34253859Sml29623 } 34263859Sml29623 34273859Sml29623 nxge_status_t 34283859Sml29623 nxge_intr_mask_mgmt(p_nxge_t nxgep) 34293859Sml29623 { 34303859Sml29623 p_nxge_ldgv_t ldgvp; 34313859Sml29623 p_nxge_ldg_t ldgp; 34323859Sml29623 p_nxge_ldv_t ldvp; 34333859Sml29623 npi_handle_t handle; 34343859Sml29623 int i, j; 34353859Sml29623 npi_status_t rs = NPI_SUCCESS; 34363859Sml29623 34373859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_mask_mgmt")); 34383859Sml29623 34393859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) { 34403859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 34416929Smisaki "<== nxge_intr_mask_mgmt: Null ldgvp")); 34423859Sml29623 return (NXGE_ERROR); 34433859Sml29623 } 34443859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 34453859Sml29623 ldgp = ldgvp->ldgp; 34463859Sml29623 ldvp = ldgvp->ldvp; 34473859Sml29623 if (ldgp == NULL || ldvp == NULL) { 34483859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 34496929Smisaki "<== nxge_intr_mask_mgmt: Null ldgp or ldvp")); 34503859Sml29623 return (NXGE_ERROR); 34513859Sml29623 } 34523859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34536929Smisaki "==> nxge_intr_mask_mgmt: # of intrs %d ", ldgvp->ldg_intrs)); 34543859Sml29623 /* Initialize masks. */ 34553859Sml29623 if (nxgep->niu_type != N2_NIU) { 34563859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34576929Smisaki "==> nxge_intr_mask_mgmt(Neptune): # intrs %d ", 34586929Smisaki ldgvp->ldg_intrs)); 34593859Sml29623 for (i = 0; i < ldgvp->ldg_intrs; i++, ldgp++) { 34603859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34616929Smisaki "==> nxge_intr_mask_mgmt(Neptune): # ldv %d " 34626929Smisaki "in group %d", ldgp->nldvs, ldgp->ldg)); 34633859Sml29623 for (j = 0; j < ldgp->nldvs; j++, ldvp++) { 34643859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34656929Smisaki "==> nxge_intr_mask_mgmt: set ldv # %d " 34666929Smisaki "for ldg %d", ldvp->ldv, ldgp->ldg)); 34673859Sml29623 rs = npi_intr_mask_set(handle, ldvp->ldv, 34686929Smisaki ldvp->ldv_ldf_masks); 34693859Sml29623 if (rs != NPI_SUCCESS) { 34703859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 34716929Smisaki "<== nxge_intr_mask_mgmt: " 34726929Smisaki "set mask failed " 34736929Smisaki " rs 0x%x ldv %d mask 0x%x", 34746929Smisaki rs, ldvp->ldv, 34756929Smisaki ldvp->ldv_ldf_masks)); 34763859Sml29623 return (NXGE_ERROR | rs); 34773859Sml29623 } 34783859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34796929Smisaki "==> nxge_intr_mask_mgmt: " 34806929Smisaki "set mask OK " 34816929Smisaki " rs 0x%x ldv %d mask 0x%x", 34826929Smisaki rs, ldvp->ldv, 34836929Smisaki ldvp->ldv_ldf_masks)); 34843859Sml29623 } 34853859Sml29623 } 34863859Sml29623 } 34873859Sml29623 ldgp = ldgvp->ldgp; 34883859Sml29623 /* Configure timer and arm bit */ 34893859Sml29623 for (i = 0; i < nxgep->ldgvp->ldg_intrs; i++, ldgp++) { 34903859Sml29623 rs = npi_intr_ldg_mgmt_set(handle, ldgp->ldg, 34916929Smisaki ldgp->arm, ldgp->ldg_timer); 34923859Sml29623 if (rs != NPI_SUCCESS) { 34933859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 34946929Smisaki "<== nxge_intr_mask_mgmt: " 34956929Smisaki "set timer failed " 34966929Smisaki " rs 0x%x dg %d timer 0x%x", 34976929Smisaki rs, ldgp->ldg, ldgp->ldg_timer)); 34983859Sml29623 return (NXGE_ERROR | rs); 34993859Sml29623 } 35003859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35016929Smisaki "==> nxge_intr_mask_mgmt: " 35026929Smisaki "set timer OK " 35036929Smisaki " rs 0x%x ldg %d timer 0x%x", 35046929Smisaki rs, ldgp->ldg, ldgp->ldg_timer)); 35053859Sml29623 } 35063859Sml29623 35073859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_fzc_intr_mask_mgmt")); 35083859Sml29623 return (NXGE_OK); 35093859Sml29623 } 35103859Sml29623 35113859Sml29623 nxge_status_t 35123859Sml29623 nxge_intr_mask_mgmt_set(p_nxge_t nxgep, boolean_t on) 35133859Sml29623 { 35143859Sml29623 p_nxge_ldgv_t ldgvp; 35153859Sml29623 p_nxge_ldg_t ldgp; 35163859Sml29623 p_nxge_ldv_t ldvp; 35173859Sml29623 npi_handle_t handle; 35183859Sml29623 int i, j; 35193859Sml29623 npi_status_t rs = NPI_SUCCESS; 35203859Sml29623 35213859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35226929Smisaki "==> nxge_intr_mask_mgmt_set (%d)", on)); 35233859Sml29623 35243859Sml29623 if (nxgep->niu_type == N2_NIU) { 35253859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35266929Smisaki "<== nxge_intr_mask_mgmt_set (%d) not set (N2/NIU)", 35276929Smisaki on)); 35283859Sml29623 return (NXGE_ERROR); 35293859Sml29623 } 35303859Sml29623 35313859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) { 35323859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 35336929Smisaki "==> nxge_intr_mask_mgmt_set: Null ldgvp")); 35343859Sml29623 return (NXGE_ERROR); 35353859Sml29623 } 35363859Sml29623 35373859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 35383859Sml29623 ldgp = ldgvp->ldgp; 35393859Sml29623 ldvp = ldgvp->ldvp; 35403859Sml29623 if (ldgp == NULL || ldvp == NULL) { 35413859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 35426929Smisaki "<== nxge_intr_mask_mgmt_set: Null ldgp or ldvp")); 35433859Sml29623 return (NXGE_ERROR); 35443859Sml29623 } 35453859Sml29623 /* set masks. */ 35463859Sml29623 for (i = 0; i < ldgvp->ldg_intrs; i++, ldgp++) { 35473859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35486929Smisaki "==> nxge_intr_mask_mgmt_set: flag %d ldg %d" 35496929Smisaki "set mask nldvs %d", on, ldgp->ldg, ldgp->nldvs)); 35503859Sml29623 for (j = 0; j < ldgp->nldvs; j++, ldvp++) { 35513859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35526929Smisaki "==> nxge_intr_mask_mgmt_set: " 35536929Smisaki "for %d %d flag %d", i, j, on)); 35543859Sml29623 if (on) { 35553859Sml29623 ldvp->ldv_ldf_masks = 0; 35563859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35576929Smisaki "==> nxge_intr_mask_mgmt_set: " 35586929Smisaki "ON mask off")); 35593859Sml29623 } else if (!on) { 35603859Sml29623 ldvp->ldv_ldf_masks = (uint8_t)LD_IM1_MASK; 35613859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35626929Smisaki "==> nxge_intr_mask_mgmt_set:mask on")); 35633859Sml29623 } 35643859Sml29623 rs = npi_intr_mask_set(handle, ldvp->ldv, 35656929Smisaki ldvp->ldv_ldf_masks); 35663859Sml29623 if (rs != NPI_SUCCESS) { 35673859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 35686929Smisaki "==> nxge_intr_mask_mgmt_set: " 35696929Smisaki "set mask failed " 35706929Smisaki " rs 0x%x ldv %d mask 0x%x", 35716929Smisaki rs, ldvp->ldv, ldvp->ldv_ldf_masks)); 35723859Sml29623 return (NXGE_ERROR | rs); 35733859Sml29623 } 35743859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35756929Smisaki "==> nxge_intr_mask_mgmt_set: flag %d" 35766929Smisaki "set mask OK " 35776929Smisaki " ldv %d mask 0x%x", 35786929Smisaki on, ldvp->ldv, ldvp->ldv_ldf_masks)); 35793859Sml29623 } 35803859Sml29623 } 35813859Sml29623 35823859Sml29623 ldgp = ldgvp->ldgp; 35833859Sml29623 /* set the arm bit */ 35843859Sml29623 for (i = 0; i < nxgep->ldgvp->ldg_intrs; i++, ldgp++) { 35853859Sml29623 if (on && !ldgp->arm) { 35863859Sml29623 ldgp->arm = B_TRUE; 35873859Sml29623 } else if (!on && ldgp->arm) { 35883859Sml29623 ldgp->arm = B_FALSE; 35893859Sml29623 } 35903859Sml29623 rs = npi_intr_ldg_mgmt_set(handle, ldgp->ldg, 35916929Smisaki ldgp->arm, ldgp->ldg_timer); 35923859Sml29623 if (rs != NPI_SUCCESS) { 35933859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 35946929Smisaki "<== nxge_intr_mask_mgmt_set: " 35956929Smisaki "set timer failed " 35966929Smisaki " rs 0x%x ldg %d timer 0x%x", 35976929Smisaki rs, ldgp->ldg, ldgp->ldg_timer)); 35983859Sml29623 return (NXGE_ERROR | rs); 35993859Sml29623 } 36003859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 36016929Smisaki "==> nxge_intr_mask_mgmt_set: OK (flag %d) " 36026929Smisaki "set timer " 36036929Smisaki " ldg %d timer 0x%x", 36046929Smisaki on, ldgp->ldg, ldgp->ldg_timer)); 36053859Sml29623 } 36063859Sml29623 36073859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_mask_mgmt_set")); 36083859Sml29623 return (NXGE_OK); 36093859Sml29623 } 36103859Sml29623 36113859Sml29623 static nxge_status_t 36123859Sml29623 nxge_get_mac_addr_properties(p_nxge_t nxgep) 36133859Sml29623 { 36144732Sdavemq #if defined(_BIG_ENDIAN) 36153859Sml29623 uchar_t *prop_val; 36163859Sml29623 uint_t prop_len; 36174732Sdavemq uint_t j; 36184732Sdavemq #endif 36193859Sml29623 uint_t i; 36203859Sml29623 uint8_t func_num; 36214732Sdavemq boolean_t compute_macs = B_TRUE; 36223859Sml29623 36233859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_get_mac_addr_properties ")); 36243859Sml29623 36253859Sml29623 #if defined(_BIG_ENDIAN) 36263859Sml29623 /* 36273859Sml29623 * Get the ethernet address. 36283859Sml29623 */ 36293859Sml29623 (void) localetheraddr((struct ether_addr *)NULL, &nxgep->ouraddr); 36303859Sml29623 36313859Sml29623 /* 36323859Sml29623 * Check if it is an adapter with its own local mac address If it is 36333859Sml29623 * present, override the system mac address. 36343859Sml29623 */ 36353859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 36366929Smisaki "local-mac-address", &prop_val, 36376929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 36383859Sml29623 if (prop_len == ETHERADDRL) { 36393859Sml29623 nxgep->factaddr = *(p_ether_addr_t)prop_val; 36403859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "Local mac address = " 36416929Smisaki "%02x:%02x:%02x:%02x:%02x:%02x", 36426929Smisaki prop_val[0], prop_val[1], prop_val[2], 36436929Smisaki prop_val[3], prop_val[4], prop_val[5])); 36443859Sml29623 } 36453859Sml29623 ddi_prop_free(prop_val); 36463859Sml29623 } 36473859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 36486929Smisaki "local-mac-address?", &prop_val, 36496929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 36503859Sml29623 if (strncmp("true", (caddr_t)prop_val, (size_t)prop_len) == 0) { 36513859Sml29623 nxgep->ouraddr = nxgep->factaddr; 36523859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, 36536929Smisaki "Using local MAC address")); 36543859Sml29623 } 36553859Sml29623 ddi_prop_free(prop_val); 36563859Sml29623 } else { 36573859Sml29623 nxgep->ouraddr = nxgep->factaddr; 36583859Sml29623 } 36594185Sspeer 36604977Sraghus if ((!nxgep->vpd_info.present) || 36614732Sdavemq (nxge_is_valid_local_mac(nxgep->factaddr))) 36624185Sspeer goto got_mac_addr; 36634185Sspeer 36644185Sspeer NXGE_DEBUG_MSG((nxgep, DDI_CTL, "nxge_get_mac_addr_properties: " 36654185Sspeer "MAC address from properties is not valid...reading from PROM")); 36664185Sspeer 36674185Sspeer #endif 36684185Sspeer if (!nxgep->vpd_info.ver_valid) { 36694185Sspeer (void) nxge_espc_mac_addrs_get(nxgep); 36704185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 36714977Sraghus NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "Failed to get " 36724977Sraghus "MAC address")); 36734185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "EEPROM version " 36744185Sspeer "[%s] invalid...please update", 36754185Sspeer nxgep->vpd_info.ver)); 36764185Sspeer return (NXGE_ERROR); 36774185Sspeer } 36784185Sspeer nxgep->ouraddr = nxgep->factaddr; 36794185Sspeer goto got_mac_addr; 36804185Sspeer } 36814185Sspeer /* 36824185Sspeer * First get the MAC address from the info in the VPD data read 36834185Sspeer * from the EEPROM. 36844185Sspeer */ 36854185Sspeer nxge_espc_get_next_mac_addr(nxgep->vpd_info.mac_addr, 36864732Sdavemq nxgep->function_num, &nxgep->factaddr); 36874185Sspeer 36884185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 36894185Sspeer NXGE_DEBUG_MSG((nxgep, DDI_CTL, 36904185Sspeer "nxge_get_mac_addr_properties: " 36914185Sspeer "MAC address in EEPROM VPD data not valid" 36924185Sspeer "...reading from NCR registers")); 36934185Sspeer (void) nxge_espc_mac_addrs_get(nxgep); 36944185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 36954977Sraghus NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "Failed to get " 36964977Sraghus "MAC address")); 36974185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "EEPROM version " 36984185Sspeer "[%s] invalid...please update", 36994185Sspeer nxgep->vpd_info.ver)); 37004185Sspeer return (NXGE_ERROR); 37014185Sspeer } 37024185Sspeer } 37034185Sspeer 37043859Sml29623 nxgep->ouraddr = nxgep->factaddr; 37054185Sspeer 37064185Sspeer got_mac_addr: 37073859Sml29623 func_num = nxgep->function_num; 37083859Sml29623 37093859Sml29623 /* 37104732Sdavemq * Note: mac-addresses property is the list of mac addresses for a 37114732Sdavemq * port. NXGE_MAX_MMAC_ADDRS is the total number of MAC addresses 37124732Sdavemq * allocated for a board. 37133859Sml29623 */ 37144732Sdavemq nxgep->nxge_mmac_info.total_factory_macs = NXGE_MAX_MMAC_ADDRS; 37154732Sdavemq 37164732Sdavemq #if defined(_BIG_ENDIAN) 37174732Sdavemq if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 37184732Sdavemq "mac-addresses", &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 37193859Sml29623 /* 37204732Sdavemq * XAUI may have up to 18 MACs, more than the XMAC can 37214732Sdavemq * use (1 unique MAC plus 16 alternate MACs) 37223859Sml29623 */ 37234732Sdavemq nxgep->nxge_mmac_info.num_factory_mmac = 37244732Sdavemq prop_len / ETHERADDRL - 1; 37254732Sdavemq if (nxgep->nxge_mmac_info.num_factory_mmac > 37264732Sdavemq XMAC_MAX_ALT_ADDR_ENTRY) { 37274185Sspeer nxgep->nxge_mmac_info.num_factory_mmac = 37284732Sdavemq XMAC_MAX_ALT_ADDR_ENTRY; 37294732Sdavemq } 37304732Sdavemq 37314732Sdavemq for (i = 1; i <= nxgep->nxge_mmac_info.num_factory_mmac; i++) { 37324732Sdavemq for (j = 0; j < ETHERADDRL; j++) { 37334732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][j] = 37344732Sdavemq *(prop_val + (i * ETHERADDRL) + j); 37354732Sdavemq } 37364732Sdavemq NXGE_DEBUG_MSG((nxgep, DDI_CTL, 37374732Sdavemq "nxge_get_mac_addr_properties: Alt mac[%d] from " 37384732Sdavemq "mac-addresses property[%2x:%2x:%2x:%2x:%2x:%2x]", 37394732Sdavemq i, nxgep->nxge_mmac_info.factory_mac_pool[i][0], 37404732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][1], 37414732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][2], 37424732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][3], 37434732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][4], 37444732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][5])); 37454185Sspeer } 37464732Sdavemq 37474732Sdavemq compute_macs = B_FALSE; 37484732Sdavemq ddi_prop_free(prop_val); 37494732Sdavemq goto got_mmac_info; 37503859Sml29623 } 37514732Sdavemq #endif 37524732Sdavemq /* 37534732Sdavemq * total_factory_macs = 32 37544732Sdavemq * num_factory_mmac = (32 >> (nports/2)) - 1 37554732Sdavemq * So if nports = 4, then num_factory_mmac = 7 37564732Sdavemq * if nports = 2, then num_factory_mmac = 15 37574732Sdavemq */ 37584732Sdavemq nxgep->nxge_mmac_info.num_factory_mmac = 37594732Sdavemq ((nxgep->nxge_mmac_info.total_factory_macs >> 37604732Sdavemq (nxgep->nports >> 1))) - 1; 37614732Sdavemq 37624732Sdavemq got_mmac_info: 37634732Sdavemq 37644732Sdavemq if ((nxgep->function_num < 2) && 37654732Sdavemq (nxgep->nxge_mmac_info.num_factory_mmac > 37664732Sdavemq XMAC_MAX_ALT_ADDR_ENTRY)) { 37674732Sdavemq nxgep->nxge_mmac_info.num_factory_mmac = 37684732Sdavemq XMAC_MAX_ALT_ADDR_ENTRY; 37694732Sdavemq } else if ((nxgep->function_num > 1) && 37704732Sdavemq (nxgep->nxge_mmac_info.num_factory_mmac > 37714732Sdavemq BMAC_MAX_ALT_ADDR_ENTRY)) { 37724732Sdavemq nxgep->nxge_mmac_info.num_factory_mmac = 37734732Sdavemq BMAC_MAX_ALT_ADDR_ENTRY; 37744185Sspeer } 37754185Sspeer 37763859Sml29623 for (i = 0; i <= nxgep->nxge_mmac_info.num_mmac; i++) { 37773859Sml29623 (void) npi_mac_altaddr_disable(nxgep->npi_handle, 37786929Smisaki NXGE_GET_PORT_NUM(func_num), i); 37793859Sml29623 } 37803859Sml29623 37814732Sdavemq (void) nxge_init_mmac(nxgep, compute_macs); 37823859Sml29623 return (NXGE_OK); 37833859Sml29623 } 37843859Sml29623 37853859Sml29623 void 37863859Sml29623 nxge_get_xcvr_properties(p_nxge_t nxgep) 37873859Sml29623 { 37883859Sml29623 uchar_t *prop_val; 37893859Sml29623 uint_t prop_len; 37903859Sml29623 37913859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_get_xcvr_properties")); 37923859Sml29623 37933859Sml29623 /* 37943859Sml29623 * Read the type of physical layer interface being used. 37953859Sml29623 */ 37963859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 37973859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 37986929Smisaki "phy-type", &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 37993859Sml29623 if (strncmp("pcs", (caddr_t)prop_val, 38006929Smisaki (size_t)prop_len) == 0) { 38013859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = PCS_XCVR; 38023859Sml29623 } else { 38033859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 38043859Sml29623 } 38053859Sml29623 ddi_prop_free(prop_val); 38063859Sml29623 } else if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 38076929Smisaki "phy-interface", &prop_val, 38086929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 38093859Sml29623 if (strncmp("pcs", (caddr_t)prop_val, (size_t)prop_len) == 0) { 38103859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = PCS_XCVR; 38113859Sml29623 } else { 38123859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 38133859Sml29623 } 38143859Sml29623 ddi_prop_free(prop_val); 38153859Sml29623 } 38163859Sml29623 } 38173859Sml29623 38183859Sml29623 /* 38193859Sml29623 * Static functions start here. 38203859Sml29623 */ 38213859Sml29623 38223859Sml29623 static void 38233859Sml29623 nxge_ldgv_setup(p_nxge_ldg_t *ldgp, p_nxge_ldv_t *ldvp, uint8_t ldv, 38243859Sml29623 uint8_t endldg, int *ngrps) 38253859Sml29623 { 38263859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup")); 38273859Sml29623 /* Assign the group number for each device. */ 38283859Sml29623 (*ldvp)->ldg_assigned = (*ldgp)->ldg; 38293859Sml29623 (*ldvp)->ldgp = *ldgp; 38303859Sml29623 (*ldvp)->ldv = ldv; 38313859Sml29623 38323859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup: " 38336929Smisaki "ldv %d endldg %d ldg %d, ldvp $%p", 38346929Smisaki ldv, endldg, (*ldgp)->ldg, (*ldgp)->ldvp)); 38353859Sml29623 38363859Sml29623 (*ldgp)->nldvs++; 38373859Sml29623 if ((*ldgp)->ldg == (endldg - 1)) { 38383859Sml29623 if ((*ldgp)->ldvp == NULL) { 38393859Sml29623 (*ldgp)->ldvp = *ldvp; 38403859Sml29623 *ngrps += 1; 38413859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 38426929Smisaki "==> nxge_ldgv_setup: ngrps %d", *ngrps)); 38433859Sml29623 } 38443859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 38456929Smisaki "==> nxge_ldgv_setup: ldvp $%p ngrps %d", 38466929Smisaki *ldvp, *ngrps)); 38473859Sml29623 ++*ldvp; 38483859Sml29623 } else { 38493859Sml29623 (*ldgp)->ldvp = *ldvp; 38503859Sml29623 *ngrps += 1; 38513859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup(done): " 38526929Smisaki "ldv %d endldg %d ldg %d, ldvp $%p", 38536929Smisaki ldv, endldg, (*ldgp)->ldg, (*ldgp)->ldvp)); 38543859Sml29623 (*ldvp) = ++*ldvp; 38553859Sml29623 (*ldgp) = ++*ldgp; 38563859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 38576929Smisaki "==> nxge_ldgv_setup: new ngrps %d", *ngrps)); 38583859Sml29623 } 38593859Sml29623 38603859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup: " 38616929Smisaki "ldv %d ldvp $%p endldg %d ngrps %d", 38626929Smisaki ldv, ldvp, endldg, *ngrps)); 38633859Sml29623 38643859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "<== nxge_ldgv_setup")); 38653859Sml29623 } 38663859Sml29623 38673859Sml29623 /* 38683859Sml29623 * Note: This function assumes the following distribution of mac 38693859Sml29623 * addresses among 4 ports in neptune: 38703859Sml29623 * 38713859Sml29623 * ------------- 38723859Sml29623 * 0| |0 - local-mac-address for fn 0 38733859Sml29623 * ------------- 38743859Sml29623 * 1| |1 - local-mac-address for fn 1 38753859Sml29623 * ------------- 38763859Sml29623 * 2| |2 - local-mac-address for fn 2 38773859Sml29623 * ------------- 38783859Sml29623 * 3| |3 - local-mac-address for fn 3 38793859Sml29623 * ------------- 38803859Sml29623 * | |4 - Start of alt. mac addr. for fn 0 38813859Sml29623 * | | 38823859Sml29623 * | | 38833859Sml29623 * | |10 38843859Sml29623 * -------------- 38853859Sml29623 * | |11 - Start of alt. mac addr. for fn 1 38863859Sml29623 * | | 38873859Sml29623 * | | 38883859Sml29623 * | |17 38893859Sml29623 * -------------- 38903859Sml29623 * | |18 - Start of alt. mac addr. for fn 2 38913859Sml29623 * | | 38923859Sml29623 * | | 38933859Sml29623 * | |24 38943859Sml29623 * -------------- 38953859Sml29623 * | |25 - Start of alt. mac addr. for fn 3 38963859Sml29623 * | | 38973859Sml29623 * | | 38983859Sml29623 * | |31 38993859Sml29623 * -------------- 39003859Sml29623 * 39013859Sml29623 * For N2/NIU the mac addresses is from XAUI card. 39024732Sdavemq * 39034732Sdavemq * When 'compute_addrs' is true, the alternate mac addresses are computed 39044732Sdavemq * using the unique mac address as base. Otherwise the alternate addresses 39054732Sdavemq * are assigned from the list read off the 'mac-addresses' property. 39063859Sml29623 */ 39073859Sml29623 39083859Sml29623 static void 39094732Sdavemq nxge_init_mmac(p_nxge_t nxgep, boolean_t compute_addrs) 39103859Sml29623 { 39113859Sml29623 int slot; 39123859Sml29623 uint8_t func_num; 39133859Sml29623 uint16_t *base_mmac_addr; 39143859Sml29623 uint32_t alt_mac_ls4b; 39153859Sml29623 uint16_t *mmac_addr; 39163859Sml29623 uint32_t base_mac_ls4b; /* least significant 4 bytes */ 39173859Sml29623 nxge_mmac_t *mmac_info; 39183859Sml29623 npi_mac_addr_t mac_addr; 39193859Sml29623 39203859Sml29623 func_num = nxgep->function_num; 39213859Sml29623 base_mmac_addr = (uint16_t *)&nxgep->factaddr; 39223859Sml29623 mmac_info = (nxge_mmac_t *)&nxgep->nxge_mmac_info; 39233859Sml29623 39244732Sdavemq if (compute_addrs) { 39254732Sdavemq base_mac_ls4b = ((uint32_t)base_mmac_addr[1]) << 16 | 39264732Sdavemq base_mmac_addr[2]; 39274732Sdavemq 39284732Sdavemq if (nxgep->niu_type == N2_NIU) { 39294732Sdavemq /* ls4b of 1st altmac */ 39304732Sdavemq alt_mac_ls4b = base_mac_ls4b + 1; 39314732Sdavemq } else { /* Neptune */ 39324732Sdavemq alt_mac_ls4b = base_mac_ls4b + 39334732Sdavemq (nxgep->nports - func_num) + 39344732Sdavemq (func_num * (mmac_info->num_factory_mmac)); 39354732Sdavemq } 39363859Sml29623 } 39373859Sml29623 39383859Sml29623 /* Set flags for unique MAC */ 39393859Sml29623 mmac_info->mac_pool[0].flags |= MMAC_SLOT_USED | MMAC_VENDOR_ADDR; 39403859Sml29623 39413859Sml29623 /* Clear flags of all alternate MAC slots */ 39423859Sml29623 for (slot = 1; slot <= mmac_info->num_mmac; slot++) { 39433859Sml29623 if (slot <= mmac_info->num_factory_mmac) 39443859Sml29623 mmac_info->mac_pool[slot].flags = MMAC_VENDOR_ADDR; 39453859Sml29623 else 39463859Sml29623 mmac_info->mac_pool[slot].flags = 0; 39473859Sml29623 } 39483859Sml29623 39493859Sml29623 /* Generate and store factory alternate MACs */ 39503859Sml29623 for (slot = 1; slot <= mmac_info->num_factory_mmac; slot++) { 39513859Sml29623 mmac_addr = (uint16_t *)&mmac_info->factory_mac_pool[slot]; 39524732Sdavemq if (compute_addrs) { 39534732Sdavemq mmac_addr[0] = base_mmac_addr[0]; 39544732Sdavemq mac_addr.w2 = mmac_addr[0]; 39554732Sdavemq 39564732Sdavemq mmac_addr[1] = (alt_mac_ls4b >> 16) & 0x0FFFF; 39574732Sdavemq mac_addr.w1 = mmac_addr[1]; 39584732Sdavemq 39594732Sdavemq mmac_addr[2] = alt_mac_ls4b & 0x0FFFF; 39604732Sdavemq mac_addr.w0 = mmac_addr[2]; 39614732Sdavemq 39624732Sdavemq alt_mac_ls4b++; 39634732Sdavemq } else { 39644732Sdavemq mac_addr.w2 = mmac_addr[0]; 39654732Sdavemq mac_addr.w1 = mmac_addr[1]; 39664732Sdavemq mac_addr.w0 = mmac_addr[2]; 39674732Sdavemq } 39684732Sdavemq 39694732Sdavemq NXGE_DEBUG_MSG((nxgep, DDI_CTL, 39704732Sdavemq "mac_pool_addr[%2x:%2x:%2x:%2x:%2x:%2x] npi_addr[%x%x%x]", 39714732Sdavemq mmac_info->factory_mac_pool[slot][0], 39724732Sdavemq mmac_info->factory_mac_pool[slot][1], 39734732Sdavemq mmac_info->factory_mac_pool[slot][2], 39744732Sdavemq mmac_info->factory_mac_pool[slot][3], 39754732Sdavemq mmac_info->factory_mac_pool[slot][4], 39764732Sdavemq mmac_info->factory_mac_pool[slot][5], 39774732Sdavemq mac_addr.w0, mac_addr.w1, mac_addr.w2)); 39783859Sml29623 /* 39794732Sdavemq * slot minus 1 because npi_mac_altaddr_entry expects 0 39803859Sml29623 * for the first alternate mac address. 39813859Sml29623 */ 39823859Sml29623 (void) npi_mac_altaddr_entry(nxgep->npi_handle, OP_SET, 39836929Smisaki NXGE_GET_PORT_NUM(func_num), slot - 1, &mac_addr); 39843859Sml29623 } 39853859Sml29623 /* Initialize the first two parameters for mmac kstat */ 39863859Sml29623 nxgep->statsp->mmac_stats.mmac_max_cnt = mmac_info->num_mmac; 39873859Sml29623 nxgep->statsp->mmac_stats.mmac_avail_cnt = mmac_info->num_mmac; 39883859Sml29623 } 39898275SEric Cheng 39908275SEric Cheng /* 39918275SEric Cheng * Convert an RDC group index into a port ring index. That is, map 39928275SEric Cheng * <groupid> to an index into nxgep->rx_ring_handles. 39938275SEric Cheng * (group ring index -> port ring index) 39948275SEric Cheng */ 39958275SEric Cheng int 39968275SEric Cheng nxge_get_rxring_index(p_nxge_t nxgep, int groupid, int ringidx) 39978275SEric Cheng { 39988275SEric Cheng int i; 39998275SEric Cheng int index = 0; 40008275SEric Cheng p_nxge_rdc_grp_t rdc_grp_p; 40018275SEric Cheng p_nxge_dma_pt_cfg_t p_dma_cfgp; 40028275SEric Cheng p_nxge_hw_pt_cfg_t p_cfgp; 40038275SEric Cheng 40048275SEric Cheng p_dma_cfgp = &nxgep->pt_config; 40058275SEric Cheng p_cfgp = &p_dma_cfgp->hw_config; 40068275SEric Cheng 400710309SSriharsha.Basavapatna@Sun.COM if (isLDOMguest(nxgep)) 400810309SSriharsha.Basavapatna@Sun.COM return (ringidx); 400910309SSriharsha.Basavapatna@Sun.COM 40108275SEric Cheng for (i = 0; i < groupid; i++) { 40118275SEric Cheng rdc_grp_p = 40128275SEric Cheng &p_dma_cfgp->rdc_grps[p_cfgp->def_mac_rxdma_grpid + i]; 40138275SEric Cheng index += rdc_grp_p->max_rdcs; 40148275SEric Cheng } 40158275SEric Cheng 40168275SEric Cheng return (index + ringidx); 40178275SEric Cheng } 4018