ixgbe_main.c revision 5b6dd21f5401160f9a62ac2e76a858c2bc105370
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * CDDL HEADER START
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The contents of this file are subject to the terms of the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Common Development and Distribution License (the "License").
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * You may not use this file except in compliance with the License.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
193974072f41a843678abf5f61979c748687e66bSherry Moore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
193974072f41a843678abf5f61979c748687e66bSherry Moore * or http://www.opensolaris.org/os/licensing.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * See the License for the specific language governing permissions
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * and limitations under the License.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
193974072f41a843678abf5f61979c748687e66bSherry Moore * When distributing Covered Code, include this CDDL HEADER in each
193974072f41a843678abf5f61979c748687e66bSherry Moore * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If applicable, add the following below this CDDL HEADER, with the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * fields enclosed by brackets "[]" replaced with your own identifying
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * information: Portions Copyright [yyyy] [name of copyright owner]
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * CDDL HEADER END
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China */
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China/*
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#include "ixgbe_sw.h"
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing Chinastatic char ixgbe_ident[] = "Intel 10Gb Ethernet";
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing Chinastatic char ixgbe_version[] = "ixgbe 1.1.7";
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Local function protoypes
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_register_mac(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_identify_hardware(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_regs_map(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_init_properties(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_init_driver_settings(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_init_locks(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_destroy_locks(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_init(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_chip_start(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_chip_stop(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_reset(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_tx_clean(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t ixgbe_tx_drain(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t ixgbe_rx_drain(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_alloc_rings(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_free_rings(ixgbe_t *);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic int ixgbe_alloc_rx_data(ixgbe_t *);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic void ixgbe_free_rx_data(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_setup_rings(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_setup_rx(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_setup_tx(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_setup_rx_ring(ixgbe_rx_ring_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_setup_tx_ring(ixgbe_tx_ring_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_setup_rss(ixgbe_t *);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic void ixgbe_setup_vmdq(ixgbe_t *);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic void ixgbe_setup_vmdq_rss(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_init_unicst(ixgbe_t *);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic int ixgbe_unicst_find(ixgbe_t *, const uint8_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_setup_multicst(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_get_hw_state(ixgbe_t *);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic void ixgbe_setup_vmdq_rss_conf(ixgbe_t *ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_get_conf(ixgbe_t *);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic void ixgbe_init_params(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_get_prop(ixgbe_t *, char *, int, int, int);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guostatic void ixgbe_driver_link_check(ixgbe_t *);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic void ixgbe_sfp_check(void *);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing Chinastatic void ixgbe_overtemp_check(void *);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guostatic void ixgbe_link_timer(void *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_local_timer(void *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_arm_watchdog_timer(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_restart_watchdog_timer(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_disable_adapter_interrupts(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_enable_adapter_interrupts(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t is_valid_mac_addr(uint8_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t ixgbe_stall_check(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t ixgbe_set_loopback_mode(ixgbe_t *, uint32_t);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_set_internal_mac_loopback(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t ixgbe_find_mac_address(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_alloc_intrs(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_alloc_intr_handles(ixgbe_t *, int);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_add_intr_handlers(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_map_rxring_to_vector(ixgbe_t *, int, int);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_map_txring_to_vector(ixgbe_t *, int, int);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic void ixgbe_setup_ivar(ixgbe_t *, uint16_t, uint8_t, int8_t);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic void ixgbe_enable_ivar(ixgbe_t *, uint16_t, int8_t);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic void ixgbe_disable_ivar(ixgbe_t *, uint16_t, int8_t);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic uint32_t ixgbe_get_hw_rx_index(ixgbe_t *ixgbe, uint32_t sw_rx_index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic int ixgbe_map_intrs_to_vectors(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_setup_adapter_vector(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_rem_intr_handlers(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_rem_intrs(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_enable_intrs(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_disable_intrs(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic uint_t ixgbe_intr_legacy(void *, void *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic uint_t ixgbe_intr_msi(void *, void *);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic uint_t ixgbe_intr_msix(void *, void *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_intr_rx_work(ixgbe_rx_ring_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_intr_tx_work(ixgbe_tx_ring_t *);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guostatic void ixgbe_intr_other_work(ixgbe_t *, uint32_t);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_get_driver_control(struct ixgbe_hw *);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic int ixgbe_addmac(void *, const uint8_t *);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic int ixgbe_remmac(void *, const uint8_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_release_driver_control(struct ixgbe_hw *);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_attach(dev_info_t *, ddi_attach_cmd_t);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_detach(dev_info_t *, ddi_detach_cmd_t);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_resume(dev_info_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_suspend(dev_info_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_unconfigure(dev_info_t *, ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic uint8_t *ixgbe_mc_table_itr(struct ixgbe_hw *, uint8_t **, uint32_t *);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic int ixgbe_cbfunc(dev_info_t *, ddi_cb_action_t, void *, void *, void *);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic int ixgbe_intr_cb_register(ixgbe_t *);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic int ixgbe_intr_adjust(ixgbe_t *, ddi_cb_action_t, int);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt const void *impl_data);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_fm_init(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_fm_fini(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerchar *ixgbe_priv_props[] = {
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
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China};
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China#define IXGBE_MAX_PRIV_PROPS \
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China (sizeof (ixgbe_priv_props) / sizeof (mac_priv_prop_t))
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic struct cb_ops ixgbe_cb_ops = {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nulldev, /* cb_open */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nulldev, /* cb_close */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_strategy */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_print */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_dump */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_read */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_write */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_ioctl */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_devmap */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_mmap */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_segmap */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nochpoll, /* cb_chpoll */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_prop_op, /* cb_prop_op */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt NULL, /* cb_stream */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt D_MP | D_HOTPLUG, /* cb_flag */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt CB_REV, /* cb_rev */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* cb_aread */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev /* cb_awrite */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt};
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic struct dev_ops ixgbe_dev_ops = {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DEVO_REV, /* devo_rev */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt 0, /* devo_refcnt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt NULL, /* devo_getinfo */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nulldev, /* devo_identify */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nulldev, /* devo_probe */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_attach, /* devo_attach */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_detach, /* devo_detach */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt nodev, /* devo_reset */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &ixgbe_cb_ops, /* devo_cb_ops */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt NULL, /* devo_bus_ops */
193974072f41a843678abf5f61979c748687e66bSherry Moore ddi_power, /* devo_power */
193974072f41a843678abf5f61979c748687e66bSherry Moore ddi_quiesce_not_supported, /* devo_quiesce */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt};
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic struct modldrv ixgbe_modldrv = {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &mod_driverops, /* Type of module. This one is a driver */
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe_ident, /* Discription string */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &ixgbe_dev_ops /* driver ops */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt};
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic struct modlinkage ixgbe_modlinkage = {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MODREV_1, &ixgbe_modldrv, NULL
9da57d7b0ddd8d73b676ce12c040362132cdd538bt};
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Access attributes for register mapping
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btddi_device_acc_attr_t ixgbe_regs_acc_attr = {
837c1ac4e72b7d86278cca88b1075af557f7d161Stephen Hanson DDI_DEVICE_ATTR_V1,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_STRUCTURE_LE_ACC,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_STRICTORDER_ACC,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_FLAGERR_ACC
9da57d7b0ddd8d73b676ce12c040362132cdd538bt};
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Loopback property
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic lb_property_t lb_normal = {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt normal, "normal", IXGBE_LB_NONE
9da57d7b0ddd8d73b676ce12c040362132cdd538bt};
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic lb_property_t lb_mac = {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt internal, "MAC", IXGBE_LB_INTERNAL_MAC
9da57d7b0ddd8d73b676ce12c040362132cdd538bt};
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing Chinastatic lb_property_t lb_external = {
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China external, "External", IXGBE_LB_EXTERNAL
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China};
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China#define IXGBE_M_CALLBACK_FLAGS \
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (MC_IOCTL | MC_GETCAPAB | MC_SETPROP | MC_GETPROP | MC_PROPINFO)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic mac_callbacks_t ixgbe_m_callbacks = {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_M_CALLBACK_FLAGS,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_m_stat,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_m_start,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_m_stop,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_m_promisc,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_m_multicst,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt NULL,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_m_ioctl,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_m_getcapab,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China NULL,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China NULL,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_m_setprop,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_m_getprop,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_m_propinfo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt};
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo/*
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * Initialize capabilities of each supported adapter type
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guostatic adapter_info_t ixgbe_82598eb_cap = {
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 64, /* maximum number of rx queues */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 1, /* minimum number of rx queues */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 64, /* default number of rx queues */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 16, /* maximum number of rx groups */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 1, /* minimum number of rx groups */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 1, /* default number of rx groups */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 32, /* maximum number of tx queues */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 1, /* minimum number of tx queues */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 8, /* default number of tx queues */
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China 16366, /* maximum MTU size */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China 0xFFFF, /* maximum interrupt throttle rate */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China 0, /* minimum interrupt throttle rate */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China 200, /* default interrupt throttle rate */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 18, /* maximum total msix vectors */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 16, /* maximum number of ring vectors */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 2, /* maximum number of other vectors */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo IXGBE_EICR_LSC, /* "other" interrupt types handled */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China 0, /* "other" interrupt types enable mask */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo (IXGBE_FLAG_DCA_CAPABLE /* capability flags */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo | IXGBE_FLAG_RSS_CAPABLE
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo | IXGBE_FLAG_VMDQ_CAPABLE)
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo};
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic adapter_info_t ixgbe_82599eb_cap = {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China 128, /* maximum number of rx queues */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China 1, /* minimum number of rx queues */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 128, /* default number of rx queues */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 64, /* maximum number of rx groups */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 1, /* minimum number of rx groups */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 1, /* default number of rx groups */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China 128, /* maximum number of tx queues */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China 1, /* minimum number of tx queues */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China 8, /* default number of tx queues */
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China 15500, /* maximum MTU size */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China 0xFF8, /* maximum interrupt throttle rate */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China 0, /* minimum interrupt throttle rate */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China 200, /* default interrupt throttle rate */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China 64, /* maximum total msix vectors */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China 16, /* maximum number of ring vectors */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China 2, /* maximum number of other vectors */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (IXGBE_EICR_LSC
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China | IXGBE_EICR_GPI_SDP1
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China | IXGBE_EICR_GPI_SDP2), /* "other" interrupt types handled */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (IXGBE_SDP1_GPIEN
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China | IXGBE_SDP2_GPIEN), /* "other" interrupt types enable mask */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (IXGBE_FLAG_DCA_CAPABLE
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China | IXGBE_FLAG_RSS_CAPABLE
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China | IXGBE_FLAG_VMDQ_CAPABLE
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China | IXGBE_FLAG_RSC_CAPABLE
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China | IXGBE_FLAG_SFP_PLUG_CAPABLE) /* capability flags */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China};
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Module Initialization Functions.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538bt_init(void)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int status;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac_init_ops(&ixgbe_dev_ops, MODULE_NAME);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt status = mod_install(&ixgbe_modlinkage);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (status != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac_fini_ops(&ixgbe_dev_ops);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (status);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538bt_fini(void)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int status;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt status = mod_remove(&ixgbe_modlinkage);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (status == DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac_fini_ops(&ixgbe_dev_ops);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (status);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538bt_info(struct modinfo *modinfop)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int status;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt status = mod_info(&ixgbe_modlinkage, modinfop);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (status);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_attach - Driver attach.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This function is the device specific initialization entry
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * point. This entry point is required and must be written.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The DDI_ATTACH command must be provided in the attach entry
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * point. When attach() is called with cmd set to DDI_ATTACH,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * all normal kernel services (such as kmem_alloc(9F)) are
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * available for use by the driver.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The attach() function will be called once for each instance
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * of the device on the system with cmd set to DDI_ATTACH.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Until attach() succeeds, the only driver entry points which
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * may be called are open(9E) and getinfo(9E).
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_attach(dev_info_t *devinfo, ddi_attach_cmd_t cmd)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_osdep *osdep;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int instance;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo char taskqname[32];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check the command and perform corresponding operations
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (cmd) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt default:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_RESUME:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (ixgbe_resume(devinfo));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_ATTACH:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Get the device instance */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt instance = ddi_get_instance(devinfo);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Allocate memory for the instance data structure */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe = kmem_zalloc(sizeof (ixgbe_t), KM_SLEEP);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->dip = devinfo;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->instance = instance;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt osdep = &ixgbe->osdep;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->back = osdep;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt osdep->ixgbe = ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Attach the instance pointer to the dev_info data structure */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_set_driver_private(devinfo, ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize for fma support
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg ixgbe->fm_capabilities = ixgbe_get_prop(ixgbe, PROP_FM_CAPABLE,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt 0, 0x0f, DDI_FM_EREPORT_CAPABLE | DDI_FM_ACCCHK_CAPABLE |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_FM_DMACHK_CAPABLE | DDI_FM_ERRCB_CAPABLE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_fm_init(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_FM_INIT;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Map PCI config space registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (pci_config_setup(devinfo, &osdep->cfg_handle) != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to map PCI configurations");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_PCI_CONFIG;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Identify the chipset family
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_identify_hardware(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to identify hardware");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Map device registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_regs_map(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to map device registers");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_REGS_MAP;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize driver parameters
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_init_properties(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_PROPS;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Register interrupt callback
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_intr_cb_register(ixgbe) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe, "Failed to register interrupt callback");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto attach_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_alloc_intrs(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to allocate interrupts");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_ALLOC_INTR;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate rx/tx rings based on the ring numbers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The actual numbers of rx/tx rings are decided by the number of
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * allocated interrupt vectors, so we should allocate the rings after
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * interrupts are allocated.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_alloc_rings(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to allocate rx and tx rings");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_ALLOC_RINGS;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Map rings to interrupt vectors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (ixgbe_map_intrs_to_vectors(ixgbe) != IXGBE_SUCCESS) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "Failed to map interrupts to vectors");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Add interrupt handlers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_add_intr_handlers(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to add interrupt handlers");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_ADD_INTR;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * Create a taskq for sfp-change
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (void) sprintf(taskqname, "ixgbe%d_sfp_taskq", instance);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if ((ixgbe->sfp_taskq = ddi_taskq_create(devinfo, taskqname,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo 1, TASKQ_DEFAULTPRI, 0)) == NULL) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "sfp_taskq create failed");
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo goto attach_fail;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->attach_progress |= ATTACH_PROGRESS_SFP_TASKQ;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Create a taskq for over-temp
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (void) sprintf(taskqname, "ixgbe%d_overtemp_taskq", instance);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if ((ixgbe->overtemp_taskq = ddi_taskq_create(devinfo, taskqname,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China 1, TASKQ_DEFAULTPRI, 0)) == NULL) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "overtemp_taskq create failed");
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China goto attach_fail;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->attach_progress |= ATTACH_PROGRESS_OVERTEMP_TASKQ;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize driver parameters
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_init_driver_settings(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to initialize driver settings");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize mutexes for this device.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Do this before enabling the interrupt handler and
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * register the softint to avoid the condition where
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * interrupt handler can try using uninitialized mutex.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_init_locks(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_LOCKS;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_init(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to initialize adapter");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_check_complete = B_FALSE;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_check_hrtime = gethrtime() +
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo (IXGBE_LINK_UP_TIME * 100000000ULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_INIT;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.cfg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize statistics
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_init_stats(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to initialize statistics");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_STATS;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Register the driver to the MAC
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_register_mac(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to register MAC");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo mac_link_update(ixgbe->mac_hdl, LINK_STATE_UNKNOWN);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_MAC;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->periodic_id = ddi_periodic_add(ixgbe_link_timer, ixgbe,
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo IXGBE_CYCLIC_PERIOD, DDI_IPL_0);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->periodic_id == 0) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe_error(ixgbe, "Failed to add the link check timer");
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo goto attach_fail;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->attach_progress |= ATTACH_PROGRESS_LINK_TIMER;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Now that mutex locks are initialized, and the chip is also
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * initialized, enable interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_enable_intrs(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to enable DDI interrupts");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto attach_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->attach_progress |= ATTACH_PROGRESS_ENABLE_INTR;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe_log(ixgbe, "%s, %s", ixgbe_ident, ixgbe_version);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_or_32(&ixgbe->ixgbe_state, IXGBE_INITIALIZED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btattach_fail:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_unconfigure(devinfo, ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_detach - Driver detach.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The detach() function is the complement of the attach routine.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If cmd is set to DDI_DETACH, detach() is used to remove the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * state associated with a given instance of a device node
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * prior to the removal of that instance from the system.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The detach() function will be called once for each instance
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * of the device for which there has been a successful attach()
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * once there are no longer any opens on the device.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Interrupts routine are disabled, All memory allocated by this
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * driver are freed.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_detach(dev_info_t *devinfo, ddi_detach_cmd_t cmd)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check detach command
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (cmd) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt default:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_SUSPEND:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (ixgbe_suspend(devinfo));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_DETACH:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get the pointer to the driver private data structure
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe = (ixgbe_t *)ddi_get_driver_private(devinfo);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe == NULL)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If the device is still running, it needs to be stopped first.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This check is necessary because under some specific circumstances,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the detach routine can be called without stopping the interface
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * first.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->ixgbe_state & IXGBE_STARTED) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_and_32(&ixgbe->ixgbe_state, ~IXGBE_STARTED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo mutex_enter(&ixgbe->gen_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_stop(ixgbe, B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Disable and stop the watchdog timer */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_disable_watchdog_timer(ixgbe);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check if there are still rx buffers held by the upper layer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If so, fail the detach.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (!ixgbe_rx_drain(ixgbe))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Do the remaining unconfigure routines
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_unconfigure(devinfo, ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_unconfigure(dev_info_t *devinfo, ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable interrupt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_ENABLE_INTR) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_disable_intrs(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo /*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * remove the link check timer
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo */
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->attach_progress & ATTACH_PROGRESS_LINK_TIMER) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->periodic_id != NULL) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ddi_periodic_delete(ixgbe->periodic_id);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->periodic_id = NULL;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Unregister MAC
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_MAC) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) mac_unregister(ixgbe->mac_hdl);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free statistics
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_STATS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt kstat_delete((kstat_t *)ixgbe->ixgbe_ks);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remove interrupt handlers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_ADD_INTR) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_rem_intr_handlers(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * Remove taskq for sfp-status-change
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo */
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->attach_progress & ATTACH_PROGRESS_SFP_TASKQ) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ddi_taskq_destroy(ixgbe->sfp_taskq);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Remove taskq for over-temp
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (ixgbe->attach_progress & ATTACH_PROGRESS_OVERTEMP_TASKQ) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ddi_taskq_destroy(ixgbe->overtemp_taskq);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remove interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_ALLOC_INTR) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_rem_intrs(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Unregister interrupt callback handler
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (void) ddi_cb_unregister(ixgbe->cb_hdl);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remove driver properties
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_PROPS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ddi_prop_remove_all(devinfo);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Stop the chipset
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_INIT) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_chip_stop(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free register handle
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_REGS_MAP) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->osdep.reg_handle != NULL)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_regs_map_free(&ixgbe->osdep.reg_handle);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free PCI config handle
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_PCI_CONFIG) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->osdep.cfg_handle != NULL)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_config_teardown(&ixgbe->osdep.cfg_handle);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free locks
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_LOCKS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_destroy_locks(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free the rx/tx rings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_ALLOC_RINGS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_free_rings(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Unregister FMA capabilities
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_FM_INIT) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_fm_fini(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free the driver data structure
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt kmem_free(ixgbe, sizeof (ixgbe_t));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_set_driver_private(devinfo, NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_register_mac - Register the driver and its function pointers with
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the GLD interface.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_register_mac(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac_register_t *mac;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int status;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if ((mac = mac_alloc(MAC_VERSION)) == NULL)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac->m_type_ident = MAC_PLUGIN_IDENT_ETHER;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac->m_driver = ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac->m_dip = ixgbe->dip;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac->m_src_addr = hw->mac.addr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac->m_callbacks = &ixgbe_m_callbacks;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac->m_min_sdu = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac->m_max_sdu = ixgbe->default_mtu;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac->m_margin = VLAN_TAGSZ;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mac->m_priv_props = ixgbe_priv_props;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac->m_v12n = MAC_VIRT_LEVEL1;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt status = mac_register(mac, &ixgbe->mac_hdl);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mac_free(mac);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return ((status == 0) ? IXGBE_SUCCESS : IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_identify_hardware - Identify the type of the chipset.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_identify_hardware(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_osdep *osdep = &ixgbe->osdep;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get the device id
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->vendor_id =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_config_get16(osdep->cfg_handle, PCI_CONF_VENID);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->device_id =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_config_get16(osdep->cfg_handle, PCI_CONF_DEVID);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->revision_id =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_config_get8(osdep->cfg_handle, PCI_CONF_REVID);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->subsystem_device_id =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_config_get16(osdep->cfg_handle, PCI_CONF_SUBSYSID);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->subsystem_vendor_id =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_config_get16(osdep->cfg_handle, PCI_CONF_SUBVENID);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /*
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * Set the mac type of the adapter based on the device id
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if (ixgbe_set_mac_type(hw) != IXGBE_SUCCESS) {
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo return (IXGBE_FAILURE);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /*
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * Install adapter capabilities
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo switch (hw->mac.type) {
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo case ixgbe_mac_82598EB:
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo IXGBE_DEBUGLOG_0(ixgbe, "identify 82598 adapter\n");
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab = &ixgbe_82598eb_cap;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if (ixgbe_get_media_type(hw) == ixgbe_media_type_copper) {
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->flags |= IXGBE_FLAG_FAN_FAIL_CAPABLE;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->other_intr |= IXGBE_EICR_GPI_SDP1;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->capab->other_gpie |= IXGBE_SDP1_GPIEN;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo IXGBE_DEBUGLOG_0(ixgbe, "identify 82599 adapter\n");
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->capab = &ixgbe_82599eb_cap;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (hw->device_id == IXGBE_DEV_ID_82599_T3_LOM) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->capab->flags |= IXGBE_FLAG_TEMP_SENSOR_CAPABLE;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->capab->other_intr |= IXGBE_EICR_GPI_SDP0;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->capab->other_gpie |= IXGBE_SDP0_GPIEN;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo default:
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo IXGBE_DEBUGLOG_1(ixgbe,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo "adapter not supported in ixgbe_identify_hardware(): %d\n",
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo hw->mac.type);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo return (IXGBE_FAILURE);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_regs_map - Map the device registers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_regs_map(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt dev_info_t *devinfo = ixgbe->dip;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_osdep *osdep = &ixgbe->osdep;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt off_t mem_size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * First get the size of device registers to be mapped.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (ddi_dev_regsize(devinfo, IXGBE_ADAPTER_REGSET, &mem_size)
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ddi_regs_map_setup() to map registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if ((ddi_regs_map_setup(devinfo, IXGBE_ADAPTER_REGSET,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (caddr_t *)&hw->hw_addr, 0,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mem_size, &ixgbe_regs_acc_attr,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &osdep->reg_handle)) != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init_properties - Initialize driver properties.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_init_properties(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get conf file properties, including link settings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * jumbo frames, ring number, descriptor number, etc.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_get_conf(ixgbe);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_init_params(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init_driver_settings - Initialize driver settings.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The settings include hardware function pointers, bus information,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * rx/tx rings settings, link state, and any other parameters that
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * need to be setup during driver initialization.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_init_driver_settings(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng dev_info_t *devinfo = ixgbe->dip;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_rx_ring_t *rx_ring;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_rx_group_t *rx_group;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_ring_t *tx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t rx_size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t tx_size;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t ring_per_group;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize chipset specific hardware function pointers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_init_shared_code(hw) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Get the system page size
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->sys_page_size = ddi_ptob(devinfo, (ulong_t)1);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set rx buffer size
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The IP header alignment room is counted in the calculation.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The rx buffer size is in unit of 1K that is required by the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * chipset hardware.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rx_size = ixgbe->max_frame_size + IPHDR_ALIGN_ROOM;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_buf_size = ((rx_size >> 10) +
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ((rx_size & (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set tx buffer size
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_size = ixgbe->max_frame_size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_buf_size = ((tx_size >> 10) +
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ((tx_size & (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Initialize rx/tx rings/groups parameters
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_rx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rx_ring = &ixgbe->rx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rx_ring->index = i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rx_ring->ixgbe = ixgbe;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_ring->group_index = i / ring_per_group;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_ring->hw_index = ixgbe_get_hw_rx_index(ixgbe, i);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < ixgbe->num_rx_groups; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_group = &ixgbe->rx_groups[i];
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_group->index = i;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_group->ixgbe = ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_tx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring = &ixgbe->tx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->index = i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->ixgbe = ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->tx_head_wb_enable)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tx_recycle = ixgbe_tx_recycle_head_wb;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt else
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tx_recycle = ixgbe_tx_recycle_legacy;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->ring_size = ixgbe->tx_ring_size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->free_list_size = ixgbe->tx_ring_size +
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ixgbe->tx_ring_size >> 1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize values of interrupt throttling rate
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (i = 1; i < MAX_INTR_VECTOR; i++)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->intr_throttling[i] = ixgbe->intr_throttling[0];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The initial link state should be "unknown"
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->link_state = LINK_STATE_UNKNOWN;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init_locks - Initialize locks.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_init_locks(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_rx_ring_t *rx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_ring_t *tx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_rx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rx_ring = &ixgbe->rx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_init(&rx_ring->rx_lock, NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_tx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring = &ixgbe->tx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_init(&tx_ring->tx_lock, NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_init(&tx_ring->recycle_lock, NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_init(&tx_ring->tcb_head_lock, NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_init(&tx_ring->tcb_tail_lock, NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_init(&ixgbe->gen_lock, NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_init(&ixgbe->watchdog_lock, NULL,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MUTEX_DRIVER, DDI_INTR_PRI(ixgbe->intr_pri));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_destroy_locks - Destroy locks.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_destroy_locks(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_rx_ring_t *rx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_ring_t *tx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_rx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rx_ring = &ixgbe->rx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_destroy(&rx_ring->rx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_tx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring = &ixgbe->tx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_destroy(&tx_ring->tx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_destroy(&tx_ring->recycle_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_destroy(&tx_ring->tcb_head_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_destroy(&tx_ring->tcb_tail_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_destroy(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_destroy(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_resume(dev_info_t *devinfo)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe = (ixgbe_t *)ddi_get_driver_private(devinfo);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe == NULL)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->ixgbe_state & IXGBE_STARTED) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe_start(ixgbe, B_FALSE) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Enable and start the watchdog timer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_enable_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_and_32(&ixgbe->ixgbe_state, ~IXGBE_SUSPENDED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->ixgbe_state & IXGBE_STARTED) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo for (i = 0; i < ixgbe->num_tx_rings; i++) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo mac_tx_ring_update(ixgbe->mac_hdl,
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->tx_rings[i].ring_handle);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_suspend(dev_info_t *devinfo)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe = (ixgbe_t *)ddi_get_driver_private(devinfo);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe == NULL)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_or_32(&ixgbe->ixgbe_state, IXGBE_SUSPENDED);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (!(ixgbe->ixgbe_state & IXGBE_STARTED)) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->gen_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (DDI_SUCCESS);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_stop(ixgbe, B_FALSE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable and stop the watchdog timer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_disable_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init - Initialize the device.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_init(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset chipset to put the hardware in a known state
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * before we try to do anything with the eeprom.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_reset_hw(hw) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto init_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Need to init eeprom before validating the checksum.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_init_eeprom_params(hw) < 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Unable to intitialize the eeprom interface.");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto init_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * NVM validation
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_validate_eeprom_checksum(hw, NULL) < 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Some PCI-E parts fail the first check due to
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the link being in sleep state. Call it again,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * if it fails a second time it's a real issue.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_validate_eeprom_checksum(hw, NULL) < 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Invalid NVM checksum. Please contact "
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "the vendor to update the NVM.");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto init_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup default flow control thresholds - enable/disable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * & flow control type is controlled by ixgbe.conf
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->fc.high_water = DEFAULT_FCRTH;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->fc.low_water = DEFAULT_FCRTL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->fc.pause_time = DEFAULT_FCPAUSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->fc.send_xon = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize link settings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_driver_setup_link(ixgbe, B_FALSE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_chip_start(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto init_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto init_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btinit_fail:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset PHY
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_reset_phy(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_chip_start - Initialize and start the chipset hardware.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_chip_start(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo int ret_val, i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get the mac address
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This function should handle SPARC case correctly.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (!ixgbe_find_mac_address(ixgbe)) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to get the mac address");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Validate the mac address
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_init_rx_addrs(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (!is_valid_mac_addr(hw->mac.addr)) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Invalid mac address");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Configure/Initialize hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo ret_val = ixgbe_init_hw(hw);
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo if (ret_val != IXGBE_SUCCESS) {
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo if (ret_val == IXGBE_ERR_EEPROM_VERSION) {
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo ixgbe_error(ixgbe,
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo "This 82599 device is pre-release and contains"
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo " outdated firmware, please contact your hardware"
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo " vendor for a replacement.");
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo } else {
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo ixgbe_error(ixgbe, "Failed to initialize hardware");
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo return (IXGBE_FAILURE);
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo /*
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo * Re-enable relaxed ordering for performance. It is disabled
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo * by default in the hardware init.
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (ixgbe->relax_order_enable == B_TRUE)
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_enable_relaxed_ordering(hw);
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup adapter interrupt vectors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_adapter_vector(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize unicast addresses.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_init_unicst(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup and initialize the mctable structures.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_multicst(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set interrupt throttling rate
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->intr_cnt; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_EITR(i), ixgbe->intr_throttling[i]);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Save the state of the phy
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_get_hw_state(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Make sure driver has control
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_get_driver_control(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_chip_stop - Stop the chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_chip_stop(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Tell firmware driver is no longer in control
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_release_driver_control(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset the chipset
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_reset_hw(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset PHY
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_reset_phy(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_reset - Reset the chipset and re-start the driver.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * It involves stopping and re-starting the chipset,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * and re-configuring the rx/tx rings.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_reset(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo int i;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China /*
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Disable and stop the watchdog timer
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_disable_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(ixgbe->ixgbe_state & IXGBE_STARTED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_and_32(&ixgbe->ixgbe_state, ~IXGBE_STARTED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_stop(ixgbe, B_FALSE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe_start(ixgbe, B_FALSE) != IXGBE_SUCCESS) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->gen_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo /*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * After resetting, need to recheck the link status.
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo */
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_check_complete = B_FALSE;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_check_hrtime = gethrtime() +
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo (IXGBE_LINK_UP_TIME * 100000000ULL);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_or_32(&ixgbe->ixgbe_state, IXGBE_STARTED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (!(ixgbe->ixgbe_state & IXGBE_SUSPENDED)) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo for (i = 0; i < ixgbe->num_tx_rings; i++) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo mac_tx_ring_update(ixgbe->mac_hdl,
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->tx_rings[i].ring_handle);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Enable and start the watchdog timer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_enable_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_tx_clean - Clean the pending transmit packets and DMA resources.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_tx_clean(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_ring_t *tx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_control_block_t *tcb;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt link_list_t pending_list;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t desc_num;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i, j;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt LINK_LIST_INIT(&pending_list);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_tx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring = &ixgbe->tx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&tx_ring->recycle_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Clean the pending tx data - the pending packets in the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * work_list that have no chances to be transmitted again.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * We must ensure the chipset is stopped or the link is down
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * before cleaning the transmit packets.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt desc_num = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (j = 0; j < tx_ring->ring_size; j++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tcb = tx_ring->work_list[j];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (tcb != NULL) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt desc_num += tcb->desc_num;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->work_list[j] = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_free_tcb(tcb);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt LIST_PUSH_TAIL(&pending_list, &tcb->link);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (desc_num > 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atomic_add_32(&tx_ring->tbd_free, desc_num);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(tx_ring->tbd_free == tx_ring->ring_size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset the head and tail pointers of the tbd ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset the writeback head if it's enable.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tbd_head = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tbd_tail = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->tx_head_wb_enable)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *tx_ring->tbd_head_wb = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(&ixgbe->hw,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_TDH(tx_ring->index), 0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(&ixgbe->hw,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_TDT(tx_ring->index), 0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&tx_ring->recycle_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Add the tx control blocks in the pending list to
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the free list.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_put_free_list(tx_ring, &pending_list);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_tx_drain - Drain the tx rings to allow pending packets to be
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * transmitted.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_tx_drain(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_ring_t *tx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt boolean_t done;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i, j;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Wait for a specific time to allow pending tx packets
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * to be transmitted.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check the counter tbd_free to see if transmission is done.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * No lock protection is needed here.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Return B_TRUE if all pending packets have been transmitted;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Otherwise return B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < TX_DRAIN_TIME; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt done = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (j = 0; j < ixgbe->num_tx_rings; j++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring = &ixgbe->tx_rings[j];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt done = done &&
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (tx_ring->tbd_free == tx_ring->ring_size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (done)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt msec_delay(1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (done);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_rx_drain - Wait for all rx buffers to be released by upper layer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_rx_drain(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China boolean_t done = B_TRUE;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Polling the rx free list to check if those rx buffers held by
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the upper layer are released.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check the counter rcb_free to see if all pending buffers are
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * released. No lock protection is needed here.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Return B_TRUE if all pending buffers have been released;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Otherwise return B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < RX_DRAIN_TIME; i++) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China done = (ixgbe->rcb_pending == 0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (done)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt msec_delay(1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (done);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_start - Start the driver/chipset.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_start(ixgbe_t *ixgbe, boolean_t alloc_buffer)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (alloc_buffer) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe_alloc_rx_data(ixgbe) != IXGBE_SUCCESS) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China "Failed to allocate software receive rings");
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China /* Allocate buffers for all the rx/tx rings */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe_alloc_dma(ixgbe) != IXGBE_SUCCESS) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "Failed to allocate DMA resource");
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->tx_ring_init = B_TRUE;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China } else {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->tx_ring_init = B_FALSE;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_rx_rings; i++)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->rx_rings[i].rx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_tx_rings; i++)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->tx_rings[i].tx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Start the chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_chip_start(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_fm_ereport(ixgbe, DDI_FM_DEVICE_INVAL_STATE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto start_failure;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto start_failure;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup the rx/tx rings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_rings(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo /*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * ixgbe_start() will be called when resetting, however if reset
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * happens, we need to clear the ERROR, STALL and OVERTEMP flags
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * before enabling the interrupts.
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China atomic_and_32(&ixgbe->ixgbe_state, ~(IXGBE_ERROR
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China | IXGBE_STALL| IXGBE_OVERTEMP));
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Enable adapter interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The interrupts must be enabled after the driver state is START
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_enable_adapter_interrupts(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = ixgbe->num_tx_rings - 1; i >= 0; i--)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->tx_rings[i].tx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = ixgbe->num_rx_rings - 1; i >= 0; i--)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->rx_rings[i].rx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstart_failure:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = ixgbe->num_tx_rings - 1; i >= 0; i--)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->tx_rings[i].tx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = ixgbe->num_rx_rings - 1; i >= 0; i--)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->rx_rings[i].rx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_stop - Stop the driver/chipset.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btvoid
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_stop(ixgbe_t *ixgbe, boolean_t free_buffer)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable the adapter interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_disable_adapter_interrupts(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Drain the pending tx packets
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_tx_drain(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_rx_rings; i++)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->rx_rings[i].rx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_tx_rings; i++)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->tx_rings[i].tx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Stop the chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_chip_stop(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Clean the pending tx data/resources
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_clean(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = ixgbe->num_tx_rings - 1; i >= 0; i--)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->tx_rings[i].tx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = ixgbe->num_rx_rings - 1; i >= 0; i--)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->rx_rings[i].rx_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe->link_state == LINK_STATE_UP) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->link_state = LINK_STATE_UNKNOWN;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mac_link_update(ixgbe->mac_hdl, ixgbe->link_state);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (free_buffer) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China /*
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Release the DMA/memory resources of rx/tx rings
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_dma(ixgbe);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_rx_data(ixgbe);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_cbfunc - Driver interface for generic DDI callbacks
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/* ARGSUSED */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic int
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_cbfunc(dev_info_t *dip, ddi_cb_action_t cbaction, void *cbarg,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer void *arg1, void *arg2)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer{
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_t *ixgbe = (ixgbe_t *)arg1;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer switch (cbaction) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /* IRM callback */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int count;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case DDI_CB_INTR_ADD:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case DDI_CB_INTR_REMOVE:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer count = (int)(uintptr_t)cbarg;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ASSERT(ixgbe->intr_type == DDI_INTR_TYPE_MSIX);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer DTRACE_PROBE2(ixgbe__irm__callback, int, count,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int, ixgbe->intr_cnt);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_intr_adjust(ixgbe, cbaction, count) !=
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer DDI_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "IRM CB: Failed to adjust interrupts");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto cb_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer default:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_DEBUGLOG_1(ixgbe, "DDI CB: action 0x%x NOT supported",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer cbaction);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (DDI_ENOTSUP);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (DDI_SUCCESS);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyercb_fail:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (DDI_FAILURE);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer}
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_intr_adjust - Adjust interrupt to respond to IRM request.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic int
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_intr_adjust(ixgbe_t *ixgbe, ddi_cb_action_t cbaction, int count)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer{
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int i, rc, actual;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (count == 0)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (DDI_SUCCESS);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if ((cbaction == DDI_CB_INTR_ADD &&
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt + count > ixgbe->intr_cnt_max) ||
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (cbaction == DDI_CB_INTR_REMOVE &&
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt - count < ixgbe->intr_cnt_min))
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (DDI_FAILURE);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (!(ixgbe->ixgbe_state & IXGBE_STARTED)) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (DDI_FAILURE);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < ixgbe->num_rx_rings; i++)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_ring_intr_set(ixgbe->rx_rings[i].ring_handle, NULL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < ixgbe->num_tx_rings; i++)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_ring_intr_set(ixgbe->tx_rings[i].ring_handle, NULL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mutex_enter(&ixgbe->gen_lock);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->ixgbe_state &= ~IXGBE_STARTED;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->ixgbe_state |= IXGBE_INTR_ADJUST;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->ixgbe_state |= IXGBE_SUSPENDED;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_link_update(ixgbe->mac_hdl, LINK_STATE_UNKNOWN);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_stop(ixgbe, B_FALSE);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Disable interrupts
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->attach_progress & ATTACH_PROGRESS_ENABLE_INTR) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc = ixgbe_disable_intrs(ixgbe);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ASSERT(rc == IXGBE_SUCCESS);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress &= ~ATTACH_PROGRESS_ENABLE_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Remove interrupt handlers
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->attach_progress & ATTACH_PROGRESS_ADD_INTR) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_rem_intr_handlers(ixgbe);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress &= ~ATTACH_PROGRESS_ADD_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Clear vect_map
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer bzero(&ixgbe->vect_map, sizeof (ixgbe->vect_map));
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer switch (cbaction) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case DDI_CB_INTR_ADD:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc = ddi_intr_alloc(ixgbe->dip, ixgbe->htable,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer DDI_INTR_TYPE_MSIX, ixgbe->intr_cnt, count, &actual,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer DDI_INTR_ALLOC_NORMAL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (rc != DDI_SUCCESS || actual != count) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_log(ixgbe, "Adjust interrupts failed."
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "return: %d, irm cb size: %d, actual: %d",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc, count, actual);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto intr_adjust_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt += count;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case DDI_CB_INTR_REMOVE:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = ixgbe->intr_cnt - count;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer i < ixgbe->intr_cnt; i ++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc = ddi_intr_free(ixgbe->htable[i]);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->htable[i] = NULL;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (rc != DDI_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_log(ixgbe, "Adjust interrupts failed."
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "return: %d, irm cb size: %d, actual: %d",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc, count, actual);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto intr_adjust_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt -= count;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Get priority for first vector, assume remaining are all the same
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc = ddi_intr_get_pri(ixgbe->htable[0], &ixgbe->intr_pri);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (rc != DDI_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_log(ixgbe,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "Get interrupt priority failed: %d", rc);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto intr_adjust_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc = ddi_intr_get_cap(ixgbe->htable[0], &ixgbe->intr_cap);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (rc != DDI_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_log(ixgbe, "Get interrupt cap failed: %d", rc);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto intr_adjust_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress |= ATTACH_PROGRESS_ALLOC_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Map rings to interrupt vectors
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_map_intrs_to_vectors(ixgbe) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "IRM CB: Failed to map interrupts to vectors");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto intr_adjust_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Add interrupt handlers
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_add_intr_handlers(ixgbe) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe, "IRM CB: Failed to add interrupt handlers");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto intr_adjust_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress |= ATTACH_PROGRESS_ADD_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Now that mutex locks are initialized, and the chip is also
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * initialized, enable interrupts.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_enable_intrs(ixgbe) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe, "IRM CB: Failed to enable DDI interrupts");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto intr_adjust_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress |= ATTACH_PROGRESS_ENABLE_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_start(ixgbe, B_FALSE) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe, "IRM CB: Failed to start");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer goto intr_adjust_fail;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->ixgbe_state &= ~IXGBE_INTR_ADJUST;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->ixgbe_state &= ~IXGBE_SUSPENDED;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->ixgbe_state |= IXGBE_STARTED;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mutex_exit(&ixgbe->gen_lock);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < ixgbe->num_rx_rings; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_ring_intr_set(ixgbe->rx_rings[i].ring_handle,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->htable[ixgbe->rx_rings[i].intr_vector]);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < ixgbe->num_tx_rings; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_ring_intr_set(ixgbe->tx_rings[i].ring_handle,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->htable[ixgbe->tx_rings[i].intr_vector]);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /* Wakeup all Tx rings */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < ixgbe->num_tx_rings; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_tx_ring_update(ixgbe->mac_hdl,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->tx_rings[i].ring_handle);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_DEBUGLOG_3(ixgbe,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "IRM CB: interrupts new value: 0x%x(0x%x:0x%x).",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt, ixgbe->intr_cnt_min, ixgbe->intr_cnt_max);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (DDI_SUCCESS);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerintr_adjust_fail:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mutex_exit(&ixgbe->gen_lock);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (DDI_FAILURE);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer}
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_intr_cb_register - Register interrupt callback function.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic int
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_intr_cb_register(ixgbe_t *ixgbe)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer{
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ddi_cb_register(ixgbe->dip, DDI_CB_FLAG_INTR, ixgbe_cbfunc,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe, NULL, &ixgbe->cb_hdl) != DDI_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (IXGBE_FAILURE);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_DEBUGLOG_0(ixgbe, "Interrupt callback function registered.");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (IXGBE_SUCCESS);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer}
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_rings - Allocate memory space for rx/tx rings.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_alloc_rings(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory space for rx rings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_rings = kmem_zalloc(
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (ixgbe_rx_ring_t) * ixgbe->num_rx_rings,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt KM_NOSLEEP);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->rx_rings == NULL) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory space for tx rings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_rings = kmem_zalloc(
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (ixgbe_tx_ring_t) * ixgbe->num_tx_rings,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt KM_NOSLEEP);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->tx_rings == NULL) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt kmem_free(ixgbe->rx_rings,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (ixgbe_rx_ring_t) * ixgbe->num_rx_rings);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_rings = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Allocate memory space for rx ring groups
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->rx_groups = kmem_zalloc(
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (ixgbe_rx_group_t) * ixgbe->num_rx_groups,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng KM_NOSLEEP);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->rx_groups == NULL) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng kmem_free(ixgbe->rx_rings,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (ixgbe_rx_ring_t) * ixgbe->num_rx_rings);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng kmem_free(ixgbe->tx_rings,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (ixgbe_tx_ring_t) * ixgbe->num_tx_rings);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->rx_rings = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->tx_rings = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (IXGBE_FAILURE);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_free_rings - Free the memory space of rx/tx rings.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_free_rings(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->rx_rings != NULL) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt kmem_free(ixgbe->rx_rings,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (ixgbe_rx_ring_t) * ixgbe->num_rx_rings);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_rings = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->tx_rings != NULL) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt kmem_free(ixgbe->tx_rings,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (ixgbe_tx_ring_t) * ixgbe->num_tx_rings);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_rings = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->rx_groups != NULL) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng kmem_free(ixgbe->rx_groups,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (ixgbe_rx_group_t) * ixgbe->num_rx_groups);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->rx_groups = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic int
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_alloc_rx_data(ixgbe_t *ixgbe)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China{
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_ring_t *rx_ring;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China int i;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->num_rx_rings; i++) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_ring = &ixgbe->rx_rings[i];
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe_alloc_rx_ring_data(rx_ring) != IXGBE_SUCCESS)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China goto alloc_rx_rings_failure;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (IXGBE_SUCCESS);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaalloc_rx_rings_failure:
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_rx_data(ixgbe);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China return (IXGBE_FAILURE);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China}
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic void
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_free_rx_data(ixgbe_t *ixgbe)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China{
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_ring_t *rx_ring;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China int i;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->num_rx_rings; i++) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_ring = &ixgbe->rx_rings[i];
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_enter(&ixgbe->rx_pending_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data != NULL) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->flag |= IXGBE_RX_STOPPED;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (rx_data->rcb_pending == 0) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_rx_ring_data(rx_data);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_ring->rx_data = NULL;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->rx_pending_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China }
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China}
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_rings - Setup rx/tx rings.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_setup_rings(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup the rx/tx rings, including the following:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 1. Setup the descriptor ring and the control block buffers;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 2. Initialize necessary registers for receive/transmit;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 3. Initialize software pointers/parameters for receive/transmit;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_rx(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_tx(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_setup_rx_ring(ixgbe_rx_ring_t *rx_ring)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe = rx_ring->ixgbe;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data = rx_ring->rx_data;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rx_control_block_t *rcb;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt union ixgbe_adv_rx_desc *rbd;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t buf_low;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t buf_high;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t reg_val;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&rx_ring->rx_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->rx_ring_size; i++) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rcb = rx_data->work_list[i];
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rbd = &rx_data->rbd_ring[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rbd->read.pkt_addr = rcb->rx_buf.dma_address;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rbd->read.hdr_addr = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the length register
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China size = rx_data->ring_size * sizeof (union ixgbe_adv_rx_desc);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RDLEN(rx_ring->hw_index), size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the base address registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China buf_low = (uint32_t)rx_data->rbd_area.dma_address;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China buf_high = (uint32_t)(rx_data->rbd_area.dma_address >> 32);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RDBAH(rx_ring->hw_index), buf_high);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RDBAL(rx_ring->hw_index), buf_low);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup head & tail pointers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RDT(rx_ring->hw_index),
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_data->ring_size - 1);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RDH(rx_ring->hw_index), 0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_next = 0;
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China rx_data->lro_first = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup the Receive Descriptor Control Register (RXDCTL)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * PTHRESH=32 descriptors (half the internal cache)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * HTHRESH=0 descriptors (to minimize latency on fetch)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * WTHRESH defaults to 1 (writeback each descriptor)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rx_ring->hw_index));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val |= IXGBE_RXDCTL_ENABLE; /* enable queue */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* Not a valid value for 82599 */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (hw->mac.type < ixgbe_mac_82599EB) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val |= 0x0020; /* pthresh */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rx_ring->hw_index), reg_val);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (hw->mac.type == ixgbe_mac_82599EB) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val |= (IXGBE_RDRXCTL_CRCSTRIP | IXGBE_RDRXCTL_AGGDIS);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg_val);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup the Split and Replication Receive Control Register.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set the rx buffer size and the advanced descriptor type.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val = (ixgbe->rx_buf_size >> IXGBE_SRRCTL_BSIZEPKT_SHIFT) |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val |= IXGBE_SRRCTL_DROP_EN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(rx_ring->hw_index), reg_val);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_setup_rx(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_rx_ring_t *rx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t reg_val;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t ring_mapping;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t i, index;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t psrtype_rss_bit;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* PSRTYPE must be configured for 82599 */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->classify_mode != IXGBE_CLASSIFY_VMDQ &&
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode != IXGBE_CLASSIFY_VMDQ_RSS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val = IXGBE_PSRTYPE_TCPHDR | IXGBE_PSRTYPE_UDPHDR |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_PSRTYPE_IPV4HDR | IXGBE_PSRTYPE_IPV6HDR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val |= IXGBE_PSRTYPE_L2HDR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val |= 0x80000000;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(0), reg_val);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->num_rx_groups > 32) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer psrtype_rss_bit = 0x20000000;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer psrtype_rss_bit = 0x40000000;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < ixgbe->capab->max_rx_grp_num; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val = IXGBE_PSRTYPE_TCPHDR | IXGBE_PSRTYPE_UDPHDR |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_PSRTYPE_IPV4HDR | IXGBE_PSRTYPE_IPV6HDR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val |= IXGBE_PSRTYPE_L2HDR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val |= psrtype_rss_bit;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(i), reg_val);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set filter control in FCTRL to accept broadcast packets and do
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * not pass pause frames to host. Flow control settings are already
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * in this register, so preserve them.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val = IXGBE_READ_REG(hw, IXGBE_FCTRL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val |= IXGBE_FCTRL_BAM; /* broadcast accept mode */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val |= IXGBE_FCTRL_DPF; /* discard pause frames */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_FCTRL, reg_val);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Hardware checksum settings
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->rx_hcksum_enable) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val = IXGBE_RXCSUM_IPPCSE; /* IP checksum */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, reg_val);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Setup VMDq and RSS for multiple receive queues
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer switch (ixgbe->classify_mode) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case IXGBE_CLASSIFY_RSS:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * One group, only RSS is needed when more than
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * one ring enabled.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_setup_rss(ixgbe);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case IXGBE_CLASSIFY_VMDQ:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Multiple groups, each group has one ring,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * only VMDq is needed.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_setup_vmdq(ixgbe);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case IXGBE_CLASSIFY_VMDQ_RSS:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Multiple groups and multiple rings, both
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * VMDq and RSS are needed.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_setup_vmdq_rss(ixgbe);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer default:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Enable the receive unit. This must be done after filter
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * control is set in FCTRL.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val = (IXGBE_RXCTRL_RXEN /* Enable Receive Unit */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt | IXGBE_RXCTRL_DMBYPS); /* descriptor monitor bypass */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, reg_val);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_rx_ring must be called after configuring RXCTRL
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_rx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rx_ring = &ixgbe->rx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_rx_ring(rx_ring);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Setup the per-ring statistics mapping.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ring_mapping = 0;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < ixgbe->num_rx_rings; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer index = ixgbe->rx_rings[i].hw_index;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_mapping = IXGBE_READ_REG(hw, IXGBE_RQSMR(index >> 2));
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_mapping |= (i & 0xF) << (8 * (index & 0x3));
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RQSMR(index >> 2), ring_mapping);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * The Max Frame Size in MHADD/MAXFRS will be internally increased
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * by four bytes if the packet has a VLAN field, so includes MTU,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * ethernet header and frame check sequence.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Register is MAXFRS in 82599.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val = (ixgbe->default_mtu + sizeof (struct ether_header)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt + ETHERFCSL) << IXGBE_MHADD_MFS_SHIFT;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_MHADD, reg_val);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup Jumbo Frame enable bit
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->default_mtu > ETHERMTU) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val = IXGBE_READ_REG(hw, IXGBE_HLREG0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val |= IXGBE_HLREG0_JUMBOEN;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg_val);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer /*
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer * Setup RSC for multiple receive queues.
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer */
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer if (ixgbe->lro_enable) {
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer for (i = 0; i < ixgbe->num_rx_rings; i++) {
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer /*
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer * Make sure rx_buf_size * MAXDESC not greater
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer * than 65535.
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer * Intel recommends 4 for MAXDESC field value.
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer */
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val = IXGBE_READ_REG(hw, IXGBE_RSCCTL(i));
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val |= IXGBE_RSCCTL_RSCEN;
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer if (ixgbe->rx_buf_size == IXGBE_PKG_BUF_16k)
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val |= IXGBE_RSCCTL_MAXDESC_1;
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer else
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val |= IXGBE_RSCCTL_MAXDESC_4;
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(i), reg_val);
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer }
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val = IXGBE_READ_REG(hw, IXGBE_RSCDBU);
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val |= IXGBE_RSCDBU_RSCACKDIS;
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RSCDBU, reg_val);
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val |= IXGBE_RDRXCTL_RSCACKC;
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo reg_val |= IXGBE_RDRXCTL_FCOE_WRFIX;
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer reg_val &= ~IXGBE_RDRXCTL_RSCFRSTSIZE;
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg_val);
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_setup_tx_ring(ixgbe_tx_ring_t *tx_ring)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe = tx_ring->ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t buf_low;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t buf_high;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t reg_val;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&tx_ring->tx_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the length register
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt size = tx_ring->ring_size * sizeof (union ixgbe_adv_tx_desc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_TDLEN(tx_ring->index), size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the base address registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt buf_low = (uint32_t)tx_ring->tbd_area.dma_address;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt buf_high = (uint32_t)(tx_ring->tbd_area.dma_address >> 32);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_TDBAL(tx_ring->index), buf_low);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_TDBAH(tx_ring->index), buf_high);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup head & tail pointers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_TDH(tx_ring->index), 0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_TDT(tx_ring->index), 0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup head write-back
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->tx_head_wb_enable) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The memory of the head write-back is allocated using
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the extra tbd beyond the tail of the tbd ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tbd_head_wb = (uint32_t *)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ((uintptr_t)tx_ring->tbd_area.address + size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *tx_ring->tbd_head_wb = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt buf_low = (uint32_t)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (tx_ring->tbd_area.dma_address + size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt buf_high = (uint32_t)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ((tx_ring->tbd_area.dma_address + size) >> 32);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Set the head write-back enable bit */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt buf_low |= IXGBE_TDWBAL_HEAD_WB_ENABLE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_TDWBAL(tx_ring->index), buf_low);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_TDWBAH(tx_ring->index), buf_high);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Turn off relaxed ordering for head write back or it will
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * cause problems with the tx recycling
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val = IXGBE_READ_REG(hw,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DCA_TXCTRL(tx_ring->index));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DCA_TXCTRL(tx_ring->index), reg_val);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tbd_head_wb = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tbd_head = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tbd_tail = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tbd_free = tx_ring->ring_size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe->tx_ring_init == B_TRUE) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tcb_head = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tcb_tail = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tcb_free = tx_ring->free_list_size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
f27d3025d908422c3f6e682964b4f1e2b4834e4agg * Initialize the s/w context structure
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
f27d3025d908422c3f6e682964b4f1e2b4834e4agg bzero(&tx_ring->tx_context, sizeof (ixgbe_tx_context_t));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_setup_tx(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_ring_t *tx_ring;
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg uint32_t reg_val;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint32_t ring_mapping;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_tx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring = &ixgbe->tx_rings[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_tx_ring(tx_ring);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Setup the per-ring statistics mapping.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ring_mapping = 0;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < ixgbe->num_tx_rings; i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ring_mapping |= (i & 0xF) << (8 * (i & 0x3));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if ((i & 0x3) == 0x3) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_TQSMR(i >> 2),
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ring_mapping);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_TQSM(i >> 2),
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ring_mapping);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ring_mapping = 0;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (i & 0x3) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_TQSMR(i >> 2), ring_mapping);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_TQSM(i >> 2), ring_mapping);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg /*
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * Enable CRC appending and TX padding (for short tx frames)
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg */
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg reg_val = IXGBE_READ_REG(hw, IXGBE_HLREG0);
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg reg_val |= IXGBE_HLREG0_TXCRCEN | IXGBE_HLREG0_TXPADEN;
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg_val);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * enable DMA for 82599 parts
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (hw->mac.type == ixgbe_mac_82599EB) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* DMATXCTL.TE must be set after all Tx config is complete */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val |= IXGBE_DMATXCTL_TE;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg_val);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Enabling tx queues ..
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * For 82599 must be done after DMATXCTL.TE is set
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->num_tx_rings; i++) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China tx_ring = &ixgbe->tx_rings[i];
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val = IXGBE_READ_REG(hw, IXGBE_TXDCTL(tx_ring->index));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val |= IXGBE_TXDCTL_ENABLE;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(tx_ring->index), reg_val);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_rss - Setup receive-side scaling feature.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_setup_rss(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg uint32_t i, mrqc, rxcsum;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t random;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t reta;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t ring_per_group;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Fill out redirection table
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reta = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < 128; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reta = (reta << 8) | (i % ring_per_group) |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ((i % ring_per_group) << 4);
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg if ((i & 3) == 3)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Fill out hash function seeds with a random constant
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < 10; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) random_get_pseudo_bytes((uint8_t *)&random,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (uint32_t));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), random);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * Enable RSS & perform hash on these packet types
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mrqc = IXGBE_MRQC_RSSEN |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV4 |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV4_TCP |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV4_UDP |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV6_EX |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV6 |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV6_TCP |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV6_UDP |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable Packet Checksum to enable RSS for multiple receive queues.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * It is an adapter hardware limitation that Packet Checksum is
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * mutually exclusive with RSS.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rxcsum |= IXGBE_RXCSUM_PCSD;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rxcsum &= ~IXGBE_RXCSUM_IPPCSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, rxcsum);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_setup_vmdq - Setup MAC classification feature
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic void
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_setup_vmdq(ixgbe_t *ixgbe)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer{
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer struct ixgbe_hw *hw = &ixgbe->hw;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t vmdctl, i, vtctl;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Setup the VMDq Control register, enable VMDq based on
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * packet destination MAC address:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer switch (hw->mac.type) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case ixgbe_mac_82598EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * VMDq Enable = 1;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * VMDq Filter = 0; MAC filtering
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Default VMDq output index = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer vmdctl = IXGBE_VMD_CTL_VMDQ_EN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_VMD_CTL, vmdctl);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case ixgbe_mac_82599EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable VMDq-only.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer vmdctl = IXGBE_MRQC_VMDQEN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_MRQC, vmdctl);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < hw->mac.num_rar_entries; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(i), 0);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(i), 0);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable Virtualization and Replication.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer vtctl = IXGBE_VT_CTL_VT_ENABLE | IXGBE_VT_CTL_REPLEN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vtctl);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable receiving packets to all VFs
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_VFRE(0), IXGBE_VFRE_ENABLE_ALL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_VFRE(1), IXGBE_VFRE_ENABLE_ALL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer default:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer}
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_setup_vmdq_rss - Setup both vmdq feature and rss feature.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic void
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_setup_vmdq_rss(ixgbe_t *ixgbe)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer{
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer struct ixgbe_hw *hw = &ixgbe->hw;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t i, mrqc, rxcsum;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t random;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t reta;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t ring_per_group;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t vmdctl, vtctl;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Fill out redirection table
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reta = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < 128; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reta = (reta << 8) | (i % ring_per_group) |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ((i % ring_per_group) << 4);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if ((i & 3) == 3)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Fill out hash function seeds with a random constant
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < 10; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (void) random_get_pseudo_bytes((uint8_t *)&random,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer sizeof (uint32_t));
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), random);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable and setup RSS and VMDq
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer switch (hw->mac.type) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case ixgbe_mac_82598EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable RSS & Setup RSS Hash functions
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mrqc = IXGBE_MRQC_RSSEN |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV4 |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV4_TCP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV4_UDP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_EX |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6 |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_TCP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_UDP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable and Setup VMDq
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * VMDq Filter = 0; MAC filtering
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Default VMDq output index = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer vmdctl = IXGBE_VMD_CTL_VMDQ_EN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_VMD_CTL, vmdctl);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case ixgbe_mac_82599EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable RSS & Setup RSS Hash functions
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mrqc = IXGBE_MRQC_RSS_FIELD_IPV4 |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV4_TCP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV4_UDP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_EX |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6 |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_TCP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_UDP |
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable VMDq+RSS.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->num_rx_groups > 32) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mrqc = mrqc | IXGBE_MRQC_VMDQRSS64EN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mrqc = mrqc | IXGBE_MRQC_VMDQRSS32EN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < hw->mac.num_rar_entries; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(i), 0);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(i), 0);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer default:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Disable Packet Checksum to enable RSS for multiple receive queues.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * It is an adapter hardware limitation that Packet Checksum is
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * mutually exclusive with RSS.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rxcsum |= IXGBE_RXCSUM_PCSD;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rxcsum &= ~IXGBE_RXCSUM_IPPCSE;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, rxcsum);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (hw->mac.type == ixgbe_mac_82599EB) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable Virtualization and Replication.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer vtctl = IXGBE_VT_CTL_VT_ENABLE | IXGBE_VT_CTL_REPLEN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vtctl);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable receiving packets to all VFs
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_VFRE(0), IXGBE_VFRE_ENABLE_ALL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_VFRE(1), IXGBE_VFRE_ENABLE_ALL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer}
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init_unicst - Initialize the unicast addresses.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_init_unicst(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng uint8_t *mac_addr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int slot;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Here we should consider two situations:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * 1. Chipset is initialized at the first time,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Clear all the multiple unicast addresses.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 2. Chipset is reset
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Recover the multiple unicast addresses from the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * software data structure to the RAR registers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (!ixgbe->unicst_init) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the multiple unicast addresses
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->unicst_total = hw->mac.num_rar_entries;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->unicst_avail = ixgbe->unicst_total;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < ixgbe->unicst_total; slot++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_addr = ixgbe->unicst_addr[slot].mac.addr;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng bzero(mac_addr, ETHERADDRL);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) ixgbe_set_rar(hw, slot, mac_addr, NULL, NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->unicst_addr[slot].mac.set = 0;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->unicst_init = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Re-configure the RAR registers */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < ixgbe->unicst_total; slot++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_addr = ixgbe->unicst_addr[slot].mac.addr;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->unicst_addr[slot].mac.set == 1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) ixgbe_set_rar(hw, slot, mac_addr,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->unicst_addr[slot].mac.group_index,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_RAH_AV);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng } else {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng bzero(mac_addr, ETHERADDRL);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) ixgbe_set_rar(hw, slot, mac_addr,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng NULL, NULL);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * ixgbe_unicst_find - Find the slot for the specified unicast address
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengint
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_unicst_find(ixgbe_t *ixgbe, const uint8_t *mac_addr)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int slot;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ASSERT(mutex_owned(&ixgbe->gen_lock));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < ixgbe->unicst_total; slot++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (bcmp(ixgbe->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
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_multicst_add - Add a multicst address.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_multicst_add(ixgbe_t *ixgbe, const uint8_t *multiaddr)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if ((multiaddr[0] & 01) == 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (EINVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->mcast_count >= MAX_NUM_MULTICAST_ADDRESSES) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (ENOENT);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt bcopy(multiaddr,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &ixgbe->mcast_table[ixgbe->mcast_count], ETHERADDRL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->mcast_count++;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Update the multicast table in the hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_multicst(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (EIO);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_multicst_remove - Remove a multicst address.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_multicst_remove(ixgbe_t *ixgbe, const uint8_t *multiaddr)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->mcast_count; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (bcmp(multiaddr, &ixgbe->mcast_table[i],
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ETHERADDRL) == 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i++; i < ixgbe->mcast_count; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->mcast_table[i - 1] =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->mcast_table[i];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->mcast_count--;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Update the multicast table in the hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_setup_multicst(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (EIO);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_multicast - Setup multicast data structures.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This routine initializes all of the multicast related structures
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * and save them in the hardware registers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_setup_multicst(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint8_t *mc_addr_list;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t mc_addr_count;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(ixgbe->mcast_count <= MAX_NUM_MULTICAST_ADDRESSES);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mc_addr_list = (uint8_t *)ixgbe->mcast_table;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mc_addr_count = ixgbe->mcast_count;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Update the multicast addresses to the MTA registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_update_mc_addr_list(hw, mc_addr_list, mc_addr_count,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_mc_table_itr);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_setup_vmdq_rss_conf - Configure vmdq and rss (number and mode).
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Configure the rx classification mode (vmdq & rss) and vmdq & rss numbers.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Different chipsets may have different allowed configuration of vmdq and rss.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic void
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_setup_vmdq_rss_conf(ixgbe_t *ixgbe)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer{
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer struct ixgbe_hw *hw = &ixgbe->hw;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t ring_per_group;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer switch (hw->mac.type) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case ixgbe_mac_82598EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * 82598 supports the following combination:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * vmdq no. x rss no.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * [5..16] x 1
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * [1..4] x [1..16]
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * However 8 rss queue per pool (vmdq) is sufficient for
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * most cases.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->num_rx_groups > 4) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->num_rx_rings = ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->num_rx_rings = ixgbe->num_rx_groups *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer min(8, ring_per_group);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer case ixgbe_mac_82599EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * 82599 supports the following combination:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * vmdq no. x rss no.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * [33..64] x [1..2]
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * [2..32] x [1..4]
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * 1 x [1..16]
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * However 8 rss queue per pool (vmdq) is sufficient for
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * most cases.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->num_rx_groups == 1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->num_rx_rings = min(8, ring_per_group);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else if (ixgbe->num_rx_groups <= 32) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->num_rx_rings = ixgbe->num_rx_groups *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer min(4, ring_per_group);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else if (ixgbe->num_rx_groups <= 64) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->num_rx_rings = ixgbe->num_rx_groups *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer min(2, ring_per_group);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer default:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->num_rx_groups == 1 && ring_per_group == 1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode = IXGBE_CLASSIFY_NONE;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else if (ixgbe->num_rx_groups != 1 && ring_per_group == 1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode = IXGBE_CLASSIFY_VMDQ;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else if (ixgbe->num_rx_groups != 1 && ring_per_group != 1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode = IXGBE_CLASSIFY_VMDQ_RSS;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode = IXGBE_CLASSIFY_RSS;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo IXGBE_DEBUGLOG_2(ixgbe, "rx group number:%d, rx ring number:%d",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->num_rx_groups, ixgbe->num_rx_rings);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer}
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_get_conf - Get driver configurations set in driver.conf.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This routine gets user-configured values out of the configuration
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * file ixgbe.conf.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For each configurable value, there is a minimum, a maximum, and a
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * default.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If user does not configure a value, use the default.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If user configures below the minimum, use the minumum.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If user configures above the maximum, use the maxumum.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_get_conf(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t flow_control;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe driver supports the following user configurations:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Jumbo frame configuration:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * default_mtu
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Ethernet flow control configuration:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * flow_control
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Multiple rings configurations:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * tx_queue_number
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * tx_ring_size
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * rx_queue_number
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * rx_ring_size
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ixgbe_get_prop() to get the value for a specific
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * configuration parameter.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Jumbo frame configuration - max_frame_size controls host buffer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * allocation, so includes MTU, ethernet header, vlan tag and
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * frame check sequence.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->default_mtu = ixgbe_get_prop(ixgbe, PROP_DEFAULT_MTU,
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China MIN_MTU, ixgbe->capab->max_mtu, DEFAULT_MTU);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->max_frame_size = ixgbe->default_mtu +
9da57d7b0ddd8d73b676ce12c040362132cdd538bt sizeof (struct ether_vlan_header) + ETHERFCSL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Ethernet flow control configuration
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt flow_control = ixgbe_get_prop(ixgbe, PROP_FLOW_CONTROL,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_fc_none, 3, ixgbe_fc_none);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (flow_control == 3)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt flow_control = ixgbe_fc_default;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * fc.requested mode is what the user requests. After autoneg,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * fc.current_mode will be the flow_control mode that was negotiated.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China hw->fc.requested_mode = flow_control;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Multiple rings configurations
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->num_tx_rings = ixgbe_get_prop(ixgbe, PROP_TX_QUEUE_NUM,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->min_tx_que_num,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->max_tx_que_num,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->def_tx_que_num);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_ring_size = ixgbe_get_prop(ixgbe, PROP_TX_RING_SIZE,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MIN_TX_RING_SIZE, MAX_TX_RING_SIZE, DEFAULT_TX_RING_SIZE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->num_rx_rings = ixgbe_get_prop(ixgbe, PROP_RX_QUEUE_NUM,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->min_rx_que_num,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->max_rx_que_num,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->def_rx_que_num);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_ring_size = ixgbe_get_prop(ixgbe, PROP_RX_RING_SIZE,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MIN_RX_RING_SIZE, MAX_RX_RING_SIZE, DEFAULT_RX_RING_SIZE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Multiple groups configuration
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->num_rx_groups = ixgbe_get_prop(ixgbe, PROP_RX_GROUP_NUM,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->capab->min_rx_grp_num, ixgbe->capab->max_rx_grp_num,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->capab->def_rx_grp_num);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->mr_enable = ixgbe_get_prop(ixgbe, PROP_MR_ENABLE,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng 0, 1, DEFAULT_MR_ENABLE);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->mr_enable == B_FALSE) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->num_tx_rings = 1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->num_rx_rings = 1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->num_rx_groups = 1;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode = IXGBE_CLASSIFY_NONE;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->num_rx_rings = ixgbe->num_rx_groups *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer max(ixgbe->num_rx_rings / ixgbe->num_rx_groups, 1);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * The combination of num_rx_rings and num_rx_groups
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * may be not supported by h/w. We need to adjust
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * them to appropriate values.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_setup_vmdq_rss_conf(ixgbe);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Tunable used to force an interrupt type. The only use is
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * for testing of the lesser interrupt types.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 0 = don't force interrupt type
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * 1 = force interrupt type MSI-X
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 2 = force interrupt type MSI
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 3 = force interrupt type Legacy
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->intr_force = ixgbe_get_prop(ixgbe, PROP_INTR_FORCE,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_INTR_NONE, IXGBE_INTR_LEGACY, IXGBE_INTR_NONE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_hcksum_enable = ixgbe_get_prop(ixgbe, PROP_TX_HCKSUM_ENABLE,
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg 0, 1, DEFAULT_TX_HCKSUM_ENABLE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_hcksum_enable = ixgbe_get_prop(ixgbe, PROP_RX_HCKSUM_ENABLE,
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg 0, 1, DEFAULT_RX_HCKSUM_ENABLE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->lso_enable = ixgbe_get_prop(ixgbe, PROP_LSO_ENABLE,
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg 0, 1, DEFAULT_LSO_ENABLE);
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe->lro_enable = ixgbe_get_prop(ixgbe, PROP_LRO_ENABLE,
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China 0, 1, DEFAULT_LRO_ENABLE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_head_wb_enable = ixgbe_get_prop(ixgbe, PROP_TX_HEAD_WB_ENABLE,
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg 0, 1, DEFAULT_TX_HEAD_WB_ENABLE);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->relax_order_enable = ixgbe_get_prop(ixgbe,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China PROP_RELAX_ORDER_ENABLE, 0, 1, DEFAULT_RELAX_ORDER_ENABLE);
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* Head Write Back not recommended for 82599 */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (hw->mac.type >= ixgbe_mac_82599EB) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->tx_head_wb_enable = B_FALSE;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg /*
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * ixgbe LSO needs the tx h/w checksum support.
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * LSO will be disabled if tx h/w checksum is not
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * enabled.
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg */
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg if (ixgbe->tx_hcksum_enable == B_FALSE) {
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg ixgbe->lso_enable = B_FALSE;
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China /*
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China * ixgbe LRO needs the rx h/w checksum support.
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China * LRO will be disabled if rx h/w checksum is not
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China * enabled.
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China */
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China if (ixgbe->rx_hcksum_enable == B_FALSE) {
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe->lro_enable = B_FALSE;
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China }
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China /*
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China * ixgbe LRO only been supported by 82599 now
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China */
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China if (hw->mac.type != ixgbe_mac_82599EB) {
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe->lro_enable = B_FALSE;
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_copy_thresh = ixgbe_get_prop(ixgbe, PROP_TX_COPY_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MIN_TX_COPY_THRESHOLD, MAX_TX_COPY_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DEFAULT_TX_COPY_THRESHOLD);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_recycle_thresh = ixgbe_get_prop(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt PROP_TX_RECYCLE_THRESHOLD, MIN_TX_RECYCLE_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MAX_TX_RECYCLE_THRESHOLD, DEFAULT_TX_RECYCLE_THRESHOLD);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_overload_thresh = ixgbe_get_prop(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt PROP_TX_OVERLOAD_THRESHOLD, MIN_TX_OVERLOAD_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MAX_TX_OVERLOAD_THRESHOLD, DEFAULT_TX_OVERLOAD_THRESHOLD);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_resched_thresh = ixgbe_get_prop(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt PROP_TX_RESCHED_THRESHOLD, MIN_TX_RESCHED_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MAX_TX_RESCHED_THRESHOLD, DEFAULT_TX_RESCHED_THRESHOLD);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_copy_thresh = ixgbe_get_prop(ixgbe, PROP_RX_COPY_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MIN_RX_COPY_THRESHOLD, MAX_RX_COPY_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DEFAULT_RX_COPY_THRESHOLD);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_limit_per_intr = ixgbe_get_prop(ixgbe, PROP_RX_LIMIT_PER_INTR,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MIN_RX_LIMIT_PER_INTR, MAX_RX_LIMIT_PER_INTR,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DEFAULT_RX_LIMIT_PER_INTR);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->intr_throttling[0] = ixgbe_get_prop(ixgbe, PROP_INTR_THROTTLING,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->capab->min_intr_throttle,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->capab->max_intr_throttle,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->capab->def_intr_throttle);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /*
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * 82599 requires the interupt throttling rate is
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * a multiple of 8. This is enforced by the register
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * definiton.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (hw->mac.type == ixgbe_mac_82599EB)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->intr_throttling[0] = ixgbe->intr_throttling[0] & 0xFF8;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China}
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic void
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_init_params(ixgbe_t *ixgbe)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China{
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_en_10000fdx_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_en_1000fdx_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_en_100fdx_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_10000fdx_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_1000fdx_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_100fdx_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_pause_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_asym_pause_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_rem_fault = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_autoneg_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_pause_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_asym_pause_cap = 1;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_rem_fault = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_lp_10000fdx_cap = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_lp_1000fdx_cap = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_lp_100fdx_cap = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_lp_autoneg_cap = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_lp_pause_cap = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_lp_asym_pause_cap = 0;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->param_lp_rem_fault = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_get_prop - Get a property value out of the configuration file
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe.conf.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Caller provides the name of the property, a default value, a minimum
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * value, and a maximum value.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Return configured value of the property, with default, minimum and
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * maximum properly applied.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_get_prop(ixgbe_t *ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt char *propname, /* name of the property */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int minval, /* minimum acceptable value */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int maxval, /* maximim acceptable value */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int defval) /* default value */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int value;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ddi_prop_get_int() to read the conf settings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt value = ddi_prop_get_int(DDI_DEV_T_ANY, ixgbe->dip,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_PROP_DONTPASS, propname, defval);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (value > maxval)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt value = maxval;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (value < minval)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt value = minval;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (value);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_driver_setup_link - Using the link properties to setup the link.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_driver_setup_link(ixgbe_t *ixgbe, boolean_t setup_hw)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China u32 autoneg_advertised = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China /*
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China * No half duplex support with 10Gb parts
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China */
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China if (ixgbe->param_adv_10000fdx_cap == 1)
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China if (ixgbe->param_adv_1000fdx_cap == 1)
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China if (ixgbe->param_adv_100fdx_cap == 1)
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China if (ixgbe->param_adv_autoneg_cap == 1 && autoneg_advertised == 0) {
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China ixgbe_notice(ixgbe, "Invalid link settings. Setup link "
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China "to autonegotiation with full link capabilities.");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China autoneg_advertised = IXGBE_LINK_SPEED_10GB_FULL |
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China IXGBE_LINK_SPEED_1GB_FULL |
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China IXGBE_LINK_SPEED_100_FULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (setup_hw) {
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China if (ixgbe_setup_link(&ixgbe->hw, autoneg_advertised,
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_autoneg_cap, B_TRUE) != IXGBE_SUCCESS) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_notice(ixgbe, "Setup link failed on this "
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China "device.");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * ixgbe_driver_link_check - Link status processing.
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo *
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * This function can be called in both kernel context and interrupt context
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guostatic void
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guoixgbe_driver_link_check(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_link_speed speed = IXGBE_LINK_SPEED_UNKNOWN;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt boolean_t link_up = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt boolean_t link_changed = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo (void) ixgbe_check_link(hw, &speed, &link_up, false);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (link_up) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_check_complete = B_TRUE;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* Link is up, enable flow control settings */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China (void) ixgbe_fc_enable(hw, 0);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The Link is up, check whether it was marked as down earlier
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->link_state != LINK_STATE_UP) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (speed) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case IXGBE_LINK_SPEED_10GB_FULL:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->link_speed = SPEED_10GB;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case IXGBE_LINK_SPEED_1GB_FULL:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->link_speed = SPEED_1GB;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case IXGBE_LINK_SPEED_100_FULL:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->link_speed = SPEED_100;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->link_duplex = LINK_DUPLEX_FULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->link_state = LINK_STATE_UP;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt link_changed = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->link_check_complete == B_TRUE ||
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo (ixgbe->link_check_complete == B_FALSE &&
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo gethrtime() >= ixgbe->link_check_hrtime)) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo /*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * The link is really down
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo */
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_check_complete = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->link_state != LINK_STATE_DOWN) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_speed = 0;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_duplex = LINK_DUPLEX_UNKNOWN;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->link_state = LINK_STATE_DOWN;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo link_changed = B_TRUE;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo /*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * If we are in an interrupt context, need to re-enable the
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * interrupt, which was automasked
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo */
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (servicing_interrupt() != 0) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->eims |= IXGBE_EICR_LSC;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo IXGBE_WRITE_REG(hw, IXGBE_EIMS, ixgbe->eims);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if (link_changed) {
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo mac_link_update(ixgbe->mac_hdl, ixgbe->link_state);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China/*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * ixgbe_sfp_check - sfp module processing done in taskq only for 82599.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic void
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_sfp_check(void *arg)
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China{
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_t *ixgbe = (ixgbe_t *)arg;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China uint32_t eicr = ixgbe->eicr;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China struct ixgbe_hw *hw = &ixgbe->hw;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo mutex_enter(&ixgbe->gen_lock);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (eicr & IXGBE_EICR_GPI_SDP1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* clear the interrupt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* if link up, do multispeed fiber setup */
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_setup_link(hw, IXGBE_LINK_SPEED_82599_AUTONEG,
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China B_TRUE, B_TRUE);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_driver_link_check(ixgbe);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_get_hw_state(ixgbe);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China } else if (eicr & IXGBE_EICR_GPI_SDP2) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* clear the interrupt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP2);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* if link up, do sfp module setup */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China (void) hw->mac.ops.setup_sfp(hw);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* do multispeed fiber setup */
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_setup_link(hw, IXGBE_LINK_SPEED_82599_AUTONEG,
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China B_TRUE, B_TRUE);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_driver_link_check(ixgbe);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_get_hw_state(ixgbe);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo mutex_exit(&ixgbe->gen_lock);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * We need to fully re-check the link later.
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->link_check_complete = B_FALSE;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->link_check_hrtime = gethrtime() +
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (IXGBE_LINK_UP_TIME * 100000000ULL);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China}
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China/*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * ixgbe_overtemp_check - overtemp module processing done in taskq
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China *
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * This routine will only be called on adapters with temperature sensor.
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * The indication of over-temperature can be either SDP0 interrupt or the link
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * status change interrupt.
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing Chinastatic void
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing Chinaixgbe_overtemp_check(void *arg)
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China{
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = (ixgbe_t *)arg;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China struct ixgbe_hw *hw = &ixgbe->hw;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China uint32_t eicr = ixgbe->eicr;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_link_speed speed;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China boolean_t link_up;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China mutex_enter(&ixgbe->gen_lock);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /* make sure we know current state of link */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_check_link(hw, &speed, &link_up, false);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /* check over-temp condition */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (((eicr & IXGBE_EICR_GPI_SDP0) && (!link_up)) ||
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (eicr & IXGBE_EICR_LSC)) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (hw->phy.ops.check_overtemp(hw) == IXGBE_ERR_OVERTEMP) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China atomic_or_32(&ixgbe->ixgbe_state, IXGBE_OVERTEMP);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Disable the adapter interrupts
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_disable_adapter_interrupts(ixgbe);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Disable Rx/Tx units
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_stop_adapter(hw);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "Problem: Network adapter has been stopped "
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "because it has overheated");
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "Action: Restart the computer. "
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "If the problem persists, power off the system "
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "and replace the adapter");
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /* write to clear the interrupt */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->gen_lock);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo}
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo/*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * ixgbe_link_timer - timer for link status detection
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo */
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guostatic void
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guoixgbe_link_timer(void *arg)
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo{
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe_t *ixgbe = (ixgbe_t *)arg;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo mutex_enter(&ixgbe->gen_lock);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe_driver_link_check(ixgbe);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo mutex_exit(&ixgbe->gen_lock);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China}
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_local_timer - Driver watchdog function.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * This function will handle the transmit stall check and other routines.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_local_timer(void *arg)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe = (ixgbe_t *)arg;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (ixgbe->ixgbe_state & IXGBE_OVERTEMP)
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China goto out;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->ixgbe_state & IXGBE_ERROR) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->reset_count++;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe_reset(ixgbe) == IXGBE_SUCCESS)
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_RESTORED);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China goto out;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_stall_check(ixgbe)) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_or_32(&ixgbe->ixgbe_state, IXGBE_STALL);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->reset_count++;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_reset(ixgbe) == IXGBE_SUCCESS)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_RESTORED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing Chinaout:
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe_restart_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_stall_check - Check for transmit stall.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This function checks if the adapter is stalled (in transmit).
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * It is called each time the watchdog timeout is invoked.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If the transmit descriptor reclaim continuously fails,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the watchdog value will increment by 1. If the watchdog
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * value exceeds the threshold, the ixgbe is assumed to
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * have stalled and need to be reset.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_stall_check(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_ring_t *tx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt boolean_t result;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->link_state != LINK_STATE_UP)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_FALSE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If any tx ring is stalled, we'll reset the chipset
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt result = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->num_tx_rings; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring = &ixgbe->tx_rings[i];
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (tx_ring->tbd_free <= ixgbe->tx_recycle_thresh) {
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo tx_ring->tx_recycle(tx_ring);
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (tx_ring->recycle_fail > 0)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->stall_watchdog++;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt else
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->stall_watchdog = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (tx_ring->stall_watchdog >= STALL_WATCHDOG_TIMEOUT) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt result = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (result) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->stall_watchdog = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->recycle_fail = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (result);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * is_valid_mac_addr - Check if the mac address is valid.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t
9da57d7b0ddd8d73b676ce12c040362132cdd538btis_valid_mac_addr(uint8_t *mac_addr)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt const uint8_t addr_test1[6] = { 0, 0, 0, 0, 0, 0 };
9da57d7b0ddd8d73b676ce12c040362132cdd538bt const uint8_t addr_test2[6] =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (!(bcmp(addr_test1, mac_addr, ETHERADDRL)) ||
9da57d7b0ddd8d73b676ce12c040362132cdd538bt !(bcmp(addr_test2, mac_addr, ETHERADDRL)))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_FALSE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_find_mac_address(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#ifdef __sparc
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uchar_t *bytes;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ether_addr sysaddr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint_t nelts;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int err;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt boolean_t found = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The "vendor's factory-set address" may already have
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * been extracted from the chip, but if the property
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * "local-mac-address" is set we use that instead.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * We check whether it looks like an array of 6
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * bytes (which it should, if OBP set it). If we can't
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * make sense of it this way, we'll ignore it.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt err = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, ixgbe->dip,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_PROP_DONTPASS, "local-mac-address", &bytes, &nelts);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (err == DDI_PROP_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (nelts == ETHERADDRL) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt while (nelts--)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->mac.addr[nelts] = bytes[nelts];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt found = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_prop_free(bytes);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Look up the OBP property "local-mac-address?". If the user has set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 'local-mac-address? = false', use "the system address" instead.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, ixgbe->dip, 0,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "local-mac-address?", &bytes, &nelts) == DDI_PROP_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (strncmp("false", (caddr_t)bytes, (size_t)nelts) == 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (localetheraddr(NULL, &sysaddr) != 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt bcopy(&sysaddr, hw->mac.addr, ETHERADDRL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt found = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_prop_free(bytes);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Finally(!), if there's a valid "mac-address" property (created
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * if we netbooted from this interface), we must use this instead
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * of any of the above to ensure that the NFS/install server doesn't
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * get confused by the address changing as Solaris takes over!
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt err = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, ixgbe->dip,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_PROP_DONTPASS, "mac-address", &bytes, &nelts);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (err == DDI_PROP_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (nelts == ETHERADDRL) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt while (nelts--)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw->mac.addr[nelts] = bytes[nelts];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt found = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_prop_free(bytes);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (found) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt bcopy(hw->mac.addr, hw->mac.perm_addr, ETHERADDRL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#else
9da57d7b0ddd8d73b676ce12c040362132cdd538bt _NOTE(ARGUNUSED(ixgbe));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#endif
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_arm_watchdog_timer)
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_arm_watchdog_timer(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Fire a watchdog timer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_tid =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt timeout(ixgbe_local_timer,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void *)ixgbe, 1 * drv_usectohz(1000000));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_enable_watchdog_timer - Enable and start the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btvoid
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_enable_watchdog_timer(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (!ixgbe->watchdog_enable) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_enable = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_start = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_arm_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_disable_watchdog_timer - Disable and stop the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btvoid
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_disable_watchdog_timer(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt timeout_id_t tid;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_enable = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_start = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tid = ixgbe->watchdog_tid;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_tid = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (tid != 0)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) untimeout(tid);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_start_watchdog_timer - Start the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guovoid
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_start_watchdog_timer(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->watchdog_enable) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (!ixgbe->watchdog_start) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_start = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_arm_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_restart_watchdog_timer - Restart the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_restart_watchdog_timer(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->watchdog_start)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_arm_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_stop_watchdog_timer - Stop the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guovoid
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_stop_watchdog_timer(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt timeout_id_t tid;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_start = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tid = ixgbe->watchdog_tid;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->watchdog_tid = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->watchdog_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (tid != 0)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) untimeout(tid);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_disable_adapter_interrupts - Disable all adapter interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_disable_adapter_interrupts(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * mask all interrupts off
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xffffffff);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * for MSI-X, also disable autoclear
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->intr_type == DDI_INTR_TYPE_MSIX) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_EIAC, 0x0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_FLUSH(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_enable_adapter_interrupts - Enable all hardware interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_enable_adapter_interrupts(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo uint32_t eiac, eiam;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo uint32_t gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* interrupt types to enable */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->eims = IXGBE_EIMS_ENABLE_MASK; /* shared code default */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->eims &= ~IXGBE_EIMS_TCP_TIMER; /* minus tcp timer */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->eims |= ixgbe->capab->other_intr; /* "other" interrupt types */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* enable automask on "other" causes that this adapter can generate */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo eiam = ixgbe->capab->other_intr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * msi-x mode
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->intr_type == DDI_INTR_TYPE_MSIX) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* enable autoclear but not on bits 29:20 */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo eiac = (ixgbe->eims & ~IXGBE_OTHER_INTR);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* general purpose interrupt enable */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo gpie |= (IXGBE_GPIE_MSIX_MODE
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo | IXGBE_GPIE_PBA_SUPPORT
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo | IXGBE_GPIE_OCD
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo | IXGBE_GPIE_EIAME);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * non-msi-x mode
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* disable autoclear, leave gpie at default */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt eiac = 0;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * General purpose interrupt enable.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * For 82599, extended interrupt automask enable
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * only in MSI or MSI-X mode
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if ((hw->mac.type < ixgbe_mac_82599EB) ||
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China (ixgbe->intr_type == DDI_INTR_TYPE_MSI)) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China gpie |= IXGBE_GPIE_EIAME;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /* Enable specific "other" interrupt types */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China gpie |= ixgbe->capab->other_gpie;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China gpie |= ixgbe->capab->other_gpie;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /* Enable RSC Delay 8us when LRO enabled */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (ixgbe->lro_enable) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China gpie |= (1 << IXGBE_GPIE_RSC_DELAY_SHIFT);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* write to interrupt control registers */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo IXGBE_WRITE_REG(hw, IXGBE_EIMS, ixgbe->eims);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_EIAC, eiac);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo IXGBE_WRITE_REG(hw, IXGBE_EIAM, eiam);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_FLUSH(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_loopback_ioctl - Loopback support.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btenum ioc_reply
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_loopback_ioctl(ixgbe_t *ixgbe, struct iocblk *iocp, mblk_t *mp)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt lb_info_sz_t *lbsp;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt lb_property_t *lbpp;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t *lbmp;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t value;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (mp->b_cont == NULL)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_INVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (iocp->ioc_cmd) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt default:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_INVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case LB_GET_INFO_SIZE:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt size = sizeof (lb_info_sz_t);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (iocp->ioc_count != size)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_INVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt value = sizeof (lb_normal);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt value += sizeof (lb_mac);
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China value += sizeof (lb_external);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt lbsp = (lb_info_sz_t *)(uintptr_t)mp->b_cont->b_rptr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *lbsp = value;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case LB_GET_INFO:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt value = sizeof (lb_normal);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt value += sizeof (lb_mac);
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China value += sizeof (lb_external);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt size = value;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (iocp->ioc_count != size)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_INVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt value = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt lbpp = (lb_property_t *)(uintptr_t)mp->b_cont->b_rptr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt lbpp[value++] = lb_normal;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt lbpp[value++] = lb_mac;
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China lbpp[value++] = lb_external;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case LB_GET_MODE:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt size = sizeof (uint32_t);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (iocp->ioc_count != size)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_INVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt lbmp = (uint32_t *)(uintptr_t)mp->b_cont->b_rptr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *lbmp = ixgbe->loopback_mode;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case LB_SET_MODE:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt size = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (iocp->ioc_count != sizeof (uint32_t))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_INVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt lbmp = (uint32_t *)(uintptr_t)mp->b_cont->b_rptr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (!ixgbe_set_loopback_mode(ixgbe, *lbmp))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_INVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt iocp->ioc_count = size;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt iocp->ioc_error = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_INVAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IOC_REPLY);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_set_loopback_mode - Setup loopback based on the loopback mode.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic boolean_t
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_set_loopback_mode(ixgbe_t *ixgbe, uint32_t mode)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (mode == ixgbe->loopback_mode)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->loopback_mode = mode;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (mode == IXGBE_LB_NONE) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset the chip
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_reset(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (mode) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt default:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_FALSE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China case IXGBE_LB_EXTERNAL:
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China break;
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case IXGBE_LB_INTERNAL_MAC:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_set_internal_mac_loopback(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_set_internal_mac_loopback - Set the internal MAC loopback mode.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_set_internal_mac_loopback(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t reg;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint8_t atlas;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup MAC loopback
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg = IXGBE_READ_REG(&ixgbe->hw, IXGBE_HLREG0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg |= IXGBE_HLREG0_LPBK;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(&ixgbe->hw, IXGBE_HLREG0, reg);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg = IXGBE_READ_REG(&ixgbe->hw, IXGBE_AUTOC);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg &= ~IXGBE_AUTOC_LMS_MASK;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(&ixgbe->hw, IXGBE_AUTOC, reg);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable Atlas Tx lanes to keep packets in loopback and not on wire
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_read_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_LPBK,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &atlas);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atlas |= IXGBE_ATLAS_PDN_TX_REG_EN;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_LPBK,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atlas);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_read_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_10G,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &atlas);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atlas |= IXGBE_ATLAS_PDN_TX_10G_QL_ALL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_10G,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atlas);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_read_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_1G,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &atlas);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atlas |= IXGBE_ATLAS_PDN_TX_1G_QL_ALL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_1G,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atlas);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_read_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_AN,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &atlas);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atlas |= IXGBE_ATLAS_PDN_TX_AN_QL_ALL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_AN,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt atlas);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China reg = IXGBE_READ_REG(&ixgbe->hw, IXGBE_AUTOC);
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China reg |= (IXGBE_AUTOC_FLU |
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China IXGBE_AUTOC_10G_KX4);
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China IXGBE_WRITE_REG(&ixgbe->hw, IXGBE_AUTOC, reg);
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_setup_link(&ixgbe->hw, IXGBE_LINK_SPEED_10GB_FULL,
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China B_FALSE, B_TRUE);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_intr_rx_work)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_intr_rx_work - RX processing of ISR.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_intr_rx_work(ixgbe_rx_ring_t *rx_ring)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mblk_t *mp;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&rx_ring->rx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mp = ixgbe_ring_rx(rx_ring, IXGBE_POLL_NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&rx_ring->rx_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (mp != NULL)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_rx_ring(rx_ring->ixgbe->mac_hdl, rx_ring->ring_handle, mp,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_ring->ring_gen_num);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_intr_tx_work)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_intr_tx_work - TX processing of ISR.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_intr_tx_work(ixgbe_tx_ring_t *tx_ring)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = tx_ring->ixgbe;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Recycle the tx descriptors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tx_recycle(tx_ring);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Schedule the re-transmit
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (tx_ring->reschedule &&
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China (tx_ring->tbd_free >= ixgbe->tx_resched_thresh)) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->reschedule = B_FALSE;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_tx_ring_update(tx_ring->ixgbe->mac_hdl,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng tx_ring->ring_handle);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUG_STAT(tx_ring->stat_reschedule);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_intr_other_work)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * ixgbe_intr_other_work - Process interrupt types other than tx/rx
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guoixgbe_intr_other_work(ixgbe_t *ixgbe, uint32_t eicr)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ASSERT(mutex_owned(&ixgbe->gen_lock));
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * handle link status change
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if (eicr & IXGBE_EICR_LSC) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe_driver_link_check(ixgbe);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_get_hw_state(ixgbe);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * check for fan failure on adapters with fans
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if ((ixgbe->capab->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) &&
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo (eicr & IXGBE_EICR_GPI_SDP1)) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China atomic_or_32(&ixgbe->ixgbe_state, IXGBE_OVERTEMP);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Disable the adapter interrupts
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_disable_adapter_interrupts(ixgbe);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Disable Rx/Tx units
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_stop_adapter(&ixgbe->hw);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "Problem: Network adapter has been stopped "
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "because the fan has stopped.\n");
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "Action: Replace the adapter.\n");
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /* re-enable the interrupt, which was automasked */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->eims |= IXGBE_EICR_GPI_SDP1;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Do SFP check for adapters with hot-plug capability
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if ((ixgbe->capab->flags & IXGBE_FLAG_SFP_PLUG_CAPABLE) &&
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ((eicr & IXGBE_EICR_GPI_SDP1) || (eicr & IXGBE_EICR_GPI_SDP2))) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->eicr = eicr;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if ((ddi_taskq_dispatch(ixgbe->sfp_taskq,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_sfp_check, (void *)ixgbe,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China DDI_NOSLEEP)) != DDI_SUCCESS) {
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo ixgbe_log(ixgbe, "No memory available to dispatch "
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo "taskq for SFP check");
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Do over-temperature check for adapters with temp sensor
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if ((ixgbe->capab->flags & IXGBE_FLAG_TEMP_SENSOR_CAPABLE) &&
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ((eicr & IXGBE_EICR_GPI_SDP0) || (eicr & IXGBE_EICR_LSC))) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->eicr = eicr;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if ((ddi_taskq_dispatch(ixgbe->overtemp_taskq,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_overtemp_check, (void *)ixgbe,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China DDI_NOSLEEP)) != DDI_SUCCESS) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_log(ixgbe, "No memory available to dispatch "
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China "taskq for overtemp check");
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_intr_legacy - Interrupt handler for legacy interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic uint_t
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_intr_legacy(void *arg1, void *arg2)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe = (ixgbe_t *)arg1;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_tx_ring_t *tx_ring;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_ring_t *rx_ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t eicr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mblk_t *mp;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt boolean_t tx_reschedule;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint_t result;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo _NOTE(ARGUNUSED(arg2));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_enter(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_INTR_UNCLAIMED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt mp = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_reschedule = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Any bit set in eicr: claim this interrupt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo mutex_exit(&ixgbe->gen_lock);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_or_32(&ixgbe->ixgbe_state, IXGBE_ERROR);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo return (DDI_INTR_CLAIMED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (eicr) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For legacy interrupt, we have only one interrupt,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * so we have only one rx ring and one tx ring enabled.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(ixgbe->num_rx_rings == 1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(ixgbe->num_tx_rings == 1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For legacy interrupt, rx rings[0] will use RTxQ[0].
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (eicr & 0x1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eimc |= IXGBE_EICR_RTX_QUEUE;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_EIMC, ixgbe->eimc);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eims |= IXGBE_EICR_RTX_QUEUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Clean the rx descriptors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_ring = &ixgbe->rx_rings[0];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mp = ixgbe_ring_rx(rx_ring, IXGBE_POLL_NULL);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For legacy interrupt, tx rings[0] will use RTxQ[1].
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (eicr & 0x2) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Recycle the tx descriptors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring = &ixgbe->tx_rings[0];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->tx_recycle(tx_ring);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Schedule the re-transmit
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_reschedule = (tx_ring->reschedule &&
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China (tx_ring->tbd_free >= ixgbe->tx_resched_thresh));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* any interrupt type other than tx/rx */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if (eicr & ixgbe->capab->other_intr) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eimc = IXGBE_82599_OTHER_INTR;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_EIMC, ixgbe->eimc);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe_intr_other_work(ixgbe, eicr);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo mutex_exit(&ixgbe->gen_lock);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt result = DDI_INTR_CLAIMED;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo mutex_exit(&ixgbe->gen_lock);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * No interrupt cause bits set: don't claim this interrupt.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt result = DDI_INTR_UNCLAIMED;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* re-enable the interrupts which were automasked */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo IXGBE_WRITE_REG(hw, IXGBE_EIMS, ixgbe->eims);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Do the following work outside of the gen_lock
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (mp != NULL) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_rx_ring(rx_ring->ixgbe->mac_hdl, rx_ring->ring_handle, mp,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_ring->ring_gen_num);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (tx_reschedule) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt tx_ring->reschedule = B_FALSE;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_tx_ring_update(ixgbe->mac_hdl, tx_ring->ring_handle);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUG_STAT(tx_ring->stat_reschedule);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (result);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_intr_msi - Interrupt handler for MSI.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic uint_t
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_intr_msi(void *arg1, void *arg2)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_t *ixgbe = (ixgbe_t *)arg1;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t eicr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo _NOTE(ARGUNUSED(arg2));
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_or_32(&ixgbe->ixgbe_state, IXGBE_ERROR);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo return (DDI_INTR_CLAIMED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For MSI interrupt, we have only one vector,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * so we have only one rx ring and one tx ring enabled.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(ixgbe->num_rx_rings == 1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(ixgbe->num_tx_rings == 1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For MSI interrupt, rx rings[0] will use RTxQ[0].
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (eicr & 0x1) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_intr_rx_work(&ixgbe->rx_rings[0]);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For MSI interrupt, tx rings[0] will use RTxQ[1].
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (eicr & 0x2) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_intr_tx_work(&ixgbe->tx_rings[0]);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* any interrupt type other than tx/rx */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if (eicr & ixgbe->capab->other_intr) {
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo mutex_enter(&ixgbe->gen_lock);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eimc = IXGBE_82599_OTHER_INTR;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_EIMC, ixgbe->eimc);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe_intr_other_work(ixgbe, eicr);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo mutex_exit(&ixgbe->gen_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* re-enable the interrupts which were automasked */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo IXGBE_WRITE_REG(hw, IXGBE_EIMS, ixgbe->eims);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_INTR_CLAIMED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * ixgbe_intr_msix - Interrupt handler for MSI-X.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic uint_t
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_intr_msix(void *arg1, void *arg2)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_intr_vector_t *vect = (ixgbe_intr_vector_t *)arg1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_t *ixgbe = vect->ixgbe;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China struct ixgbe_hw *hw = &ixgbe->hw;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China uint32_t eicr;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int r_idx = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo _NOTE(ARGUNUSED(arg2));
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Clean each rx ring that has its bit set in the map
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt r_idx = bt_getlowbit(vect->rx_map, 0, (ixgbe->num_rx_rings - 1));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt while (r_idx >= 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_intr_rx_work(&ixgbe->rx_rings[r_idx]);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt r_idx = bt_getlowbit(vect->rx_map, (r_idx + 1),
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ixgbe->num_rx_rings - 1));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Clean each tx ring that has its bit set in the map
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng r_idx = bt_getlowbit(vect->tx_map, 0, (ixgbe->num_tx_rings - 1));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng while (r_idx >= 0) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_intr_tx_work(&ixgbe->tx_rings[r_idx]);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng r_idx = bt_getlowbit(vect->tx_map, (r_idx + 1),
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (ixgbe->num_tx_rings - 1));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Clean other interrupt (link change) that has its bit set in the map
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (BT_TEST(vect->other_map, 0) == 1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) !=
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo DDI_FM_OK) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ddi_fm_service_impact(ixgbe->dip,
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo DDI_SERVICE_DEGRADED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_or_32(&ixgbe->ixgbe_state, IXGBE_ERROR);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo return (DDI_INTR_CLAIMED);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo }
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /*
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Check "other" cause bits: any interrupt type other than tx/rx
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (eicr & ixgbe->capab->other_intr) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China mutex_enter(&ixgbe->gen_lock);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_intr_other_work(ixgbe, eicr);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->eims |= IXGBE_EICR_RTX_QUEUE;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_intr_other_work(ixgbe, eicr);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->gen_lock);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* re-enable the interrupts which were automasked */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_EIMS, ixgbe->eims);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (DDI_INTR_CLAIMED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_intrs - Allocate interrupts for the driver.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Normal sequence is to try MSI-X; if not sucessful, try MSI;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * if not successful, try Legacy.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe->intr_force can be used to force sequence to start with
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * any of the 3 types.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If MSI-X is not used, number of tx/rx rings is forced to 1.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_alloc_intrs(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt dev_info_t *devinfo;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int intr_types;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int rc;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt devinfo = ixgbe->dip;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get supported interrupt types
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_get_supported_types(devinfo, &intr_types);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Get supported interrupt types failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_1(ixgbe, "Supported interrupt types: %x", intr_types);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->intr_type = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Install MSI-X interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if ((intr_types & DDI_INTR_TYPE_MSIX) &&
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ixgbe->intr_force <= IXGBE_INTR_MSIX)) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ixgbe_alloc_intr_handles(ixgbe, DDI_INTR_TYPE_MSIX);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc == IXGBE_SUCCESS)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Allocate MSI-X failed, trying MSI interrupts...");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * MSI-X not used, force rings and groups to 1
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->num_rx_rings = 1;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->num_rx_groups = 1;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->num_tx_rings = 1;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode = IXGBE_CLASSIFY_NONE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "MSI-X not used, force rings and groups number to 1");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Install MSI interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if ((intr_types & DDI_INTR_TYPE_MSI) &&
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ixgbe->intr_force <= IXGBE_INTR_MSI)) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ixgbe_alloc_intr_handles(ixgbe, DDI_INTR_TYPE_MSI);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc == IXGBE_SUCCESS)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Allocate MSI failed, trying Legacy interrupts...");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Install legacy interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (intr_types & DDI_INTR_TYPE_FIXED) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ixgbe_alloc_intr_handles(ixgbe, DDI_INTR_TYPE_FIXED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc == IXGBE_SUCCESS)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Allocate Legacy interrupts failed");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If none of the 3 types succeeded, return failure
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_intr_handles - Allocate interrupt handles.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For legacy and MSI, only 1 handle is needed. For MSI-X,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * if fewer than 2 handles are available, return failure.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Upon success, this maps the vectors to rx and tx rings for
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_alloc_intr_handles(ixgbe_t *ixgbe, int intr_type)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt dev_info_t *devinfo;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int request, count, actual;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int minimum;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int rc;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t ring_per_group;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt devinfo = ixgbe->dip;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (intr_type) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_INTR_TYPE_FIXED:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt request = 1; /* Request 1 legacy interrupt handle */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt minimum = 1;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_0(ixgbe, "interrupt type: legacy");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_INTR_TYPE_MSI:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt request = 1; /* Request 1 MSI interrupt handle */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt minimum = 1;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_0(ixgbe, "interrupt type: MSI");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_INTR_TYPE_MSIX:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Best number of vectors for the adapter is
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * (# rx rings + # tx rings), however we will
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * limit the request number.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer request = min(16, ixgbe->num_rx_rings + ixgbe->num_tx_rings);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (request > ixgbe->capab->max_ring_vect)
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China request = ixgbe->capab->max_ring_vect;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer minimum = 1;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_0(ixgbe, "interrupt type: MSI-X");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt default:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "invalid call to ixgbe_alloc_intr_handles(): %d\n",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt intr_type);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_2(ixgbe, "interrupt handles requested: %d minimum: %d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt request, minimum);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get number of supported interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_get_nintrs(devinfo, intr_type, &count);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if ((rc != DDI_SUCCESS) || (count < minimum)) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Get interrupt number failed. Return: %d, count: %d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc, count);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_1(ixgbe, "interrupts supported: %d", count);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt actual = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->intr_cnt = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt_max = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt_min = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate an array of interrupt handles
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->intr_size = request * sizeof (ddi_intr_handle_t);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->htable = kmem_alloc(ixgbe->intr_size, KM_SLEEP);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_alloc(devinfo, ixgbe->htable, intr_type, 0,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt request, &actual, DDI_INTR_ALLOC_NORMAL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe, "Allocate interrupts failed. "
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "return: %d, request: %d, actual: %d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc, request, actual);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto alloc_handle_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_1(ixgbe, "interrupts actually allocated: %d", actual);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * upper/lower limit of interrupts
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->intr_cnt = actual;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt_max = request;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt_min = minimum;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * rss number per group should not exceed the rx interrupt number,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * else need to adjust rx ring number.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ASSERT((ixgbe->num_rx_rings % ixgbe->num_rx_groups) == 0);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (actual < ring_per_group) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->num_rx_rings = ixgbe->num_rx_groups * actual;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_setup_vmdq_rss_conf(ixgbe);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Now we know the actual number of vectors. Here we map the vector
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * to other, rx rings and tx ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (actual < minimum) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe, "Insufficient interrupt handles available: %d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt actual);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto alloc_handle_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get priority for first vector, assume remaining are all the same
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_get_pri(ixgbe->htable[0], &ixgbe->intr_pri);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Get interrupt priority failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto alloc_handle_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_get_cap(ixgbe->htable[0], &ixgbe->intr_cap);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Get interrupt cap failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt goto alloc_handle_fail;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->intr_type = intr_type;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btalloc_handle_fail:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_rem_intrs(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_add_intr_handlers - Add interrupt handlers based on the interrupt type.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Before adding the interrupt handlers, the interrupt vectors have
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * been allocated, and the rx/tx rings have also been allocated.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_add_intr_handlers(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int vector = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int rc;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (ixgbe->intr_type) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_INTR_TYPE_MSIX:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Add interrupt handler for all vectors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (vector = 0; vector < ixgbe->intr_cnt; vector++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * install pointer to vect_map[vector]
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_add_handler(ixgbe->htable[vector],
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China (ddi_intr_handler_t *)ixgbe_intr_msix,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void *)&ixgbe->vect_map[vector], NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo "Add interrupt handler failed. "
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "return: %d, vector: %d", rc, vector);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (vector--; vector >= 0; vector--) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ddi_intr_remove_handler(
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->htable[vector]);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_INTR_TYPE_MSI:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Add interrupt handlers for the only vector
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_add_handler(ixgbe->htable[vector],
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ddi_intr_handler_t *)ixgbe_intr_msi,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void *)ixgbe, NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Add MSI interrupt handler failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt case DDI_INTR_TYPE_FIXED:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Add interrupt handlers for the only vector
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_add_handler(ixgbe->htable[vector],
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ddi_intr_handler_t *)ixgbe_intr_legacy,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void *)ixgbe, NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Add legacy interrupt handler failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt break;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt default:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_map_rxring_to_vector)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_map_rxring_to_vector - Map given rx ring to given interrupt vector.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_map_rxring_to_vector(ixgbe_t *ixgbe, int r_idx, int v_idx)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set bit in map
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt BT_SET(ixgbe->vect_map[v_idx].rx_map, r_idx);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Count bits set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->vect_map[v_idx].rxr_cnt++;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remember bit position
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->rx_rings[r_idx].intr_vector = v_idx;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_rings[r_idx].vect_bit = 1 << v_idx;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_map_txring_to_vector)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_map_txring_to_vector - Map given tx ring to given interrupt vector.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_map_txring_to_vector(ixgbe_t *ixgbe, int t_idx, int v_idx)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set bit in map
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt BT_SET(ixgbe->vect_map[v_idx].tx_map, t_idx);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Count bits set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->vect_map[v_idx].txr_cnt++;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remember bit position
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->tx_rings[t_idx].intr_vector = v_idx;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_rings[t_idx].vect_bit = 1 << v_idx;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * ixgbe_setup_ivar - Set the given entry in the given interrupt vector
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * allocation register (IVAR).
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * cause:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * -1 : other cause
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * 0 : rx
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * 1 : tx
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_setup_ivar(ixgbe_t *ixgbe, uint16_t intr_alloc_entry, uint8_t msix_vector,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China int8_t cause)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt u32 ivar, index;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China switch (hw->mac.type) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China msix_vector |= IXGBE_IVAR_ALLOC_VAL;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (cause == -1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China cause = 0;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = (((cause * 64) + intr_alloc_entry) >> 2) & 0x1F;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar &= ~(0xFF << (8 * (intr_alloc_entry & 0x3)));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar |= (msix_vector << (8 * (intr_alloc_entry & 0x3)));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (cause == -1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* other causes */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China msix_vector |= IXGBE_IVAR_ALLOC_VAL;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = (intr_alloc_entry & 1) * 8;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar &= ~(0xFF << index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar |= (msix_vector << index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China } else {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* tx or rx causes */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China msix_vector |= IXGBE_IVAR_ALLOC_VAL;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = ((16 * (intr_alloc_entry & 1)) + (8 * cause));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_IVAR(intr_alloc_entry >> 1));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar &= ~(0xFF << index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar |= (msix_vector << index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR(intr_alloc_entry >> 1),
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China default:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * ixgbe_enable_ivar - Enable the given entry by setting the VAL bit of
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * given interrupt vector allocation register (IVAR).
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * cause:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * -1 : other cause
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * 0 : rx
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * 1 : tx
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic void
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_enable_ivar(ixgbe_t *ixgbe, uint16_t intr_alloc_entry, int8_t cause)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng struct ixgbe_hw *hw = &ixgbe->hw;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng u32 ivar, index;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China switch (hw->mac.type) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (cause == -1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China cause = 0;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = (((cause * 64) + intr_alloc_entry) >> 2) & 0x1F;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar |= (IXGBE_IVAR_ALLOC_VAL << (8 *
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China (intr_alloc_entry & 0x3)));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (cause == -1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* other causes */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = (intr_alloc_entry & 1) * 8;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar |= (IXGBE_IVAR_ALLOC_VAL << index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China } else {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* tx or rx causes */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = ((16 * (intr_alloc_entry & 1)) + (8 * cause));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_IVAR(intr_alloc_entry >> 1));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar |= (IXGBE_IVAR_ALLOC_VAL << index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR(intr_alloc_entry >> 1),
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China default:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * ixgbe_disable_ivar - Disble the given entry by clearing the VAL bit of
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * given interrupt vector allocation register (IVAR).
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * cause:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * -1 : other cause
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * 0 : rx
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * 1 : tx
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic void
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_disable_ivar(ixgbe_t *ixgbe, uint16_t intr_alloc_entry, int8_t cause)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng struct ixgbe_hw *hw = &ixgbe->hw;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng u32 ivar, index;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China switch (hw->mac.type) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (cause == -1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China cause = 0;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = (((cause * 64) + intr_alloc_entry) >> 2) & 0x1F;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar &= ~(IXGBE_IVAR_ALLOC_VAL<< (8 *
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China (intr_alloc_entry & 0x3)));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (cause == -1) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* other causes */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = (intr_alloc_entry & 1) * 8;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar &= ~(IXGBE_IVAR_ALLOC_VAL << index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China } else {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* tx or rx causes */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China index = ((16 * (intr_alloc_entry & 1)) + (8 * cause));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar = IXGBE_READ_REG(hw,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_IVAR(intr_alloc_entry >> 1));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar &= ~(IXGBE_IVAR_ALLOC_VAL << index);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR(intr_alloc_entry >> 1),
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ivar);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China default:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Convert the rx ring index driver maintained to the rx ring index
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * in h/w.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic uint32_t
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_get_hw_rx_index(ixgbe_t *ixgbe, uint32_t sw_rx_index)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer{
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer struct ixgbe_hw *hw = &ixgbe->hw;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t rx_ring_per_group, hw_rx_index;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->classify_mode == IXGBE_CLASSIFY_RSS ||
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode == IXGBE_CLASSIFY_NONE) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (sw_rx_index);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else if (ixgbe->classify_mode == IXGBE_CLASSIFY_VMDQ) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (sw_rx_index);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (sw_rx_index * 2);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else if (ixgbe->classify_mode == IXGBE_CLASSIFY_VMDQ_RSS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China switch (hw->mac.type) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer hw_rx_index = (sw_rx_index / rx_ring_per_group) *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer 16 + (sw_rx_index % rx_ring_per_group);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (hw_rx_index);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->num_rx_groups > 32) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer hw_rx_index = (sw_rx_index /
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_ring_per_group) * 2 +
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (sw_rx_index % rx_ring_per_group);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer hw_rx_index = (sw_rx_index /
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_ring_per_group) * 4 +
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (sw_rx_index % rx_ring_per_group);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (hw_rx_index);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China default:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Should never reach. Just to make compiler happy.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (sw_rx_index);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer}
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * ixgbe_map_intrs_to_vectors - Map different interrupts to MSI-X vectors.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * For MSI-X, here will map rx interrupt, tx interrupt and other interrupt
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * to vector[0 - (intr_cnt -1)].
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_map_intrs_to_vectors(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i, vector = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* initialize vector map */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt bzero(&ixgbe->vect_map, sizeof (ixgbe->vect_map));
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (i = 0; i < ixgbe->intr_cnt; i++) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->vect_map[i].ixgbe = ixgbe;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * non-MSI-X case is very simple: rx rings[0] on RTxQ[0],
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tx rings[0] on RTxQ[1].
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->intr_type != DDI_INTR_TYPE_MSIX) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_map_rxring_to_vector(ixgbe, 0, 0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_map_txring_to_vector(ixgbe, 0, 1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Interrupts/vectors mapping for MSI-X
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Map other interrupt to vector 0,
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Set bit in map and count the bits set.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China BT_SET(ixgbe->vect_map[vector].other_map, 0);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->vect_map[vector].other_cnt++;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Map rx ring interrupts to vectors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < ixgbe->num_rx_rings; i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_map_rxring_to_vector(ixgbe, i, vector);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China vector = (vector +1) % ixgbe->intr_cnt;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Map tx ring interrupts to vectors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < ixgbe->num_tx_rings; i++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_map_txring_to_vector(ixgbe, i, vector);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China vector = (vector +1) % ixgbe->intr_cnt;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_adapter_vector - Setup the adapter interrupt vector(s).
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * This relies on ring/vector mapping already set up in the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * vect_map[] structures
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_setup_adapter_vector(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_intr_vector_t *vect; /* vector bitmap */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int r_idx; /* ring index */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int v_idx; /* vector index */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer uint32_t hw_index;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Clear any previous entries
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China switch (hw->mac.type) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82598EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (v_idx = 0; v_idx < 25; v_idx++)
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR(v_idx), 0);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (v_idx = 0; v_idx < 64; v_idx++)
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR(v_idx), 0);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, 0);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China default:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China break;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For non MSI-X interrupt, rx rings[0] will use RTxQ[0], and
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tx rings[0] will use RTxQ[1].
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->intr_type != DDI_INTR_TYPE_MSIX) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_setup_ivar(ixgbe, 0, 0, 0);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_setup_ivar(ixgbe, 0, 1, 1);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * For MSI-X interrupt, "Other" is always on vector[0].
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_setup_ivar(ixgbe, IXGBE_IVAR_OTHER_CAUSES_INDEX, 0, -1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For each interrupt vector, populate the IVAR table
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (v_idx = 0; v_idx < ixgbe->intr_cnt; v_idx++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt vect = &ixgbe->vect_map[v_idx];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For each rx ring bit set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt r_idx = bt_getlowbit(vect->rx_map, 0,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ixgbe->num_rx_rings - 1));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt while (r_idx >= 0) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer hw_index = ixgbe->rx_rings[r_idx].hw_index;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_setup_ivar(ixgbe, hw_index, v_idx, 0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt r_idx = bt_getlowbit(vect->rx_map, (r_idx + 1),
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ixgbe->num_rx_rings - 1));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For each tx ring bit set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt r_idx = bt_getlowbit(vect->tx_map, 0,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ixgbe->num_tx_rings - 1));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt while (r_idx >= 0) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_setup_ivar(ixgbe, r_idx, v_idx, 1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt r_idx = bt_getlowbit(vect->tx_map, (r_idx + 1),
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (ixgbe->num_tx_rings - 1));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_rem_intr_handlers - Remove the interrupt handlers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_rem_intr_handlers(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int rc;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->intr_cnt; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_remove_handler(ixgbe->htable[i]);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_1(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Remove intr handler failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_rem_intrs - Remove the allocated interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_rem_intrs(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int rc;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->intr_cnt; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_free(ixgbe->htable[i]);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_1(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Free intr failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt kmem_free(ixgbe->htable, ixgbe->intr_size);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->htable = NULL;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_enable_intrs - Enable all the ddi interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_enable_intrs(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int rc;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Enable interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->intr_cap & DDI_INTR_FLAG_BLOCK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ddi_intr_block_enable() for MSI
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_block_enable(ixgbe->htable, ixgbe->intr_cnt);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Enable block intr failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ddi_intr_enable() for Legacy/MSI non block enable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->intr_cnt; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_enable(ixgbe->htable[i]);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Enable intr failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_disable_intrs - Disable all the interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_disable_intrs(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int rc;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable all interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->intr_cap & DDI_INTR_FLAG_BLOCK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_block_disable(ixgbe->htable, ixgbe->intr_cnt);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Disable block intr failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < ixgbe->intr_cnt; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_disable(ixgbe->htable[i]);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (rc != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_log(ixgbe,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Disable intr failed: %d", rc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_FAILURE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (IXGBE_SUCCESS);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_get_hw_state - Get and save parameters related to adapter hardware.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_get_hw_state(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt struct ixgbe_hw *hw = &ixgbe->hw;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe_link_speed speed = IXGBE_LINK_SPEED_UNKNOWN;
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo boolean_t link_up = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t pcs1g_anlp = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t pcs1g_ana = 0;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China boolean_t autoneg = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(mutex_owned(&ixgbe->gen_lock));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->param_lp_1000fdx_cap = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->param_lp_100fdx_cap = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* check for link, don't wait */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo (void) ixgbe_check_link(hw, &speed, &link_up, false);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China pcs1g_ana = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if (link_up) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pcs1g_anlp = IXGBE_READ_REG(hw, IXGBE_PCS1GANLP);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->param_lp_1000fdx_cap =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (pcs1g_anlp & IXGBE_PCS1GANLP_LPFD) ? 1 : 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->param_lp_100fdx_cap =
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (pcs1g_anlp & IXGBE_PCS1GANLP_LPFD) ? 1 : 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_get_link_capabilities(hw, &speed, &autoneg);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_1000fdx_cap = ((pcs1g_ana & IXGBE_PCS1GANA_FDC) &&
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (speed & IXGBE_LINK_SPEED_1GB_FULL)) ? 1 : 0;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->param_adv_100fdx_cap = ((pcs1g_ana & IXGBE_PCS1GANA_FDC) &&
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (speed & IXGBE_LINK_SPEED_100_FULL)) ? 1 : 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_get_driver_control - Notify that driver is in control of device.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_get_driver_control(struct ixgbe_hw *hw)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t ctrl_ext;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Notify firmware that driver is in control of device
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_release_driver_control - Notify that driver is no longer in control
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * of device.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_release_driver_control(struct ixgbe_hw *hw)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t ctrl_ext;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Notify firmware that driver is no longer in control of device
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_atomic_reserve - Atomic decrease operation.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_atomic_reserve(uint32_t *count_p, uint32_t n)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t oldval;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint32_t newval;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ATOMICALLY
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt do {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt oldval = *count_p;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (oldval < n)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (-1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt newval = oldval - n;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } while (atomic_cas_32(count_p, oldval, newval) != oldval);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (newval);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_mc_table_itr - Traverse the entries in the multicast table.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic uint8_t *
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_mc_table_itr(struct ixgbe_hw *hw, uint8_t **upd_ptr, uint32_t *vmdq)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint8_t *addr = *upd_ptr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint8_t *new_ptr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo _NOTE(ARGUNUSED(hw));
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo _NOTE(ARGUNUSED(vmdq));
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo
9da57d7b0ddd8d73b676ce12c040362132cdd538bt new_ptr = addr + IXGBE_ETH_LENGTH_OF_ADDRESS;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt *upd_ptr = new_ptr;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (addr);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * FMA support
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_check_acc_handle(ddi_acc_handle_t handle)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_error_t de;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_acc_err_get(handle, &de, DDI_FME_VERSION);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_acc_err_clear(handle, DDI_FME_VERSION);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (de.fme_status);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btint
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_check_dma_handle(ddi_dma_handle_t handle)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_error_t de;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_dma_err_get(handle, &de, DDI_FME_VERSION);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (de.fme_status);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt/*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_fm_error_cb - The IO fault service error handling callback function.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err, const void *impl_data)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt _NOTE(ARGUNUSED(impl_data));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * as the driver can always deal with an error in any dma or
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * access handle, we can just return the fme_status value.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_ereport_post(dip, err, NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (err->fme_status);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_fm_init(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_iblock_cookie_t iblk;
837c1ac4e72b7d86278cca88b1075af557f7d161Stephen Hanson int fma_dma_flag;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Only register with IO Fault Services if we have some capability
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->fm_capabilities & DDI_FM_ACCCHK_CAPABLE) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_regs_acc_attr.devacc_attr_access = DDI_FLAGERR_ACC;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_regs_acc_attr.devacc_attr_access = DDI_DEFAULT_ACC;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->fm_capabilities & DDI_FM_DMACHK_CAPABLE) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt fma_dma_flag = 1;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } else {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt fma_dma_flag = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
837c1ac4e72b7d86278cca88b1075af557f7d161Stephen Hanson ixgbe_set_fma_flags(fma_dma_flag);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->fm_capabilities) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Register capabilities with IO Fault Services
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_init(ixgbe->dip, &ixgbe->fm_capabilities, &iblk);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize pci ereport capabilities if ereport capable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (DDI_FM_EREPORT_CAP(ixgbe->fm_capabilities) ||
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_FM_ERRCB_CAP(ixgbe->fm_capabilities))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_ereport_setup(ixgbe->dip);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Register error callback if error callback capable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (DDI_FM_ERRCB_CAP(ixgbe->fm_capabilities))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_handler_register(ixgbe->dip,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_fm_error_cb, (void*) ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_fm_fini(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Only unregister FMA capabilities if they are registered
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->fm_capabilities) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Release any resources allocated by pci_ereport_setup()
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (DDI_FM_EREPORT_CAP(ixgbe->fm_capabilities) ||
9da57d7b0ddd8d73b676ce12c040362132cdd538bt DDI_FM_ERRCB_CAP(ixgbe->fm_capabilities))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt pci_ereport_teardown(ixgbe->dip);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Un-register error callback if error callback capable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (DDI_FM_ERRCB_CAP(ixgbe->fm_capabilities))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_handler_unregister(ixgbe->dip);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /*
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Unregister from IO Fault Service
9da57d7b0ddd8d73b676ce12c040362132cdd538bt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_fini(ixgbe->dip);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538btvoid
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_fm_ereport(ixgbe_t *ixgbe, char *detail)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt{
9da57d7b0ddd8d73b676ce12c040362132cdd538bt uint64_t ena;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt char buf[FM_MAX_CLASS];
9da57d7b0ddd8d73b676ce12c040362132cdd538bt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) snprintf(buf, FM_MAX_CLASS, "%s.%s", DDI_FM_DEVICE, detail);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ena = fm_ena_generate(0, FM_ENA_FMT1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (DDI_FM_EREPORT_CAP(ixgbe->fm_capabilities)) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ddi_fm_ereport_post(ixgbe->dip, buf, ena, DDI_NOSLEEP,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt FM_VERSION, DATA_TYPE_UINT8, FM_EREPORT_VERS0, NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt }
9da57d7b0ddd8d73b676ce12c040362132cdd538bt}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic int
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_ring_start(mac_ring_driver_t rh, uint64_t mr_gen_num)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_ring_t *rx_ring = (ixgbe_rx_ring_t *)rh;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_enter(&rx_ring->rx_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_ring->ring_gen_num = mr_gen_num;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&rx_ring->rx_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Get the global ring index by a ring index within a group.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic int
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_get_rx_ring_index(ixgbe_t *ixgbe, int gindex, int rindex)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer{
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_rx_ring_t *rx_ring;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int i;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < ixgbe->num_rx_rings; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_ring = &ixgbe->rx_rings[i];
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (rx_ring->group_index == gindex)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rindex--;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (rindex < 0)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (i);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (-1);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer}
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Callback funtion for MAC layer to register all rings.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* ARGSUSED */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengvoid
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_fill_ring(void *arg, mac_ring_type_t rtype, const int group_index,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng const int ring_index, mac_ring_info_t *infop, mac_ring_handle_t rh)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_t *ixgbe = (ixgbe_t *)arg;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_intr_t *mintr = &infop->mri_intr;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng switch (rtype) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng case MAC_RING_TYPE_RX: {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * 'index' is the ring index within the group.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Need to get the global ring index by searching in groups.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int global_ring_index = ixgbe_get_rx_ring_index(
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe, group_index, ring_index);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ASSERT(global_ring_index >= 0);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_rx_ring_t *rx_ring = &ixgbe->rx_rings[global_ring_index];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_ring->ring_handle = rh;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mri_driver = (mac_ring_driver_t)rx_ring;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mri_start = ixgbe_ring_start;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mri_stop = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mri_poll = ixgbe_ring_rx_poll;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer infop->mri_stat = ixgbe_rx_ring_stat;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mintr->mi_handle = (mac_intr_handle_t)rx_ring;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mintr->mi_enable = ixgbe_rx_ring_intr_enable;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mintr->mi_disable = ixgbe_rx_ring_intr_disable;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->intr_type &
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (DDI_INTR_TYPE_MSIX | DDI_INTR_TYPE_MSI)) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mintr->mi_ddi_handle =
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->htable[rx_ring->intr_vector];
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng case MAC_RING_TYPE_TX: {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ASSERT(group_index == -1);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ASSERT(ring_index < ixgbe->num_tx_rings);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_tx_ring_t *tx_ring = &ixgbe->tx_rings[ring_index];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng tx_ring->ring_handle = rh;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mri_driver = (mac_ring_driver_t)tx_ring;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mri_start = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mri_stop = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mri_tx = ixgbe_ring_tx;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer infop->mri_stat = ixgbe_tx_ring_stat;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->intr_type &
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (DDI_INTR_TYPE_MSIX | DDI_INTR_TYPE_MSI)) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mintr->mi_ddi_handle =
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->htable[tx_ring->intr_vector];
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng default:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Callback funtion for MAC layer to register all groups.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengvoid
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_fill_group(void *arg, mac_ring_type_t rtype, const int index,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_group_info_t *infop, mac_group_handle_t gh)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_t *ixgbe = (ixgbe_t *)arg;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng switch (rtype) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng case MAC_RING_TYPE_RX: {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_group_t *rx_group;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_group = &ixgbe->rx_groups[index];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng rx_group->group_handle = gh;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mgi_driver = (mac_group_driver_t)rx_group;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mgi_start = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mgi_stop = NULL;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mgi_addmac = ixgbe_addmac;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mgi_remmac = ixgbe_remmac;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mgi_count = (ixgbe->num_rx_rings / ixgbe->num_rx_groups);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng case MAC_RING_TYPE_TX:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng default:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng break;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Enable interrupt on the specificed rx ring.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengint
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_rx_ring_intr_enable(mac_intr_handle_t intrh)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_ring_t *rx_ring = (ixgbe_rx_ring_t *)intrh;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_t *ixgbe = rx_ring->ixgbe;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int r_idx = rx_ring->index;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int hw_r_idx = rx_ring->hw_index;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int v_idx = rx_ring->intr_vector;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_enter(&ixgbe->gen_lock);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->ixgbe_state & IXGBE_INTR_ADJUST) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mutex_exit(&ixgbe->gen_lock);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Simply return 0.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Interrupts are being adjusted. ixgbe_intr_adjust()
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * will eventually re-enable the interrupt when it's
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * done with the adjustment.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (0);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * To enable interrupt by setting the VAL bit of given interrupt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * vector allocation register (IVAR).
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_enable_ivar(ixgbe, hw_r_idx, 0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng BT_SET(ixgbe->vect_map[v_idx].rx_map, r_idx);
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo /*
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo * Trigger a Rx interrupt on this ring
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo */
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo IXGBE_WRITE_REG(&ixgbe->hw, IXGBE_EICS, (1 << v_idx));
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo IXGBE_WRITE_FLUSH(&ixgbe->hw);
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Disable interrupt on the specificed rx ring.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengint
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_rx_ring_intr_disable(mac_intr_handle_t intrh)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_ring_t *rx_ring = (ixgbe_rx_ring_t *)intrh;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_t *ixgbe = rx_ring->ixgbe;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int r_idx = rx_ring->index;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int hw_r_idx = rx_ring->hw_index;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int v_idx = rx_ring->intr_vector;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_enter(&ixgbe->gen_lock);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->ixgbe_state & IXGBE_INTR_ADJUST) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mutex_exit(&ixgbe->gen_lock);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Simply return 0.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * In the rare case where an interrupt is being
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * disabled while interrupts are being adjusted,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * we don't fail the operation. No interrupts will
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * be generated while they are adjusted, and
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_intr_adjust() will cause the interrupts
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * to be re-enabled once it completes. Note that
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * in this case, packets may be delivered to the
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * stack via interrupts before xgbe_rx_ring_intr_enable()
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * is called again. This is acceptable since interrupt
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * adjustment is infrequent, and the stack will be
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * able to handle these packets.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (0);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * To disable interrupt by clearing the VAL bit of given interrupt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * vector allocation register (IVAR).
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_disable_ivar(ixgbe, hw_r_idx, 0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng BT_CLEAR(ixgbe->vect_map[v_idx].rx_map, r_idx);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Add a mac address.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic int
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_addmac(void *arg, const uint8_t *mac_addr)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_group_t *rx_group = (ixgbe_rx_group_t *)arg;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_t *ixgbe = rx_group->ixgbe;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer struct ixgbe_hw *hw = &ixgbe->hw;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer int slot, i;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_enter(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (ECANCELED);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->unicst_avail == 0) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* no slots available */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (ENOSPC);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * The first ixgbe->num_rx_groups slots are reserved for each respective
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * group. The rest slots are shared by all groups. While adding a
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * MAC address, reserved slots are firstly checked then the shared
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * slots are searched.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer slot = -1;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->unicst_addr[rx_group->index].mac.set == 1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = ixgbe->num_rx_groups; i < ixgbe->unicst_total; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->unicst_addr[i].mac.set == 0) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer slot = i;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer break;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer }
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer slot = rx_group->index;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (slot == -1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /* no slots available */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mutex_exit(&ixgbe->gen_lock);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (ENOSPC);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer bcopy(mac_addr, ixgbe->unicst_addr[slot].mac.addr, ETHERADDRL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (void) ixgbe_set_rar(hw, slot, ixgbe->unicst_addr[slot].mac.addr,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_group->index, IXGBE_RAH_AV);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->unicst_addr[slot].mac.set = 1;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->unicst_addr[slot].mac.group_index = rx_group->index;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->unicst_avail--;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/*
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Remove a mac address.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic int
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_remmac(void *arg, const uint8_t *mac_addr)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng{
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_group_t *rx_group = (ixgbe_rx_group_t *)arg;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_t *ixgbe = rx_group->ixgbe;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer struct ixgbe_hw *hw = &ixgbe->hw;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng int slot;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_enter(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (ECANCELED);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng slot = ixgbe_unicst_find(ixgbe, mac_addr);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (slot == -1) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (EINVAL);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (ixgbe->unicst_addr[slot].mac.set == 0) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (EINVAL);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng bzero(ixgbe->unicst_addr[slot].mac.addr, ETHERADDRL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (void) ixgbe_clear_rar(hw, slot);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->unicst_addr[slot].mac.set = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->unicst_avail++;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mutex_exit(&ixgbe->gen_lock);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer return (0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng}