mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
e1000: multi-queue defines/modification to data structures
defines/modifies data structures, function prototypes and changes to the driver rendering it capable of handling <n> tx/rx queues Signed-off-by: Mallikarjuna R Chilakala <mallikarjuna.chilakala@intel.com> Signed-off-by: Ganesh Venkatesan <ganesh.venkatesan@intel.com> Signed-off-by: John Ronciak <john.ronciak@intel.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
This commit is contained in:
parent
868d530994
commit
581d708eb4
@ -72,6 +72,10 @@
|
||||
#include <linux/mii.h>
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#ifdef CONFIG_E1000_MQ
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/smp.h>
|
||||
#endif
|
||||
|
||||
#define BAR_0 0
|
||||
#define BAR_1 1
|
||||
@ -168,7 +172,30 @@ struct e1000_buffer {
|
||||
struct e1000_ps_page { struct page *ps_page[MAX_PS_BUFFERS]; };
|
||||
struct e1000_ps_page_dma { uint64_t ps_page_dma[MAX_PS_BUFFERS]; };
|
||||
|
||||
struct e1000_desc_ring {
|
||||
struct e1000_tx_ring {
|
||||
/* pointer to the descriptor ring memory */
|
||||
void *desc;
|
||||
/* physical address of the descriptor ring */
|
||||
dma_addr_t dma;
|
||||
/* length of descriptor ring in bytes */
|
||||
unsigned int size;
|
||||
/* number of descriptors in the ring */
|
||||
unsigned int count;
|
||||
/* next descriptor to associate a buffer with */
|
||||
unsigned int next_to_use;
|
||||
/* next descriptor to check for DD status bit */
|
||||
unsigned int next_to_clean;
|
||||
/* array of buffer information structs */
|
||||
struct e1000_buffer *buffer_info;
|
||||
|
||||
struct e1000_buffer previous_buffer_info;
|
||||
spinlock_t tx_lock;
|
||||
uint16_t tdh;
|
||||
uint16_t tdt;
|
||||
uint64_t pkt;
|
||||
};
|
||||
|
||||
struct e1000_rx_ring {
|
||||
/* pointer to the descriptor ring memory */
|
||||
void *desc;
|
||||
/* physical address of the descriptor ring */
|
||||
@ -186,6 +213,10 @@ struct e1000_desc_ring {
|
||||
/* arrays of page information for packet split */
|
||||
struct e1000_ps_page *ps_page;
|
||||
struct e1000_ps_page_dma *ps_page_dma;
|
||||
|
||||
uint16_t rdh;
|
||||
uint16_t rdt;
|
||||
uint64_t pkt;
|
||||
};
|
||||
|
||||
#define E1000_DESC_UNUSED(R) \
|
||||
@ -227,9 +258,10 @@ struct e1000_adapter {
|
||||
unsigned long led_status;
|
||||
|
||||
/* TX */
|
||||
struct e1000_desc_ring tx_ring;
|
||||
struct e1000_buffer previous_buffer_info;
|
||||
spinlock_t tx_lock;
|
||||
struct e1000_tx_ring *tx_ring; /* One per active queue */
|
||||
#ifdef CONFIG_E1000_MQ
|
||||
struct e1000_tx_ring **cpu_tx_ring; /* per-cpu */
|
||||
#endif
|
||||
uint32_t txd_cmd;
|
||||
uint32_t tx_int_delay;
|
||||
uint32_t tx_abs_int_delay;
|
||||
@ -246,13 +278,26 @@ struct e1000_adapter {
|
||||
|
||||
/* RX */
|
||||
#ifdef CONFIG_E1000_NAPI
|
||||
boolean_t (*clean_rx) (struct e1000_adapter *adapter, int *work_done,
|
||||
int work_to_do);
|
||||
boolean_t (*clean_rx) (struct e1000_adapter *adapter,
|
||||
struct e1000_rx_ring *rx_ring,
|
||||
int *work_done, int work_to_do);
|
||||
#else
|
||||
boolean_t (*clean_rx) (struct e1000_adapter *adapter);
|
||||
boolean_t (*clean_rx) (struct e1000_adapter *adapter,
|
||||
struct e1000_rx_ring *rx_ring);
|
||||
#endif
|
||||
void (*alloc_rx_buf) (struct e1000_adapter *adapter);
|
||||
struct e1000_desc_ring rx_ring;
|
||||
void (*alloc_rx_buf) (struct e1000_adapter *adapter,
|
||||
struct e1000_rx_ring *rx_ring);
|
||||
struct e1000_rx_ring *rx_ring; /* One per active queue */
|
||||
#ifdef CONFIG_E1000_NAPI
|
||||
struct net_device *polling_netdev; /* One per active queue */
|
||||
#endif
|
||||
#ifdef CONFIG_E1000_MQ
|
||||
struct net_device **cpu_netdev; /* per-cpu */
|
||||
struct call_async_data_struct rx_sched_call_data;
|
||||
int cpu_for_queue[4];
|
||||
#endif
|
||||
int num_queues;
|
||||
|
||||
uint64_t hw_csum_err;
|
||||
uint64_t hw_csum_good;
|
||||
uint32_t rx_int_delay;
|
||||
@ -278,8 +323,8 @@ struct e1000_adapter {
|
||||
struct e1000_phy_stats phy_stats;
|
||||
|
||||
uint32_t test_icr;
|
||||
struct e1000_desc_ring test_tx_ring;
|
||||
struct e1000_desc_ring test_rx_ring;
|
||||
struct e1000_tx_ring test_tx_ring;
|
||||
struct e1000_rx_ring test_rx_ring;
|
||||
|
||||
|
||||
int msg_enable;
|
||||
|
@ -39,10 +39,10 @@ extern int e1000_up(struct e1000_adapter *adapter);
|
||||
extern void e1000_down(struct e1000_adapter *adapter);
|
||||
extern void e1000_reset(struct e1000_adapter *adapter);
|
||||
extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
|
||||
extern int e1000_setup_rx_resources(struct e1000_adapter *adapter);
|
||||
extern int e1000_setup_tx_resources(struct e1000_adapter *adapter);
|
||||
extern void e1000_free_rx_resources(struct e1000_adapter *adapter);
|
||||
extern void e1000_free_tx_resources(struct e1000_adapter *adapter);
|
||||
extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
|
||||
extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
|
||||
extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
|
||||
extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
|
||||
extern void e1000_update_stats(struct e1000_adapter *adapter);
|
||||
|
||||
struct e1000_stats {
|
||||
@ -576,8 +576,8 @@ e1000_get_ringparam(struct net_device *netdev,
|
||||
{
|
||||
struct e1000_adapter *adapter = netdev_priv(netdev);
|
||||
e1000_mac_type mac_type = adapter->hw.mac_type;
|
||||
struct e1000_desc_ring *txdr = &adapter->tx_ring;
|
||||
struct e1000_desc_ring *rxdr = &adapter->rx_ring;
|
||||
struct e1000_tx_ring *txdr = adapter->tx_ring;
|
||||
struct e1000_rx_ring *rxdr = adapter->rx_ring;
|
||||
|
||||
ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD :
|
||||
E1000_MAX_82544_RXD;
|
||||
@ -597,20 +597,40 @@ e1000_set_ringparam(struct net_device *netdev,
|
||||
{
|
||||
struct e1000_adapter *adapter = netdev_priv(netdev);
|
||||
e1000_mac_type mac_type = adapter->hw.mac_type;
|
||||
struct e1000_desc_ring *txdr = &adapter->tx_ring;
|
||||
struct e1000_desc_ring *rxdr = &adapter->rx_ring;
|
||||
struct e1000_desc_ring tx_old, tx_new, rx_old, rx_new;
|
||||
int err;
|
||||
struct e1000_tx_ring *txdr, *tx_old, *tx_new;
|
||||
struct e1000_rx_ring *rxdr, *rx_old, *rx_new;
|
||||
int i, err, tx_ring_size, rx_ring_size;
|
||||
|
||||
tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_queues;
|
||||
rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_queues;
|
||||
|
||||
if (netif_running(adapter->netdev))
|
||||
e1000_down(adapter);
|
||||
|
||||
tx_old = adapter->tx_ring;
|
||||
rx_old = adapter->rx_ring;
|
||||
|
||||
adapter->tx_ring = kmalloc(tx_ring_size, GFP_KERNEL);
|
||||
if (!adapter->tx_ring) {
|
||||
err = -ENOMEM;
|
||||
goto err_setup_rx;
|
||||
}
|
||||
memset(adapter->tx_ring, 0, tx_ring_size);
|
||||
|
||||
adapter->rx_ring = kmalloc(rx_ring_size, GFP_KERNEL);
|
||||
if (!adapter->rx_ring) {
|
||||
kfree(adapter->tx_ring);
|
||||
err = -ENOMEM;
|
||||
goto err_setup_rx;
|
||||
}
|
||||
memset(adapter->rx_ring, 0, rx_ring_size);
|
||||
|
||||
txdr = adapter->tx_ring;
|
||||
rxdr = adapter->rx_ring;
|
||||
|
||||
if((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
|
||||
return -EINVAL;
|
||||
|
||||
if(netif_running(adapter->netdev))
|
||||
e1000_down(adapter);
|
||||
|
||||
rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD);
|
||||
rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ?
|
||||
E1000_MAX_RXD : E1000_MAX_82544_RXD));
|
||||
@ -621,11 +641,16 @@ e1000_set_ringparam(struct net_device *netdev,
|
||||
E1000_MAX_TXD : E1000_MAX_82544_TXD));
|
||||
E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
|
||||
|
||||
for (i = 0; i < adapter->num_queues; i++) {
|
||||
txdr[i].count = txdr->count;
|
||||
rxdr[i].count = rxdr->count;
|
||||
}
|
||||
|
||||
if(netif_running(adapter->netdev)) {
|
||||
/* Try to get new resources before deleting old */
|
||||
if((err = e1000_setup_rx_resources(adapter)))
|
||||
if ((err = e1000_setup_all_rx_resources(adapter)))
|
||||
goto err_setup_rx;
|
||||
if((err = e1000_setup_tx_resources(adapter)))
|
||||
if ((err = e1000_setup_all_tx_resources(adapter)))
|
||||
goto err_setup_tx;
|
||||
|
||||
/* save the new, restore the old in order to free it,
|
||||
@ -635,8 +660,10 @@ e1000_set_ringparam(struct net_device *netdev,
|
||||
tx_new = adapter->tx_ring;
|
||||
adapter->rx_ring = rx_old;
|
||||
adapter->tx_ring = tx_old;
|
||||
e1000_free_rx_resources(adapter);
|
||||
e1000_free_tx_resources(adapter);
|
||||
e1000_free_all_rx_resources(adapter);
|
||||
e1000_free_all_tx_resources(adapter);
|
||||
kfree(tx_old);
|
||||
kfree(rx_old);
|
||||
adapter->rx_ring = rx_new;
|
||||
adapter->tx_ring = tx_new;
|
||||
if((err = e1000_up(adapter)))
|
||||
@ -645,7 +672,7 @@ e1000_set_ringparam(struct net_device *netdev,
|
||||
|
||||
return 0;
|
||||
err_setup_tx:
|
||||
e1000_free_rx_resources(adapter);
|
||||
e1000_free_all_rx_resources(adapter);
|
||||
err_setup_rx:
|
||||
adapter->rx_ring = rx_old;
|
||||
adapter->tx_ring = tx_old;
|
||||
@ -903,8 +930,8 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
|
||||
static void
|
||||
e1000_free_desc_rings(struct e1000_adapter *adapter)
|
||||
{
|
||||
struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
|
||||
struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
|
||||
struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
|
||||
struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
int i;
|
||||
|
||||
@ -946,8 +973,8 @@ e1000_free_desc_rings(struct e1000_adapter *adapter)
|
||||
static int
|
||||
e1000_setup_desc_rings(struct e1000_adapter *adapter)
|
||||
{
|
||||
struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
|
||||
struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
|
||||
struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
|
||||
struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
uint32_t rctl;
|
||||
int size, i, ret_val;
|
||||
@ -1347,8 +1374,8 @@ e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
|
||||
static int
|
||||
e1000_run_loopback_test(struct e1000_adapter *adapter)
|
||||
{
|
||||
struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
|
||||
struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
|
||||
struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
|
||||
struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
int i, j, k, l, lc, good_cnt, ret_val=0;
|
||||
unsigned long time;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -306,7 +306,8 @@ e1000_check_options(struct e1000_adapter *adapter)
|
||||
.def = E1000_DEFAULT_TXD,
|
||||
.arg = { .r = { .min = E1000_MIN_TXD }}
|
||||
};
|
||||
struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
|
||||
struct e1000_tx_ring *tx_ring = adapter->tx_ring;
|
||||
int i;
|
||||
e1000_mac_type mac_type = adapter->hw.mac_type;
|
||||
opt.arg.r.max = mac_type < e1000_82544 ?
|
||||
E1000_MAX_TXD : E1000_MAX_82544_TXD;
|
||||
@ -319,6 +320,8 @@ e1000_check_options(struct e1000_adapter *adapter)
|
||||
} else {
|
||||
tx_ring->count = opt.def;
|
||||
}
|
||||
for (i = 0; i < adapter->num_queues; i++)
|
||||
tx_ring[i].count = tx_ring->count;
|
||||
}
|
||||
{ /* Receive Descriptor Count */
|
||||
struct e1000_option opt = {
|
||||
@ -329,7 +332,8 @@ e1000_check_options(struct e1000_adapter *adapter)
|
||||
.def = E1000_DEFAULT_RXD,
|
||||
.arg = { .r = { .min = E1000_MIN_RXD }}
|
||||
};
|
||||
struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
|
||||
struct e1000_rx_ring *rx_ring = adapter->rx_ring;
|
||||
int i;
|
||||
e1000_mac_type mac_type = adapter->hw.mac_type;
|
||||
opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
|
||||
E1000_MAX_82544_RXD;
|
||||
@ -342,6 +346,8 @@ e1000_check_options(struct e1000_adapter *adapter)
|
||||
} else {
|
||||
rx_ring->count = opt.def;
|
||||
}
|
||||
for (i = 0; i < adapter->num_queues; i++)
|
||||
rx_ring[i].count = rx_ring->count;
|
||||
}
|
||||
{ /* Checksum Offload Enable/Disable */
|
||||
struct e1000_option opt = {
|
||||
|
Loading…
Reference in New Issue
Block a user