e1000g_main.c revision 30fd040177af69f32a3917f66ce942b3707b02e5
/*
* This file is provided under a CDDLv1 license. When using or
* redistributing this file, you may do so under this license.
* In redistributing this file this license must be included
* and no other modification of this header file is permitted.
*
* CDDL LICENSE SUMMARY
*
* Copyright(c) 1999 - 2009 Intel Corporation. All rights reserved.
*
* The contents of this file are subject to the terms of Version
* 1.0 of the Common Development and Distribution License (the "License").
*
* You should have received a copy of the License with this software.
* You can obtain a copy of the License at
* See the License for the specific language governing permissions
* and limitations under the License.
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* **********************************************************************
* *
* Module Name: *
* e1000g_main.c *
* *
* Abstract: *
* This file contains the interface routines for the solaris OS. *
* It has all DDI entry point routines and GLD entry point routines. *
* *
* This file also contains routines that take care of initialization *
* uninit routine and interrupt routine. *
* *
* **********************************************************************
*/
#include "e1000g_sw.h"
#include "e1000g_debug.h"
static char ident[] = "Intel PRO/1000 Ethernet";
static char e1000g_string[] = "Intel(R) PRO/1000 Network Connection";
static char e1000g_version[] = "Driver Ver. 5.3.3";
/*
* Proto types for DDI entry points
*/
static int e1000g_quiesce(dev_info_t *);
/*
* init and intr routines prototype
*/
static int e1000g_resume(dev_info_t *);
static int e1000g_suspend(dev_info_t *);
#pragma inline(e1000g_intr_work)
static int e1000g_init(struct e1000g *);
static int e1000g_m_start(void *);
static void e1000g_m_stop(void *);
static int e1000g_m_promisc(void *, boolean_t);
static int e1000g_m_setprop(void *, const char *, mac_prop_id_t,
uint_t, const void *);
static int e1000g_m_getprop(void *, const char *, mac_prop_id_t,
const void *);
static void e1000g_init_locks(struct e1000g *);
static void e1000g_destroy_locks(struct e1000g *);
static int e1000g_identify_hardware(struct e1000g *);
static int e1000g_regs_map(struct e1000g *);
static int e1000g_set_driver_params(struct e1000g *);
static void e1000g_set_bufsize(struct e1000g *);
static int e1000g_register_mac(struct e1000g *);
static void e1000g_init_unicst(struct e1000g *);
/*
* Local routines
*/
static void e1000g_tx_clean(struct e1000g *);
static void e1000g_rx_clean(struct e1000g *);
static void e1000g_link_timer(void *);
static void e1000g_local_timer(void *);
static void e1000g_smartspeed(struct e1000g *);
static void e1000g_get_conf(struct e1000g *);
static int e1000g_get_prop(struct e1000g *, char *, int, int, int);
static void enable_watchdog_timer(struct e1000g *);
static void disable_watchdog_timer(struct e1000g *);
static void start_watchdog_timer(struct e1000g *);
static void restart_watchdog_timer(struct e1000g *);
static void stop_watchdog_timer(struct e1000g *);
static void stop_link_timer(struct e1000g *);
static void stop_82547_timer(e1000g_tx_ring_t *);
static void e1000g_force_speed_duplex(struct e1000g *);
static void e1000g_get_max_frame_size(struct e1000g *);
#ifdef E1000G_DEBUG
#endif
static void e1000g_set_internal_loopback(struct e1000g *);
static void e1000g_set_external_loopback_1000(struct e1000g *);
static void e1000g_set_external_loopback_100(struct e1000g *);
static void e1000g_set_external_loopback_10(struct e1000g *);
static int e1000g_add_intrs(struct e1000g *);
static int e1000g_intr_add(struct e1000g *, int);
static int e1000g_rem_intrs(struct e1000g *);
static int e1000g_enable_intrs(struct e1000g *);
static int e1000g_disable_intrs(struct e1000g *);
#ifdef __sparc
#endif
static void e1000g_get_phy_state(struct e1000g *);
const void *impl_data);
static void e1000g_param_sync(struct e1000g *);
static void e1000g_get_driver_control(struct e1000_hw *);
static void e1000g_release_driver_control(struct e1000_hw *);
{"_tx_bcopy_threshold", MAC_PROP_PERM_RW},
{"_tx_interrupt_enable", MAC_PROP_PERM_RW},
{"_tx_intr_delay", MAC_PROP_PERM_RW},
{"_tx_intr_abs_delay", MAC_PROP_PERM_RW},
{"_rx_bcopy_threshold", MAC_PROP_PERM_RW},
{"_max_num_rcv_packets", MAC_PROP_PERM_RW},
{"_rx_intr_delay", MAC_PROP_PERM_RW},
{"_rx_intr_abs_delay", MAC_PROP_PERM_RW},
{"_intr_throttling_rate", MAC_PROP_PERM_RW},
{"_intr_adaptive", MAC_PROP_PERM_RW},
{"_adv_pause_cap", MAC_PROP_PERM_READ},
{"_adv_asym_pause_cap", MAC_PROP_PERM_READ},
};
#define E1000G_MAX_PRIV_PROPS \
(sizeof (e1000g_priv_props)/sizeof (mac_priv_prop_t))
nulldev, /* cb_open */
nulldev, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
nodev, /* cb_read */
nodev, /* cb_write */
nodev, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
NULL, /* cb_stream */
CB_REV, /* cb_rev */
nodev, /* cb_aread */
nodev /* cb_awrite */
};
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
NULL, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
e1000g_attach, /* devo_attach */
e1000g_detach, /* devo_detach */
nodev, /* devo_reset */
&cb_ws_ops, /* devo_cb_ops */
NULL, /* devo_bus_ops */
ddi_power, /* devo_power */
e1000g_quiesce /* devo_quiesce */
};
&mod_driverops, /* Type of module. This one is a driver */
ident, /* Discription string */
&ws_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
};
/* Access attributes for register mapping */
static ddi_device_acc_attr_t e1000g_regs_acc_attr = {
};
#define E1000G_M_CALLBACK_FLAGS \
static mac_callbacks_t e1000g_m_callbacks = {
NULL,
NULL,
NULL,
};
/*
* Global variables
*/
/*
* Workaround for Dynamic Reconfiguration support, for x86 platform only.
* Here we maintain a private dev_info list if e1000g_force_detach is
* enabled. If we force the driver to detach while there are still some
* rx buffers retained in the upper layer, we have to keep a copy of the
* dev_info. In some cases (Dynamic Reconfiguration), the dev_info data
* structure will be freed after the driver is detached. However when we
* finally free those rx buffers released by the upper layer, we need to
* refer to the dev_info to free the dma buffers. So we save a copy of
* the dev_info for this purpose. On x86 platform, we assume this copy
* of dev_info is always valid, but on SPARC platform, it could be invalid
* after the system board level DR operation. For this reason, the global
* variable e1000g_force_detach must be B_FALSE on SPARC platform.
*/
#ifdef __sparc
#else
#endif
/*
* The rwlock is defined to protect the whole processing of rx recycling
* and the rx packets release in detach processing to make them mutually
* exclusive.
* The rx recycling processes different rx packets in different threads,
* so it will be protected with RW_READER and it won't block any other rx
* recycling threads.
* While the detach processing will be protected with RW_WRITER to make
* it mutually exclusive with the rx recycling.
*/
/*
* The rwlock e1000g_dma_type_lock is defined to protect the global flag
* e1000g_dma_type. For SPARC, the initial value of the flag is "USE_DVMA".
* If there are many e1000g instances, the system may run out of DVMA
* resources during the initialization of the instances, then the flag will
* be changed to "USE_DMA". Because different e1000g instances are initialized
* in parallel, we need to use this lock to protect the flag.
*/
/*
* The 82546 chipset is a dual-port device, both the ports share one eeprom.
* Based on the information from Intel, the 82546 chipset has some hardware
* problem. When one port is being reset and the other port is trying to
* access the eeprom, it could cause system hang or panic. To workaround this
* hardware problem, we use a global mutex to prevent such operations from
* happening simultaneously on different instances. This workaround is applied
* to all the devices supported by this driver.
*/
/*
* Loadable module configuration entry points for the driver
*/
/*
* _init - module initialization
*/
int
_init(void)
{
int status;
if (status != DDI_SUCCESS)
else {
}
return (status);
}
/*
* _fini - module finalization
*/
int
_fini(void)
{
int status;
if (e1000g_mblks_pending != 0) {
return (EBUSY);
}
if (status == DDI_SUCCESS) {
if (e1000g_force_detach) {
while (e1000g_private_devi_list != NULL) {
sizeof (struct dev_info));
sizeof (private_devi_list_t));
}
}
}
return (status);
}
/*
* _info - module information
*/
int
{
}
/*
* e1000g_attach - driver attach
*
* This function is the device-specific initialization entry
* point. This entry point is required and must be written.
* The DDI_ATTACH command must be provided in the attach entry
* point. When attach() is called with cmd set to DDI_ATTACH,
* all normal kernel services (such as kmem_alloc(9F)) are
* available for use by the driver.
*
* The attach() function will be called once for each instance
* of the device on the system with cmd set to DDI_ATTACH.
* Until attach() succeeds, the only driver entry points which
* may be called are open(9E) and getinfo(9E).
*/
static int
{
struct e1000g_osdep *osdep;
int instance;
switch (cmd) {
default:
"Unsupported command send to e1000g_attach... ");
return (DDI_FAILURE);
case DDI_RESUME:
return (e1000g_resume(devinfo));
case DDI_ATTACH:
break;
}
/*
* get device instance number
*/
/*
* Allocate soft data structure
*/
Adapter =
/*
* Initialize for fma support
*/
0, 0x0f,
/*
* PCI Configure
*/
goto attach_fail;
}
/*
* Setup hardware
*/
goto attach_fail;
}
/*
* Map in the device registers.
*/
goto attach_fail;
}
/*
* Initialize driver parameters
*/
goto attach_fail;
}
goto attach_fail;
}
/*
* Initialize interrupts
*/
goto attach_fail;
}
/*
* Initialize mutex's for this device.
* Do this before enabling the interrupt handler and
* register the softint to avoid the condition where
* interrupt handler can try using uninitialized mutex
*/
/*
* Initialize Driver Counters
*/
goto attach_fail;
}
/*
* Initialize chip hardware and software structures
*/
goto attach_fail;
}
/*
* Register the driver to the MAC
*/
goto attach_fail;
}
/*
* Now that mutex locks are initialized, and the chip is also
* initialized, enable interrupts.
*/
goto attach_fail;
}
/*
* If e1000g_force_detach is enabled, in global private dip list,
* we will create a new entry, which maintains the priv_dip for DR
* supports after driver detached.
*/
if (e1000g_force_detach) {
sizeof (struct dev_info));
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
static int
{
int err;
return (DDI_FAILURE);
}
static int
{
/* Get the device id */
hw->revision_id =
"MAC type could not be set properly.");
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
/* Get size of adapter register memory */
DDI_SUCCESS) {
"ddi_dev_regsize for registers failed");
return (DDI_FAILURE);
}
/* Map adapter register memory */
"ddi_regs_map_setup for registers failed");
goto regs_map_fail;
}
/* ICH needs to map flash memory */
/* get flash size */
&mem_size) != DDI_SUCCESS) {
"ddi_dev_regsize for ICH flash failed");
goto regs_map_fail;
}
/* map flash in */
"ddi_regs_map_setup for ICH flash failed");
goto regs_map_fail;
}
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
static int
{
/* Set MAC type and initialize hardware functions */
"Could not setup hardware functions");
return (DDI_FAILURE);
}
/* Get bus information */
"Could not get bus information");
return (DDI_FAILURE);
}
/* get mem_base addr */
/* get io_base addr */
if (bar64) {
/* IO BAR is different for 64 bit BAR mode */
} else {
/* normal 32-bit BAR mode */
}
} else {
/* no I/O access for adapters prior to 82544 */
}
/* Set the autoneg_wait_to_complete flag to B_FALSE */
/* Adaptive IFS related changes */
/* Enable phy init script for IGP phy of 82541/82547 */
/* Enable the TTL workaround for 82541/82547 */
#ifdef __sparc
#else
#endif
/* Get conf file properties */
/* Get Jumbo Frames settings in conf file */
/* Master Latency Timer */
/* copper options */
}
/* The initial link state should be "unknown" */
/* Initialize rx parameters */
/* Initialize tx parameters */
/* Initialize rx parameters */
return (DDI_SUCCESS);
}
static void
{
#ifdef __sparc
#endif
/* Get the system page size */
#ifdef __sparc
if (iommu_pagesize != 0) {
if (iommu_pagesize > 0x4000)
} else {
}
}
if (Adapter->lso_enable) {
} else {
}
#endif
if (Adapter->mem_workaround_82546 &&
} else {
if ((rx_size > FRAME_SIZE_UPTO_2K) &&
(rx_size <= FRAME_SIZE_UPTO_4K))
else if ((rx_size > FRAME_SIZE_UPTO_4K) &&
(rx_size <= FRAME_SIZE_UPTO_8K))
else if ((rx_size > FRAME_SIZE_UPTO_8K) &&
(rx_size <= FRAME_SIZE_UPTO_16K))
else
}
else if ((tx_size > FRAME_SIZE_UPTO_4K) &&
(tx_size <= FRAME_SIZE_UPTO_8K))
else if ((tx_size > FRAME_SIZE_UPTO_8K) &&
(tx_size <= FRAME_SIZE_UPTO_16K))
else
/*
* For Wiseman adapters we have an requirement of having receive
* buffers aligned at 256 byte boundary. Since Livengood does not
* require this and forcing it for all hardwares will have
* performance implications, I am making it applicable only for
* Wiseman and for Jumbo frames enabled mode as rest of the time,
* it is okay to have normal frames...but it does involve a
* potential risk where we may loose data if buffer is not
* aligned...so all wiseman boards to have 256 byte aligned
* buffers
*/
else
}
/*
* e1000g_detach - driver detach
*
* The detach() function is the complement of the attach routine.
* If cmd is set to DDI_DETACH, detach() is used to remove the
* state associated with a given instance of a device node
* prior to the removal of that instance from the system.
*
* The detach() function will be called once for each instance
* of the device for which there has been a successful attach()
* once there are no longer any opens on the device.
*
* Interrupts routine are disabled, All memory allocated by this
* driver are freed.
*/
static int
{
switch (cmd) {
default:
return (DDI_FAILURE);
case DDI_SUSPEND:
return (e1000g_suspend(devinfo));
case DDI_DETACH:
break;
}
return (DDI_FAILURE);
if (!rx_drain && !e1000g_force_detach)
return (DDI_FAILURE);
return (DDI_FAILURE);
}
/*
* If e1000g_force_detach is enabled, driver detach is safe.
* We will let e1000g_free_priv_devi_node routine determine
* whether we need to free the priv_dip entry for current
* driver instance.
*/
if (e1000g_force_detach) {
}
return (DDI_SUCCESS);
}
/*
* e1000g_free_priv_devi_node - free a priv_dip entry for driver instance
*
* If free_flag is true, that indicates the upper layer is not holding
* the rx buffers, we could free the priv_dip entry safely.
*
* Otherwise, we have to keep this entry even after driver detached,
* and we also need to mark this entry with E1000G_PRIV_DEVI_DETACH flag,
* so that driver could free it while all of rx buffers are returned
* by upper layer later.
*/
static void
{
if (free_flag) {
sizeof (struct dev_info));
sizeof (private_devi_list_t));
} else {
ASSERT(e1000g_mblks_pending != 0);
}
return;
}
if (free_flag) {
sizeof (struct dev_info));
sizeof (private_devi_list_t));
} else {
ASSERT(e1000g_mblks_pending != 0);
}
break;
}
}
}
static void
{
int result;
(void) e1000g_disable_intrs(Adapter);
}
}
(void) e1000g_rem_intrs(Adapter);
}
(void) ddi_prop_remove_all(devinfo);
}
}
if (result != E1000_SUCCESS) {
}
}
}
}
}
}
/*
* Another hotplug spec requirement,
* run ddi_set_driver_private(devinfo, null);
*/
}
static void
{
}
static void
{
}
static int
{
"Instance pointer is null\n");
"Devinfo is not the same as saved devinfo\n");
/*
* We note the failure, but return success, as the
* system is still usable without this controller.
*/
"e1000g_resume: failed to restart controller\n");
return (DDI_SUCCESS);
}
/* Enable and start the watchdog timer */
}
return (DDI_SUCCESS);
}
static int
{
return (DDI_FAILURE);
/* if the port isn't plumbed, we can simply return */
return (DDI_SUCCESS);
}
/* Disable and stop all the timers */
return (DDI_SUCCESS);
}
static int
{
int result;
/*
* reset to put the hardware in a known state
* before we try to do anything with the eeprom
*/
if (result != E1000_SUCCESS) {
goto init_fail;
}
if (result < E1000_SUCCESS) {
/*
* Some PCI-E parts fail the first check due to
* the link being in sleep state. Call it again,
* if it fails a second time its a real issue.
*/
}
if (result < E1000_SUCCESS) {
"Invalid NVM checksum. Please contact "
"the vendor to update the NVM.");
goto init_fail;
}
result = 0;
#ifdef __sparc
/*
* First, we try to get the local ethernet address from OBP. If
* failed, then we get it from the EEPROM of NIC card.
*/
#endif
/* Get the local ethernet address. */
if (!result) {
}
if (result < E1000_SUCCESS) {
goto init_fail;
}
/* check for valid mac address */
goto init_fail;
}
/* Set LAA state for 82571 chipset */
/* Master Latency Timer implementation */
if (Adapter->master_latency_timer) {
}
/*
* Total FIFO is 64K
*/
else
/*
* Total FIFO is 48K
*/
else
/* Keep adapter default: 20K for Rx, 20K for Tx */
pba = E1000_PBA_10K;
pba = E1000_PBA_10K;
} else {
/*
* Total FIFO is 40K
*/
else
}
/*
* These parameters set thresholds for the adapter's generation(Tx)
* and response(Rx) to Ethernet PAUSE frames. These are just threshold
* settings. Flow control is enabled or disabled in the configuration
* file.
* High-water mark is set down from the top of the rx fifo (not
* sensitive to max_frame_size) and low-water is set just below
* high-water mark.
* The high water mark must be low enough to fit one full frame above
* it in the rx FIFO. Should be the lower of:
* 90% of the Rx FIFO size and the full Rx FIFO size minus the early
* receive size (assuming ERT set to E1000_ERT_2048), or the full
* Rx FIFO size minus one full frame.
*/
else
/*
* Reset the adapter hardware the second time.
*/
if (result != E1000_SUCCESS) {
goto init_fail;
}
/* disable wakeup control by default */
/*
* MWI should be disabled on 82546.
*/
else
/*
* Configure/Initialize hardware
*/
if (result < E1000_SUCCESS) {
goto init_fail;
}
/*
* Restore LED settings to the default from EEPROM
* to meet the standard for Sun platforms.
*/
(void) e1000_cleanup_led(hw);
/* Disable Smart Power Down */
/* Make sure driver has control */
/*
* Initialize unicast addresses.
*/
/*
* Setup and initialize the mctable structures. After this routine
* completes Multicast table will be set
*/
msec_delay(5);
/*
* Implement Adaptive IFS
*/
/* Setup Interrupt Throttling Register */
} else
/* Start the timer for link setup */
else
} else {
(void *)Adapter, link_timeout);
}
/* Enable PCI-Ex master */
}
/* Save the state of the phy */
Adapter->init_count++;
goto init_fail;
}
goto init_fail;
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
/*
* Check if the link is up
*/
static boolean_t
{
(void) e1000_check_for_link(hw);
} else {
}
return (link_up);
}
static void
{
return;
}
return;
}
case LB_GET_INFO_SIZE:
case LB_GET_INFO:
case LB_GET_MODE:
case LB_SET_MODE:
break;
#ifdef E1000G_DEBUG
case E1000G_IOC_REG_PEEK:
case E1000G_IOC_REG_POKE:
break;
case E1000G_IOC_CHIP_RESET:
e1000gp->reset_count++;
if (e1000g_reset_adapter(e1000gp))
else
break;
#endif
default:
break;
}
/*
* Decide how to reply
*/
switch (status) {
default:
case IOC_INVAL:
/*
* Error, reply with a NAK and EINVAL or the specified error
*/
break;
case IOC_DONE:
/*
* OK, reply already sent
*/
break;
case IOC_ACK:
/*
* OK, reply with an ACK
*/
break;
case IOC_REPLY:
/*
* OK, send prepared reply as ACK or NAK
*/
break;
}
}
/*
* The default value of e1000g_poll_mode == 0 assumes that the NIC is
* capable of supporting only one interrupt and we shouldn't disable
* the physical interrupt. In this case we let the interrupt come and
* we queue the packets in the rx ring itself in case we are in polling
* mode (better latency but slightly lower performance and a very
* high intrrupt count in mpstat which is harmless).
*
* e1000g_poll_mode == 1 assumes that we have per Rx ring interrupt
* which can be disabled in poll mode. This gives better overall
* throughput (compared to the mode above), shows very low interrupt
* count but has slightly higher latency since we pick the packets when
* the poll thread does polling.
*
* Currently, this flag should be enabled only while doing performance
* measurement or when it can be guaranteed that entire NIC going
* in poll mode will not harm any traffic like cluster heartbeat etc.
*/
int e1000g_poll_mode = 0;
/*
* Called from the upper layers when driver is in polling mode to
* pick up any queued packets. Care should be taken to not block
* this thread.
*/
{
return (NULL);
}
/*
* Get any packets that have arrived. Works only if we
* (e1000g_poll_mode == 1). In case e1000g_poll_mode == 0,
* packets will have already been added to the poll list
* by the interrupt (see e1000g_intr_work()).
*/
else
}
}
return (NULL);
}
/* Check if we can sendup the entire chain */
rx_ring->poll_list_sz = 0;
return (mp);
}
/*
* We need to find out how much chain we can send up. We
* are guaranteed that atleast one packet will go up since
* we already checked that.
*/
sz = 0;
if (sz > bytes_to_pickup) {
break;
}
}
return (mp);
}
static int
e1000g_m_start(void *arg)
{
return (ECANCELED);
}
return (ENOTACTIVE);
}
/* Enable and start the watchdog timer */
return (0);
}
static int
{
if (global) {
/* Allocate dma resources for descriptors and buffers */
"Alloc DMA resources failed");
return (DDI_FAILURE);
}
}
"Adapter initialization failed");
if (global)
return (DDI_FAILURE);
}
}
/* Setup and initialize the transmit structures */
msec_delay(5);
/* Setup and initialize the receive structures */
msec_delay(5);
/* Restore the e1000g promiscuous mode */
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static void
e1000g_m_stop(void *arg)
{
/* Drain tx sessions */
(void) e1000g_tx_drain(Adapter);
return;
}
/* Disable and stop all the timers */
}
static void
{
int result;
/* Stop the chip and release pending resources */
/* Tell firmware driver is no longer in control */
if (result != E1000_SUCCESS) {
}
/* Release resources still held by the TX descriptors */
/* Clean the pending rx jumbo packet fragment */
if (global)
}
static void
{
rx_ring->rx_mblk_len = 0;
}
}
static void
{
/*
* Here we don't need to protect the lists using
* the usedlist_lock and freelist_lock, for they
* have been protected by the chip_lock.
*/
packet_count = 0;
/* Assemble the message chain */
} else {
}
/* Disconnect the message from the sw packet */
}
packet_count++;
}
if (packet_count > 0) {
/* Setup TX descriptor pointers */
/* Setup our HW Tx Head & Tail descriptor pointers */
}
}
static boolean_t
{
int i;
/* Allow up to 'wsdraintime' for pending xmit's to complete. */
for (i = 0; i < TX_DRAIN_TIME; i++) {
if (done)
break;
msec_delay(1);
}
return (done);
}
static boolean_t
{
} else {
}
}
return (done);
}
static boolean_t
{
/* Disable and stop all the timers */
return (B_FALSE);
}
/* Enable and start the watchdog timer */
return (B_TRUE);
}
{
/* Disable and stop all the timers */
Adapter->init_count = 0;
return (B_FALSE);
}
/* Enable and start the watchdog timer */
return (B_TRUE);
}
/*
* e1000g_intr_pciexpress - ISR for PCI Express chipsets
*
* This interrupt service routine is for PCI-Express adapters.
* The ICR contents is valid only when the E1000_ICR_INT_ASSERTED
* bit is set.
*/
static uint_t
{
if (icr & E1000_ICR_INT_ASSERTED) {
/*
* E1000_ICR_INT_ASSERTED bit was set:
* Read(Clear) the ICR, claim this interrupt,
* look for work to do.
*/
return (DDI_INTR_CLAIMED);
} else {
/*
* E1000_ICR_INT_ASSERTED bit was not set:
* Don't claim this interrupt, return immediately.
*/
return (DDI_INTR_UNCLAIMED);
}
}
/*
*
* We check the ICR contents no matter the E1000_ICR_INT_ASSERTED
* bit is set or not.
*/
static uint_t
{
if (icr) {
/*
* Any bit was set in ICR:
* Read(Clear) the ICR, claim this interrupt,
* look for work to do.
*/
return (DDI_INTR_CLAIMED);
} else {
/*
* No bit was set in ICR:
* Don't claim this interrupt, return immediately.
*/
return (DDI_INTR_UNCLAIMED);
}
}
/*
* e1000g_intr_work - actual processing of ISR
*
* Read(clear) the ICR contents and call appropriate interrupt
* processing routines.
*/
static void
{
Adapter->rx_pkt_cnt = 0;
Adapter->tx_pkt_cnt = 0;
return;
}
/*
* Here we need to check the "e1000g_state" flag within the chip_lock to
* ensure the receive routine will not execute when the adapter is
* being reset.
*/
return;
}
if (icr & E1000_ICR_RXT0) {
/*
* If the real interrupt for the Rx ring was
* not disabled (e1000g_poll_mode == 0), then
* we still pick up the packets and queue them
* on Rx ring if we were in polling mode. this
* enables the polling thread to pick up packets
* really fast in polling mode and helps improve
* latency.
*/
/*
* If not polling, see if something was
* already queued. Take care not to
* reorder packets.
*/
} else {
rx_ring->poll_list_sz = 0;
}
} else {
/*
* We are in a polling mode. Put the
* processed packets on the poll list.
*/
else
}
/*
* Nothing new has arrived (then why
* was the interrupt raised??). Check
* if something queued from the last
* time.
*/
rx_ring->poll_list_sz = 0;
} else {
}
} else
if (icr & E1000_ICR_TXDW) {
if (!Adapter->tx_intr_enable)
/* Recycle the tx descriptors */
(void) e1000g_recycle(tx_ring);
if (tx_ring->resched_needed &&
}
}
/*
* The Receive Sequence errors RXSEQ and the link status change LSC
* are checked to detect that the cable has been pulled out. For
* the Wiseman 2.0 silicon, the receive sequence errors interrupt
* are an indication that cable is not connected.
*/
if ((icr & E1000_ICR_RXSEQ) ||
(icr & E1000_ICR_LSC) ||
(icr & E1000_ICR_GPI_EN1)) {
timeout_id_t tid = 0;
/*
* Because we got a link-status-change interrupt, force
* e1000_check_for_link() to look at phy
*/
/* e1000g_link_check takes care of link status change */
/* Get new phy state */
/*
* If the link timer has not timed out, we'll not notify
* the upper layer with any link state until the link is up.
*/
} else {
}
}
if (link_changed) {
if (tid != 0)
/*
* Workaround for esb2. Data stuck in fifo on a link
* down event. Stop receiver here and reset in watchdog.
*/
rctl & ~E1000_RCTL_EN);
"ESB2 receiver disabled");
}
}
}
}
static void
{
int slot;
if (Adapter->init_count == 0) {
/* Initialize the multiple unicast addresses */
/* Workaround for an erratum of 82571 chipst */
Adapter->unicst_total--;
/* Clear both the flag and MAC address */
}
} else {
/* Workaround for an erratum of 82571 chipst */
/* Re-configure the RAR registers */
}
}
static int
int slot)
{
/*
* The first revision of Wiseman silicon (rev 2.0) has an errata
* that requires the receiver to be in reset when any of the
* receive address registers (RAR regs) are accessed. The first
* rev of Wiseman silicon also requires MWI to be disabled when
* a global reset or a receive reset is issued. So before we
* initialize the RARs, we check the rev of the Wiseman controller
* and work around any necessary HW errata.
*/
msec_delay(5);
}
/* Clear both the flag and MAC address */
} else {
}
/* Workaround for an erratum of 82571 chipst */
if (slot == 0) {
slot << 1, 0);
} else {
}
}
/*
* If we are using Wiseman rev 2.0 silicon, we will have previously
* put the receive in reset, and disabled MWI, to work around some
* HW errata. Now we should take the receiver out of reset, and
* re-enabled if MWI if it was previously enabled by the PCI BIOS.
*/
msec_delay(1);
}
return (EIO);
}
return (0);
}
static int
{
int res = 0;
if ((multiaddr[0] & 01) == 0) {
goto done;
}
goto done;
}
Adapter->mcast_count++;
/*
* Update the MC table in the hardware
*/
}
done:
return (res);
}
static int
{
unsigned i;
for (i = 0; i < Adapter->mcast_count; i++) {
ETHERADDRL) == 0) {
for (i++; i < Adapter->mcast_count; i++) {
Adapter->mcast_table[i];
}
Adapter->mcast_count--;
break;
}
}
/*
* Update the MC table in the hardware
*/
return (EIO);
}
return (0);
}
/*
* e1000g_setup_multicast - setup multicast data structures
*
* This routine initializes all of the multicast related structures.
*/
void
{
/*
* The e1000g has the ability to do perfect filtering of 16
* addresses. The driver uses one of the e1000g's 16 receive
* address registers for its node/network/mac/individual address.
* So, we have room for up to 15 multicast addresses in the CAM,
* additional MC addresses are handled by the MTA (Multicast Table
* Array)
*/
"Adapter requested more than %d MC Addresses.\n",
} else {
/*
* Set the number of MC addresses that we are being
* requested to use
*/
}
/*
* The Wiseman 2.0 silicon has an errata by which the receiver will
* hang while writing to the receive address registers if the receiver
* is not in reset before writing to the registers. Updating the RAR
* is done during the setting up of the multicast table, hence the
* receiver has to be put in reset before updating the multicast table
* and then taken out of reset at the end
*/
/*
* if WMI was enabled then dis able it before issueing the global
* reset to the hardware.
*/
/*
* Only required for WISEMAN_2_0
*/
/*
* The e1000g must be in reset before changing any RA
* registers. Reset receive unit. The chip will remain in
* the reset state until software explicitly restarts it.
*/
/* Allow receiver time to go in to reset */
msec_delay(5);
}
/*
* Only for Wiseman_2_0
* If MWI was enabled then re-enable it after issueing (as we
* disabled it up there) the receive reset command.
* Wainwright does not have a receive reset command and only thing
* close to it is global reset which will require tx setup also
*/
/*
* if WMI was enabled then reenable it after issueing the
* global or receive reset to the hardware.
*/
/*
* Take receiver out of reset
* clear E1000_RCTL_RST bit (and all others)
*/
msec_delay(5);
}
/*
* Restore original value
*/
}
int
{
int result;
goto done;
}
done:
return (result);
}
int
{
return (ECANCELED);
}
if (on)
rctl |=
else
return (EIO);
}
return (0);
}
/*
* Entry points to enable and disable interrupts at the granularity of
* a group.
* Turns the poll_mode for the whole adapter on and off to enable or
* override the ring level polling control over the hardware interrupts.
*/
static int
{
/*
* Later interrupts at the granularity of the this ring will
* invoke mac_rx() with NULL, indicating the need for another
* software classification.
* We have a single ring usable per adapter now, so we only need to
* reset the rx handle for that one.
* When more RX rings can be used, we should update each one of them.
*/
return (0);
}
static int
{
/*
* Later interrupts at the granularity of the this ring will
* invoke mac_rx() with the handle for this ring;
*/
return (0);
}
/*
* Entry points to enable and disable interrupts at the granularity of
* a ring.
* adapter poll_mode controls whether we actually proceed with hardware
* interrupt toggling.
*/
static int
{
return (0);
}
if (poll_mode) {
/* Rx interrupt enabling for MSI and legacy */
/* Trigger a Rx interrupt to check Rx ring */
}
return (0);
}
static int
{
return (0);
}
/*
* Once the adapter can support per Rx ring interrupt,
* we should disable the real interrupt instead of just setting
* the flag.
*/
if (poll_mode) {
/* Rx interrupt disabling for MSI and legacy */
}
return (0);
}
/*
* e1000g_unicst_find - Find the slot for the specified unicast address
*/
static int
{
int slot;
mac_addr, ETHERADDRL) == 0))
return (slot);
}
return (-1);
}
/*
* Entry points to add and remove a MAC address to a ring group.
* The caller takes care of adding and removing the MAC addresses
* to the filter via these two routines.
*/
static int
{
return (ECANCELED);
}
/* The same address is already in slot */
return (0);
}
if (Adapter->unicst_avail == 0) {
/* no slots available */
return (ENOSPC);
}
/* Search for a free slot */
break;
}
if (err == 0)
Adapter->unicst_avail--;
return (err);
}
static int
{
return (ECANCELED);
}
if (slot == -1) {
return (EINVAL);
}
/* Clear this slot */
if (err == 0)
Adapter->unicst_avail++;
return (err);
}
static int
{
return (0);
}
/*
* Callback funtion for MAC layer to register all rings.
*
* The hardware supports a single group with currently only one ring
* available.
* Though not offering virtualization ability per se, exposing the
*/
void
{
/*
* ask for any thing else.
*/
/* Ring level interrupts */
}
static void
{
/*
* We advertised a single RX ring. Getting a request for anything else
* signifies a bug in the MAC framework.
*/
/* Group level interrupts */
}
static boolean_t
{
switch (cap) {
case MAC_CAPAB_HCKSUM: {
if (Adapter->tx_hcksum_enable)
*txflags = HCKSUM_IPHDRCKSUM |
else
return (B_FALSE);
break;
}
case MAC_CAPAB_LSO: {
if (Adapter->lso_enable) {
} else
return (B_FALSE);
break;
}
case MAC_CAPAB_RINGS: {
/* No TX rings exposed yet */
return (B_FALSE);
break;
}
default:
return (B_FALSE);
}
return (B_TRUE);
}
static boolean_t
{
/*
* All en_* parameters are locked (read-only) while
* the device is in any sort of loopback mode ...
*/
switch (pr_num) {
case MAC_PROP_EN_1000FDX_CAP:
case MAC_PROP_EN_1000HDX_CAP:
case MAC_PROP_EN_100FDX_CAP:
case MAC_PROP_EN_100HDX_CAP:
case MAC_PROP_EN_10FDX_CAP:
case MAC_PROP_EN_10HDX_CAP:
case MAC_PROP_AUTONEG:
case MAC_PROP_FLOWCTRL:
return (B_TRUE);
}
return (B_FALSE);
}
/*
*/
static int
{
int err = 0;
return (ECANCELED);
}
/*
* All en_* parameters are locked (read-only)
* while the device is in any sort of loopback mode.
*/
return (EBUSY);
}
switch (pr_num) {
case MAC_PROP_EN_1000FDX_CAP:
goto reset;
case MAC_PROP_EN_100FDX_CAP:
goto reset;
case MAC_PROP_EN_100HDX_CAP:
goto reset;
case MAC_PROP_EN_10FDX_CAP:
goto reset;
case MAC_PROP_EN_10HDX_CAP:
goto reset;
case MAC_PROP_AUTONEG:
goto reset;
case MAC_PROP_FLOWCTRL:
switch (flowctrl) {
default:
break;
case LINK_FLOWCTRL_NONE:
break;
case LINK_FLOWCTRL_RX:
break;
case LINK_FLOWCTRL_TX:
break;
case LINK_FLOWCTRL_BI:
break;
}
if (err == 0) {
}
break;
case MAC_PROP_ADV_1000FDX_CAP:
case MAC_PROP_ADV_1000HDX_CAP:
case MAC_PROP_ADV_100FDX_CAP:
case MAC_PROP_ADV_100HDX_CAP:
case MAC_PROP_ADV_10FDX_CAP:
case MAC_PROP_ADV_10HDX_CAP:
case MAC_PROP_EN_1000HDX_CAP:
case MAC_PROP_STATUS:
case MAC_PROP_SPEED:
case MAC_PROP_DUPLEX:
break;
case MAC_PROP_MTU:
err = 0;
break;
}
if ((tmp < DEFAULT_FRAME_SIZE) ||
(tmp > MAXIMUM_FRAME_SIZE)) {
break;
}
/* ich8 does not support jumbo frames */
(tmp > DEFAULT_FRAME_SIZE)) {
break;
}
/* ich9 does not do jumbo frames on one phy type */
(tmp > DEFAULT_FRAME_SIZE)) {
break;
}
break;
}
if (err == 0) {
}
break;
case MAC_PROP_PRIVATE:
pr_valsize, pr_val);
break;
default:
break;
}
return (err);
}
static int
{
int err = 0;
if (pr_valsize == 0)
return (EINVAL);
*perm = MAC_PROP_PERM_RW;
pr_valsize, pr_val));
}
switch (pr_num) {
case MAC_PROP_DUPLEX:
if (pr_valsize >= sizeof (link_duplex_t)) {
sizeof (link_duplex_t));
} else
break;
case MAC_PROP_SPEED:
if (pr_valsize >= sizeof (uint64_t)) {
} else
break;
case MAC_PROP_AUTONEG:
break;
case MAC_PROP_FLOWCTRL:
if (pr_valsize >= sizeof (link_flowctrl_t)) {
switch (fc->current_mode) {
case e1000_fc_none:
break;
case e1000_fc_rx_pause:
break;
case e1000_fc_tx_pause:
break;
case e1000_fc_full:
break;
}
} else
break;
case MAC_PROP_ADV_1000FDX_CAP:
break;
case MAC_PROP_EN_1000FDX_CAP:
break;
case MAC_PROP_ADV_1000HDX_CAP:
break;
case MAC_PROP_EN_1000HDX_CAP:
break;
case MAC_PROP_ADV_100FDX_CAP:
break;
case MAC_PROP_EN_100FDX_CAP:
break;
case MAC_PROP_ADV_100HDX_CAP:
break;
case MAC_PROP_EN_100HDX_CAP:
break;
case MAC_PROP_ADV_10FDX_CAP:
break;
case MAC_PROP_EN_10FDX_CAP:
break;
case MAC_PROP_ADV_10HDX_CAP:
break;
case MAC_PROP_EN_10HDX_CAP:
break;
case MAC_PROP_ADV_100T4_CAP:
case MAC_PROP_EN_100T4_CAP:
break;
case MAC_PROP_PRIVATE:
break;
default:
break;
}
return (err);
}
/* ARGSUSED2 */
static int
{
int err = 0;
long result;
return (err);
}
if (result < MIN_TX_BCOPY_THRESHOLD ||
else {
}
return (err);
}
return (err);
}
else {
if (Adapter->tx_intr_enable)
else
}
return (err);
}
return (err);
}
if (result < MIN_TX_INTR_DELAY ||
else {
}
return (err);
}
return (err);
}
if (result < MIN_TX_INTR_ABS_DELAY ||
else {
}
return (err);
}
return (err);
}
if (result < MIN_RX_BCOPY_THRESHOLD ||
else
return (err);
}
return (err);
}
if (result < MIN_RX_LIMIT_ON_INTR ||
else
return (err);
}
return (err);
}
if (result < MIN_RX_INTR_DELAY ||
else {
}
return (err);
}
return (err);
}
if (result < MIN_RX_INTR_ABS_DELAY ||
else {
}
return (err);
}
return (err);
}
if (result < MIN_INTR_THROTTLING ||
else {
} else
}
return (err);
}
return (err);
}
else {
} else {
}
}
return (err);
}
return (ENOTSUP);
}
static int
{
int value;
if (is_default)
goto done;
err = 0;
goto done;
}
if (is_default)
goto done;
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
err = 0;
goto done;
}
done:
if (err == 0) {
}
return (err);
}
/*
* e1000g_get_conf - get configurations set in e1000g.conf
* This routine gets user-configured values out of the configuration
* file e1000g.conf.
*
* For each configurable value, there is a minimum, a maximum, and a
* default.
* If user does not configure a value, use the default.
* If user configures below the minimum, use the minumum.
* If user configures above the maximum, use the maxumum.
*/
static void
{
/*
* get each configurable property from e1000g.conf
*/
/*
* NumTxDescriptors
*/
/*
* NumRxDescriptors
*/
/*
* NumRxFreeList
*/
/*
* NumTxPacketList
*/
/*
* FlowControl
*/
/* 4 is the setting that says "let the eeprom decide" */
/*
* Max Num Receive Packets on Interrupt
*/
/*
* PHY master slave setting
*/
/*
* Parameter which controls TBI mode workaround, which is only
* needed on certain switches such as Cisco 6500/Foundry
*/
0, 1, DEFAULT_TBI_COMPAT_ENABLE);
/*
* MSI Enable
*/
0, 1, DEFAULT_MSI_ENABLE);
/*
* Interrupt Throttling Rate
*/
/*
* It is enabled by default
*/
/*
*/
0, 1, DEFAULT_TX_HCKSUM_ENABLE);
/*
*
* If the chip is flagged as not capable of (correctly)
* handling checksumming, we don't enable it on either
* Rx or Tx side. Otherwise, we take this chip's settings
* from the patchable global defaults.
*
* We advertise our capabilities only if TX offload is
* enabled. On receive, the stack will accept checksummed
* packets anyway, even if we haven't said we can deliver
* them.
*/
case e1000_82540:
case e1000_82544:
case e1000_82545:
case e1000_82545_rev_3:
case e1000_82546:
case e1000_82546_rev_3:
case e1000_82571:
case e1000_82572:
case e1000_82573:
case e1000_80003es2lan:
break;
/*
* For the following Intel PRO/1000 chipsets, we have not
* tested the hardware checksum offload capability, so we
* disable the capability for them.
* e1000_82542,
* e1000_82543,
* e1000_82541,
* e1000_82541_rev_2,
* e1000_82547,
* e1000_82547_rev_2,
*/
default:
}
/*
* If the tx hardware checksum is not enabled, LSO should be
* disabled.
*/
0, 1, DEFAULT_LSO_ENABLE);
case e1000_82546:
case e1000_82546_rev_3:
if (Adapter->lso_enable)
/* FALLTHRU */
case e1000_82571:
case e1000_82572:
case e1000_82573:
case e1000_80003es2lan:
break;
default:
}
if (!Adapter->tx_hcksum_enable) {
}
/*
* If mem_workaround_82546 is enabled, the rx buffer allocated by
* e1000_82545, e1000_82546 and e1000_82546_rev_3
* will not cross 64k boundary.
*/
0, 1, DEFAULT_MEM_WORKAROUND_82546);
}
/*
* e1000g_get_prop - routine to read properties
*
* Get a user-configure property value out of the configuration
* file e1000g.conf.
*
* Caller provides name of the property, a default value, a minimum
* value, and a maximum value.
*
* Return configured value of the property, with default, minimum and
* maximum properly applied.
*/
static int
char *propname, /* name of the property */
int minval, /* minimum acceptable value */
int maxval, /* maximim acceptable value */
int defval) /* default value */
{
int propval; /* value returned for requested property */
int *props; /* point to array of properties returned */
/*
* get the array of properties from the config file
*/
/* got some properties, test if we got enough */
} else {
/* not enough properties configured */
"Not Enough %s values found in e1000g.conf"
" - set to %d\n",
}
/* free memory allocated for properties */
} else {
}
/*
* enforce limits
*/
"Too High %s value in e1000g.conf - set to %d\n",
}
"Too Low %s value in e1000g.conf - set to %d\n",
}
return (propval);
}
static boolean_t
{
if (e1000g_link_up(Adapter)) {
/*
* The Link is up, check whether it was marked as down earlier
*/
Adapter->tx_link_down_timeout = 0;
if (speed == SPEED_1000)
else
}
}
Adapter->smartspeed = 0;
} else {
Adapter->link_speed = 0;
Adapter->link_duplex = 0;
/*
* resolution.
*/
(void) e1000_read_phy_reg(hw,
(void) e1000_write_phy_reg(hw,
}
} else {
}
if (Adapter->tx_link_down_timeout <
} else if (Adapter->tx_link_down_timeout ==
}
}
}
return (link_changed);
}
/*
* e1000g_reset_link - Using the link properties to setup the link
*/
int
{
struct e1000_mac_info *mac;
struct e1000_phy_info *phy;
phy->autoneg_advertised = 0;
/*
* 1000hdx is not supported for autonegotiation
*/
if (phy->autoneg_advertised == 0)
} else {
/*
* 1000fdx and 1000hdx are not supported for forced link
*/
else
}
if (invalid) {
"Invalid link sets. Setup link to"
"support autonegotiation with all link capabilities.");
}
}
static void
{
if (tx_ring->resched_needed &&
drv_usectohz(1000000)) &&
}
}
static void
e1000g_local_timer(void *ws)
{
Adapter->reset_count++;
if (e1000g_global_reset(Adapter)) {
} else
return;
}
if (e1000g_stall_check(Adapter)) {
"Tx stall detected. Activate automatic recovery.\n");
Adapter->reset_count++;
if (e1000g_reset_adapter(Adapter)) {
}
return;
}
if (Adapter->link_complete)
if (link_changed)
/*
* Workaround for esb2. Data stuck in fifo on a link
* down event. Reset the adapter to recover it.
*/
if (Adapter->esb2_workaround) {
(void) e1000g_reset_adapter(Adapter);
return;
}
/*
* With 82571 controllers, any locally administered address will
* be overwritten when there is a reset on the other port.
* Detect this circumstance and correct it.
*/
}
}
/*
* Long TTL workaround for 82541/82547
*/
(void) e1000_igp_ttl_workaround_82547(hw);
/*
* Check for Adaptive IFS settings If there are lots of collisions
* change the value in steps...
* These properties should only be set for 10/100
*/
}
/*
* Set Timer Interrupts
*/
else
}
/*
* The function e1000g_link_timer() is called when the timer for link setup
* is expired, which indicates the completion of the link setup. The link
* state will not be updated until the link setup is completed. And the
* link state will not be sent to the upper layer through mac_link_update()
* in this function. It will be updated in the local timer routine or the
* interrupt service routine after the interface is started (plumbed).
*/
static void
e1000g_link_timer(void *arg)
{
}
/*
* e1000g_force_speed_duplex - read forced speed/duplex out of e1000g.conf
*
* This function read the forced speed and duplex for 10/100 Mbps speeds
* and also for 1000 Mbps speeds from the e1000g.conf file
*/
static void
{
int forced;
/*
* get value out of config file
*/
switch (forced) {
case GDIAG_10_HALF:
/*
* Disable Auto Negotiation
*/
break;
case GDIAG_10_FULL:
/*
* Disable Auto Negotiation
*/
break;
case GDIAG_100_HALF:
/*
* Disable Auto Negotiation
*/
break;
case GDIAG_100_FULL:
/*
* Disable Auto Negotiation
*/
break;
case GDIAG_1000_FULL:
/*
* The gigabit spec requires autonegotiation. Therefore,
* when the user wants to force the speed to 1000Mbps, we
* enable AutoNeg, but only allow the harware to advertise
* 1000Mbps. This is different from 10/100 operation, where
* we are allowed to link without any negotiation.
*/
break;
default: /* obey the setting of AutoNegAdvertised */
break;
} /* switch */
}
/*
* e1000g_get_max_frame_size - get jumbo frame setting from e1000g.conf
*
* This function reads MaxFrameSize from e1000g.conf
*/
static void
{
int max_frame;
/*
* get value out of config file
*/
switch (max_frame) {
case 0:
break;
/*
* To avoid excessive memory allocation for rx buffers,
* the bytes of E1000G_IPALIGNPRESERVEROOM are reserved.
*/
case 1:
sizeof (struct ether_vlan_header) - ETHERFCSL -
break;
case 2:
sizeof (struct ether_vlan_header) - ETHERFCSL -
break;
case 3:
else
sizeof (struct ether_vlan_header) - ETHERFCSL -
break;
default:
break;
} /* switch */
sizeof (struct ether_vlan_header) + ETHERFCSL;
/* ich8 does not do jumbo frames */
sizeof (struct ether_vlan_header) + ETHERFCSL;
}
/* ich9 does not do jumbo frames on one phy type */
sizeof (struct ether_vlan_header) + ETHERFCSL;
}
}
static void
{
}
#pragma inline(arm_watchdog_timer)
static void
{
if (!Adapter->watchdog_timer_enabled) {
}
}
static void
{
Adapter->watchdog_tid = 0;
if (tid != 0)
}
static void
{
if (Adapter->watchdog_timer_enabled) {
if (!Adapter->watchdog_timer_started) {
}
}
}
static void
{
}
static void
{
Adapter->watchdog_tid = 0;
if (tid != 0)
}
static void
{
/* Disable the link timer */
if (tid != 0)
}
static void
{
/* Disable the tx timer for 82547 chipset */
tx_ring->timer_id_82547 = 0;
if (tid != 0)
}
void
{
0xffffffff & ~E1000_IMS_RXSEQ);
}
void
{
if (Adapter->tx_intr_enable)
}
/*
* This routine is called by e1000g_quiesce(), therefore must not block.
*/
void
{
}
void
{
}
void
{
}
static void
{
/*
* If we're not T-or-T, or we're not autoneg'ing, or we're not
* advertising 1000Full, we don't even use the workaround
*/
return;
/*
* True if this is the first call of this function or after every
* 30 seconds of not having link
*/
if (Adapter->smartspeed == 0) {
/*
* assume back-to-back
*/
if (!(phy_status & SR_1000T_MS_CONFIG_FAULT))
return;
if (!(phy_status & SR_1000T_MS_CONFIG_FAULT))
return;
/*
* We're assuming back-2-back because our status register
* relationship that was "negotiated"
*/
/*
* Is the phy configured for manual configuration of
*/
if (phy_ctrl & CR_1000T_MS_ENABLE) {
/*
* Yes. Then disable manual configuration (enable
*/
(void) e1000_write_phy_reg(hw,
/*
* Effectively starting the clock
*/
Adapter->smartspeed++;
/*
* Restart autonegotiation
*/
if (!e1000_phy_setup_autoneg(hw) &&
phy_ctrl |= (MII_CR_AUTO_NEG_EN |
(void) e1000_write_phy_reg(hw,
}
}
return;
/*
* Has 6 seconds transpired still without link? Remember,
* you should reset the smartspeed counter once you obtain
* link
*/
/*
* Yes. Remember, we did at the start determine that
* still assuming there's someone on the other end, but we
* just haven't yet been able to talk to it. We then
* we're running 2/3 pair cables.
*/
/*
* If still no link, perhaps using 2/3 pair cable
*/
/*
* Restart autoneg with phy enabled for manual
*/
if (!e1000_phy_setup_autoneg(hw) &&
phy_ctrl |=
}
/*
* Hopefully, there are no more faults and we've obtained
* link as a result.
*/
}
/*
* Restart process after E1000_SMARTSPEED_MAX iterations (30
* seconds)
*/
Adapter->smartspeed = 0;
}
static boolean_t
{
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
return (B_FALSE);
return (B_TRUE);
}
/*
* e1000g_stall_check - check for tx stall
*
* This function checks if the adapter is stalled (in transmit).
*
* It is called each time the watchdog timeout is invoked.
* If the transmit descriptor reclaim continuously fails,
* the watchdog value will increment by 1. If the watchdog
* value exceeds the threshold, the adapter is assumed to
* have stalled and need to be reset.
*/
static boolean_t
{
return (B_FALSE);
if (tx_ring->recycle_fail > 0)
else
tx_ring->stall_watchdog = 0;
return (B_FALSE);
tx_ring->stall_watchdog = 0;
tx_ring->recycle_fail = 0;
return (B_TRUE);
}
#ifdef E1000G_DEBUG
static enum ioc_reply
{
case E1000G_IOC_REG_PEEK:
break;
case E1000G_IOC_REG_POKE:
break;
"e1000g_diag_ioctl: invalid ioctl command 0x%X\n",
return (IOC_INVAL);
}
/*
* Validate format of ioctl
*/
return (IOC_INVAL);
return (IOC_INVAL);
/*
* Validate request parameters
*/
switch (ppd->pp_acc_space) {
default:
"e1000g_diag_ioctl: invalid access space 0x%X\n",
ppd->pp_acc_space);
return (IOC_INVAL);
case E1000G_PP_SPACE_REG:
/*
* Memory-mapped I/O space
*/
return (IOC_INVAL);
return (IOC_INVAL);
mem_va = 0;
maxoff = 0x10000;
break;
case E1000G_PP_SPACE_E1000G:
/*
* E1000g data structure!
*/
break;
}
return (IOC_INVAL);
return (IOC_INVAL);
/*
* All OK - go!
*/
}
static void
{
}
static void
{
}
static void
{
void *vaddr;
switch (ppd->pp_acc_size) {
case 1:
break;
case 2:
break;
case 4:
break;
case 8:
break;
}
"e1000g_ioc_peek_mem($%p, $%p) peeked 0x%llx from $%p\n",
}
static void
{
void *vaddr;
"e1000g_ioc_poke_mem($%p, $%p) poking 0x%llx at $%p\n",
switch (ppd->pp_acc_size) {
case 1:
break;
case 2:
break;
case 4:
break;
case 8:
break;
}
}
#endif
/*
* Loopback Support
*/
static lb_property_t lb_normal =
static lb_property_t lb_external1000 =
static lb_property_t lb_external100 =
static lb_property_t lb_external10 =
static lb_property_t lb_phy =
static enum ioc_reply
{
return (IOC_INVAL);
if (!e1000g_check_loopback_support(hw)) {
return (IOC_INVAL);
}
default:
return (IOC_INVAL);
case LB_GET_INFO_SIZE:
size = sizeof (lb_info_sz_t);
return (IOC_INVAL);
/*
* Workaround for hardware faults. In order to get a stable
* state of phy, we will wait for a specific interval and
* try again. The time delay is an experiential value based
* on our testing.
*/
msec_delay(100);
case e1000_82571:
case e1000_82572:
case e1000_80003es2lan:
value += sizeof (lb_external1000);
break;
}
}
value += sizeof (lb_external100);
value += sizeof (lb_external10);
break;
case LB_GET_INFO:
case e1000_82571:
case e1000_82572:
case e1000_80003es2lan:
value += sizeof (lb_external1000);
break;
}
}
value += sizeof (lb_external100);
value += sizeof (lb_external10);
return (IOC_INVAL);
value = 0;
case e1000_82571:
case e1000_82572:
case e1000_80003es2lan:
break;
}
}
break;
case LB_GET_MODE:
return (IOC_INVAL);
break;
case LB_SET_MODE:
size = 0;
return (IOC_INVAL);
return (IOC_INVAL);
break;
}
return (IOC_INVAL);
}
return (IOC_REPLY);
}
static boolean_t
{
case e1000_82540:
case e1000_82545:
case e1000_82545_rev_3:
case e1000_82546:
case e1000_82546_rev_3:
case e1000_82541:
case e1000_82541_rev_2:
case e1000_82547:
case e1000_82547_rev_2:
case e1000_82571:
case e1000_82572:
case e1000_82573:
case e1000_82574:
case e1000_80003es2lan:
case e1000_ich9lan:
case e1000_ich10lan:
return (B_TRUE);
}
return (B_FALSE);
}
static boolean_t
{
int i, times;
return (B_TRUE);
times = 0;
if (mode == E1000G_LB_NONE) {
/* Reset the chip */
(void) e1000g_reset_adapter(Adapter);
return (B_TRUE);
}
switch (mode) {
default:
return (B_FALSE);
case E1000G_LB_EXTERNAL_1000:
break;
case E1000G_LB_EXTERNAL_100:
break;
case E1000G_LB_EXTERNAL_10:
break;
case E1000G_LB_INTERNAL_PHY:
break;
}
times++;
/* Wait for link up */
for (i = (PHY_FORCE_LIMIT * 2); i > 0; i--)
msec_delay(100);
if (!link_up) {
"Failed to get the link up");
if (times < 2) {
/* Reset the link */
"Reset the link ...");
(void) e1000g_reset_adapter(Adapter);
goto again;
}
}
return (B_TRUE);
}
/*
* The following loopback settings are from Intel's technical
* document - "How To Loopback". All the register settings and
* time delay values are directly inherited from the document
* without more explanations available.
*/
static void
{
/* Disable Smart Power Down */
case e1000_82540:
case e1000_82545:
case e1000_82545_rev_3:
case e1000_82546:
case e1000_82546_rev_3:
case e1000_82573:
/* Reset PHY to auto-neg off and force 1000 */
phy_ctrl | MII_CR_RESET);
/*
* Disable PHY receiver for 82540/545/546 and 82573 Family.
* See comments above e1000g_set_internal_loopback() for the
* background.
*/
break;
case e1000_80003es2lan:
/* Force Link Up */
0x1CC);
/* Sets PCS loopback at 1Gbs */
0x1046);
break;
}
/*
* The following registers should be set for e1000_phy_bm phy type.
* e1000_82574, e1000_ich10lan and some e1000_ich9lan use this phy.
* For others, we do not need to set these registers.
*/
/* Set Default MAC Interface speed to 1GB */
phy_reg &= ~0x0007;
phy_reg |= 0x006;
/* Assert SW reset for above settings to take effect */
msec_delay(1);
/* Force Full Duplex */
/* Set Link Up (in force link) */
/* Force Link */
/* Set Early Link Enable */
}
/* Set loopback */
msec_delay(250);
E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */
E1000_CTRL_FD); /* Force Duplex to FULL */
case e1000_82540:
case e1000_82545:
case e1000_82545_rev_3:
case e1000_82546:
case e1000_82546_rev_3:
/*
* For some serdes we'll need to commit the writes now
* so that the status is updated on link
*/
msec_delay(100);
}
/* Invert Loss of Signal */
ctrl |= E1000_CTRL_ILOS;
} else {
/* Set ILOS on fiber nic if half duplex is detected */
if ((status & E1000_STATUS_FD) == 0)
}
break;
case e1000_82571:
case e1000_82572:
/*
* accessible PHY. Therefore, loopback beyond MAC must be done
* using SerDes analog loopback.
*/
/* Disable autoneg by setting bit 31 of TXCW to zero */
/*
* Write 0x410 to Serdes Control register
* to enable Serdes analog loopback
*/
msec_delay(10);
}
/* Set ILOS on fiber nic if half duplex is detected */
((status & E1000_STATUS_FD) == 0 ||
(status & E1000_STATUS_LU) == 0))
ctrl |= E1000_CTRL_SLU;
break;
case e1000_82573:
ctrl |= E1000_CTRL_ILOS;
break;
case e1000_ich9lan:
case e1000_ich10lan:
ctrl |= E1000_CTRL_SLU;
break;
}
}
static void
{
/* Disable Smart Power Down */
case e1000_82571:
case e1000_82572:
case e1000_media_type_copper:
/* Force link up (Must be done before the PHY writes) */
rctl |= (E1000_RCTL_EN |
E1000_RCTL_BAM); /* 0x803E */
E1000_CTRL_EXT_SDP7_DIR); /* 0x0DD0 */
/*
* This sequence tunes the PHY's SDP and no customer
* settable values. For background, see comments above
* e1000g_set_internal_loopback().
*/
msec_delay(10);
msec_delay(50);
break;
case e1000_media_type_fiber:
if (((status & E1000_STATUS_LU) == 0) ||
}
/* Disable autoneg by setting bit 31 of TXCW to zero */
/*
* Write 0x410 to Serdes Control register
* to enable Serdes analog loopback
*/
msec_delay(10);
break;
default:
break;
}
break;
case e1000_82574:
case e1000_80003es2lan:
case e1000_ich9lan:
case e1000_ich10lan:
(void) e1000g_reset_link(Adapter);
break;
}
}
static void
{
/* Disable Smart Power Down */
/* Force 100/FD, reset PHY */
msec_delay(10);
/* Force 100/FD */
phy_ctrl); /* 0x2100 */
msec_delay(10);
E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
E1000_CTRL_SPD_100 | /* Force Speed to 100 */
E1000_CTRL_FD); /* Force Duplex to FULL */
}
static void
{
/* Disable Smart Power Down */
/* Force 10/FD, reset PHY */
msec_delay(10);
/* Force 10/FD */
phy_ctrl); /* 0x0100 */
msec_delay(10);
E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
E1000_CTRL_SPD_10 | /* Force Speed to 10 */
E1000_CTRL_FD); /* Force Duplex to FULL */
}
#ifdef __sparc
static boolean_t
{
struct ether_addr sysaddr;
int err;
/*
* The "vendor's factory-set address" may already have
* been extracted from the chip, but if the property
* "local-mac-address" is set we use that instead.
*
* We check whether it looks like an array of 6
* bytes (which it should, if OBP set it). If we can't
* make sense of it this way, we'll ignore it.
*/
if (err == DDI_PROP_SUCCESS) {
if (nelts == ETHERADDRL) {
while (nelts--)
}
}
/*
* Look up the OBP property "local-mac-address?". If the user has set
* 'local-mac-address? = false', use "the system address" instead.
*/
}
}
}
/*
* Finally(!), if there's a valid "mac-address" property (created
* if we netbooted from this interface), we must use this instead
* get confused by the address changing as Solaris takes over!
*/
if (err == DDI_PROP_SUCCESS) {
if (nelts == ETHERADDRL) {
while (nelts--)
}
}
if (found) {
}
return (found);
}
#endif
static int
{
int intr_types;
int rc;
/* Get supported interrupt types */
if (rc != DDI_SUCCESS) {
"Get supported interrupt types failed: %d\n", rc);
return (DDI_FAILURE);
}
/*
* Based on Intel Technical Advisory document (TA-160), there are some
* cases where some older Intel PCI-X NICs may "advertise" to the OS
* that it supports MSI, but in fact has problems.
* So we should only enable MSI for PCI-E NICs and disable MSI for old
*/
if (rc != DDI_SUCCESS) {
"Add MSI failed, trying Legacy interrupts\n");
} else {
}
}
(intr_types & DDI_INTR_TYPE_FIXED)) {
if (rc != DDI_SUCCESS) {
"Add Legacy interrupts failed\n");
return (DDI_FAILURE);
}
}
"No interrupts registered\n");
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
*/
static int
{
int flag;
/* get number of interrupts */
"Get interrupt number failed. Return: %d, count: %d\n",
return (DDI_FAILURE);
}
/* get number of available interrupts */
"Get interrupt available number failed. "
return (DDI_FAILURE);
}
"Interrupts count: %d, available: %d\n",
}
/* Allocate an array of interrupt handles */
/* Set NORMAL behavior for both MSI and FIXED interrupt */
/* call ddi_intr_alloc() */
"Allocate interrupts failed: %d\n", rc);
return (DDI_FAILURE);
}
"Interrupts requested: %d, received: %d\n",
}
/* Get priority for first msi, assume remaining are all the same */
if (rc != DDI_SUCCESS) {
"Get interrupt priority failed: %d\n", rc);
/* Free already allocated intr */
for (y = 0; y < actual; y++)
return (DDI_FAILURE);
}
/*
* In Legacy Interrupt mode, for PCI-Express adapters, we should
* use the interrupt service routine e1000g_intr_pciexpress()
* to avoid interrupt stealing when sharing interrupt with other
* devices.
*/
else
/* Call ddi_intr_add_handler() */
for (x = 0; x < actual; x++) {
if (rc != DDI_SUCCESS) {
"Add interrupt handler failed: %d\n", rc);
/* Remove already added handler */
for (y = 0; y < x; y++)
(void) ddi_intr_remove_handler(
/* Free already allocated intr */
for (y = 0; y < actual; y++)
return (DDI_FAILURE);
}
}
if (rc != DDI_SUCCESS) {
"Get interrupt cap failed: %d\n", rc);
/* Free already allocated intr */
for (y = 0; y < actual; y++) {
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
int x;
int rc;
if (rc != DDI_SUCCESS) {
"Remove intr handler failed: %d\n", rc);
return (DDI_FAILURE);
}
if (rc != DDI_SUCCESS) {
"Free intr failed: %d\n", rc);
return (DDI_FAILURE);
}
}
return (DDI_SUCCESS);
}
static int
{
int x;
int rc;
/* Enable interrupts */
/* Call ddi_intr_block_enable() for MSI */
if (rc != DDI_SUCCESS) {
"Enable block intr failed: %d\n", rc);
return (DDI_FAILURE);
}
} else {
if (rc != DDI_SUCCESS) {
"Enable intr failed: %d\n", rc);
return (DDI_FAILURE);
}
}
}
return (DDI_SUCCESS);
}
static int
{
int x;
int rc;
/* Disable all interrupts */
if (rc != DDI_SUCCESS) {
"Disable block intr failed: %d\n", rc);
return (DDI_FAILURE);
}
} else {
if (rc != DDI_SUCCESS) {
"Disable intr failed: %d\n", rc);
return (DDI_FAILURE);
}
}
}
return (DDI_SUCCESS);
}
/*
* e1000g_get_phy_state - get the state of PHY registers, save in the adapter
*/
static void
{
}
}
/*
* FMA support
*/
int
{
return (de.fme_status);
}
int
{
return (de.fme_status);
}
/*
* The IO fault service error handling callback function
*/
/* ARGSUSED2 */
static int
{
/*
* as the driver can always deal with an error in any dma or
* access handle, we can just return the fme_status value.
*/
return (err->fme_status);
}
static void
{
int fma_acc_flag, fma_dma_flag;
/* Only register with IO Fault Services if we have some capability */
fma_acc_flag = 1;
} else {
fma_acc_flag = 0;
}
fma_dma_flag = 1;
} else {
fma_dma_flag = 0;
}
if (Adapter->fm_capabilities) {
/* Register capabilities with IO Fault Services */
/*
* Initialize pci ereport capabilities if ereport capable
*/
/*
* Register error callback if error callback capable
*/
e1000g_fm_error_cb, (void*) Adapter);
}
}
static void
{
/* Only unregister FMA capabilities if we registered some */
if (Adapter->fm_capabilities) {
/*
* Release any resources allocated by pci_ereport_setup()
*/
/*
* Un-register error callback if error callback capable
*/
/* Unregister from IO Fault Services */
}
}
void
{
char buf[FM_MAX_CLASS];
}
}
/*
* quiesce(9E) entry point.
*
* This function is called when the system is single-threaded at high
* PIL with preemption disabled. Therefore, this function must not be
* blocked.
*
* This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure.
* DDI_FAILURE indicates an error condition and should almost never happen.
*/
static int
{
return (DDI_FAILURE);
/* Setup our HW Tx Head & Tail descriptor pointers */
/* Setup our HW Rx Head & Tail descriptor pointers */
return (DDI_SUCCESS);
}
static int
{
int err = 0;
ASSERT(pr_valsize > 0);
switch (pr_num) {
case MAC_PROP_AUTONEG:
break;
case MAC_PROP_FLOWCTRL:
if (pr_valsize < sizeof (link_flowctrl_t))
return (EINVAL);
break;
case MAC_PROP_ADV_1000FDX_CAP:
case MAC_PROP_EN_1000FDX_CAP:
break;
case MAC_PROP_ADV_1000HDX_CAP:
case MAC_PROP_EN_1000HDX_CAP:
break;
case MAC_PROP_ADV_100FDX_CAP:
case MAC_PROP_EN_100FDX_CAP:
break;
case MAC_PROP_ADV_100HDX_CAP:
case MAC_PROP_EN_100HDX_CAP:
break;
case MAC_PROP_ADV_10FDX_CAP:
case MAC_PROP_EN_10FDX_CAP:
break;
case MAC_PROP_ADV_10HDX_CAP:
case MAC_PROP_EN_10HDX_CAP:
break;
default:
break;
}
return (err);
}
/*
* synchronize the adv* and en* parameters.
*
* parameters. The usage of ndd for setting adv parameters will
* synchronize all the en parameters with the e1000g parameters,
* implicitly disabling any settings made via dladm.
*/
static void
{
}
/*
* e1000g_get_driver_control - tell manageability firmware that the driver
* has control.
*/
static void
{
/* tell manageability firmware the driver has taken over */
case e1000_82573:
break;
case e1000_82571:
case e1000_82572:
case e1000_82574:
case e1000_80003es2lan:
case e1000_ich8lan:
case e1000_ich9lan:
case e1000_ich10lan:
break;
default:
/* no manageability firmware: do nothing */
break;
}
}
/*
* e1000g_release_driver_control - tell manageability firmware that the driver
* has released control.
*/
static void
{
/* tell manageability firmware the driver has released control */
case e1000_82573:
break;
case e1000_82571:
case e1000_82572:
case e1000_82574:
case e1000_80003es2lan:
case e1000_ich8lan:
case e1000_ich9lan:
case e1000_ich10lan:
break;
default:
/* no manageability firmware: do nothing */
break;
}
}
/*
* Restore e1000g promiscuous mode.
*/
static void
{
if (Adapter->e1000g_promisc) {
}
}