igb: update napi polling to consolidate function and return correct values
Subsystems (2)
PATCH 1/5 igb: update napi polling to consolidate function and return correct values
From: Alexander Duyck <[email protected]>
igb is currently not returning the correct values for napi. In addition it is doing more work than necessary since it will not exit polling until work_done is equal to zero.
This patch makes the following changes:
1. Consolidates msi-x and non-msi polling routines.
2. Corrects return values for polling routines.
---
drivers/net/igb/igb_main.c | 77 +++++++++++++++++--------------------------- 1 files changed, 30 insertions(+), 47 deletions(-)
drivers/net/igb/igb_main.c +30 -47
@@ -106,7 +106,6 @@ static irqreturn_t igb_intr_msi(int irq, void *);static irqreturn_t igb_msix_other (int irq,void *);static irqreturn_t igb_msix_rx (int irq,void *);static irqreturn_t igb_msix_tx (int irq,void *); -static int igb_clean_rx_ring_msix (struct napi_struct *,int );#ifdef CONFIG_IGB_DCA static void igb_update_rx_dca (struct igb_ring *);static void igb_update_tx_dca (struct igb_ring *);
@@ -3688,50 +3687,35 @@ static irqreturn_t igb_intr(int irq, void *data)return IRQ_HANDLED ; } -/** -* igb_poll - NAPI Rx polling callback -* @napi: napi polling structure -* @budget: count of how many packets we should handle -**/ -static int igb_poll (struct napi_struct *napi,int budget) +static inline void igb_rx_irq_enable (struct igb_ring *rx_ring) { - struct igb_ring *rx_ring = container_of(napi, struct igb_ring, napi);struct igb_adapter *adapter = rx_ring->adapter; -struct net_device *netdev = adapter->netdev; -int tx_clean_complete, work_done =0 ; - -/* this poll routine only supports one tx and one rx queue */ -#ifdef CONFIG_IGB_DCA -if (adapter->flags &IGB_FLAG_DCA_ENABLED ) -igb_update_tx_dca (&adapter->tx_ring[0 ]); -#endif - tx_clean_complete =igb_clean_tx_irq (&adapter->tx_ring[0 ]); - -#ifdef CONFIG_IGB_DCA -if (adapter->flags &IGB_FLAG_DCA_ENABLED ) -igb_update_rx_dca (&adapter->rx_ring[0 ]); -#endif -igb_clean_rx_irq_adv (&adapter->rx_ring[0 ], &work_done, budget); +struct e1000_hw *hw = &adapter->hw; -/* If no Tx and not enough Rx work done, exit the polling mode */ -if ((tx_clean_complete && (work_done < budget)) || - !netif_running (netdev)) { -if (adapter->itr_setting &3 ) +if (adapter->itr_setting &3 ) { +if (adapter->num_rx_queues ==1 )igb_set_itr (adapter); -napi_complete (napi); -if (!test_bit (__IGB_DOWN, &adapter->state)) -igb_irq_enable (adapter); -return 0 ; +else +igb_update_ring_itr (rx_ring); } -return 1 ; +if (!test_bit (__IGB_DOWN, &adapter->state)) { +if (adapter->msix_entries) +wr32 (E1000_EIMS , rx_ring->eims_value); +else +igb_irq_enable (adapter); + } } -static int igb_clean_rx_ring_msix (struct napi_struct *napi,int budget) +/** +* igb_poll - NAPI Rx polling callback +* @napi: napi polling structure +* @budget: count of how many packets we should handle +**/ +static int igb_poll (struct napi_struct *napi,int budget) { struct igb_ring *rx_ring = container_of(napi, struct igb_ring, napi);struct igb_adapter *adapter = rx_ring->adapter; -struct e1000_hw *hw = &adapter->hw;struct net_device *netdev = adapter->netdev;int work_done =0 ;
@@ -3741,23 +3725,22 @@ static int igb_clean_rx_ring_msix(struct napi_struct *napi, int budget)#endif igb_clean_rx_irq_adv (rx_ring, &work_done, budget); +if (rx_ring->buddy) { +#ifdef CONFIG_IGB_DCA +if (adapter->flags &IGB_FLAG_DCA_ENABLED ) +igb_update_tx_dca (rx_ring->buddy); +#endif +if (!igb_clean_tx_irq (rx_ring->buddy)) + work_done = budget; + } +/* If not enough Rx work done, exit the polling mode */ -if ((work_done ==0 ) || !netif_running (netdev)) { +if ((work_done < budget) || !netif_running (netdev)) {napi_complete (napi); - -if (adapter->itr_setting &3 ) { -if (adapter->num_rx_queues ==1 ) -igb_set_itr (adapter); -else -igb_update_ring_itr (rx_ring); - } -if (!test_bit (__IGB_DOWN, &adapter->state)) -wr32 (E1000_EIMS , rx_ring->eims_value); - -return 0 ; +igb_rx_irq_enable (rx_ring); } -return 1 ; +return work_done; }/**
PATCH 2/5 igb: add vfs_allocated_count as placeholder for number of vfs
From: Alexander Duyck <[email protected]>
This is the first step in supporting sr-iov. The vf_allocated_count value will be 0 until we actually have vfs present. In the meantime it represents an offset value for the start of the queues.
---
drivers/net/igb/igb.h | 9 ++++++--- drivers/net/igb/igb_main.c | 17 +++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/igb/igb.h +6 -3
@@ -57,8 +57,10 @@ struct igb_adapter;#define IGB_MIN_ITR_USECS 10/* Transmit and receive queues */ -#define IGB_MAX_RX_QUEUES 4 -#define IGB_MAX_TX_QUEUES 4 +#define IGB_MAX_RX_QUEUES (adapter->vfs_allocated_count ? \ + (adapter->vfs_allocated_count > 6 ? 1 : 2) : 4) +#define IGB_MAX_TX_QUEUES IGB_MAX_RX_QUEUES +#define IGB_ABS_MAX_TX_QUEUES 4/* RX descriptor control thresholds. * PTHRESH - MAC will consider prefetch if it has fewer than this number of
@@ -267,9 +269,10 @@ struct igb_adapter {unsigned int flags;u32 eeprom_wol; -struct igb_ring *multi_tx_table[IGB_MAX_TX_QUEUES ]; +struct igb_ring *multi_tx_table[IGB_ABS_MAX_TX_QUEUES ];unsigned int tx_ring_count;unsigned int rx_ring_count; +unsigned int vfs_allocated_count; };#define IGB_FLAG_HAS_MSI (1 << 0)
drivers/net/igb/igb_main.c +11 -6
@@ -312,6 +312,7 @@ module_exit(igb_exit_module);static void igb_cache_ring_register (struct igb_adapter *adapter) {int i; +unsigned int rbase_offset = adapter->vfs_allocated_count;switch (adapter->hw.mac.type) {case e1000_82576:
@@ -321,9 +322,11 @@ static void igb_cache_ring_register(struct igb_adapter *adapter)* and continue consuming queues in the same sequence */ for (i =0 ; i < adapter->num_rx_queues; i++) - adapter->rx_ring[i].reg_idx =Q_IDX_82576 (i); + adapter->rx_ring[i].reg_idx = rbase_offset + +Q_IDX_82576 (i);for (i =0 ; i < adapter->num_tx_queues; i++) - adapter->tx_ring[i].reg_idx =Q_IDX_82576 (i); + adapter->tx_ring[i].reg_idx = rbase_offset + +Q_IDX_82576 (i);break ;case e1000_82575:default :
@@ -423,7 +426,7 @@ static void igb_assign_vector(struct igb_adapter *adapter, int rx_queue,a vector number along with a "valid" bit. Sadly, the layout of the table is somewhat counterintuitive. */ if (rx_queue >IGB_N0_QUEUE ) { - index = (rx_queue >>1 ); + index = (rx_queue >>1 ) + adapter->vfs_allocated_count; ivar =array_rd32 (E1000_IVAR0 , index);if (rx_queue &0x1 ) {/* vector goes into third byte of register */
@@ -438,7 +441,7 @@ static void igb_assign_vector(struct igb_adapter *adapter, int rx_queue,array_wr32 (E1000_IVAR0 , index, ivar); }if (tx_queue >IGB_N0_QUEUE ) { - index = (tx_queue >>1 ); + index = (tx_queue >>1 ) + adapter->vfs_allocated_count; ivar =array_rd32 (E1000_IVAR0 , index);if (tx_queue &0x1 ) {/* vector goes into high byte of register */
@@ -1157,7 +1160,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,pci_save_state (pdev); err = -ENOMEM ; - netdev =alloc_etherdev_mq (sizeof (struct igb_adapter ),IGB_MAX_TX_QUEUES ); + netdev =alloc_etherdev_mq (sizeof (struct igb_adapter ), +IGB_ABS_MAX_TX_QUEUES );if (!netdev) goto err_alloc_etherdev;
@@ -2029,6 +2033,7 @@ static void igb_configure_rx(struct igb_adapter *adapter)writel (reta.dword, hw->hw_addr +E1000_RETA (0 ) + (j & ~3 )); } + mrqc =E1000_MRQC_ENABLE_RSS_4Q ;/* Fill out hash function seeds */
@@ -3150,7 +3155,7 @@ static int igb_xmit_frame_adv(struct sk_buff *skb, struct net_device *netdev)struct igb_ring *tx_ring;int r_idx =0 ; - r_idx = skb->queue_mapping & (IGB_MAX_TX_QUEUES -1 ); + r_idx = skb->queue_mapping & (IGB_ABS_MAX_TX_QUEUES -1 ); tx_ring = adapter->multi_tx_table[r_idx];/* This goes back to the question of how to logically map a tx queue
Re: [net-next PATCH 2/5] igb: add vfs_allocated_count as placeholder for number of vfs
From: Jeff Kirsher <[email protected]>
Date: Thu, 19 Feb 2009 20:39:23 -0800
Quoted 6 lines
This is the first step in supporting sr-iov. The
vf_allocated_countvalue will be 0 until we actually have vfs present. In the meantime it represents an offset value for the start of the queues.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 3/5 igb: add pf side of VMDq support
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
Add the pf portion of vmdq support. This provides enough support so that VMDq is enabled, and the pf is functional without enabling vfs.
---
drivers/net/igb/e1000_82575.h | 26 ++++++ drivers/net/igb/e1000_defines.h | 2 drivers/net/igb/e1000_regs.h | 7 +- drivers/net/igb/igb.h | 3 - drivers/net/igb/igb_ethtool.c | 2 drivers/net/igb/igb_main.c | 174 ++++++++++++++++++++++++++++++++++++--- 6 files changed, 195 insertions(+), 19 deletions(-)
drivers/net/igb/e1000_82575.h +26 -0
@@ -40,8 +40,11 @@ extern void igb_rx_fifo_flush_82575(struct e1000_hw *hw);#define E1000_SRRCTL_BSIZEHDRSIZE_SHIFT 2/* Shift _left_ */ #define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF 0x02000000#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS 0x0A000000 +#define E1000_SRRCTL_DROP_EN 0x80000000#define E1000_MRQC_ENABLE_RSS_4Q 0x00000002 +#define E1000_MRQC_ENABLE_VMDQ 0x00000003 +#define E1000_MRQC_ENABLE_VMDQ_RSS_2Q 0x00000005#define E1000_MRQC_RSS_FIELD_IPV4_UDP 0x00400000#define E1000_MRQC_RSS_FIELD_IPV6_UDP 0x00800000#define E1000_MRQC_RSS_FIELD_IPV6_UDP_EX 0x01000000
@@ -159,4 +162,27 @@ struct e1000_adv_tx_context_desc {#define E1000_DCA_TXCTRL_CPUID_SHIFT 24/* Tx CPUID now in the last byte */ #define E1000_DCA_RXCTRL_CPUID_SHIFT 24/* Rx CPUID now in the last byte */ +/* Easy defines for setting default pool, would normally be left a zero */ +#define E1000_VT_CTL_DEFAULT_POOL_SHIFT 7 +#define E1000_VT_CTL_DEFAULT_POOL_MASK (0x7 << E1000_VT_CTL_DEFAULT_POOL_SHIFT) + +/* Other useful VMD_CTL register defines */ +#define E1000_VT_CTL_IGNORE_MAC (1 << 28) +#define E1000_VT_CTL_DISABLE_DEF_POOL (1 << 29) +#define E1000_VT_CTL_VM_REPL_EN (1 << 30) + +/* Per VM Offload register setup */ +#define E1000_VMOLR_RLPML_MASK 0x00003FFF/* Long Packet Maximum Length mask */ +#define E1000_VMOLR_LPE 0x00010000/* Accept Long packet */ +#define E1000_VMOLR_RSSE 0x00020000/* Enable RSS */ +#define E1000_VMOLR_AUPE 0x01000000/* Accept untagged packets */ +#define E1000_VMOLR_ROMPE 0x02000000/* Accept overflow multicast */ +#define E1000_VMOLR_ROPE 0x04000000/* Accept overflow unicast */ +#define E1000_VMOLR_BAM 0x08000000/* Accept Broadcast packets */ +#define E1000_VMOLR_MPME 0x10000000/* Multicast promiscuous mode */ +#define E1000_VMOLR_STRVLAN 0x40000000/* Vlan stripping enable */ + +#define ALL_QUEUES 0xFFFF + +#endif
drivers/net/igb/e1000_defines.h +2 -0
@@ -399,6 +399,8 @@#define E1000_RAH_AV 0x80000000/* Receive descriptor valid */ #define E1000_RAL_MAC_ADDR_LEN 4#define E1000_RAH_MAC_ADDR_LEN 2 +#define E1000_RAH_POOL_MASK 0x03FC0000 +#define E1000_RAH_POOL_1 0x00040000/* Error Codes */ #define E1000_ERR_NVM 1
drivers/net/igb/e1000_regs.h +6 -1
@@ -292,7 +292,7 @@ enum {#define E1000_RAH (_i) (((_i) <= 15) ? (0x05404 + ((_i) * 8)) : \ (0x054E4 + ((_i - 16) * 8)))#define E1000_VFTA 0x05600/* VLAN Filter Table Array - RW Array */ -#define E1000_VMD_CTL 0x0581C/* VMDq Control - RW */ +#define E1000_VT_CTL 0x0581C/* VMDq Control - RW */ #define E1000_WUC 0x05800/* Wakeup Control - RW */ #define E1000_WUFC 0x05808/* Wakeup Filter Control - RW */ #define E1000_WUS 0x05810/* Wakeup Status - RO */
@@ -320,6 +320,11 @@ enum {#define E1000_RETA (_i) (0x05C00 + ((_i) * 4))#define E1000_RSSRK (_i) (0x05C80 + ((_i) * 4))/* RSS Random Key - RW Array */ +/* VT Registers */ +#define E1000_QDE 0x02408/* Queue Drop Enable - RW */ +/* These act per VF so an array friendly macro is used */ +#define E1000_VMOLR (_n) (0x05AD0 + (4 * (_n))) +#define wr32 (reg, value) (writel(value, hw->hw_addr + reg))#define rd32 (reg) (readl(hw->hw_addr + reg))#define wrfl () ((void)rd32(E1000_STATUS))
drivers/net/igb/igb.h +1 -2
@@ -88,8 +88,7 @@ struct igb_adapter;#define IGB_RXBUFFER_2048 2048#define IGB_RXBUFFER_16384 16384 -/* Packet Buffer allocations */ - +#define MAX_STD_JUMBO_FRAME_SIZE 9234/* How many Tx Descriptors do we need to call netif_wake_queue ? */ #define IGB_TX_QUEUE_WAKE 16
drivers/net/igb/igb_ethtool.c +1 -1
@@ -398,7 +398,7 @@ static void igb_get_regs(struct net_device *netdev, regs_buff[34 ] =rd32 (E1000_RLPML ); regs_buff[35 ] =rd32 (E1000_RFCTL ); regs_buff[36 ] =rd32 (E1000_MRQC ); - regs_buff[37 ] =rd32 (E1000_VMD_CTL ); + regs_buff[37 ] =rd32 (E1000_VT_CTL );/* Transmit */ regs_buff[38 ] =rd32 (E1000_TCTL );
drivers/net/igb/igb_main.c +159 -15
272 lines not on this page · raw message
Re: [net-next PATCH 3/5] igb: add pf side of VMDq support
From: Jeff Kirsher <[email protected]>
Date: Thu, 19 Feb 2009 20:39:44 -0800
Quoted 5 lines
Add the pf portion of vmdq support. This provides enough support so that VMDq is enabled, and the pf is functional without enabling vfs.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 4/5 igb: Add support for enabling VFs to PF driver.
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
This patch adds the support to handle requests from the VF to perform operations such as completing resets, setting/reading mac address, adding vlans, adding multicast addresses, setting rlpml, and general communications between the PF and all VFs.
---
drivers/net/igb/Makefile | 2 drivers/net/igb/e1000_82575.c | 42 ++++ drivers/net/igb/e1000_82575.h | 17 + drivers/net/igb/e1000_defines.h | 9 + drivers/net/igb/e1000_hw.h | 31 +++ drivers/net/igb/e1000_mac.c | 24 ++ drivers/net/igb/e1000_mac.h | 1 drivers/net/igb/e1000_mbx.c | 447 +++++++++++++++++++++++++++++++++++++++ drivers/net/igb/e1000_mbx.h | 77 +++++++ drivers/net/igb/e1000_regs.h | 12 + drivers/net/igb/igb.h | 12 + drivers/net/igb/igb_main.c | 429 +++++++++++++++++++++++++++++++++++-- 12 files changed, 1077 insertions(+), 26 deletions(-) create mode 100644 drivers/net/igb/e1000_mbx.c create mode 100644 drivers/net/igb/e1000_mbx.h
drivers/net/igb/Makefile +1 -1
@@ -33,5 +33,5 @@ obj-$(CONFIG_IGB) += igb.o igb-objs := igb_main.o igb_ethtool.o e1000_82575.o \ - e1000_mac.o e1000_nvm.o e1000_phy.o + e1000_mac.o e1000_nvm.o e1000_phy.o e1000_mbx.o
drivers/net/igb/e1000_82575.c +42 -0
54 lines not on this page · raw message
drivers/net/igb/e1000_82575.h +17 -0
@@ -162,6 +162,10 @@ struct e1000_adv_tx_context_desc {#define E1000_DCA_TXCTRL_CPUID_SHIFT 24/* Tx CPUID now in the last byte */ #define E1000_DCA_RXCTRL_CPUID_SHIFT 24/* Rx CPUID now in the last byte */ +#define MAX_NUM_VFS 8 + +#define E1000_DTXSWC_VMDQ_LOOPBACK_EN (1 << 31)/* global VF LB enable */ +/* Easy defines for setting default pool, would normally be left a zero */ #define E1000_VT_CTL_DEFAULT_POOL_SHIFT 7#define E1000_VT_CTL_DEFAULT_POOL_MASK (0x7 << E1000_VT_CTL_DEFAULT_POOL_SHIFT)
@@ -181,8 +185,21 @@ struct e1000_adv_tx_context_desc {#define E1000_VMOLR_BAM 0x08000000/* Accept Broadcast packets */ #define E1000_VMOLR_MPME 0x10000000/* Multicast promiscuous mode */ #define E1000_VMOLR_STRVLAN 0x40000000/* Vlan stripping enable */ +#define E1000_VMOLR_STRCRC 0x80000000/* CRC stripping enable */ + +#define E1000_VLVF_ARRAY_SIZE 32 +#define E1000_VLVF_VLANID_MASK 0x00000FFF +#define E1000_VLVF_POOLSEL_SHIFT 12 +#define E1000_VLVF_POOLSEL_MASK (0xFF << E1000_VLVF_POOLSEL_SHIFT) +#define E1000_VLVF_LVLAN 0x00100000 +#define E1000_VLVF_VLANID_ENABLE 0x80000000 + +#define E1000_IOVCTL 0x05BBC +#define E1000_IOVCTL_REUSE_VFQ 0x00000001#define ALL_QUEUES 0xFFFF +void igb_vmdq_set_loopback_pf (struct e1000_hw *,bool ); +void igb_vmdq_set_replication_pf (struct e1000_hw *,bool );#endif
drivers/net/igb/e1000_defines.h +9 -0
@@ -45,6 +45,8 @@/* Extended Device Control */ #define E1000_CTRL_EXT_SDP7_DATA 0x00000080/* Value of SW Defineable Pin 7 */ +/* Physical Func Reset Done Indication */ +#define E1000_CTRL_EXT_PFRSTD 0x00004000#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000#define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES 0x00C00000#define E1000_CTRL_EXT_LINK_MODE_SGMII 0x00800000
@@ -325,6 +327,7 @@#define E1000_ICR_RXSEQ 0x00000008/* rx sequence error */ #define E1000_ICR_RXDMT0 0x00000010/* rx desc min. threshold (0) */ #define E1000_ICR_RXT0 0x00000080/* rx timer intr (ring 0) */ +#define E1000_ICR_VMMB 0x00000100/* VM MB event */ /* If this bit asserted, the driver should claim the interrupt */ #define E1000_ICR_INT_ASSERTED 0x80000000/* LAN connected device generates an interrupt */
@@ -362,6 +365,7 @@/* Interrupt Mask Set */ #define E1000_IMS_TXDW E1000_ICR_TXDW/* Transmit desc written back */ #define E1000_IMS_LSC E1000_ICR_LSC/* Link Status Change */ +#define E1000_IMS_VMMB E1000_ICR_VMMB/* Mail box activity */ #define E1000_IMS_RXSEQ E1000_ICR_RXSEQ/* rx sequence error */ #define E1000_IMS_RXDMT0 E1000_ICR_RXDMT0/* rx desc min. threshold */ #define E1000_IMS_RXT0 E1000_ICR_RXT0/* rx timer intr */
@@ -413,6 +417,7 @@#define E1000_BLK_PHY_RESET 12#define E1000_ERR_SWFW_SYNC 13#define E1000_NOT_IMPLEMENTED 14 +#define E1000_ERR_MBX 15/* Loop limit on how long we wait for auto-negotiation to complete */ #define COPPER_LINK_UP_LIMIT 10
@@ -659,4 +664,8 @@#define E1000_GEN_CTL_ADDRESS_SHIFT 8#define E1000_GEN_POLL_TIMEOUT 640 +#define E1000_VFTA_ENTRY_SHIFT 5 +#define E1000_VFTA_ENTRY_MASK 0x7F +#define E1000_VFTA_ENTRY_BIT_SHIFT_MASK 0x1F +#endif
drivers/net/igb/e1000_hw.h +30 -1
@@ -32,7 +32,6 @@#include <linux/delay.h> #include <linux/io.h> -#include "e1000_mac.h" #include "e1000_regs.h" #include "e1000_defines.h"
@@ -272,6 +271,7 @@ struct e1000_host_mng_command_info {#include "e1000_mac.h" #include "e1000_phy.h" #include "e1000_nvm.h" +#include "e1000_mbx.h" struct e1000_mac_operations {s32 (*check_for_link)(struct e1000_hw *);
@@ -427,6 +427,34 @@ struct e1000_fc_info {enum e1000_fc_type original_type; }; +struct e1000_mbx_operations { +s32 (*init_params)(struct e1000_hw *hw); +s32 (*read)(struct e1000_hw *,u32 *,u16 ,u16 ); +s32 (*write)(struct e1000_hw *,u32 *,u16 ,u16 ); +s32 (*read_posted)(struct e1000_hw *,u32 *,u16 ,u16 ); +s32 (*write_posted)(struct e1000_hw *,u32 *,u16 ,u16 ); +s32 (*check_for_msg)(struct e1000_hw *,u16 ); +s32 (*check_for_ack)(struct e1000_hw *,u16 ); +s32 (*check_for_rst)(struct e1000_hw *,u16 ); +}; + +struct e1000_mbx_stats { +u32 msgs_tx; +u32 msgs_rx; + +u32 acks; +u32 reqs; +u32 rsts; +}; + +struct e1000_mbx_info { +struct e1000_mbx_operations ops; +struct e1000_mbx_stats stats; +u32 timeout; +u32 usec_delay; +u16 size; +}; +struct e1000_dev_spec_82575 {bool sgmii_active; };
@@ -443,6 +471,7 @@ struct e1000_hw {struct e1000_phy_info phy;struct e1000_nvm_info nvm;struct e1000_bus_info bus; +struct e1000_mbx_info mbx;struct e1000_host_mng_dhcp_cookie mng_cookie;union {
drivers/net/igb/e1000_mac.c +24 -0
@@ -118,6 +118,30 @@ void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value) }/** +* igb_vfta_set - enable or disable vlan in VLAN filter table +* @hw: pointer to the HW structure +* @vid: VLAN id to add or remove +* @add: if true add filter, if false remove +* +* Sets or clears a bit in the VLAN filter table array based on VLAN id +* and if we are adding or removing the filter +**/ +void igb_vfta_set (struct e1000_hw *hw,u32 vid,bool add) +{ +u32 index = (vid >>E1000_VFTA_ENTRY_SHIFT ) &E1000_VFTA_ENTRY_MASK ; +u32 mask =1 < (vid &E1000_VFTA_ENTRY_BIT_SHIFT_MASK ); +u32 vfta; + + vfta =array_rd32 (E1000_VFTA , index); +if (add) + vfta |= mask; +else + vfta &= ~mask; + +igb_write_vfta (hw, index, vfta); +} + +/** * igb_check_alt_mac_addr - Check for alternate MAC addr * @hw: pointer to the HW structure *
drivers/net/igb/e1000_mac.h +1 -0
@@ -58,6 +58,7 @@ s32 igb_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg,void igb_clear_hw_cntrs_base (struct e1000_hw *hw);void igb_clear_vfta (struct e1000_hw *hw); +void igb_vfta_set (struct e1000_hw *hw,u32 vid,bool add);void igb_config_collision_dist (struct e1000_hw *hw);void igb_mta_set (struct e1000_hw *hw,u32 hash_value);void igb_put_hw_semaphore (struct e1000_hw *hw);
drivers/net/igb/e1000_mbx.c new file +447 -0
447 lines not on this page · raw message
drivers/net/igb/e1000_mbx.h new file +77 -0
77 lines not on this page · raw message
drivers/net/igb/e1000_regs.h +12 -0
@@ -321,9 +321,21 @@ enum {#define E1000_RSSRK (_i) (0x05C80 + ((_i) * 4))/* RSS Random Key - RW Array */ /* VT Registers */ +#define E1000_MBVFICR 0x00C80/* Mailbox VF Cause - RWC */ +#define E1000_MBVFIMR 0x00C84/* Mailbox VF int Mask - RW */ +#define E1000_VFLRE 0x00C88/* VF Register Events - RWC */ +#define E1000_VFRE 0x00C8C/* VF Receive Enables */ +#define E1000_VFTE 0x00C90/* VF Transmit Enables */ #define E1000_QDE 0x02408/* Queue Drop Enable - RW */ +#define E1000_DTXSWC 0x03500/* DMA Tx Switch Control - RW */ +#define E1000_RPLOLR 0x05AF0/* Replication Offload - RW */ +#define E1000_IOVTCL 0x05BBC/* IOV Control Register */ /* These act per VF so an array friendly macro is used */ +#define E1000_P2VMAILBOX (_n) (0x00C00 + (4 * (_n))) +#define E1000_VMBMEM (_n) (0x00800 + (64 * (_n)))#define E1000_VMOLR (_n) (0x05AD0 + (4 * (_n))) +#define E1000_VLVF (_n) (0x05D00 + (4 * (_n)))/* VLAN Virtual Machine +* Filter - RW */ #define wr32 (reg, value) (writel(value, hw->hw_addr + reg))#define rd32 (reg) (readl(hw->hw_addr + reg))
drivers/net/igb/igb.h +12 -0
@@ -62,6 +62,17 @@ struct igb_adapter;#define IGB_MAX_TX_QUEUES IGB_MAX_RX_QUEUES#define IGB_ABS_MAX_TX_QUEUES 4 +#define IGB_MAX_VF_MC_ENTRIES 30 +#define IGB_MAX_VF_FUNCTIONS 8 +#define IGB_MAX_VFTA_ENTRIES 128 + +struct vf_data_storage { +unsigned char vf_mac_addresses[ETH_ALEN ]; +u16 vf_mc_hashes[IGB_MAX_VF_MC_ENTRIES ]; +u16 num_vf_mc_hashes; +bool clear_to_send; +}; +/* RX descriptor control thresholds. * PTHRESH - MAC will consider prefetch if it has fewer than this number of * descriptors available in its onboard memory.
@@ -272,6 +283,7 @@ struct igb_adapter {unsigned int tx_ring_count;unsigned int rx_ring_count;unsigned int vfs_allocated_count; +struct vf_data_storage *vf_data; };#define IGB_FLAG_HAS_MSI (1 << 0)
drivers/net/igb/igb_main.c +405 -24
532 lines not on this page · raw message
Re: [net-next PATCH 4/5] igb: Add support for enabling VFs to PF driver.
From: Jeff Kirsher <[email protected]>
Date: Thu, 19 Feb 2009 20:40:07 -0800
Quoted 7 lines
This patch adds the support to handle requests from the VF to perform operations such as completing resets, setting/reading mac address, adding vlans, adding multicast addresses, setting rlpml, and general communications between the PF and all VFs.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 5/5 igb: this patch addes the sr-iov enablement option via num_vfs parameter
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
This code adds a module parameter called num_vfs which defines if the driver should attempt to use sr-iov and if so how many VFs should be enabled.
---
drivers/net/igb/igb_main.c | 125 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 120 insertions(+), 5 deletions(-)
drivers/net/igb/igb_main.c +120 -5
@@ -146,12 +146,18 @@ static struct notifier_block dca_notifier = { .priority = 0 };#endif -#ifdef CONFIG_NET_POLL_CONTROLLER /* for netdump / net console */ static void igb_netpoll (struct net_device *);#endif +#ifdef CONFIG_PCI_IOV +static ssize_t igb_set_num_vfs (struct device *,struct device_attribute *, +const char *,size_t ); +static ssize_t igb_show_num_vfs (struct device *,struct device_attribute *, +char *); +DEVICE_ATTR (num_vfs,S_IRUGO |S_IWUSR , igb_show_num_vfs, igb_set_num_vfs); +#endif static pci_ers_result_t igb_io_error_detected (struct pci_dev *,pci_channel_state_t );static pci_ers_result_t igb_io_slot_reset (struct pci_dev *);
@@ -588,9 +594,6 @@ static int igb_request_msix(struct igb_adapter *adapter) goto out; ring->itr_register =E1000_EITR (0 ) + (vector <<2 ); ring->itr_val = adapter->itr; -/* overwrite the poll routine for MSIX, we've already done -* netif_napi_add */ - ring->napi.poll = &igb_clean_rx_ring_msix; vector++; }
@@ -1392,6 +1395,19 @@ static int __devinit igb_probe(struct pci_dev *pdev,if (err) goto err_register; +#ifdef CONFIG_PCI_IOV +/* since iov functionality isn't critical to base device function we +* can accept failure. If it fails we don't allow iov to be enabled */ +if (hw->mac.type == e1000_82576) { + err =pci_enable_sriov (pdev,0 ); +if (!err) + err =device_create_file (&netdev->dev, + &dev_attr_num_vfs); +if (err) +dev_err (&pdev->dev,"Failed to initialize IOV\n" ); + } + +#endif #ifdef CONFIG_IGB_DCA if (dca_add_requester (&pdev->dev) ==0 ) { adapter->flags |=IGB_FLAG_DCA_ENABLED ;
@@ -1547,6 +1563,20 @@ static void __devexit igb_remove(struct pci_dev *pdev)igb_free_queues (adapter); +#ifdef CONFIG_PCI_IOV +/* reclaim resources allocated to VFs */ +if (adapter->vf_data) { +/* disable iov and allow time for transactions to clear */ +pci_disable_sriov (pdev); +msleep (500 ); + +kfree (adapter->vf_data); + adapter->vf_data =NULL ; +wr32 (E1000_IOVCTL ,E1000_IOVCTL_REUSE_VFQ ); +msleep (100 ); +dev_info (&pdev->dev,"IOV Disabled\n" ); + } +#endif iounmap (hw->hw_addr);if (hw->flash_address)iounmap (hw->flash_address);
@@ -5341,7 +5371,7 @@ static int igb_set_vf_mac(struct igb_adapter *adapter,igb_rar_set (hw, mac_addr, rar_entry); -memcpy (adapter->vf_data[vf].vf_mac_addresses, mac_addr,6 ); +memcpy (adapter->vf_data[vf].vf_mac_addresses, mac_addr,ETH_ALEN );igb_set_rah_pool (hw, vf, rar_entry);
@@ -5366,4 +5396,89 @@ static void igb_vmm_control(struct igb_adapter *adapter)igb_vmdq_set_replication_pf (hw, true); } +#ifdef CONFIG_PCI_IOV +static ssize_t igb_show_num_vfs (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct igb_adapter *adapter =netdev_priv (to_net_dev (dev)); + +return sprintf (buf,"%d\n" , adapter->vfs_allocated_count); +} + +static ssize_t igb_set_num_vfs (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct net_device *netdev =to_net_dev (dev); +struct igb_adapter *adapter =netdev_priv (netdev); +struct e1000_hw *hw = &adapter->hw; +struct pci_dev *pdev = adapter->pdev; +unsigned int num_vfs, i; +unsigned char mac_addr[ETH_ALEN ]; +int err; + +sscanf (buf,"%u" , &num_vfs); + +if (num_vfs >7 ) + num_vfs =7 ; + +/* value unchanged do nothing */ +if (num_vfs == adapter->vfs_allocated_count) +return count; + +if (netdev->flags &IFF_UP ) +igb_close (netdev); + +igb_reset_interrupt_capability (adapter); +igb_free_queues (adapter); + adapter->tx_ring =NULL ; + adapter->rx_ring =NULL ; + adapter->vfs_allocated_count =0 ; + +/* reclaim resources allocated to VFs since we are changing count */ +if (adapter->vf_data) { +/* disable iov and allow time for transactions to clear */ +pci_disable_sriov (pdev); +msleep (500 ); + +kfree (adapter->vf_data); + adapter->vf_data =NULL ; +wr32 (E1000_IOVCTL ,E1000_IOVCTL_REUSE_VFQ ); +msleep (100 ); +dev_info (&pdev->dev,"IOV Disabled\n" ); + } + +if (num_vfs) { + adapter->vf_data =kcalloc (num_vfs, +sizeof (struct vf_data_storage ), +GFP_KERNEL ); +if (!adapter->vf_data) { +dev_err (&pdev->dev,"Could not allocate VF private " +"data - IOV enable failed\n" ); + }else { + err =pci_enable_sriov (pdev, num_vfs); +if (!err) { + adapter->vfs_allocated_count = num_vfs; +dev_info (&pdev->dev,"%d vfs allocated\n" , num_vfs); +for (i =0 ; i < adapter->vfs_allocated_count; i++) { +random_ether_addr (mac_addr); +igb_set_vf_mac (adapter, i, mac_addr); + } + }else { +kfree (adapter->vf_data); + adapter->vf_data =NULL ; + } + } + } + +igb_set_interrupt_capability (adapter); +igb_alloc_queues (adapter); +igb_reset (adapter); + +if (netdev->flags &IFF_UP ) +igb_open (netdev); + +return count; +} +#endif /* CONFIG_PCI_IOV */ /* igb_main.c */
David Miller
maintainerRe: [net-next PATCH 5/5] igb: this patch addes the sr-iov enablement option via num_vfs parameter
From: Jeff Kirsher <[email protected]>
Date: Thu, 19 Feb 2009 20:40:30 -0800
Quoted 6 lines
This code adds a module parameter called
num_vfswhich defines if the driver should attempt to use sr-iov and if so how many VFs should be enabled.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Also applied, thanks a lot.
From: Jeff Kirsher <[email protected]>
Date: Thu, 19 Feb 2009 20:39:04 -0800
Quoted 10 lines
igb is currently not returning the correct values for napi. In addition it is doing more work than necessary since it will not exit polling until
work_doneis equal to zero.This patch makes the following changes:
1. Consolidates msi-x and non-msi polling routines.
2. Corrects return values for polling routines.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.