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 /* 22*8661SSantwona.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 303859Sml29623 static void nxge_get_niu_property(dev_info_t *, niu_type_t *); 313859Sml29623 static nxge_status_t nxge_get_mac_addr_properties(p_nxge_t); 323859Sml29623 static nxge_status_t nxge_use_cfg_n2niu_properties(p_nxge_t); 333859Sml29623 static void nxge_use_cfg_neptune_properties(p_nxge_t); 343859Sml29623 static void nxge_use_cfg_dma_config(p_nxge_t); 353859Sml29623 static void nxge_use_cfg_vlan_class_config(p_nxge_t); 363859Sml29623 static void nxge_use_cfg_mac_class_config(p_nxge_t); 373859Sml29623 static void nxge_use_cfg_class_config(p_nxge_t); 383859Sml29623 static void nxge_use_cfg_link_cfg(p_nxge_t); 393859Sml29623 static void nxge_set_hw_dma_config(p_nxge_t); 403859Sml29623 static void nxge_set_hw_vlan_class_config(p_nxge_t); 413859Sml29623 static void nxge_set_hw_mac_class_config(p_nxge_t); 423859Sml29623 static void nxge_set_hw_class_config(p_nxge_t); 433859Sml29623 static nxge_status_t nxge_use_default_dma_config_n2(p_nxge_t); 443859Sml29623 static void nxge_ldgv_setup(p_nxge_ldg_t *, p_nxge_ldv_t *, uint8_t, 453859Sml29623 uint8_t, int *); 464732Sdavemq static void nxge_init_mmac(p_nxge_t, boolean_t); 476495Sspeer static void nxge_set_rdc_intr_property(p_nxge_t); 483859Sml29623 493859Sml29623 uint32_t nxge_use_hw_property = 1; 503859Sml29623 uint32_t nxge_groups_per_port = 2; 513859Sml29623 523859Sml29623 extern uint32_t nxge_use_partition; 533859Sml29623 extern uint32_t nxge_dma_obp_props_only; 543859Sml29623 553859Sml29623 extern uint16_t nxge_rcr_timeout; 563859Sml29623 extern uint16_t nxge_rcr_threshold; 573859Sml29623 583859Sml29623 extern uint_t nxge_rx_intr(void *, void *); 593859Sml29623 extern uint_t nxge_tx_intr(void *, void *); 603859Sml29623 extern uint_t nxge_mif_intr(void *, void *); 613859Sml29623 extern uint_t nxge_mac_intr(void *, void *); 623859Sml29623 extern uint_t nxge_syserr_intr(void *, void *); 633859Sml29623 extern void *nxge_list; 643859Sml29623 653859Sml29623 #define NXGE_SHARED_REG_SW_SIM 663859Sml29623 673859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 683859Sml29623 uint64_t global_dev_ctrl = 0; 693859Sml29623 #endif 703859Sml29623 713859Sml29623 #define MAX_SIBLINGS NXGE_MAX_PORTS 723859Sml29623 733859Sml29623 extern uint32_t nxge_rbr_size; 743859Sml29623 extern uint32_t nxge_rcr_size; 753859Sml29623 extern uint32_t nxge_tx_ring_size; 763859Sml29623 extern uint32_t nxge_rbr_spare_size; 773859Sml29623 783859Sml29623 extern npi_status_t npi_mac_altaddr_disable(npi_handle_t, uint8_t, uint8_t); 793859Sml29623 808275SEric Cheng /* 818275SEric Cheng * XXX: Use temporarily to specify the number of packets each interrupt process 828275SEric Cheng * By default, the number of packet processed per interrupt is 1. 838275SEric Cheng */ 848275SEric Cheng int nxge_max_intr_pkts; 858275SEric Cheng 863859Sml29623 static uint8_t p2_tx_fair[2] = {12, 12}; 873859Sml29623 static uint8_t p2_tx_equal[2] = {12, 12}; 883859Sml29623 static uint8_t p4_tx_fair[4] = {6, 6, 6, 6}; 893859Sml29623 static uint8_t p4_tx_equal[4] = {6, 6, 6, 6}; 903859Sml29623 static uint8_t p2_rx_fair[2] = {8, 8}; 913859Sml29623 static uint8_t p2_rx_equal[2] = {8, 8}; 923859Sml29623 static uint8_t p4_rx_fair[4] = {4, 4, 4, 4}; 933859Sml29623 static uint8_t p4_rx_equal[4] = {4, 4, 4, 4}; 943859Sml29623 953859Sml29623 static uint8_t p2_rdcgrp_fair[2] = {4, 4}; 963859Sml29623 static uint8_t p2_rdcgrp_equal[2] = {4, 4}; 973859Sml29623 static uint8_t p4_rdcgrp_fair[4] = {2, 2, 1, 1}; 983859Sml29623 static uint8_t p4_rdcgrp_equal[4] = {2, 2, 2, 2}; 993859Sml29623 static uint8_t p2_rdcgrp_cls[2] = {1, 1}; 1003859Sml29623 static uint8_t p4_rdcgrp_cls[4] = {1, 1, 1, 1}; 1013859Sml29623 1024732Sdavemq static uint8_t rx_4_1G[4] = {4, 4, 4, 4}; 1034732Sdavemq static uint8_t rx_2_10G[2] = {8, 8}; 1044732Sdavemq static uint8_t rx_2_10G_2_1G[4] = {6, 6, 2, 2}; 1054732Sdavemq static uint8_t rx_1_10G_3_1G[4] = {10, 2, 2, 2}; 1064732Sdavemq static uint8_t rx_1_1G_1_10G_2_1G[4] = {2, 10, 2, 2}; 1074732Sdavemq 1084732Sdavemq static uint8_t tx_4_1G[4] = {6, 6, 6, 6}; 1094732Sdavemq static uint8_t tx_2_10G[2] = {12, 12}; 1104732Sdavemq static uint8_t tx_2_10G_2_1G[4] = {10, 10, 2, 2}; 1114732Sdavemq static uint8_t tx_1_10G_3_1G[4] = {12, 4, 4, 4}; 1124732Sdavemq static uint8_t tx_1_1G_1_10G_2_1G[4] = {4, 12, 4, 4}; 1134732Sdavemq 1143859Sml29623 typedef enum { 1153859Sml29623 DEFAULT = 0, 1163859Sml29623 EQUAL, 1173859Sml29623 FAIR, 1183859Sml29623 CUSTOM, 1193859Sml29623 CLASSIFY, 1203859Sml29623 L2_CLASSIFY, 1213859Sml29623 L3_DISTRIBUTE, 1223859Sml29623 L3_CLASSIFY, 1233859Sml29623 L3_TCAM, 1243859Sml29623 CONFIG_TOKEN_NONE 1253859Sml29623 } config_token_t; 1263859Sml29623 1273859Sml29623 static char *token_names[] = { 1283859Sml29623 "default", 1293859Sml29623 "equal", 1303859Sml29623 "fair", 1313859Sml29623 "custom", 1323859Sml29623 "classify", 1333859Sml29623 "l2_classify", 1343859Sml29623 "l3_distribute", 1353859Sml29623 "l3_classify", 1363859Sml29623 "l3_tcam", 1373859Sml29623 "none", 1383859Sml29623 }; 1393859Sml29623 1403859Sml29623 void nxge_virint_regs_dump(p_nxge_t nxgep); 1413859Sml29623 1423859Sml29623 void 1433859Sml29623 nxge_virint_regs_dump(p_nxge_t nxgep) 1443859Sml29623 { 1453859Sml29623 npi_handle_t handle; 1463859Sml29623 1473859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_virint_regs_dump")); 1483859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 1493859Sml29623 (void) npi_vir_dump_pio_fzc_regs_one(handle); 1503859Sml29623 (void) npi_vir_dump_ldgnum(handle); 1513859Sml29623 (void) npi_vir_dump_ldsv(handle); 1523859Sml29623 (void) npi_vir_dump_imask0(handle); 1533859Sml29623 (void) npi_vir_dump_sid(handle); 1543859Sml29623 (void) npi_mac_dump_regs(handle, nxgep->function_num); 1553859Sml29623 (void) npi_ipp_dump_regs(handle, nxgep->function_num); 1563859Sml29623 (void) npi_fflp_dump_regs(handle); 1573859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_virint_regs_dump")); 1583859Sml29623 } 1593859Sml29623 1603859Sml29623 /* 1613859Sml29623 * For now: we hard coded the DMA configurations. 1623859Sml29623 * and assume for one partition only. 1633859Sml29623 * 1643859Sml29623 * OBP. Then OBP will pass this partition's 1653859Sml29623 * Neptune configurations to fcode to create 1663859Sml29623 * properties for them. 1673859Sml29623 * 1683859Sml29623 * Since Neptune(PCI-E) and NIU (Niagara-2) has 1693859Sml29623 * different bus interfaces, the driver needs 1703859Sml29623 * to know which bus it is connected to. 1713859Sml29623 * Ravinder suggested: create a device property. 1723859Sml29623 * In partitioning environment, we cannot 1733859Sml29623 * use .conf file (need to check). If conf changes, 1743859Sml29623 * need to reboot the system. 1753859Sml29623 * The following function assumes that we will 1763859Sml29623 * retrieve its properties from a virtualized nexus driver. 1773859Sml29623 */ 1783859Sml29623 1793859Sml29623 nxge_status_t 1803859Sml29623 nxge_cntlops(dev_info_t *dip, nxge_ctl_enum_t ctlop, void *arg, void *result) 1813859Sml29623 { 1823859Sml29623 nxge_status_t status = NXGE_OK; 1833859Sml29623 int instance; 1843859Sml29623 p_nxge_t nxgep; 1853859Sml29623 1863859Sml29623 #ifndef NXGE_SHARED_REG_SW_SIM 1873859Sml29623 npi_handle_t handle; 1883859Sml29623 uint16_t sr16, cr16; 1893859Sml29623 #endif 1903859Sml29623 instance = ddi_get_instance(dip); 1913859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, "Instance %d ", instance)); 1923859Sml29623 1933859Sml29623 if (nxge_list == NULL) { 1943859Sml29623 NXGE_ERROR_MSG((NULL, NXGE_ERR_CTL, 1956929Smisaki "nxge_cntlops: nxge_list null")); 1963859Sml29623 return (NXGE_ERROR); 1973859Sml29623 } 1983859Sml29623 nxgep = (p_nxge_t)ddi_get_soft_state(nxge_list, instance); 1993859Sml29623 if (nxgep == NULL) { 2003859Sml29623 NXGE_ERROR_MSG((NULL, NXGE_ERR_CTL, 2016929Smisaki "nxge_cntlops: nxgep null")); 2023859Sml29623 return (NXGE_ERROR); 2033859Sml29623 } 2043859Sml29623 #ifndef NXGE_SHARED_REG_SW_SIM 2053859Sml29623 handle = nxgep->npi_reg_handle; 2063859Sml29623 #endif 2073859Sml29623 switch (ctlop) { 2083859Sml29623 case NXGE_CTLOPS_NIUTYPE: 2093859Sml29623 nxge_get_niu_property(dip, (niu_type_t *)result); 2103859Sml29623 return (status); 2113859Sml29623 2123859Sml29623 case NXGE_CTLOPS_GET_SHARED_REG: 2133859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2143859Sml29623 *(uint64_t *)result = global_dev_ctrl; 2153859Sml29623 return (0); 2163859Sml29623 #else 2173859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2183859Sml29623 *(uint16_t *)result = sr16; 2193859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2206929Smisaki "nxge_cntlops: NXGE_CTLOPS_GET_SHARED_REG")); 2213859Sml29623 return (0); 2223859Sml29623 #endif 2233859Sml29623 2243859Sml29623 case NXGE_CTLOPS_SET_SHARED_REG_LOCK: 2253859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2263859Sml29623 global_dev_ctrl = *(uint64_t *)arg; 2273859Sml29623 return (0); 2283859Sml29623 #else 2293859Sml29623 status = NPI_FAILURE; 2303859Sml29623 while (status != NPI_SUCCESS) 2313859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2323859Sml29623 2333859Sml29623 sr16 = *(uint16_t *)arg; 2343859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2353859Sml29623 status = npi_dev_func_sr_lock_free(handle); 2363859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2376929Smisaki "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2383859Sml29623 return (0); 2393859Sml29623 #endif 2403859Sml29623 2413859Sml29623 case NXGE_CTLOPS_UPDATE_SHARED_REG: 2423859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2433859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2443859Sml29623 return (0); 2453859Sml29623 #else 2463859Sml29623 status = NPI_FAILURE; 2473859Sml29623 while (status != NPI_SUCCESS) 2483859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2493859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2503859Sml29623 sr16 |= *(uint16_t *)arg; 2513859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2523859Sml29623 status = npi_dev_func_sr_lock_free(handle); 2533859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2546929Smisaki "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2553859Sml29623 return (0); 2563859Sml29623 #endif 2573859Sml29623 2583859Sml29623 case NXGE_CTLOPS_CLEAR_BIT_SHARED_REG_UL: 2593859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2603859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2613859Sml29623 return (0); 2623859Sml29623 #else 2633859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2643859Sml29623 cr16 = *(uint16_t *)arg; 2653859Sml29623 sr16 &= ~cr16; 2663859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2673859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2686929Smisaki "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2693859Sml29623 return (0); 2703859Sml29623 #endif 2713859Sml29623 2723859Sml29623 case NXGE_CTLOPS_CLEAR_BIT_SHARED_REG: 2733859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2743859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2753859Sml29623 return (0); 2763859Sml29623 #else 2773859Sml29623 status = NPI_FAILURE; 2783859Sml29623 while (status != NPI_SUCCESS) 2793859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2803859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2813859Sml29623 cr16 = *(uint16_t *)arg; 2823859Sml29623 sr16 &= ~cr16; 2833859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2843859Sml29623 status = npi_dev_func_sr_lock_free(handle); 2853859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2866929Smisaki "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2873859Sml29623 return (0); 2883859Sml29623 #endif 2893859Sml29623 2903859Sml29623 case NXGE_CTLOPS_GET_LOCK_BLOCK: 2913859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2923859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2933859Sml29623 return (0); 2943859Sml29623 #else 2953859Sml29623 status = NPI_FAILURE; 2963859Sml29623 while (status != NPI_SUCCESS) 2973859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2983859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2996929Smisaki "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_BLOCK")); 3003859Sml29623 return (0); 3013859Sml29623 #endif 3023859Sml29623 case NXGE_CTLOPS_GET_LOCK_TRY: 3033859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 3043859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 3053859Sml29623 return (0); 3063859Sml29623 #else 3073859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 3083859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 3096929Smisaki "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_TRY")); 3103859Sml29623 if (status == NPI_SUCCESS) 3113859Sml29623 return (NXGE_OK); 3123859Sml29623 else 3133859Sml29623 return (NXGE_ERROR); 3143859Sml29623 #endif 3153859Sml29623 case NXGE_CTLOPS_FREE_LOCK: 3163859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 3173859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 3183859Sml29623 return (0); 3193859Sml29623 #else 3203859Sml29623 status = npi_dev_func_sr_lock_free(handle); 3213859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 3226929Smisaki "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_FREE")); 3233859Sml29623 if (status == NPI_SUCCESS) 3243859Sml29623 return (NXGE_OK); 3253859Sml29623 else 3263859Sml29623 return (NXGE_ERROR); 3273859Sml29623 #endif 3283859Sml29623 3293859Sml29623 default: 3303859Sml29623 status = NXGE_ERROR; 3313859Sml29623 } 3323859Sml29623 3333859Sml29623 return (status); 3343859Sml29623 } 3353859Sml29623 3363859Sml29623 void 3373859Sml29623 nxge_common_lock_get(p_nxge_t nxgep) 3383859Sml29623 { 3393859Sml29623 uint32_t status = NPI_FAILURE; 3403859Sml29623 npi_handle_t handle; 3413859Sml29623 3423859Sml29623 #if defined(NXGE_SHARE_REG_SW_SIM) 3433859Sml29623 return; 3443859Sml29623 #endif 3453859Sml29623 handle = nxgep->npi_reg_handle; 3463859Sml29623 while (status != NPI_SUCCESS) 3473859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 3483859Sml29623 } 3493859Sml29623 3503859Sml29623 void 3513859Sml29623 nxge_common_lock_free(p_nxge_t nxgep) 3523859Sml29623 { 3533859Sml29623 npi_handle_t handle; 3543859Sml29623 3553859Sml29623 #if defined(NXGE_SHARE_REG_SW_SIM) 3563859Sml29623 return; 3573859Sml29623 #endif 3583859Sml29623 handle = nxgep->npi_reg_handle; 3593859Sml29623 (void) npi_dev_func_sr_lock_free(handle); 3603859Sml29623 } 3613859Sml29623 3624185Sspeer 3633859Sml29623 static void 3643859Sml29623 nxge_get_niu_property(dev_info_t *dip, niu_type_t *niu_type) 3653859Sml29623 { 3663859Sml29623 uchar_t *prop_val; 3673859Sml29623 uint_t prop_len; 3683859Sml29623 3694732Sdavemq *niu_type = NIU_TYPE_NONE; 3703859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, 3716929Smisaki "niu-type", (uchar_t **)&prop_val, 3726929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 3733859Sml29623 if (strncmp("niu", (caddr_t)prop_val, (size_t)prop_len) == 0) { 3743859Sml29623 *niu_type = N2_NIU; 3753859Sml29623 } 3763859Sml29623 ddi_prop_free(prop_val); 3773859Sml29623 } 3783859Sml29623 } 3793859Sml29623 3803859Sml29623 static config_token_t 3813859Sml29623 nxge_get_config_token(char *prop) 3823859Sml29623 { 3833859Sml29623 config_token_t token = DEFAULT; 3843859Sml29623 3853859Sml29623 while (token < CONFIG_TOKEN_NONE) { 3863859Sml29623 if (strncmp(prop, token_names[token], 4) == 0) 3873859Sml29623 break; 3883859Sml29623 token++; 3893859Sml29623 } 3903859Sml29623 return (token); 3913859Sml29623 } 3923859Sml29623 3933859Sml29623 /* per port */ 3943859Sml29623 3953859Sml29623 static nxge_status_t 3963859Sml29623 nxge_update_rxdma_grp_properties(p_nxge_t nxgep, config_token_t token, 3973859Sml29623 dev_info_t *s_dip[]) 3983859Sml29623 { 3993859Sml29623 nxge_status_t status = NXGE_OK; 4003859Sml29623 int ddi_status; 4013859Sml29623 int num_ports = nxgep->nports; 4023859Sml29623 int port, bits, j; 4033859Sml29623 uint8_t start_grp = 0, num_grps = 0; 4043859Sml29623 p_nxge_param_t param_arr; 4053859Sml29623 uint32_t grp_bitmap[MAX_SIBLINGS]; 4063859Sml29623 int custom_start_grp[MAX_SIBLINGS]; 4073859Sml29623 int custom_num_grp[MAX_SIBLINGS]; 4083859Sml29623 uint8_t bad_config = B_FALSE; 4093859Sml29623 char *start_prop, *num_prop, *cfg_prop; 4103859Sml29623 4113859Sml29623 start_grp = 0; 4123859Sml29623 param_arr = nxgep->param_arr; 4133859Sml29623 start_prop = param_arr[param_rdc_grps_start].fcode_name; 4143859Sml29623 num_prop = param_arr[param_rx_rdc_grps].fcode_name; 4153859Sml29623 4163859Sml29623 switch (token) { 4173859Sml29623 case FAIR: 4183859Sml29623 cfg_prop = "fair"; 4193859Sml29623 for (port = 0; port < num_ports; port++) { 4203859Sml29623 custom_num_grp[port] = 4216929Smisaki (num_ports == 4) ? 4226929Smisaki p4_rdcgrp_fair[port] : 4236929Smisaki p2_rdcgrp_fair[port]; 4243859Sml29623 custom_start_grp[port] = start_grp; 4253859Sml29623 start_grp += custom_num_grp[port]; 4263859Sml29623 } 4273859Sml29623 break; 4283859Sml29623 4293859Sml29623 case EQUAL: 4303859Sml29623 cfg_prop = "equal"; 4313859Sml29623 for (port = 0; port < num_ports; port++) { 4323859Sml29623 custom_num_grp[port] = 4336929Smisaki (num_ports == 4) ? 4346929Smisaki p4_rdcgrp_equal[port] : 4356929Smisaki p2_rdcgrp_equal[port]; 4363859Sml29623 custom_start_grp[port] = start_grp; 4373859Sml29623 start_grp += custom_num_grp[port]; 4383859Sml29623 } 4393859Sml29623 break; 4403859Sml29623 4413859Sml29623 4423859Sml29623 case CLASSIFY: 4433859Sml29623 cfg_prop = "classify"; 4443859Sml29623 for (port = 0; port < num_ports; port++) { 4453859Sml29623 custom_num_grp[port] = (num_ports == 4) ? 4466929Smisaki p4_rdcgrp_cls[port] : p2_rdcgrp_cls[port]; 4473859Sml29623 custom_start_grp[port] = start_grp; 4483859Sml29623 start_grp += custom_num_grp[port]; 4493859Sml29623 } 4503859Sml29623 break; 4513859Sml29623 4523859Sml29623 case CUSTOM: 4533859Sml29623 cfg_prop = "custom"; 4543859Sml29623 /* See if it is good config */ 4553859Sml29623 num_grps = 0; 4563859Sml29623 for (port = 0; port < num_ports; port++) { 4573859Sml29623 custom_start_grp[port] = 4586929Smisaki ddi_prop_get_int(DDI_DEV_T_NONE, s_dip[port], 4596929Smisaki DDI_PROP_DONTPASS, start_prop, -1); 4603859Sml29623 if ((custom_start_grp[port] == -1) || 4616929Smisaki (custom_start_grp[port] >= 4626929Smisaki NXGE_MAX_RDC_GRPS)) { 4633859Sml29623 bad_config = B_TRUE; 4643859Sml29623 break; 4653859Sml29623 } 4663859Sml29623 custom_num_grp[port] = ddi_prop_get_int( 4676929Smisaki DDI_DEV_T_NONE, 4686929Smisaki s_dip[port], 4696929Smisaki DDI_PROP_DONTPASS, 4706929Smisaki num_prop, -1); 4713859Sml29623 4723859Sml29623 if ((custom_num_grp[port] == -1) || 4736929Smisaki (custom_num_grp[port] > 4746929Smisaki NXGE_MAX_RDC_GRPS) || 4756929Smisaki ((custom_num_grp[port] + 4766929Smisaki custom_start_grp[port]) >= 4776929Smisaki NXGE_MAX_RDC_GRPS)) { 4783859Sml29623 bad_config = B_TRUE; 4793859Sml29623 break; 4803859Sml29623 } 4813859Sml29623 num_grps += custom_num_grp[port]; 4823859Sml29623 if (num_grps > NXGE_MAX_RDC_GRPS) { 4833859Sml29623 bad_config = B_TRUE; 4843859Sml29623 break; 4853859Sml29623 } 4863859Sml29623 grp_bitmap[port] = 0; 4873859Sml29623 for (bits = 0; 4886929Smisaki bits < custom_num_grp[port]; 4896929Smisaki bits++) { 4903859Sml29623 grp_bitmap[port] |= 4916929Smisaki (1 << (bits + custom_start_grp[port])); 4923859Sml29623 } 4933859Sml29623 4943859Sml29623 } 4953859Sml29623 4963859Sml29623 if (bad_config == B_FALSE) { 4973859Sml29623 /* check for overlap */ 4983859Sml29623 for (port = 0; port < num_ports - 1; port++) { 4993859Sml29623 for (j = port + 1; j < num_ports; j++) { 5003859Sml29623 if (grp_bitmap[port] & 5016929Smisaki grp_bitmap[j]) { 5023859Sml29623 bad_config = B_TRUE; 5033859Sml29623 break; 5043859Sml29623 } 5053859Sml29623 } 5063859Sml29623 if (bad_config == B_TRUE) 5073859Sml29623 break; 5083859Sml29623 } 5093859Sml29623 } 5103859Sml29623 if (bad_config == B_TRUE) { 5113859Sml29623 /* use default config */ 5123859Sml29623 for (port = 0; port < num_ports; port++) { 5133859Sml29623 custom_num_grp[port] = 5146929Smisaki (num_ports == 4) ? 5156929Smisaki p4_rx_fair[port] : p2_rx_fair[port]; 5163859Sml29623 custom_start_grp[port] = start_grp; 5173859Sml29623 start_grp += custom_num_grp[port]; 5183859Sml29623 } 5193859Sml29623 } 5203859Sml29623 break; 5213859Sml29623 5223859Sml29623 default: 5233859Sml29623 /* use default config */ 5243859Sml29623 cfg_prop = "fair"; 5253859Sml29623 for (port = 0; port < num_ports; port++) { 5263859Sml29623 custom_num_grp[port] = (num_ports == 4) ? 5276929Smisaki p4_rx_fair[port] : p2_rx_fair[port]; 5283859Sml29623 custom_start_grp[port] = start_grp; 5293859Sml29623 start_grp += custom_num_grp[port]; 5303859Sml29623 } 5313859Sml29623 break; 5323859Sml29623 } 5333859Sml29623 5343859Sml29623 /* Now Update the rx properties */ 5353859Sml29623 for (port = 0; port < num_ports; port++) { 5363859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 5376929Smisaki "rxdma-grp-cfg", cfg_prop); 5383859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5393859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5406929Smisaki " property %s not updating", 5416929Smisaki cfg_prop)); 5423859Sml29623 status |= NXGE_DDI_FAILED; 5433859Sml29623 } 5443859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 5456929Smisaki num_prop, custom_num_grp[port]); 5463859Sml29623 5473859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5483859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5496929Smisaki " property %s not updating", 5506929Smisaki num_prop)); 5513859Sml29623 status |= NXGE_DDI_FAILED; 5523859Sml29623 } 5533859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 5546929Smisaki start_prop, custom_start_grp[port]); 5553859Sml29623 5563859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5573859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5586929Smisaki " property %s not updating", 5596929Smisaki start_prop)); 5603859Sml29623 status |= NXGE_DDI_FAILED; 5613859Sml29623 } 5623859Sml29623 } 5633859Sml29623 if (status & NXGE_DDI_FAILED) 5643859Sml29623 status |= NXGE_ERROR; 5653859Sml29623 5663859Sml29623 return (status); 5673859Sml29623 } 5683859Sml29623 5693859Sml29623 static nxge_status_t 5703859Sml29623 nxge_update_rxdma_properties(p_nxge_t nxgep, config_token_t token, 5713859Sml29623 dev_info_t *s_dip[]) 5723859Sml29623 { 5733859Sml29623 nxge_status_t status = NXGE_OK; 5743859Sml29623 int ddi_status; 5753859Sml29623 int num_ports = nxgep->nports; 5763859Sml29623 int port, bits, j; 5773859Sml29623 uint8_t start_rdc = 0, num_rdc = 0; 5783859Sml29623 p_nxge_param_t param_arr; 5793859Sml29623 uint32_t rdc_bitmap[MAX_SIBLINGS]; 5803859Sml29623 int custom_start_rdc[MAX_SIBLINGS]; 5813859Sml29623 int custom_num_rdc[MAX_SIBLINGS]; 5823859Sml29623 uint8_t bad_config = B_FALSE; 5833859Sml29623 int *prop_val; 5843859Sml29623 uint_t prop_len; 5853859Sml29623 char *start_rdc_prop, *num_rdc_prop, *cfg_prop; 5863859Sml29623 5873859Sml29623 start_rdc = 0; 5883859Sml29623 param_arr = nxgep->param_arr; 5893859Sml29623 start_rdc_prop = param_arr[param_rxdma_channels_begin].fcode_name; 5903859Sml29623 num_rdc_prop = param_arr[param_rxdma_channels].fcode_name; 5913859Sml29623 5923859Sml29623 switch (token) { 5933859Sml29623 case FAIR: 5943859Sml29623 cfg_prop = "fair"; 5953859Sml29623 for (port = 0; port < num_ports; port++) { 5963859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 5976929Smisaki p4_rx_fair[port] : p2_rx_fair[port]; 5983859Sml29623 custom_start_rdc[port] = start_rdc; 5993859Sml29623 start_rdc += custom_num_rdc[port]; 6003859Sml29623 } 6013859Sml29623 break; 6023859Sml29623 6033859Sml29623 case EQUAL: 6043859Sml29623 cfg_prop = "equal"; 6053859Sml29623 for (port = 0; port < num_ports; port++) { 6063859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 6076929Smisaki p4_rx_equal[port] : 6086929Smisaki p2_rx_equal[port]; 6093859Sml29623 custom_start_rdc[port] = start_rdc; 6103859Sml29623 start_rdc += custom_num_rdc[port]; 6113859Sml29623 } 6123859Sml29623 break; 6133859Sml29623 6143859Sml29623 case CUSTOM: 6153859Sml29623 cfg_prop = "custom"; 6163859Sml29623 /* See if it is good config */ 6173859Sml29623 num_rdc = 0; 6183859Sml29623 for (port = 0; port < num_ports; port++) { 6193859Sml29623 ddi_status = ddi_prop_lookup_int_array( 6206929Smisaki DDI_DEV_T_ANY, 6216929Smisaki s_dip[port], 0, 6226929Smisaki start_rdc_prop, 6236929Smisaki &prop_val, 6246929Smisaki &prop_len); 6253859Sml29623 if (ddi_status == DDI_SUCCESS) 6263859Sml29623 custom_start_rdc[port] = *prop_val; 6273859Sml29623 else { 6283859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6296929Smisaki " %s custom start port %d" 6306929Smisaki " read failed ", 6316929Smisaki " rxdma-cfg", port)); 6323859Sml29623 bad_config = B_TRUE; 6333859Sml29623 status |= NXGE_DDI_FAILED; 6343859Sml29623 } 6353859Sml29623 if ((custom_start_rdc[port] == -1) || 6366929Smisaki (custom_start_rdc[port] >= 6376929Smisaki NXGE_MAX_RDCS)) { 6383859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6396929Smisaki " %s custom start %d" 6406929Smisaki " out of range %x ", 6416929Smisaki " rxdma-cfg", 6426929Smisaki port, 6436929Smisaki custom_start_rdc[port])); 6443859Sml29623 bad_config = B_TRUE; 6453859Sml29623 break; 6463859Sml29623 } 6473859Sml29623 ddi_status = ddi_prop_lookup_int_array( 6486929Smisaki DDI_DEV_T_ANY, 6496929Smisaki s_dip[port], 6506929Smisaki 0, 6516929Smisaki num_rdc_prop, 6526929Smisaki &prop_val, 6536929Smisaki &prop_len); 6543859Sml29623 6553859Sml29623 if (ddi_status == DDI_SUCCESS) 6563859Sml29623 custom_num_rdc[port] = *prop_val; 6573859Sml29623 else { 6583859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6596929Smisaki " %s custom num port %d" 6606929Smisaki " read failed ", 6616929Smisaki "rxdma-cfg", port)); 6623859Sml29623 bad_config = B_TRUE; 6633859Sml29623 status |= NXGE_DDI_FAILED; 6643859Sml29623 } 6653859Sml29623 6663859Sml29623 if ((custom_num_rdc[port] == -1) || 6676929Smisaki (custom_num_rdc[port] > 6686929Smisaki NXGE_MAX_RDCS) || 6696929Smisaki ((custom_num_rdc[port] + 6706929Smisaki custom_start_rdc[port]) > 6716929Smisaki NXGE_MAX_RDCS)) { 6723859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6736929Smisaki " %s custom num %d" 6746929Smisaki " out of range %x ", 6756929Smisaki " rxdma-cfg", 6766929Smisaki port, custom_num_rdc[port])); 6773859Sml29623 bad_config = B_TRUE; 6783859Sml29623 break; 6793859Sml29623 } 6803859Sml29623 num_rdc += custom_num_rdc[port]; 6813859Sml29623 if (num_rdc > NXGE_MAX_RDCS) { 6823859Sml29623 bad_config = B_TRUE; 6833859Sml29623 break; 6843859Sml29623 } 6853859Sml29623 rdc_bitmap[port] = 0; 6863859Sml29623 for (bits = 0; 6876929Smisaki bits < custom_num_rdc[port]; bits++) { 6883859Sml29623 rdc_bitmap[port] |= 6896929Smisaki (1 << (bits + custom_start_rdc[port])); 6903859Sml29623 } 6913859Sml29623 } 6923859Sml29623 6933859Sml29623 if (bad_config == B_FALSE) { 6943859Sml29623 /* check for overlap */ 6953859Sml29623 for (port = 0; port < num_ports - 1; port++) { 6963859Sml29623 for (j = port + 1; j < num_ports; j++) { 6973859Sml29623 if (rdc_bitmap[port] & 6986929Smisaki rdc_bitmap[j]) { 6993859Sml29623 NXGE_DEBUG_MSG((nxgep, 7006929Smisaki CFG_CTL, 7016929Smisaki " rxdma-cfg" 7026929Smisaki " property custom" 7036929Smisaki " bit overlap" 7046929Smisaki " %d %d ", 7056929Smisaki port, j)); 7063859Sml29623 bad_config = B_TRUE; 7073859Sml29623 break; 7083859Sml29623 } 7093859Sml29623 } 7103859Sml29623 if (bad_config == B_TRUE) 7113859Sml29623 break; 7123859Sml29623 } 7133859Sml29623 } 7143859Sml29623 if (bad_config == B_TRUE) { 7153859Sml29623 /* use default config */ 7163859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7176929Smisaki " rxdma-cfg property:" 7186929Smisaki " bad custom config:" 7196929Smisaki " use default")); 7203859Sml29623 for (port = 0; port < num_ports; port++) { 7213859Sml29623 custom_num_rdc[port] = 7226929Smisaki (num_ports == 4) ? 7236929Smisaki p4_rx_fair[port] : 7246929Smisaki p2_rx_fair[port]; 7253859Sml29623 custom_start_rdc[port] = start_rdc; 7263859Sml29623 start_rdc += custom_num_rdc[port]; 7273859Sml29623 } 7283859Sml29623 } 7293859Sml29623 break; 7303859Sml29623 7313859Sml29623 default: 7323859Sml29623 /* use default config */ 7333859Sml29623 cfg_prop = "fair"; 7343859Sml29623 for (port = 0; port < num_ports; port++) { 7353859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 7366929Smisaki p4_rx_fair[port] : p2_rx_fair[port]; 7373859Sml29623 custom_start_rdc[port] = start_rdc; 7383859Sml29623 start_rdc += custom_num_rdc[port]; 7393859Sml29623 } 7403859Sml29623 break; 7413859Sml29623 } 7423859Sml29623 7433859Sml29623 /* Now Update the rx properties */ 7443859Sml29623 for (port = 0; port < num_ports; port++) { 7453859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7466929Smisaki " update property rxdma-cfg with %s ", cfg_prop)); 7473859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 7486929Smisaki "rxdma-cfg", cfg_prop); 7493859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7503859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7516929Smisaki " property rxdma-cfg is not updating to %s", 7526929Smisaki cfg_prop)); 7533859Sml29623 status |= NXGE_DDI_FAILED; 7543859Sml29623 } 7553859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 7566929Smisaki num_rdc_prop, custom_num_rdc[port])); 7573859Sml29623 7583859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 7596929Smisaki num_rdc_prop, custom_num_rdc[port]); 7603859Sml29623 7613859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7623859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 7636929Smisaki " property %s not updating with %d", 7646929Smisaki num_rdc_prop, custom_num_rdc[port])); 7653859Sml29623 status |= NXGE_DDI_FAILED; 7663859Sml29623 } 7673859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 7686929Smisaki start_rdc_prop, custom_start_rdc[port])); 7693859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 7706929Smisaki start_rdc_prop, custom_start_rdc[port]); 7713859Sml29623 7723859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7733859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 7746929Smisaki " property %s not updating with %d ", 7756929Smisaki start_rdc_prop, custom_start_rdc[port])); 7763859Sml29623 status |= NXGE_DDI_FAILED; 7773859Sml29623 } 7783859Sml29623 } 7793859Sml29623 if (status & NXGE_DDI_FAILED) 7803859Sml29623 status |= NXGE_ERROR; 7813859Sml29623 return (status); 7823859Sml29623 } 7833859Sml29623 7843859Sml29623 static nxge_status_t 7853859Sml29623 nxge_update_txdma_properties(p_nxge_t nxgep, config_token_t token, 7863859Sml29623 dev_info_t *s_dip[]) 7873859Sml29623 { 7883859Sml29623 nxge_status_t status = NXGE_OK; 7893859Sml29623 int ddi_status = DDI_SUCCESS; 7903859Sml29623 int num_ports = nxgep->nports; 7913859Sml29623 int port, bits, j; 7928275SEric Cheng uint8_t start_tdc, num_tdc = 0; 7933859Sml29623 p_nxge_param_t param_arr; 7943859Sml29623 uint32_t tdc_bitmap[MAX_SIBLINGS]; 7953859Sml29623 int custom_start_tdc[MAX_SIBLINGS]; 7963859Sml29623 int custom_num_tdc[MAX_SIBLINGS]; 7973859Sml29623 uint8_t bad_config = B_FALSE; 7983859Sml29623 int *prop_val; 7993859Sml29623 uint_t prop_len; 8003859Sml29623 char *start_tdc_prop, *num_tdc_prop, *cfg_prop; 8013859Sml29623 8023859Sml29623 start_tdc = 0; 8033859Sml29623 param_arr = nxgep->param_arr; 8043859Sml29623 start_tdc_prop = param_arr[param_txdma_channels_begin].fcode_name; 8053859Sml29623 num_tdc_prop = param_arr[param_txdma_channels].fcode_name; 8063859Sml29623 8073859Sml29623 switch (token) { 8083859Sml29623 case FAIR: 8093859Sml29623 cfg_prop = "fair"; 8103859Sml29623 for (port = 0; port < num_ports; port++) { 8113859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 8126929Smisaki p4_tx_fair[port] : p2_tx_fair[port]; 8133859Sml29623 custom_start_tdc[port] = start_tdc; 8143859Sml29623 start_tdc += custom_num_tdc[port]; 8153859Sml29623 } 8163859Sml29623 break; 8173859Sml29623 8183859Sml29623 case EQUAL: 8193859Sml29623 cfg_prop = "equal"; 8203859Sml29623 for (port = 0; port < num_ports; port++) { 8213859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 8226929Smisaki p4_tx_equal[port] : p2_tx_equal[port]; 8233859Sml29623 custom_start_tdc[port] = start_tdc; 8243859Sml29623 start_tdc += custom_num_tdc[port]; 8253859Sml29623 } 8263859Sml29623 break; 8273859Sml29623 8283859Sml29623 case CUSTOM: 8293859Sml29623 cfg_prop = "custom"; 8303859Sml29623 /* See if it is good config */ 8313859Sml29623 num_tdc = 0; 8323859Sml29623 for (port = 0; port < num_ports; port++) { 8333859Sml29623 ddi_status = ddi_prop_lookup_int_array( 8346929Smisaki DDI_DEV_T_ANY, s_dip[port], 0, start_tdc_prop, 8356929Smisaki &prop_val, &prop_len); 8363859Sml29623 if (ddi_status == DDI_SUCCESS) 8373859Sml29623 custom_start_tdc[port] = *prop_val; 8383859Sml29623 else { 8393859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8406929Smisaki " %s custom start port %d" 8416929Smisaki " read failed ", " txdma-cfg", port)); 8423859Sml29623 bad_config = B_TRUE; 8433859Sml29623 status |= NXGE_DDI_FAILED; 8443859Sml29623 } 8453859Sml29623 8463859Sml29623 if ((custom_start_tdc[port] == -1) || 8476929Smisaki (custom_start_tdc[port] >= 8486929Smisaki NXGE_MAX_RDCS)) { 8493859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8506929Smisaki " %s custom start %d" 8516929Smisaki " out of range %x ", " txdma-cfg", 8526929Smisaki port, custom_start_tdc[port])); 8533859Sml29623 bad_config = B_TRUE; 8543859Sml29623 break; 8553859Sml29623 } 8563859Sml29623 8573859Sml29623 ddi_status = ddi_prop_lookup_int_array( 8586929Smisaki DDI_DEV_T_ANY, s_dip[port], 0, num_tdc_prop, 8596929Smisaki &prop_val, &prop_len); 8603859Sml29623 if (ddi_status == DDI_SUCCESS) 8613859Sml29623 custom_num_tdc[port] = *prop_val; 8623859Sml29623 else { 8633859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8646929Smisaki " %s custom num port %d" 8656929Smisaki " read failed ", " txdma-cfg", port)); 8663859Sml29623 bad_config = B_TRUE; 8673859Sml29623 status |= NXGE_DDI_FAILED; 8683859Sml29623 } 8693859Sml29623 8703859Sml29623 if ((custom_num_tdc[port] == -1) || 8716929Smisaki (custom_num_tdc[port] > 8726929Smisaki NXGE_MAX_TDCS) || 8736929Smisaki ((custom_num_tdc[port] + 8746929Smisaki custom_start_tdc[port]) > 8756929Smisaki NXGE_MAX_TDCS)) { 8763859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8776929Smisaki " %s custom num %d" 8786929Smisaki " out of range %x ", " rxdma-cfg", 8796929Smisaki port, custom_num_tdc[port])); 8803859Sml29623 bad_config = B_TRUE; 8813859Sml29623 break; 8823859Sml29623 } 8833859Sml29623 num_tdc += custom_num_tdc[port]; 8843859Sml29623 if (num_tdc > NXGE_MAX_TDCS) { 8853859Sml29623 bad_config = B_TRUE; 8863859Sml29623 break; 8873859Sml29623 } 8883859Sml29623 tdc_bitmap[port] = 0; 8893859Sml29623 for (bits = 0; 8906929Smisaki bits < custom_num_tdc[port]; bits++) { 8913859Sml29623 tdc_bitmap[port] |= 8926929Smisaki (1 << 8936929Smisaki (bits + custom_start_tdc[port])); 8943859Sml29623 } 8953859Sml29623 8963859Sml29623 } 8973859Sml29623 8983859Sml29623 if (bad_config == B_FALSE) { 8993859Sml29623 /* check for overlap */ 9003859Sml29623 for (port = 0; port < num_ports - 1; port++) { 9013859Sml29623 for (j = port + 1; j < num_ports; j++) { 9023859Sml29623 if (tdc_bitmap[port] & 9036929Smisaki tdc_bitmap[j]) { 9043859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9056929Smisaki " rxdma-cfg" 9066929Smisaki " property custom" 9076929Smisaki " bit overlap" 9086929Smisaki " %d %d ", 9096929Smisaki port, j)); 9103859Sml29623 bad_config = B_TRUE; 9113859Sml29623 break; 9123859Sml29623 } 9133859Sml29623 } 9143859Sml29623 if (bad_config == B_TRUE) 9153859Sml29623 break; 9163859Sml29623 } 9173859Sml29623 } 9183859Sml29623 if (bad_config == B_TRUE) { 9193859Sml29623 /* use default config */ 9203859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9216929Smisaki " txdma-cfg property:" 9226929Smisaki " bad custom config:" " use default")); 9233859Sml29623 9243859Sml29623 for (port = 0; port < num_ports; port++) { 9253859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 9266929Smisaki p4_tx_fair[port] : p2_tx_fair[port]; 9273859Sml29623 custom_start_tdc[port] = start_tdc; 9283859Sml29623 start_tdc += custom_num_tdc[port]; 9293859Sml29623 } 9303859Sml29623 } 9313859Sml29623 break; 9323859Sml29623 9333859Sml29623 default: 9343859Sml29623 /* use default config */ 9353859Sml29623 cfg_prop = "fair"; 9363859Sml29623 for (port = 0; port < num_ports; port++) { 9373859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 9386929Smisaki p4_tx_fair[port] : p2_tx_fair[port]; 9393859Sml29623 custom_start_tdc[port] = start_tdc; 9403859Sml29623 start_tdc += custom_num_tdc[port]; 9413859Sml29623 } 9423859Sml29623 break; 9433859Sml29623 } 9443859Sml29623 9453859Sml29623 /* Now Update the tx properties */ 9463859Sml29623 for (port = 0; port < num_ports; port++) { 9473859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9486929Smisaki " update property txdma-cfg with %s ", cfg_prop)); 9493859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 9506929Smisaki "txdma-cfg", cfg_prop); 9513859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9523859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9536929Smisaki " property txdma-cfg is not updating to %s", 9546929Smisaki cfg_prop)); 9553859Sml29623 status |= NXGE_DDI_FAILED; 9563859Sml29623 } 9573859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 9586929Smisaki num_tdc_prop, custom_num_tdc[port])); 9593859Sml29623 9603859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 9616929Smisaki num_tdc_prop, custom_num_tdc[port]); 9623859Sml29623 9633859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9643859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 9656929Smisaki " property %s not updating with %d", 9666929Smisaki num_tdc_prop, 9676929Smisaki custom_num_tdc[port])); 9683859Sml29623 status |= NXGE_DDI_FAILED; 9693859Sml29623 } 9703859Sml29623 9713859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 9726929Smisaki start_tdc_prop, custom_start_tdc[port])); 9733859Sml29623 9743859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 9756929Smisaki start_tdc_prop, custom_start_tdc[port]); 9763859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9773859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 9786929Smisaki " property %s not updating with %d ", 9796929Smisaki start_tdc_prop, custom_start_tdc[port])); 9803859Sml29623 status |= NXGE_DDI_FAILED; 9813859Sml29623 } 9823859Sml29623 } 9833859Sml29623 if (status & NXGE_DDI_FAILED) 9843859Sml29623 status |= NXGE_ERROR; 9853859Sml29623 return (status); 9863859Sml29623 } 9873859Sml29623 9883859Sml29623 static nxge_status_t 9893859Sml29623 nxge_update_cfg_properties(p_nxge_t nxgep, uint32_t flags, 9903859Sml29623 config_token_t token, dev_info_t *s_dip[]) 9913859Sml29623 { 9923859Sml29623 nxge_status_t status = NXGE_OK; 9933859Sml29623 9943859Sml29623 switch (flags) { 9953859Sml29623 case COMMON_TXDMA_CFG: 9963859Sml29623 if (nxge_dma_obp_props_only == 0) 9973859Sml29623 status = nxge_update_txdma_properties(nxgep, 9986929Smisaki token, s_dip); 9993859Sml29623 break; 10003859Sml29623 case COMMON_RXDMA_CFG: 10013859Sml29623 if (nxge_dma_obp_props_only == 0) 10023859Sml29623 status = nxge_update_rxdma_properties(nxgep, 10036929Smisaki token, s_dip); 10043859Sml29623 10053859Sml29623 break; 10063859Sml29623 case COMMON_RXDMA_GRP_CFG: 10073859Sml29623 status = nxge_update_rxdma_grp_properties(nxgep, 10086929Smisaki token, s_dip); 10093859Sml29623 break; 10103859Sml29623 default: 10113859Sml29623 return (NXGE_ERROR); 10123859Sml29623 } 10133859Sml29623 return (status); 10143859Sml29623 } 10153859Sml29623 10163859Sml29623 /* 10173859Sml29623 * verify consistence. 10183859Sml29623 * (May require publishing the properties on all the ports. 10193859Sml29623 * 10203859Sml29623 * What if properties are published on function 0 device only? 10213859Sml29623 * 10223859Sml29623 * 10233859Sml29623 * rxdma-cfg, txdma-cfg, rxdma-grp-cfg (required ) 10243859Sml29623 * What about class configs? 10253859Sml29623 * 10263859Sml29623 * If consistent, update the property on all the siblings. 10273859Sml29623 * set a flag on hardware shared register 10283859Sml29623 * The rest of the siblings will check the flag 10293859Sml29623 * if the flag is set, they will use the updated property 10303859Sml29623 * without doing any validation. 10313859Sml29623 */ 10323859Sml29623 10333859Sml29623 nxge_status_t 10343859Sml29623 nxge_cfg_verify_set_classify_prop(p_nxge_t nxgep, char *prop, 10353859Sml29623 uint64_t known_cfg, uint32_t override, dev_info_t *c_dip[]) 10363859Sml29623 { 10373859Sml29623 nxge_status_t status = NXGE_OK; 10383859Sml29623 int ddi_status = DDI_SUCCESS; 10393859Sml29623 int i = 0, found = 0, update_prop = B_TRUE; 10403859Sml29623 int *cfg_val; 10413859Sml29623 uint_t new_value, cfg_value[MAX_SIBLINGS]; 10423859Sml29623 uint_t prop_len; 10433859Sml29623 uint_t known_cfg_value; 10443859Sml29623 10453859Sml29623 known_cfg_value = (uint_t)known_cfg; 10463859Sml29623 10473859Sml29623 if (override == B_TRUE) { 10483859Sml29623 new_value = known_cfg_value; 10493859Sml29623 for (i = 0; i < nxgep->nports; i++) { 10503859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, 10516929Smisaki c_dip[i], prop, new_value); 10523859Sml29623 #ifdef NXGE_DEBUG_ERROR 10533859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 10543859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 10556929Smisaki " property %s failed update ", prop)); 10563859Sml29623 #endif 10573859Sml29623 } 10583859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 10593859Sml29623 return (NXGE_ERROR | NXGE_DDI_FAILED); 10603859Sml29623 } 10613859Sml29623 for (i = 0; i < nxgep->nports; i++) { 10623859Sml29623 cfg_value[i] = known_cfg_value; 10633859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, c_dip[i], 0, 10646929Smisaki prop, &cfg_val, 10656929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 10663859Sml29623 cfg_value[i] = *cfg_val; 10673859Sml29623 ddi_prop_free(cfg_val); 10683859Sml29623 found++; 10693859Sml29623 } 10703859Sml29623 } 10713859Sml29623 10723859Sml29623 if (found != i) { 10733859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10746929Smisaki " property %s not specified on all ports", prop)); 10753859Sml29623 if (found == 0) { 10763859Sml29623 /* not specified: Use default */ 10773859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10786929Smisaki " property %s not specified on any port:" 10796929Smisaki " Using default", prop)); 10803859Sml29623 new_value = known_cfg_value; 10813859Sml29623 } else { 10823859Sml29623 /* specified on some */ 10833859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10846929Smisaki " property %s not specified" 10856929Smisaki " on some ports: Using default", prop)); 10863859Sml29623 /* ? use p0 value instead ? */ 10873859Sml29623 new_value = known_cfg_value; 10883859Sml29623 } 10893859Sml29623 } else { 10903859Sml29623 /* check type and consistence */ 10913859Sml29623 /* found on all devices */ 10923859Sml29623 for (i = 1; i < found; i++) { 10933859Sml29623 if (cfg_value[i] != cfg_value[i - 1]) { 10943859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10956929Smisaki " property %s inconsistent:" 10966929Smisaki " Using default", prop)); 10973859Sml29623 new_value = known_cfg_value; 10983859Sml29623 break; 10993859Sml29623 } 11003859Sml29623 /* 11013859Sml29623 * Found on all the ports and consistent. Nothing to 11023859Sml29623 * do. 11033859Sml29623 */ 11043859Sml29623 update_prop = B_FALSE; 11053859Sml29623 } 11063859Sml29623 } 11073859Sml29623 11083859Sml29623 if (update_prop == B_TRUE) { 11093859Sml29623 for (i = 0; i < nxgep->nports; i++) { 11103859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, 11116929Smisaki c_dip[i], prop, new_value); 11123859Sml29623 #ifdef NXGE_DEBUG_ERROR 11133859Sml29623 if (ddi_status != DDI_SUCCESS) 11143859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 11156929Smisaki " property %s not updating with %d" 11166929Smisaki " Using default", 11176929Smisaki prop, new_value)); 11183859Sml29623 #endif 11193859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 11203859Sml29623 status |= NXGE_DDI_FAILED; 11213859Sml29623 } 11223859Sml29623 } 11233859Sml29623 if (status & NXGE_DDI_FAILED) 11243859Sml29623 status |= NXGE_ERROR; 11253859Sml29623 11263859Sml29623 return (status); 11273859Sml29623 } 11283859Sml29623 11293859Sml29623 static uint64_t 11303859Sml29623 nxge_class_get_known_cfg(p_nxge_t nxgep, int class_prop, int rx_quick_cfg) 11313859Sml29623 { 11323859Sml29623 int start_prop; 11333859Sml29623 uint64_t cfg_value; 11343859Sml29623 p_nxge_param_t param_arr; 11353859Sml29623 11363859Sml29623 param_arr = nxgep->param_arr; 11373859Sml29623 cfg_value = param_arr[class_prop].value; 11383859Sml29623 start_prop = param_h1_init_value; 11393859Sml29623 11403859Sml29623 /* update the properties per quick config */ 11413859Sml29623 switch (rx_quick_cfg) { 11423859Sml29623 case CFG_L3_WEB: 11433859Sml29623 case CFG_L3_DISTRIBUTE: 11443859Sml29623 cfg_value = nxge_classify_get_cfg_value(nxgep, 11456929Smisaki rx_quick_cfg, class_prop - start_prop); 11463859Sml29623 break; 11473859Sml29623 default: 11483859Sml29623 cfg_value = param_arr[class_prop].value; 11493859Sml29623 break; 11503859Sml29623 } 11513859Sml29623 return (cfg_value); 11523859Sml29623 } 11533859Sml29623 11543859Sml29623 static nxge_status_t 11553859Sml29623 nxge_cfg_verify_set_classify(p_nxge_t nxgep, dev_info_t *c_dip[]) 11563859Sml29623 { 11573859Sml29623 nxge_status_t status = NXGE_OK; 11583859Sml29623 int rx_quick_cfg, class_prop, start_prop, end_prop; 11593859Sml29623 char *prop_name; 11603859Sml29623 int override = B_TRUE; 11613859Sml29623 uint64_t cfg_value; 11623859Sml29623 p_nxge_param_t param_arr; 11633859Sml29623 11643859Sml29623 param_arr = nxgep->param_arr; 11653859Sml29623 rx_quick_cfg = param_arr[param_rx_quick_cfg].value; 11663859Sml29623 start_prop = param_h1_init_value; 11673859Sml29623 end_prop = param_class_opt_ipv6_sctp; 11683859Sml29623 11693859Sml29623 /* update the properties per quick config */ 11703859Sml29623 if (rx_quick_cfg == CFG_NOT_SPECIFIED) 11713859Sml29623 override = B_FALSE; 11723859Sml29623 11733859Sml29623 /* 11743859Sml29623 * these parameter affect the classification outcome. 11753859Sml29623 * these parameters are used to configure the Flow key and 11763859Sml29623 * the TCAM key for each of the IP classes. 11773859Sml29623 * Included here are also the H1 and H2 initial values 11783859Sml29623 * which affect the distribution as well as final hash value 11793859Sml29623 * (hence the offset into RDC table and FCRAM bucket location) 11803859Sml29623 * 11813859Sml29623 */ 11823859Sml29623 for (class_prop = start_prop; class_prop <= end_prop; class_prop++) { 11833859Sml29623 prop_name = param_arr[class_prop].fcode_name; 11843859Sml29623 cfg_value = nxge_class_get_known_cfg(nxgep, 11856929Smisaki class_prop, rx_quick_cfg); 11863859Sml29623 status = nxge_cfg_verify_set_classify_prop(nxgep, prop_name, 11876929Smisaki cfg_value, override, c_dip); 11883859Sml29623 } 11893859Sml29623 11903859Sml29623 /* 11913859Sml29623 * these properties do not affect the actual classification outcome. 11923859Sml29623 * used to enable/disable or tune the fflp hardware 11933859Sml29623 * 11943859Sml29623 * fcram_access_ratio, tcam_access_ratio, tcam_enable, llc_snap_enable 11953859Sml29623 * 11963859Sml29623 */ 11973859Sml29623 override = B_FALSE; 11983859Sml29623 for (class_prop = param_fcram_access_ratio; 11996929Smisaki class_prop <= param_llc_snap_enable; class_prop++) { 12003859Sml29623 prop_name = param_arr[class_prop].fcode_name; 12013859Sml29623 cfg_value = param_arr[class_prop].value; 12023859Sml29623 status = nxge_cfg_verify_set_classify_prop(nxgep, prop_name, 12036929Smisaki cfg_value, override, c_dip); 12043859Sml29623 } 12053859Sml29623 12063859Sml29623 return (status); 12073859Sml29623 } 12083859Sml29623 12093859Sml29623 nxge_status_t 12103859Sml29623 nxge_cfg_verify_set(p_nxge_t nxgep, uint32_t flag) 12113859Sml29623 { 12123859Sml29623 nxge_status_t status = NXGE_OK; 12133859Sml29623 int i = 0, found = 0; 12143859Sml29623 int num_siblings; 12153859Sml29623 dev_info_t *c_dip[MAX_SIBLINGS + 1]; 12163859Sml29623 char *prop_val[MAX_SIBLINGS]; 12173859Sml29623 config_token_t c_token[MAX_SIBLINGS]; 12183859Sml29623 char *prop; 12193859Sml29623 12203859Sml29623 if (nxge_dma_obp_props_only) 12213859Sml29623 return (NXGE_OK); 12223859Sml29623 12233859Sml29623 num_siblings = 0; 12243859Sml29623 c_dip[num_siblings] = ddi_get_child(nxgep->p_dip); 12253859Sml29623 while (c_dip[num_siblings]) { 12263859Sml29623 c_dip[num_siblings + 1] = 12276929Smisaki ddi_get_next_sibling(c_dip[num_siblings]); 12283859Sml29623 num_siblings++; 12293859Sml29623 } 12303859Sml29623 12313859Sml29623 switch (flag) { 12323859Sml29623 case COMMON_TXDMA_CFG: 12333859Sml29623 prop = "txdma-cfg"; 12343859Sml29623 break; 12353859Sml29623 case COMMON_RXDMA_CFG: 12363859Sml29623 prop = "rxdma-cfg"; 12373859Sml29623 break; 12383859Sml29623 case COMMON_RXDMA_GRP_CFG: 12393859Sml29623 prop = "rxdma-grp-cfg"; 12403859Sml29623 break; 12413859Sml29623 case COMMON_CLASS_CFG: 12423859Sml29623 status = nxge_cfg_verify_set_classify(nxgep, c_dip); 12433859Sml29623 return (status); 12443859Sml29623 default: 12453859Sml29623 return (NXGE_ERROR); 12463859Sml29623 } 12473859Sml29623 12483859Sml29623 i = 0; 12493859Sml29623 while (i < num_siblings) { 12503859Sml29623 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, c_dip[i], 0, prop, 12516929Smisaki (char **)&prop_val[i]) == DDI_PROP_SUCCESS) { 12523859Sml29623 c_token[i] = nxge_get_config_token(prop_val[i]); 12533859Sml29623 ddi_prop_free(prop_val[i]); 12543859Sml29623 found++; 12553859Sml29623 } else 12563859Sml29623 c_token[i] = CONFIG_TOKEN_NONE; 12573859Sml29623 i++; 12583859Sml29623 } 12593859Sml29623 12603859Sml29623 if (found != i) { 12613859Sml29623 if (found == 0) { 12623859Sml29623 /* not specified: Use default */ 12633859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12646929Smisaki " property %s not specified on any port:" 12656929Smisaki " Using default", prop)); 12663859Sml29623 12673859Sml29623 status = nxge_update_cfg_properties(nxgep, 12686929Smisaki flag, FAIR, c_dip); 12693859Sml29623 return (status); 12703859Sml29623 } else { 12713859Sml29623 /* 12723859Sml29623 * if the convention is to use function 0 device then 12733859Sml29623 * populate the other devices with this configuration. 12743859Sml29623 * 12753859Sml29623 * The other alternative is to use the default config. 12763859Sml29623 */ 12773859Sml29623 /* not specified: Use default */ 12783859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12796929Smisaki " property %s not specified on some ports:" 12806929Smisaki " Using default", prop)); 12813859Sml29623 status = nxge_update_cfg_properties(nxgep, 12826929Smisaki flag, FAIR, c_dip); 12833859Sml29623 return (status); 12843859Sml29623 } 12853859Sml29623 } 12863859Sml29623 12873859Sml29623 /* check type and consistence */ 12883859Sml29623 /* found on all devices */ 12893859Sml29623 for (i = 1; i < found; i++) { 12903859Sml29623 if (c_token[i] != c_token[i - 1]) { 12913859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12926929Smisaki " property %s inconsistent:" 12936929Smisaki " Using default", prop)); 12943859Sml29623 status = nxge_update_cfg_properties(nxgep, 12956929Smisaki flag, FAIR, c_dip); 12963859Sml29623 return (status); 12973859Sml29623 } 12983859Sml29623 } 12993859Sml29623 13003859Sml29623 /* 13013859Sml29623 * Found on all the ports check if it is custom configuration. if 13023859Sml29623 * custom, then verify consistence 13033859Sml29623 * 13043859Sml29623 * finally create soft properties 13053859Sml29623 */ 13063859Sml29623 status = nxge_update_cfg_properties(nxgep, flag, c_token[0], c_dip); 13073859Sml29623 return (status); 13083859Sml29623 } 13093859Sml29623 13103859Sml29623 nxge_status_t 13113859Sml29623 nxge_cfg_verify_set_quick_config(p_nxge_t nxgep) 13123859Sml29623 { 13133859Sml29623 nxge_status_t status = NXGE_OK; 13143859Sml29623 int ddi_status = DDI_SUCCESS; 13153859Sml29623 char *prop_val; 13163859Sml29623 char *rx_prop; 13173859Sml29623 char *prop; 13183859Sml29623 uint32_t cfg_value = CFG_NOT_SPECIFIED; 13193859Sml29623 p_nxge_param_t param_arr; 13203859Sml29623 13213859Sml29623 param_arr = nxgep->param_arr; 13223859Sml29623 rx_prop = param_arr[param_rx_quick_cfg].fcode_name; 13233859Sml29623 13243859Sml29623 prop = "rx-quick-cfg"; 13253859Sml29623 13263859Sml29623 /* 13273859Sml29623 * good value are 13283859Sml29623 * 13293859Sml29623 * "web-server" "generic-server" "l3-classify" "flow-classify" 13303859Sml29623 */ 13313859Sml29623 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, nxgep->dip, 0, 13326929Smisaki prop, (char **)&prop_val) != DDI_PROP_SUCCESS) { 13333859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 13346929Smisaki " property %s not specified: using default ", prop)); 13353859Sml29623 cfg_value = CFG_NOT_SPECIFIED; 13363859Sml29623 } else { 13373859Sml29623 cfg_value = CFG_L3_DISTRIBUTE; 13383859Sml29623 if (strncmp("web-server", (caddr_t)prop_val, 8) == 0) { 13393859Sml29623 cfg_value = CFG_L3_WEB; 13403859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 13416929Smisaki " %s: web server ", prop)); 13423859Sml29623 } 13433859Sml29623 if (strncmp("generic-server", (caddr_t)prop_val, 8) == 0) { 13443859Sml29623 cfg_value = CFG_L3_DISTRIBUTE; 13453859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 13466929Smisaki " %s: distribute ", prop)); 13473859Sml29623 } 13483859Sml29623 /* more */ 13493859Sml29623 ddi_prop_free(prop_val); 13503859Sml29623 } 13513859Sml29623 13523859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 13536929Smisaki rx_prop, cfg_value); 13543859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 13553859Sml29623 status |= NXGE_DDI_FAILED; 13563859Sml29623 13573859Sml29623 /* now handle specified cases: */ 13583859Sml29623 if (status & NXGE_DDI_FAILED) 13593859Sml29623 status |= NXGE_ERROR; 13603859Sml29623 return (status); 13613859Sml29623 } 13623859Sml29623 13636835Syc148097 /* 13646835Syc148097 * Device properties adv-autoneg-cap etc are defined by FWARC 13656835Syc148097 * http://sac.sfbay/FWARC/2002/345/20020610_asif.haswarey 13666835Syc148097 */ 13673859Sml29623 static void 13683859Sml29623 nxge_use_cfg_link_cfg(p_nxge_t nxgep) 13693859Sml29623 { 13703859Sml29623 int *prop_val; 13713859Sml29623 uint_t prop_len; 13723859Sml29623 dev_info_t *dip; 13733859Sml29623 int speed; 13743859Sml29623 int duplex; 13753859Sml29623 int adv_autoneg_cap; 13763859Sml29623 int adv_10gfdx_cap; 13773859Sml29623 int adv_10ghdx_cap; 13783859Sml29623 int adv_1000fdx_cap; 13793859Sml29623 int adv_1000hdx_cap; 13803859Sml29623 int adv_100fdx_cap; 13813859Sml29623 int adv_100hdx_cap; 13823859Sml29623 int adv_10fdx_cap; 13833859Sml29623 int adv_10hdx_cap; 13843859Sml29623 int status = DDI_SUCCESS; 13853859Sml29623 13863859Sml29623 dip = nxgep->dip; 13873859Sml29623 13883859Sml29623 /* 13893859Sml29623 * first find out the card type and the supported link speeds and 13903859Sml29623 * features 13913859Sml29623 */ 13923859Sml29623 /* add code for card type */ 13933859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-autoneg-cap", 13946929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 13953859Sml29623 ddi_prop_free(prop_val); 13963859Sml29623 return; 13973859Sml29623 } 13983859Sml29623 13993859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10gfdx-cap", 14006929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14013859Sml29623 ddi_prop_free(prop_val); 14023859Sml29623 return; 14033859Sml29623 } 14043859Sml29623 14053859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-1000hdx-cap", 14066929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14073859Sml29623 ddi_prop_free(prop_val); 14083859Sml29623 return; 14093859Sml29623 } 14103859Sml29623 14113859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-1000fdx-cap", 14126929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14133859Sml29623 ddi_prop_free(prop_val); 14143859Sml29623 return; 14153859Sml29623 } 14163859Sml29623 14173859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-100fdx-cap", 14186929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14193859Sml29623 ddi_prop_free(prop_val); 14203859Sml29623 return; 14213859Sml29623 } 14223859Sml29623 14233859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-100hdx-cap", 14246929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14253859Sml29623 ddi_prop_free(prop_val); 14263859Sml29623 return; 14273859Sml29623 } 14283859Sml29623 14293859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10fdx-cap", 14306929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14313859Sml29623 ddi_prop_free(prop_val); 14323859Sml29623 return; 14333859Sml29623 } 14343859Sml29623 14353859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10hdx-cap", 14366929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14373859Sml29623 ddi_prop_free(prop_val); 14383859Sml29623 return; 14393859Sml29623 } 14403859Sml29623 14413859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, "speed", 14426929Smisaki (uchar_t **)&prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14433859Sml29623 if (strncmp("10000", (caddr_t)prop_val, 14446929Smisaki (size_t)prop_len) == 0) { 14453859Sml29623 speed = 10000; 14463859Sml29623 } else if (strncmp("1000", (caddr_t)prop_val, 14476929Smisaki (size_t)prop_len) == 0) { 14483859Sml29623 speed = 1000; 14493859Sml29623 } else if (strncmp("100", (caddr_t)prop_val, 14506929Smisaki (size_t)prop_len) == 0) { 14513859Sml29623 speed = 100; 14523859Sml29623 } else if (strncmp("10", (caddr_t)prop_val, 14536929Smisaki (size_t)prop_len) == 0) { 14543859Sml29623 speed = 10; 14553859Sml29623 } else if (strncmp("auto", (caddr_t)prop_val, 14566929Smisaki (size_t)prop_len) == 0) { 14573859Sml29623 speed = 0; 14583859Sml29623 } else { 14593859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_NOTE, 14606929Smisaki "speed property is invalid reverting to auto")); 14613859Sml29623 speed = 0; 14623859Sml29623 } 14633859Sml29623 ddi_prop_free(prop_val); 14643859Sml29623 } else 14653859Sml29623 speed = 0; 14663859Sml29623 14673859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, "duplex", 14686929Smisaki (uchar_t **)&prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14693859Sml29623 if (strncmp("full", (caddr_t)prop_val, 14706929Smisaki (size_t)prop_len) == 0) { 14713859Sml29623 duplex = 2; 14723859Sml29623 } else if (strncmp("half", (caddr_t)prop_val, 14736929Smisaki (size_t)prop_len) == 0) { 14743859Sml29623 duplex = 1; 14753859Sml29623 } else if (strncmp("auto", (caddr_t)prop_val, 14766929Smisaki (size_t)prop_len) == 0) { 14773859Sml29623 duplex = 0; 14783859Sml29623 } else { 14793859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_NOTE, 14806929Smisaki "duplex property is invalid" 14816929Smisaki " reverting to auto")); 14823859Sml29623 duplex = 0; 14833859Sml29623 } 14843859Sml29623 ddi_prop_free(prop_val); 14853859Sml29623 } else 14863859Sml29623 duplex = 0; 14873859Sml29623 14886835Syc148097 /* speed == 0 or duplex == 0 means auto negotiation. */ 14893859Sml29623 adv_autoneg_cap = (speed == 0) || (duplex == 0); 14903859Sml29623 if (adv_autoneg_cap == 0) { 14913859Sml29623 adv_10gfdx_cap = ((speed == 10000) && (duplex == 2)); 14923859Sml29623 adv_10ghdx_cap = adv_10gfdx_cap; 14933859Sml29623 adv_10ghdx_cap |= ((speed == 10000) && (duplex == 1)); 14943859Sml29623 adv_1000fdx_cap = adv_10ghdx_cap; 14953859Sml29623 adv_1000fdx_cap |= ((speed == 1000) && (duplex == 2)); 14963859Sml29623 adv_1000hdx_cap = adv_1000fdx_cap; 14973859Sml29623 adv_1000hdx_cap |= ((speed == 1000) && (duplex == 1)); 14983859Sml29623 adv_100fdx_cap = adv_1000hdx_cap; 14993859Sml29623 adv_100fdx_cap |= ((speed == 100) && (duplex == 2)); 15003859Sml29623 adv_100hdx_cap = adv_100fdx_cap; 15013859Sml29623 adv_100hdx_cap |= ((speed == 100) && (duplex == 1)); 15023859Sml29623 adv_10fdx_cap = adv_100hdx_cap; 15033859Sml29623 adv_10fdx_cap |= ((speed == 10) && (duplex == 2)); 15043859Sml29623 adv_10hdx_cap = adv_10fdx_cap; 15053859Sml29623 adv_10hdx_cap |= ((speed == 10) && (duplex == 1)); 15063859Sml29623 } else if (speed == 0) { 15073859Sml29623 adv_10gfdx_cap = (duplex == 2); 15083859Sml29623 adv_10ghdx_cap = (duplex == 1); 15093859Sml29623 adv_1000fdx_cap = (duplex == 2); 15103859Sml29623 adv_1000hdx_cap = (duplex == 1); 15113859Sml29623 adv_100fdx_cap = (duplex == 2); 15123859Sml29623 adv_100hdx_cap = (duplex == 1); 15133859Sml29623 adv_10fdx_cap = (duplex == 2); 15143859Sml29623 adv_10hdx_cap = (duplex == 1); 15153859Sml29623 } 15163859Sml29623 if (duplex == 0) { 15173859Sml29623 adv_10gfdx_cap = (speed == 0); 15183859Sml29623 adv_10gfdx_cap |= (speed == 10000); 15193859Sml29623 adv_10ghdx_cap = adv_10gfdx_cap; 15203859Sml29623 adv_10ghdx_cap |= (speed == 10000); 15213859Sml29623 adv_1000fdx_cap = adv_10ghdx_cap; 15223859Sml29623 adv_1000fdx_cap |= (speed == 1000); 15233859Sml29623 adv_1000hdx_cap = adv_1000fdx_cap; 15243859Sml29623 adv_1000hdx_cap |= (speed == 1000); 15253859Sml29623 adv_100fdx_cap = adv_1000hdx_cap; 15263859Sml29623 adv_100fdx_cap |= (speed == 100); 15273859Sml29623 adv_100hdx_cap = adv_100fdx_cap; 15283859Sml29623 adv_100hdx_cap |= (speed == 100); 15293859Sml29623 adv_10fdx_cap = adv_100hdx_cap; 15303859Sml29623 adv_10fdx_cap |= (speed == 10); 15313859Sml29623 adv_10hdx_cap = adv_10fdx_cap; 15323859Sml29623 adv_10hdx_cap |= (speed == 10); 15333859Sml29623 } 15343859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15356929Smisaki "adv-autoneg-cap", &adv_autoneg_cap, 1); 15363859Sml29623 if (status) 15373859Sml29623 return; 15383859Sml29623 15393859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15406929Smisaki "adv-10gfdx-cap", &adv_10gfdx_cap, 1); 15413859Sml29623 if (status) 15423859Sml29623 goto nxge_map_myargs_to_gmii_fail1; 15433859Sml29623 15443859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15456929Smisaki "adv-10ghdx-cap", &adv_10ghdx_cap, 1); 15463859Sml29623 if (status) 15473859Sml29623 goto nxge_map_myargs_to_gmii_fail2; 15483859Sml29623 15493859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15506929Smisaki "adv-1000fdx-cap", &adv_1000fdx_cap, 1); 15513859Sml29623 if (status) 15523859Sml29623 goto nxge_map_myargs_to_gmii_fail3; 15533859Sml29623 15543859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15556929Smisaki "adv-1000hdx-cap", &adv_1000hdx_cap, 1); 15563859Sml29623 if (status) 15573859Sml29623 goto nxge_map_myargs_to_gmii_fail4; 15583859Sml29623 15593859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15606929Smisaki "adv-100fdx-cap", &adv_100fdx_cap, 1); 15613859Sml29623 if (status) 15623859Sml29623 goto nxge_map_myargs_to_gmii_fail5; 15633859Sml29623 15643859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15656929Smisaki "adv-100hdx-cap", &adv_100hdx_cap, 1); 15663859Sml29623 if (status) 15673859Sml29623 goto nxge_map_myargs_to_gmii_fail6; 15683859Sml29623 15693859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15706929Smisaki "adv-10fdx-cap", &adv_10fdx_cap, 1); 15713859Sml29623 if (status) 15723859Sml29623 goto nxge_map_myargs_to_gmii_fail7; 15733859Sml29623 15743859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15756929Smisaki "adv-10hdx-cap", &adv_10hdx_cap, 1); 15763859Sml29623 if (status) 15773859Sml29623 goto nxge_map_myargs_to_gmii_fail8; 15783859Sml29623 15793859Sml29623 return; 15803859Sml29623 15813859Sml29623 nxge_map_myargs_to_gmii_fail9: 15823859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10hdx-cap"); 15833859Sml29623 15843859Sml29623 nxge_map_myargs_to_gmii_fail8: 15853859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10fdx-cap"); 15863859Sml29623 15873859Sml29623 nxge_map_myargs_to_gmii_fail7: 15883859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-100hdx-cap"); 15893859Sml29623 15903859Sml29623 nxge_map_myargs_to_gmii_fail6: 15913859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-100fdx-cap"); 15923859Sml29623 15933859Sml29623 nxge_map_myargs_to_gmii_fail5: 15943859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-1000hdx-cap"); 15953859Sml29623 15963859Sml29623 nxge_map_myargs_to_gmii_fail4: 15973859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-1000fdx-cap"); 15983859Sml29623 15993859Sml29623 nxge_map_myargs_to_gmii_fail3: 16003859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10ghdx-cap"); 16013859Sml29623 16023859Sml29623 nxge_map_myargs_to_gmii_fail2: 16033859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10gfdx-cap"); 16043859Sml29623 16053859Sml29623 nxge_map_myargs_to_gmii_fail1: 16063859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-autoneg-cap"); 16073859Sml29623 } 16083859Sml29623 16093859Sml29623 nxge_status_t 16103859Sml29623 nxge_get_config_properties(p_nxge_t nxgep) 16113859Sml29623 { 16123859Sml29623 nxge_status_t status = NXGE_OK; 16133859Sml29623 p_nxge_hw_list_t hw_p; 16143859Sml29623 16153859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, " ==> nxge_get_config_properties")); 16163859Sml29623 16173859Sml29623 if ((hw_p = nxgep->nxge_hw_p) == NULL) { 16183859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 16196929Smisaki " nxge_get_config_properties:" 16206929Smisaki " common hardware not set", nxgep->niu_type)); 16213859Sml29623 return (NXGE_ERROR); 16223859Sml29623 } 16233859Sml29623 16243859Sml29623 /* 16258275SEric Cheng * XXX: read-in the config file to determine the number of packet 16268275SEric Cheng * to process by each interrupt. 16278275SEric Cheng */ 16288275SEric Cheng nxge_max_intr_pkts = ddi_getprop(DDI_DEV_T_ANY, nxgep->dip, 16298275SEric Cheng DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS, "max_intr_pkts", 1); 16308275SEric Cheng 16318275SEric Cheng 16328275SEric Cheng /* 16333859Sml29623 * Get info on how many ports Neptune card has. 16343859Sml29623 */ 16354977Sraghus nxgep->nports = nxge_get_nports(nxgep); 16364732Sdavemq if (nxgep->nports <= 0) { 16374732Sdavemq NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 16384732Sdavemq "<==nxge_get_config_properties: Invalid Neptune type 0x%x", 16394732Sdavemq nxgep->niu_type)); 16404732Sdavemq return (NXGE_ERROR); 16414732Sdavemq } 16424732Sdavemq nxgep->classifier.tcam_size = TCAM_NIU_TCAM_MAX_ENTRY; 16434977Sraghus if (NXGE_IS_VALID_NEPTUNE_TYPE(nxgep)) { 16444977Sraghus nxgep->classifier.tcam_size = TCAM_NXGE_TCAM_MAX_ENTRY; 16454977Sraghus } 16464732Sdavemq if (nxgep->function_num >= nxgep->nports) { 16474732Sdavemq return (NXGE_ERROR); 16483859Sml29623 } 16493859Sml29623 16503859Sml29623 status = nxge_get_mac_addr_properties(nxgep); 16513859Sml29623 if (status != NXGE_OK) 16523859Sml29623 return (NXGE_ERROR); 16533859Sml29623 16543859Sml29623 /* 16553859Sml29623 * read the configuration type. If none is specified, used default. 16563859Sml29623 * Config types: equal: (default) DMA channels, RDC groups, TCAM, FCRAM 16573859Sml29623 * are shared equally across all the ports. 16583859Sml29623 * 16593859Sml29623 * Fair: DMA channels, RDC groups, TCAM, FCRAM are shared proportional 16603859Sml29623 * to the port speed. 16613859Sml29623 * 16623859Sml29623 * 16633859Sml29623 * custom: DMA channels, RDC groups, TCAM, FCRAM partition is 16643859Sml29623 * specified in nxge.conf. Need to read each parameter and set 16653859Sml29623 * up the parameters in nxge structures. 16663859Sml29623 * 16673859Sml29623 */ 16683859Sml29623 switch (nxgep->niu_type) { 16693859Sml29623 case N2_NIU: 16703859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 16716929Smisaki " ==> nxge_get_config_properties: N2")); 16723859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 16733859Sml29623 if ((hw_p->flags & COMMON_CFG_VALID) != 16746929Smisaki COMMON_CFG_VALID) { 16753859Sml29623 status = nxge_cfg_verify_set(nxgep, 16766929Smisaki COMMON_RXDMA_GRP_CFG); 16773859Sml29623 status = nxge_cfg_verify_set(nxgep, 16786929Smisaki COMMON_CLASS_CFG); 16793859Sml29623 hw_p->flags |= COMMON_CFG_VALID; 16803859Sml29623 } 16813859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 16823859Sml29623 status = nxge_use_cfg_n2niu_properties(nxgep); 16833859Sml29623 break; 16844732Sdavemq default: 16854977Sraghus if (!NXGE_IS_VALID_NEPTUNE_TYPE(nxgep)) { 16864732Sdavemq NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 16874732Sdavemq " nxge_get_config_properties:" 16884732Sdavemq " unknown NIU type 0x%x", nxgep->niu_type)); 16894732Sdavemq return (NXGE_ERROR); 16904732Sdavemq } 16914732Sdavemq 16923859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 16936929Smisaki " ==> nxge_get_config_properties: Neptune")); 16943859Sml29623 status = nxge_cfg_verify_set_quick_config(nxgep); 16953859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 16963859Sml29623 if ((hw_p->flags & COMMON_CFG_VALID) != 16976929Smisaki COMMON_CFG_VALID) { 16983859Sml29623 status = nxge_cfg_verify_set(nxgep, 16996929Smisaki COMMON_TXDMA_CFG); 17003859Sml29623 status = nxge_cfg_verify_set(nxgep, 17016929Smisaki COMMON_RXDMA_CFG); 17023859Sml29623 status = nxge_cfg_verify_set(nxgep, 17036929Smisaki COMMON_RXDMA_GRP_CFG); 17043859Sml29623 status = nxge_cfg_verify_set(nxgep, 17056929Smisaki COMMON_CLASS_CFG); 17063859Sml29623 hw_p->flags |= COMMON_CFG_VALID; 17073859Sml29623 } 17083859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 17093859Sml29623 nxge_use_cfg_neptune_properties(nxgep); 17103859Sml29623 status = NXGE_OK; 17113859Sml29623 break; 17123859Sml29623 } 17133859Sml29623 17146003Sml29623 /* 17156003Sml29623 * Get the software LSO enable flag property from the 17166003Sml29623 * driver configuration file (nxge.conf). 17176003Sml29623 * This flag will be set to disable (0) if this property 17186003Sml29623 * does not exist. 17196003Sml29623 */ 17206003Sml29623 nxgep->soft_lso_enable = ddi_prop_get_int(DDI_DEV_T_ANY, nxgep->dip, 17216003Sml29623 DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "soft-lso-enable", 0); 17226003Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 17236003Sml29623 "nxge_get_config_properties: software lso %d\n", 17246003Sml29623 nxgep->soft_lso_enable)); 17256003Sml29623 17263859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, " <== nxge_get_config_properties")); 17273859Sml29623 return (status); 17283859Sml29623 } 17293859Sml29623 17303859Sml29623 static nxge_status_t 17313859Sml29623 nxge_use_cfg_n2niu_properties(p_nxge_t nxgep) 17323859Sml29623 { 17333859Sml29623 nxge_status_t status = NXGE_OK; 17343859Sml29623 17353859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_n2niu_properties")); 17363859Sml29623 17373859Sml29623 status = nxge_use_default_dma_config_n2(nxgep); 17383859Sml29623 if (status != NXGE_OK) { 17393859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 17406929Smisaki " ==> nxge_use_cfg_n2niu_properties (err 0x%x)", 17416929Smisaki status)); 17423859Sml29623 return (status | NXGE_ERROR); 17433859Sml29623 } 17443859Sml29623 17453859Sml29623 (void) nxge_use_cfg_vlan_class_config(nxgep); 17463859Sml29623 (void) nxge_use_cfg_mac_class_config(nxgep); 17473859Sml29623 (void) nxge_use_cfg_class_config(nxgep); 17483859Sml29623 (void) nxge_use_cfg_link_cfg(nxgep); 17493859Sml29623 17503859Sml29623 /* 17513859Sml29623 * Read in the hardware (fcode) properties. Use the ndd array to read 17523859Sml29623 * each property. 17533859Sml29623 */ 17543859Sml29623 (void) nxge_get_param_soft_properties(nxgep); 17553859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_n2niu_properties")); 17563859Sml29623 17573859Sml29623 return (status); 17583859Sml29623 } 17593859Sml29623 17603859Sml29623 static void 17613859Sml29623 nxge_use_cfg_neptune_properties(p_nxge_t nxgep) 17623859Sml29623 { 17633859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_neptune_properties")); 17643859Sml29623 17653859Sml29623 (void) nxge_use_cfg_dma_config(nxgep); 17663859Sml29623 (void) nxge_use_cfg_vlan_class_config(nxgep); 17673859Sml29623 (void) nxge_use_cfg_mac_class_config(nxgep); 17683859Sml29623 (void) nxge_use_cfg_class_config(nxgep); 17693859Sml29623 (void) nxge_use_cfg_link_cfg(nxgep); 17703859Sml29623 17713859Sml29623 /* 17723859Sml29623 * Read in the hardware (fcode) properties. Use the ndd array to read 17733859Sml29623 * each property. 17743859Sml29623 */ 17753859Sml29623 (void) nxge_get_param_soft_properties(nxgep); 17763859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_neptune_properties")); 17773859Sml29623 } 17783859Sml29623 17793859Sml29623 /* 17803859Sml29623 * FWARC 2006/556 17813859Sml29623 */ 17823859Sml29623 17833859Sml29623 static nxge_status_t 17843859Sml29623 nxge_use_default_dma_config_n2(p_nxge_t nxgep) 17853859Sml29623 { 17863859Sml29623 int ndmas; 17873859Sml29623 uint8_t func; 17883859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 17893859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 17903859Sml29623 int *prop_val; 17913859Sml29623 uint_t prop_len; 17923859Sml29623 int i; 17933859Sml29623 nxge_status_t status = NXGE_OK; 17943859Sml29623 17953859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2")); 17963859Sml29623 17973859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 17983859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 17993859Sml29623 18003859Sml29623 func = nxgep->function_num; 18013859Sml29623 p_cfgp->function_number = func; 18023859Sml29623 ndmas = NXGE_TDMA_PER_NIU_PORT; 18033859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 18046929Smisaki "tx-dma-channels", (int **)&prop_val, 18056929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 18066495Sspeer p_cfgp->tdc.start = prop_val[0]; 18073859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18086929Smisaki "==> nxge_use_default_dma_config_n2: tdc starts %d " 18096929Smisaki "(#%d)", p_cfgp->tdc.start, prop_len)); 18103859Sml29623 18113859Sml29623 ndmas = prop_val[1]; 18123859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18136929Smisaki "==> nxge_use_default_dma_config_n2: #tdc %d (#%d)", 18146929Smisaki ndmas, prop_len)); 18153859Sml29623 ddi_prop_free(prop_val); 18163859Sml29623 } else { 18173859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18186929Smisaki "==> nxge_use_default_dma_config_n2: " 18196929Smisaki "get tx-dma-channels failed")); 18203859Sml29623 return (NXGE_DDI_FAILED); 18213859Sml29623 } 18223859Sml29623 18238275SEric Cheng p_cfgp->tdc.count = ndmas; 18246495Sspeer p_cfgp->tdc.owned = p_cfgp->tdc.count; 18253859Sml29623 18263859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 18278275SEric Cheng "p_cfgp 0x%llx max_tdcs %d start %d", 18288275SEric Cheng p_cfgp, p_cfgp->tdc.count, p_cfgp->tdc.start)); 18293859Sml29623 18303859Sml29623 /* Receive DMA */ 18313859Sml29623 ndmas = NXGE_RDMA_PER_NIU_PORT; 18323859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 18336929Smisaki "rx-dma-channels", (int **)&prop_val, 18346929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 18353859Sml29623 p_cfgp->start_rdc = prop_val[0]; 18363859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18376929Smisaki "==> nxge_use_default_dma_config_n2(obp): rdc start %d" 18386929Smisaki " (#%d)", p_cfgp->start_rdc, prop_len)); 18393859Sml29623 ndmas = prop_val[1]; 18403859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18416929Smisaki "==> nxge_use_default_dma_config_n2(obp):#rdc %d (#%d)", 18426929Smisaki ndmas, prop_len)); 18433859Sml29623 ddi_prop_free(prop_val); 18443859Sml29623 } else { 18453859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18466929Smisaki "==> nxge_use_default_dma_config_n2: " 18476929Smisaki "get rx-dma-channel failed")); 18483859Sml29623 return (NXGE_DDI_FAILED); 18493859Sml29623 } 18503859Sml29623 18518275SEric Cheng p_cfgp->max_rdcs = ndmas; 18523859Sml29623 nxgep->rdc_mask = (ndmas - 1); 18533859Sml29623 18543859Sml29623 /* Hypervisor: rdc # and group # use the same # !! */ 18556495Sspeer p_cfgp->max_grpids = p_cfgp->max_rdcs + p_cfgp->tdc.owned; 18563859Sml29623 p_cfgp->mif_ldvid = p_cfgp->mac_ldvid = p_cfgp->ser_ldvid = 0; 18573859Sml29623 18583859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 18596929Smisaki "interrupts", (int **)&prop_val, 18606929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 18613859Sml29623 /* 18623859Sml29623 * For each device assigned, the content of each interrupts 18633859Sml29623 * property is its logical device group. 18643859Sml29623 * 18653859Sml29623 * Assignment of interrupts property is in the the following 18663859Sml29623 * order: 18673859Sml29623 * 18683859Sml29623 * MAC MIF (if configured) SYSTEM ERROR (if configured) first 18693859Sml29623 * receive channel next channel...... last receive channel 18703859Sml29623 * first transmit channel next channel...... last transmit 18713859Sml29623 * channel 18723859Sml29623 * 18733859Sml29623 * prop_len should be at least for one mac and total # of rx and 18743859Sml29623 * tx channels. Function 0 owns MIF and ERROR 18753859Sml29623 */ 18763859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18776929Smisaki "==> nxge_use_default_dma_config_n2(obp): " 18786929Smisaki "# interrupts %d", prop_len)); 18793859Sml29623 18803859Sml29623 switch (func) { 18813859Sml29623 case 0: 18823859Sml29623 p_cfgp->ldg_chn_start = 3; 18833859Sml29623 p_cfgp->mac_ldvid = NXGE_MAC_LD_PORT0; 18843859Sml29623 p_cfgp->mif_ldvid = NXGE_MIF_LD; 18853859Sml29623 p_cfgp->ser_ldvid = NXGE_SYS_ERROR_LD; 18863859Sml29623 18873859Sml29623 break; 18883859Sml29623 case 1: 18893859Sml29623 p_cfgp->ldg_chn_start = 1; 18903859Sml29623 p_cfgp->mac_ldvid = NXGE_MAC_LD_PORT1; 18913859Sml29623 18923859Sml29623 break; 18933859Sml29623 default: 18943859Sml29623 status = NXGE_DDI_FAILED; 18953859Sml29623 break; 18963859Sml29623 } 18973859Sml29623 18983859Sml29623 if (status != NXGE_OK) 18993859Sml29623 return (status); 19003859Sml29623 19013859Sml29623 for (i = 0; i < prop_len; i++) { 19023859Sml29623 p_cfgp->ldg[i] = prop_val[i]; 19033859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19046929Smisaki "==> nxge_use_default_dma_config_n2(obp): " 19056929Smisaki "F%d: interrupt #%d, ldg %d", 19066929Smisaki nxgep->function_num, i, p_cfgp->ldg[i])); 19073859Sml29623 } 19083859Sml29623 19093859Sml29623 p_cfgp->max_grpids = prop_len; 19103859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19116929Smisaki "==> nxge_use_default_dma_config_n2(obp): %d " 19126929Smisaki "(#%d) maxgrpids %d channel starts %d", 19136929Smisaki p_cfgp->mac_ldvid, i, p_cfgp->max_grpids, 19146929Smisaki p_cfgp->ldg_chn_start)); 19153859Sml29623 ddi_prop_free(prop_val); 19163859Sml29623 } else { 19173859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 19186929Smisaki "==> nxge_use_default_dma_config_n2: " 19196929Smisaki "get interrupts failed")); 19203859Sml29623 return (NXGE_DDI_FAILED); 19213859Sml29623 } 19223859Sml29623 19233859Sml29623 p_cfgp->max_ldgs = p_cfgp->max_grpids; 19243859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19258275SEric Cheng "==> nxge_use_default_dma_config_n2: p_cfgp 0x%llx max_rdcs %d " 19268275SEric Cheng "max_grpids %d macid %d mifid %d serrid %d", 19278275SEric Cheng p_cfgp, p_cfgp->max_rdcs, p_cfgp->max_grpids, 19286929Smisaki p_cfgp->mac_ldvid, p_cfgp->mif_ldvid, p_cfgp->ser_ldvid)); 19293859Sml29623 19308275SEric Cheng 19313859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 19326929Smisaki "p_cfgp p%p start_ldg %d nxgep->max_ldgs %d", 19336929Smisaki p_cfgp, p_cfgp->start_ldg, p_cfgp->max_ldgs)); 19343859Sml29623 19353859Sml29623 /* 19363859Sml29623 * RDC groups and the beginning RDC group assigned to this function. 19373859Sml29623 */ 19388275SEric Cheng p_cfgp->max_rdc_grpids = NXGE_MAX_RDC_GROUPS / nxgep->nports; 19398275SEric Cheng p_cfgp->def_mac_rxdma_grpid = 19408275SEric Cheng nxgep->function_num * NXGE_MAX_RDC_GROUPS / nxgep->nports; 19418275SEric Cheng p_cfgp->def_mac_txdma_grpid = 19428275SEric Cheng nxgep->function_num * NXGE_MAX_TDC_GROUPS / nxgep->nports; 19438275SEric Cheng 19448275SEric Cheng if ((p_cfgp->def_mac_rxdma_grpid = nxge_fzc_rdc_tbl_bind(nxgep, 19458275SEric Cheng p_cfgp->def_mac_rxdma_grpid, B_TRUE)) >= NXGE_MAX_RDC_GRPS) { 19466495Sspeer NXGE_ERROR_MSG((nxgep, CFG_CTL, 19476495Sspeer "nxge_use_default_dma_config_n2(): " 19486495Sspeer "nxge_fzc_rdc_tbl_bind failed")); 19496495Sspeer return (NXGE_DDI_FAILED); 19506495Sspeer } 19513859Sml29623 19523859Sml29623 status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 19536495Sspeer "rx-rdc-grps", p_cfgp->max_rdc_grpids); 19543859Sml29623 if (status) { 19553859Sml29623 return (NXGE_DDI_FAILED); 19563859Sml29623 } 19573859Sml29623 status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 19586929Smisaki "rx-rdc-grps-begin", p_cfgp->def_mac_rxdma_grpid); 19593859Sml29623 if (status) { 19603859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, nxgep->dip, 19616929Smisaki "rx-rdc-grps"); 19623859Sml29623 return (NXGE_DDI_FAILED); 19633859Sml29623 } 19643859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 19656929Smisaki "p_cfgp $%p # rdc groups %d start rdc group id %d", 19666929Smisaki p_cfgp, p_cfgp->max_rdc_grpids, 19676929Smisaki p_cfgp->def_mac_rxdma_grpid)); 19683859Sml29623 19693859Sml29623 nxge_set_hw_dma_config(nxgep); 19703859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "<== nxge_use_default_dma_config_n2")); 19713859Sml29623 return (status); 19723859Sml29623 } 19733859Sml29623 19743859Sml29623 static void 19753859Sml29623 nxge_use_cfg_dma_config(p_nxge_t nxgep) 19763859Sml29623 { 19774732Sdavemq int tx_ndmas, rx_ndmas, nrxgp, st_txdma, st_rxdma; 19783859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 19793859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 19803859Sml29623 dev_info_t *dip; 19813859Sml29623 p_nxge_param_t param_arr; 19823859Sml29623 char *prop; 19833859Sml29623 int *prop_val; 19843859Sml29623 uint_t prop_len; 19854732Sdavemq int i; 19864732Sdavemq uint8_t *ch_arr_p; 19873859Sml29623 19883859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_dma_config")); 19893859Sml29623 param_arr = nxgep->param_arr; 19903859Sml29623 19913859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 19923859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 19933859Sml29623 dip = nxgep->dip; 19943859Sml29623 p_cfgp->function_number = nxgep->function_num; 19953859Sml29623 prop = param_arr[param_txdma_channels_begin].fcode_name; 19963859Sml29623 19973859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 19986929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 19996495Sspeer p_cfgp->tdc.start = *prop_val; 20003859Sml29623 ddi_prop_free(prop_val); 20013859Sml29623 } else { 20024732Sdavemq switch (nxgep->niu_type) { 20034732Sdavemq case NEPTUNE_4_1GC: 20044732Sdavemq ch_arr_p = &tx_4_1G[0]; 20054732Sdavemq break; 20064732Sdavemq case NEPTUNE_2_10GF: 20074732Sdavemq ch_arr_p = &tx_2_10G[0]; 20084732Sdavemq break; 20094732Sdavemq case NEPTUNE_2_10GF_2_1GC: 20106261Sjoycey case NEPTUNE_2_10GF_2_1GRF: 20114732Sdavemq ch_arr_p = &tx_2_10G_2_1G[0]; 20124732Sdavemq break; 20134732Sdavemq case NEPTUNE_1_10GF_3_1GC: 20144732Sdavemq ch_arr_p = &tx_1_10G_3_1G[0]; 20154732Sdavemq break; 20164732Sdavemq case NEPTUNE_1_1GC_1_10GF_2_1GC: 20174732Sdavemq ch_arr_p = &tx_1_1G_1_10G_2_1G[0]; 20184732Sdavemq break; 20194732Sdavemq default: 20205196Ssbehera switch (nxgep->platform_type) { 20215196Ssbehera case P_NEPTUNE_ALONSO: 20225196Ssbehera ch_arr_p = &tx_2_10G_2_1G[0]; 20235196Ssbehera break; 20245196Ssbehera default: 20255196Ssbehera ch_arr_p = &p4_tx_equal[0]; 20265196Ssbehera break; 20275196Ssbehera } 20284732Sdavemq break; 20293859Sml29623 } 20304732Sdavemq st_txdma = 0; 20314732Sdavemq for (i = 0; i < nxgep->function_num; i++, ch_arr_p++) 20324732Sdavemq st_txdma += *ch_arr_p; 20334732Sdavemq 20343859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 20354732Sdavemq prop, st_txdma); 20366495Sspeer p_cfgp->tdc.start = st_txdma; 20373859Sml29623 } 20383859Sml29623 20393859Sml29623 prop = param_arr[param_txdma_channels].fcode_name; 20403859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20416929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20423859Sml29623 tx_ndmas = *prop_val; 20433859Sml29623 ddi_prop_free(prop_val); 20443859Sml29623 } else { 20454732Sdavemq switch (nxgep->niu_type) { 20464732Sdavemq case NEPTUNE_4_1GC: 20474732Sdavemq tx_ndmas = tx_4_1G[nxgep->function_num]; 20484732Sdavemq break; 20494732Sdavemq case NEPTUNE_2_10GF: 20504732Sdavemq tx_ndmas = tx_2_10G[nxgep->function_num]; 20514732Sdavemq break; 20524732Sdavemq case NEPTUNE_2_10GF_2_1GC: 20536261Sjoycey case NEPTUNE_2_10GF_2_1GRF: 20544732Sdavemq tx_ndmas = tx_2_10G_2_1G[nxgep->function_num]; 20554732Sdavemq break; 20564732Sdavemq case NEPTUNE_1_10GF_3_1GC: 20574732Sdavemq tx_ndmas = tx_1_10G_3_1G[nxgep->function_num]; 20584732Sdavemq break; 20594732Sdavemq case NEPTUNE_1_1GC_1_10GF_2_1GC: 20604732Sdavemq tx_ndmas = tx_1_1G_1_10G_2_1G[nxgep->function_num]; 20614732Sdavemq break; 20624732Sdavemq default: 20635196Ssbehera switch (nxgep->platform_type) { 20645196Ssbehera case P_NEPTUNE_ALONSO: 20655196Ssbehera tx_ndmas = tx_2_10G_2_1G[nxgep->function_num]; 20665196Ssbehera break; 20675196Ssbehera default: 20685196Ssbehera tx_ndmas = p4_tx_equal[nxgep->function_num]; 20695196Ssbehera break; 20705196Ssbehera } 20714732Sdavemq break; 20723859Sml29623 } 20733859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 20746929Smisaki prop, tx_ndmas); 20753859Sml29623 } 20763859Sml29623 20778275SEric Cheng p_cfgp->tdc.count = tx_ndmas; 20786495Sspeer p_cfgp->tdc.owned = p_cfgp->tdc.count; 20793859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_dma_config: " 20808275SEric Cheng "p_cfgp 0x%llx max_tdcs %d", p_cfgp, p_cfgp->tdc.count)); 20813859Sml29623 20823859Sml29623 prop = param_arr[param_rxdma_channels_begin].fcode_name; 20833859Sml29623 20843859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20856929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20863859Sml29623 p_cfgp->start_rdc = *prop_val; 20873859Sml29623 ddi_prop_free(prop_val); 20883859Sml29623 } else { 20894732Sdavemq switch (nxgep->niu_type) { 20904732Sdavemq case NEPTUNE_4_1GC: 20914732Sdavemq ch_arr_p = &rx_4_1G[0]; 20924732Sdavemq break; 20934732Sdavemq case NEPTUNE_2_10GF: 20944732Sdavemq ch_arr_p = &rx_2_10G[0]; 20954732Sdavemq break; 20964732Sdavemq case NEPTUNE_2_10GF_2_1GC: 20976261Sjoycey case NEPTUNE_2_10GF_2_1GRF: 20984732Sdavemq ch_arr_p = &rx_2_10G_2_1G[0]; 20994732Sdavemq break; 21004732Sdavemq case NEPTUNE_1_10GF_3_1GC: 21014732Sdavemq ch_arr_p = &rx_1_10G_3_1G[0]; 21024732Sdavemq break; 21034732Sdavemq case NEPTUNE_1_1GC_1_10GF_2_1GC: 21044732Sdavemq ch_arr_p = &rx_1_1G_1_10G_2_1G[0]; 21054732Sdavemq break; 21064732Sdavemq default: 21075196Ssbehera switch (nxgep->platform_type) { 21085196Ssbehera case P_NEPTUNE_ALONSO: 21095196Ssbehera ch_arr_p = &rx_2_10G_2_1G[0]; 21105196Ssbehera break; 21115196Ssbehera default: 21125196Ssbehera ch_arr_p = &p4_rx_equal[0]; 21135196Ssbehera break; 21145196Ssbehera } 21154732Sdavemq break; 21163859Sml29623 } 21174732Sdavemq st_rxdma = 0; 21184732Sdavemq for (i = 0; i < nxgep->function_num; i++, ch_arr_p++) 21194732Sdavemq st_rxdma += *ch_arr_p; 21204732Sdavemq 21213859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 21224732Sdavemq prop, st_rxdma); 21234732Sdavemq p_cfgp->start_rdc = st_rxdma; 21243859Sml29623 } 21253859Sml29623 21263859Sml29623 prop = param_arr[param_rxdma_channels].fcode_name; 21273859Sml29623 21283859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 21296929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 21303859Sml29623 rx_ndmas = *prop_val; 21313859Sml29623 ddi_prop_free(prop_val); 21323859Sml29623 } else { 21334732Sdavemq switch (nxgep->niu_type) { 21344732Sdavemq case NEPTUNE_4_1GC: 21354732Sdavemq rx_ndmas = rx_4_1G[nxgep->function_num]; 21364732Sdavemq break; 21374732Sdavemq case NEPTUNE_2_10GF: 21384732Sdavemq rx_ndmas = rx_2_10G[nxgep->function_num]; 21394732Sdavemq break; 21404732Sdavemq case NEPTUNE_2_10GF_2_1GC: 21416261Sjoycey case NEPTUNE_2_10GF_2_1GRF: 21424732Sdavemq rx_ndmas = rx_2_10G_2_1G[nxgep->function_num]; 21434732Sdavemq break; 21444732Sdavemq case NEPTUNE_1_10GF_3_1GC: 21454732Sdavemq rx_ndmas = rx_1_10G_3_1G[nxgep->function_num]; 21464732Sdavemq break; 21474732Sdavemq case NEPTUNE_1_1GC_1_10GF_2_1GC: 21484732Sdavemq rx_ndmas = rx_1_1G_1_10G_2_1G[nxgep->function_num]; 21494732Sdavemq break; 21504732Sdavemq default: 21515196Ssbehera switch (nxgep->platform_type) { 21525196Ssbehera case P_NEPTUNE_ALONSO: 21535196Ssbehera rx_ndmas = rx_2_10G_2_1G[nxgep->function_num]; 21545196Ssbehera break; 21555196Ssbehera default: 21565196Ssbehera rx_ndmas = p4_rx_equal[nxgep->function_num]; 21575196Ssbehera break; 21585196Ssbehera } 21594732Sdavemq break; 21603859Sml29623 } 21613859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 21626929Smisaki prop, rx_ndmas); 21633859Sml29623 } 21643859Sml29623 21658275SEric Cheng p_cfgp->max_rdcs = rx_ndmas; 21668275SEric Cheng 21678275SEric Cheng /* 21688275SEric Cheng * RDC groups and the beginning RDC group assigned to this function. 21698275SEric Cheng * XXX: this may be wrong if prop value is used. 21708275SEric Cheng */ 21718275SEric Cheng p_cfgp->def_mac_rxdma_grpid = 21728275SEric Cheng nxgep->function_num * NXGE_MAX_RDC_GROUPS / nxgep->nports; 21738275SEric Cheng p_cfgp->def_mac_txdma_grpid = 21748275SEric Cheng nxgep->function_num * NXGE_MAX_TDC_GROUPS / nxgep->nports; 21758275SEric Cheng 21768275SEric Cheng if ((p_cfgp->def_mac_rxdma_grpid = nxge_fzc_rdc_tbl_bind(nxgep, 21778275SEric Cheng p_cfgp->def_mac_rxdma_grpid, B_TRUE)) >= NXGE_MAX_RDC_GRPS) { 21788275SEric Cheng NXGE_ERROR_MSG((nxgep, CFG_CTL, 21798275SEric Cheng "nxge_use_default_dma_config2(): " 21808275SEric Cheng "nxge_fzc_rdc_tbl_bind failed")); 21818275SEric Cheng goto nxge_use_cfg_dma_config_exit; 21823859Sml29623 } 21833859Sml29623 21843859Sml29623 prop = param_arr[param_rx_rdc_grps].fcode_name; 21853859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 21866929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 21873859Sml29623 nrxgp = *prop_val; 21883859Sml29623 ddi_prop_free(prop_val); 21893859Sml29623 } else { 21908275SEric Cheng nrxgp = NXGE_MAX_RDC_GRPS / nxgep->nports; 21913859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 21926929Smisaki prop, nrxgp); 21933859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 21946929Smisaki "==> nxge_use_default_dma_config: " 21956929Smisaki "num_rdc_grpid not found: use def:# of " 21966929Smisaki "rdc groups %d\n", nrxgp)); 21973859Sml29623 } 21983859Sml29623 p_cfgp->max_rdc_grpids = nrxgp; 21993859Sml29623 22003859Sml29623 /* 22013859Sml29623 * 2/4 ports have the same hard-wired logical groups assigned. 22023859Sml29623 */ 22033859Sml29623 p_cfgp->start_ldg = nxgep->function_num * NXGE_LDGRP_PER_4PORTS; 22043859Sml29623 p_cfgp->max_ldgs = NXGE_LDGRP_PER_4PORTS; 22053859Sml29623 22063859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_default_dma_config: " 22078275SEric Cheng "p_cfgp 0x%llx max_rdcs %d max_grpids %d default_grpid %d", 22088275SEric Cheng p_cfgp, p_cfgp->max_rdcs, p_cfgp->max_grpids, 22098275SEric Cheng p_cfgp->def_mac_rxdma_grpid)); 22103859Sml29623 22113859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_dma_config: " 22126929Smisaki "p_cfgp 0x%016llx start_ldg %d nxgep->max_ldgs %d " 22136929Smisaki "def_mac_rxdma_grpid %d", 22146929Smisaki p_cfgp, p_cfgp->start_ldg, p_cfgp->max_ldgs, 22156929Smisaki p_cfgp->def_mac_rxdma_grpid)); 22163859Sml29623 22173859Sml29623 prop = param_arr[param_rxdma_intr_time].fcode_name; 22183859Sml29623 22193859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 22206929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 22213859Sml29623 if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) { 2222*8661SSantwona.Behera@Sun.COM nxge_rcr_timeout = prop_val[0]; 22233859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 22246929Smisaki nxgep->dip, prop, prop_val, prop_len); 22253859Sml29623 } 22263859Sml29623 ddi_prop_free(prop_val); 22273859Sml29623 } 22283859Sml29623 prop = param_arr[param_rxdma_intr_pkts].fcode_name; 22293859Sml29623 22303859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 22316929Smisaki &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 22323859Sml29623 if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) { 2233*8661SSantwona.Behera@Sun.COM nxge_rcr_threshold = prop_val[0]; 22343859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 22356929Smisaki nxgep->dip, prop, prop_val, prop_len); 22363859Sml29623 } 22373859Sml29623 ddi_prop_free(prop_val); 22383859Sml29623 } 22393859Sml29623 nxge_set_hw_dma_config(nxgep); 22403859Sml29623 22414732Sdavemq NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_dma_config: " 22424732Sdavemq "sTDC[%d] nTDC[%d] sRDC[%d] nRDC[%d]", 22436495Sspeer p_cfgp->tdc.start, p_cfgp->tdc.count, 22444732Sdavemq p_cfgp->start_rdc, p_cfgp->max_rdcs)); 22454732Sdavemq 22466495Sspeer nxge_use_cfg_dma_config_exit: 22473859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_dma_config")); 22483859Sml29623 } 22493859Sml29623 22506495Sspeer void 22516495Sspeer nxge_get_logical_props(p_nxge_t nxgep) 22526495Sspeer { 22536495Sspeer nxge_dma_pt_cfg_t *port = &nxgep->pt_config; 22546495Sspeer nxge_hw_pt_cfg_t *hardware; 22556495Sspeer nxge_rdc_grp_t *group; 22566495Sspeer 22576495Sspeer (void) memset(port, 0, sizeof (*port)); 22586495Sspeer 22598275SEric Cheng port->mac_port = nxgep->function_num; /* := function number */ 22606495Sspeer 22616495Sspeer /* 22626495Sspeer * alloc_buf_size: 22636495Sspeer * dead variables. 22646495Sspeer */ 22656495Sspeer port->rbr_size = nxge_rbr_size; 22666495Sspeer port->rcr_size = nxge_rcr_size; 22676495Sspeer 22686495Sspeer port->tx_dma_map = 0; /* Transmit DMA channel bit map */ 22696495Sspeer 22706495Sspeer nxge_set_rdc_intr_property(nxgep); 22716495Sspeer 22726495Sspeer port->rcr_full_header = NXGE_RCR_FULL_HEADER; 22736495Sspeer port->rx_drr_weight = PT_DRR_WT_DEFAULT_10G; 22746495Sspeer 22756495Sspeer /* ----------------------------------------------------- */ 22766495Sspeer hardware = &port->hw_config; 22776495Sspeer 22786495Sspeer (void) memset(hardware, 0, sizeof (*hardware)); 22796495Sspeer 22806495Sspeer /* 22816495Sspeer * partition_id, read_write_mode: 22826495Sspeer * dead variables. 22836495Sspeer */ 22846495Sspeer 22856495Sspeer /* 22866495Sspeer * drr_wt, rx_full_header, *_ldg?, start_mac_entry, 22876495Sspeer * mac_pref, def_mac_rxdma_grpid, start_vlan, max_vlans, 22886495Sspeer * start_ldgs, max_ldgs, max_ldvs, 22896495Sspeer * vlan_pref, def_vlan_rxdma_grpid are meaningful only 22906495Sspeer * in the service domain. 22916495Sspeer */ 22926495Sspeer 22936495Sspeer group = &port->rdc_grps[0]; 22946495Sspeer 22958275SEric Cheng group->flag = B_TRUE; /* configured */ 22966495Sspeer group->config_method = RDC_TABLE_ENTRY_METHOD_REP; 22978275SEric Cheng group->port = NXGE_GET_PORT_NUM(nxgep->function_num); 22986495Sspeer 22996495Sspeer /* HIO futures: this is still an open question. */ 23006495Sspeer hardware->max_macs = 1; 23016495Sspeer } 23026495Sspeer 23033859Sml29623 static void 23043859Sml29623 nxge_use_cfg_vlan_class_config(p_nxge_t nxgep) 23053859Sml29623 { 23063859Sml29623 uint_t vlan_cnt; 23073859Sml29623 int *vlan_cfg_val; 23083859Sml29623 int status; 23093859Sml29623 p_nxge_param_t param_arr; 23103859Sml29623 char *prop; 23113859Sml29623 23123859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_vlan_config")); 23133859Sml29623 param_arr = nxgep->param_arr; 23143859Sml29623 prop = param_arr[param_vlan_2rdc_grp].fcode_name; 23153859Sml29623 23163859Sml29623 status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 23176929Smisaki &vlan_cfg_val, &vlan_cnt); 23183859Sml29623 if (status == DDI_PROP_SUCCESS) { 23193859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, 23206929Smisaki nxgep->dip, prop, vlan_cfg_val, vlan_cnt); 23213859Sml29623 ddi_prop_free(vlan_cfg_val); 23223859Sml29623 } 23233859Sml29623 nxge_set_hw_vlan_class_config(nxgep); 23243859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_vlan_config")); 23253859Sml29623 } 23263859Sml29623 23273859Sml29623 static void 23283859Sml29623 nxge_use_cfg_mac_class_config(p_nxge_t nxgep) 23293859Sml29623 { 23303859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 23313859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 23323859Sml29623 uint_t mac_cnt; 23333859Sml29623 int *mac_cfg_val; 23343859Sml29623 int status; 23353859Sml29623 p_nxge_param_t param_arr; 23363859Sml29623 char *prop; 23373859Sml29623 23383859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_mac_class_config")); 23393859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 23403859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 23413859Sml29623 p_cfgp->start_mac_entry = 0; 23423859Sml29623 param_arr = nxgep->param_arr; 23433859Sml29623 prop = param_arr[param_mac_2rdc_grp].fcode_name; 23443859Sml29623 23453859Sml29623 switch (nxgep->function_num) { 23463859Sml29623 case 0: 23473859Sml29623 case 1: 23483859Sml29623 /* 10G ports */ 23493859Sml29623 p_cfgp->max_macs = NXGE_MAX_MACS_XMACS; 23503859Sml29623 break; 23513859Sml29623 case 2: 23523859Sml29623 case 3: 23533859Sml29623 /* 1G ports */ 23543859Sml29623 default: 23553859Sml29623 p_cfgp->max_macs = NXGE_MAX_MACS_BMACS; 23563859Sml29623 break; 23573859Sml29623 } 23583859Sml29623 23593859Sml29623 p_cfgp->mac_pref = 1; 23603859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 23616929Smisaki "== nxge_use_cfg_mac_class_config: " 23626929Smisaki " mac_pref bit set def_mac_rxdma_grpid %d", 23636929Smisaki p_cfgp->def_mac_rxdma_grpid)); 23643859Sml29623 23653859Sml29623 status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 23666929Smisaki &mac_cfg_val, &mac_cnt); 23673859Sml29623 if (status == DDI_PROP_SUCCESS) { 23683859Sml29623 if (mac_cnt <= p_cfgp->max_macs) 23693859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, 23706929Smisaki nxgep->dip, prop, mac_cfg_val, mac_cnt); 23713859Sml29623 ddi_prop_free(mac_cfg_val); 23723859Sml29623 } 23733859Sml29623 nxge_set_hw_mac_class_config(nxgep); 23743859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_mac_class_config")); 23753859Sml29623 } 23763859Sml29623 23773859Sml29623 static void 23783859Sml29623 nxge_use_cfg_class_config(p_nxge_t nxgep) 23793859Sml29623 { 23803859Sml29623 nxge_set_hw_class_config(nxgep); 23813859Sml29623 } 23823859Sml29623 23833859Sml29623 static void 23843859Sml29623 nxge_set_rdc_intr_property(p_nxge_t nxgep) 23853859Sml29623 { 23863859Sml29623 int i; 23873859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 23883859Sml29623 23893859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_rdc_intr_property")); 23903859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 23913859Sml29623 23923859Sml29623 for (i = 0; i < NXGE_MAX_RDCS; i++) { 23933859Sml29623 p_dma_cfgp->rcr_timeout[i] = nxge_rcr_timeout; 23943859Sml29623 p_dma_cfgp->rcr_threshold[i] = nxge_rcr_threshold; 23953859Sml29623 } 23963859Sml29623 23973859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_rdc_intr_property")); 23983859Sml29623 } 23993859Sml29623 24003859Sml29623 static void 24013859Sml29623 nxge_set_hw_dma_config(p_nxge_t nxgep) 24023859Sml29623 { 24038275SEric Cheng int i, j, ngrps, bitmap, end, st_rdc; 24048275SEric Cheng p_nxge_dma_pt_cfg_t p_dma_cfgp; 24058275SEric Cheng p_nxge_hw_pt_cfg_t p_cfgp; 24068275SEric Cheng p_nxge_rdc_grp_t rdc_grp_p; 24078275SEric Cheng p_nxge_tdc_grp_t tdc_grp_p; 24088275SEric Cheng nxge_grp_t *group; 24098275SEric Cheng uint8_t nrdcs; 24108275SEric Cheng dc_map_t map = 0; 24113859Sml29623 24123859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_set_hw_dma_config")); 24133859Sml29623 24143859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 24153859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 24168275SEric Cheng 24178275SEric Cheng switch (nxgep->niu_type) { 24188275SEric Cheng case NEPTUNE_4_1GC: 24198275SEric Cheng case NEPTUNE_2_10GF_2_1GC: 24208275SEric Cheng case NEPTUNE_1_10GF_3_1GC: 24218275SEric Cheng case NEPTUNE_1_1GC_1_10GF_2_1GC: 24228275SEric Cheng case NEPTUNE_2_10GF_2_1GRF: 24238275SEric Cheng default: 24248275SEric Cheng ngrps = 2; 24258275SEric Cheng break; 24268275SEric Cheng case NEPTUNE_2_10GF: 24278275SEric Cheng case NEPTUNE_2_1GRF: 24288275SEric Cheng case N2_NIU: 24298275SEric Cheng ngrps = 4; 24308275SEric Cheng break; 24318275SEric Cheng } 24328275SEric Cheng 24338275SEric Cheng /* 24348275SEric Cheng * Setup TDC groups 24358275SEric Cheng */ 24363859Sml29623 bitmap = 0; 24376495Sspeer end = p_cfgp->tdc.start + p_cfgp->tdc.owned; 24386495Sspeer for (i = p_cfgp->tdc.start; i < end; i++) { 24393859Sml29623 bitmap |= (1 << i); 24403859Sml29623 } 24413859Sml29623 24426495Sspeer nxgep->tx_set.owned.map |= bitmap; /* Owned, & not shared. */ 24438275SEric Cheng nxgep->tx_set.owned.count = p_cfgp->tdc.owned; 24443859Sml29623 p_dma_cfgp->tx_dma_map = bitmap; 24458275SEric Cheng 24468275SEric Cheng for (i = 0; i < ngrps; i++) { 24478275SEric Cheng group = (nxge_grp_t *)nxge_grp_add(nxgep, 24488275SEric Cheng NXGE_TRANSMIT_GROUP); 24498275SEric Cheng tdc_grp_p = &p_dma_cfgp->tdc_grps[ 24508275SEric Cheng p_cfgp->def_mac_txdma_grpid + i]; 24518275SEric Cheng if (i == 0) 24528275SEric Cheng tdc_grp_p->map = bitmap; 24538275SEric Cheng else 24548275SEric Cheng tdc_grp_p->map = 0; 24558275SEric Cheng /* no ring is associated with a group initially */ 24568275SEric Cheng tdc_grp_p->start_tdc = 0; 24578275SEric Cheng tdc_grp_p->max_tdcs = 0; 24588275SEric Cheng tdc_grp_p->grp_index = group->index; 24598275SEric Cheng } 24608275SEric Cheng 24618275SEric Cheng for (i = 0; i < NXGE_MAX_RDCS; i++) { 24628275SEric Cheng nxgep->rx_channel_started[i] = B_FALSE; 24638275SEric Cheng } 24648275SEric Cheng 24658275SEric Cheng /* 24668275SEric Cheng * Setup RDC groups 24678275SEric Cheng */ 24688275SEric Cheng st_rdc = p_cfgp->start_rdc; 24698275SEric Cheng for (i = 0; i < ngrps; i++) { 24708275SEric Cheng /* 24718275SEric Cheng * All rings are associated with the default group initially 24728275SEric Cheng */ 24738275SEric Cheng if (i == 0) { 24748275SEric Cheng /* default group */ 24758275SEric Cheng switch (nxgep->niu_type) { 24768275SEric Cheng case NEPTUNE_4_1GC: 24778275SEric Cheng nrdcs = rx_4_1G[nxgep->function_num]; 24783859Sml29623 break; 24798275SEric Cheng case N2_NIU: 24808275SEric Cheng case NEPTUNE_2_10GF: 24818275SEric Cheng nrdcs = rx_2_10G[nxgep->function_num]; 24828275SEric Cheng break; 24838275SEric Cheng case NEPTUNE_2_10GF_2_1GC: 24848275SEric Cheng nrdcs = rx_2_10G_2_1G[nxgep->function_num]; 24858275SEric Cheng break; 24868275SEric Cheng case NEPTUNE_1_10GF_3_1GC: 24878275SEric Cheng nrdcs = rx_1_10G_3_1G[nxgep->function_num]; 24888275SEric Cheng break; 24898275SEric Cheng case NEPTUNE_1_1GC_1_10GF_2_1GC: 24908275SEric Cheng nrdcs = rx_1_1G_1_10G_2_1G[nxgep->function_num]; 24913859Sml29623 break; 24923859Sml29623 default: 24938275SEric Cheng switch (nxgep->platform_type) { 24948275SEric Cheng case P_NEPTUNE_ALONSO: 24958275SEric Cheng nrdcs = 24968275SEric Cheng rx_2_10G_2_1G[nxgep->function_num]; 24978275SEric Cheng break; 24988275SEric Cheng default: 24998275SEric Cheng nrdcs = rx_4_1G[nxgep->function_num]; 25008275SEric Cheng break; 25018275SEric Cheng } 25023859Sml29623 break; 25033859Sml29623 } 25048275SEric Cheng } else { 25058275SEric Cheng nrdcs = 0; 25063859Sml29623 } 25076495Sspeer 25086495Sspeer rdc_grp_p = &p_dma_cfgp->rdc_grps[ 25096929Smisaki p_cfgp->def_mac_rxdma_grpid + i]; 25108275SEric Cheng rdc_grp_p->start_rdc = st_rdc; 25118275SEric Cheng rdc_grp_p->max_rdcs = nrdcs; 25126495Sspeer rdc_grp_p->def_rdc = rdc_grp_p->start_rdc; 25133859Sml29623 25143859Sml29623 /* default to: 0, 1, 2, 3, ...., 0, 1, 2, 3.... */ 25158275SEric Cheng if (nrdcs != 0) { 25168275SEric Cheng for (j = 0; j < nrdcs; j++) { 25178275SEric Cheng map |= (1 << j); 25188275SEric Cheng } 25198275SEric Cheng map <<= rdc_grp_p->start_rdc; 25208275SEric Cheng } else 25218275SEric Cheng map = 0; 25226495Sspeer rdc_grp_p->map = map; 25236495Sspeer 25246495Sspeer nxgep->rx_set.owned.map |= map; /* Owned, & not shared. */ 25258275SEric Cheng nxgep->rx_set.owned.count = nrdcs; 25266495Sspeer 25276495Sspeer group = (nxge_grp_t *)nxge_grp_add(nxgep, NXGE_RECEIVE_GROUP); 25286495Sspeer 25293859Sml29623 rdc_grp_p->config_method = RDC_TABLE_ENTRY_METHOD_SEQ; 25308275SEric Cheng rdc_grp_p->flag = B_TRUE; /* This group has been configured. */ 25318275SEric Cheng rdc_grp_p->grp_index = group->index; 25328275SEric Cheng rdc_grp_p->port = NXGE_GET_PORT_NUM(nxgep->function_num); 25338275SEric Cheng 25348275SEric Cheng map = 0; 25353859Sml29623 } 25363859Sml29623 25376495Sspeer 25383859Sml29623 /* default RDC */ 25393859Sml29623 p_cfgp->def_rdc = p_cfgp->start_rdc; 25403859Sml29623 nxgep->def_rdc = p_cfgp->start_rdc; 25413859Sml29623 25423859Sml29623 /* full 18 byte header ? */ 25433859Sml29623 p_dma_cfgp->rcr_full_header = NXGE_RCR_FULL_HEADER; 25443859Sml29623 p_dma_cfgp->rx_drr_weight = PT_DRR_WT_DEFAULT_10G; 25453859Sml29623 if (nxgep->function_num > 1) 25463859Sml29623 p_dma_cfgp->rx_drr_weight = PT_DRR_WT_DEFAULT_1G; 25473859Sml29623 p_dma_cfgp->rbr_size = nxge_rbr_size; 25483859Sml29623 p_dma_cfgp->rcr_size = nxge_rcr_size; 25493859Sml29623 25503859Sml29623 nxge_set_rdc_intr_property(nxgep); 25513859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_hw_dma_config")); 25523859Sml29623 } 25533859Sml29623 25543859Sml29623 boolean_t 25553859Sml29623 nxge_check_rxdma_port_member(p_nxge_t nxgep, uint8_t rdc) 25563859Sml29623 { 25573859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 25583859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 25593859Sml29623 int status = B_TRUE; 25603859Sml29623 25613859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rxdma_port_member")); 25623859Sml29623 25633859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 25643859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 25653859Sml29623 25663859Sml29623 /* Receive DMA Channels */ 25673859Sml29623 if (rdc < p_cfgp->max_rdcs) 25683859Sml29623 status = B_TRUE; 25693859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rxdma_port_member")); 25703859Sml29623 return (status); 25713859Sml29623 } 25723859Sml29623 25733859Sml29623 boolean_t 25743859Sml29623 nxge_check_txdma_port_member(p_nxge_t nxgep, uint8_t tdc) 25753859Sml29623 { 25763859Sml29623 int status = B_FALSE; 25773859Sml29623 25786495Sspeer NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_txdma_port_member")); 25796495Sspeer 25806495Sspeer if (tdc >= nxgep->pt_config.hw_config.tdc.start && 25816495Sspeer tdc < nxgep->pt_config.hw_config.tdc.count) 25823859Sml29623 status = B_TRUE; 25836495Sspeer 25846495Sspeer NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_txdma_port_member")); 25853859Sml29623 return (status); 25863859Sml29623 } 25873859Sml29623 25883859Sml29623 boolean_t 25893859Sml29623 nxge_check_rxdma_rdcgrp_member(p_nxge_t nxgep, uint8_t rdc_grp, uint8_t rdc) 25903859Sml29623 { 25913859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 25923859Sml29623 int status = B_TRUE; 25933859Sml29623 p_nxge_rdc_grp_t rdc_grp_p; 25943859Sml29623 25953859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 25966929Smisaki " ==> nxge_check_rxdma_rdcgrp_member")); 25973859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " nxge_check_rxdma_rdcgrp_member" 25986929Smisaki " rdc %d group %d", rdc, rdc_grp)); 25993859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 26003859Sml29623 26013859Sml29623 rdc_grp_p = &p_dma_cfgp->rdc_grps[rdc_grp]; 26023859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " max %d ", rdc_grp_p->max_rdcs)); 26033859Sml29623 if (rdc >= rdc_grp_p->max_rdcs) { 26043859Sml29623 status = B_FALSE; 26053859Sml29623 } 26063859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 26076929Smisaki " <== nxge_check_rxdma_rdcgrp_member")); 26083859Sml29623 return (status); 26093859Sml29623 } 26103859Sml29623 26113859Sml29623 boolean_t 26123859Sml29623 nxge_check_rdcgrp_port_member(p_nxge_t nxgep, uint8_t rdc_grp) 26133859Sml29623 { 26143859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 26153859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 26163859Sml29623 int status = B_TRUE; 26173859Sml29623 26183859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rdcgrp_port_member")); 26193859Sml29623 26203859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 26213859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 26223859Sml29623 26233859Sml29623 if (rdc_grp >= p_cfgp->max_rdc_grpids) 26243859Sml29623 status = B_FALSE; 26253859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rdcgrp_port_member")); 26263859Sml29623 return (status); 26273859Sml29623 } 26283859Sml29623 26293859Sml29623 static void 26303859Sml29623 nxge_set_hw_vlan_class_config(p_nxge_t nxgep) 26313859Sml29623 { 26323859Sml29623 int i; 26333859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 26343859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 26353859Sml29623 p_nxge_param_t param_arr; 26363859Sml29623 uint_t vlan_cnt; 26373859Sml29623 int *vlan_cfg_val; 26383859Sml29623 nxge_param_map_t *vmap; 26393859Sml29623 char *prop; 26403859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 26413859Sml29623 uint32_t good_cfg[32]; 26423859Sml29623 int good_count = 0; 26433859Sml29623 nxge_mv_cfg_t *vlan_tbl; 26443859Sml29623 26453859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_hw_vlan_config")); 26463859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 26473859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 26483859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 26493859Sml29623 26503859Sml29623 param_arr = nxgep->param_arr; 26513859Sml29623 prop = param_arr[param_vlan_2rdc_grp].fcode_name; 26523859Sml29623 26533859Sml29623 /* 26543859Sml29623 * By default, VLAN to RDC group mapping is disabled Need to read HW or 26553859Sml29623 * .conf properties to find out if mapping is required 26563859Sml29623 * 26573859Sml29623 * Format 26583859Sml29623 * 26593859Sml29623 * uint32_t array, each array entry specifying the VLAN id and the 26603859Sml29623 * mapping 26613859Sml29623 * 26623859Sml29623 * bit[30] = add bit[29] = remove bit[28] = preference bits[23-16] = 26633859Sml29623 * rdcgrp bits[15-0] = VLAN ID ( ) 26643859Sml29623 */ 26653859Sml29623 26663859Sml29623 for (i = 0; i < NXGE_MAX_VLANS; i++) { 26673859Sml29623 p_class_cfgp->vlan_tbl[i].flag = 0; 26683859Sml29623 } 26693859Sml29623 26703859Sml29623 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0]; 26713859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 26726929Smisaki &vlan_cfg_val, &vlan_cnt) == DDI_PROP_SUCCESS) { 26733859Sml29623 for (i = 0; i < vlan_cnt; i++) { 26743859Sml29623 vmap = (nxge_param_map_t *)&vlan_cfg_val[i]; 26753859Sml29623 if ((vmap->param_id) && 26766929Smisaki (vmap->param_id < NXGE_MAX_VLANS) && 26776929Smisaki (vmap->map_to < 26786929Smisaki p_cfgp->max_rdc_grpids) && 26796929Smisaki (vmap->map_to >= (uint8_t)0)) { 26803859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 26816929Smisaki " nxge_vlan_config mapping" 26826929Smisaki " id %d grp %d", 26836929Smisaki vmap->param_id, vmap->map_to)); 26843859Sml29623 good_cfg[good_count] = vlan_cfg_val[i]; 26853859Sml29623 if (vlan_tbl[vmap->param_id].flag == 0) 26863859Sml29623 good_count++; 26873859Sml29623 vlan_tbl[vmap->param_id].flag = 1; 26883859Sml29623 vlan_tbl[vmap->param_id].rdctbl = 26896495Sspeer vmap->map_to + p_cfgp->def_mac_rxdma_grpid; 26903859Sml29623 vlan_tbl[vmap->param_id].mpr_npr = vmap->pref; 26913859Sml29623 } 26923859Sml29623 } 26933859Sml29623 ddi_prop_free(vlan_cfg_val); 26943859Sml29623 if (good_count != vlan_cnt) { 26953859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 26966929Smisaki nxgep->dip, prop, (int *)good_cfg, good_count); 26973859Sml29623 } 26983859Sml29623 } 26993859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_set_hw_vlan_config")); 27003859Sml29623 } 27013859Sml29623 27023859Sml29623 static void 27033859Sml29623 nxge_set_hw_mac_class_config(p_nxge_t nxgep) 27043859Sml29623 { 27053859Sml29623 int i; 27063859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 27073859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 27083859Sml29623 p_nxge_param_t param_arr; 27093859Sml29623 uint_t mac_cnt; 27103859Sml29623 int *mac_cfg_val; 27113859Sml29623 nxge_param_map_t *mac_map; 27123859Sml29623 char *prop; 27133859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 27143859Sml29623 int good_count = 0; 27153859Sml29623 int good_cfg[NXGE_MAX_MACS]; 27163859Sml29623 nxge_mv_cfg_t *mac_host_info; 27173859Sml29623 27183859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_set_hw_mac_config")); 27193859Sml29623 27203859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 27213859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 27223859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 27233859Sml29623 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0]; 27243859Sml29623 27253859Sml29623 param_arr = nxgep->param_arr; 27263859Sml29623 prop = param_arr[param_mac_2rdc_grp].fcode_name; 27273859Sml29623 27283859Sml29623 for (i = 0; i < NXGE_MAX_MACS; i++) { 27293859Sml29623 p_class_cfgp->mac_host_info[i].flag = 0; 27304484Sspeer p_class_cfgp->mac_host_info[i].rdctbl = 27314484Sspeer p_cfgp->def_mac_rxdma_grpid; 27323859Sml29623 } 27333859Sml29623 27343859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 27356929Smisaki &mac_cfg_val, &mac_cnt) == DDI_PROP_SUCCESS) { 27363859Sml29623 for (i = 0; i < mac_cnt; i++) { 27373859Sml29623 mac_map = (nxge_param_map_t *)&mac_cfg_val[i]; 27383859Sml29623 if ((mac_map->param_id < p_cfgp->max_macs) && 27396929Smisaki (mac_map->map_to < 27406929Smisaki p_cfgp->max_rdc_grpids) && 27416929Smisaki (mac_map->map_to >= (uint8_t)0)) { 27423859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 27436929Smisaki " nxge_mac_config mapping" 27446929Smisaki " id %d grp %d", 27456929Smisaki mac_map->param_id, mac_map->map_to)); 27463859Sml29623 mac_host_info[mac_map->param_id].mpr_npr = 27478275SEric Cheng p_cfgp->mac_pref; 27483859Sml29623 mac_host_info[mac_map->param_id].rdctbl = 27496929Smisaki mac_map->map_to + 27506929Smisaki p_cfgp->def_mac_rxdma_grpid; 27513859Sml29623 good_cfg[good_count] = mac_cfg_val[i]; 27523859Sml29623 if (mac_host_info[mac_map->param_id].flag == 0) 27533859Sml29623 good_count++; 27543859Sml29623 mac_host_info[mac_map->param_id].flag = 1; 27553859Sml29623 } 27563859Sml29623 } 27573859Sml29623 ddi_prop_free(mac_cfg_val); 27583859Sml29623 if (good_count != mac_cnt) { 27593859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 27606929Smisaki nxgep->dip, prop, good_cfg, good_count); 27613859Sml29623 } 27623859Sml29623 } 27633859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_set_hw_mac_config")); 27643859Sml29623 } 27653859Sml29623 27663859Sml29623 static void 27673859Sml29623 nxge_set_hw_class_config(p_nxge_t nxgep) 27683859Sml29623 { 27693859Sml29623 int i; 27703859Sml29623 p_nxge_param_t param_arr; 27713859Sml29623 int *int_prop_val; 27723859Sml29623 uint32_t cfg_value; 27733859Sml29623 char *prop; 27743859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 27753859Sml29623 int start_prop, end_prop; 27763859Sml29623 uint_t prop_cnt; 27773859Sml29623 27783859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_hw_class_config")); 27793859Sml29623 27803859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 27813859Sml29623 param_arr = nxgep->param_arr; 27823859Sml29623 start_prop = param_class_opt_ip_usr4; 27833859Sml29623 end_prop = param_class_opt_ipv6_sctp; 27843859Sml29623 27853859Sml29623 for (i = start_prop; i <= end_prop; i++) { 27863859Sml29623 prop = param_arr[i].fcode_name; 27873859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 27886929Smisaki 0, prop, &int_prop_val, 27896929Smisaki &prop_cnt) == DDI_PROP_SUCCESS) { 27903859Sml29623 cfg_value = (uint32_t)*int_prop_val; 27913859Sml29623 ddi_prop_free(int_prop_val); 27923859Sml29623 } else { 27933859Sml29623 cfg_value = (uint32_t)param_arr[i].value; 27943859Sml29623 } 27953859Sml29623 p_class_cfgp->class_cfg[i - start_prop] = cfg_value; 27963859Sml29623 } 27973859Sml29623 27983859Sml29623 prop = param_arr[param_h1_init_value].fcode_name; 27993859Sml29623 28003859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 28016929Smisaki &int_prop_val, &prop_cnt) == DDI_PROP_SUCCESS) { 28023859Sml29623 cfg_value = (uint32_t)*int_prop_val; 28033859Sml29623 ddi_prop_free(int_prop_val); 28043859Sml29623 } else { 28053859Sml29623 cfg_value = (uint32_t)param_arr[param_h1_init_value].value; 28063859Sml29623 } 28073859Sml29623 28083859Sml29623 p_class_cfgp->init_h1 = (uint32_t)cfg_value; 28093859Sml29623 prop = param_arr[param_h2_init_value].fcode_name; 28103859Sml29623 28113859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 28126929Smisaki &int_prop_val, &prop_cnt) == DDI_PROP_SUCCESS) { 28133859Sml29623 cfg_value = (uint32_t)*int_prop_val; 28143859Sml29623 ddi_prop_free(int_prop_val); 28153859Sml29623 } else { 28163859Sml29623 cfg_value = (uint32_t)param_arr[param_h2_init_value].value; 28173859Sml29623 } 28183859Sml29623 28193859Sml29623 p_class_cfgp->init_h2 = (uint16_t)cfg_value; 28203859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_hw_class_config")); 28213859Sml29623 } 28223859Sml29623 28233859Sml29623 nxge_status_t 28243859Sml29623 nxge_ldgv_init_n2(p_nxge_t nxgep, int *navail_p, int *nrequired_p) 28253859Sml29623 { 28266495Sspeer int i, maxldvs, maxldgs, nldvs; 28273859Sml29623 int ldv, endldg; 28283859Sml29623 uint8_t func; 28293859Sml29623 uint8_t channel; 28303859Sml29623 uint8_t chn_start; 28313859Sml29623 boolean_t own_sys_err = B_FALSE, own_fzc = B_FALSE; 28323859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 28333859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 28343859Sml29623 p_nxge_ldgv_t ldgvp; 28353859Sml29623 p_nxge_ldg_t ldgp, ptr; 28367466SMisaki.Kataoka@Sun.COM p_nxge_ldv_t ldvp, sysldvp; 28373859Sml29623 nxge_status_t status = NXGE_OK; 28386495Sspeer nxge_grp_set_t *set; 28393859Sml29623 28403859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2")); 28413859Sml29623 if (!*navail_p) { 28423859Sml29623 *nrequired_p = 0; 28433859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 28446929Smisaki "<== nxge_ldgv_init:no avail")); 28453859Sml29623 return (NXGE_ERROR); 28463859Sml29623 } 28473859Sml29623 /* 28483859Sml29623 * N2/NIU: one logical device owns one logical group. and each 28493859Sml29623 * device/group will be assigned one vector by Hypervisor. 28503859Sml29623 */ 28513859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 28523859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 28533859Sml29623 maxldgs = p_cfgp->max_ldgs; 28543859Sml29623 if (!maxldgs) { 28553859Sml29623 /* No devices configured. */ 28563859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_init_n2: " 28576929Smisaki "no logical groups configured.")); 28583859Sml29623 return (NXGE_ERROR); 28593859Sml29623 } else { 28603859Sml29623 maxldvs = maxldgs + 1; 28613859Sml29623 } 28623859Sml29623 28633859Sml29623 /* 28643859Sml29623 * If function zero instance, it needs to handle the system and MIF 28653859Sml29623 * error interrupts. MIF interrupt may not be needed for N2/NIU. 28663859Sml29623 */ 28673859Sml29623 func = nxgep->function_num; 28683859Sml29623 if (func == 0) { 28693859Sml29623 own_sys_err = B_TRUE; 28703859Sml29623 if (!p_cfgp->ser_ldvid) { 28713859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 28726929Smisaki "nxge_ldgv_init_n2: func 0, ERR ID not set!")); 28733859Sml29623 } 28743859Sml29623 /* MIF interrupt */ 28753859Sml29623 if (!p_cfgp->mif_ldvid) { 28763859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 28776929Smisaki "nxge_ldgv_init_n2: func 0, MIF ID not set!")); 28783859Sml29623 } 28793859Sml29623 } 28803859Sml29623 28813859Sml29623 /* 28823859Sml29623 * Assume single partition, each function owns mac. 28833859Sml29623 */ 28843859Sml29623 if (!nxge_use_partition) 28853859Sml29623 own_fzc = B_TRUE; 28863859Sml29623 28873859Sml29623 ldgvp = nxgep->ldgvp; 28883859Sml29623 if (ldgvp == NULL) { 28893859Sml29623 ldgvp = KMEM_ZALLOC(sizeof (nxge_ldgv_t), KM_SLEEP); 28903859Sml29623 nxgep->ldgvp = ldgvp; 28913859Sml29623 ldgvp->maxldgs = (uint8_t)maxldgs; 28923859Sml29623 ldgvp->maxldvs = (uint8_t)maxldvs; 28936495Sspeer ldgp = ldgvp->ldgp = KMEM_ZALLOC( 28946929Smisaki sizeof (nxge_ldg_t) * maxldgs, KM_SLEEP); 28956495Sspeer ldvp = ldgvp->ldvp = KMEM_ZALLOC( 28966929Smisaki sizeof (nxge_ldv_t) * maxldvs, KM_SLEEP); 28973859Sml29623 } else { 28983859Sml29623 ldgp = ldgvp->ldgp; 28993859Sml29623 ldvp = ldgvp->ldvp; 29003859Sml29623 } 29013859Sml29623 29026495Sspeer ldgvp->ndma_ldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs; 29033859Sml29623 ldgvp->tmres = NXGE_TIMER_RESO; 29043859Sml29623 29053859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 29066929Smisaki "==> nxge_ldgv_init_n2: maxldvs %d maxldgs %d", 29076929Smisaki maxldvs, maxldgs)); 29083859Sml29623 29093859Sml29623 /* logical start_ldg is ldv */ 29103859Sml29623 ptr = ldgp; 29113859Sml29623 for (i = 0; i < maxldgs; i++) { 29123859Sml29623 ptr->func = func; 29133859Sml29623 ptr->arm = B_TRUE; 29143859Sml29623 ptr->vldg_index = (uint8_t)i; 29153859Sml29623 ptr->ldg_timer = NXGE_TIMER_LDG; 29163859Sml29623 ptr->ldg = p_cfgp->ldg[i]; 29173859Sml29623 ptr->sys_intr_handler = nxge_intr; 29183859Sml29623 ptr->nldvs = 0; 29193859Sml29623 ptr->ldvp = NULL; 29203859Sml29623 ptr->nxgep = nxgep; 29213859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 29226929Smisaki "==> nxge_ldgv_init_n2: maxldvs %d maxldgs %d " 29236929Smisaki "ldg %d ldgptr $%p", 29246929Smisaki maxldvs, maxldgs, ptr->ldg, ptr)); 29253859Sml29623 ptr++; 29263859Sml29623 } 29273859Sml29623 29283859Sml29623 endldg = NXGE_INT_MAX_LDG; 29293859Sml29623 nldvs = 0; 29303859Sml29623 ldgvp->nldvs = 0; 29313859Sml29623 ldgp->ldvp = NULL; 29323859Sml29623 *nrequired_p = 0; 29333859Sml29623 29343859Sml29623 /* 29353859Sml29623 * logical device group table is organized in the following order (same 29363859Sml29623 * as what interrupt property has). function 0: owns MAC, MIF, error, 29373859Sml29623 * rx, tx. function 1: owns MAC, rx, tx. 29383859Sml29623 */ 29393859Sml29623 29403859Sml29623 if (own_fzc && p_cfgp->mac_ldvid) { 29413859Sml29623 /* Each function should own MAC interrupt */ 29423859Sml29623 ldv = p_cfgp->mac_ldvid; 29433859Sml29623 ldvp->ldv = (uint8_t)ldv; 29443859Sml29623 ldvp->is_mac = B_TRUE; 29453859Sml29623 ldvp->ldv_intr_handler = nxge_mac_intr; 29463859Sml29623 ldvp->ldv_ldf_masks = 0; 29473859Sml29623 ldvp->nxgep = nxgep; 29483859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 29496929Smisaki "==> nxge_ldgv_init_n2(mac): maxldvs %d ldv %d " 29506929Smisaki "ldg %d ldgptr $%p ldvptr $%p", 29516929Smisaki maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 29523859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 29533859Sml29623 nldvs++; 29543859Sml29623 } 29553859Sml29623 29563859Sml29623 if (own_fzc && p_cfgp->mif_ldvid) { 29573859Sml29623 ldv = p_cfgp->mif_ldvid; 29583859Sml29623 ldvp->ldv = (uint8_t)ldv; 29593859Sml29623 ldvp->is_mif = B_TRUE; 29603859Sml29623 ldvp->ldv_intr_handler = nxge_mif_intr; 29613859Sml29623 ldvp->ldv_ldf_masks = 0; 29623859Sml29623 ldvp->nxgep = nxgep; 29633859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 29646929Smisaki "==> nxge_ldgv_init_n2(mif): maxldvs %d ldv %d " 29656929Smisaki "ldg %d ldgptr $%p ldvptr $%p", 29666929Smisaki maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 29673859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 29683859Sml29623 nldvs++; 29693859Sml29623 } 29703859Sml29623 29717466SMisaki.Kataoka@Sun.COM /* 29728275SEric Cheng * HW based syserr interrupt for port0, and SW based syserr interrupt 29738275SEric Cheng * for port1 29747466SMisaki.Kataoka@Sun.COM */ 29753859Sml29623 if (own_sys_err && p_cfgp->ser_ldvid) { 29763859Sml29623 ldv = p_cfgp->ser_ldvid; 29773859Sml29623 /* 29783859Sml29623 * Unmask the system interrupt states. 29793859Sml29623 */ 29803859Sml29623 (void) nxge_fzc_sys_err_mask_set(nxgep, SYS_ERR_SMX_MASK | 29816929Smisaki SYS_ERR_IPP_MASK | SYS_ERR_TXC_MASK | 29826929Smisaki SYS_ERR_ZCP_MASK); 29837466SMisaki.Kataoka@Sun.COM 29847466SMisaki.Kataoka@Sun.COM ldvp->use_timer = B_TRUE; 29857466SMisaki.Kataoka@Sun.COM ldvp->ldv = (uint8_t)ldv; 29867466SMisaki.Kataoka@Sun.COM ldvp->is_syserr = B_TRUE; 29877466SMisaki.Kataoka@Sun.COM ldvp->ldv_intr_handler = nxge_syserr_intr; 29887466SMisaki.Kataoka@Sun.COM ldvp->ldv_ldf_masks = 0; 29897466SMisaki.Kataoka@Sun.COM ldvp->nxgep = nxgep; 29907466SMisaki.Kataoka@Sun.COM ldgvp->ldvp_syserr = ldvp; 29917466SMisaki.Kataoka@Sun.COM 29927466SMisaki.Kataoka@Sun.COM NXGE_DEBUG_MSG((nxgep, INT_CTL, 29937466SMisaki.Kataoka@Sun.COM "==> nxge_ldgv_init_n2(syserr): maxldvs %d ldv %d " 29947466SMisaki.Kataoka@Sun.COM "ldg %d ldgptr $%p ldvptr p%p", 29957466SMisaki.Kataoka@Sun.COM maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 29967466SMisaki.Kataoka@Sun.COM nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 29977466SMisaki.Kataoka@Sun.COM nldvs++; 29987466SMisaki.Kataoka@Sun.COM } else { 29997466SMisaki.Kataoka@Sun.COM /* 30008275SEric Cheng * SW based: allocate the ldv for the syserr since the vector 30018275SEric Cheng * should not be consumed for port1 30027466SMisaki.Kataoka@Sun.COM */ 30037466SMisaki.Kataoka@Sun.COM sysldvp = KMEM_ZALLOC(sizeof (nxge_ldv_t), KM_SLEEP); 30047466SMisaki.Kataoka@Sun.COM sysldvp->use_timer = B_TRUE; 30057466SMisaki.Kataoka@Sun.COM sysldvp->ldv = NXGE_SYS_ERROR_LD; 30067466SMisaki.Kataoka@Sun.COM sysldvp->is_syserr = B_TRUE; 30077466SMisaki.Kataoka@Sun.COM sysldvp->ldv_intr_handler = nxge_syserr_intr; 30087466SMisaki.Kataoka@Sun.COM sysldvp->ldv_ldf_masks = 0; 30097466SMisaki.Kataoka@Sun.COM sysldvp->nxgep = nxgep; 30107466SMisaki.Kataoka@Sun.COM ldgvp->ldvp_syserr = sysldvp; 30118275SEric Cheng ldgvp->ldvp_syserr_alloced = B_TRUE; 30123859Sml29623 } 30133859Sml29623 30148275SEric Cheng 30153859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 30166929Smisaki "(before rx) func %d nldvs %d navail %d nrequired %d", 30176929Smisaki func, nldvs, *navail_p, *nrequired_p)); 30183859Sml29623 30193859Sml29623 /* 30203859Sml29623 * Start with RDC to configure logical devices for each group. 30213859Sml29623 */ 30226495Sspeer chn_start = p_cfgp->ldg_chn_start; 30236495Sspeer set = &nxgep->rx_set; 30246495Sspeer for (channel = 0; channel < NXGE_MAX_RDCS; channel++) { 30256495Sspeer if ((1 << channel) & set->owned.map) { 30266495Sspeer ldvp->is_rxdma = B_TRUE; 30276495Sspeer ldvp->ldv = (uint8_t)channel + NXGE_RDMA_LD_START; 30286495Sspeer ldvp->channel = channel; 30296495Sspeer ldvp->vdma_index = (uint8_t)channel; 30306495Sspeer ldvp->ldv_intr_handler = nxge_rx_intr; 30316495Sspeer ldvp->ldv_ldf_masks = 0; 30326495Sspeer ldvp->nxgep = nxgep; 30336495Sspeer ldgp->ldg = p_cfgp->ldg[chn_start]; 30346495Sspeer 30356495Sspeer NXGE_DEBUG_MSG((nxgep, INT_CTL, 30366495Sspeer "==> nxge_ldgv_init_n2(rx%d): maxldvs %d ldv %d " 30376495Sspeer "ldg %d ldgptr 0x%016llx ldvptr 0x%016llx", 30386495Sspeer i, maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 30396495Sspeer nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv, 30406495Sspeer endldg, nrequired_p); 30416495Sspeer nldvs++; 30426495Sspeer chn_start++; 30436495Sspeer } 30443859Sml29623 } 30453859Sml29623 30463859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 30476929Smisaki "func %d nldvs %d navail %d nrequired %d", 30486929Smisaki func, nldvs, *navail_p, *nrequired_p)); 30493859Sml29623 30503859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 30516929Smisaki "func %d nldvs %d navail %d nrequired %d ldgp 0x%llx " 30526929Smisaki "ldvp 0x%llx", 30536929Smisaki func, nldvs, *navail_p, *nrequired_p, ldgp, ldvp)); 30543859Sml29623 /* 30553859Sml29623 * Transmit DMA channels. 30563859Sml29623 */ 30576495Sspeer chn_start = p_cfgp->ldg_chn_start + 8; 30586495Sspeer set = &nxgep->tx_set; 30596495Sspeer for (channel = 0; channel < NXGE_MAX_TDCS; channel++) { 30606495Sspeer if ((1 << channel) & set->owned.map) { 30616495Sspeer ldvp->is_txdma = B_TRUE; 30626495Sspeer ldvp->ldv = (uint8_t)channel + NXGE_TDMA_LD_START; 30636495Sspeer ldvp->channel = channel; 30646495Sspeer ldvp->vdma_index = (uint8_t)channel; 30656495Sspeer ldvp->ldv_intr_handler = nxge_tx_intr; 30666495Sspeer ldvp->ldv_ldf_masks = 0; 30676495Sspeer ldgp->ldg = p_cfgp->ldg[chn_start]; 30686495Sspeer ldvp->nxgep = nxgep; 30696495Sspeer NXGE_DEBUG_MSG((nxgep, INT_CTL, 30706495Sspeer "==> nxge_ldgv_init_n2(tx%d): maxldvs %d ldv %d " 30716495Sspeer "ldg %d ldgptr %p ldvptr %p", 30726495Sspeer channel, maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 30736495Sspeer nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv, 30746495Sspeer endldg, nrequired_p); 30756495Sspeer nldvs++; 30766495Sspeer chn_start++; 30776495Sspeer } 30783859Sml29623 } 30793859Sml29623 30803859Sml29623 ldgvp->ldg_intrs = *nrequired_p; 30813859Sml29623 ldgvp->nldvs = (uint8_t)nldvs; 30823859Sml29623 30833859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 30846929Smisaki "func %d nldvs %d maxgrps %d navail %d nrequired %d", 30856929Smisaki func, nldvs, maxldgs, *navail_p, *nrequired_p)); 30863859Sml29623 30873859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_init_n2")); 30883859Sml29623 return (status); 30893859Sml29623 } 30903859Sml29623 30913859Sml29623 /* 30923859Sml29623 * Interrupts related interface functions. 30933859Sml29623 */ 30943859Sml29623 30953859Sml29623 nxge_status_t 30963859Sml29623 nxge_ldgv_init(p_nxge_t nxgep, int *navail_p, int *nrequired_p) 30973859Sml29623 { 30986495Sspeer int i, maxldvs, maxldgs, nldvs; 30993859Sml29623 int ldv, ldg, endldg, ngrps; 31003859Sml29623 uint8_t func; 31013859Sml29623 uint8_t channel; 31023859Sml29623 boolean_t own_sys_err = B_FALSE, own_fzc = B_FALSE; 31033859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 31043859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 31053859Sml29623 p_nxge_ldgv_t ldgvp; 31063859Sml29623 p_nxge_ldg_t ldgp, ptr; 31073859Sml29623 p_nxge_ldv_t ldvp; 31086495Sspeer nxge_grp_set_t *set; 31096495Sspeer 31103859Sml29623 nxge_status_t status = NXGE_OK; 31113859Sml29623 31123859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init")); 31133859Sml29623 if (!*navail_p) { 31143859Sml29623 *nrequired_p = 0; 31153859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 31166929Smisaki "<== nxge_ldgv_init:no avail")); 31173859Sml29623 return (NXGE_ERROR); 31183859Sml29623 } 31193859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 31203859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 31213859Sml29623 31226495Sspeer nldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs; 31233859Sml29623 31243859Sml29623 /* 31253859Sml29623 * If function zero instance, it needs to handle the system error 31263859Sml29623 * interrupts. 31273859Sml29623 */ 31283859Sml29623 func = nxgep->function_num; 31293859Sml29623 if (func == 0) { 31303859Sml29623 nldvs++; 31313859Sml29623 own_sys_err = B_TRUE; 31323859Sml29623 } else { 31333859Sml29623 /* use timer */ 31343859Sml29623 nldvs++; 31353859Sml29623 } 31363859Sml29623 31373859Sml29623 /* 31383859Sml29623 * Assume single partition, each function owns mac. 31393859Sml29623 */ 31403859Sml29623 if (!nxge_use_partition) { 31413859Sml29623 /* mac */ 31423859Sml29623 nldvs++; 31433859Sml29623 /* MIF */ 31443859Sml29623 nldvs++; 31453859Sml29623 own_fzc = B_TRUE; 31463859Sml29623 } 31473859Sml29623 maxldvs = nldvs; 31483859Sml29623 maxldgs = p_cfgp->max_ldgs; 31493859Sml29623 if (!maxldvs || !maxldgs) { 31503859Sml29623 /* No devices configured. */ 31513859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_init: " 31526929Smisaki "no logical devices or groups configured.")); 31533859Sml29623 return (NXGE_ERROR); 31543859Sml29623 } 31553859Sml29623 ldgvp = nxgep->ldgvp; 31563859Sml29623 if (ldgvp == NULL) { 31573859Sml29623 ldgvp = KMEM_ZALLOC(sizeof (nxge_ldgv_t), KM_SLEEP); 31583859Sml29623 nxgep->ldgvp = ldgvp; 31593859Sml29623 ldgvp->maxldgs = (uint8_t)maxldgs; 31603859Sml29623 ldgvp->maxldvs = (uint8_t)maxldvs; 31613859Sml29623 ldgp = ldgvp->ldgp = KMEM_ZALLOC(sizeof (nxge_ldg_t) * maxldgs, 31626929Smisaki KM_SLEEP); 31633859Sml29623 ldvp = ldgvp->ldvp = KMEM_ZALLOC(sizeof (nxge_ldv_t) * maxldvs, 31646929Smisaki KM_SLEEP); 31653859Sml29623 } 31666495Sspeer ldgvp->ndma_ldvs = p_cfgp->tdc.owned + p_cfgp->max_rdcs; 31673859Sml29623 ldgvp->tmres = NXGE_TIMER_RESO; 31683859Sml29623 31693859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 31706929Smisaki "==> nxge_ldgv_init: maxldvs %d maxldgs %d nldvs %d", 31716929Smisaki maxldvs, maxldgs, nldvs)); 31723859Sml29623 ldg = p_cfgp->start_ldg; 31733859Sml29623 ptr = ldgp; 31743859Sml29623 for (i = 0; i < maxldgs; i++) { 31753859Sml29623 ptr->func = func; 31763859Sml29623 ptr->arm = B_TRUE; 31773859Sml29623 ptr->vldg_index = (uint8_t)i; 31783859Sml29623 ptr->ldg_timer = NXGE_TIMER_LDG; 31793859Sml29623 ptr->ldg = ldg++; 31803859Sml29623 ptr->sys_intr_handler = nxge_intr; 31813859Sml29623 ptr->nldvs = 0; 31823859Sml29623 ptr->nxgep = nxgep; 31833859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 31846929Smisaki "==> nxge_ldgv_init: maxldvs %d maxldgs %d ldg %d", 31856929Smisaki maxldvs, maxldgs, ptr->ldg)); 31863859Sml29623 ptr++; 31873859Sml29623 } 31883859Sml29623 31893859Sml29623 ldg = p_cfgp->start_ldg; 31903859Sml29623 if (maxldgs > *navail_p) { 31913859Sml29623 ngrps = *navail_p; 31923859Sml29623 } else { 31933859Sml29623 ngrps = maxldgs; 31943859Sml29623 } 31953859Sml29623 endldg = ldg + ngrps; 31963859Sml29623 31973859Sml29623 /* 31983859Sml29623 * Receive DMA channels. 31993859Sml29623 */ 32003859Sml29623 nldvs = 0; 32013859Sml29623 ldgvp->nldvs = 0; 32023859Sml29623 ldgp->ldvp = NULL; 32033859Sml29623 *nrequired_p = 0; 32043859Sml29623 32053859Sml29623 /* 32063859Sml29623 * Start with RDC to configure logical devices for each group. 32073859Sml29623 */ 32086495Sspeer set = &nxgep->rx_set; 32096495Sspeer for (channel = 0; channel < NXGE_MAX_RDCS; channel++) { 32106495Sspeer if ((1 << channel) & set->owned.map) { 32116495Sspeer /* For now, <channel & <vdma_index> are the same. */ 32126495Sspeer ldvp->is_rxdma = B_TRUE; 32136495Sspeer ldvp->ldv = (uint8_t)channel + NXGE_RDMA_LD_START; 32146495Sspeer ldvp->channel = channel; 32156495Sspeer ldvp->vdma_index = (uint8_t)channel; 32166495Sspeer ldvp->ldv_intr_handler = nxge_rx_intr; 32176495Sspeer ldvp->ldv_ldf_masks = 0; 32186495Sspeer ldvp->use_timer = B_FALSE; 32196495Sspeer ldvp->nxgep = nxgep; 32206495Sspeer nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv, 32216495Sspeer endldg, nrequired_p); 32226495Sspeer nldvs++; 32236495Sspeer } 32243859Sml29623 } 32253859Sml29623 32263859Sml29623 /* 32273859Sml29623 * Transmit DMA channels. 32283859Sml29623 */ 32296495Sspeer set = &nxgep->tx_set; 32306495Sspeer for (channel = 0; channel < NXGE_MAX_TDCS; channel++) { 32316495Sspeer if ((1 << channel) & set->owned.map) { 32326495Sspeer /* For now, <channel & <vdma_index> are the same. */ 32336495Sspeer ldvp->is_txdma = B_TRUE; 32346495Sspeer ldvp->ldv = (uint8_t)channel + NXGE_TDMA_LD_START; 32356495Sspeer ldvp->channel = channel; 32366495Sspeer ldvp->vdma_index = (uint8_t)channel; 32376495Sspeer ldvp->ldv_intr_handler = nxge_tx_intr; 32386495Sspeer ldvp->ldv_ldf_masks = 0; 32396495Sspeer ldvp->use_timer = B_FALSE; 32406495Sspeer ldvp->nxgep = nxgep; 32416495Sspeer nxge_ldgv_setup(&ldgp, &ldvp, ldvp->ldv, 32426495Sspeer endldg, nrequired_p); 32436495Sspeer nldvs++; 32446495Sspeer } 32453859Sml29623 } 32463859Sml29623 32473859Sml29623 if (own_fzc) { 32483859Sml29623 ldv = NXGE_MIF_LD; 32493859Sml29623 ldvp->ldv = (uint8_t)ldv; 32503859Sml29623 ldvp->is_mif = B_TRUE; 32513859Sml29623 ldvp->ldv_intr_handler = nxge_mif_intr; 32523859Sml29623 ldvp->ldv_ldf_masks = 0; 32533859Sml29623 ldvp->use_timer = B_FALSE; 32543859Sml29623 ldvp->nxgep = nxgep; 32553859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 32563859Sml29623 nldvs++; 32573859Sml29623 } 32583859Sml29623 /* 32593859Sml29623 * MAC port (function zero control) 32603859Sml29623 */ 32613859Sml29623 if (own_fzc) { 32623859Sml29623 ldvp->is_mac = B_TRUE; 32633859Sml29623 ldvp->ldv_intr_handler = nxge_mac_intr; 32643859Sml29623 ldvp->ldv_ldf_masks = 0; 32653859Sml29623 ldv = func + NXGE_MAC_LD_START; 32663859Sml29623 ldvp->ldv = (uint8_t)ldv; 32673859Sml29623 ldvp->use_timer = B_FALSE; 32683859Sml29623 ldvp->nxgep = nxgep; 32693859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 32703859Sml29623 nldvs++; 32713859Sml29623 } 32723859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init: " 32736929Smisaki "func %d nldvs %d navail %d nrequired %d", 32746929Smisaki func, nldvs, *navail_p, *nrequired_p)); 32753859Sml29623 /* 32763859Sml29623 * Function 0 owns system error interrupts. 32773859Sml29623 */ 32783859Sml29623 ldvp->use_timer = B_TRUE; 32793859Sml29623 if (own_sys_err) { 32803859Sml29623 ldv = NXGE_SYS_ERROR_LD; 32813859Sml29623 ldvp->ldv = (uint8_t)ldv; 32823859Sml29623 ldvp->is_syserr = B_TRUE; 32833859Sml29623 ldvp->ldv_intr_handler = nxge_syserr_intr; 32843859Sml29623 ldvp->ldv_ldf_masks = 0; 32853859Sml29623 ldvp->nxgep = nxgep; 32863859Sml29623 ldgvp->ldvp_syserr = ldvp; 32873859Sml29623 /* 32883859Sml29623 * Unmask the system interrupt states. 32893859Sml29623 */ 32903859Sml29623 (void) nxge_fzc_sys_err_mask_set(nxgep, SYS_ERR_SMX_MASK | 32916929Smisaki SYS_ERR_IPP_MASK | SYS_ERR_TXC_MASK | 32926929Smisaki SYS_ERR_ZCP_MASK); 32933859Sml29623 32943859Sml29623 (void) nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 32953859Sml29623 nldvs++; 32963859Sml29623 } else { 32973859Sml29623 ldv = NXGE_SYS_ERROR_LD; 32983859Sml29623 ldvp->ldv = (uint8_t)ldv; 32993859Sml29623 ldvp->is_syserr = B_TRUE; 33003859Sml29623 ldvp->ldv_intr_handler = nxge_syserr_intr; 33013859Sml29623 ldvp->nxgep = nxgep; 33023859Sml29623 ldvp->ldv_ldf_masks = 0; 33033859Sml29623 ldgvp->ldvp_syserr = ldvp; 33043859Sml29623 } 33053859Sml29623 33063859Sml29623 ldgvp->ldg_intrs = *nrequired_p; 33073859Sml29623 33083859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init: " 33096929Smisaki "func %d nldvs %d navail %d nrequired %d", 33106929Smisaki func, nldvs, *navail_p, *nrequired_p)); 33113859Sml29623 33123859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_init")); 33133859Sml29623 return (status); 33143859Sml29623 } 33153859Sml29623 33163859Sml29623 nxge_status_t 33173859Sml29623 nxge_ldgv_uninit(p_nxge_t nxgep) 33183859Sml29623 { 33193859Sml29623 p_nxge_ldgv_t ldgvp; 33203859Sml29623 33213859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_uninit")); 33223859Sml29623 ldgvp = nxgep->ldgvp; 33233859Sml29623 if (ldgvp == NULL) { 33243859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_uninit: " 33256929Smisaki "no logical group configured.")); 33263859Sml29623 return (NXGE_OK); 33273859Sml29623 } 33288275SEric Cheng if (ldgvp->ldvp_syserr_alloced == B_TRUE) { 33297466SMisaki.Kataoka@Sun.COM KMEM_FREE(ldgvp->ldvp_syserr, sizeof (nxge_ldv_t)); 33307466SMisaki.Kataoka@Sun.COM } 33313859Sml29623 if (ldgvp->ldgp) { 33323859Sml29623 KMEM_FREE(ldgvp->ldgp, sizeof (nxge_ldg_t) * ldgvp->maxldgs); 33333859Sml29623 } 33343859Sml29623 if (ldgvp->ldvp) { 33353859Sml29623 KMEM_FREE(ldgvp->ldvp, sizeof (nxge_ldv_t) * ldgvp->maxldvs); 33363859Sml29623 } 33373859Sml29623 KMEM_FREE(ldgvp, sizeof (nxge_ldgv_t)); 33383859Sml29623 nxgep->ldgvp = NULL; 33393859Sml29623 33403859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_uninit")); 33413859Sml29623 return (NXGE_OK); 33423859Sml29623 } 33433859Sml29623 33443859Sml29623 nxge_status_t 33453859Sml29623 nxge_intr_ldgv_init(p_nxge_t nxgep) 33463859Sml29623 { 33473859Sml29623 nxge_status_t status = NXGE_OK; 33483859Sml29623 33493859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_ldgv_init")); 33503859Sml29623 /* 33513859Sml29623 * Configure the logical device group numbers, state vectors and 33523859Sml29623 * interrupt masks for each logical device. 33533859Sml29623 */ 33543859Sml29623 status = nxge_fzc_intr_init(nxgep); 33553859Sml29623 33563859Sml29623 /* 33573859Sml29623 * Configure logical device masks and timers. 33583859Sml29623 */ 33593859Sml29623 status = nxge_intr_mask_mgmt(nxgep); 33603859Sml29623 33613859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_ldgv_init")); 33623859Sml29623 return (status); 33633859Sml29623 } 33643859Sml29623 33653859Sml29623 nxge_status_t 33663859Sml29623 nxge_intr_mask_mgmt(p_nxge_t nxgep) 33673859Sml29623 { 33683859Sml29623 p_nxge_ldgv_t ldgvp; 33693859Sml29623 p_nxge_ldg_t ldgp; 33703859Sml29623 p_nxge_ldv_t ldvp; 33713859Sml29623 npi_handle_t handle; 33723859Sml29623 int i, j; 33733859Sml29623 npi_status_t rs = NPI_SUCCESS; 33743859Sml29623 33753859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_mask_mgmt")); 33763859Sml29623 33773859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) { 33783859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 33796929Smisaki "<== nxge_intr_mask_mgmt: Null ldgvp")); 33803859Sml29623 return (NXGE_ERROR); 33813859Sml29623 } 33823859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 33833859Sml29623 ldgp = ldgvp->ldgp; 33843859Sml29623 ldvp = ldgvp->ldvp; 33853859Sml29623 if (ldgp == NULL || ldvp == NULL) { 33863859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 33876929Smisaki "<== nxge_intr_mask_mgmt: Null ldgp or ldvp")); 33883859Sml29623 return (NXGE_ERROR); 33893859Sml29623 } 33903859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33916929Smisaki "==> nxge_intr_mask_mgmt: # of intrs %d ", ldgvp->ldg_intrs)); 33923859Sml29623 /* Initialize masks. */ 33933859Sml29623 if (nxgep->niu_type != N2_NIU) { 33943859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33956929Smisaki "==> nxge_intr_mask_mgmt(Neptune): # intrs %d ", 33966929Smisaki ldgvp->ldg_intrs)); 33973859Sml29623 for (i = 0; i < ldgvp->ldg_intrs; i++, ldgp++) { 33983859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33996929Smisaki "==> nxge_intr_mask_mgmt(Neptune): # ldv %d " 34006929Smisaki "in group %d", ldgp->nldvs, ldgp->ldg)); 34013859Sml29623 for (j = 0; j < ldgp->nldvs; j++, ldvp++) { 34023859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34036929Smisaki "==> nxge_intr_mask_mgmt: set ldv # %d " 34046929Smisaki "for ldg %d", ldvp->ldv, ldgp->ldg)); 34053859Sml29623 rs = npi_intr_mask_set(handle, ldvp->ldv, 34066929Smisaki ldvp->ldv_ldf_masks); 34073859Sml29623 if (rs != NPI_SUCCESS) { 34083859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 34096929Smisaki "<== nxge_intr_mask_mgmt: " 34106929Smisaki "set mask failed " 34116929Smisaki " rs 0x%x ldv %d mask 0x%x", 34126929Smisaki rs, ldvp->ldv, 34136929Smisaki ldvp->ldv_ldf_masks)); 34143859Sml29623 return (NXGE_ERROR | rs); 34153859Sml29623 } 34163859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34176929Smisaki "==> nxge_intr_mask_mgmt: " 34186929Smisaki "set mask OK " 34196929Smisaki " rs 0x%x ldv %d mask 0x%x", 34206929Smisaki rs, ldvp->ldv, 34216929Smisaki ldvp->ldv_ldf_masks)); 34223859Sml29623 } 34233859Sml29623 } 34243859Sml29623 } 34253859Sml29623 ldgp = ldgvp->ldgp; 34263859Sml29623 /* Configure timer and arm bit */ 34273859Sml29623 for (i = 0; i < nxgep->ldgvp->ldg_intrs; i++, ldgp++) { 34283859Sml29623 rs = npi_intr_ldg_mgmt_set(handle, ldgp->ldg, 34296929Smisaki ldgp->arm, ldgp->ldg_timer); 34303859Sml29623 if (rs != NPI_SUCCESS) { 34313859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 34326929Smisaki "<== nxge_intr_mask_mgmt: " 34336929Smisaki "set timer failed " 34346929Smisaki " rs 0x%x dg %d timer 0x%x", 34356929Smisaki rs, ldgp->ldg, ldgp->ldg_timer)); 34363859Sml29623 return (NXGE_ERROR | rs); 34373859Sml29623 } 34383859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34396929Smisaki "==> nxge_intr_mask_mgmt: " 34406929Smisaki "set timer OK " 34416929Smisaki " rs 0x%x ldg %d timer 0x%x", 34426929Smisaki rs, ldgp->ldg, ldgp->ldg_timer)); 34433859Sml29623 } 34443859Sml29623 34453859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_fzc_intr_mask_mgmt")); 34463859Sml29623 return (NXGE_OK); 34473859Sml29623 } 34483859Sml29623 34493859Sml29623 nxge_status_t 34503859Sml29623 nxge_intr_mask_mgmt_set(p_nxge_t nxgep, boolean_t on) 34513859Sml29623 { 34523859Sml29623 p_nxge_ldgv_t ldgvp; 34533859Sml29623 p_nxge_ldg_t ldgp; 34543859Sml29623 p_nxge_ldv_t ldvp; 34553859Sml29623 npi_handle_t handle; 34563859Sml29623 int i, j; 34573859Sml29623 npi_status_t rs = NPI_SUCCESS; 34583859Sml29623 34593859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34606929Smisaki "==> nxge_intr_mask_mgmt_set (%d)", on)); 34613859Sml29623 34623859Sml29623 if (nxgep->niu_type == N2_NIU) { 34633859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34646929Smisaki "<== nxge_intr_mask_mgmt_set (%d) not set (N2/NIU)", 34656929Smisaki on)); 34663859Sml29623 return (NXGE_ERROR); 34673859Sml29623 } 34683859Sml29623 34693859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) { 34703859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 34716929Smisaki "==> nxge_intr_mask_mgmt_set: Null ldgvp")); 34723859Sml29623 return (NXGE_ERROR); 34733859Sml29623 } 34743859Sml29623 34753859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 34763859Sml29623 ldgp = ldgvp->ldgp; 34773859Sml29623 ldvp = ldgvp->ldvp; 34783859Sml29623 if (ldgp == NULL || ldvp == NULL) { 34793859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 34806929Smisaki "<== nxge_intr_mask_mgmt_set: Null ldgp or ldvp")); 34813859Sml29623 return (NXGE_ERROR); 34823859Sml29623 } 34833859Sml29623 /* set masks. */ 34843859Sml29623 for (i = 0; i < ldgvp->ldg_intrs; i++, ldgp++) { 34853859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34866929Smisaki "==> nxge_intr_mask_mgmt_set: flag %d ldg %d" 34876929Smisaki "set mask nldvs %d", on, ldgp->ldg, ldgp->nldvs)); 34883859Sml29623 for (j = 0; j < ldgp->nldvs; j++, ldvp++) { 34893859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34906929Smisaki "==> nxge_intr_mask_mgmt_set: " 34916929Smisaki "for %d %d flag %d", i, j, on)); 34923859Sml29623 if (on) { 34933859Sml29623 ldvp->ldv_ldf_masks = 0; 34943859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 34956929Smisaki "==> nxge_intr_mask_mgmt_set: " 34966929Smisaki "ON mask off")); 34973859Sml29623 } else if (!on) { 34983859Sml29623 ldvp->ldv_ldf_masks = (uint8_t)LD_IM1_MASK; 34993859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35006929Smisaki "==> nxge_intr_mask_mgmt_set:mask on")); 35013859Sml29623 } 35023859Sml29623 rs = npi_intr_mask_set(handle, ldvp->ldv, 35036929Smisaki ldvp->ldv_ldf_masks); 35043859Sml29623 if (rs != NPI_SUCCESS) { 35053859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 35066929Smisaki "==> nxge_intr_mask_mgmt_set: " 35076929Smisaki "set mask failed " 35086929Smisaki " rs 0x%x ldv %d mask 0x%x", 35096929Smisaki rs, ldvp->ldv, ldvp->ldv_ldf_masks)); 35103859Sml29623 return (NXGE_ERROR | rs); 35113859Sml29623 } 35123859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35136929Smisaki "==> nxge_intr_mask_mgmt_set: flag %d" 35146929Smisaki "set mask OK " 35156929Smisaki " ldv %d mask 0x%x", 35166929Smisaki on, ldvp->ldv, ldvp->ldv_ldf_masks)); 35173859Sml29623 } 35183859Sml29623 } 35193859Sml29623 35203859Sml29623 ldgp = ldgvp->ldgp; 35213859Sml29623 /* set the arm bit */ 35223859Sml29623 for (i = 0; i < nxgep->ldgvp->ldg_intrs; i++, ldgp++) { 35233859Sml29623 if (on && !ldgp->arm) { 35243859Sml29623 ldgp->arm = B_TRUE; 35253859Sml29623 } else if (!on && ldgp->arm) { 35263859Sml29623 ldgp->arm = B_FALSE; 35273859Sml29623 } 35283859Sml29623 rs = npi_intr_ldg_mgmt_set(handle, ldgp->ldg, 35296929Smisaki ldgp->arm, ldgp->ldg_timer); 35303859Sml29623 if (rs != NPI_SUCCESS) { 35313859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 35326929Smisaki "<== nxge_intr_mask_mgmt_set: " 35336929Smisaki "set timer failed " 35346929Smisaki " rs 0x%x ldg %d timer 0x%x", 35356929Smisaki rs, ldgp->ldg, ldgp->ldg_timer)); 35363859Sml29623 return (NXGE_ERROR | rs); 35373859Sml29623 } 35383859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 35396929Smisaki "==> nxge_intr_mask_mgmt_set: OK (flag %d) " 35406929Smisaki "set timer " 35416929Smisaki " ldg %d timer 0x%x", 35426929Smisaki on, ldgp->ldg, ldgp->ldg_timer)); 35433859Sml29623 } 35443859Sml29623 35453859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_mask_mgmt_set")); 35463859Sml29623 return (NXGE_OK); 35473859Sml29623 } 35483859Sml29623 35493859Sml29623 static nxge_status_t 35503859Sml29623 nxge_get_mac_addr_properties(p_nxge_t nxgep) 35513859Sml29623 { 35524732Sdavemq #if defined(_BIG_ENDIAN) 35533859Sml29623 uchar_t *prop_val; 35543859Sml29623 uint_t prop_len; 35554732Sdavemq uint_t j; 35564732Sdavemq #endif 35573859Sml29623 uint_t i; 35583859Sml29623 uint8_t func_num; 35594732Sdavemq boolean_t compute_macs = B_TRUE; 35603859Sml29623 35613859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_get_mac_addr_properties ")); 35623859Sml29623 35633859Sml29623 #if defined(_BIG_ENDIAN) 35643859Sml29623 /* 35653859Sml29623 * Get the ethernet address. 35663859Sml29623 */ 35673859Sml29623 (void) localetheraddr((struct ether_addr *)NULL, &nxgep->ouraddr); 35683859Sml29623 35693859Sml29623 /* 35703859Sml29623 * Check if it is an adapter with its own local mac address If it is 35713859Sml29623 * present, override the system mac address. 35723859Sml29623 */ 35733859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 35746929Smisaki "local-mac-address", &prop_val, 35756929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 35763859Sml29623 if (prop_len == ETHERADDRL) { 35773859Sml29623 nxgep->factaddr = *(p_ether_addr_t)prop_val; 35783859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "Local mac address = " 35796929Smisaki "%02x:%02x:%02x:%02x:%02x:%02x", 35806929Smisaki prop_val[0], prop_val[1], prop_val[2], 35816929Smisaki prop_val[3], prop_val[4], prop_val[5])); 35823859Sml29623 } 35833859Sml29623 ddi_prop_free(prop_val); 35843859Sml29623 } 35853859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 35866929Smisaki "local-mac-address?", &prop_val, 35876929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 35883859Sml29623 if (strncmp("true", (caddr_t)prop_val, (size_t)prop_len) == 0) { 35893859Sml29623 nxgep->ouraddr = nxgep->factaddr; 35903859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, 35916929Smisaki "Using local MAC address")); 35923859Sml29623 } 35933859Sml29623 ddi_prop_free(prop_val); 35943859Sml29623 } else { 35953859Sml29623 nxgep->ouraddr = nxgep->factaddr; 35963859Sml29623 } 35974185Sspeer 35984977Sraghus if ((!nxgep->vpd_info.present) || 35994732Sdavemq (nxge_is_valid_local_mac(nxgep->factaddr))) 36004185Sspeer goto got_mac_addr; 36014185Sspeer 36024185Sspeer NXGE_DEBUG_MSG((nxgep, DDI_CTL, "nxge_get_mac_addr_properties: " 36034185Sspeer "MAC address from properties is not valid...reading from PROM")); 36044185Sspeer 36054185Sspeer #endif 36064185Sspeer if (!nxgep->vpd_info.ver_valid) { 36074185Sspeer (void) nxge_espc_mac_addrs_get(nxgep); 36084185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 36094977Sraghus NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "Failed to get " 36104977Sraghus "MAC address")); 36114185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "EEPROM version " 36124185Sspeer "[%s] invalid...please update", 36134185Sspeer nxgep->vpd_info.ver)); 36144185Sspeer return (NXGE_ERROR); 36154185Sspeer } 36164185Sspeer nxgep->ouraddr = nxgep->factaddr; 36174185Sspeer goto got_mac_addr; 36184185Sspeer } 36194185Sspeer /* 36204185Sspeer * First get the MAC address from the info in the VPD data read 36214185Sspeer * from the EEPROM. 36224185Sspeer */ 36234185Sspeer nxge_espc_get_next_mac_addr(nxgep->vpd_info.mac_addr, 36244732Sdavemq nxgep->function_num, &nxgep->factaddr); 36254185Sspeer 36264185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 36274185Sspeer NXGE_DEBUG_MSG((nxgep, DDI_CTL, 36284185Sspeer "nxge_get_mac_addr_properties: " 36294185Sspeer "MAC address in EEPROM VPD data not valid" 36304185Sspeer "...reading from NCR registers")); 36314185Sspeer (void) nxge_espc_mac_addrs_get(nxgep); 36324185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 36334977Sraghus NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "Failed to get " 36344977Sraghus "MAC address")); 36354185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "EEPROM version " 36364185Sspeer "[%s] invalid...please update", 36374185Sspeer nxgep->vpd_info.ver)); 36384185Sspeer return (NXGE_ERROR); 36394185Sspeer } 36404185Sspeer } 36414185Sspeer 36423859Sml29623 nxgep->ouraddr = nxgep->factaddr; 36434185Sspeer 36444185Sspeer got_mac_addr: 36453859Sml29623 func_num = nxgep->function_num; 36463859Sml29623 36473859Sml29623 /* 36484732Sdavemq * Note: mac-addresses property is the list of mac addresses for a 36494732Sdavemq * port. NXGE_MAX_MMAC_ADDRS is the total number of MAC addresses 36504732Sdavemq * allocated for a board. 36513859Sml29623 */ 36524732Sdavemq nxgep->nxge_mmac_info.total_factory_macs = NXGE_MAX_MMAC_ADDRS; 36534732Sdavemq 36544732Sdavemq #if defined(_BIG_ENDIAN) 36554732Sdavemq if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 36564732Sdavemq "mac-addresses", &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 36573859Sml29623 /* 36584732Sdavemq * XAUI may have up to 18 MACs, more than the XMAC can 36594732Sdavemq * use (1 unique MAC plus 16 alternate MACs) 36603859Sml29623 */ 36614732Sdavemq nxgep->nxge_mmac_info.num_factory_mmac = 36624732Sdavemq prop_len / ETHERADDRL - 1; 36634732Sdavemq if (nxgep->nxge_mmac_info.num_factory_mmac > 36644732Sdavemq XMAC_MAX_ALT_ADDR_ENTRY) { 36654185Sspeer nxgep->nxge_mmac_info.num_factory_mmac = 36664732Sdavemq XMAC_MAX_ALT_ADDR_ENTRY; 36674732Sdavemq } 36684732Sdavemq 36694732Sdavemq for (i = 1; i <= nxgep->nxge_mmac_info.num_factory_mmac; i++) { 36704732Sdavemq for (j = 0; j < ETHERADDRL; j++) { 36714732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][j] = 36724732Sdavemq *(prop_val + (i * ETHERADDRL) + j); 36734732Sdavemq } 36744732Sdavemq NXGE_DEBUG_MSG((nxgep, DDI_CTL, 36754732Sdavemq "nxge_get_mac_addr_properties: Alt mac[%d] from " 36764732Sdavemq "mac-addresses property[%2x:%2x:%2x:%2x:%2x:%2x]", 36774732Sdavemq i, nxgep->nxge_mmac_info.factory_mac_pool[i][0], 36784732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][1], 36794732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][2], 36804732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][3], 36814732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][4], 36824732Sdavemq nxgep->nxge_mmac_info.factory_mac_pool[i][5])); 36834185Sspeer } 36844732Sdavemq 36854732Sdavemq compute_macs = B_FALSE; 36864732Sdavemq ddi_prop_free(prop_val); 36874732Sdavemq goto got_mmac_info; 36883859Sml29623 } 36894732Sdavemq #endif 36904732Sdavemq /* 36914732Sdavemq * total_factory_macs = 32 36924732Sdavemq * num_factory_mmac = (32 >> (nports/2)) - 1 36934732Sdavemq * So if nports = 4, then num_factory_mmac = 7 36944732Sdavemq * if nports = 2, then num_factory_mmac = 15 36954732Sdavemq */ 36964732Sdavemq nxgep->nxge_mmac_info.num_factory_mmac = 36974732Sdavemq ((nxgep->nxge_mmac_info.total_factory_macs >> 36984732Sdavemq (nxgep->nports >> 1))) - 1; 36994732Sdavemq 37004732Sdavemq got_mmac_info: 37014732Sdavemq 37024732Sdavemq if ((nxgep->function_num < 2) && 37034732Sdavemq (nxgep->nxge_mmac_info.num_factory_mmac > 37044732Sdavemq XMAC_MAX_ALT_ADDR_ENTRY)) { 37054732Sdavemq nxgep->nxge_mmac_info.num_factory_mmac = 37064732Sdavemq XMAC_MAX_ALT_ADDR_ENTRY; 37074732Sdavemq } else if ((nxgep->function_num > 1) && 37084732Sdavemq (nxgep->nxge_mmac_info.num_factory_mmac > 37094732Sdavemq BMAC_MAX_ALT_ADDR_ENTRY)) { 37104732Sdavemq nxgep->nxge_mmac_info.num_factory_mmac = 37114732Sdavemq BMAC_MAX_ALT_ADDR_ENTRY; 37124185Sspeer } 37134185Sspeer 37143859Sml29623 for (i = 0; i <= nxgep->nxge_mmac_info.num_mmac; i++) { 37153859Sml29623 (void) npi_mac_altaddr_disable(nxgep->npi_handle, 37166929Smisaki NXGE_GET_PORT_NUM(func_num), i); 37173859Sml29623 } 37183859Sml29623 37194732Sdavemq (void) nxge_init_mmac(nxgep, compute_macs); 37203859Sml29623 return (NXGE_OK); 37213859Sml29623 } 37223859Sml29623 37233859Sml29623 void 37243859Sml29623 nxge_get_xcvr_properties(p_nxge_t nxgep) 37253859Sml29623 { 37263859Sml29623 uchar_t *prop_val; 37273859Sml29623 uint_t prop_len; 37283859Sml29623 37293859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_get_xcvr_properties")); 37303859Sml29623 37313859Sml29623 /* 37323859Sml29623 * Read the type of physical layer interface being used. 37333859Sml29623 */ 37343859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 37353859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 37366929Smisaki "phy-type", &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 37373859Sml29623 if (strncmp("pcs", (caddr_t)prop_val, 37386929Smisaki (size_t)prop_len) == 0) { 37393859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = PCS_XCVR; 37403859Sml29623 } else { 37413859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 37423859Sml29623 } 37433859Sml29623 ddi_prop_free(prop_val); 37443859Sml29623 } else if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 37456929Smisaki "phy-interface", &prop_val, 37466929Smisaki &prop_len) == DDI_PROP_SUCCESS) { 37473859Sml29623 if (strncmp("pcs", (caddr_t)prop_val, (size_t)prop_len) == 0) { 37483859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = PCS_XCVR; 37493859Sml29623 } else { 37503859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 37513859Sml29623 } 37523859Sml29623 ddi_prop_free(prop_val); 37533859Sml29623 } 37543859Sml29623 } 37553859Sml29623 37563859Sml29623 /* 37573859Sml29623 * Static functions start here. 37583859Sml29623 */ 37593859Sml29623 37603859Sml29623 static void 37613859Sml29623 nxge_ldgv_setup(p_nxge_ldg_t *ldgp, p_nxge_ldv_t *ldvp, uint8_t ldv, 37623859Sml29623 uint8_t endldg, int *ngrps) 37633859Sml29623 { 37643859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup")); 37653859Sml29623 /* Assign the group number for each device. */ 37663859Sml29623 (*ldvp)->ldg_assigned = (*ldgp)->ldg; 37673859Sml29623 (*ldvp)->ldgp = *ldgp; 37683859Sml29623 (*ldvp)->ldv = ldv; 37693859Sml29623 37703859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup: " 37716929Smisaki "ldv %d endldg %d ldg %d, ldvp $%p", 37726929Smisaki ldv, endldg, (*ldgp)->ldg, (*ldgp)->ldvp)); 37733859Sml29623 37743859Sml29623 (*ldgp)->nldvs++; 37753859Sml29623 if ((*ldgp)->ldg == (endldg - 1)) { 37763859Sml29623 if ((*ldgp)->ldvp == NULL) { 37773859Sml29623 (*ldgp)->ldvp = *ldvp; 37783859Sml29623 *ngrps += 1; 37793859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 37806929Smisaki "==> nxge_ldgv_setup: ngrps %d", *ngrps)); 37813859Sml29623 } 37823859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 37836929Smisaki "==> nxge_ldgv_setup: ldvp $%p ngrps %d", 37846929Smisaki *ldvp, *ngrps)); 37853859Sml29623 ++*ldvp; 37863859Sml29623 } else { 37873859Sml29623 (*ldgp)->ldvp = *ldvp; 37883859Sml29623 *ngrps += 1; 37893859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup(done): " 37906929Smisaki "ldv %d endldg %d ldg %d, ldvp $%p", 37916929Smisaki ldv, endldg, (*ldgp)->ldg, (*ldgp)->ldvp)); 37923859Sml29623 (*ldvp) = ++*ldvp; 37933859Sml29623 (*ldgp) = ++*ldgp; 37943859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 37956929Smisaki "==> nxge_ldgv_setup: new ngrps %d", *ngrps)); 37963859Sml29623 } 37973859Sml29623 37983859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup: " 37996929Smisaki "ldv %d ldvp $%p endldg %d ngrps %d", 38006929Smisaki ldv, ldvp, endldg, *ngrps)); 38013859Sml29623 38023859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "<== nxge_ldgv_setup")); 38033859Sml29623 } 38043859Sml29623 38053859Sml29623 /* 38063859Sml29623 * Note: This function assumes the following distribution of mac 38073859Sml29623 * addresses among 4 ports in neptune: 38083859Sml29623 * 38093859Sml29623 * ------------- 38103859Sml29623 * 0| |0 - local-mac-address for fn 0 38113859Sml29623 * ------------- 38123859Sml29623 * 1| |1 - local-mac-address for fn 1 38133859Sml29623 * ------------- 38143859Sml29623 * 2| |2 - local-mac-address for fn 2 38153859Sml29623 * ------------- 38163859Sml29623 * 3| |3 - local-mac-address for fn 3 38173859Sml29623 * ------------- 38183859Sml29623 * | |4 - Start of alt. mac addr. for fn 0 38193859Sml29623 * | | 38203859Sml29623 * | | 38213859Sml29623 * | |10 38223859Sml29623 * -------------- 38233859Sml29623 * | |11 - Start of alt. mac addr. for fn 1 38243859Sml29623 * | | 38253859Sml29623 * | | 38263859Sml29623 * | |17 38273859Sml29623 * -------------- 38283859Sml29623 * | |18 - Start of alt. mac addr. for fn 2 38293859Sml29623 * | | 38303859Sml29623 * | | 38313859Sml29623 * | |24 38323859Sml29623 * -------------- 38333859Sml29623 * | |25 - Start of alt. mac addr. for fn 3 38343859Sml29623 * | | 38353859Sml29623 * | | 38363859Sml29623 * | |31 38373859Sml29623 * -------------- 38383859Sml29623 * 38393859Sml29623 * For N2/NIU the mac addresses is from XAUI card. 38404732Sdavemq * 38414732Sdavemq * When 'compute_addrs' is true, the alternate mac addresses are computed 38424732Sdavemq * using the unique mac address as base. Otherwise the alternate addresses 38434732Sdavemq * are assigned from the list read off the 'mac-addresses' property. 38443859Sml29623 */ 38453859Sml29623 38463859Sml29623 static void 38474732Sdavemq nxge_init_mmac(p_nxge_t nxgep, boolean_t compute_addrs) 38483859Sml29623 { 38493859Sml29623 int slot; 38503859Sml29623 uint8_t func_num; 38513859Sml29623 uint16_t *base_mmac_addr; 38523859Sml29623 uint32_t alt_mac_ls4b; 38533859Sml29623 uint16_t *mmac_addr; 38543859Sml29623 uint32_t base_mac_ls4b; /* least significant 4 bytes */ 38553859Sml29623 nxge_mmac_t *mmac_info; 38563859Sml29623 npi_mac_addr_t mac_addr; 38573859Sml29623 38583859Sml29623 func_num = nxgep->function_num; 38593859Sml29623 base_mmac_addr = (uint16_t *)&nxgep->factaddr; 38603859Sml29623 mmac_info = (nxge_mmac_t *)&nxgep->nxge_mmac_info; 38613859Sml29623 38624732Sdavemq if (compute_addrs) { 38634732Sdavemq base_mac_ls4b = ((uint32_t)base_mmac_addr[1]) << 16 | 38644732Sdavemq base_mmac_addr[2]; 38654732Sdavemq 38664732Sdavemq if (nxgep->niu_type == N2_NIU) { 38674732Sdavemq /* ls4b of 1st altmac */ 38684732Sdavemq alt_mac_ls4b = base_mac_ls4b + 1; 38694732Sdavemq } else { /* Neptune */ 38704732Sdavemq alt_mac_ls4b = base_mac_ls4b + 38714732Sdavemq (nxgep->nports - func_num) + 38724732Sdavemq (func_num * (mmac_info->num_factory_mmac)); 38734732Sdavemq } 38743859Sml29623 } 38753859Sml29623 38763859Sml29623 /* Set flags for unique MAC */ 38773859Sml29623 mmac_info->mac_pool[0].flags |= MMAC_SLOT_USED | MMAC_VENDOR_ADDR; 38783859Sml29623 38793859Sml29623 /* Clear flags of all alternate MAC slots */ 38803859Sml29623 for (slot = 1; slot <= mmac_info->num_mmac; slot++) { 38813859Sml29623 if (slot <= mmac_info->num_factory_mmac) 38823859Sml29623 mmac_info->mac_pool[slot].flags = MMAC_VENDOR_ADDR; 38833859Sml29623 else 38843859Sml29623 mmac_info->mac_pool[slot].flags = 0; 38853859Sml29623 } 38863859Sml29623 38873859Sml29623 /* Generate and store factory alternate MACs */ 38883859Sml29623 for (slot = 1; slot <= mmac_info->num_factory_mmac; slot++) { 38893859Sml29623 mmac_addr = (uint16_t *)&mmac_info->factory_mac_pool[slot]; 38904732Sdavemq if (compute_addrs) { 38914732Sdavemq mmac_addr[0] = base_mmac_addr[0]; 38924732Sdavemq mac_addr.w2 = mmac_addr[0]; 38934732Sdavemq 38944732Sdavemq mmac_addr[1] = (alt_mac_ls4b >> 16) & 0x0FFFF; 38954732Sdavemq mac_addr.w1 = mmac_addr[1]; 38964732Sdavemq 38974732Sdavemq mmac_addr[2] = alt_mac_ls4b & 0x0FFFF; 38984732Sdavemq mac_addr.w0 = mmac_addr[2]; 38994732Sdavemq 39004732Sdavemq alt_mac_ls4b++; 39014732Sdavemq } else { 39024732Sdavemq mac_addr.w2 = mmac_addr[0]; 39034732Sdavemq mac_addr.w1 = mmac_addr[1]; 39044732Sdavemq mac_addr.w0 = mmac_addr[2]; 39054732Sdavemq } 39064732Sdavemq 39074732Sdavemq NXGE_DEBUG_MSG((nxgep, DDI_CTL, 39084732Sdavemq "mac_pool_addr[%2x:%2x:%2x:%2x:%2x:%2x] npi_addr[%x%x%x]", 39094732Sdavemq mmac_info->factory_mac_pool[slot][0], 39104732Sdavemq mmac_info->factory_mac_pool[slot][1], 39114732Sdavemq mmac_info->factory_mac_pool[slot][2], 39124732Sdavemq mmac_info->factory_mac_pool[slot][3], 39134732Sdavemq mmac_info->factory_mac_pool[slot][4], 39144732Sdavemq mmac_info->factory_mac_pool[slot][5], 39154732Sdavemq mac_addr.w0, mac_addr.w1, mac_addr.w2)); 39163859Sml29623 /* 39174732Sdavemq * slot minus 1 because npi_mac_altaddr_entry expects 0 39183859Sml29623 * for the first alternate mac address. 39193859Sml29623 */ 39203859Sml29623 (void) npi_mac_altaddr_entry(nxgep->npi_handle, OP_SET, 39216929Smisaki NXGE_GET_PORT_NUM(func_num), slot - 1, &mac_addr); 39223859Sml29623 } 39233859Sml29623 /* Initialize the first two parameters for mmac kstat */ 39243859Sml29623 nxgep->statsp->mmac_stats.mmac_max_cnt = mmac_info->num_mmac; 39253859Sml29623 nxgep->statsp->mmac_stats.mmac_avail_cnt = mmac_info->num_mmac; 39263859Sml29623 } 39278275SEric Cheng 39288275SEric Cheng /* 39298275SEric Cheng * Convert an RDC group index into a port ring index. That is, map 39308275SEric Cheng * <groupid> to an index into nxgep->rx_ring_handles. 39318275SEric Cheng * (group ring index -> port ring index) 39328275SEric Cheng */ 39338275SEric Cheng int 39348275SEric Cheng nxge_get_rxring_index(p_nxge_t nxgep, int groupid, int ringidx) 39358275SEric Cheng { 39368275SEric Cheng int i; 39378275SEric Cheng int index = 0; 39388275SEric Cheng p_nxge_rdc_grp_t rdc_grp_p; 39398275SEric Cheng p_nxge_dma_pt_cfg_t p_dma_cfgp; 39408275SEric Cheng p_nxge_hw_pt_cfg_t p_cfgp; 39418275SEric Cheng 39428275SEric Cheng p_dma_cfgp = &nxgep->pt_config; 39438275SEric Cheng p_cfgp = &p_dma_cfgp->hw_config; 39448275SEric Cheng 39458275SEric Cheng for (i = 0; i < groupid; i++) { 39468275SEric Cheng rdc_grp_p = 39478275SEric Cheng &p_dma_cfgp->rdc_grps[p_cfgp->def_mac_rxdma_grpid + i]; 39488275SEric Cheng index += rdc_grp_p->max_rdcs; 39498275SEric Cheng } 39508275SEric Cheng 39518275SEric Cheng return (index + ringidx); 39528275SEric Cheng } 3953