Esempio n. 1
0
static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
{
	u8 err = 0;
	struct ixgbe_adapter *adapter = netdev_priv(netdev);

	DPRINTK(DRV, INFO, "Set DCB Admin Mode.\n");

	if (state > 0) {
		/* Turn on DCB */
		if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
			goto out;

		if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) {
			DPRINTK(DRV, ERR, "Enable failed, needs MSI-X\n");
			err = 1;
			goto out;
		}

		if (netif_running(netdev))
			netdev->netdev_ops->ndo_stop(netdev);
		ixgbe_reset_interrupt_capability(adapter);
		ixgbe_napi_del_all(adapter);
		INIT_LIST_HEAD(&netdev->napi_list);
		kfree(adapter->tx_ring);
		kfree(adapter->rx_ring);
		adapter->tx_ring = NULL;
		adapter->rx_ring = NULL;
		netdev->select_queue = &ixgbe_dcb_select_queue;

		adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
		adapter->flags |= IXGBE_FLAG_DCB_ENABLED;
		ixgbe_init_interrupt_scheme(adapter);
		if (netif_running(netdev))
			netdev->netdev_ops->ndo_open(netdev);
	} else {
		/* Turn off DCB */
		if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
			if (netif_running(netdev))
				netdev->netdev_ops->ndo_stop(netdev);
			ixgbe_reset_interrupt_capability(adapter);
			ixgbe_napi_del_all(adapter);
			INIT_LIST_HEAD(&netdev->napi_list);
			kfree(adapter->tx_ring);
			kfree(adapter->rx_ring);
			adapter->tx_ring = NULL;
			adapter->rx_ring = NULL;
			netdev->select_queue = NULL;

			adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
			adapter->flags |= IXGBE_FLAG_RSS_ENABLED;
			ixgbe_init_interrupt_scheme(adapter);
			if (netif_running(netdev))
				netdev->netdev_ops->ndo_open(netdev);
		}
	}
out:
	return err;
}
Esempio n. 2
0
/**
 * ixgbe_init_interrupt_scheme - Determine proper interrupt scheme
 * @adapter: board private structure to initialize
 *
 * We determine which interrupt scheme to use based on...
 * - Kernel support (MSI, MSI-X)
 *   - which can be user-defined (via MODULE_PARAM)
 * - Hardware queue count (num_*_queues)
 *   - defined by miscellaneous hardware support/features (RSS, etc.)
 **/
int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter)
{
	int err;

	/* Number of supported queues */
	ixgbe_set_num_queues(adapter);

	/* Set interrupt mode */
	ixgbe_set_interrupt_capability(adapter);

	err = ixgbe_alloc_q_vectors(adapter);
	if (err) {
		e_dev_err("Unable to allocate memory for queue vectors\n");
		goto err_alloc_q_vectors;
	}

	ixgbe_cache_ring_register(adapter);

	e_dev_info("Multiqueue %s: Rx Queue count = %u, Tx Queue count = %u\n",
		   (adapter->num_rx_queues > 1) ? "Enabled" : "Disabled",
		   adapter->num_rx_queues, adapter->num_tx_queues);

	set_bit(__IXGBE_DOWN, &adapter->state);

	return 0;

err_alloc_q_vectors:
	ixgbe_reset_interrupt_capability(adapter);
	return err;
}
Esempio n. 3
0
/**
 * ixgbe_clear_interrupt_scheme - Clear the current interrupt scheme settings
 * @adapter: board private structure to clear interrupt scheme on
 *
 * We go through and clear interrupt specific resources and reset the structure
 * to pre-load conditions
 **/
void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter)
{
	adapter->num_tx_queues = 0;
	adapter->num_rx_queues = 0;

	ixgbe_free_q_vectors(adapter);
	ixgbe_reset_interrupt_capability(adapter);
}
static int ixgbe_set_ringparam(struct net_device *netdev,
                               struct ethtool_ringparam *ring)
{
	struct ixgbe_adapter *adapter = netdev_priv(netdev);
	struct ixgbe_ring *temp_ring;
	int i, err;
	u32 new_rx_count, new_tx_count;

	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
		return -EINVAL;

	new_rx_count = max(ring->rx_pending, (u32)IXGBE_MIN_RXD);
	new_rx_count = min(new_rx_count, (u32)IXGBE_MAX_RXD);
	new_rx_count = ALIGN(new_rx_count, IXGBE_REQ_RX_DESCRIPTOR_MULTIPLE);

	new_tx_count = max(ring->tx_pending, (u32)IXGBE_MIN_TXD);
	new_tx_count = min(new_tx_count, (u32)IXGBE_MAX_TXD);
	new_tx_count = ALIGN(new_tx_count, IXGBE_REQ_TX_DESCRIPTOR_MULTIPLE);

	if ((new_tx_count == adapter->tx_ring->count) &&
	    (new_rx_count == adapter->rx_ring->count)) {
		/* nothing to do */
		return 0;
	}

	temp_ring = kcalloc(adapter->num_tx_queues,
	                    sizeof(struct ixgbe_ring), GFP_KERNEL);
	if (!temp_ring)
		return -ENOMEM;

	while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
		msleep(1);

	if (new_tx_count != adapter->tx_ring->count) {
		for (i = 0; i < adapter->num_tx_queues; i++) {
			temp_ring[i].count = new_tx_count;
			err = ixgbe_setup_tx_resources(adapter, &temp_ring[i]);
			if (err) {
				while (i) {
					i--;
					ixgbe_free_tx_resources(adapter,
					                        &temp_ring[i]);
				}
				goto err_setup;
			}
			temp_ring[i].v_idx = adapter->tx_ring[i].v_idx;
		}
		if (netif_running(netdev))
			netdev->netdev_ops->ndo_stop(netdev);
		ixgbe_reset_interrupt_capability(adapter);
		ixgbe_napi_del_all(adapter);
		INIT_LIST_HEAD(&netdev->napi_list);
		kfree(adapter->tx_ring);
		adapter->tx_ring = temp_ring;
		temp_ring = NULL;
		adapter->tx_ring_count = new_tx_count;
	}

	temp_ring = kcalloc(adapter->num_rx_queues,
	                    sizeof(struct ixgbe_ring), GFP_KERNEL);
	if (!temp_ring) {
		if (netif_running(netdev))
			netdev->netdev_ops->ndo_open(netdev);
		return -ENOMEM;
	}

	if (new_rx_count != adapter->rx_ring->count) {
		for (i = 0; i < adapter->num_rx_queues; i++) {
			temp_ring[i].count = new_rx_count;
			err = ixgbe_setup_rx_resources(adapter, &temp_ring[i]);
			if (err) {
				while (i) {
					i--;
					ixgbe_free_rx_resources(adapter,
					                        &temp_ring[i]);
				}
				goto err_setup;
			}
			temp_ring[i].v_idx = adapter->rx_ring[i].v_idx;
		}
		if (netif_running(netdev))
			netdev->netdev_ops->ndo_stop(netdev);
		ixgbe_reset_interrupt_capability(adapter);
		ixgbe_napi_del_all(adapter);
		INIT_LIST_HEAD(&netdev->napi_list);
		kfree(adapter->rx_ring);
		adapter->rx_ring = temp_ring;
		temp_ring = NULL;

		adapter->rx_ring_count = new_rx_count;
	}

	/* success! */
	err = 0;
err_setup:
	ixgbe_init_interrupt_scheme(adapter);
	if (netif_running(netdev))
		netdev->netdev_ops->ndo_open(netdev);

	clear_bit(__IXGBE_RESETTING, &adapter->state);
	return err;
}