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