ixgbe_main.c revision c971fb7ec0a19c6cd00c5614a94c97f953b6e8b1
/*
* CDDL HEADER START
*
* Copyright(c) 2007-2008 Intel Corporation. All rights reserved.
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at:
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When using or redistributing this file, you may do so under the
* License only. No other modification of this header is permitted.
*
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms of the CDDL.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "ixgbe_sw.h"
static char ident[] = "Intel 10Gb Ethernet 1.0.1";
/*
* Local function protoypes
*/
static int ixgbe_register_mac(ixgbe_t *);
static int ixgbe_identify_hardware(ixgbe_t *);
static int ixgbe_regs_map(ixgbe_t *);
static void ixgbe_init_properties(ixgbe_t *);
static int ixgbe_init_driver_settings(ixgbe_t *);
static void ixgbe_init_locks(ixgbe_t *);
static void ixgbe_destroy_locks(ixgbe_t *);
static int ixgbe_init(ixgbe_t *);
static int ixgbe_chip_start(ixgbe_t *);
static void ixgbe_chip_stop(ixgbe_t *);
static int ixgbe_reset(ixgbe_t *);
static void ixgbe_tx_clean(ixgbe_t *);
static int ixgbe_alloc_rings(ixgbe_t *);
static int ixgbe_init_rings(ixgbe_t *);
static void ixgbe_free_rings(ixgbe_t *);
static void ixgbe_fini_rings(ixgbe_t *);
static void ixgbe_setup_rings(ixgbe_t *);
static void ixgbe_setup_rx(ixgbe_t *);
static void ixgbe_setup_tx(ixgbe_t *);
static void ixgbe_setup_rx_ring(ixgbe_rx_ring_t *);
static void ixgbe_setup_tx_ring(ixgbe_tx_ring_t *);
static void ixgbe_setup_rss(ixgbe_t *);
static void ixgbe_init_unicst(ixgbe_t *);
static void ixgbe_setup_multicst(ixgbe_t *);
static void ixgbe_get_hw_state(ixgbe_t *);
static void ixgbe_get_conf(ixgbe_t *);
static int ixgbe_get_prop(ixgbe_t *, char *, int, int, int);
static void ixgbe_local_timer(void *);
static void ixgbe_arm_watchdog_timer(ixgbe_t *);
static void ixgbe_start_watchdog_timer(ixgbe_t *);
static void ixgbe_restart_watchdog_timer(ixgbe_t *);
static void ixgbe_stop_watchdog_timer(ixgbe_t *);
static void ixgbe_disable_adapter_interrupts(ixgbe_t *);
static void ixgbe_enable_adapter_interrupts(ixgbe_t *);
static void ixgbe_set_internal_mac_loopback(ixgbe_t *);
static int ixgbe_alloc_intrs(ixgbe_t *);
static int ixgbe_alloc_intr_handles(ixgbe_t *, int);
static int ixgbe_add_intr_handlers(ixgbe_t *);
static void ixgbe_map_rxring_to_vector(ixgbe_t *, int, int);
static void ixgbe_map_txring_to_vector(ixgbe_t *, int, int);
static int ixgbe_map_rings_to_vectors(ixgbe_t *);
static void ixgbe_setup_adapter_vector(ixgbe_t *);
static void ixgbe_rem_intr_handlers(ixgbe_t *);
static void ixgbe_rem_intrs(ixgbe_t *);
static int ixgbe_enable_intrs(ixgbe_t *);
static int ixgbe_disable_intrs(ixgbe_t *);
static uint_t ixgbe_intr_legacy(void *, void *);
static uint_t ixgbe_intr_msi(void *, void *);
static uint_t ixgbe_intr_rx(void *, void *);
static uint_t ixgbe_intr_tx_other(void *, void *);
static void ixgbe_intr_rx_work(ixgbe_rx_ring_t *);
static void ixgbe_intr_tx_work(ixgbe_tx_ring_t *);
static void ixgbe_intr_other_work(ixgbe_t *);
static void ixgbe_get_driver_control(struct ixgbe_hw *);
static void ixgbe_release_driver_control(struct ixgbe_hw *);
static int ixgbe_resume(dev_info_t *);
static int ixgbe_suspend(dev_info_t *);
const void *impl_data);
static void ixgbe_fm_init(ixgbe_t *);
static void ixgbe_fm_fini(ixgbe_t *);
static struct cb_ops ixgbe_cb_ops = {
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 */
};
static struct dev_ops ixgbe_dev_ops = {
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
NULL, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
ixgbe_attach, /* devo_attach */
ixgbe_detach, /* devo_detach */
nodev, /* devo_reset */
&ixgbe_cb_ops, /* devo_cb_ops */
NULL, /* devo_bus_ops */
ddi_power /* devo_power */
};
static struct modldrv ixgbe_modldrv = {
&mod_driverops, /* Type of module. This one is a driver */
ident, /* Discription string */
&ixgbe_dev_ops /* driver ops */
};
static struct modlinkage ixgbe_modlinkage = {
};
/*
* Access attributes for register mapping
*/
};
/*
* Loopback property
*/
static lb_property_t lb_normal = {
};
static lb_property_t lb_mac = {
};
static mac_callbacks_t ixgbe_m_callbacks = {
NULL,
};
/*
* Module Initialization Functions.
*/
int
_init(void)
{
int status;
if (status != DDI_SUCCESS) {
}
return (status);
}
int
_fini(void)
{
int status;
if (status == DDI_SUCCESS) {
}
return (status);
}
int
{
int status;
return (status);
}
/*
* ixgbe_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 ixgbe_osdep *osdep;
int instance;
/*
* Check the command and perform corresponding operations
*/
switch (cmd) {
default:
return (DDI_FAILURE);
case DDI_RESUME:
return (ixgbe_resume(devinfo));
case DDI_ATTACH:
break;
}
/* Get the device instance */
/* Allocate memory for the instance data structure */
/* Attach the instance pointer to the dev_info data structure */
/*
* Initialize for fma support
*/
/*
* Map PCI config space registers
*/
goto attach_fail;
}
/*
* Identify the chipset family
*/
goto attach_fail;
}
/*
* Map device registers
*/
goto attach_fail;
}
/*
* Initialize driver parameters
*/
/*
* Allocate interrupts
*/
goto attach_fail;
}
/*
* allocated interrupt vectors, so we should allocate the rings after
* interrupts are allocated.
*/
goto attach_fail;
}
/*
* Map rings to interrupt vectors
*/
goto attach_fail;
}
/*
* Add interrupt handlers
*/
goto attach_fail;
}
/*
* Initialize driver parameters
*/
goto attach_fail;
}
/*
* Initialize mutexes 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 chipset hardware
*/
goto attach_fail;
}
goto attach_fail;
}
/*
*/
goto attach_fail;
}
/*
* Initialize statistics
*/
goto attach_fail;
}
/*
* Initialize NDD parameters
*/
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;
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
/*
* ixgbe_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
{
/*
* Check detach command
*/
switch (cmd) {
default:
return (DDI_FAILURE);
case DDI_SUSPEND:
return (ixgbe_suspend(devinfo));
case DDI_DETACH:
break;
}
/*
* Get the pointer to the driver private data structure
*/
return (DDI_FAILURE);
/*
* Unregister MAC. If failed, we have to fail the detach
*/
return (DDI_FAILURE);
}
/*
* If the device is still running, it needs to be stopped first.
* This check is necessary because under some specific circumstances,
* the detach routine can be called without stopping the interface
* first.
*/
/* Disable and stop the watchdog timer */
} else
/*
* Check if there are still rx buffers held by the upper layer.
* If so, fail the detach.
*/
if (!ixgbe_rx_drain(ixgbe))
return (DDI_FAILURE);
/*
* Do the remaining unconfigure routines
*/
return (DDI_SUCCESS);
}
static void
{
/*
* Disable interrupt
*/
(void) ixgbe_disable_intrs(ixgbe);
}
/*
* Unregister MAC
*/
}
/*
* Free ndd parameters
*/
}
/*
* Free statistics
*/
}
/*
* Remove interrupt handlers
*/
}
/*
* Remove interrupts
*/
}
/*
* Remove driver properties
*/
(void) ddi_prop_remove_all(devinfo);
}
/*
*/
}
/*
* Stop the chipset
*/
}
/*
* Free register handle
*/
}
/*
* Free PCI config handle
*/
}
/*
* Free locks
*/
}
/*
*/
}
/*
* Unregister FMA capabilities
*/
}
/*
* Free the driver data structure
*/
}
/*
* ixgbe_register_mac - Register the driver and its function pointers with
* the GLD interface.
*/
static int
{
int status;
return (IXGBE_FAILURE);
}
/*
* ixgbe_identify_hardware - Identify the type of the chipset.
*/
static int
{
/*
* Get the device id
*/
hw->revision_id =
return (IXGBE_SUCCESS);
}
/*
* ixgbe_regs_map - Map the device registers.
*
*/
static int
{
/*
* First get the size of device registers to be mapped.
*/
return (IXGBE_FAILURE);
}
/*
* Call ddi_regs_map_setup() to map registers
*/
return (IXGBE_FAILURE);
}
return (IXGBE_SUCCESS);
}
/*
* ixgbe_init_properties - Initialize driver properties.
*/
static void
{
/*
* Get conf file properties, including link settings
* jumbo frames, ring number, descriptor number, etc.
*/
}
/*
* ixgbe_init_driver_settings - Initialize driver settings.
*
* The settings include hardware function pointers, bus information,
* need to be setup during driver initialization.
*/
static int
{
int i;
/*
* Initialize chipset specific hardware function pointers
*/
return (IXGBE_FAILURE);
}
/*
* Set rx buffer size
*
* The IP header alignment room is counted in the calculation.
* The rx buffer size is in unit of 1K that is required by the
* chipset hardware.
*/
/*
* Set tx buffer size
*/
/*
*/
for (i = 0; i < ixgbe->num_rx_rings; i++) {
}
for (i = 0; i < ixgbe->num_tx_rings; i++) {
if (ixgbe->tx_head_wb_enable)
else
}
/*
* Initialize values of interrupt throttling rate
*/
for (i = 1; i < IXGBE_MAX_RING_VECTOR; i++)
/*
* The initial link state should be "unknown"
*/
return (IXGBE_SUCCESS);
}
/*
* ixgbe_init_locks - Initialize locks.
*/
static void
{
int i;
for (i = 0; i < ixgbe->num_rx_rings; i++) {
}
for (i = 0; i < ixgbe->num_tx_rings; i++) {
}
}
/*
* ixgbe_destroy_locks - Destroy locks.
*/
static void
{
int i;
for (i = 0; i < ixgbe->num_rx_rings; i++) {
}
for (i = 0; i < ixgbe->num_tx_rings; i++) {
}
}
static int
{
return (DDI_FAILURE);
return (DDI_FAILURE);
}
/*
* Enable and start the watchdog timer
*/
}
return (DDI_SUCCESS);
}
static int
{
return (DDI_FAILURE);
/*
* Disable and stop the watchdog timer
*/
return (DDI_SUCCESS);
}
/*
* ixgbe_init - Initialize the device.
*/
static int
{
/*
* Reset chipset to put the hardware in a known state
* before we try to do anything with the eeprom.
*/
goto init_fail;
}
/*
* Need to init eeprom before validating the checksum.
*/
if (ixgbe_init_eeprom_params(hw) < 0) {
"Unable to intitialize the eeprom interface.");
goto init_fail;
}
/*
* NVM validation
*/
/*
* 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 it's a real issue.
*/
"Invalid NVM checksum. Please contact "
"the vendor to update the NVM.");
goto init_fail;
}
}
/*
* & flow control type is controlled by ixgbe.conf
*/
/*
* Don't wait for auto-negotiation to complete
*/
/*
* Initialize link settings
*/
/*
* Initialize the chipset hardware
*/
goto init_fail;
}
goto init_fail;
}
goto init_fail;
}
return (IXGBE_SUCCESS);
/*
* Reset PHY
*/
(void) ixgbe_reset_phy(hw);
return (IXGBE_FAILURE);
}
/*
* initialize relevant hardware settings.
*/
static int
{
int i;
/*
*/
return (IXGBE_FAILURE);
/*
*/
for (i = 0; i < ixgbe->num_rx_rings; i++)
for (i = 0; i < ixgbe->num_tx_rings; i++)
return (IXGBE_SUCCESS);
}
/*
*/
static void
{
/*
*/
}
/*
* ixgbe_chip_start - Initialize and start the chipset hardware.
*/
static int
{
int i;
/*
* Get the mac address
* This function should handle SPARC case correctly.
*/
if (!ixgbe_find_mac_address(ixgbe)) {
return (IXGBE_FAILURE);
}
/*
* Validate the mac address
*/
(void) ixgbe_init_rx_addrs(hw);
return (IXGBE_FAILURE);
}
/*
* Configure/Initialize hardware
*/
return (IXGBE_FAILURE);
}
/*
* Setup adapter interrupt vectors
*/
/*
* Initialize unicast addresses.
*/
/*
* Setup and initialize the mctable structures.
*/
/*
* Set interrupt throttling rate
*/
/*
* Save the state of the phy
*/
/*
* Make sure driver has control
*/
return (IXGBE_SUCCESS);
}
/*
* ixgbe_chip_stop - Stop the chipset hardware
*/
static void
{
/*
* Tell firmware driver is no longer in control
*/
/*
* Reset the chipset
*/
(void) ixgbe_reset_hw(hw);
/*
* Reset PHY
*/
(void) ixgbe_reset_phy(hw);
}
/*
* ixgbe_reset - Reset the chipset and re-start the driver.
*
* It involves stopping and re-starting the chipset,
*/
static int
{
int i;
/*
* before draining pending data and resetting hardware.
*/
/*
* Drain the pending transmit packets
*/
(void) ixgbe_tx_drain(ixgbe);
for (i = 0; i < ixgbe->num_rx_rings; i++)
for (i = 0; i < ixgbe->num_tx_rings; i++)
/*
* Stop the chipset hardware
*/
/*
*/
/*
* Start the chipset hardware
*/
goto reset_failure;
}
goto reset_failure;
}
/*
*/
/*
* Enable adapter interrupts
* The interrupts must be enabled after the driver state is START
*/
return (IXGBE_SUCCESS);
return (IXGBE_FAILURE);
}
/*
* ixgbe_tx_clean - Clean the pending transmit packets and DMA resources.
*/
static void
{
int i, j;
for (i = 0; i < ixgbe->num_tx_rings; i++) {
/*
* Clean the pending tx data - the pending packets in the
* work_list that have no chances to be transmitted again.
*
* We must ensure the chipset is stopped or the link is down
* before cleaning the transmit packets.
*/
desc_num = 0;
}
}
if (desc_num > 0) {
/*
* Reset the head and tail pointers of the tbd ring;
* Reset the writeback head if it's enable.
*/
if (ixgbe->tx_head_wb_enable)
*tx_ring->tbd_head_wb = 0;
}
/*
* Add the tx control blocks in the pending list to
* the free list.
*/
}
}
/*
* ixgbe_tx_drain - Drain the tx rings to allow pending packets to be
* transmitted.
*/
static boolean_t
{
int i, j;
/*
* Wait for a specific time to allow pending tx packets
* to be transmitted.
*
* Check the counter tbd_free to see if transmission is done.
* No lock protection is needed here.
*
* Return B_TRUE if all pending packets have been transmitted;
* Otherwise return B_FALSE;
*/
for (i = 0; i < TX_DRAIN_TIME; i++) {
for (j = 0; j < ixgbe->num_tx_rings; j++) {
}
if (done)
break;
msec_delay(1);
}
return (done);
}
/*
* ixgbe_rx_drain - Wait for all rx buffers to be released by upper layer.
*/
static boolean_t
{
int i, j;
/*
* Polling the rx free list to check if those rx buffers held by
* the upper layer are released.
*
* Check the counter rcb_free to see if all pending buffers are
* released. No lock protection is needed here.
*
* Return B_TRUE if all pending buffers have been released;
* Otherwise return B_FALSE;
*/
for (i = 0; i < RX_DRAIN_TIME; i++) {
for (j = 0; j < ixgbe->num_rx_rings; j++) {
}
if (done)
break;
msec_delay(1);
}
return (done);
}
/*
*/
int
{
int i;
for (i = 0; i < ixgbe->num_rx_rings; i++)
for (i = 0; i < ixgbe->num_tx_rings; i++)
/*
* Start the chipset hardware
*/
goto start_failure;
}
goto start_failure;
}
/*
*/
/*
* Enable adapter interrupts
* The interrupts must be enabled after the driver state is START
*/
return (IXGBE_SUCCESS);
return (IXGBE_FAILURE);
}
/*
*/
void
{
int i;
/*
* Disable the adapter interrupts
*/
/*
* Drain the pending tx packets
*/
(void) ixgbe_tx_drain(ixgbe);
for (i = 0; i < ixgbe->num_rx_rings; i++)
for (i = 0; i < ixgbe->num_tx_rings; i++)
/*
* Stop the chipset hardware
*/
}
/*
*/
}
/*
*/
static int
{
/*
* Allocate memory space for rx rings
*/
return (IXGBE_FAILURE);
}
/*
* Allocate memory space for tx rings
*/
return (IXGBE_FAILURE);
}
return (IXGBE_SUCCESS);
}
/*
*/
static void
{
}
}
}
/*
*/
static void
{
/*
*
* 1. Setup the descriptor ring and the control block buffers;
* 3. Initialize software pointers/parameters for receive/transmit;
*/
}
static void
{
union ixgbe_adv_rx_desc *rbd;
int i;
for (i = 0; i < ixgbe->rx_ring_size; i++) {
}
/*
* Initialize the length register
*/
/*
* Initialize the base address registers
*/
/*
* Setup head & tail pointers
*/
/*
* Note: Considering the case that the chipset is being reset
* and there are still some buffers held by the upper layer,
* we should not reset the values of rcb_head, rcb_tail and
* rcb_free if the state is not IXGBE_UNKNOWN.
*/
}
/*
* Setup the Receive Descriptor Control Register (RXDCTL)
* PTHRESH=32 descriptors (half the internal cache)
* HTHRESH=0 descriptors (to minimize latency on fetch)
* WTHRESH defaults to 1 (writeback each descriptor)
*/
/*
* Setup the Split and Replication Receive Control Register.
* Set the rx buffer size and the advanced descriptor type.
*/
}
static void
{
int i;
/*
* Set filter control in FCTRL to accept broadcast packets and do
* not pass pause frames to host. Flow control settings are already
* in this register, so preserve them.
*/
/*
* Enable the receive unit. This must be done after filter
* control is set in FCTRL.
*/
| IXGBE_RXCTRL_DMBYPS); /* descriptor monitor bypass */
/*
* ixgbe_setup_rx_ring must be called after configuring RXCTRL
*/
for (i = 0; i < ixgbe->num_rx_rings; i++) {
}
/*
* The Max Frame Size in MHADD will be internally increased by four
* bytes if the packet has a VLAN field, so includes MTU, ethernet
* header and frame check sequence.
*/
+ ETHERFCSL) << IXGBE_MHADD_MFS_SHIFT;
/*
* Setup Jumbo Frame enable bit
*/
}
/*
* Hardware checksum settings
*/
if (ixgbe->rx_hcksum_enable) {
}
/*
* Setup RSS for multiple receive queues
*/
}
static void
{
/*
* Initialize the length register
*/
/*
* Initialize the base address registers
*/
/*
* setup TXDCTL(tx_ring->index)
*/
/*
* Setup head & tail pointers
*/
/*
* Setup head write-back
*/
if (ixgbe->tx_head_wb_enable) {
/*
* The memory of the head write-back is allocated using
* the extra tbd beyond the tail of the tbd ring.
*/
*tx_ring->tbd_head_wb = 0;
/* Set the head write-back enable bit */
/*
* Turn off relaxed ordering for head write back or it will
* cause problems with the tx recycling
*/
} else {
}
/*
* Note: Considering the case that the chipset is being reset,
* and there are still some tcb in the pending list,
* we should not reset the values of tcb_head, tcb_tail and
* tcb_free if the state is not IXGBE_UNKNOWN.
*/
}
/*
* Initialize hardware checksum offload settings
*/
}
static void
{
int i;
for (i = 0; i < ixgbe->num_tx_rings; i++) {
}
/*
* Enable CRC appending and TX padding (for short tx frames)
*/
}
/*
* ixgbe_setup_rss - Setup receive-side scaling feature.
*/
static void
{
/*
* Fill out redirection table
*/
reta = 0;
for (i = 0; i < 128; i++) {
if ((i & 3) == 3)
}
/*
* Fill out hash function seeds with a random constant
*/
for (i = 0; i < 10; i++) {
sizeof (uint32_t));
}
/*
* Enable RSS & perform hash on these packet types
*/
mrqc = IXGBE_MRQC_RSSEN |
/*
* Disable Packet Checksum to enable RSS for multiple receive queues.
* It is an adapter hardware limitation that Packet Checksum is
* mutually exclusive with RSS.
*/
}
/*
* ixgbe_init_unicst - Initialize the unicast addresses.
*/
static void
{
int slot;
/*
* Here we should consider two situations:
*
* 1. Chipset is initialized the first time
* Initialize the multiple unicast addresses, and
* save the default mac address.
*
* 2. Chipset is reset
* Recover the multiple unicast addresses from the
* software data structure to the RAR registers.
*/
if (!ixgbe->unicst_init) {
/*
* Initialize the multiple unicast addresses
*/
} else {
/*
* Recover the default mac address
*/
/* Re-configure the RAR registers */
}
}
/*
* ixgbe_unicst_set - Set the unicast address to the specified slot.
*/
int
{
/*
* Save the unicast address in the software data structure
*/
/*
* Set the unicast address to the RAR register
*/
return (EIO);
}
return (0);
}
/*
* ixgbe_multicst_add - Add a multicst address.
*/
int
{
if ((multiaddr[0] & 01) == 0) {
return (EINVAL);
}
return (ENOENT);
}
ixgbe->mcast_count++;
/*
* Update the multicast table in the hardware
*/
return (EIO);
}
return (0);
}
/*
* ixgbe_multicst_remove - Remove a multicst address.
*/
int
{
int i;
for (i = 0; i < ixgbe->mcast_count; i++) {
ETHERADDRL) == 0) {
for (i++; i < ixgbe->mcast_count; i++) {
ixgbe->mcast_table[i];
}
ixgbe->mcast_count--;
break;
}
}
/*
* Update the multicast table in the hardware
*/
return (EIO);
}
return (0);
}
/*
* ixgbe_setup_multicast - Setup multicast data structures.
*
* This routine initializes all of the multicast related structures
* and save them in the hardware registers.
*/
static void
{
/*
* Update the multicast addresses to the MTA registers
*/
}
/*
* ixgbe_get_conf - Get driver configurations set in driver.conf.
*
* This routine gets user-configured values out of the configuration
* file ixgbe.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
{
/*
* ixgbe driver supports the following user configurations:
*
* Jumbo frame configuration:
* default_mtu
*
* Ethernet flow control configuration:
* flow_control
*
* Multiple rings configurations:
* tx_queue_number
* tx_ring_size
* rx_queue_number
* rx_ring_size
*
* Call ixgbe_get_prop() to get the value for a specific
* configuration parameter.
*/
/*
* Jumbo frame configuration - max_frame_size controls host buffer
* allocation, so includes MTU, ethernet header, vlan tag and
* frame check sequence.
*/
sizeof (struct ether_vlan_header) + ETHERFCSL;
/*
* Ethernet flow control configuration
*/
if (flow_control == 3)
/*
* Multiple rings configurations
*/
/*
* Tunable used to force an interrupt type. The only use is
* for testing of the lesser interrupt types.
* 0 = don't force interrupt type
* 1 = force interrupt type MSIX
* 2 = force interrupt type MSI
* 3 = force interrupt type Legacy
*/
0, 1, DEFAULT_TX_HCKSUM_ENABLE);
0, 1, DEFAULT_RX_HCKSUM_ENABLE);
0, 1, DEFAULT_LSO_ENABLE);
0, 1, DEFAULT_TX_HEAD_WB_ENABLE);
/*
* ixgbe LSO needs the tx h/w checksum support.
* LSO will be disabled if tx h/w checksum is not
* enabled.
*/
}
}
/*
* ixgbe_get_prop - Get a property value out of the configuration file
* ixgbe.conf.
*
* Caller provides the 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 value;
/*
* Call ddi_prop_get_int() to read the conf settings
*/
return (value);
}
/*
* ixgbe_driver_setup_link - Using the link properties to setup the link.
*/
int
{
struct ixgbe_mac_info *mac;
struct ixgbe_phy_info *phy;
phy->autoneg_advertised = 0;
/*
* No half duplex support with 10Gb parts
*/
if (phy->autoneg_advertised == 0)
} else {
}
if (invalid) {
"autonegotiation with full link capabilities.");
}
if (setup_hw) {
return (IXGBE_FAILURE);
}
return (IXGBE_SUCCESS);
}
/*
* ixgbe_driver_link_check - Link status processing.
*/
static boolean_t
{
if (link_up) {
/*
* The Link is up, check whether it was marked as down earlier
*/
switch (speed) {
break;
break;
}
ixgbe->link_down_timeout = 0;
}
} else {
ixgbe->link_speed = 0;
ixgbe->link_duplex = 0;
}
} else if (ixgbe->link_down_timeout ==
}
}
}
return (link_changed);
}
/*
* ixgbe_local_timer - Driver watchdog function.
*
* This function will handle the transmit stall check, link status check and
* other routines.
*/
static void
ixgbe_local_timer(void *arg)
{
if (ixgbe_stall_check(ixgbe)) {
ixgbe->reset_count++;
}
}
/*
* ixgbe_stall_check - Check for transmit 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 ixgbe is assumed to
* have stalled and need to be reset.
*/
static boolean_t
{
int i;
return (B_FALSE);
/*
* If any tx ring is stalled, we'll reset the chipset
*/
for (i = 0; i < ixgbe->num_tx_rings; i++) {
if (tx_ring->recycle_fail > 0)
else
tx_ring->stall_watchdog = 0;
break;
}
}
if (result) {
tx_ring->stall_watchdog = 0;
tx_ring->recycle_fail = 0;
}
return (result);
}
/*
* is_valid_mac_addr - Check if the mac address is valid.
*/
static boolean_t
{
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
return (B_FALSE);
return (B_TRUE);
}
static boolean_t
{
#ifdef __sparc
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 (B_TRUE);
}
#else
#endif
return (B_TRUE);
}
#pragma inline(ixgbe_arm_watchdog_timer)
static void
{
/*
* Fire a watchdog timer
*/
}
/*
* ixgbe_enable_watchdog_timer - Enable and start the driver watchdog timer.
*/
void
{
if (!ixgbe->watchdog_enable) {
}
}
/*
* ixgbe_disable_watchdog_timer - Disable and stop the driver watchdog timer.
*/
void
{
ixgbe->watchdog_tid = 0;
if (tid != 0)
}
/*
* ixgbe_start_watchdog_timer - Start the driver watchdog timer.
*/
static void
{
if (ixgbe->watchdog_enable) {
if (!ixgbe->watchdog_start) {
}
}
}
/*
* ixgbe_restart_watchdog_timer - Restart the driver watchdog timer.
*/
static void
{
if (ixgbe->watchdog_start)
}
/*
* ixgbe_stop_watchdog_timer - Stop the driver watchdog timer.
*/
static void
{
ixgbe->watchdog_tid = 0;
if (tid != 0)
}
/*
* ixgbe_disable_adapter_interrupts - Disable all adapter interrupts.
*/
static void
{
/*
* mask all interrupts off
*/
/*
* for MSI-X, also disable autoclear
*/
}
}
/*
* ixgbe_enable_adapter_interrupts - Enable all hardware interrupts.
*/
static void
{
gpie = 0;
/*
* msi-x mode
*/
/* enable autoclear but not on bits 29:20 */
/* general purpose interrupt enable */
gpie |= (IXGBE_GPIE_MSIX_MODE |
/*
* non-msi-x mode
*/
} else {
/* disable autoclear, leave gpie at default */
eiac = 0;
}
}
/*
* ixgbe_loopback_ioctl - Loopback support.
*/
enum ioc_reply
{
return (IOC_INVAL);
default:
return (IOC_INVAL);
case LB_GET_INFO_SIZE:
size = sizeof (lb_info_sz_t);
return (IOC_INVAL);
break;
case LB_GET_INFO:
return (IOC_INVAL);
value = 0;
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);
}
/*
* ixgbe_set_loopback_mode - Setup loopback based on the loopback mode.
*/
static boolean_t
{
return (B_TRUE);
if (mode == IXGBE_LB_NONE) {
/*
* Reset the chip
*/
(void) ixgbe_reset(ixgbe);
return (B_TRUE);
}
switch (mode) {
default:
return (B_FALSE);
case IXGBE_LB_INTERNAL_MAC:
break;
}
return (B_TRUE);
}
/*
* ixgbe_set_internal_mac_loopback - Set the internal MAC loopback mode.
*/
static void
{
/*
* Setup MAC loopback
*/
reg |= IXGBE_HLREG0_LPBK;
reg &= ~IXGBE_AUTOC_LMS_MASK;
/*
* Disable Atlas Tx lanes to keep packets in loopback and not on wire
*/
&atlas);
atlas);
&atlas);
atlas);
&atlas);
atlas);
&atlas);
atlas);
}
}
#pragma inline(ixgbe_intr_rx_work)
/*
* ixgbe_intr_rx_work - RX processing of ISR.
*/
static void
{
}
#pragma inline(ixgbe_intr_tx_work)
/*
* ixgbe_intr_tx_work - TX processing of ISR.
*/
static void
{
/*
* Recycle the tx descriptors
*/
/*
* Schedule the re-transmit
*/
if (tx_ring->reschedule &&
}
}
#pragma inline(ixgbe_intr_other_work)
/*
* ixgbe_intr_other_work - Other processing of ISR.
*/
static void
{
/*
* Take care of link status change
*/
/*
* Get new phy state
*/
if (link_changed)
}
/*
* ixgbe_intr_legacy - Interrupt handler for legacy interrupts.
*/
static uint_t
{
return (DDI_INTR_UNCLAIMED);
}
/*
* Any bit set in eicr: claim this interrupt
*/
if (eicr) {
/*
* For legacy interrupt, we have only one interrupt,
* so we have only one rx ring and one tx ring enabled.
*/
/*
* For legacy interrupt, we can't differentiate
* between tx and rx, so always clean both
*/
if (eicr & IXGBE_EICR_RTX_QUEUE) {
/*
* Clean the rx descriptors
*/
/*
* Recycle the tx descriptors
*/
/*
* Schedule the re-transmit
*/
}
if (eicr & IXGBE_EICR_LSC) {
/* take care of link status change */
/* Get new phy state */
}
} else {
/*
* No interrupt cause bits set: don't claim this interrupt.
*/
}
/*
* Do the following work outside of the gen_lock
*/
if (tx_reschedule) {
}
if (link_changed)
return (result);
}
/*
* ixgbe_intr_msi - Interrupt handler for MSI.
*/
static uint_t
{
/*
* For MSI interrupt, we have only one vector,
* so we have only one rx ring and one tx ring enabled.
*/
/*
* For MSI interrupt, we can't differentiate
* between tx and rx, so always clean both.
*/
if (eicr & IXGBE_EICR_RTX_QUEUE) {
}
if (eicr & IXGBE_EICR_LSC) {
}
return (DDI_INTR_CLAIMED);
}
/*
* ixgbe_intr_rx - Interrupt handler for rx.
*/
static uint_t
{
int r_idx;
/*
* clean each rx ring that has its bit set in the map
*/
while (r_idx >= 0) {
}
return (DDI_INTR_CLAIMED);
}
/*
* ixgbe_intr_tx_other - Interrupt handler for both tx and other.
*
* Always look for Tx cleanup work. Only look for other work if the right
* bits are set in the Interrupt Cause Register.
*/
static uint_t
{
/*
* Always look for Tx cleanup work. We don't have separate
* transmit vectors, so we have only one tx ring enabled.
*/
/*
* Check for "other" causes.
*/
if (eicr & IXGBE_EICR_LSC) {
}
return (DDI_INTR_CLAIMED);
}
/*
* ixgbe_alloc_intrs - Allocate interrupts for the driver.
*
* Normal sequence is to try MSI-X; if not sucessful, try MSI;
* if not successful, try Legacy.
* ixgbe->intr_force can be used to force sequence to start with
* any of the 3 types.
*/
static int
{
int intr_types;
int rc;
/*
* Get supported interrupt types
*/
if (rc != DDI_SUCCESS) {
"Get supported interrupt types failed: %d", rc);
return (IXGBE_FAILURE);
}
/*
* Install MSI-X interrupts
*/
if ((intr_types & DDI_INTR_TYPE_MSIX) &&
if (rc == IXGBE_SUCCESS)
return (IXGBE_SUCCESS);
"Allocate MSI-X failed, trying MSI interrupts...");
}
/*
* MSI-X not used, force rings to 1
*/
"MSI-X not used, force rx and tx queue number to 1");
/*
* Install MSI interrupts
*/
if ((intr_types & DDI_INTR_TYPE_MSI) &&
if (rc == IXGBE_SUCCESS)
return (IXGBE_SUCCESS);
"Allocate MSI failed, trying Legacy interrupts...");
}
/*
* Install legacy interrupts
*/
if (intr_types & DDI_INTR_TYPE_FIXED) {
if (rc == IXGBE_SUCCESS)
return (IXGBE_SUCCESS);
"Allocate Legacy interrupts failed");
}
/*
* If none of the 3 types succeeded, return failure
*/
return (IXGBE_FAILURE);
}
/*
* ixgbe_alloc_intr_handles - Allocate interrupt handles.
*
* For legacy and MSI, only 1 handle is needed. For MSI-X,
* if fewer than 2 handles are available, return failure.
* Upon success, this sets the number of Rx rings to a number that
* matches the handles available for Rx interrupts.
*/
static int
{
int rc;
/*
* Currently only 1 tx ring is supported. More tx rings
* will be supported with future enhancement.
*/
"Use only 1 MSI-X vector for tx, "
"force tx queue number to 1");
}
switch (intr_type) {
case DDI_INTR_TYPE_FIXED:
minimum = 1;
break;
case DDI_INTR_TYPE_MSI:
minimum = 1;
break;
case DDI_INTR_TYPE_MSIX:
/*
* Best number of vectors for the adapter is
* # rx rings + # tx rings + 1 for other
* But currently we only support number of vectors of
* # rx rings + 1 for tx & other
*/
minimum = 2;
break;
default:
"invalid call to ixgbe_alloc_intr_handles(): %d\n",
return (IXGBE_FAILURE);
}
/*
* Get number of supported interrupts
*/
"Get interrupt number failed. Return: %d, count: %d",
return (IXGBE_FAILURE);
}
/*
* Get number of available interrupts
*/
"Get interrupt available number failed. "
return (IXGBE_FAILURE);
}
}
actual = 0;
/*
* Allocate an array of interrupt handles
*/
if (rc != DDI_SUCCESS) {
"return: %d, request: %d, actual: %d",
goto alloc_handle_fail;
}
/*
* Now we know the actual number of vectors. Here we assume that
* tx and other will share 1 vector and all remaining (must be at
* least 1 remaining) will be used for rx.
*/
actual);
goto alloc_handle_fail;
}
/*
* For MSI-X, actual might force us to reduce number of rx rings
*/
if (intr_type == DDI_INTR_TYPE_MSIX) {
"MSI-X vectors force Rx queue number to %d",
rx_rings);
}
}
/*
* Get priority for first vector, assume remaining are all the same
*/
if (rc != DDI_SUCCESS) {
"Get interrupt priority failed: %d", rc);
goto alloc_handle_fail;
}
if (rc != DDI_SUCCESS) {
"Get interrupt cap failed: %d", rc);
goto alloc_handle_fail;
}
return (IXGBE_SUCCESS);
return (IXGBE_FAILURE);
}
/*
* ixgbe_add_intr_handlers - Add interrupt handlers based on the interrupt type.
*
* Before adding the interrupt handlers, the interrupt vectors have
*/
static int
{
int vector;
int rc;
int i;
vector = 0;
case DDI_INTR_TYPE_MSIX:
/*
* Add interrupt handler for tx + other
*/
if (rc != DDI_SUCCESS) {
return (IXGBE_FAILURE);
}
vector++;
/*
* Add interrupt handler for each rx ring
*/
for (i = 0; i < ixgbe->num_rx_rings; i++) {
/*
* install pointer to vect_map[vector]
*/
if (rc != DDI_SUCCESS) {
"Add rx interrupt handler failed. "
"return: %d, rx ring: %d", rc, i);
(void) ddi_intr_remove_handler(
}
return (IXGBE_FAILURE);
}
vector++;
}
break;
case DDI_INTR_TYPE_MSI:
/*
* Add interrupt handlers for the only vector
*/
if (rc != DDI_SUCCESS) {
"Add MSI interrupt handler failed: %d", rc);
return (IXGBE_FAILURE);
}
vector++;
break;
case DDI_INTR_TYPE_FIXED:
/*
* Add interrupt handlers for the only vector
*/
if (rc != DDI_SUCCESS) {
"Add legacy interrupt handler failed: %d", rc);
return (IXGBE_FAILURE);
}
vector++;
break;
default:
return (IXGBE_FAILURE);
}
return (IXGBE_SUCCESS);
}
#pragma inline(ixgbe_map_rxring_to_vector)
/*
* ixgbe_map_rxring_to_vector - Map given rx ring to given interrupt vector.
*/
static void
{
/*
* Set bit in map
*/
/*
* Count bits set
*/
/*
* Remember bit position
*/
}
#pragma inline(ixgbe_map_txring_to_vector)
/*
* ixgbe_map_txring_to_vector - Map given tx ring to given interrupt vector.
*/
static void
{
/*
* Set bit in map
*/
/*
* Count bits set
*/
/*
* Remember bit position
*/
}
/*
* ixgbe_set_ivar - Set the given entry in the given interrupt vector
* allocation register (IVAR).
*/
static void
{
}
/*
* ixgbe_map_rings_to_vectors - Map descriptor rings to interrupt vectors.
*
* For msi-x, this currently implements only the scheme which is
* 1 vector for tx + other, 1 vector for each rx ring.
*/
static int
{
int i, vector = 0;
/* initialize vector map */
/*
* non-MSI-X case is very simple: all interrupts on vector 0
*/
ixgbe_map_rxring_to_vector(ixgbe, 0, 0);
ixgbe_map_txring_to_vector(ixgbe, 0, 0);
return (IXGBE_SUCCESS);
}
/*
*/
/*
* Map vector 0 to tx
*/
vect_remain--;
/*
* Map remaining vectors to rx rings
*/
for (i = 0; i < vect_remain; i++) {
}
return (IXGBE_SUCCESS);
}
/*
* ixgbe_setup_adapter_vector - Setup the adapter interrupt vector(s).
*
* vect_map[] structures
*/
static void
{
int r_idx; /* ring index */
int v_idx; /* vector index */
/*
* Clear any previous entries
*/
/*
* "Other" is always on vector 0
*/
/*
* For each interrupt vector, populate the IVAR table
*/
/*
* For each rx ring bit set
*/
while (r_idx >= 0) {
v_idx);
}
/*
* For each tx ring bit set
*/
while (r_idx >= 0) {
v_idx);
}
}
}
/*
* ixgbe_rem_intr_handlers - Remove the interrupt handlers.
*/
static void
{
int i;
int rc;
if (rc != DDI_SUCCESS) {
"Remove intr handler failed: %d", rc);
}
}
}
/*
* ixgbe_rem_intrs - Remove the allocated interrupts.
*/
static void
{
int i;
int rc;
if (rc != DDI_SUCCESS) {
"Free intr failed: %d", rc);
}
}
}
/*
* ixgbe_enable_intrs - Enable all the ddi interrupts.
*/
static int
{
int i;
int rc;
/*
* Enable interrupts
*/
/*
* Call ddi_intr_block_enable() for MSI
*/
if (rc != DDI_SUCCESS) {
"Enable block intr failed: %d", rc);
return (IXGBE_FAILURE);
}
} else {
/*
*/
if (rc != DDI_SUCCESS) {
"Enable intr failed: %d", rc);
return (IXGBE_FAILURE);
}
}
}
return (IXGBE_SUCCESS);
}
/*
* ixgbe_disable_intrs - Disable all the interrupts.
*/
static int
{
int i;
int rc;
/*
* Disable all interrupts
*/
if (rc != DDI_SUCCESS) {
"Disable block intr failed: %d", rc);
return (IXGBE_FAILURE);
}
} else {
if (rc != DDI_SUCCESS) {
"Disable intr failed: %d", rc);
return (IXGBE_FAILURE);
}
}
}
return (IXGBE_SUCCESS);
}
/*
* ixgbe_get_hw_state - Get and save parameters related to adapter hardware.
*/
static void
{
uint32_t pcs1g_anlp = 0;
ixgbe->param_lp_1000fdx_cap = 0;
ixgbe->param_lp_100fdx_cap = 0;
if (links & IXGBE_LINKS_PCS_1G_EN) {
}
}
/*
* ixgbe_get_driver_control - Notify that driver is in control of device.
*/
static void
{
/*
* Notify firmware that driver is in control of device
*/
}
/*
* ixgbe_release_driver_control - Notify that driver is no longer in control
* of device.
*/
static void
{
/*
* Notify firmware that driver is no longer in control of device
*/
}
/*
* ixgbe_atomic_reserve - Atomic decrease operation.
*/
int
{
/*
* ATOMICALLY
*/
do {
if (oldval < n)
return (-1);
return (newval);
}
/*
* ixgbe_mc_table_itr - Traverse the entries in the multicast table.
*/
static uint8_t *
{
return (addr);
}
/*
* FMA support
*/
int
{
return (de.fme_status);
}
int
{
return (de.fme_status);
}
/*
* ixgbe_fm_error_cb - The IO fault service error handling callback function.
*/
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 (ixgbe->fm_capabilities) {
/*
* Register capabilities with IO Fault Services
*/
/*
* Initialize pci ereport capabilities if ereport capable
*/
/*
* Register error callback if error callback capable
*/
ixgbe_fm_error_cb, (void*) ixgbe);
}
}
static void
{
/*
* Only unregister FMA capabilities if they are registered
*/
if (ixgbe->fm_capabilities) {
/*
* Release any resources allocated by pci_ereport_setup()
*/
/*
* Un-register error callback if error callback capable
*/
/*
* Unregister from IO Fault Service
*/
}
}
void
{
char buf[FM_MAX_CLASS];
}
}