c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * CDDL HEADER START
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The contents of this file are subject to the terms of the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common Development and Distribution License (the "License").
c869993e79c1eafbec61a56bf6cea848fe754c71xy * You may not use this file except in compliance with the License.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * or http://www.opensolaris.org/os/licensing.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * See the License for the specific language governing permissions
c869993e79c1eafbec61a56bf6cea848fe754c71xy * and limitations under the License.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * When distributing Covered Code, include this CDDL HEADER in each
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If applicable, add the following below this CDDL HEADER, with the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * fields enclosed by brackets "[]" replaced with your own identifying
c869993e79c1eafbec61a56bf6cea848fe754c71xy * information: Portions Copyright [yyyy] [name of copyright owner]
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * CDDL HEADER END
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
193974072f41a843678abf5f61979c748687e66bSherry Moore/*
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi * Copyright (c) 2007-2012 Intel Corporation. All rights reserved.
6d1cdc09693601c358cdcd1bbd6a462920ac89adGuoqing Zhu */
6d1cdc09693601c358cdcd1bbd6a462920ac89adGuoqing Zhu
6d1cdc09693601c358cdcd1bbd6a462920ac89adGuoqing Zhu/*
6d1cdc09693601c358cdcd1bbd6a462920ac89adGuoqing Zhu * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
43ae55058ad99c869a9ae39d039490e8a3680520Dan McDonald * Copyright 2013, Nexenta Systems, Inc. All rights reserved.
49b7860084dbba18bc00b29413d6182197f9fe93Robert Mustacchi * Copyright 2016 Joyent, Inc.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy#include "igb_sw.h"
c869993e79c1eafbec61a56bf6cea848fe754c71xy
193974072f41a843678abf5f61979c748687e66bSherry Moorestatic char ident[] = "Intel 1Gb Ethernet";
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingalestatic char igb_version[] = "igb 2.3.8-ish";
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Local function protoypes
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_register_mac(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_identify_hardware(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_regs_map(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_init_properties(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_init_driver_settings(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_init_locks(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_destroy_locks(igb_t *);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinastatic int igb_init_mac_address(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_init(igb_t *);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinastatic int igb_init_adapter(igb_t *);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinastatic void igb_stop_adapter(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_reset(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_tx_clean(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t igb_tx_drain(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t igb_rx_drain(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_alloc_rings(igb_t *);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic int igb_alloc_rx_data(igb_t *);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic void igb_free_rx_data(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_free_rings(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_setup_rings(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_setup_rx(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_setup_tx(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_setup_rx_ring(igb_rx_ring_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_setup_tx_ring(igb_tx_ring_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_setup_rss(igb_t *);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic void igb_setup_mac_rss_classify(igb_t *);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic void igb_setup_mac_classify(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_init_unicst(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_setup_multicst(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_get_phy_state(igb_t *);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic void igb_param_sync(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_get_conf(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_get_prop(igb_t *, char *, int, int, int);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t igb_is_link_up(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t igb_link_check(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_local_timer(void *);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinastatic void igb_link_timer(void *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_arm_watchdog_timer(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_start_watchdog_timer(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_restart_watchdog_timer(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_stop_watchdog_timer(igb_t *);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinastatic void igb_start_link_timer(igb_t *);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinastatic void igb_stop_link_timer(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_disable_adapter_interrupts(igb_t *);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinastatic void igb_enable_adapter_interrupts_82575(igb_t *);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinastatic void igb_enable_adapter_interrupts_82576(igb_t *);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing Chinastatic void igb_enable_adapter_interrupts_82580(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t is_valid_mac_addr(uint8_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t igb_stall_check(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t igb_set_loopback_mode(igb_t *, uint32_t);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_set_external_loopback(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_set_internal_phy_loopback(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_set_internal_serdes_loopback(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t igb_find_mac_address(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_alloc_intrs(igb_t *);
fa25784ca4b51c206177d891a654f1d36a25d41fxystatic int igb_alloc_intr_handles(igb_t *, int);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_add_intr_handlers(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_rem_intr_handlers(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_rem_intrs(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_enable_intrs(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_disable_intrs(igb_t *);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinastatic void igb_setup_msix_82575(igb_t *);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinastatic void igb_setup_msix_82576(igb_t *);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing Chinastatic void igb_setup_msix_82580(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic uint_t igb_intr_legacy(void *, void *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic uint_t igb_intr_msi(void *, void *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic uint_t igb_intr_rx(void *, void *);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic uint_t igb_intr_tx(void *, void *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic uint_t igb_intr_tx_other(void *, void *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_intr_rx_work(igb_rx_ring_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_intr_tx_work(igb_tx_ring_t *);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic void igb_intr_link_work(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_get_driver_control(struct e1000_hw *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_release_driver_control(struct e1000_hw *);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_attach(dev_info_t *, ddi_attach_cmd_t);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_detach(dev_info_t *, ddi_detach_cmd_t);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_resume(dev_info_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int igb_suspend(dev_info_t *);
193974072f41a843678abf5f61979c748687e66bSherry Moorestatic int igb_quiesce(dev_info_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void igb_unconfigure(dev_info_t *, igb_t *);
8bb4b220fdb894543e41a5f9037898cf3c3f312bglstatic int igb_fm_error_cb(dev_info_t *, ddi_fm_error_t *,
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl const void *);
8bb4b220fdb894543e41a5f9037898cf3c3f312bglstatic void igb_fm_init(igb_t *);
8bb4b220fdb894543e41a5f9037898cf3c3f312bglstatic void igb_fm_fini(igb_t *);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republicstatic void igb_release_multicast(igb_t *);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerchar *igb_priv_props[] = {
43ae55058ad99c869a9ae39d039490e8a3680520Dan McDonald "_eee_support",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_tx_copy_thresh",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_tx_recycle_thresh",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_tx_overload_thresh",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_tx_resched_thresh",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_rx_copy_thresh",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_rx_limit_per_intr",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_intr_throttling",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_adv_pause_cap",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "_adv_asym_pause_cap",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer NULL
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China};
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic struct cb_ops igb_cb_ops = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy nulldev, /* cb_open */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nulldev, /* cb_close */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_strategy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_print */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_dump */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_read */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_write */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_ioctl */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_devmap */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_mmap */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_segmap */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nochpoll, /* cb_chpoll */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_prop_op, /* cb_prop_op */
c869993e79c1eafbec61a56bf6cea848fe754c71xy NULL, /* cb_stream */
c869993e79c1eafbec61a56bf6cea848fe754c71xy D_MP | D_HOTPLUG, /* cb_flag */
c869993e79c1eafbec61a56bf6cea848fe754c71xy CB_REV, /* cb_rev */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* cb_aread */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev /* cb_awrite */
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic struct dev_ops igb_dev_ops = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy DEVO_REV, /* devo_rev */
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0, /* devo_refcnt */
c869993e79c1eafbec61a56bf6cea848fe754c71xy NULL, /* devo_getinfo */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nulldev, /* devo_identify */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nulldev, /* devo_probe */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_attach, /* devo_attach */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_detach, /* devo_detach */
c869993e79c1eafbec61a56bf6cea848fe754c71xy nodev, /* devo_reset */
c869993e79c1eafbec61a56bf6cea848fe754c71xy &igb_cb_ops, /* devo_cb_ops */
c869993e79c1eafbec61a56bf6cea848fe754c71xy NULL, /* devo_bus_ops */
193974072f41a843678abf5f61979c748687e66bSherry Moore ddi_power, /* devo_power */
193974072f41a843678abf5f61979c748687e66bSherry Moore igb_quiesce, /* devo_quiesce */
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic struct modldrv igb_modldrv = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy &mod_driverops, /* Type of module. This one is a driver */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ident, /* Discription string */
c869993e79c1eafbec61a56bf6cea848fe754c71xy &igb_dev_ops, /* driver ops */
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic struct modlinkage igb_modlinkage = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy MODREV_1, &igb_modldrv, NULL
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/* Access attributes for register mapping */
c869993e79c1eafbec61a56bf6cea848fe754c71xyddi_device_acc_attr_t igb_regs_acc_attr = {
837c1ac4e72b7d86278cca88b1075af557f7d161Stephen Hanson DDI_DEVICE_ATTR_V1,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_STRUCTURE_LE_ACC,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_STRICTORDER_ACC,
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DDI_FLAGERR_ACC
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China#define IGB_M_CALLBACK_FLAGS \
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (MC_IOCTL | MC_GETCAPAB | MC_SETPROP | MC_GETPROP | MC_PROPINFO)
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic mac_callbacks_t igb_m_callbacks = {
c869993e79c1eafbec61a56bf6cea848fe754c71xy IGB_M_CALLBACK_FLAGS,
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_m_stat,
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_m_start,
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_m_stop,
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_m_promisc,
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_m_multicst,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy NULL,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_m_ioctl,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_m_getcapab,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China NULL,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China NULL,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_m_setprop,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer igb_m_getprop,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer igb_m_propinfo
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China/*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Initialize capabilities of each supported adapter type
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinastatic adapter_info_t igb_82575_cap = {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* limits */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 4, /* maximum number of rx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 1, /* minimum number of rx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 4, /* default number of rx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 4, /* maximum number of tx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 1, /* minimum number of tx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 4, /* default number of tx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 65535, /* maximum interrupt throttle rate */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 0, /* minimum interrupt throttle rate */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 200, /* default interrupt throttle rate */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* function pointers */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb_enable_adapter_interrupts_82575,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb_setup_msix_82575,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* capabilities */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China (IGB_FLAG_HAS_DCA | /* capability flags */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China IGB_FLAG_VMDQ_POOL),
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China 0xffc00000 /* mask for RXDCTL register */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China};
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinastatic adapter_info_t igb_82576_cap = {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* limits */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China 16, /* maximum number of rx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 1, /* minimum number of rx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 4, /* default number of rx queues */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China 16, /* maximum number of tx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 1, /* minimum number of tx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 4, /* default number of tx queues */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 65535, /* maximum interrupt throttle rate */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 0, /* minimum interrupt throttle rate */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China 200, /* default interrupt throttle rate */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* function pointers */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb_enable_adapter_interrupts_82576,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb_setup_msix_82576,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* capabilities */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China (IGB_FLAG_HAS_DCA | /* capability flags */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China IGB_FLAG_VMDQ_POOL |
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China IGB_FLAG_NEED_CTX_IDX),
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China 0xffe00000 /* mask for RXDCTL register */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China};
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing Chinastatic adapter_info_t igb_82580_cap = {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* limits */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 8, /* maximum number of rx queues */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 1, /* minimum number of rx queues */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 4, /* default number of rx queues */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 8, /* maximum number of tx queues */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 1, /* minimum number of tx queues */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 4, /* default number of tx queues */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 65535, /* maximum interrupt throttle rate */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 0, /* minimum interrupt throttle rate */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 200, /* default interrupt throttle rate */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* function pointers */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb_enable_adapter_interrupts_82580,
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb_setup_msix_82580,
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* capabilities */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China (IGB_FLAG_HAS_DCA | /* capability flags */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China IGB_FLAG_VMDQ_POOL |
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China IGB_FLAG_NEED_CTX_IDX),
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China 0xffe00000 /* mask for RXDCTL register */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China};
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchistatic adapter_info_t igb_i350_cap = {
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi /* limits */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 8, /* maximum number of rx queues */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 1, /* minimum number of rx queues */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 4, /* default number of rx queues */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 8, /* maximum number of tx queues */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 1, /* minimum number of tx queues */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 4, /* default number of tx queues */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 65535, /* maximum interrupt throttle rate */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 0, /* minimum interrupt throttle rate */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 200, /* default interrupt throttle rate */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi /* function pointers */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi igb_enable_adapter_interrupts_82580,
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi igb_setup_msix_82580,
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi /* capabilities */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi (IGB_FLAG_HAS_DCA | /* capability flags */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi IGB_FLAG_VMDQ_POOL |
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi IGB_FLAG_NEED_CTX_IDX),
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi 0xffe00000 /* mask for RXDCTL register */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi};
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingalestatic adapter_info_t igb_i210_cap = {
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale /* limits */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 4, /* maximum number of rx queues */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 1, /* minimum number of rx queues */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 4, /* default number of rx queues */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 4, /* maximum number of tx queues */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 1, /* minimum number of tx queues */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 4, /* default number of tx queues */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 65535, /* maximum interrupt throttle rate */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 0, /* minimum interrupt throttle rate */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 200, /* default interrupt throttle rate */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale /* function pointers */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale igb_enable_adapter_interrupts_82580,
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale igb_setup_msix_82580,
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale /* capabilities */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale (IGB_FLAG_HAS_DCA | /* capability flags */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale IGB_FLAG_VMDQ_POOL |
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale IGB_FLAG_NEED_CTX_IDX),
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale 0xfff00000 /* mask for RXDCTL register */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale};
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amorestatic adapter_info_t igb_i354_cap = {
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore /* limits */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 8, /* maximum number of rx queues */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 1, /* minimum number of rx queues */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 4, /* default number of rx queues */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 8, /* maximum number of tx queues */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 1, /* minimum number of tx queues */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 4, /* default number of tx queues */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 65535, /* maximum interrupt throttle rate */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 0, /* minimum interrupt throttle rate */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 200, /* default interrupt throttle rate */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore /* function pointers */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore igb_enable_adapter_interrupts_82580,
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore igb_setup_msix_82580,
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore /* capabilities */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore (IGB_FLAG_HAS_DCA | /* capability flags */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore IGB_FLAG_VMDQ_POOL |
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore IGB_FLAG_NEED_CTX_IDX),
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore 0xfff00000 /* mask for RXDCTL register */
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore};
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Module Initialization Functions
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xy_init(void)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int status;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_init_ops(&igb_dev_ops, MODULE_NAME);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy status = mod_install(&igb_modlinkage);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (status != DDI_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_fini_ops(&igb_dev_ops);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (status);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xy_fini(void)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int status;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy status = mod_remove(&igb_modlinkage);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (status == DDI_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_fini_ops(&igb_dev_ops);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (status);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xy_info(struct modinfo *modinfop)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int status;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy status = mod_info(&igb_modlinkage, modinfop);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (status);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_attach - driver attach
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This function is the device specific initialization entry
c869993e79c1eafbec61a56bf6cea848fe754c71xy * point. This entry point is required and must be written.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The DDI_ATTACH command must be provided in the attach entry
c869993e79c1eafbec61a56bf6cea848fe754c71xy * point. When attach() is called with cmd set to DDI_ATTACH,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * all normal kernel services (such as kmem_alloc(9F)) are
c869993e79c1eafbec61a56bf6cea848fe754c71xy * available for use by the driver.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The attach() function will be called once for each instance
c869993e79c1eafbec61a56bf6cea848fe754c71xy * of the device on the system with cmd set to DDI_ATTACH.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Until attach() succeeds, the only driver entry points which
c869993e79c1eafbec61a56bf6cea848fe754c71xy * may be called are open(9E) and getinfo(9E).
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_attach(dev_info_t *devinfo, ddi_attach_cmd_t cmd)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct igb_osdep *osdep;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int instance;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Check the command and perform corresponding operations
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy switch (cmd) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy default:
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case DDI_RESUME:
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (igb_resume(devinfo));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case DDI_ATTACH:
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Get the device instance */
c869993e79c1eafbec61a56bf6cea848fe754c71xy instance = ddi_get_instance(devinfo);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Allocate memory for the instance data structure */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb = kmem_zalloc(sizeof (igb_t), KM_SLEEP);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->dip = devinfo;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->instance = instance;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy osdep = &igb->osdep;
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->back = osdep;
c869993e79c1eafbec61a56bf6cea848fe754c71xy osdep->igb = igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Attach the instance pointer to the dev_info data structure */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_set_driver_private(devinfo, igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /* Initialize for fma support */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb->fm_capabilities = igb_get_prop(igb, "fm-capable",
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl 0, 0x0f,
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DDI_FM_EREPORT_CAPABLE | DDI_FM_ACCCHK_CAPABLE |
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DDI_FM_DMACHK_CAPABLE | DDI_FM_ERRCB_CAPABLE);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_fm_init(igb);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb->attach_progress |= ATTACH_PROGRESS_FMINIT;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Map PCI config space registers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (pci_config_setup(devinfo, &osdep->cfg_handle) != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to map PCI configurations");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_PCI_CONFIG;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Identify the chipset family
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_identify_hardware(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to identify hardware");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Map device registers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_regs_map(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to map device registers");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_REGS_MAP;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize driver parameters
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_init_properties(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_PROPS;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_alloc_intrs(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to allocate interrupts");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_ALLOC_INTR;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate rx/tx rings based on the ring numbers.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The actual numbers of rx/tx rings are decided by the number of
c869993e79c1eafbec61a56bf6cea848fe754c71xy * allocated interrupt vectors, so we should allocate the rings after
c869993e79c1eafbec61a56bf6cea848fe754c71xy * interrupts are allocated.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_alloc_rings(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Failed to allocate rx/tx rings or groups");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_ALLOC_RINGS;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Add interrupt handlers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_add_intr_handlers(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to add interrupt handlers");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_ADD_INTR;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize driver parameters
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_init_driver_settings(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Failed to initialize driver settings");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.cfg_handle) != DDI_FM_OK) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl goto attach_fail;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize mutexes for this device.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Do this before enabling the interrupt handler and
c869993e79c1eafbec61a56bf6cea848fe754c71xy * register the softint to avoid the condition where
c869993e79c1eafbec61a56bf6cea848fe754c71xy * interrupt handler can try using uninitialized mutex
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_init_locks(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_LOCKS;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Initialize the adapter
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (igb_init(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to initialize adapter");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China igb->attach_progress |= ATTACH_PROGRESS_INIT_ADAPTER;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize statistics
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_init_stats(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to initialize statistics");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_STATS;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Register the driver to the MAC
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_register_mac(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to register MAC");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_MAC;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Now that mutex locks are initialized, and the chip is also
c869993e79c1eafbec61a56bf6cea848fe754c71xy * initialized, enable interrupts.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_enable_intrs(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to enable DDI interrupts");
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto attach_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress |= ATTACH_PROGRESS_ENABLE_INTR;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "%s", igb_version);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_INITIALIZED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi /*
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi * Newer models have Energy Efficient Ethernet, let's disable this by
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi * default.
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi */
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi if (igb->hw.mac.type == e1000_i350)
49b7860084dbba18bc00b29413d6182197f9fe93Robert Mustacchi (void) e1000_set_eee_i350(&igb->hw, B_FALSE, B_FALSE);
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore else if (igb->hw.mac.type == e1000_i354)
49b7860084dbba18bc00b29413d6182197f9fe93Robert Mustacchi (void) e1000_set_eee_i354(&igb->hw, B_FALSE, B_FALSE);
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyattach_fail:
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_unconfigure(devinfo, igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_detach - driver detach
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The detach() function is the complement of the attach routine.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If cmd is set to DDI_DETACH, detach() is used to remove the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * state associated with a given instance of a device node
c869993e79c1eafbec61a56bf6cea848fe754c71xy * prior to the removal of that instance from the system.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The detach() function will be called once for each instance
c869993e79c1eafbec61a56bf6cea848fe754c71xy * of the device for which there has been a successful attach()
c869993e79c1eafbec61a56bf6cea848fe754c71xy * once there are no longer any opens on the device.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Interrupts routine are disabled, All memory allocated by this
c869993e79c1eafbec61a56bf6cea848fe754c71xy * driver are freed.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_detach(dev_info_t *devinfo, ddi_detach_cmd_t cmd)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Check detach command
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy switch (cmd) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy default:
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case DDI_SUSPEND:
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (igb_suspend(devinfo));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case DDI_DETACH:
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get the pointer to the driver private data structure
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb = (igb_t *)ddi_get_driver_private(devinfo);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb == NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Unregister MAC. If failed, we have to fail the detach
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (mac_unregister(igb->mac_hdl) != 0) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to unregister MAC");
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->attach_progress &= ~ATTACH_PROGRESS_MAC;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If the device is still running, it needs to be stopped first.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This check is necessary because under some specific circumstances,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the detach routine can be called without stopping the interface
c869993e79c1eafbec61a56bf6cea848fe754c71xy * first.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->igb_state & IGB_STARTED) {
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_and_32(&igb->igb_state, ~IGB_STARTED);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_stop(igb, B_TRUE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Disable and stop the watchdog timer */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_disable_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Check if there are still rx buffers held by the upper layer.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If so, fail the detach.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (!igb_rx_drain(igb))
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Do the remaining unconfigure routines
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_unconfigure(devinfo, igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
193974072f41a843678abf5f61979c748687e66bSherry Moore/*
193974072f41a843678abf5f61979c748687e66bSherry Moore * quiesce(9E) entry point.
193974072f41a843678abf5f61979c748687e66bSherry Moore *
193974072f41a843678abf5f61979c748687e66bSherry Moore * This function is called when the system is single-threaded at high
193974072f41a843678abf5f61979c748687e66bSherry Moore * PIL with preemption disabled. Therefore, this function must not be
193974072f41a843678abf5f61979c748687e66bSherry Moore * blocked.
193974072f41a843678abf5f61979c748687e66bSherry Moore *
193974072f41a843678abf5f61979c748687e66bSherry Moore * This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure.
193974072f41a843678abf5f61979c748687e66bSherry Moore * DDI_FAILURE indicates an error condition and should almost never happen.
193974072f41a843678abf5f61979c748687e66bSherry Moore */
193974072f41a843678abf5f61979c748687e66bSherry Moorestatic int
193974072f41a843678abf5f61979c748687e66bSherry Mooreigb_quiesce(dev_info_t *devinfo)
193974072f41a843678abf5f61979c748687e66bSherry Moore{
193974072f41a843678abf5f61979c748687e66bSherry Moore igb_t *igb;
193974072f41a843678abf5f61979c748687e66bSherry Moore struct e1000_hw *hw;
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore igb = (igb_t *)ddi_get_driver_private(devinfo);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore if (igb == NULL)
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_FAILURE);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore hw = &igb->hw;
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /*
193974072f41a843678abf5f61979c748687e66bSherry Moore * Disable the adapter interrupts
193974072f41a843678abf5f61979c748687e66bSherry Moore */
193974072f41a843678abf5f61979c748687e66bSherry Moore igb_disable_adapter_interrupts(igb);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /* Tell firmware driver is no longer in control */
193974072f41a843678abf5f61979c748687e66bSherry Moore igb_release_driver_control(hw);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /*
193974072f41a843678abf5f61979c748687e66bSherry Moore * Reset the chipset
193974072f41a843678abf5f61979c748687e66bSherry Moore */
193974072f41a843678abf5f61979c748687e66bSherry Moore (void) e1000_reset_hw(hw);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /*
193974072f41a843678abf5f61979c748687e66bSherry Moore * Reset PHY if possible
193974072f41a843678abf5f61979c748687e66bSherry Moore */
193974072f41a843678abf5f61979c748687e66bSherry Moore if (e1000_check_reset_block(hw) == E1000_SUCCESS)
193974072f41a843678abf5f61979c748687e66bSherry Moore (void) e1000_phy_hw_reset(hw);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_SUCCESS);
193974072f41a843678abf5f61979c748687e66bSherry Moore}
193974072f41a843678abf5f61979c748687e66bSherry Moore
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China/*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * igb_unconfigure - release all resources held by this instance
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_unconfigure(dev_info_t *devinfo, igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Disable interrupt
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_ENABLE_INTR) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) igb_disable_intrs(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Unregister MAC
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_MAC) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) mac_unregister(igb->mac_hdl);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free statistics
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_STATS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kstat_delete((kstat_t *)igb->igb_ks);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Remove interrupt handlers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_ADD_INTR) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rem_intr_handlers(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Remove interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_ALLOC_INTR) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rem_intrs(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Remove driver properties
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_PROPS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) ddi_prop_remove_all(devinfo);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Stop the adapter
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (igb->attach_progress & ATTACH_PROGRESS_INIT_ADAPTER) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China igb_stop_adapter(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_UNAFFECTED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic /*
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic * Free multicast table
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic */
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb_release_multicast(igb);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free register handle
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_REGS_MAP) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->osdep.reg_handle != NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_regs_map_free(&igb->osdep.reg_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free PCI config handle
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_PCI_CONFIG) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->osdep.cfg_handle != NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy pci_config_teardown(&igb->osdep.cfg_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free locks
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_LOCKS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_destroy_locks(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free the rx/tx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->attach_progress & ATTACH_PROGRESS_ALLOC_RINGS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_free_rings(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /*
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Remove FMA
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb->attach_progress & ATTACH_PROGRESS_FMINIT) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_fm_fini(igb);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free the driver data structure
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(igb, sizeof (igb_t));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_set_driver_private(devinfo, NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_register_mac - Register the driver and its function pointers with
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the GLD interface
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_register_mac(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_register_t *mac;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int status;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if ((mac = mac_alloc(MAC_VERSION)) == NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->m_type_ident = MAC_PLUGIN_IDENT_ETHER;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->m_driver = igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->m_dip = igb->dip;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->m_src_addr = hw->mac.addr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->m_callbacks = &igb_m_callbacks;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->m_min_sdu = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->m_max_sdu = igb->max_frame_size -
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (struct ether_vlan_header) - ETHERFCSL;
d62bc4badc1c1f1549c961cfb8b420e650e1272byz mac->m_margin = VLAN_TAGSZ;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mac->m_priv_props = igb_priv_props;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac->m_v12n = MAC_VIRT_LEVEL1;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy status = mac_register(mac, &igb->mac_hdl);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_free(mac);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return ((status == 0) ? IGB_SUCCESS : IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_identify_hardware - Identify the type of the chipset
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_identify_hardware(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct igb_osdep *osdep = &igb->osdep;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get the device id
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->vendor_id =
c869993e79c1eafbec61a56bf6cea848fe754c71xy pci_config_get16(osdep->cfg_handle, PCI_CONF_VENID);
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->device_id =
c869993e79c1eafbec61a56bf6cea848fe754c71xy pci_config_get16(osdep->cfg_handle, PCI_CONF_DEVID);
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->revision_id =
c869993e79c1eafbec61a56bf6cea848fe754c71xy pci_config_get8(osdep->cfg_handle, PCI_CONF_REVID);
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->subsystem_device_id =
c869993e79c1eafbec61a56bf6cea848fe754c71xy pci_config_get16(osdep->cfg_handle, PCI_CONF_SUBSYSID);
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->subsystem_vendor_id =
c869993e79c1eafbec61a56bf6cea848fe754c71xy pci_config_get16(osdep->cfg_handle, PCI_CONF_SUBVENID);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set the mac type of the adapter based on the device id
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (e1000_set_mac_type(hw) != E1000_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Install adapter capabilities based on mac type
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China case e1000_82575:
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->capab = &igb_82575_cap;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China break;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China case e1000_82576:
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->capab = &igb_82576_cap;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China break;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China case e1000_82580:
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb->capab = &igb_82580_cap;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China break;
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi case e1000_i350:
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi igb->capab = &igb_i350_cap;
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi break;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale case e1000_i210:
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale case e1000_i211:
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale igb->capab = &igb_i210_cap;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale break;
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore case e1000_i354:
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore igb->capab = &igb_i354_cap;
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore break;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China default:
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_regs_map - Map the device registers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_regs_map(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy dev_info_t *devinfo = igb->dip;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct igb_osdep *osdep = &igb->osdep;
c869993e79c1eafbec61a56bf6cea848fe754c71xy off_t mem_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * First get the size of device registers to be mapped.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China if (ddi_dev_regsize(devinfo, IGB_ADAPTER_REGSET, &mem_size) !=
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China DDI_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Call ddi_regs_map_setup() to map registers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China if ((ddi_regs_map_setup(devinfo, IGB_ADAPTER_REGSET,
c869993e79c1eafbec61a56bf6cea848fe754c71xy (caddr_t *)&hw->hw_addr, 0,
c869993e79c1eafbec61a56bf6cea848fe754c71xy mem_size, &igb_regs_acc_attr,
c869993e79c1eafbec61a56bf6cea848fe754c71xy &osdep->reg_handle)) != DDI_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_init_properties - Initialize driver properties
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_init_properties(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get conf file properties, including link settings
c869993e79c1eafbec61a56bf6cea848fe754c71xy * jumbo frames, ring number, descriptor number, etc.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_get_conf(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_init_driver_settings - Initialize driver settings
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The settings include hardware function pointers, bus information,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * rx/tx rings settings, link state, and any other parameters that
c869993e79c1eafbec61a56bf6cea848fe754c71xy * need to be setup during driver initialization.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_init_driver_settings(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rx_ring_t *rx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t rx_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t tx_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize chipset specific hardware function pointers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (e1000_setup_init_funcs(hw, B_TRUE) != E1000_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get bus information
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (e1000_get_bus_info(hw) != E1000_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo /*
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo * Get the system page size
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo */
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo igb->page_size = ddi_ptob(igb->dip, (ulong_t)1);
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set rx buffer size
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The IP header alignment room is counted in the calculation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The rx buffer size is in unit of 1K that is required by the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * chipset hardware.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_size = igb->max_frame_size + IPHDR_ALIGN_ROOM;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->rx_buf_size = ((rx_size >> 10) +
c869993e79c1eafbec61a56bf6cea848fe754c71xy ((rx_size & (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set tx buffer size
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_size = igb->max_frame_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_buf_size = ((tx_size >> 10) +
c869993e79c1eafbec61a56bf6cea848fe754c71xy ((tx_size & (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize rx/tx rings parameters
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring = &igb->rx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring->index = i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring->igb = igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->index = i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->igb = igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->tx_head_wb_enable)
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tx_recycle = igb_tx_recycle_head_wb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy else
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tx_recycle = igb_tx_recycle_legacy;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->ring_size = igb->tx_ring_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->free_list_size = igb->tx_ring_size +
c869993e79c1eafbec61a56bf6cea848fe754c71xy (igb->tx_ring_size >> 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Initialize values of interrupt throttling rates
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 1; i < MAX_NUM_EITR; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->intr_throttling[i] = igb->intr_throttling[0];
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The initial link state should be "unknown"
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->link_state = LINK_STATE_UNKNOWN;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_init_locks - Initialize locks
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_init_locks(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rx_ring_t *rx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring = &igb->rx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_init(&rx_ring->rx_lock, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_init(&tx_ring->tx_lock, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_init(&tx_ring->recycle_lock, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_init(&tx_ring->tcb_head_lock, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_init(&tx_ring->tcb_tail_lock, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_init(&igb->gen_lock, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_init(&igb->watchdog_lock, NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China mutex_init(&igb->link_lock, NULL,
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China MUTEX_DRIVER, DDI_INTR_PRI(igb->intr_pri));
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_destroy_locks - Destroy locks
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_destroy_locks(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rx_ring_t *rx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring = &igb->rx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_destroy(&rx_ring->rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_destroy(&tx_ring->tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_destroy(&tx_ring->recycle_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_destroy(&tx_ring->tcb_head_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_destroy(&tx_ring->tcb_tail_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_destroy(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_destroy(&igb->watchdog_lock);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China mutex_destroy(&igb->link_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_resume(dev_info_t *devinfo)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb = (igb_t *)ddi_get_driver_private(devinfo);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb == NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu /*
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu * Enable interrupts
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu */
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu if (igb->attach_progress & ATTACH_PROGRESS_ENABLE_INTR) {
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu if (igb_enable_intrs(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Failed to enable DDI interrupts");
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu mutex_exit(&igb->gen_lock);
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu return (DDI_FAILURE);
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu }
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu }
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->igb_state & IGB_STARTED) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb_start(igb, B_FALSE) != IGB_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Enable and start the watchdog timer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_enable_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_and_32(&igb->igb_state, ~IGB_SUSPENDED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_suspend(dev_info_t *devinfo)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb = (igb_t *)ddi_get_driver_private(devinfo);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb == NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_SUSPENDED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu /*
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu * Disable interrupts
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu */
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu if (igb->attach_progress & ATTACH_PROGRESS_ENABLE_INTR) {
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu (void) igb_disable_intrs(igb);
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu }
82722020b3918ce4d9594e3c6e0462bab345d102Crisson Guanghao Hu
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (!(igb->igb_state & IGB_STARTED)) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China mutex_exit(&igb->gen_lock);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China return (DDI_SUCCESS);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_stop(igb, B_FALSE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Disable and stop the watchdog timer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_disable_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinastatic int
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinaigb_init(igb_t *igb)
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China{
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China mutex_enter(&igb->gen_lock);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Initilize the adapter
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (igb_init_adapter(igb) != IGB_SUCCESS) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China mutex_exit(&igb->gen_lock);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China igb_fm_ereport(igb, DDI_FM_DEVICE_INVAL_STATE);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China mutex_exit(&igb->gen_lock);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China return (IGB_SUCCESS);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China}
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * igb_init_mac_address - Initialize the default MAC address
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China *
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * On success, the MAC address is entered in the igb->hw.mac.addr
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * and hw->mac.perm_addr fields and the adapter's RAR(0) receive
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * address register.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China *
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Important side effects:
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * 1. adapter is reset - this is required to put it in a known state.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * 2. all of non-volatile memory (NVM) is read & checksummed - NVM is where
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * MAC address and all default settings are stored, so a valid checksum
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * is required.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinaigb_init_mac_address(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Reset chipset to put the hardware in a known state
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * before we try to get MAC address from NVM.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (e1000_reset_hw(hw) != E1000_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Adapter reset failed.");
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China goto init_mac_fail;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * NVM validation
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale if (((igb->hw.mac.type != e1000_i210) &&
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale (igb->hw.mac.type != e1000_i211)) &&
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale (e1000_validate_nvm_checksum(hw) < 0)) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Some PCI-E parts fail the first check due to
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the link being in sleep state. Call it again,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * if it fails a second time its a real issue.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (e1000_validate_nvm_checksum(hw) < 0) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Invalid NVM checksum. Please contact "
c869993e79c1eafbec61a56bf6cea848fe754c71xy "the vendor to update the NVM.");
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China goto init_mac_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Get the mac address
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * This function should handle SPARC case correctly.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (!igb_find_mac_address(igb)) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to get the mac address");
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China goto init_mac_fail;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /* Validate mac address */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (!is_valid_mac_addr(hw->mac.addr)) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Invalid mac address");
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China goto init_mac_fail;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China return (IGB_SUCCESS);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinainit_mac_fail:
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China}
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China/*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * igb_init_adapter - Initialize the adapter
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinastatic int
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinaigb_init_adapter(igb_t *igb)
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China{
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China struct e1000_hw *hw = &igb->hw;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China uint32_t pba;
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski int oemid[2];
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski uint16_t nvmword;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale uint32_t hwm;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale uint32_t default_mtu;
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski u8 pbanum[E1000_PBANUM_LENGTH];
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski char eepromver[5]; /* f.ff */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China int i;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China ASSERT(mutex_owned(&igb->gen_lock));
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * In order to obtain the default MAC address, this will reset the
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * adapter and validate the NVM that the address and many other
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * default settings come from.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (igb_init_mac_address(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to initialize MAC address");
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China goto init_adapter_fail;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * Packet Buffer Allocation (PBA)
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * Writing PBA sets the receive portion of the buffer
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * the remainder is used for the transmit buffer.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale switch (hw->mac.type) {
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale case e1000_82575:
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba = E1000_PBA_32K;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale break;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale case e1000_82576:
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba = E1000_READ_REG(hw, E1000_RXPBS);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba &= E1000_RXPBS_SIZE_MASK_82576;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale break;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale case e1000_82580:
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale case e1000_i350:
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore case e1000_i354:
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba = E1000_READ_REG(hw, E1000_RXPBS);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba = e1000_rxpbs_adjust_82580(pba);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale break;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale case e1000_i210:
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale case e1000_i211:
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China pba = E1000_PBA_34K;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale default:
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale break;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale }
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale /* Special needs in case of Jumbo frames */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale default_mtu = igb_get_prop(igb, PROP_DEFAULT_MTU,
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale MIN_MTU, MAX_MTU, DEFAULT_MTU);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale if ((hw->mac.type == e1000_82575) && (default_mtu > ETHERMTU)) {
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale u32 tx_space, min_tx, min_rx;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba = E1000_READ_REG(hw, E1000_PBA);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale tx_space = pba >> 16;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba &= 0xffff;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale min_tx = (igb->max_frame_size +
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale sizeof (struct e1000_tx_desc) - ETHERNET_FCS_SIZE) * 2;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale min_tx = roundup(min_tx, 1024);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale min_tx >>= 10;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale min_rx = igb->max_frame_size;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale min_rx = roundup(min_rx, 1024);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale min_rx >>= 10;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale if (tx_space < min_tx &&
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale ((min_tx - tx_space) < pba)) {
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba = pba - (min_tx - tx_space);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale /*
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * if short on rx space, rx wins
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * and must trump tx adjustment
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale if (pba < min_rx)
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale pba = min_rx;
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale }
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale E1000_WRITE_REG(hw, E1000_PBA, pba);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale DEBUGOUT1("igb_init: pba=%dK", pba);
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale /*
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * These parameters control the automatic generation (Tx) and
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * response (Rx) to Ethernet PAUSE frames.
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * - High water mark should allow for at least two frames to be
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * received after sending an XOFF.
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * - Low water mark works best when it is very near the high water mark.
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * This allows the receiver to restart by sending XON when it has
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale * drained a bit.
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale */
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale hwm = min(((pba << 10) * 9 / 10),
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale ((pba << 10) - 2 * igb->max_frame_size));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale if (hw->mac.type < e1000_82576) {
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale hw->fc.high_water = hwm & 0xFFF8; /* 8-byte granularity */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China hw->fc.low_water = hw->fc.high_water - 8;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China } else {
6ed0a5cff079e25f4aa15cef67c6dd48ee60b018Tycho Nightingale hw->fc.high_water = hwm & 0xFFF0; /* 16-byte granularity */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China hw->fc.low_water = hw->fc.high_water - 16;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->fc.pause_time = E1000_FC_PAUSE_TIME;
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->fc.send_xon = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China (void) e1000_validate_mdi_setting(hw);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Reset the chipset hardware the second time to put PBA settings
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * into effect.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (e1000_reset_hw(hw) != E1000_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Second reset failed");
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China goto init_adapter_fail;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Don't wait for auto-negotiation to complete
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->phy.autoneg_wait_to_complete = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Copper options
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (hw->phy.media_type == e1000_media_type_copper) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->phy.mdix = 0; /* AUTO_ALL_MODES */
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->phy.disable_polarity_correction = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->phy.ms_type = e1000_ms_hw_default; /* E1000_MASTER_SLAVE */
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize link settings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) igb_setup_link(igb, B_FALSE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Configure/Initialize hardware
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (e1000_init_hw(hw) != E1000_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Failed to initialize hardware");
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China goto init_adapter_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China /*
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * Start the link setup timer
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China */
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb_start_link_timer(igb);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Disable wakeup control by default
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_WUC, 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Record phy info in hw struct
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (void) e1000_get_phy_info(hw);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Make sure driver has control
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_get_driver_control(hw);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Restore LED settings to the default from EEPROM
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * to meet the standard for Sun platforms.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (void) e1000_cleanup_led(hw);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Setup MSI-X interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->intr_type == DDI_INTR_TYPE_MSIX)
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->capab->setup_msix(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize unicast addresses.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_init_unicst(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Setup and initialize the mctable structures.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_setup_multicst(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set interrupt throttling rate
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->intr_cnt; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_EITR(i), igb->intr_throttling[i]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski /*
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski * Read identifying information and place in devinfo.
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski */
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski nvmword = 0xffff;
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (void) e1000_read_nvm(&igb->hw, NVM_OEM_OFFSET_0, 1, &nvmword);
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski oemid[0] = (int)nvmword;
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (void) e1000_read_nvm(&igb->hw, NVM_OEM_OFFSET_1, 1, &nvmword);
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski oemid[1] = (int)nvmword;
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (void) ddi_prop_update_int_array(DDI_DEV_T_NONE, igb->dip,
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski "oem-identifier", oemid, 2);
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski pbanum[0] = '\0';
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (void) e1000_read_pba_string(&igb->hw, pbanum, sizeof (pbanum));
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski if (*pbanum != '\0') {
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (void) ddi_prop_update_string(DDI_DEV_T_NONE, igb->dip,
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski "printed-board-assembly", (char *)pbanum);
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski }
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski nvmword = 0xffff;
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (void) e1000_read_nvm(&igb->hw, NVM_VERSION, 1, &nvmword);
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski if ((nvmword & 0xf00) == 0) {
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (void) snprintf(eepromver, sizeof (eepromver), "%x.%x",
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (nvmword & 0xf000) >> 12, (nvmword & 0xff));
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski (void) ddi_prop_update_string(DDI_DEV_T_NONE, igb->dip,
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski "nvm-version", eepromver);
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski }
69c7619071dc71a079b65cd199d237df0f487d15Keith M Wesolowski
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Save the state of the phy
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_get_phy_state(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_param_sync(igb);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinainit_adapter_fail:
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Reset PHY if possible
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (e1000_check_reset_block(hw) == E1000_SUCCESS)
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (void) e1000_phy_hw_reset(hw);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * igb_stop_adapter - Stop the adapter
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing Chinaigb_stop_adapter(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China /* Stop the link setup timer */
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb_stop_link_timer(igb);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Tell firmware driver is no longer in control */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_release_driver_control(hw);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Reset the chipset
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (e1000_reset_hw(hw) != E1000_SUCCESS) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_fm_ereport(igb, DDI_FM_DEVICE_INVAL_STATE);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * e1000_phy_hw_reset is not needed here, MAC reset above is sufficient
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_reset - Reset the chipset and restart the driver.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * It involves stopping and re-starting the chipset,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * and re-configuring the rx/tx rings.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_reset(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(igb->igb_state & IGB_STARTED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_and_32(&igb->igb_state, ~IGB_STARTED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Disable the adapter interrupts to stop any rx/tx activities
c869993e79c1eafbec61a56bf6cea848fe754c71xy * before draining pending data and resetting hardware.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_disable_adapter_interrupts(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Drain the pending transmit packets
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) igb_tx_drain(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->rx_rings[i].rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->tx_rings[i].tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Stop the adapter
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China igb_stop_adapter(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Clean the pending tx data/resources
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_clean(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Start the adapter
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (igb_init_adapter(igb) != IGB_SUCCESS) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_fm_ereport(igb, DDI_FM_DEVICE_INVAL_STATE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy goto reset_failure;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Setup the rx/tx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->tx_ring_init = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_setup_rings(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_and_32(&igb->igb_state, ~(IGB_ERROR | IGB_STALL));
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Enable adapter interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The interrupts must be enabled after the driver state is START
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->capab->enable_intr(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.cfg_handle) != DDI_FM_OK)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl goto reset_failure;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl goto reset_failure;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_tx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->tx_rings[i].tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_rx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->rx_rings[i].rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_STARTED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyreset_failure:
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_tx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->tx_rings[i].tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_rx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->rx_rings[i].rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_tx_clean - Clean the pending transmit packets and DMA resources
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_tx_clean(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_control_block_t *tcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy link_list_t pending_list;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t desc_num;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i, j;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy LINK_LIST_INIT(&pending_list);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&tx_ring->recycle_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Clean the pending tx data - the pending packets in the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * work_list that have no chances to be transmitted again.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * We must ensure the chipset is stopped or the link is down
c869993e79c1eafbec61a56bf6cea848fe754c71xy * before cleaning the transmit packets.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy desc_num = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (j = 0; j < tx_ring->ring_size; j++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tcb = tx_ring->work_list[j];
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tcb != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy desc_num += tcb->desc_num;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->work_list[j] = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_free_tcb(tcb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy LIST_PUSH_TAIL(&pending_list, &tcb->link);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (desc_num > 0) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy atomic_add_32(&tx_ring->tbd_free, desc_num);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(tx_ring->tbd_free == tx_ring->ring_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
fa25784ca4b51c206177d891a654f1d36a25d41fxy * Reset the head and tail pointers of the tbd ring;
fa25784ca4b51c206177d891a654f1d36a25d41fxy * Reset the head write-back if it is enabled.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_head = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_tail = 0;
fa25784ca4b51c206177d891a654f1d36a25d41fxy if (igb->tx_head_wb_enable)
fa25784ca4b51c206177d891a654f1d36a25d41fxy *tx_ring->tbd_head_wb = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(&igb->hw, E1000_TDH(tx_ring->index), 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(&igb->hw, E1000_TDT(tx_ring->index), 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&tx_ring->recycle_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Add the tx control blocks in the pending list to
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the free list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_put_free_list(tx_ring, &pending_list);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_tx_drain - Drain the tx rings to allow pending packets to be transmitted
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_tx_drain(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t done;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i, j;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Wait for a specific time to allow pending tx packets
c869993e79c1eafbec61a56bf6cea848fe754c71xy * to be transmitted.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Check the counter tbd_free to see if transmission is done.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * No lock protection is needed here.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Return B_TRUE if all pending packets have been transmitted;
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Otherwise return B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < TX_DRAIN_TIME; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy done = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (j = 0; j < igb->num_tx_rings; j++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[j];
c869993e79c1eafbec61a56bf6cea848fe754c71xy done = done &&
c869993e79c1eafbec61a56bf6cea848fe754c71xy (tx_ring->tbd_free == tx_ring->ring_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (done)
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy msec_delay(1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (done);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_rx_drain - Wait for all rx buffers to be released by upper layer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_rx_drain(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t done;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Polling the rx free list to check if those rx buffers held by
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the upper layer are released.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Check the counter rcb_free to see if all pending buffers are
c869993e79c1eafbec61a56bf6cea848fe754c71xy * released. No lock protection is needed here.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Return B_TRUE if all pending buffers have been released;
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Otherwise return B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < RX_DRAIN_TIME; i++) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China done = (igb->rcb_pending == 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (done)
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy msec_delay(1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (done);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_start - Start the driver/chipset
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_start(igb_t *igb, boolean_t alloc_buffer)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (alloc_buffer) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb_alloc_rx_data(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China "Failed to allocate software receive rings");
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /* Allocate buffers for all the rx/tx rings */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb_alloc_dma(igb) != IGB_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Failed to allocate DMA resource");
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->tx_ring_init = B_TRUE;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China } else {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->tx_ring_init = B_FALSE;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->rx_rings[i].rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->tx_rings[i].tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Start the adapter
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if ((igb->attach_progress & ATTACH_PROGRESS_INIT_ADAPTER) == 0) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (igb_init_adapter(igb) != IGB_SUCCESS) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_fm_ereport(igb, DDI_FM_DEVICE_INVAL_STATE);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng goto start_failure;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China igb->attach_progress |= ATTACH_PROGRESS_INIT_ADAPTER;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Setup the rx/tx rings
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_setup_rings(igb);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Enable adapter interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The interrupts must be enabled after the driver state is START
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->capab->enable_intr(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.cfg_handle) != DDI_FM_OK)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl goto start_failure;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl goto start_failure;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi if (igb->hw.mac.type == e1000_i350)
49b7860084dbba18bc00b29413d6182197f9fe93Robert Mustacchi (void) e1000_set_eee_i350(&igb->hw, B_FALSE, B_FALSE);
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore else if (igb->hw.mac.type == e1000_i354)
49b7860084dbba18bc00b29413d6182197f9fe93Robert Mustacchi (void) e1000_set_eee_i354(&igb->hw, B_FALSE, B_FALSE);
7e5262732e5b384b6aaeaa77959a6c9dad5d1161Robert Mustacchi
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_tx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->tx_rings[i].tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_rx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->rx_rings[i].rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystart_failure:
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_tx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->tx_rings[i].tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_rx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->rx_rings[i].rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_stop - Stop the driver/chipset
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyvoid
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_stop(igb_t *igb, boolean_t free_buffer)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China igb->attach_progress &= ~ATTACH_PROGRESS_INIT_ADAPTER;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Disable the adapter interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_disable_adapter_interrupts(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Drain the pending tx packets
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) igb_tx_drain(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->rx_rings[i].rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->tx_rings[i].tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Stop the adapter
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China igb_stop_adapter(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Clean the pending tx data/resources
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_clean(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_tx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->tx_rings[i].tx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = igb->num_rx_rings - 1; i >= 0; i--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->rx_rings[i].rx_lock);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb->link_state == LINK_STATE_UP) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->link_state = LINK_STATE_UNKNOWN;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mac_link_update(igb->mac_hdl, igb->link_state);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (free_buffer) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Release the DMA/memory resources of rx/tx rings
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_dma(igb);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_rx_data(igb);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_alloc_rings - Allocate memory space for rx/tx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_alloc_rings(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate memory space for rx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->rx_rings = kmem_zalloc(
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (igb_rx_ring_t) * igb->num_rx_rings,
c869993e79c1eafbec61a56bf6cea848fe754c71xy KM_NOSLEEP);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->rx_rings == NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Allocate memory space for tx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_rings = kmem_zalloc(
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (igb_tx_ring_t) * igb->num_tx_rings,
c869993e79c1eafbec61a56bf6cea848fe754c71xy KM_NOSLEEP);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->tx_rings == NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(igb->rx_rings,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (igb_rx_ring_t) * igb->num_rx_rings);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->rx_rings = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Allocate memory space for rx ring groups
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->rx_groups = kmem_zalloc(
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (igb_rx_group_t) * igb->num_rx_groups,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng KM_NOSLEEP);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (igb->rx_groups == NULL) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng kmem_free(igb->rx_rings,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (igb_rx_ring_t) * igb->num_rx_rings);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng kmem_free(igb->tx_rings,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (igb_tx_ring_t) * igb->num_tx_rings);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->rx_rings = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->tx_rings = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (IGB_FAILURE);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_free_rings - Free the memory space of rx/tx rings.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_free_rings(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->rx_rings != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(igb->rx_rings,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (igb_rx_ring_t) * igb->num_rx_rings);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->rx_rings = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->tx_rings != NULL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(igb->tx_rings,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (igb_tx_ring_t) * igb->num_tx_rings);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_rings = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (igb->rx_groups != NULL) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng kmem_free(igb->rx_groups,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (igb_rx_group_t) * igb->num_rx_groups);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->rx_groups = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic int
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_alloc_rx_data(igb_t *igb)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China{
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_rx_ring_t *rx_ring;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China int i;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China for (i = 0; i < igb->num_rx_rings; i++) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_ring = &igb->rx_rings[i];
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb_alloc_rx_ring_data(rx_ring) != IGB_SUCCESS)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China goto alloc_rx_rings_failure;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return (IGB_SUCCESS);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaalloc_rx_rings_failure:
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_rx_data(igb);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return (IGB_FAILURE);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China}
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic void
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_free_rx_data(igb_t *igb)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China{
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_rx_ring_t *rx_ring;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_rx_data_t *rx_data;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China int i;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China for (i = 0; i < igb->num_rx_rings; i++) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_ring = &igb->rx_rings[i];
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mutex_enter(&igb->rx_pending_lock);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data != NULL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->flag |= IGB_RX_STOPPED;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (rx_data->rcb_pending == 0) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_free_rx_ring_data(rx_data);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_ring->rx_data = NULL;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mutex_exit(&igb->rx_pending_lock);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China}
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_setup_rings - Setup rx/tx rings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_setup_rings(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Setup the rx/tx rings, including the following:
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 1. Setup the descriptor ring and the control block buffers;
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 2. Initialize necessary registers for receive/transmit;
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 3. Initialize software pointers/parameters for receive/transmit;
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_setup_rx(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_setup_tx(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_setup_rx_ring(igb_rx_ring_t *rx_ring)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb = rx_ring->igb;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_rx_data_t *rx_data = rx_ring->rx_data;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_control_block_t *rcb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy union e1000_adv_rx_desc *rbd;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t buf_low;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t buf_high;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China uint32_t rxdctl;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&rx_ring->rx_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Initialize descriptor ring with buffer addresses
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->rx_ring_size; i++) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rcb = rx_data->work_list[i];
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rbd = &rx_data->rbd_ring[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rbd->read.pkt_addr = rcb->rx_buf.dma_address;
c869993e79c1eafbec61a56bf6cea848fe754c71xy rbd->read.hdr_addr = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Initialize the base address registers
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China buf_low = (uint32_t)rx_data->rbd_area.dma_address;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China buf_high = (uint32_t)(rx_data->rbd_area.dma_address >> 32);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_RDBAH(rx_ring->index), buf_high);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_RDBAL(rx_ring->index), buf_low);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize the length register
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China size = rx_data->ring_size * sizeof (union e1000_adv_rx_desc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_RDLEN(rx_ring->index), size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Initialize buffer size & descriptor type
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_SRRCTL(rx_ring->index),
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China ((igb->rx_buf_size >> E1000_SRRCTL_BSIZEPKT_SHIFT) |
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China E1000_SRRCTL_DESCTYPE_ADV_ONEBUF));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Setup the Receive Descriptor Control Register (RXDCTL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China rxdctl = E1000_READ_REG(hw, E1000_RXDCTL(rx_ring->index));
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China rxdctl &= igb->capab->rxdctl_mask;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China rxdctl |= E1000_RXDCTL_QUEUE_ENABLE;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China rxdctl |= 16; /* pthresh */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China rxdctl |= 8 << 8; /* hthresh */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China rxdctl |= 1 << 16; /* wthresh */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_RXDCTL(rx_ring->index), rxdctl);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data->rbd_next = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_setup_rx(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rx_ring_t *rx_ring;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_rx_data_t *rx_data;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_rx_group_t *rx_group;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China uint32_t rctl, rxcsum;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t ring_per_group;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Setup the Receive Control Register (RCTL), and enable the
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * receiver. The initial configuration is to: enable the receiver,
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * accept broadcasts, discard bad packets, accept long packets,
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * disable VLAN filter checking, and set receive buffer size to
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * 2k. For 82575, also set the receive descriptor minimum
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * threshold size to 1/2 the ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China rctl = E1000_READ_REG(hw, E1000_RCTL);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Clear the field used for wakeup control. This driver doesn't do
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * wakeup but leave this here for completeness.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China rctl |= (E1000_RCTL_EN | /* Enable Receive Unit */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_RCTL_BAM | /* Accept Broadcast Packets */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_RCTL_LPE | /* Large Packet Enable */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* Multicast filter offset */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China (hw->mac.mc_filter_type << E1000_RCTL_MO_SHIFT) |
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_RCTL_RDMTS_HALF | /* rx descriptor threshold */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_RCTL_SECRC); /* Strip Ethernet CRC */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < igb->num_rx_groups; i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_group = &igb->rx_groups[i];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_group->index = i;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_group->igb = igb;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
d556530cda421a2e47778c115a8d39f8571f104cxy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Set up all rx descriptor rings - must be called before receive unit
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * enabled.
d556530cda421a2e47778c115a8d39f8571f104cxy */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ring_per_group = igb->num_rx_rings / igb->num_rx_groups;
d556530cda421a2e47778c115a8d39f8571f104cxy for (i = 0; i < igb->num_rx_rings; i++) {
d556530cda421a2e47778c115a8d39f8571f104cxy rx_ring = &igb->rx_rings[i];
d556530cda421a2e47778c115a8d39f8571f104cxy igb_setup_rx_ring(rx_ring);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Map a ring to a group by assigning a group index
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_ring->group_index = i / ring_per_group;
d556530cda421a2e47778c115a8d39f8571f104cxy }
d556530cda421a2e47778c115a8d39f8571f104cxy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Setup the Rx Long Packet Max Length register
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_RLPML, igb->max_frame_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Hardware checksum settings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->rx_hcksum_enable) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China rxcsum =
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_RXCSUM_TUOFL | /* TCP/UDP checksum */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_RXCSUM_IPOFL; /* IP checksum */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Setup classify and RSS for multiple receive queues
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng switch (igb->vmdq_mode) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng case E1000_VMDQ_OFF:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * One ring group, only RSS is needed when more than
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * one ring enabled.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (igb->num_rx_rings > 1)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_setup_rss(igb);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng case E1000_VMDQ_MAC:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Multiple groups, each group has one ring,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * only the MAC classification is needed.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_setup_mac_classify(igb);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng case E1000_VMDQ_MAC_RSS:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Multiple groups and multiple rings, both
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * MAC classification and RSS are needed.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_setup_mac_rss_classify(igb);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Enable the receive unit - must be done after all
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * the rx setup above.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_RCTL, rctl);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Initialize all adapter ring head & tail pointers - must
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * be done after receive unit is enabled
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China for (i = 0; i < igb->num_rx_rings; i++) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China rx_ring = &igb->rx_rings[i];
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_RDH(i), 0);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_RDT(i), rx_data->ring_size - 1);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * 82575 with manageability enabled needs a special flush to make
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * sure the fifos start clean.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if ((hw->mac.type == e1000_82575) &&
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_RCV_TCO_EN)) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China e1000_rx_fifo_flush_82575(hw);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_setup_tx_ring(igb_tx_ring_t *tx_ring)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb = tx_ring->igb;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t buf_low;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t buf_high;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t reg_val;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&tx_ring->tx_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize the length register
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy size = tx_ring->ring_size * sizeof (union e1000_adv_tx_desc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_TDLEN(tx_ring->index), size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize the base address registers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf_low = (uint32_t)tx_ring->tbd_area.dma_address;
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf_high = (uint32_t)(tx_ring->tbd_area.dma_address >> 32);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_TDBAL(tx_ring->index), buf_low);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_TDBAH(tx_ring->index), buf_high);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Setup head & tail pointers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_TDH(tx_ring->index), 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_TDT(tx_ring->index), 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Setup head write-back
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->tx_head_wb_enable) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The memory of the head write-back is allocated using
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the extra tbd beyond the tail of the tbd ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_head_wb = (uint32_t *)
c869993e79c1eafbec61a56bf6cea848fe754c71xy ((uintptr_t)tx_ring->tbd_area.address + size);
fa25784ca4b51c206177d891a654f1d36a25d41fxy *tx_ring->tbd_head_wb = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf_low = (uint32_t)
c869993e79c1eafbec61a56bf6cea848fe754c71xy (tx_ring->tbd_area.dma_address + size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf_high = (uint32_t)
c869993e79c1eafbec61a56bf6cea848fe754c71xy ((tx_ring->tbd_area.dma_address + size) >> 32);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Set the head write-back enable bit */
c869993e79c1eafbec61a56bf6cea848fe754c71xy buf_low |= E1000_TX_HEAD_WB_ENABLE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_TDWBAL(tx_ring->index), buf_low);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_TDWBAH(tx_ring->index), buf_high);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Turn off relaxed ordering for head write back or it will
c869993e79c1eafbec61a56bf6cea848fe754c71xy * cause problems with the tx recycling
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy reg_val = E1000_READ_REG(hw,
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_DCA_TXCTRL(tx_ring->index));
c869993e79c1eafbec61a56bf6cea848fe754c71xy reg_val &= ~E1000_DCA_TXCTRL_TX_WB_RO_EN;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw,
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_DCA_TXCTRL(tx_ring->index), reg_val);
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_head_wb = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_head = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_tail = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tbd_free = tx_ring->ring_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb->tx_ring_init == B_TRUE) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tcb_head = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tcb_tail = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tcb_free = tx_ring->free_list_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Enable TXDCTL per queue
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China reg_val = E1000_READ_REG(hw, E1000_TXDCTL(tx_ring->index));
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China reg_val |= E1000_TXDCTL_QUEUE_ENABLE;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_TXDCTL(tx_ring->index), reg_val);
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo /*
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo * Initialize hardware checksum offload settings
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo */
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo bzero(&tx_ring->tx_context, sizeof (tx_context_t));
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_setup_tx(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t reg_val;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_setup_tx_ring(tx_ring);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Setup the Transmit Control Register (TCTL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China reg_val = E1000_READ_REG(hw, E1000_TCTL);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China reg_val &= ~E1000_TCTL_CT;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China reg_val |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* Enable transmits */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China reg_val |= E1000_TCTL_EN;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_TCTL, reg_val);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_setup_rss - Setup receive-side scaling feature
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_setup_rss(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t i, mrqc, rxcsum;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China int shift = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t random;
c869993e79c1eafbec61a56bf6cea848fe754c71xy union e1000_reta {
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t dword;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint8_t bytes[4];
c869993e79c1eafbec61a56bf6cea848fe754c71xy } reta;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Setup the Redirection Table */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China if (hw->mac.type == e1000_82576) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China shift = 3;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China } else if (hw->mac.type == e1000_82575) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China shift = 6;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < (32 * 4); i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy reta.bytes[i & 3] = (i % igb->num_rx_rings) << shift;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if ((i & 3) == 3) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw,
c869993e79c1eafbec61a56bf6cea848fe754c71xy (E1000_RETA(0) + (i & ~3)), reta.dword);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Fill out hash function seeds */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < 10; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) random_get_pseudo_bytes((uint8_t *)&random,
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (uint32_t));
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_RSSRK(i), random);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Setup the Multiple Receive Queue Control register */
c869993e79c1eafbec61a56bf6cea848fe754c71xy mrqc = E1000_MRQC_ENABLE_RSS_4Q;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mrqc |= (E1000_MRQC_RSS_FIELD_IPV4 |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_MRQC_RSS_FIELD_IPV4_TCP |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_MRQC_RSS_FIELD_IPV6 |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_MRQC_RSS_FIELD_IPV6_TCP |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_MRQC_RSS_FIELD_IPV4_UDP |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_MRQC_RSS_FIELD_IPV6_UDP |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_MRQC_RSS_FIELD_IPV6_UDP_EX |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_MRQC_RSS_FIELD_IPV6_TCP_EX);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_MRQC, mrqc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Disable Packet Checksum to enable RSS for multiple receive queues.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The Packet Checksum is not ethernet CRC. It is another kind of
c869993e79c1eafbec61a56bf6cea848fe754c71xy * checksum offloading provided by the 82575 chipset besides the IP
c869993e79c1eafbec61a56bf6cea848fe754c71xy * header checksum offloading and the TCP/UDP checksum offloading.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The Packet Checksum is by default computed over the entire packet
c869993e79c1eafbec61a56bf6cea848fe754c71xy * from the first byte of the DA through the last byte of the CRC,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * including the Ethernet and IP headers.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * It is a hardware limitation that Packet Checksum is mutually
c869993e79c1eafbec61a56bf6cea848fe754c71xy * exclusive with RSS.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy rxcsum = E1000_READ_REG(hw, E1000_RXCSUM);
c869993e79c1eafbec61a56bf6cea848fe754c71xy rxcsum |= E1000_RXCSUM_PCSD;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * igb_setup_mac_rss_classify - Setup MAC classification and rss
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic void
da14cebe459d3275048785f25bd869cb09b5307fEric Chengigb_setup_mac_rss_classify(igb_t *igb)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng struct e1000_hw *hw = &igb->hw;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t i, mrqc, vmdctl, rxcsum;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t ring_per_group;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int shift_group0, shift_group1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t random;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng union e1000_reta {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t dword;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint8_t bytes[4];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng } reta;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ring_per_group = igb->num_rx_rings / igb->num_rx_groups;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* Setup the Redirection Table, it is shared between two groups */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng shift_group0 = 2;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng shift_group1 = 6;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < (32 * 4); i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng reta.bytes[i & 3] = ((i % ring_per_group) << shift_group0) |
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ((ring_per_group + (i % ring_per_group)) << shift_group1);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if ((i & 3) == 3) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_WRITE_REG(hw,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (E1000_RETA(0) + (i & ~3)), reta.dword);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* Fill out hash function seeds */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < 10; i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) random_get_pseudo_bytes((uint8_t *)&random,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (uint32_t));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_WRITE_REG(hw, E1000_RSSRK(i), random);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Setup the Multiple Receive Queue Control register,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * enable VMDq based on packet destination MAC address and RSS.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mrqc = E1000_MRQC_ENABLE_VMDQ_MAC_RSS_GROUP;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mrqc |= (E1000_MRQC_RSS_FIELD_IPV4 |
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_MRQC_RSS_FIELD_IPV4_TCP |
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_MRQC_RSS_FIELD_IPV6 |
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_MRQC_RSS_FIELD_IPV6_TCP |
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_MRQC_RSS_FIELD_IPV4_UDP |
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_MRQC_RSS_FIELD_IPV6_UDP |
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_MRQC_RSS_FIELD_IPV6_UDP_EX |
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_MRQC_RSS_FIELD_IPV6_TCP_EX);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_WRITE_REG(hw, E1000_MRQC, mrqc);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* Define the default group and default queues */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng vmdctl = E1000_VMDQ_MAC_GROUP_DEFAULT_QUEUE;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_VT_CTL, vmdctl);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Disable Packet Checksum to enable RSS for multiple receive queues.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * The Packet Checksum is not ethernet CRC. It is another kind of
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * checksum offloading provided by the 82575 chipset besides the IP
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * header checksum offloading and the TCP/UDP checksum offloading.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * The Packet Checksum is by default computed over the entire packet
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * from the first byte of the DA through the last byte of the CRC,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * including the Ethernet and IP headers.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * It is a hardware limitation that Packet Checksum is mutually
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * exclusive with RSS.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rxcsum = E1000_READ_REG(hw, E1000_RXCSUM);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rxcsum |= E1000_RXCSUM_PCSD;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * igb_setup_mac_classify - Setup MAC classification feature
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic void
da14cebe459d3275048785f25bd869cb09b5307fEric Chengigb_setup_mac_classify(igb_t *igb)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng struct e1000_hw *hw = &igb->hw;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t mrqc, rxcsum;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Setup the Multiple Receive Queue Control register,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * enable VMDq based on packet destination MAC address.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mrqc = E1000_MRQC_ENABLE_VMDQ_MAC_GROUP;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_WRITE_REG(hw, E1000_MRQC, mrqc);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Disable Packet Checksum to enable RSS for multiple receive queues.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * The Packet Checksum is not ethernet CRC. It is another kind of
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * checksum offloading provided by the 82575 chipset besides the IP
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * header checksum offloading and the TCP/UDP checksum offloading.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * The Packet Checksum is by default computed over the entire packet
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * from the first byte of the DA through the last byte of the CRC,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * including the Ethernet and IP headers.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * It is a hardware limitation that Packet Checksum is mutually
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * exclusive with RSS.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rxcsum = E1000_READ_REG(hw, E1000_RXCSUM);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rxcsum |= E1000_RXCSUM_PCSD;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_init_unicst - Initialize the unicast addresses
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_init_unicst(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int slot;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Here we should consider two situations:
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 1. Chipset is initialized the first time
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initialize the multiple unicast addresses, and
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * save the default MAC address.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 2. Chipset is reset
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Recover the multiple unicast addresses from the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * software data structure to the RAR registers.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Clear the default MAC address in the RAR0 rgister,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * which is loaded from EEPROM when system boot or chipreset,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * this will cause the conficts with add_mac/rem_mac entry
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * points when VMDq is enabled. For this reason, the RAR0
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * must be cleared for both cases mentioned above.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng e1000_rar_clear(hw, 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (!igb->unicst_init) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* Initialize the multiple unicast addresses */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->unicst_total = MAX_NUM_UNICAST_ADDRESSES;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->unicst_avail = igb->unicst_total;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < igb->unicst_total; slot++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->unicst_addr[slot].mac.set = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->unicst_init = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Re-configure the RAR registers */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < igb->unicst_total; slot++) {
c124a83e09115de88ecccd4f689983f42a1d53bdRobert Mustacchi (void) e1000_rar_set_vmdq(hw,
c124a83e09115de88ecccd4f689983f42a1d53bdRobert Mustacchi igb->unicst_addr[slot].mac.addr,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng slot, igb->vmdq_mode,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->unicst_addr[slot].mac.group_index);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * igb_unicst_find - Find the slot for the specified unicast address
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengint
da14cebe459d3275048785f25bd869cb09b5307fEric Chengigb_unicst_find(igb_t *igb, const uint8_t *mac_addr)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int slot;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ASSERT(mutex_owned(&igb->gen_lock));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < igb->unicst_total; slot++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (bcmp(igb->unicst_addr[slot].mac.addr,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_addr, ETHERADDRL) == 0)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (slot);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (-1);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_unicst_set - Set the unicast address to the specified slot
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_unicst_set(igb_t *igb, const uint8_t *mac_addr,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int slot)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Save the unicast address in the software data structure
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy bcopy(mac_addr, igb->unicst_addr[slot].mac.addr, ETHERADDRL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set the unicast address to the RAR register
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c124a83e09115de88ecccd4f689983f42a1d53bdRobert Mustacchi (void) e1000_rar_set(hw, (uint8_t *)mac_addr, slot);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return (EIO);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_multicst_add - Add a multicst address
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_multicst_add(igb_t *igb, const uint8_t *multiaddr)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic struct ether_addr *new_table;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic size_t new_len;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic size_t old_len;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if ((multiaddr[0] & 01) == 0) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR, "Illegal multicast address");
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (EINVAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic if (igb->mcast_count >= igb->mcast_max_num) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Adapter requested more than %d mcast addresses",
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb->mcast_max_num);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (ENOENT);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic if (igb->mcast_count == igb->mcast_alloc_count) {
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic old_len = igb->mcast_alloc_count *
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic sizeof (struct ether_addr);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic new_len = (igb->mcast_alloc_count + MCAST_ALLOC_COUNT) *
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic sizeof (struct ether_addr);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic new_table = kmem_alloc(new_len, KM_NOSLEEP);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic if (new_table == NULL) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic "Not enough memory to alloc mcast table");
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic return (ENOMEM);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic }
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic if (igb->mcast_table != NULL) {
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic bcopy(igb->mcast_table, new_table, old_len);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic kmem_free(igb->mcast_table, old_len);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic }
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb->mcast_alloc_count += MCAST_ALLOC_COUNT;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb->mcast_table = new_table;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic }
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
c869993e79c1eafbec61a56bf6cea848fe754c71xy bcopy(multiaddr,
c869993e79c1eafbec61a56bf6cea848fe754c71xy &igb->mcast_table[igb->mcast_count], ETHERADDRL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->mcast_count++;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Update the multicast table in the hardware
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_setup_multicst(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return (EIO);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_multicst_remove - Remove a multicst address
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_multicst_remove(igb_t *igb, const uint8_t *multiaddr)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic struct ether_addr *new_table;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic size_t new_len;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic size_t old_len;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->mcast_count; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (bcmp(multiaddr, &igb->mcast_table[i],
c869993e79c1eafbec61a56bf6cea848fe754c71xy ETHERADDRL) == 0) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i++; i < igb->mcast_count; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->mcast_table[i - 1] =
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->mcast_table[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->mcast_count--;
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic if ((igb->mcast_alloc_count - igb->mcast_count) >
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic MCAST_ALLOC_COUNT) {
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic old_len = igb->mcast_alloc_count *
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic sizeof (struct ether_addr);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic new_len = (igb->mcast_alloc_count - MCAST_ALLOC_COUNT) *
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic sizeof (struct ether_addr);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic new_table = kmem_alloc(new_len, KM_NOSLEEP);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic if (new_table != NULL) {
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic bcopy(igb->mcast_table, new_table, new_len);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic kmem_free(igb->mcast_table, old_len);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb->mcast_alloc_count -= MCAST_ALLOC_COUNT;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb->mcast_table = new_table;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic }
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic }
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Update the multicast table in the hardware
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_setup_multicst(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return (EIO);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republicstatic void
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republicigb_release_multicast(igb_t *igb)
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic{
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic if (igb->mcast_table != NULL) {
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic kmem_free(igb->mcast_table,
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb->mcast_alloc_count * sizeof (struct ether_addr));
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb->mcast_table = NULL;
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic }
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic}
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_setup_multicast - setup multicast data structures
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This routine initializes all of the multicast related structures
c869993e79c1eafbec61a56bf6cea848fe754c71xy * and save them in the hardware registers.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_setup_multicst(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint8_t *mc_addr_list;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t mc_addr_count;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic ASSERT(igb->mcast_count <= igb->mcast_max_num);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mc_addr_list = (uint8_t *)igb->mcast_table;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mc_addr_count = igb->mcast_count;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Update the multicase addresses to the MTA registers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
7d46e7ad7bb3e7ef36bb4f0816ad4d6c2784f405zhefeng xu - Sun Microsystems - Beijing China e1000_update_mc_addr_list(hw, mc_addr_list, mc_addr_count);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_get_conf - Get driver configurations set in driver.conf
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This routine gets user-configured values out of the configuration
c869993e79c1eafbec61a56bf6cea848fe754c71xy * file igb.conf.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * For each configurable value, there is a minimum, a maximum, and a
c869993e79c1eafbec61a56bf6cea848fe754c71xy * default.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If user does not configure a value, use the default.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If user configures below the minimum, use the minumum.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If user configures above the maximum, use the maxumum.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_get_conf(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t default_mtu;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t flow_control;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t ring_per_group;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb driver supports the following user configurations:
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Link configurations:
c869993e79c1eafbec61a56bf6cea848fe754c71xy * adv_autoneg_cap
c869993e79c1eafbec61a56bf6cea848fe754c71xy * adv_1000fdx_cap
c869993e79c1eafbec61a56bf6cea848fe754c71xy * adv_100fdx_cap
c869993e79c1eafbec61a56bf6cea848fe754c71xy * adv_100hdx_cap
c869993e79c1eafbec61a56bf6cea848fe754c71xy * adv_10fdx_cap
c869993e79c1eafbec61a56bf6cea848fe754c71xy * adv_10hdx_cap
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Note: 1000hdx is not supported.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Jumbo frame configuration:
c869993e79c1eafbec61a56bf6cea848fe754c71xy * default_mtu
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Ethernet flow control configuration:
c869993e79c1eafbec61a56bf6cea848fe754c71xy * flow_control
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Multiple rings configurations:
c869993e79c1eafbec61a56bf6cea848fe754c71xy * tx_queue_number
c869993e79c1eafbec61a56bf6cea848fe754c71xy * tx_ring_size
c869993e79c1eafbec61a56bf6cea848fe754c71xy * rx_queue_number
c869993e79c1eafbec61a56bf6cea848fe754c71xy * rx_ring_size
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Call igb_get_prop() to get the value for a specific
c869993e79c1eafbec61a56bf6cea848fe754c71xy * configuration parameter.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Link configurations
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->param_adv_autoneg_cap = igb_get_prop(igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy PROP_ADV_AUTONEG_CAP, 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->param_adv_1000fdx_cap = igb_get_prop(igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy PROP_ADV_1000FDX_CAP, 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->param_adv_100fdx_cap = igb_get_prop(igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy PROP_ADV_100FDX_CAP, 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->param_adv_100hdx_cap = igb_get_prop(igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy PROP_ADV_100HDX_CAP, 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->param_adv_10fdx_cap = igb_get_prop(igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy PROP_ADV_10FDX_CAP, 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->param_adv_10hdx_cap = igb_get_prop(igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy PROP_ADV_10HDX_CAP, 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Jumbo frame configurations
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy default_mtu = igb_get_prop(igb, PROP_DEFAULT_MTU,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MIN_MTU, MAX_MTU, DEFAULT_MTU);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->max_frame_size = default_mtu +
c869993e79c1eafbec61a56bf6cea848fe754c71xy sizeof (struct ether_vlan_header) + ETHERFCSL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Ethernet flow control configuration
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy flow_control = igb_get_prop(igb, PROP_FLOW_CONTROL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy e1000_fc_none, 4, e1000_fc_full);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (flow_control == 4)
c869993e79c1eafbec61a56bf6cea848fe754c71xy flow_control = e1000_fc_default;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China hw->fc.requested_mode = flow_control;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Multiple rings configurations
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_ring_size = igb_get_prop(igb, PROP_TX_RING_SIZE,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MIN_TX_RING_SIZE, MAX_TX_RING_SIZE, DEFAULT_TX_RING_SIZE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->rx_ring_size = igb_get_prop(igb, PROP_RX_RING_SIZE,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MIN_RX_RING_SIZE, MAX_RX_RING_SIZE, DEFAULT_RX_RING_SIZE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
7d46e7ad7bb3e7ef36bb4f0816ad4d6c2784f405zhefeng xu - Sun Microsystems - Beijing China igb->mr_enable = igb_get_prop(igb, PROP_MR_ENABLE, 0, 1, 0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_rx_groups = igb_get_prop(igb, PROP_RX_GROUP_NUM,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng MIN_RX_GROUP_NUM, MAX_RX_GROUP_NUM, DEFAULT_RX_GROUP_NUM);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /*
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * Currently we do not support VMDq for 82576 and 82580.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * If it is e1000_82576, set num_rx_groups to 1.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China if (hw->mac.type >= e1000_82576)
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->num_rx_groups = 1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (igb->mr_enable) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->num_tx_rings = igb->capab->def_tx_que_num;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->num_rx_rings = igb->capab->def_rx_que_num;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng } else {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_tx_rings = 1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_rx_rings = 1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (igb->num_rx_groups > 1) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "Invalid rx groups number. Please enable multiple "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "rings first");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_rx_groups = 1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Check the divisibility between rx rings and rx groups.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = igb->num_rx_groups; i > 0; i--) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if ((igb->num_rx_rings % i) == 0)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (i != igb->num_rx_groups) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "Invalid rx groups number. Downgrade the rx group "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "number to %d.", i);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_rx_groups = i;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Get the ring number per group.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ring_per_group = igb->num_rx_rings / igb->num_rx_groups;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (igb->num_rx_groups == 1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * One rx ring group, the rx ring number is num_rx_rings.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->vmdq_mode = E1000_VMDQ_OFF;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng } else if (ring_per_group == 1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Multiple rx groups, each group has one rx ring.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->vmdq_mode = E1000_VMDQ_MAC;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng } else {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Multiple groups and multiple rings.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->vmdq_mode = E1000_VMDQ_MAC_RSS;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Tunable used to force an interrupt type. The only use is
c869993e79c1eafbec61a56bf6cea848fe754c71xy * for testing of the lesser interrupt types.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 0 = don't force interrupt type
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 1 = force interrupt type MSIX
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 2 = force interrupt type MSI
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 3 = force interrupt type Legacy
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->intr_force = igb_get_prop(igb, PROP_INTR_FORCE,
d556530cda421a2e47778c115a8d39f8571f104cxy IGB_INTR_NONE, IGB_INTR_LEGACY, IGB_INTR_NONE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_hcksum_enable = igb_get_prop(igb, PROP_TX_HCKSUM_ENABLE,
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->rx_hcksum_enable = igb_get_prop(igb, PROP_RX_HCKSUM_ENABLE,
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->lso_enable = igb_get_prop(igb, PROP_LSO_ENABLE,
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_head_wb_enable = igb_get_prop(igb, PROP_TX_HEAD_WB_ENABLE,
c869993e79c1eafbec61a56bf6cea848fe754c71xy 0, 1, 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo /*
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo * igb LSO needs the tx h/w checksum support.
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo * Here LSO will be disabled if tx h/w checksum has been disabled.
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo */
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo if (igb->tx_hcksum_enable == B_FALSE)
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo igb->lso_enable = B_FALSE;
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_copy_thresh = igb_get_prop(igb, PROP_TX_COPY_THRESHOLD,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MIN_TX_COPY_THRESHOLD, MAX_TX_COPY_THRESHOLD,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DEFAULT_TX_COPY_THRESHOLD);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_recycle_thresh = igb_get_prop(igb, PROP_TX_RECYCLE_THRESHOLD,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MIN_TX_RECYCLE_THRESHOLD, MAX_TX_RECYCLE_THRESHOLD,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DEFAULT_TX_RECYCLE_THRESHOLD);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_overload_thresh = igb_get_prop(igb, PROP_TX_OVERLOAD_THRESHOLD,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MIN_TX_OVERLOAD_THRESHOLD, MAX_TX_OVERLOAD_THRESHOLD,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DEFAULT_TX_OVERLOAD_THRESHOLD);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->tx_resched_thresh = igb_get_prop(igb, PROP_TX_RESCHED_THRESHOLD,
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu MIN_TX_RESCHED_THRESHOLD,
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu MIN(igb->tx_ring_size, MAX_TX_RESCHED_THRESHOLD),
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu igb->tx_ring_size > DEFAULT_TX_RESCHED_THRESHOLD ?
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu DEFAULT_TX_RESCHED_THRESHOLD : DEFAULT_TX_RESCHED_THRESHOLD_LOW);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->rx_copy_thresh = igb_get_prop(igb, PROP_RX_COPY_THRESHOLD,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MIN_RX_COPY_THRESHOLD, MAX_RX_COPY_THRESHOLD,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DEFAULT_RX_COPY_THRESHOLD);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->rx_limit_per_intr = igb_get_prop(igb, PROP_RX_LIMIT_PER_INTR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy MIN_RX_LIMIT_PER_INTR, MAX_RX_LIMIT_PER_INTR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DEFAULT_RX_LIMIT_PER_INTR);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->intr_throttling[0] = igb_get_prop(igb, PROP_INTR_THROTTLING,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->capab->min_intr_throttle,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->capab->max_intr_throttle,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->capab->def_intr_throttle);
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic /*
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic * Max number of multicast addresses
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic */
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb->mcast_max_num =
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic igb_get_prop(igb, PROP_MCAST_MAX_NUM,
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic MIN_MCAST_NUM, MAX_MCAST_NUM, DEFAULT_MCAST_NUM);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_get_prop - Get a property value out of the configuration file igb.conf
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Caller provides the name of the property, a default value, a minimum
c869993e79c1eafbec61a56bf6cea848fe754c71xy * value, and a maximum value.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Return configured value of the property, with default, minimum and
c869993e79c1eafbec61a56bf6cea848fe754c71xy * maximum properly applied.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_get_prop(igb_t *igb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy char *propname, /* name of the property */
c869993e79c1eafbec61a56bf6cea848fe754c71xy int minval, /* minimum acceptable value */
c869993e79c1eafbec61a56bf6cea848fe754c71xy int maxval, /* maximim acceptable value */
c869993e79c1eafbec61a56bf6cea848fe754c71xy int defval) /* default value */
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int value;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Call ddi_prop_get_int() to read the conf settings
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy value = ddi_prop_get_int(DDI_DEV_T_ANY, igb->dip,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_PROP_DONTPASS, propname, defval);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (value > maxval)
c869993e79c1eafbec61a56bf6cea848fe754c71xy value = maxval;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (value < minval)
c869993e79c1eafbec61a56bf6cea848fe754c71xy value = minval;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (value);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_setup_link - Using the link properties to setup the link
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_setup_link(igb_t *igb, boolean_t setup_hw)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_mac_info *mac;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_phy_info *phy;
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t invalid;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac = &igb->hw.mac;
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy = &igb->hw.phy;
c869993e79c1eafbec61a56bf6cea848fe754c71xy invalid = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->param_adv_autoneg_cap == 1) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->autoneg = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy->autoneg_advertised = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 1000hdx is not supported for autonegotiation
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->param_adv_1000fdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy->autoneg_advertised |= ADVERTISE_1000_FULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->param_adv_100fdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy->autoneg_advertised |= ADVERTISE_100_FULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->param_adv_100hdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy->autoneg_advertised |= ADVERTISE_100_HALF;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->param_adv_10fdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy->autoneg_advertised |= ADVERTISE_10_FULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->param_adv_10hdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy->autoneg_advertised |= ADVERTISE_10_HALF;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (phy->autoneg_advertised == 0)
c869993e79c1eafbec61a56bf6cea848fe754c71xy invalid = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->autoneg = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 1000fdx and 1000hdx are not supported for forced link
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->param_adv_100fdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->forced_speed_duplex = ADVERTISE_100_FULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy else if (igb->param_adv_100hdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->forced_speed_duplex = ADVERTISE_100_HALF;
c869993e79c1eafbec61a56bf6cea848fe754c71xy else if (igb->param_adv_10fdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->forced_speed_duplex = ADVERTISE_10_FULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy else if (igb->param_adv_10hdx_cap == 1)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->forced_speed_duplex = ADVERTISE_10_HALF;
c869993e79c1eafbec61a56bf6cea848fe754c71xy else
c869993e79c1eafbec61a56bf6cea848fe754c71xy invalid = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (invalid) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "Invalid link settings. Setup "
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "link to autonegotiation with full link capabilities.");
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac->autoneg = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy->autoneg_advertised = ADVERTISE_1000_FULL |
c869993e79c1eafbec61a56bf6cea848fe754c71xy ADVERTISE_100_FULL | ADVERTISE_100_HALF |
c869993e79c1eafbec61a56bf6cea848fe754c71xy ADVERTISE_10_FULL | ADVERTISE_10_HALF;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (setup_hw) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (e1000_setup_link(&igb->hw) != E1000_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_is_link_up - Check if the link is up
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_is_link_up(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China boolean_t link_up = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * get_link_status is set in the interrupt handler on link-status-change
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * or rx sequence error interrupt. get_link_status will stay
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * false until the e1000_check_for_link establishes link only
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * for copper adapters.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China switch (hw->phy.media_type) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China case e1000_media_type_copper:
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (hw->mac.get_link_status) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (void) e1000_check_for_link(hw);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China link_up = !hw->mac.get_link_status;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China } else {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China link_up = B_TRUE;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China break;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China case e1000_media_type_fiber:
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (void) e1000_check_for_link(hw);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China link_up = (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China break;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China case e1000_media_type_internal_serdes:
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (void) e1000_check_for_link(hw);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China link_up = hw->mac.serdes_has_link;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (link_up);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_link_check - Link status processing
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_link_check(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t speed = 0, duplex = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t link_changed = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb_is_link_up(igb)) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The Link is up, check whether it was marked as down earlier
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->link_state != LINK_STATE_UP) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) e1000_get_speed_and_duplex(hw, &speed, &duplex);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->link_speed = speed;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->link_duplex = duplex;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->link_state = LINK_STATE_UP;
c869993e79c1eafbec61a56bf6cea848fe754c71xy link_changed = B_TRUE;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (!igb->link_complete)
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb_stop_link_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China } else if (igb->link_complete) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->link_state != LINK_STATE_DOWN) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->link_speed = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->link_duplex = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->link_state = LINK_STATE_DOWN;
c869993e79c1eafbec61a56bf6cea848fe754c71xy link_changed = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China return (B_FALSE);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (link_changed);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_local_timer - driver watchdog function
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * This function will handle the hardware stall check, link status
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * check and other routines.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_local_timer(void *arg)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb = (igb_t *)arg;
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China boolean_t link_changed = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (igb->igb_state & IGB_ERROR) {
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb->reset_count++;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (igb_reset(igb) == IGB_SUCCESS)
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China ddi_fm_service_impact(igb->dip, DDI_SERVICE_RESTORED);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb_restart_watchdog_timer(igb);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China return;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China }
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (igb_stall_check(igb) || (igb->igb_state & IGB_STALL)) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_fm_ereport(igb, DDI_FM_DEVICE_STALL);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->reset_count++;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_reset(igb) == IGB_SUCCESS)
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China ddi_fm_service_impact(igb->dip, DDI_SERVICE_RESTORED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb_restart_watchdog_timer(igb);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China return;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (!(igb->igb_state & IGB_SUSPENDED) && (igb->igb_state & IGB_STARTED))
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China link_changed = igb_link_check(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (link_changed)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_link_update(igb->mac_hdl, igb->link_state);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_restart_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China/*
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * igb_link_timer - link setup timer function
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China *
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * It is called when the timer for link setup is expired, which indicates
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * the completion of the link setup. The link state will not be updated
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * until the link setup is completed. And the link state will not be sent
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * to the upper layer through mac_link_update() in this function. It will
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * be updated in the local timer routine or the interrupts service routine
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * after the interface is started (plumbed).
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China */
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinastatic void
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinaigb_link_timer(void *arg)
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China{
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb_t *igb = (igb_t *)arg;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China mutex_enter(&igb->link_lock);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb->link_complete = B_TRUE;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb->link_tid = 0;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China mutex_exit(&igb->link_lock);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China}
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_stall_check - check for transmit stall
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This function checks if the adapter is stalled (in transmit).
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * It is called each time the watchdog timeout is invoked.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If the transmit descriptor reclaim continuously fails,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the watchdog value will increment by 1. If the watchdog
c869993e79c1eafbec61a56bf6cea848fe754c71xy * value exceeds the threshold, the igb is assumed to
c869993e79c1eafbec61a56bf6cea848fe754c71xy * have stalled and need to be reset.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_stall_check(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t result;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->link_state != LINK_STATE_UP)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_FALSE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If any tx ring is stalled, we'll reset the chipset
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy result = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_tx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->recycle_fail > 0)
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->stall_watchdog++;
c869993e79c1eafbec61a56bf6cea848fe754c71xy else
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->stall_watchdog = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->stall_watchdog >= STALL_WATCHDOG_TIMEOUT) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy result = B_TRUE;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China if (hw->mac.type == e1000_82580) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China hw->dev_spec._82575.global_device_reset
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China = B_TRUE;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (result) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->stall_watchdog = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->recycle_fail = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (result);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * is_valid_mac_addr - Check if the mac address is valid
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyis_valid_mac_addr(uint8_t *mac_addr)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy const uint8_t addr_test1[6] = { 0, 0, 0, 0, 0, 0 };
c869993e79c1eafbec61a56bf6cea848fe754c71xy const uint8_t addr_test2[6] =
c869993e79c1eafbec61a56bf6cea848fe754c71xy { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (!(bcmp(addr_test1, mac_addr, ETHERADDRL)) ||
c869993e79c1eafbec61a56bf6cea848fe754c71xy !(bcmp(addr_test2, mac_addr, ETHERADDRL)))
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_FALSE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_TRUE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_find_mac_address(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy#ifdef __sparc
c869993e79c1eafbec61a56bf6cea848fe754c71xy uchar_t *bytes;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct ether_addr sysaddr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint_t nelts;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int err;
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t found = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The "vendor's factory-set address" may already have
c869993e79c1eafbec61a56bf6cea848fe754c71xy * been extracted from the chip, but if the property
c869993e79c1eafbec61a56bf6cea848fe754c71xy * "local-mac-address" is set we use that instead.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * We check whether it looks like an array of 6
c869993e79c1eafbec61a56bf6cea848fe754c71xy * bytes (which it should, if OBP set it). If we can't
c869993e79c1eafbec61a56bf6cea848fe754c71xy * make sense of it this way, we'll ignore it.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy err = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, igb->dip,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_PROP_DONTPASS, "local-mac-address", &bytes, &nelts);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (err == DDI_PROP_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (nelts == ETHERADDRL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy while (nelts--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->mac.addr[nelts] = bytes[nelts];
c869993e79c1eafbec61a56bf6cea848fe754c71xy found = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_prop_free(bytes);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Look up the OBP property "local-mac-address?". If the user has set
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 'local-mac-address? = false', use "the system address" instead.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, igb->dip, 0,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "local-mac-address?", &bytes, &nelts) == DDI_PROP_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (strncmp("false", (caddr_t)bytes, (size_t)nelts) == 0) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (localetheraddr(NULL, &sysaddr) != 0) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy bcopy(&sysaddr, hw->mac.addr, ETHERADDRL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy found = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_prop_free(bytes);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Finally(!), if there's a valid "mac-address" property (created
c869993e79c1eafbec61a56bf6cea848fe754c71xy * if we netbooted from this interface), we must use this instead
c869993e79c1eafbec61a56bf6cea848fe754c71xy * of any of the above to ensure that the NFS/install server doesn't
c869993e79c1eafbec61a56bf6cea848fe754c71xy * get confused by the address changing as Solaris takes over!
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy err = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, igb->dip,
c869993e79c1eafbec61a56bf6cea848fe754c71xy DDI_PROP_DONTPASS, "mac-address", &bytes, &nelts);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (err == DDI_PROP_SUCCESS) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (nelts == ETHERADDRL) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy while (nelts--)
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->mac.addr[nelts] = bytes[nelts];
c869993e79c1eafbec61a56bf6cea848fe754c71xy found = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy ddi_prop_free(bytes);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (found) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy bcopy(hw->mac.addr, hw->mac.perm_addr, ETHERADDRL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_TRUE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy#endif
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Read the device MAC address from the EEPROM
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (e1000_read_mac_addr(hw) != E1000_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_FALSE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_TRUE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy#pragma inline(igb_arm_watchdog_timer)
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_arm_watchdog_timer(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Fire a watchdog timer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_tid =
c869993e79c1eafbec61a56bf6cea848fe754c71xy timeout(igb_local_timer,
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void *)igb, 1 * drv_usectohz(1000000));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_enable_watchdog_timer - Enable and start the driver watchdog timer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyvoid
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_enable_watchdog_timer(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (!igb->watchdog_enable) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_enable = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_start = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_arm_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_disable_watchdog_timer - Disable and stop the driver watchdog timer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyvoid
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_disable_watchdog_timer(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy timeout_id_t tid;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_enable = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_start = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tid = igb->watchdog_tid;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_tid = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tid != 0)
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) untimeout(tid);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_start_watchdog_timer - Start the driver watchdog timer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_start_watchdog_timer(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->watchdog_enable) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (!igb->watchdog_start) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_start = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_arm_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_restart_watchdog_timer - Restart the driver watchdog timer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_restart_watchdog_timer(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->watchdog_start)
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_arm_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_stop_watchdog_timer - Stop the driver watchdog timer
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_stop_watchdog_timer(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy timeout_id_t tid;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_start = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tid = igb->watchdog_tid;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->watchdog_tid = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->watchdog_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tid != 0)
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) untimeout(tid);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China/*
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * igb_start_link_timer - Start the link setup timer
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China */
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinastatic void
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinaigb_start_link_timer(struct igb *igb)
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China{
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China struct e1000_hw *hw = &igb->hw;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China clock_t link_timeout;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (hw->mac.autoneg)
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China link_timeout = PHY_AUTO_NEG_LIMIT *
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China drv_usectohz(100000);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China else
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China link_timeout = PHY_FORCE_LIMIT * drv_usectohz(100000);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China mutex_enter(&igb->link_lock);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (hw->phy.autoneg_wait_to_complete) {
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb->link_complete = B_TRUE;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China } else {
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb->link_complete = B_FALSE;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb->link_tid = timeout(igb_link_timer, (void *)igb,
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China link_timeout);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China }
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China mutex_exit(&igb->link_lock);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China}
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China/*
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China * igb_stop_link_timer - Stop the link setup timer
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China */
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinastatic void
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing Chinaigb_stop_link_timer(struct igb *igb)
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China{
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China timeout_id_t tid;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China mutex_enter(&igb->link_lock);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb->link_complete = B_TRUE;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China tid = igb->link_tid;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China igb->link_tid = 0;
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China mutex_exit(&igb->link_lock);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (tid != 0)
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China (void) untimeout(tid);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China}
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_disable_adapter_interrupts - Clear/disable all hardware interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_disable_adapter_interrupts(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set the IMC register to mask all the interrupts,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * including the tx interrupts.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IMC, ~0);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IAM, 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Additional disabling for MSI-X
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->intr_type == DDI_INTR_TYPE_MSIX) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_EIMC, ~0);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_EIAC, 0);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_EIAM, 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_FLUSH(hw);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China/*
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * igb_enable_adapter_interrupts_82580 - Enable NIC interrupts for 82580
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing Chinastatic void
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing Chinaigb_enable_adapter_interrupts_82580(igb_t *igb)
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China{
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China struct e1000_hw *hw = &igb->hw;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* Clear any pending interrupts */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China (void) E1000_READ_REG(hw, E1000_ICR);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb->ims_mask |= E1000_IMS_DRSTA;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China if (igb->intr_type == DDI_INTR_TYPE_MSIX) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* Interrupt enabling for MSI-X */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_EIMS, igb->eims_mask);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_EIAC, igb->eims_mask);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb->ims_mask = (E1000_IMS_LSC | E1000_IMS_DRSTA);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IMS, igb->ims_mask);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China } else { /* Interrupt enabling for MSI and legacy */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IVAR0, E1000_IVAR_VALID);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb->ims_mask = IMS_ENABLE_MASK | E1000_IMS_TXQE;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb->ims_mask |= E1000_IMS_DRSTA;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IMS, igb->ims_mask);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* Disable auto-mask for ICR interrupt bits */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IAM, 0);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_FLUSH(hw);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China}
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * igb_enable_adapter_interrupts_82576 - Enable NIC interrupts for 82576
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinaigb_enable_adapter_interrupts_82576(igb_t *igb)
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China{
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China struct e1000_hw *hw = &igb->hw;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /* Clear any pending interrupts */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (void) E1000_READ_REG(hw, E1000_ICR);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China if (igb->intr_type == DDI_INTR_TYPE_MSIX) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* Interrupt enabling for MSI-X */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_EIMS, igb->eims_mask);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_EIAC, igb->eims_mask);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->ims_mask = E1000_IMS_LSC;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_LSC);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China } else {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* Interrupt enabling for MSI and legacy */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IVAR0, E1000_IVAR_VALID);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->ims_mask = IMS_ENABLE_MASK | E1000_IMS_TXQE;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IMS,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China (IMS_ENABLE_MASK | E1000_IMS_TXQE));
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* Disable auto-mask for ICR interrupt bits */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IAM, 0);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_FLUSH(hw);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China}
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China/*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * igb_enable_adapter_interrupts_82575 - Enable NIC interrupts for 82575
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinastatic void
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinaigb_enable_adapter_interrupts_82575(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t reg;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /* Clear any pending interrupts */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China (void) E1000_READ_REG(hw, E1000_ICR);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->intr_type == DDI_INTR_TYPE_MSIX) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Interrupt enabling for MSI-X */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_EIMS, igb->eims_mask);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_EIAC, igb->eims_mask);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->ims_mask = E1000_IMS_LSC;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_LSC);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Enable MSI-X PBA support */
c869993e79c1eafbec61a56bf6cea848fe754c71xy reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
c869993e79c1eafbec61a56bf6cea848fe754c71xy reg |= E1000_CTRL_EXT_PBA_CLR;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Non-selective interrupt clear-on-read */
c869993e79c1eafbec61a56bf6cea848fe754c71xy reg |= E1000_CTRL_EXT_IRCA; /* Called NSICR in the EAS */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Interrupt enabling for MSI and legacy */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->ims_mask = IMS_ENABLE_MASK;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_IMS, IMS_ENABLE_MASK);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_FLUSH(hw);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Loopback Support
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic lb_property_t lb_normal =
c869993e79c1eafbec61a56bf6cea848fe754c71xy { normal, "normal", IGB_LB_NONE };
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic lb_property_t lb_external =
c869993e79c1eafbec61a56bf6cea848fe754c71xy { external, "External", IGB_LB_EXTERNAL };
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic lb_property_t lb_phy =
c869993e79c1eafbec61a56bf6cea848fe754c71xy { internal, "PHY", IGB_LB_INTERNAL_PHY };
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic lb_property_t lb_serdes =
c869993e79c1eafbec61a56bf6cea848fe754c71xy { internal, "SerDes", IGB_LB_INTERNAL_SERDES };
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyenum ioc_reply
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_loopback_ioctl(igb_t *igb, struct iocblk *iocp, mblk_t *mp)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy lb_info_sz_t *lbsp;
c869993e79c1eafbec61a56bf6cea848fe754c71xy lb_property_t *lbpp;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t *lbmp;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t value;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (mp->b_cont == NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IOC_INVAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy switch (iocp->ioc_cmd) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy default:
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IOC_INVAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case LB_GET_INFO_SIZE:
c869993e79c1eafbec61a56bf6cea848fe754c71xy size = sizeof (lb_info_sz_t);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (iocp->ioc_count != size)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IOC_INVAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy value = sizeof (lb_normal);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (hw->phy.media_type == e1000_media_type_copper)
c869993e79c1eafbec61a56bf6cea848fe754c71xy value += sizeof (lb_phy);
c869993e79c1eafbec61a56bf6cea848fe754c71xy else
c869993e79c1eafbec61a56bf6cea848fe754c71xy value += sizeof (lb_serdes);
c869993e79c1eafbec61a56bf6cea848fe754c71xy value += sizeof (lb_external);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy lbsp = (lb_info_sz_t *)(uintptr_t)mp->b_cont->b_rptr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy *lbsp = value;
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case LB_GET_INFO:
c869993e79c1eafbec61a56bf6cea848fe754c71xy value = sizeof (lb_normal);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (hw->phy.media_type == e1000_media_type_copper)
c869993e79c1eafbec61a56bf6cea848fe754c71xy value += sizeof (lb_phy);
c869993e79c1eafbec61a56bf6cea848fe754c71xy else
c869993e79c1eafbec61a56bf6cea848fe754c71xy value += sizeof (lb_serdes);
c869993e79c1eafbec61a56bf6cea848fe754c71xy value += sizeof (lb_external);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy size = value;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (iocp->ioc_count != size)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IOC_INVAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy value = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy lbpp = (lb_property_t *)(uintptr_t)mp->b_cont->b_rptr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy lbpp[value++] = lb_normal;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (hw->phy.media_type == e1000_media_type_copper)
c869993e79c1eafbec61a56bf6cea848fe754c71xy lbpp[value++] = lb_phy;
c869993e79c1eafbec61a56bf6cea848fe754c71xy else
c869993e79c1eafbec61a56bf6cea848fe754c71xy lbpp[value++] = lb_serdes;
c869993e79c1eafbec61a56bf6cea848fe754c71xy lbpp[value++] = lb_external;
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case LB_GET_MODE:
c869993e79c1eafbec61a56bf6cea848fe754c71xy size = sizeof (uint32_t);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (iocp->ioc_count != size)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IOC_INVAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy lbmp = (uint32_t *)(uintptr_t)mp->b_cont->b_rptr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy *lbmp = igb->loopback_mode;
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case LB_SET_MODE:
c869993e79c1eafbec61a56bf6cea848fe754c71xy size = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (iocp->ioc_count != sizeof (uint32_t))
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IOC_INVAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy lbmp = (uint32_t *)(uintptr_t)mp->b_cont->b_rptr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (!igb_set_loopback_mode(igb, *lbmp))
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IOC_INVAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy iocp->ioc_count = size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy iocp->ioc_error = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return (IOC_INVAL);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IOC_REPLY);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_set_loopback_mode - Setup loopback based on the loopback mode
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic boolean_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_set_loopback_mode(igb_t *igb, uint32_t mode)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (mode == igb->loopback_mode)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_TRUE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->loopback_mode = mode;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (mode == IGB_LB_NONE) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Reset the chip */
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->phy.autoneg_wait_to_complete = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) igb_reset(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw->phy.autoneg_wait_to_complete = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_TRUE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy switch (mode) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy default:
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_FALSE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case IGB_LB_EXTERNAL:
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_set_external_loopback(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case IGB_LB_INTERNAL_PHY:
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_set_internal_phy_loopback(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case IGB_LB_INTERNAL_SERDES:
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_set_internal_serdes_loopback(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * When external loopback is set, wait up to 1000ms to get the link up.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * According to test, 1000ms can work and it's an experimental value.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (mode == IGB_LB_EXTERNAL) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China for (i = 0; i <= 10; i++) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mutex_enter(&igb->gen_lock);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) igb_link_check(igb);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China mutex_exit(&igb->gen_lock);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb->link_state == LINK_STATE_UP)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China break;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China msec_delay(100);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb->link_state != LINK_STATE_UP) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Does not support external loopback.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * Reset driver to loopback none.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->loopback_mode = IGB_LB_NONE;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /* Reset the chip */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China hw->phy.autoneg_wait_to_complete = B_TRUE;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) igb_reset(igb);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China hw->phy.autoneg_wait_to_complete = B_FALSE;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "Set external loopback "
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "failed, reset to loopback none.");
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China return (B_FALSE);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (B_TRUE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_set_external_loopback - Set the external loopback mode
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_set_external_loopback(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw;
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu uint32_t ctrl_ext;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu /* Set link mode to PHY (00b) in the Extended Control register */
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu ctrl_ext &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) e1000_write_phy_reg(hw, 0x0, 0x0140);
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu (void) e1000_write_phy_reg(hw, 0x9, 0x1a00);
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) e1000_write_phy_reg(hw, 0x12, 0x1610);
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) e1000_write_phy_reg(hw, 0x1f37, 0x3f1c);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_set_internal_phy_loopback - Set the internal PHY loopback mode
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_set_internal_phy_loopback(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t ctrl_ext;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_ctrl;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_pconf;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Set link mode to PHY (00b) in the Extended Control register */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl_ext &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set PHY control register (0x4140):
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set full duplex mode
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set loopback bit
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Clear auto-neg enable bit
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set PHY speed
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy_ctrl = MII_CR_FULL_DUPLEX | MII_CR_SPEED_1000 | MII_CR_LOOPBACK;
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) e1000_write_phy_reg(hw, PHY_CONTROL, phy_ctrl);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Set the link disable bit in the Port Configuration register */
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) e1000_read_phy_reg(hw, 0x10, &phy_pconf);
c869993e79c1eafbec61a56bf6cea848fe754c71xy phy_pconf |= (uint16_t)1 << 14;
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) e1000_write_phy_reg(hw, 0x10, phy_pconf);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_set_internal_serdes_loopback - Set the internal SerDes loopback mode
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_set_internal_serdes_loopback(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t ctrl_ext;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t ctrl;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t pcs_lctl;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t connsw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Set link mode to SerDes (11b) in the Extended Control register */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Configure the SerDes to loopback */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_SCTL, 0x410);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Set Device Control register */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl = E1000_READ_REG(hw, E1000_CTRL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl |= (E1000_CTRL_FD | /* Force full duplex */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_CTRL_SLU); /* Force link up */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl &= ~(E1000_CTRL_RFCE | /* Disable receive flow control */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_CTRL_TFCE | /* Disable transmit flow control */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_CTRL_LRST); /* Clear link reset */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Set PCS Link Control register */
c869993e79c1eafbec61a56bf6cea848fe754c71xy pcs_lctl = E1000_READ_REG(hw, E1000_PCS_LCTL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy pcs_lctl |= (E1000_PCS_LCTL_FORCE_LINK |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_PCS_LCTL_FSD |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_PCS_LCTL_FDV_FULL |
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_PCS_LCTL_FLV_LINK_UP);
c869993e79c1eafbec61a56bf6cea848fe754c71xy pcs_lctl &= ~E1000_PCS_LCTL_AN_ENABLE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_PCS_LCTL, pcs_lctl);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Set the Copper/Fiber Switch Control - CONNSW register */
c869993e79c1eafbec61a56bf6cea848fe754c71xy connsw = E1000_READ_REG(hw, E1000_CONNSW);
c869993e79c1eafbec61a56bf6cea848fe754c71xy connsw &= ~E1000_CONNSW_ENRGSRC;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_CONNSW, connsw);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy#pragma inline(igb_intr_rx_work)
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_intr_rx_work - rx processing of ISR
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_intr_rx_work(igb_rx_ring_t *rx_ring)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy mblk_t *mp;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&rx_ring->rx_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mp = igb_rx(rx_ring, IGB_NO_POLL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&rx_ring->rx_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (mp != NULL)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_rx_ring(rx_ring->igb->mac_hdl, rx_ring->ring_handle, mp,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_ring->ring_gen_num);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy#pragma inline(igb_intr_tx_work)
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_intr_tx_work - tx processing of ISR
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_intr_tx_work(igb_tx_ring_t *tx_ring)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb_t *igb = tx_ring->igb;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Recycle the tx descriptors */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tx_recycle(tx_ring);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Schedule the re-transmit */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_ring->reschedule &&
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (tx_ring->tbd_free >= igb->tx_resched_thresh)) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->reschedule = B_FALSE;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_tx_ring_update(tx_ring->igb->mac_hdl, tx_ring->ring_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy IGB_DEBUG_STAT(tx_ring->stat_reschedule);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng#pragma inline(igb_intr_link_work)
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * igb_intr_link_work - link-status-change processing of ISR
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
da14cebe459d3275048785f25bd869cb09b5307fEric Chengigb_intr_link_work(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t link_changed;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_stop_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Because we got a link-status-change interrupt, force
c869993e79c1eafbec61a56bf6cea848fe754c71xy * e1000_check_for_link() to look at phy
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->hw.mac.get_link_status = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* igb_link_check takes care of link status change */
c869993e79c1eafbec61a56bf6cea848fe754c71xy link_changed = igb_link_check(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Get new phy state */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_get_phy_state(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (link_changed)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_link_update(igb->mac_hdl, igb->link_state);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_start_watchdog_timer(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_intr_legacy - Interrupt handler for legacy interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic uint_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_intr_legacy(void *arg1, void *arg2)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb = (igb_t *)arg1;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t icr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy mblk_t *mp;
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t tx_reschedule;
c869993e79c1eafbec61a56bf6cea848fe754c71xy boolean_t link_changed;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint_t result;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy _NOTE(ARGUNUSED(arg2));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_enter(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->igb_state & IGB_SUSPENDED) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_INTR_UNCLAIMED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mp = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_reschedule = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy link_changed = B_FALSE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy icr = E1000_READ_REG(&igb->hw, E1000_ICR);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
b227c420ebc30f71999e5e7cd26ca1b23d2cb088chenlu chen - Sun Microsystems - Beijing China mutex_exit(&igb->gen_lock);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_ERROR);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China return (DDI_INTR_UNCLAIMED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China }
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (icr & E1000_ICR_INT_ASSERTED) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * E1000_ICR_INT_ASSERTED bit was set:
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Read(Clear) the ICR, claim this interrupt,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * look for work to do.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(igb->num_rx_rings == 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(igb->num_tx_rings == 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* Make sure all interrupt causes cleared */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China (void) E1000_READ_REG(&igb->hw, E1000_EICR);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (icr & E1000_ICR_RXT0) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mp = igb_rx(&igb->rx_rings[0], IGB_NO_POLL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (icr & E1000_ICR_TXDW) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring = &igb->tx_rings[0];
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Recycle the tx descriptors */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->tx_recycle(tx_ring);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Schedule the re-transmit */
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_reschedule = (tx_ring->reschedule &&
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (tx_ring->tbd_free >= igb->tx_resched_thresh));
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (icr & E1000_ICR_LSC) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Because we got a link-status-change interrupt, force
c869993e79c1eafbec61a56bf6cea848fe754c71xy * e1000_check_for_link() to look at phy
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->hw.mac.get_link_status = B_TRUE;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* igb_link_check takes care of link status change */
c869993e79c1eafbec61a56bf6cea848fe754c71xy link_changed = igb_link_check(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Get new phy state */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_get_phy_state(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China if (icr & E1000_ICR_DRSTA) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* 82580 Full Device Reset needed */
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_STALL);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy result = DDI_INTR_CLAIMED;
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * E1000_ICR_INT_ASSERTED bit was not set:
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Don't claim this interrupt.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy result = DDI_INTR_UNCLAIMED;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy mutex_exit(&igb->gen_lock);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Do the following work outside of the gen_lock
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (mp != NULL)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_rx(igb->mac_hdl, NULL, mp);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (tx_reschedule) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy tx_ring->reschedule = B_FALSE;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_tx_ring_update(igb->mac_hdl, tx_ring->ring_handle);
c869993e79c1eafbec61a56bf6cea848fe754c71xy IGB_DEBUG_STAT(tx_ring->stat_reschedule);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (link_changed)
c869993e79c1eafbec61a56bf6cea848fe754c71xy mac_link_update(igb->mac_hdl, igb->link_state);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (result);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_intr_msi - Interrupt handler for MSI
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic uint_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_intr_msi(void *arg1, void *arg2)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb = (igb_t *)arg1;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t icr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy _NOTE(ARGUNUSED(arg2));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy icr = E1000_READ_REG(&igb->hw, E1000_ICR);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_ERROR);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China return (DDI_INTR_CLAIMED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China }
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* Make sure all interrupt causes cleared */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China (void) E1000_READ_REG(&igb->hw, E1000_EICR);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * For MSI interrupt, we have only one vector,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * so we have only one rx ring and one tx ring enabled.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(igb->num_rx_rings == 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(igb->num_tx_rings == 1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (icr & E1000_ICR_RXT0) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_intr_rx_work(&igb->rx_rings[0]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (icr & E1000_ICR_TXDW) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_intr_tx_work(&igb->tx_rings[0]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (icr & E1000_ICR_LSC) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_intr_link_work(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China if (icr & E1000_ICR_DRSTA) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* 82580 Full Device Reset needed */
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_STALL);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_INTR_CLAIMED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_intr_rx - Interrupt handler for rx
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic uint_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_intr_rx(void *arg1, void *arg2)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rx_ring_t *rx_ring = (igb_rx_ring_t *)arg1;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy _NOTE(ARGUNUSED(arg2));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Only used via MSI-X vector so don't check cause bits
c869993e79c1eafbec61a56bf6cea848fe754c71xy * and only clean the given ring.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_intr_rx_work(rx_ring);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_INTR_CLAIMED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * igb_intr_tx - Interrupt handler for tx
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic uint_t
da14cebe459d3275048785f25bd869cb09b5307fEric Chengigb_intr_tx(void *arg1, void *arg2)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_tx_ring_t *tx_ring = (igb_tx_ring_t *)arg1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng _NOTE(ARGUNUSED(arg2));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Only used via MSI-X vector so don't check cause bits
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * and only clean the given ring.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_intr_tx_work(tx_ring);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (DDI_INTR_CLAIMED);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_intr_tx_other - Interrupt handler for both tx and other
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic uint_t
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_intr_tx_other(void *arg1, void *arg2)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_t *igb = (igb_t *)arg1;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t icr;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy _NOTE(ARGUNUSED(arg2));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy icr = E1000_READ_REG(&igb->hw, E1000_ICR);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_ERROR);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China return (DDI_INTR_CLAIMED);
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China }
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Look for tx reclaiming work first. Remember, in the
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * case of only interrupt sharing, only one tx ring is
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * used
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_intr_tx_work(&igb->tx_rings[0]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * Check for "other" causes.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (icr & E1000_ICR_LSC) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_intr_link_work(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China /*
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * The DOUTSYNC bit indicates a tx packet dropped because
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * DMA engine gets "out of sync". There isn't a real fix
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * for this. The Intel recommendation is to count the number
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * of occurrences so user can detect when it is happening.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * The issue is non-fatal and there's no recovery action
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China * available.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China */
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China if (icr & E1000_ICR_DOUTSYNC) {
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China IGB_STAT(igb->dout_sync);
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China }
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China if (icr & E1000_ICR_DRSTA) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* 82580 Full Device Reset needed */
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China atomic_or_32(&igb->igb_state, IGB_STALL);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (DDI_INTR_CLAIMED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_alloc_intrs - Allocate interrupts for the driver
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Normal sequence is to try MSI-X; if not sucessful, try MSI;
c869993e79c1eafbec61a56bf6cea848fe754c71xy * if not successful, try Legacy.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb->intr_force can be used to force sequence to start with
c869993e79c1eafbec61a56bf6cea848fe754c71xy * any of the 3 types.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If MSI-X is not used, number of tx/rx rings is forced to 1.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_alloc_intrs(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy dev_info_t *devinfo;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int intr_types;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy devinfo = igb->dip;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Get supported interrupt types */
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_get_supported_types(devinfo, &intr_types);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Get supported interrupt types failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "Supported interrupt types: %x",
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov intr_types);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->intr_type = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Install MSI-X interrupts */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if ((intr_types & DDI_INTR_TYPE_MSIX) &&
c869993e79c1eafbec61a56bf6cea848fe754c71xy (igb->intr_force <= IGB_INTR_MSIX)) {
fa25784ca4b51c206177d891a654f1d36a25d41fxy rc = igb_alloc_intr_handles(igb, DDI_INTR_TYPE_MSIX);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc == IGB_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Allocate MSI-X failed, trying MSI interrupts...");
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* MSI-X not used, force rings to 1 */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->num_rx_rings = 1;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->num_tx_rings = 1;
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "MSI-X not used, force rx and tx queue number to 1");
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Install MSI interrupts */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if ((intr_types & DDI_INTR_TYPE_MSI) &&
c869993e79c1eafbec61a56bf6cea848fe754c71xy (igb->intr_force <= IGB_INTR_MSI)) {
fa25784ca4b51c206177d891a654f1d36a25d41fxy rc = igb_alloc_intr_handles(igb, DDI_INTR_TYPE_MSI);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc == IGB_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Allocate MSI failed, trying Legacy interrupts...");
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Install legacy interrupts */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (intr_types & DDI_INTR_TYPE_FIXED) {
fa25784ca4b51c206177d891a654f1d36a25d41fxy rc = igb_alloc_intr_handles(igb, DDI_INTR_TYPE_FIXED);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc == IGB_SUCCESS)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Allocate Legacy interrupts failed");
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* If none of the 3 types succeeded, return failure */
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
fa25784ca4b51c206177d891a654f1d36a25d41fxy * igb_alloc_intr_handles - Allocate interrupt handles.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
fa25784ca4b51c206177d891a654f1d36a25d41fxy * For legacy and MSI, only 1 handle is needed. For MSI-X,
fa25784ca4b51c206177d891a654f1d36a25d41fxy * if fewer than 2 handles are available, return failure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Upon success, this sets the number of Rx rings to a number that
fa25784ca4b51c206177d891a654f1d36a25d41fxy * matches the handles available for Rx interrupts.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
fa25784ca4b51c206177d891a654f1d36a25d41fxyigb_alloc_intr_handles(igb_t *igb, int intr_type)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy dev_info_t *devinfo;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int orig, request, count, avail, actual;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int diff, minimum;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy devinfo = igb->dip;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxy switch (intr_type) {
fa25784ca4b51c206177d891a654f1d36a25d41fxy case DDI_INTR_TYPE_FIXED:
fa25784ca4b51c206177d891a654f1d36a25d41fxy request = 1; /* Request 1 legacy interrupt handle */
fa25784ca4b51c206177d891a654f1d36a25d41fxy minimum = 1;
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "interrupt type: legacy");
fa25784ca4b51c206177d891a654f1d36a25d41fxy break;
fa25784ca4b51c206177d891a654f1d36a25d41fxy
fa25784ca4b51c206177d891a654f1d36a25d41fxy case DDI_INTR_TYPE_MSI:
fa25784ca4b51c206177d891a654f1d36a25d41fxy request = 1; /* Request 1 MSI interrupt handle */
fa25784ca4b51c206177d891a654f1d36a25d41fxy minimum = 1;
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "interrupt type: MSI");
fa25784ca4b51c206177d891a654f1d36a25d41fxy break;
fa25784ca4b51c206177d891a654f1d36a25d41fxy
fa25784ca4b51c206177d891a654f1d36a25d41fxy case DDI_INTR_TYPE_MSIX:
fa25784ca4b51c206177d891a654f1d36a25d41fxy /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Number of vectors for the adapter is
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * # rx rings + # tx rings
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * One of tx vectors is for tx & other
fa25784ca4b51c206177d891a654f1d36a25d41fxy */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng request = igb->num_rx_rings + igb->num_tx_rings;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng orig = request;
fa25784ca4b51c206177d891a654f1d36a25d41fxy minimum = 2;
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "interrupt type: MSI-X");
fa25784ca4b51c206177d891a654f1d36a25d41fxy break;
fa25784ca4b51c206177d891a654f1d36a25d41fxy
fa25784ca4b51c206177d891a654f1d36a25d41fxy default:
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
fa25784ca4b51c206177d891a654f1d36a25d41fxy "invalid call to igb_alloc_intr_handles(): %d\n",
fa25784ca4b51c206177d891a654f1d36a25d41fxy intr_type);
fa25784ca4b51c206177d891a654f1d36a25d41fxy return (IGB_FAILURE);
fa25784ca4b51c206177d891a654f1d36a25d41fxy }
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "interrupt handles requested: %d minimum: %d",
fa25784ca4b51c206177d891a654f1d36a25d41fxy request, minimum);
fa25784ca4b51c206177d891a654f1d36a25d41fxy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
fa25784ca4b51c206177d891a654f1d36a25d41fxy * Get number of supported interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
fa25784ca4b51c206177d891a654f1d36a25d41fxy rc = ddi_intr_get_nintrs(devinfo, intr_type, &count);
fa25784ca4b51c206177d891a654f1d36a25d41fxy if ((rc != DDI_SUCCESS) || (count < minimum)) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
fa25784ca4b51c206177d891a654f1d36a25d41fxy "Get supported interrupt number failed. "
fa25784ca4b51c206177d891a654f1d36a25d41fxy "Return: %d, count: %d", rc, count);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "interrupts supported: %d", count);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxy /*
fa25784ca4b51c206177d891a654f1d36a25d41fxy * Get number of available interrupts
fa25784ca4b51c206177d891a654f1d36a25d41fxy */
fa25784ca4b51c206177d891a654f1d36a25d41fxy rc = ddi_intr_get_navail(devinfo, intr_type, &avail);
fa25784ca4b51c206177d891a654f1d36a25d41fxy if ((rc != DDI_SUCCESS) || (avail < minimum)) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
fa25784ca4b51c206177d891a654f1d36a25d41fxy "Get available interrupt number failed. "
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Return: %d, available: %d", rc, avail);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "interrupts available: %d", avail);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (avail < request) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Request %d handles, %d available",
c869993e79c1eafbec61a56bf6cea848fe754c71xy request, avail);
c869993e79c1eafbec61a56bf6cea848fe754c71xy request = avail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy actual = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->intr_cnt = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxy /*
fa25784ca4b51c206177d891a654f1d36a25d41fxy * Allocate an array of interrupt handles
fa25784ca4b51c206177d891a654f1d36a25d41fxy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->intr_size = request * sizeof (ddi_intr_handle_t);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->htable = kmem_alloc(igb->intr_size, KM_SLEEP);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxy rc = ddi_intr_alloc(devinfo, igb->htable, intr_type, 0,
c869993e79c1eafbec61a56bf6cea848fe754c71xy request, &actual, DDI_INTR_ALLOC_NORMAL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "Allocate interrupts failed. "
c869993e79c1eafbec61a56bf6cea848fe754c71xy "return: %d, request: %d, actual: %d",
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc, request, actual);
fa25784ca4b51c206177d891a654f1d36a25d41fxy goto alloc_handle_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO, "interrupts actually allocated: %d", actual);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->intr_cnt = actual;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxy if (actual < minimum) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov "Insufficient interrupt handles allocated: %d",
c869993e79c1eafbec61a56bf6cea848fe754c71xy actual);
fa25784ca4b51c206177d891a654f1d36a25d41fxy goto alloc_handle_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxy /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For MSI-X, actual might force us to reduce number of tx & rx rings
fa25784ca4b51c206177d891a654f1d36a25d41fxy */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if ((intr_type == DDI_INTR_TYPE_MSIX) && (orig > actual)) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng diff = orig - actual;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (diff < igb->num_tx_rings) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "MSI-X vectors force Tx queue number to %d",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_tx_rings - diff);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_tx_rings -= diff;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng } else {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "MSI-X vectors force Tx queue number to 1");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_tx_rings = 1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
fa25784ca4b51c206177d891a654f1d36a25d41fxy "MSI-X vectors force Rx queue number to %d",
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng actual - 1);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->num_rx_rings = actual - 1;
fa25784ca4b51c206177d891a654f1d36a25d41fxy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxy /*
fa25784ca4b51c206177d891a654f1d36a25d41fxy * Get priority for first vector, assume remaining are all the same
fa25784ca4b51c206177d891a654f1d36a25d41fxy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_get_pri(igb->htable[0], &igb->intr_pri);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Get interrupt priority failed: %d", rc);
fa25784ca4b51c206177d891a654f1d36a25d41fxy goto alloc_handle_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_get_cap(igb->htable[0], &igb->intr_cap);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Get interrupt cap failed: %d", rc);
fa25784ca4b51c206177d891a654f1d36a25d41fxy goto alloc_handle_fail;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxy igb->intr_type = intr_type;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxyalloc_handle_fail:
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rem_intrs(igb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_add_intr_handlers - Add interrupt handlers based on the interrupt type
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Before adding the interrupt handlers, the interrupt vectors have
c869993e79c1eafbec61a56bf6cea848fe754c71xy * been allocated, and the rx/tx rings have also been allocated.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_add_intr_handlers(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb_rx_ring_t *rx_ring;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb_tx_ring_t *tx_ring;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int vector;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy vector = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy switch (igb->intr_type) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy case DDI_INTR_TYPE_MSIX:
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Add interrupt handler for tx + other */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng tx_ring = &igb->tx_rings[0];
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_add_handler(igb->htable[vector],
c869993e79c1eafbec61a56bf6cea848fe754c71xy (ddi_intr_handler_t *)igb_intr_tx_other,
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void *)igb, NULL);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Add tx/other interrupt handler failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng tx_ring->intr_vector = vector;
c869993e79c1eafbec61a56bf6cea848fe754c71xy vector++;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Add interrupt handler for each rx ring */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring = &igb->rx_rings[i];
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_add_handler(igb->htable[vector],
c869993e79c1eafbec61a56bf6cea848fe754c71xy (ddi_intr_handler_t *)igb_intr_rx,
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void *)rx_ring, NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Add rx interrupt handler failed. "
c869993e79c1eafbec61a56bf6cea848fe754c71xy "return: %d, rx ring: %d", rc, i);
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (vector--; vector >= 0; vector--) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void) ddi_intr_remove_handler(
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->htable[vector]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring->intr_vector = vector;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy vector++;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* Add interrupt handler for each tx ring from 2nd ring */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 1; i < igb->num_tx_rings; i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng tx_ring = &igb->tx_rings[i];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rc = ddi_intr_add_handler(igb->htable[vector],
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (ddi_intr_handler_t *)igb_intr_tx,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void *)tx_ring, NULL);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "Add tx interrupt handler failed. "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "return: %d, tx ring: %d", rc, i);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (vector--; vector >= 0; vector--) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) ddi_intr_remove_handler(
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->htable[vector]);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (IGB_FAILURE);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng tx_ring->intr_vector = vector;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng vector++;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case DDI_INTR_TYPE_MSI:
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Add interrupt handlers for the only vector */
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_add_handler(igb->htable[vector],
c869993e79c1eafbec61a56bf6cea848fe754c71xy (ddi_intr_handler_t *)igb_intr_msi,
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void *)igb, NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Add MSI interrupt handler failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring = &igb->rx_rings[0];
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring->intr_vector = vector;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy vector++;
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy case DDI_INTR_TYPE_FIXED:
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Add interrupt handlers for the only vector */
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_add_handler(igb->htable[vector],
c869993e79c1eafbec61a56bf6cea848fe754c71xy (ddi_intr_handler_t *)igb_intr_legacy,
c869993e79c1eafbec61a56bf6cea848fe754c71xy (void *)igb, NULL);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Add legacy interrupt handler failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring = &igb->rx_rings[0];
c869993e79c1eafbec61a56bf6cea848fe754c71xy rx_ring->intr_vector = vector;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy vector++;
c869993e79c1eafbec61a56bf6cea848fe754c71xy break;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy default:
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(vector == igb->intr_cnt);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * igb_setup_msix_82575 - setup 82575 adapter to use MSI-X interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * For each vector enabled on the adapter, Set the MSIXBM register accordingly
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinaigb_setup_msix_82575(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t eims = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i, vector;
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Set vector for tx ring 0 and other causes.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * NOTE assumption that it is vector 0.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy vector = 0;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->eims_mask = E1000_EICR_TX_QUEUE0 | E1000_EICR_OTHER;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_MSIXBM(vector), igb->eims_mask);
c869993e79c1eafbec61a56bf6cea848fe754c71xy vector++;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->num_rx_rings; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Set vector for each rx ring
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy eims = (E1000_EICR_RX_QUEUE0 << i);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_MSIXBM(vector), eims);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Accumulate bits to enable in
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * igb_enable_adapter_interrupts_82575()
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->eims_mask |= eims;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy vector++;
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 1; i < igb->num_tx_rings; i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Set vector for each tx ring from 2nd tx ring
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng eims = (E1000_EICR_TX_QUEUE0 << i);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng E1000_WRITE_REG(hw, E1000_MSIXBM(vector), eims);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Accumulate bits to enable in
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * igb_enable_adapter_interrupts_82575()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng igb->eims_mask |= eims;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng vector++;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(vector == igb->intr_cnt);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Disable IAM for ICR interrupt bits
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_IAM, 0);
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_FLUSH(hw);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China/*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * igb_setup_msix_82576 - setup 82576 adapter to use MSI-X interrupts
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China *
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * 82576 uses a table based method for assigning vectors. Each queue has a
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * single entry in the table to which we write a vector number along with a
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * "valid" bit. The entry is a single byte in a 4-byte register. Vectors
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * take a different position in the 4-byte register depending on whether
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * they are numbered above or below 8.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinastatic void
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinaigb_setup_msix_82576(igb_t *igb)
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China{
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China struct e1000_hw *hw = &igb->hw;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China uint32_t ivar, index, vector;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China int i;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* must enable msi-x capability before IVAR settings */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_GPIE,
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China (E1000_GPIE_MSIX_MODE | E1000_GPIE_PBA | E1000_GPIE_NSICR));
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Set vector for tx ring 0 and other causes.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * NOTE assumption that it is vector 0.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * This is also interdependent with installation of interrupt service
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * routines in igb_add_intr_handlers().
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* assign "other" causes to vector 0 */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China vector = 0;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar = ((vector | E1000_IVAR_VALID) << 8);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IVAR_MISC, ivar);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* assign tx ring 0 to vector 0 */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar = ((vector | E1000_IVAR_VALID) << 8);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IVAR0, ivar);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* prepare to enable tx & other interrupt causes */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->eims_mask = (1 << vector);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China vector ++;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China for (i = 0; i < igb->num_rx_rings; i++) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Set vector for each rx ring
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China index = (i & 0x7);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China if (i < 8) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* vector goes into low byte of register */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar = ivar & 0xFFFFFF00;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar |= (vector | E1000_IVAR_VALID);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China } else {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* vector goes into third byte of register */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar = ivar & 0xFF00FFFF;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar |= ((vector | E1000_IVAR_VALID) << 16);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* Accumulate interrupt-cause bits to enable */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->eims_mask |= (1 << vector);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China vector ++;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China for (i = 1; i < igb->num_tx_rings; i++) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /*
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Set vector for each tx ring from 2nd tx ring.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * Note assumption that tx vectors numericall follow rx vectors.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China index = (i & 0x7);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China if (i < 8) {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* vector goes into second byte of register */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar = ivar & 0xFFFF00FF;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar |= ((vector | E1000_IVAR_VALID) << 8);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China } else {
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* vector goes into fourth byte of register */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar = ivar & 0x00FFFFFF;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ivar |= (vector | E1000_IVAR_VALID) << 24;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China /* Accumulate interrupt-cause bits to enable */
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China igb->eims_mask |= (1 << vector);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China vector ++;
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China }
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ASSERT(vector == igb->intr_cnt);
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China}
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China/*
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * igb_setup_msix_82580 - setup 82580 adapter to use MSI-X interrupts
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China *
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * 82580 uses same table approach at 82576 but has fewer entries. Each
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * queue has a single entry in the table to which we write a vector number
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * along with a "valid" bit. Vectors take a different position in the
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * register depending on * whether * they are numbered above or below 4.
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing Chinastatic void
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing Chinaigb_setup_msix_82580(igb_t *igb)
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China{
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China struct e1000_hw *hw = &igb->hw;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China uint32_t ivar, index, vector;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China int i;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* must enable msi-x capability before IVAR settings */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_GPIE, (E1000_GPIE_MSIX_MODE |
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_GPIE_PBA | E1000_GPIE_NSICR | E1000_GPIE_EIAME));
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /*
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * Set vector for tx ring 0 and other causes.
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * NOTE assumption that it is vector 0.
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * This is also interdependent with installation of interrupt service
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * routines in igb_add_intr_handlers().
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* assign "other" causes to vector 0 */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China vector = 0;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar = ((vector | E1000_IVAR_VALID) << 8);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IVAR_MISC, ivar);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* assign tx ring 0 to vector 0 */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar = ((vector | E1000_IVAR_VALID) << 8);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG(hw, E1000_IVAR0, ivar);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* prepare to enable tx & other interrupt causes */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb->eims_mask = (1 << vector);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China vector ++;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China for (i = 0; i < igb->num_rx_rings; i++) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /*
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * Set vector for each rx ring
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China index = (i >> 1);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China if (i & 1) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* vector goes into third byte of register */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar = ivar & 0xFF00FFFF;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar |= ((vector | E1000_IVAR_VALID) << 16);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China } else {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* vector goes into low byte of register */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar = ivar & 0xFFFFFF00;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar |= (vector | E1000_IVAR_VALID);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* Accumulate interrupt-cause bits to enable */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb->eims_mask |= (1 << vector);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China vector ++;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China for (i = 1; i < igb->num_tx_rings; i++) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /*
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * Set vector for each tx ring from 2nd tx ring.
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China * Note assumption that tx vectors numericall follow rx vectors.
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China index = (i >> 1);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China if (i & 1) {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* vector goes into high byte of register */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar = ivar & 0x00FFFFFF;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar |= ((vector | E1000_IVAR_VALID) << 24);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China } else {
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* vector goes into second byte of register */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar = ivar & 0xFFFF00FF;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ivar |= (vector | E1000_IVAR_VALID) << 8;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China /* Accumulate interrupt-cause bits to enable */
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China igb->eims_mask |= (1 << vector);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China vector ++;
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China }
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China ASSERT(vector == igb->intr_cnt);
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China}
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_rem_intr_handlers - remove the interrupt handlers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_rem_intr_handlers(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->intr_cnt; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_remove_handler(igb->htable[i]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Remove intr handler failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_rem_intrs - remove the allocated interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_rem_intrs(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->intr_cnt; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_free(igb->htable[i]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_INFO,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Free intr failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy kmem_free(igb->htable, igb->intr_size);
c869993e79c1eafbec61a56bf6cea848fe754c71xy igb->htable = NULL;
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_enable_intrs - enable all the ddi interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_enable_intrs(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Enable interrupts */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->intr_cap & DDI_INTR_FLAG_BLOCK) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Call ddi_intr_block_enable() for MSI */
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_block_enable(igb->htable, igb->intr_cnt);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Enable block intr failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Call ddi_intr_enable() for Legacy/MSI non block enable */
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->intr_cnt; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_enable(igb->htable[i]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Enable intr failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_disable_intrs - disable all the ddi interrupts
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic int
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_disable_intrs(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy int i;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Disable all interrupts */
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (igb->intr_cap & DDI_INTR_FLAG_BLOCK) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_block_disable(igb->htable, igb->intr_cnt);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Disable block intr failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy } else {
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (i = 0; i < igb->intr_cnt; i++) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = ddi_intr_disable(igb->htable[i]);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc != DDI_SUCCESS) {
fa4e188e8e6bc718b1a096b3d1dc046952a69304Yuri Pankov igb_log(igb, IGB_LOG_ERROR,
c869993e79c1eafbec61a56bf6cea848fe754c71xy "Disable intr failed: %d", rc);
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_FAILURE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (IGB_SUCCESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_get_phy_state - Get and save the parameters read from PHY registers
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_get_phy_state(igb_t *igb)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy struct e1000_hw *hw = &igb->hw;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_ctrl;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_status;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_an_adv;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_an_exp;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_ext_status;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_1000t_ctrl;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_1000t_status;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint16_t phy_lp_able;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy ASSERT(mutex_owned(&igb->gen_lock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (hw->phy.media_type == e1000_media_type_copper) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) e1000_read_phy_reg(hw, PHY_CONTROL, &phy_ctrl);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) e1000_read_phy_reg(hw, PHY_STATUS, &phy_status);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) e1000_read_phy_reg(hw, PHY_AUTONEG_ADV, &phy_an_adv);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) e1000_read_phy_reg(hw, PHY_AUTONEG_EXP, &phy_an_exp);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) e1000_read_phy_reg(hw, PHY_EXT_STATUS, &phy_ext_status);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_1000t_ctrl);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) e1000_read_phy_reg(hw,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China PHY_1000T_STATUS, &phy_1000t_status);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (void) e1000_read_phy_reg(hw, PHY_LP_ABILITY, &phy_lp_able);
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_autoneg_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_status & MII_SR_AUTONEG_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_pause_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_PAUSE) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_asym_pause_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_ASM_DIR) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_1000fdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ((phy_ext_status & IEEE_ESR_1000T_FD_CAPS) ||
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_ext_status & IEEE_ESR_1000X_FD_CAPS)) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_1000hdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China ((phy_ext_status & IEEE_ESR_1000T_HD_CAPS) ||
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_ext_status & IEEE_ESR_1000X_HD_CAPS)) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_100t4_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_status & MII_SR_100T4_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_100fdx_cap = ((phy_status & MII_SR_100X_FD_CAPS) ||
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_status & MII_SR_100T2_FD_CAPS)) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_100hdx_cap = ((phy_status & MII_SR_100X_HD_CAPS) ||
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_status & MII_SR_100T2_HD_CAPS)) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_10fdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_status & MII_SR_10T_FD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_10hdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_status & MII_SR_10T_HD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_rem_fault =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_status & MII_SR_REMOTE_FAULT) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_autoneg_cap = hw->mac.autoneg;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_pause_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_PAUSE) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_asym_pause_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_ASM_DIR) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_1000hdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_1000t_ctrl & CR_1000T_HD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_100t4_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_100T4_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_rem_fault =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_REMOTE_FAULT) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China if (igb->param_adv_autoneg_cap == 1) {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_1000fdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_1000t_ctrl & CR_1000T_FD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_100fdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_100TX_FD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_100hdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_100TX_HD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_10fdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_10T_FD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_10hdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_adv & NWAY_AR_10T_HD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_autoneg_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_an_exp & NWAY_ER_LP_NWAY_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_pause_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_lp_able & NWAY_LPAR_PAUSE) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_asym_pause_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_lp_able & NWAY_LPAR_ASM_DIR) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_1000fdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_1000t_status & SR_1000T_LP_FD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_1000hdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_1000t_status & SR_1000T_LP_HD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_100t4_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_lp_able & NWAY_LPAR_100T4_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_100fdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_lp_able & NWAY_LPAR_100TX_FD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_100hdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_lp_able & NWAY_LPAR_100TX_HD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_10fdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_lp_able & NWAY_LPAR_10T_FD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_10hdx_cap =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_lp_able & NWAY_LPAR_10T_HD_CAPS) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_rem_fault =
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China (phy_lp_able & NWAY_LPAR_REMOTE_FAULT) ? 1 : 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China } else {
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China /*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * 1Gig Fiber adapter only offers 1Gig Full Duplex.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_autoneg_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_pause_cap = 1;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_asym_pause_cap = 1;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_1000fdx_cap = 1;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_1000hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_100t4_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_100fdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_100hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_10fdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_10hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_autoneg_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_pause_cap = 1;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_asym_pause_cap = 1;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_1000fdx_cap = 1;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_1000hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_100t4_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_100fdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_100hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_10fdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_adv_10hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_autoneg_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_pause_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_asym_pause_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_1000fdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_1000hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_100t4_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_100fdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_100hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_10fdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_10hdx_cap = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_lp_rem_fault = 0;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China }
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China}
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China/*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * synchronize the adv* and en* parameters.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China *
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * See comments in <sys/dld.h> for details of the *_en_*
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * parameters. The usage of ndd for setting adv parameters will
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * synchronize all the en parameters with the e1000g parameters,
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China * implicitly disabling any settings made via dladm.
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China */
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinastatic void
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing Chinaigb_param_sync(igb_t *igb)
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China{
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_en_1000fdx_cap = igb->param_adv_1000fdx_cap;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_en_1000hdx_cap = igb->param_adv_1000hdx_cap;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_en_100t4_cap = igb->param_adv_100t4_cap;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_en_100fdx_cap = igb->param_adv_100fdx_cap;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_en_100hdx_cap = igb->param_adv_100hdx_cap;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_en_10fdx_cap = igb->param_adv_10fdx_cap;
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China igb->param_en_10hdx_cap = igb->param_adv_10hdx_cap;
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_get_driver_control
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_get_driver_control(struct e1000_hw *hw)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t ctrl_ext;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Notify firmware that driver is in control of device */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl_ext |= E1000_CTRL_EXT_DRV_LOAD;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_release_driver_control
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xystatic void
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_release_driver_control(struct e1000_hw *hw)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t ctrl_ext;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Notify firmware that driver is no longer in control of device */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
c869993e79c1eafbec61a56bf6cea848fe754c71xy ctrl_ext &= ~E1000_CTRL_EXT_DRV_LOAD;
c869993e79c1eafbec61a56bf6cea848fe754c71xy E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * igb_atomic_reserve - Atomic decrease operation
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xyint
c869993e79c1eafbec61a56bf6cea848fe754c71xyigb_atomic_reserve(uint32_t *count_p, uint32_t n)
c869993e79c1eafbec61a56bf6cea848fe754c71xy{
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t oldval;
c869993e79c1eafbec61a56bf6cea848fe754c71xy uint32_t newval;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* ATOMICALLY */
c869993e79c1eafbec61a56bf6cea848fe754c71xy do {
c869993e79c1eafbec61a56bf6cea848fe754c71xy oldval = *count_p;
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (oldval < n)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (-1);
c869993e79c1eafbec61a56bf6cea848fe754c71xy newval = oldval - n;
c869993e79c1eafbec61a56bf6cea848fe754c71xy } while (atomic_cas_32(count_p, oldval, newval) != oldval);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy return (newval);
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl/*
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * FMA support
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bglint
8bb4b220fdb894543e41a5f9037898cf3c3f312bgligb_check_acc_handle(ddi_acc_handle_t handle)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl{
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_error_t de;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_acc_err_get(handle, &de, DDI_FME_VERSION);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_acc_err_clear(handle, DDI_FME_VERSION);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return (de.fme_status);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl}
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bglint
8bb4b220fdb894543e41a5f9037898cf3c3f312bgligb_check_dma_handle(ddi_dma_handle_t handle)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl{
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_error_t de;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_dma_err_get(handle, &de, DDI_FME_VERSION);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return (de.fme_status);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl}
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl/*
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * The IO fault service error handling callback function
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl/*ARGSUSED*/
8bb4b220fdb894543e41a5f9037898cf3c3f312bglstatic int
8bb4b220fdb894543e41a5f9037898cf3c3f312bgligb_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err, const void *impl_data)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl{
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /*
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * as the driver can always deal with an error in any dma or
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * access handle, we can just return the fme_status value.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl pci_ereport_post(dip, err, NULL);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return (err->fme_status);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl}
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bglstatic void
8bb4b220fdb894543e41a5f9037898cf3c3f312bgligb_fm_init(igb_t *igb)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl{
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_iblock_cookie_t iblk;
837c1ac4e72b7d86278cca88b1075af557f7d161Stephen Hanson int fma_dma_flag;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /* Only register with IO Fault Services if we have some capability */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb->fm_capabilities & DDI_FM_ACCCHK_CAPABLE) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_regs_acc_attr.devacc_attr_access = DDI_FLAGERR_ACC;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl } else {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_regs_acc_attr.devacc_attr_access = DDI_DEFAULT_ACC;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb->fm_capabilities & DDI_FM_DMACHK_CAPABLE) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl fma_dma_flag = 1;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl } else {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl fma_dma_flag = 0;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
837c1ac4e72b7d86278cca88b1075af557f7d161Stephen Hanson (void) igb_set_fma_flags(fma_dma_flag);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb->fm_capabilities) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /* Register capabilities with IO Fault Services */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_init(igb->dip, &igb->fm_capabilities, &iblk);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /*
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Initialize pci ereport capabilities if ereport capable
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (DDI_FM_EREPORT_CAP(igb->fm_capabilities) ||
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DDI_FM_ERRCB_CAP(igb->fm_capabilities))
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl pci_ereport_setup(igb->dip);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /*
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Register error callback if error callback capable
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (DDI_FM_ERRCB_CAP(igb->fm_capabilities))
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_handler_register(igb->dip,
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl igb_fm_error_cb, (void*) igb);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl}
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bglstatic void
8bb4b220fdb894543e41a5f9037898cf3c3f312bgligb_fm_fini(igb_t *igb)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl{
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /* Only unregister FMA capabilities if we registered some */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (igb->fm_capabilities) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /*
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Release any resources allocated by pci_ereport_setup()
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (DDI_FM_EREPORT_CAP(igb->fm_capabilities) ||
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DDI_FM_ERRCB_CAP(igb->fm_capabilities))
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl pci_ereport_teardown(igb->dip);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /*
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Un-register error callback if error callback capable
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (DDI_FM_ERRCB_CAP(igb->fm_capabilities))
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_handler_unregister(igb->dip);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl /* Unregister from IO Fault Services */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_fini(igb->dip);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl}
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bglvoid
8bb4b220fdb894543e41a5f9037898cf3c3f312bgligb_fm_ereport(igb_t *igb, char *detail)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl{
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl uint64_t ena;
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl char buf[FM_MAX_CLASS];
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl (void) snprintf(buf, FM_MAX_CLASS, "%s.%s", DDI_FM_DEVICE, detail);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ena = fm_ena_generate(0, FM_ENA_FMT1);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl if (DDI_FM_EREPORT_CAP(igb->fm_capabilities)) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl ddi_fm_ereport_post(igb->dip, buf, ena, DDI_NOSLEEP,
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl FM_VERSION, DATA_TYPE_UINT8, FM_EREPORT_VERS0, NULL);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl}