13859Sml29623 /* 23859Sml29623 * CDDL HEADER START 33859Sml29623 * 43859Sml29623 * The contents of this file are subject to the terms of the 53859Sml29623 * Common Development and Distribution License (the "License"). 63859Sml29623 * You may not use this file except in compliance with the License. 73859Sml29623 * 83859Sml29623 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93859Sml29623 * or http://www.opensolaris.org/os/licensing. 103859Sml29623 * See the License for the specific language governing permissions 113859Sml29623 * and limitations under the License. 123859Sml29623 * 133859Sml29623 * When distributing Covered Code, include this CDDL HEADER in each 143859Sml29623 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153859Sml29623 * If applicable, add the following below this CDDL HEADER, with the 163859Sml29623 * fields enclosed by brackets "[]" replaced with your own identifying 173859Sml29623 * information: Portions Copyright [yyyy] [name of copyright owner] 183859Sml29623 * 193859Sml29623 * CDDL HEADER END 203859Sml29623 */ 213859Sml29623 /* 223859Sml29623 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 233859Sml29623 * Use is subject to license terms. 243859Sml29623 */ 253859Sml29623 263859Sml29623 #pragma ident "%Z%%M% %I% %E% SMI" 273859Sml29623 283859Sml29623 #include <sys/nxge/nxge_impl.h> 293859Sml29623 #include <sys/nxge/nxge_mac.h> 303859Sml29623 313859Sml29623 static void nxge_get_niu_property(dev_info_t *, niu_type_t *); 323859Sml29623 static nxge_status_t nxge_get_mac_addr_properties(p_nxge_t); 333859Sml29623 static nxge_status_t nxge_use_cfg_n2niu_properties(p_nxge_t); 343859Sml29623 static void nxge_use_cfg_neptune_properties(p_nxge_t); 353859Sml29623 static void nxge_use_cfg_dma_config(p_nxge_t); 363859Sml29623 static void nxge_use_cfg_vlan_class_config(p_nxge_t); 373859Sml29623 static void nxge_use_cfg_mac_class_config(p_nxge_t); 383859Sml29623 static void nxge_use_cfg_class_config(p_nxge_t); 393859Sml29623 static void nxge_use_cfg_link_cfg(p_nxge_t); 403859Sml29623 static void nxge_set_hw_dma_config(p_nxge_t); 413859Sml29623 static void nxge_set_hw_vlan_class_config(p_nxge_t); 423859Sml29623 static void nxge_set_hw_mac_class_config(p_nxge_t); 433859Sml29623 static void nxge_set_hw_class_config(p_nxge_t); 443859Sml29623 static nxge_status_t nxge_use_default_dma_config_n2(p_nxge_t); 453859Sml29623 static void nxge_ldgv_setup(p_nxge_ldg_t *, p_nxge_ldv_t *, uint8_t, 463859Sml29623 uint8_t, int *); 473859Sml29623 static void nxge_init_mmac(p_nxge_t); 483859Sml29623 493859Sml29623 uint32_t nxge_use_hw_property = 1; 503859Sml29623 uint32_t nxge_groups_per_port = 2; 513859Sml29623 523859Sml29623 extern uint32_t nxge_use_partition; 533859Sml29623 extern uint32_t nxge_dma_obp_props_only; 543859Sml29623 553859Sml29623 extern uint16_t nxge_rcr_timeout; 563859Sml29623 extern uint16_t nxge_rcr_threshold; 573859Sml29623 583859Sml29623 extern uint_t nxge_rx_intr(void *, void *); 593859Sml29623 extern uint_t nxge_tx_intr(void *, void *); 603859Sml29623 extern uint_t nxge_mif_intr(void *, void *); 613859Sml29623 extern uint_t nxge_mac_intr(void *, void *); 623859Sml29623 extern uint_t nxge_syserr_intr(void *, void *); 633859Sml29623 extern void *nxge_list; 643859Sml29623 653859Sml29623 #define NXGE_SHARED_REG_SW_SIM 663859Sml29623 673859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 683859Sml29623 uint64_t global_dev_ctrl = 0; 693859Sml29623 #endif 703859Sml29623 713859Sml29623 #define MAX_SIBLINGS NXGE_MAX_PORTS 723859Sml29623 733859Sml29623 extern uint32_t nxge_rbr_size; 743859Sml29623 extern uint32_t nxge_rcr_size; 753859Sml29623 extern uint32_t nxge_tx_ring_size; 763859Sml29623 extern uint32_t nxge_rbr_spare_size; 773859Sml29623 783859Sml29623 extern npi_status_t npi_mac_altaddr_disable(npi_handle_t, uint8_t, uint8_t); 793859Sml29623 803859Sml29623 static uint8_t p2_tx_fair[2] = {12, 12}; 813859Sml29623 static uint8_t p2_tx_equal[2] = {12, 12}; 823859Sml29623 static uint8_t p4_tx_fair[4] = {6, 6, 6, 6}; 833859Sml29623 static uint8_t p4_tx_equal[4] = {6, 6, 6, 6}; 843859Sml29623 static uint8_t p2_rx_fair[2] = {8, 8}; 853859Sml29623 static uint8_t p2_rx_equal[2] = {8, 8}; 863859Sml29623 873859Sml29623 static uint8_t p4_rx_fair[4] = {4, 4, 4, 4}; 883859Sml29623 static uint8_t p4_rx_equal[4] = {4, 4, 4, 4}; 893859Sml29623 903859Sml29623 static uint8_t p2_rdcgrp_fair[2] = {4, 4}; 913859Sml29623 static uint8_t p2_rdcgrp_equal[2] = {4, 4}; 923859Sml29623 static uint8_t p4_rdcgrp_fair[4] = {2, 2, 1, 1}; 933859Sml29623 static uint8_t p4_rdcgrp_equal[4] = {2, 2, 2, 2}; 943859Sml29623 static uint8_t p2_rdcgrp_cls[2] = {1, 1}; 953859Sml29623 static uint8_t p4_rdcgrp_cls[4] = {1, 1, 1, 1}; 963859Sml29623 973859Sml29623 typedef enum { 983859Sml29623 DEFAULT = 0, 993859Sml29623 EQUAL, 1003859Sml29623 FAIR, 1013859Sml29623 CUSTOM, 1023859Sml29623 CLASSIFY, 1033859Sml29623 L2_CLASSIFY, 1043859Sml29623 L3_DISTRIBUTE, 1053859Sml29623 L3_CLASSIFY, 1063859Sml29623 L3_TCAM, 1073859Sml29623 CONFIG_TOKEN_NONE 1083859Sml29623 } config_token_t; 1093859Sml29623 1103859Sml29623 static char *token_names[] = { 1113859Sml29623 "default", 1123859Sml29623 "equal", 1133859Sml29623 "fair", 1143859Sml29623 "custom", 1153859Sml29623 "classify", 1163859Sml29623 "l2_classify", 1173859Sml29623 "l3_distribute", 1183859Sml29623 "l3_classify", 1193859Sml29623 "l3_tcam", 1203859Sml29623 "none", 1213859Sml29623 }; 1223859Sml29623 1233859Sml29623 void nxge_virint_regs_dump(p_nxge_t nxgep); 1243859Sml29623 1253859Sml29623 void 1263859Sml29623 nxge_virint_regs_dump(p_nxge_t nxgep) 1273859Sml29623 { 1283859Sml29623 npi_handle_t handle; 1293859Sml29623 1303859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_virint_regs_dump")); 1313859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 1323859Sml29623 (void) npi_vir_dump_pio_fzc_regs_one(handle); 1333859Sml29623 (void) npi_vir_dump_ldgnum(handle); 1343859Sml29623 (void) npi_vir_dump_ldsv(handle); 1353859Sml29623 (void) npi_vir_dump_imask0(handle); 1363859Sml29623 (void) npi_vir_dump_sid(handle); 1373859Sml29623 (void) npi_mac_dump_regs(handle, nxgep->function_num); 1383859Sml29623 (void) npi_ipp_dump_regs(handle, nxgep->function_num); 1393859Sml29623 (void) npi_fflp_dump_regs(handle); 1403859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_virint_regs_dump")); 1413859Sml29623 } 1423859Sml29623 1433859Sml29623 /* 1443859Sml29623 * For now: we hard coded the DMA configurations. 1453859Sml29623 * and assume for one partition only. 1463859Sml29623 * 1473859Sml29623 * OBP. Then OBP will pass this partition's 1483859Sml29623 * Neptune configurations to fcode to create 1493859Sml29623 * properties for them. 1503859Sml29623 * 1513859Sml29623 * Since Neptune(PCI-E) and NIU (Niagara-2) has 1523859Sml29623 * different bus interfaces, the driver needs 1533859Sml29623 * to know which bus it is connected to. 1543859Sml29623 * Ravinder suggested: create a device property. 1553859Sml29623 * In partitioning environment, we cannot 1563859Sml29623 * use .conf file (need to check). If conf changes, 1573859Sml29623 * need to reboot the system. 1583859Sml29623 * The following function assumes that we will 1593859Sml29623 * retrieve its properties from a virtualized nexus driver. 1603859Sml29623 */ 1613859Sml29623 1623859Sml29623 nxge_status_t 1633859Sml29623 nxge_cntlops(dev_info_t *dip, nxge_ctl_enum_t ctlop, void *arg, void *result) 1643859Sml29623 { 1653859Sml29623 nxge_status_t status = NXGE_OK; 1663859Sml29623 int instance; 1673859Sml29623 p_nxge_t nxgep; 1683859Sml29623 1693859Sml29623 #ifndef NXGE_SHARED_REG_SW_SIM 1703859Sml29623 npi_handle_t handle; 1713859Sml29623 uint16_t sr16, cr16; 1723859Sml29623 #endif 1733859Sml29623 instance = ddi_get_instance(dip); 1743859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, "Instance %d ", instance)); 1753859Sml29623 1763859Sml29623 if (nxge_list == NULL) { 1773859Sml29623 NXGE_ERROR_MSG((NULL, NXGE_ERR_CTL, 1783859Sml29623 "nxge_cntlops: nxge_list null")); 1793859Sml29623 return (NXGE_ERROR); 1803859Sml29623 } 1813859Sml29623 nxgep = (p_nxge_t)ddi_get_soft_state(nxge_list, instance); 1823859Sml29623 if (nxgep == NULL) { 1833859Sml29623 NXGE_ERROR_MSG((NULL, NXGE_ERR_CTL, 1843859Sml29623 "nxge_cntlops: nxgep null")); 1853859Sml29623 return (NXGE_ERROR); 1863859Sml29623 } 1873859Sml29623 #ifndef NXGE_SHARED_REG_SW_SIM 1883859Sml29623 handle = nxgep->npi_reg_handle; 1893859Sml29623 #endif 1903859Sml29623 switch (ctlop) { 1913859Sml29623 case NXGE_CTLOPS_NIUTYPE: 1923859Sml29623 nxge_get_niu_property(dip, (niu_type_t *)result); 1933859Sml29623 return (status); 1943859Sml29623 1953859Sml29623 case NXGE_CTLOPS_GET_SHARED_REG: 1963859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 1973859Sml29623 *(uint64_t *)result = global_dev_ctrl; 1983859Sml29623 return (0); 1993859Sml29623 #else 2003859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2013859Sml29623 *(uint16_t *)result = sr16; 2023859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2033859Sml29623 "nxge_cntlops: NXGE_CTLOPS_GET_SHARED_REG")); 2043859Sml29623 return (0); 2053859Sml29623 #endif 2063859Sml29623 2073859Sml29623 case NXGE_CTLOPS_SET_SHARED_REG_LOCK: 2083859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2093859Sml29623 global_dev_ctrl = *(uint64_t *)arg; 2103859Sml29623 return (0); 2113859Sml29623 #else 2123859Sml29623 status = NPI_FAILURE; 2133859Sml29623 while (status != NPI_SUCCESS) 2143859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2153859Sml29623 2163859Sml29623 sr16 = *(uint16_t *)arg; 2173859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2183859Sml29623 status = npi_dev_func_sr_lock_free(handle); 2193859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2203859Sml29623 "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2213859Sml29623 return (0); 2223859Sml29623 #endif 2233859Sml29623 2243859Sml29623 case NXGE_CTLOPS_UPDATE_SHARED_REG: 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 status = npi_dev_func_sr_sr_get(handle, &sr16); 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, 2373859Sml29623 "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2383859Sml29623 return (0); 2393859Sml29623 #endif 2403859Sml29623 2413859Sml29623 case NXGE_CTLOPS_CLEAR_BIT_SHARED_REG_UL: 2423859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2433859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2443859Sml29623 return (0); 2453859Sml29623 #else 2463859Sml29623 status = npi_dev_func_sr_sr_get(handle, &sr16); 2473859Sml29623 cr16 = *(uint16_t *)arg; 2483859Sml29623 sr16 &= ~cr16; 2493859Sml29623 status = npi_dev_func_sr_sr_set_only(handle, &sr16); 2503859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2513859Sml29623 "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2523859Sml29623 return (0); 2533859Sml29623 #endif 2543859Sml29623 2553859Sml29623 case NXGE_CTLOPS_CLEAR_BIT_SHARED_REG: 2563859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2573859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2583859Sml29623 return (0); 2593859Sml29623 #else 2603859Sml29623 status = NPI_FAILURE; 2613859Sml29623 while (status != NPI_SUCCESS) 2623859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 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 status = npi_dev_func_sr_lock_free(handle); 2683859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2693859Sml29623 "nxge_cntlops: NXGE_CTLOPS_SET_SHARED_REG")); 2703859Sml29623 return (0); 2713859Sml29623 #endif 2723859Sml29623 2733859Sml29623 case NXGE_CTLOPS_GET_LOCK_BLOCK: 2743859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2753859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2763859Sml29623 return (0); 2773859Sml29623 #else 2783859Sml29623 status = NPI_FAILURE; 2793859Sml29623 while (status != NPI_SUCCESS) 2803859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2813859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2823859Sml29623 "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_BLOCK")); 2833859Sml29623 return (0); 2843859Sml29623 #endif 2853859Sml29623 case NXGE_CTLOPS_GET_LOCK_TRY: 2863859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 2873859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 2883859Sml29623 return (0); 2893859Sml29623 #else 2903859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 2913859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 2923859Sml29623 "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_TRY")); 2933859Sml29623 if (status == NPI_SUCCESS) 2943859Sml29623 return (NXGE_OK); 2953859Sml29623 else 2963859Sml29623 return (NXGE_ERROR); 2973859Sml29623 #endif 2983859Sml29623 case NXGE_CTLOPS_FREE_LOCK: 2993859Sml29623 #ifdef NXGE_SHARED_REG_SW_SIM 3003859Sml29623 global_dev_ctrl |= *(uint64_t *)arg; 3013859Sml29623 return (0); 3023859Sml29623 #else 3033859Sml29623 status = npi_dev_func_sr_lock_free(handle); 3043859Sml29623 NXGE_DEBUG_MSG((NULL, VIR_CTL, 3053859Sml29623 "nxge_cntlops: NXGE_CTLOPS_GET_LOCK_FREE")); 3063859Sml29623 if (status == NPI_SUCCESS) 3073859Sml29623 return (NXGE_OK); 3083859Sml29623 else 3093859Sml29623 return (NXGE_ERROR); 3103859Sml29623 #endif 3113859Sml29623 3123859Sml29623 default: 3133859Sml29623 status = NXGE_ERROR; 3143859Sml29623 } 3153859Sml29623 3163859Sml29623 return (status); 3173859Sml29623 } 3183859Sml29623 3193859Sml29623 void 3203859Sml29623 nxge_common_lock_get(p_nxge_t nxgep) 3213859Sml29623 { 3223859Sml29623 uint32_t status = NPI_FAILURE; 3233859Sml29623 npi_handle_t handle; 3243859Sml29623 3253859Sml29623 #if defined(NXGE_SHARE_REG_SW_SIM) 3263859Sml29623 return; 3273859Sml29623 #endif 3283859Sml29623 handle = nxgep->npi_reg_handle; 3293859Sml29623 while (status != NPI_SUCCESS) 3303859Sml29623 status = npi_dev_func_sr_lock_enter(handle); 3313859Sml29623 } 3323859Sml29623 3333859Sml29623 void 3343859Sml29623 nxge_common_lock_free(p_nxge_t nxgep) 3353859Sml29623 { 3363859Sml29623 npi_handle_t handle; 3373859Sml29623 3383859Sml29623 #if defined(NXGE_SHARE_REG_SW_SIM) 3393859Sml29623 return; 3403859Sml29623 #endif 3413859Sml29623 handle = nxgep->npi_reg_handle; 3423859Sml29623 (void) npi_dev_func_sr_lock_free(handle); 3433859Sml29623 } 3443859Sml29623 345*4185Sspeer 3463859Sml29623 static void 3473859Sml29623 nxge_get_niu_property(dev_info_t *dip, niu_type_t *niu_type) 3483859Sml29623 { 3493859Sml29623 uchar_t *prop_val; 3503859Sml29623 uint_t prop_len; 3513859Sml29623 3523859Sml29623 *niu_type = NEPTUNE; 3533859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, 3543859Sml29623 "niu-type", (uchar_t **)&prop_val, 3553859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 3563859Sml29623 if (strncmp("niu", (caddr_t)prop_val, (size_t)prop_len) == 0) { 3573859Sml29623 *niu_type = N2_NIU; 3583859Sml29623 } 3593859Sml29623 ddi_prop_free(prop_val); 3603859Sml29623 } 3613859Sml29623 } 3623859Sml29623 3633859Sml29623 static config_token_t 3643859Sml29623 nxge_get_config_token(char *prop) 3653859Sml29623 { 3663859Sml29623 config_token_t token = DEFAULT; 3673859Sml29623 3683859Sml29623 while (token < CONFIG_TOKEN_NONE) { 3693859Sml29623 if (strncmp(prop, token_names[token], 4) == 0) 3703859Sml29623 break; 3713859Sml29623 token++; 3723859Sml29623 } 3733859Sml29623 return (token); 3743859Sml29623 } 3753859Sml29623 3763859Sml29623 /* per port */ 3773859Sml29623 3783859Sml29623 static nxge_status_t 3793859Sml29623 nxge_update_rxdma_grp_properties(p_nxge_t nxgep, config_token_t token, 3803859Sml29623 dev_info_t *s_dip[]) 3813859Sml29623 { 3823859Sml29623 nxge_status_t status = NXGE_OK; 3833859Sml29623 int ddi_status; 3843859Sml29623 int num_ports = nxgep->nports; 3853859Sml29623 int port, bits, j; 3863859Sml29623 uint8_t start_grp = 0, num_grps = 0; 3873859Sml29623 p_nxge_param_t param_arr; 3883859Sml29623 uint32_t grp_bitmap[MAX_SIBLINGS]; 3893859Sml29623 int custom_start_grp[MAX_SIBLINGS]; 3903859Sml29623 int custom_num_grp[MAX_SIBLINGS]; 3913859Sml29623 uint8_t bad_config = B_FALSE; 3923859Sml29623 char *start_prop, *num_prop, *cfg_prop; 3933859Sml29623 3943859Sml29623 start_grp = 0; 3953859Sml29623 param_arr = nxgep->param_arr; 3963859Sml29623 start_prop = param_arr[param_rdc_grps_start].fcode_name; 3973859Sml29623 num_prop = param_arr[param_rx_rdc_grps].fcode_name; 3983859Sml29623 3993859Sml29623 switch (token) { 4003859Sml29623 case FAIR: 4013859Sml29623 cfg_prop = "fair"; 4023859Sml29623 for (port = 0; port < num_ports; port++) { 4033859Sml29623 custom_num_grp[port] = 4043859Sml29623 (num_ports == 4) ? 4053859Sml29623 p4_rdcgrp_fair[port] : 4063859Sml29623 p2_rdcgrp_fair[port]; 4073859Sml29623 custom_start_grp[port] = start_grp; 4083859Sml29623 start_grp += custom_num_grp[port]; 4093859Sml29623 } 4103859Sml29623 break; 4113859Sml29623 4123859Sml29623 case EQUAL: 4133859Sml29623 cfg_prop = "equal"; 4143859Sml29623 for (port = 0; port < num_ports; port++) { 4153859Sml29623 custom_num_grp[port] = 4163859Sml29623 (num_ports == 4) ? 4173859Sml29623 p4_rdcgrp_equal[port] : 4183859Sml29623 p2_rdcgrp_equal[port]; 4193859Sml29623 custom_start_grp[port] = start_grp; 4203859Sml29623 start_grp += custom_num_grp[port]; 4213859Sml29623 } 4223859Sml29623 break; 4233859Sml29623 4243859Sml29623 4253859Sml29623 case CLASSIFY: 4263859Sml29623 cfg_prop = "classify"; 4273859Sml29623 for (port = 0; port < num_ports; port++) { 4283859Sml29623 custom_num_grp[port] = (num_ports == 4) ? 4293859Sml29623 p4_rdcgrp_cls[port] : p2_rdcgrp_cls[port]; 4303859Sml29623 custom_start_grp[port] = start_grp; 4313859Sml29623 start_grp += custom_num_grp[port]; 4323859Sml29623 } 4333859Sml29623 break; 4343859Sml29623 4353859Sml29623 case CUSTOM: 4363859Sml29623 cfg_prop = "custom"; 4373859Sml29623 /* See if it is good config */ 4383859Sml29623 num_grps = 0; 4393859Sml29623 for (port = 0; port < num_ports; port++) { 4403859Sml29623 custom_start_grp[port] = 4413859Sml29623 ddi_prop_get_int(DDI_DEV_T_NONE, s_dip[port], 4423859Sml29623 DDI_PROP_DONTPASS, start_prop, -1); 4433859Sml29623 if ((custom_start_grp[port] == -1) || 4443859Sml29623 (custom_start_grp[port] >= 4453859Sml29623 NXGE_MAX_RDC_GRPS)) { 4463859Sml29623 bad_config = B_TRUE; 4473859Sml29623 break; 4483859Sml29623 } 4493859Sml29623 custom_num_grp[port] = ddi_prop_get_int( 4503859Sml29623 DDI_DEV_T_NONE, 4513859Sml29623 s_dip[port], 4523859Sml29623 DDI_PROP_DONTPASS, 4533859Sml29623 num_prop, -1); 4543859Sml29623 4553859Sml29623 if ((custom_num_grp[port] == -1) || 4563859Sml29623 (custom_num_grp[port] > 4573859Sml29623 NXGE_MAX_RDC_GRPS) || 4583859Sml29623 ((custom_num_grp[port] + 4593859Sml29623 custom_start_grp[port]) >= 4603859Sml29623 NXGE_MAX_RDC_GRPS)) { 4613859Sml29623 bad_config = B_TRUE; 4623859Sml29623 break; 4633859Sml29623 } 4643859Sml29623 num_grps += custom_num_grp[port]; 4653859Sml29623 if (num_grps > NXGE_MAX_RDC_GRPS) { 4663859Sml29623 bad_config = B_TRUE; 4673859Sml29623 break; 4683859Sml29623 } 4693859Sml29623 grp_bitmap[port] = 0; 4703859Sml29623 for (bits = 0; 4713859Sml29623 bits < custom_num_grp[port]; 4723859Sml29623 bits++) { 4733859Sml29623 grp_bitmap[port] |= 4743859Sml29623 (1 << (bits + custom_start_grp[port])); 4753859Sml29623 } 4763859Sml29623 4773859Sml29623 } 4783859Sml29623 4793859Sml29623 if (bad_config == B_FALSE) { 4803859Sml29623 /* check for overlap */ 4813859Sml29623 for (port = 0; port < num_ports - 1; port++) { 4823859Sml29623 for (j = port + 1; j < num_ports; j++) { 4833859Sml29623 if (grp_bitmap[port] & 4843859Sml29623 grp_bitmap[j]) { 4853859Sml29623 bad_config = B_TRUE; 4863859Sml29623 break; 4873859Sml29623 } 4883859Sml29623 } 4893859Sml29623 if (bad_config == B_TRUE) 4903859Sml29623 break; 4913859Sml29623 } 4923859Sml29623 } 4933859Sml29623 if (bad_config == B_TRUE) { 4943859Sml29623 /* use default config */ 4953859Sml29623 for (port = 0; port < num_ports; port++) { 4963859Sml29623 custom_num_grp[port] = 4973859Sml29623 (num_ports == 4) ? 4983859Sml29623 p4_rx_fair[port] : p2_rx_fair[port]; 4993859Sml29623 custom_start_grp[port] = start_grp; 5003859Sml29623 start_grp += custom_num_grp[port]; 5013859Sml29623 } 5023859Sml29623 } 5033859Sml29623 break; 5043859Sml29623 5053859Sml29623 default: 5063859Sml29623 /* use default config */ 5073859Sml29623 cfg_prop = "fair"; 5083859Sml29623 for (port = 0; port < num_ports; port++) { 5093859Sml29623 custom_num_grp[port] = (num_ports == 4) ? 5103859Sml29623 p4_rx_fair[port] : p2_rx_fair[port]; 5113859Sml29623 custom_start_grp[port] = start_grp; 5123859Sml29623 start_grp += custom_num_grp[port]; 5133859Sml29623 } 5143859Sml29623 break; 5153859Sml29623 } 5163859Sml29623 5173859Sml29623 /* Now Update the rx properties */ 5183859Sml29623 for (port = 0; port < num_ports; port++) { 5193859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 5203859Sml29623 "rxdma-grp-cfg", cfg_prop); 5213859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5223859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5233859Sml29623 " property %s not updating", 5243859Sml29623 cfg_prop)); 5253859Sml29623 status |= NXGE_DDI_FAILED; 5263859Sml29623 } 5273859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 5283859Sml29623 num_prop, custom_num_grp[port]); 5293859Sml29623 5303859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5313859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5323859Sml29623 " property %s not updating", 5333859Sml29623 num_prop)); 5343859Sml29623 status |= NXGE_DDI_FAILED; 5353859Sml29623 } 5363859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 5373859Sml29623 start_prop, custom_start_grp[port]); 5383859Sml29623 5393859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 5403859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5413859Sml29623 " property %s not updating", 5423859Sml29623 start_prop)); 5433859Sml29623 status |= NXGE_DDI_FAILED; 5443859Sml29623 } 5453859Sml29623 } 5463859Sml29623 if (status & NXGE_DDI_FAILED) 5473859Sml29623 status |= NXGE_ERROR; 5483859Sml29623 5493859Sml29623 return (status); 5503859Sml29623 } 5513859Sml29623 5523859Sml29623 static nxge_status_t 5533859Sml29623 nxge_update_rxdma_properties(p_nxge_t nxgep, config_token_t token, 5543859Sml29623 dev_info_t *s_dip[]) 5553859Sml29623 { 5563859Sml29623 nxge_status_t status = NXGE_OK; 5573859Sml29623 int ddi_status; 5583859Sml29623 int num_ports = nxgep->nports; 5593859Sml29623 int port, bits, j; 5603859Sml29623 uint8_t start_rdc = 0, num_rdc = 0; 5613859Sml29623 p_nxge_param_t param_arr; 5623859Sml29623 uint32_t rdc_bitmap[MAX_SIBLINGS]; 5633859Sml29623 int custom_start_rdc[MAX_SIBLINGS]; 5643859Sml29623 int custom_num_rdc[MAX_SIBLINGS]; 5653859Sml29623 uint8_t bad_config = B_FALSE; 5663859Sml29623 int *prop_val; 5673859Sml29623 uint_t prop_len; 5683859Sml29623 char *start_rdc_prop, *num_rdc_prop, *cfg_prop; 5693859Sml29623 5703859Sml29623 start_rdc = 0; 5713859Sml29623 param_arr = nxgep->param_arr; 5723859Sml29623 start_rdc_prop = param_arr[param_rxdma_channels_begin].fcode_name; 5733859Sml29623 num_rdc_prop = param_arr[param_rxdma_channels].fcode_name; 5743859Sml29623 5753859Sml29623 switch (token) { 5763859Sml29623 case FAIR: 5773859Sml29623 cfg_prop = "fair"; 5783859Sml29623 for (port = 0; port < num_ports; port++) { 5793859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 5803859Sml29623 p4_rx_fair[port] : p2_rx_fair[port]; 5813859Sml29623 custom_start_rdc[port] = start_rdc; 5823859Sml29623 start_rdc += custom_num_rdc[port]; 5833859Sml29623 } 5843859Sml29623 break; 5853859Sml29623 5863859Sml29623 case EQUAL: 5873859Sml29623 cfg_prop = "equal"; 5883859Sml29623 for (port = 0; port < num_ports; port++) { 5893859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 5903859Sml29623 p4_rx_equal[port] : 5913859Sml29623 p2_rx_equal[port]; 5923859Sml29623 custom_start_rdc[port] = start_rdc; 5933859Sml29623 start_rdc += custom_num_rdc[port]; 5943859Sml29623 } 5953859Sml29623 break; 5963859Sml29623 5973859Sml29623 case CUSTOM: 5983859Sml29623 cfg_prop = "custom"; 5993859Sml29623 /* See if it is good config */ 6003859Sml29623 num_rdc = 0; 6013859Sml29623 for (port = 0; port < num_ports; port++) { 6023859Sml29623 ddi_status = ddi_prop_lookup_int_array( 6033859Sml29623 DDI_DEV_T_ANY, 6043859Sml29623 s_dip[port], 0, 6053859Sml29623 start_rdc_prop, 6063859Sml29623 &prop_val, 6073859Sml29623 &prop_len); 6083859Sml29623 if (ddi_status == DDI_SUCCESS) 6093859Sml29623 custom_start_rdc[port] = *prop_val; 6103859Sml29623 else { 6113859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6123859Sml29623 " %s custom start port %d" 6133859Sml29623 " read failed ", 6143859Sml29623 " rxdma-cfg", port)); 6153859Sml29623 bad_config = B_TRUE; 6163859Sml29623 status |= NXGE_DDI_FAILED; 6173859Sml29623 } 6183859Sml29623 if ((custom_start_rdc[port] == -1) || 6193859Sml29623 (custom_start_rdc[port] >= 6203859Sml29623 NXGE_MAX_RDCS)) { 6213859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6223859Sml29623 " %s custom start %d" 6233859Sml29623 " out of range %x ", 6243859Sml29623 " rxdma-cfg", 6253859Sml29623 port, 6263859Sml29623 custom_start_rdc[port])); 6273859Sml29623 bad_config = B_TRUE; 6283859Sml29623 break; 6293859Sml29623 } 6303859Sml29623 ddi_status = ddi_prop_lookup_int_array( 6313859Sml29623 DDI_DEV_T_ANY, 6323859Sml29623 s_dip[port], 6333859Sml29623 0, 6343859Sml29623 num_rdc_prop, 6353859Sml29623 &prop_val, 6363859Sml29623 &prop_len); 6373859Sml29623 6383859Sml29623 if (ddi_status == DDI_SUCCESS) 6393859Sml29623 custom_num_rdc[port] = *prop_val; 6403859Sml29623 else { 6413859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6423859Sml29623 " %s custom num port %d" 6433859Sml29623 " read failed ", 6443859Sml29623 "rxdma-cfg", port)); 6453859Sml29623 bad_config = B_TRUE; 6463859Sml29623 status |= NXGE_DDI_FAILED; 6473859Sml29623 } 6483859Sml29623 6493859Sml29623 if ((custom_num_rdc[port] == -1) || 6503859Sml29623 (custom_num_rdc[port] > 6513859Sml29623 NXGE_MAX_RDCS) || 6523859Sml29623 ((custom_num_rdc[port] + 6533859Sml29623 custom_start_rdc[port]) > 6543859Sml29623 NXGE_MAX_RDCS)) { 6553859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 6563859Sml29623 " %s custom num %d" 6573859Sml29623 " out of range %x ", 6583859Sml29623 " rxdma-cfg", 6593859Sml29623 port, custom_num_rdc[port])); 6603859Sml29623 bad_config = B_TRUE; 6613859Sml29623 break; 6623859Sml29623 } 6633859Sml29623 num_rdc += custom_num_rdc[port]; 6643859Sml29623 if (num_rdc > NXGE_MAX_RDCS) { 6653859Sml29623 bad_config = B_TRUE; 6663859Sml29623 break; 6673859Sml29623 } 6683859Sml29623 rdc_bitmap[port] = 0; 6693859Sml29623 for (bits = 0; 6703859Sml29623 bits < custom_num_rdc[port]; bits++) { 6713859Sml29623 rdc_bitmap[port] |= 6723859Sml29623 (1 << (bits + custom_start_rdc[port])); 6733859Sml29623 } 6743859Sml29623 } 6753859Sml29623 6763859Sml29623 if (bad_config == B_FALSE) { 6773859Sml29623 /* check for overlap */ 6783859Sml29623 for (port = 0; port < num_ports - 1; port++) { 6793859Sml29623 for (j = port + 1; j < num_ports; j++) { 6803859Sml29623 if (rdc_bitmap[port] & 6813859Sml29623 rdc_bitmap[j]) { 6823859Sml29623 NXGE_DEBUG_MSG((nxgep, 6833859Sml29623 CFG_CTL, 6843859Sml29623 " rxdma-cfg" 6853859Sml29623 " property custom" 6863859Sml29623 " bit overlap" 6873859Sml29623 " %d %d ", 6883859Sml29623 port, j)); 6893859Sml29623 bad_config = B_TRUE; 6903859Sml29623 break; 6913859Sml29623 } 6923859Sml29623 } 6933859Sml29623 if (bad_config == B_TRUE) 6943859Sml29623 break; 6953859Sml29623 } 6963859Sml29623 } 6973859Sml29623 if (bad_config == B_TRUE) { 6983859Sml29623 /* use default config */ 6993859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7003859Sml29623 " rxdma-cfg property:" 7013859Sml29623 " bad custom config:" 7023859Sml29623 " use default")); 7033859Sml29623 for (port = 0; port < num_ports; port++) { 7043859Sml29623 custom_num_rdc[port] = 7053859Sml29623 (num_ports == 4) ? 7063859Sml29623 p4_rx_fair[port] : 7073859Sml29623 p2_rx_fair[port]; 7083859Sml29623 custom_start_rdc[port] = start_rdc; 7093859Sml29623 start_rdc += custom_num_rdc[port]; 7103859Sml29623 } 7113859Sml29623 } 7123859Sml29623 break; 7133859Sml29623 7143859Sml29623 default: 7153859Sml29623 /* use default config */ 7163859Sml29623 cfg_prop = "fair"; 7173859Sml29623 for (port = 0; port < num_ports; port++) { 7183859Sml29623 custom_num_rdc[port] = (num_ports == 4) ? 7193859Sml29623 p4_rx_fair[port] : p2_rx_fair[port]; 7203859Sml29623 custom_start_rdc[port] = start_rdc; 7213859Sml29623 start_rdc += custom_num_rdc[port]; 7223859Sml29623 } 7233859Sml29623 break; 7243859Sml29623 } 7253859Sml29623 7263859Sml29623 /* Now Update the rx properties */ 7273859Sml29623 for (port = 0; port < num_ports; port++) { 7283859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7293859Sml29623 " update property rxdma-cfg with %s ", cfg_prop)); 7303859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 7313859Sml29623 "rxdma-cfg", cfg_prop); 7323859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7333859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 7343859Sml29623 " property rxdma-cfg is not updating to %s", 7353859Sml29623 cfg_prop)); 7363859Sml29623 status |= NXGE_DDI_FAILED; 7373859Sml29623 } 7383859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 7393859Sml29623 num_rdc_prop, custom_num_rdc[port])); 7403859Sml29623 7413859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 7423859Sml29623 num_rdc_prop, custom_num_rdc[port]); 7433859Sml29623 7443859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7453859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 7463859Sml29623 " property %s not updating with %d", 7473859Sml29623 num_rdc_prop, custom_num_rdc[port])); 7483859Sml29623 status |= NXGE_DDI_FAILED; 7493859Sml29623 } 7503859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 7513859Sml29623 start_rdc_prop, custom_start_rdc[port])); 7523859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 7533859Sml29623 start_rdc_prop, custom_start_rdc[port]); 7543859Sml29623 7553859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 7563859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 7573859Sml29623 " property %s not updating with %d ", 7583859Sml29623 start_rdc_prop, custom_start_rdc[port])); 7593859Sml29623 status |= NXGE_DDI_FAILED; 7603859Sml29623 } 7613859Sml29623 } 7623859Sml29623 if (status & NXGE_DDI_FAILED) 7633859Sml29623 status |= NXGE_ERROR; 7643859Sml29623 return (status); 7653859Sml29623 } 7663859Sml29623 7673859Sml29623 static nxge_status_t 7683859Sml29623 nxge_update_txdma_properties(p_nxge_t nxgep, config_token_t token, 7693859Sml29623 dev_info_t *s_dip[]) 7703859Sml29623 { 7713859Sml29623 nxge_status_t status = NXGE_OK; 7723859Sml29623 int ddi_status = DDI_SUCCESS; 7733859Sml29623 int num_ports = nxgep->nports; 7743859Sml29623 int port, bits, j; 7753859Sml29623 uint8_t start_tdc = 0, num_tdc = 0; 7763859Sml29623 p_nxge_param_t param_arr; 7773859Sml29623 uint32_t tdc_bitmap[MAX_SIBLINGS]; 7783859Sml29623 int custom_start_tdc[MAX_SIBLINGS]; 7793859Sml29623 int custom_num_tdc[MAX_SIBLINGS]; 7803859Sml29623 uint8_t bad_config = B_FALSE; 7813859Sml29623 int *prop_val; 7823859Sml29623 uint_t prop_len; 7833859Sml29623 char *start_tdc_prop, *num_tdc_prop, *cfg_prop; 7843859Sml29623 7853859Sml29623 start_tdc = 0; 7863859Sml29623 param_arr = nxgep->param_arr; 7873859Sml29623 start_tdc_prop = param_arr[param_txdma_channels_begin].fcode_name; 7883859Sml29623 num_tdc_prop = param_arr[param_txdma_channels].fcode_name; 7893859Sml29623 7903859Sml29623 switch (token) { 7913859Sml29623 case FAIR: 7923859Sml29623 cfg_prop = "fair"; 7933859Sml29623 for (port = 0; port < num_ports; port++) { 7943859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 7953859Sml29623 p4_tx_fair[port] : p2_tx_fair[port]; 7963859Sml29623 custom_start_tdc[port] = start_tdc; 7973859Sml29623 start_tdc += custom_num_tdc[port]; 7983859Sml29623 } 7993859Sml29623 break; 8003859Sml29623 8013859Sml29623 case EQUAL: 8023859Sml29623 cfg_prop = "equal"; 8033859Sml29623 for (port = 0; port < num_ports; port++) { 8043859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 8053859Sml29623 p4_tx_equal[port] : p2_tx_equal[port]; 8063859Sml29623 custom_start_tdc[port] = start_tdc; 8073859Sml29623 start_tdc += custom_num_tdc[port]; 8083859Sml29623 } 8093859Sml29623 break; 8103859Sml29623 8113859Sml29623 case CUSTOM: 8123859Sml29623 cfg_prop = "custom"; 8133859Sml29623 /* See if it is good config */ 8143859Sml29623 num_tdc = 0; 8153859Sml29623 for (port = 0; port < num_ports; port++) { 8163859Sml29623 ddi_status = ddi_prop_lookup_int_array( 8173859Sml29623 DDI_DEV_T_ANY, s_dip[port], 0, start_tdc_prop, 8183859Sml29623 &prop_val, &prop_len); 8193859Sml29623 if (ddi_status == DDI_SUCCESS) 8203859Sml29623 custom_start_tdc[port] = *prop_val; 8213859Sml29623 else { 8223859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8233859Sml29623 " %s custom start port %d" 8243859Sml29623 " read failed ", " txdma-cfg", port)); 8253859Sml29623 bad_config = B_TRUE; 8263859Sml29623 status |= NXGE_DDI_FAILED; 8273859Sml29623 } 8283859Sml29623 8293859Sml29623 if ((custom_start_tdc[port] == -1) || 8303859Sml29623 (custom_start_tdc[port] >= 8313859Sml29623 NXGE_MAX_RDCS)) { 8323859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8333859Sml29623 " %s custom start %d" 8343859Sml29623 " out of range %x ", " txdma-cfg", 8353859Sml29623 port, custom_start_tdc[port])); 8363859Sml29623 bad_config = B_TRUE; 8373859Sml29623 break; 8383859Sml29623 } 8393859Sml29623 8403859Sml29623 ddi_status = ddi_prop_lookup_int_array( 8413859Sml29623 DDI_DEV_T_ANY, s_dip[port], 0, num_tdc_prop, 8423859Sml29623 &prop_val, &prop_len); 8433859Sml29623 if (ddi_status == DDI_SUCCESS) 8443859Sml29623 custom_num_tdc[port] = *prop_val; 8453859Sml29623 else { 8463859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8473859Sml29623 " %s custom num port %d" 8483859Sml29623 " read failed ", " txdma-cfg", port)); 8493859Sml29623 bad_config = B_TRUE; 8503859Sml29623 status |= NXGE_DDI_FAILED; 8513859Sml29623 } 8523859Sml29623 8533859Sml29623 if ((custom_num_tdc[port] == -1) || 8543859Sml29623 (custom_num_tdc[port] > 8553859Sml29623 NXGE_MAX_TDCS) || 8563859Sml29623 ((custom_num_tdc[port] + 8573859Sml29623 custom_start_tdc[port]) > 8583859Sml29623 NXGE_MAX_TDCS)) { 8593859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8603859Sml29623 " %s custom num %d" 8613859Sml29623 " out of range %x ", " rxdma-cfg", 8623859Sml29623 port, custom_num_tdc[port])); 8633859Sml29623 bad_config = B_TRUE; 8643859Sml29623 break; 8653859Sml29623 } 8663859Sml29623 num_tdc += custom_num_tdc[port]; 8673859Sml29623 if (num_tdc > NXGE_MAX_TDCS) { 8683859Sml29623 bad_config = B_TRUE; 8693859Sml29623 break; 8703859Sml29623 } 8713859Sml29623 tdc_bitmap[port] = 0; 8723859Sml29623 for (bits = 0; 8733859Sml29623 bits < custom_num_tdc[port]; bits++) { 8743859Sml29623 tdc_bitmap[port] |= 8753859Sml29623 (1 << 8763859Sml29623 (bits + custom_start_tdc[port])); 8773859Sml29623 } 8783859Sml29623 8793859Sml29623 } 8803859Sml29623 8813859Sml29623 if (bad_config == B_FALSE) { 8823859Sml29623 /* check for overlap */ 8833859Sml29623 for (port = 0; port < num_ports - 1; port++) { 8843859Sml29623 for (j = port + 1; j < num_ports; j++) { 8853859Sml29623 if (tdc_bitmap[port] & 8863859Sml29623 tdc_bitmap[j]) { 8873859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 8883859Sml29623 " rxdma-cfg" 8893859Sml29623 " property custom" 8903859Sml29623 " bit overlap" 8913859Sml29623 " %d %d ", 8923859Sml29623 port, j)); 8933859Sml29623 bad_config = B_TRUE; 8943859Sml29623 break; 8953859Sml29623 } 8963859Sml29623 } 8973859Sml29623 if (bad_config == B_TRUE) 8983859Sml29623 break; 8993859Sml29623 } 9003859Sml29623 } 9013859Sml29623 if (bad_config == B_TRUE) { 9023859Sml29623 /* use default config */ 9033859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9043859Sml29623 " txdma-cfg property:" 9053859Sml29623 " bad custom config:" " use default")); 9063859Sml29623 9073859Sml29623 for (port = 0; port < num_ports; port++) { 9083859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 9093859Sml29623 p4_tx_fair[port] : p2_tx_fair[port]; 9103859Sml29623 custom_start_tdc[port] = start_tdc; 9113859Sml29623 start_tdc += custom_num_tdc[port]; 9123859Sml29623 } 9133859Sml29623 } 9143859Sml29623 break; 9153859Sml29623 9163859Sml29623 default: 9173859Sml29623 /* use default config */ 9183859Sml29623 cfg_prop = "fair"; 9193859Sml29623 for (port = 0; port < num_ports; port++) { 9203859Sml29623 custom_num_tdc[port] = (num_ports == 4) ? 9213859Sml29623 p4_tx_fair[port] : p2_tx_fair[port]; 9223859Sml29623 custom_start_tdc[port] = start_tdc; 9233859Sml29623 start_tdc += custom_num_tdc[port]; 9243859Sml29623 } 9253859Sml29623 break; 9263859Sml29623 } 9273859Sml29623 9283859Sml29623 /* Now Update the tx properties */ 9293859Sml29623 for (port = 0; port < num_ports; port++) { 9303859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9313859Sml29623 " update property txdma-cfg with %s ", cfg_prop)); 9323859Sml29623 ddi_status = ddi_prop_update_string(DDI_DEV_T_NONE, s_dip[port], 9333859Sml29623 "txdma-cfg", cfg_prop); 9343859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9353859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 9363859Sml29623 " property txdma-cfg is not updating to %s", 9373859Sml29623 cfg_prop)); 9383859Sml29623 status |= NXGE_DDI_FAILED; 9393859Sml29623 } 9403859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 9413859Sml29623 num_tdc_prop, custom_num_tdc[port])); 9423859Sml29623 9433859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 9443859Sml29623 num_tdc_prop, custom_num_tdc[port]); 9453859Sml29623 9463859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9473859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 9483859Sml29623 " property %s not updating with %d", 9493859Sml29623 num_tdc_prop, 9503859Sml29623 custom_num_tdc[port])); 9513859Sml29623 status |= NXGE_DDI_FAILED; 9523859Sml29623 } 9533859Sml29623 9543859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " update property %s with %d ", 9553859Sml29623 start_tdc_prop, custom_start_tdc[port])); 9563859Sml29623 9573859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, s_dip[port], 9583859Sml29623 start_tdc_prop, custom_start_tdc[port]); 9593859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) { 9603859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 9613859Sml29623 " property %s not updating with %d ", 9623859Sml29623 start_tdc_prop, custom_start_tdc[port])); 9633859Sml29623 status |= NXGE_DDI_FAILED; 9643859Sml29623 } 9653859Sml29623 } 9663859Sml29623 if (status & NXGE_DDI_FAILED) 9673859Sml29623 status |= NXGE_ERROR; 9683859Sml29623 return (status); 9693859Sml29623 } 9703859Sml29623 9713859Sml29623 static nxge_status_t 9723859Sml29623 nxge_update_cfg_properties(p_nxge_t nxgep, uint32_t flags, 9733859Sml29623 config_token_t token, dev_info_t *s_dip[]) 9743859Sml29623 { 9753859Sml29623 nxge_status_t status = NXGE_OK; 9763859Sml29623 9773859Sml29623 switch (flags) { 9783859Sml29623 case COMMON_TXDMA_CFG: 9793859Sml29623 if (nxge_dma_obp_props_only == 0) 9803859Sml29623 status = nxge_update_txdma_properties(nxgep, 9813859Sml29623 token, s_dip); 9823859Sml29623 break; 9833859Sml29623 case COMMON_RXDMA_CFG: 9843859Sml29623 if (nxge_dma_obp_props_only == 0) 9853859Sml29623 status = nxge_update_rxdma_properties(nxgep, 9863859Sml29623 token, s_dip); 9873859Sml29623 9883859Sml29623 break; 9893859Sml29623 case COMMON_RXDMA_GRP_CFG: 9903859Sml29623 status = nxge_update_rxdma_grp_properties(nxgep, 9913859Sml29623 token, s_dip); 9923859Sml29623 break; 9933859Sml29623 default: 9943859Sml29623 return (NXGE_ERROR); 9953859Sml29623 } 9963859Sml29623 return (status); 9973859Sml29623 } 9983859Sml29623 9993859Sml29623 /* 10003859Sml29623 * verify consistence. 10013859Sml29623 * (May require publishing the properties on all the ports. 10023859Sml29623 * 10033859Sml29623 * What if properties are published on function 0 device only? 10043859Sml29623 * 10053859Sml29623 * 10063859Sml29623 * rxdma-cfg, txdma-cfg, rxdma-grp-cfg (required ) 10073859Sml29623 * What about class configs? 10083859Sml29623 * 10093859Sml29623 * If consistent, update the property on all the siblings. 10103859Sml29623 * set a flag on hardware shared register 10113859Sml29623 * The rest of the siblings will check the flag 10123859Sml29623 * if the flag is set, they will use the updated property 10133859Sml29623 * without doing any validation. 10143859Sml29623 */ 10153859Sml29623 10163859Sml29623 nxge_status_t 10173859Sml29623 nxge_cfg_verify_set_classify_prop(p_nxge_t nxgep, char *prop, 10183859Sml29623 uint64_t known_cfg, uint32_t override, dev_info_t *c_dip[]) 10193859Sml29623 { 10203859Sml29623 nxge_status_t status = NXGE_OK; 10213859Sml29623 int ddi_status = DDI_SUCCESS; 10223859Sml29623 int i = 0, found = 0, update_prop = B_TRUE; 10233859Sml29623 int *cfg_val; 10243859Sml29623 uint_t new_value, cfg_value[MAX_SIBLINGS]; 10253859Sml29623 uint_t prop_len; 10263859Sml29623 uint_t known_cfg_value; 10273859Sml29623 10283859Sml29623 known_cfg_value = (uint_t)known_cfg; 10293859Sml29623 10303859Sml29623 if (override == B_TRUE) { 10313859Sml29623 new_value = known_cfg_value; 10323859Sml29623 for (i = 0; i < nxgep->nports; i++) { 10333859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, 10343859Sml29623 c_dip[i], prop, new_value); 10353859Sml29623 #ifdef NXGE_DEBUG_ERROR 10363859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 10373859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 10383859Sml29623 " property %s failed update ", prop)); 10393859Sml29623 #endif 10403859Sml29623 } 10413859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 10423859Sml29623 return (NXGE_ERROR | NXGE_DDI_FAILED); 10433859Sml29623 } 10443859Sml29623 for (i = 0; i < nxgep->nports; i++) { 10453859Sml29623 cfg_value[i] = known_cfg_value; 10463859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, c_dip[i], 0, 10473859Sml29623 prop, &cfg_val, 10483859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 10493859Sml29623 cfg_value[i] = *cfg_val; 10503859Sml29623 ddi_prop_free(cfg_val); 10513859Sml29623 found++; 10523859Sml29623 } 10533859Sml29623 } 10543859Sml29623 10553859Sml29623 if (found != i) { 10563859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10573859Sml29623 " property %s not specified on all ports", prop)); 10583859Sml29623 if (found == 0) { 10593859Sml29623 /* not specified: Use default */ 10603859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10613859Sml29623 " property %s not specified on any port:" 10623859Sml29623 " Using default", prop)); 10633859Sml29623 new_value = known_cfg_value; 10643859Sml29623 } else { 10653859Sml29623 /* specified on some */ 10663859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10673859Sml29623 " property %s not specified" 10683859Sml29623 " on some ports: Using default", prop)); 10693859Sml29623 /* ? use p0 value instead ? */ 10703859Sml29623 new_value = known_cfg_value; 10713859Sml29623 } 10723859Sml29623 } else { 10733859Sml29623 /* check type and consistence */ 10743859Sml29623 /* found on all devices */ 10753859Sml29623 for (i = 1; i < found; i++) { 10763859Sml29623 if (cfg_value[i] != cfg_value[i - 1]) { 10773859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 10783859Sml29623 " property %s inconsistent:" 10793859Sml29623 " Using default", prop)); 10803859Sml29623 new_value = known_cfg_value; 10813859Sml29623 break; 10823859Sml29623 } 10833859Sml29623 /* 10843859Sml29623 * Found on all the ports and consistent. Nothing to 10853859Sml29623 * do. 10863859Sml29623 */ 10873859Sml29623 update_prop = B_FALSE; 10883859Sml29623 } 10893859Sml29623 } 10903859Sml29623 10913859Sml29623 if (update_prop == B_TRUE) { 10923859Sml29623 for (i = 0; i < nxgep->nports; i++) { 10933859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, 10943859Sml29623 c_dip[i], prop, new_value); 10953859Sml29623 #ifdef NXGE_DEBUG_ERROR 10963859Sml29623 if (ddi_status != DDI_SUCCESS) 10973859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 10983859Sml29623 " property %s not updating with %d" 10993859Sml29623 " Using default", 11003859Sml29623 prop, new_value)); 11013859Sml29623 #endif 11023859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 11033859Sml29623 status |= NXGE_DDI_FAILED; 11043859Sml29623 } 11053859Sml29623 } 11063859Sml29623 if (status & NXGE_DDI_FAILED) 11073859Sml29623 status |= NXGE_ERROR; 11083859Sml29623 11093859Sml29623 return (status); 11103859Sml29623 } 11113859Sml29623 11123859Sml29623 static uint64_t 11133859Sml29623 nxge_class_get_known_cfg(p_nxge_t nxgep, int class_prop, int rx_quick_cfg) 11143859Sml29623 { 11153859Sml29623 int start_prop; 11163859Sml29623 uint64_t cfg_value; 11173859Sml29623 p_nxge_param_t param_arr; 11183859Sml29623 11193859Sml29623 param_arr = nxgep->param_arr; 11203859Sml29623 cfg_value = param_arr[class_prop].value; 11213859Sml29623 start_prop = param_h1_init_value; 11223859Sml29623 11233859Sml29623 /* update the properties per quick config */ 11243859Sml29623 switch (rx_quick_cfg) { 11253859Sml29623 case CFG_L3_WEB: 11263859Sml29623 case CFG_L3_DISTRIBUTE: 11273859Sml29623 cfg_value = nxge_classify_get_cfg_value(nxgep, 11283859Sml29623 rx_quick_cfg, class_prop - start_prop); 11293859Sml29623 break; 11303859Sml29623 default: 11313859Sml29623 cfg_value = param_arr[class_prop].value; 11323859Sml29623 break; 11333859Sml29623 } 11343859Sml29623 return (cfg_value); 11353859Sml29623 } 11363859Sml29623 11373859Sml29623 static nxge_status_t 11383859Sml29623 nxge_cfg_verify_set_classify(p_nxge_t nxgep, dev_info_t *c_dip[]) 11393859Sml29623 { 11403859Sml29623 nxge_status_t status = NXGE_OK; 11413859Sml29623 int rx_quick_cfg, class_prop, start_prop, end_prop; 11423859Sml29623 char *prop_name; 11433859Sml29623 int override = B_TRUE; 11443859Sml29623 uint64_t cfg_value; 11453859Sml29623 p_nxge_param_t param_arr; 11463859Sml29623 11473859Sml29623 param_arr = nxgep->param_arr; 11483859Sml29623 rx_quick_cfg = param_arr[param_rx_quick_cfg].value; 11493859Sml29623 start_prop = param_h1_init_value; 11503859Sml29623 end_prop = param_class_opt_ipv6_sctp; 11513859Sml29623 11523859Sml29623 /* update the properties per quick config */ 11533859Sml29623 if (rx_quick_cfg == CFG_NOT_SPECIFIED) 11543859Sml29623 override = B_FALSE; 11553859Sml29623 11563859Sml29623 /* 11573859Sml29623 * these parameter affect the classification outcome. 11583859Sml29623 * these parameters are used to configure the Flow key and 11593859Sml29623 * the TCAM key for each of the IP classes. 11603859Sml29623 * Included here are also the H1 and H2 initial values 11613859Sml29623 * which affect the distribution as well as final hash value 11623859Sml29623 * (hence the offset into RDC table and FCRAM bucket location) 11633859Sml29623 * 11643859Sml29623 */ 11653859Sml29623 for (class_prop = start_prop; class_prop <= end_prop; class_prop++) { 11663859Sml29623 prop_name = param_arr[class_prop].fcode_name; 11673859Sml29623 cfg_value = nxge_class_get_known_cfg(nxgep, 11683859Sml29623 class_prop, rx_quick_cfg); 11693859Sml29623 status = nxge_cfg_verify_set_classify_prop(nxgep, prop_name, 11703859Sml29623 cfg_value, override, c_dip); 11713859Sml29623 } 11723859Sml29623 11733859Sml29623 /* 11743859Sml29623 * these properties do not affect the actual classification outcome. 11753859Sml29623 * used to enable/disable or tune the fflp hardware 11763859Sml29623 * 11773859Sml29623 * fcram_access_ratio, tcam_access_ratio, tcam_enable, llc_snap_enable 11783859Sml29623 * 11793859Sml29623 */ 11803859Sml29623 override = B_FALSE; 11813859Sml29623 for (class_prop = param_fcram_access_ratio; 11823859Sml29623 class_prop <= param_llc_snap_enable; class_prop++) { 11833859Sml29623 prop_name = param_arr[class_prop].fcode_name; 11843859Sml29623 cfg_value = param_arr[class_prop].value; 11853859Sml29623 status = nxge_cfg_verify_set_classify_prop(nxgep, prop_name, 11863859Sml29623 cfg_value, override, c_dip); 11873859Sml29623 } 11883859Sml29623 11893859Sml29623 return (status); 11903859Sml29623 } 11913859Sml29623 11923859Sml29623 nxge_status_t 11933859Sml29623 nxge_cfg_verify_set(p_nxge_t nxgep, uint32_t flag) 11943859Sml29623 { 11953859Sml29623 nxge_status_t status = NXGE_OK; 11963859Sml29623 int i = 0, found = 0; 11973859Sml29623 int num_siblings; 11983859Sml29623 dev_info_t *c_dip[MAX_SIBLINGS + 1]; 11993859Sml29623 char *prop_val[MAX_SIBLINGS]; 12003859Sml29623 config_token_t c_token[MAX_SIBLINGS]; 12013859Sml29623 char *prop; 12023859Sml29623 12033859Sml29623 if (nxge_dma_obp_props_only) 12043859Sml29623 return (NXGE_OK); 12053859Sml29623 12063859Sml29623 num_siblings = 0; 12073859Sml29623 c_dip[num_siblings] = ddi_get_child(nxgep->p_dip); 12083859Sml29623 while (c_dip[num_siblings]) { 12093859Sml29623 c_dip[num_siblings + 1] = 12103859Sml29623 ddi_get_next_sibling(c_dip[num_siblings]); 12113859Sml29623 num_siblings++; 12123859Sml29623 } 12133859Sml29623 12143859Sml29623 switch (flag) { 12153859Sml29623 case COMMON_TXDMA_CFG: 12163859Sml29623 prop = "txdma-cfg"; 12173859Sml29623 break; 12183859Sml29623 case COMMON_RXDMA_CFG: 12193859Sml29623 prop = "rxdma-cfg"; 12203859Sml29623 break; 12213859Sml29623 case COMMON_RXDMA_GRP_CFG: 12223859Sml29623 prop = "rxdma-grp-cfg"; 12233859Sml29623 break; 12243859Sml29623 case COMMON_CLASS_CFG: 12253859Sml29623 status = nxge_cfg_verify_set_classify(nxgep, c_dip); 12263859Sml29623 return (status); 12273859Sml29623 default: 12283859Sml29623 return (NXGE_ERROR); 12293859Sml29623 } 12303859Sml29623 12313859Sml29623 i = 0; 12323859Sml29623 while (i < num_siblings) { 12333859Sml29623 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, c_dip[i], 0, prop, 12343859Sml29623 (char **)&prop_val[i]) == DDI_PROP_SUCCESS) { 12353859Sml29623 c_token[i] = nxge_get_config_token(prop_val[i]); 12363859Sml29623 ddi_prop_free(prop_val[i]); 12373859Sml29623 found++; 12383859Sml29623 } else 12393859Sml29623 c_token[i] = CONFIG_TOKEN_NONE; 12403859Sml29623 i++; 12413859Sml29623 } 12423859Sml29623 12433859Sml29623 if (found != i) { 12443859Sml29623 if (found == 0) { 12453859Sml29623 /* not specified: Use default */ 12463859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12473859Sml29623 " property %s not specified on any port:" 12483859Sml29623 " Using default", prop)); 12493859Sml29623 12503859Sml29623 status = nxge_update_cfg_properties(nxgep, 12513859Sml29623 flag, FAIR, c_dip); 12523859Sml29623 return (status); 12533859Sml29623 } else { 12543859Sml29623 /* 12553859Sml29623 * if the convention is to use function 0 device then 12563859Sml29623 * populate the other devices with this configuration. 12573859Sml29623 * 12583859Sml29623 * The other alternative is to use the default config. 12593859Sml29623 */ 12603859Sml29623 /* not specified: Use default */ 12613859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12623859Sml29623 " property %s not specified on some ports:" 12633859Sml29623 " Using default", prop)); 12643859Sml29623 status = nxge_update_cfg_properties(nxgep, 12653859Sml29623 flag, FAIR, c_dip); 12663859Sml29623 return (status); 12673859Sml29623 } 12683859Sml29623 } 12693859Sml29623 12703859Sml29623 /* check type and consistence */ 12713859Sml29623 /* found on all devices */ 12723859Sml29623 for (i = 1; i < found; i++) { 12733859Sml29623 if (c_token[i] != c_token[i - 1]) { 12743859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 12753859Sml29623 " property %s inconsistent:" 12763859Sml29623 " Using default", prop)); 12773859Sml29623 status = nxge_update_cfg_properties(nxgep, 12783859Sml29623 flag, FAIR, c_dip); 12793859Sml29623 return (status); 12803859Sml29623 } 12813859Sml29623 } 12823859Sml29623 12833859Sml29623 /* 12843859Sml29623 * Found on all the ports check if it is custom configuration. if 12853859Sml29623 * custom, then verify consistence 12863859Sml29623 * 12873859Sml29623 * finally create soft properties 12883859Sml29623 */ 12893859Sml29623 status = nxge_update_cfg_properties(nxgep, flag, c_token[0], c_dip); 12903859Sml29623 return (status); 12913859Sml29623 } 12923859Sml29623 12933859Sml29623 nxge_status_t 12943859Sml29623 nxge_cfg_verify_set_quick_config(p_nxge_t nxgep) 12953859Sml29623 { 12963859Sml29623 nxge_status_t status = NXGE_OK; 12973859Sml29623 int ddi_status = DDI_SUCCESS; 12983859Sml29623 char *prop_val; 12993859Sml29623 char *rx_prop; 13003859Sml29623 char *prop; 13013859Sml29623 uint32_t cfg_value = CFG_NOT_SPECIFIED; 13023859Sml29623 p_nxge_param_t param_arr; 13033859Sml29623 13043859Sml29623 param_arr = nxgep->param_arr; 13053859Sml29623 rx_prop = param_arr[param_rx_quick_cfg].fcode_name; 13063859Sml29623 13073859Sml29623 prop = "rx-quick-cfg"; 13083859Sml29623 13093859Sml29623 /* 13103859Sml29623 * good value are 13113859Sml29623 * 13123859Sml29623 * "web-server" "generic-server" "l3-classify" "flow-classify" 13133859Sml29623 */ 13143859Sml29623 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, nxgep->dip, 0, 13153859Sml29623 prop, (char **)&prop_val) != DDI_PROP_SUCCESS) { 13163859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 13173859Sml29623 " property %s not specified: using default ", prop)); 13183859Sml29623 cfg_value = CFG_NOT_SPECIFIED; 13193859Sml29623 } else { 13203859Sml29623 cfg_value = CFG_L3_DISTRIBUTE; 13213859Sml29623 if (strncmp("web-server", (caddr_t)prop_val, 8) == 0) { 13223859Sml29623 cfg_value = CFG_L3_WEB; 13233859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 13243859Sml29623 " %s: web server ", prop)); 13253859Sml29623 } 13263859Sml29623 if (strncmp("generic-server", (caddr_t)prop_val, 8) == 0) { 13273859Sml29623 cfg_value = CFG_L3_DISTRIBUTE; 13283859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 13293859Sml29623 " %s: distribute ", prop)); 13303859Sml29623 } 13313859Sml29623 /* more */ 13323859Sml29623 ddi_prop_free(prop_val); 13333859Sml29623 } 13343859Sml29623 13353859Sml29623 ddi_status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 13363859Sml29623 rx_prop, cfg_value); 13373859Sml29623 if (ddi_status != DDI_PROP_SUCCESS) 13383859Sml29623 status |= NXGE_DDI_FAILED; 13393859Sml29623 13403859Sml29623 /* now handle specified cases: */ 13413859Sml29623 if (status & NXGE_DDI_FAILED) 13423859Sml29623 status |= NXGE_ERROR; 13433859Sml29623 return (status); 13443859Sml29623 } 13453859Sml29623 13463859Sml29623 static void 13473859Sml29623 nxge_use_cfg_link_cfg(p_nxge_t nxgep) 13483859Sml29623 { 13493859Sml29623 int *prop_val; 13503859Sml29623 uint_t prop_len; 13513859Sml29623 dev_info_t *dip; 13523859Sml29623 int speed; 13533859Sml29623 int duplex; 13543859Sml29623 int adv_autoneg_cap; 13553859Sml29623 int adv_10gfdx_cap; 13563859Sml29623 int adv_10ghdx_cap; 13573859Sml29623 int adv_1000fdx_cap; 13583859Sml29623 int adv_1000hdx_cap; 13593859Sml29623 int adv_100fdx_cap; 13603859Sml29623 int adv_100hdx_cap; 13613859Sml29623 int adv_10fdx_cap; 13623859Sml29623 int adv_10hdx_cap; 13633859Sml29623 int status = DDI_SUCCESS; 13643859Sml29623 13653859Sml29623 dip = nxgep->dip; 13663859Sml29623 13673859Sml29623 /* 13683859Sml29623 * first find out the card type and the supported link speeds and 13693859Sml29623 * features 13703859Sml29623 */ 13713859Sml29623 /* add code for card type */ 13723859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-autoneg-cap", 13733859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 13743859Sml29623 ddi_prop_free(prop_val); 13753859Sml29623 return; 13763859Sml29623 } 13773859Sml29623 13783859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10gfdx-cap", 13793859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 13803859Sml29623 ddi_prop_free(prop_val); 13813859Sml29623 return; 13823859Sml29623 } 13833859Sml29623 13843859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-1000hdx-cap", 13853859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 13863859Sml29623 ddi_prop_free(prop_val); 13873859Sml29623 return; 13883859Sml29623 } 13893859Sml29623 13903859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-1000fdx-cap", 13913859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 13923859Sml29623 ddi_prop_free(prop_val); 13933859Sml29623 return; 13943859Sml29623 } 13953859Sml29623 13963859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-100fdx-cap", 13973859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 13983859Sml29623 ddi_prop_free(prop_val); 13993859Sml29623 return; 14003859Sml29623 } 14013859Sml29623 14023859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-100hdx-cap", 14033859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14043859Sml29623 ddi_prop_free(prop_val); 14053859Sml29623 return; 14063859Sml29623 } 14073859Sml29623 14083859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10fdx-cap", 14093859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14103859Sml29623 ddi_prop_free(prop_val); 14113859Sml29623 return; 14123859Sml29623 } 14133859Sml29623 14143859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, "adv-10hdx-cap", 14153859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14163859Sml29623 ddi_prop_free(prop_val); 14173859Sml29623 return; 14183859Sml29623 } 14193859Sml29623 14203859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, "speed", 14213859Sml29623 (uchar_t **)&prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14223859Sml29623 if (strncmp("10000", (caddr_t)prop_val, 14233859Sml29623 (size_t)prop_len) == 0) { 14243859Sml29623 speed = 10000; 14253859Sml29623 } else if (strncmp("1000", (caddr_t)prop_val, 14263859Sml29623 (size_t)prop_len) == 0) { 14273859Sml29623 speed = 1000; 14283859Sml29623 } else if (strncmp("100", (caddr_t)prop_val, 14293859Sml29623 (size_t)prop_len) == 0) { 14303859Sml29623 speed = 100; 14313859Sml29623 } else if (strncmp("10", (caddr_t)prop_val, 14323859Sml29623 (size_t)prop_len) == 0) { 14333859Sml29623 speed = 10; 14343859Sml29623 } else if (strncmp("auto", (caddr_t)prop_val, 14353859Sml29623 (size_t)prop_len) == 0) { 14363859Sml29623 speed = 0; 14373859Sml29623 } else { 14383859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_NOTE, 14393859Sml29623 "speed property is invalid reverting to auto")); 14403859Sml29623 speed = 0; 14413859Sml29623 } 14423859Sml29623 ddi_prop_free(prop_val); 14433859Sml29623 } else 14443859Sml29623 speed = 0; 14453859Sml29623 14463859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip, 0, "duplex", 14473859Sml29623 (uchar_t **)&prop_val, &prop_len) == DDI_PROP_SUCCESS) { 14483859Sml29623 if (strncmp("full", (caddr_t)prop_val, 14493859Sml29623 (size_t)prop_len) == 0) { 14503859Sml29623 duplex = 2; 14513859Sml29623 } else if (strncmp("half", (caddr_t)prop_val, 14523859Sml29623 (size_t)prop_len) == 0) { 14533859Sml29623 duplex = 1; 14543859Sml29623 } else if (strncmp("auto", (caddr_t)prop_val, 14553859Sml29623 (size_t)prop_len) == 0) { 14563859Sml29623 duplex = 0; 14573859Sml29623 } else { 14583859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_NOTE, 14593859Sml29623 "duplex property is invalid" 14603859Sml29623 " reverting to auto")); 14613859Sml29623 duplex = 0; 14623859Sml29623 } 14633859Sml29623 ddi_prop_free(prop_val); 14643859Sml29623 } else 14653859Sml29623 duplex = 0; 14663859Sml29623 14673859Sml29623 adv_autoneg_cap = (speed == 0) || (duplex == 0); 14683859Sml29623 if (adv_autoneg_cap == 0) { 14693859Sml29623 adv_10gfdx_cap = ((speed == 10000) && (duplex == 2)); 14703859Sml29623 adv_10ghdx_cap = adv_10gfdx_cap; 14713859Sml29623 adv_10ghdx_cap |= ((speed == 10000) && (duplex == 1)); 14723859Sml29623 adv_1000fdx_cap = adv_10ghdx_cap; 14733859Sml29623 adv_1000fdx_cap |= ((speed == 1000) && (duplex == 2)); 14743859Sml29623 adv_1000hdx_cap = adv_1000fdx_cap; 14753859Sml29623 adv_1000hdx_cap |= ((speed == 1000) && (duplex == 1)); 14763859Sml29623 adv_100fdx_cap = adv_1000hdx_cap; 14773859Sml29623 adv_100fdx_cap |= ((speed == 100) && (duplex == 2)); 14783859Sml29623 adv_100hdx_cap = adv_100fdx_cap; 14793859Sml29623 adv_100hdx_cap |= ((speed == 100) && (duplex == 1)); 14803859Sml29623 adv_10fdx_cap = adv_100hdx_cap; 14813859Sml29623 adv_10fdx_cap |= ((speed == 10) && (duplex == 2)); 14823859Sml29623 adv_10hdx_cap = adv_10fdx_cap; 14833859Sml29623 adv_10hdx_cap |= ((speed == 10) && (duplex == 1)); 14843859Sml29623 } else if (speed == 0) { 14853859Sml29623 adv_10gfdx_cap = (duplex == 2); 14863859Sml29623 adv_10ghdx_cap = (duplex == 1); 14873859Sml29623 adv_1000fdx_cap = (duplex == 2); 14883859Sml29623 adv_1000hdx_cap = (duplex == 1); 14893859Sml29623 adv_100fdx_cap = (duplex == 2); 14903859Sml29623 adv_100hdx_cap = (duplex == 1); 14913859Sml29623 adv_10fdx_cap = (duplex == 2); 14923859Sml29623 adv_10hdx_cap = (duplex == 1); 14933859Sml29623 } 14943859Sml29623 if (duplex == 0) { 14953859Sml29623 adv_10gfdx_cap = (speed == 0); 14963859Sml29623 adv_10gfdx_cap |= (speed == 10000); 14973859Sml29623 adv_10ghdx_cap = adv_10gfdx_cap; 14983859Sml29623 adv_10ghdx_cap |= (speed == 10000); 14993859Sml29623 adv_1000fdx_cap = adv_10ghdx_cap; 15003859Sml29623 adv_1000fdx_cap |= (speed == 1000); 15013859Sml29623 adv_1000hdx_cap = adv_1000fdx_cap; 15023859Sml29623 adv_1000hdx_cap |= (speed == 1000); 15033859Sml29623 adv_100fdx_cap = adv_1000hdx_cap; 15043859Sml29623 adv_100fdx_cap |= (speed == 100); 15053859Sml29623 adv_100hdx_cap = adv_100fdx_cap; 15063859Sml29623 adv_100hdx_cap |= (speed == 100); 15073859Sml29623 adv_10fdx_cap = adv_100hdx_cap; 15083859Sml29623 adv_10fdx_cap |= (speed == 10); 15093859Sml29623 adv_10hdx_cap = adv_10fdx_cap; 15103859Sml29623 adv_10hdx_cap |= (speed == 10); 15113859Sml29623 } 15123859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15133859Sml29623 "adv-autoneg-cap", &adv_autoneg_cap, 1); 15143859Sml29623 if (status) 15153859Sml29623 return; 15163859Sml29623 15173859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15183859Sml29623 "adv-10gfdx-cap", &adv_10gfdx_cap, 1); 15193859Sml29623 if (status) 15203859Sml29623 goto nxge_map_myargs_to_gmii_fail1; 15213859Sml29623 15223859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15233859Sml29623 "adv-10ghdx-cap", &adv_10ghdx_cap, 1); 15243859Sml29623 if (status) 15253859Sml29623 goto nxge_map_myargs_to_gmii_fail2; 15263859Sml29623 15273859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15283859Sml29623 "adv-1000fdx-cap", &adv_1000fdx_cap, 1); 15293859Sml29623 if (status) 15303859Sml29623 goto nxge_map_myargs_to_gmii_fail3; 15313859Sml29623 15323859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15333859Sml29623 "adv-1000hdx-cap", &adv_1000hdx_cap, 1); 15343859Sml29623 if (status) 15353859Sml29623 goto nxge_map_myargs_to_gmii_fail4; 15363859Sml29623 15373859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15383859Sml29623 "adv-100fdx-cap", &adv_100fdx_cap, 1); 15393859Sml29623 if (status) 15403859Sml29623 goto nxge_map_myargs_to_gmii_fail5; 15413859Sml29623 15423859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15433859Sml29623 "adv-100hdx-cap", &adv_100hdx_cap, 1); 15443859Sml29623 if (status) 15453859Sml29623 goto nxge_map_myargs_to_gmii_fail6; 15463859Sml29623 15473859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15483859Sml29623 "adv-10fdx-cap", &adv_10fdx_cap, 1); 15493859Sml29623 if (status) 15503859Sml29623 goto nxge_map_myargs_to_gmii_fail7; 15513859Sml29623 15523859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, dip, 15533859Sml29623 "adv-10hdx-cap", &adv_10hdx_cap, 1); 15543859Sml29623 if (status) 15553859Sml29623 goto nxge_map_myargs_to_gmii_fail8; 15563859Sml29623 15573859Sml29623 return; 15583859Sml29623 15593859Sml29623 nxge_map_myargs_to_gmii_fail9: 15603859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10hdx-cap"); 15613859Sml29623 15623859Sml29623 nxge_map_myargs_to_gmii_fail8: 15633859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10fdx-cap"); 15643859Sml29623 15653859Sml29623 nxge_map_myargs_to_gmii_fail7: 15663859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-100hdx-cap"); 15673859Sml29623 15683859Sml29623 nxge_map_myargs_to_gmii_fail6: 15693859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-100fdx-cap"); 15703859Sml29623 15713859Sml29623 nxge_map_myargs_to_gmii_fail5: 15723859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-1000hdx-cap"); 15733859Sml29623 15743859Sml29623 nxge_map_myargs_to_gmii_fail4: 15753859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-1000fdx-cap"); 15763859Sml29623 15773859Sml29623 nxge_map_myargs_to_gmii_fail3: 15783859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10ghdx-cap"); 15793859Sml29623 15803859Sml29623 nxge_map_myargs_to_gmii_fail2: 15813859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-10gfdx-cap"); 15823859Sml29623 15833859Sml29623 nxge_map_myargs_to_gmii_fail1: 15843859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "adv-autoneg-cap"); 15853859Sml29623 } 15863859Sml29623 15873859Sml29623 nxge_status_t 15883859Sml29623 nxge_get_config_properties(p_nxge_t nxgep) 15893859Sml29623 { 15903859Sml29623 nxge_status_t status = NXGE_OK; 15913859Sml29623 p_nxge_hw_list_t hw_p; 15923859Sml29623 15933859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, " ==> nxge_get_config_properties")); 15943859Sml29623 15953859Sml29623 if ((hw_p = nxgep->nxge_hw_p) == NULL) { 15963859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 15973859Sml29623 " nxge_get_config_properties:" 15983859Sml29623 " common hardware not set", nxgep->niu_type)); 15993859Sml29623 return (NXGE_ERROR); 16003859Sml29623 } 16013859Sml29623 16023859Sml29623 /* 16033859Sml29623 * Get info on how many ports Neptune card has. 16043859Sml29623 */ 16053859Sml29623 switch (nxgep->niu_type) { 16063859Sml29623 case N2_NIU: 16073859Sml29623 nxgep->nports = 2; 16083859Sml29623 nxgep->classifier.tcam_size = TCAM_NIU_TCAM_MAX_ENTRY; 16093859Sml29623 if (nxgep->function_num > 1) { 16103859Sml29623 return (NXGE_ERROR); 16113859Sml29623 } 16123859Sml29623 break; 1613*4185Sspeer 16143859Sml29623 case NEPTUNE_2: 16153859Sml29623 case NEPTUNE: 16163859Sml29623 default: 1617*4185Sspeer 1618*4185Sspeer if ((nxgep->niu_type == NEPTUNE_2) && 1619*4185Sspeer (nxgep->function_num > 1)) { 16203859Sml29623 return (NXGE_ERROR); 1621*4185Sspeer } 1622*4185Sspeer if (!nxgep->vpd_info.ver_valid) { 1623*4185Sspeer status = nxge_espc_num_ports_get(nxgep); 1624*4185Sspeer if (status != NXGE_OK) { 1625*4185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 1626*4185Sspeer "EEPROM version [%s] invalid...please " 1627*4185Sspeer "update", nxgep->vpd_info.ver)); 1628*4185Sspeer return (status); 1629*4185Sspeer } 1630*4185Sspeer nxgep->classifier.tcam_size = TCAM_NXGE_TCAM_MAX_ENTRY; 1631*4185Sspeer break; 1632*4185Sspeer } 1633*4185Sspeer /* 1634*4185Sspeer * First try to get the no. of ports from the info 1635*4185Sspeer * in the VPD read off the EEPROM. 1636*4185Sspeer */ 1637*4185Sspeer if ((strncmp(nxgep->vpd_info.bd_model, NXGE_QGC_LP_BM_STR, 1638*4185Sspeer strlen(NXGE_QGC_LP_BM_STR)) == 0) || 1639*4185Sspeer (strncmp(nxgep->vpd_info.bd_model, NXGE_QGC_PEM_BM_STR, 1640*4185Sspeer strlen(NXGE_QGC_PEM_BM_STR)) == 0)) { 1641*4185Sspeer nxgep->nports = NXGE_NUM_OF_PORTS_QUAD; 1642*4185Sspeer } else if ((strncmp(nxgep->vpd_info.bd_model, 1643*4185Sspeer NXGE_2XGF_LP_BM_STR, strlen(NXGE_2XGF_LP_BM_STR)) == 0) || 1644*4185Sspeer (strncmp(nxgep->vpd_info.bd_model, NXGE_2XGF_PEM_BM_STR, 1645*4185Sspeer strlen(NXGE_2XGF_PEM_BM_STR)) == 0)) { 1646*4185Sspeer nxgep->nports = NXGE_NUM_OF_PORTS_DUAL; 1647*4185Sspeer } else { 1648*4185Sspeer NXGE_DEBUG_MSG((nxgep, VPD_CTL, 1649*4185Sspeer "nxge_get_config_properties: port num not set in" 1650*4185Sspeer " EEPROM...Reading from SEEPROM")); 1651*4185Sspeer status = nxge_espc_num_ports_get(nxgep); 1652*4185Sspeer if (status != NXGE_OK) 1653*4185Sspeer return (status); 1654*4185Sspeer } 16553859Sml29623 nxgep->classifier.tcam_size = TCAM_NXGE_TCAM_MAX_ENTRY; 16563859Sml29623 break; 16573859Sml29623 } 16583859Sml29623 16593859Sml29623 status = nxge_get_mac_addr_properties(nxgep); 16603859Sml29623 if (status != NXGE_OK) 16613859Sml29623 return (NXGE_ERROR); 16623859Sml29623 16633859Sml29623 /* 16643859Sml29623 * read the configuration type. If none is specified, used default. 16653859Sml29623 * Config types: equal: (default) DMA channels, RDC groups, TCAM, FCRAM 16663859Sml29623 * are shared equally across all the ports. 16673859Sml29623 * 16683859Sml29623 * Fair: DMA channels, RDC groups, TCAM, FCRAM are shared proportional 16693859Sml29623 * to the port speed. 16703859Sml29623 * 16713859Sml29623 * 16723859Sml29623 * custom: DMA channels, RDC groups, TCAM, FCRAM partition is 16733859Sml29623 * specified in nxge.conf. Need to read each parameter and set 16743859Sml29623 * up the parameters in nxge structures. 16753859Sml29623 * 16763859Sml29623 */ 16773859Sml29623 switch (nxgep->niu_type) { 16783859Sml29623 case N2_NIU: 16793859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 16803859Sml29623 " ==> nxge_get_config_properties: N2")); 16813859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 16823859Sml29623 if ((hw_p->flags & COMMON_CFG_VALID) != 16833859Sml29623 COMMON_CFG_VALID) { 16843859Sml29623 status = nxge_cfg_verify_set(nxgep, 16853859Sml29623 COMMON_RXDMA_GRP_CFG); 16863859Sml29623 status = nxge_cfg_verify_set(nxgep, 16873859Sml29623 COMMON_CLASS_CFG); 16883859Sml29623 hw_p->flags |= COMMON_CFG_VALID; 16893859Sml29623 } 16903859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 16913859Sml29623 status = nxge_use_cfg_n2niu_properties(nxgep); 16923859Sml29623 break; 16933859Sml29623 16943859Sml29623 case NEPTUNE: 16953859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 16963859Sml29623 " ==> nxge_get_config_properties: Neptune")); 16973859Sml29623 status = nxge_cfg_verify_set_quick_config(nxgep); 16983859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 16993859Sml29623 if ((hw_p->flags & COMMON_CFG_VALID) != 17003859Sml29623 COMMON_CFG_VALID) { 17013859Sml29623 status = nxge_cfg_verify_set(nxgep, 17023859Sml29623 COMMON_TXDMA_CFG); 17033859Sml29623 status = nxge_cfg_verify_set(nxgep, 17043859Sml29623 COMMON_RXDMA_CFG); 17053859Sml29623 status = nxge_cfg_verify_set(nxgep, 17063859Sml29623 COMMON_RXDMA_GRP_CFG); 17073859Sml29623 status = nxge_cfg_verify_set(nxgep, 17083859Sml29623 COMMON_CLASS_CFG); 17093859Sml29623 hw_p->flags |= COMMON_CFG_VALID; 17103859Sml29623 } 17113859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 17123859Sml29623 nxge_use_cfg_neptune_properties(nxgep); 17133859Sml29623 status = NXGE_OK; 17143859Sml29623 break; 17153859Sml29623 17163859Sml29623 case NEPTUNE_2: 17173859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, 17183859Sml29623 " ==> nxge_get_config_properties: Neptune-2")); 17193859Sml29623 if (nxgep->function_num > 1) 17203859Sml29623 return (NXGE_ERROR); 17213859Sml29623 status = nxge_cfg_verify_set_quick_config(nxgep); 17223859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 17233859Sml29623 17243859Sml29623 if ((hw_p->flags & COMMON_CFG_VALID) != 17253859Sml29623 COMMON_CFG_VALID) { 17263859Sml29623 status = nxge_cfg_verify_set(nxgep, 17273859Sml29623 COMMON_TXDMA_CFG); 17283859Sml29623 status = nxge_cfg_verify_set(nxgep, 17293859Sml29623 COMMON_RXDMA_CFG); 17303859Sml29623 status = nxge_cfg_verify_set(nxgep, 17313859Sml29623 COMMON_RXDMA_GRP_CFG); 17323859Sml29623 status = nxge_cfg_verify_set(nxgep, 17333859Sml29623 COMMON_CLASS_CFG); 17343859Sml29623 hw_p->flags |= COMMON_CFG_VALID; 17353859Sml29623 } 17363859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 17373859Sml29623 17383859Sml29623 nxge_use_cfg_neptune_properties(nxgep); 17393859Sml29623 status = NXGE_OK; 17403859Sml29623 break; 17413859Sml29623 17423859Sml29623 default: 17433859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 17443859Sml29623 " nxge_get_config_properties:" 17453859Sml29623 " unknown NIU type %x", nxgep->niu_type)); 17463859Sml29623 return (NXGE_ERROR); 17473859Sml29623 } 17483859Sml29623 17493859Sml29623 NXGE_DEBUG_MSG((nxgep, VPD_CTL, " <== nxge_get_config_properties")); 17503859Sml29623 return (status); 17513859Sml29623 } 17523859Sml29623 17533859Sml29623 static nxge_status_t 17543859Sml29623 nxge_use_cfg_n2niu_properties(p_nxge_t nxgep) 17553859Sml29623 { 17563859Sml29623 nxge_status_t status = NXGE_OK; 17573859Sml29623 17583859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_n2niu_properties")); 17593859Sml29623 17603859Sml29623 status = nxge_use_default_dma_config_n2(nxgep); 17613859Sml29623 if (status != NXGE_OK) { 17623859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 17633859Sml29623 " ==> nxge_use_cfg_n2niu_properties (err 0x%x)", 17643859Sml29623 status)); 17653859Sml29623 return (status | NXGE_ERROR); 17663859Sml29623 } 17673859Sml29623 17683859Sml29623 (void) nxge_use_cfg_vlan_class_config(nxgep); 17693859Sml29623 (void) nxge_use_cfg_mac_class_config(nxgep); 17703859Sml29623 (void) nxge_use_cfg_class_config(nxgep); 17713859Sml29623 (void) nxge_use_cfg_link_cfg(nxgep); 17723859Sml29623 17733859Sml29623 /* 17743859Sml29623 * Read in the hardware (fcode) properties. Use the ndd array to read 17753859Sml29623 * each property. 17763859Sml29623 */ 17773859Sml29623 (void) nxge_get_param_soft_properties(nxgep); 17783859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_n2niu_properties")); 17793859Sml29623 17803859Sml29623 return (status); 17813859Sml29623 } 17823859Sml29623 17833859Sml29623 static void 17843859Sml29623 nxge_use_cfg_neptune_properties(p_nxge_t nxgep) 17853859Sml29623 { 17863859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_neptune_properties")); 17873859Sml29623 17883859Sml29623 (void) nxge_use_cfg_dma_config(nxgep); 17893859Sml29623 (void) nxge_use_cfg_vlan_class_config(nxgep); 17903859Sml29623 (void) nxge_use_cfg_mac_class_config(nxgep); 17913859Sml29623 (void) nxge_use_cfg_class_config(nxgep); 17923859Sml29623 (void) nxge_use_cfg_link_cfg(nxgep); 17933859Sml29623 17943859Sml29623 /* 17953859Sml29623 * Read in the hardware (fcode) properties. Use the ndd array to read 17963859Sml29623 * each property. 17973859Sml29623 */ 17983859Sml29623 (void) nxge_get_param_soft_properties(nxgep); 17993859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_neptune_properties")); 18003859Sml29623 } 18013859Sml29623 18023859Sml29623 /* 18033859Sml29623 * FWARC 2006/556 18043859Sml29623 */ 18053859Sml29623 18063859Sml29623 static nxge_status_t 18073859Sml29623 nxge_use_default_dma_config_n2(p_nxge_t nxgep) 18083859Sml29623 { 18093859Sml29623 int ndmas; 18103859Sml29623 int nrxgp; 18113859Sml29623 uint8_t func; 18123859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 18133859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 18143859Sml29623 int *prop_val; 18153859Sml29623 uint_t prop_len; 18163859Sml29623 int i; 18173859Sml29623 nxge_status_t status = NXGE_OK; 18183859Sml29623 18193859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2")); 18203859Sml29623 18213859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 18223859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 18233859Sml29623 18243859Sml29623 func = nxgep->function_num; 18253859Sml29623 p_cfgp->function_number = func; 18263859Sml29623 ndmas = NXGE_TDMA_PER_NIU_PORT; 18273859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 18283859Sml29623 "tx-dma-channels", (int **)&prop_val, 18293859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 18303859Sml29623 p_cfgp->start_tdc = prop_val[0]; 18313859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18323859Sml29623 "==> nxge_use_default_dma_config_n2: tdc starts %d " 18333859Sml29623 "(#%d)", p_cfgp->start_tdc, prop_len)); 18343859Sml29623 18353859Sml29623 ndmas = prop_val[1]; 18363859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18373859Sml29623 "==> nxge_use_default_dma_config_n2: #tdc %d (#%d)", 18383859Sml29623 ndmas, prop_len)); 18393859Sml29623 ddi_prop_free(prop_val); 18403859Sml29623 } else { 18413859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18423859Sml29623 "==> nxge_use_default_dma_config_n2: " 18433859Sml29623 "get tx-dma-channels failed")); 18443859Sml29623 return (NXGE_DDI_FAILED); 18453859Sml29623 } 18463859Sml29623 18473859Sml29623 p_cfgp->max_tdcs = nxgep->max_tdcs = ndmas; 18483859Sml29623 nxgep->tdc_mask = (ndmas - 1); 18493859Sml29623 18503859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 18513859Sml29623 "p_cfgp 0x%llx max_tdcs %d nxgep->max_tdcs %d start %d", 18523859Sml29623 p_cfgp, p_cfgp->max_tdcs, nxgep->max_tdcs, p_cfgp->start_tdc)); 18533859Sml29623 18543859Sml29623 /* Receive DMA */ 18553859Sml29623 ndmas = NXGE_RDMA_PER_NIU_PORT; 18563859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 18573859Sml29623 "rx-dma-channels", (int **)&prop_val, 18583859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 18593859Sml29623 p_cfgp->start_rdc = prop_val[0]; 18603859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18613859Sml29623 "==> nxge_use_default_dma_config_n2(obp): rdc start %d" 18623859Sml29623 " (#%d)", p_cfgp->start_rdc, prop_len)); 18633859Sml29623 ndmas = prop_val[1]; 18643859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 18653859Sml29623 "==> nxge_use_default_dma_config_n2(obp):#rdc %d (#%d)", 18663859Sml29623 ndmas, prop_len)); 18673859Sml29623 ddi_prop_free(prop_val); 18683859Sml29623 } else { 18693859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 18703859Sml29623 "==> nxge_use_default_dma_config_n2: " 18713859Sml29623 "get rx-dma-channel failed")); 18723859Sml29623 return (NXGE_DDI_FAILED); 18733859Sml29623 } 18743859Sml29623 18753859Sml29623 p_cfgp->max_rdcs = nxgep->max_rdcs = ndmas; 18763859Sml29623 nxgep->rdc_mask = (ndmas - 1); 18773859Sml29623 18783859Sml29623 /* Hypervisor: rdc # and group # use the same # !! */ 18793859Sml29623 p_cfgp->max_grpids = p_cfgp->max_rdcs + p_cfgp->max_tdcs; 18803859Sml29623 p_cfgp->start_grpid = 0; 18813859Sml29623 p_cfgp->mif_ldvid = p_cfgp->mac_ldvid = p_cfgp->ser_ldvid = 0; 18823859Sml29623 18833859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 18843859Sml29623 "interrupts", (int **)&prop_val, 18853859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 18863859Sml29623 /* 18873859Sml29623 * For each device assigned, the content of each interrupts 18883859Sml29623 * property is its logical device group. 18893859Sml29623 * 18903859Sml29623 * Assignment of interrupts property is in the the following 18913859Sml29623 * order: 18923859Sml29623 * 18933859Sml29623 * MAC MIF (if configured) SYSTEM ERROR (if configured) first 18943859Sml29623 * receive channel next channel...... last receive channel 18953859Sml29623 * first transmit channel next channel...... last transmit 18963859Sml29623 * channel 18973859Sml29623 * 18983859Sml29623 * prop_len should be at least for one mac and total # of rx and 18993859Sml29623 * tx channels. Function 0 owns MIF and ERROR 19003859Sml29623 */ 19013859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19023859Sml29623 "==> nxge_use_default_dma_config_n2(obp): " 19033859Sml29623 "# interrupts %d", prop_len)); 19043859Sml29623 19053859Sml29623 switch (func) { 19063859Sml29623 case 0: 19073859Sml29623 p_cfgp->ldg_chn_start = 3; 19083859Sml29623 p_cfgp->mac_ldvid = NXGE_MAC_LD_PORT0; 19093859Sml29623 p_cfgp->mif_ldvid = NXGE_MIF_LD; 19103859Sml29623 p_cfgp->ser_ldvid = NXGE_SYS_ERROR_LD; 19113859Sml29623 19123859Sml29623 break; 19133859Sml29623 case 1: 19143859Sml29623 p_cfgp->ldg_chn_start = 1; 19153859Sml29623 p_cfgp->mac_ldvid = NXGE_MAC_LD_PORT1; 19163859Sml29623 19173859Sml29623 break; 19183859Sml29623 default: 19193859Sml29623 status = NXGE_DDI_FAILED; 19203859Sml29623 break; 19213859Sml29623 } 19223859Sml29623 19233859Sml29623 if (status != NXGE_OK) 19243859Sml29623 return (status); 19253859Sml29623 19263859Sml29623 for (i = 0; i < prop_len; i++) { 19273859Sml29623 p_cfgp->ldg[i] = prop_val[i]; 19283859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19293859Sml29623 "==> nxge_use_default_dma_config_n2(obp): " 19303859Sml29623 "interrupt #%d, ldg %d", 19313859Sml29623 i, p_cfgp->ldg[i])); 19323859Sml29623 } 19333859Sml29623 19343859Sml29623 p_cfgp->max_grpids = prop_len; 19353859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19363859Sml29623 "==> nxge_use_default_dma_config_n2(obp): %d " 19373859Sml29623 "(#%d) maxgrpids %d channel starts %d", 19383859Sml29623 p_cfgp->mac_ldvid, i, p_cfgp->max_grpids, 19393859Sml29623 p_cfgp->ldg_chn_start)); 19403859Sml29623 ddi_prop_free(prop_val); 19413859Sml29623 } else { 19423859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 19433859Sml29623 "==> nxge_use_default_dma_config_n2: " 19443859Sml29623 "get interrupts failed")); 19453859Sml29623 return (NXGE_DDI_FAILED); 19463859Sml29623 } 19473859Sml29623 19483859Sml29623 p_cfgp->max_ldgs = p_cfgp->max_grpids; 19493859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 19503859Sml29623 "==> nxge_use_default_dma_config_n2: " 19513859Sml29623 "p_cfgp 0x%llx max_rdcs %d nxgep->max_rdcs %d max_grpids %d" 19523859Sml29623 "start_grpid %d macid %d mifid %d serrid %d", 19533859Sml29623 p_cfgp, p_cfgp->max_rdcs, nxgep->max_rdcs, p_cfgp->max_grpids, 19543859Sml29623 p_cfgp->start_grpid, 19553859Sml29623 p_cfgp->mac_ldvid, p_cfgp->mif_ldvid, p_cfgp->ser_ldvid)); 19563859Sml29623 19573859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 19583859Sml29623 "p_cfgp p%p start_ldg %d nxgep->max_ldgs %d", 19593859Sml29623 p_cfgp, p_cfgp->start_ldg, p_cfgp->max_ldgs)); 19603859Sml29623 19613859Sml29623 /* 19623859Sml29623 * RDC groups and the beginning RDC group assigned to this function. 19633859Sml29623 */ 19643859Sml29623 nrxgp = 2; 19653859Sml29623 p_cfgp->max_rdc_grpids = nrxgp; 19663859Sml29623 p_cfgp->start_rdc_grpid = (nxgep->function_num * nrxgp); 19673859Sml29623 19683859Sml29623 status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 19693859Sml29623 "rx-rdc-grps", nrxgp); 19703859Sml29623 if (status) { 19713859Sml29623 return (NXGE_DDI_FAILED); 19723859Sml29623 } 19733859Sml29623 status = ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 19743859Sml29623 "rx-rdc-grps-begin", p_cfgp->start_rdc_grpid); 19753859Sml29623 if (status) { 19763859Sml29623 (void) ddi_prop_remove(DDI_DEV_T_NONE, nxgep->dip, 19773859Sml29623 "rx-rdc-grps"); 19783859Sml29623 return (NXGE_DDI_FAILED); 19793859Sml29623 } 19803859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "==> nxge_use_default_dma_config_n2: " 19813859Sml29623 "p_cfgp $%p # rdc groups %d start rdc group id %d", 19823859Sml29623 p_cfgp, p_cfgp->max_rdc_grpids, 19833859Sml29623 p_cfgp->start_rdc_grpid)); 19843859Sml29623 19853859Sml29623 nxge_set_hw_dma_config(nxgep); 19863859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, "<== nxge_use_default_dma_config_n2")); 19873859Sml29623 return (status); 19883859Sml29623 } 19893859Sml29623 19903859Sml29623 static void 19913859Sml29623 nxge_use_cfg_dma_config(p_nxge_t nxgep) 19923859Sml29623 { 19933859Sml29623 int tx_ndmas, rx_ndmas, nrxgp; 19943859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 19953859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 19963859Sml29623 dev_info_t *dip; 19973859Sml29623 p_nxge_param_t param_arr; 19983859Sml29623 char *prop; 19993859Sml29623 int *prop_val; 20003859Sml29623 uint_t prop_len; 20013859Sml29623 20023859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_dma_config")); 20033859Sml29623 param_arr = nxgep->param_arr; 20043859Sml29623 20053859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 20063859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 20073859Sml29623 dip = nxgep->dip; 20083859Sml29623 p_cfgp->function_number = nxgep->function_num; 20093859Sml29623 prop = param_arr[param_txdma_channels_begin].fcode_name; 20103859Sml29623 20113859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20123859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20133859Sml29623 p_cfgp->start_tdc = *prop_val; 20143859Sml29623 ddi_prop_free(prop_val); 20153859Sml29623 } else { 20163859Sml29623 if (nxgep->nports == 2) { 20173859Sml29623 tx_ndmas = (nxgep->function_num * p2_tx_equal[0]); 20183859Sml29623 } else { 20193859Sml29623 tx_ndmas = (nxgep->function_num * p4_tx_equal[0]); 20203859Sml29623 } 20213859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 20223859Sml29623 prop, tx_ndmas); 20233859Sml29623 p_cfgp->start_tdc = tx_ndmas; 20243859Sml29623 } 20253859Sml29623 20263859Sml29623 prop = param_arr[param_txdma_channels].fcode_name; 20273859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20283859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20293859Sml29623 tx_ndmas = *prop_val; 20303859Sml29623 ddi_prop_free(prop_val); 20313859Sml29623 } else { 20323859Sml29623 if (nxgep->nports == 2) { 20333859Sml29623 tx_ndmas = p2_tx_equal[0]; 20343859Sml29623 } else { 20353859Sml29623 tx_ndmas = p4_tx_equal[0]; 20363859Sml29623 } 20373859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 20383859Sml29623 prop, tx_ndmas); 20393859Sml29623 } 20403859Sml29623 20413859Sml29623 p_cfgp->max_tdcs = nxgep->max_tdcs = tx_ndmas; 20423859Sml29623 nxgep->tdc_mask = (tx_ndmas - 1); 20433859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_dma_config: " 20443859Sml29623 "p_cfgp 0x%llx max_tdcs %d nxgep->max_tdcs %d", 20453859Sml29623 p_cfgp, p_cfgp->max_tdcs, nxgep->max_tdcs)); 20463859Sml29623 20473859Sml29623 prop = param_arr[param_rxdma_channels_begin].fcode_name; 20483859Sml29623 20493859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20503859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20513859Sml29623 p_cfgp->start_rdc = *prop_val; 20523859Sml29623 ddi_prop_free(prop_val); 20533859Sml29623 } else { 20543859Sml29623 if (nxgep->nports == 2) { 20553859Sml29623 rx_ndmas = (nxgep->function_num * p2_rx_equal[0]); 20563859Sml29623 } else { 20573859Sml29623 rx_ndmas = (nxgep->function_num * p4_rx_equal[0]); 20583859Sml29623 } 20593859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 20603859Sml29623 prop, rx_ndmas); 20613859Sml29623 p_cfgp->start_rdc = rx_ndmas; 20623859Sml29623 } 20633859Sml29623 20643859Sml29623 prop = param_arr[param_rxdma_channels].fcode_name; 20653859Sml29623 20663859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20673859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20683859Sml29623 rx_ndmas = *prop_val; 20693859Sml29623 ddi_prop_free(prop_val); 20703859Sml29623 } else { 20713859Sml29623 if (nxgep->nports == 2) { 20723859Sml29623 rx_ndmas = p2_rx_equal[0]; 20733859Sml29623 } else { 20743859Sml29623 rx_ndmas = p4_rx_equal[0]; 20753859Sml29623 } 20763859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 20773859Sml29623 prop, rx_ndmas); 20783859Sml29623 } 20793859Sml29623 20803859Sml29623 p_cfgp->max_rdcs = nxgep->max_rdcs = rx_ndmas; 20813859Sml29623 20823859Sml29623 prop = param_arr[param_rdc_grps_start].fcode_name; 20833859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 20843859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 20853859Sml29623 p_cfgp->start_rdc_grpid = *prop_val; 20863859Sml29623 ddi_prop_free(prop_val); 20873859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 20883859Sml29623 "==> nxge_use_default_dma_config: " 20893859Sml29623 "use property " "start_grpid %d ", 20903859Sml29623 p_cfgp->start_grpid)); 20913859Sml29623 } else { 20923859Sml29623 p_cfgp->start_rdc_grpid = nxgep->function_num; 20933859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 20943859Sml29623 prop, p_cfgp->start_rdc_grpid); 20953859Sml29623 20963859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 20973859Sml29623 "==> nxge_use_default_dma_config: " 20983859Sml29623 "use default " 20993859Sml29623 "start_grpid %d (same as function #)", 21003859Sml29623 p_cfgp->start_grpid)); 21013859Sml29623 } 21023859Sml29623 21033859Sml29623 prop = param_arr[param_rx_rdc_grps].fcode_name; 21043859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 21053859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 21063859Sml29623 nrxgp = *prop_val; 21073859Sml29623 ddi_prop_free(prop_val); 21083859Sml29623 } else { 21093859Sml29623 nrxgp = 1; 21103859Sml29623 (void) ddi_prop_update_int(DDI_DEV_T_NONE, nxgep->dip, 21113859Sml29623 prop, nrxgp); 21123859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 21133859Sml29623 "==> nxge_use_default_dma_config: " 21143859Sml29623 "num_rdc_grpid not found: use def:# of " 21153859Sml29623 "rdc groups %d\n", nrxgp)); 21163859Sml29623 } 21173859Sml29623 21183859Sml29623 p_cfgp->max_rdc_grpids = nrxgp; 21193859Sml29623 21203859Sml29623 /* 21213859Sml29623 * 2/4 ports have the same hard-wired logical groups assigned. 21223859Sml29623 */ 21233859Sml29623 p_cfgp->start_ldg = nxgep->function_num * NXGE_LDGRP_PER_4PORTS; 21243859Sml29623 p_cfgp->max_ldgs = NXGE_LDGRP_PER_4PORTS; 21253859Sml29623 21263859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_default_dma_config: " 21273859Sml29623 "p_cfgp 0x%llx max_rdcs %d nxgep->max_rdcs %d max_grpids %d" 21283859Sml29623 "start_grpid %d", 21293859Sml29623 p_cfgp, p_cfgp->max_rdcs, nxgep->max_rdcs, p_cfgp->max_grpids, 21303859Sml29623 p_cfgp->start_grpid)); 21313859Sml29623 21323859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_dma_config: " 21333859Sml29623 "p_cfgp 0x%016llx start_ldg %d nxgep->max_ldgs %d " 21343859Sml29623 "start_rdc_grpid %d", 21353859Sml29623 p_cfgp, p_cfgp->start_ldg, p_cfgp->max_ldgs, 21363859Sml29623 p_cfgp->start_rdc_grpid)); 21373859Sml29623 21383859Sml29623 prop = param_arr[param_rxdma_intr_time].fcode_name; 21393859Sml29623 21403859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 21413859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 21423859Sml29623 if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) { 21433859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 21443859Sml29623 nxgep->dip, prop, prop_val, prop_len); 21453859Sml29623 } 21463859Sml29623 ddi_prop_free(prop_val); 21473859Sml29623 } 21483859Sml29623 prop = param_arr[param_rxdma_intr_pkts].fcode_name; 21493859Sml29623 21503859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, 0, prop, 21513859Sml29623 &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 21523859Sml29623 if ((prop_len > 0) && (prop_len <= p_cfgp->max_rdcs)) { 21533859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 21543859Sml29623 nxgep->dip, prop, prop_val, prop_len); 21553859Sml29623 } 21563859Sml29623 ddi_prop_free(prop_val); 21573859Sml29623 } 21583859Sml29623 nxge_set_hw_dma_config(nxgep); 21593859Sml29623 21603859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_use_cfg_dma_config")); 21613859Sml29623 } 21623859Sml29623 21633859Sml29623 static void 21643859Sml29623 nxge_use_cfg_vlan_class_config(p_nxge_t nxgep) 21653859Sml29623 { 21663859Sml29623 uint_t vlan_cnt; 21673859Sml29623 int *vlan_cfg_val; 21683859Sml29623 int status; 21693859Sml29623 p_nxge_param_t param_arr; 21703859Sml29623 char *prop; 21713859Sml29623 21723859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_use_cfg_vlan_config")); 21733859Sml29623 param_arr = nxgep->param_arr; 21743859Sml29623 prop = param_arr[param_vlan_2rdc_grp].fcode_name; 21753859Sml29623 21763859Sml29623 status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 21773859Sml29623 &vlan_cfg_val, &vlan_cnt); 21783859Sml29623 if (status == DDI_PROP_SUCCESS) { 21793859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, 21803859Sml29623 nxgep->dip, prop, vlan_cfg_val, vlan_cnt); 21813859Sml29623 ddi_prop_free(vlan_cfg_val); 21823859Sml29623 } 21833859Sml29623 nxge_set_hw_vlan_class_config(nxgep); 21843859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_vlan_config")); 21853859Sml29623 } 21863859Sml29623 21873859Sml29623 static void 21883859Sml29623 nxge_use_cfg_mac_class_config(p_nxge_t nxgep) 21893859Sml29623 { 21903859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 21913859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 21923859Sml29623 uint_t mac_cnt; 21933859Sml29623 int *mac_cfg_val; 21943859Sml29623 int status; 21953859Sml29623 p_nxge_param_t param_arr; 21963859Sml29623 char *prop; 21973859Sml29623 21983859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_use_cfg_mac_class_config")); 21993859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 22003859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 22013859Sml29623 p_cfgp->start_mac_entry = 0; 22023859Sml29623 param_arr = nxgep->param_arr; 22033859Sml29623 prop = param_arr[param_mac_2rdc_grp].fcode_name; 22043859Sml29623 22053859Sml29623 switch (nxgep->function_num) { 22063859Sml29623 case 0: 22073859Sml29623 case 1: 22083859Sml29623 /* 10G ports */ 22093859Sml29623 p_cfgp->max_macs = NXGE_MAX_MACS_XMACS; 22103859Sml29623 break; 22113859Sml29623 case 2: 22123859Sml29623 case 3: 22133859Sml29623 /* 1G ports */ 22143859Sml29623 default: 22153859Sml29623 p_cfgp->max_macs = NXGE_MAX_MACS_BMACS; 22163859Sml29623 break; 22173859Sml29623 } 22183859Sml29623 22193859Sml29623 p_cfgp->mac_pref = 1; 22203859Sml29623 p_cfgp->def_mac_rxdma_grpid = p_cfgp->start_rdc_grpid; 22213859Sml29623 22223859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 22233859Sml29623 "== nxge_use_cfg_mac_class_config: " 22243859Sml29623 " mac_pref bit set def_mac_rxdma_grpid %d", 22253859Sml29623 p_cfgp->def_mac_rxdma_grpid)); 22263859Sml29623 22273859Sml29623 status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 22283859Sml29623 &mac_cfg_val, &mac_cnt); 22293859Sml29623 if (status == DDI_PROP_SUCCESS) { 22303859Sml29623 if (mac_cnt <= p_cfgp->max_macs) 22313859Sml29623 status = ddi_prop_update_int_array(DDI_DEV_T_NONE, 22323859Sml29623 nxgep->dip, prop, mac_cfg_val, mac_cnt); 22333859Sml29623 ddi_prop_free(mac_cfg_val); 22343859Sml29623 } 22353859Sml29623 nxge_set_hw_mac_class_config(nxgep); 22363859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_use_cfg_mac_class_config")); 22373859Sml29623 } 22383859Sml29623 22393859Sml29623 static void 22403859Sml29623 nxge_use_cfg_class_config(p_nxge_t nxgep) 22413859Sml29623 { 22423859Sml29623 nxge_set_hw_class_config(nxgep); 22433859Sml29623 } 22443859Sml29623 22453859Sml29623 static void 22463859Sml29623 nxge_set_rdc_intr_property(p_nxge_t nxgep) 22473859Sml29623 { 22483859Sml29623 int i; 22493859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 22503859Sml29623 22513859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_rdc_intr_property")); 22523859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 22533859Sml29623 22543859Sml29623 for (i = 0; i < NXGE_MAX_RDCS; i++) { 22553859Sml29623 p_dma_cfgp->rcr_timeout[i] = nxge_rcr_timeout; 22563859Sml29623 p_dma_cfgp->rcr_threshold[i] = nxge_rcr_threshold; 22573859Sml29623 } 22583859Sml29623 22593859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_rdc_intr_property")); 22603859Sml29623 } 22613859Sml29623 22623859Sml29623 static void 22633859Sml29623 nxge_set_hw_dma_config(p_nxge_t nxgep) 22643859Sml29623 { 22653859Sml29623 int i, j, rdc, ndmas, ngrps, bitmap, end, st_rdc; 22663859Sml29623 int32_t status; 22673859Sml29623 uint8_t rdcs_per_grp; 22683859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 22693859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 22703859Sml29623 p_nxge_rdc_grp_t rdc_grp_p; 22713859Sml29623 int rdcgrp_cfg = CFG_NOT_SPECIFIED, rx_quick_cfg; 22723859Sml29623 char *prop, *prop_val; 22733859Sml29623 p_nxge_param_t param_arr; 22743859Sml29623 config_token_t token; 22753859Sml29623 22763859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_set_hw_dma_config")); 22773859Sml29623 22783859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 22793859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 22803859Sml29623 rdc_grp_p = p_dma_cfgp->rdc_grps; 22813859Sml29623 22823859Sml29623 /* Transmit DMA Channels */ 22833859Sml29623 bitmap = 0; 22843859Sml29623 end = p_cfgp->start_tdc + p_cfgp->max_tdcs; 22853859Sml29623 nxgep->ntdc = p_cfgp->max_tdcs; 22863859Sml29623 p_dma_cfgp->tx_dma_map = 0; 22873859Sml29623 for (i = p_cfgp->start_tdc; i < end; i++) { 22883859Sml29623 bitmap |= (1 << i); 22893859Sml29623 nxgep->tdc[i - p_cfgp->start_tdc] = (uint8_t)i; 22903859Sml29623 } 22913859Sml29623 22923859Sml29623 p_dma_cfgp->tx_dma_map = bitmap; 22933859Sml29623 param_arr = nxgep->param_arr; 22943859Sml29623 22953859Sml29623 /* Assume RDCs are evenly distributed */ 22963859Sml29623 rx_quick_cfg = param_arr[param_rx_quick_cfg].value; 22973859Sml29623 switch (rx_quick_cfg) { 22983859Sml29623 case CFG_NOT_SPECIFIED: 22993859Sml29623 prop = "rxdma-grp-cfg"; 23003859Sml29623 status = ddi_prop_lookup_string(DDI_DEV_T_NONE, 23013859Sml29623 nxgep->dip, 0, prop, (char **)&prop_val); 23023859Sml29623 if (status != DDI_PROP_SUCCESS) { 23033859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, 23043859Sml29623 " property %s not found", prop)); 23053859Sml29623 rdcgrp_cfg = CFG_L3_DISTRIBUTE; 23063859Sml29623 } else { 23073859Sml29623 token = nxge_get_config_token(prop_val); 23083859Sml29623 switch (token) { 23093859Sml29623 case L2_CLASSIFY: 23103859Sml29623 break; 23113859Sml29623 case CLASSIFY: 23123859Sml29623 case L3_CLASSIFY: 23133859Sml29623 case L3_DISTRIBUTE: 23143859Sml29623 case L3_TCAM: 23153859Sml29623 rdcgrp_cfg = CFG_L3_DISTRIBUTE; 23163859Sml29623 break; 23173859Sml29623 default: 23183859Sml29623 rdcgrp_cfg = CFG_L3_DISTRIBUTE; 23193859Sml29623 break; 23203859Sml29623 } 23213859Sml29623 ddi_prop_free(prop_val); 23223859Sml29623 } 23233859Sml29623 break; 23243859Sml29623 case CFG_L3_WEB: 23253859Sml29623 case CFG_L3_DISTRIBUTE: 23263859Sml29623 case CFG_L2_CLASSIFY: 23273859Sml29623 case CFG_L3_TCAM: 23283859Sml29623 rdcgrp_cfg = rx_quick_cfg; 23293859Sml29623 break; 23303859Sml29623 default: 23313859Sml29623 rdcgrp_cfg = CFG_L3_DISTRIBUTE; 23323859Sml29623 break; 23333859Sml29623 } 23343859Sml29623 23353859Sml29623 /* Receive DMA Channels */ 23363859Sml29623 st_rdc = p_cfgp->start_rdc; 23373859Sml29623 nxgep->nrdc = p_cfgp->max_rdcs; 23383859Sml29623 23393859Sml29623 for (i = 0; i < p_cfgp->max_rdcs; i++) { 23403859Sml29623 nxgep->rdc[i] = i + p_cfgp->start_rdc; 23413859Sml29623 } 23423859Sml29623 23433859Sml29623 switch (rdcgrp_cfg) { 23443859Sml29623 case CFG_L3_DISTRIBUTE: 23453859Sml29623 case CFG_L3_WEB: 23463859Sml29623 case CFG_L3_TCAM: 23473859Sml29623 ndmas = p_cfgp->max_rdcs; 23483859Sml29623 ngrps = 1; 23493859Sml29623 rdcs_per_grp = ndmas / ngrps; 23503859Sml29623 break; 23513859Sml29623 case CFG_L2_CLASSIFY: 23523859Sml29623 ndmas = p_cfgp->max_rdcs / 2; 23533859Sml29623 if (p_cfgp->max_rdcs < 2) 23543859Sml29623 ndmas = 1; 23553859Sml29623 ngrps = 1; 23563859Sml29623 rdcs_per_grp = ndmas / ngrps; 23573859Sml29623 break; 23583859Sml29623 default: 23593859Sml29623 ngrps = p_cfgp->max_rdc_grpids; 23603859Sml29623 ndmas = p_cfgp->max_rdcs; 23613859Sml29623 rdcs_per_grp = ndmas / ngrps; 23623859Sml29623 break; 23633859Sml29623 } 23643859Sml29623 23653859Sml29623 for (i = 0; i < ngrps; i++) { 23663859Sml29623 rdc_grp_p = &p_dma_cfgp->rdc_grps[i]; 23673859Sml29623 rdc_grp_p->start_rdc = st_rdc + i * rdcs_per_grp; 23683859Sml29623 rdc_grp_p->max_rdcs = rdcs_per_grp; 23693859Sml29623 23703859Sml29623 /* default to: 0, 1, 2, 3, ...., 0, 1, 2, 3.... */ 23713859Sml29623 rdc_grp_p->config_method = RDC_TABLE_ENTRY_METHOD_SEQ; 23723859Sml29623 rdc = rdc_grp_p->start_rdc; 23733859Sml29623 for (j = 0; j < NXGE_MAX_RDCS; j++) { 23743859Sml29623 rdc_grp_p->rdc[j] = rdc++; 23753859Sml29623 if (rdc == (rdc_grp_p->start_rdc + rdcs_per_grp)) { 23763859Sml29623 rdc = rdc_grp_p->start_rdc; 23773859Sml29623 } 23783859Sml29623 } 23793859Sml29623 rdc_grp_p->def_rdc = rdc_grp_p->rdc[0]; 23803859Sml29623 rdc_grp_p->flag = 1; /* configured */ 23813859Sml29623 } 23823859Sml29623 23833859Sml29623 /* default RDC */ 23843859Sml29623 p_cfgp->def_rdc = p_cfgp->start_rdc; 23853859Sml29623 nxgep->def_rdc = p_cfgp->start_rdc; 23863859Sml29623 23873859Sml29623 /* full 18 byte header ? */ 23883859Sml29623 p_dma_cfgp->rcr_full_header = NXGE_RCR_FULL_HEADER; 23893859Sml29623 p_dma_cfgp->rx_drr_weight = PT_DRR_WT_DEFAULT_10G; 23903859Sml29623 if (nxgep->function_num > 1) 23913859Sml29623 p_dma_cfgp->rx_drr_weight = PT_DRR_WT_DEFAULT_1G; 23923859Sml29623 p_dma_cfgp->rbr_size = nxge_rbr_size; 23933859Sml29623 p_dma_cfgp->rcr_size = nxge_rcr_size; 23943859Sml29623 23953859Sml29623 nxge_set_rdc_intr_property(nxgep); 23963859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_hw_dma_config")); 23973859Sml29623 } 23983859Sml29623 23993859Sml29623 boolean_t 24003859Sml29623 nxge_check_rxdma_port_member(p_nxge_t nxgep, uint8_t rdc) 24013859Sml29623 { 24023859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 24033859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 24043859Sml29623 int status = B_TRUE; 24053859Sml29623 24063859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rxdma_port_member")); 24073859Sml29623 24083859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 24093859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 24103859Sml29623 24113859Sml29623 /* Receive DMA Channels */ 24123859Sml29623 if (rdc < p_cfgp->max_rdcs) 24133859Sml29623 status = B_TRUE; 24143859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rxdma_port_member")); 24153859Sml29623 return (status); 24163859Sml29623 } 24173859Sml29623 24183859Sml29623 boolean_t 24193859Sml29623 nxge_check_txdma_port_member(p_nxge_t nxgep, uint8_t tdc) 24203859Sml29623 { 24213859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 24223859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 24233859Sml29623 int status = B_FALSE; 24243859Sml29623 24253859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rxdma_port_member")); 24263859Sml29623 24273859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 24283859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 24293859Sml29623 24303859Sml29623 /* Receive DMA Channels */ 24313859Sml29623 if (tdc < p_cfgp->max_tdcs) 24323859Sml29623 status = B_TRUE; 24333859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rxdma_port_member")); 24343859Sml29623 return (status); 24353859Sml29623 } 24363859Sml29623 24373859Sml29623 boolean_t 24383859Sml29623 nxge_check_rxdma_rdcgrp_member(p_nxge_t nxgep, uint8_t rdc_grp, uint8_t rdc) 24393859Sml29623 { 24403859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 24413859Sml29623 int status = B_TRUE; 24423859Sml29623 p_nxge_rdc_grp_t rdc_grp_p; 24433859Sml29623 24443859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 24453859Sml29623 " ==> nxge_check_rxdma_rdcgrp_member")); 24463859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " nxge_check_rxdma_rdcgrp_member" 24473859Sml29623 " rdc %d group %d", rdc, rdc_grp)); 24483859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 24493859Sml29623 24503859Sml29623 rdc_grp_p = &p_dma_cfgp->rdc_grps[rdc_grp]; 24513859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " max %d ", rdc_grp_p->max_rdcs)); 24523859Sml29623 if (rdc >= rdc_grp_p->max_rdcs) { 24533859Sml29623 status = B_FALSE; 24543859Sml29623 } 24553859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 24563859Sml29623 " <== nxge_check_rxdma_rdcgrp_member")); 24573859Sml29623 return (status); 24583859Sml29623 } 24593859Sml29623 24603859Sml29623 boolean_t 24613859Sml29623 nxge_check_rdcgrp_port_member(p_nxge_t nxgep, uint8_t rdc_grp) 24623859Sml29623 { 24633859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 24643859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 24653859Sml29623 int status = B_TRUE; 24663859Sml29623 24673859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, "==> nxge_check_rdcgrp_port_member")); 24683859Sml29623 24693859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 24703859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 24713859Sml29623 24723859Sml29623 if (rdc_grp >= p_cfgp->max_rdc_grpids) 24733859Sml29623 status = B_FALSE; 24743859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, " <== nxge_check_rdcgrp_port_member")); 24753859Sml29623 return (status); 24763859Sml29623 } 24773859Sml29623 24783859Sml29623 static void 24793859Sml29623 nxge_set_hw_vlan_class_config(p_nxge_t nxgep) 24803859Sml29623 { 24813859Sml29623 int i; 24823859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 24833859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 24843859Sml29623 p_nxge_param_t param_arr; 24853859Sml29623 uint_t vlan_cnt; 24863859Sml29623 int *vlan_cfg_val; 24873859Sml29623 nxge_param_map_t *vmap; 24883859Sml29623 char *prop; 24893859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 24903859Sml29623 uint32_t good_cfg[32]; 24913859Sml29623 int good_count = 0; 24923859Sml29623 nxge_mv_cfg_t *vlan_tbl; 24933859Sml29623 24943859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_hw_vlan_config")); 24953859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 24963859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 24973859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 24983859Sml29623 24993859Sml29623 param_arr = nxgep->param_arr; 25003859Sml29623 prop = param_arr[param_vlan_2rdc_grp].fcode_name; 25013859Sml29623 25023859Sml29623 /* 25033859Sml29623 * By default, VLAN to RDC group mapping is disabled Need to read HW or 25043859Sml29623 * .conf properties to find out if mapping is required 25053859Sml29623 * 25063859Sml29623 * Format 25073859Sml29623 * 25083859Sml29623 * uint32_t array, each array entry specifying the VLAN id and the 25093859Sml29623 * mapping 25103859Sml29623 * 25113859Sml29623 * bit[30] = add bit[29] = remove bit[28] = preference bits[23-16] = 25123859Sml29623 * rdcgrp bits[15-0] = VLAN ID ( ) 25133859Sml29623 */ 25143859Sml29623 25153859Sml29623 for (i = 0; i < NXGE_MAX_VLANS; i++) { 25163859Sml29623 p_class_cfgp->vlan_tbl[i].flag = 0; 25173859Sml29623 } 25183859Sml29623 25193859Sml29623 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0]; 25203859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 25213859Sml29623 &vlan_cfg_val, &vlan_cnt) == DDI_PROP_SUCCESS) { 25223859Sml29623 for (i = 0; i < vlan_cnt; i++) { 25233859Sml29623 vmap = (nxge_param_map_t *)&vlan_cfg_val[i]; 25243859Sml29623 if ((vmap->param_id) && 25253859Sml29623 (vmap->param_id < NXGE_MAX_VLANS) && 25263859Sml29623 (vmap->map_to < 25273859Sml29623 p_cfgp->max_rdc_grpids) && 25283859Sml29623 (vmap->map_to >= (uint8_t)0)) { 25293859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 25303859Sml29623 " nxge_vlan_config mapping" 25313859Sml29623 " id %d grp %d", 25323859Sml29623 vmap->param_id, vmap->map_to)); 25333859Sml29623 good_cfg[good_count] = vlan_cfg_val[i]; 25343859Sml29623 if (vlan_tbl[vmap->param_id].flag == 0) 25353859Sml29623 good_count++; 25363859Sml29623 vlan_tbl[vmap->param_id].flag = 1; 25373859Sml29623 vlan_tbl[vmap->param_id].rdctbl = 25383859Sml29623 vmap->map_to + p_cfgp->start_rdc_grpid; 25393859Sml29623 vlan_tbl[vmap->param_id].mpr_npr = vmap->pref; 25403859Sml29623 } 25413859Sml29623 } 25423859Sml29623 ddi_prop_free(vlan_cfg_val); 25433859Sml29623 if (good_count != vlan_cnt) { 25443859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 25453859Sml29623 nxgep->dip, prop, (int *)good_cfg, good_count); 25463859Sml29623 } 25473859Sml29623 } 25483859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_set_hw_vlan_config")); 25493859Sml29623 } 25503859Sml29623 25513859Sml29623 static void 25523859Sml29623 nxge_set_hw_mac_class_config(p_nxge_t nxgep) 25533859Sml29623 { 25543859Sml29623 int i; 25553859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 25563859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 25573859Sml29623 p_nxge_param_t param_arr; 25583859Sml29623 uint_t mac_cnt; 25593859Sml29623 int *mac_cfg_val; 25603859Sml29623 nxge_param_map_t *mac_map; 25613859Sml29623 char *prop; 25623859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 25633859Sml29623 int good_count = 0; 25643859Sml29623 int good_cfg[NXGE_MAX_MACS]; 25653859Sml29623 nxge_mv_cfg_t *mac_host_info; 25663859Sml29623 25673859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "==> nxge_set_hw_mac_config")); 25683859Sml29623 25693859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 25703859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 25713859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 25723859Sml29623 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0]; 25733859Sml29623 25743859Sml29623 param_arr = nxgep->param_arr; 25753859Sml29623 prop = param_arr[param_mac_2rdc_grp].fcode_name; 25763859Sml29623 25773859Sml29623 for (i = 0; i < NXGE_MAX_MACS; i++) { 25783859Sml29623 p_class_cfgp->mac_host_info[i].flag = 0; 25793859Sml29623 } 25803859Sml29623 25813859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 25823859Sml29623 &mac_cfg_val, &mac_cnt) == DDI_PROP_SUCCESS) { 25833859Sml29623 for (i = 0; i < mac_cnt; i++) { 25843859Sml29623 mac_map = (nxge_param_map_t *)&mac_cfg_val[i]; 25853859Sml29623 if ((mac_map->param_id < p_cfgp->max_macs) && 25863859Sml29623 (mac_map->map_to < 25873859Sml29623 p_cfgp->max_rdc_grpids) && 25883859Sml29623 (mac_map->map_to >= (uint8_t)0)) { 25893859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG2_CTL, 25903859Sml29623 " nxge_mac_config mapping" 25913859Sml29623 " id %d grp %d", 25923859Sml29623 mac_map->param_id, mac_map->map_to)); 25933859Sml29623 mac_host_info[mac_map->param_id].mpr_npr = 25943859Sml29623 mac_map->pref; 25953859Sml29623 mac_host_info[mac_map->param_id].rdctbl = 25963859Sml29623 mac_map->map_to + 25973859Sml29623 p_cfgp->start_rdc_grpid; 25983859Sml29623 good_cfg[good_count] = mac_cfg_val[i]; 25993859Sml29623 if (mac_host_info[mac_map->param_id].flag == 0) 26003859Sml29623 good_count++; 26013859Sml29623 mac_host_info[mac_map->param_id].flag = 1; 26023859Sml29623 } 26033859Sml29623 } 26043859Sml29623 ddi_prop_free(mac_cfg_val); 26053859Sml29623 if (good_count != mac_cnt) { 26063859Sml29623 (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, 26073859Sml29623 nxgep->dip, prop, good_cfg, good_count); 26083859Sml29623 } 26093859Sml29623 } 26103859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, "<== nxge_set_hw_mac_config")); 26113859Sml29623 } 26123859Sml29623 26133859Sml29623 static void 26143859Sml29623 nxge_set_hw_class_config(p_nxge_t nxgep) 26153859Sml29623 { 26163859Sml29623 int i; 26173859Sml29623 p_nxge_param_t param_arr; 26183859Sml29623 int *int_prop_val; 26193859Sml29623 uint32_t cfg_value; 26203859Sml29623 char *prop; 26213859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 26223859Sml29623 int start_prop, end_prop; 26233859Sml29623 uint_t prop_cnt; 26243859Sml29623 26253859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " ==> nxge_set_hw_class_config")); 26263859Sml29623 26273859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 26283859Sml29623 param_arr = nxgep->param_arr; 26293859Sml29623 start_prop = param_class_opt_ip_usr4; 26303859Sml29623 end_prop = param_class_opt_ipv6_sctp; 26313859Sml29623 26323859Sml29623 for (i = start_prop; i <= end_prop; i++) { 26333859Sml29623 prop = param_arr[i].fcode_name; 26343859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 26353859Sml29623 0, prop, &int_prop_val, 26363859Sml29623 &prop_cnt) == DDI_PROP_SUCCESS) { 26373859Sml29623 cfg_value = (uint32_t)*int_prop_val; 26383859Sml29623 ddi_prop_free(int_prop_val); 26393859Sml29623 } else { 26403859Sml29623 cfg_value = (uint32_t)param_arr[i].value; 26413859Sml29623 } 26423859Sml29623 p_class_cfgp->class_cfg[i - start_prop] = cfg_value; 26433859Sml29623 } 26443859Sml29623 26453859Sml29623 prop = param_arr[param_h1_init_value].fcode_name; 26463859Sml29623 26473859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 26483859Sml29623 &int_prop_val, &prop_cnt) == DDI_PROP_SUCCESS) { 26493859Sml29623 cfg_value = (uint32_t)*int_prop_val; 26503859Sml29623 ddi_prop_free(int_prop_val); 26513859Sml29623 } else { 26523859Sml29623 cfg_value = (uint32_t)param_arr[param_h1_init_value].value; 26533859Sml29623 } 26543859Sml29623 26553859Sml29623 p_class_cfgp->init_h1 = (uint32_t)cfg_value; 26563859Sml29623 prop = param_arr[param_h2_init_value].fcode_name; 26573859Sml29623 26583859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, prop, 26593859Sml29623 &int_prop_val, &prop_cnt) == DDI_PROP_SUCCESS) { 26603859Sml29623 cfg_value = (uint32_t)*int_prop_val; 26613859Sml29623 ddi_prop_free(int_prop_val); 26623859Sml29623 } else { 26633859Sml29623 cfg_value = (uint32_t)param_arr[param_h2_init_value].value; 26643859Sml29623 } 26653859Sml29623 26663859Sml29623 p_class_cfgp->init_h2 = (uint16_t)cfg_value; 26673859Sml29623 NXGE_DEBUG_MSG((nxgep, CFG_CTL, " <== nxge_set_hw_class_config")); 26683859Sml29623 } 26693859Sml29623 26703859Sml29623 nxge_status_t 26713859Sml29623 nxge_ldgv_init_n2(p_nxge_t nxgep, int *navail_p, int *nrequired_p) 26723859Sml29623 { 26733859Sml29623 int i, maxldvs, maxldgs, start, end, nldvs; 26743859Sml29623 int ldv, endldg; 26753859Sml29623 uint8_t func; 26763859Sml29623 uint8_t channel; 26773859Sml29623 uint8_t chn_start; 26783859Sml29623 boolean_t own_sys_err = B_FALSE, own_fzc = B_FALSE; 26793859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 26803859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 26813859Sml29623 p_nxge_ldgv_t ldgvp; 26823859Sml29623 p_nxge_ldg_t ldgp, ptr; 26833859Sml29623 p_nxge_ldv_t ldvp; 26843859Sml29623 nxge_status_t status = NXGE_OK; 26853859Sml29623 26863859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2")); 26873859Sml29623 if (!*navail_p) { 26883859Sml29623 *nrequired_p = 0; 26893859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 26903859Sml29623 "<== nxge_ldgv_init:no avail")); 26913859Sml29623 return (NXGE_ERROR); 26923859Sml29623 } 26933859Sml29623 /* 26943859Sml29623 * N2/NIU: one logical device owns one logical group. and each 26953859Sml29623 * device/group will be assigned one vector by Hypervisor. 26963859Sml29623 */ 26973859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 26983859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 26993859Sml29623 maxldgs = p_cfgp->max_ldgs; 27003859Sml29623 if (!maxldgs) { 27013859Sml29623 /* No devices configured. */ 27023859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_init_n2: " 27033859Sml29623 "no logical groups configured.")); 27043859Sml29623 return (NXGE_ERROR); 27053859Sml29623 } else { 27063859Sml29623 maxldvs = maxldgs + 1; 27073859Sml29623 } 27083859Sml29623 27093859Sml29623 /* 27103859Sml29623 * If function zero instance, it needs to handle the system and MIF 27113859Sml29623 * error interrupts. MIF interrupt may not be needed for N2/NIU. 27123859Sml29623 */ 27133859Sml29623 func = nxgep->function_num; 27143859Sml29623 if (func == 0) { 27153859Sml29623 own_sys_err = B_TRUE; 27163859Sml29623 if (!p_cfgp->ser_ldvid) { 27173859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 27183859Sml29623 "nxge_ldgv_init_n2: func 0, ERR ID not set!")); 27193859Sml29623 } 27203859Sml29623 /* MIF interrupt */ 27213859Sml29623 if (!p_cfgp->mif_ldvid) { 27223859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 27233859Sml29623 "nxge_ldgv_init_n2: func 0, MIF ID not set!")); 27243859Sml29623 } 27253859Sml29623 } 27263859Sml29623 27273859Sml29623 /* 27283859Sml29623 * Assume single partition, each function owns mac. 27293859Sml29623 */ 27303859Sml29623 if (!nxge_use_partition) 27313859Sml29623 own_fzc = B_TRUE; 27323859Sml29623 27333859Sml29623 ldgvp = nxgep->ldgvp; 27343859Sml29623 if (ldgvp == NULL) { 27353859Sml29623 ldgvp = KMEM_ZALLOC(sizeof (nxge_ldgv_t), KM_SLEEP); 27363859Sml29623 nxgep->ldgvp = ldgvp; 27373859Sml29623 ldgvp->maxldgs = (uint8_t)maxldgs; 27383859Sml29623 ldgvp->maxldvs = (uint8_t)maxldvs; 27393859Sml29623 ldgp = ldgvp->ldgp = KMEM_ZALLOC(sizeof (nxge_ldg_t) * maxldgs, 27403859Sml29623 KM_SLEEP); 27413859Sml29623 ldvp = ldgvp->ldvp = KMEM_ZALLOC(sizeof (nxge_ldv_t) * maxldvs, 27423859Sml29623 KM_SLEEP); 27433859Sml29623 } else { 27443859Sml29623 ldgp = ldgvp->ldgp; 27453859Sml29623 ldvp = ldgvp->ldvp; 27463859Sml29623 } 27473859Sml29623 27483859Sml29623 ldgvp->ndma_ldvs = p_cfgp->max_tdcs + p_cfgp->max_rdcs; 27493859Sml29623 ldgvp->tmres = NXGE_TIMER_RESO; 27503859Sml29623 27513859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 27523859Sml29623 "==> nxge_ldgv_init_n2: maxldvs %d maxldgs %d", 27533859Sml29623 maxldvs, maxldgs)); 27543859Sml29623 27553859Sml29623 /* logical start_ldg is ldv */ 27563859Sml29623 ptr = ldgp; 27573859Sml29623 for (i = 0; i < maxldgs; i++) { 27583859Sml29623 ptr->func = func; 27593859Sml29623 ptr->arm = B_TRUE; 27603859Sml29623 ptr->vldg_index = (uint8_t)i; 27613859Sml29623 ptr->ldg_timer = NXGE_TIMER_LDG; 27623859Sml29623 ptr->ldg = p_cfgp->ldg[i]; 27633859Sml29623 ptr->sys_intr_handler = nxge_intr; 27643859Sml29623 ptr->nldvs = 0; 27653859Sml29623 ptr->ldvp = NULL; 27663859Sml29623 ptr->nxgep = nxgep; 27673859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 27683859Sml29623 "==> nxge_ldgv_init_n2: maxldvs %d maxldgs %d " 27693859Sml29623 "ldg %d ldgptr $%p", 27703859Sml29623 maxldvs, maxldgs, ptr->ldg, ptr)); 27713859Sml29623 ptr++; 27723859Sml29623 } 27733859Sml29623 27743859Sml29623 endldg = NXGE_INT_MAX_LDG; 27753859Sml29623 nldvs = 0; 27763859Sml29623 ldgvp->nldvs = 0; 27773859Sml29623 ldgp->ldvp = NULL; 27783859Sml29623 *nrequired_p = 0; 27793859Sml29623 27803859Sml29623 /* 27813859Sml29623 * logical device group table is organized in the following order (same 27823859Sml29623 * as what interrupt property has). function 0: owns MAC, MIF, error, 27833859Sml29623 * rx, tx. function 1: owns MAC, rx, tx. 27843859Sml29623 */ 27853859Sml29623 27863859Sml29623 if (own_fzc && p_cfgp->mac_ldvid) { 27873859Sml29623 /* Each function should own MAC interrupt */ 27883859Sml29623 ldv = p_cfgp->mac_ldvid; 27893859Sml29623 ldvp->ldv = (uint8_t)ldv; 27903859Sml29623 ldvp->is_mac = B_TRUE; 27913859Sml29623 ldvp->ldv_intr_handler = nxge_mac_intr; 27923859Sml29623 ldvp->ldv_ldf_masks = 0; 27933859Sml29623 ldvp->nxgep = nxgep; 27943859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 27953859Sml29623 "==> nxge_ldgv_init_n2(mac): maxldvs %d ldv %d " 27963859Sml29623 "ldg %d ldgptr $%p ldvptr $%p", 27973859Sml29623 maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 27983859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 27993859Sml29623 nldvs++; 28003859Sml29623 } 28013859Sml29623 28023859Sml29623 if (own_fzc && p_cfgp->mif_ldvid) { 28033859Sml29623 ldv = p_cfgp->mif_ldvid; 28043859Sml29623 ldvp->ldv = (uint8_t)ldv; 28053859Sml29623 ldvp->is_mif = B_TRUE; 28063859Sml29623 ldvp->ldv_intr_handler = nxge_mif_intr; 28073859Sml29623 ldvp->ldv_ldf_masks = 0; 28083859Sml29623 ldvp->nxgep = nxgep; 28093859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 28103859Sml29623 "==> nxge_ldgv_init_n2(mif): maxldvs %d ldv %d " 28113859Sml29623 "ldg %d ldgptr $%p ldvptr $%p", 28123859Sml29623 maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 28133859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 28143859Sml29623 nldvs++; 28153859Sml29623 } 28163859Sml29623 28173859Sml29623 ldv = NXGE_SYS_ERROR_LD; 28183859Sml29623 ldvp->use_timer = B_TRUE; 28193859Sml29623 if (own_sys_err && p_cfgp->ser_ldvid) { 28203859Sml29623 ldv = p_cfgp->ser_ldvid; 28213859Sml29623 /* 28223859Sml29623 * Unmask the system interrupt states. 28233859Sml29623 */ 28243859Sml29623 (void) nxge_fzc_sys_err_mask_set(nxgep, SYS_ERR_SMX_MASK | 28253859Sml29623 SYS_ERR_IPP_MASK | SYS_ERR_TXC_MASK | 28263859Sml29623 SYS_ERR_ZCP_MASK); 28273859Sml29623 } 28283859Sml29623 ldvp->ldv = (uint8_t)ldv; 28293859Sml29623 ldvp->is_syserr = B_TRUE; 28303859Sml29623 ldvp->ldv_intr_handler = nxge_syserr_intr; 28313859Sml29623 ldvp->ldv_ldf_masks = 0; 28323859Sml29623 ldvp->nxgep = nxgep; 28333859Sml29623 ldgvp->ldvp_syserr = ldvp; 28343859Sml29623 28353859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 28363859Sml29623 "==> nxge_ldgv_init_n2(syserr): maxldvs %d ldv %d " 28373859Sml29623 "ldg %d ldgptr $%p ldvptr p%p", 28383859Sml29623 maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 28393859Sml29623 28403859Sml29623 if (own_sys_err && p_cfgp->ser_ldvid) { 28413859Sml29623 (void) nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 28423859Sml29623 } else { 28433859Sml29623 ldvp++; 28443859Sml29623 } 28453859Sml29623 28463859Sml29623 nldvs++; 28473859Sml29623 28483859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 28493859Sml29623 "(before rx) func %d nldvs %d navail %d nrequired %d", 28503859Sml29623 func, nldvs, *navail_p, *nrequired_p)); 28513859Sml29623 28523859Sml29623 /* 28533859Sml29623 * Receive DMA channels. 28543859Sml29623 */ 28553859Sml29623 channel = p_cfgp->start_rdc; 28563859Sml29623 start = p_cfgp->start_rdc + NXGE_RDMA_LD_START; 28573859Sml29623 end = start + p_cfgp->max_rdcs; 28583859Sml29623 chn_start = p_cfgp->ldg_chn_start; 28593859Sml29623 /* 28603859Sml29623 * Start with RDC to configure logical devices for each group. 28613859Sml29623 */ 28623859Sml29623 for (i = 0, ldv = start; ldv < end; i++, ldv++, chn_start++) { 28633859Sml29623 ldvp->is_rxdma = B_TRUE; 28643859Sml29623 ldvp->ldv = (uint8_t)ldv; 28653859Sml29623 ldvp->channel = channel++; 28663859Sml29623 ldvp->vdma_index = (uint8_t)i; 28673859Sml29623 ldvp->ldv_intr_handler = nxge_rx_intr; 28683859Sml29623 ldvp->ldv_ldf_masks = 0; 28693859Sml29623 ldvp->nxgep = nxgep; 28703859Sml29623 ldgp->ldg = p_cfgp->ldg[chn_start]; 28713859Sml29623 28723859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 28733859Sml29623 "==> nxge_ldgv_init_n2(rx%d): maxldvs %d ldv %d " 28743859Sml29623 "ldg %d ldgptr 0x%016llx ldvptr 0x%016llx", 28753859Sml29623 i, maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 28763859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 28773859Sml29623 nldvs++; 28783859Sml29623 } 28793859Sml29623 28803859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 28813859Sml29623 "func %d nldvs %d navail %d nrequired %d", 28823859Sml29623 func, nldvs, *navail_p, *nrequired_p)); 28833859Sml29623 28843859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 28853859Sml29623 "func %d nldvs %d navail %d nrequired %d ldgp 0x%llx " 28863859Sml29623 "ldvp 0x%llx", 28873859Sml29623 func, nldvs, *navail_p, *nrequired_p, ldgp, ldvp)); 28883859Sml29623 /* 28893859Sml29623 * Transmit DMA channels. 28903859Sml29623 */ 28913859Sml29623 channel = p_cfgp->start_tdc; 28923859Sml29623 start = p_cfgp->start_tdc + NXGE_TDMA_LD_START; 28933859Sml29623 end = start + p_cfgp->max_tdcs; 28943859Sml29623 for (i = 0, ldv = start; ldv < end; i++, ldv++, chn_start++) { 28953859Sml29623 ldvp->is_txdma = B_TRUE; 28963859Sml29623 ldvp->ldv = (uint8_t)ldv; 28973859Sml29623 ldvp->channel = channel++; 28983859Sml29623 ldvp->vdma_index = (uint8_t)i; 28993859Sml29623 ldvp->ldv_intr_handler = nxge_tx_intr; 29003859Sml29623 ldvp->ldv_ldf_masks = 0; 29013859Sml29623 ldgp->ldg = p_cfgp->ldg[chn_start]; 29023859Sml29623 ldvp->nxgep = nxgep; 29033859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 29043859Sml29623 "==> nxge_ldgv_init_n2(tx%d): maxldvs %d ldv %d " 29053859Sml29623 "ldg %d ldgptr 0x%016llx ldvptr 0x%016llx", 29063859Sml29623 i, maxldvs, ldv, ldgp->ldg, ldgp, ldvp)); 29073859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 29083859Sml29623 nldvs++; 29093859Sml29623 } 29103859Sml29623 29113859Sml29623 ldgvp->ldg_intrs = *nrequired_p; 29123859Sml29623 ldgvp->nldvs = (uint8_t)nldvs; 29133859Sml29623 29143859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init_n2: " 29153859Sml29623 "func %d nldvs %d maxgrps %d navail %d nrequired %d", 29163859Sml29623 func, nldvs, maxldgs, *navail_p, *nrequired_p)); 29173859Sml29623 29183859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_init_n2")); 29193859Sml29623 return (status); 29203859Sml29623 } 29213859Sml29623 29223859Sml29623 /* 29233859Sml29623 * Interrupts related interface functions. 29243859Sml29623 */ 29253859Sml29623 29263859Sml29623 nxge_status_t 29273859Sml29623 nxge_ldgv_init(p_nxge_t nxgep, int *navail_p, int *nrequired_p) 29283859Sml29623 { 29293859Sml29623 int i, maxldvs, maxldgs, start, end, nldvs; 29303859Sml29623 int ldv, ldg, endldg, ngrps; 29313859Sml29623 uint8_t func; 29323859Sml29623 uint8_t channel; 29333859Sml29623 boolean_t own_sys_err = B_FALSE, own_fzc = B_FALSE; 29343859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 29353859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 29363859Sml29623 p_nxge_ldgv_t ldgvp; 29373859Sml29623 p_nxge_ldg_t ldgp, ptr; 29383859Sml29623 p_nxge_ldv_t ldvp; 29393859Sml29623 nxge_status_t status = NXGE_OK; 29403859Sml29623 29413859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init")); 29423859Sml29623 if (!*navail_p) { 29433859Sml29623 *nrequired_p = 0; 29443859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 29453859Sml29623 "<== nxge_ldgv_init:no avail")); 29463859Sml29623 return (NXGE_ERROR); 29473859Sml29623 } 29483859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 29493859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 29503859Sml29623 29513859Sml29623 nldvs = p_cfgp->max_tdcs + p_cfgp->max_rdcs; 29523859Sml29623 29533859Sml29623 /* 29543859Sml29623 * If function zero instance, it needs to handle the system error 29553859Sml29623 * interrupts. 29563859Sml29623 */ 29573859Sml29623 func = nxgep->function_num; 29583859Sml29623 if (func == 0) { 29593859Sml29623 nldvs++; 29603859Sml29623 own_sys_err = B_TRUE; 29613859Sml29623 } else { 29623859Sml29623 /* use timer */ 29633859Sml29623 nldvs++; 29643859Sml29623 } 29653859Sml29623 29663859Sml29623 /* 29673859Sml29623 * Assume single partition, each function owns mac. 29683859Sml29623 */ 29693859Sml29623 if (!nxge_use_partition) { 29703859Sml29623 /* mac */ 29713859Sml29623 nldvs++; 29723859Sml29623 /* MIF */ 29733859Sml29623 nldvs++; 29743859Sml29623 own_fzc = B_TRUE; 29753859Sml29623 } 29763859Sml29623 maxldvs = nldvs; 29773859Sml29623 maxldgs = p_cfgp->max_ldgs; 29783859Sml29623 if (!maxldvs || !maxldgs) { 29793859Sml29623 /* No devices configured. */ 29803859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_init: " 29813859Sml29623 "no logical devices or groups configured.")); 29823859Sml29623 return (NXGE_ERROR); 29833859Sml29623 } 29843859Sml29623 ldgvp = nxgep->ldgvp; 29853859Sml29623 if (ldgvp == NULL) { 29863859Sml29623 ldgvp = KMEM_ZALLOC(sizeof (nxge_ldgv_t), KM_SLEEP); 29873859Sml29623 nxgep->ldgvp = ldgvp; 29883859Sml29623 ldgvp->maxldgs = (uint8_t)maxldgs; 29893859Sml29623 ldgvp->maxldvs = (uint8_t)maxldvs; 29903859Sml29623 ldgp = ldgvp->ldgp = KMEM_ZALLOC(sizeof (nxge_ldg_t) * maxldgs, 29913859Sml29623 KM_SLEEP); 29923859Sml29623 ldvp = ldgvp->ldvp = KMEM_ZALLOC(sizeof (nxge_ldv_t) * maxldvs, 29933859Sml29623 KM_SLEEP); 29943859Sml29623 } 29953859Sml29623 ldgvp->ndma_ldvs = p_cfgp->max_tdcs + p_cfgp->max_rdcs; 29963859Sml29623 ldgvp->tmres = NXGE_TIMER_RESO; 29973859Sml29623 29983859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 29993859Sml29623 "==> nxge_ldgv_init: maxldvs %d maxldgs %d nldvs %d", 30003859Sml29623 maxldvs, maxldgs, nldvs)); 30013859Sml29623 ldg = p_cfgp->start_ldg; 30023859Sml29623 ptr = ldgp; 30033859Sml29623 for (i = 0; i < maxldgs; i++) { 30043859Sml29623 ptr->func = func; 30053859Sml29623 ptr->arm = B_TRUE; 30063859Sml29623 ptr->vldg_index = (uint8_t)i; 30073859Sml29623 ptr->ldg_timer = NXGE_TIMER_LDG; 30083859Sml29623 ptr->ldg = ldg++; 30093859Sml29623 ptr->sys_intr_handler = nxge_intr; 30103859Sml29623 ptr->nldvs = 0; 30113859Sml29623 ptr->nxgep = nxgep; 30123859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 30133859Sml29623 "==> nxge_ldgv_init: maxldvs %d maxldgs %d ldg %d", 30143859Sml29623 maxldvs, maxldgs, ptr->ldg)); 30153859Sml29623 ptr++; 30163859Sml29623 } 30173859Sml29623 30183859Sml29623 ldg = p_cfgp->start_ldg; 30193859Sml29623 if (maxldgs > *navail_p) { 30203859Sml29623 ngrps = *navail_p; 30213859Sml29623 } else { 30223859Sml29623 ngrps = maxldgs; 30233859Sml29623 } 30243859Sml29623 endldg = ldg + ngrps; 30253859Sml29623 30263859Sml29623 /* 30273859Sml29623 * Receive DMA channels. 30283859Sml29623 */ 30293859Sml29623 channel = p_cfgp->start_rdc; 30303859Sml29623 start = p_cfgp->start_rdc + NXGE_RDMA_LD_START; 30313859Sml29623 end = start + p_cfgp->max_rdcs; 30323859Sml29623 nldvs = 0; 30333859Sml29623 ldgvp->nldvs = 0; 30343859Sml29623 ldgp->ldvp = NULL; 30353859Sml29623 *nrequired_p = 0; 30363859Sml29623 30373859Sml29623 /* 30383859Sml29623 * Start with RDC to configure logical devices for each group. 30393859Sml29623 */ 30403859Sml29623 for (i = 0, ldv = start; ldv < end; i++, ldv++) { 30413859Sml29623 ldvp->is_rxdma = B_TRUE; 30423859Sml29623 ldvp->ldv = (uint8_t)ldv; 30433859Sml29623 /* If non-seq needs to change the following code */ 30443859Sml29623 ldvp->channel = channel++; 30453859Sml29623 ldvp->vdma_index = (uint8_t)i; 30463859Sml29623 ldvp->ldv_intr_handler = nxge_rx_intr; 30473859Sml29623 ldvp->ldv_ldf_masks = 0; 30483859Sml29623 ldvp->use_timer = B_FALSE; 30493859Sml29623 ldvp->nxgep = nxgep; 30503859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 30513859Sml29623 nldvs++; 30523859Sml29623 } 30533859Sml29623 30543859Sml29623 /* 30553859Sml29623 * Transmit DMA channels. 30563859Sml29623 */ 30573859Sml29623 channel = p_cfgp->start_tdc; 30583859Sml29623 start = p_cfgp->start_tdc + NXGE_TDMA_LD_START; 30593859Sml29623 end = start + p_cfgp->max_tdcs; 30603859Sml29623 for (i = 0, ldv = start; ldv < end; i++, ldv++) { 30613859Sml29623 ldvp->is_txdma = B_TRUE; 30623859Sml29623 ldvp->ldv = (uint8_t)ldv; 30633859Sml29623 ldvp->channel = channel++; 30643859Sml29623 ldvp->vdma_index = (uint8_t)i; 30653859Sml29623 ldvp->ldv_intr_handler = nxge_tx_intr; 30663859Sml29623 ldvp->ldv_ldf_masks = 0; 30673859Sml29623 ldvp->use_timer = B_FALSE; 30683859Sml29623 ldvp->nxgep = nxgep; 30693859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 30703859Sml29623 nldvs++; 30713859Sml29623 } 30723859Sml29623 30733859Sml29623 if (own_fzc) { 30743859Sml29623 ldv = NXGE_MIF_LD; 30753859Sml29623 ldvp->ldv = (uint8_t)ldv; 30763859Sml29623 ldvp->is_mif = B_TRUE; 30773859Sml29623 ldvp->ldv_intr_handler = nxge_mif_intr; 30783859Sml29623 ldvp->ldv_ldf_masks = 0; 30793859Sml29623 ldvp->use_timer = B_FALSE; 30803859Sml29623 ldvp->nxgep = nxgep; 30813859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 30823859Sml29623 nldvs++; 30833859Sml29623 } 30843859Sml29623 /* 30853859Sml29623 * MAC port (function zero control) 30863859Sml29623 */ 30873859Sml29623 if (own_fzc) { 30883859Sml29623 ldvp->is_mac = B_TRUE; 30893859Sml29623 ldvp->ldv_intr_handler = nxge_mac_intr; 30903859Sml29623 ldvp->ldv_ldf_masks = 0; 30913859Sml29623 ldv = func + NXGE_MAC_LD_START; 30923859Sml29623 ldvp->ldv = (uint8_t)ldv; 30933859Sml29623 ldvp->use_timer = B_FALSE; 30943859Sml29623 ldvp->nxgep = nxgep; 30953859Sml29623 nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 30963859Sml29623 nldvs++; 30973859Sml29623 } 30983859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init: " 30993859Sml29623 "func %d nldvs %d navail %d nrequired %d", 31003859Sml29623 func, nldvs, *navail_p, *nrequired_p)); 31013859Sml29623 /* 31023859Sml29623 * Function 0 owns system error interrupts. 31033859Sml29623 */ 31043859Sml29623 ldvp->use_timer = B_TRUE; 31053859Sml29623 if (own_sys_err) { 31063859Sml29623 ldv = NXGE_SYS_ERROR_LD; 31073859Sml29623 ldvp->ldv = (uint8_t)ldv; 31083859Sml29623 ldvp->is_syserr = B_TRUE; 31093859Sml29623 ldvp->ldv_intr_handler = nxge_syserr_intr; 31103859Sml29623 ldvp->ldv_ldf_masks = 0; 31113859Sml29623 ldvp->nxgep = nxgep; 31123859Sml29623 ldgvp->ldvp_syserr = ldvp; 31133859Sml29623 /* 31143859Sml29623 * Unmask the system interrupt states. 31153859Sml29623 */ 31163859Sml29623 (void) nxge_fzc_sys_err_mask_set(nxgep, SYS_ERR_SMX_MASK | 31173859Sml29623 SYS_ERR_IPP_MASK | SYS_ERR_TXC_MASK | 31183859Sml29623 SYS_ERR_ZCP_MASK); 31193859Sml29623 31203859Sml29623 (void) nxge_ldgv_setup(&ldgp, &ldvp, ldv, endldg, nrequired_p); 31213859Sml29623 nldvs++; 31223859Sml29623 } else { 31233859Sml29623 ldv = NXGE_SYS_ERROR_LD; 31243859Sml29623 ldvp->ldv = (uint8_t)ldv; 31253859Sml29623 ldvp->is_syserr = B_TRUE; 31263859Sml29623 ldvp->ldv_intr_handler = nxge_syserr_intr; 31273859Sml29623 ldvp->nxgep = nxgep; 31283859Sml29623 ldvp->ldv_ldf_masks = 0; 31293859Sml29623 ldgvp->ldvp_syserr = ldvp; 31303859Sml29623 } 31313859Sml29623 31323859Sml29623 ldgvp->ldg_intrs = *nrequired_p; 31333859Sml29623 31343859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_init: " 31353859Sml29623 "func %d nldvs %d navail %d nrequired %d", 31363859Sml29623 func, nldvs, *navail_p, *nrequired_p)); 31373859Sml29623 31383859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_init")); 31393859Sml29623 return (status); 31403859Sml29623 } 31413859Sml29623 31423859Sml29623 nxge_status_t 31433859Sml29623 nxge_ldgv_uninit(p_nxge_t nxgep) 31443859Sml29623 { 31453859Sml29623 p_nxge_ldgv_t ldgvp; 31463859Sml29623 31473859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_ldgv_uninit")); 31483859Sml29623 ldgvp = nxgep->ldgvp; 31493859Sml29623 if (ldgvp == NULL) { 31503859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "<== nxge_ldgv_uninit: " 31513859Sml29623 "no logical group configured.")); 31523859Sml29623 return (NXGE_OK); 31533859Sml29623 } 31543859Sml29623 if (ldgvp->ldgp) { 31553859Sml29623 KMEM_FREE(ldgvp->ldgp, sizeof (nxge_ldg_t) * ldgvp->maxldgs); 31563859Sml29623 } 31573859Sml29623 if (ldgvp->ldvp) { 31583859Sml29623 KMEM_FREE(ldgvp->ldvp, sizeof (nxge_ldv_t) * ldgvp->maxldvs); 31593859Sml29623 } 31603859Sml29623 KMEM_FREE(ldgvp, sizeof (nxge_ldgv_t)); 31613859Sml29623 nxgep->ldgvp = NULL; 31623859Sml29623 31633859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_ldgv_uninit")); 31643859Sml29623 return (NXGE_OK); 31653859Sml29623 } 31663859Sml29623 31673859Sml29623 nxge_status_t 31683859Sml29623 nxge_intr_ldgv_init(p_nxge_t nxgep) 31693859Sml29623 { 31703859Sml29623 nxge_status_t status = NXGE_OK; 31713859Sml29623 31723859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_ldgv_init")); 31733859Sml29623 /* 31743859Sml29623 * Configure the logical device group numbers, state vectors and 31753859Sml29623 * interrupt masks for each logical device. 31763859Sml29623 */ 31773859Sml29623 status = nxge_fzc_intr_init(nxgep); 31783859Sml29623 31793859Sml29623 /* 31803859Sml29623 * Configure logical device masks and timers. 31813859Sml29623 */ 31823859Sml29623 status = nxge_intr_mask_mgmt(nxgep); 31833859Sml29623 31843859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_ldgv_init")); 31853859Sml29623 return (status); 31863859Sml29623 } 31873859Sml29623 31883859Sml29623 nxge_status_t 31893859Sml29623 nxge_intr_mask_mgmt(p_nxge_t nxgep) 31903859Sml29623 { 31913859Sml29623 p_nxge_ldgv_t ldgvp; 31923859Sml29623 p_nxge_ldg_t ldgp; 31933859Sml29623 p_nxge_ldv_t ldvp; 31943859Sml29623 npi_handle_t handle; 31953859Sml29623 int i, j; 31963859Sml29623 npi_status_t rs = NPI_SUCCESS; 31973859Sml29623 31983859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_mask_mgmt")); 31993859Sml29623 32003859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) { 32013859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 32023859Sml29623 "<== nxge_intr_mask_mgmt: Null ldgvp")); 32033859Sml29623 return (NXGE_ERROR); 32043859Sml29623 } 32053859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 32063859Sml29623 ldgp = ldgvp->ldgp; 32073859Sml29623 ldvp = ldgvp->ldvp; 32083859Sml29623 if (ldgp == NULL || ldvp == NULL) { 32093859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 32103859Sml29623 "<== nxge_intr_mask_mgmt: Null ldgp or ldvp")); 32113859Sml29623 return (NXGE_ERROR); 32123859Sml29623 } 32133859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32143859Sml29623 "==> nxge_intr_mask_mgmt: # of intrs %d ", ldgvp->ldg_intrs)); 32153859Sml29623 /* Initialize masks. */ 32163859Sml29623 if (nxgep->niu_type != N2_NIU) { 32173859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32183859Sml29623 "==> nxge_intr_mask_mgmt(Neptune): # intrs %d ", 32193859Sml29623 ldgvp->ldg_intrs)); 32203859Sml29623 for (i = 0; i < ldgvp->ldg_intrs; i++, ldgp++) { 32213859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32223859Sml29623 "==> nxge_intr_mask_mgmt(Neptune): # ldv %d " 32233859Sml29623 "in group %d", ldgp->nldvs, ldgp->ldg)); 32243859Sml29623 for (j = 0; j < ldgp->nldvs; j++, ldvp++) { 32253859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32263859Sml29623 "==> nxge_intr_mask_mgmt: set ldv # %d " 32273859Sml29623 "for ldg %d", ldvp->ldv, ldgp->ldg)); 32283859Sml29623 rs = npi_intr_mask_set(handle, ldvp->ldv, 32293859Sml29623 ldvp->ldv_ldf_masks); 32303859Sml29623 if (rs != NPI_SUCCESS) { 32313859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 32323859Sml29623 "<== nxge_intr_mask_mgmt: " 32333859Sml29623 "set mask failed " 32343859Sml29623 " rs 0x%x ldv %d mask 0x%x", 32353859Sml29623 rs, ldvp->ldv, 32363859Sml29623 ldvp->ldv_ldf_masks)); 32373859Sml29623 return (NXGE_ERROR | rs); 32383859Sml29623 } 32393859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32403859Sml29623 "==> nxge_intr_mask_mgmt: " 32413859Sml29623 "set mask OK " 32423859Sml29623 " rs 0x%x ldv %d mask 0x%x", 32433859Sml29623 rs, ldvp->ldv, 32443859Sml29623 ldvp->ldv_ldf_masks)); 32453859Sml29623 } 32463859Sml29623 } 32473859Sml29623 } 32483859Sml29623 ldgp = ldgvp->ldgp; 32493859Sml29623 /* Configure timer and arm bit */ 32503859Sml29623 for (i = 0; i < nxgep->ldgvp->ldg_intrs; i++, ldgp++) { 32513859Sml29623 rs = npi_intr_ldg_mgmt_set(handle, ldgp->ldg, 32523859Sml29623 ldgp->arm, ldgp->ldg_timer); 32533859Sml29623 if (rs != NPI_SUCCESS) { 32543859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 32553859Sml29623 "<== nxge_intr_mask_mgmt: " 32563859Sml29623 "set timer failed " 32573859Sml29623 " rs 0x%x dg %d timer 0x%x", 32583859Sml29623 rs, ldgp->ldg, ldgp->ldg_timer)); 32593859Sml29623 return (NXGE_ERROR | rs); 32603859Sml29623 } 32613859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32623859Sml29623 "==> nxge_intr_mask_mgmt: " 32633859Sml29623 "set timer OK " 32643859Sml29623 " rs 0x%x ldg %d timer 0x%x", 32653859Sml29623 rs, ldgp->ldg, ldgp->ldg_timer)); 32663859Sml29623 } 32673859Sml29623 32683859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_fzc_intr_mask_mgmt")); 32693859Sml29623 return (NXGE_OK); 32703859Sml29623 } 32713859Sml29623 32723859Sml29623 nxge_status_t 32733859Sml29623 nxge_intr_mask_mgmt_set(p_nxge_t nxgep, boolean_t on) 32743859Sml29623 { 32753859Sml29623 p_nxge_ldgv_t ldgvp; 32763859Sml29623 p_nxge_ldg_t ldgp; 32773859Sml29623 p_nxge_ldv_t ldvp; 32783859Sml29623 npi_handle_t handle; 32793859Sml29623 int i, j; 32803859Sml29623 npi_status_t rs = NPI_SUCCESS; 32813859Sml29623 32823859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32833859Sml29623 "==> nxge_intr_mask_mgmt_set (%d)", on)); 32843859Sml29623 32853859Sml29623 if (nxgep->niu_type == N2_NIU) { 32863859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 32873859Sml29623 "<== nxge_intr_mask_mgmt_set (%d) not set (N2/NIU)", 32883859Sml29623 on)); 32893859Sml29623 return (NXGE_ERROR); 32903859Sml29623 } 32913859Sml29623 32923859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) { 32933859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 32943859Sml29623 "==> nxge_intr_mask_mgmt_set: Null ldgvp")); 32953859Sml29623 return (NXGE_ERROR); 32963859Sml29623 } 32973859Sml29623 32983859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 32993859Sml29623 ldgp = ldgvp->ldgp; 33003859Sml29623 ldvp = ldgvp->ldvp; 33013859Sml29623 if (ldgp == NULL || ldvp == NULL) { 33023859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 33033859Sml29623 "<== nxge_intr_mask_mgmt_set: Null ldgp or ldvp")); 33043859Sml29623 return (NXGE_ERROR); 33053859Sml29623 } 33063859Sml29623 /* set masks. */ 33073859Sml29623 for (i = 0; i < ldgvp->ldg_intrs; i++, ldgp++) { 33083859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33093859Sml29623 "==> nxge_intr_mask_mgmt_set: flag %d ldg %d" 33103859Sml29623 "set mask nldvs %d", on, ldgp->ldg, ldgp->nldvs)); 33113859Sml29623 for (j = 0; j < ldgp->nldvs; j++, ldvp++) { 33123859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33133859Sml29623 "==> nxge_intr_mask_mgmt_set: " 33143859Sml29623 "for %d %d flag %d", i, j, on)); 33153859Sml29623 if (on) { 33163859Sml29623 ldvp->ldv_ldf_masks = 0; 33173859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33183859Sml29623 "==> nxge_intr_mask_mgmt_set: " 33193859Sml29623 "ON mask off")); 33203859Sml29623 } else if (!on) { 33213859Sml29623 ldvp->ldv_ldf_masks = (uint8_t)LD_IM1_MASK; 33223859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33233859Sml29623 "==> nxge_intr_mask_mgmt_set:mask on")); 33243859Sml29623 } 33253859Sml29623 rs = npi_intr_mask_set(handle, ldvp->ldv, 33263859Sml29623 ldvp->ldv_ldf_masks); 33273859Sml29623 if (rs != NPI_SUCCESS) { 33283859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 33293859Sml29623 "==> nxge_intr_mask_mgmt_set: " 33303859Sml29623 "set mask failed " 33313859Sml29623 " rs 0x%x ldv %d mask 0x%x", 33323859Sml29623 rs, ldvp->ldv, ldvp->ldv_ldf_masks)); 33333859Sml29623 return (NXGE_ERROR | rs); 33343859Sml29623 } 33353859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33363859Sml29623 "==> nxge_intr_mask_mgmt_set: flag %d" 33373859Sml29623 "set mask OK " 33383859Sml29623 " ldv %d mask 0x%x", 33393859Sml29623 on, ldvp->ldv, ldvp->ldv_ldf_masks)); 33403859Sml29623 } 33413859Sml29623 } 33423859Sml29623 33433859Sml29623 ldgp = ldgvp->ldgp; 33443859Sml29623 /* set the arm bit */ 33453859Sml29623 for (i = 0; i < nxgep->ldgvp->ldg_intrs; i++, ldgp++) { 33463859Sml29623 if (on && !ldgp->arm) { 33473859Sml29623 ldgp->arm = B_TRUE; 33483859Sml29623 } else if (!on && ldgp->arm) { 33493859Sml29623 ldgp->arm = B_FALSE; 33503859Sml29623 } 33513859Sml29623 rs = npi_intr_ldg_mgmt_set(handle, ldgp->ldg, 33523859Sml29623 ldgp->arm, ldgp->ldg_timer); 33533859Sml29623 if (rs != NPI_SUCCESS) { 33543859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 33553859Sml29623 "<== nxge_intr_mask_mgmt_set: " 33563859Sml29623 "set timer failed " 33573859Sml29623 " rs 0x%x ldg %d timer 0x%x", 33583859Sml29623 rs, ldgp->ldg, ldgp->ldg_timer)); 33593859Sml29623 return (NXGE_ERROR | rs); 33603859Sml29623 } 33613859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 33623859Sml29623 "==> nxge_intr_mask_mgmt_set: OK (flag %d) " 33633859Sml29623 "set timer " 33643859Sml29623 " ldg %d timer 0x%x", 33653859Sml29623 on, ldgp->ldg, ldgp->ldg_timer)); 33663859Sml29623 } 33673859Sml29623 33683859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_mask_mgmt_set")); 33693859Sml29623 return (NXGE_OK); 33703859Sml29623 } 33713859Sml29623 33723859Sml29623 static nxge_status_t 33733859Sml29623 nxge_get_mac_addr_properties(p_nxge_t nxgep) 33743859Sml29623 { 33753859Sml29623 uchar_t *prop_val; 33763859Sml29623 uint_t prop_len; 33773859Sml29623 uint_t i; 33783859Sml29623 uint8_t func_num; 33793859Sml29623 uint8_t total_factory_macs; 33803859Sml29623 33813859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_get_mac_addr_properties ")); 33823859Sml29623 33833859Sml29623 #if defined(_BIG_ENDIAN) 33843859Sml29623 /* 33853859Sml29623 * Get the ethernet address. 33863859Sml29623 */ 33873859Sml29623 (void) localetheraddr((struct ether_addr *)NULL, &nxgep->ouraddr); 33883859Sml29623 33893859Sml29623 /* 33903859Sml29623 * Check if it is an adapter with its own local mac address If it is 33913859Sml29623 * present, override the system mac address. 33923859Sml29623 */ 33933859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 33943859Sml29623 "local-mac-address", &prop_val, 33953859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 33963859Sml29623 if (prop_len == ETHERADDRL) { 33973859Sml29623 nxgep->factaddr = *(p_ether_addr_t)prop_val; 33983859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "Local mac address = " 33993859Sml29623 "%02x:%02x:%02x:%02x:%02x:%02x", 34003859Sml29623 prop_val[0], prop_val[1], prop_val[2], 34013859Sml29623 prop_val[3], prop_val[4], prop_val[5])); 34023859Sml29623 } 34033859Sml29623 ddi_prop_free(prop_val); 34043859Sml29623 } 34053859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 34063859Sml29623 "local-mac-address?", &prop_val, 34073859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 34083859Sml29623 if (strncmp("true", (caddr_t)prop_val, (size_t)prop_len) == 0) { 34093859Sml29623 nxgep->ouraddr = nxgep->factaddr; 34103859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, 34113859Sml29623 "Using local MAC address")); 34123859Sml29623 } 34133859Sml29623 ddi_prop_free(prop_val); 34143859Sml29623 } else { 34153859Sml29623 nxgep->ouraddr = nxgep->factaddr; 34163859Sml29623 } 3417*4185Sspeer 3418*4185Sspeer if ((nxgep->niu_type == N2_NIU) || 3419*4185Sspeer nxge_is_valid_local_mac(nxgep->factaddr)) 3420*4185Sspeer goto got_mac_addr; 3421*4185Sspeer 3422*4185Sspeer NXGE_DEBUG_MSG((nxgep, DDI_CTL, "nxge_get_mac_addr_properties: " 3423*4185Sspeer "MAC address from properties is not valid...reading from PROM")); 3424*4185Sspeer 3425*4185Sspeer #endif 3426*4185Sspeer if (!nxgep->vpd_info.ver_valid) { 3427*4185Sspeer (void) nxge_espc_mac_addrs_get(nxgep); 3428*4185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 3429*4185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "EEPROM version " 3430*4185Sspeer "[%s] invalid...please update", 3431*4185Sspeer nxgep->vpd_info.ver)); 3432*4185Sspeer return (NXGE_ERROR); 3433*4185Sspeer } 3434*4185Sspeer nxgep->ouraddr = nxgep->factaddr; 3435*4185Sspeer goto got_mac_addr; 3436*4185Sspeer } 3437*4185Sspeer /* 3438*4185Sspeer * First get the MAC address from the info in the VPD data read 3439*4185Sspeer * from the EEPROM. 3440*4185Sspeer */ 3441*4185Sspeer nxge_espc_get_next_mac_addr(nxgep->vpd_info.mac_addr, 3442*4185Sspeer nxgep->mac.portnum, &nxgep->factaddr); 3443*4185Sspeer 3444*4185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 3445*4185Sspeer NXGE_DEBUG_MSG((nxgep, DDI_CTL, 3446*4185Sspeer "nxge_get_mac_addr_properties: " 3447*4185Sspeer "MAC address in EEPROM VPD data not valid" 3448*4185Sspeer "...reading from NCR registers")); 3449*4185Sspeer (void) nxge_espc_mac_addrs_get(nxgep); 3450*4185Sspeer if (!nxge_is_valid_local_mac(nxgep->factaddr)) { 3451*4185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "EEPROM version " 3452*4185Sspeer "[%s] invalid...please update", 3453*4185Sspeer nxgep->vpd_info.ver)); 3454*4185Sspeer return (NXGE_ERROR); 3455*4185Sspeer } 3456*4185Sspeer } 3457*4185Sspeer 34583859Sml29623 nxgep->ouraddr = nxgep->factaddr; 3459*4185Sspeer 3460*4185Sspeer got_mac_addr: 34613859Sml29623 func_num = nxgep->function_num; 34623859Sml29623 34633859Sml29623 /* 34643859Sml29623 * total_factory_macs is the total number of MACs the factory assigned 34653859Sml29623 * to the whole Neptune device. NIU does not need this parameter 34663859Sml29623 * because it derives the number of factory MACs for each port from 34673859Sml29623 * the device properties. 34683859Sml29623 */ 34693859Sml29623 if (nxgep->niu_type == NEPTUNE || nxgep->niu_type == NEPTUNE_2) { 3470*4185Sspeer /* First get VPD data from EEPROM */ 3471*4185Sspeer if (nxgep->vpd_info.ver_valid && nxgep->vpd_info.num_macs) { 3472*4185Sspeer nxgep->nxge_mmac_info.total_factory_macs = 3473*4185Sspeer nxgep->vpd_info.num_macs; 3474*4185Sspeer } else { 3475*4185Sspeer NXGE_DEBUG_MSG((nxgep, DDI_CTL, 3476*4185Sspeer "nxge_get_mac_addr_properties: Number of MAC " 3477*4185Sspeer "addresses in EEPROM VPD data not valid" 3478*4185Sspeer "...reading from NCR registers")); 3479*4185Sspeer if (nxge_espc_num_macs_get(nxgep, 3480*4185Sspeer &total_factory_macs) == NXGE_OK) { 3481*4185Sspeer nxgep->nxge_mmac_info.total_factory_macs = 3482*4185Sspeer total_factory_macs; 3483*4185Sspeer } else { 3484*4185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3485*4185Sspeer "EEPROM version [%s] invalid...please " 3486*4185Sspeer "update", nxgep->vpd_info.ver)); 3487*4185Sspeer return (NXGE_ERROR); 3488*4185Sspeer } 34893859Sml29623 } 34903859Sml29623 } 34913859Sml29623 34923859Sml29623 /* 34933859Sml29623 * Note: mac-addresses of n2-niu is the list of mac addresses for a 34943859Sml29623 * port. #mac-addresses stored in Neptune's SEEPROM is the total number 34953859Sml29623 * of MAC addresses allocated for a board. 34963859Sml29623 */ 34973859Sml29623 if (nxgep->niu_type == N2_NIU) { 34983859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 34993859Sml29623 "mac-addresses", &prop_val, &prop_len) == 35003859Sml29623 DDI_PROP_SUCCESS) { 35013859Sml29623 /* 35023859Sml29623 * XAUI may have up to 18 MACs, more than the XMAC can 35033859Sml29623 * use (1 unique MAC plus 16 alternate MACs) 35043859Sml29623 */ 35053859Sml29623 nxgep->nxge_mmac_info.num_factory_mmac 35063859Sml29623 = prop_len / ETHERADDRL - 1; 35073859Sml29623 if (nxgep->nxge_mmac_info.num_factory_mmac > 35083859Sml29623 XMAC_MAX_ALT_ADDR_ENTRY) { 35093859Sml29623 nxgep->nxge_mmac_info.num_factory_mmac = 35103859Sml29623 XMAC_MAX_ALT_ADDR_ENTRY; 35113859Sml29623 } 35123859Sml29623 ddi_prop_free(prop_val); 35133859Sml29623 } 35143859Sml29623 } else { 35153859Sml29623 /* 35163859Sml29623 * total_factory_macs = 32 35173859Sml29623 * num_factory_mmac = (32 >> (nports/2)) - 1 35183859Sml29623 * So if nports = 4, then num_factory_mmac = 7 35193859Sml29623 * if nports = 2, then num_factory_mmac = 15 35203859Sml29623 */ 35213859Sml29623 nxgep->nxge_mmac_info.num_factory_mmac 35223859Sml29623 = ((nxgep->nxge_mmac_info.total_factory_macs >> 35233859Sml29623 (nxgep->nports >> 1))) - 1; 3524*4185Sspeer 3525*4185Sspeer if (nxgep->nxge_mmac_info.num_factory_mmac < 1) { 3526*4185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3527*4185Sspeer "Invalid value [0x%x] for num_factory_mmac", 3528*4185Sspeer nxgep->nxge_mmac_info.num_factory_mmac)); 3529*4185Sspeer return (NXGE_ERROR); 3530*4185Sspeer } 3531*4185Sspeer if ((nxgep->function_num < 2) && 3532*4185Sspeer (nxgep->nxge_mmac_info.num_factory_mmac > 3533*4185Sspeer XMAC_MAX_ALT_ADDR_ENTRY)) { 3534*4185Sspeer nxgep->nxge_mmac_info.num_factory_mmac = 3535*4185Sspeer XMAC_MAX_ALT_ADDR_ENTRY; 3536*4185Sspeer } else if ((nxgep->function_num > 1) && 3537*4185Sspeer (nxgep->nxge_mmac_info.num_factory_mmac > 3538*4185Sspeer BMAC_MAX_ALT_ADDR_ENTRY)) { 3539*4185Sspeer nxgep->nxge_mmac_info.num_factory_mmac = 3540*4185Sspeer BMAC_MAX_ALT_ADDR_ENTRY; 3541*4185Sspeer } 35423859Sml29623 } 3543*4185Sspeer 3544*4185Sspeer if (nxgep->nxge_mmac_info.num_mmac < 1) { 3545*4185Sspeer NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3546*4185Sspeer "Invalid value [0x%x] for num_mmac", 3547*4185Sspeer nxgep->nxge_mmac_info.num_mmac)); 3548*4185Sspeer return (NXGE_ERROR); 3549*4185Sspeer } 3550*4185Sspeer 35513859Sml29623 for (i = 0; i <= nxgep->nxge_mmac_info.num_mmac; i++) { 35523859Sml29623 (void) npi_mac_altaddr_disable(nxgep->npi_handle, 35533859Sml29623 NXGE_GET_PORT_NUM(func_num), i); 35543859Sml29623 } 35553859Sml29623 35563859Sml29623 (void) nxge_init_mmac(nxgep); 35573859Sml29623 return (NXGE_OK); 35583859Sml29623 } 35593859Sml29623 35603859Sml29623 void 35613859Sml29623 nxge_get_xcvr_properties(p_nxge_t nxgep) 35623859Sml29623 { 35633859Sml29623 uchar_t *prop_val; 35643859Sml29623 uint_t prop_len; 35653859Sml29623 35663859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_get_xcvr_properties")); 35673859Sml29623 35683859Sml29623 /* 35693859Sml29623 * Read the type of physical layer interface being used. 35703859Sml29623 */ 35713859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 35723859Sml29623 if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 35733859Sml29623 "phy-type", &prop_val, &prop_len) == DDI_PROP_SUCCESS) { 35743859Sml29623 if (strncmp("pcs", (caddr_t)prop_val, 35753859Sml29623 (size_t)prop_len) == 0) { 35763859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = PCS_XCVR; 35773859Sml29623 } else { 35783859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 35793859Sml29623 } 35803859Sml29623 ddi_prop_free(prop_val); 35813859Sml29623 } else if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, nxgep->dip, 0, 35823859Sml29623 "phy-interface", &prop_val, 35833859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 35843859Sml29623 if (strncmp("pcs", (caddr_t)prop_val, (size_t)prop_len) == 0) { 35853859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = PCS_XCVR; 35863859Sml29623 } else { 35873859Sml29623 nxgep->statsp->mac_stats.xcvr_inuse = INT_MII_XCVR; 35883859Sml29623 } 35893859Sml29623 ddi_prop_free(prop_val); 35903859Sml29623 } 35913859Sml29623 } 35923859Sml29623 35933859Sml29623 /* 35943859Sml29623 * Static functions start here. 35953859Sml29623 */ 35963859Sml29623 35973859Sml29623 static void 35983859Sml29623 nxge_ldgv_setup(p_nxge_ldg_t *ldgp, p_nxge_ldv_t *ldvp, uint8_t ldv, 35993859Sml29623 uint8_t endldg, int *ngrps) 36003859Sml29623 { 36013859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup")); 36023859Sml29623 /* Assign the group number for each device. */ 36033859Sml29623 (*ldvp)->ldg_assigned = (*ldgp)->ldg; 36043859Sml29623 (*ldvp)->ldgp = *ldgp; 36053859Sml29623 (*ldvp)->ldv = ldv; 36063859Sml29623 36073859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup: " 36083859Sml29623 "ldv %d endldg %d ldg %d, ldvp $%p", 36093859Sml29623 ldv, endldg, (*ldgp)->ldg, (*ldgp)->ldvp)); 36103859Sml29623 36113859Sml29623 (*ldgp)->nldvs++; 36123859Sml29623 if ((*ldgp)->ldg == (endldg - 1)) { 36133859Sml29623 if ((*ldgp)->ldvp == NULL) { 36143859Sml29623 (*ldgp)->ldvp = *ldvp; 36153859Sml29623 *ngrps += 1; 36163859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 36173859Sml29623 "==> nxge_ldgv_setup: ngrps %d", *ngrps)); 36183859Sml29623 } 36193859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 36203859Sml29623 "==> nxge_ldgv_setup: ldvp $%p ngrps %d", 36213859Sml29623 *ldvp, *ngrps)); 36223859Sml29623 ++*ldvp; 36233859Sml29623 } else { 36243859Sml29623 (*ldgp)->ldvp = *ldvp; 36253859Sml29623 *ngrps += 1; 36263859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup(done): " 36273859Sml29623 "ldv %d endldg %d ldg %d, ldvp $%p", 36283859Sml29623 ldv, endldg, (*ldgp)->ldg, (*ldgp)->ldvp)); 36293859Sml29623 (*ldvp) = ++*ldvp; 36303859Sml29623 (*ldgp) = ++*ldgp; 36313859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, 36323859Sml29623 "==> nxge_ldgv_setup: new ngrps %d", *ngrps)); 36333859Sml29623 } 36343859Sml29623 36353859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "==> nxge_ldgv_setup: " 36363859Sml29623 "ldv %d ldvp $%p endldg %d ngrps %d", 36373859Sml29623 ldv, ldvp, endldg, *ngrps)); 36383859Sml29623 36393859Sml29623 NXGE_DEBUG_MSG((NULL, INT_CTL, "<== nxge_ldgv_setup")); 36403859Sml29623 } 36413859Sml29623 36423859Sml29623 /* 36433859Sml29623 * Note: This function assumes the following distribution of mac 36443859Sml29623 * addresses among 4 ports in neptune: 36453859Sml29623 * 36463859Sml29623 * ------------- 36473859Sml29623 * 0| |0 - local-mac-address for fn 0 36483859Sml29623 * ------------- 36493859Sml29623 * 1| |1 - local-mac-address for fn 1 36503859Sml29623 * ------------- 36513859Sml29623 * 2| |2 - local-mac-address for fn 2 36523859Sml29623 * ------------- 36533859Sml29623 * 3| |3 - local-mac-address for fn 3 36543859Sml29623 * ------------- 36553859Sml29623 * | |4 - Start of alt. mac addr. for fn 0 36563859Sml29623 * | | 36573859Sml29623 * | | 36583859Sml29623 * | |10 36593859Sml29623 * -------------- 36603859Sml29623 * | |11 - Start of alt. mac addr. for fn 1 36613859Sml29623 * | | 36623859Sml29623 * | | 36633859Sml29623 * | |17 36643859Sml29623 * -------------- 36653859Sml29623 * | |18 - Start of alt. mac addr. for fn 2 36663859Sml29623 * | | 36673859Sml29623 * | | 36683859Sml29623 * | |24 36693859Sml29623 * -------------- 36703859Sml29623 * | |25 - Start of alt. mac addr. for fn 3 36713859Sml29623 * | | 36723859Sml29623 * | | 36733859Sml29623 * | |31 36743859Sml29623 * -------------- 36753859Sml29623 * 36763859Sml29623 * For N2/NIU the mac addresses is from XAUI card. 36773859Sml29623 */ 36783859Sml29623 36793859Sml29623 static void 36803859Sml29623 nxge_init_mmac(p_nxge_t nxgep) 36813859Sml29623 { 36823859Sml29623 int slot; 36833859Sml29623 uint8_t func_num; 36843859Sml29623 uint16_t *base_mmac_addr; 36853859Sml29623 uint32_t alt_mac_ls4b; 36863859Sml29623 uint16_t *mmac_addr; 36873859Sml29623 uint32_t base_mac_ls4b; /* least significant 4 bytes */ 36883859Sml29623 nxge_mmac_t *mmac_info; 36893859Sml29623 npi_mac_addr_t mac_addr; 36903859Sml29623 36913859Sml29623 func_num = nxgep->function_num; 36923859Sml29623 base_mmac_addr = (uint16_t *)&nxgep->factaddr; 36933859Sml29623 mmac_info = (nxge_mmac_t *)&nxgep->nxge_mmac_info; 36943859Sml29623 36953859Sml29623 base_mac_ls4b = ((uint32_t)base_mmac_addr[1]) << 16 | 36963859Sml29623 base_mmac_addr[2]; 36973859Sml29623 36983859Sml29623 if (nxgep->niu_type == N2_NIU) { 36993859Sml29623 alt_mac_ls4b = base_mac_ls4b + 1; /* ls4b of 1st altmac */ 37003859Sml29623 } else { /* Neptune */ 37013859Sml29623 alt_mac_ls4b = base_mac_ls4b + (nxgep->nports - func_num) 37023859Sml29623 + (func_num * (mmac_info->num_factory_mmac)); 37033859Sml29623 } 37043859Sml29623 37053859Sml29623 /* Set flags for unique MAC */ 37063859Sml29623 mmac_info->mac_pool[0].flags |= MMAC_SLOT_USED | MMAC_VENDOR_ADDR; 37073859Sml29623 37083859Sml29623 /* Clear flags of all alternate MAC slots */ 37093859Sml29623 for (slot = 1; slot <= mmac_info->num_mmac; slot++) { 37103859Sml29623 if (slot <= mmac_info->num_factory_mmac) 37113859Sml29623 mmac_info->mac_pool[slot].flags = MMAC_VENDOR_ADDR; 37123859Sml29623 else 37133859Sml29623 mmac_info->mac_pool[slot].flags = 0; 37143859Sml29623 } 37153859Sml29623 37163859Sml29623 /* Generate and store factory alternate MACs */ 37173859Sml29623 for (slot = 1; slot <= mmac_info->num_factory_mmac; slot++) { 37183859Sml29623 mmac_addr = (uint16_t *)&mmac_info->factory_mac_pool[slot]; 37193859Sml29623 mmac_addr[0] = base_mmac_addr[0]; 37203859Sml29623 mac_addr.w2 = mmac_addr[0]; 37213859Sml29623 37223859Sml29623 mmac_addr[1] = (alt_mac_ls4b >> 16) & 0x0FFFF; 37233859Sml29623 mac_addr.w1 = mmac_addr[1]; 37243859Sml29623 37253859Sml29623 mmac_addr[2] = alt_mac_ls4b & 0x0FFFF; 37263859Sml29623 mac_addr.w0 = mmac_addr[2]; 37273859Sml29623 /* 37283859Sml29623 * slot minus 1 because npi_mac_alraddr_entry expects 0 37293859Sml29623 * for the first alternate mac address. 37303859Sml29623 */ 37313859Sml29623 (void) npi_mac_altaddr_entry(nxgep->npi_handle, OP_SET, 37323859Sml29623 NXGE_GET_PORT_NUM(func_num), slot - 1, &mac_addr); 37333859Sml29623 37343859Sml29623 alt_mac_ls4b++; 37353859Sml29623 } 37363859Sml29623 /* Initialize the first two parameters for mmac kstat */ 37373859Sml29623 nxgep->statsp->mmac_stats.mmac_max_cnt = mmac_info->num_mmac; 37383859Sml29623 nxgep->statsp->mmac_stats.mmac_avail_cnt = mmac_info->num_mmac; 37393859Sml29623 } 3740