1*3859Sml29623 /* 2*3859Sml29623 * CDDL HEADER START 3*3859Sml29623 * 4*3859Sml29623 * The contents of this file are subject to the terms of the 5*3859Sml29623 * Common Development and Distribution License (the "License"). 6*3859Sml29623 * You may not use this file except in compliance with the License. 7*3859Sml29623 * 8*3859Sml29623 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*3859Sml29623 * or http://www.opensolaris.org/os/licensing. 10*3859Sml29623 * See the License for the specific language governing permissions 11*3859Sml29623 * and limitations under the License. 12*3859Sml29623 * 13*3859Sml29623 * When distributing Covered Code, include this CDDL HEADER in each 14*3859Sml29623 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*3859Sml29623 * If applicable, add the following below this CDDL HEADER, with the 16*3859Sml29623 * fields enclosed by brackets "[]" replaced with your own identifying 17*3859Sml29623 * information: Portions Copyright [yyyy] [name of copyright owner] 18*3859Sml29623 * 19*3859Sml29623 * CDDL HEADER END 20*3859Sml29623 */ 21*3859Sml29623 /* 22*3859Sml29623 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*3859Sml29623 * Use is subject to license terms. 24*3859Sml29623 */ 25*3859Sml29623 26*3859Sml29623 #pragma ident "%Z%%M% %I% %E% SMI" 27*3859Sml29623 28*3859Sml29623 #include <sys/nxge/nxge_impl.h> 29*3859Sml29623 #include <inet/common.h> 30*3859Sml29623 #include <inet/mi.h> 31*3859Sml29623 #include <inet/nd.h> 32*3859Sml29623 33*3859Sml29623 extern uint64_t npi_debug_level; 34*3859Sml29623 35*3859Sml29623 #define NXGE_PARAM_MAC_RW \ 36*3859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_MAC | \ 37*3859Sml29623 NXGE_PARAM_NDD_WR_OK | NXGE_PARAM_READ_PROP 38*3859Sml29623 39*3859Sml29623 #define NXGE_PARAM_MAC_DONT_SHOW \ 40*3859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_MAC | NXGE_PARAM_DONT_SHOW 41*3859Sml29623 42*3859Sml29623 #define NXGE_PARAM_RXDMA_RW \ 43*3859Sml29623 NXGE_PARAM_RWP | NXGE_PARAM_RXDMA | NXGE_PARAM_NDD_WR_OK | \ 44*3859Sml29623 NXGE_PARAM_READ_PROP 45*3859Sml29623 46*3859Sml29623 #define NXGE_PARAM_RXDMA_RWC \ 47*3859Sml29623 NXGE_PARAM_RWP | NXGE_PARAM_RXDMA | NXGE_PARAM_INIT_ONLY | \ 48*3859Sml29623 NXGE_PARAM_READ_PROP 49*3859Sml29623 50*3859Sml29623 #define NXGE_PARAM_L2CLASS_CFG \ 51*3859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_PROP_ARR32 | NXGE_PARAM_READ_PROP | \ 52*3859Sml29623 NXGE_PARAM_NDD_WR_OK 53*3859Sml29623 54*3859Sml29623 #define NXGE_PARAM_CLASS_RWS \ 55*3859Sml29623 NXGE_PARAM_RWS | NXGE_PARAM_READ_PROP 56*3859Sml29623 57*3859Sml29623 #define NXGE_PARAM_ARRAY_INIT_SIZE 0x20ULL 58*3859Sml29623 59*3859Sml29623 #define SET_RX_INTR_TIME_DISABLE 0 60*3859Sml29623 #define SET_RX_INTR_TIME_ENABLE 1 61*3859Sml29623 #define SET_RX_INTR_PKTS 2 62*3859Sml29623 63*3859Sml29623 #define BASE_ANY 0 64*3859Sml29623 #define BASE_BINARY 2 65*3859Sml29623 #define BASE_HEX 16 66*3859Sml29623 #define BASE_DECIMAL 10 67*3859Sml29623 #define ALL_FF_64 0xFFFFFFFFFFFFFFFFULL 68*3859Sml29623 #define ALL_FF_32 0xFFFFFFFFUL 69*3859Sml29623 70*3859Sml29623 #define NXGE_NDD_INFODUMP_BUFF_SIZE 2048 /* is 2k enough? */ 71*3859Sml29623 #define NXGE_NDD_INFODUMP_BUFF_8K 8192 72*3859Sml29623 #define NXGE_NDD_INFODUMP_BUFF_16K 0x2000 73*3859Sml29623 #define NXGE_NDD_INFODUMP_BUFF_64K 0x8000 74*3859Sml29623 75*3859Sml29623 #define PARAM_OUTOF_RANGE(vptr, eptr, rval, pa) \ 76*3859Sml29623 ((vptr == eptr) || (rval < pa->minimum) || (rval > pa->maximum)) 77*3859Sml29623 78*3859Sml29623 #define ADVANCE_PRINT_BUFFER(pmp, plen, rlen) { \ 79*3859Sml29623 ((mblk_t *)pmp)->b_wptr += plen; \ 80*3859Sml29623 rlen -= plen; \ 81*3859Sml29623 } 82*3859Sml29623 83*3859Sml29623 static int nxge_param_rx_intr_pkts(p_nxge_t, queue_t *, 84*3859Sml29623 mblk_t *, char *, caddr_t); 85*3859Sml29623 static int nxge_param_rx_intr_time(p_nxge_t, queue_t *, 86*3859Sml29623 mblk_t *, char *, caddr_t); 87*3859Sml29623 static int nxge_param_set_mac(p_nxge_t, queue_t *, 88*3859Sml29623 mblk_t *, char *, caddr_t); 89*3859Sml29623 static int nxge_param_set_port_rdc(p_nxge_t, queue_t *, 90*3859Sml29623 mblk_t *, char *, caddr_t); 91*3859Sml29623 static int nxge_param_set_grp_rdc(p_nxge_t, queue_t *, 92*3859Sml29623 mblk_t *, char *, caddr_t); 93*3859Sml29623 static int nxge_param_set_ether_usr(p_nxge_t, 94*3859Sml29623 queue_t *, mblk_t *, char *, caddr_t); 95*3859Sml29623 static int nxge_param_set_ip_usr(p_nxge_t, 96*3859Sml29623 queue_t *, mblk_t *, char *, caddr_t); 97*3859Sml29623 static int nxge_param_set_ip_opt(p_nxge_t, 98*3859Sml29623 queue_t *, mblk_t *, char *, caddr_t); 99*3859Sml29623 static int nxge_param_set_vlan_rdcgrp(p_nxge_t, 100*3859Sml29623 queue_t *, mblk_t *, char *, caddr_t); 101*3859Sml29623 static int nxge_param_set_mac_rdcgrp(p_nxge_t, 102*3859Sml29623 queue_t *, mblk_t *, char *, caddr_t); 103*3859Sml29623 static int nxge_param_fflp_hash_init(p_nxge_t, 104*3859Sml29623 queue_t *, mblk_t *, char *, caddr_t); 105*3859Sml29623 static int nxge_param_llc_snap_enable(p_nxge_t, queue_t *, 106*3859Sml29623 mblk_t *, char *, caddr_t); 107*3859Sml29623 static int nxge_param_hash_lookup_enable(p_nxge_t, queue_t *, 108*3859Sml29623 mblk_t *, char *, caddr_t); 109*3859Sml29623 static int nxge_param_tcam_enable(p_nxge_t, queue_t *, 110*3859Sml29623 mblk_t *, char *, caddr_t); 111*3859Sml29623 static int nxge_param_get_rxdma_info(p_nxge_t, queue_t *q, 112*3859Sml29623 p_mblk_t, caddr_t); 113*3859Sml29623 static int nxge_param_get_txdma_info(p_nxge_t, queue_t *q, 114*3859Sml29623 p_mblk_t, caddr_t); 115*3859Sml29623 static int nxge_param_get_vlan_rdcgrp(p_nxge_t, queue_t *, 116*3859Sml29623 p_mblk_t, caddr_t); 117*3859Sml29623 static int nxge_param_get_mac_rdcgrp(p_nxge_t, queue_t *, 118*3859Sml29623 p_mblk_t, caddr_t); 119*3859Sml29623 static int nxge_param_get_rxdma_rdcgrp_info(p_nxge_t, queue_t *, 120*3859Sml29623 p_mblk_t, caddr_t); 121*3859Sml29623 static int nxge_param_get_ip_opt(p_nxge_t, queue_t *, mblk_t *, caddr_t); 122*3859Sml29623 static int nxge_param_get_mac(p_nxge_t, queue_t *q, p_mblk_t, caddr_t); 123*3859Sml29623 static int nxge_param_get_debug_flag(p_nxge_t, queue_t *, p_mblk_t, caddr_t); 124*3859Sml29623 static int nxge_param_set_nxge_debug_flag(p_nxge_t, queue_t *, mblk_t *, 125*3859Sml29623 char *, caddr_t); 126*3859Sml29623 static int nxge_param_set_npi_debug_flag(p_nxge_t, 127*3859Sml29623 queue_t *, mblk_t *, char *, caddr_t); 128*3859Sml29623 static int nxge_param_dump_rdc(p_nxge_t, queue_t *q, p_mblk_t, caddr_t); 129*3859Sml29623 static int nxge_param_dump_tdc(p_nxge_t, queue_t *q, p_mblk_t, caddr_t); 130*3859Sml29623 static int nxge_param_dump_mac_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t); 131*3859Sml29623 static int nxge_param_dump_ipp_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t); 132*3859Sml29623 static int nxge_param_dump_fflp_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t); 133*3859Sml29623 static int nxge_param_dump_vlan_table(p_nxge_t, queue_t *, p_mblk_t, caddr_t); 134*3859Sml29623 static int nxge_param_dump_rdc_table(p_nxge_t, queue_t *, p_mblk_t, caddr_t); 135*3859Sml29623 static int nxge_param_dump_ptrs(p_nxge_t, queue_t *, p_mblk_t, caddr_t); 136*3859Sml29623 static boolean_t nxge_param_link_update(p_nxge_t); 137*3859Sml29623 138*3859Sml29623 /* 139*3859Sml29623 * Global array of Neptune changable parameters. 140*3859Sml29623 * This array is initialized to correspond to the default 141*3859Sml29623 * Neptune 4 port configuration. This array would be copied 142*3859Sml29623 * into each port's parameter structure and modifed per 143*3859Sml29623 * fcode and nxge.conf configuration. Later, the parameters are 144*3859Sml29623 * exported to ndd to display and run-time configuration (at least 145*3859Sml29623 * some of them). 146*3859Sml29623 * 147*3859Sml29623 */ 148*3859Sml29623 149*3859Sml29623 static nxge_param_t nxge_param_arr[] = { 150*3859Sml29623 /* 151*3859Sml29623 * min max value old hw-name conf-name 152*3859Sml29623 */ 153*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 154*3859Sml29623 0, 999, 1000, 0, "instance", "instance"}, 155*3859Sml29623 156*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 157*3859Sml29623 0, 999, 1000, 0, "main-instance", "main_instance"}, 158*3859Sml29623 159*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 160*3859Sml29623 0, 3, 0, 0, "function-number", "function_number"}, 161*3859Sml29623 162*3859Sml29623 /* Partition Id */ 163*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 164*3859Sml29623 0, 8, 0, 0, "partition-id", "partition_id"}, 165*3859Sml29623 166*3859Sml29623 /* Read Write Permission Mode */ 167*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW, 168*3859Sml29623 0, 2, 0, 0, "read-write-mode", "read_write_mode"}, 169*3859Sml29623 170*3859Sml29623 /* hw cfg types */ 171*3859Sml29623 /* control the DMA config of Neptune/NIU */ 172*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 173*3859Sml29623 CFG_DEFAULT, CFG_CUSTOM, CFG_DEFAULT, CFG_DEFAULT, 174*3859Sml29623 "niu-cfg-type", "niu_cfg_type"}, 175*3859Sml29623 176*3859Sml29623 /* control the TXDMA config of the Port controlled by tx-quick-cfg */ 177*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 178*3859Sml29623 CFG_DEFAULT, CFG_CUSTOM, CFG_NOT_SPECIFIED, CFG_DEFAULT, 179*3859Sml29623 "tx-qcfg-type", "tx_qcfg_type"}, 180*3859Sml29623 181*3859Sml29623 /* control the RXDMA config of the Port controlled by rx-quick-cfg */ 182*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 183*3859Sml29623 CFG_DEFAULT, CFG_CUSTOM, CFG_NOT_SPECIFIED, CFG_DEFAULT, 184*3859Sml29623 "rx-qcfg-type", "rx_qcfg_type"}, 185*3859Sml29623 186*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, 187*3859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW, 188*3859Sml29623 0, 1, 0, 0, "master-cfg-enable", "master_cfg_enable"}, 189*3859Sml29623 190*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, 191*3859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW, 192*3859Sml29623 0, 1, 0, 0, "master-cfg-value", "master_cfg_value"}, 193*3859Sml29623 194*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 195*3859Sml29623 0, 1, 1, 1, "adv-autoneg-cap", "adv_autoneg_cap"}, 196*3859Sml29623 197*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 198*3859Sml29623 0, 1, 1, 1, "adv-10gfdx-cap", "adv_10gfdx_cap"}, 199*3859Sml29623 200*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW, 201*3859Sml29623 0, 1, 0, 0, "adv-10ghdx-cap", "adv_10ghdx_cap"}, 202*3859Sml29623 203*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 204*3859Sml29623 0, 1, 1, 1, "adv-1000fdx-cap", "adv_1000fdx_cap"}, 205*3859Sml29623 206*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW, 207*3859Sml29623 0, 1, 0, 0, "adv-1000hdx-cap", "adv_1000hdx_cap"}, 208*3859Sml29623 209*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW, 210*3859Sml29623 0, 1, 0, 0, "adv-100T4-cap", "adv_100T4_cap"}, 211*3859Sml29623 212*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 213*3859Sml29623 0, 1, 1, 1, "adv-100fdx-cap", "adv_100fdx_cap"}, 214*3859Sml29623 215*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW, 216*3859Sml29623 0, 1, 0, 0, "adv-100hdx-cap", "adv_100hdx_cap"}, 217*3859Sml29623 218*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 219*3859Sml29623 0, 1, 1, 1, "adv-10fdx-cap", "adv_10fdx_cap"}, 220*3859Sml29623 221*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW, 222*3859Sml29623 0, 1, 0, 0, "adv-10hdx-cap", "adv_10hdx_cap"}, 223*3859Sml29623 224*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 225*3859Sml29623 0, 1, 0, 0, "adv-asmpause-cap", "adv_asmpause_cap"}, 226*3859Sml29623 227*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 228*3859Sml29623 0, 1, 0, 0, "adv-pause-cap", "adv_pause_cap"}, 229*3859Sml29623 230*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 231*3859Sml29623 0, 1, 0, 0, "use-int-xcvr", "use_int_xcvr"}, 232*3859Sml29623 233*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 234*3859Sml29623 0, 1, 1, 1, "enable-ipg0", "enable_ipg0"}, 235*3859Sml29623 236*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 237*3859Sml29623 0, 255, 8, 8, "ipg0", "ipg0"}, 238*3859Sml29623 239*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 240*3859Sml29623 0, 255, 8, 8, "ipg1", "ipg1"}, 241*3859Sml29623 242*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 243*3859Sml29623 0, 255, 4, 4, "ipg2", "ipg2"}, 244*3859Sml29623 245*3859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW, 246*3859Sml29623 0, 1, 0, 0, "accept-jumbo", "accept_jumbo"}, 247*3859Sml29623 248*3859Sml29623 /* Transmit DMA channels */ 249*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_READ_PROP, 250*3859Sml29623 0, 3, 0, 0, "tx-dma-weight", "tx_dma_weight"}, 251*3859Sml29623 252*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_READ_PROP, 253*3859Sml29623 0, 31, 0, 0, "tx-dma-channels-begin", "tx_dma_channels_begin"}, 254*3859Sml29623 255*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_READ_PROP, 256*3859Sml29623 0, 32, 0, 0, "tx-dma-channels", "tx_dma_channels"}, 257*3859Sml29623 { nxge_param_get_txdma_info, NULL, 258*3859Sml29623 NXGE_PARAM_READ | NXGE_PARAM_READ_PROP, 259*3859Sml29623 0, 32, 0, 0, "tx-dma-info", "tx_dma_info"}, 260*3859Sml29623 261*3859Sml29623 /* Receive DMA channels */ 262*3859Sml29623 { nxge_param_get_generic, NULL, 263*3859Sml29623 NXGE_PARAM_READ | NXGE_PARAM_READ_PROP, 264*3859Sml29623 0, 31, 0, 0, "rx-dma-channels-begin", "rx_dma_channels_begin"}, 265*3859Sml29623 266*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_READ_PROP, 267*3859Sml29623 0, 32, 0, 0, "rx-dma-channels", "rx_dma_channels"}, 268*3859Sml29623 269*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_READ_PROP, 270*3859Sml29623 0, 65535, PT_DRR_WT_DEFAULT_10G, 0, 271*3859Sml29623 "rx-drr-weight", "rx_drr_weight"}, 272*3859Sml29623 273*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_READ_PROP, 274*3859Sml29623 0, 1, 1, 0, "rx-full-header", "rx_full_header"}, 275*3859Sml29623 276*3859Sml29623 { nxge_param_get_rxdma_info, NULL, NXGE_PARAM_READ, 277*3859Sml29623 0, 32, 0, 0, "rx-dma-info", "rx_dma_info"}, 278*3859Sml29623 279*3859Sml29623 { nxge_param_get_rxdma_info, NULL, 280*3859Sml29623 NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW, 281*3859Sml29623 NXGE_RBR_RBB_MIN, NXGE_RBR_RBB_MAX, NXGE_RBR_RBB_DEFAULT, 0, 282*3859Sml29623 "rx-rbr-size", "rx_rbr_size"}, 283*3859Sml29623 284*3859Sml29623 { nxge_param_get_rxdma_info, NULL, 285*3859Sml29623 NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW, 286*3859Sml29623 NXGE_RCR_MIN, NXGE_RCR_MAX, NXGE_RCR_DEFAULT, 0, 287*3859Sml29623 "rx-rcr-size", "rx_rcr_size"}, 288*3859Sml29623 289*3859Sml29623 { nxge_param_get_generic, nxge_param_set_port_rdc, NXGE_PARAM_RXDMA_RW, 290*3859Sml29623 0, 15, 0, 0, "default-port-rdc", "default_port_rdc"}, 291*3859Sml29623 292*3859Sml29623 { nxge_param_get_generic, nxge_param_rx_intr_time, NXGE_PARAM_RXDMA_RW, 293*3859Sml29623 NXGE_RDC_RCR_TIMEOUT_MIN, NXGE_RDC_RCR_TIMEOUT_MAX, 294*3859Sml29623 RXDMA_RCR_TO_DEFAULT, 0, "rxdma-intr-time", "rxdma_intr_time"}, 295*3859Sml29623 296*3859Sml29623 { nxge_param_get_generic, nxge_param_rx_intr_pkts, NXGE_PARAM_RXDMA_RW, 297*3859Sml29623 NXGE_RDC_RCR_THRESHOLD_MIN, NXGE_RDC_RCR_THRESHOLD_MAX, 298*3859Sml29623 RXDMA_RCR_PTHRES_DEFAULT, 0, 299*3859Sml29623 "rxdma-intr-pkts", "rxdma_intr_pkts"}, 300*3859Sml29623 301*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ_PROP, 302*3859Sml29623 0, 8, 0, 0, "rx-rdc-grps-begin", "rx_rdc_grps_begin"}, 303*3859Sml29623 304*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ_PROP, 305*3859Sml29623 0, 8, 0, 0, "rx-rdc-grps", "rx_rdc_grps"}, 306*3859Sml29623 307*3859Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc, NXGE_PARAM_RXDMA_RW, 308*3859Sml29623 0, 15, 0, 0, "default-grp0-rdc", "default_grp0_rdc"}, 309*3859Sml29623 310*3859Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc, NXGE_PARAM_RXDMA_RW, 311*3859Sml29623 0, 15, 2, 0, "default-grp1-rdc", "default_grp1_rdc"}, 312*3859Sml29623 313*3859Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc, NXGE_PARAM_RXDMA_RW, 314*3859Sml29623 0, 15, 4, 0, "default-grp2-rdc", "default_grp2_rdc"}, 315*3859Sml29623 316*3859Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc, NXGE_PARAM_RXDMA_RW, 317*3859Sml29623 0, 15, 6, 0, "default-grp3-rdc", "default_grp3_rdc"}, 318*3859Sml29623 319*3859Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc, NXGE_PARAM_RXDMA_RW, 320*3859Sml29623 0, 15, 8, 0, "default-grp4-rdc", "default_grp4_rdc"}, 321*3859Sml29623 322*3859Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc, NXGE_PARAM_RXDMA_RW, 323*3859Sml29623 0, 15, 10, 0, "default-grp5-rdc", "default_grp5_rdc"}, 324*3859Sml29623 325*3859Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc, NXGE_PARAM_RXDMA_RW, 326*3859Sml29623 0, 15, 12, 0, "default-grp6-rdc", "default_grp6_rdc"}, 327*3859Sml29623 328*3859Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc, NXGE_PARAM_RXDMA_RW, 329*3859Sml29623 0, 15, 14, 0, "default-grp7-rdc", "default_grp7_rdc"}, 330*3859Sml29623 331*3859Sml29623 { nxge_param_get_rxdma_rdcgrp_info, NULL, 332*3859Sml29623 NXGE_PARAM_READ | NXGE_PARAM_CMPLX, 333*3859Sml29623 0, 8, 0, 0, "rdc-groups-info", "rdc_groups_info"}, 334*3859Sml29623 335*3859Sml29623 /* Logical device groups */ 336*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 337*3859Sml29623 0, 63, 0, 0, "start-ldg", "start_ldg"}, 338*3859Sml29623 339*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ, 340*3859Sml29623 0, 64, 0, 0, "max-ldg", "max_ldg" }, 341*3859Sml29623 342*3859Sml29623 /* MAC table information */ 343*3859Sml29623 { nxge_param_get_mac_rdcgrp, nxge_param_set_mac_rdcgrp, 344*3859Sml29623 NXGE_PARAM_L2CLASS_CFG, 345*3859Sml29623 0, 31, 0, 0, "mac-2rdc-grp", "mac_2rdc_grp"}, 346*3859Sml29623 347*3859Sml29623 /* VLAN table information */ 348*3859Sml29623 { nxge_param_get_vlan_rdcgrp, nxge_param_set_vlan_rdcgrp, 349*3859Sml29623 NXGE_PARAM_L2CLASS_CFG, 350*3859Sml29623 0, 31, 0, 0, "vlan-2rdc-grp", "vlan_2rdc_grp"}, 351*3859Sml29623 352*3859Sml29623 { nxge_param_get_generic, NULL, 353*3859Sml29623 NXGE_PARAM_READ_PROP | NXGE_PARAM_READ | NXGE_PARAM_PROP_ARR32, 354*3859Sml29623 0, 0x0ffff, 0x0ffff, 0, "fcram-part-cfg", "fcram_part_cfg"}, 355*3859Sml29623 356*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_CLASS_RWS, 357*3859Sml29623 0, 0x10, 0xa, 0, "fcram-access-ratio", "fcram_access_ratio"}, 358*3859Sml29623 359*3859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_CLASS_RWS, 360*3859Sml29623 0, 0x10, 0xa, 0, "tcam-access-ratio", "tcam_access_ratio"}, 361*3859Sml29623 362*3859Sml29623 { nxge_param_get_generic, nxge_param_tcam_enable, 363*3859Sml29623 NXGE_PARAM_CLASS_RWS, 364*3859Sml29623 0, 0x1, 0x0, 0, "tcam-enable", "tcam_enable"}, 365*3859Sml29623 366*3859Sml29623 { nxge_param_get_generic, nxge_param_hash_lookup_enable, 367*3859Sml29623 NXGE_PARAM_CLASS_RWS, 368*3859Sml29623 0, 0x01, 0x0, 0, "hash-lookup-enable", "hash_lookup_enable"}, 369*3859Sml29623 370*3859Sml29623 { nxge_param_get_generic, nxge_param_llc_snap_enable, 371*3859Sml29623 NXGE_PARAM_CLASS_RWS, 372*3859Sml29623 0, 0x01, 0x01, 0, "llc-snap-enable", "llc_snap_enable"}, 373*3859Sml29623 374*3859Sml29623 { nxge_param_get_generic, nxge_param_fflp_hash_init, 375*3859Sml29623 NXGE_PARAM_CLASS_RWS, 376*3859Sml29623 0, ALL_FF_32, ALL_FF_32, 0, "h1-init-value", "h1_init_value"}, 377*3859Sml29623 378*3859Sml29623 { nxge_param_get_generic, nxge_param_fflp_hash_init, 379*3859Sml29623 NXGE_PARAM_CLASS_RWS, 380*3859Sml29623 0, 0x0ffff, 0x0ffff, 0, "h2-init-value", "h2_init_value"}, 381*3859Sml29623 382*3859Sml29623 { nxge_param_get_generic, nxge_param_set_ether_usr, 383*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 384*3859Sml29623 0, ALL_FF_32, 0x0, 0, 385*3859Sml29623 "class-cfg-ether-usr1", "class_cfg_ether_usr1"}, 386*3859Sml29623 387*3859Sml29623 { nxge_param_get_generic, nxge_param_set_ether_usr, 388*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 389*3859Sml29623 0, ALL_FF_32, 0x0, 0, 390*3859Sml29623 "class-cfg-ether-usr2", "class_cfg_ether_usr2"}, 391*3859Sml29623 392*3859Sml29623 { nxge_param_get_generic, nxge_param_set_ip_usr, 393*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 394*3859Sml29623 0, ALL_FF_32, 0x0, 0, 395*3859Sml29623 "class-cfg-ip-usr4", "class_cfg_ip_usr4"}, 396*3859Sml29623 397*3859Sml29623 { nxge_param_get_generic, nxge_param_set_ip_usr, 398*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 399*3859Sml29623 0, ALL_FF_32, 0x0, 0, 400*3859Sml29623 "class-cfg-ip-usr5", "class_cfg_ip_usr5"}, 401*3859Sml29623 402*3859Sml29623 { nxge_param_get_generic, nxge_param_set_ip_usr, 403*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 404*3859Sml29623 0, ALL_FF_32, 0x0, 0, 405*3859Sml29623 "class-cfg-ip-usr6", "class_cfg_ip_usr6"}, 406*3859Sml29623 407*3859Sml29623 { nxge_param_get_generic, nxge_param_set_ip_usr, 408*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 409*3859Sml29623 0, ALL_FF_32, 0x0, 0, 410*3859Sml29623 "class-cfg-ip-usr7", "class_cfg_ip_usr7"}, 411*3859Sml29623 412*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, 413*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 414*3859Sml29623 0, ALL_FF_32, 0x0, 0, 415*3859Sml29623 "class-opt-ip-usr4", "class_opt_ip_usr4"}, 416*3859Sml29623 417*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, 418*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 419*3859Sml29623 0, ALL_FF_32, 0x0, 0, 420*3859Sml29623 "class-opt-ip-usr5", "class_opt_ip_usr5"}, 421*3859Sml29623 422*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, 423*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 424*3859Sml29623 0, ALL_FF_32, 0x0, 0, 425*3859Sml29623 "class-opt-ip-usr6", "class_opt_ip_usr6"}, 426*3859Sml29623 427*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, 428*3859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW, 429*3859Sml29623 0, ALL_FF_32, 0x0, 0, 430*3859Sml29623 "class-opt-ip-usr7", "class_opt_ip_usr7"}, 431*3859Sml29623 432*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, 433*3859Sml29623 NXGE_PARAM_CLASS_RWS, 434*3859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0, 435*3859Sml29623 "class-opt-ipv4-tcp", "class_opt_ipv4_tcp"}, 436*3859Sml29623 437*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, 438*3859Sml29623 NXGE_PARAM_CLASS_RWS, 439*3859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0, 440*3859Sml29623 "class-opt-ipv4-udp", "class_opt_ipv4_udp"}, 441*3859Sml29623 442*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, 443*3859Sml29623 NXGE_PARAM_CLASS_RWS, 444*3859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0, 445*3859Sml29623 "class-opt-ipv4-ah", "class_opt_ipv4_ah"}, 446*3859Sml29623 447*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, 448*3859Sml29623 NXGE_PARAM_CLASS_RWS, 449*3859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0, 450*3859Sml29623 "class-opt-ipv4-sctp", "class_opt_ipv4_sctp"}, 451*3859Sml29623 452*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS, 453*3859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0, 454*3859Sml29623 "class-opt-ipv6-tcp", "class_opt_ipv6_tcp"}, 455*3859Sml29623 456*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS, 457*3859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0, 458*3859Sml29623 "class-opt-ipv6-udp", "class_opt_ipv6_udp"}, 459*3859Sml29623 460*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS, 461*3859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0, 462*3859Sml29623 "class-opt-ipv6-ah", "class_opt_ipv6_ah"}, 463*3859Sml29623 464*3859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS, 465*3859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0, 466*3859Sml29623 "class-opt-ipv6-sctp", "class_opt_ipv6_sctp"}, 467*3859Sml29623 468*3859Sml29623 { nxge_param_get_debug_flag, nxge_param_set_nxge_debug_flag, 469*3859Sml29623 NXGE_PARAM_RW, 470*3859Sml29623 0ULL, ALL_FF_64, 0ULL, 0ULL, 471*3859Sml29623 "nxge-debug-flag", "nxge_debug_flag"}, 472*3859Sml29623 473*3859Sml29623 { nxge_param_get_debug_flag, nxge_param_set_npi_debug_flag, 474*3859Sml29623 NXGE_PARAM_RW, 475*3859Sml29623 0ULL, ALL_FF_64, 0ULL, 0ULL, 476*3859Sml29623 "npi-debug-flag", "npi_debug_flag"}, 477*3859Sml29623 478*3859Sml29623 { nxge_param_dump_tdc, NULL, NXGE_PARAM_READ, 479*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-tdc", "dump_tdc"}, 480*3859Sml29623 481*3859Sml29623 { nxge_param_dump_rdc, NULL, NXGE_PARAM_READ, 482*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-rdc", "dump_rdc"}, 483*3859Sml29623 484*3859Sml29623 { nxge_param_dump_mac_regs, NULL, NXGE_PARAM_READ, 485*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-mac-regs", "dump_mac_regs"}, 486*3859Sml29623 487*3859Sml29623 { nxge_param_dump_ipp_regs, NULL, NXGE_PARAM_READ, 488*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-ipp-regs", "dump_ipp_regs"}, 489*3859Sml29623 490*3859Sml29623 { nxge_param_dump_fflp_regs, NULL, NXGE_PARAM_READ, 491*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, 492*3859Sml29623 "dump-fflp-regs", "dump_fflp_regs"}, 493*3859Sml29623 494*3859Sml29623 { nxge_param_dump_vlan_table, NULL, NXGE_PARAM_READ, 495*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, 496*3859Sml29623 "dump-vlan-table", "dump_vlan_table"}, 497*3859Sml29623 498*3859Sml29623 { nxge_param_dump_rdc_table, NULL, NXGE_PARAM_READ, 499*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, 500*3859Sml29623 "dump-rdc-table", "dump_rdc_table"}, 501*3859Sml29623 502*3859Sml29623 { nxge_param_dump_ptrs, NULL, NXGE_PARAM_READ, 503*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-ptrs", "dump_ptrs"}, 504*3859Sml29623 505*3859Sml29623 { NULL, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW, 506*3859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "end", "end"}, 507*3859Sml29623 }; 508*3859Sml29623 509*3859Sml29623 extern void *nxge_list; 510*3859Sml29623 511*3859Sml29623 void 512*3859Sml29623 nxge_get_param_soft_properties(p_nxge_t nxgep) 513*3859Sml29623 { 514*3859Sml29623 515*3859Sml29623 p_nxge_param_t param_arr; 516*3859Sml29623 uint_t prop_len; 517*3859Sml29623 int i, j; 518*3859Sml29623 uint32_t param_count; 519*3859Sml29623 uint32_t *int_prop_val; 520*3859Sml29623 521*3859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, " ==> nxge_get_param_soft_properties")); 522*3859Sml29623 523*3859Sml29623 param_arr = nxgep->param_arr; 524*3859Sml29623 param_count = nxgep->param_count; 525*3859Sml29623 for (i = 0; i < param_count; i++) { 526*3859Sml29623 if ((param_arr[i].type & NXGE_PARAM_READ_PROP) == 0) 527*3859Sml29623 continue; 528*3859Sml29623 if ((param_arr[i].type & NXGE_PARAM_PROP_STR)) 529*3859Sml29623 continue; 530*3859Sml29623 if ((param_arr[i].type & NXGE_PARAM_PROP_ARR32) || 531*3859Sml29623 (param_arr[i].type & NXGE_PARAM_PROP_ARR64)) { 532*3859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, 533*3859Sml29623 nxgep->dip, 0, param_arr[i].fcode_name, 534*3859Sml29623 (int **)&int_prop_val, 535*3859Sml29623 (uint_t *)&prop_len) 536*3859Sml29623 == DDI_PROP_SUCCESS) { 537*3859Sml29623 uint32_t *cfg_value; 538*3859Sml29623 uint64_t prop_count; 539*3859Sml29623 540*3859Sml29623 if (prop_len > NXGE_PARAM_ARRAY_INIT_SIZE) 541*3859Sml29623 prop_len = NXGE_PARAM_ARRAY_INIT_SIZE; 542*3859Sml29623 cfg_value = (uint32_t *)param_arr[i].value; 543*3859Sml29623 for (j = 0; j < prop_len; j++) { 544*3859Sml29623 cfg_value[j] = int_prop_val[j]; 545*3859Sml29623 } 546*3859Sml29623 prop_count = prop_len; 547*3859Sml29623 param_arr[i].type |= 548*3859Sml29623 (prop_count << NXGE_PARAM_ARRAY_CNT_SHIFT); 549*3859Sml29623 ddi_prop_free(int_prop_val); 550*3859Sml29623 } 551*3859Sml29623 continue; 552*3859Sml29623 } 553*3859Sml29623 554*3859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 555*3859Sml29623 param_arr[i].fcode_name, 556*3859Sml29623 (int **)&int_prop_val, 557*3859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 558*3859Sml29623 if ((*int_prop_val >= param_arr[i].minimum) && 559*3859Sml29623 (*int_prop_val <= param_arr[i].maximum)) 560*3859Sml29623 param_arr[i].value = *int_prop_val; 561*3859Sml29623 #ifdef NXGE_DEBUG_ERROR 562*3859Sml29623 else { 563*3859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 564*3859Sml29623 "nxge%d: 'prom' file parameter error\n", 565*3859Sml29623 nxgep->instance)); 566*3859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 567*3859Sml29623 "Parameter keyword '%s'" 568*3859Sml29623 " is outside valid range\n", 569*3859Sml29623 param_arr[i].name)); 570*3859Sml29623 } 571*3859Sml29623 #endif 572*3859Sml29623 ddi_prop_free(int_prop_val); 573*3859Sml29623 } 574*3859Sml29623 575*3859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0, 576*3859Sml29623 param_arr[i].name, 577*3859Sml29623 (int **)&int_prop_val, 578*3859Sml29623 &prop_len) == DDI_PROP_SUCCESS) { 579*3859Sml29623 if ((*int_prop_val >= param_arr[i].minimum) && 580*3859Sml29623 (*int_prop_val <= param_arr[i].maximum)) 581*3859Sml29623 param_arr[i].value = *int_prop_val; 582*3859Sml29623 #ifdef NXGE_DEBUG_ERROR 583*3859Sml29623 else { 584*3859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 585*3859Sml29623 "nxge%d: 'conf' file parameter error\n", 586*3859Sml29623 nxgep->instance)); 587*3859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL, 588*3859Sml29623 "Parameter keyword '%s'" 589*3859Sml29623 "is outside valid range\n", 590*3859Sml29623 param_arr[i].name)); 591*3859Sml29623 } 592*3859Sml29623 #endif 593*3859Sml29623 ddi_prop_free(int_prop_val); 594*3859Sml29623 } 595*3859Sml29623 } 596*3859Sml29623 } 597*3859Sml29623 598*3859Sml29623 static int 599*3859Sml29623 nxge_private_param_register(p_nxge_t nxgep, p_nxge_param_t param_arr) 600*3859Sml29623 { 601*3859Sml29623 int status = B_TRUE; 602*3859Sml29623 int channel; 603*3859Sml29623 uint8_t grp; 604*3859Sml29623 char *prop_name; 605*3859Sml29623 char *end; 606*3859Sml29623 uint32_t name_chars; 607*3859Sml29623 608*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL, 609*3859Sml29623 "nxge_private_param_register %s", param_arr->name)); 610*3859Sml29623 611*3859Sml29623 if ((param_arr->type & NXGE_PARAM_PRIV) != NXGE_PARAM_PRIV) 612*3859Sml29623 return (B_TRUE); 613*3859Sml29623 614*3859Sml29623 prop_name = param_arr->name; 615*3859Sml29623 if (param_arr->type & NXGE_PARAM_RXDMA) { 616*3859Sml29623 if (strncmp("rxdma_intr", prop_name, 10) == 0) 617*3859Sml29623 return (B_TRUE); 618*3859Sml29623 name_chars = strlen("default_grp"); 619*3859Sml29623 if (strncmp("default_grp", prop_name, name_chars) == 0) { 620*3859Sml29623 prop_name += name_chars; 621*3859Sml29623 grp = mi_strtol(prop_name, &end, 10); 622*3859Sml29623 /* now check if this rdcgrp is in config */ 623*3859Sml29623 return (nxge_check_rdcgrp_port_member(nxgep, grp)); 624*3859Sml29623 } 625*3859Sml29623 name_chars = strlen(prop_name); 626*3859Sml29623 if (strncmp("default_port_rdc", prop_name, name_chars) == 0) { 627*3859Sml29623 return (B_TRUE); 628*3859Sml29623 } 629*3859Sml29623 return (B_FALSE); 630*3859Sml29623 } 631*3859Sml29623 632*3859Sml29623 if (param_arr->type & NXGE_PARAM_TXDMA) { 633*3859Sml29623 name_chars = strlen("txdma"); 634*3859Sml29623 if (strncmp("txdma", prop_name, name_chars) == 0) { 635*3859Sml29623 prop_name += name_chars; 636*3859Sml29623 channel = mi_strtol(prop_name, &end, 10); 637*3859Sml29623 /* now check if this rdc is in config */ 638*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL, 639*3859Sml29623 " nxge_private_param_register: %d", 640*3859Sml29623 channel)); 641*3859Sml29623 return (nxge_check_txdma_port_member(nxgep, channel)); 642*3859Sml29623 } 643*3859Sml29623 return (B_FALSE); 644*3859Sml29623 } 645*3859Sml29623 646*3859Sml29623 status = B_FALSE; 647*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL, "<== nxge_private_param_register")); 648*3859Sml29623 649*3859Sml29623 return (status); 650*3859Sml29623 } 651*3859Sml29623 652*3859Sml29623 void 653*3859Sml29623 nxge_setup_param(p_nxge_t nxgep) 654*3859Sml29623 { 655*3859Sml29623 p_nxge_param_t param_arr; 656*3859Sml29623 int i; 657*3859Sml29623 pfi_t set_pfi; 658*3859Sml29623 659*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_setup_param")); 660*3859Sml29623 661*3859Sml29623 /* 662*3859Sml29623 * Make sure the param_instance is set to a valid device instance. 663*3859Sml29623 */ 664*3859Sml29623 if (nxge_param_arr[param_instance].value == 1000) 665*3859Sml29623 nxge_param_arr[param_instance].value = nxgep->instance; 666*3859Sml29623 667*3859Sml29623 param_arr = nxgep->param_arr; 668*3859Sml29623 param_arr[param_instance].value = nxgep->instance; 669*3859Sml29623 param_arr[param_function_number].value = nxgep->function_num; 670*3859Sml29623 671*3859Sml29623 for (i = 0; i < nxgep->param_count; i++) { 672*3859Sml29623 if ((param_arr[i].type & NXGE_PARAM_PRIV) && 673*3859Sml29623 (nxge_private_param_register(nxgep, 674*3859Sml29623 ¶m_arr[i]) == B_FALSE)) { 675*3859Sml29623 param_arr[i].setf = NULL; 676*3859Sml29623 param_arr[i].getf = NULL; 677*3859Sml29623 } 678*3859Sml29623 679*3859Sml29623 if (param_arr[i].type & NXGE_PARAM_CMPLX) 680*3859Sml29623 param_arr[i].setf = NULL; 681*3859Sml29623 682*3859Sml29623 if (param_arr[i].type & NXGE_PARAM_DONT_SHOW) { 683*3859Sml29623 param_arr[i].setf = NULL; 684*3859Sml29623 param_arr[i].getf = NULL; 685*3859Sml29623 } 686*3859Sml29623 687*3859Sml29623 set_pfi = (pfi_t)param_arr[i].setf; 688*3859Sml29623 689*3859Sml29623 if ((set_pfi) && (param_arr[i].type & NXGE_PARAM_INIT_ONLY)) { 690*3859Sml29623 set_pfi = NULL; 691*3859Sml29623 } 692*3859Sml29623 693*3859Sml29623 if (!nxge_nd_load(&nxgep->param_list, param_arr[i].name, 694*3859Sml29623 (pfi_t)param_arr[i].getf, set_pfi, 695*3859Sml29623 (caddr_t)¶m_arr[i])) { 696*3859Sml29623 (void) nxge_nd_free(&nxgep->param_list); 697*3859Sml29623 break; 698*3859Sml29623 } 699*3859Sml29623 } 700*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_setup_param")); 701*3859Sml29623 } 702*3859Sml29623 703*3859Sml29623 void 704*3859Sml29623 nxge_init_param(p_nxge_t nxgep) 705*3859Sml29623 { 706*3859Sml29623 p_nxge_param_t param_arr; 707*3859Sml29623 int i, alloc_size; 708*3859Sml29623 uint64_t alloc_count; 709*3859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_init_param")); 710*3859Sml29623 /* 711*3859Sml29623 * Make sure the param_instance is set to a valid device instance. 712*3859Sml29623 */ 713*3859Sml29623 if (nxge_param_arr[param_instance].value == 1000) 714*3859Sml29623 nxge_param_arr[param_instance].value = nxgep->instance; 715*3859Sml29623 716*3859Sml29623 param_arr = nxgep->param_arr; 717*3859Sml29623 if (param_arr == NULL) { 718*3859Sml29623 param_arr = (p_nxge_param_t) 719*3859Sml29623 KMEM_ZALLOC(sizeof (nxge_param_arr), KM_SLEEP); 720*3859Sml29623 } 721*3859Sml29623 722*3859Sml29623 for (i = 0; i < sizeof (nxge_param_arr)/sizeof (nxge_param_t); i++) { 723*3859Sml29623 param_arr[i] = nxge_param_arr[i]; 724*3859Sml29623 if ((param_arr[i].type & NXGE_PARAM_PROP_ARR32) || 725*3859Sml29623 (param_arr[i].type & NXGE_PARAM_PROP_ARR64)) { 726*3859Sml29623 alloc_count = NXGE_PARAM_ARRAY_INIT_SIZE; 727*3859Sml29623 alloc_size = alloc_count * sizeof (uint64_t); 728*3859Sml29623 param_arr[i].value = 729*3859Sml29623 (uint64_t)KMEM_ZALLOC(alloc_size, KM_SLEEP); 730*3859Sml29623 param_arr[i].old_value = 731*3859Sml29623 (uint64_t)KMEM_ZALLOC(alloc_size, KM_SLEEP); 732*3859Sml29623 param_arr[i].type |= 733*3859Sml29623 (alloc_count << NXGE_PARAM_ARRAY_ALLOC_SHIFT); 734*3859Sml29623 } 735*3859Sml29623 } 736*3859Sml29623 737*3859Sml29623 nxgep->param_arr = param_arr; 738*3859Sml29623 nxgep->param_count = sizeof (nxge_param_arr)/sizeof (nxge_param_t); 739*3859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_init_param: count %d", 740*3859Sml29623 nxgep->param_count)); 741*3859Sml29623 } 742*3859Sml29623 743*3859Sml29623 void 744*3859Sml29623 nxge_destroy_param(p_nxge_t nxgep) 745*3859Sml29623 { 746*3859Sml29623 int i; 747*3859Sml29623 uint64_t free_size, free_count; 748*3859Sml29623 749*3859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_destroy_param")); 750*3859Sml29623 751*3859Sml29623 /* 752*3859Sml29623 * Make sure the param_instance is set to a valid device instance. 753*3859Sml29623 */ 754*3859Sml29623 if (nxge_param_arr[param_instance].value == nxgep->instance) { 755*3859Sml29623 for (i = 0; i <= nxge_param_arr[param_instance].maximum; i++) { 756*3859Sml29623 if ((ddi_get_soft_state(nxge_list, i) != NULL) && 757*3859Sml29623 (i != nxgep->instance)) 758*3859Sml29623 break; 759*3859Sml29623 } 760*3859Sml29623 nxge_param_arr[param_instance].value = i; 761*3859Sml29623 } 762*3859Sml29623 763*3859Sml29623 if (nxgep->param_list) 764*3859Sml29623 nxge_nd_free(&nxgep->param_list); 765*3859Sml29623 for (i = 0; i < nxgep->param_count; i++) 766*3859Sml29623 if ((nxgep->param_arr[i].type & NXGE_PARAM_PROP_ARR32) || 767*3859Sml29623 (nxgep->param_arr[i].type & NXGE_PARAM_PROP_ARR64)) { 768*3859Sml29623 free_count = ((nxgep->param_arr[i].type & 769*3859Sml29623 NXGE_PARAM_ARRAY_ALLOC_MASK) >> 770*3859Sml29623 NXGE_PARAM_ARRAY_ALLOC_SHIFT); 771*3859Sml29623 free_count = NXGE_PARAM_ARRAY_INIT_SIZE; 772*3859Sml29623 free_size = sizeof (uint64_t) * free_count; 773*3859Sml29623 KMEM_FREE((void *)nxgep->param_arr[i].value, free_size); 774*3859Sml29623 KMEM_FREE((void *)nxgep->param_arr[i].old_value, 775*3859Sml29623 free_size); 776*3859Sml29623 } 777*3859Sml29623 778*3859Sml29623 KMEM_FREE(nxgep->param_arr, sizeof (nxge_param_arr)); 779*3859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_destroy_param")); 780*3859Sml29623 } 781*3859Sml29623 782*3859Sml29623 /* 783*3859Sml29623 * Extracts the value from the 'nxge' parameter array and prints the 784*3859Sml29623 * parameter value. cp points to the required parameter. 785*3859Sml29623 */ 786*3859Sml29623 787*3859Sml29623 /* ARGSUSED */ 788*3859Sml29623 int 789*3859Sml29623 nxge_param_get_generic(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 790*3859Sml29623 { 791*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 792*3859Sml29623 793*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 794*3859Sml29623 "==> nxge_param_get_generic name %s ", pa->name)); 795*3859Sml29623 796*3859Sml29623 if (pa->value > 0xffffffff) 797*3859Sml29623 (void) mi_mpprintf(mp, "%x%x", 798*3859Sml29623 (int)(pa->value >> 32), (int)(pa->value & 0xffffffff)); 799*3859Sml29623 else 800*3859Sml29623 (void) mi_mpprintf(mp, "%x", (int)pa->value); 801*3859Sml29623 802*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_generic")); 803*3859Sml29623 return (0); 804*3859Sml29623 } 805*3859Sml29623 806*3859Sml29623 /* ARGSUSED */ 807*3859Sml29623 static int 808*3859Sml29623 nxge_param_get_mac(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 809*3859Sml29623 { 810*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 811*3859Sml29623 812*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_mac")); 813*3859Sml29623 814*3859Sml29623 (void) mi_mpprintf(mp, "%d", (uint32_t)pa->value); 815*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_mac")); 816*3859Sml29623 return (0); 817*3859Sml29623 } 818*3859Sml29623 819*3859Sml29623 /* ARGSUSED */ 820*3859Sml29623 int 821*3859Sml29623 nxge_param_get_txdma_info(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 822*3859Sml29623 { 823*3859Sml29623 824*3859Sml29623 uint_t print_len, buf_len; 825*3859Sml29623 p_mblk_t np; 826*3859Sml29623 int tdc; 827*3859Sml29623 828*3859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE; 829*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_txdma_info")); 830*3859Sml29623 831*3859Sml29623 (void) mi_mpprintf(mp, "TXDMA Information for Port\t %d \n", 832*3859Sml29623 nxgep->function_num); 833*3859Sml29623 834*3859Sml29623 835*3859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) { 836*3859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer"); 837*3859Sml29623 return (0); 838*3859Sml29623 } 839*3859Sml29623 840*3859Sml29623 buf_len = buff_alloc_size; 841*3859Sml29623 mp->b_cont = np; 842*3859Sml29623 843*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 844*3859Sml29623 "Total TDCs\t %d\n", nxgep->ntdc); 845*3859Sml29623 846*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 847*3859Sml29623 buf_len -= print_len; 848*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 849*3859Sml29623 "TDC\t HW TDC\t\n"); 850*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 851*3859Sml29623 852*3859Sml29623 buf_len -= print_len; 853*3859Sml29623 for (tdc = 0; tdc < nxgep->ntdc; tdc++) { 854*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, 855*3859Sml29623 buf_len, "%d\t %d\n", 856*3859Sml29623 tdc, nxgep->tdc[tdc]); 857*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 858*3859Sml29623 buf_len -= print_len; 859*3859Sml29623 } 860*3859Sml29623 861*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_txdma_info")); 862*3859Sml29623 return (0); 863*3859Sml29623 } 864*3859Sml29623 865*3859Sml29623 /* ARGSUSED */ 866*3859Sml29623 int 867*3859Sml29623 nxge_param_get_rxdma_info(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 868*3859Sml29623 { 869*3859Sml29623 uint_t print_len, buf_len; 870*3859Sml29623 p_mblk_t np; 871*3859Sml29623 int rdc; 872*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 873*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 874*3859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE; 875*3859Sml29623 p_rx_rcr_rings_t rx_rcr_rings; 876*3859Sml29623 p_rx_rcr_ring_t *rcr_rings; 877*3859Sml29623 p_rx_rbr_rings_t rx_rbr_rings; 878*3859Sml29623 p_rx_rbr_ring_t *rbr_rings; 879*3859Sml29623 880*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_rxdma_info")); 881*3859Sml29623 882*3859Sml29623 (void) mi_mpprintf(mp, "RXDMA Information for Port\t %d \n", 883*3859Sml29623 nxgep->function_num); 884*3859Sml29623 885*3859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) { 886*3859Sml29623 /* The following may work even if we cannot get a large buf. */ 887*3859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer"); 888*3859Sml29623 return (0); 889*3859Sml29623 } 890*3859Sml29623 891*3859Sml29623 buf_len = buff_alloc_size; 892*3859Sml29623 mp->b_cont = np; 893*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 894*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 895*3859Sml29623 896*3859Sml29623 rx_rcr_rings = nxgep->rx_rcr_rings; 897*3859Sml29623 rcr_rings = rx_rcr_rings->rcr_rings; 898*3859Sml29623 rx_rbr_rings = nxgep->rx_rbr_rings; 899*3859Sml29623 rbr_rings = rx_rbr_rings->rbr_rings; 900*3859Sml29623 901*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 902*3859Sml29623 "Total RDCs\t %d\n", p_cfgp->max_rdcs); 903*3859Sml29623 904*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 905*3859Sml29623 buf_len -= print_len; 906*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 907*3859Sml29623 "RDC\t HW RDC\t Timeout\t Packets RBR ptr \t" 908*3859Sml29623 "chunks\t RCR ptr\n"); 909*3859Sml29623 910*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 911*3859Sml29623 buf_len -= print_len; 912*3859Sml29623 for (rdc = 0; rdc < p_cfgp->max_rdcs; rdc++) { 913*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 914*3859Sml29623 " %d\t %d\t %x\t\t %x\t $%p\t 0x%x\t $%p\n", 915*3859Sml29623 rdc, nxgep->rdc[rdc], 916*3859Sml29623 p_dma_cfgp->rcr_timeout[rdc], 917*3859Sml29623 p_dma_cfgp->rcr_threshold[rdc], 918*3859Sml29623 rbr_rings[rdc], 919*3859Sml29623 rbr_rings[rdc]->num_blocks, rcr_rings[rdc]); 920*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 921*3859Sml29623 buf_len -= print_len; 922*3859Sml29623 } 923*3859Sml29623 924*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_rxdma_info")); 925*3859Sml29623 return (0); 926*3859Sml29623 } 927*3859Sml29623 928*3859Sml29623 /* ARGSUSED */ 929*3859Sml29623 int 930*3859Sml29623 nxge_param_get_rxdma_rdcgrp_info(p_nxge_t nxgep, queue_t *q, 931*3859Sml29623 p_mblk_t mp, caddr_t cp) 932*3859Sml29623 { 933*3859Sml29623 uint_t print_len, buf_len; 934*3859Sml29623 p_mblk_t np; 935*3859Sml29623 int offset, rdc, i, rdc_grp; 936*3859Sml29623 p_nxge_rdc_grp_t rdc_grp_p; 937*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 938*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 939*3859Sml29623 940*3859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE; 941*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 942*3859Sml29623 "==> nxge_param_get_rxdma_rdcgrp_info")); 943*3859Sml29623 944*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 945*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 946*3859Sml29623 947*3859Sml29623 (void) mi_mpprintf(mp, "RXDMA RDC Group Information for Port\t %d \n", 948*3859Sml29623 nxgep->function_num); 949*3859Sml29623 950*3859Sml29623 rdc_grp = p_cfgp->start_rdc_grpid; 951*3859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) { 952*3859Sml29623 /* The following may work even if we cannot get a large buf. */ 953*3859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer"); 954*3859Sml29623 return (0); 955*3859Sml29623 } 956*3859Sml29623 957*3859Sml29623 buf_len = buff_alloc_size; 958*3859Sml29623 mp->b_cont = np; 959*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 960*3859Sml29623 "Total RDC Groups\t %d \n" 961*3859Sml29623 "start RDC group\t %d\n", 962*3859Sml29623 p_cfgp->max_rdc_grpids, 963*3859Sml29623 p_cfgp->start_rdc_grpid); 964*3859Sml29623 965*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 966*3859Sml29623 buf_len -= print_len; 967*3859Sml29623 968*3859Sml29623 for (i = 0, rdc_grp = p_cfgp->start_rdc_grpid; 969*3859Sml29623 rdc_grp < (p_cfgp->max_rdc_grpids + p_cfgp->start_rdc_grpid); 970*3859Sml29623 rdc_grp++, i++) { 971*3859Sml29623 rdc_grp_p = &p_dma_cfgp->rdc_grps[i]; 972*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 973*3859Sml29623 "\nRDC Group Info for Group [%d] %d\n" 974*3859Sml29623 "RDC Count %d\tstart RDC %d\n" 975*3859Sml29623 "RDC Group Population Information" 976*3859Sml29623 " (offsets 0 - 15)\n", 977*3859Sml29623 i, rdc_grp, rdc_grp_p->max_rdcs, 978*3859Sml29623 rdc_grp_p->start_rdc); 979*3859Sml29623 980*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 981*3859Sml29623 buf_len -= print_len; 982*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, 983*3859Sml29623 buf_len, "\n"); 984*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 985*3859Sml29623 buf_len -= print_len; 986*3859Sml29623 987*3859Sml29623 for (rdc = 0; rdc < rdc_grp_p->max_rdcs; rdc++) { 988*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, 989*3859Sml29623 buf_len, "[%d]=%d ", rdc, 990*3859Sml29623 rdc_grp_p->start_rdc + rdc); 991*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 992*3859Sml29623 buf_len -= print_len; 993*3859Sml29623 } 994*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, 995*3859Sml29623 buf_len, "\n"); 996*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 997*3859Sml29623 buf_len -= print_len; 998*3859Sml29623 999*3859Sml29623 for (offset = 0; offset < 16; offset++) { 1000*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, 1001*3859Sml29623 buf_len, " %2d ", 1002*3859Sml29623 rdc_grp_p->rdc[offset]); 1003*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 1004*3859Sml29623 buf_len -= print_len; 1005*3859Sml29623 } 1006*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, 1007*3859Sml29623 buf_len, "\n"); 1008*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 1009*3859Sml29623 buf_len -= print_len; 1010*3859Sml29623 } 1011*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1012*3859Sml29623 "<== nxge_param_get_rxdma_rdcgrp_info")); 1013*3859Sml29623 return (0); 1014*3859Sml29623 } 1015*3859Sml29623 1016*3859Sml29623 int 1017*3859Sml29623 nxge_mk_mblk_tail_space(p_mblk_t mp, p_mblk_t *nmp, size_t size) 1018*3859Sml29623 { 1019*3859Sml29623 p_mblk_t tmp; 1020*3859Sml29623 1021*3859Sml29623 tmp = mp; 1022*3859Sml29623 while (tmp->b_cont) 1023*3859Sml29623 tmp = tmp->b_cont; 1024*3859Sml29623 if ((tmp->b_wptr + size) >= tmp->b_datap->db_lim) { 1025*3859Sml29623 tmp->b_cont = allocb(1024, BPRI_HI); 1026*3859Sml29623 tmp = tmp->b_cont; 1027*3859Sml29623 if (!tmp) 1028*3859Sml29623 return (ENOMEM); 1029*3859Sml29623 } 1030*3859Sml29623 1031*3859Sml29623 *nmp = tmp; 1032*3859Sml29623 return (0); 1033*3859Sml29623 } 1034*3859Sml29623 1035*3859Sml29623 /* 1036*3859Sml29623 * Sets the ge parameter to the value in the nxge_param_register using 1037*3859Sml29623 * nxge_nd_load(). 1038*3859Sml29623 */ 1039*3859Sml29623 1040*3859Sml29623 /* ARGSUSED */ 1041*3859Sml29623 int 1042*3859Sml29623 nxge_param_set_generic(p_nxge_t nxgep, queue_t *q, mblk_t *mp, 1043*3859Sml29623 char *value, caddr_t cp) 1044*3859Sml29623 { 1045*3859Sml29623 char *end; 1046*3859Sml29623 uint32_t new_value; 1047*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1048*3859Sml29623 1049*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, " ==> nxge_param_set_generic")); 1050*3859Sml29623 new_value = (uint32_t)mi_strtol(value, &end, 10); 1051*3859Sml29623 if (end == value || new_value < pa->minimum || 1052*3859Sml29623 new_value > pa->maximum) { 1053*3859Sml29623 return (EINVAL); 1054*3859Sml29623 } 1055*3859Sml29623 pa->value = new_value; 1056*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, " <== nxge_param_set_generic")); 1057*3859Sml29623 return (0); 1058*3859Sml29623 } 1059*3859Sml29623 1060*3859Sml29623 /* 1061*3859Sml29623 * Sets the ge parameter to the value in the nxge_param_register using 1062*3859Sml29623 * nxge_nd_load(). 1063*3859Sml29623 */ 1064*3859Sml29623 1065*3859Sml29623 /* ARGSUSED */ 1066*3859Sml29623 int 1067*3859Sml29623 nxge_param_set_instance(p_nxge_t nxgep, queue_t *q, mblk_t *mp, 1068*3859Sml29623 char *value, caddr_t cp) 1069*3859Sml29623 { 1070*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " ==> nxge_param_set_instance")); 1071*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_set_instance")); 1072*3859Sml29623 return (0); 1073*3859Sml29623 } 1074*3859Sml29623 1075*3859Sml29623 /* 1076*3859Sml29623 * Sets the ge parameter to the value in the nxge_param_register using 1077*3859Sml29623 * nxge_nd_load(). 1078*3859Sml29623 */ 1079*3859Sml29623 1080*3859Sml29623 /* ARGSUSED */ 1081*3859Sml29623 int 1082*3859Sml29623 nxge_param_set_mac(p_nxge_t nxgep, queue_t *q, mblk_t *mp, 1083*3859Sml29623 char *value, caddr_t cp) 1084*3859Sml29623 { 1085*3859Sml29623 char *end; 1086*3859Sml29623 uint32_t new_value; 1087*3859Sml29623 int status = 0; 1088*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1089*3859Sml29623 1090*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_mac")); 1091*3859Sml29623 new_value = (uint32_t)mi_strtol(value, &end, BASE_DECIMAL); 1092*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, new_value, pa)) { 1093*3859Sml29623 return (EINVAL); 1094*3859Sml29623 } 1095*3859Sml29623 1096*3859Sml29623 if (pa->value != new_value) { 1097*3859Sml29623 pa->old_value = pa->value; 1098*3859Sml29623 pa->value = new_value; 1099*3859Sml29623 } 1100*3859Sml29623 1101*3859Sml29623 if (!nxge_param_link_update(nxgep)) { 1102*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1103*3859Sml29623 " false ret from nxge_param_link_update")); 1104*3859Sml29623 status = EINVAL; 1105*3859Sml29623 } 1106*3859Sml29623 1107*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_mac")); 1108*3859Sml29623 return (status); 1109*3859Sml29623 } 1110*3859Sml29623 1111*3859Sml29623 /* ARGSUSED */ 1112*3859Sml29623 static int 1113*3859Sml29623 nxge_param_rx_intr_pkts(p_nxge_t nxgep, queue_t *q, mblk_t *mp, 1114*3859Sml29623 char *value, caddr_t cp) 1115*3859Sml29623 { 1116*3859Sml29623 char *end; 1117*3859Sml29623 uint32_t cfg_value; 1118*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1119*3859Sml29623 1120*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_rx_intr_pkts")); 1121*3859Sml29623 1122*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY); 1123*3859Sml29623 1124*3859Sml29623 if ((cfg_value > NXGE_RDC_RCR_THRESHOLD_MAX) || 1125*3859Sml29623 (cfg_value < NXGE_RDC_RCR_THRESHOLD_MIN)) { 1126*3859Sml29623 return (EINVAL); 1127*3859Sml29623 } 1128*3859Sml29623 1129*3859Sml29623 if ((pa->value != cfg_value)) { 1130*3859Sml29623 pa->old_value = pa->value; 1131*3859Sml29623 pa->value = cfg_value; 1132*3859Sml29623 nxgep->intr_threshold = pa->value; 1133*3859Sml29623 } 1134*3859Sml29623 1135*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_rx_intr_pkts")); 1136*3859Sml29623 return (0); 1137*3859Sml29623 } 1138*3859Sml29623 1139*3859Sml29623 /* ARGSUSED */ 1140*3859Sml29623 static int 1141*3859Sml29623 nxge_param_rx_intr_time(p_nxge_t nxgep, queue_t *q, mblk_t *mp, 1142*3859Sml29623 char *value, caddr_t cp) 1143*3859Sml29623 { 1144*3859Sml29623 char *end; 1145*3859Sml29623 uint32_t cfg_value; 1146*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1147*3859Sml29623 1148*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_rx_intr_time")); 1149*3859Sml29623 1150*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY); 1151*3859Sml29623 1152*3859Sml29623 if ((cfg_value > NXGE_RDC_RCR_TIMEOUT_MAX) || 1153*3859Sml29623 (cfg_value < NXGE_RDC_RCR_TIMEOUT_MIN)) { 1154*3859Sml29623 return (EINVAL); 1155*3859Sml29623 } 1156*3859Sml29623 1157*3859Sml29623 if ((pa->value != cfg_value)) { 1158*3859Sml29623 pa->old_value = pa->value; 1159*3859Sml29623 pa->value = cfg_value; 1160*3859Sml29623 nxgep->intr_timeout = pa->value; 1161*3859Sml29623 } 1162*3859Sml29623 1163*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_rx_intr_time")); 1164*3859Sml29623 return (0); 1165*3859Sml29623 } 1166*3859Sml29623 1167*3859Sml29623 /* ARGSUSED */ 1168*3859Sml29623 static int 1169*3859Sml29623 nxge_param_set_mac_rdcgrp(p_nxge_t nxgep, queue_t *q, 1170*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1171*3859Sml29623 { 1172*3859Sml29623 char *end; 1173*3859Sml29623 uint32_t status = 0, cfg_value; 1174*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1175*3859Sml29623 uint32_t cfg_it = B_FALSE; 1176*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 1177*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 1178*3859Sml29623 uint32_t *val_ptr, *old_val_ptr; 1179*3859Sml29623 nxge_param_map_t *mac_map; 1180*3859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 1181*3859Sml29623 nxge_mv_cfg_t *mac_host_info; 1182*3859Sml29623 1183*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_mac_rdcgrp ")); 1184*3859Sml29623 1185*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 1186*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 1187*3859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 1188*3859Sml29623 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0]; 1189*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX); 1190*3859Sml29623 1191*3859Sml29623 /* 1192*3859Sml29623 * now do decoding 1193*3859Sml29623 */ 1194*3859Sml29623 mac_map = (nxge_param_map_t *)&cfg_value; 1195*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " cfg_value %x id %x map_to %x", 1196*3859Sml29623 cfg_value, mac_map->param_id, mac_map->map_to)); 1197*3859Sml29623 1198*3859Sml29623 if ((mac_map->param_id < p_cfgp->max_macs) && 1199*3859Sml29623 (mac_map->map_to < (p_cfgp->max_rdc_grpids + 1200*3859Sml29623 p_cfgp->start_rdc_grpid)) && (mac_map->map_to >= 1201*3859Sml29623 p_cfgp->start_rdc_grpid)) { 1202*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1203*3859Sml29623 " nxge_param_set_mac_rdcgrp mapping" 1204*3859Sml29623 " id %d grp %d", mac_map->param_id, mac_map->map_to)); 1205*3859Sml29623 val_ptr = (uint32_t *)pa->value; 1206*3859Sml29623 old_val_ptr = (uint32_t *)pa->old_value; 1207*3859Sml29623 if (val_ptr[mac_map->param_id] != cfg_value) { 1208*3859Sml29623 old_val_ptr[mac_map->param_id] = 1209*3859Sml29623 val_ptr[mac_map->param_id]; 1210*3859Sml29623 val_ptr[mac_map->param_id] = cfg_value; 1211*3859Sml29623 mac_host_info[mac_map->param_id].mpr_npr = 1212*3859Sml29623 mac_map->pref; 1213*3859Sml29623 mac_host_info[mac_map->param_id].flag = 1; 1214*3859Sml29623 mac_host_info[mac_map->param_id].rdctbl = 1215*3859Sml29623 mac_map->map_to; 1216*3859Sml29623 cfg_it = B_TRUE; 1217*3859Sml29623 } 1218*3859Sml29623 } else { 1219*3859Sml29623 return (EINVAL); 1220*3859Sml29623 } 1221*3859Sml29623 1222*3859Sml29623 if (cfg_it == B_TRUE) { 1223*3859Sml29623 status = nxge_logical_mac_assign_rdc_table(nxgep, 1224*3859Sml29623 (uint8_t)mac_map->param_id); 1225*3859Sml29623 if (status != NXGE_OK) 1226*3859Sml29623 return (EINVAL); 1227*3859Sml29623 } 1228*3859Sml29623 1229*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_mac_rdcgrp")); 1230*3859Sml29623 return (0); 1231*3859Sml29623 } 1232*3859Sml29623 1233*3859Sml29623 /* ARGSUSED */ 1234*3859Sml29623 static int 1235*3859Sml29623 nxge_param_set_vlan_rdcgrp(p_nxge_t nxgep, queue_t *q, 1236*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1237*3859Sml29623 { 1238*3859Sml29623 char *end; 1239*3859Sml29623 uint32_t status = 0, cfg_value; 1240*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1241*3859Sml29623 uint32_t cfg_it = B_FALSE; 1242*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 1243*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 1244*3859Sml29623 uint32_t *val_ptr, *old_val_ptr; 1245*3859Sml29623 nxge_param_map_t *vmap, *old_map; 1246*3859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 1247*3859Sml29623 uint64_t cfgd_vlans; 1248*3859Sml29623 int i, inc = 0, cfg_position; 1249*3859Sml29623 nxge_mv_cfg_t *vlan_tbl; 1250*3859Sml29623 1251*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_vlan_rdcgrp ")); 1252*3859Sml29623 1253*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 1254*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 1255*3859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 1256*3859Sml29623 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0]; 1257*3859Sml29623 1258*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX); 1259*3859Sml29623 1260*3859Sml29623 /* now do decoding */ 1261*3859Sml29623 cfgd_vlans = ((pa->type & NXGE_PARAM_ARRAY_CNT_MASK) >> 1262*3859Sml29623 NXGE_PARAM_ARRAY_CNT_SHIFT); 1263*3859Sml29623 1264*3859Sml29623 if (cfgd_vlans == NXGE_PARAM_ARRAY_INIT_SIZE) { 1265*3859Sml29623 /* 1266*3859Sml29623 * for now, we process only upto max 1267*3859Sml29623 * NXGE_PARAM_ARRAY_INIT_SIZE parameters 1268*3859Sml29623 * In the future, we may want to expand 1269*3859Sml29623 * the storage array and continue 1270*3859Sml29623 */ 1271*3859Sml29623 return (EINVAL); 1272*3859Sml29623 } 1273*3859Sml29623 1274*3859Sml29623 vmap = (nxge_param_map_t *)&cfg_value; 1275*3859Sml29623 if ((vmap->param_id) && 1276*3859Sml29623 (vmap->param_id < NXGE_MAX_VLANS) && 1277*3859Sml29623 (vmap->map_to < p_cfgp->max_rdc_grpids)) { 1278*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1279*3859Sml29623 "nxge_param_set_vlan_rdcgrp mapping" 1280*3859Sml29623 " id %d grp %d", 1281*3859Sml29623 vmap->param_id, vmap->map_to)); 1282*3859Sml29623 val_ptr = (uint32_t *)pa->value; 1283*3859Sml29623 old_val_ptr = (uint32_t *)pa->old_value; 1284*3859Sml29623 1285*3859Sml29623 /* search to see if this vlan id is already configured */ 1286*3859Sml29623 for (i = 0; i < cfgd_vlans; i++) { 1287*3859Sml29623 old_map = (nxge_param_map_t *)&val_ptr[i]; 1288*3859Sml29623 if ((old_map->param_id == 0) || 1289*3859Sml29623 (vmap->param_id == old_map->param_id) || 1290*3859Sml29623 (vlan_tbl[vmap->param_id].flag)) { 1291*3859Sml29623 cfg_position = i; 1292*3859Sml29623 break; 1293*3859Sml29623 } 1294*3859Sml29623 } 1295*3859Sml29623 1296*3859Sml29623 if (cfgd_vlans == 0) { 1297*3859Sml29623 cfg_position = 0; 1298*3859Sml29623 inc++; 1299*3859Sml29623 } 1300*3859Sml29623 1301*3859Sml29623 if (i == cfgd_vlans) { 1302*3859Sml29623 cfg_position = i; 1303*3859Sml29623 inc++; 1304*3859Sml29623 } 1305*3859Sml29623 1306*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL, 1307*3859Sml29623 "set_vlan_rdcgrp mapping" 1308*3859Sml29623 " i %d cfgd_vlans %llx position %d ", 1309*3859Sml29623 i, cfgd_vlans, cfg_position)); 1310*3859Sml29623 if (val_ptr[cfg_position] != cfg_value) { 1311*3859Sml29623 old_val_ptr[cfg_position] = val_ptr[cfg_position]; 1312*3859Sml29623 val_ptr[cfg_position] = cfg_value; 1313*3859Sml29623 vlan_tbl[vmap->param_id].mpr_npr = vmap->pref; 1314*3859Sml29623 vlan_tbl[vmap->param_id].flag = 1; 1315*3859Sml29623 vlan_tbl[vmap->param_id].rdctbl = 1316*3859Sml29623 vmap->map_to + p_cfgp->start_rdc_grpid; 1317*3859Sml29623 cfg_it = B_TRUE; 1318*3859Sml29623 if (inc) { 1319*3859Sml29623 cfgd_vlans++; 1320*3859Sml29623 pa->type &= ~NXGE_PARAM_ARRAY_CNT_MASK; 1321*3859Sml29623 pa->type |= (cfgd_vlans << 1322*3859Sml29623 NXGE_PARAM_ARRAY_CNT_SHIFT); 1323*3859Sml29623 1324*3859Sml29623 } 1325*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL, 1326*3859Sml29623 "after: param_set_vlan_rdcgrp " 1327*3859Sml29623 " cfg_vlans %llx position %d \n", 1328*3859Sml29623 cfgd_vlans, cfg_position)); 1329*3859Sml29623 } 1330*3859Sml29623 } else { 1331*3859Sml29623 return (EINVAL); 1332*3859Sml29623 } 1333*3859Sml29623 1334*3859Sml29623 if (cfg_it == B_TRUE) { 1335*3859Sml29623 status = nxge_fflp_config_vlan_table(nxgep, 1336*3859Sml29623 (uint16_t)vmap->param_id); 1337*3859Sml29623 if (status != NXGE_OK) 1338*3859Sml29623 return (EINVAL); 1339*3859Sml29623 } 1340*3859Sml29623 1341*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_vlan_rdcgrp")); 1342*3859Sml29623 return (0); 1343*3859Sml29623 } 1344*3859Sml29623 1345*3859Sml29623 /* ARGSUSED */ 1346*3859Sml29623 static int 1347*3859Sml29623 nxge_param_get_vlan_rdcgrp(p_nxge_t nxgep, queue_t *q, 1348*3859Sml29623 mblk_t *mp, caddr_t cp) 1349*3859Sml29623 { 1350*3859Sml29623 1351*3859Sml29623 uint_t print_len, buf_len; 1352*3859Sml29623 p_mblk_t np; 1353*3859Sml29623 int i; 1354*3859Sml29623 uint32_t *val_ptr; 1355*3859Sml29623 nxge_param_map_t *vmap; 1356*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1357*3859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 1358*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 1359*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 1360*3859Sml29623 uint64_t cfgd_vlans = 0; 1361*3859Sml29623 nxge_mv_cfg_t *vlan_tbl; 1362*3859Sml29623 int buff_alloc_size = 1363*3859Sml29623 NXGE_NDD_INFODUMP_BUFF_SIZE * 32; 1364*3859Sml29623 1365*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_vlan_rdcgrp ")); 1366*3859Sml29623 (void) mi_mpprintf(mp, "VLAN RDC Mapping Information for Port\t %d \n", 1367*3859Sml29623 nxgep->function_num); 1368*3859Sml29623 1369*3859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) { 1370*3859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer"); 1371*3859Sml29623 return (0); 1372*3859Sml29623 } 1373*3859Sml29623 1374*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 1375*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 1376*3859Sml29623 1377*3859Sml29623 buf_len = buff_alloc_size; 1378*3859Sml29623 mp->b_cont = np; 1379*3859Sml29623 cfgd_vlans = (pa->type & NXGE_PARAM_ARRAY_CNT_MASK) >> 1380*3859Sml29623 NXGE_PARAM_ARRAY_CNT_SHIFT; 1381*3859Sml29623 1382*3859Sml29623 i = (int)cfgd_vlans; 1383*3859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 1384*3859Sml29623 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0]; 1385*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 1386*3859Sml29623 "Configured VLANs %d\n" 1387*3859Sml29623 "VLAN ID\t RDC GRP (Actual/Port)\t" 1388*3859Sml29623 " Prefernce\n", i); 1389*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 1390*3859Sml29623 buf_len -= print_len; 1391*3859Sml29623 1392*3859Sml29623 val_ptr = (uint32_t *)pa->value; 1393*3859Sml29623 1394*3859Sml29623 for (i = 0; i < cfgd_vlans; i++) { 1395*3859Sml29623 vmap = (nxge_param_map_t *)&val_ptr[i]; 1396*3859Sml29623 if (p_class_cfgp->vlan_tbl[vmap->param_id].flag) { 1397*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, 1398*3859Sml29623 buf_len, 1399*3859Sml29623 " %d\t\t %d/%d\t\t %d\n", 1400*3859Sml29623 vmap->param_id, 1401*3859Sml29623 vlan_tbl[vmap->param_id].rdctbl, 1402*3859Sml29623 vlan_tbl[vmap->param_id].rdctbl - 1403*3859Sml29623 p_cfgp->start_rdc_grpid, 1404*3859Sml29623 vlan_tbl[vmap->param_id].mpr_npr); 1405*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 1406*3859Sml29623 buf_len -= print_len; 1407*3859Sml29623 } 1408*3859Sml29623 } 1409*3859Sml29623 1410*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_vlan_rdcgrp")); 1411*3859Sml29623 return (0); 1412*3859Sml29623 } 1413*3859Sml29623 1414*3859Sml29623 /* ARGSUSED */ 1415*3859Sml29623 static int 1416*3859Sml29623 nxge_param_get_mac_rdcgrp(p_nxge_t nxgep, queue_t *q, 1417*3859Sml29623 mblk_t *mp, caddr_t cp) 1418*3859Sml29623 { 1419*3859Sml29623 uint_t print_len, buf_len; 1420*3859Sml29623 p_mblk_t np; 1421*3859Sml29623 int i; 1422*3859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp; 1423*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 1424*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 1425*3859Sml29623 nxge_mv_cfg_t *mac_host_info; 1426*3859Sml29623 1427*3859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE * 32; 1428*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_mac_rdcgrp ")); 1429*3859Sml29623 (void) mi_mpprintf(mp, 1430*3859Sml29623 "MAC ADDR RDC Mapping Information for Port\t %d\n", 1431*3859Sml29623 nxgep->function_num); 1432*3859Sml29623 1433*3859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) { 1434*3859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer"); 1435*3859Sml29623 return (0); 1436*3859Sml29623 } 1437*3859Sml29623 1438*3859Sml29623 buf_len = buff_alloc_size; 1439*3859Sml29623 mp->b_cont = np; 1440*3859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; 1441*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 1442*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 1443*3859Sml29623 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0]; 1444*3859Sml29623 print_len = snprintf((char *)np->b_wptr, buf_len, 1445*3859Sml29623 "MAC ID\t RDC GRP (Actual/Port)\t" 1446*3859Sml29623 " Prefernce\n"); 1447*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 1448*3859Sml29623 buf_len -= print_len; 1449*3859Sml29623 for (i = 0; i < p_cfgp->max_macs; i++) { 1450*3859Sml29623 if (mac_host_info[i].flag) { 1451*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, 1452*3859Sml29623 buf_len, 1453*3859Sml29623 " %d\t %d/%d\t\t %d\n", 1454*3859Sml29623 i, mac_host_info[i].rdctbl, 1455*3859Sml29623 mac_host_info[i].rdctbl - 1456*3859Sml29623 p_cfgp->start_rdc_grpid, 1457*3859Sml29623 mac_host_info[i].mpr_npr); 1458*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 1459*3859Sml29623 buf_len -= print_len; 1460*3859Sml29623 } 1461*3859Sml29623 } 1462*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 1463*3859Sml29623 "Done Info Dumping \n"); 1464*3859Sml29623 ((mblk_t *)np)->b_wptr += print_len; 1465*3859Sml29623 buf_len -= print_len; 1466*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_macrdcgrp")); 1467*3859Sml29623 return (0); 1468*3859Sml29623 } 1469*3859Sml29623 1470*3859Sml29623 /* ARGSUSED */ 1471*3859Sml29623 static int 1472*3859Sml29623 nxge_param_tcam_enable(p_nxge_t nxgep, queue_t *q, 1473*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1474*3859Sml29623 { 1475*3859Sml29623 uint32_t status = 0, cfg_value; 1476*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1477*3859Sml29623 uint32_t cfg_it = B_FALSE; 1478*3859Sml29623 char *end; 1479*3859Sml29623 1480*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_tcam_enable")); 1481*3859Sml29623 1482*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY); 1483*3859Sml29623 if (pa->value != cfg_value) { 1484*3859Sml29623 pa->old_value = pa->value; 1485*3859Sml29623 pa->value = cfg_value; 1486*3859Sml29623 cfg_it = B_TRUE; 1487*3859Sml29623 } 1488*3859Sml29623 1489*3859Sml29623 if (cfg_it == B_TRUE) { 1490*3859Sml29623 if (pa->value) 1491*3859Sml29623 status = nxge_fflp_config_tcam_enable(nxgep); 1492*3859Sml29623 else 1493*3859Sml29623 status = nxge_fflp_config_tcam_disable(nxgep); 1494*3859Sml29623 if (status != NXGE_OK) 1495*3859Sml29623 return (EINVAL); 1496*3859Sml29623 } 1497*3859Sml29623 1498*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_tcam_enable")); 1499*3859Sml29623 return (0); 1500*3859Sml29623 } 1501*3859Sml29623 1502*3859Sml29623 /* ARGSUSED */ 1503*3859Sml29623 static int 1504*3859Sml29623 nxge_param_hash_lookup_enable(p_nxge_t nxgep, queue_t *q, 1505*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1506*3859Sml29623 { 1507*3859Sml29623 uint32_t status = 0, cfg_value; 1508*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1509*3859Sml29623 uint32_t cfg_it = B_FALSE; 1510*3859Sml29623 char *end; 1511*3859Sml29623 1512*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_hash_lookup_enable")); 1513*3859Sml29623 1514*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY); 1515*3859Sml29623 if (pa->value != cfg_value) { 1516*3859Sml29623 pa->old_value = pa->value; 1517*3859Sml29623 pa->value = cfg_value; 1518*3859Sml29623 cfg_it = B_TRUE; 1519*3859Sml29623 } 1520*3859Sml29623 1521*3859Sml29623 if (cfg_it == B_TRUE) { 1522*3859Sml29623 if (pa->value) 1523*3859Sml29623 status = nxge_fflp_config_hash_lookup_enable(nxgep); 1524*3859Sml29623 else 1525*3859Sml29623 status = nxge_fflp_config_hash_lookup_disable(nxgep); 1526*3859Sml29623 if (status != NXGE_OK) 1527*3859Sml29623 return (EINVAL); 1528*3859Sml29623 } 1529*3859Sml29623 1530*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_hash_lookup_enable")); 1531*3859Sml29623 return (0); 1532*3859Sml29623 } 1533*3859Sml29623 1534*3859Sml29623 /* ARGSUSED */ 1535*3859Sml29623 static int 1536*3859Sml29623 nxge_param_llc_snap_enable(p_nxge_t nxgep, queue_t *q, 1537*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1538*3859Sml29623 { 1539*3859Sml29623 char *end; 1540*3859Sml29623 uint32_t status = 0, cfg_value; 1541*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1542*3859Sml29623 uint32_t cfg_it = B_FALSE; 1543*3859Sml29623 1544*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_llc_snap_enable")); 1545*3859Sml29623 1546*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY); 1547*3859Sml29623 if (pa->value != cfg_value) { 1548*3859Sml29623 pa->old_value = pa->value; 1549*3859Sml29623 pa->value = cfg_value; 1550*3859Sml29623 cfg_it = B_TRUE; 1551*3859Sml29623 } 1552*3859Sml29623 1553*3859Sml29623 if (cfg_it == B_TRUE) { 1554*3859Sml29623 if (pa->value) 1555*3859Sml29623 status = nxge_fflp_config_tcam_enable(nxgep); 1556*3859Sml29623 else 1557*3859Sml29623 status = nxge_fflp_config_tcam_disable(nxgep); 1558*3859Sml29623 if (status != NXGE_OK) 1559*3859Sml29623 return (EINVAL); 1560*3859Sml29623 } 1561*3859Sml29623 1562*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_llc_snap_enable")); 1563*3859Sml29623 return (0); 1564*3859Sml29623 } 1565*3859Sml29623 1566*3859Sml29623 /* ARGSUSED */ 1567*3859Sml29623 static int 1568*3859Sml29623 nxge_param_set_ether_usr(p_nxge_t nxgep, queue_t *q, 1569*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1570*3859Sml29623 { 1571*3859Sml29623 char *end; 1572*3859Sml29623 uint8_t ether_class; 1573*3859Sml29623 uint32_t status = 0, cfg_value; 1574*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1575*3859Sml29623 uint8_t cfg_it = B_FALSE; 1576*3859Sml29623 1577*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ether_usr")); 1578*3859Sml29623 1579*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX); 1580*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) { 1581*3859Sml29623 return (EINVAL); 1582*3859Sml29623 } 1583*3859Sml29623 1584*3859Sml29623 if (pa->value != cfg_value) { 1585*3859Sml29623 pa->old_value = pa->value; 1586*3859Sml29623 pa->value = cfg_value; 1587*3859Sml29623 cfg_it = B_TRUE; 1588*3859Sml29623 } 1589*3859Sml29623 1590*3859Sml29623 /* do the actual hw setup */ 1591*3859Sml29623 if (cfg_it == B_TRUE) { 1592*3859Sml29623 ether_class = mi_strtol(pa->name, &end, 10); 1593*3859Sml29623 #ifdef lint 1594*3859Sml29623 ether_class = ether_class; 1595*3859Sml29623 #endif 1596*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " nxge_param_set_ether_usr")); 1597*3859Sml29623 } 1598*3859Sml29623 1599*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ether_usr")); 1600*3859Sml29623 return (status); 1601*3859Sml29623 } 1602*3859Sml29623 1603*3859Sml29623 /* ARGSUSED */ 1604*3859Sml29623 static int 1605*3859Sml29623 nxge_param_set_ip_usr(p_nxge_t nxgep, queue_t *q, 1606*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1607*3859Sml29623 { 1608*3859Sml29623 char *end; 1609*3859Sml29623 tcam_class_t class; 1610*3859Sml29623 uint32_t status, cfg_value; 1611*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1612*3859Sml29623 uint32_t cfg_it = B_FALSE; 1613*3859Sml29623 1614*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ip_usr")); 1615*3859Sml29623 1616*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX); 1617*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) { 1618*3859Sml29623 return (EINVAL); 1619*3859Sml29623 } 1620*3859Sml29623 1621*3859Sml29623 if (pa->value != cfg_value) { 1622*3859Sml29623 pa->old_value = pa->value; 1623*3859Sml29623 pa->value = cfg_value; 1624*3859Sml29623 cfg_it = B_TRUE; 1625*3859Sml29623 } 1626*3859Sml29623 1627*3859Sml29623 /* do the actual hw setup with cfg_value. */ 1628*3859Sml29623 if (cfg_it == B_TRUE) { 1629*3859Sml29623 class = mi_strtol(pa->name, &end, 10); 1630*3859Sml29623 status = nxge_fflp_ip_usr_class_config(nxgep, class, pa->value); 1631*3859Sml29623 } 1632*3859Sml29623 1633*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ip_usr")); 1634*3859Sml29623 return (status); 1635*3859Sml29623 } 1636*3859Sml29623 1637*3859Sml29623 /* ARGSUSED */ 1638*3859Sml29623 static int 1639*3859Sml29623 nxge_class_name_2value(p_nxge_t nxgep, char *name) 1640*3859Sml29623 { 1641*3859Sml29623 int i; 1642*3859Sml29623 int class_instance = param_class_opt_ip_usr4; 1643*3859Sml29623 p_nxge_param_t param_arr; 1644*3859Sml29623 1645*3859Sml29623 param_arr = nxgep->param_arr; 1646*3859Sml29623 for (i = TCAM_CLASS_IP_USER_4; i <= TCAM_CLASS_SCTP_IPV6; i++) { 1647*3859Sml29623 if (strcmp(param_arr[class_instance].name, name) == 0) 1648*3859Sml29623 return (i); 1649*3859Sml29623 class_instance++; 1650*3859Sml29623 } 1651*3859Sml29623 return (-1); 1652*3859Sml29623 } 1653*3859Sml29623 1654*3859Sml29623 /* ARGSUSED */ 1655*3859Sml29623 static int 1656*3859Sml29623 nxge_param_set_ip_opt(p_nxge_t nxgep, queue_t *q, 1657*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1658*3859Sml29623 { 1659*3859Sml29623 char *end; 1660*3859Sml29623 uint32_t status, cfg_value; 1661*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1662*3859Sml29623 tcam_class_t class; 1663*3859Sml29623 uint32_t cfg_it = B_FALSE; 1664*3859Sml29623 1665*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ip_opt")); 1666*3859Sml29623 1667*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX); 1668*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) { 1669*3859Sml29623 return (EINVAL); 1670*3859Sml29623 } 1671*3859Sml29623 1672*3859Sml29623 if (pa->value != cfg_value) { 1673*3859Sml29623 pa->old_value = pa->value; 1674*3859Sml29623 pa->value = cfg_value; 1675*3859Sml29623 cfg_it = B_TRUE; 1676*3859Sml29623 } 1677*3859Sml29623 1678*3859Sml29623 if (cfg_it == B_TRUE) { 1679*3859Sml29623 /* do the actual hw setup */ 1680*3859Sml29623 class = nxge_class_name_2value(nxgep, pa->name); 1681*3859Sml29623 if (class == -1) 1682*3859Sml29623 return (EINVAL); 1683*3859Sml29623 1684*3859Sml29623 status = nxge_fflp_ip_class_config(nxgep, class, pa->value); 1685*3859Sml29623 if (status != NXGE_OK) 1686*3859Sml29623 return (EINVAL); 1687*3859Sml29623 } 1688*3859Sml29623 1689*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ip_opt")); 1690*3859Sml29623 return (0); 1691*3859Sml29623 } 1692*3859Sml29623 1693*3859Sml29623 /* ARGSUSED */ 1694*3859Sml29623 static int 1695*3859Sml29623 nxge_param_get_ip_opt(p_nxge_t nxgep, queue_t *q, 1696*3859Sml29623 mblk_t *mp, caddr_t cp) 1697*3859Sml29623 { 1698*3859Sml29623 uint32_t status, cfg_value; 1699*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1700*3859Sml29623 tcam_class_t class; 1701*3859Sml29623 1702*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_ip_opt")); 1703*3859Sml29623 1704*3859Sml29623 /* do the actual hw setup */ 1705*3859Sml29623 class = nxge_class_name_2value(nxgep, pa->name); 1706*3859Sml29623 if (class == -1) 1707*3859Sml29623 return (EINVAL); 1708*3859Sml29623 1709*3859Sml29623 cfg_value = 0; 1710*3859Sml29623 status = nxge_fflp_ip_class_config_get(nxgep, class, &cfg_value); 1711*3859Sml29623 if (status != NXGE_OK) 1712*3859Sml29623 return (EINVAL); 1713*3859Sml29623 1714*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1715*3859Sml29623 "nxge_param_get_ip_opt_get %x ", cfg_value)); 1716*3859Sml29623 1717*3859Sml29623 pa->value = cfg_value; 1718*3859Sml29623 (void) mi_mpprintf(mp, "%x", cfg_value); 1719*3859Sml29623 1720*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_ip_opt status ")); 1721*3859Sml29623 return (0); 1722*3859Sml29623 } 1723*3859Sml29623 1724*3859Sml29623 /* ARGSUSED */ 1725*3859Sml29623 static int 1726*3859Sml29623 nxge_param_fflp_hash_init(p_nxge_t nxgep, queue_t *q, 1727*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1728*3859Sml29623 { 1729*3859Sml29623 char *end; 1730*3859Sml29623 uint32_t status, cfg_value; 1731*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1732*3859Sml29623 tcam_class_t class; 1733*3859Sml29623 uint32_t cfg_it = B_FALSE; 1734*3859Sml29623 1735*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_fflp_hash_init")); 1736*3859Sml29623 1737*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX); 1738*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) { 1739*3859Sml29623 return (EINVAL); 1740*3859Sml29623 } 1741*3859Sml29623 1742*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1743*3859Sml29623 "nxge_param_fflp_hash_init value %x", cfg_value)); 1744*3859Sml29623 1745*3859Sml29623 if (pa->value != cfg_value) { 1746*3859Sml29623 pa->old_value = pa->value; 1747*3859Sml29623 pa->value = cfg_value; 1748*3859Sml29623 cfg_it = B_TRUE; 1749*3859Sml29623 } 1750*3859Sml29623 1751*3859Sml29623 if (cfg_it == B_TRUE) { 1752*3859Sml29623 char *h_name; 1753*3859Sml29623 1754*3859Sml29623 /* do the actual hw setup */ 1755*3859Sml29623 h_name = pa->name; 1756*3859Sml29623 h_name++; 1757*3859Sml29623 class = mi_strtol(h_name, &end, 10); 1758*3859Sml29623 switch (class) { 1759*3859Sml29623 case 1: 1760*3859Sml29623 status = nxge_fflp_set_hash1(nxgep, 1761*3859Sml29623 (uint32_t)pa->value); 1762*3859Sml29623 break; 1763*3859Sml29623 case 2: 1764*3859Sml29623 status = nxge_fflp_set_hash2(nxgep, 1765*3859Sml29623 (uint16_t)pa->value); 1766*3859Sml29623 break; 1767*3859Sml29623 1768*3859Sml29623 default: 1769*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1770*3859Sml29623 " nxge_param_fflp_hash_init" 1771*3859Sml29623 " %s Wrong hash var %d", 1772*3859Sml29623 pa->name, class)); 1773*3859Sml29623 return (EINVAL); 1774*3859Sml29623 } 1775*3859Sml29623 if (status != NXGE_OK) 1776*3859Sml29623 return (EINVAL); 1777*3859Sml29623 } 1778*3859Sml29623 1779*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_fflp_hash_init")); 1780*3859Sml29623 return (0); 1781*3859Sml29623 } 1782*3859Sml29623 1783*3859Sml29623 /* ARGSUSED */ 1784*3859Sml29623 static int 1785*3859Sml29623 nxge_param_set_grp_rdc(p_nxge_t nxgep, queue_t *q, 1786*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1787*3859Sml29623 { 1788*3859Sml29623 char *end; 1789*3859Sml29623 uint32_t status = 0, cfg_value; 1790*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1791*3859Sml29623 uint32_t cfg_it = B_FALSE; 1792*3859Sml29623 int rdc_grp; 1793*3859Sml29623 uint8_t real_rdc; 1794*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 1795*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 1796*3859Sml29623 p_nxge_rdc_grp_t rdc_grp_p; 1797*3859Sml29623 1798*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 1799*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 1800*3859Sml29623 1801*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_grp_rdc")); 1802*3859Sml29623 1803*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY); 1804*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) { 1805*3859Sml29623 return (EINVAL); 1806*3859Sml29623 } 1807*3859Sml29623 1808*3859Sml29623 if (cfg_value >= p_cfgp->max_rdcs) { 1809*3859Sml29623 return (EINVAL); 1810*3859Sml29623 } 1811*3859Sml29623 1812*3859Sml29623 if (pa->value != cfg_value) { 1813*3859Sml29623 pa->old_value = pa->value; 1814*3859Sml29623 pa->value = cfg_value; 1815*3859Sml29623 cfg_it = B_TRUE; 1816*3859Sml29623 } 1817*3859Sml29623 1818*3859Sml29623 if (cfg_it == B_TRUE) { 1819*3859Sml29623 char *grp_name; 1820*3859Sml29623 grp_name = pa->name; 1821*3859Sml29623 grp_name += strlen("default-grp"); 1822*3859Sml29623 rdc_grp = mi_strtol(grp_name, &end, 10); 1823*3859Sml29623 rdc_grp_p = &p_dma_cfgp->rdc_grps[rdc_grp]; 1824*3859Sml29623 real_rdc = rdc_grp_p->start_rdc + cfg_value; 1825*3859Sml29623 if (nxge_check_rxdma_rdcgrp_member(nxgep, rdc_grp, 1826*3859Sml29623 cfg_value) == B_FALSE) { 1827*3859Sml29623 pa->value = pa->old_value; 1828*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1829*3859Sml29623 " nxge_param_set_grp_rdc" 1830*3859Sml29623 " %d read %d actual %d outof range", 1831*3859Sml29623 rdc_grp, cfg_value, real_rdc)); 1832*3859Sml29623 return (EINVAL); 1833*3859Sml29623 } 1834*3859Sml29623 status = nxge_rxdma_cfg_rdcgrp_default_rdc(nxgep, rdc_grp, 1835*3859Sml29623 real_rdc); 1836*3859Sml29623 if (status != NXGE_OK) 1837*3859Sml29623 return (EINVAL); 1838*3859Sml29623 } 1839*3859Sml29623 1840*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_grp_rdc")); 1841*3859Sml29623 return (0); 1842*3859Sml29623 } 1843*3859Sml29623 1844*3859Sml29623 /* ARGSUSED */ 1845*3859Sml29623 static int 1846*3859Sml29623 nxge_param_set_port_rdc(p_nxge_t nxgep, queue_t *q, 1847*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1848*3859Sml29623 { 1849*3859Sml29623 char *end; 1850*3859Sml29623 uint32_t status = B_TRUE, cfg_value; 1851*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1852*3859Sml29623 uint32_t cfg_it = B_FALSE; 1853*3859Sml29623 1854*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 1855*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 1856*3859Sml29623 1857*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_port_rdc")); 1858*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 1859*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 1860*3859Sml29623 1861*3859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY); 1862*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) { 1863*3859Sml29623 return (EINVAL); 1864*3859Sml29623 } 1865*3859Sml29623 1866*3859Sml29623 if (pa->value != cfg_value) { 1867*3859Sml29623 if (cfg_value >= p_cfgp->max_rdcs) 1868*3859Sml29623 return (EINVAL); 1869*3859Sml29623 pa->old_value = pa->value; 1870*3859Sml29623 pa->value = cfg_value; 1871*3859Sml29623 cfg_it = B_TRUE; 1872*3859Sml29623 } 1873*3859Sml29623 1874*3859Sml29623 if (cfg_it == B_TRUE) { 1875*3859Sml29623 status = nxge_rxdma_cfg_port_default_rdc(nxgep, 1876*3859Sml29623 nxgep->function_num, 1877*3859Sml29623 nxgep->rdc[cfg_value]); 1878*3859Sml29623 if (status != NXGE_OK) 1879*3859Sml29623 return (EINVAL); 1880*3859Sml29623 } 1881*3859Sml29623 1882*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_port_rdc")); 1883*3859Sml29623 return (0); 1884*3859Sml29623 } 1885*3859Sml29623 1886*3859Sml29623 /* ARGSUSED */ 1887*3859Sml29623 static int 1888*3859Sml29623 nxge_param_set_nxge_debug_flag(p_nxge_t nxgep, queue_t *q, 1889*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1890*3859Sml29623 { 1891*3859Sml29623 char *end; 1892*3859Sml29623 uint32_t status = 0; 1893*3859Sml29623 uint64_t cfg_value = 0; 1894*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1895*3859Sml29623 uint32_t cfg_it = B_FALSE; 1896*3859Sml29623 1897*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_nxge_debug_flag")); 1898*3859Sml29623 cfg_value = mi_strtol(value, &end, BASE_HEX); 1899*3859Sml29623 1900*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) { 1901*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, 1902*3859Sml29623 " nxge_param_set_nxge_debug_flag" 1903*3859Sml29623 " outof range %llx", cfg_value)); 1904*3859Sml29623 return (EINVAL); 1905*3859Sml29623 } 1906*3859Sml29623 if (pa->value != cfg_value) { 1907*3859Sml29623 pa->old_value = pa->value; 1908*3859Sml29623 pa->value = cfg_value; 1909*3859Sml29623 cfg_it = B_TRUE; 1910*3859Sml29623 } 1911*3859Sml29623 1912*3859Sml29623 if (cfg_it == B_TRUE) { 1913*3859Sml29623 nxgep->nxge_debug_level = pa->value; 1914*3859Sml29623 } 1915*3859Sml29623 1916*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_nxge_debug_flag")); 1917*3859Sml29623 return (status); 1918*3859Sml29623 } 1919*3859Sml29623 1920*3859Sml29623 /* ARGSUSED */ 1921*3859Sml29623 static int 1922*3859Sml29623 nxge_param_get_debug_flag(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 1923*3859Sml29623 { 1924*3859Sml29623 int status = 0; 1925*3859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp; 1926*3859Sml29623 1927*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_debug_flag")); 1928*3859Sml29623 1929*3859Sml29623 if (pa->value > 0xffffffff) 1930*3859Sml29623 (void) mi_mpprintf(mp, "%x%x", (int)(pa->value >> 32), 1931*3859Sml29623 (int)(pa->value & 0xffffffff)); 1932*3859Sml29623 else 1933*3859Sml29623 (void) mi_mpprintf(mp, "%x", (int)pa->value); 1934*3859Sml29623 1935*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_debug_flag")); 1936*3859Sml29623 return (status); 1937*3859Sml29623 } 1938*3859Sml29623 1939*3859Sml29623 /* ARGSUSED */ 1940*3859Sml29623 static int 1941*3859Sml29623 nxge_param_set_npi_debug_flag(p_nxge_t nxgep, queue_t *q, 1942*3859Sml29623 mblk_t *mp, char *value, caddr_t cp) 1943*3859Sml29623 { 1944*3859Sml29623 char *end; 1945*3859Sml29623 uint32_t status = 0; 1946*3859Sml29623 uint64_t cfg_value = 0; 1947*3859Sml29623 p_nxge_param_t pa; 1948*3859Sml29623 uint32_t cfg_it = B_FALSE; 1949*3859Sml29623 1950*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_npi_debug_flag")); 1951*3859Sml29623 cfg_value = mi_strtol(value, &end, BASE_HEX); 1952*3859Sml29623 pa = (p_nxge_param_t)cp; 1953*3859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) { 1954*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " nxge_param_set_npi_debug_flag" 1955*3859Sml29623 " outof range %llx", cfg_value)); 1956*3859Sml29623 return (EINVAL); 1957*3859Sml29623 } 1958*3859Sml29623 if (pa->value != cfg_value) { 1959*3859Sml29623 pa->old_value = pa->value; 1960*3859Sml29623 pa->value = cfg_value; 1961*3859Sml29623 cfg_it = B_TRUE; 1962*3859Sml29623 } 1963*3859Sml29623 1964*3859Sml29623 if (cfg_it == B_TRUE) { 1965*3859Sml29623 npi_debug_level = pa->value; 1966*3859Sml29623 } 1967*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_debug_flag")); 1968*3859Sml29623 return (status); 1969*3859Sml29623 } 1970*3859Sml29623 1971*3859Sml29623 /* ARGSUSED */ 1972*3859Sml29623 static int 1973*3859Sml29623 nxge_param_dump_rdc(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 1974*3859Sml29623 { 1975*3859Sml29623 uint_t rdc; 1976*3859Sml29623 1977*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_rdc")); 1978*3859Sml29623 1979*3859Sml29623 (void) npi_rxdma_dump_fzc_regs(NXGE_DEV_NPI_HANDLE(nxgep)); 1980*3859Sml29623 for (rdc = 0; rdc < nxgep->nrdc; rdc++) 1981*3859Sml29623 (void) nxge_dump_rxdma_channel(nxgep, nxgep->rdc[rdc]); 1982*3859Sml29623 1983*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_rdc")); 1984*3859Sml29623 return (0); 1985*3859Sml29623 } 1986*3859Sml29623 1987*3859Sml29623 /* ARGSUSED */ 1988*3859Sml29623 static int 1989*3859Sml29623 nxge_param_dump_tdc(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 1990*3859Sml29623 { 1991*3859Sml29623 uint_t tdc; 1992*3859Sml29623 1993*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_tdc")); 1994*3859Sml29623 1995*3859Sml29623 for (tdc = 0; tdc < nxgep->ntdc; tdc++) 1996*3859Sml29623 (void) nxge_txdma_regs_dump(nxgep, nxgep->tdc[tdc]); 1997*3859Sml29623 1998*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_tdc")); 1999*3859Sml29623 return (0); 2000*3859Sml29623 } 2001*3859Sml29623 2002*3859Sml29623 /* ARGSUSED */ 2003*3859Sml29623 static int 2004*3859Sml29623 nxge_param_dump_fflp_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 2005*3859Sml29623 { 2006*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_fflp_regs")); 2007*3859Sml29623 2008*3859Sml29623 (void) npi_fflp_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep)); 2009*3859Sml29623 2010*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_fflp_regs")); 2011*3859Sml29623 return (0); 2012*3859Sml29623 } 2013*3859Sml29623 2014*3859Sml29623 /* ARGSUSED */ 2015*3859Sml29623 static int 2016*3859Sml29623 nxge_param_dump_mac_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 2017*3859Sml29623 { 2018*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_mac_regs")); 2019*3859Sml29623 2020*3859Sml29623 (void) npi_mac_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep), 2021*3859Sml29623 nxgep->function_num); 2022*3859Sml29623 2023*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_mac_regs")); 2024*3859Sml29623 return (0); 2025*3859Sml29623 } 2026*3859Sml29623 2027*3859Sml29623 /* ARGSUSED */ 2028*3859Sml29623 static int 2029*3859Sml29623 nxge_param_dump_ipp_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 2030*3859Sml29623 { 2031*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_ipp_regs")); 2032*3859Sml29623 2033*3859Sml29623 (void) npi_ipp_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep), 2034*3859Sml29623 nxgep->function_num); 2035*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_ipp_regs")); 2036*3859Sml29623 return (0); 2037*3859Sml29623 } 2038*3859Sml29623 2039*3859Sml29623 /* ARGSUSED */ 2040*3859Sml29623 static int 2041*3859Sml29623 nxge_param_dump_vlan_table(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 2042*3859Sml29623 { 2043*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_dump_vlan_table")); 2044*3859Sml29623 2045*3859Sml29623 (void) npi_fflp_vlan_tbl_dump(NXGE_DEV_NPI_HANDLE(nxgep)); 2046*3859Sml29623 2047*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_dump_vlan_table")); 2048*3859Sml29623 return (0); 2049*3859Sml29623 } 2050*3859Sml29623 2051*3859Sml29623 /* ARGSUSED */ 2052*3859Sml29623 static int 2053*3859Sml29623 nxge_param_dump_rdc_table(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 2054*3859Sml29623 { 2055*3859Sml29623 uint8_t table; 2056*3859Sml29623 2057*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_dump_rdc_table")); 2058*3859Sml29623 for (table = 0; table < NXGE_MAX_RDC_GROUPS; table++) { 2059*3859Sml29623 (void) npi_rxdma_dump_rdc_table(NXGE_DEV_NPI_HANDLE(nxgep), 2060*3859Sml29623 table); 2061*3859Sml29623 } 2062*3859Sml29623 2063*3859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_dump_rdc_table")); 2064*3859Sml29623 return (0); 2065*3859Sml29623 } 2066*3859Sml29623 2067*3859Sml29623 typedef struct block_info { 2068*3859Sml29623 char *name; 2069*3859Sml29623 uint32_t offset; 2070*3859Sml29623 } block_info_t; 2071*3859Sml29623 2072*3859Sml29623 block_info_t reg_block[] = { 2073*3859Sml29623 {"PIO", PIO}, 2074*3859Sml29623 {"FZC_PIO", FZC_PIO}, 2075*3859Sml29623 {"FZC_XMAC", FZC_MAC}, 2076*3859Sml29623 {"FZC_IPP", FZC_IPP}, 2077*3859Sml29623 {"FFLP", FFLP}, 2078*3859Sml29623 {"FZC_FFLP", FZC_FFLP}, 2079*3859Sml29623 {"PIO_VADDR", PIO_VADDR}, 2080*3859Sml29623 {"ZCP", ZCP}, 2081*3859Sml29623 {"FZC_ZCP", FZC_ZCP}, 2082*3859Sml29623 {"DMC", DMC}, 2083*3859Sml29623 {"FZC_DMC", FZC_DMC}, 2084*3859Sml29623 {"TXC", TXC}, 2085*3859Sml29623 {"FZC_TXC", FZC_TXC}, 2086*3859Sml29623 {"PIO_LDSV", PIO_LDSV}, 2087*3859Sml29623 {"PIO_LDGIM", PIO_LDGIM}, 2088*3859Sml29623 {"PIO_IMASK0", PIO_IMASK0}, 2089*3859Sml29623 {"PIO_IMASK1", PIO_IMASK1}, 2090*3859Sml29623 {"FZC_PROM", FZC_PROM}, 2091*3859Sml29623 {"END", ALL_FF_32}, 2092*3859Sml29623 }; 2093*3859Sml29623 2094*3859Sml29623 /* ARGSUSED */ 2095*3859Sml29623 static int 2096*3859Sml29623 nxge_param_dump_ptrs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp) 2097*3859Sml29623 { 2098*3859Sml29623 uint_t print_len, buf_len; 2099*3859Sml29623 p_mblk_t np; 2100*3859Sml29623 int rdc, tdc, block; 2101*3859Sml29623 uint64_t base; 2102*3859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp; 2103*3859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp; 2104*3859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_8K; 2105*3859Sml29623 p_tx_ring_t *tx_rings; 2106*3859Sml29623 p_rx_rcr_rings_t rx_rcr_rings; 2107*3859Sml29623 p_rx_rcr_ring_t *rcr_rings; 2108*3859Sml29623 p_rx_rbr_rings_t rx_rbr_rings; 2109*3859Sml29623 p_rx_rbr_ring_t *rbr_rings; 2110*3859Sml29623 2111*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 2112*3859Sml29623 "==> nxge_param_dump_ptrs")); 2113*3859Sml29623 2114*3859Sml29623 (void) mi_mpprintf(mp, "ptr information for Port\t %d \n", 2115*3859Sml29623 nxgep->function_num); 2116*3859Sml29623 2117*3859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) { 2118*3859Sml29623 /* The following may work even if we cannot get a large buf. */ 2119*3859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer"); 2120*3859Sml29623 return (0); 2121*3859Sml29623 } 2122*3859Sml29623 2123*3859Sml29623 buf_len = buff_alloc_size; 2124*3859Sml29623 mp->b_cont = np; 2125*3859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 2126*3859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 2127*3859Sml29623 2128*3859Sml29623 rx_rcr_rings = nxgep->rx_rcr_rings; 2129*3859Sml29623 rcr_rings = rx_rcr_rings->rcr_rings; 2130*3859Sml29623 rx_rbr_rings = nxgep->rx_rbr_rings; 2131*3859Sml29623 rbr_rings = rx_rbr_rings->rbr_rings; 2132*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 2133*3859Sml29623 "nxgep (nxge_t) $%p\n" 2134*3859Sml29623 "dev_regs (dev_regs_t) $%p\n", 2135*3859Sml29623 nxgep, nxgep->dev_regs); 2136*3859Sml29623 2137*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2138*3859Sml29623 2139*3859Sml29623 /* do register pointers */ 2140*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 2141*3859Sml29623 "reg base (npi_reg_ptr_t) $%p\t " 2142*3859Sml29623 "pci reg (npi_reg_ptr_t) $%p\n", 2143*3859Sml29623 nxgep->dev_regs->nxge_regp, 2144*3859Sml29623 nxgep->dev_regs->nxge_pciregp); 2145*3859Sml29623 2146*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2147*3859Sml29623 2148*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 2149*3859Sml29623 "\nBlock \t Offset \n"); 2150*3859Sml29623 2151*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2152*3859Sml29623 block = 0; 2153*3859Sml29623 base = (uint64_t)nxgep->dev_regs->nxge_regp; 2154*3859Sml29623 while (reg_block[block].offset != ALL_FF_32) { 2155*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 2156*3859Sml29623 "%9s\t 0x%llx\n", 2157*3859Sml29623 reg_block[block].name, 2158*3859Sml29623 (unsigned long long)(reg_block[block].offset + base)); 2159*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2160*3859Sml29623 block++; 2161*3859Sml29623 } 2162*3859Sml29623 2163*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 2164*3859Sml29623 "\nRDC\t rcrp (rx_rcr_ring_t)\t " 2165*3859Sml29623 "rbrp (rx_rbr_ring_t)\n"); 2166*3859Sml29623 2167*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2168*3859Sml29623 2169*3859Sml29623 for (rdc = 0; rdc < p_cfgp->max_rdcs; rdc++) { 2170*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 2171*3859Sml29623 " %d\t $%p\t\t $%p\n", 2172*3859Sml29623 rdc, rcr_rings[rdc], 2173*3859Sml29623 rbr_rings[rdc]); 2174*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2175*3859Sml29623 } 2176*3859Sml29623 2177*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 2178*3859Sml29623 "\nTDC\t tdcp (tx_ring_t)\n"); 2179*3859Sml29623 2180*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2181*3859Sml29623 tx_rings = nxgep->tx_rings->rings; 2182*3859Sml29623 for (tdc = 0; tdc < p_cfgp->max_tdcs; tdc++) { 2183*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, 2184*3859Sml29623 " %d\t $%p\n", tdc, tx_rings[tdc]); 2185*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2186*3859Sml29623 } 2187*3859Sml29623 2188*3859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, "\n\n"); 2189*3859Sml29623 2190*3859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len); 2191*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_ptrs")); 2192*3859Sml29623 return (0); 2193*3859Sml29623 } 2194*3859Sml29623 2195*3859Sml29623 /* 2196*3859Sml29623 * Load 'name' into the named dispatch table pointed to by 'ndp'. 2197*3859Sml29623 * 'ndp' should be the address of a char pointer cell. If the table 2198*3859Sml29623 * does not exist (*ndp == 0), a new table is allocated and 'ndp' 2199*3859Sml29623 * is stuffed. If there is not enough space in the table for a new 2200*3859Sml29623 * entry, more space is allocated. 2201*3859Sml29623 */ 2202*3859Sml29623 /* ARGSUSED */ 2203*3859Sml29623 boolean_t 2204*3859Sml29623 nxge_nd_load(caddr_t *pparam, char *name, 2205*3859Sml29623 pfi_t get_pfi, pfi_t set_pfi, caddr_t data) 2206*3859Sml29623 { 2207*3859Sml29623 ND *nd; 2208*3859Sml29623 NDE *nde; 2209*3859Sml29623 2210*3859Sml29623 NXGE_DEBUG_MSG((NULL, NDD2_CTL, " ==> nxge_nd_load")); 2211*3859Sml29623 if (!pparam) 2212*3859Sml29623 return (B_FALSE); 2213*3859Sml29623 2214*3859Sml29623 if ((nd = (ND *)*pparam) == NULL) { 2215*3859Sml29623 if ((nd = (ND *)KMEM_ZALLOC(sizeof (ND), KM_NOSLEEP)) == NULL) 2216*3859Sml29623 return (B_FALSE); 2217*3859Sml29623 *pparam = (caddr_t)nd; 2218*3859Sml29623 } 2219*3859Sml29623 2220*3859Sml29623 if (nd->nd_tbl) { 2221*3859Sml29623 for (nde = nd->nd_tbl; nde->nde_name; nde++) { 2222*3859Sml29623 if (strcmp(name, nde->nde_name) == 0) 2223*3859Sml29623 goto fill_it; 2224*3859Sml29623 } 2225*3859Sml29623 } 2226*3859Sml29623 2227*3859Sml29623 if (nd->nd_free_count <= 1) { 2228*3859Sml29623 if ((nde = (NDE *)KMEM_ZALLOC(nd->nd_size + 2229*3859Sml29623 NDE_ALLOC_SIZE, KM_NOSLEEP)) == NULL) 2230*3859Sml29623 return (B_FALSE); 2231*3859Sml29623 nd->nd_free_count += NDE_ALLOC_COUNT; 2232*3859Sml29623 if (nd->nd_tbl) { 2233*3859Sml29623 bcopy((char *)nd->nd_tbl, (char *)nde, nd->nd_size); 2234*3859Sml29623 KMEM_FREE((char *)nd->nd_tbl, nd->nd_size); 2235*3859Sml29623 } else { 2236*3859Sml29623 nd->nd_free_count--; 2237*3859Sml29623 nde->nde_name = "?"; 2238*3859Sml29623 nde->nde_get_pfi = nxge_nd_get_names; 2239*3859Sml29623 nde->nde_set_pfi = nxge_set_default; 2240*3859Sml29623 } 2241*3859Sml29623 nde->nde_data = (caddr_t)nd; 2242*3859Sml29623 nd->nd_tbl = nde; 2243*3859Sml29623 nd->nd_size += NDE_ALLOC_SIZE; 2244*3859Sml29623 } 2245*3859Sml29623 for (nde = nd->nd_tbl; nde->nde_name; nde++) 2246*3859Sml29623 noop; 2247*3859Sml29623 nd->nd_free_count--; 2248*3859Sml29623 fill_it: 2249*3859Sml29623 nde->nde_name = name; 2250*3859Sml29623 nde->nde_get_pfi = get_pfi; 2251*3859Sml29623 nde->nde_set_pfi = set_pfi; 2252*3859Sml29623 nde->nde_data = data; 2253*3859Sml29623 NXGE_DEBUG_MSG((NULL, NDD2_CTL, " <== nxge_nd_load")); 2254*3859Sml29623 2255*3859Sml29623 return (B_TRUE); 2256*3859Sml29623 } 2257*3859Sml29623 2258*3859Sml29623 /* 2259*3859Sml29623 * Free the table pointed to by 'pparam' 2260*3859Sml29623 */ 2261*3859Sml29623 void 2262*3859Sml29623 nxge_nd_free(caddr_t *pparam) 2263*3859Sml29623 { 2264*3859Sml29623 ND *nd; 2265*3859Sml29623 2266*3859Sml29623 if ((nd = (ND *)*pparam) != NULL) { 2267*3859Sml29623 if (nd->nd_tbl) 2268*3859Sml29623 KMEM_FREE((char *)nd->nd_tbl, nd->nd_size); 2269*3859Sml29623 KMEM_FREE((char *)nd, sizeof (ND)); 2270*3859Sml29623 *pparam = nil(caddr_t); 2271*3859Sml29623 } 2272*3859Sml29623 } 2273*3859Sml29623 2274*3859Sml29623 int 2275*3859Sml29623 nxge_nd_getset(p_nxge_t nxgep, queue_t *q, caddr_t param, p_mblk_t mp) 2276*3859Sml29623 { 2277*3859Sml29623 int err; 2278*3859Sml29623 IOCP iocp; 2279*3859Sml29623 p_mblk_t mp1, mp2; 2280*3859Sml29623 ND *nd; 2281*3859Sml29623 NDE *nde; 2282*3859Sml29623 char *valp; 2283*3859Sml29623 size_t avail; 2284*3859Sml29623 2285*3859Sml29623 if (!param) { 2286*3859Sml29623 return (B_FALSE); 2287*3859Sml29623 } 2288*3859Sml29623 2289*3859Sml29623 nd = (ND *)param; 2290*3859Sml29623 iocp = (IOCP)mp->b_rptr; 2291*3859Sml29623 if ((iocp->ioc_count == 0) || !(mp1 = mp->b_cont)) { 2292*3859Sml29623 mp->b_datap->db_type = M_IOCACK; 2293*3859Sml29623 iocp->ioc_count = 0; 2294*3859Sml29623 iocp->ioc_error = EINVAL; 2295*3859Sml29623 return (B_FALSE); 2296*3859Sml29623 } 2297*3859Sml29623 2298*3859Sml29623 /* 2299*3859Sml29623 * NOTE - logic throughout nd_xxx assumes single data block for ioctl. 2300*3859Sml29623 * However, existing code sends in some big buffers. 2301*3859Sml29623 */ 2302*3859Sml29623 avail = iocp->ioc_count; 2303*3859Sml29623 if (mp1->b_cont) { 2304*3859Sml29623 freemsg(mp1->b_cont); 2305*3859Sml29623 mp1->b_cont = NULL; 2306*3859Sml29623 } 2307*3859Sml29623 2308*3859Sml29623 mp1->b_datap->db_lim[-1] = '\0'; /* Force null termination */ 2309*3859Sml29623 for (valp = (char *)mp1->b_rptr; *valp != '\0'; valp++) { 2310*3859Sml29623 if (*valp == '-') 2311*3859Sml29623 *valp = '_'; 2312*3859Sml29623 } 2313*3859Sml29623 2314*3859Sml29623 valp = (char *)mp1->b_rptr; 2315*3859Sml29623 2316*3859Sml29623 for (nde = nd->nd_tbl; /* */; nde++) { 2317*3859Sml29623 if (!nde->nde_name) 2318*3859Sml29623 return (B_FALSE); 2319*3859Sml29623 if (strcmp(nde->nde_name, valp) == 0) 2320*3859Sml29623 break; 2321*3859Sml29623 } 2322*3859Sml29623 err = EINVAL; 2323*3859Sml29623 while (*valp++) 2324*3859Sml29623 noop; 2325*3859Sml29623 if (!*valp || valp >= (char *)mp1->b_wptr) 2326*3859Sml29623 valp = nilp(char); 2327*3859Sml29623 switch (iocp->ioc_cmd) { 2328*3859Sml29623 case ND_GET: 2329*3859Sml29623 /* 2330*3859Sml29623 * (temporary) hack: "*valp" is size of user buffer for 2331*3859Sml29623 * copyout. If result of action routine is too big, free 2332*3859Sml29623 * excess and return ioc_rval as buffer size needed. 2333*3859Sml29623 * Return as many mblocks as will fit, free the rest. For 2334*3859Sml29623 * backward compatibility, assume size of original ioctl 2335*3859Sml29623 * buffer if "*valp" bad or not given. 2336*3859Sml29623 */ 2337*3859Sml29623 if (valp) 2338*3859Sml29623 avail = mi_strtol(valp, (char **)0, 10); 2339*3859Sml29623 /* 2340*3859Sml29623 * We overwrite the name/value with the reply data 2341*3859Sml29623 */ 2342*3859Sml29623 mp2 = mp1; 2343*3859Sml29623 while (mp2) { 2344*3859Sml29623 mp2->b_wptr = mp2->b_rptr; 2345*3859Sml29623 mp2 = mp2->b_cont; 2346*3859Sml29623 } 2347*3859Sml29623 2348*3859Sml29623 err = (*nde->nde_get_pfi)(nxgep, q, mp1, nde->nde_data); 2349*3859Sml29623 2350*3859Sml29623 if (!err) { 2351*3859Sml29623 size_t size_out = 0; 2352*3859Sml29623 size_t excess; 2353*3859Sml29623 2354*3859Sml29623 iocp->ioc_rval = 0; 2355*3859Sml29623 2356*3859Sml29623 /* Tack on the null */ 2357*3859Sml29623 err = nxge_mk_mblk_tail_space(mp1, &mp2, 1); 2358*3859Sml29623 if (!err) { 2359*3859Sml29623 *mp2->b_wptr++ = '\0'; 2360*3859Sml29623 size_out = msgdsize(mp1); 2361*3859Sml29623 excess = size_out - avail; 2362*3859Sml29623 if (excess > 0) { 2363*3859Sml29623 iocp->ioc_rval = (int)size_out; 2364*3859Sml29623 size_out -= excess; 2365*3859Sml29623 (void) adjmsg(mp1, -(excess + 1)); 2366*3859Sml29623 err = nxge_mk_mblk_tail_space( 2367*3859Sml29623 mp1, &mp2, 1); 2368*3859Sml29623 if (!err) 2369*3859Sml29623 *mp2->b_wptr++ = '\0'; 2370*3859Sml29623 else 2371*3859Sml29623 size_out = 0; 2372*3859Sml29623 } 2373*3859Sml29623 } else 2374*3859Sml29623 size_out = 0; 2375*3859Sml29623 iocp->ioc_count = size_out; 2376*3859Sml29623 } 2377*3859Sml29623 break; 2378*3859Sml29623 2379*3859Sml29623 case ND_SET: 2380*3859Sml29623 if (valp) { 2381*3859Sml29623 if (nde->nde_set_pfi) { 2382*3859Sml29623 err = (*nde->nde_set_pfi)(nxgep, q, mp1, valp, 2383*3859Sml29623 nde->nde_data); 2384*3859Sml29623 iocp->ioc_count = 0; 2385*3859Sml29623 freemsg(mp1); 2386*3859Sml29623 mp->b_cont = NULL; 2387*3859Sml29623 } 2388*3859Sml29623 } 2389*3859Sml29623 break; 2390*3859Sml29623 2391*3859Sml29623 default: 2392*3859Sml29623 break; 2393*3859Sml29623 } 2394*3859Sml29623 iocp->ioc_error = err; 2395*3859Sml29623 mp->b_datap->db_type = M_IOCACK; 2396*3859Sml29623 return (B_TRUE); 2397*3859Sml29623 } 2398*3859Sml29623 2399*3859Sml29623 /* ARGSUSED */ 2400*3859Sml29623 int 2401*3859Sml29623 nxge_nd_get_names(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t param) 2402*3859Sml29623 { 2403*3859Sml29623 ND *nd; 2404*3859Sml29623 NDE *nde; 2405*3859Sml29623 char *rwtag; 2406*3859Sml29623 boolean_t get_ok, set_ok; 2407*3859Sml29623 size_t param_len; 2408*3859Sml29623 int status = 0; 2409*3859Sml29623 2410*3859Sml29623 nd = (ND *)param; 2411*3859Sml29623 if (!nd) 2412*3859Sml29623 return (ENOENT); 2413*3859Sml29623 2414*3859Sml29623 for (nde = nd->nd_tbl; nde->nde_name; nde++) { 2415*3859Sml29623 get_ok = (nde->nde_get_pfi != nxge_get_default) && 2416*3859Sml29623 (nde->nde_get_pfi != NULL); 2417*3859Sml29623 set_ok = (nde->nde_set_pfi != nxge_set_default) && 2418*3859Sml29623 (nde->nde_set_pfi != NULL); 2419*3859Sml29623 if (get_ok) { 2420*3859Sml29623 if (set_ok) 2421*3859Sml29623 rwtag = "read and write"; 2422*3859Sml29623 else 2423*3859Sml29623 rwtag = "read only"; 2424*3859Sml29623 } else if (set_ok) 2425*3859Sml29623 rwtag = "write only"; 2426*3859Sml29623 else { 2427*3859Sml29623 continue; 2428*3859Sml29623 } 2429*3859Sml29623 param_len = strlen(rwtag); 2430*3859Sml29623 param_len += strlen(nde->nde_name); 2431*3859Sml29623 param_len += 4; 2432*3859Sml29623 2433*3859Sml29623 (void) mi_mpprintf(mp, "%s (%s)", nde->nde_name, rwtag); 2434*3859Sml29623 } 2435*3859Sml29623 return (status); 2436*3859Sml29623 } 2437*3859Sml29623 2438*3859Sml29623 /* ARGSUSED */ 2439*3859Sml29623 int 2440*3859Sml29623 nxge_get_default(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t data) 2441*3859Sml29623 { 2442*3859Sml29623 return (EACCES); 2443*3859Sml29623 } 2444*3859Sml29623 2445*3859Sml29623 /* ARGSUSED */ 2446*3859Sml29623 int 2447*3859Sml29623 nxge_set_default(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, char *value, 2448*3859Sml29623 caddr_t data) 2449*3859Sml29623 { 2450*3859Sml29623 return (EACCES); 2451*3859Sml29623 } 2452*3859Sml29623 2453*3859Sml29623 void 2454*3859Sml29623 nxge_param_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, struct iocblk *iocp) 2455*3859Sml29623 { 2456*3859Sml29623 int cmd; 2457*3859Sml29623 int status = B_FALSE; 2458*3859Sml29623 2459*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_ioctl")); 2460*3859Sml29623 cmd = iocp->ioc_cmd; 2461*3859Sml29623 2462*3859Sml29623 switch (cmd) { 2463*3859Sml29623 default: 2464*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 2465*3859Sml29623 "nxge_param_ioctl: bad cmd 0x%0x", cmd)); 2466*3859Sml29623 break; 2467*3859Sml29623 2468*3859Sml29623 case ND_GET: 2469*3859Sml29623 case ND_SET: 2470*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 2471*3859Sml29623 "nxge_param_ioctl: cmd 0x%0x", cmd)); 2472*3859Sml29623 if (!nxge_nd_getset(nxgep, wq, nxgep->param_list, mp)) { 2473*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 2474*3859Sml29623 "false ret from nxge_nd_getset")); 2475*3859Sml29623 break; 2476*3859Sml29623 } 2477*3859Sml29623 status = B_TRUE; 2478*3859Sml29623 break; 2479*3859Sml29623 } 2480*3859Sml29623 2481*3859Sml29623 if (status) { 2482*3859Sml29623 qreply(wq, mp); 2483*3859Sml29623 } else { 2484*3859Sml29623 miocnak(wq, mp, 0, EINVAL); 2485*3859Sml29623 } 2486*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_ioctl")); 2487*3859Sml29623 } 2488*3859Sml29623 2489*3859Sml29623 /* ARGSUSED */ 2490*3859Sml29623 static boolean_t 2491*3859Sml29623 nxge_param_link_update(p_nxge_t nxgep) 2492*3859Sml29623 { 2493*3859Sml29623 p_nxge_param_t param_arr; 2494*3859Sml29623 nxge_param_index_t i; 2495*3859Sml29623 boolean_t update_xcvr; 2496*3859Sml29623 boolean_t update_dev; 2497*3859Sml29623 int instance; 2498*3859Sml29623 boolean_t status = B_TRUE; 2499*3859Sml29623 2500*3859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_link_update")); 2501*3859Sml29623 2502*3859Sml29623 param_arr = nxgep->param_arr; 2503*3859Sml29623 instance = nxgep->instance; 2504*3859Sml29623 update_xcvr = B_FALSE; 2505*3859Sml29623 for (i = param_anar_1000fdx; i < param_anar_asmpause; i++) { 2506*3859Sml29623 update_xcvr |= param_arr[i].value; 2507*3859Sml29623 } 2508*3859Sml29623 2509*3859Sml29623 if (update_xcvr) { 2510*3859Sml29623 update_xcvr = B_FALSE; 2511*3859Sml29623 for (i = param_autoneg; i < param_enable_ipg0; i++) { 2512*3859Sml29623 update_xcvr |= 2513*3859Sml29623 (param_arr[i].value != param_arr[i].old_value); 2514*3859Sml29623 param_arr[i].old_value = param_arr[i].value; 2515*3859Sml29623 } 2516*3859Sml29623 if (update_xcvr) { 2517*3859Sml29623 RW_ENTER_WRITER(&nxgep->filter_lock); 2518*3859Sml29623 (void) nxge_link_monitor(nxgep, LINK_MONITOR_STOP); 2519*3859Sml29623 (void) nxge_link_init(nxgep); 2520*3859Sml29623 (void) nxge_mac_init(nxgep); 2521*3859Sml29623 (void) nxge_link_monitor(nxgep, LINK_MONITOR_START); 2522*3859Sml29623 RW_EXIT(&nxgep->filter_lock); 2523*3859Sml29623 } 2524*3859Sml29623 } else { 2525*3859Sml29623 cmn_err(CE_WARN, " Last setting will leave nxge%d with " 2526*3859Sml29623 " no link capabilities.", instance); 2527*3859Sml29623 cmn_err(CE_WARN, " Restoring previous setting."); 2528*3859Sml29623 for (i = param_anar_1000fdx; i < param_anar_asmpause; i++) 2529*3859Sml29623 param_arr[i].value = param_arr[i].old_value; 2530*3859Sml29623 } 2531*3859Sml29623 2532*3859Sml29623 update_dev = B_FALSE; 2533*3859Sml29623 2534*3859Sml29623 if (update_dev) { 2535*3859Sml29623 RW_ENTER_WRITER(&nxgep->filter_lock); 2536*3859Sml29623 (void) nxge_rx_mac_disable(nxgep); 2537*3859Sml29623 (void) nxge_tx_mac_disable(nxgep); 2538*3859Sml29623 (void) nxge_tx_mac_enable(nxgep); 2539*3859Sml29623 (void) nxge_rx_mac_enable(nxgep); 2540*3859Sml29623 RW_EXIT(&nxgep->filter_lock); 2541*3859Sml29623 } 2542*3859Sml29623 2543*3859Sml29623 nxge_param_hw_update_exit: 2544*3859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, 2545*3859Sml29623 "<== nxge_param_link_update status = 0x%08x", status)); 2546*3859Sml29623 return (status); 2547*3859Sml29623 } 2548