Commit 047e0030 authored by Alexander Duyck's avatar Alexander Duyck Committed by David S. Miller

igb: add new data structure for handling interrupts and NAPI

Add a new igb_q_vector data structure to handle interrupts and NAPI.  This
helps to abstract the rings away from the adapter struct.  In addition it
allows for a bit of consolidation since a tx and rx ring can share a
q_vector.
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 678b77e2
...@@ -55,6 +55,8 @@ struct igb_adapter; ...@@ -55,6 +55,8 @@ struct igb_adapter;
#define IGB_DEFAULT_ITR 3 /* dynamic */ #define IGB_DEFAULT_ITR 3 /* dynamic */
#define IGB_MAX_ITR_USECS 10000 #define IGB_MAX_ITR_USECS 10000
#define IGB_MIN_ITR_USECS 10 #define IGB_MIN_ITR_USECS 10
#define NON_Q_VECTORS 1
#define MAX_Q_VECTORS 8
/* Transmit and receive queues */ /* Transmit and receive queues */
#define IGB_MAX_RX_QUEUES (adapter->vfs_allocated_count ? \ #define IGB_MAX_RX_QUEUES (adapter->vfs_allocated_count ? \
...@@ -149,8 +151,25 @@ struct igb_rx_queue_stats { ...@@ -149,8 +151,25 @@ struct igb_rx_queue_stats {
u64 drops; u64 drops;
}; };
struct igb_ring { struct igb_q_vector {
struct igb_adapter *adapter; /* backlink */ struct igb_adapter *adapter; /* backlink */
struct igb_ring *rx_ring;
struct igb_ring *tx_ring;
struct napi_struct napi;
u32 eims_value;
u16 cpu;
u16 itr_val;
u8 set_itr;
u8 itr_shift;
void __iomem *itr_register;
char name[IFNAMSIZ + 9];
};
struct igb_ring {
struct igb_q_vector *q_vector; /* backlink to q_vector */
void *desc; /* descriptor ring memory */ void *desc; /* descriptor ring memory */
dma_addr_t dma; /* phys address of the ring */ dma_addr_t dma; /* phys address of the ring */
unsigned int size; /* length of desc. ring in bytes */ unsigned int size; /* length of desc. ring in bytes */
...@@ -161,13 +180,9 @@ struct igb_ring { ...@@ -161,13 +180,9 @@ struct igb_ring {
u16 tail; u16 tail;
struct igb_buffer *buffer_info; /* array of buffer info structs */ struct igb_buffer *buffer_info; /* array of buffer info structs */
u32 eims_value; u8 queue_index;
u32 itr_val; u8 reg_idx;
u16 itr_register;
u16 cpu;
u16 queue_index;
u16 reg_idx;
unsigned int total_bytes; unsigned int total_bytes;
unsigned int total_packets; unsigned int total_packets;
...@@ -181,13 +196,8 @@ struct igb_ring { ...@@ -181,13 +196,8 @@ struct igb_ring {
struct { struct {
struct igb_rx_queue_stats rx_stats; struct igb_rx_queue_stats rx_stats;
u64 rx_queue_drops; u64 rx_queue_drops;
struct napi_struct napi;
int set_itr;
struct igb_ring *buddy;
}; };
}; };
char name[IFNAMSIZ + 5];
}; };
#define E1000_RX_DESC_ADV(R, i) \ #define E1000_RX_DESC_ADV(R, i) \
...@@ -254,7 +264,6 @@ struct igb_adapter { ...@@ -254,7 +264,6 @@ struct igb_adapter {
/* OS defined structs */ /* OS defined structs */
struct net_device *netdev; struct net_device *netdev;
struct napi_struct napi;
struct pci_dev *pdev; struct pci_dev *pdev;
struct cyclecounter cycles; struct cyclecounter cycles;
struct timecounter clock; struct timecounter clock;
...@@ -272,6 +281,9 @@ struct igb_adapter { ...@@ -272,6 +281,9 @@ struct igb_adapter {
struct igb_ring test_rx_ring; struct igb_ring test_rx_ring;
int msg_enable; int msg_enable;
unsigned int num_q_vectors;
struct igb_q_vector *q_vector[MAX_Q_VECTORS];
struct msix_entry *msix_entries; struct msix_entry *msix_entries;
u32 eims_enable_mask; u32 eims_enable_mask;
u32 eims_other; u32 eims_other;
......
...@@ -1907,7 +1907,6 @@ static int igb_set_coalesce(struct net_device *netdev, ...@@ -1907,7 +1907,6 @@ static int igb_set_coalesce(struct net_device *netdev,
struct ethtool_coalesce *ec) struct ethtool_coalesce *ec)
{ {
struct igb_adapter *adapter = netdev_priv(netdev); struct igb_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
int i; int i;
if ((ec->rx_coalesce_usecs > IGB_MAX_ITR_USECS) || if ((ec->rx_coalesce_usecs > IGB_MAX_ITR_USECS) ||
...@@ -1925,8 +1924,11 @@ static int igb_set_coalesce(struct net_device *netdev, ...@@ -1925,8 +1924,11 @@ static int igb_set_coalesce(struct net_device *netdev,
adapter->itr = adapter->itr_setting; adapter->itr = adapter->itr_setting;
} }
for (i = 0; i < adapter->num_rx_queues; i++) for (i = 0; i < adapter->num_q_vectors; i++) {
wr32(adapter->rx_ring[i].itr_register, adapter->itr); struct igb_q_vector *q_vector = adapter->q_vector[i];
q_vector->itr_val = adapter->itr;
q_vector->set_itr = 1;
}
return 0; return 0;
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment