13859Sml29623 /*
23859Sml29623 * CDDL HEADER START
33859Sml29623 *
43859Sml29623 * The contents of this file are subject to the terms of the
53859Sml29623 * Common Development and Distribution License (the "License").
63859Sml29623 * You may not use this file except in compliance with the License.
73859Sml29623 *
83859Sml29623 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93859Sml29623 * or http://www.opensolaris.org/os/licensing.
103859Sml29623 * See the License for the specific language governing permissions
113859Sml29623 * and limitations under the License.
123859Sml29623 *
133859Sml29623 * When distributing Covered Code, include this CDDL HEADER in each
143859Sml29623 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153859Sml29623 * If applicable, add the following below this CDDL HEADER, with the
163859Sml29623 * fields enclosed by brackets "[]" replaced with your own identifying
173859Sml29623 * information: Portions Copyright [yyyy] [name of copyright owner]
183859Sml29623 *
193859Sml29623 * CDDL HEADER END
203859Sml29623 */
213859Sml29623 /*
228661SSantwona.Behera@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
233859Sml29623 * Use is subject to license terms.
243859Sml29623 */
253859Sml29623
263859Sml29623 #include <sys/nxge/nxge_impl.h>
276495Sspeer #include <sys/nxge/nxge_hio.h>
286495Sspeer
293859Sml29623 #include <inet/common.h>
303859Sml29623 #include <inet/mi.h>
313859Sml29623 #include <inet/nd.h>
323859Sml29623
333859Sml29623 extern uint64_t npi_debug_level;
343859Sml29623
353859Sml29623 #define NXGE_PARAM_MAC_RW \
363859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_MAC | \
373859Sml29623 NXGE_PARAM_NDD_WR_OK | NXGE_PARAM_READ_PROP
383859Sml29623
393859Sml29623 #define NXGE_PARAM_MAC_DONT_SHOW \
403859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_MAC | NXGE_PARAM_DONT_SHOW
413859Sml29623
423859Sml29623 #define NXGE_PARAM_RXDMA_RW \
433859Sml29623 NXGE_PARAM_RWP | NXGE_PARAM_RXDMA | NXGE_PARAM_NDD_WR_OK | \
443859Sml29623 NXGE_PARAM_READ_PROP
453859Sml29623
463859Sml29623 #define NXGE_PARAM_RXDMA_RWC \
473859Sml29623 NXGE_PARAM_RWP | NXGE_PARAM_RXDMA | NXGE_PARAM_INIT_ONLY | \
483859Sml29623 NXGE_PARAM_READ_PROP
493859Sml29623
503859Sml29623 #define NXGE_PARAM_L2CLASS_CFG \
513859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_PROP_ARR32 | NXGE_PARAM_READ_PROP | \
523859Sml29623 NXGE_PARAM_NDD_WR_OK
533859Sml29623
543859Sml29623 #define NXGE_PARAM_CLASS_RWS \
553859Sml29623 NXGE_PARAM_RWS | NXGE_PARAM_READ_PROP
563859Sml29623
573859Sml29623 #define NXGE_PARAM_ARRAY_INIT_SIZE 0x20ULL
583859Sml29623
593859Sml29623 #define SET_RX_INTR_TIME_DISABLE 0
603859Sml29623 #define SET_RX_INTR_TIME_ENABLE 1
613859Sml29623 #define SET_RX_INTR_PKTS 2
623859Sml29623
633859Sml29623 #define BASE_ANY 0
643859Sml29623 #define BASE_BINARY 2
653859Sml29623 #define BASE_HEX 16
663859Sml29623 #define BASE_DECIMAL 10
673859Sml29623 #define ALL_FF_64 0xFFFFFFFFFFFFFFFFULL
683859Sml29623 #define ALL_FF_32 0xFFFFFFFFUL
693859Sml29623
703859Sml29623 #define NXGE_NDD_INFODUMP_BUFF_SIZE 2048 /* is 2k enough? */
713859Sml29623 #define NXGE_NDD_INFODUMP_BUFF_8K 8192
723859Sml29623 #define NXGE_NDD_INFODUMP_BUFF_16K 0x2000
733859Sml29623 #define NXGE_NDD_INFODUMP_BUFF_64K 0x8000
743859Sml29623
753859Sml29623 #define PARAM_OUTOF_RANGE(vptr, eptr, rval, pa) \
763859Sml29623 ((vptr == eptr) || (rval < pa->minimum) || (rval > pa->maximum))
773859Sml29623
783859Sml29623 #define ADVANCE_PRINT_BUFFER(pmp, plen, rlen) { \
793859Sml29623 ((mblk_t *)pmp)->b_wptr += plen; \
803859Sml29623 rlen -= plen; \
813859Sml29623 }
823859Sml29623
836512Ssowmini int nxge_param_set_mac(p_nxge_t, queue_t *,
843859Sml29623 mblk_t *, char *, caddr_t);
853859Sml29623 static int nxge_param_set_port_rdc(p_nxge_t, queue_t *,
863859Sml29623 mblk_t *, char *, caddr_t);
873859Sml29623 static int nxge_param_set_grp_rdc(p_nxge_t, queue_t *,
883859Sml29623 mblk_t *, char *, caddr_t);
893859Sml29623 static int nxge_param_set_ether_usr(p_nxge_t,
903859Sml29623 queue_t *, mblk_t *, char *, caddr_t);
913859Sml29623 static int nxge_param_set_ip_usr(p_nxge_t,
923859Sml29623 queue_t *, mblk_t *, char *, caddr_t);
933859Sml29623 static int nxge_param_set_vlan_rdcgrp(p_nxge_t,
943859Sml29623 queue_t *, mblk_t *, char *, caddr_t);
953859Sml29623 static int nxge_param_set_mac_rdcgrp(p_nxge_t,
963859Sml29623 queue_t *, mblk_t *, char *, caddr_t);
973859Sml29623 static int nxge_param_fflp_hash_init(p_nxge_t,
983859Sml29623 queue_t *, mblk_t *, char *, caddr_t);
993859Sml29623 static int nxge_param_llc_snap_enable(p_nxge_t, queue_t *,
1003859Sml29623 mblk_t *, char *, caddr_t);
1013859Sml29623 static int nxge_param_hash_lookup_enable(p_nxge_t, queue_t *,
1023859Sml29623 mblk_t *, char *, caddr_t);
1033859Sml29623 static int nxge_param_tcam_enable(p_nxge_t, queue_t *,
1043859Sml29623 mblk_t *, char *, caddr_t);
1054185Sspeer static int nxge_param_get_fw_ver(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1064977Sraghus static int nxge_param_get_port_mode(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1073859Sml29623 static int nxge_param_get_rxdma_info(p_nxge_t, queue_t *q,
1083859Sml29623 p_mblk_t, caddr_t);
1093859Sml29623 static int nxge_param_get_txdma_info(p_nxge_t, queue_t *q,
1103859Sml29623 p_mblk_t, caddr_t);
1113859Sml29623 static int nxge_param_get_vlan_rdcgrp(p_nxge_t, queue_t *,
1123859Sml29623 p_mblk_t, caddr_t);
1133859Sml29623 static int nxge_param_get_mac_rdcgrp(p_nxge_t, queue_t *,
1143859Sml29623 p_mblk_t, caddr_t);
1153859Sml29623 static int nxge_param_get_rxdma_rdcgrp_info(p_nxge_t, queue_t *,
1163859Sml29623 p_mblk_t, caddr_t);
117*9005SSantwona.Behera@Sun.COM static int nxge_param_get_rx_intr_time(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
118*9005SSantwona.Behera@Sun.COM static int nxge_param_get_rx_intr_pkts(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1193859Sml29623 static int nxge_param_get_ip_opt(p_nxge_t, queue_t *, mblk_t *, caddr_t);
1203859Sml29623 static int nxge_param_get_mac(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
1213859Sml29623 static int nxge_param_get_debug_flag(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1223859Sml29623 static int nxge_param_set_nxge_debug_flag(p_nxge_t, queue_t *, mblk_t *,
1233859Sml29623 char *, caddr_t);
1243859Sml29623 static int nxge_param_set_npi_debug_flag(p_nxge_t,
1253859Sml29623 queue_t *, mblk_t *, char *, caddr_t);
1263859Sml29623 static int nxge_param_dump_rdc(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
1273859Sml29623 static int nxge_param_dump_tdc(p_nxge_t, queue_t *q, p_mblk_t, caddr_t);
1283859Sml29623 static int nxge_param_dump_mac_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1293859Sml29623 static int nxge_param_dump_ipp_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1303859Sml29623 static int nxge_param_dump_fflp_regs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1313859Sml29623 static int nxge_param_dump_vlan_table(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1323859Sml29623 static int nxge_param_dump_rdc_table(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1333859Sml29623 static int nxge_param_dump_ptrs(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
1346439Sml29623 static void nxge_param_sync(p_nxge_t);
1353859Sml29623
1363859Sml29623 /*
1373859Sml29623 * Global array of Neptune changable parameters.
1383859Sml29623 * This array is initialized to correspond to the default
1393859Sml29623 * Neptune 4 port configuration. This array would be copied
1403859Sml29623 * into each port's parameter structure and modifed per
1413859Sml29623 * fcode and nxge.conf configuration. Later, the parameters are
1423859Sml29623 * exported to ndd to display and run-time configuration (at least
1433859Sml29623 * some of them).
1443859Sml29623 *
1456835Syc148097 * Parameters with DONT_SHOW are not shown by ndd.
1466835Syc148097 *
1473859Sml29623 */
1483859Sml29623
1493859Sml29623 static nxge_param_t nxge_param_arr[] = {
1503859Sml29623 /*
1513859Sml29623 * min max value old hw-name conf-name
1523859Sml29623 */
1534439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1543859Sml29623 0, 999, 1000, 0, "instance", "instance"},
1553859Sml29623
1564439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1573859Sml29623 0, 999, 1000, 0, "main-instance", "main_instance"},
1583859Sml29623
1593859Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ,
1603859Sml29623 0, 3, 0, 0, "function-number", "function_number"},
1613859Sml29623
1623859Sml29623 /* Partition Id */
1634439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1643859Sml29623 0, 8, 0, 0, "partition-id", "partition_id"},
1653859Sml29623
1663859Sml29623 /* Read Write Permission Mode */
1674439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1683859Sml29623 0, 2, 0, 0, "read-write-mode", "read_write_mode"},
1693859Sml29623
1704185Sspeer { nxge_param_get_fw_ver, NULL, NXGE_PARAM_READ,
1714185Sspeer 0, 32, 0, 0, "version", "fw_version"},
1724185Sspeer
1734977Sraghus { nxge_param_get_port_mode, NULL, NXGE_PARAM_READ,
1744977Sraghus 0, 32, 0, 0, "port-mode", "port_mode"},
1754977Sraghus
1763859Sml29623 /* hw cfg types */
1773859Sml29623 /* control the DMA config of Neptune/NIU */
1784439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1793859Sml29623 CFG_DEFAULT, CFG_CUSTOM, CFG_DEFAULT, CFG_DEFAULT,
1803859Sml29623 "niu-cfg-type", "niu_cfg_type"},
1813859Sml29623
1823859Sml29623 /* control the TXDMA config of the Port controlled by tx-quick-cfg */
1834439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1843859Sml29623 CFG_DEFAULT, CFG_CUSTOM, CFG_NOT_SPECIFIED, CFG_DEFAULT,
1853859Sml29623 "tx-qcfg-type", "tx_qcfg_type"},
1863859Sml29623
1873859Sml29623 /* control the RXDMA config of the Port controlled by rx-quick-cfg */
1884439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_DONT_SHOW,
1893859Sml29623 CFG_DEFAULT, CFG_CUSTOM, CFG_NOT_SPECIFIED, CFG_DEFAULT,
1903859Sml29623 "rx-qcfg-type", "rx_qcfg_type"},
1913859Sml29623
1923859Sml29623 { nxge_param_get_mac, nxge_param_set_mac,
1933859Sml29623 NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW,
1943859Sml29623 0, 1, 0, 0, "master-cfg-enable", "master_cfg_enable"},
1953859Sml29623
1963859Sml29623 { nxge_param_get_mac, nxge_param_set_mac,
1974439Sml29623 NXGE_PARAM_DONT_SHOW,
1983859Sml29623 0, 1, 0, 0, "master-cfg-value", "master_cfg_value"},
1993859Sml29623
2003859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2013859Sml29623 0, 1, 1, 1, "adv-autoneg-cap", "adv_autoneg_cap"},
2023859Sml29623
2033859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2043859Sml29623 0, 1, 1, 1, "adv-10gfdx-cap", "adv_10gfdx_cap"},
2053859Sml29623
2063859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2073859Sml29623 0, 1, 0, 0, "adv-10ghdx-cap", "adv_10ghdx_cap"},
2083859Sml29623
2093859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2103859Sml29623 0, 1, 1, 1, "adv-1000fdx-cap", "adv_1000fdx_cap"},
2113859Sml29623
2123859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2133859Sml29623 0, 1, 0, 0, "adv-1000hdx-cap", "adv_1000hdx_cap"},
2143859Sml29623
2153859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2163859Sml29623 0, 1, 0, 0, "adv-100T4-cap", "adv_100T4_cap"},
2173859Sml29623
2183859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2193859Sml29623 0, 1, 1, 1, "adv-100fdx-cap", "adv_100fdx_cap"},
2203859Sml29623
2213859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2223859Sml29623 0, 1, 0, 0, "adv-100hdx-cap", "adv_100hdx_cap"},
2233859Sml29623
2243859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2253859Sml29623 0, 1, 1, 1, "adv-10fdx-cap", "adv_10fdx_cap"},
2263859Sml29623
2273859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_DONT_SHOW,
2283859Sml29623 0, 1, 0, 0, "adv-10hdx-cap", "adv_10hdx_cap"},
2293859Sml29623
2304439Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2313859Sml29623 0, 1, 0, 0, "adv-asmpause-cap", "adv_asmpause_cap"},
2323859Sml29623
2333859Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_MAC_RW,
2343859Sml29623 0, 1, 0, 0, "adv-pause-cap", "adv_pause_cap"},
2353859Sml29623
2364439Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2373859Sml29623 0, 1, 0, 0, "use-int-xcvr", "use_int_xcvr"},
2383859Sml29623
2394439Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2403859Sml29623 0, 1, 1, 1, "enable-ipg0", "enable_ipg0"},
2413859Sml29623
2424439Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2433859Sml29623 0, 255, 8, 8, "ipg0", "ipg0"},
2443859Sml29623
2454439Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2463859Sml29623 0, 255, 8, 8, "ipg1", "ipg1"},
2473859Sml29623
2484439Sml29623 { nxge_param_get_mac, nxge_param_set_mac, NXGE_PARAM_DONT_SHOW,
2493859Sml29623 0, 255, 4, 4, "ipg2", "ipg2"},
2503859Sml29623
2513859Sml29623 /* Transmit DMA channels */
2524439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
2534439Sml29623 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2543859Sml29623 0, 3, 0, 0, "tx-dma-weight", "tx_dma_weight"},
2553859Sml29623
2564439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
2574439Sml29623 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2583859Sml29623 0, 31, 0, 0, "tx-dma-channels-begin", "tx_dma_channels_begin"},
2593859Sml29623
2604439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
2614439Sml29623 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2623859Sml29623 0, 32, 0, 0, "tx-dma-channels", "tx_dma_channels"},
2633859Sml29623 { nxge_param_get_txdma_info, NULL,
2644439Sml29623 NXGE_PARAM_READ | NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2653859Sml29623 0, 32, 0, 0, "tx-dma-info", "tx_dma_info"},
2663859Sml29623
2673859Sml29623 /* Receive DMA channels */
2683859Sml29623 { nxge_param_get_generic, NULL,
2694439Sml29623 NXGE_PARAM_READ | NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2703859Sml29623 0, 31, 0, 0, "rx-dma-channels-begin", "rx_dma_channels_begin"},
2713859Sml29623
2724439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
2734439Sml29623 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2743859Sml29623 0, 32, 0, 0, "rx-dma-channels", "rx_dma_channels"},
2753859Sml29623
2764439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
2774439Sml29623 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2783859Sml29623 0, 65535, PT_DRR_WT_DEFAULT_10G, 0,
2793859Sml29623 "rx-drr-weight", "rx_drr_weight"},
2803859Sml29623
2814439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ |
2824439Sml29623 NXGE_PARAM_READ_PROP | NXGE_PARAM_DONT_SHOW,
2833859Sml29623 0, 1, 1, 0, "rx-full-header", "rx_full_header"},
2843859Sml29623
2854439Sml29623 { nxge_param_get_rxdma_info, NULL, NXGE_PARAM_READ |
2864439Sml29623 NXGE_PARAM_DONT_SHOW,
2873859Sml29623 0, 32, 0, 0, "rx-dma-info", "rx_dma_info"},
2883859Sml29623
2893859Sml29623 { nxge_param_get_rxdma_info, NULL,
2903859Sml29623 NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
2913859Sml29623 NXGE_RBR_RBB_MIN, NXGE_RBR_RBB_MAX, NXGE_RBR_RBB_DEFAULT, 0,
2923859Sml29623 "rx-rbr-size", "rx_rbr_size"},
2933859Sml29623
2943859Sml29623 { nxge_param_get_rxdma_info, NULL,
2953859Sml29623 NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
2963859Sml29623 NXGE_RCR_MIN, NXGE_RCR_MAX, NXGE_RCR_DEFAULT, 0,
2973859Sml29623 "rx-rcr-size", "rx_rcr_size"},
2983859Sml29623
2994439Sml29623 { nxge_param_get_generic, nxge_param_set_port_rdc,
3004439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3013859Sml29623 0, 15, 0, 0, "default-port-rdc", "default_port_rdc"},
3023859Sml29623
303*9005SSantwona.Behera@Sun.COM { nxge_param_get_rx_intr_time, nxge_param_rx_intr_time,
304*9005SSantwona.Behera@Sun.COM NXGE_PARAM_RXDMA_RW,
3053859Sml29623 NXGE_RDC_RCR_TIMEOUT_MIN, NXGE_RDC_RCR_TIMEOUT_MAX,
3068661SSantwona.Behera@Sun.COM NXGE_RDC_RCR_TIMEOUT, 0, "rxdma-intr-time", "rxdma_intr_time"},
3073859Sml29623
308*9005SSantwona.Behera@Sun.COM { nxge_param_get_rx_intr_pkts, nxge_param_rx_intr_pkts,
309*9005SSantwona.Behera@Sun.COM NXGE_PARAM_RXDMA_RW,
3103859Sml29623 NXGE_RDC_RCR_THRESHOLD_MIN, NXGE_RDC_RCR_THRESHOLD_MAX,
3118661SSantwona.Behera@Sun.COM NXGE_RDC_RCR_THRESHOLD, 0,
3123859Sml29623 "rxdma-intr-pkts", "rxdma_intr_pkts"},
3133859Sml29623
3144439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ_PROP |
3154439Sml29623 NXGE_PARAM_DONT_SHOW,
3163859Sml29623 0, 8, 0, 0, "rx-rdc-grps-begin", "rx_rdc_grps_begin"},
3173859Sml29623
3184439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ_PROP |
3194439Sml29623 NXGE_PARAM_DONT_SHOW,
3203859Sml29623 0, 8, 0, 0, "rx-rdc-grps", "rx_rdc_grps"},
3213859Sml29623
3224439Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc,
3234439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3243859Sml29623 0, 15, 0, 0, "default-grp0-rdc", "default_grp0_rdc"},
3253859Sml29623
3264439Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc,
3274439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3283859Sml29623 0, 15, 2, 0, "default-grp1-rdc", "default_grp1_rdc"},
3293859Sml29623
3304439Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc,
3314439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3323859Sml29623 0, 15, 4, 0, "default-grp2-rdc", "default_grp2_rdc"},
3333859Sml29623
3344439Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc,
3354439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3363859Sml29623 0, 15, 6, 0, "default-grp3-rdc", "default_grp3_rdc"},
3373859Sml29623
3384439Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc,
3394439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3403859Sml29623 0, 15, 8, 0, "default-grp4-rdc", "default_grp4_rdc"},
3413859Sml29623
3424439Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc,
3434439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3443859Sml29623 0, 15, 10, 0, "default-grp5-rdc", "default_grp5_rdc"},
3453859Sml29623
3464439Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc,
3474439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3483859Sml29623 0, 15, 12, 0, "default-grp6-rdc", "default_grp6_rdc"},
3493859Sml29623
3504439Sml29623 { nxge_param_get_generic, nxge_param_set_grp_rdc,
3514439Sml29623 NXGE_PARAM_RXDMA_RW | NXGE_PARAM_DONT_SHOW,
3523859Sml29623 0, 15, 14, 0, "default-grp7-rdc", "default_grp7_rdc"},
3533859Sml29623
3543859Sml29623 { nxge_param_get_rxdma_rdcgrp_info, NULL,
3554439Sml29623 NXGE_PARAM_READ | NXGE_PARAM_CMPLX | NXGE_PARAM_DONT_SHOW,
3563859Sml29623 0, 8, 0, 0, "rdc-groups-info", "rdc_groups_info"},
3573859Sml29623
3583859Sml29623 /* Logical device groups */
3594439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
3603859Sml29623 0, 63, 0, 0, "start-ldg", "start_ldg"},
3613859Sml29623
3624439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
3633859Sml29623 0, 64, 0, 0, "max-ldg", "max_ldg" },
3643859Sml29623
3653859Sml29623 /* MAC table information */
3663859Sml29623 { nxge_param_get_mac_rdcgrp, nxge_param_set_mac_rdcgrp,
3674439Sml29623 NXGE_PARAM_L2CLASS_CFG | NXGE_PARAM_DONT_SHOW,
3683859Sml29623 0, 31, 0, 0, "mac-2rdc-grp", "mac_2rdc_grp"},
3693859Sml29623
3703859Sml29623 /* VLAN table information */
3713859Sml29623 { nxge_param_get_vlan_rdcgrp, nxge_param_set_vlan_rdcgrp,
3724439Sml29623 NXGE_PARAM_L2CLASS_CFG | NXGE_PARAM_DONT_SHOW,
3733859Sml29623 0, 31, 0, 0, "vlan-2rdc-grp", "vlan_2rdc_grp"},
3743859Sml29623
3753859Sml29623 { nxge_param_get_generic, NULL,
3764439Sml29623 NXGE_PARAM_READ_PROP | NXGE_PARAM_READ |
3774439Sml29623 NXGE_PARAM_PROP_ARR32 | NXGE_PARAM_DONT_SHOW,
3783859Sml29623 0, 0x0ffff, 0x0ffff, 0, "fcram-part-cfg", "fcram_part_cfg"},
3793859Sml29623
3804439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_CLASS_RWS |
3814439Sml29623 NXGE_PARAM_DONT_SHOW,
3823859Sml29623 0, 0x10, 0xa, 0, "fcram-access-ratio", "fcram_access_ratio"},
3833859Sml29623
3844439Sml29623 { nxge_param_get_generic, NULL, NXGE_PARAM_CLASS_RWS |
3854439Sml29623 NXGE_PARAM_DONT_SHOW,
3863859Sml29623 0, 0x10, 0xa, 0, "tcam-access-ratio", "tcam_access_ratio"},
3873859Sml29623
3883859Sml29623 { nxge_param_get_generic, nxge_param_tcam_enable,
3894439Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
3903859Sml29623 0, 0x1, 0x0, 0, "tcam-enable", "tcam_enable"},
3913859Sml29623
3923859Sml29623 { nxge_param_get_generic, nxge_param_hash_lookup_enable,
3934439Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
3943859Sml29623 0, 0x01, 0x0, 0, "hash-lookup-enable", "hash_lookup_enable"},
3953859Sml29623
3963859Sml29623 { nxge_param_get_generic, nxge_param_llc_snap_enable,
3974439Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
3983859Sml29623 0, 0x01, 0x01, 0, "llc-snap-enable", "llc_snap_enable"},
3993859Sml29623
4003859Sml29623 { nxge_param_get_generic, nxge_param_fflp_hash_init,
4014439Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4023859Sml29623 0, ALL_FF_32, ALL_FF_32, 0, "h1-init-value", "h1_init_value"},
4033859Sml29623
4043859Sml29623 { nxge_param_get_generic, nxge_param_fflp_hash_init,
4054439Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4063859Sml29623 0, 0x0ffff, 0x0ffff, 0, "h2-init-value", "h2_init_value"},
4073859Sml29623
4083859Sml29623 { nxge_param_get_generic, nxge_param_set_ether_usr,
4093859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4103859Sml29623 0, ALL_FF_32, 0x0, 0,
4113859Sml29623 "class-cfg-ether-usr1", "class_cfg_ether_usr1"},
4123859Sml29623
4133859Sml29623 { nxge_param_get_generic, nxge_param_set_ether_usr,
4143859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4153859Sml29623 0, ALL_FF_32, 0x0, 0,
4163859Sml29623 "class-cfg-ether-usr2", "class_cfg_ether_usr2"},
4173859Sml29623
4183859Sml29623 { nxge_param_get_generic, nxge_param_set_ip_usr,
4193859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4203859Sml29623 0, ALL_FF_32, 0x0, 0,
4213859Sml29623 "class-cfg-ip-usr4", "class_cfg_ip_usr4"},
4223859Sml29623
4233859Sml29623 { nxge_param_get_generic, nxge_param_set_ip_usr,
4243859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4253859Sml29623 0, ALL_FF_32, 0x0, 0,
4263859Sml29623 "class-cfg-ip-usr5", "class_cfg_ip_usr5"},
4273859Sml29623
4283859Sml29623 { nxge_param_get_generic, nxge_param_set_ip_usr,
4293859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4303859Sml29623 0, ALL_FF_32, 0x0, 0,
4313859Sml29623 "class-cfg-ip-usr6", "class_cfg_ip_usr6"},
4323859Sml29623
4333859Sml29623 { nxge_param_get_generic, nxge_param_set_ip_usr,
4343859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4353859Sml29623 0, ALL_FF_32, 0x0, 0,
4363859Sml29623 "class-cfg-ip-usr7", "class_cfg_ip_usr7"},
4373859Sml29623
4383859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4393859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4403859Sml29623 0, ALL_FF_32, 0x0, 0,
4413859Sml29623 "class-opt-ip-usr4", "class_opt_ip_usr4"},
4423859Sml29623
4433859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4443859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4453859Sml29623 0, ALL_FF_32, 0x0, 0,
4463859Sml29623 "class-opt-ip-usr5", "class_opt_ip_usr5"},
4473859Sml29623
4483859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4493859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4503859Sml29623 0, ALL_FF_32, 0x0, 0,
4513859Sml29623 "class-opt-ip-usr6", "class_opt_ip_usr6"},
4523859Sml29623
4533859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4543859Sml29623 NXGE_PARAM_CLASS_RWS | NXGE_PARAM_DONT_SHOW,
4553859Sml29623 0, ALL_FF_32, 0x0, 0,
4563859Sml29623 "class-opt-ip-usr7", "class_opt_ip_usr7"},
4573859Sml29623
4583859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4593859Sml29623 NXGE_PARAM_CLASS_RWS,
4603859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4613859Sml29623 "class-opt-ipv4-tcp", "class_opt_ipv4_tcp"},
4623859Sml29623
4633859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4643859Sml29623 NXGE_PARAM_CLASS_RWS,
4653859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4663859Sml29623 "class-opt-ipv4-udp", "class_opt_ipv4_udp"},
4673859Sml29623
4683859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4693859Sml29623 NXGE_PARAM_CLASS_RWS,
4703859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4713859Sml29623 "class-opt-ipv4-ah", "class_opt_ipv4_ah"},
4723859Sml29623
4733859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt,
4743859Sml29623 NXGE_PARAM_CLASS_RWS,
4753859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4763859Sml29623 "class-opt-ipv4-sctp", "class_opt_ipv4_sctp"},
4773859Sml29623
4783859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
4793859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4803859Sml29623 "class-opt-ipv6-tcp", "class_opt_ipv6_tcp"},
4813859Sml29623
4823859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
4833859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4843859Sml29623 "class-opt-ipv6-udp", "class_opt_ipv6_udp"},
4853859Sml29623
4863859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
4873859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4883859Sml29623 "class-opt-ipv6-ah", "class_opt_ipv6_ah"},
4893859Sml29623
4903859Sml29623 { nxge_param_get_ip_opt, nxge_param_set_ip_opt, NXGE_PARAM_CLASS_RWS,
4913859Sml29623 0, ALL_FF_32, NXGE_CLASS_FLOW_GEN_SERVER, 0,
4923859Sml29623 "class-opt-ipv6-sctp", "class_opt_ipv6_sctp"},
4933859Sml29623
4943859Sml29623 { nxge_param_get_debug_flag, nxge_param_set_nxge_debug_flag,
4954439Sml29623 NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW,
4963859Sml29623 0ULL, ALL_FF_64, 0ULL, 0ULL,
4973859Sml29623 "nxge-debug-flag", "nxge_debug_flag"},
4983859Sml29623
4993859Sml29623 { nxge_param_get_debug_flag, nxge_param_set_npi_debug_flag,
5004439Sml29623 NXGE_PARAM_RW | NXGE_PARAM_DONT_SHOW,
5013859Sml29623 0ULL, ALL_FF_64, 0ULL, 0ULL,
5023859Sml29623 "npi-debug-flag", "npi_debug_flag"},
5033859Sml29623
5044439Sml29623 { nxge_param_dump_tdc, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
5053859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-tdc", "dump_tdc"},
5063859Sml29623
5074439Sml29623 { nxge_param_dump_rdc, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
5083859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-rdc", "dump_rdc"},
5093859Sml29623
5104439Sml29623 { nxge_param_dump_mac_regs, NULL, NXGE_PARAM_READ |
5114439Sml29623 NXGE_PARAM_DONT_SHOW,
5123859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-mac-regs", "dump_mac_regs"},
5133859Sml29623
5144439Sml29623 { nxge_param_dump_ipp_regs, NULL, NXGE_PARAM_READ |
5154439Sml29623 NXGE_PARAM_DONT_SHOW,
5163859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-ipp-regs", "dump_ipp_regs"},
5173859Sml29623
5184439Sml29623 { nxge_param_dump_fflp_regs, NULL, NXGE_PARAM_READ |
5194439Sml29623 NXGE_PARAM_DONT_SHOW,
5203859Sml29623 0, 0x0fffffff, 0x0fffffff, 0,
5213859Sml29623 "dump-fflp-regs", "dump_fflp_regs"},
5223859Sml29623
5234439Sml29623 { nxge_param_dump_vlan_table, NULL, NXGE_PARAM_READ |
5244439Sml29623 NXGE_PARAM_DONT_SHOW,
5253859Sml29623 0, 0x0fffffff, 0x0fffffff, 0,
5263859Sml29623 "dump-vlan-table", "dump_vlan_table"},
5273859Sml29623
5284439Sml29623 { nxge_param_dump_rdc_table, NULL, NXGE_PARAM_READ |
5294439Sml29623 NXGE_PARAM_DONT_SHOW,
5303859Sml29623 0, 0x0fffffff, 0x0fffffff, 0,
5313859Sml29623 "dump-rdc-table", "dump_rdc_table"},
5323859Sml29623
5334439Sml29623 { nxge_param_dump_ptrs, NULL, NXGE_PARAM_READ |
5344439Sml29623 NXGE_PARAM_DONT_SHOW,
5353859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "dump-ptrs", "dump_ptrs"},
5363859Sml29623
5373859Sml29623 { NULL, NULL, NXGE_PARAM_READ | NXGE_PARAM_DONT_SHOW,
5383859Sml29623 0, 0x0fffffff, 0x0fffffff, 0, "end", "end"},
5393859Sml29623 };
5403859Sml29623
5413859Sml29623 extern void *nxge_list;
5423859Sml29623
5433859Sml29623 void
nxge_get_param_soft_properties(p_nxge_t nxgep)5443859Sml29623 nxge_get_param_soft_properties(p_nxge_t nxgep)
5453859Sml29623 {
5463859Sml29623
5473859Sml29623 p_nxge_param_t param_arr;
5483859Sml29623 uint_t prop_len;
5493859Sml29623 int i, j;
5503859Sml29623 uint32_t param_count;
5513859Sml29623 uint32_t *int_prop_val;
5523859Sml29623
5533859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, " ==> nxge_get_param_soft_properties"));
5543859Sml29623
5553859Sml29623 param_arr = nxgep->param_arr;
5563859Sml29623 param_count = nxgep->param_count;
5573859Sml29623 for (i = 0; i < param_count; i++) {
5583859Sml29623 if ((param_arr[i].type & NXGE_PARAM_READ_PROP) == 0)
5593859Sml29623 continue;
5603859Sml29623 if ((param_arr[i].type & NXGE_PARAM_PROP_STR))
5613859Sml29623 continue;
5623859Sml29623 if ((param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
5636512Ssowmini (param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
5643859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY,
5656512Ssowmini nxgep->dip, 0, param_arr[i].fcode_name,
5666512Ssowmini (int **)&int_prop_val,
5676512Ssowmini (uint_t *)&prop_len)
5686512Ssowmini == DDI_PROP_SUCCESS) {
5693859Sml29623 uint32_t *cfg_value;
5703859Sml29623 uint64_t prop_count;
5713859Sml29623
5723859Sml29623 if (prop_len > NXGE_PARAM_ARRAY_INIT_SIZE)
5733859Sml29623 prop_len = NXGE_PARAM_ARRAY_INIT_SIZE;
5745125Sjoycey #if defined(__i386)
5755125Sjoycey cfg_value =
5766512Ssowmini (uint32_t *)(int32_t)param_arr[i].value;
5775125Sjoycey #else
5783859Sml29623 cfg_value = (uint32_t *)param_arr[i].value;
5795125Sjoycey #endif
5803859Sml29623 for (j = 0; j < prop_len; j++) {
5813859Sml29623 cfg_value[j] = int_prop_val[j];
5823859Sml29623 }
5833859Sml29623 prop_count = prop_len;
5843859Sml29623 param_arr[i].type |=
5853859Sml29623 (prop_count << NXGE_PARAM_ARRAY_CNT_SHIFT);
5863859Sml29623 ddi_prop_free(int_prop_val);
5873859Sml29623 }
5883859Sml29623 continue;
5893859Sml29623 }
5903859Sml29623
5913859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
5926512Ssowmini param_arr[i].fcode_name,
5936512Ssowmini (int **)&int_prop_val,
5946512Ssowmini &prop_len) == DDI_PROP_SUCCESS) {
5953859Sml29623 if ((*int_prop_val >= param_arr[i].minimum) &&
5966512Ssowmini (*int_prop_val <= param_arr[i].maximum))
5973859Sml29623 param_arr[i].value = *int_prop_val;
5983859Sml29623 #ifdef NXGE_DEBUG_ERROR
5993859Sml29623 else {
6003859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL,
6016512Ssowmini "nxge%d: 'prom' file parameter error\n",
6026512Ssowmini nxgep->instance));
6033859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL,
6046512Ssowmini "Parameter keyword '%s'"
6056512Ssowmini " is outside valid range\n",
6066512Ssowmini param_arr[i].name));
6073859Sml29623 }
6083859Sml29623 #endif
6093859Sml29623 ddi_prop_free(int_prop_val);
6103859Sml29623 }
6113859Sml29623
6123859Sml29623 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, nxgep->dip, 0,
6136512Ssowmini param_arr[i].name,
6146512Ssowmini (int **)&int_prop_val,
6156512Ssowmini &prop_len) == DDI_PROP_SUCCESS) {
6163859Sml29623 if ((*int_prop_val >= param_arr[i].minimum) &&
6176512Ssowmini (*int_prop_val <= param_arr[i].maximum))
6183859Sml29623 param_arr[i].value = *int_prop_val;
6193859Sml29623 #ifdef NXGE_DEBUG_ERROR
6203859Sml29623 else {
6213859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL,
6226512Ssowmini "nxge%d: 'conf' file parameter error\n",
6236512Ssowmini nxgep->instance));
6243859Sml29623 NXGE_DEBUG_MSG((nxgep, OBP_CTL,
6256512Ssowmini "Parameter keyword '%s'"
6266512Ssowmini "is outside valid range\n",
6276512Ssowmini param_arr[i].name));
6283859Sml29623 }
6293859Sml29623 #endif
6303859Sml29623 ddi_prop_free(int_prop_val);
6313859Sml29623 }
6323859Sml29623 }
6333859Sml29623 }
6343859Sml29623
6353859Sml29623 static int
nxge_private_param_register(p_nxge_t nxgep,p_nxge_param_t param_arr)6363859Sml29623 nxge_private_param_register(p_nxge_t nxgep, p_nxge_param_t param_arr)
6373859Sml29623 {
6383859Sml29623 int status = B_TRUE;
6393859Sml29623 int channel;
6403859Sml29623 uint8_t grp;
6413859Sml29623 char *prop_name;
6423859Sml29623 char *end;
6433859Sml29623 uint32_t name_chars;
6443859Sml29623
6453859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
6466512Ssowmini "nxge_private_param_register %s", param_arr->name));
6473859Sml29623
6483859Sml29623 if ((param_arr->type & NXGE_PARAM_PRIV) != NXGE_PARAM_PRIV)
6493859Sml29623 return (B_TRUE);
6503859Sml29623
6513859Sml29623 prop_name = param_arr->name;
6523859Sml29623 if (param_arr->type & NXGE_PARAM_RXDMA) {
6533859Sml29623 if (strncmp("rxdma_intr", prop_name, 10) == 0)
6543859Sml29623 return (B_TRUE);
6553859Sml29623 name_chars = strlen("default_grp");
6563859Sml29623 if (strncmp("default_grp", prop_name, name_chars) == 0) {
6573859Sml29623 prop_name += name_chars;
6583859Sml29623 grp = mi_strtol(prop_name, &end, 10);
6593859Sml29623 /* now check if this rdcgrp is in config */
6603859Sml29623 return (nxge_check_rdcgrp_port_member(nxgep, grp));
6613859Sml29623 }
6623859Sml29623 name_chars = strlen(prop_name);
6633859Sml29623 if (strncmp("default_port_rdc", prop_name, name_chars) == 0) {
6643859Sml29623 return (B_TRUE);
6653859Sml29623 }
6663859Sml29623 return (B_FALSE);
6673859Sml29623 }
6683859Sml29623
6693859Sml29623 if (param_arr->type & NXGE_PARAM_TXDMA) {
6703859Sml29623 name_chars = strlen("txdma");
6713859Sml29623 if (strncmp("txdma", prop_name, name_chars) == 0) {
6723859Sml29623 prop_name += name_chars;
6733859Sml29623 channel = mi_strtol(prop_name, &end, 10);
6743859Sml29623 /* now check if this rdc is in config */
6753859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
6766512Ssowmini " nxge_private_param_register: %d",
6776512Ssowmini channel));
6783859Sml29623 return (nxge_check_txdma_port_member(nxgep, channel));
6793859Sml29623 }
6803859Sml29623 return (B_FALSE);
6813859Sml29623 }
6823859Sml29623
6833859Sml29623 status = B_FALSE;
6843859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL, "<== nxge_private_param_register"));
6853859Sml29623
6863859Sml29623 return (status);
6873859Sml29623 }
6883859Sml29623
6893859Sml29623 void
nxge_setup_param(p_nxge_t nxgep)6903859Sml29623 nxge_setup_param(p_nxge_t nxgep)
6913859Sml29623 {
6923859Sml29623 p_nxge_param_t param_arr;
6933859Sml29623 int i;
6943859Sml29623 pfi_t set_pfi;
6953859Sml29623
6963859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_setup_param"));
6973859Sml29623
6983859Sml29623 /*
6993859Sml29623 * Make sure the param_instance is set to a valid device instance.
7003859Sml29623 */
7013859Sml29623 if (nxge_param_arr[param_instance].value == 1000)
7023859Sml29623 nxge_param_arr[param_instance].value = nxgep->instance;
7033859Sml29623
7043859Sml29623 param_arr = nxgep->param_arr;
7053859Sml29623 param_arr[param_instance].value = nxgep->instance;
7063859Sml29623 param_arr[param_function_number].value = nxgep->function_num;
7073859Sml29623
7083859Sml29623 for (i = 0; i < nxgep->param_count; i++) {
7093859Sml29623 if ((param_arr[i].type & NXGE_PARAM_PRIV) &&
7106512Ssowmini (nxge_private_param_register(nxgep,
7116512Ssowmini ¶m_arr[i]) == B_FALSE)) {
7123859Sml29623 param_arr[i].setf = NULL;
7133859Sml29623 param_arr[i].getf = NULL;
7143859Sml29623 }
7153859Sml29623
7163859Sml29623 if (param_arr[i].type & NXGE_PARAM_CMPLX)
7173859Sml29623 param_arr[i].setf = NULL;
7183859Sml29623
7193859Sml29623 if (param_arr[i].type & NXGE_PARAM_DONT_SHOW) {
7203859Sml29623 param_arr[i].setf = NULL;
7213859Sml29623 param_arr[i].getf = NULL;
7223859Sml29623 }
7233859Sml29623
7243859Sml29623 set_pfi = (pfi_t)param_arr[i].setf;
7253859Sml29623
7263859Sml29623 if ((set_pfi) && (param_arr[i].type & NXGE_PARAM_INIT_ONLY)) {
7273859Sml29623 set_pfi = NULL;
7283859Sml29623 }
7293859Sml29623
7303859Sml29623 }
7313859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_setup_param"));
7323859Sml29623 }
7333859Sml29623
7343859Sml29623 void
nxge_init_param(p_nxge_t nxgep)7353859Sml29623 nxge_init_param(p_nxge_t nxgep)
7363859Sml29623 {
7373859Sml29623 p_nxge_param_t param_arr;
7383859Sml29623 int i, alloc_size;
7393859Sml29623 uint64_t alloc_count;
7403859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_init_param"));
7413859Sml29623 /*
7423859Sml29623 * Make sure the param_instance is set to a valid device instance.
7433859Sml29623 */
7443859Sml29623 if (nxge_param_arr[param_instance].value == 1000)
7453859Sml29623 nxge_param_arr[param_instance].value = nxgep->instance;
7463859Sml29623
7473859Sml29623 param_arr = nxgep->param_arr;
7483859Sml29623 if (param_arr == NULL) {
7493859Sml29623 param_arr = (p_nxge_param_t)
7506512Ssowmini KMEM_ZALLOC(sizeof (nxge_param_arr), KM_SLEEP);
7513859Sml29623 }
7523859Sml29623
7533859Sml29623 for (i = 0; i < sizeof (nxge_param_arr)/sizeof (nxge_param_t); i++) {
7543859Sml29623 param_arr[i] = nxge_param_arr[i];
7553859Sml29623 if ((param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
7566512Ssowmini (param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
7573859Sml29623 alloc_count = NXGE_PARAM_ARRAY_INIT_SIZE;
7583859Sml29623 alloc_size = alloc_count * sizeof (uint64_t);
7593859Sml29623 param_arr[i].value =
7605125Sjoycey #if defined(__i386)
7616512Ssowmini (uint64_t)(uint32_t)KMEM_ZALLOC(alloc_size,
7626512Ssowmini KM_SLEEP);
7635125Sjoycey #else
7646439Sml29623 (uint64_t)KMEM_ZALLOC(alloc_size, KM_SLEEP);
7655125Sjoycey #endif
7663859Sml29623 param_arr[i].old_value =
7675125Sjoycey #if defined(__i386)
7686512Ssowmini (uint64_t)(uint32_t)KMEM_ZALLOC(alloc_size,
7696512Ssowmini KM_SLEEP);
7705125Sjoycey #else
7716512Ssowmini (uint64_t)KMEM_ZALLOC(alloc_size, KM_SLEEP);
7725125Sjoycey #endif
7733859Sml29623 param_arr[i].type |=
7746512Ssowmini (alloc_count << NXGE_PARAM_ARRAY_ALLOC_SHIFT);
7753859Sml29623 }
7763859Sml29623 }
7773859Sml29623
7783859Sml29623 nxgep->param_arr = param_arr;
7793859Sml29623 nxgep->param_count = sizeof (nxge_param_arr)/sizeof (nxge_param_t);
7806439Sml29623
7816439Sml29623 nxge_param_sync(nxgep);
7826439Sml29623
7833859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_init_param: count %d",
7846512Ssowmini nxgep->param_count));
7853859Sml29623 }
7863859Sml29623
7873859Sml29623 void
nxge_destroy_param(p_nxge_t nxgep)7883859Sml29623 nxge_destroy_param(p_nxge_t nxgep)
7893859Sml29623 {
7903859Sml29623 int i;
7913859Sml29623 uint64_t free_size, free_count;
7923859Sml29623
7933859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_destroy_param"));
7943859Sml29623
7954732Sdavemq if (nxgep->param_arr == NULL)
7964732Sdavemq return;
7973859Sml29623 /*
7983859Sml29623 * Make sure the param_instance is set to a valid device instance.
7993859Sml29623 */
8003859Sml29623 if (nxge_param_arr[param_instance].value == nxgep->instance) {
8013859Sml29623 for (i = 0; i <= nxge_param_arr[param_instance].maximum; i++) {
8023859Sml29623 if ((ddi_get_soft_state(nxge_list, i) != NULL) &&
8036512Ssowmini (i != nxgep->instance))
8043859Sml29623 break;
8053859Sml29623 }
8063859Sml29623 nxge_param_arr[param_instance].value = i;
8073859Sml29623 }
8083859Sml29623
8093859Sml29623 for (i = 0; i < nxgep->param_count; i++)
8103859Sml29623 if ((nxgep->param_arr[i].type & NXGE_PARAM_PROP_ARR32) ||
8116512Ssowmini (nxgep->param_arr[i].type & NXGE_PARAM_PROP_ARR64)) {
8123859Sml29623 free_count = ((nxgep->param_arr[i].type &
8136512Ssowmini NXGE_PARAM_ARRAY_ALLOC_MASK) >>
8146512Ssowmini NXGE_PARAM_ARRAY_ALLOC_SHIFT);
8153859Sml29623 free_count = NXGE_PARAM_ARRAY_INIT_SIZE;
8163859Sml29623 free_size = sizeof (uint64_t) * free_count;
8175125Sjoycey #if defined(__i386)
8185125Sjoycey KMEM_FREE((void *)(uint32_t)nxgep->param_arr[i].value,
8196512Ssowmini free_size);
8205125Sjoycey #else
8213859Sml29623 KMEM_FREE((void *)nxgep->param_arr[i].value, free_size);
8225125Sjoycey #endif
8235125Sjoycey #if defined(__i386)
8245125Sjoycey KMEM_FREE((void *)(uint32_t)
8256512Ssowmini nxgep->param_arr[i].old_value, free_size);
8265125Sjoycey #else
8273859Sml29623 KMEM_FREE((void *)nxgep->param_arr[i].old_value,
8286512Ssowmini free_size);
8295125Sjoycey #endif
8303859Sml29623 }
8313859Sml29623
8323859Sml29623 KMEM_FREE(nxgep->param_arr, sizeof (nxge_param_arr));
8333859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_destroy_param"));
8343859Sml29623 }
8353859Sml29623
8363859Sml29623 /*
8373859Sml29623 * Extracts the value from the 'nxge' parameter array and prints the
8383859Sml29623 * parameter value. cp points to the required parameter.
8393859Sml29623 */
8403859Sml29623
8413859Sml29623 /* ARGSUSED */
8423859Sml29623 int
nxge_param_get_generic(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)8433859Sml29623 nxge_param_get_generic(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
8443859Sml29623 {
8453859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
8463859Sml29623
8473859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
8486512Ssowmini "==> nxge_param_get_generic name %s ", pa->name));
8493859Sml29623
8503859Sml29623 if (pa->value > 0xffffffff)
8513859Sml29623 (void) mi_mpprintf(mp, "%x%x",
8526512Ssowmini (int)(pa->value >> 32), (int)(pa->value & 0xffffffff));
8533859Sml29623 else
8543859Sml29623 (void) mi_mpprintf(mp, "%x", (int)pa->value);
8553859Sml29623
8563859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_generic"));
8573859Sml29623 return (0);
8583859Sml29623 }
8593859Sml29623
8603859Sml29623 /* ARGSUSED */
8613859Sml29623 static int
nxge_param_get_mac(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)8623859Sml29623 nxge_param_get_mac(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
8633859Sml29623 {
8643859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
8653859Sml29623
8663859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_mac"));
8673859Sml29623
8683859Sml29623 (void) mi_mpprintf(mp, "%d", (uint32_t)pa->value);
8693859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_mac"));
8703859Sml29623 return (0);
8713859Sml29623 }
8723859Sml29623
8733859Sml29623 /* ARGSUSED */
8744185Sspeer static int
nxge_param_get_fw_ver(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)8754185Sspeer nxge_param_get_fw_ver(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
8764185Sspeer {
8774185Sspeer NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_fw_ver"));
8784185Sspeer
8794185Sspeer (void) mi_mpprintf(mp, "Firmware version for nxge%d: %s\n",
8804185Sspeer nxgep->instance, nxgep->vpd_info.ver);
8814185Sspeer
8824185Sspeer NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_fw_ver"));
8834185Sspeer return (0);
8844185Sspeer }
8854185Sspeer
8864185Sspeer /* ARGSUSED */
8874977Sraghus static int
nxge_param_get_port_mode(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)8884977Sraghus nxge_param_get_port_mode(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
8894977Sraghus {
8904977Sraghus NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_port_mode"));
8914977Sraghus
8924977Sraghus switch (nxgep->mac.portmode) {
8934977Sraghus case PORT_1G_COPPER:
8945572Ssbehera (void) mi_mpprintf(mp, "Port mode for nxge%d: 1G Copper %s\n",
8955572Ssbehera nxgep->instance,
8965572Ssbehera nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
8974977Sraghus break;
8984977Sraghus case PORT_1G_FIBER:
8995572Ssbehera (void) mi_mpprintf(mp, "Port mode for nxge%d: 1G Fiber %s\n",
9005572Ssbehera nxgep->instance,
9015572Ssbehera nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9024977Sraghus break;
9034977Sraghus case PORT_10G_COPPER:
9045572Ssbehera (void) mi_mpprintf(mp, "Port mode for nxge%d: 10G Copper "
9055572Ssbehera "%s\n", nxgep->instance,
9065572Ssbehera nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9074977Sraghus break;
9084977Sraghus case PORT_10G_FIBER:
9095572Ssbehera (void) mi_mpprintf(mp, "Port mode for nxge%d: 10G Fiber %s\n",
9105572Ssbehera nxgep->instance,
9115572Ssbehera nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9124977Sraghus break;
9134977Sraghus case PORT_10G_SERDES:
9145572Ssbehera (void) mi_mpprintf(mp, "Port mode for nxge%d: 10G Serdes "
9155572Ssbehera "%s\n", nxgep->instance,
9165572Ssbehera nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9174977Sraghus break;
9184977Sraghus case PORT_1G_SERDES:
9195572Ssbehera (void) mi_mpprintf(mp, "Port mode for nxge%d: 1G Serdes %s\n",
9205572Ssbehera nxgep->instance,
9215572Ssbehera nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9224977Sraghus break;
9234977Sraghus case PORT_1G_RGMII_FIBER:
9244977Sraghus (void) mi_mpprintf(mp, "Port mode for nxge%d: 1G RGMII "
9255572Ssbehera "Fiber %s\n", nxgep->instance,
9265572Ssbehera nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9275572Ssbehera break;
9285572Ssbehera case PORT_HSP_MODE:
9295572Ssbehera (void) mi_mpprintf(mp, "Port mode for nxge%d: Hot Swappable "
9305572Ssbehera "PHY, Currently NOT present\n", nxgep->instance);
9314977Sraghus break;
9326835Syc148097 case PORT_10G_TN1010:
9336835Syc148097 (void) mi_mpprintf(mp, "Port mode for nxge%d:"
9346835Syc148097 " 10G Copper with TN1010 %s\n", nxgep->instance,
9356835Syc148097 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9366835Syc148097 break;
9376835Syc148097 case PORT_1G_TN1010:
9386837Syc148097 (void) mi_mpprintf(mp, "Port mode for nxge%d:"
9396835Syc148097 " 1G Copper with TN1010 %s\n", nxgep->instance,
9406835Syc148097 nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9416835Syc148097 break;
9424977Sraghus default:
9435572Ssbehera (void) mi_mpprintf(mp, "Port mode for nxge%d: Unknown %s\n",
9445572Ssbehera nxgep->instance,
9455572Ssbehera nxgep->hot_swappable_phy ? "[Hot Swappable]" : "");
9464977Sraghus break;
9474977Sraghus }
9484977Sraghus
9496003Sml29623 (void) mi_mpprintf(mp, "Software LSO for nxge%d: %s\n",
9506003Sml29623 nxgep->instance,
9516003Sml29623 nxgep->soft_lso_enable ? "enable" : "disable");
9526003Sml29623
9534977Sraghus NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_port_mode"));
9544977Sraghus return (0);
9554977Sraghus }
9564977Sraghus
9574977Sraghus /* ARGSUSED */
958*9005SSantwona.Behera@Sun.COM static int
nxge_param_get_rx_intr_time(p_nxge_t nxgep,queue_t * q,mblk_t * mp,caddr_t cp)959*9005SSantwona.Behera@Sun.COM nxge_param_get_rx_intr_time(p_nxge_t nxgep, queue_t *q, mblk_t *mp, caddr_t cp)
960*9005SSantwona.Behera@Sun.COM {
961*9005SSantwona.Behera@Sun.COM p_nxge_param_t pa = (p_nxge_param_t)cp;
962*9005SSantwona.Behera@Sun.COM
963*9005SSantwona.Behera@Sun.COM NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_rx_intr_time"));
964*9005SSantwona.Behera@Sun.COM
965*9005SSantwona.Behera@Sun.COM pa->value = (uint32_t)nxgep->intr_timeout;
966*9005SSantwona.Behera@Sun.COM (void) mi_mpprintf(mp, "%d", (uint32_t)nxgep->intr_timeout);
967*9005SSantwona.Behera@Sun.COM
968*9005SSantwona.Behera@Sun.COM NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_rx_intr_time"));
969*9005SSantwona.Behera@Sun.COM return (0);
970*9005SSantwona.Behera@Sun.COM }
971*9005SSantwona.Behera@Sun.COM
972*9005SSantwona.Behera@Sun.COM /* ARGSUSED */
973*9005SSantwona.Behera@Sun.COM static int
nxge_param_get_rx_intr_pkts(p_nxge_t nxgep,queue_t * q,mblk_t * mp,caddr_t cp)974*9005SSantwona.Behera@Sun.COM nxge_param_get_rx_intr_pkts(p_nxge_t nxgep, queue_t *q, mblk_t *mp, caddr_t cp)
975*9005SSantwona.Behera@Sun.COM {
976*9005SSantwona.Behera@Sun.COM p_nxge_param_t pa = (p_nxge_param_t)cp;
977*9005SSantwona.Behera@Sun.COM
978*9005SSantwona.Behera@Sun.COM NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_rx_intr_pkts"));
979*9005SSantwona.Behera@Sun.COM
980*9005SSantwona.Behera@Sun.COM pa->value = (uint32_t)nxgep->intr_threshold;
981*9005SSantwona.Behera@Sun.COM (void) mi_mpprintf(mp, "%d", (uint32_t)nxgep->intr_threshold);
982*9005SSantwona.Behera@Sun.COM
983*9005SSantwona.Behera@Sun.COM NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_rx_intr_pkts"));
984*9005SSantwona.Behera@Sun.COM return (0);
985*9005SSantwona.Behera@Sun.COM }
986*9005SSantwona.Behera@Sun.COM
987*9005SSantwona.Behera@Sun.COM /* ARGSUSED */
9883859Sml29623 int
nxge_param_get_txdma_info(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)9893859Sml29623 nxge_param_get_txdma_info(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
9903859Sml29623 {
9913859Sml29623
9926495Sspeer uint_t print_len, buf_len;
9933859Sml29623 p_mblk_t np;
9943859Sml29623
9953859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
9966495Sspeer int tdc;
9976495Sspeer
9986495Sspeer nxge_grp_set_t *set;
9996495Sspeer
10003859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_txdma_info"));
10013859Sml29623
10023859Sml29623 (void) mi_mpprintf(mp, "TXDMA Information for Port\t %d \n",
10036512Ssowmini nxgep->function_num);
10043859Sml29623
10053859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
10063859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
10073859Sml29623 return (0);
10083859Sml29623 }
10093859Sml29623
10103859Sml29623 buf_len = buff_alloc_size;
10113859Sml29623 mp->b_cont = np;
10126495Sspeer print_len = 0;
10133859Sml29623
10143859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
10156512Ssowmini "TDC\t HW TDC\t\n");
10163859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
10173859Sml29623 buf_len -= print_len;
10186495Sspeer
10196495Sspeer set = &nxgep->tx_set;
10208275SEric Cheng for (tdc = 0; tdc < NXGE_MAX_TDCS; tdc++) {
10216495Sspeer if ((1 << tdc) & set->owned.map) {
10226495Sspeer print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
10236495Sspeer buf_len, "%d\n", tdc);
10246495Sspeer ((mblk_t *)np)->b_wptr += print_len;
10256495Sspeer buf_len -= print_len;
10266495Sspeer }
10273859Sml29623 }
10283859Sml29623
10293859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_txdma_info"));
10303859Sml29623 return (0);
10313859Sml29623 }
10323859Sml29623
10333859Sml29623 /* ARGSUSED */
10343859Sml29623 int
nxge_param_get_rxdma_info(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)10353859Sml29623 nxge_param_get_rxdma_info(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
10363859Sml29623 {
10373859Sml29623 uint_t print_len, buf_len;
10383859Sml29623 p_mblk_t np;
10393859Sml29623 int rdc;
10403859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
10413859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
10423859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
10433859Sml29623 p_rx_rcr_rings_t rx_rcr_rings;
10443859Sml29623 p_rx_rcr_ring_t *rcr_rings;
10453859Sml29623 p_rx_rbr_rings_t rx_rbr_rings;
10463859Sml29623 p_rx_rbr_ring_t *rbr_rings;
10476495Sspeer nxge_grp_set_t *set;
10483859Sml29623
10493859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_rxdma_info"));
10503859Sml29623
10513859Sml29623 (void) mi_mpprintf(mp, "RXDMA Information for Port\t %d \n",
10526512Ssowmini nxgep->function_num);
10533859Sml29623
10543859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
10553859Sml29623 /* The following may work even if we cannot get a large buf. */
10563859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
10573859Sml29623 return (0);
10583859Sml29623 }
10593859Sml29623
10603859Sml29623 buf_len = buff_alloc_size;
10613859Sml29623 mp->b_cont = np;
10623859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
10633859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
10643859Sml29623
10653859Sml29623 rx_rcr_rings = nxgep->rx_rcr_rings;
10663859Sml29623 rcr_rings = rx_rcr_rings->rcr_rings;
10673859Sml29623 rx_rbr_rings = nxgep->rx_rbr_rings;
10683859Sml29623 rbr_rings = rx_rbr_rings->rbr_rings;
10693859Sml29623
10703859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
10716512Ssowmini "Total RDCs\t %d\n", p_cfgp->max_rdcs);
10723859Sml29623
10733859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
10743859Sml29623 buf_len -= print_len;
10753859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
10766512Ssowmini "RDC\t HW RDC\t Timeout\t Packets RBR ptr \t"
10776512Ssowmini "chunks\t RCR ptr\n");
10783859Sml29623
10793859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
10803859Sml29623 buf_len -= print_len;
10816495Sspeer
10826495Sspeer set = &nxgep->rx_set;
10836495Sspeer for (rdc = 0; rdc < NXGE_MAX_RDCS; rdc++) {
10846495Sspeer if ((1 << rdc) & set->owned.map) {
10856495Sspeer print_len = snprintf((char *)
10866495Sspeer ((mblk_t *)np)->b_wptr, buf_len,
10876495Sspeer " %d\t %x\t\t %x\t $%p\t 0x%x\t $%p\n",
10886495Sspeer rdc,
10896495Sspeer p_dma_cfgp->rcr_timeout[rdc],
10906495Sspeer p_dma_cfgp->rcr_threshold[rdc],
10917632SNick.Todd@Sun.COM (void *)rbr_rings[rdc],
10927632SNick.Todd@Sun.COM rbr_rings[rdc]->num_blocks, (void *)rcr_rings[rdc]);
10933859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
10943859Sml29623 buf_len -= print_len;
10956495Sspeer }
10963859Sml29623 }
10973859Sml29623
10983859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_rxdma_info"));
10993859Sml29623 return (0);
11003859Sml29623 }
11013859Sml29623
11023859Sml29623 /* ARGSUSED */
11033859Sml29623 int
nxge_param_get_rxdma_rdcgrp_info(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)11043859Sml29623 nxge_param_get_rxdma_rdcgrp_info(p_nxge_t nxgep, queue_t *q,
11053859Sml29623 p_mblk_t mp, caddr_t cp)
11063859Sml29623 {
11073859Sml29623 uint_t print_len, buf_len;
11083859Sml29623 p_mblk_t np;
11093859Sml29623 int offset, rdc, i, rdc_grp;
11103859Sml29623 p_nxge_rdc_grp_t rdc_grp_p;
11113859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
11123859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
11133859Sml29623
11143859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE;
11153859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
11166512Ssowmini "==> nxge_param_get_rxdma_rdcgrp_info"));
11173859Sml29623
11183859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
11193859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
11203859Sml29623
11213859Sml29623 (void) mi_mpprintf(mp, "RXDMA RDC Group Information for Port\t %d \n",
11226512Ssowmini nxgep->function_num);
11233859Sml29623
11246495Sspeer rdc_grp = p_cfgp->def_mac_rxdma_grpid;
11253859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
11263859Sml29623 /* The following may work even if we cannot get a large buf. */
11273859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
11283859Sml29623 return (0);
11293859Sml29623 }
11303859Sml29623
11313859Sml29623 buf_len = buff_alloc_size;
11323859Sml29623 mp->b_cont = np;
11333859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
11346512Ssowmini "Total RDC Groups\t %d \n"
11356512Ssowmini "default RDC group\t %d\n",
11366512Ssowmini p_cfgp->max_rdc_grpids,
11376512Ssowmini p_cfgp->def_mac_rxdma_grpid);
11383859Sml29623
11393859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
11403859Sml29623 buf_len -= print_len;
11413859Sml29623
11428661SSantwona.Behera@Sun.COM for (i = 0; i < NXGE_MAX_RDC_GROUPS; i++) {
11436495Sspeer if (p_cfgp->grpids[i]) {
11446495Sspeer rdc_grp_p = &p_dma_cfgp->rdc_grps[i];
11456495Sspeer print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
11466495Sspeer buf_len,
11476495Sspeer "\nRDC Group Info for Group [%d] %d\n"
11486495Sspeer "RDC Count %d\tstart RDC %d\n"
11496495Sspeer "RDC Group Population Information"
11506495Sspeer " (offsets 0 - 15)\n",
11516495Sspeer i, rdc_grp, rdc_grp_p->max_rdcs,
11526495Sspeer rdc_grp_p->start_rdc);
11536495Sspeer
11546495Sspeer ((mblk_t *)np)->b_wptr += print_len;
11556495Sspeer buf_len -= print_len;
11563859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
11576495Sspeer buf_len, "\n");
11586495Sspeer ((mblk_t *)np)->b_wptr += print_len;
11596495Sspeer buf_len -= print_len;
11606495Sspeer
11616495Sspeer for (rdc = 0; rdc < rdc_grp_p->max_rdcs; rdc++) {
11626495Sspeer print_len = snprintf(
11636512Ssowmini (char *)((mblk_t *)np)->b_wptr,
11646512Ssowmini buf_len, "[%d]=%d ", rdc,
11656512Ssowmini rdc_grp_p->start_rdc + rdc);
11666495Sspeer ((mblk_t *)np)->b_wptr += print_len;
11676495Sspeer buf_len -= print_len;
11686495Sspeer }
11696495Sspeer print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
11706495Sspeer buf_len, "\n");
11716495Sspeer ((mblk_t *)np)->b_wptr += print_len;
11726495Sspeer buf_len -= print_len;
11736495Sspeer
11746495Sspeer for (offset = 0; offset < 16; offset++) {
11756495Sspeer print_len = snprintf(
11766512Ssowmini (char *)((mblk_t *)np)->b_wptr,
11776512Ssowmini buf_len, " %c",
11786512Ssowmini rdc_grp_p->map & (1 << offset) ?
11796512Ssowmini '1' : '0');
11806495Sspeer ((mblk_t *)np)->b_wptr += print_len;
11816495Sspeer buf_len -= print_len;
11826495Sspeer }
11836495Sspeer print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
11846495Sspeer buf_len, "\n");
11853859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
11863859Sml29623 buf_len -= print_len;
11873859Sml29623 }
11883859Sml29623 }
11893859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
11906512Ssowmini "<== nxge_param_get_rxdma_rdcgrp_info"));
11913859Sml29623 return (0);
11923859Sml29623 }
11933859Sml29623
11943859Sml29623 int
nxge_mk_mblk_tail_space(p_mblk_t mp,p_mblk_t * nmp,size_t size)11953859Sml29623 nxge_mk_mblk_tail_space(p_mblk_t mp, p_mblk_t *nmp, size_t size)
11963859Sml29623 {
11973859Sml29623 p_mblk_t tmp;
11983859Sml29623
11993859Sml29623 tmp = mp;
12003859Sml29623 while (tmp->b_cont)
12013859Sml29623 tmp = tmp->b_cont;
12023859Sml29623 if ((tmp->b_wptr + size) >= tmp->b_datap->db_lim) {
12033859Sml29623 tmp->b_cont = allocb(1024, BPRI_HI);
12043859Sml29623 tmp = tmp->b_cont;
12053859Sml29623 if (!tmp)
12063859Sml29623 return (ENOMEM);
12073859Sml29623 }
12083859Sml29623
12093859Sml29623 *nmp = tmp;
12103859Sml29623 return (0);
12113859Sml29623 }
12123859Sml29623
12133859Sml29623
12143859Sml29623 /* ARGSUSED */
12153859Sml29623 int
nxge_param_set_generic(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)12163859Sml29623 nxge_param_set_generic(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
12173859Sml29623 char *value, caddr_t cp)
12183859Sml29623 {
12193859Sml29623 char *end;
12203859Sml29623 uint32_t new_value;
12213859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
12223859Sml29623
12233859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, " ==> nxge_param_set_generic"));
12243859Sml29623 new_value = (uint32_t)mi_strtol(value, &end, 10);
12253859Sml29623 if (end == value || new_value < pa->minimum ||
12266512Ssowmini new_value > pa->maximum) {
12273859Sml29623 return (EINVAL);
12283859Sml29623 }
12293859Sml29623 pa->value = new_value;
12303859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, " <== nxge_param_set_generic"));
12313859Sml29623 return (0);
12323859Sml29623 }
12333859Sml29623
12343859Sml29623
12353859Sml29623 /* ARGSUSED */
12363859Sml29623 int
nxge_param_set_instance(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)12373859Sml29623 nxge_param_set_instance(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
12383859Sml29623 char *value, caddr_t cp)
12393859Sml29623 {
12403859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " ==> nxge_param_set_instance"));
12413859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_set_instance"));
12423859Sml29623 return (0);
12433859Sml29623 }
12443859Sml29623
12453859Sml29623
12463859Sml29623 /* ARGSUSED */
12473859Sml29623 int
nxge_param_set_mac(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)12483859Sml29623 nxge_param_set_mac(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
12493859Sml29623 char *value, caddr_t cp)
12503859Sml29623 {
12513859Sml29623 char *end;
12523859Sml29623 uint32_t new_value;
12533859Sml29623 int status = 0;
12543859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
12553859Sml29623
12563859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_mac"));
12573859Sml29623 new_value = (uint32_t)mi_strtol(value, &end, BASE_DECIMAL);
12583859Sml29623 if (PARAM_OUTOF_RANGE(value, end, new_value, pa)) {
12593859Sml29623 return (EINVAL);
12603859Sml29623 }
12613859Sml29623
12623859Sml29623 if (pa->value != new_value) {
12633859Sml29623 pa->old_value = pa->value;
12643859Sml29623 pa->value = new_value;
12653859Sml29623 }
12663859Sml29623
12673859Sml29623 if (!nxge_param_link_update(nxgep)) {
12683859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
12696512Ssowmini " false ret from nxge_param_link_update"));
12703859Sml29623 status = EINVAL;
12713859Sml29623 }
12723859Sml29623
12733859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_mac"));
12743859Sml29623 return (status);
12753859Sml29623 }
12763859Sml29623
12773859Sml29623 /* ARGSUSED */
12786439Sml29623 int
nxge_param_rx_intr_pkts(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)12793859Sml29623 nxge_param_rx_intr_pkts(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
12803859Sml29623 char *value, caddr_t cp)
12813859Sml29623 {
12823859Sml29623 char *end;
12833859Sml29623 uint32_t cfg_value;
12843859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
12853859Sml29623
12863859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_rx_intr_pkts"));
12873859Sml29623
12883859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
12893859Sml29623
12903859Sml29623 if ((cfg_value > NXGE_RDC_RCR_THRESHOLD_MAX) ||
12916512Ssowmini (cfg_value < NXGE_RDC_RCR_THRESHOLD_MIN)) {
12923859Sml29623 return (EINVAL);
12933859Sml29623 }
12943859Sml29623
12953859Sml29623 if ((pa->value != cfg_value)) {
12963859Sml29623 pa->old_value = pa->value;
12973859Sml29623 pa->value = cfg_value;
12983859Sml29623 nxgep->intr_threshold = pa->value;
12993859Sml29623 }
13003859Sml29623
13013859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_rx_intr_pkts"));
13023859Sml29623 return (0);
13033859Sml29623 }
13043859Sml29623
13053859Sml29623 /* ARGSUSED */
13066439Sml29623 int
nxge_param_rx_intr_time(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)13073859Sml29623 nxge_param_rx_intr_time(p_nxge_t nxgep, queue_t *q, mblk_t *mp,
13083859Sml29623 char *value, caddr_t cp)
13093859Sml29623 {
13103859Sml29623 char *end;
13113859Sml29623 uint32_t cfg_value;
13123859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
13133859Sml29623
13143859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_rx_intr_time"));
13153859Sml29623
13163859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
13173859Sml29623
13183859Sml29623 if ((cfg_value > NXGE_RDC_RCR_TIMEOUT_MAX) ||
13196512Ssowmini (cfg_value < NXGE_RDC_RCR_TIMEOUT_MIN)) {
13203859Sml29623 return (EINVAL);
13213859Sml29623 }
13223859Sml29623
13233859Sml29623 if ((pa->value != cfg_value)) {
13243859Sml29623 pa->old_value = pa->value;
13253859Sml29623 pa->value = cfg_value;
13263859Sml29623 nxgep->intr_timeout = pa->value;
13273859Sml29623 }
13283859Sml29623
13293859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_rx_intr_time"));
13303859Sml29623 return (0);
13313859Sml29623 }
13323859Sml29623
13333859Sml29623 /* ARGSUSED */
13343859Sml29623 static int
nxge_param_set_mac_rdcgrp(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)13353859Sml29623 nxge_param_set_mac_rdcgrp(p_nxge_t nxgep, queue_t *q,
13363859Sml29623 mblk_t *mp, char *value, caddr_t cp)
13373859Sml29623 {
13383859Sml29623 char *end;
13393859Sml29623 uint32_t status = 0, cfg_value;
13403859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
13413859Sml29623 uint32_t cfg_it = B_FALSE;
13423859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
13433859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
13443859Sml29623 uint32_t *val_ptr, *old_val_ptr;
13453859Sml29623 nxge_param_map_t *mac_map;
13463859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp;
13473859Sml29623 nxge_mv_cfg_t *mac_host_info;
13483859Sml29623
13493859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_mac_rdcgrp "));
13503859Sml29623
13513859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
13523859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
13533859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
13543859Sml29623 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0];
13553859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
13563859Sml29623
13573859Sml29623 /*
13583859Sml29623 * now do decoding
13593859Sml29623 */
13603859Sml29623 mac_map = (nxge_param_map_t *)&cfg_value;
13613859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " cfg_value %x id %x map_to %x",
13626512Ssowmini cfg_value, mac_map->param_id, mac_map->map_to));
13633859Sml29623
13643859Sml29623 if ((mac_map->param_id < p_cfgp->max_macs) &&
13656495Sspeer p_cfgp->grpids[mac_map->map_to]) {
13663859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
13676495Sspeer " nxge_param_set_mac_rdcgrp mapping"
13686495Sspeer " id %d grp %d", mac_map->param_id, mac_map->map_to));
13695125Sjoycey #if defined(__i386)
13705125Sjoycey val_ptr = (uint32_t *)(uint32_t)pa->value;
13715125Sjoycey #else
13723859Sml29623 val_ptr = (uint32_t *)pa->value;
13735125Sjoycey #endif
13745125Sjoycey #if defined(__i386)
13755125Sjoycey old_val_ptr = (uint32_t *)(uint32_t)pa->old_value;
13765125Sjoycey #else
13773859Sml29623 old_val_ptr = (uint32_t *)pa->old_value;
13785125Sjoycey #endif
13793859Sml29623 if (val_ptr[mac_map->param_id] != cfg_value) {
13803859Sml29623 old_val_ptr[mac_map->param_id] =
13816495Sspeer val_ptr[mac_map->param_id];
13823859Sml29623 val_ptr[mac_map->param_id] = cfg_value;
13833859Sml29623 mac_host_info[mac_map->param_id].mpr_npr =
13846495Sspeer mac_map->pref;
13853859Sml29623 mac_host_info[mac_map->param_id].flag = 1;
13863859Sml29623 mac_host_info[mac_map->param_id].rdctbl =
13876495Sspeer mac_map->map_to;
13883859Sml29623 cfg_it = B_TRUE;
13893859Sml29623 }
13903859Sml29623 } else {
13913859Sml29623 return (EINVAL);
13923859Sml29623 }
13933859Sml29623
13943859Sml29623 if (cfg_it == B_TRUE) {
13953859Sml29623 status = nxge_logical_mac_assign_rdc_table(nxgep,
13966495Sspeer (uint8_t)mac_map->param_id);
13973859Sml29623 if (status != NXGE_OK)
13983859Sml29623 return (EINVAL);
13993859Sml29623 }
14003859Sml29623
14013859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_mac_rdcgrp"));
14023859Sml29623 return (0);
14033859Sml29623 }
14043859Sml29623
14053859Sml29623 /* ARGSUSED */
14063859Sml29623 static int
nxge_param_set_vlan_rdcgrp(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)14073859Sml29623 nxge_param_set_vlan_rdcgrp(p_nxge_t nxgep, queue_t *q,
14083859Sml29623 mblk_t *mp, char *value, caddr_t cp)
14093859Sml29623 {
14103859Sml29623 char *end;
14113859Sml29623 uint32_t status = 0, cfg_value;
14123859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
14133859Sml29623 uint32_t cfg_it = B_FALSE;
14143859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
14153859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
14163859Sml29623 uint32_t *val_ptr, *old_val_ptr;
14173859Sml29623 nxge_param_map_t *vmap, *old_map;
14183859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp;
14193859Sml29623 uint64_t cfgd_vlans;
14203859Sml29623 int i, inc = 0, cfg_position;
14213859Sml29623 nxge_mv_cfg_t *vlan_tbl;
14223859Sml29623
14233859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_vlan_rdcgrp "));
14243859Sml29623
14253859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
14263859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
14273859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
14283859Sml29623 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0];
14293859Sml29623
14303859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
14313859Sml29623
14323859Sml29623 /* now do decoding */
14333859Sml29623 cfgd_vlans = ((pa->type & NXGE_PARAM_ARRAY_CNT_MASK) >>
14346512Ssowmini NXGE_PARAM_ARRAY_CNT_SHIFT);
14353859Sml29623
14363859Sml29623 if (cfgd_vlans == NXGE_PARAM_ARRAY_INIT_SIZE) {
14373859Sml29623 /*
14383859Sml29623 * for now, we process only upto max
14393859Sml29623 * NXGE_PARAM_ARRAY_INIT_SIZE parameters
14403859Sml29623 * In the future, we may want to expand
14413859Sml29623 * the storage array and continue
14423859Sml29623 */
14433859Sml29623 return (EINVAL);
14443859Sml29623 }
14453859Sml29623
14463859Sml29623 vmap = (nxge_param_map_t *)&cfg_value;
14473859Sml29623 if ((vmap->param_id) &&
14486512Ssowmini (vmap->param_id < NXGE_MAX_VLANS) &&
14496512Ssowmini (vmap->map_to < p_cfgp->max_rdc_grpids)) {
14503859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
14516512Ssowmini "nxge_param_set_vlan_rdcgrp mapping"
14526512Ssowmini " id %d grp %d",
14536512Ssowmini vmap->param_id, vmap->map_to));
14545125Sjoycey #if defined(__i386)
14555125Sjoycey val_ptr = (uint32_t *)(uint32_t)pa->value;
14565125Sjoycey #else
14573859Sml29623 val_ptr = (uint32_t *)pa->value;
14585125Sjoycey #endif
14595125Sjoycey #if defined(__i386)
14605125Sjoycey old_val_ptr = (uint32_t *)(uint32_t)pa->old_value;
14615125Sjoycey #else
14623859Sml29623 old_val_ptr = (uint32_t *)pa->old_value;
14635125Sjoycey #endif
14643859Sml29623
14653859Sml29623 /* search to see if this vlan id is already configured */
14663859Sml29623 for (i = 0; i < cfgd_vlans; i++) {
14673859Sml29623 old_map = (nxge_param_map_t *)&val_ptr[i];
14683859Sml29623 if ((old_map->param_id == 0) ||
14696512Ssowmini (vmap->param_id == old_map->param_id) ||
14706512Ssowmini (vlan_tbl[vmap->param_id].flag)) {
14713859Sml29623 cfg_position = i;
14723859Sml29623 break;
14733859Sml29623 }
14743859Sml29623 }
14753859Sml29623
14763859Sml29623 if (cfgd_vlans == 0) {
14773859Sml29623 cfg_position = 0;
14783859Sml29623 inc++;
14793859Sml29623 }
14803859Sml29623
14813859Sml29623 if (i == cfgd_vlans) {
14823859Sml29623 cfg_position = i;
14833859Sml29623 inc++;
14843859Sml29623 }
14853859Sml29623
14863859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
14876512Ssowmini "set_vlan_rdcgrp mapping"
14886512Ssowmini " i %d cfgd_vlans %llx position %d ",
14896512Ssowmini i, cfgd_vlans, cfg_position));
14903859Sml29623 if (val_ptr[cfg_position] != cfg_value) {
14913859Sml29623 old_val_ptr[cfg_position] = val_ptr[cfg_position];
14923859Sml29623 val_ptr[cfg_position] = cfg_value;
14933859Sml29623 vlan_tbl[vmap->param_id].mpr_npr = vmap->pref;
14943859Sml29623 vlan_tbl[vmap->param_id].flag = 1;
14953859Sml29623 vlan_tbl[vmap->param_id].rdctbl =
14966495Sspeer vmap->map_to + p_cfgp->def_mac_rxdma_grpid;
14973859Sml29623 cfg_it = B_TRUE;
14983859Sml29623 if (inc) {
14993859Sml29623 cfgd_vlans++;
15003859Sml29623 pa->type &= ~NXGE_PARAM_ARRAY_CNT_MASK;
15013859Sml29623 pa->type |= (cfgd_vlans <<
15026512Ssowmini NXGE_PARAM_ARRAY_CNT_SHIFT);
15033859Sml29623
15043859Sml29623 }
15053859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD2_CTL,
15066512Ssowmini "after: param_set_vlan_rdcgrp "
15076512Ssowmini " cfg_vlans %llx position %d \n",
15086512Ssowmini cfgd_vlans, cfg_position));
15093859Sml29623 }
15103859Sml29623 } else {
15113859Sml29623 return (EINVAL);
15123859Sml29623 }
15133859Sml29623
15143859Sml29623 if (cfg_it == B_TRUE) {
15153859Sml29623 status = nxge_fflp_config_vlan_table(nxgep,
15166512Ssowmini (uint16_t)vmap->param_id);
15173859Sml29623 if (status != NXGE_OK)
15183859Sml29623 return (EINVAL);
15193859Sml29623 }
15203859Sml29623
15213859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_vlan_rdcgrp"));
15223859Sml29623 return (0);
15233859Sml29623 }
15243859Sml29623
15253859Sml29623 /* ARGSUSED */
15263859Sml29623 static int
nxge_param_get_vlan_rdcgrp(p_nxge_t nxgep,queue_t * q,mblk_t * mp,caddr_t cp)15273859Sml29623 nxge_param_get_vlan_rdcgrp(p_nxge_t nxgep, queue_t *q,
15283859Sml29623 mblk_t *mp, caddr_t cp)
15293859Sml29623 {
15303859Sml29623
15313859Sml29623 uint_t print_len, buf_len;
15323859Sml29623 p_mblk_t np;
15333859Sml29623 int i;
15343859Sml29623 uint32_t *val_ptr;
15353859Sml29623 nxge_param_map_t *vmap;
15363859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
15373859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp;
15383859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
15393859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
15403859Sml29623 uint64_t cfgd_vlans = 0;
15413859Sml29623 nxge_mv_cfg_t *vlan_tbl;
15423859Sml29623 int buff_alloc_size =
15436512Ssowmini NXGE_NDD_INFODUMP_BUFF_SIZE * 32;
15443859Sml29623
15453859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_vlan_rdcgrp "));
15463859Sml29623 (void) mi_mpprintf(mp, "VLAN RDC Mapping Information for Port\t %d \n",
15476512Ssowmini nxgep->function_num);
15483859Sml29623
15493859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
15503859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
15513859Sml29623 return (0);
15523859Sml29623 }
15533859Sml29623
15543859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
15553859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
15563859Sml29623
15573859Sml29623 buf_len = buff_alloc_size;
15583859Sml29623 mp->b_cont = np;
15593859Sml29623 cfgd_vlans = (pa->type & NXGE_PARAM_ARRAY_CNT_MASK) >>
15606512Ssowmini NXGE_PARAM_ARRAY_CNT_SHIFT;
15613859Sml29623
15623859Sml29623 i = (int)cfgd_vlans;
15633859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
15643859Sml29623 vlan_tbl = (nxge_mv_cfg_t *)&p_class_cfgp->vlan_tbl[0];
15653859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
15666512Ssowmini "Configured VLANs %d\n"
15676512Ssowmini "VLAN ID\t RDC GRP (Actual/Port)\t"
15686512Ssowmini " Prefernce\n", i);
15693859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
15703859Sml29623 buf_len -= print_len;
15715125Sjoycey #if defined(__i386)
15725125Sjoycey val_ptr = (uint32_t *)(uint32_t)pa->value;
15735125Sjoycey #else
15743859Sml29623 val_ptr = (uint32_t *)pa->value;
15755125Sjoycey #endif
15763859Sml29623
15773859Sml29623 for (i = 0; i < cfgd_vlans; i++) {
15783859Sml29623 vmap = (nxge_param_map_t *)&val_ptr[i];
15793859Sml29623 if (p_class_cfgp->vlan_tbl[vmap->param_id].flag) {
15803859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
15816512Ssowmini buf_len,
15826512Ssowmini " %d\t\t %d/%d\t\t %d\n",
15836512Ssowmini vmap->param_id,
15846512Ssowmini vlan_tbl[vmap->param_id].rdctbl,
15856512Ssowmini vlan_tbl[vmap->param_id].rdctbl -
15866512Ssowmini p_cfgp->def_mac_rxdma_grpid,
15876512Ssowmini vlan_tbl[vmap->param_id].mpr_npr);
15883859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
15893859Sml29623 buf_len -= print_len;
15903859Sml29623 }
15913859Sml29623 }
15923859Sml29623
15933859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_vlan_rdcgrp"));
15943859Sml29623 return (0);
15953859Sml29623 }
15963859Sml29623
15973859Sml29623 /* ARGSUSED */
15983859Sml29623 static int
nxge_param_get_mac_rdcgrp(p_nxge_t nxgep,queue_t * q,mblk_t * mp,caddr_t cp)15993859Sml29623 nxge_param_get_mac_rdcgrp(p_nxge_t nxgep, queue_t *q,
16003859Sml29623 mblk_t *mp, caddr_t cp)
16013859Sml29623 {
16023859Sml29623 uint_t print_len, buf_len;
16033859Sml29623 p_mblk_t np;
16043859Sml29623 int i;
16053859Sml29623 p_nxge_class_pt_cfg_t p_class_cfgp;
16063859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
16073859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
16083859Sml29623 nxge_mv_cfg_t *mac_host_info;
16093859Sml29623
16103859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_SIZE * 32;
16113859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_mac_rdcgrp "));
16123859Sml29623 (void) mi_mpprintf(mp,
16136512Ssowmini "MAC ADDR RDC Mapping Information for Port\t %d\n",
16146512Ssowmini nxgep->function_num);
16153859Sml29623
16163859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
16173859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
16183859Sml29623 return (0);
16193859Sml29623 }
16203859Sml29623
16213859Sml29623 buf_len = buff_alloc_size;
16223859Sml29623 mp->b_cont = np;
16233859Sml29623 p_class_cfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config;
16243859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
16253859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
16263859Sml29623 mac_host_info = (nxge_mv_cfg_t *)&p_class_cfgp->mac_host_info[0];
16273859Sml29623 print_len = snprintf((char *)np->b_wptr, buf_len,
16286512Ssowmini "MAC ID\t RDC GRP (Actual/Port)\t"
16296512Ssowmini " Prefernce\n");
16303859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
16313859Sml29623 buf_len -= print_len;
16323859Sml29623 for (i = 0; i < p_cfgp->max_macs; i++) {
16333859Sml29623 if (mac_host_info[i].flag) {
16343859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr,
16356512Ssowmini buf_len,
16366512Ssowmini " %d\t %d/%d\t\t %d\n",
16376512Ssowmini i, mac_host_info[i].rdctbl,
16386512Ssowmini mac_host_info[i].rdctbl -
16396512Ssowmini p_cfgp->def_mac_rxdma_grpid,
16406512Ssowmini mac_host_info[i].mpr_npr);
16413859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
16423859Sml29623 buf_len -= print_len;
16433859Sml29623 }
16443859Sml29623 }
16453859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
16466512Ssowmini "Done Info Dumping \n");
16473859Sml29623 ((mblk_t *)np)->b_wptr += print_len;
16483859Sml29623 buf_len -= print_len;
16493859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_macrdcgrp"));
16503859Sml29623 return (0);
16513859Sml29623 }
16523859Sml29623
16533859Sml29623 /* ARGSUSED */
16543859Sml29623 static int
nxge_param_tcam_enable(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)16553859Sml29623 nxge_param_tcam_enable(p_nxge_t nxgep, queue_t *q,
16563859Sml29623 mblk_t *mp, char *value, caddr_t cp)
16573859Sml29623 {
16583859Sml29623 uint32_t status = 0, cfg_value;
16593859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
16603859Sml29623 uint32_t cfg_it = B_FALSE;
16613859Sml29623 char *end;
16623859Sml29623
16633859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_tcam_enable"));
16643859Sml29623
16653859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
16663859Sml29623 if (pa->value != cfg_value) {
16673859Sml29623 pa->old_value = pa->value;
16683859Sml29623 pa->value = cfg_value;
16693859Sml29623 cfg_it = B_TRUE;
16703859Sml29623 }
16713859Sml29623
16723859Sml29623 if (cfg_it == B_TRUE) {
16733859Sml29623 if (pa->value)
16743859Sml29623 status = nxge_fflp_config_tcam_enable(nxgep);
16753859Sml29623 else
16763859Sml29623 status = nxge_fflp_config_tcam_disable(nxgep);
16773859Sml29623 if (status != NXGE_OK)
16783859Sml29623 return (EINVAL);
16793859Sml29623 }
16803859Sml29623
16813859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_tcam_enable"));
16823859Sml29623 return (0);
16833859Sml29623 }
16843859Sml29623
16853859Sml29623 /* ARGSUSED */
16863859Sml29623 static int
nxge_param_hash_lookup_enable(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)16873859Sml29623 nxge_param_hash_lookup_enable(p_nxge_t nxgep, queue_t *q,
16883859Sml29623 mblk_t *mp, char *value, caddr_t cp)
16893859Sml29623 {
16903859Sml29623 uint32_t status = 0, cfg_value;
16913859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
16923859Sml29623 uint32_t cfg_it = B_FALSE;
16933859Sml29623 char *end;
16943859Sml29623
16953859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_hash_lookup_enable"));
16963859Sml29623
16973859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
16983859Sml29623 if (pa->value != cfg_value) {
16993859Sml29623 pa->old_value = pa->value;
17003859Sml29623 pa->value = cfg_value;
17013859Sml29623 cfg_it = B_TRUE;
17023859Sml29623 }
17033859Sml29623
17043859Sml29623 if (cfg_it == B_TRUE) {
17053859Sml29623 if (pa->value)
17063859Sml29623 status = nxge_fflp_config_hash_lookup_enable(nxgep);
17073859Sml29623 else
17083859Sml29623 status = nxge_fflp_config_hash_lookup_disable(nxgep);
17093859Sml29623 if (status != NXGE_OK)
17103859Sml29623 return (EINVAL);
17113859Sml29623 }
17123859Sml29623
17133859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_hash_lookup_enable"));
17143859Sml29623 return (0);
17153859Sml29623 }
17163859Sml29623
17173859Sml29623 /* ARGSUSED */
17183859Sml29623 static int
nxge_param_llc_snap_enable(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)17193859Sml29623 nxge_param_llc_snap_enable(p_nxge_t nxgep, queue_t *q,
17203859Sml29623 mblk_t *mp, char *value, caddr_t cp)
17213859Sml29623 {
17223859Sml29623 char *end;
17233859Sml29623 uint32_t status = 0, cfg_value;
17243859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
17253859Sml29623 uint32_t cfg_it = B_FALSE;
17263859Sml29623
17273859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_llc_snap_enable"));
17283859Sml29623
17293859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_BINARY);
17303859Sml29623 if (pa->value != cfg_value) {
17313859Sml29623 pa->old_value = pa->value;
17323859Sml29623 pa->value = cfg_value;
17333859Sml29623 cfg_it = B_TRUE;
17343859Sml29623 }
17353859Sml29623
17363859Sml29623 if (cfg_it == B_TRUE) {
17373859Sml29623 if (pa->value)
17383859Sml29623 status = nxge_fflp_config_tcam_enable(nxgep);
17393859Sml29623 else
17403859Sml29623 status = nxge_fflp_config_tcam_disable(nxgep);
17413859Sml29623 if (status != NXGE_OK)
17423859Sml29623 return (EINVAL);
17433859Sml29623 }
17443859Sml29623
17453859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_llc_snap_enable"));
17463859Sml29623 return (0);
17473859Sml29623 }
17483859Sml29623
17493859Sml29623 /* ARGSUSED */
17503859Sml29623 static int
nxge_param_set_ether_usr(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)17513859Sml29623 nxge_param_set_ether_usr(p_nxge_t nxgep, queue_t *q,
17523859Sml29623 mblk_t *mp, char *value, caddr_t cp)
17533859Sml29623 {
17543859Sml29623 char *end;
17553859Sml29623 uint8_t ether_class;
17563859Sml29623 uint32_t status = 0, cfg_value;
17573859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
17583859Sml29623 uint8_t cfg_it = B_FALSE;
17593859Sml29623
17603859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ether_usr"));
17613859Sml29623
17623859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
17633859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
17643859Sml29623 return (EINVAL);
17653859Sml29623 }
17663859Sml29623
17673859Sml29623 if (pa->value != cfg_value) {
17683859Sml29623 pa->old_value = pa->value;
17693859Sml29623 pa->value = cfg_value;
17703859Sml29623 cfg_it = B_TRUE;
17713859Sml29623 }
17723859Sml29623
17733859Sml29623 /* do the actual hw setup */
17743859Sml29623 if (cfg_it == B_TRUE) {
17753859Sml29623 ether_class = mi_strtol(pa->name, &end, 10);
17763859Sml29623 #ifdef lint
17773859Sml29623 ether_class = ether_class;
17783859Sml29623 #endif
17793859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " nxge_param_set_ether_usr"));
17803859Sml29623 }
17813859Sml29623
17823859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ether_usr"));
17833859Sml29623 return (status);
17843859Sml29623 }
17853859Sml29623
17863859Sml29623 /* ARGSUSED */
17873859Sml29623 static int
nxge_param_set_ip_usr(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)17883859Sml29623 nxge_param_set_ip_usr(p_nxge_t nxgep, queue_t *q,
17893859Sml29623 mblk_t *mp, char *value, caddr_t cp)
17903859Sml29623 {
17913859Sml29623 char *end;
17923859Sml29623 tcam_class_t class;
17933859Sml29623 uint32_t status, cfg_value;
17943859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
17953859Sml29623 uint32_t cfg_it = B_FALSE;
17963859Sml29623
17973859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ip_usr"));
17983859Sml29623
17993859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
18003859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
18013859Sml29623 return (EINVAL);
18023859Sml29623 }
18033859Sml29623
18043859Sml29623 if (pa->value != cfg_value) {
18053859Sml29623 pa->old_value = pa->value;
18063859Sml29623 pa->value = cfg_value;
18073859Sml29623 cfg_it = B_TRUE;
18083859Sml29623 }
18093859Sml29623
18103859Sml29623 /* do the actual hw setup with cfg_value. */
18113859Sml29623 if (cfg_it == B_TRUE) {
18123859Sml29623 class = mi_strtol(pa->name, &end, 10);
18133859Sml29623 status = nxge_fflp_ip_usr_class_config(nxgep, class, pa->value);
18143859Sml29623 }
18153859Sml29623
18163859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ip_usr"));
18173859Sml29623 return (status);
18183859Sml29623 }
18193859Sml29623
18203859Sml29623 /* ARGSUSED */
18213859Sml29623 static int
nxge_class_name_2value(p_nxge_t nxgep,char * name)18223859Sml29623 nxge_class_name_2value(p_nxge_t nxgep, char *name)
18233859Sml29623 {
18243859Sml29623 int i;
18253859Sml29623 int class_instance = param_class_opt_ip_usr4;
18263859Sml29623 p_nxge_param_t param_arr;
18273859Sml29623
18283859Sml29623 param_arr = nxgep->param_arr;
18293859Sml29623 for (i = TCAM_CLASS_IP_USER_4; i <= TCAM_CLASS_SCTP_IPV6; i++) {
18303859Sml29623 if (strcmp(param_arr[class_instance].name, name) == 0)
18313859Sml29623 return (i);
18323859Sml29623 class_instance++;
18333859Sml29623 }
18343859Sml29623 return (-1);
18353859Sml29623 }
18363859Sml29623
18373859Sml29623 /* ARGSUSED */
18386439Sml29623 int
nxge_param_set_ip_opt(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)18393859Sml29623 nxge_param_set_ip_opt(p_nxge_t nxgep, queue_t *q,
18403859Sml29623 mblk_t *mp, char *value, caddr_t cp)
18413859Sml29623 {
18423859Sml29623 char *end;
18433859Sml29623 uint32_t status, cfg_value;
18443859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
18453859Sml29623 tcam_class_t class;
18463859Sml29623 uint32_t cfg_it = B_FALSE;
18473859Sml29623
18483859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_ip_opt"));
18493859Sml29623
18503859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
18513859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
18523859Sml29623 return (EINVAL);
18533859Sml29623 }
18543859Sml29623
18553859Sml29623 if (pa->value != cfg_value) {
18563859Sml29623 pa->old_value = pa->value;
18573859Sml29623 pa->value = cfg_value;
18583859Sml29623 cfg_it = B_TRUE;
18593859Sml29623 }
18603859Sml29623
18613859Sml29623 if (cfg_it == B_TRUE) {
18623859Sml29623 /* do the actual hw setup */
18633859Sml29623 class = nxge_class_name_2value(nxgep, pa->name);
18643859Sml29623 if (class == -1)
18653859Sml29623 return (EINVAL);
18663859Sml29623
1867*9005SSantwona.Behera@Sun.COM /* Filter out the allowed bits */
1868*9005SSantwona.Behera@Sun.COM pa->value &= (NXGE_CLASS_FLOW_USE_PORTNUM |
1869*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_L2DA | NXGE_CLASS_FLOW_USE_VLAN |
1870*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_PROTO | NXGE_CLASS_FLOW_USE_IPSRC |
1871*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_IPDST | NXGE_CLASS_FLOW_USE_SRC_PORT |
1872*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_DST_PORT);
1873*9005SSantwona.Behera@Sun.COM
18743859Sml29623 status = nxge_fflp_ip_class_config(nxgep, class, pa->value);
18753859Sml29623 if (status != NXGE_OK)
18763859Sml29623 return (EINVAL);
18773859Sml29623 }
18783859Sml29623
18793859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_ip_opt"));
18803859Sml29623 return (0);
18813859Sml29623 }
18823859Sml29623
18833859Sml29623 /* ARGSUSED */
18843859Sml29623 static int
nxge_param_get_ip_opt(p_nxge_t nxgep,queue_t * q,mblk_t * mp,caddr_t cp)18853859Sml29623 nxge_param_get_ip_opt(p_nxge_t nxgep, queue_t *q,
18863859Sml29623 mblk_t *mp, caddr_t cp)
18873859Sml29623 {
18883859Sml29623 uint32_t status, cfg_value;
18893859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
18903859Sml29623 tcam_class_t class;
18913859Sml29623
18923859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_ip_opt"));
18933859Sml29623
18943859Sml29623 /* do the actual hw setup */
18953859Sml29623 class = nxge_class_name_2value(nxgep, pa->name);
18963859Sml29623 if (class == -1)
18973859Sml29623 return (EINVAL);
18983859Sml29623
18993859Sml29623 cfg_value = 0;
19003859Sml29623 status = nxge_fflp_ip_class_config_get(nxgep, class, &cfg_value);
19013859Sml29623 if (status != NXGE_OK)
19023859Sml29623 return (EINVAL);
19033859Sml29623
1904*9005SSantwona.Behera@Sun.COM /* Filter out the allowed bits */
1905*9005SSantwona.Behera@Sun.COM cfg_value &= (NXGE_CLASS_FLOW_USE_PORTNUM | NXGE_CLASS_FLOW_USE_L2DA |
1906*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_VLAN | NXGE_CLASS_FLOW_USE_PROTO |
1907*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_IPSRC | NXGE_CLASS_FLOW_USE_IPDST |
1908*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_SRC_PORT | NXGE_CLASS_FLOW_USE_DST_PORT);
1909*9005SSantwona.Behera@Sun.COM
19103859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
19116512Ssowmini "nxge_param_get_ip_opt_get %x ", cfg_value));
19123859Sml29623
19133859Sml29623 pa->value = cfg_value;
19143859Sml29623 (void) mi_mpprintf(mp, "%x", cfg_value);
19153859Sml29623
19163859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_ip_opt status "));
19173859Sml29623 return (0);
19183859Sml29623 }
19193859Sml29623
19203859Sml29623 /* ARGSUSED */
19213859Sml29623 static int
nxge_param_fflp_hash_init(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)19223859Sml29623 nxge_param_fflp_hash_init(p_nxge_t nxgep, queue_t *q,
19233859Sml29623 mblk_t *mp, char *value, caddr_t cp)
19243859Sml29623 {
19253859Sml29623 char *end;
19263859Sml29623 uint32_t status, cfg_value;
19273859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
19283859Sml29623 tcam_class_t class;
19293859Sml29623 uint32_t cfg_it = B_FALSE;
19303859Sml29623
19313859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_fflp_hash_init"));
19323859Sml29623
19333859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_HEX);
19343859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
19353859Sml29623 return (EINVAL);
19363859Sml29623 }
19373859Sml29623
19383859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
19396512Ssowmini "nxge_param_fflp_hash_init value %x", cfg_value));
19403859Sml29623
19413859Sml29623 if (pa->value != cfg_value) {
19423859Sml29623 pa->old_value = pa->value;
19433859Sml29623 pa->value = cfg_value;
19443859Sml29623 cfg_it = B_TRUE;
19453859Sml29623 }
19463859Sml29623
19473859Sml29623 if (cfg_it == B_TRUE) {
19483859Sml29623 char *h_name;
19493859Sml29623
19503859Sml29623 /* do the actual hw setup */
19513859Sml29623 h_name = pa->name;
19523859Sml29623 h_name++;
19533859Sml29623 class = mi_strtol(h_name, &end, 10);
19543859Sml29623 switch (class) {
19553859Sml29623 case 1:
19563859Sml29623 status = nxge_fflp_set_hash1(nxgep,
19576512Ssowmini (uint32_t)pa->value);
19583859Sml29623 break;
19593859Sml29623 case 2:
19603859Sml29623 status = nxge_fflp_set_hash2(nxgep,
19616512Ssowmini (uint16_t)pa->value);
19623859Sml29623 break;
19633859Sml29623
19643859Sml29623 default:
19653859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
19666512Ssowmini " nxge_param_fflp_hash_init"
19676512Ssowmini " %s Wrong hash var %d",
19686512Ssowmini pa->name, class));
19693859Sml29623 return (EINVAL);
19703859Sml29623 }
19713859Sml29623 if (status != NXGE_OK)
19723859Sml29623 return (EINVAL);
19733859Sml29623 }
19743859Sml29623
19753859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " <== nxge_param_fflp_hash_init"));
19763859Sml29623 return (0);
19773859Sml29623 }
19783859Sml29623
19793859Sml29623 /* ARGSUSED */
19803859Sml29623 static int
nxge_param_set_grp_rdc(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)19813859Sml29623 nxge_param_set_grp_rdc(p_nxge_t nxgep, queue_t *q,
19823859Sml29623 mblk_t *mp, char *value, caddr_t cp)
19833859Sml29623 {
19843859Sml29623 char *end;
19853859Sml29623 uint32_t status = 0, cfg_value;
19863859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
19873859Sml29623 uint32_t cfg_it = B_FALSE;
19883859Sml29623 int rdc_grp;
19893859Sml29623 uint8_t real_rdc;
19903859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
19913859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
19923859Sml29623 p_nxge_rdc_grp_t rdc_grp_p;
19933859Sml29623
19943859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
19953859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
19963859Sml29623
19973859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_grp_rdc"));
19983859Sml29623
19993859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
20003859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
20013859Sml29623 return (EINVAL);
20023859Sml29623 }
20033859Sml29623
20043859Sml29623 if (cfg_value >= p_cfgp->max_rdcs) {
20053859Sml29623 return (EINVAL);
20063859Sml29623 }
20073859Sml29623
20083859Sml29623 if (pa->value != cfg_value) {
20093859Sml29623 pa->old_value = pa->value;
20103859Sml29623 pa->value = cfg_value;
20113859Sml29623 cfg_it = B_TRUE;
20123859Sml29623 }
20133859Sml29623
20143859Sml29623 if (cfg_it == B_TRUE) {
20153859Sml29623 char *grp_name;
20163859Sml29623 grp_name = pa->name;
20173859Sml29623 grp_name += strlen("default-grp");
20183859Sml29623 rdc_grp = mi_strtol(grp_name, &end, 10);
20193859Sml29623 rdc_grp_p = &p_dma_cfgp->rdc_grps[rdc_grp];
20203859Sml29623 real_rdc = rdc_grp_p->start_rdc + cfg_value;
20213859Sml29623 if (nxge_check_rxdma_rdcgrp_member(nxgep, rdc_grp,
20226512Ssowmini cfg_value) == B_FALSE) {
20233859Sml29623 pa->value = pa->old_value;
20243859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
20256512Ssowmini " nxge_param_set_grp_rdc"
20266512Ssowmini " %d read %d actual %d outof range",
20276512Ssowmini rdc_grp, cfg_value, real_rdc));
20283859Sml29623 return (EINVAL);
20293859Sml29623 }
20303859Sml29623 status = nxge_rxdma_cfg_rdcgrp_default_rdc(nxgep, rdc_grp,
20316512Ssowmini real_rdc);
20323859Sml29623 if (status != NXGE_OK)
20333859Sml29623 return (EINVAL);
20343859Sml29623 }
20353859Sml29623
20363859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_grp_rdc"));
20373859Sml29623 return (0);
20383859Sml29623 }
20393859Sml29623
20403859Sml29623 /* ARGSUSED */
20413859Sml29623 static int
nxge_param_set_port_rdc(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)20423859Sml29623 nxge_param_set_port_rdc(p_nxge_t nxgep, queue_t *q,
20433859Sml29623 mblk_t *mp, char *value, caddr_t cp)
20443859Sml29623 {
20453859Sml29623 char *end;
20463859Sml29623 uint32_t status = B_TRUE, cfg_value;
20473859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
20483859Sml29623 uint32_t cfg_it = B_FALSE;
20493859Sml29623
20503859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
20513859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
20523859Sml29623
20533859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_port_rdc"));
20543859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
20553859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
20563859Sml29623
20573859Sml29623 cfg_value = (uint32_t)mi_strtol(value, &end, BASE_ANY);
20583859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
20593859Sml29623 return (EINVAL);
20603859Sml29623 }
20613859Sml29623
20623859Sml29623 if (pa->value != cfg_value) {
20633859Sml29623 if (cfg_value >= p_cfgp->max_rdcs)
20643859Sml29623 return (EINVAL);
20653859Sml29623 pa->old_value = pa->value;
20663859Sml29623 pa->value = cfg_value;
20673859Sml29623 cfg_it = B_TRUE;
20683859Sml29623 }
20693859Sml29623
20703859Sml29623 if (cfg_it == B_TRUE) {
20716495Sspeer int rdc;
20726495Sspeer if ((rdc = nxge_dci_map(nxgep, VP_BOUND_RX, cfg_value)) < 0)
20736495Sspeer return (EINVAL);
20743859Sml29623 status = nxge_rxdma_cfg_port_default_rdc(nxgep,
20756495Sspeer nxgep->function_num, rdc);
20763859Sml29623 if (status != NXGE_OK)
20773859Sml29623 return (EINVAL);
20783859Sml29623 }
20793859Sml29623
20803859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_port_rdc"));
20813859Sml29623 return (0);
20823859Sml29623 }
20833859Sml29623
20843859Sml29623 /* ARGSUSED */
20853859Sml29623 static int
nxge_param_set_nxge_debug_flag(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)20863859Sml29623 nxge_param_set_nxge_debug_flag(p_nxge_t nxgep, queue_t *q,
20873859Sml29623 mblk_t *mp, char *value, caddr_t cp)
20883859Sml29623 {
20893859Sml29623 char *end;
20903859Sml29623 uint32_t status = 0;
20913859Sml29623 uint64_t cfg_value = 0;
20923859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
20933859Sml29623 uint32_t cfg_it = B_FALSE;
20943859Sml29623
20953859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_nxge_debug_flag"));
20963859Sml29623 cfg_value = mi_strtol(value, &end, BASE_HEX);
20973859Sml29623
20983859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
20993859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
21006512Ssowmini " nxge_param_set_nxge_debug_flag"
21016512Ssowmini " outof range %llx", cfg_value));
21023859Sml29623 return (EINVAL);
21033859Sml29623 }
21043859Sml29623 if (pa->value != cfg_value) {
21053859Sml29623 pa->old_value = pa->value;
21063859Sml29623 pa->value = cfg_value;
21073859Sml29623 cfg_it = B_TRUE;
21083859Sml29623 }
21093859Sml29623
21103859Sml29623 if (cfg_it == B_TRUE) {
21113859Sml29623 nxgep->nxge_debug_level = pa->value;
21123859Sml29623 }
21133859Sml29623
21143859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_nxge_debug_flag"));
21153859Sml29623 return (status);
21163859Sml29623 }
21173859Sml29623
21183859Sml29623 /* ARGSUSED */
21193859Sml29623 static int
nxge_param_get_debug_flag(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)21203859Sml29623 nxge_param_get_debug_flag(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
21213859Sml29623 {
21223859Sml29623 int status = 0;
21233859Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
21243859Sml29623
21253859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_get_debug_flag"));
21263859Sml29623
21273859Sml29623 if (pa->value > 0xffffffff)
21283859Sml29623 (void) mi_mpprintf(mp, "%x%x", (int)(pa->value >> 32),
21296512Ssowmini (int)(pa->value & 0xffffffff));
21303859Sml29623 else
21313859Sml29623 (void) mi_mpprintf(mp, "%x", (int)pa->value);
21323859Sml29623
21333859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_debug_flag"));
21343859Sml29623 return (status);
21353859Sml29623 }
21363859Sml29623
21373859Sml29623 /* ARGSUSED */
21383859Sml29623 static int
nxge_param_set_npi_debug_flag(p_nxge_t nxgep,queue_t * q,mblk_t * mp,char * value,caddr_t cp)21393859Sml29623 nxge_param_set_npi_debug_flag(p_nxge_t nxgep, queue_t *q,
21403859Sml29623 mblk_t *mp, char *value, caddr_t cp)
21413859Sml29623 {
21423859Sml29623 char *end;
21433859Sml29623 uint32_t status = 0;
21443859Sml29623 uint64_t cfg_value = 0;
21453859Sml29623 p_nxge_param_t pa;
21463859Sml29623 uint32_t cfg_it = B_FALSE;
21473859Sml29623
21483859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_set_npi_debug_flag"));
21493859Sml29623 cfg_value = mi_strtol(value, &end, BASE_HEX);
21503859Sml29623 pa = (p_nxge_param_t)cp;
21513859Sml29623 if (PARAM_OUTOF_RANGE(value, end, cfg_value, pa)) {
21523859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, " nxge_param_set_npi_debug_flag"
21536512Ssowmini " outof range %llx", cfg_value));
21543859Sml29623 return (EINVAL);
21553859Sml29623 }
21563859Sml29623 if (pa->value != cfg_value) {
21573859Sml29623 pa->old_value = pa->value;
21583859Sml29623 pa->value = cfg_value;
21593859Sml29623 cfg_it = B_TRUE;
21603859Sml29623 }
21613859Sml29623
21623859Sml29623 if (cfg_it == B_TRUE) {
21633859Sml29623 npi_debug_level = pa->value;
21643859Sml29623 }
21653859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_set_debug_flag"));
21663859Sml29623 return (status);
21673859Sml29623 }
21683859Sml29623
21693859Sml29623 /* ARGSUSED */
21703859Sml29623 static int
nxge_param_dump_rdc(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)21713859Sml29623 nxge_param_dump_rdc(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
21723859Sml29623 {
21736495Sspeer nxge_grp_set_t *set = &nxgep->rx_set;
21746495Sspeer int rdc;
21753859Sml29623
21763859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_rdc"));
21773859Sml29623
21786495Sspeer if (!isLDOMguest(nxgep))
21796512Ssowmini (void) npi_rxdma_dump_fzc_regs(NXGE_DEV_NPI_HANDLE(nxgep));
21806495Sspeer
21816495Sspeer for (rdc = 0; rdc < NXGE_MAX_TDCS; rdc++) {
21826495Sspeer if ((1 << rdc) & set->owned.map) {
21836495Sspeer (void) nxge_dump_rxdma_channel(nxgep, rdc);
21846495Sspeer }
21856495Sspeer }
21863859Sml29623
21873859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_rdc"));
21883859Sml29623 return (0);
21893859Sml29623 }
21903859Sml29623
21913859Sml29623 /* ARGSUSED */
21923859Sml29623 static int
nxge_param_dump_tdc(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)21933859Sml29623 nxge_param_dump_tdc(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
21943859Sml29623 {
21956495Sspeer nxge_grp_set_t *set = &nxgep->tx_set;
21966495Sspeer int tdc;
21973859Sml29623
21983859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_tdc"));
21993859Sml29623
22006495Sspeer for (tdc = 0; tdc < NXGE_MAX_TDCS; tdc++) {
22016495Sspeer if ((1 << tdc) & set->owned.map) {
22026495Sspeer (void) nxge_txdma_regs_dump(nxgep, tdc);
22036495Sspeer }
22046495Sspeer }
22053859Sml29623
22063859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_tdc"));
22073859Sml29623 return (0);
22083859Sml29623 }
22093859Sml29623
22103859Sml29623 /* ARGSUSED */
22113859Sml29623 static int
nxge_param_dump_fflp_regs(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)22123859Sml29623 nxge_param_dump_fflp_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
22133859Sml29623 {
22143859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_fflp_regs"));
22153859Sml29623
22163859Sml29623 (void) npi_fflp_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep));
22173859Sml29623
22183859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_fflp_regs"));
22193859Sml29623 return (0);
22203859Sml29623 }
22213859Sml29623
22223859Sml29623 /* ARGSUSED */
22233859Sml29623 static int
nxge_param_dump_mac_regs(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)22243859Sml29623 nxge_param_dump_mac_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
22253859Sml29623 {
22263859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_mac_regs"));
22273859Sml29623
22283859Sml29623 (void) npi_mac_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep),
22296512Ssowmini nxgep->function_num);
22303859Sml29623
22313859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_mac_regs"));
22323859Sml29623 return (0);
22333859Sml29623 }
22343859Sml29623
22353859Sml29623 /* ARGSUSED */
22363859Sml29623 static int
nxge_param_dump_ipp_regs(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)22373859Sml29623 nxge_param_dump_ipp_regs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
22383859Sml29623 {
22393859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_param_dump_ipp_regs"));
22403859Sml29623
22413859Sml29623 (void) npi_ipp_dump_regs(NXGE_DEV_NPI_HANDLE(nxgep),
22426512Ssowmini nxgep->function_num);
22433859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_ipp_regs"));
22443859Sml29623 return (0);
22453859Sml29623 }
22463859Sml29623
22473859Sml29623 /* ARGSUSED */
22483859Sml29623 static int
nxge_param_dump_vlan_table(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)22493859Sml29623 nxge_param_dump_vlan_table(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
22503859Sml29623 {
22513859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_dump_vlan_table"));
22523859Sml29623
22533859Sml29623 (void) npi_fflp_vlan_tbl_dump(NXGE_DEV_NPI_HANDLE(nxgep));
22543859Sml29623
22553859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_dump_vlan_table"));
22563859Sml29623 return (0);
22573859Sml29623 }
22583859Sml29623
22593859Sml29623 /* ARGSUSED */
22603859Sml29623 static int
nxge_param_dump_rdc_table(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)22613859Sml29623 nxge_param_dump_rdc_table(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
22623859Sml29623 {
22633859Sml29623 uint8_t table;
22643859Sml29623
22653859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_dump_rdc_table"));
22663859Sml29623 for (table = 0; table < NXGE_MAX_RDC_GROUPS; table++) {
22673859Sml29623 (void) npi_rxdma_dump_rdc_table(NXGE_DEV_NPI_HANDLE(nxgep),
22686512Ssowmini table);
22693859Sml29623 }
22703859Sml29623
22713859Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_dump_rdc_table"));
22723859Sml29623 return (0);
22733859Sml29623 }
22743859Sml29623
22753859Sml29623 typedef struct block_info {
22763859Sml29623 char *name;
22773859Sml29623 uint32_t offset;
22783859Sml29623 } block_info_t;
22793859Sml29623
22803859Sml29623 block_info_t reg_block[] = {
22813859Sml29623 {"PIO", PIO},
22823859Sml29623 {"FZC_PIO", FZC_PIO},
22833859Sml29623 {"FZC_XMAC", FZC_MAC},
22843859Sml29623 {"FZC_IPP", FZC_IPP},
22853859Sml29623 {"FFLP", FFLP},
22863859Sml29623 {"FZC_FFLP", FZC_FFLP},
22873859Sml29623 {"PIO_VADDR", PIO_VADDR},
22883859Sml29623 {"ZCP", ZCP},
22893859Sml29623 {"FZC_ZCP", FZC_ZCP},
22903859Sml29623 {"DMC", DMC},
22913859Sml29623 {"FZC_DMC", FZC_DMC},
22923859Sml29623 {"TXC", TXC},
22933859Sml29623 {"FZC_TXC", FZC_TXC},
22943859Sml29623 {"PIO_LDSV", PIO_LDSV},
22953859Sml29623 {"PIO_LDGIM", PIO_LDGIM},
22963859Sml29623 {"PIO_IMASK0", PIO_IMASK0},
22973859Sml29623 {"PIO_IMASK1", PIO_IMASK1},
22983859Sml29623 {"FZC_PROM", FZC_PROM},
22993859Sml29623 {"END", ALL_FF_32},
23003859Sml29623 };
23013859Sml29623
23023859Sml29623 /* ARGSUSED */
23033859Sml29623 static int
nxge_param_dump_ptrs(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t cp)23043859Sml29623 nxge_param_dump_ptrs(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t cp)
23053859Sml29623 {
23063859Sml29623 uint_t print_len, buf_len;
23073859Sml29623 p_mblk_t np;
23083859Sml29623 int rdc, tdc, block;
23093859Sml29623 uint64_t base;
23103859Sml29623 p_nxge_dma_pt_cfg_t p_dma_cfgp;
23113859Sml29623 p_nxge_hw_pt_cfg_t p_cfgp;
23123859Sml29623 int buff_alloc_size = NXGE_NDD_INFODUMP_BUFF_8K;
23133859Sml29623 p_tx_ring_t *tx_rings;
23143859Sml29623 p_rx_rcr_rings_t rx_rcr_rings;
23153859Sml29623 p_rx_rcr_ring_t *rcr_rings;
23163859Sml29623 p_rx_rbr_rings_t rx_rbr_rings;
23173859Sml29623 p_rx_rbr_ring_t *rbr_rings;
23183859Sml29623
23193859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL,
23206512Ssowmini "==> nxge_param_dump_ptrs"));
23213859Sml29623
23223859Sml29623 (void) mi_mpprintf(mp, "ptr information for Port\t %d \n",
23236512Ssowmini nxgep->function_num);
23243859Sml29623
23253859Sml29623 if ((np = allocb(buff_alloc_size, BPRI_HI)) == NULL) {
23263859Sml29623 /* The following may work even if we cannot get a large buf. */
23273859Sml29623 (void) mi_mpprintf(mp, "%s\n", "out of buffer");
23283859Sml29623 return (0);
23293859Sml29623 }
23303859Sml29623
23313859Sml29623 buf_len = buff_alloc_size;
23323859Sml29623 mp->b_cont = np;
23333859Sml29623 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config;
23343859Sml29623 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
23353859Sml29623
23363859Sml29623 rx_rcr_rings = nxgep->rx_rcr_rings;
23373859Sml29623 rcr_rings = rx_rcr_rings->rcr_rings;
23383859Sml29623 rx_rbr_rings = nxgep->rx_rbr_rings;
23393859Sml29623 rbr_rings = rx_rbr_rings->rbr_rings;
23403859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
23416512Ssowmini "nxgep (nxge_t) $%p\n"
23426512Ssowmini "dev_regs (dev_regs_t) $%p\n",
23437632SNick.Todd@Sun.COM (void *)nxgep, (void *)nxgep->dev_regs);
23443859Sml29623
23453859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
23463859Sml29623
23473859Sml29623 /* do register pointers */
23483859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
23496512Ssowmini "reg base (npi_reg_ptr_t) $%p\t "
23506512Ssowmini "pci reg (npi_reg_ptr_t) $%p\n",
23517632SNick.Todd@Sun.COM (void *)nxgep->dev_regs->nxge_regp,
23527632SNick.Todd@Sun.COM (void *)nxgep->dev_regs->nxge_pciregp);
23533859Sml29623
23543859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
23553859Sml29623
23563859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
23576512Ssowmini "\nBlock \t Offset \n");
23583859Sml29623
23593859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
23603859Sml29623 block = 0;
23615125Sjoycey #if defined(__i386)
23625125Sjoycey base = (uint64_t)(uint32_t)nxgep->dev_regs->nxge_regp;
23635125Sjoycey #else
23643859Sml29623 base = (uint64_t)nxgep->dev_regs->nxge_regp;
23655125Sjoycey #endif
23663859Sml29623 while (reg_block[block].offset != ALL_FF_32) {
23673859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
23686512Ssowmini "%9s\t 0x%llx\n",
23696512Ssowmini reg_block[block].name,
23706512Ssowmini (unsigned long long)(reg_block[block].offset + base));
23713859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
23723859Sml29623 block++;
23733859Sml29623 }
23743859Sml29623
23753859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
23766512Ssowmini "\nRDC\t rcrp (rx_rcr_ring_t)\t "
23776512Ssowmini "rbrp (rx_rbr_ring_t)\n");
23783859Sml29623
23793859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
23803859Sml29623
23813859Sml29623 for (rdc = 0; rdc < p_cfgp->max_rdcs; rdc++) {
23823859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
23836512Ssowmini " %d\t $%p\t\t $%p\n",
23847632SNick.Todd@Sun.COM rdc, (void *)rcr_rings[rdc],
23857632SNick.Todd@Sun.COM (void *)rbr_rings[rdc]);
23863859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
23873859Sml29623 }
23883859Sml29623
23893859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
23906512Ssowmini "\nTDC\t tdcp (tx_ring_t)\n");
23913859Sml29623
23923859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
23933859Sml29623 tx_rings = nxgep->tx_rings->rings;
23946495Sspeer for (tdc = 0; tdc < p_cfgp->tdc.count; tdc++) {
23953859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len,
23967632SNick.Todd@Sun.COM " %d\t $%p\n", tdc, (void *)tx_rings[tdc]);
23973859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
23983859Sml29623 }
23993859Sml29623
24003859Sml29623 print_len = snprintf((char *)((mblk_t *)np)->b_wptr, buf_len, "\n\n");
24013859Sml29623
24023859Sml29623 ADVANCE_PRINT_BUFFER(np, print_len, buf_len);
24033859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_param_dump_ptrs"));
24043859Sml29623 return (0);
24053859Sml29623 }
24063859Sml29623
24073859Sml29623
24083859Sml29623 /* ARGSUSED */
24093859Sml29623 int
nxge_nd_get_names(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t param)24103859Sml29623 nxge_nd_get_names(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t param)
24113859Sml29623 {
24123859Sml29623 ND *nd;
24133859Sml29623 NDE *nde;
24143859Sml29623 char *rwtag;
24153859Sml29623 boolean_t get_ok, set_ok;
24163859Sml29623 size_t param_len;
24173859Sml29623 int status = 0;
24183859Sml29623
24193859Sml29623 nd = (ND *)param;
24203859Sml29623 if (!nd)
24213859Sml29623 return (ENOENT);
24223859Sml29623
24233859Sml29623 for (nde = nd->nd_tbl; nde->nde_name; nde++) {
24243859Sml29623 get_ok = (nde->nde_get_pfi != nxge_get_default) &&
24256512Ssowmini (nde->nde_get_pfi != NULL);
24263859Sml29623 set_ok = (nde->nde_set_pfi != nxge_set_default) &&
24276512Ssowmini (nde->nde_set_pfi != NULL);
24283859Sml29623 if (get_ok) {
24293859Sml29623 if (set_ok)
24303859Sml29623 rwtag = "read and write";
24313859Sml29623 else
24323859Sml29623 rwtag = "read only";
24333859Sml29623 } else if (set_ok)
24343859Sml29623 rwtag = "write only";
24353859Sml29623 else {
24363859Sml29623 continue;
24373859Sml29623 }
24383859Sml29623 param_len = strlen(rwtag);
24393859Sml29623 param_len += strlen(nde->nde_name);
24403859Sml29623 param_len += 4;
24413859Sml29623
24423859Sml29623 (void) mi_mpprintf(mp, "%s (%s)", nde->nde_name, rwtag);
24433859Sml29623 }
24443859Sml29623 return (status);
24453859Sml29623 }
24463859Sml29623
24473859Sml29623 /* ARGSUSED */
24483859Sml29623 int
nxge_get_default(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,caddr_t data)24493859Sml29623 nxge_get_default(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, caddr_t data)
24503859Sml29623 {
24513859Sml29623 return (EACCES);
24523859Sml29623 }
24533859Sml29623
24543859Sml29623 /* ARGSUSED */
24553859Sml29623 int
nxge_set_default(p_nxge_t nxgep,queue_t * q,p_mblk_t mp,char * value,caddr_t data)24563859Sml29623 nxge_set_default(p_nxge_t nxgep, queue_t *q, p_mblk_t mp, char *value,
24573859Sml29623 caddr_t data)
24583859Sml29623 {
24593859Sml29623 return (EACCES);
24603859Sml29623 }
24613859Sml29623
24626439Sml29623 boolean_t
nxge_param_link_update(p_nxge_t nxgep)24633859Sml29623 nxge_param_link_update(p_nxge_t nxgep)
24643859Sml29623 {
24653859Sml29623 p_nxge_param_t param_arr;
24663859Sml29623 nxge_param_index_t i;
24673859Sml29623 boolean_t update_xcvr;
24683859Sml29623 boolean_t update_dev;
24693859Sml29623 int instance;
24703859Sml29623 boolean_t status = B_TRUE;
24713859Sml29623
24726439Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_param_link_update"));
24733859Sml29623
24743859Sml29623 param_arr = nxgep->param_arr;
24753859Sml29623 instance = nxgep->instance;
24763859Sml29623 update_xcvr = B_FALSE;
24773859Sml29623 for (i = param_anar_1000fdx; i < param_anar_asmpause; i++) {
24783859Sml29623 update_xcvr |= param_arr[i].value;
24793859Sml29623 }
24803859Sml29623
24813859Sml29623 if (update_xcvr) {
24823859Sml29623 update_xcvr = B_FALSE;
24833859Sml29623 for (i = param_autoneg; i < param_enable_ipg0; i++) {
24843859Sml29623 update_xcvr |=
24856512Ssowmini (param_arr[i].value != param_arr[i].old_value);
24863859Sml29623 param_arr[i].old_value = param_arr[i].value;
24873859Sml29623 }
24883859Sml29623 if (update_xcvr) {
24896439Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
24906439Sml29623 "==> nxge_param_link_update: update xcvr"));
24913859Sml29623 RW_ENTER_WRITER(&nxgep->filter_lock);
24923859Sml29623 (void) nxge_link_monitor(nxgep, LINK_MONITOR_STOP);
24933859Sml29623 (void) nxge_link_init(nxgep);
24943859Sml29623 (void) nxge_mac_init(nxgep);
24953859Sml29623 (void) nxge_link_monitor(nxgep, LINK_MONITOR_START);
24963859Sml29623 RW_EXIT(&nxgep->filter_lock);
24973859Sml29623 }
24983859Sml29623 } else {
24993859Sml29623 cmn_err(CE_WARN, " Last setting will leave nxge%d with "
25006512Ssowmini " no link capabilities.", instance);
25013859Sml29623 cmn_err(CE_WARN, " Restoring previous setting.");
25023859Sml29623 for (i = param_anar_1000fdx; i < param_anar_asmpause; i++)
25033859Sml29623 param_arr[i].value = param_arr[i].old_value;
25043859Sml29623 }
25053859Sml29623
25063859Sml29623 update_dev = B_FALSE;
25073859Sml29623
25083859Sml29623 if (update_dev) {
25093859Sml29623 RW_ENTER_WRITER(&nxgep->filter_lock);
25106439Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
25116439Sml29623 "==> nxge_param_link_update: update dev"));
25123859Sml29623 (void) nxge_rx_mac_disable(nxgep);
25133859Sml29623 (void) nxge_tx_mac_disable(nxgep);
25143859Sml29623 (void) nxge_tx_mac_enable(nxgep);
25153859Sml29623 (void) nxge_rx_mac_enable(nxgep);
25163859Sml29623 RW_EXIT(&nxgep->filter_lock);
25173859Sml29623 }
25183859Sml29623
25193859Sml29623 nxge_param_hw_update_exit:
25203859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL,
25216512Ssowmini "<== nxge_param_link_update status = 0x%08x", status));
25223859Sml29623 return (status);
25233859Sml29623 }
25246439Sml29623
25256439Sml29623 /*
25266439Sml29623 * synchronize the adv* and en* parameters.
25276439Sml29623 *
25286439Sml29623 * See comments in <sys/dld.h> for details of the *_en_*
25296439Sml29623 * parameters. The usage of ndd for setting adv parameters will
25306439Sml29623 * synchronize all the en parameters with the nxge parameters,
25316439Sml29623 * implicitly disabling any settings made via dladm.
25326439Sml29623 */
25336439Sml29623 static void
nxge_param_sync(p_nxge_t nxgep)25346439Sml29623 nxge_param_sync(p_nxge_t nxgep)
25356439Sml29623 {
25366439Sml29623 p_nxge_param_t param_arr;
25376439Sml29623 param_arr = nxgep->param_arr;
25386439Sml29623
25396439Sml29623 nxgep->param_en_pause = param_arr[param_anar_pause].value;
25406439Sml29623 nxgep->param_en_1000fdx = param_arr[param_anar_1000fdx].value;
25416439Sml29623 nxgep->param_en_100fdx = param_arr[param_anar_100fdx].value;
25426439Sml29623 nxgep->param_en_10fdx = param_arr[param_anar_10fdx].value;
25436439Sml29623 }
25446439Sml29623
25456439Sml29623 /* ARGSUSED */
25466439Sml29623 int
nxge_dld_get_ip_opt(p_nxge_t nxgep,caddr_t cp)25476439Sml29623 nxge_dld_get_ip_opt(p_nxge_t nxgep, caddr_t cp)
25486439Sml29623 {
25496439Sml29623 uint32_t status, cfg_value;
25506439Sml29623 p_nxge_param_t pa = (p_nxge_param_t)cp;
25516439Sml29623 tcam_class_t class;
25526439Sml29623
25536439Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "==> nxge_dld_get_ip_opt"));
25546439Sml29623
25556439Sml29623 /* do the actual hw setup */
25566439Sml29623 class = nxge_class_name_2value(nxgep, pa->name);
25576439Sml29623 if (class == -1)
25586439Sml29623 return (EINVAL);
25596439Sml29623
25606439Sml29623 cfg_value = 0;
25616439Sml29623 status = nxge_fflp_ip_class_config_get(nxgep, class, &cfg_value);
25626439Sml29623 if (status != NXGE_OK)
25636439Sml29623 return (EINVAL);
25646439Sml29623
2565*9005SSantwona.Behera@Sun.COM /* Filter out the allowed bits */
2566*9005SSantwona.Behera@Sun.COM cfg_value &= (NXGE_CLASS_FLOW_USE_PORTNUM | NXGE_CLASS_FLOW_USE_L2DA |
2567*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_VLAN | NXGE_CLASS_FLOW_USE_PROTO |
2568*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_IPSRC | NXGE_CLASS_FLOW_USE_IPDST |
2569*9005SSantwona.Behera@Sun.COM NXGE_CLASS_FLOW_USE_SRC_PORT | NXGE_CLASS_FLOW_USE_DST_PORT);
2570*9005SSantwona.Behera@Sun.COM
25716439Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL,
25726439Sml29623 "nxge_param_get_ip_opt_get %x ", cfg_value));
25736439Sml29623
25746439Sml29623 pa->value = cfg_value;
25756439Sml29623
25766439Sml29623 NXGE_DEBUG_MSG((nxgep, NDD_CTL, "<== nxge_param_get_ip_opt status "));
25776439Sml29623 return (0);
25786439Sml29623 }
2579