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