hxge_vmac.c revision 6afd6cae9f08dc0b5e9999820ce01095af9d2eab
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * CDDL HEADER START
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * The contents of this file are subject to the terms of the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Common Development and Distribution License (the "License").
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * You may not use this file except in compliance with the License.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * See the License for the specific language governing permissions
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * and limitations under the License.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * When distributing Covered Code, include this CDDL HEADER in each
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * If applicable, add the following below this CDDL HEADER, with the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * fields enclosed by brackets "[]" replaced with your own identifying
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * information: Portions Copyright [yyyy] [name of copyright owner]
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * CDDL HEADER END
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Use is subject to license terms.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qshxge_status_t hxge_set_promisc(p_hxge_t hxgep, boolean_t on);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * The driver doesn't control the link.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * It is always 10Gb full duplex.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Clear the interrupt status registers */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Take the masks off the overflow counters. Interrupt the system when
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * any counts overflow. Don't interrupt the system for each frame.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * The current counts are retrieved when the "kstat" command is used.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs (void) hpi_pfc_set_rx_int_stat_mask(hxgep->hpi_handle, 0, 1);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs (void) hpi_pfc_set_tx_int_stat_mask(hxgep->hpi_handle, 0, 1);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "hxge_vmac_init: failed to initialize VMAC>"));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Initialize the TxVMAC sub-block */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* CFG_VMAC_TX_EN is done separately */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Initialize the RxVMAC sub-block */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * NOTE: CFG_VMAC_RX_ENABLE is done separately. Do not enable
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * strip CRC. Bug ID 11451 -- enable strip CRC will cause
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * rejection on minimum sized packets.
1c29f7e382074ff2792b7f30c9be898ead487a30Qiyan Sun - Sun Microsystems - San Diego United States xconfig = CFG_VMAC_RX_PASS_FLOW_CTRL_FR;
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (hpi_vmac_rx_config(handle, INIT, xconfig, max_frame_length)
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Enable TxVMAC */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "==> hxge_tx_vmac_enable"));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs return (rv);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Based on speed */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs rv = hpi_vmac_tx_config(handle, ENABLE, CFG_VMAC_TX_EN, 0);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "<== hxge_tx_vmac_enable"));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Disable TxVMAC */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "==> hxge_tx_vmac_disable"));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs rv = hpi_vmac_tx_config(handle, DISABLE, CFG_VMAC_TX_EN, 0);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "<== hxge_tx_vmac_disable"));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Enable RxVMAC */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "==> hxge_rx_vmac_enable"));
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer * Because of hardware bug document with CR6770577, need
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer * reprogram max framesize when enabling/disabling RX
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer * vmac. Max framesize is programed here in
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer * hxge_rx_vmac_init().
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs return (rv);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs rv = hpi_vmac_rx_config(handle, ENABLE, CFG_VMAC_RX_EN, 0);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "<== hxge_rx_vmac_enable"));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Disable RxVMAC */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "==> hxge_rx_vmac_disable"));
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer * Because of hardware bug document with CR6770577, need
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer * reprogram max framesize when enabling/disabling RX
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer * vmac. Max framesize is programed here in
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer * hxge_rx_vmac_init().
6afd6cae9f08dc0b5e9999820ce01095af9d2eabMichael Speer (void) hpi_vmac_rx_set_framesize(HXGE_DEV_HPI_HANDLE(hxgep),
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs rv = hpi_vmac_rx_config(handle, DISABLE, CFG_VMAC_RX_EN, 0);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "<== hxge_rx_vmac_disable"));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Reset TxVMAC */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Reset RxVMAC */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/*ARGSUSED*/
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Clear the interrupt status registers */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Set promiscous mode
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "==> hxge_set_promisc: on %d", on));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_DEBUG_MSG((hxgep, MAC_CTL, "<== hxge_set_promisc"));
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "hxge_set_promisc: "
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_TX_FRAME_CNT, &tx_frame_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_TX_BYTE_CNT, &tx_byte_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_RX_FRAME_CNT, &rx_frame_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_RX_BYTE_CNT, &rx_byte_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_RX_DROP_FR_CNT, &rx_drop_fr_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_RX_DROP_BYTE_CNT, &rx_drop_byte_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_RX_CRC_CNT, &rx_crc_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_RX_PAUSE_CNT, &rx_pause_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_RX_BCAST_FR_CNT, &rx_bcast_fr_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs HXGE_REG_RD64(handle, VMAC_RX_MCAST_FR_CNT, &rx_mcast_fr_cnt.value);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs statsp->vmac_stats.tx_frame_cnt += tx_frame_cnt.bits.tx_frame_cnt;
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs statsp->vmac_stats.tx_byte_cnt += tx_byte_cnt.bits.tx_byte_cnt;
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs statsp->vmac_stats.rx_frame_cnt += rx_frame_cnt.bits.rx_frame_cnt;
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs statsp->vmac_stats.rx_byte_cnt += rx_byte_cnt.bits.rx_byte_cnt;
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs statsp->vmac_stats.rx_crc_cnt += rx_crc_cnt.bits.rx_crc_cnt;
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs statsp->vmac_stats.rx_pause_cnt += rx_pause_cnt.bits.rx_pause_cnt;
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United Stateshxge_vmac_set_framesize(p_hxge_t hxgep)
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States int status = 0;
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States HXGE_DEBUG_MSG((hxgep, NDD_CTL, "==> hxge_vmac_set_framesize"));
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States RW_ENTER_WRITER(&hxgep->filter_lock);
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States (void) hxge_rx_vmac_disable(hxgep);
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States (void) hxge_tx_vmac_disable(hxgep);
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States * Apply the new jumbo parameter here which is contained in hxgep
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States * data structure (hxgep->vmac.maxframesize);
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States * The order of the following two calls is important.
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States (void) hxge_tx_vmac_enable(hxgep);
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States (void) hxge_rx_vmac_enable(hxgep);
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States RW_EXIT(&hxgep->filter_lock);
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States HXGE_DEBUG_MSG((hxgep, NDD_CTL, "<== hxge_vmac_set_framesize"));