ixgbe_main.c revision 43fab1a9f38ff02e665a874ea0a8eb3818e61ff3
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * CDDL HEADER START
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.
193974072f41a843678abf5f61979c748687e66bSherry Moore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * See the License for the specific language governing permissions
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * and limitations under the License.
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 * CDDL HEADER END
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * Copyright (c) 2012, Joyent, Inc. All rights reserved.
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
43fab1a9f38ff02e665a874ea0a8eb3818e61ff3Saso Kiselkov * Copyright (c) 2013 Saso Kiselkov. All rights reserved.
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 * Local function protoypes
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 *);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengstatic int ixgbe_unicst_find(ixgbe_t *, const uint8_t *);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerstatic void ixgbe_setup_vmdq_rss_conf(ixgbe_t *ixgbe);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinastatic void ixgbe_init_params(ixgbe_t *);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_get_prop(ixgbe_t *, char *, int, int, int);
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 boolean_t ixgbe_set_loopback_mode(ixgbe_t *, uint32_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 *);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinastatic uint_t ixgbe_intr_msix(void *, void *);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guostatic void ixgbe_intr_other_work(ixgbe_t *, uint32_t);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void ixgbe_release_driver_control(struct ixgbe_hw *);
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_adjust(ixgbe_t *, ddi_cb_action_t, int);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic int ixgbe_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt const void *impl_data);
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",
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))
9da57d7b0ddd8d73b676ce12c040362132cdd538bt 0, /* devo_refcnt */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt &mod_driverops, /* Type of module. This one is a driver */
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe_ident, /* Discription string */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Access attributes for register mapping
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Loopback property
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing Chinastatic lb_property_t lb_external = {
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China external, "External", IXGBE_LB_EXTERNAL
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China#define IXGBE_M_CALLBACK_FLAGS \
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (MC_IOCTL | MC_GETCAPAB | MC_SETPROP | MC_GETPROP | MC_PROPINFO)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_m_getcapab,
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_m_setprop,
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * Initialize capabilities of each supported adapter type
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 IXGBE_EICR_LSC, /* "other" interrupt types handled */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China 0, /* "other" interrupt types enable mask */
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 */
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 (IXGBE_SDP1_GPIEN
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China | IXGBE_SDP2_GPIEN), /* "other" interrupt types enable mask */
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 */
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald 0, /* minimum interrupt throttle rate */
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald | IXGBE_EICR_GPI_SDP2), /* "other" interrupt types handled */
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald | IXGBE_SDP2_GPIEN), /* "other" interrupt types enable mask */
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald | IXGBE_FLAG_RSC_CAPABLE) /* capability flags */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Module Initialization Functions.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_attach - Driver attach.
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 * 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 * Check the command and perform corresponding operations
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (cmd) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Get the device instance */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Allocate memory for the instance data structure */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Attach the instance pointer to the dev_info data structure */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize for fma support
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg ixgbe->fm_capabilities = ixgbe_get_prop(ixgbe, PROP_FM_CAPABLE,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt 0, 0x0f, DDI_FM_EREPORT_CAPABLE | DDI_FM_ACCCHK_CAPABLE |
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Map PCI config space registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (pci_config_setup(devinfo, &osdep->cfg_handle) != DDI_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Identify the chipset family
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Map device registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize driver parameters
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Register interrupt callback
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_intr_cb_register(ixgbe) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe, "Failed to register interrupt callback");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate interrupts
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 ixgbe_error(ixgbe, "Failed to allocate rx and tx rings");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Map rings to interrupt vectors
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 * Add interrupt handlers
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * Create a taskq for sfp-change
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,
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_error(ixgbe, "sfp_taskq create failed");
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->attach_progress |= ATTACH_PROGRESS_SFP_TASKQ;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Create a taskq for over-temp
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 ixgbe->attach_progress |= ATTACH_PROGRESS_OVERTEMP_TASKQ;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize driver parameters
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_init_driver_settings(ixgbe) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_error(ixgbe, "Failed to initialize driver settings");
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 * Initialize chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.cfg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize statistics
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Register the driver to the MAC
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo mac_link_update(ixgbe->mac_hdl, LINK_STATE_UNKNOWN);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->periodic_id = ddi_periodic_add(ixgbe_link_timer, ixgbe,
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe_error(ixgbe, "Failed to add the link check timer");
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ixgbe->attach_progress |= ATTACH_PROGRESS_LINK_TIMER;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Now that mutex locks are initialized, and the chip is also
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * initialized, enable interrupts.
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 * ixgbe_detach - Driver detach.
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 * 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 * Interrupts routine are disabled, All memory allocated by this
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * driver are freed.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check detach command
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (cmd) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get the pointer to the driver private data structure
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
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_and_32(&ixgbe->ixgbe_state, ~IXGBE_STARTED);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_stop(ixgbe, B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Disable and stop the watchdog timer */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check if there are still rx buffers held by the upper layer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If so, fail the detach.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Do the remaining unconfigure routines
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable interrupt
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_ENABLE_INTR) {
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * remove the link check timer
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->attach_progress & ATTACH_PROGRESS_LINK_TIMER) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Unregister MAC
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free statistics
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remove interrupt handlers
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * Remove taskq for sfp-status-change
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe->attach_progress & ATTACH_PROGRESS_SFP_TASKQ) {
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Remove taskq for over-temp
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);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remove interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_ALLOC_INTR) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Unregister interrupt callback handler
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remove driver properties
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Stop the chipset
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free register handle
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free PCI config handle
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_PCI_CONFIG) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free locks
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free the rx/tx rings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe->attach_progress & ATTACH_PROGRESS_ALLOC_RINGS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Unregister FMA capabilities
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Free the driver data structure
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_register_mac - Register the driver and its function pointers with
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the GLD interface.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mac->m_priv_props = ixgbe_priv_props;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_identify_hardware - Identify the type of the chipset.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get the device id
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * Set the mac type of the adapter based on the device id
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * Install adapter capabilities
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo IXGBE_DEBUGLOG_0(ixgbe, "identify 82598 adapter\n");
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if (ixgbe_get_media_type(hw) == ixgbe_media_type_copper) {
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo ixgbe->capab->flags |= IXGBE_FLAG_FAN_FAIL_CAPABLE;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->capab->other_gpie |= IXGBE_SDP1_GPIEN;
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;
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;
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald IXGBE_DEBUGLOG_0(ixgbe, "identify X540 adapter\n");
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * For now, X540 is all set in its capab structure.
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * As other X540 variants show up, things can change here.
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo "adapter not supported in ixgbe_identify_hardware(): %d\n",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_regs_map - Map the device registers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * First get the size of device registers to be mapped.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if (ddi_dev_regsize(devinfo, IXGBE_ADAPTER_REGSET, &mem_size)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ddi_regs_map_setup() to map registers
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China if ((ddi_regs_map_setup(devinfo, IXGBE_ADAPTER_REGSET,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init_properties - Initialize driver properties.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get conf file properties, including link settings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * jumbo frames, ring number, descriptor number, etc.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_init_params(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init_driver_settings - Initialize driver settings.
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 * Initialize chipset specific hardware function pointers
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Get the system page size
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->sys_page_size = ddi_ptob(devinfo, (ulong_t)1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set rx buffer size
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 ((rx_size & (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set tx buffer size
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ((tx_size & (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Initialize rx/tx rings/groups parameters
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rx_ring->hw_index = ixgbe_get_hw_rx_index(ixgbe, i);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize values of interrupt throttling rate
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (i = 1; i < MAX_INTR_VECTOR; i++)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The initial link state should be "unknown"
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init_locks - Initialize locks.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_destroy_locks - Destroy locks.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe_start(ixgbe, B_FALSE) != IXGBE_SUCCESS) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Enable and start the watchdog timer
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_and_32(&ixgbe->ixgbe_state, ~IXGBE_SUSPENDED);
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 ixgbe_stop(ixgbe, B_FALSE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable and stop the watchdog timer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init - Initialize the device.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset chipset to put the hardware in a known state
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * before we try to do anything with the eeprom.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Need to init eeprom before validating the checksum.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Unable to intitialize the eeprom interface.");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * NVM validation
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 "Invalid NVM checksum. Please contact "
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "the vendor to update the NVM.");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup default flow control thresholds - enable/disable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * & flow control type is controlled by ixgbe.conf
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize link settings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset PHY
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_chip_start - Initialize and start the chipset hardware.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get the mac address
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This function should handle SPARC case correctly.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Validate the mac address
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 ixgbe_error(ixgbe, "Failed to initialize hardware");
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo * Re-enable relaxed ordering for performance. It is disabled
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo * by default in the hardware init.
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (ixgbe->relax_order_enable == B_TRUE)
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_enable_relaxed_ordering(hw);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup adapter interrupt vectors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize unicast addresses.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup and initialize the mctable structures.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set interrupt throttling rate
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]);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Save the state of the phy
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Make sure driver has control
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_chip_stop - Stop the chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Tell firmware driver is no longer in control
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset the chipset
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset PHY
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_reset - Reset the chipset and re-start the driver.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * It involves stopping and re-starting the chipset,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * and re-configuring the rx/tx rings.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Disable and stop the watchdog timer
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_disable_watchdog_timer(ixgbe);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo atomic_and_32(&ixgbe->ixgbe_state, ~IXGBE_STARTED);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_stop(ixgbe, B_FALSE);
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);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * After resetting, need to recheck the link status.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->gen_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Enable and start the watchdog timer
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_enable_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_tx_clean - Clean the pending transmit packets and DMA resources.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Clean the pending tx data - the pending packets in the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * work_list that have no chances to be transmitted again.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * We must ensure the chipset is stopped or the link is down
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * before cleaning the transmit packets.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset the head and tail pointers of the tbd ring;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset the writeback head if it's enable.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Add the tx control blocks in the pending list to
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the free list.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_tx_drain - Drain the tx rings to allow pending packets to be
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * transmitted.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Wait for a specific time to allow pending tx packets
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * to be transmitted.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check the counter tbd_free to see if transmission is done.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * No lock protection is needed here.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Return B_TRUE if all pending packets have been transmitted;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Otherwise return B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < TX_DRAIN_TIME; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_rx_drain - Wait for all rx buffers to be released by upper layer.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China boolean_t done = B_TRUE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Polling the rx free list to check if those rx buffers held by
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the upper layer are released.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Check the counter rcb_free to see if all pending buffers are
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * released. No lock protection is needed here.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Return B_TRUE if all pending buffers have been released;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Otherwise return B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < RX_DRAIN_TIME; i++) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China done = (ixgbe->rcb_pending == 0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_start - Start the driver/chipset.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_start(ixgbe_t *ixgbe, boolean_t alloc_buffer)
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 /* 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 ixgbe->tx_ring_init = B_TRUE;
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->tx_ring_init = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Start the chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup the rx/tx rings
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.
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China atomic_and_32(&ixgbe->ixgbe_state, ~(IXGBE_ERROR
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China | IXGBE_STALL| IXGBE_OVERTEMP));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Enable adapter interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The interrupts must be enabled after the driver state is START
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_stop - Stop the driver/chipset.
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_stop(ixgbe_t *ixgbe, boolean_t free_buffer)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable the adapter interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Drain the pending tx packets
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Stop the chipset hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Clean the pending tx data/resources
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 if (free_buffer) {
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * Release the DMA/memory resources of rx/tx rings
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_dma(ixgbe);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_free_rx_data(ixgbe);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_cbfunc - Driver interface for generic DDI callbacks
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer/* ARGSUSED */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_cbfunc(dev_info_t *dip, ddi_cb_action_t cbaction, void *cbarg,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /* IRM callback */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ASSERT(ixgbe->intr_type == DDI_INTR_TYPE_MSIX);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer DTRACE_PROBE2(ixgbe__irm__callback, int, count,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_intr_adjust(ixgbe, cbaction, count) !=
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "IRM CB: Failed to adjust interrupts");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_DEBUGLOG_1(ixgbe, "DDI CB: action 0x%x NOT supported",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_intr_adjust - Adjust interrupt to respond to IRM request.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_intr_adjust(ixgbe_t *ixgbe, ddi_cb_action_t cbaction, int count)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt + count > ixgbe->intr_cnt_max) ||
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->intr_cnt - count < ixgbe->intr_cnt_min))
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_ring_intr_set(ixgbe->rx_rings[i].ring_handle, NULL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_ring_intr_set(ixgbe->tx_rings[i].ring_handle, NULL);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_link_update(ixgbe->mac_hdl, LINK_STATE_UNKNOWN);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Disable interrupts
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->attach_progress & ATTACH_PROGRESS_ENABLE_INTR) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress &= ~ATTACH_PROGRESS_ENABLE_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Remove interrupt handlers
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->attach_progress & ATTACH_PROGRESS_ADD_INTR) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress &= ~ATTACH_PROGRESS_ADD_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Clear vect_map
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer bzero(&ixgbe->vect_map, sizeof (ixgbe->vect_map));
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc = ddi_intr_alloc(ixgbe->dip, ixgbe->htable,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer DDI_INTR_TYPE_MSIX, ixgbe->intr_cnt, count, &actual,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "return: %d, irm cb size: %d, actual: %d",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "return: %d, irm cb size: %d, actual: %d",
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Get priority for first vector, assume remaining are all the same
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc = ddi_intr_get_pri(ixgbe->htable[0], &ixgbe->intr_pri);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer rc = ddi_intr_get_cap(ixgbe->htable[0], &ixgbe->intr_cap);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_log(ixgbe, "Get interrupt cap failed: %d", rc);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress |= ATTACH_PROGRESS_ALLOC_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Map rings to interrupt vectors
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_map_intrs_to_vectors(ixgbe) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer "IRM CB: Failed to map interrupts to vectors");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Add interrupt handlers
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_add_intr_handlers(ixgbe) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe, "IRM CB: Failed to add interrupt handlers");
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->attach_progress |= ATTACH_PROGRESS_ADD_INTR;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Now that mutex locks are initialized, and the chip is also
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * initialized, enable interrupts.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe_enable_intrs(ixgbe) != IXGBE_SUCCESS) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_error(ixgbe, "IRM CB: Failed to enable DDI interrupts");
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 mac_ring_intr_set(ixgbe->rx_rings[i].ring_handle,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->htable[ixgbe->rx_rings[i].intr_vector]);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_ring_intr_set(ixgbe->tx_rings[i].ring_handle,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->htable[ixgbe->tx_rings[i].intr_vector]);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer /* Wakeup all Tx rings */
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 ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_LOST);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_intr_cb_register - Register interrupt callback function.
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 IXGBE_DEBUGLOG_0(ixgbe, "Interrupt callback function registered.");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_rings - Allocate memory space for rx/tx rings.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory space for rx rings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate memory space for tx rings
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Allocate memory space for rx ring groups
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (ixgbe_rx_group_t) * ixgbe->num_rx_groups,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_free_rings - Free the memory space of rx/tx rings.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng sizeof (ixgbe_rx_group_t) * ixgbe->num_rx_groups);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_alloc_rx_data(ixgbe_t *ixgbe)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_ring_t *rx_ring;
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 return (IXGBE_SUCCESS);
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 Chinaixgbe_free_rx_data(ixgbe_t *ixgbe)
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 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 mutex_enter(&ixgbe->rx_pending_lock);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data = rx_ring->rx_data;
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 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 mutex_exit(&ixgbe->rx_pending_lock);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_rings - Setup rx/tx rings.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup the rx/tx rings, including the following:
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;
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_rx_data_t *rx_data = rx_ring->rx_data;
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 * Initialize the length register
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 * Initialize the base address registers
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 * Setup head & tail pointers
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RDT(rx_ring->hw_index),
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RDH(rx_ring->hw_index), 0);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China rx_data->rbd_next = 0;
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China rx_data->lro_first = 0;
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)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rx_ring->hw_index));
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald /* Not a valid value for 82599 or X540 */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China reg_val |= 0x0020; /* pthresh */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rx_ring->hw_index), reg_val);
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);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup the Split and Replication Receive Control Register.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set the rx buffer size and the advanced descriptor type.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt reg_val = (ixgbe->rx_buf_size >> IXGBE_SRRCTL_BSIZEPKT_SHIFT) |
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);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
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 IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(0), reg_val);
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 IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(i), reg_val);
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.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Hardware checksum settings
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer reg_val = IXGBE_RXCSUM_IPPCSE; /* IP checksum */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Setup VMDq and RSS for multiple receive queues
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * One group, only RSS is needed when more than
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * one ring enabled.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Multiple groups, each group has one ring,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * only VMDq is needed.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Multiple groups and multiple rings, both
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * VMDq and RSS are needed.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Enable the receive unit. This must be done after filter
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * control is set in FCTRL.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_rx_ring must be called after configuring RXCTRL
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Setup the per-ring statistics mapping.
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);
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 reg_val = (ixgbe->default_mtu + sizeof (struct ether_header)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup Jumbo Frame enable bit
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer * Setup RSC for multiple receive queues.
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 reg_val = IXGBE_READ_REG(hw, IXGBE_RSCCTL(i));
1878b97151eb2746480d8b2139fa08a2e8f14df3Venugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(i), reg_val);
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the length register
9da57d7b0ddd8d73b676ce12c040362132cdd538bt size = tx_ring->ring_size * sizeof (union ixgbe_adv_tx_desc);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the base address registers
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 * Setup head & tail pointers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup head write-back
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The memory of the head write-back is allocated using
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * the extra tbd beyond the tail of the tbd ring.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Set the head write-back enable bit */
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 * Turn off relaxed ordering for head write back or it will
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * cause problems with the tx recycling
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald reg_val = (hw->mac.type == ixgbe_mac_82598EB) ?
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(tx_ring->index)) :
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL_82599(tx_ring->index));
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald IXGBE_DCA_TXCTRL_82599(tx_ring->index), reg_val);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (ixgbe->tx_ring_init == B_TRUE) {
f27d3025d908422c3f6e682964b4f1e2b4834e4agg * Initialize the s/w context structure
f27d3025d908422c3f6e682964b4f1e2b4834e4agg bzero(&tx_ring->tx_context, sizeof (ixgbe_tx_context_t));
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Setup the per-ring statistics mapping.
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),
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 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 case ixgbe_mac_82599EB:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_TQSM(i >> 2), ring_mapping);
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * Enable CRC appending and TX padding (for short tx frames)
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * enable DMA for 82599 and X540 parts
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald /* 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);
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald /* Disable arbiter to set MTQC */
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald IXGBE_WRITE_REG(hw, IXGBE_MTQC, IXGBE_MTQC_64Q_1PB);
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 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);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_rss - Setup receive-side scaling feature.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Fill out redirection table
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < 128; i++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Fill out hash function seeds with a random constant
9da57d7b0ddd8d73b676ce12c040362132cdd538bt for (i = 0; i < 10; i++) {
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * Enable RSS & perform hash on these packet types
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.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_setup_vmdq - Setup MAC classification feature
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Setup the VMDq Control register, enable VMDq based on
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * packet destination MAC address:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * VMDq Enable = 1;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * VMDq Filter = 0; MAC filtering
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Default VMDq output index = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable VMDq-only.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < hw->mac.num_rar_entries; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable Virtualization and Replication.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer vtctl = IXGBE_VT_CTL_VT_ENABLE | IXGBE_VT_CTL_REPLEN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable receiving packets to all VFs
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 * ixgbe_setup_vmdq_rss - Setup both vmdq feature and rss feature.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Fill out redirection table
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < 128; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Fill out hash function seeds with a random constant
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < 10; i++) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer (void) random_get_pseudo_bytes((uint8_t *)&random,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable and setup RSS and VMDq
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable RSS & Setup RSS Hash functions
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable and Setup VMDq
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * VMDq Filter = 0; MAC filtering
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Default VMDq output index = 0;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable RSS & Setup RSS Hash functions
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable VMDq+RSS.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (i = 0; i < hw->mac.num_rar_entries; i++) {
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 * Enable Virtualization and Replication.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer vtctl = IXGBE_VT_CTL_VT_ENABLE | IXGBE_VT_CTL_REPLEN;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Enable receiving packets to all VFs
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);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_init_unicst - Initialize the unicast addresses.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Here we should consider two situations:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * 1. Chipset is initialized at the first time,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Clear all the multiple unicast addresses.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * 2. Chipset is reset
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Recover the multiple unicast addresses from the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * software data structure to the RAR registers.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize the multiple unicast addresses
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->unicst_total = hw->mac.num_rar_entries;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < ixgbe->unicst_total; slot++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) ixgbe_set_rar(hw, slot, mac_addr, NULL, NULL);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* Re-configure the RAR registers */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < ixgbe->unicst_total; slot++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * ixgbe_unicst_find - Find the slot for the specified unicast address
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_unicst_find(ixgbe_t *ixgbe, const uint8_t *mac_addr)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (slot = 0; slot < ixgbe->unicst_total; slot++) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng return (-1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_multicst_add - Add a multicst address.
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_multicst_add(ixgbe_t *ixgbe, const uint8_t *multiaddr)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Update the multicast table in the hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_multicst_remove - Remove a multicst address.
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_multicst_remove(ixgbe_t *ixgbe, const uint8_t *multiaddr)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Update the multicast table in the hardware
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (0);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_multicast - Setup multicast data structures.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This routine initializes all of the multicast related structures
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * and save them in the hardware registers.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ASSERT(ixgbe->mcast_count <= MAX_NUM_MULTICAST_ADDRESSES);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Update the multicast addresses to the MTA registers
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_update_mc_addr_list(hw, mc_addr_list, mc_addr_count,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * ixgbe_setup_vmdq_rss_conf - Configure vmdq and rss (number and mode).
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 * 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 ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
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.
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * For now, treat X540 like the 82599.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->num_rx_rings = min(8, ring_per_group);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ring_per_group = ixgbe->num_rx_rings / ixgbe->num_rx_groups;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->num_rx_groups == 1 && ring_per_group == 1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else if (ixgbe->num_rx_groups != 1 && ring_per_group == 1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer } else if (ixgbe->num_rx_groups != 1 && ring_per_group != 1) {
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode = IXGBE_CLASSIFY_VMDQ_RSS;
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo IXGBE_DEBUGLOG_2(ixgbe, "rx group number:%d, rx ring number:%d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_get_conf - Get driver configurations set in driver.conf.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This routine gets user-configured values out of the configuration
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.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe driver supports the following user configurations:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Jumbo frame configuration:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * default_mtu
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Ethernet flow control configuration:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * flow_control
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Multiple rings configurations:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * tx_queue_number
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * tx_ring_size
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * rx_queue_number
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * rx_ring_size
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ixgbe_get_prop() to get the value for a specific
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * configuration parameter.
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 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 * Ethernet flow control configuration
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 hw->fc.requested_mode = flow_control;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Multiple rings configurations
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->num_tx_rings = ixgbe_get_prop(ixgbe, PROP_TX_QUEUE_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 ixgbe->num_rx_rings = ixgbe_get_prop(ixgbe, PROP_RX_QUEUE_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);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Multiple groups configuration
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,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe->mr_enable = ixgbe_get_prop(ixgbe, PROP_MR_ENABLE,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer max(ixgbe->num_rx_rings / ixgbe->num_rx_groups, 1);
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.
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 ixgbe->intr_force = ixgbe_get_prop(ixgbe, PROP_INTR_FORCE,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_hcksum_enable = ixgbe_get_prop(ixgbe, PROP_TX_HCKSUM_ENABLE,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_hcksum_enable = ixgbe_get_prop(ixgbe, PROP_RX_HCKSUM_ENABLE,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->lso_enable = ixgbe_get_prop(ixgbe, PROP_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,
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);
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald /* Head Write Back not recommended for 82599 and X540 */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->tx_head_wb_enable = B_FALSE;
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * ixgbe LSO needs the tx h/w checksum support.
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * LSO will be disabled if tx h/w checksum is not
c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1gg * enabled.
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 if (ixgbe->rx_hcksum_enable == B_FALSE) {
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe->lro_enable = B_FALSE;
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * ixgbe LRO only been supported by 82599 and X540 now
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe->lro_enable = B_FALSE;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->tx_copy_thresh = ixgbe_get_prop(ixgbe, PROP_TX_COPY_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt MAX_TX_OVERLOAD_THRESHOLD, DEFAULT_TX_OVERLOAD_THRESHOLD);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_copy_thresh = ixgbe_get_prop(ixgbe, PROP_RX_COPY_THRESHOLD,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe->rx_limit_per_intr = ixgbe_get_prop(ixgbe, PROP_RX_LIMIT_PER_INTR,
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);
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * 82599 and X540 require the interrupt throttling rate is
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China * a multiple of 8. This is enforced by the register
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald if (hw->mac.type == ixgbe_mac_82599EB || hw->mac.type == ixgbe_mac_X540)
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe->intr_throttling[0] = ixgbe->intr_throttling[0] & 0xFF8;
43fab1a9f38ff02e665a874ea0a8eb3818e61ff3Saso Kiselkov hw->allow_unsupported_sfp = ixgbe_get_prop(ixgbe,
43fab1a9f38ff02e665a874ea0a8eb3818e61ff3Saso Kiselkov PROP_ALLOW_UNSUPPORTED_SFP, 0, 1, DEFAULT_ALLOW_UNSUPPORTED_SFP);
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing Chinaixgbe_init_params(ixgbe_t *ixgbe)
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 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 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 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 * ixgbe_get_prop - Get a property value out of the configuration file
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Caller provides the name of the property, a default value, a minimum
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * value, and a maximum value.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Return configured value of the property, with default, minimum and
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * maximum properly applied.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ddi_prop_get_int() to read the conf settings
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_driver_setup_link - Using the link properties to setup the link.
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_driver_setup_link(ixgbe_t *ixgbe, boolean_t setup_hw)
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China u32 autoneg_advertised = 0;
3cfa0eb9019abbded0c93bce072ab4e73b989c13chenlu chen - Sun Microsystems - Beijing China * No half duplex support with 10Gb parts
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;
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;
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;
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.");
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;
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 "
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * ixgbe_driver_link_check - Link status processing.
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * This function can be called in both kernel context and interrupt context
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo (void) ixgbe_check_link(hw, &speed, &link_up, false);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China /* Link is up, enable flow control settings */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * The Link is up, check whether it was marked as down earlier
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 case IXGBE_LINK_SPEED_1GB_FULL:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->link_speed = SPEED_1GB;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China case IXGBE_LINK_SPEED_100_FULL:
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->link_speed = SPEED_100;
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * The link is really down
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * If we are in an interrupt context, need to re-enable the
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * interrupt, which was automasked
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo mac_link_update(ixgbe->mac_hdl, ixgbe->link_state);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * ixgbe_sfp_check - sfp module processing done in taskq only for 82599.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_sfp_check(void *arg)
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 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 /* 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 /* 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 /* 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);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * We need to fully re-check the link later.
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 * ixgbe_overtemp_check - overtemp module processing done in taskq
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 Chinaixgbe_overtemp_check(void *arg)
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 mutex_enter(&ixgbe->gen_lock);
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 /* 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 * Disable the adapter interrupts
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_disable_adapter_interrupts(ixgbe);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Disable Rx/Tx units
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_stop_adapter(hw);
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 /* write to clear the interrupt */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China mutex_exit(&ixgbe->gen_lock);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * ixgbe_link_timer - timer for link status detection
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_local_timer - Driver watchdog function.
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * This function will handle the transmit stall check and other routines.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China if (ixgbe->ixgbe_state & IXGBE_OVERTEMP)
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_RESTORED);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
ffd8e8832e01f996f32459073f4dd308fe5265baWinson Wang - Sun Microsystems - Beijing China ixgbe_restart_watchdog_timer(ixgbe);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_stall_check - Check for transmit stall.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * This function checks if the adapter is stalled (in transmit).
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 * If any tx ring is stalled, we'll reset the chipset
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China if (tx_ring->tbd_free <= ixgbe->tx_recycle_thresh) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * is_valid_mac_addr - Check if the mac address is valid.
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 * 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 err = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, ixgbe->dip,
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 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 * 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 err = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, ixgbe->dip,
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Fire a watchdog timer
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_enable_watchdog_timer - Enable and start the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_disable_watchdog_timer - Disable and stop the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_start_watchdog_timer - Start the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_restart_watchdog_timer - Restart the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_stop_watchdog_timer - Stop the driver watchdog timer.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_disable_adapter_interrupts - Disable all adapter interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * mask all interrupts off
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * for MSI-X, also disable autoclear
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_enable_adapter_interrupts - Enable all hardware interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
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 */
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* enable automask on "other" causes that this adapter can generate */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * msi-x mode
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* enable autoclear but not on bits 29:20 */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* general purpose interrupt enable */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * non-msi-x mode
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* disable autoclear, leave gpie at default */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * General purpose interrupt enable.
69b5a878d62fdee1b12e78371ce6cc8abddcad15Dan McDonald * For 82599 or X540, extended interrupt automask enable
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * only in MSI or MSI-X mode
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China (ixgbe->intr_type == DDI_INTR_TYPE_MSI)) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China gpie |= IXGBE_GPIE_EIAME;
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 case ixgbe_mac_82599EB:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China gpie |= ixgbe->capab->other_gpie;
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);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* write to interrupt control registers */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_loopback_ioctl - Loopback support.
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_loopback_ioctl(ixgbe_t *ixgbe, struct iocblk *iocp, mblk_t *mp)
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China value += sizeof (lb_external);
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China value += sizeof (lb_external);
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China lbpp[value++] = lb_external;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_set_loopback_mode - Setup loopback based on the loopback mode.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Reset the chip
9da57d7b0ddd8d73b676ce12c040362132cdd538bt switch (mode) {
1fedc51fe8f78efa2ee550387171e6adb2223b8dWinson Wang - Sun Microsystems - Beijing China case IXGBE_LB_EXTERNAL:
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_set_internal_mac_loopback - Set the internal MAC loopback mode.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Setup MAC loopback
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable Atlas Tx lanes to keep packets in loopback and not on wire
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 (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_LPBK,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_read_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_10G,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_10G,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_read_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_1G,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_1G,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_read_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_AN,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) ixgbe_write_analog_reg8(&ixgbe->hw, IXGBE_ATLAS_PDN_AN,
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 (void) ixgbe_setup_link(&ixgbe->hw, IXGBE_LINK_SPEED_10GB_FULL,
00f1c25a65b1cfd93d859ba8bd8872cd7f276c86chenlu chen - Sun Microsystems - Beijing China B_FALSE, B_TRUE);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_intr_rx_work)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_intr_rx_work - RX processing of ISR.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_rx_ring(rx_ring->ixgbe->mac_hdl, rx_ring->ring_handle, mp,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_intr_tx_work)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_intr_tx_work - TX processing of ISR.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China ixgbe_t *ixgbe = tx_ring->ixgbe;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Recycle the tx descriptors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Schedule the re-transmit
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China (tx_ring->tbd_free >= ixgbe->tx_resched_thresh)) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt#pragma inline(ixgbe_intr_other_work)
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * ixgbe_intr_other_work - Process interrupt types other than tx/rx
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guoixgbe_intr_other_work(ixgbe_t *ixgbe, uint32_t eicr)
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo * handle link status change
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_get_hw_state(ixgbe);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo * check for fan failure on adapters with fans
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo if ((ixgbe->capab->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) &&
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China atomic_or_32(&ixgbe->ixgbe_state, IXGBE_OVERTEMP);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Disable the adapter interrupts
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe_disable_adapter_interrupts(ixgbe);
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Disable Rx/Tx units
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China (void) ixgbe_stop_adapter(&ixgbe->hw);
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 /* re-enable the interrupt, which was automasked */
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China ixgbe->eims |= IXGBE_EICR_GPI_SDP1;
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Do SFP check for adapters with hot-plug capability
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;
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");
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Do over-temperature check for adapters with temp sensor
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");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_intr_legacy - Interrupt handler for legacy interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Any bit set in eicr: claim this interrupt
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);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For legacy interrupt, we have only one interrupt,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * so we have only one rx ring and one tx ring enabled.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For legacy interrupt, rx rings[0] will use RTxQ[0].
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 * Clean the rx descriptors
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For legacy interrupt, tx rings[0] will use RTxQ[1].
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Recycle the tx descriptors
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Schedule the re-transmit
ea65739ebec0cbd625d8c89e19592be58fa186a6chenlu chen - Sun Microsystems - Beijing China (tx_ring->tbd_free >= ixgbe->tx_resched_thresh));
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* any interrupt type other than tx/rx */
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 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);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * No interrupt cause bits set: don't claim this interrupt.
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* re-enable the interrupts which were automasked */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Do the following work outside of the gen_lock
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_rx_ring(rx_ring->ixgbe->mac_hdl, rx_ring->ring_handle, mp,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng mac_tx_ring_update(ixgbe->mac_hdl, tx_ring->ring_handle);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_intr_msi - Interrupt handler for MSI.
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);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For MSI interrupt, we have only one vector,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * so we have only one rx ring and one tx ring enabled.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For MSI interrupt, rx rings[0] will use RTxQ[0].
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For MSI interrupt, tx rings[0] will use RTxQ[1].
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* any interrupt type other than tx/rx */
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 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);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe->eims &= ~(eicr & IXGBE_OTHER_INTR);
13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22Paul Guo /* re-enable the interrupts which were automasked */
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * ixgbe_intr_msix - Interrupt handler for MSI-X.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_intr_msix(void *arg1, void *arg2)
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_intr_vector_t *vect = (ixgbe_intr_vector_t *)arg1;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China struct ixgbe_hw *hw = &ixgbe->hw;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Clean each rx ring that has its bit set in the map
9da57d7b0ddd8d73b676ce12c040362132cdd538bt r_idx = bt_getlowbit(vect->rx_map, 0, (ixgbe->num_rx_rings - 1));
9da57d7b0ddd8d73b676ce12c040362132cdd538bt while (r_idx >= 0) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Clean each tx ring that has its bit set in the map
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng r_idx = bt_getlowbit(vect->tx_map, 0, (ixgbe->num_tx_rings - 1));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng while (r_idx >= 0) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Clean other interrupt (link change) that has its bit set in the map
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);
62e6e1adfc8d795f477410703cc7a88dc5b82622Paul Guo if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) !=
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China * Check "other" cause bits: any interrupt type other than tx/rx
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 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 mutex_exit(&ixgbe->gen_lock);
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);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_intrs - Allocate interrupts for the driver.
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 * Get supported interrupt types
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_1(ixgbe, "Supported interrupt types: %x", intr_types);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Install MSI-X interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ixgbe_alloc_intr_handles(ixgbe, DDI_INTR_TYPE_MSIX);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Allocate MSI-X failed, trying MSI interrupts...");
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * MSI-X not used, force rings and groups to 1
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng "MSI-X not used, force rings and groups number to 1");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Install MSI interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Allocate MSI failed, trying Legacy interrupts...");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Install legacy interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ixgbe_alloc_intr_handles(ixgbe, DDI_INTR_TYPE_FIXED);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Allocate Legacy interrupts failed");
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * If none of the 3 types succeeded, return failure
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_alloc_intr_handles - Allocate interrupt handles.
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 * Best number of vectors for the adapter is
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * (# rx rings + # tx rings), however we will
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * limit the request number.
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;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "invalid call to ixgbe_alloc_intr_handles(): %d\n",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_2(ixgbe, "interrupt handles requested: %d minimum: %d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get number of supported interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "Get interrupt number failed. Return: %d, count: %d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_1(ixgbe, "interrupts supported: %d", count);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Allocate an array of interrupt handles
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_alloc(devinfo, ixgbe->htable, intr_type, 0,
9da57d7b0ddd8d73b676ce12c040362132cdd538bt "return: %d, request: %d, actual: %d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt IXGBE_DEBUGLOG_1(ixgbe, "interrupts actually allocated: %d", actual);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * upper/lower limit of interrupts
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * rss number per group should not exceed the rx interrupt number,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * else need to adjust rx ring number.
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;
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 ixgbe_log(ixgbe, "Insufficient interrupt handles available: %d",
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Get priority for first vector, assume remaining are all the same
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_get_pri(ixgbe->htable[0], &ixgbe->intr_pri);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_get_cap(ixgbe->htable[0], &ixgbe->intr_cap);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_add_intr_handlers - Add interrupt handlers based on the interrupt type.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Before adding the interrupt handlers, the interrupt vectors have
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * been allocated, and the rx/tx rings have also been allocated.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Add interrupt handler for all vectors
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China for (vector = 0; vector < ixgbe->intr_cnt; vector++) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * install pointer to vect_map[vector]
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China (ddi_intr_handler_t *)ixgbe_intr_msix,
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo "Add interrupt handler failed. "
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Add interrupt handlers for the only vector
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Add interrupt handlers for the only vector
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_map_rxring_to_vector - Map given rx ring to given interrupt vector.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_map_rxring_to_vector(ixgbe_t *ixgbe, int r_idx, int v_idx)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set bit in map
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Count bits set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remember bit position
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_map_txring_to_vector - Map given tx ring to given interrupt vector.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_map_txring_to_vector(ixgbe_t *ixgbe, int t_idx, int v_idx)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Set bit in map
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Count bits set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Remember bit position
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * ixgbe_setup_ivar - Set the given entry in the given interrupt vector
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * allocation register (IVAR).
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * -1 : other cause
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 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 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 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 /* 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),
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 * -1 : other cause
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_enable_ivar(ixgbe_t *ixgbe, uint16_t intr_alloc_entry, int8_t cause)
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 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 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 /* 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 * 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 * -1 : other cause
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_disable_ivar(ixgbe_t *ixgbe, uint16_t intr_alloc_entry, int8_t cause)
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 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 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 /* 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),
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Convert the rx ring index driver maintained to the rx ring index
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_get_hw_rx_index(ixgbe_t *ixgbe, uint32_t sw_rx_index)
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->classify_mode == IXGBE_CLASSIFY_RSS ||
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe->classify_mode == IXGBE_CLASSIFY_NONE) {
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:
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
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;
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) *
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China case ixgbe_mac_82599EB:
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Should never reach. Just to make compiler happy.
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * ixgbe_map_intrs_to_vectors - Map different interrupts to MSI-X vectors.
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)].
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing Chinaixgbe_map_intrs_to_vectors(ixgbe_t *ixgbe)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt int i, vector = 0;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt /* initialize vector 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;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * non-MSI-X case is very simple: rx rings[0] on RTxQ[0],
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tx rings[0] on RTxQ[1].
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Interrupts/vectors mapping for MSI-X
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 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 * Map rx ring interrupts to vectors
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China vector = (vector +1) % ixgbe->intr_cnt;
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * Map tx ring interrupts to vectors
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China vector = (vector +1) % ixgbe->intr_cnt;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_setup_adapter_vector - Setup the adapter interrupt vector(s).
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * This relies on ring/vector mapping already set up in the
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * vect_map[] structures
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_intr_vector_t *vect; /* vector bitmap */
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Clear any previous entries
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 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);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * For non MSI-X interrupt, rx rings[0] will use RTxQ[0], and
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tx rings[0] will use RTxQ[1].
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);
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China * For MSI-X interrupt, "Other" is always on vector[0].
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_setup_ivar(ixgbe, IXGBE_IVAR_OTHER_CAUSES_INDEX, 0, -1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For each interrupt vector, populate the IVAR table
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For each rx ring bit set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt while (r_idx >= 0) {
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * For each tx ring bit set
9da57d7b0ddd8d73b676ce12c040362132cdd538bt while (r_idx >= 0) {
73cd555c10e70dac413ae4b40de8450a291750acBin Tu - Sun Microsystems - Beijing China ixgbe_setup_ivar(ixgbe, r_idx, v_idx, 1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_rem_intr_handlers - Remove the interrupt handlers.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_rem_intrs - Remove the allocated interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_enable_intrs - Enable all the ddi interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Enable interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ddi_intr_block_enable() for MSI
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_block_enable(ixgbe->htable, ixgbe->intr_cnt);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Call ddi_intr_enable() for Legacy/MSI non block enable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_disable_intrs - Disable all the interrupts.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Disable all interrupts
9da57d7b0ddd8d73b676ce12c040362132cdd538bt rc = ddi_intr_block_disable(ixgbe->htable, ixgbe->intr_cnt);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_get_hw_state - Get and save parameters related to adapter hardware.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
5b6dd21f5401160f9a62ac2e76a858c2bc105370chenlu chen - Sun Microsystems - Beijing China boolean_t autoneg = B_FALSE;
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 (void) ixgbe_get_link_capabilities(hw, &speed, &autoneg);
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 * ixgbe_get_driver_control - Notify that driver is in control of device.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Notify firmware that driver is in control of device
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_release_driver_control - Notify that driver is no longer in control
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * of device.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Notify firmware that driver is no longer in control of device
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_atomic_reserve - Atomic decrease operation.
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ATOMICALLY
9da57d7b0ddd8d73b676ce12c040362132cdd538bt return (-1);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt } while (atomic_cas_32(count_p, oldval, newval) != oldval);
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_mc_table_itr - Traverse the entries in the multicast table.
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_mc_table_itr(struct ixgbe_hw *hw, uint8_t **upd_ptr, uint32_t *vmdq)
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * FMA support
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * ixgbe_fm_error_cb - The IO fault service error handling callback function.
9da57d7b0ddd8d73b676ce12c040362132cdd538btixgbe_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err, const void *impl_data)
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.
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Only register with IO Fault Services if we have some capability
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_regs_acc_attr.devacc_attr_access = DDI_FLAGERR_ACC;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt ixgbe_regs_acc_attr.devacc_attr_access = DDI_DEFAULT_ACC;
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Register capabilities with IO Fault Services
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Initialize pci ereport capabilities if ereport capable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Register error callback if error callback capable
9da57d7b0ddd8d73b676ce12c040362132cdd538btstatic void
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Only unregister FMA capabilities if they are registered
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Release any resources allocated by pci_ereport_setup()
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Un-register error callback if error callback capable
9da57d7b0ddd8d73b676ce12c040362132cdd538bt * Unregister from IO Fault Service
9da57d7b0ddd8d73b676ce12c040362132cdd538bt (void) snprintf(buf, FM_MAX_CLASS, "%s.%s", DDI_FM_DEVICE, detail);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_ring_start(mac_ring_driver_t rh, uint64_t mr_gen_num)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_ring_t *rx_ring = (ixgbe_rx_ring_t *)rh;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Get the global ring index by a ring index within a group.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerixgbe_get_rx_ring_index(ixgbe_t *ixgbe, int gindex, int rindex)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Callback funtion for MAC layer to register all rings.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* ARGSUSED */
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)
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 int global_ring_index = ixgbe_get_rx_ring_index(
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer ixgbe_rx_ring_t *rx_ring = &ixgbe->rx_rings[global_ring_index];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_tx_ring_t *tx_ring = &ixgbe->tx_rings[ring_index];
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Callback funtion for MAC layer to register all groups.
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_fill_group(void *arg, mac_ring_type_t rtype, const int index,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mgi_driver = (mac_group_driver_t)rx_group;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng infop->mgi_count = (ixgbe->num_rx_rings / ixgbe->num_rx_groups);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Enable interrupt on the specificed rx ring.
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_rx_ring_intr_enable(mac_intr_handle_t intrh)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_ring_t *rx_ring = (ixgbe_rx_ring_t *)intrh;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->ixgbe_state & IXGBE_INTR_ADJUST) {
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.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * To enable interrupt by setting the VAL bit of given interrupt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * vector allocation register (IVAR).
19843f01b1bef3453f717c23c8f89fb9313f6749Paul Guo * Trigger a Rx interrupt on this ring
185c5677613512bc5a906decb5034a5135f67fb1Paul Guo IXGBE_WRITE_REG(&ixgbe->hw, IXGBE_EICS, (1 << v_idx));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Disable interrupt on the specificed rx ring.
da14cebe459d3275048785f25bd869cb09b5307fEric Chengixgbe_rx_ring_intr_disable(mac_intr_handle_t intrh)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_ring_t *rx_ring = (ixgbe_rx_ring_t *)intrh;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (ixgbe->ixgbe_state & IXGBE_INTR_ADJUST) {
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.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * To disable interrupt by clearing the VAL bit of given interrupt
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * vector allocation register (IVAR).
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Add a mac address.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_group_t *rx_group = (ixgbe_rx_group_t *)arg;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* no slots available */
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 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 /* no slots available */
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 ixgbe->unicst_addr[slot].mac.group_index = rx_group->index;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Remove a mac address.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ixgbe_rx_group_t *rx_group = (ixgbe_rx_group_t *)arg;