diff options
Diffstat (limited to 'drivers/net/ethernet/intel/ixgbe')
26 files changed, 2352 insertions, 1409 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 0ac6b11c6e4..ac9f2148cdc 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -55,7 +56,7 @@  #include <net/busy_poll.h>  #ifdef CONFIG_NET_RX_BUSY_POLL -#define LL_EXTENDED_STATS +#define BP_EXTENDED_STATS  #endif  /* common prefix used by pr_<> macros */  #undef pr_fmt @@ -67,7 +68,11 @@  #define IXGBE_MAX_TXD			   4096  #define IXGBE_MIN_TXD			     64 +#if (PAGE_SIZE < 8192)  #define IXGBE_DEFAULT_RXD		    512 +#else +#define IXGBE_DEFAULT_RXD		    128 +#endif  #define IXGBE_MAX_RXD			   4096  #define IXGBE_MIN_RXD			     64 @@ -150,7 +155,6 @@ struct vf_data_storage {  struct vf_macvlans {  	struct list_head l;  	int vf; -	int rar_entry;  	bool free;  	bool is_macvlan;  	u8 vf_macvlan[ETH_ALEN]; @@ -187,11 +191,11 @@ struct ixgbe_rx_buffer {  struct ixgbe_queue_stats {  	u64 packets;  	u64 bytes; -#ifdef LL_EXTENDED_STATS +#ifdef BP_EXTENDED_STATS  	u64 yields;  	u64 misses;  	u64 cleaned; -#endif  /* LL_EXTENDED_STATS */ +#endif  /* BP_EXTENDED_STATS */  };  struct ixgbe_tx_queue_stats { @@ -219,6 +223,15 @@ enum ixgbe_ring_state_t {  	__IXGBE_RX_FCOE,  }; +struct ixgbe_fwd_adapter { +	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; +	struct net_device *netdev; +	struct ixgbe_adapter *real_adapter; +	unsigned int tx_base_queue; +	unsigned int rx_base_queue; +	int pool; +}; +  #define check_for_tx_hang(ring) \  	test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)  #define set_check_for_tx_hang(ring) \ @@ -236,12 +249,12 @@ struct ixgbe_ring {  	struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */  	struct net_device *netdev;	/* netdev ring belongs to */  	struct device *dev;		/* device for DMA mapping */ +	struct ixgbe_fwd_adapter *l2_accel_priv;  	void *desc;			/* descriptor ring memory */  	union {  		struct ixgbe_tx_buffer *tx_buffer_info;  		struct ixgbe_rx_buffer *rx_buffer_info;  	}; -	unsigned long last_rx_timestamp;  	unsigned long state;  	u8 __iomem *tail;  	dma_addr_t dma;			/* phys. address of descriptor ring */ @@ -293,6 +306,12 @@ enum ixgbe_ring_f_enum {  #define IXGBE_MAX_FCOE_INDICES  8  #define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)  #define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1) +#define IXGBE_MAX_L2A_QUEUES 4 +#define IXGBE_MAX_L2A_QUEUES 4 +#define IXGBE_BAD_L2A_QUEUE 3 +#define IXGBE_MAX_MACVLANS	31 +#define IXGBE_MAX_DCBMACVLANS	8 +  struct ixgbe_ring_feature {  	u16 limit;	/* upper limit on feature indices */  	u16 indices;	/* current value of indices */ @@ -343,7 +362,7 @@ struct ixgbe_ring_container {  	for (pos = (head).ring; pos != NULL; pos = pos->next)  #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \ -                              ? 8 : 1) +			      ? 8 : 1)  #define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS  /* MAX_Q_VECTORS of these are allocated, @@ -369,11 +388,13 @@ struct ixgbe_q_vector {  #ifdef CONFIG_NET_RX_BUSY_POLL  	unsigned int state;  #define IXGBE_QV_STATE_IDLE        0 -#define IXGBE_QV_STATE_NAPI	   1    /* NAPI owns this QV */ -#define IXGBE_QV_STATE_POLL	   2    /* poll owns this QV */ -#define IXGBE_QV_LOCKED (IXGBE_QV_STATE_NAPI | IXGBE_QV_STATE_POLL) -#define IXGBE_QV_STATE_NAPI_YIELD  4    /* NAPI yielded this QV */ -#define IXGBE_QV_STATE_POLL_YIELD  8    /* poll yielded this QV */ +#define IXGBE_QV_STATE_NAPI	   1     /* NAPI owns this QV */ +#define IXGBE_QV_STATE_POLL	   2     /* poll owns this QV */ +#define IXGBE_QV_STATE_DISABLED	   4     /* QV is disabled */ +#define IXGBE_QV_OWNED (IXGBE_QV_STATE_NAPI | IXGBE_QV_STATE_POLL) +#define IXGBE_QV_LOCKED (IXGBE_QV_OWNED | IXGBE_QV_STATE_DISABLED) +#define IXGBE_QV_STATE_NAPI_YIELD  8     /* NAPI yielded this QV */ +#define IXGBE_QV_STATE_POLL_YIELD  16    /* poll yielded this QV */  #define IXGBE_QV_YIELD (IXGBE_QV_STATE_NAPI_YIELD | IXGBE_QV_STATE_POLL_YIELD)  #define IXGBE_QV_USER_PEND (IXGBE_QV_STATE_POLL | IXGBE_QV_STATE_POLL_YIELD)  	spinlock_t lock; @@ -394,18 +415,19 @@ static inline void ixgbe_qv_init_lock(struct ixgbe_q_vector *q_vector)  static inline bool ixgbe_qv_lock_napi(struct ixgbe_q_vector *q_vector)  {  	int rc = true; -	spin_lock(&q_vector->lock); +	spin_lock_bh(&q_vector->lock);  	if (q_vector->state & IXGBE_QV_LOCKED) {  		WARN_ON(q_vector->state & IXGBE_QV_STATE_NAPI);  		q_vector->state |= IXGBE_QV_STATE_NAPI_YIELD;  		rc = false; -#ifdef LL_EXTENDED_STATS +#ifdef BP_EXTENDED_STATS  		q_vector->tx.ring->stats.yields++;  #endif -	} else +	} else {  		/* we don't care if someone yielded */  		q_vector->state = IXGBE_QV_STATE_NAPI; -	spin_unlock(&q_vector->lock); +	} +	spin_unlock_bh(&q_vector->lock);  	return rc;  } @@ -413,14 +435,15 @@ static inline bool ixgbe_qv_lock_napi(struct ixgbe_q_vector *q_vector)  static inline bool ixgbe_qv_unlock_napi(struct ixgbe_q_vector *q_vector)  {  	int rc = false; -	spin_lock(&q_vector->lock); +	spin_lock_bh(&q_vector->lock);  	WARN_ON(q_vector->state & (IXGBE_QV_STATE_POLL |  			       IXGBE_QV_STATE_NAPI_YIELD));  	if (q_vector->state & IXGBE_QV_STATE_POLL_YIELD)  		rc = true; -	q_vector->state = IXGBE_QV_STATE_IDLE; -	spin_unlock(&q_vector->lock); +	/* will reset state to idle, unless QV is disabled */ +	q_vector->state &= IXGBE_QV_STATE_DISABLED; +	spin_unlock_bh(&q_vector->lock);  	return rc;  } @@ -432,12 +455,13 @@ static inline bool ixgbe_qv_lock_poll(struct ixgbe_q_vector *q_vector)  	if ((q_vector->state & IXGBE_QV_LOCKED)) {  		q_vector->state |= IXGBE_QV_STATE_POLL_YIELD;  		rc = false; -#ifdef LL_EXTENDED_STATS +#ifdef BP_EXTENDED_STATS  		q_vector->rx.ring->stats.yields++;  #endif -	} else +	} else {  		/* preserve yield marks */  		q_vector->state |= IXGBE_QV_STATE_POLL; +	}  	spin_unlock_bh(&q_vector->lock);  	return rc;  } @@ -451,17 +475,32 @@ static inline bool ixgbe_qv_unlock_poll(struct ixgbe_q_vector *q_vector)  	if (q_vector->state & IXGBE_QV_STATE_POLL_YIELD)  		rc = true; -	q_vector->state = IXGBE_QV_STATE_IDLE; +	/* will reset state to idle, unless QV is disabled */ +	q_vector->state &= IXGBE_QV_STATE_DISABLED;  	spin_unlock_bh(&q_vector->lock);  	return rc;  }  /* true if a socket is polling, even if it did not get the lock */ -static inline bool ixgbe_qv_ll_polling(struct ixgbe_q_vector *q_vector) +static inline bool ixgbe_qv_busy_polling(struct ixgbe_q_vector *q_vector)  { -	WARN_ON(!(q_vector->state & IXGBE_QV_LOCKED)); +	WARN_ON(!(q_vector->state & IXGBE_QV_OWNED));  	return q_vector->state & IXGBE_QV_USER_PEND;  } + +/* false if QV is currently owned */ +static inline bool ixgbe_qv_disable(struct ixgbe_q_vector *q_vector) +{ +	int rc = true; +	spin_lock_bh(&q_vector->lock); +	if (q_vector->state & IXGBE_QV_OWNED) +		rc = false; +	q_vector->state |= IXGBE_QV_STATE_DISABLED; +	spin_unlock_bh(&q_vector->lock); + +	return rc; +} +  #else /* CONFIG_NET_RX_BUSY_POLL */  static inline void ixgbe_qv_init_lock(struct ixgbe_q_vector *q_vector)  { @@ -487,10 +526,16 @@ static inline bool ixgbe_qv_unlock_poll(struct ixgbe_q_vector *q_vector)  	return false;  } -static inline bool ixgbe_qv_ll_polling(struct ixgbe_q_vector *q_vector) +static inline bool ixgbe_qv_busy_polling(struct ixgbe_q_vector *q_vector)  {  	return false;  } + +static inline bool ixgbe_qv_disable(struct ixgbe_q_vector *q_vector) +{ +	return true; +} +  #endif /* CONFIG_NET_RX_BUSY_POLL */  #ifdef CONFIG_IXGBE_HWMON @@ -508,8 +553,10 @@ struct hwmon_attr {  };  struct hwmon_buff { -	struct device *device; -	struct hwmon_attr *hwmon_list; +	struct attribute_group group; +	const struct attribute_group *groups[2]; +	struct attribute *attrs[IXGBE_MAX_SENSORS * 4 + 1]; +	struct hwmon_attr hwmon_list[IXGBE_MAX_SENSORS * 4];  	unsigned int n_hwmon;  };  #endif /* CONFIG_IXGBE_HWMON */ @@ -539,6 +586,11 @@ static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)  	return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;  } +static inline void ixgbe_write_tail(struct ixgbe_ring *ring, u32 value) +{ +	writel(value, ring->tail); +} +  #define IXGBE_RX_DESC(R, i)	    \  	(&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))  #define IXGBE_TX_DESC(R, i)	    \ @@ -560,6 +612,15 @@ static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)  #define MAX_MSIX_VECTORS_82598 18  #define MAX_Q_VECTORS_82598 16 +struct ixgbe_mac_addr { +	u8 addr[ETH_ALEN]; +	u16 queue; +	u16 state; /* bitmask */ +}; +#define IXGBE_MAC_STATE_DEFAULT		0x1 +#define IXGBE_MAC_STATE_MODIFIED	0x2 +#define IXGBE_MAC_STATE_IN_USE		0x4 +  #define MAX_Q_VECTORS MAX_Q_VECTORS_82599  #define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599 @@ -696,6 +757,7 @@ struct ixgbe_adapter {  #ifdef IXGBE_FCOE  	struct ixgbe_fcoe fcoe;  #endif /* IXGBE_FCOE */ +	u8 __iomem *io_addr; /* Mainly for iounmap use */  	u32 wol;  	u16 bd_number; @@ -711,9 +773,11 @@ struct ixgbe_adapter {  	struct ptp_clock_info ptp_caps;  	struct work_struct ptp_tx_work;  	struct sk_buff *ptp_tx_skb; +	struct hwtstamp_config tstamp_config;  	unsigned long ptp_tx_start;  	unsigned long last_overflow_check;  	unsigned long last_rx_ptp_check; +	unsigned long last_rx_timestamp;  	spinlock_t tmreg_lock;  	struct cyclecounter cc;  	struct timecounter tc; @@ -729,15 +793,17 @@ struct ixgbe_adapter {  	u32 timer_event_accumulator;  	u32 vferr_refcount; +	struct ixgbe_mac_addr *mac_table;  	struct kobject *info_kobj;  #ifdef CONFIG_IXGBE_HWMON -	struct hwmon_buff ixgbe_hwmon_buff; +	struct hwmon_buff *ixgbe_hwmon_buff;  #endif /* CONFIG_IXGBE_HWMON */  #ifdef CONFIG_DEBUG_FS  	struct dentry *ixgbe_dbg_adapter;  #endif /*CONFIG_DEBUG_FS*/  	u8 default_up; +	unsigned long fwd_bitmask; /* Bitmask indicating in use pools */  };  struct ixgbe_fdir_filter { @@ -751,9 +817,13 @@ enum ixgbe_state_t {  	__IXGBE_TESTING,  	__IXGBE_RESETTING,  	__IXGBE_DOWN, +	__IXGBE_DISABLED, +	__IXGBE_REMOVING,  	__IXGBE_SERVICE_SCHED, +	__IXGBE_SERVICE_INITED,  	__IXGBE_IN_SFP_INIT,  	__IXGBE_PTP_RUNNING, +	__IXGBE_PTP_TX_IN_PROGRESS,  };  struct ixgbe_cb { @@ -786,93 +856,95 @@ extern const char ixgbe_driver_version[];  extern char ixgbe_default_device_descr[];  #endif /* IXGBE_FCOE */ -extern void ixgbe_up(struct ixgbe_adapter *adapter); -extern void ixgbe_down(struct ixgbe_adapter *adapter); -extern void ixgbe_reinit_locked(struct ixgbe_adapter *adapter); -extern void ixgbe_reset(struct ixgbe_adapter *adapter); -extern void ixgbe_set_ethtool_ops(struct net_device *netdev); -extern int ixgbe_setup_rx_resources(struct ixgbe_ring *); -extern int ixgbe_setup_tx_resources(struct ixgbe_ring *); -extern void ixgbe_free_rx_resources(struct ixgbe_ring *); -extern void ixgbe_free_tx_resources(struct ixgbe_ring *); -extern void ixgbe_configure_rx_ring(struct ixgbe_adapter *,struct ixgbe_ring *); -extern void ixgbe_configure_tx_ring(struct ixgbe_adapter *,struct ixgbe_ring *); -extern void ixgbe_disable_rx_queue(struct ixgbe_adapter *adapter, -				   struct ixgbe_ring *); -extern void ixgbe_update_stats(struct ixgbe_adapter *adapter); -extern int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter); -extern int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id, +void ixgbe_up(struct ixgbe_adapter *adapter); +void ixgbe_down(struct ixgbe_adapter *adapter); +void ixgbe_reinit_locked(struct ixgbe_adapter *adapter); +void ixgbe_reset(struct ixgbe_adapter *adapter); +void ixgbe_set_ethtool_ops(struct net_device *netdev); +int ixgbe_setup_rx_resources(struct ixgbe_ring *); +int ixgbe_setup_tx_resources(struct ixgbe_ring *); +void ixgbe_free_rx_resources(struct ixgbe_ring *); +void ixgbe_free_tx_resources(struct ixgbe_ring *); +void ixgbe_configure_rx_ring(struct ixgbe_adapter *, struct ixgbe_ring *); +void ixgbe_configure_tx_ring(struct ixgbe_adapter *, struct ixgbe_ring *); +void ixgbe_disable_rx_queue(struct ixgbe_adapter *adapter, struct ixgbe_ring *); +void ixgbe_update_stats(struct ixgbe_adapter *adapter); +int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter); +int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,  			       u16 subdevice_id); -extern void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter); -extern netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, -					 struct ixgbe_adapter *, -					 struct ixgbe_ring *); -extern void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *, -                                             struct ixgbe_tx_buffer *); -extern void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16); -extern void ixgbe_write_eitr(struct ixgbe_q_vector *); -extern int ixgbe_poll(struct napi_struct *napi, int budget); -extern int ethtool_ioctl(struct ifreq *ifr); -extern s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw); -extern s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl); -extern s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl); -extern s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw, -						 union ixgbe_atr_hash_dword input, -						 union ixgbe_atr_hash_dword common, -                                                 u8 queue); -extern s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw, -					   union ixgbe_atr_input *input_mask); -extern s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw, -						 union ixgbe_atr_input *input, -						 u16 soft_id, u8 queue); -extern s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw, -						 union ixgbe_atr_input *input, -						 u16 soft_id); -extern void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input, -						 union ixgbe_atr_input *mask); -extern bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw); -extern void ixgbe_set_rx_mode(struct net_device *netdev); +#ifdef CONFIG_PCI_IOV +void ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter); +#endif +int ixgbe_add_mac_filter(struct ixgbe_adapter *adapter, +			 u8 *addr, u16 queue); +int ixgbe_del_mac_filter(struct ixgbe_adapter *adapter, +			 u8 *addr, u16 queue); +void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter); +netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, struct ixgbe_adapter *, +				  struct ixgbe_ring *); +void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *, +				      struct ixgbe_tx_buffer *); +void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16); +void ixgbe_write_eitr(struct ixgbe_q_vector *); +int ixgbe_poll(struct napi_struct *napi, int budget); +int ethtool_ioctl(struct ifreq *ifr); +s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw); +s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl); +s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl); +s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw, +					  union ixgbe_atr_hash_dword input, +					  union ixgbe_atr_hash_dword common, +					  u8 queue); +s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw, +				    union ixgbe_atr_input *input_mask); +s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw, +					  union ixgbe_atr_input *input, +					  u16 soft_id, u8 queue); +s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw, +					  union ixgbe_atr_input *input, +					  u16 soft_id); +void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input, +					  union ixgbe_atr_input *mask); +void ixgbe_set_rx_mode(struct net_device *netdev);  #ifdef CONFIG_IXGBE_DCB -extern void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter); +void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);  #endif -extern int ixgbe_setup_tc(struct net_device *dev, u8 tc); -extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32); -extern void ixgbe_do_reset(struct net_device *netdev); +int ixgbe_setup_tc(struct net_device *dev, u8 tc); +void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32); +void ixgbe_do_reset(struct net_device *netdev);  #ifdef CONFIG_IXGBE_HWMON -extern void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter); -extern int ixgbe_sysfs_init(struct ixgbe_adapter *adapter); +void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter); +int ixgbe_sysfs_init(struct ixgbe_adapter *adapter);  #endif /* CONFIG_IXGBE_HWMON */  #ifdef IXGBE_FCOE -extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter); -extern int ixgbe_fso(struct ixgbe_ring *tx_ring, -		     struct ixgbe_tx_buffer *first, -		     u8 *hdr_len); -extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, -			  union ixgbe_adv_rx_desc *rx_desc, -			  struct sk_buff *skb); -extern int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid, -                              struct scatterlist *sgl, unsigned int sgc); -extern int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid, -				 struct scatterlist *sgl, unsigned int sgc); -extern int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid); -extern int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter); -extern void ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter); -extern int ixgbe_fcoe_enable(struct net_device *netdev); -extern int ixgbe_fcoe_disable(struct net_device *netdev); +void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter); +int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first, +	      u8 *hdr_len); +int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, +		   union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb); +int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid, +		       struct scatterlist *sgl, unsigned int sgc); +int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid, +			  struct scatterlist *sgl, unsigned int sgc); +int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid); +int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter); +void ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter); +int ixgbe_fcoe_enable(struct net_device *netdev); +int ixgbe_fcoe_disable(struct net_device *netdev);  #ifdef CONFIG_IXGBE_DCB -extern u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter); -extern u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up); +u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter); +u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up);  #endif /* CONFIG_IXGBE_DCB */ -extern int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type); -extern int ixgbe_fcoe_get_hbainfo(struct net_device *netdev, -				  struct netdev_fcoe_hbainfo *info); -extern u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter); +int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type); +int ixgbe_fcoe_get_hbainfo(struct net_device *netdev, +			   struct netdev_fcoe_hbainfo *info); +u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);  #endif /* IXGBE_FCOE */  #ifdef CONFIG_DEBUG_FS -extern void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter); -extern void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter); -extern void ixgbe_dbg_init(void); -extern void ixgbe_dbg_exit(void); +void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter); +void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter); +void ixgbe_dbg_init(void); +void ixgbe_dbg_exit(void);  #else  static inline void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) {}  static inline void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter) {} @@ -884,35 +956,22 @@ static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)  	return netdev_get_tx_queue(ring->netdev, ring->queue_index);  } -extern void ixgbe_ptp_init(struct ixgbe_adapter *adapter); -extern void ixgbe_ptp_stop(struct ixgbe_adapter *adapter); -extern void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter); -extern void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter); -extern void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector, -				    struct sk_buff *skb); -static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring, -					 union ixgbe_adv_rx_desc *rx_desc, -					 struct sk_buff *skb) -{ -	if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS))) -		return; - -	__ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, skb); - -	/* -	 * Update the last_rx_timestamp timer in order to enable watchdog check -	 * for error case of latched timestamp on a dropped packet. -	 */ -	rx_ring->last_rx_timestamp = jiffies; -} - -extern int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter, -				    struct ifreq *ifr, int cmd); -extern void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter); -extern void ixgbe_ptp_reset(struct ixgbe_adapter *adapter); -extern void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr); +void ixgbe_ptp_init(struct ixgbe_adapter *adapter); +void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter); +void ixgbe_ptp_stop(struct ixgbe_adapter *adapter); +void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter); +void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter); +void ixgbe_ptp_rx_hwtstamp(struct ixgbe_adapter *adapter, struct sk_buff *skb); +int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr); +int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr); +void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter); +void ixgbe_ptp_reset(struct ixgbe_adapter *adapter); +void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr);  #ifdef CONFIG_PCI_IOV  void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);  #endif +netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, +				  struct ixgbe_adapter *adapter, +				  struct ixgbe_ring *tx_ring);  #endif /* _IXGBE_H_ */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c index a26f3fee4f3..15609331ec1 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -40,10 +41,10 @@  #define IXGBE_82598_RX_PB_SIZE	 512  static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw, -                                         ixgbe_link_speed speed, -                                         bool autoneg_wait_to_complete); +					 ixgbe_link_speed speed, +					 bool autoneg_wait_to_complete);  static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset, -                                       u8 *eeprom_data); +				       u8 *eeprom_data);  /**   *  ixgbe_set_pcie_completion_timeout - set pci-e completion timeout @@ -57,10 +58,12 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,   **/  static void ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw)  { -	struct ixgbe_adapter *adapter = hw->back;  	u32 gcr = IXGBE_READ_REG(hw, IXGBE_GCR);  	u16 pcie_devctl2; +	if (ixgbe_removed(hw->hw_addr)) +		return; +  	/* only take action if timeout value is defaulted to 0 */  	if (gcr & IXGBE_GCR_CMPL_TMOUT_MASK)  		goto out; @@ -79,11 +82,9 @@ static void ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw)  	 * directly in order to set the completion timeout value for  	 * 16ms to 55ms  	 */ -	pci_read_config_word(adapter->pdev, -	                     IXGBE_PCI_DEVICE_CONTROL2, &pcie_devctl2); +	pcie_devctl2 = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_DEVICE_CONTROL2);  	pcie_devctl2 |= IXGBE_PCI_DEVICE_CONTROL2_16ms; -	pci_write_config_word(adapter->pdev, -	                      IXGBE_PCI_DEVICE_CONTROL2, pcie_devctl2); +	ixgbe_write_pci_cfg_word(hw, IXGBE_PCI_DEVICE_CONTROL2, pcie_devctl2);  out:  	/* disable completion timeout resend */  	gcr &= ~IXGBE_GCR_CMPL_TMOUT_RESEND; @@ -100,6 +101,7 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)  	mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;  	mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;  	mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES; +	mac->rx_pb_size = IXGBE_82598_RX_PB_SIZE;  	mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;  	mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;  	mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw); @@ -138,7 +140,7 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)  		phy->ops.setup_link = &ixgbe_setup_phy_link_tnx;  		phy->ops.check_link = &ixgbe_check_phy_link_tnx;  		phy->ops.get_firmware_version = -		             &ixgbe_get_phy_firmware_version_tnx; +			     &ixgbe_get_phy_firmware_version_tnx;  		break;  	case ixgbe_phy_nl:  		phy->ops.reset = &ixgbe_reset_phy_nl; @@ -154,8 +156,8 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)  		/* Check to see if SFP+ module is supported */  		ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, -		                                            &list_offset, -		                                            &data_offset); +							    &list_offset, +							    &data_offset);  		if (ret_val != 0) {  			ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;  			goto out; @@ -201,8 +203,6 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)  		IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);  	} -	hw->mac.rx_pb_size = IXGBE_82598_RX_PB_SIZE; -  	/* set the completion timeout for interface */  	if (ret_val == 0)  		ixgbe_set_pcie_completion_timeout(hw); @@ -219,8 +219,8 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)   *  Determines the link capabilities by reading the AUTOC register.   **/  static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw, -                                             ixgbe_link_speed *speed, -                                             bool *autoneg) +					     ixgbe_link_speed *speed, +					     bool *autoneg)  {  	s32 status = 0;  	u32 autoc = 0; @@ -337,19 +337,25 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)  	int i;  	bool link_up; -	/* -	 * Validate the water mark configuration for packet buffer 0.  Zero -	 * water marks indicate that the packet buffer was not configured -	 * and the watermarks for packet buffer 0 should always be configured. -	 */ -	if (!hw->fc.low_water || -	    !hw->fc.high_water[0] || -	    !hw->fc.pause_time) { -		hw_dbg(hw, "Invalid water mark configuration\n"); +	/* Validate the water mark configuration */ +	if (!hw->fc.pause_time) {  		ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;  		goto out;  	} +	/* Low water mark of zero causes XOFF floods */ +	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { +		if ((hw->fc.current_mode & ixgbe_fc_tx_pause) && +		    hw->fc.high_water[i]) { +			if (!hw->fc.low_water[i] || +			    hw->fc.low_water[i] >= hw->fc.high_water[i]) { +				hw_dbg(hw, "Invalid water mark configuration\n"); +				ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; +				goto out; +			} +		} +	} +  	/*  	 * On 82598 having Rx FC on causes resets while doing 1G  	 * so if it's on turn it off once we know link_speed. For @@ -432,12 +438,11 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)  	IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg);  	IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg); -	fcrtl = (hw->fc.low_water << 10) | IXGBE_FCRTL_XONE; -  	/* Set up and enable Rx high/low water mark thresholds, enable XON. */  	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {  		if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&  		    hw->fc.high_water[i]) { +			fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;  			fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;  			IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl);  			IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), fcrth); @@ -468,7 +473,7 @@ out:   *  Restarts the link.  Performs autonegotiation if needed.   **/  static s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw, -                                      bool autoneg_wait_to_complete) +				      bool autoneg_wait_to_complete)  {  	u32 autoc_reg;  	u32 links_reg; @@ -550,8 +555,8 @@ static s32 ixgbe_validate_link_ready(struct ixgbe_hw *hw)   *  Reads the links register to determine if link is up and the current speed   **/  static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, -                                      ixgbe_link_speed *speed, bool *link_up, -                                      bool link_up_wait_to_complete) +				      ixgbe_link_speed *speed, bool *link_up, +				      bool link_up_wait_to_complete)  {  	u32 links_reg;  	u32 i; @@ -567,7 +572,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,  		hw->phy.ops.read_reg(hw, 0xC79F, MDIO_MMD_PMAPMD, &link_reg);  		hw->phy.ops.read_reg(hw, 0xC79F, MDIO_MMD_PMAPMD, &link_reg);  		hw->phy.ops.read_reg(hw, 0xC00C, MDIO_MMD_PMAPMD, -		                     &adapt_comp_reg); +				     &adapt_comp_reg);  		if (link_up_wait_to_complete) {  			for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {  				if ((link_reg & 1) && @@ -579,11 +584,11 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,  				}  				msleep(100);  				hw->phy.ops.read_reg(hw, 0xC79F, -				                     MDIO_MMD_PMAPMD, -				                     &link_reg); +						     MDIO_MMD_PMAPMD, +						     &link_reg);  				hw->phy.ops.read_reg(hw, 0xC00C, -				                     MDIO_MMD_PMAPMD, -				                     &adapt_comp_reg); +						     MDIO_MMD_PMAPMD, +						     &adapt_comp_reg);  			}  		} else {  			if ((link_reg & 1) && ((adapt_comp_reg & 1) == 0)) @@ -656,7 +661,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,  	/* Set KX4/KX support according to speed requested */  	else if (link_mode == IXGBE_AUTOC_LMS_KX4_AN || -	         link_mode == IXGBE_AUTOC_LMS_KX4_AN_1G_AN) { +		 link_mode == IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {  		autoc &= ~IXGBE_AUTOC_KX4_KX_SUPP_MASK;  		if (speed & IXGBE_LINK_SPEED_10GB_FULL)  			autoc |= IXGBE_AUTOC_KX4_SUPP; @@ -689,14 +694,14 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,   *  Sets the link speed in the AUTOC register in the MAC and restarts link.   **/  static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw, -                                               ixgbe_link_speed speed, -                                               bool autoneg_wait_to_complete) +					       ixgbe_link_speed speed, +					       bool autoneg_wait_to_complete)  {  	s32 status;  	/* Setup the PHY according to input speed */  	status = hw->phy.ops.setup_link_speed(hw, speed, -	                                      autoneg_wait_to_complete); +					      autoneg_wait_to_complete);  	/* Set up MAC */  	ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete); @@ -735,28 +740,28 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)  	if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) {  		/* Enable Tx Atlas so packets can be transmitted again */  		hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, -		                             &analog_val); +					     &analog_val);  		analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN;  		hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, -		                              analog_val); +					      analog_val);  		hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G, -		                             &analog_val); +					     &analog_val);  		analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL;  		hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G, -		                              analog_val); +					      analog_val);  		hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G, -		                             &analog_val); +					     &analog_val);  		analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL;  		hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G, -		                              analog_val); +					      analog_val);  		hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN, -		                             &analog_val); +					     &analog_val);  		analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL;  		hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN, -		                              analog_val); +					      analog_val);  	}  	/* Reset PHY */ @@ -955,7 +960,7 @@ static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw)  	for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)  		for (offset = 0; offset < hw->mac.vft_size; offset++)  			IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset), -			                0); +					0);  	return 0;  } @@ -973,7 +978,7 @@ static s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)  	u32  atlas_ctl;  	IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, -	                IXGBE_ATLASCTL_WRITE_CMD | (reg << 8)); +			IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));  	IXGBE_WRITE_FLUSH(hw);  	udelay(10);  	atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL); @@ -1237,14 +1242,14 @@ static void ixgbe_set_lan_id_multi_port_pcie_82598(struct ixgbe_hw *hw)  }  /** - * ixgbe_set_rxpba_82598 - Configure packet buffers + * ixgbe_set_rxpba_82598 - Initialize RX packet buffer   * @hw: pointer to hardware structure - * @dcb_config: pointer to ixgbe_dcb_config structure - * - * Configure packet buffers. - */ -static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb, u32 headroom, -				  int strategy) + * @num_pb: number of packet buffers to allocate + * @headroom: reserve n KB of headroom + * @strategy: packet buffer allocation strategy + **/ +static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb, +				  u32 headroom, int strategy)  {  	u32 rxpktsize = IXGBE_RXPBSIZE_64KB;  	u8  i = 0; @@ -1273,8 +1278,6 @@ static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb, u32 headroom,  	/* Setup Tx packet buffer sizes */  	for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++)  		IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), IXGBE_TXPBSIZE_40KB); - -	return;  }  static struct ixgbe_mac_operations mac_ops_82598 = { @@ -1315,7 +1318,8 @@ static struct ixgbe_mac_operations mac_ops_82598 = {  	.release_swfw_sync      = &ixgbe_release_swfw_sync,  	.get_thermal_sensor_data = NULL,  	.init_thermal_sensor_thresh = NULL, -	.mng_fw_enabled		= NULL, +	.prot_autoc_read	= &prot_autoc_read_generic, +	.prot_autoc_write	= &prot_autoc_write_generic,  };  static struct ixgbe_eeprom_operations eeprom_ops_82598 = { diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c index 007a0083a63..bc7c924240a 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -47,24 +48,26 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,  						 ixgbe_link_speed speed,  						 bool autoneg_wait_to_complete);  static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw, -                                           ixgbe_link_speed speed, -                                           bool autoneg_wait_to_complete); +					   ixgbe_link_speed speed, +					   bool autoneg_wait_to_complete);  static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw);  static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,  				      bool autoneg_wait_to_complete);  static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, -                               ixgbe_link_speed speed, -                               bool autoneg_wait_to_complete); +			       ixgbe_link_speed speed, +			       bool autoneg_wait_to_complete);  static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw, -                                         ixgbe_link_speed speed, -                                         bool autoneg_wait_to_complete); +					 ixgbe_link_speed speed, +					 bool autoneg_wait_to_complete);  static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw);  static s32 ixgbe_read_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,  				     u8 dev_addr, u8 *data);  static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,  				      u8 dev_addr, u8 data); +static s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw); +static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw); -static bool ixgbe_mng_enabled(struct ixgbe_hw *hw) +bool ixgbe_mng_enabled(struct ixgbe_hw *hw)  {  	u32 fwsm, manc, factps; @@ -91,11 +94,11 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)  	 * and MNG not enabled  	 */  	if ((mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) && -	    !hw->mng_fw_enabled) { +	    !ixgbe_mng_enabled(hw)) {  		mac->ops.disable_tx_laser = -		                       &ixgbe_disable_tx_laser_multispeed_fiber; +				       &ixgbe_disable_tx_laser_multispeed_fiber;  		mac->ops.enable_tx_laser = -		                        &ixgbe_enable_tx_laser_multispeed_fiber; +					&ixgbe_enable_tx_laser_multispeed_fiber;  		mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;  	} else {  		mac->ops.disable_tx_laser = NULL; @@ -122,7 +125,6 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)  {  	s32 ret_val = 0;  	u16 list_offset, data_offset, data_value; -	bool got_lock = false;  	if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {  		ixgbe_init_mac_link_ops_82599(hw); @@ -130,13 +132,13 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)  		hw->phy.ops.reset = NULL;  		ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset, -		                                              &data_offset); +							      &data_offset);  		if (ret_val != 0)  			goto setup_sfp_out;  		/* PHY config will finish before releasing the semaphore */  		ret_val = hw->mac.ops.acquire_swfw_sync(hw, -		                                        IXGBE_GSSR_MAC_CSR_SM); +							IXGBE_GSSR_MAC_CSR_SM);  		if (ret_val != 0) {  			ret_val = IXGBE_ERR_SWFW_SYNC;  			goto setup_sfp_out; @@ -160,30 +162,10 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)  		usleep_range(hw->eeprom.semaphore_delay * 1000,  			     hw->eeprom.semaphore_delay * 2000); -		/* Need SW/FW semaphore around AUTOC writes if LESM on, -		 * likewise reset_pipeline requires lock as it also writes -		 * AUTOC. -		 */ -		if (ixgbe_verify_lesm_fw_enabled_82599(hw)) { -			ret_val = hw->mac.ops.acquire_swfw_sync(hw, -							IXGBE_GSSR_MAC_CSR_SM); -			if (ret_val) -				goto setup_sfp_out; - -			got_lock = true; -		} -  		/* Restart DSP and set SFI mode */ -		IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((hw->mac.orig_autoc) | -				IXGBE_AUTOC_LMS_10G_SERIAL)); -		hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); -		ret_val = ixgbe_reset_pipeline_82599(hw); - -		if (got_lock) { -			hw->mac.ops.release_swfw_sync(hw, -						      IXGBE_GSSR_MAC_CSR_SM); -			got_lock = false; -		} +		ret_val = hw->mac.ops.prot_autoc_write(hw, +			hw->mac.orig_autoc | IXGBE_AUTOC_LMS_10G_SERIAL, +			false);  		if (ret_val) {  			hw_dbg(hw, " sfp module setup not complete\n"); @@ -207,6 +189,81 @@ setup_sfp_err:  	return IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;  } +/** + *  prot_autoc_read_82599 - Hides MAC differences needed for AUTOC read + *  @hw: pointer to hardware structure + *  @locked: Return the if we locked for this read. + *  @reg_val: Value we read from AUTOC + * + *  For this part (82599) we need to wrap read-modify-writes with a possible + *  FW/SW lock.  It is assumed this lock will be freed with the next + *  prot_autoc_write_82599().  Note, that locked can only be true in cases + *  where this function doesn't return an error. + **/ +static s32 prot_autoc_read_82599(struct ixgbe_hw *hw, bool *locked, +				 u32 *reg_val) +{ +	s32 ret_val; + +	*locked = false; +	/* If LESM is on then we need to hold the SW/FW semaphore. */ +	if (ixgbe_verify_lesm_fw_enabled_82599(hw)) { +		ret_val = hw->mac.ops.acquire_swfw_sync(hw, +					IXGBE_GSSR_MAC_CSR_SM); +		if (ret_val) +			return IXGBE_ERR_SWFW_SYNC; + +		*locked = true; +	} + +	*reg_val = IXGBE_READ_REG(hw, IXGBE_AUTOC); +	return 0; +} + +/** + * prot_autoc_write_82599 - Hides MAC differences needed for AUTOC write + * @hw: pointer to hardware structure + * @reg_val: value to write to AUTOC + * @locked: bool to indicate whether the SW/FW lock was already taken by + *	     previous proc_autoc_read_82599. + * + * This part (82599) may need to hold a the SW/FW lock around all writes to + * AUTOC. Likewise after a write we need to do a pipeline reset. + **/ +static s32 prot_autoc_write_82599(struct ixgbe_hw *hw, u32 autoc, bool locked) +{ +	s32 ret_val = 0; + +	/* Blocked by MNG FW so bail */ +	if (ixgbe_check_reset_blocked(hw)) +		goto out; + +	/* We only need to get the lock if: +	 *  - We didn't do it already (in the read part of a read-modify-write) +	 *  - LESM is enabled. +	 */ +	if (!locked && ixgbe_verify_lesm_fw_enabled_82599(hw)) { +		ret_val = hw->mac.ops.acquire_swfw_sync(hw, +					IXGBE_GSSR_MAC_CSR_SM); +		if (ret_val) +			return IXGBE_ERR_SWFW_SYNC; + +		locked = true; +	} + +	IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc); +	ret_val = ixgbe_reset_pipeline_82599(hw); + +out: +	/* Free the SW/FW semaphore as we either grabbed it here or +	 * already had it when this function was called. +	 */ +	if (locked) +		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM); + +	return ret_val; +} +  static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)  {  	struct ixgbe_mac_info *mac = &hw->mac; @@ -216,6 +273,7 @@ static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)  	mac->mcft_size = IXGBE_82599_MC_TBL_SIZE;  	mac->vft_size = IXGBE_82599_VFT_TBL_SIZE;  	mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES; +	mac->rx_pb_size = IXGBE_82599_RX_PB_SIZE;  	mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES;  	mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES;  	mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw); @@ -276,7 +334,7 @@ static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)  		phy->ops.check_link = &ixgbe_check_phy_link_tnx;  		phy->ops.setup_link = &ixgbe_setup_phy_link_tnx;  		phy->ops.get_firmware_version = -		             &ixgbe_get_phy_firmware_version_tnx; +			     &ixgbe_get_phy_firmware_version_tnx;  		break;  	default:  		break; @@ -294,7 +352,7 @@ static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)   *  Determines the link capabilities by reading the AUTOC register.   **/  static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw, -                                             ixgbe_link_speed *speed, +					     ixgbe_link_speed *speed,  					     bool *autoneg)  {  	s32 status = 0; @@ -456,12 +514,20 @@ out:   *   * Disables link, should be called during D3 power down sequence.   * - */ + **/  static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw)  { -	u32 autoc2_reg; +	u32 autoc2_reg, fwsm; +	u16 ee_ctrl_2 = 0; + +	hw->eeprom.ops.read(hw, IXGBE_EEPROM_CTRL_2, &ee_ctrl_2); -	if (!hw->mng_fw_enabled && !hw->wol_enabled) { +	/* Check to see if MNG FW could be enabled */ +	fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM); + +	if (((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT) && +	    !hw->wol_enabled && +	    ee_ctrl_2 & IXGBE_EEPROM_CCD_BIT) {  		autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);  		autoc2_reg |= IXGBE_AUTOC2_LINK_DISABLE_ON_D3_MASK;  		IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg); @@ -477,7 +543,7 @@ static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw)   *  Restarts the link.  Performs autonegotiation if needed.   **/  static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw, -                               bool autoneg_wait_to_complete) +			       bool autoneg_wait_to_complete)  {  	u32 autoc_reg;  	u32 links_reg; @@ -542,6 +608,10 @@ static void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)  {  	u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP); +	/* Blocked by MNG FW so bail */ +	if (ixgbe_check_reset_blocked(hw)) +		return; +  	/* Disable tx laser; allow 100us to go dark per spec */  	esdp_reg |= IXGBE_ESDP_SDP3;  	IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); @@ -582,6 +652,10 @@ static void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)   **/  static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)  { +	/* Blocked by MNG FW so bail */ +	if (ixgbe_check_reset_blocked(hw)) +		return; +  	if (hw->mac.autotry_restart) {  		ixgbe_disable_tx_laser_multispeed_fiber(hw);  		ixgbe_enable_tx_laser_multispeed_fiber(hw); @@ -590,75 +664,6 @@ static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)  }  /** - *  ixgbe_set_fiber_fixed_speed - Set module link speed for fixed fiber - *  @hw: pointer to hardware structure - *  @speed: link speed to set - * - *  We set the module speed differently for fixed fiber.  For other - *  multi-speed devices we don't have an error value so here if we - *  detect an error we just log it and exit. - */ -static void ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw, -					ixgbe_link_speed speed) -{ -	s32 status; -	u8 rs, eeprom_data; - -	switch (speed) { -	case IXGBE_LINK_SPEED_10GB_FULL: -		/* one bit mask same as setting on */ -		rs = IXGBE_SFF_SOFT_RS_SELECT_10G; -		break; -	case IXGBE_LINK_SPEED_1GB_FULL: -		rs = IXGBE_SFF_SOFT_RS_SELECT_1G; -		break; -	default: -		hw_dbg(hw, "Invalid fixed module speed\n"); -		return; -	} - -	/* Set RS0 */ -	status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB, -					   IXGBE_I2C_EEPROM_DEV_ADDR2, -					   &eeprom_data); -	if (status) { -		hw_dbg(hw, "Failed to read Rx Rate Select RS0\n"); -		goto out; -	} - -	eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs; - -	status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB, -					    IXGBE_I2C_EEPROM_DEV_ADDR2, -					    eeprom_data); -	if (status) { -		hw_dbg(hw, "Failed to write Rx Rate Select RS0\n"); -		goto out; -	} - -	/* Set RS1 */ -	status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB, -					   IXGBE_I2C_EEPROM_DEV_ADDR2, -					   &eeprom_data); -	if (status) { -		hw_dbg(hw, "Failed to read Rx Rate Select RS1\n"); -		goto out; -	} - -	eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs; - -	status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB, -					    IXGBE_I2C_EEPROM_DEV_ADDR2, -					    eeprom_data); -	if (status) { -		hw_dbg(hw, "Failed to write Rx Rate Select RS1\n"); -		goto out; -	} -out: -	return; -} - -/**   *  ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed   *  @hw: pointer to hardware structure   *  @speed: new link speed @@ -667,8 +672,8 @@ out:   *  Set the link speed in the AUTOC register and restarts link.   **/  static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, -                                          ixgbe_link_speed speed, -                                          bool autoneg_wait_to_complete) +					  ixgbe_link_speed speed, +					  bool autoneg_wait_to_complete)  {  	s32 status = 0;  	ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN; @@ -768,10 +773,6 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,  		/* Set the module link speed */  		switch (hw->phy.media_type) { -		case ixgbe_media_type_fiber_fixed: -			ixgbe_set_fiber_fixed_speed(hw, -						IXGBE_LINK_SPEED_1GB_FULL); -			break;  		case ixgbe_media_type_fiber:  			esdp_reg &= ~IXGBE_ESDP_SDP5;  			esdp_reg |= IXGBE_ESDP_SDP5_DIR; @@ -819,8 +820,8 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,  	 */  	if (speedcnt > 1)  		status = ixgbe_setup_mac_link_multispeed_fiber(hw, -		                                               highest_link_speed, -		                                               autoneg_wait_to_complete); +							       highest_link_speed, +							       autoneg_wait_to_complete);  out:  	/* Set autoneg_advertised value based on input link speed */ @@ -941,8 +942,7 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,  out:  	if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL)) -		hw_dbg(hw, "Smartspeed has downgraded the link speed from " -		       "the maximum advertised\n"); +		hw_dbg(hw, "Smartspeed has downgraded the link speed from the maximum advertised\n");  	return status;  } @@ -958,16 +958,19 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,  				      ixgbe_link_speed speed,  				      bool autoneg_wait_to_complete)  { +	bool autoneg = false;  	s32 status = 0; -	u32 autoc, pma_pmd_1g, link_mode, start_autoc; +	u32 pma_pmd_1g, link_mode, links_reg, i;  	u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2); -	u32 orig_autoc = 0;  	u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK; -	u32 links_reg; -	u32 i;  	ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN; -	bool got_lock = false; -	bool autoneg = false; + +	/* holds the value of AUTOC register at this current point in time */ +	u32 current_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); +	/* holds the cached value of AUTOC register */ +	u32 orig_autoc = 0; +	/* temporary variable used for comparison purposes */ +	u32 autoc = current_autoc;  	/* Check to see if speed passed in is supported. */  	status = hw->mac.ops.get_link_capabilities(hw, &link_capabilities, @@ -984,12 +987,10 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,  	/* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/  	if (hw->mac.orig_link_settings_stored) -		autoc = hw->mac.orig_autoc; +		orig_autoc = hw->mac.orig_autoc;  	else -		autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); +		orig_autoc = autoc; -	orig_autoc = autoc; -	start_autoc = hw->mac.cached_autoc;  	link_mode = autoc & IXGBE_AUTOC_LMS_MASK;  	pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK; @@ -1008,8 +1009,8 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,  		if (speed & IXGBE_LINK_SPEED_1GB_FULL)  			autoc |= IXGBE_AUTOC_KX_SUPP;  	} else if ((pma_pmd_1g == IXGBE_AUTOC_1G_SFI) && -	           (link_mode == IXGBE_AUTOC_LMS_1G_LINK_NO_AN || -	            link_mode == IXGBE_AUTOC_LMS_1G_AN)) { +		   (link_mode == IXGBE_AUTOC_LMS_1G_LINK_NO_AN || +		    link_mode == IXGBE_AUTOC_LMS_1G_AN)) {  		/* Switch from 1G SFI to 10G SFI if requested */  		if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&  		    (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)) { @@ -1017,7 +1018,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,  			autoc |= IXGBE_AUTOC_LMS_10G_SERIAL;  		}  	} else if ((pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI) && -	           (link_mode == IXGBE_AUTOC_LMS_10G_SERIAL)) { +		   (link_mode == IXGBE_AUTOC_LMS_10G_SERIAL)) {  		/* Switch from 10G SFI to 1G SFI if requested */  		if ((speed == IXGBE_LINK_SPEED_1GB_FULL) &&  		    (pma_pmd_1g == IXGBE_AUTOC_1G_SFI)) { @@ -1029,28 +1030,11 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,  		}  	} -	if (autoc != start_autoc) { -		/* Need SW/FW semaphore around AUTOC writes if LESM is on, -		 * likewise reset_pipeline requires us to hold this lock as -		 * it also writes to AUTOC. -		 */ -		if (ixgbe_verify_lesm_fw_enabled_82599(hw)) { -			status = hw->mac.ops.acquire_swfw_sync(hw, -							IXGBE_GSSR_MAC_CSR_SM); -			if (status != 0) -				goto out; - -			got_lock = true; -		} - +	if (autoc != current_autoc) {  		/* Restart link */ -		IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc); -		hw->mac.cached_autoc = autoc; -		ixgbe_reset_pipeline_82599(hw); - -		if (got_lock) -			hw->mac.ops.release_swfw_sync(hw, -						      IXGBE_GSSR_MAC_CSR_SM); +		status = hw->mac.ops.prot_autoc_write(hw, autoc, false); +		if (status) +			goto out;  		/* Only poll for autoneg to complete if specified to do so */  		if (autoneg_wait_to_complete) { @@ -1067,9 +1051,8 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,  				}  				if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {  					status = -					        IXGBE_ERR_AUTONEG_NOT_COMPLETE; -					hw_dbg(hw, "Autoneg did not " -					       "complete.\n"); +						IXGBE_ERR_AUTONEG_NOT_COMPLETE; +					hw_dbg(hw, "Autoneg did not complete.\n");  				}  			}  		} @@ -1091,14 +1074,14 @@ out:   *  Restarts link on PHY and MAC based on settings passed in.   **/  static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw, -                                         ixgbe_link_speed speed, -                                         bool autoneg_wait_to_complete) +					 ixgbe_link_speed speed, +					 bool autoneg_wait_to_complete)  {  	s32 status;  	/* Setup the PHY according to input speed */  	status = hw->phy.ops.setup_link_speed(hw, speed, -	                                      autoneg_wait_to_complete); +					      autoneg_wait_to_complete);  	/* Set up MAC */  	ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete); @@ -1117,7 +1100,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)  {  	ixgbe_link_speed link_speed;  	s32 status; -	u32 ctrl, i, autoc2; +	u32 ctrl, i, autoc, autoc2;  	u32 curr_lms;  	bool link_up = false; @@ -1151,11 +1134,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)  		hw->phy.ops.reset(hw);  	/* remember AUTOC from before we reset */ -	if (hw->mac.cached_autoc) -		curr_lms = hw->mac.cached_autoc & IXGBE_AUTOC_LMS_MASK; -	else -		curr_lms = IXGBE_READ_REG(hw, IXGBE_AUTOC) & -			   IXGBE_AUTOC_LMS_MASK; +	curr_lms = IXGBE_READ_REG(hw, IXGBE_AUTOC) & IXGBE_AUTOC_LMS_MASK;  mac_reset_top:  	/* @@ -1205,7 +1184,7 @@ mac_reset_top:  	 * stored off yet.  Otherwise restore the stored original  	 * values since the reset operation sets back to defaults.  	 */ -	hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); +	autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);  	autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);  	/* Enable link if disabled in NVM */ @@ -1216,7 +1195,7 @@ mac_reset_top:  	}  	if (hw->mac.orig_link_settings_stored == false) { -		hw->mac.orig_autoc = hw->mac.cached_autoc; +		hw->mac.orig_autoc = autoc;  		hw->mac.orig_autoc2 = autoc2;  		hw->mac.orig_link_settings_stored = true;  	} else { @@ -1227,41 +1206,25 @@ mac_reset_top:  		 * Likewise if we support WoL we don't want change the  		 * LMS state either.  		 */ -		if ((hw->phy.multispeed_fiber && hw->mng_fw_enabled) || +		if ((hw->phy.multispeed_fiber && ixgbe_mng_enabled(hw)) ||  		    hw->wol_enabled)  			hw->mac.orig_autoc =  				(hw->mac.orig_autoc & ~IXGBE_AUTOC_LMS_MASK) |  				curr_lms; -		if (hw->mac.cached_autoc != hw->mac.orig_autoc) { -			/* Need SW/FW semaphore around AUTOC writes if LESM is -			 * on, likewise reset_pipeline requires us to hold -			 * this lock as it also writes to AUTOC. -			 */ -			bool got_lock = false; -			if (ixgbe_verify_lesm_fw_enabled_82599(hw)) { -				status = hw->mac.ops.acquire_swfw_sync(hw, -							IXGBE_GSSR_MAC_CSR_SM); -				if (status) -					goto reset_hw_out; - -				got_lock = true; -			} - -			IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc); -			hw->mac.cached_autoc = hw->mac.orig_autoc; -			ixgbe_reset_pipeline_82599(hw); - -			if (got_lock) -				hw->mac.ops.release_swfw_sync(hw, -							IXGBE_GSSR_MAC_CSR_SM); +		if (autoc != hw->mac.orig_autoc) { +			status = hw->mac.ops.prot_autoc_write(hw, +							hw->mac.orig_autoc, +							false); +			if (status) +				goto reset_hw_out;  		}  		if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=  		    (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {  			autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;  			autoc2 |= (hw->mac.orig_autoc2 & -			           IXGBE_AUTOC2_UPPER_MASK); +				   IXGBE_AUTOC2_UPPER_MASK);  			IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);  		}  	} @@ -1283,7 +1246,7 @@ mac_reset_top:  	/* Add the SAN MAC address to the RAR only if it's a valid address */  	if (is_valid_ether_addr(hw->mac.san_addr)) {  		hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1, -		                    hw->mac.san_addr, 0, IXGBE_RAH_AV); +				    hw->mac.san_addr, 0, IXGBE_RAH_AV);  		/* Save the SAN MAC RAR index */  		hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1; @@ -1294,7 +1257,7 @@ mac_reset_top:  	/* Store the alternative WWNN/WWPN prefix */  	hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix, -	                               &hw->mac.wwpn_prefix); +				       &hw->mac.wwpn_prefix);  reset_hw_out:  	return status; @@ -1308,6 +1271,7 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)  {  	int i;  	u32 fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL); +  	fdirctrl &= ~IXGBE_FDIRCTRL_INIT_DONE;  	/* @@ -1321,8 +1285,7 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)  		udelay(10);  	}  	if (i >= IXGBE_FDIRCMD_CMD_POLL) { -		hw_dbg(hw, "Flow Director previous command isn't complete, " -		       "aborting table re-initialization.\n"); +		hw_dbg(hw, "Flow Director previous command isn't complete, aborting table re-initialization.\n");  		return IXGBE_ERR_FDIR_REINIT_FAILED;  	} @@ -1336,12 +1299,12 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)  	 * - write 0 to bit 8 of FDIRCMD register  	 */  	IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, -	                (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) | -	                 IXGBE_FDIRCMD_CLEARHT)); +			(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) | +			 IXGBE_FDIRCMD_CLEARHT));  	IXGBE_WRITE_FLUSH(hw);  	IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, -	                (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) & -	                 ~IXGBE_FDIRCMD_CLEARHT)); +			(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) & +			 ~IXGBE_FDIRCMD_CLEARHT));  	IXGBE_WRITE_FLUSH(hw);  	/*  	 * Clear FDIR Hash register to clear any leftover hashes @@ -1356,7 +1319,7 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)  	/* Poll init-done after we write FDIRCTRL register */  	for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {  		if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) & -		                   IXGBE_FDIRCTRL_INIT_DONE) +				   IXGBE_FDIRCTRL_INIT_DONE)  			break;  		usleep_range(1000, 2000);  	} @@ -1405,7 +1368,7 @@ static void ixgbe_fdir_enable_82599(struct ixgbe_hw *hw, u32 fdirctrl)  	IXGBE_WRITE_FLUSH(hw);  	for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {  		if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) & -		                   IXGBE_FDIRCTRL_INIT_DONE) +				   IXGBE_FDIRCTRL_INIT_DONE)  			break;  		usleep_range(1000, 2000);  	} @@ -1490,7 +1453,7 @@ do { \  		bucket_hash ^= hi_hash_dword >> n; \  	else if (IXGBE_ATR_SIGNATURE_HASH_KEY & (0x01 << (n + 16))) \  		sig_hash ^= hi_hash_dword << (16 - n); \ -} while (0); +} while (0)  /**   *  ixgbe_atr_compute_sig_hash_82599 - Compute the signature hash @@ -1566,9 +1529,9 @@ static u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input,   *  @queue: queue index to direct traffic to   **/  s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw, -                                          union ixgbe_atr_hash_dword input, -                                          union ixgbe_atr_hash_dword common, -                                          u8 queue) +					  union ixgbe_atr_hash_dword input, +					  union ixgbe_atr_hash_dword common, +					  u8 queue)  {  	u64  fdirhashcmd;  	u32  fdircmd; @@ -1592,7 +1555,7 @@ s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,  	/* configure FDIRCMD register */  	fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE | -	          IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN; +		  IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;  	fdircmd |= input.formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;  	fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT; @@ -1616,7 +1579,7 @@ do { \  		bucket_hash ^= lo_hash_dword >> n; \  	if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << (n + 16))) \  		bucket_hash ^= hi_hash_dword >> n; \ -} while (0); +} while (0)  /**   *  ixgbe_atr_compute_perfect_hash_82599 - Compute the perfect filter hash @@ -1634,35 +1597,20 @@ void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,  {  	u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan; -	u32 bucket_hash = 0; +	u32 bucket_hash = 0, hi_dword = 0; +	int i;  	/* Apply masks to input data */ -	input->dword_stream[0]  &= input_mask->dword_stream[0]; -	input->dword_stream[1]  &= input_mask->dword_stream[1]; -	input->dword_stream[2]  &= input_mask->dword_stream[2]; -	input->dword_stream[3]  &= input_mask->dword_stream[3]; -	input->dword_stream[4]  &= input_mask->dword_stream[4]; -	input->dword_stream[5]  &= input_mask->dword_stream[5]; -	input->dword_stream[6]  &= input_mask->dword_stream[6]; -	input->dword_stream[7]  &= input_mask->dword_stream[7]; -	input->dword_stream[8]  &= input_mask->dword_stream[8]; -	input->dword_stream[9]  &= input_mask->dword_stream[9]; -	input->dword_stream[10] &= input_mask->dword_stream[10]; +	for (i = 0; i <= 10; i++) +		input->dword_stream[i] &= input_mask->dword_stream[i];  	/* record the flow_vm_vlan bits as they are a key part to the hash */  	flow_vm_vlan = ntohl(input->dword_stream[0]);  	/* generate common hash dword */ -	hi_hash_dword = ntohl(input->dword_stream[1] ^ -				    input->dword_stream[2] ^ -				    input->dword_stream[3] ^ -				    input->dword_stream[4] ^ -				    input->dword_stream[5] ^ -				    input->dword_stream[6] ^ -				    input->dword_stream[7] ^ -				    input->dword_stream[8] ^ -				    input->dword_stream[9] ^ -				    input->dword_stream[10]); +	for (i = 1; i <= 10; i++) +		hi_dword ^= input->dword_stream[i]; +	hi_hash_dword = ntohl(hi_dword);  	/* low dword is word swapped version of common */  	lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16); @@ -1681,21 +1629,8 @@ void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,  	lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16);  	/* Process remaining 30 bit of the key */ -	IXGBE_COMPUTE_BKT_HASH_ITERATION(1); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(2); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(3); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(4); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(5); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(6); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(7); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(8); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(9); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(10); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(11); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(12); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(13); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(14); -	IXGBE_COMPUTE_BKT_HASH_ITERATION(15); +	for (i = 1; i <= 15; i++) +		IXGBE_COMPUTE_BKT_HASH_ITERATION(i);  	/*  	 * Limit hash to 13 bits since max bucket count is 8K. @@ -1716,6 +1651,7 @@ void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,  static u32 ixgbe_get_fdirtcpm_82599(union ixgbe_atr_input *input_mask)  {  	u32 mask = ntohs(input_mask->formatted.dst_port); +  	mask <<= IXGBE_FDIRTCPM_DPORTM_SHIFT;  	mask |= ntohs(input_mask->formatted.src_port);  	mask = ((mask & 0x55555555) << 1) | ((mask & 0xAAAAAAAA) >> 1); @@ -1950,7 +1886,7 @@ static s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val)  	u32  core_ctl;  	IXGBE_WRITE_REG(hw, IXGBE_CORECTL, IXGBE_CORECTL_WRITE_CMD | -	                (reg << 8)); +			(reg << 8));  	IXGBE_WRITE_FLUSH(hw);  	udelay(10);  	core_ctl = IXGBE_READ_REG(hw, IXGBE_CORECTL); @@ -2001,7 +1937,6 @@ static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)  	/* We need to run link autotry after the driver loads */  	hw->mac.autotry_restart = true; -	hw->mac.rx_pb_size = IXGBE_82599_RX_PB_SIZE;  	if (ret_val == 0)  		ret_val = ixgbe_verify_fw_version_82599(hw); @@ -2260,7 +2195,7 @@ fw_version_err:   *  Returns true if the LESM FW module is present and enabled. Otherwise   *  returns false. Smart Speed must be disabled if LESM FW module is enabled.   **/ -bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw) +static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw)  {  	bool lesm_enabled = false;  	u16 fw_offset, fw_lesm_param_offset, fw_lesm_state; @@ -2366,7 +2301,7 @@ static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,   * full pipeline reset.  Note - We must hold the SW/FW semaphore before writing   * to AUTOC, so this function assumes the semaphore is held.   **/ -s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw) +static s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)  {  	s32 ret_val;  	u32 anlp1_reg = 0; @@ -2380,11 +2315,12 @@ s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)  		IXGBE_WRITE_FLUSH(hw);  	} -	autoc_reg = hw->mac.cached_autoc; +	autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);  	autoc_reg |= IXGBE_AUTOC_AN_RESTART;  	/* Write AUTOC register with toggled LMS[2] bit and Restart_AN */ -	IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg ^ IXGBE_AUTOC_LMS_1G_AN); +	IXGBE_WRITE_REG(hw, IXGBE_AUTOC, +			autoc_reg ^ (0x4 << IXGBE_AUTOC_LMS_SHIFT));  	/* Wait for AN to leave state 0 */  	for (i = 0; i < 10; i++) { @@ -2565,7 +2501,8 @@ static struct ixgbe_mac_operations mac_ops_82599 = {  	.release_swfw_sync      = &ixgbe_release_swfw_sync,  	.get_thermal_sensor_data = &ixgbe_get_thermal_sensor_data_generic,  	.init_thermal_sensor_thresh = &ixgbe_init_thermal_sensor_thresh_generic, -	.mng_fw_enabled		= &ixgbe_mng_enabled, +	.prot_autoc_read	= &prot_autoc_read_82599, +	.prot_autoc_write	= &prot_autoc_write_82599,  };  static struct ixgbe_eeprom_operations eeprom_ops_82599 = { diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index b5c434b617b..4e5385a2a46 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -40,7 +41,7 @@ static void ixgbe_release_eeprom_semaphore(struct ixgbe_hw *hw);  static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw);  static void ixgbe_standby_eeprom(struct ixgbe_hw *hw);  static void ixgbe_shift_out_eeprom_bits(struct ixgbe_hw *hw, u16 data, -                                        u16 count); +					u16 count);  static u16 ixgbe_shift_in_eeprom_bits(struct ixgbe_hw *hw, u16 count);  static void ixgbe_raise_eeprom_clk(struct ixgbe_hw *hw, u32 *eec);  static void ixgbe_lower_eeprom_clk(struct ixgbe_hw *hw, u32 *eec); @@ -72,7 +73,6 @@ bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)  	bool link_up;  	switch (hw->phy.media_type) { -	case ixgbe_media_type_fiber_fixed:  	case ixgbe_media_type_fiber:  		hw->mac.ops.check_link(hw, &speed, &link_up, false);  		/* if link is down, assume supported */ @@ -114,7 +114,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)  	s32 ret_val = 0;  	u32 reg = 0, reg_bp = 0;  	u16 reg_cu = 0; -	bool got_lock = false; +	bool locked = false;  	/*  	 * Validate the requested mode.  Strict IEEE mode does not allow @@ -139,11 +139,16 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)  	 * we link at 10G, the 1G advertisement is harmless and vice versa.  	 */  	switch (hw->phy.media_type) { -	case ixgbe_media_type_fiber_fixed: -	case ixgbe_media_type_fiber:  	case ixgbe_media_type_backplane: +		/* some MAC's need RMW protection on AUTOC */ +		ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, ®_bp); +		if (ret_val) +			goto out; + +		/* only backplane uses autoc so fall though */ +	case ixgbe_media_type_fiber:  		reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA); -		reg_bp = IXGBE_READ_REG(hw, IXGBE_AUTOC); +  		break;  	case ixgbe_media_type_copper:  		hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE, @@ -240,27 +245,12 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)  		 * LESM is on, likewise reset_pipeline requries the lock as  		 * it also writes AUTOC.  		 */ -		if ((hw->mac.type == ixgbe_mac_82599EB) && -		    ixgbe_verify_lesm_fw_enabled_82599(hw)) { -			ret_val = hw->mac.ops.acquire_swfw_sync(hw, -							IXGBE_GSSR_MAC_CSR_SM); -			if (ret_val) -				goto out; - -			got_lock = true; -		} - -		IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_bp); - -		if (hw->mac.type == ixgbe_mac_82599EB) -			ixgbe_reset_pipeline_82599(hw); - -		if (got_lock) -			hw->mac.ops.release_swfw_sync(hw, -						      IXGBE_GSSR_MAC_CSR_SM); +		ret_val = hw->mac.ops.prot_autoc_write(hw, reg_bp, locked); +		if (ret_val) +			goto out;  	} else if ((hw->phy.media_type == ixgbe_media_type_copper) && -		    ixgbe_device_supports_autoneg_fc(hw)) { +		   ixgbe_device_supports_autoneg_fc(hw)) {  		hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE,  				      MDIO_MMD_AN, reg_cu);  	} @@ -281,6 +271,7 @@ out:   **/  s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)  { +	s32 ret_val;  	u32 ctrl_ext;  	/* Set the media type */ @@ -302,12 +293,15 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)  	IXGBE_WRITE_FLUSH(hw);  	/* Setup flow control */ -	ixgbe_setup_fc(hw); +	ret_val = ixgbe_setup_fc(hw); +	if (!ret_val) +		goto out;  	/* Clear adapter stopped flag */  	hw->adapter_stopped = false; -	return 0; +out: +	return ret_val;  }  /** @@ -491,7 +485,7 @@ s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw)   *  Reads the part number string from the EEPROM.   **/  s32 ixgbe_read_pba_string_generic(struct ixgbe_hw *hw, u8 *pba_num, -                                  u32 pba_num_size) +				  u32 pba_num_size)  {  	s32 ret_val;  	u16 data; @@ -656,20 +650,17 @@ enum ixgbe_bus_speed ixgbe_convert_bus_speed(u16 link_status)   **/  s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw)  { -	struct ixgbe_adapter *adapter = hw->back; -	struct ixgbe_mac_info *mac = &hw->mac;  	u16 link_status;  	hw->bus.type = ixgbe_bus_type_pci_express;  	/* Get the negotiated link width and speed from PCI config space */ -	pci_read_config_word(adapter->pdev, IXGBE_PCI_LINK_STATUS, -	                     &link_status); +	link_status = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_LINK_STATUS);  	hw->bus.width = ixgbe_convert_bus_width(link_status);  	hw->bus.speed = ixgbe_convert_bus_speed(link_status); -	mac->ops.set_lan_id(hw); +	hw->mac.ops.set_lan_id(hw);  	return 0;  } @@ -827,9 +818,8 @@ s32 ixgbe_init_eeprom_params_generic(struct ixgbe_hw *hw)  			eeprom->address_bits = 16;  		else  			eeprom->address_bits = 8; -		hw_dbg(hw, "Eeprom params: type = %d, size = %d, address bits: " -			  "%d\n", eeprom->type, eeprom->word_size, -			  eeprom->address_bits); +		hw_dbg(hw, "Eeprom params: type = %d, size = %d, address bits: %d\n", +		       eeprom->type, eeprom->word_size, eeprom->address_bits);  	}  	return 0; @@ -1208,7 +1198,7 @@ static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw,  	 */  	hw->eeprom.word_page_size = IXGBE_EEPROM_PAGE_SIZE_MAX - data[0]; -	hw_dbg(hw, "Detected EEPROM page size = %d words.", +	hw_dbg(hw, "Detected EEPROM page size = %d words.\n",  	       hw->eeprom.word_page_size);  out:  	return status; @@ -1401,8 +1391,7 @@ static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw)  	}  	if (i == timeout) { -		hw_dbg(hw, "Driver can't access the Eeprom - SMBI Semaphore " -		       "not granted.\n"); +		hw_dbg(hw, "Driver can't access the Eeprom - SMBI Semaphore not granted.\n");  		/*  		 * this release is particularly important because our attempts  		 * above to get the semaphore may have succeeded, and if there @@ -1447,14 +1436,12 @@ static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw)  		 * was not granted because we don't have access to the EEPROM  		 */  		if (i >= timeout) { -			hw_dbg(hw, "SWESMBI Software EEPROM semaphore " -			       "not granted.\n"); +			hw_dbg(hw, "SWESMBI Software EEPROM semaphore not granted.\n");  			ixgbe_release_eeprom_semaphore(hw);  			status = IXGBE_ERR_EEPROM;  		}  	} else { -		hw_dbg(hw, "Software semaphore SMBI between device drivers " -		       "not granted.\n"); +		hw_dbg(hw, "Software semaphore SMBI between device drivers not granted.\n");  	}  	return status; @@ -1496,7 +1483,7 @@ static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw)  	 */  	for (i = 0; i < IXGBE_EEPROM_MAX_RETRY_SPI; i += 5) {  		ixgbe_shift_out_eeprom_bits(hw, IXGBE_EEPROM_RDSR_OPCODE_SPI, -		                            IXGBE_EEPROM_OPCODE_BITS); +					    IXGBE_EEPROM_OPCODE_BITS);  		spi_stat_reg = (u8)ixgbe_shift_in_eeprom_bits(hw, 8);  		if (!(spi_stat_reg & IXGBE_EEPROM_STATUS_RDY_SPI))  			break; @@ -1545,7 +1532,7 @@ static void ixgbe_standby_eeprom(struct ixgbe_hw *hw)   *  @count: number of bits to shift out   **/  static void ixgbe_shift_out_eeprom_bits(struct ixgbe_hw *hw, u16 data, -                                        u16 count) +					u16 count)  {  	u32 eec;  	u32 mask; @@ -1749,7 +1736,7 @@ u16 ixgbe_calc_eeprom_checksum_generic(struct ixgbe_hw *hw)   *  caller does not need checksum_val, the value can be NULL.   **/  s32 ixgbe_validate_eeprom_checksum_generic(struct ixgbe_hw *hw, -                                           u16 *checksum_val) +					   u16 *checksum_val)  {  	s32 status;  	u16 checksum; @@ -1822,7 +1809,7 @@ s32 ixgbe_update_eeprom_checksum_generic(struct ixgbe_hw *hw)   *  Puts an ethernet address into a receive address register.   **/  s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq, -                          u32 enable_addr) +			  u32 enable_addr)  {  	u32 rar_low, rar_high;  	u32 rar_entries = hw->mac.num_rar_entries; @@ -2066,7 +2053,7 @@ s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw,  	if (hw->addr_ctrl.mta_in_use > 0)  		IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, -		                IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type); +				IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);  	hw_dbg(hw, "ixgbe_update_mc_addr_list_generic Complete\n");  	return 0; @@ -2084,7 +2071,7 @@ s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw)  	if (a->mta_in_use > 0)  		IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, IXGBE_MCSTCTRL_MFE | -		                hw->mac.mc_filter_type); +				hw->mac.mc_filter_type);  	return 0;  } @@ -2119,19 +2106,25 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)  	u32 fcrtl, fcrth;  	int i; -	/* -	 * Validate the water mark configuration for packet buffer 0.  Zero -	 * water marks indicate that the packet buffer was not configured -	 * and the watermarks for packet buffer 0 should always be configured. -	 */ -	if (!hw->fc.low_water || -	    !hw->fc.high_water[0] || -	    !hw->fc.pause_time) { -		hw_dbg(hw, "Invalid water mark configuration\n"); +	/* Validate the water mark configuration. */ +	if (!hw->fc.pause_time) {  		ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;  		goto out;  	} +	/* Low water mark of zero causes XOFF floods */ +	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { +		if ((hw->fc.current_mode & ixgbe_fc_tx_pause) && +		    hw->fc.high_water[i]) { +			if (!hw->fc.low_water[i] || +			    hw->fc.low_water[i] >= hw->fc.high_water[i]) { +				hw_dbg(hw, "Invalid water mark configuration\n"); +				ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; +				goto out; +			} +		} +	} +  	/* Negotiate the fc mode to use */  	ixgbe_fc_autoneg(hw); @@ -2194,12 +2187,11 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)  	IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);  	IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg); -	fcrtl = (hw->fc.low_water << 10) | IXGBE_FCRTL_XONE; -  	/* Set up and enable Rx high/low water mark thresholds, enable XON. */  	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {  		if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&  		    hw->fc.high_water[i]) { +			fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;  			IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), fcrtl);  			fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;  		} else { @@ -2406,7 +2398,6 @@ void ixgbe_fc_autoneg(struct ixgbe_hw *hw)  	switch (hw->phy.media_type) {  	/* Autoneg flow control on fiber adapters */ -	case ixgbe_media_type_fiber_fixed:  	case ixgbe_media_type_fiber:  		if (speed == IXGBE_LINK_SPEED_1GB_FULL)  			ret_val = ixgbe_fc_autoneg_fiber(hw); @@ -2437,6 +2428,53 @@ out:  }  /** + * ixgbe_pcie_timeout_poll - Return number of times to poll for completion + * @hw: pointer to hardware structure + * + * System-wide timeout range is encoded in PCIe Device Control2 register. + * + *  Add 10% to specified maximum and return the number of times to poll for + *  completion timeout, in units of 100 microsec.  Never return less than + *  800 = 80 millisec. + **/ +static u32 ixgbe_pcie_timeout_poll(struct ixgbe_hw *hw) +{ +	s16 devctl2; +	u32 pollcnt; + +	devctl2 = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_DEVICE_CONTROL2); +	devctl2 &= IXGBE_PCIDEVCTRL2_TIMEO_MASK; + +	switch (devctl2) { +	case IXGBE_PCIDEVCTRL2_65_130ms: +		 pollcnt = 1300;         /* 130 millisec */ +		break; +	case IXGBE_PCIDEVCTRL2_260_520ms: +		pollcnt = 5200;         /* 520 millisec */ +		break; +	case IXGBE_PCIDEVCTRL2_1_2s: +		pollcnt = 20000;        /* 2 sec */ +		break; +	case IXGBE_PCIDEVCTRL2_4_8s: +		pollcnt = 80000;        /* 8 sec */ +		break; +	case IXGBE_PCIDEVCTRL2_17_34s: +		pollcnt = 34000;        /* 34 sec */ +		break; +	case IXGBE_PCIDEVCTRL2_50_100us:        /* 100 microsecs */ +	case IXGBE_PCIDEVCTRL2_1_2ms:           /* 2 millisecs */ +	case IXGBE_PCIDEVCTRL2_16_32ms:         /* 32 millisec */ +	case IXGBE_PCIDEVCTRL2_16_32ms_def:     /* 32 millisec default */ +	default: +		pollcnt = 800;          /* 80 millisec minimum */ +		break; +	} + +	/* add 10% to spec maximum */ +	return (pollcnt * 11) / 10; +} + +/**   *  ixgbe_disable_pcie_master - Disable PCI-express master access   *  @hw: pointer to hardware structure   * @@ -2447,16 +2485,16 @@ out:   **/  static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)  { -	struct ixgbe_adapter *adapter = hw->back;  	s32 status = 0; -	u32 i; +	u32 i, poll;  	u16 value;  	/* Always set this bit to ensure any future transactions are blocked */  	IXGBE_WRITE_REG(hw, IXGBE_CTRL, IXGBE_CTRL_GIO_DIS);  	/* Exit if master requests are blocked */ -	if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO)) +	if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO) || +	    ixgbe_removed(hw->hw_addr))  		goto out;  	/* Poll for master request bit to clear */ @@ -2481,10 +2519,12 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)  	 * Before proceeding, make sure that the PCIe block does not have  	 * transactions pending.  	 */ -	for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) { +	poll = ixgbe_pcie_timeout_poll(hw); +	for (i = 0; i < poll; i++) {  		udelay(100); -		pci_read_config_word(adapter->pdev, IXGBE_PCI_DEVICE_STATUS, -							 &value); +		value = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_DEVICE_STATUS); +		if (ixgbe_removed(hw->hw_addr)) +			goto out;  		if (!(value & IXGBE_PCI_DEVICE_STATUS_TRANSACTION_PENDING))  			goto out;  	} @@ -2564,6 +2604,35 @@ void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask)  }  /** + * prot_autoc_read_generic - Hides MAC differences needed for AUTOC read + * @hw: pointer to hardware structure + * @reg_val: Value we read from AUTOC + * @locked: bool to indicate whether the SW/FW lock should be taken.  Never + *	    true in this the generic case. + * + * The default case requires no protection so just to the register read. + **/ +s32 prot_autoc_read_generic(struct ixgbe_hw *hw, bool *locked, u32 *reg_val) +{ +	*locked = false; +	*reg_val = IXGBE_READ_REG(hw, IXGBE_AUTOC); +	return 0; +} + +/** + * prot_autoc_write_generic - Hides MAC differences needed for AUTOC write + * @hw: pointer to hardware structure + * @reg_val: value to write to AUTOC + * @locked: bool to indicate whether the SW/FW lock was already taken by + *	    previous read. + **/ +s32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 reg_val, bool locked) +{ +	IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_val); +	return 0; +} + +/**   *  ixgbe_disable_rx_buff_generic - Stops the receive data path   *  @hw: pointer to hardware structure   * @@ -2590,8 +2659,7 @@ s32 ixgbe_disable_rx_buff_generic(struct ixgbe_hw *hw)  	/* For informational purposes only */  	if (i >= IXGBE_MAX_SECRX_POLL) -		hw_dbg(hw, "Rx unit being enabled before security " -		       "path fully disabled.  Continuing with init.\n"); +		hw_dbg(hw, "Rx unit being enabled before security path fully disabled. Continuing with init.\n");  	return 0; @@ -2641,6 +2709,7 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)  	u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);  	u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);  	s32 ret_val = 0; +	bool locked = false;  	/*  	 * Link must be up to auto-blink the LEDs; @@ -2649,28 +2718,19 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)  	hw->mac.ops.check_link(hw, &speed, &link_up, false);  	if (!link_up) { -		/* Need the SW/FW semaphore around AUTOC writes if 82599 and -		 * LESM is on. -		 */ -		bool got_lock = false; - -		if ((hw->mac.type == ixgbe_mac_82599EB) && -		    ixgbe_verify_lesm_fw_enabled_82599(hw)) { -			ret_val = hw->mac.ops.acquire_swfw_sync(hw, -							IXGBE_GSSR_MAC_CSR_SM); -			if (ret_val) -				goto out; +		ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg); +		if (ret_val) +			goto out; -			got_lock = true; -		}  		autoc_reg |= IXGBE_AUTOC_AN_RESTART;  		autoc_reg |= IXGBE_AUTOC_FLU; -		IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); + +		ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked); +		if (ret_val) +			goto out; +  		IXGBE_WRITE_FLUSH(hw); -		if (got_lock) -			hw->mac.ops.release_swfw_sync(hw, -						      IXGBE_GSSR_MAC_CSR_SM);  		usleep_range(10000, 20000);  	} @@ -2690,33 +2750,21 @@ out:   **/  s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index)  { -	u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); +	u32 autoc_reg = 0;  	u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);  	s32 ret_val = 0; -	bool got_lock = false; - -	/* Need the SW/FW semaphore around AUTOC writes if 82599 and -	 * LESM is on. -	 */ -	if ((hw->mac.type == ixgbe_mac_82599EB) && -	    ixgbe_verify_lesm_fw_enabled_82599(hw)) { -		ret_val = hw->mac.ops.acquire_swfw_sync(hw, -						IXGBE_GSSR_MAC_CSR_SM); -		if (ret_val) -			goto out; +	bool locked = false; -		got_lock = true; -	} +	ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg); +	if (ret_val) +		goto out;  	autoc_reg &= ~IXGBE_AUTOC_FLU;  	autoc_reg |= IXGBE_AUTOC_AN_RESTART; -	IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); -	if (hw->mac.type == ixgbe_mac_82599EB) -		ixgbe_reset_pipeline_82599(hw); - -	if (got_lock) -		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM); +	ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked); +	if (ret_val) +		goto out;  	led_reg &= ~IXGBE_LED_MODE_MASK(index);  	led_reg &= ~IXGBE_LED_BLINK(index); @@ -2738,7 +2786,7 @@ out:   *  get and set mac_addr routines.   **/  static s32 ixgbe_get_san_mac_addr_offset(struct ixgbe_hw *hw, -                                        u16 *san_mac_offset) +					u16 *san_mac_offset)  {  	s32 ret_val; @@ -2784,7 +2832,7 @@ s32 ixgbe_get_san_mac_addr_generic(struct ixgbe_hw *hw, u8 *san_mac_addr)  	hw->mac.ops.set_lan_id(hw);  	/* apply the port offset to the address offset */  	(hw->bus.func) ? (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT1_OFFSET) : -	                 (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT0_OFFSET); +			 (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT0_OFFSET);  	for (i = 0; i < 3; i++) {  		ret_val = hw->eeprom.ops.read(hw, san_mac_offset,  					      &san_mac_data); @@ -2817,7 +2865,6 @@ san_mac_addr_clr:   **/  u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw)  { -	struct ixgbe_adapter *adapter = hw->back;  	u16 msix_count = 1;  	u16 max_msix_count;  	u16 pcie_offset; @@ -2836,7 +2883,9 @@ u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw)  		return msix_count;  	} -	pci_read_config_word(adapter->pdev, pcie_offset, &msix_count); +	msix_count = ixgbe_read_pci_cfg_word(hw, pcie_offset); +	if (ixgbe_removed(hw->hw_addr)) +		msix_count = 0;  	msix_count &= IXGBE_PCIE_MSIX_TBL_SZ_MASK;  	/* MSI-X count is zero-based in HW */ @@ -2868,6 +2917,9 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq)  	mpsar_lo = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));  	mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar)); +	if (ixgbe_removed(hw->hw_addr)) +		goto done; +  	if (!mpsar_lo && !mpsar_hi)  		goto done; @@ -3020,7 +3072,7 @@ static s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan)   *  Turn on/off specified VLAN in the VLAN filter table.   **/  s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind, -                           bool vlan_on) +			   bool vlan_on)  {  	s32 regindex;  	u32 bitindex; @@ -3142,9 +3194,9 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,  				 * Ignore it. */  				vfta_changed = false;  			} -		} -		else +		} else {  			IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index), 0); +		}  	}  	if (vfta_changed) @@ -3244,7 +3296,7 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed,   *  block to check the support for the alternative WWNN/WWPN prefix support.   **/  s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix, -                                        u16 *wwpn_prefix) +					u16 *wwpn_prefix)  {  	u16 offset, caps;  	u16 alt_san_mac_blk_offset; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h index d259dc76604..2ae5d4b8fc9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -38,7 +39,7 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw);  s32 ixgbe_start_hw_gen2(struct ixgbe_hw *hw);  s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw);  s32 ixgbe_read_pba_string_generic(struct ixgbe_hw *hw, u8 *pba_num, -                                  u32 pba_num_size); +				  u32 pba_num_size);  s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr);  enum ixgbe_bus_width ixgbe_convert_bus_width(u16 link_status);  enum ixgbe_bus_speed ixgbe_convert_bus_speed(u16 link_status); @@ -60,16 +61,16 @@ s32 ixgbe_write_eewr_generic(struct ixgbe_hw *hw, u16 offset, u16 data);  s32 ixgbe_write_eewr_buffer_generic(struct ixgbe_hw *hw, u16 offset,  				    u16 words, u16 *data);  s32 ixgbe_read_eeprom_bit_bang_generic(struct ixgbe_hw *hw, u16 offset, -                                       u16 *data); +				       u16 *data);  s32 ixgbe_read_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,  					      u16 words, u16 *data);  u16 ixgbe_calc_eeprom_checksum_generic(struct ixgbe_hw *hw);  s32 ixgbe_validate_eeprom_checksum_generic(struct ixgbe_hw *hw, -                                           u16 *checksum_val); +					   u16 *checksum_val);  s32 ixgbe_update_eeprom_checksum_generic(struct ixgbe_hw *hw);  s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq, -                          u32 enable_addr); +			  u32 enable_addr);  s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index);  s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw);  s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, @@ -91,13 +92,17 @@ s32 ixgbe_set_vmdq_san_mac_generic(struct ixgbe_hw *hw, u32 vmdq);  s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq);  s32 ixgbe_init_uta_tables_generic(struct ixgbe_hw *hw);  s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, -                           u32 vind, bool vlan_on); +			   u32 vind, bool vlan_on);  s32 ixgbe_clear_vfta_generic(struct ixgbe_hw *hw);  s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, -                                 ixgbe_link_speed *speed, -                                 bool *link_up, bool link_up_wait_to_complete); +				 ixgbe_link_speed *speed, +				 bool *link_up, bool link_up_wait_to_complete);  s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix, -                                 u16 *wwpn_prefix); +				 u16 *wwpn_prefix); + +s32 prot_autoc_read_generic(struct ixgbe_hw *hw, bool *, u32 *reg_val); +s32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 reg_val, bool locked); +  s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index);  s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index);  void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf); @@ -106,10 +111,10 @@ s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);  s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,  				 u8 build, u8 ver);  void ixgbe_clear_tx_pending(struct ixgbe_hw *hw); +bool ixgbe_mng_enabled(struct ixgbe_hw *hw);  void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb,  			     u32 headroom, int strategy); -s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);  #define IXGBE_I2C_THERMAL_SENSOR_ADDR	0xF8  #define IXGBE_EMC_INTERNAL_DATA		0x00 @@ -124,24 +129,57 @@ s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);  s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw);  s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw); -#define IXGBE_WRITE_REG(a, reg, value) writel((value), ((a)->hw_addr + (reg))) +#define IXGBE_FAILED_READ_REG 0xffffffffU +#define IXGBE_FAILED_READ_CFG_DWORD 0xffffffffU +#define IXGBE_FAILED_READ_CFG_WORD 0xffffU + +u16 ixgbe_read_pci_cfg_word(struct ixgbe_hw *hw, u32 reg); +void ixgbe_write_pci_cfg_word(struct ixgbe_hw *hw, u32 reg, u16 value); + +static inline bool ixgbe_removed(void __iomem *addr) +{ +	return unlikely(!addr); +} + +static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) +{ +	u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr); + +	if (ixgbe_removed(reg_addr)) +		return; +	writel(value, reg_addr + reg); +} +#define IXGBE_WRITE_REG(a, reg, value) ixgbe_write_reg((a), (reg), (value))  #ifndef writeq -#define writeq(val, addr) writel((u32) (val), addr); \ -    writel((u32) (val >> 32), (addr + 4)); +#define writeq writeq +static inline void writeq(u64 val, void __iomem *addr) +{ +	writel((u32)val, addr); +	writel((u32)(val >> 32), addr + 4); +}  #endif -#define IXGBE_WRITE_REG64(a, reg, value) writeq((value), ((a)->hw_addr + (reg))) +static inline void ixgbe_write_reg64(struct ixgbe_hw *hw, u32 reg, u64 value) +{ +	u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr); + +	if (ixgbe_removed(reg_addr)) +		return; +	writeq(value, reg_addr + reg); +} +#define IXGBE_WRITE_REG64(a, reg, value) ixgbe_write_reg64((a), (reg), (value)) -#define IXGBE_READ_REG(a, reg) readl((a)->hw_addr + (reg)) +u32 ixgbe_read_reg(struct ixgbe_hw *hw, u32 reg); +#define IXGBE_READ_REG(a, reg) ixgbe_read_reg((a), (reg)) -#define IXGBE_WRITE_REG_ARRAY(a, reg, offset, value) (\ -    writel((value), ((a)->hw_addr + (reg) + ((offset) << 2)))) +#define IXGBE_WRITE_REG_ARRAY(a, reg, offset, value) \ +		ixgbe_write_reg((a), (reg) + ((offset) << 2), (value)) -#define IXGBE_READ_REG_ARRAY(a, reg, offset) (\ -    readl((a)->hw_addr + (reg) + ((offset) << 2))) +#define IXGBE_READ_REG_ARRAY(a, reg, offset) \ +		ixgbe_read_reg((a), (reg) + ((offset) << 2)) -#define IXGBE_WRITE_FLUSH(a) IXGBE_READ_REG(a, IXGBE_STATUS) +#define IXGBE_WRITE_FLUSH(a) ixgbe_read_reg((a), IXGBE_STATUS)  #define ixgbe_hw_to_netdev(hw) (((struct ixgbe_adapter *)(hw)->back)->netdev) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c index e055e000131..a689ee0d4be 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c @@ -267,7 +267,7 @@ void ixgbe_dcb_unpack_map(struct ixgbe_dcb_config *cfg, int direction, u8 *map)   * Configure dcb settings and enable dcb mode.   */  s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, -                        struct ixgbe_dcb_config *dcb_config) +			struct ixgbe_dcb_config *dcb_config)  {  	s32 ret = 0;  	u8 pfc_en; @@ -389,7 +389,6 @@ static void ixgbe_dcb_read_rtrup2tc_82599(struct ixgbe_hw *hw, u8 *map)  	for (i = 0; i < MAX_USER_PRIORITY; i++)  		map[i] = IXGBE_RTRUP2TC_UP_MASK &  			(reg >> (i * IXGBE_RTRUP2TC_UP_SHIFT)); -	return;  }  void ixgbe_dcb_read_rtrup2tc(struct ixgbe_hw *hw, u8 *map) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c index 7a77f37a7cb..d3ba63f9ad3 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c @@ -208,7 +208,6 @@ s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw, u8 pfc_en)  	IXGBE_WRITE_REG(hw, IXGBE_FCTRL, reg); -	fcrtl = (hw->fc.low_water << 10) | IXGBE_FCRTL_XONE;  	/* Configure PFC Tx thresholds per TC */  	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {  		if (!(pfc_en & (1 << i))) { @@ -217,6 +216,7 @@ s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw, u8 pfc_en)  			continue;  		} +		fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;  		reg = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;  		IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl);  		IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), reg); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c index 05e23b80b5e..3b932fe64ab 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -241,7 +242,6 @@ s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 pfc_en, u8 *prio_tc)  			max_tc = prio_tc[i];  	} -	fcrtl = (hw->fc.low_water << 10) | IXGBE_FCRTL_XONE;  	/* Configure PFC Tx thresholds per TC */  	for (i = 0; i <= max_tc; i++) { @@ -256,6 +256,7 @@ s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 pfc_en, u8 *prio_tc)  		if (enabled) {  			reg = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN; +			fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;  			IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), fcrtl);  		} else {  			reg = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)) - 32; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h index d71d9ce3e39..90c370230e2 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -30,17 +31,17 @@  /* DCB register definitions */  #define IXGBE_RTTDCS_TDPAC      0x00000001 /* 0 Round Robin, -                                            * 1 WSP - Weighted Strict Priority -                                            */ +					    * 1 WSP - Weighted Strict Priority +					    */  #define IXGBE_RTTDCS_VMPAC      0x00000002 /* 0 Round Robin, -                                            * 1 WRR - Weighted Round Robin -                                            */ +					    * 1 WRR - Weighted Round Robin +					    */  #define IXGBE_RTTDCS_TDRM       0x00000010 /* Transmit Recycle Mode */  #define IXGBE_RTTDCS_ARBDIS     0x00000040 /* DCB arbiter disable */  #define IXGBE_RTTDCS_BDPM       0x00400000 /* Bypass Data Pipe - must clear! */  #define IXGBE_RTTDCS_BPBFSM     0x00800000 /* Bypass PB Free Space - must -                                             * clear! -                                             */ +					     * clear! +					     */  #define IXGBE_RTTDCS_SPEED_CHG  0x80000000 /* Link speed change */  /* Receive UP2TC mapping */ @@ -55,11 +56,11 @@  #define IXGBE_RTRPT4C_LSP       0x80000000 /* LSP enable bit */  #define IXGBE_RDRXCTL_MPBEN     0x00000010 /* DMA config for multiple packet -                                            * buffers enable -                                            */ +					    * buffers enable +					    */  #define IXGBE_RDRXCTL_MCEN      0x00000040 /* DMA config for multiple cores -                                            * (RSS) enable -                                            */ +					    * (RSS) enable +					    */  /* RTRPCS Bit Masks */  #define IXGBE_RTRPCS_RRM        0x00000002 /* Receive Recycle Mode enable */ @@ -80,8 +81,8 @@  /* RTTPCS Bit Masks */  #define IXGBE_RTTPCS_TPPAC      0x00000020 /* 0 Round Robin, -                                            * 1 SP - Strict Priority -                                            */ +					    * 1 SP - Strict Priority +					    */  #define IXGBE_RTTPCS_ARBDIS     0x00000040 /* Arbiter disable */  #define IXGBE_RTTPCS_TPRM       0x00000100 /* Transmit Recycle Mode enable */  #define IXGBE_RTTPCS_ARBD_SHIFT 22 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c index edd89a1ef27..5172b6b12c0 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c @@ -192,8 +192,8 @@ static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,  }  static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc, -                                         u8 prio, u8 bwg_id, u8 bw_pct, -                                         u8 up_map) +					 u8 prio, u8 bwg_id, u8 bw_pct, +					 u8 up_map)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -210,7 +210,7 @@ static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,  }  static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id, -                                          u8 bw_pct) +					  u8 bw_pct)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -218,8 +218,8 @@ static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,  }  static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc, -                                         u8 prio, u8 bwg_id, u8 bw_pct, -                                         u8 up_map) +					 u8 prio, u8 bwg_id, u8 bw_pct, +					 u8 up_map)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -236,7 +236,7 @@ static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,  }  static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id, -                                          u8 bw_pct) +					  u8 bw_pct)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -244,8 +244,8 @@ static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,  }  static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc, -                                         u8 *prio, u8 *bwg_id, u8 *bw_pct, -                                         u8 *up_map) +					 u8 *prio, u8 *bwg_id, u8 *bw_pct, +					 u8 *up_map)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -256,7 +256,7 @@ static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc,  }  static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id, -                                          u8 *bw_pct) +					  u8 *bw_pct)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -264,8 +264,8 @@ static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,  }  static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc, -                                         u8 *prio, u8 *bwg_id, u8 *bw_pct, -                                         u8 *up_map) +					 u8 *prio, u8 *bwg_id, u8 *bw_pct, +					 u8 *up_map)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -276,7 +276,7 @@ static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc,  }  static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id, -                                          u8 *bw_pct) +					  u8 *bw_pct)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -284,7 +284,7 @@ static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,  }  static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority, -                                    u8 setting) +				    u8 setting)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -295,7 +295,7 @@ static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,  }  static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority, -                                    u8 *setting) +				    u8 *setting)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c index c5933f6dcee..5e2c1e35e51 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -252,8 +253,7 @@ void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter)   **/  void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter)  { -	if (adapter->ixgbe_dbg_adapter) -		debugfs_remove_recursive(adapter->ixgbe_dbg_adapter); +	debugfs_remove_recursive(adapter->ixgbe_dbg_adapter);  	adapter->ixgbe_dbg_adapter = NULL;  } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index e8649abf97c..a452730a327 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -140,8 +141,8 @@ static const struct ixgbe_stats ixgbe_gstrings_stats[] = {  			 sizeof(((struct ixgbe_adapter *)0)->stats.pxofftxc)) \  			/ sizeof(u64))  #define IXGBE_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + \ -                         IXGBE_PB_STATS_LEN + \ -                         IXGBE_QUEUE_STATS_LEN) +			 IXGBE_PB_STATS_LEN + \ +			 IXGBE_QUEUE_STATS_LEN)  static const char ixgbe_gstrings_test[][ETH_GSTRING_LEN] = {  	"Register test  (offline)", "Eeprom test    (offline)", @@ -151,7 +152,7 @@ static const char ixgbe_gstrings_test[][ETH_GSTRING_LEN] = {  #define IXGBE_TEST_LEN sizeof(ixgbe_gstrings_test) / ETH_GSTRING_LEN  static int ixgbe_get_settings(struct net_device *netdev, -                              struct ethtool_cmd *ecmd) +			      struct ethtool_cmd *ecmd)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_hw *hw = &adapter->hw; @@ -160,13 +161,6 @@ static int ixgbe_get_settings(struct net_device *netdev,  	bool autoneg = false;  	bool link_up; -	/* SFP type is needed for get_link_capabilities */ -	if (hw->phy.media_type & (ixgbe_media_type_fiber | -				  ixgbe_media_type_fiber_qsfp)) { -		if (hw->phy.sfp_type == ixgbe_sfp_type_not_present) -				hw->phy.ops.identify_sfp(hw); -	} -  	hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg);  	/* set the supported link speeds */ @@ -302,15 +296,15 @@ static int ixgbe_get_settings(struct net_device *netdev,  		}  		ecmd->duplex = DUPLEX_FULL;  	} else { -		ethtool_cmd_speed_set(ecmd, -1); -		ecmd->duplex = -1; +		ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); +		ecmd->duplex = DUPLEX_UNKNOWN;  	}  	return 0;  }  static int ixgbe_set_settings(struct net_device *netdev, -                              struct ethtool_cmd *ecmd) +			      struct ethtool_cmd *ecmd)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_hw *hw = &adapter->hw; @@ -367,7 +361,7 @@ static int ixgbe_set_settings(struct net_device *netdev,  }  static void ixgbe_get_pauseparam(struct net_device *netdev, -                                 struct ethtool_pauseparam *pause) +				 struct ethtool_pauseparam *pause)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_hw *hw = &adapter->hw; @@ -389,7 +383,7 @@ static void ixgbe_get_pauseparam(struct net_device *netdev,  }  static int ixgbe_set_pauseparam(struct net_device *netdev, -                                struct ethtool_pauseparam *pause) +				struct ethtool_pauseparam *pause)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_hw *hw = &adapter->hw; @@ -442,14 +436,14 @@ static void ixgbe_set_msglevel(struct net_device *netdev, u32 data)  static int ixgbe_get_regs_len(struct net_device *netdev)  { -#define IXGBE_REGS_LEN  1129 +#define IXGBE_REGS_LEN  1139  	return IXGBE_REGS_LEN * sizeof(u32);  }  #define IXGBE_GET_STAT(_A_, _R_) _A_->stats._R_  static void ixgbe_get_regs(struct net_device *netdev, -                           struct ethtool_regs *regs, void *p) +			   struct ethtool_regs *regs, void *p)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_hw *hw = &adapter->hw; @@ -602,22 +596,53 @@ static void ixgbe_get_regs(struct net_device *netdev,  	regs_buff[828] = IXGBE_READ_REG(hw, IXGBE_FHFT(0));  	/* DCB */ -	regs_buff[829] = IXGBE_READ_REG(hw, IXGBE_RMCS); -	regs_buff[830] = IXGBE_READ_REG(hw, IXGBE_DPMCS); -	regs_buff[831] = IXGBE_READ_REG(hw, IXGBE_PDPMCS); -	regs_buff[832] = IXGBE_READ_REG(hw, IXGBE_RUPPBMR); -	for (i = 0; i < 8; i++) -		regs_buff[833 + i] = IXGBE_READ_REG(hw, IXGBE_RT2CR(i)); -	for (i = 0; i < 8; i++) -		regs_buff[841 + i] = IXGBE_READ_REG(hw, IXGBE_RT2SR(i)); -	for (i = 0; i < 8; i++) -		regs_buff[849 + i] = IXGBE_READ_REG(hw, IXGBE_TDTQ2TCCR(i)); -	for (i = 0; i < 8; i++) -		regs_buff[857 + i] = IXGBE_READ_REG(hw, IXGBE_TDTQ2TCSR(i)); +	regs_buff[829] = IXGBE_READ_REG(hw, IXGBE_RMCS);   /* same as FCCFG  */ +	regs_buff[831] = IXGBE_READ_REG(hw, IXGBE_PDPMCS); /* same as RTTPCS */ + +	switch (hw->mac.type) { +	case ixgbe_mac_82598EB: +		regs_buff[830] = IXGBE_READ_REG(hw, IXGBE_DPMCS); +		regs_buff[832] = IXGBE_READ_REG(hw, IXGBE_RUPPBMR); +		for (i = 0; i < 8; i++) +			regs_buff[833 + i] = +				IXGBE_READ_REG(hw, IXGBE_RT2CR(i)); +		for (i = 0; i < 8; i++) +			regs_buff[841 + i] = +				IXGBE_READ_REG(hw, IXGBE_RT2SR(i)); +		for (i = 0; i < 8; i++) +			regs_buff[849 + i] = +				IXGBE_READ_REG(hw, IXGBE_TDTQ2TCCR(i)); +		for (i = 0; i < 8; i++) +			regs_buff[857 + i] = +				IXGBE_READ_REG(hw, IXGBE_TDTQ2TCSR(i)); +		break; +	case ixgbe_mac_82599EB: +	case ixgbe_mac_X540: +		regs_buff[830] = IXGBE_READ_REG(hw, IXGBE_RTTDCS); +		regs_buff[832] = IXGBE_READ_REG(hw, IXGBE_RTRPCS); +		for (i = 0; i < 8; i++) +			regs_buff[833 + i] = +				IXGBE_READ_REG(hw, IXGBE_RTRPT4C(i)); +		for (i = 0; i < 8; i++) +			regs_buff[841 + i] = +				IXGBE_READ_REG(hw, IXGBE_RTRPT4S(i)); +		for (i = 0; i < 8; i++) +			regs_buff[849 + i] = +				IXGBE_READ_REG(hw, IXGBE_RTTDT2C(i)); +		for (i = 0; i < 8; i++) +			regs_buff[857 + i] = +				IXGBE_READ_REG(hw, IXGBE_RTTDT2S(i)); +		break; +	default: +		break; +	} +  	for (i = 0; i < 8; i++) -		regs_buff[865 + i] = IXGBE_READ_REG(hw, IXGBE_TDPT2TCCR(i)); +		regs_buff[865 + i] = +		IXGBE_READ_REG(hw, IXGBE_TDPT2TCCR(i)); /* same as RTTPT2C */  	for (i = 0; i < 8; i++) -		regs_buff[873 + i] = IXGBE_READ_REG(hw, IXGBE_TDPT2TCSR(i)); +		regs_buff[873 + i] = +		IXGBE_READ_REG(hw, IXGBE_TDPT2TCSR(i)); /* same as RTTPT2S */  	/* Statistics */  	regs_buff[881] = IXGBE_GET_STAT(adapter, crcerrs); @@ -757,6 +782,20 @@ static void ixgbe_get_regs(struct net_device *netdev,  	/* 82599 X540 specific registers  */  	regs_buff[1128] = IXGBE_READ_REG(hw, IXGBE_MFLCN); + +	/* 82599 X540 specific DCB registers  */ +	regs_buff[1129] = IXGBE_READ_REG(hw, IXGBE_RTRUP2TC); +	regs_buff[1130] = IXGBE_READ_REG(hw, IXGBE_RTTUP2TC); +	for (i = 0; i < 4; i++) +		regs_buff[1131 + i] = IXGBE_READ_REG(hw, IXGBE_TXLLQ(i)); +	regs_buff[1135] = IXGBE_READ_REG(hw, IXGBE_RTTBCNRM); +					/* same as RTTQCNRM */ +	regs_buff[1136] = IXGBE_READ_REG(hw, IXGBE_RTTBCNRD); +					/* same as RTTQCNRR */ + +	/* X540 specific DCB registers  */ +	regs_buff[1137] = IXGBE_READ_REG(hw, IXGBE_RTTQCNCR); +	regs_buff[1138] = IXGBE_READ_REG(hw, IXGBE_RTTQCNTG);  }  static int ixgbe_get_eeprom_len(struct net_device *netdev) @@ -766,7 +805,7 @@ static int ixgbe_get_eeprom_len(struct net_device *netdev)  }  static int ixgbe_get_eeprom(struct net_device *netdev, -                            struct ethtool_eeprom *eeprom, u8 *bytes) +			    struct ethtool_eeprom *eeprom, u8 *bytes)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_hw *hw = &adapter->hw; @@ -872,7 +911,7 @@ err:  }  static void ixgbe_get_drvinfo(struct net_device *netdev, -                              struct ethtool_drvinfo *drvinfo) +			      struct ethtool_drvinfo *drvinfo)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	u32 nvm_track_id; @@ -894,7 +933,7 @@ static void ixgbe_get_drvinfo(struct net_device *netdev,  }  static void ixgbe_get_ringparam(struct net_device *netdev, -                                struct ethtool_ringparam *ring) +				struct ethtool_ringparam *ring)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_ring *tx_ring = adapter->tx_ring[0]; @@ -907,7 +946,7 @@ static void ixgbe_get_ringparam(struct net_device *netdev,  }  static int ixgbe_set_ringparam(struct net_device *netdev, -                               struct ethtool_ringparam *ring) +			       struct ethtool_ringparam *ring)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_ring *temp_ring; @@ -1036,7 +1075,7 @@ static int ixgbe_get_sset_count(struct net_device *netdev, int sset)  }  static void ixgbe_get_ethtool_stats(struct net_device *netdev, -                                    struct ethtool_stats *stats, u64 *data) +				    struct ethtool_stats *stats, u64 *data)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct rtnl_link_stats64 temp; @@ -1064,7 +1103,7 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,  		}  		data[i] = (ixgbe_gstrings_stats[i].sizeof_stat == -		           sizeof(u64)) ? *(u64 *)p : *(u32 *)p; +			   sizeof(u64)) ? *(u64 *)p : *(u32 *)p;  	}  	for (j = 0; j < netdev->num_tx_queues; j++) {  		ring = adapter->tx_ring[j]; @@ -1072,7 +1111,7 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,  			data[i] = 0;  			data[i+1] = 0;  			i += 2; -#ifdef LL_EXTENDED_STATS +#ifdef BP_EXTENDED_STATS  			data[i] = 0;  			data[i+1] = 0;  			data[i+2] = 0; @@ -1082,12 +1121,12 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,  		}  		do { -			start = u64_stats_fetch_begin_bh(&ring->syncp); +			start = u64_stats_fetch_begin_irq(&ring->syncp);  			data[i]   = ring->stats.packets;  			data[i+1] = ring->stats.bytes; -		} while (u64_stats_fetch_retry_bh(&ring->syncp, start)); +		} while (u64_stats_fetch_retry_irq(&ring->syncp, start));  		i += 2; -#ifdef LL_EXTENDED_STATS +#ifdef BP_EXTENDED_STATS  		data[i] = ring->stats.yields;  		data[i+1] = ring->stats.misses;  		data[i+2] = ring->stats.cleaned; @@ -1100,7 +1139,7 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,  			data[i] = 0;  			data[i+1] = 0;  			i += 2; -#ifdef LL_EXTENDED_STATS +#ifdef BP_EXTENDED_STATS  			data[i] = 0;  			data[i+1] = 0;  			data[i+2] = 0; @@ -1110,12 +1149,12 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,  		}  		do { -			start = u64_stats_fetch_begin_bh(&ring->syncp); +			start = u64_stats_fetch_begin_irq(&ring->syncp);  			data[i]   = ring->stats.packets;  			data[i+1] = ring->stats.bytes; -		} while (u64_stats_fetch_retry_bh(&ring->syncp, start)); +		} while (u64_stats_fetch_retry_irq(&ring->syncp, start));  		i += 2; -#ifdef LL_EXTENDED_STATS +#ifdef BP_EXTENDED_STATS  		data[i] = ring->stats.yields;  		data[i+1] = ring->stats.misses;  		data[i+2] = ring->stats.cleaned; @@ -1134,7 +1173,7 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,  }  static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, -                              u8 *data) +			      u8 *data)  {  	char *p = (char *)data;  	int i; @@ -1157,28 +1196,28 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,  			p += ETH_GSTRING_LEN;  			sprintf(p, "tx_queue_%u_bytes", i);  			p += ETH_GSTRING_LEN; -#ifdef LL_EXTENDED_STATS -			sprintf(p, "tx_queue_%u_ll_napi_yield", i); +#ifdef BP_EXTENDED_STATS +			sprintf(p, "tx_queue_%u_bp_napi_yield", i);  			p += ETH_GSTRING_LEN; -			sprintf(p, "tx_queue_%u_ll_misses", i); +			sprintf(p, "tx_queue_%u_bp_misses", i);  			p += ETH_GSTRING_LEN; -			sprintf(p, "tx_queue_%u_ll_cleaned", i); +			sprintf(p, "tx_queue_%u_bp_cleaned", i);  			p += ETH_GSTRING_LEN; -#endif /* LL_EXTENDED_STATS */ +#endif /* BP_EXTENDED_STATS */  		}  		for (i = 0; i < IXGBE_NUM_RX_QUEUES; i++) {  			sprintf(p, "rx_queue_%u_packets", i);  			p += ETH_GSTRING_LEN;  			sprintf(p, "rx_queue_%u_bytes", i);  			p += ETH_GSTRING_LEN; -#ifdef LL_EXTENDED_STATS -			sprintf(p, "rx_queue_%u_ll_poll_yield", i); +#ifdef BP_EXTENDED_STATS +			sprintf(p, "rx_queue_%u_bp_poll_yield", i);  			p += ETH_GSTRING_LEN; -			sprintf(p, "rx_queue_%u_ll_misses", i); +			sprintf(p, "rx_queue_%u_bp_misses", i);  			p += ETH_GSTRING_LEN; -			sprintf(p, "rx_queue_%u_ll_cleaned", i); +			sprintf(p, "rx_queue_%u_bp_cleaned", i);  			p += ETH_GSTRING_LEN; -#endif /* LL_EXTENDED_STATS */ +#endif /* BP_EXTENDED_STATS */  		}  		for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++) {  			sprintf(p, "tx_pb_%u_pxon", i); @@ -1202,6 +1241,11 @@ static int ixgbe_link_test(struct ixgbe_adapter *adapter, u64 *data)  	struct ixgbe_hw *hw = &adapter->hw;  	bool link_up;  	u32 link_speed = 0; + +	if (ixgbe_removed(hw->hw_addr)) { +		*data = 1; +		return 1; +	}  	*data = 0;  	hw->mac.ops.check_link(hw, &link_speed, &link_up, true); @@ -1297,61 +1341,60 @@ static bool reg_pattern_test(struct ixgbe_adapter *adapter, u64 *data, int reg,  	static const u32 test_pattern[] = {  		0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; +	if (ixgbe_removed(adapter->hw.hw_addr)) { +		*data = 1; +		return 1; +	}  	for (pat = 0; pat < ARRAY_SIZE(test_pattern); pat++) { -		before = readl(adapter->hw.hw_addr + reg); -		writel((test_pattern[pat] & write), -		       (adapter->hw.hw_addr + reg)); -		val = readl(adapter->hw.hw_addr + reg); +		before = ixgbe_read_reg(&adapter->hw, reg); +		ixgbe_write_reg(&adapter->hw, reg, test_pattern[pat] & write); +		val = ixgbe_read_reg(&adapter->hw, reg);  		if (val != (test_pattern[pat] & write & mask)) { -			e_err(drv, "pattern test reg %04X failed: got " -			      "0x%08X expected 0x%08X\n", +			e_err(drv, "pattern test reg %04X failed: got 0x%08X expected 0x%08X\n",  			      reg, val, (test_pattern[pat] & write & mask));  			*data = reg; -			writel(before, adapter->hw.hw_addr + reg); -			return 1; +			ixgbe_write_reg(&adapter->hw, reg, before); +			return true;  		} -		writel(before, adapter->hw.hw_addr + reg); +		ixgbe_write_reg(&adapter->hw, reg, before);  	} -	return 0; +	return false;  }  static bool reg_set_and_check(struct ixgbe_adapter *adapter, u64 *data, int reg,  			      u32 mask, u32 write)  {  	u32 val, before; -	before = readl(adapter->hw.hw_addr + reg); -	writel((write & mask), (adapter->hw.hw_addr + reg)); -	val = readl(adapter->hw.hw_addr + reg); + +	if (ixgbe_removed(adapter->hw.hw_addr)) { +		*data = 1; +		return 1; +	} +	before = ixgbe_read_reg(&adapter->hw, reg); +	ixgbe_write_reg(&adapter->hw, reg, write & mask); +	val = ixgbe_read_reg(&adapter->hw, reg);  	if ((write & mask) != (val & mask)) { -		e_err(drv, "set/check reg %04X test failed: got 0x%08X " -		      "expected 0x%08X\n", reg, (val & mask), (write & mask)); +		e_err(drv, "set/check reg %04X test failed: got 0x%08X expected 0x%08X\n", +		      reg, (val & mask), (write & mask));  		*data = reg; -		writel(before, (adapter->hw.hw_addr + reg)); -		return 1; +		ixgbe_write_reg(&adapter->hw, reg, before); +		return true;  	} -	writel(before, (adapter->hw.hw_addr + reg)); -	return 0; +	ixgbe_write_reg(&adapter->hw, reg, before); +	return false;  } -#define REG_PATTERN_TEST(reg, mask, write)				      \ -	do {								      \ -		if (reg_pattern_test(adapter, data, reg, mask, write))	      \ -			return 1;					      \ -	} while (0)							      \ - - -#define REG_SET_AND_CHECK(reg, mask, write)				      \ -	do {								      \ -		if (reg_set_and_check(adapter, data, reg, mask, write))	      \ -			return 1;					      \ -	} while (0)							      \ -  static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)  {  	const struct ixgbe_reg_test *test;  	u32 value, before, after;  	u32 i, toggle; +	if (ixgbe_removed(adapter->hw.hw_addr)) { +		e_err(drv, "Adapter removed - register test blocked\n"); +		*data = 1; +		return 1; +	}  	switch (adapter->hw.mac.type) {  	case ixgbe_mac_82598EB:  		toggle = 0x7FFFF3FF; @@ -1374,18 +1417,18 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)  	 * tests.  Some bits are read-only, some toggle, and some  	 * are writeable on newer MACs.  	 */ -	before = IXGBE_READ_REG(&adapter->hw, IXGBE_STATUS); -	value = (IXGBE_READ_REG(&adapter->hw, IXGBE_STATUS) & toggle); -	IXGBE_WRITE_REG(&adapter->hw, IXGBE_STATUS, toggle); -	after = IXGBE_READ_REG(&adapter->hw, IXGBE_STATUS) & toggle; +	before = ixgbe_read_reg(&adapter->hw, IXGBE_STATUS); +	value = (ixgbe_read_reg(&adapter->hw, IXGBE_STATUS) & toggle); +	ixgbe_write_reg(&adapter->hw, IXGBE_STATUS, toggle); +	after = ixgbe_read_reg(&adapter->hw, IXGBE_STATUS) & toggle;  	if (value != after) { -		e_err(drv, "failed STATUS register test got: 0x%08X " -		      "expected: 0x%08X\n", after, value); +		e_err(drv, "failed STATUS register test got: 0x%08X expected: 0x%08X\n", +		      after, value);  		*data = 1;  		return 1;  	}  	/* restore previous status */ -	IXGBE_WRITE_REG(&adapter->hw, IXGBE_STATUS, before); +	ixgbe_write_reg(&adapter->hw, IXGBE_STATUS, before);  	/*  	 * Perform the remainder of the register test, looping through @@ -1393,38 +1436,47 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)  	 */  	while (test->reg) {  		for (i = 0; i < test->array_len; i++) { +			bool b = false; +  			switch (test->test_type) {  			case PATTERN_TEST: -				REG_PATTERN_TEST(test->reg + (i * 0x40), -						 test->mask, -						 test->write); +				b = reg_pattern_test(adapter, data, +						     test->reg + (i * 0x40), +						     test->mask, +						     test->write);  				break;  			case SET_READ_TEST: -				REG_SET_AND_CHECK(test->reg + (i * 0x40), -						  test->mask, -						  test->write); +				b = reg_set_and_check(adapter, data, +						      test->reg + (i * 0x40), +						      test->mask, +						      test->write);  				break;  			case WRITE_NO_TEST: -				writel(test->write, -				       (adapter->hw.hw_addr + test->reg) -				       + (i * 0x40)); +				ixgbe_write_reg(&adapter->hw, +						test->reg + (i * 0x40), +						test->write);  				break;  			case TABLE32_TEST: -				REG_PATTERN_TEST(test->reg + (i * 4), -						 test->mask, -						 test->write); +				b = reg_pattern_test(adapter, data, +						     test->reg + (i * 4), +						     test->mask, +						     test->write);  				break;  			case TABLE64_TEST_LO: -				REG_PATTERN_TEST(test->reg + (i * 8), -						 test->mask, -						 test->write); +				b = reg_pattern_test(adapter, data, +						     test->reg + (i * 8), +						     test->mask, +						     test->write);  				break;  			case TABLE64_TEST_HI: -				REG_PATTERN_TEST((test->reg + 4) + (i * 8), -						 test->mask, -						 test->write); +				b = reg_pattern_test(adapter, data, +						     (test->reg + 4) + (i * 8), +						     test->mask, +						     test->write);  				break;  			} +			if (b) +				return 1;  		}  		test++;  	} @@ -1473,10 +1525,10 @@ static int ixgbe_intr_test(struct ixgbe_adapter *adapter, u64 *data)  			return -1;  		}  	} else if (!request_irq(irq, ixgbe_test_intr, IRQF_PROBE_SHARED, -	                        netdev->name, netdev)) { +				netdev->name, netdev)) {  		shared_int = false;  	} else if (request_irq(irq, ixgbe_test_intr, IRQF_SHARED, -	                       netdev->name, netdev)) { +			       netdev->name, netdev)) {  		*data = 1;  		return -1;  	} @@ -1503,9 +1555,9 @@ static int ixgbe_intr_test(struct ixgbe_adapter *adapter, u64 *data)  			 */  			adapter->test_icr = 0;  			IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, -			                ~mask & 0x00007FFF); +					~mask & 0x00007FFF);  			IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS, -			                ~mask & 0x00007FFF); +					~mask & 0x00007FFF);  			IXGBE_WRITE_FLUSH(&adapter->hw);  			usleep_range(10000, 20000); @@ -1527,7 +1579,7 @@ static int ixgbe_intr_test(struct ixgbe_adapter *adapter, u64 *data)  		IXGBE_WRITE_FLUSH(&adapter->hw);  		usleep_range(10000, 20000); -		if (!(adapter->test_icr &mask)) { +		if (!(adapter->test_icr & mask)) {  			*data = 4;  			break;  		} @@ -1542,9 +1594,9 @@ static int ixgbe_intr_test(struct ixgbe_adapter *adapter, u64 *data)  			 */  			adapter->test_icr = 0;  			IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, -			                ~mask & 0x00007FFF); +					~mask & 0x00007FFF);  			IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS, -			                ~mask & 0x00007FFF); +					~mask & 0x00007FFF);  			IXGBE_WRITE_FLUSH(&adapter->hw);  			usleep_range(10000, 20000); @@ -1904,11 +1956,21 @@ out:  }  static void ixgbe_diag_test(struct net_device *netdev, -                            struct ethtool_test *eth_test, u64 *data) +			    struct ethtool_test *eth_test, u64 *data)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	bool if_running = netif_running(netdev); +	if (ixgbe_removed(adapter->hw.hw_addr)) { +		e_err(hw, "Adapter removed - test blocked\n"); +		data[0] = 1; +		data[1] = 1; +		data[2] = 1; +		data[3] = 1; +		data[4] = 1; +		eth_test->flags |= ETH_TEST_FL_FAILED; +		return; +	}  	set_bit(__IXGBE_TESTING, &adapter->state);  	if (eth_test->flags == ETH_TEST_FL_OFFLINE) {  		struct ixgbe_hw *hw = &adapter->hw; @@ -1917,14 +1979,12 @@ static void ixgbe_diag_test(struct net_device *netdev,  			int i;  			for (i = 0; i < adapter->num_vfs; i++) {  				if (adapter->vfinfo[i].clear_to_send) { -					netdev_warn(netdev, "%s", -						    "offline diagnostic is not " -						    "supported when VFs are " -						    "present\n"); +					netdev_warn(netdev, "offline diagnostic is not supported when VFs are present\n");  					data[0] = 1;  					data[1] = 1;  					data[2] = 1;  					data[3] = 1; +					data[4] = 1;  					eth_test->flags |= ETH_TEST_FL_FAILED;  					clear_bit(__IXGBE_TESTING,  						  &adapter->state); @@ -1966,8 +2026,7 @@ static void ixgbe_diag_test(struct net_device *netdev,  		 * loopback diagnostic. */  		if (adapter->flags & (IXGBE_FLAG_SRIOV_ENABLED |  				      IXGBE_FLAG_VMDQ_ENABLED)) { -			e_info(hw, "Skip MAC loopback diagnostic in VT " -			       "mode\n"); +			e_info(hw, "Skip MAC loopback diagnostic in VT mode\n");  			data[3] = 0;  			goto skip_loopback;  		} @@ -2007,7 +2066,7 @@ skip_ol_tests:  }  static int ixgbe_wol_exclusion(struct ixgbe_adapter *adapter, -                               struct ethtool_wolinfo *wol) +			       struct ethtool_wolinfo *wol)  {  	struct ixgbe_hw *hw = &adapter->hw;  	int retval = 0; @@ -2023,12 +2082,12 @@ static int ixgbe_wol_exclusion(struct ixgbe_adapter *adapter,  }  static void ixgbe_get_wol(struct net_device *netdev, -                          struct ethtool_wolinfo *wol) +			  struct ethtool_wolinfo *wol)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	wol->supported = WAKE_UCAST | WAKE_MCAST | -	                 WAKE_BCAST | WAKE_MAGIC; +			 WAKE_BCAST | WAKE_MAGIC;  	wol->wolopts = 0;  	if (ixgbe_wol_exclusion(adapter, wol) || @@ -2110,7 +2169,7 @@ static int ixgbe_set_phys_id(struct net_device *netdev,  }  static int ixgbe_get_coalesce(struct net_device *netdev, -                              struct ethtool_coalesce *ec) +			      struct ethtool_coalesce *ec)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -2151,8 +2210,7 @@ static bool ixgbe_update_rsc(struct ixgbe_adapter *adapter)  	    adapter->rx_itr_setting > IXGBE_MIN_RSC_ITR) {  		if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) {  			adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; -			e_info(probe, "rx-usecs value high enough " -				      "to re-enable RSC\n"); +			e_info(probe, "rx-usecs value high enough to re-enable RSC\n");  			return true;  		}  	/* if interrupt rate is too high then disable RSC */ @@ -2165,7 +2223,7 @@ static bool ixgbe_update_rsc(struct ixgbe_adapter *adapter)  }  static int ixgbe_set_coalesce(struct net_device *netdev, -                              struct ethtool_coalesce *ec) +			      struct ethtool_coalesce *ec)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_q_vector *q_vector; @@ -2212,13 +2270,13 @@ static int ixgbe_set_coalesce(struct net_device *netdev,  #if IS_ENABLED(CONFIG_BQL)  	/* detect ITR changes that require update of TXDCTL.WTHRESH */ -	if ((adapter->tx_itr_setting > 1) && +	if ((adapter->tx_itr_setting != 1) &&  	    (adapter->tx_itr_setting < IXGBE_100K_ITR)) {  		if ((tx_itr_prev == 1) || -		    (tx_itr_prev > IXGBE_100K_ITR)) +		    (tx_itr_prev >= IXGBE_100K_ITR))  			need_reset = true;  	} else { -		if ((tx_itr_prev > 1) && +		if ((tx_itr_prev != 1) &&  		    (tx_itr_prev < IXGBE_100K_ITR))  			need_reset = true;  	} @@ -2350,9 +2408,11 @@ static int ixgbe_get_rss_hash_opts(struct ixgbe_adapter *adapter,  	switch (cmd->flow_type) {  	case TCP_V4_FLOW:  		cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; +		/* fallthrough */  	case UDP_V4_FLOW:  		if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV4_UDP)  			cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; +		/* fallthrough */  	case SCTP_V4_FLOW:  	case AH_ESP_V4_FLOW:  	case AH_V4_FLOW: @@ -2362,9 +2422,11 @@ static int ixgbe_get_rss_hash_opts(struct ixgbe_adapter *adapter,  		break;  	case TCP_V6_FLOW:  		cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; +		/* fallthrough */  	case UDP_V6_FLOW:  		if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV6_UDP)  			cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; +		/* fallthrough */  	case SCTP_V6_FLOW:  	case AH_ESP_V6_FLOW:  	case AH_V6_FLOW: @@ -2716,8 +2778,7 @@ static int ixgbe_set_rss_hash_opt(struct ixgbe_adapter *adapter,  		if ((flags2 & UDP_RSS_FLAGS) &&  		    !(adapter->flags2 & UDP_RSS_FLAGS)) -			e_warn(drv, "enabling UDP RSS: fragmented packets" -			       " may arrive out of order to the stack above\n"); +			e_warn(drv, "enabling UDP RSS: fragmented packets may arrive out of order to the stack above\n");  		adapter->flags2 = flags2; @@ -3028,5 +3089,5 @@ static const struct ethtool_ops ixgbe_ethtool_ops = {  void ixgbe_set_ethtool_ops(struct net_device *netdev)  { -	SET_ETHTOOL_OPS(netdev, &ixgbe_ethtool_ops); +	netdev->ethtool_ops = &ixgbe_ethtool_ops;  } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index f58db453a97..25a3dfef33e 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -407,13 +408,13 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,  	switch (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_FCSTAT)) {  	/* return 0 to bypass going to ULD for DDPed data */ -	case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_DDP): +	case cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_DDP):  		/* update length of DDPed data */  		ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss);  		rc = 0;  		break;  	/* unmap the sg list when FCPRSP is received */ -	case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_FCPRSP): +	case cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_FCPRSP):  		dma_unmap_sg(&adapter->pdev->dev, ddp->sgl,  			     ddp->sgc, DMA_FROM_DEVICE);  		ddp->err = ddp_err; @@ -421,14 +422,14 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,  		ddp->sgc = 0;  		/* fall through */  	/* if DDP length is present pass it through to ULD */ -	case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NODDP): +	case cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NODDP):  		/* update length of DDPed data */  		ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss);  		if (ddp->len)  			rc = ddp->len;  		break;  	/* no match will return as an error */ -	case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NOMTCH): +	case cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NOMTCH):  	default:  		break;  	} @@ -585,7 +586,7 @@ static int ixgbe_fcoe_dma_pool_alloc(struct ixgbe_fcoe *fcoe,  	struct dma_pool *pool;  	char pool_name[32]; -	snprintf(pool_name, 32, "ixgbe_fcoe_ddp_%d", cpu); +	snprintf(pool_name, 32, "ixgbe_fcoe_ddp_%u", cpu);  	pool = dma_pool_create(pool_name, dev, IXGBE_FCPTR_MAX,  			       IXGBE_FCPTR_ALIGN, PAGE_SIZE); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h index 3a02759b5e9..0772b7730fc 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -80,9 +81,7 @@ struct ixgbe_fcoe {  	void *extra_ddp_buffer;  	dma_addr_t extra_ddp_buffer_dma;  	unsigned long mode; -#ifdef CONFIG_IXGBE_DCB  	u8 up; -#endif  };  #endif /* _IXGBE_FCOE_H */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c index 90b4e1089ec..2d9451e3968 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -498,6 +499,7 @@ static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)  #ifdef IXGBE_FCOE  	u16 fcoe_i = 0;  #endif +	bool pools = (find_first_zero_bit(&adapter->fwd_bitmask, 32) > 1);  	/* only proceed if SR-IOV is enabled */  	if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) @@ -510,7 +512,7 @@ static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)  	vmdq_i = min_t(u16, IXGBE_MAX_VMDQ_INDICES, vmdq_i);  	/* 64 pool mode with 2 queues per pool */ -	if ((vmdq_i > 32) || (rss_i < 4)) { +	if ((vmdq_i > 32) || (rss_i < 4) || (vmdq_i > 16 && pools)) {  		vmdq_m = IXGBE_82599_VMDQ_2Q_MASK;  		rss_m = IXGBE_RSS_2Q_MASK;  		rss_i = min_t(u16, rss_i, 2); @@ -697,7 +699,7 @@ static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)  static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,  				       int vectors)  { -	int err, vector_threshold; +	int vector_threshold;  	/* We'll want at least 2 (vector_threshold):  	 * 1) TxQ[0] + RxQ[0] handler @@ -711,18 +713,10 @@ static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,  	 * Right now, we simply care about how many we'll get; we'll  	 * set them up later while requesting irq's.  	 */ -	while (vectors >= vector_threshold) { -		err = pci_enable_msix(adapter->pdev, adapter->msix_entries, -				      vectors); -		if (!err) /* Success in acquiring all requested vectors. */ -			break; -		else if (err < 0) -			vectors = 0; /* Nasty failure, quit now */ -		else /* err == number of vectors we should try again with */ -			vectors = err; -	} +	vectors = pci_enable_msix_range(adapter->pdev, adapter->msix_entries, +					vector_threshold, vectors); -	if (vectors < vector_threshold) { +	if (vectors < 0) {  		/* Can't allocate enough MSI-X interrupts?  Oh well.  		 * This just means we'll go with either a single MSI  		 * vector or fall back to legacy interrupts. @@ -852,7 +846,11 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,  		/* apply Tx specific ring traits */  		ring->count = adapter->tx_ring_count; -		ring->queue_index = txr_idx; +		if (adapter->num_rx_pools > 1) +			ring->queue_index = +				txr_idx % adapter->num_rx_queues_per_pool; +		else +			ring->queue_index = txr_idx;  		/* assign ring to adapter */  		adapter->tx_ring[txr_idx] = ring; @@ -895,7 +893,11 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,  #endif /* IXGBE_FCOE */  		/* apply Rx specific ring traits */  		ring->count = adapter->rx_ring_count; -		ring->queue_index = rxr_idx; +		if (adapter->num_rx_pools > 1) +			ring->queue_index = +				rxr_idx % adapter->num_rx_queues_per_pool; +		else +			ring->queue_index = rxr_idx;  		/* assign ring to adapter */  		adapter->rx_ring[rxr_idx] = ring; @@ -1111,8 +1113,8 @@ static void ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter)  	err = pci_enable_msi(adapter->pdev);  	if (err) {  		netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev, -			     "Unable to allocate MSI interrupt, " -			     "falling back to legacy.  Error: %d\n", err); +			     "Unable to allocate MSI interrupt, falling back to legacy.  Error: %d\n", +			     err);  		return;  	}  	adapter->flags |= IXGBE_FLAG_MSI_ENABLED; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 0ade0cd5ef5..f5aa3311ea2 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -44,6 +45,7 @@  #include <linux/ethtool.h>  #include <linux/if.h>  #include <linux/if_vlan.h> +#include <linux/if_macvlan.h>  #include <linux/if_bridge.h>  #include <linux/prefetch.h>  #include <scsi/fc/fc_fcoe.h> @@ -63,10 +65,10 @@ char ixgbe_default_device_descr[] =  static char ixgbe_default_device_descr[] =  			      "Intel(R) 10 Gigabit Network Connection";  #endif -#define DRV_VERSION "3.15.1-k" +#define DRV_VERSION "3.19.1-k"  const char ixgbe_driver_version[] = DRV_VERSION;  static const char ixgbe_copyright[] = -				"Copyright (c) 1999-2013 Intel Corporation."; +				"Copyright (c) 1999-2014 Intel Corporation.";  static const struct ixgbe_info *ixgbe_info_tbl[] = {  	[board_82598] = &ixgbe_82598_info, @@ -132,7 +134,7 @@ static struct notifier_block dca_notifier = {  static unsigned int max_vfs;  module_param(max_vfs, uint, 0);  MODULE_PARM_DESC(max_vfs, -		 "Maximum number of virtual functions to allocate per physical function - default is zero and maximum value is 63"); +		 "Maximum number of virtual functions to allocate per physical function - default is zero and maximum value is 63. (Deprecated)");  #endif /* CONFIG_PCI_IOV */  static unsigned int allow_unsupported_sfp; @@ -150,10 +152,11 @@ MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver");  MODULE_LICENSE("GPL");  MODULE_VERSION(DRV_VERSION); +static bool ixgbe_check_cfg_remove(struct ixgbe_hw *hw, struct pci_dev *pdev); +  static int ixgbe_read_pci_cfg_word_parent(struct ixgbe_adapter *adapter,  					  u32 reg, u16 *value)  { -	int pos = 0;  	struct pci_dev *parent_dev;  	struct pci_bus *parent_bus; @@ -165,11 +168,13 @@ static int ixgbe_read_pci_cfg_word_parent(struct ixgbe_adapter *adapter,  	if (!parent_dev)  		return -1; -	pos = pci_find_capability(parent_dev, PCI_CAP_ID_EXP); -	if (!pos) +	if (!pci_is_pcie(parent_dev))  		return -1; -	pci_read_config_word(parent_dev, pos + reg, value); +	pcie_capability_read_word(parent_dev, reg, value); +	if (*value == IXGBE_FAILED_READ_CFG_WORD && +	    ixgbe_check_cfg_remove(&adapter->hw, parent_dev)) +		return -1;  	return 0;  } @@ -247,7 +252,7 @@ static void ixgbe_check_minimum_link(struct ixgbe_adapter *adapter,  		max_gts = 4 * width;  		break;  	case PCIE_SPEED_8_0GT: -		/* 128b/130b encoding only reduces throughput by 1% */ +		/* 128b/130b encoding reduces throughput by less than 2% */  		max_gts = 8 * width;  		break;  	default: @@ -265,7 +270,7 @@ static void ixgbe_check_minimum_link(struct ixgbe_adapter *adapter,  		   width,  		   (speed == PCIE_SPEED_2_5GT ? "20%" :  		    speed == PCIE_SPEED_5_0GT ? "20%" : -		    speed == PCIE_SPEED_8_0GT ? "N/a" : +		    speed == PCIE_SPEED_8_0GT ? "<2%" :  		    "Unknown"));  	if (max_gts < expected_gts) { @@ -279,16 +284,125 @@ static void ixgbe_check_minimum_link(struct ixgbe_adapter *adapter,  static void ixgbe_service_event_schedule(struct ixgbe_adapter *adapter)  {  	if (!test_bit(__IXGBE_DOWN, &adapter->state) && +	    !test_bit(__IXGBE_REMOVING, &adapter->state) &&  	    !test_and_set_bit(__IXGBE_SERVICE_SCHED, &adapter->state))  		schedule_work(&adapter->service_task);  } +static void ixgbe_remove_adapter(struct ixgbe_hw *hw) +{ +	struct ixgbe_adapter *adapter = hw->back; + +	if (!hw->hw_addr) +		return; +	hw->hw_addr = NULL; +	e_dev_err("Adapter removed\n"); +	if (test_bit(__IXGBE_SERVICE_INITED, &adapter->state)) +		ixgbe_service_event_schedule(adapter); +} + +static void ixgbe_check_remove(struct ixgbe_hw *hw, u32 reg) +{ +	u32 value; + +	/* The following check not only optimizes a bit by not +	 * performing a read on the status register when the +	 * register just read was a status register read that +	 * returned IXGBE_FAILED_READ_REG. It also blocks any +	 * potential recursion. +	 */ +	if (reg == IXGBE_STATUS) { +		ixgbe_remove_adapter(hw); +		return; +	} +	value = ixgbe_read_reg(hw, IXGBE_STATUS); +	if (value == IXGBE_FAILED_READ_REG) +		ixgbe_remove_adapter(hw); +} + +/** + * ixgbe_read_reg - Read from device register + * @hw: hw specific details + * @reg: offset of register to read + * + * Returns : value read or IXGBE_FAILED_READ_REG if removed + * + * This function is used to read device registers. It checks for device + * removal by confirming any read that returns all ones by checking the + * status register value for all ones. This function avoids reading from + * the hardware if a removal was previously detected in which case it + * returns IXGBE_FAILED_READ_REG (all ones). + */ +u32 ixgbe_read_reg(struct ixgbe_hw *hw, u32 reg) +{ +	u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr); +	u32 value; + +	if (ixgbe_removed(reg_addr)) +		return IXGBE_FAILED_READ_REG; +	value = readl(reg_addr + reg); +	if (unlikely(value == IXGBE_FAILED_READ_REG)) +		ixgbe_check_remove(hw, reg); +	return value; +} + +static bool ixgbe_check_cfg_remove(struct ixgbe_hw *hw, struct pci_dev *pdev) +{ +	u16 value; + +	pci_read_config_word(pdev, PCI_VENDOR_ID, &value); +	if (value == IXGBE_FAILED_READ_CFG_WORD) { +		ixgbe_remove_adapter(hw); +		return true; +	} +	return false; +} + +u16 ixgbe_read_pci_cfg_word(struct ixgbe_hw *hw, u32 reg) +{ +	struct ixgbe_adapter *adapter = hw->back; +	u16 value; + +	if (ixgbe_removed(hw->hw_addr)) +		return IXGBE_FAILED_READ_CFG_WORD; +	pci_read_config_word(adapter->pdev, reg, &value); +	if (value == IXGBE_FAILED_READ_CFG_WORD && +	    ixgbe_check_cfg_remove(hw, adapter->pdev)) +		return IXGBE_FAILED_READ_CFG_WORD; +	return value; +} + +#ifdef CONFIG_PCI_IOV +static u32 ixgbe_read_pci_cfg_dword(struct ixgbe_hw *hw, u32 reg) +{ +	struct ixgbe_adapter *adapter = hw->back; +	u32 value; + +	if (ixgbe_removed(hw->hw_addr)) +		return IXGBE_FAILED_READ_CFG_DWORD; +	pci_read_config_dword(adapter->pdev, reg, &value); +	if (value == IXGBE_FAILED_READ_CFG_DWORD && +	    ixgbe_check_cfg_remove(hw, adapter->pdev)) +		return IXGBE_FAILED_READ_CFG_DWORD; +	return value; +} +#endif /* CONFIG_PCI_IOV */ + +void ixgbe_write_pci_cfg_word(struct ixgbe_hw *hw, u32 reg, u16 value) +{ +	struct ixgbe_adapter *adapter = hw->back; + +	if (ixgbe_removed(hw->hw_addr)) +		return; +	pci_write_config_word(adapter->pdev, reg, value); +} +  static void ixgbe_service_event_complete(struct ixgbe_adapter *adapter)  {  	BUG_ON(!test_bit(__IXGBE_SERVICE_SCHED, &adapter->state));  	/* flush memory to make sure state is correct before next watchdog */ -	smp_mb__before_clear_bit(); +	smp_mb__before_atomic();  	clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state);  } @@ -872,11 +986,18 @@ static u64 ixgbe_get_tx_completed(struct ixgbe_ring *ring)  static u64 ixgbe_get_tx_pending(struct ixgbe_ring *ring)  { -	struct ixgbe_adapter *adapter = netdev_priv(ring->netdev); -	struct ixgbe_hw *hw = &adapter->hw; +	struct ixgbe_adapter *adapter; +	struct ixgbe_hw *hw; +	u32 head, tail; + +	if (ring->l2_accel_priv) +		adapter = ring->l2_accel_priv->real_adapter; +	else +		adapter = netdev_priv(ring->netdev); -	u32 head = IXGBE_READ_REG(hw, IXGBE_TDH(ring->reg_idx)); -	u32 tail = IXGBE_READ_REG(hw, IXGBE_TDT(ring->reg_idx)); +	hw = &adapter->hw; +	head = IXGBE_READ_REG(hw, IXGBE_TDH(ring->reg_idx)); +	tail = IXGBE_READ_REG(hw, IXGBE_TDT(ring->reg_idx));  	if (head != tail)  		return (head < tail) ? @@ -1227,7 +1348,9 @@ static inline void ixgbe_rx_hash(struct ixgbe_ring *ring,  				 struct sk_buff *skb)  {  	if (ring->netdev->features & NETIF_F_RXHASH) -		skb->rxhash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); +		skb_set_hash(skb, +			     le32_to_cpu(rx_desc->wb.lower.hi_dword.rss), +			     PKT_HASH_TYPE_L3);  }  #ifdef IXGBE_FCOE @@ -1308,7 +1431,7 @@ static inline void ixgbe_release_rx_desc(struct ixgbe_ring *rx_ring, u32 val)  	 * such as IA-64).  	 */  	wmb(); -	writel(val, rx_ring->tail); +	ixgbe_write_tail(rx_ring, val);  }  static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring, @@ -1443,7 +1566,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data,  	hdr.network += ETH_HLEN;  	/* handle any vlan tag if present */ -	if (protocol == __constant_htons(ETH_P_8021Q)) { +	if (protocol == htons(ETH_P_8021Q)) {  		if ((hdr.network - data) > (max_len - VLAN_HLEN))  			return max_len; @@ -1452,7 +1575,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data,  	}  	/* handle L3 protocols */ -	if (protocol == __constant_htons(ETH_P_IP)) { +	if (protocol == htons(ETH_P_IP)) {  		if ((hdr.network - data) > (max_len - sizeof(struct iphdr)))  			return max_len; @@ -1466,7 +1589,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data,  		/* record next protocol if header is present */  		if (!(hdr.ipv4->frag_off & htons(IP_OFFSET)))  			nexthdr = hdr.ipv4->protocol; -	} else if (protocol == __constant_htons(ETH_P_IPV6)) { +	} else if (protocol == htons(ETH_P_IPV6)) {  		if ((hdr.network - data) > (max_len - sizeof(struct ipv6hdr)))  			return max_len; @@ -1474,7 +1597,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data,  		nexthdr = hdr.ipv6->nexthdr;  		hlen = sizeof(struct ipv6hdr);  #ifdef IXGBE_FCOE -	} else if (protocol == __constant_htons(ETH_P_FCOE)) { +	} else if (protocol == htons(ETH_P_FCOE)) {  		if ((hdr.network - data) > (max_len - FCOE_HEADER_LEN))  			return max_len;  		hlen = FCOE_HEADER_LEN; @@ -1567,7 +1690,8 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring,  	ixgbe_rx_checksum(rx_ring, rx_desc, skb); -	ixgbe_ptp_rx_hwtstamp(rx_ring, rx_desc, skb); +	if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS))) +		ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector->adapter, skb);  	if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) &&  	    ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { @@ -1585,7 +1709,7 @@ static void ixgbe_rx_skb(struct ixgbe_q_vector *q_vector,  {  	struct ixgbe_adapter *adapter = q_vector->adapter; -	if (ixgbe_qv_ll_polling(q_vector)) +	if (ixgbe_qv_busy_polling(q_vector))  		netif_receive_skb(skb);  	else if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL))  		napi_gro_receive(&q_vector->napi, skb); @@ -1989,7 +2113,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,  #endif /* IXGBE_FCOE */  	u16 cleaned_count = ixgbe_desc_unused(rx_ring); -	do { +	while (likely(total_rx_packets < budget)) {  		union ixgbe_adv_rx_desc *rx_desc;  		struct sk_buff *skb; @@ -2064,7 +2188,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,  		/* update budget accounting */  		total_rx_packets++; -	} while (likely(total_rx_packets < budget)); +	}  	u64_stats_update_begin(&rx_ring->syncp);  	rx_ring->stats.packets += total_rx_packets; @@ -2097,7 +2221,7 @@ static int ixgbe_low_latency_recv(struct napi_struct *napi)  	ixgbe_for_each_ring(ring, q_vector->rx) {  		found = ixgbe_clean_rx_irq(q_vector, ring, 4); -#ifdef LL_EXTENDED_STATS +#ifdef BP_EXTENDED_STATS  		if (found)  			ring->stats.cleaned += found;  		else @@ -2593,9 +2717,12 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)  	switch (hw->mac.type) {  	case ixgbe_mac_82599EB:  	case ixgbe_mac_X540: -		if (eicr & IXGBE_EICR_ECC) -			e_info(link, "Received unrecoverable ECC Err, please " -			       "reboot\n"); +		if (eicr & IXGBE_EICR_ECC) { +			e_info(link, "Received ECC Err, initiating reset\n"); +			adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED; +			ixgbe_service_event_schedule(adapter); +			IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC); +		}  		/* Handle Flow Director Full threshold interrupt */  		if (eicr & IXGBE_EICR_FLOW_DIR) {  			int reinit_count = 0; @@ -2809,9 +2936,12 @@ static irqreturn_t ixgbe_intr(int irq, void *data)  		ixgbe_check_sfp_event(adapter, eicr);  		/* Fall through */  	case ixgbe_mac_X540: -		if (eicr & IXGBE_EICR_ECC) -			e_info(link, "Received unrecoverable ECC err, please " -				     "reboot\n"); +		if (eicr & IXGBE_EICR_ECC) { +			e_info(link, "Received ECC Err, initiating reset\n"); +			adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED; +			ixgbe_service_event_schedule(adapter); +			IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC); +		}  		ixgbe_check_overtemp_event(adapter, eicr);  		break;  	default: @@ -2963,7 +3093,7 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter,  			ring->count * sizeof(union ixgbe_adv_tx_desc));  	IXGBE_WRITE_REG(hw, IXGBE_TDH(reg_idx), 0);  	IXGBE_WRITE_REG(hw, IXGBE_TDT(reg_idx), 0); -	ring->tail = hw->hw_addr + IXGBE_TDT(reg_idx); +	ring->tail = adapter->io_addr + IXGBE_TDT(reg_idx);  	/*  	 * set WTHRESH to encourage burst writeback, it should not be set @@ -3005,7 +3135,7 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter,  		struct ixgbe_q_vector *q_vector = ring->q_vector;  		if (q_vector) -			netif_set_xps_queue(adapter->netdev, +			netif_set_xps_queue(ring->netdev,  					    &q_vector->affinity_mask,  					    ring->queue_index);  	} @@ -3302,6 +3432,8 @@ static void ixgbe_rx_desc_queue_enable(struct ixgbe_adapter *adapter,  	u32 rxdctl;  	u8 reg_idx = ring->reg_idx; +	if (ixgbe_removed(hw->hw_addr)) +		return;  	/* RXDCTL.EN will return 0 on 82598 if link is down, so skip it */  	if (hw->mac.type == ixgbe_mac_82598EB &&  	    !(IXGBE_READ_REG(hw, IXGBE_LINKS) & IXGBE_LINKS_UP)) @@ -3326,6 +3458,8 @@ void ixgbe_disable_rx_queue(struct ixgbe_adapter *adapter,  	u32 rxdctl;  	u8 reg_idx = ring->reg_idx; +	if (ixgbe_removed(hw->hw_addr)) +		return;  	rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(reg_idx));  	rxdctl &= ~IXGBE_RXDCTL_ENABLE; @@ -3366,7 +3500,7 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter,  			ring->count * sizeof(union ixgbe_adv_rx_desc));  	IXGBE_WRITE_REG(hw, IXGBE_RDH(reg_idx), 0);  	IXGBE_WRITE_REG(hw, IXGBE_RDT(reg_idx), 0); -	ring->tail = hw->hw_addr + IXGBE_RDT(reg_idx); +	ring->tail = adapter->io_addr + IXGBE_RDT(reg_idx);  	ixgbe_configure_srrctl(adapter, ring);  	ixgbe_configure_rscctl(adapter, ring); @@ -3395,7 +3529,7 @@ static void ixgbe_setup_psrtype(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw;  	int rss_i = adapter->ring_feature[RING_F_RSS].indices; -	int p; +	u16 pool;  	/* PSRTYPE must be initialized in non 82598 adapters */  	u32 psrtype = IXGBE_PSRTYPE_TCPHDR | @@ -3412,9 +3546,8 @@ static void ixgbe_setup_psrtype(struct ixgbe_adapter *adapter)  	else if (rss_i > 1)  		psrtype |= 1 << 29; -	for (p = 0; p < adapter->num_rx_pools; p++) -		IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(VMDQ_P(p)), -				psrtype); +	for_each_set_bit(pool, &adapter->fwd_bitmask, 32) +		IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(VMDQ_P(pool)), psrtype);  }  static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter) @@ -3636,35 +3769,6 @@ static int ixgbe_vlan_rx_kill_vid(struct net_device *netdev,  }  /** - * ixgbe_vlan_filter_disable - helper to disable hw vlan filtering - * @adapter: driver data - */ -static void ixgbe_vlan_filter_disable(struct ixgbe_adapter *adapter) -{ -	struct ixgbe_hw *hw = &adapter->hw; -	u32 vlnctrl; - -	vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL); -	vlnctrl &= ~(IXGBE_VLNCTRL_VFE | IXGBE_VLNCTRL_CFIEN); -	IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl); -} - -/** - * ixgbe_vlan_filter_enable - helper to enable hw vlan filtering - * @adapter: driver data - */ -static void ixgbe_vlan_filter_enable(struct ixgbe_adapter *adapter) -{ -	struct ixgbe_hw *hw = &adapter->hw; -	u32 vlnctrl; - -	vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL); -	vlnctrl |= IXGBE_VLNCTRL_VFE; -	vlnctrl &= ~IXGBE_VLNCTRL_CFIEN; -	IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl); -} - -/**   * ixgbe_vlan_strip_disable - helper to disable hw vlan stripping   * @adapter: driver data   */ @@ -3683,7 +3787,11 @@ static void ixgbe_vlan_strip_disable(struct ixgbe_adapter *adapter)  	case ixgbe_mac_82599EB:  	case ixgbe_mac_X540:  		for (i = 0; i < adapter->num_rx_queues; i++) { -			j = adapter->rx_ring[i]->reg_idx; +			struct ixgbe_ring *ring = adapter->rx_ring[i]; + +			if (ring->l2_accel_priv) +				continue; +			j = ring->reg_idx;  			vlnctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(j));  			vlnctrl &= ~IXGBE_RXDCTL_VME;  			IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(j), vlnctrl); @@ -3713,7 +3821,11 @@ static void ixgbe_vlan_strip_enable(struct ixgbe_adapter *adapter)  	case ixgbe_mac_82599EB:  	case ixgbe_mac_X540:  		for (i = 0; i < adapter->num_rx_queues; i++) { -			j = adapter->rx_ring[i]->reg_idx; +			struct ixgbe_ring *ring = adapter->rx_ring[i]; + +			if (ring->l2_accel_priv) +				continue; +			j = ring->reg_idx;  			vlnctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(j));  			vlnctrl |= IXGBE_RXDCTL_VME;  			IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(j), vlnctrl); @@ -3735,6 +3847,158 @@ static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter)  }  /** + * ixgbe_write_mc_addr_list - write multicast addresses to MTA + * @netdev: network interface device structure + * + * Writes multicast address list to the MTA hash table. + * Returns: -ENOMEM on failure + *                0 on no addresses written + *                X on writing X addresses to MTA + **/ +static int ixgbe_write_mc_addr_list(struct net_device *netdev) +{ +	struct ixgbe_adapter *adapter = netdev_priv(netdev); +	struct ixgbe_hw *hw = &adapter->hw; + +	if (!netif_running(netdev)) +		return 0; + +	if (hw->mac.ops.update_mc_addr_list) +		hw->mac.ops.update_mc_addr_list(hw, netdev); +	else +		return -ENOMEM; + +#ifdef CONFIG_PCI_IOV +	ixgbe_restore_vf_multicasts(adapter); +#endif + +	return netdev_mc_count(netdev); +} + +#ifdef CONFIG_PCI_IOV +void ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter) +{ +	struct ixgbe_hw *hw = &adapter->hw; +	int i; +	for (i = 0; i < hw->mac.num_rar_entries; i++) { +		if (adapter->mac_table[i].state & IXGBE_MAC_STATE_IN_USE) +			hw->mac.ops.set_rar(hw, i, adapter->mac_table[i].addr, +					    adapter->mac_table[i].queue, +					    IXGBE_RAH_AV); +		else +			hw->mac.ops.clear_rar(hw, i); + +		adapter->mac_table[i].state &= ~(IXGBE_MAC_STATE_MODIFIED); +	} +} +#endif + +static void ixgbe_sync_mac_table(struct ixgbe_adapter *adapter) +{ +	struct ixgbe_hw *hw = &adapter->hw; +	int i; +	for (i = 0; i < hw->mac.num_rar_entries; i++) { +		if (adapter->mac_table[i].state & IXGBE_MAC_STATE_MODIFIED) { +			if (adapter->mac_table[i].state & +			    IXGBE_MAC_STATE_IN_USE) +				hw->mac.ops.set_rar(hw, i, +						adapter->mac_table[i].addr, +						adapter->mac_table[i].queue, +						IXGBE_RAH_AV); +			else +				hw->mac.ops.clear_rar(hw, i); + +			adapter->mac_table[i].state &= +						~(IXGBE_MAC_STATE_MODIFIED); +		} +	} +} + +static void ixgbe_flush_sw_mac_table(struct ixgbe_adapter *adapter) +{ +	int i; +	struct ixgbe_hw *hw = &adapter->hw; + +	for (i = 0; i < hw->mac.num_rar_entries; i++) { +		adapter->mac_table[i].state |= IXGBE_MAC_STATE_MODIFIED; +		adapter->mac_table[i].state &= ~IXGBE_MAC_STATE_IN_USE; +		memset(adapter->mac_table[i].addr, 0, ETH_ALEN); +		adapter->mac_table[i].queue = 0; +	} +	ixgbe_sync_mac_table(adapter); +} + +static int ixgbe_available_rars(struct ixgbe_adapter *adapter) +{ +	struct ixgbe_hw *hw = &adapter->hw; +	int i, count = 0; + +	for (i = 0; i < hw->mac.num_rar_entries; i++) { +		if (adapter->mac_table[i].state == 0) +			count++; +	} +	return count; +} + +/* this function destroys the first RAR entry */ +static void ixgbe_mac_set_default_filter(struct ixgbe_adapter *adapter, +					 u8 *addr) +{ +	struct ixgbe_hw *hw = &adapter->hw; + +	memcpy(&adapter->mac_table[0].addr, addr, ETH_ALEN); +	adapter->mac_table[0].queue = VMDQ_P(0); +	adapter->mac_table[0].state = (IXGBE_MAC_STATE_DEFAULT | +				       IXGBE_MAC_STATE_IN_USE); +	hw->mac.ops.set_rar(hw, 0, adapter->mac_table[0].addr, +			    adapter->mac_table[0].queue, +			    IXGBE_RAH_AV); +} + +int ixgbe_add_mac_filter(struct ixgbe_adapter *adapter, u8 *addr, u16 queue) +{ +	struct ixgbe_hw *hw = &adapter->hw; +	int i; + +	if (is_zero_ether_addr(addr)) +		return -EINVAL; + +	for (i = 0; i < hw->mac.num_rar_entries; i++) { +		if (adapter->mac_table[i].state & IXGBE_MAC_STATE_IN_USE) +			continue; +		adapter->mac_table[i].state |= (IXGBE_MAC_STATE_MODIFIED | +						IXGBE_MAC_STATE_IN_USE); +		ether_addr_copy(adapter->mac_table[i].addr, addr); +		adapter->mac_table[i].queue = queue; +		ixgbe_sync_mac_table(adapter); +		return i; +	} +	return -ENOMEM; +} + +int ixgbe_del_mac_filter(struct ixgbe_adapter *adapter, u8 *addr, u16 queue) +{ +	/* search table for addr, if found, set to 0 and sync */ +	int i; +	struct ixgbe_hw *hw = &adapter->hw; + +	if (is_zero_ether_addr(addr)) +		return -EINVAL; + +	for (i = 0; i < hw->mac.num_rar_entries; i++) { +		if (ether_addr_equal(addr, adapter->mac_table[i].addr) && +		    adapter->mac_table[i].queue == queue) { +			adapter->mac_table[i].state |= IXGBE_MAC_STATE_MODIFIED; +			adapter->mac_table[i].state &= ~IXGBE_MAC_STATE_IN_USE; +			memset(adapter->mac_table[i].addr, 0, ETH_ALEN); +			adapter->mac_table[i].queue = 0; +			ixgbe_sync_mac_table(adapter); +			return 0; +		} +	} +	return -ENOMEM; +} +/**   * ixgbe_write_uc_addr_list - write unicast addresses to RAR table   * @netdev: network interface device structure   * @@ -3743,39 +4007,23 @@ static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter)   *                0 on no addresses written   *                X on writing X addresses to the RAR table   **/ -static int ixgbe_write_uc_addr_list(struct net_device *netdev) +static int ixgbe_write_uc_addr_list(struct net_device *netdev, int vfn)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); -	struct ixgbe_hw *hw = &adapter->hw; -	unsigned int rar_entries = hw->mac.num_rar_entries - 1;  	int count = 0; -	/* In SR-IOV mode significantly less RAR entries are available */ -	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) -		rar_entries = IXGBE_MAX_PF_MACVLANS - 1; -  	/* return ENOMEM indicating insufficient memory for addresses */ -	if (netdev_uc_count(netdev) > rar_entries) +	if (netdev_uc_count(netdev) > ixgbe_available_rars(adapter))  		return -ENOMEM;  	if (!netdev_uc_empty(netdev)) {  		struct netdev_hw_addr *ha; -		/* return error if we do not support writing to RAR table */ -		if (!hw->mac.ops.set_rar) -			return -ENOMEM; -  		netdev_for_each_uc_addr(ha, netdev) { -			if (!rar_entries) -				break; -			hw->mac.ops.set_rar(hw, rar_entries--, ha->addr, -					    VMDQ_P(0), IXGBE_RAH_AV); +			ixgbe_del_mac_filter(adapter, ha->addr, vfn); +			ixgbe_add_mac_filter(adapter, ha->addr, vfn);  			count++;  		}  	} -	/* write the addresses in reverse order to avoid write combining */ -	for (; rar_entries > 0 ; rar_entries--) -		hw->mac.ops.clear_rar(hw, rar_entries); -  	return count;  } @@ -3793,11 +4041,12 @@ void ixgbe_set_rx_mode(struct net_device *netdev)  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_hw *hw = &adapter->hw;  	u32 fctrl, vmolr = IXGBE_VMOLR_BAM | IXGBE_VMOLR_AUPE; +	u32 vlnctrl;  	int count;  	/* Check for Promiscuous and All Multicast modes */ -  	fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL); +	vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);  	/* set all bits that we expect to always be set */  	fctrl &= ~IXGBE_FCTRL_SBP; /* disable store-bad-packets */ @@ -3807,34 +4056,24 @@ void ixgbe_set_rx_mode(struct net_device *netdev)  	/* clear the bits we are changing the status of */  	fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE); - +	vlnctrl &= ~(IXGBE_VLNCTRL_VFE | IXGBE_VLNCTRL_CFIEN);  	if (netdev->flags & IFF_PROMISC) {  		hw->addr_ctrl.user_set_promisc = true;  		fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE); -		vmolr |= (IXGBE_VMOLR_ROPE | IXGBE_VMOLR_MPE); +		vmolr |= IXGBE_VMOLR_MPE;  		/* Only disable hardware filter vlans in promiscuous mode  		 * if SR-IOV and VMDQ are disabled - otherwise ensure  		 * that hardware VLAN filters remain enabled.  		 */  		if (!(adapter->flags & (IXGBE_FLAG_VMDQ_ENABLED |  					IXGBE_FLAG_SRIOV_ENABLED))) -			ixgbe_vlan_filter_disable(adapter); -		else -			ixgbe_vlan_filter_enable(adapter); +			vlnctrl |= (IXGBE_VLNCTRL_VFE | IXGBE_VLNCTRL_CFIEN);  	} else {  		if (netdev->flags & IFF_ALLMULTI) {  			fctrl |= IXGBE_FCTRL_MPE;  			vmolr |= IXGBE_VMOLR_MPE; -		} else { -			/* -			 * Write addresses to the MTA, if the attempt fails -			 * then we should just turn on promiscuous mode so -			 * that we can at least receive multicast traffic -			 */ -			hw->mac.ops.update_mc_addr_list(hw, netdev); -			vmolr |= IXGBE_VMOLR_ROMPE;  		} -		ixgbe_vlan_filter_enable(adapter); +		vlnctrl |= IXGBE_VLNCTRL_VFE;  		hw->addr_ctrl.user_set_promisc = false;  	} @@ -3843,14 +4082,23 @@ void ixgbe_set_rx_mode(struct net_device *netdev)  	 * sufficient space to store all the addresses then enable  	 * unicast promiscuous mode  	 */ -	count = ixgbe_write_uc_addr_list(netdev); +	count = ixgbe_write_uc_addr_list(netdev, VMDQ_P(0));  	if (count < 0) {  		fctrl |= IXGBE_FCTRL_UPE;  		vmolr |= IXGBE_VMOLR_ROPE;  	} -	if (adapter->num_vfs) -		ixgbe_restore_vf_multicasts(adapter); +	/* Write addresses to the MTA, if the attempt fails +	 * then we should just turn on promiscuous mode so +	 * that we can at least receive multicast traffic +	 */ +	count = ixgbe_write_mc_addr_list(netdev); +	if (count < 0) { +		fctrl |= IXGBE_FCTRL_MPE; +		vmolr |= IXGBE_VMOLR_MPE; +	} else if (count) { +		vmolr |= IXGBE_VMOLR_ROMPE; +	}  	if (hw->mac.type != ixgbe_mac_82598EB) {  		vmolr |= IXGBE_READ_REG(hw, IXGBE_VMOLR(VMDQ_P(0))) & @@ -3871,6 +4119,7 @@ void ixgbe_set_rx_mode(struct net_device *netdev)  		/* NOTE:  VLAN filtering is disabled by setting PROMISC */  	} +	IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);  	IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);  	if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) @@ -3893,15 +4142,13 @@ static void ixgbe_napi_disable_all(struct ixgbe_adapter *adapter)  {  	int q_idx; -	local_bh_disable(); /* for ixgbe_qv_lock_napi() */  	for (q_idx = 0; q_idx < adapter->num_q_vectors; q_idx++) {  		napi_disable(&adapter->q_vector[q_idx]->napi); -		while (!ixgbe_qv_lock_napi(adapter->q_vector[q_idx])) { +		while (!ixgbe_qv_disable(adapter->q_vector[q_idx])) {  			pr_info("QV %d locked\n", q_idx); -			mdelay(1); +			usleep_range(1000, 20000);  		}  	} -	local_bh_enable();  }  #ifdef CONFIG_IXGBE_DCB @@ -3989,8 +4236,8 @@ static int ixgbe_hpbthresh(struct ixgbe_adapter *adapter, int pb)  	    (tc < IXGBE_FCOE_JUMBO_FRAME_SIZE) &&  	    (pb == ixgbe_fcoe_get_tc(adapter)))  		tc = IXGBE_FCOE_JUMBO_FRAME_SIZE; -  #endif +  	/* Calculate delay value for device */  	switch (hw->mac.type) {  	case ixgbe_mac_X540: @@ -4031,7 +4278,7 @@ static int ixgbe_hpbthresh(struct ixgbe_adapter *adapter, int pb)   * @adapter: board private structure to calculate for   * @pb: packet buffer to calculate   */ -static int ixgbe_lpbthresh(struct ixgbe_adapter *adapter) +static int ixgbe_lpbthresh(struct ixgbe_adapter *adapter, int pb)  {  	struct ixgbe_hw *hw = &adapter->hw;  	struct net_device *dev = adapter->netdev; @@ -4041,6 +4288,14 @@ static int ixgbe_lpbthresh(struct ixgbe_adapter *adapter)  	/* Calculate max LAN frame size */  	tc = dev->mtu + ETH_HLEN + ETH_FCS_LEN; +#ifdef IXGBE_FCOE +	/* FCoE traffic class uses FCOE jumbo frames */ +	if ((dev->features & NETIF_F_FCOE_MTU) && +	    (tc < IXGBE_FCOE_JUMBO_FRAME_SIZE) && +	    (pb == netdev_get_prio_tc_map(dev, adapter->fcoe.up))) +		tc = IXGBE_FCOE_JUMBO_FRAME_SIZE; +#endif +  	/* Calculate delay value for device */  	switch (hw->mac.type) {  	case ixgbe_mac_X540: @@ -4067,15 +4322,17 @@ static void ixgbe_pbthresh_setup(struct ixgbe_adapter *adapter)  	if (!num_tc)  		num_tc = 1; -	hw->fc.low_water = ixgbe_lpbthresh(adapter); -  	for (i = 0; i < num_tc; i++) {  		hw->fc.high_water[i] = ixgbe_hpbthresh(adapter, i); +		hw->fc.low_water[i] = ixgbe_lpbthresh(adapter, i);  		/* Low water marks must not be larger than high water marks */ -		if (hw->fc.low_water > hw->fc.high_water[i]) -			hw->fc.low_water = 0; +		if (hw->fc.low_water[i] > hw->fc.high_water[i]) +			hw->fc.low_water[i] = 0;  	} + +	for (; i < MAX_TRAFFIC_CLASS; i++) +		hw->fc.high_water[i] = 0;  }  static void ixgbe_configure_pb(struct ixgbe_adapter *adapter) @@ -4118,6 +4375,218 @@ static void ixgbe_fdir_filter_restore(struct ixgbe_adapter *adapter)  	spin_unlock(&adapter->fdir_perfect_lock);  } +static void ixgbe_macvlan_set_rx_mode(struct net_device *dev, unsigned int pool, +				      struct ixgbe_adapter *adapter) +{ +	struct ixgbe_hw *hw = &adapter->hw; +	u32 vmolr; + +	/* No unicast promiscuous support for VMDQ devices. */ +	vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(pool)); +	vmolr |= (IXGBE_VMOLR_ROMPE | IXGBE_VMOLR_BAM | IXGBE_VMOLR_AUPE); + +	/* clear the affected bit */ +	vmolr &= ~IXGBE_VMOLR_MPE; + +	if (dev->flags & IFF_ALLMULTI) { +		vmolr |= IXGBE_VMOLR_MPE; +	} else { +		vmolr |= IXGBE_VMOLR_ROMPE; +		hw->mac.ops.update_mc_addr_list(hw, dev); +	} +	ixgbe_write_uc_addr_list(adapter->netdev, pool); +	IXGBE_WRITE_REG(hw, IXGBE_VMOLR(pool), vmolr); +} + +static void ixgbe_fwd_psrtype(struct ixgbe_fwd_adapter *vadapter) +{ +	struct ixgbe_adapter *adapter = vadapter->real_adapter; +	int rss_i = adapter->num_rx_queues_per_pool; +	struct ixgbe_hw *hw = &adapter->hw; +	u16 pool = vadapter->pool; +	u32 psrtype = IXGBE_PSRTYPE_TCPHDR | +		      IXGBE_PSRTYPE_UDPHDR | +		      IXGBE_PSRTYPE_IPV4HDR | +		      IXGBE_PSRTYPE_L2HDR | +		      IXGBE_PSRTYPE_IPV6HDR; + +	if (hw->mac.type == ixgbe_mac_82598EB) +		return; + +	if (rss_i > 3) +		psrtype |= 2 << 29; +	else if (rss_i > 1) +		psrtype |= 1 << 29; + +	IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(VMDQ_P(pool)), psrtype); +} + +/** + * ixgbe_clean_rx_ring - Free Rx Buffers per Queue + * @rx_ring: ring to free buffers from + **/ +static void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring) +{ +	struct device *dev = rx_ring->dev; +	unsigned long size; +	u16 i; + +	/* ring already cleared, nothing to do */ +	if (!rx_ring->rx_buffer_info) +		return; + +	/* Free all the Rx ring sk_buffs */ +	for (i = 0; i < rx_ring->count; i++) { +		struct ixgbe_rx_buffer *rx_buffer; + +		rx_buffer = &rx_ring->rx_buffer_info[i]; +		if (rx_buffer->skb) { +			struct sk_buff *skb = rx_buffer->skb; +			if (IXGBE_CB(skb)->page_released) { +				dma_unmap_page(dev, +					       IXGBE_CB(skb)->dma, +					       ixgbe_rx_bufsz(rx_ring), +					       DMA_FROM_DEVICE); +				IXGBE_CB(skb)->page_released = false; +			} +			dev_kfree_skb(skb); +		} +		rx_buffer->skb = NULL; +		if (rx_buffer->dma) +			dma_unmap_page(dev, rx_buffer->dma, +				       ixgbe_rx_pg_size(rx_ring), +				       DMA_FROM_DEVICE); +		rx_buffer->dma = 0; +		if (rx_buffer->page) +			__free_pages(rx_buffer->page, +				     ixgbe_rx_pg_order(rx_ring)); +		rx_buffer->page = NULL; +	} + +	size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; +	memset(rx_ring->rx_buffer_info, 0, size); + +	/* Zero out the descriptor ring */ +	memset(rx_ring->desc, 0, rx_ring->size); + +	rx_ring->next_to_alloc = 0; +	rx_ring->next_to_clean = 0; +	rx_ring->next_to_use = 0; +} + +static void ixgbe_disable_fwd_ring(struct ixgbe_fwd_adapter *vadapter, +				   struct ixgbe_ring *rx_ring) +{ +	struct ixgbe_adapter *adapter = vadapter->real_adapter; +	int index = rx_ring->queue_index + vadapter->rx_base_queue; + +	/* shutdown specific queue receive and wait for dma to settle */ +	ixgbe_disable_rx_queue(adapter, rx_ring); +	usleep_range(10000, 20000); +	ixgbe_irq_disable_queues(adapter, ((u64)1 << index)); +	ixgbe_clean_rx_ring(rx_ring); +	rx_ring->l2_accel_priv = NULL; +} + +static int ixgbe_fwd_ring_down(struct net_device *vdev, +			       struct ixgbe_fwd_adapter *accel) +{ +	struct ixgbe_adapter *adapter = accel->real_adapter; +	unsigned int rxbase = accel->rx_base_queue; +	unsigned int txbase = accel->tx_base_queue; +	int i; + +	netif_tx_stop_all_queues(vdev); + +	for (i = 0; i < adapter->num_rx_queues_per_pool; i++) { +		ixgbe_disable_fwd_ring(accel, adapter->rx_ring[rxbase + i]); +		adapter->rx_ring[rxbase + i]->netdev = adapter->netdev; +	} + +	for (i = 0; i < adapter->num_rx_queues_per_pool; i++) { +		adapter->tx_ring[txbase + i]->l2_accel_priv = NULL; +		adapter->tx_ring[txbase + i]->netdev = adapter->netdev; +	} + + +	return 0; +} + +static int ixgbe_fwd_ring_up(struct net_device *vdev, +			     struct ixgbe_fwd_adapter *accel) +{ +	struct ixgbe_adapter *adapter = accel->real_adapter; +	unsigned int rxbase, txbase, queues; +	int i, baseq, err = 0; + +	if (!test_bit(accel->pool, &adapter->fwd_bitmask)) +		return 0; + +	baseq = accel->pool * adapter->num_rx_queues_per_pool; +	netdev_dbg(vdev, "pool %i:%i queues %i:%i VSI bitmask %lx\n", +		   accel->pool, adapter->num_rx_pools, +		   baseq, baseq + adapter->num_rx_queues_per_pool, +		   adapter->fwd_bitmask); + +	accel->netdev = vdev; +	accel->rx_base_queue = rxbase = baseq; +	accel->tx_base_queue = txbase = baseq; + +	for (i = 0; i < adapter->num_rx_queues_per_pool; i++) +		ixgbe_disable_fwd_ring(accel, adapter->rx_ring[rxbase + i]); + +	for (i = 0; i < adapter->num_rx_queues_per_pool; i++) { +		adapter->rx_ring[rxbase + i]->netdev = vdev; +		adapter->rx_ring[rxbase + i]->l2_accel_priv = accel; +		ixgbe_configure_rx_ring(adapter, adapter->rx_ring[rxbase + i]); +	} + +	for (i = 0; i < adapter->num_rx_queues_per_pool; i++) { +		adapter->tx_ring[txbase + i]->netdev = vdev; +		adapter->tx_ring[txbase + i]->l2_accel_priv = accel; +	} + +	queues = min_t(unsigned int, +		       adapter->num_rx_queues_per_pool, vdev->num_tx_queues); +	err = netif_set_real_num_tx_queues(vdev, queues); +	if (err) +		goto fwd_queue_err; + +	err = netif_set_real_num_rx_queues(vdev, queues); +	if (err) +		goto fwd_queue_err; + +	if (is_valid_ether_addr(vdev->dev_addr)) +		ixgbe_add_mac_filter(adapter, vdev->dev_addr, accel->pool); + +	ixgbe_fwd_psrtype(accel); +	ixgbe_macvlan_set_rx_mode(vdev, accel->pool, adapter); +	return err; +fwd_queue_err: +	ixgbe_fwd_ring_down(vdev, accel); +	return err; +} + +static void ixgbe_configure_dfwd(struct ixgbe_adapter *adapter) +{ +	struct net_device *upper; +	struct list_head *iter; +	int err; + +	netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) { +		if (netif_is_macvlan(upper)) { +			struct macvlan_dev *dfwd = netdev_priv(upper); +			struct ixgbe_fwd_adapter *vadapter = dfwd->fwd_priv; + +			if (dfwd->fwd_priv) { +				err = ixgbe_fwd_ring_up(upper, vadapter); +				if (err) +					continue; +			} +		} +	} +} +  static void ixgbe_configure(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw; @@ -4169,6 +4638,7 @@ static void ixgbe_configure(struct ixgbe_adapter *adapter)  #endif /* IXGBE_FCOE */  	ixgbe_configure_tx(adapter);  	ixgbe_configure_rx(adapter); +	ixgbe_configure_dfwd(adapter);  }  static inline bool ixgbe_is_sfp(struct ixgbe_hw *hw) @@ -4186,6 +4656,8 @@ static inline bool ixgbe_is_sfp(struct ixgbe_hw *hw)  	case ixgbe_phy_qsfp_active_unknown:  	case ixgbe_phy_qsfp_intel:  	case ixgbe_phy_qsfp_unknown: +	/* ixgbe_phy_none is set when no SFP module is present */ +	case ixgbe_phy_none:  		return true;  	case ixgbe_phy_nl:  		if (hw->mac.type == ixgbe_mac_82598EB) @@ -4337,6 +4809,7 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter)  	if (hw->mac.ops.enable_tx_laser)  		hw->mac.ops.enable_tx_laser(hw); +	smp_mb__before_atomic();  	clear_bit(__IXGBE_DOWN, &adapter->state);  	ixgbe_napi_enable_all(adapter); @@ -4362,9 +4835,6 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter)  			e_crit(drv, "Fan has stopped, replace the adapter\n");  	} -	/* enable transmits */ -	netif_tx_start_all_queues(adapter->netdev); -  	/* bring the link up in the watchdog, this could race with our first  	 * link up interrupt but shouldn't be a problem */  	adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; @@ -4409,8 +4879,12 @@ void ixgbe_up(struct ixgbe_adapter *adapter)  void ixgbe_reset(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw; +	struct net_device *netdev = adapter->netdev;  	int err; +	u8 old_addr[ETH_ALEN]; +	if (ixgbe_removed(hw->hw_addr)) +		return;  	/* lock SFP init bit to prevent race conditions with the watchdog */  	while (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state))  		usleep_range(1000, 2000); @@ -4443,9 +4917,10 @@ void ixgbe_reset(struct ixgbe_adapter *adapter)  	}  	clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state); - -	/* reprogram the RAR[0] in case user changed it. */ -	hw->mac.ops.set_rar(hw, 0, hw->mac.addr, VMDQ_P(0), IXGBE_RAH_AV); +	/* do not flush user set addresses */ +	memcpy(old_addr, &adapter->mac_table[0].addr, netdev->addr_len); +	ixgbe_flush_sw_mac_table(adapter); +	ixgbe_mac_set_default_filter(adapter, old_addr);  	/* update SAN MAC vmdq pool selection */  	if (hw->mac.san_mac_rar_index) @@ -4456,59 +4931,6 @@ void ixgbe_reset(struct ixgbe_adapter *adapter)  }  /** - * ixgbe_clean_rx_ring - Free Rx Buffers per Queue - * @rx_ring: ring to free buffers from - **/ -static void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring) -{ -	struct device *dev = rx_ring->dev; -	unsigned long size; -	u16 i; - -	/* ring already cleared, nothing to do */ -	if (!rx_ring->rx_buffer_info) -		return; - -	/* Free all the Rx ring sk_buffs */ -	for (i = 0; i < rx_ring->count; i++) { -		struct ixgbe_rx_buffer *rx_buffer; - -		rx_buffer = &rx_ring->rx_buffer_info[i]; -		if (rx_buffer->skb) { -			struct sk_buff *skb = rx_buffer->skb; -			if (IXGBE_CB(skb)->page_released) { -				dma_unmap_page(dev, -					       IXGBE_CB(skb)->dma, -					       ixgbe_rx_bufsz(rx_ring), -					       DMA_FROM_DEVICE); -				IXGBE_CB(skb)->page_released = false; -			} -			dev_kfree_skb(skb); -		} -		rx_buffer->skb = NULL; -		if (rx_buffer->dma) -			dma_unmap_page(dev, rx_buffer->dma, -				       ixgbe_rx_pg_size(rx_ring), -				       DMA_FROM_DEVICE); -		rx_buffer->dma = 0; -		if (rx_buffer->page) -			__free_pages(rx_buffer->page, -				     ixgbe_rx_pg_order(rx_ring)); -		rx_buffer->page = NULL; -	} - -	size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; -	memset(rx_ring->rx_buffer_info, 0, size); - -	/* Zero out the descriptor ring */ -	memset(rx_ring->desc, 0, rx_ring->size); - -	rx_ring->next_to_alloc = 0; -	rx_ring->next_to_clean = 0; -	rx_ring->next_to_use = 0; -} - -/**   * ixgbe_clean_tx_ring - Free Tx Buffers   * @tx_ring: ring to be cleaned   **/ @@ -4585,11 +5007,14 @@ void ixgbe_down(struct ixgbe_adapter *adapter)  {  	struct net_device *netdev = adapter->netdev;  	struct ixgbe_hw *hw = &adapter->hw; +	struct net_device *upper; +	struct list_head *iter;  	u32 rxctrl;  	int i;  	/* signal that we are down to the interrupt handler */ -	set_bit(__IXGBE_DOWN, &adapter->state); +	if (test_and_set_bit(__IXGBE_DOWN, &adapter->state)) +		return; /* do nothing if already down */  	/* disable receives */  	rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL); @@ -4608,6 +5033,19 @@ void ixgbe_down(struct ixgbe_adapter *adapter)  	netif_carrier_off(netdev);  	netif_tx_disable(netdev); +	/* disable any upper devices */ +	netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) { +		if (netif_is_macvlan(upper)) { +			struct macvlan_dev *vlan = netdev_priv(upper); + +			if (vlan->fwd_priv) { +				netif_tx_stop_all_queues(upper); +				netif_carrier_off(upper); +				netif_tx_disable(upper); +			} +		} +	} +  	ixgbe_irq_disable(adapter);  	ixgbe_napi_disable_all(adapter); @@ -4728,6 +5166,10 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)  #endif /* CONFIG_IXGBE_DCB */  #endif /* IXGBE_FCOE */ +	adapter->mac_table = kzalloc(sizeof(struct ixgbe_mac_addr) * +				     hw->mac.num_rar_entries, +				     GFP_ATOMIC); +  	/* Set MAC specific capability flags and exceptions */  	switch (hw->mac.type) {  	case ixgbe_mac_82598EB: @@ -4816,11 +5258,20 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)  	hw->fc.disable_fc_autoneg = ixgbe_device_supports_autoneg_fc(hw);  #ifdef CONFIG_PCI_IOV +	if (max_vfs > 0) +		e_dev_warn("Enabling SR-IOV VFs using the max_vfs module parameter is deprecated - please use the pci sysfs interface instead.\n"); +  	/* assign number of SR-IOV VFs */ -	if (hw->mac.type != ixgbe_mac_82598EB) -		adapter->num_vfs = (max_vfs > 63) ? 0 : max_vfs; +	if (hw->mac.type != ixgbe_mac_82598EB) { +		if (max_vfs > IXGBE_MAX_VFS_DRV_LIMIT) { +			adapter->num_vfs = 0; +			e_dev_warn("max_vfs parameter out of range. Not assigning any SR-IOV VFs\n"); +		} else { +			adapter->num_vfs = max_vfs; +		} +	} +#endif /* CONFIG_PCI_IOV */ -#endif  	/* enable itr by default in dynamic mode */  	adapter->rx_itr_setting = 1;  	adapter->tx_itr_setting = 1; @@ -4838,6 +5289,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)  		return -EIO;  	} +	/* PF holds first pool slot */ +	set_bit(0, &adapter->fwd_bitmask);  	set_bit(__IXGBE_DOWN, &adapter->state);  	return 0; @@ -4867,6 +5320,8 @@ int ixgbe_setup_tx_resources(struct ixgbe_ring *tx_ring)  	if (!tx_ring->tx_buffer_info)  		goto err; +	u64_stats_init(&tx_ring->syncp); +  	/* round up to nearest 4K */  	tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc);  	tx_ring->size = ALIGN(tx_ring->size, 4096); @@ -4949,6 +5404,8 @@ int ixgbe_setup_rx_resources(struct ixgbe_ring *rx_ring)  	if (!rx_ring->rx_buffer_info)  		goto err; +	u64_stats_init(&rx_ring->syncp); +  	/* Round up to nearest 4K */  	rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);  	rx_ring->size = ALIGN(rx_ring->size, 4096); @@ -5143,7 +5600,7 @@ static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu)  static int ixgbe_open(struct net_device *netdev)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); -	int err; +	int err, queues;  	/* disallow open during test */  	if (test_bit(__IXGBE_TESTING, &adapter->state)) @@ -5168,16 +5625,21 @@ static int ixgbe_open(struct net_device *netdev)  		goto err_req_irq;  	/* Notify the stack of the actual queue counts. */ -	err = netif_set_real_num_tx_queues(netdev, -					   adapter->num_rx_pools > 1 ? 1 : -					   adapter->num_tx_queues); +	if (adapter->num_rx_pools > 1) +		queues = adapter->num_rx_queues_per_pool; +	else +		queues = adapter->num_tx_queues; + +	err = netif_set_real_num_tx_queues(netdev, queues);  	if (err)  		goto err_set_queues; - -	err = netif_set_real_num_rx_queues(netdev, -					   adapter->num_rx_pools > 1 ? 1 : -					   adapter->num_rx_queues); +	if (adapter->num_rx_pools > 1 && +	    adapter->num_rx_queues > IXGBE_MAX_L2A_QUEUES) +		queues = IXGBE_MAX_L2A_QUEUES; +	else +		queues = adapter->num_rx_queues; +	err = netif_set_real_num_rx_queues(netdev, queues);  	if (err)  		goto err_set_queues; @@ -5199,6 +5661,17 @@ err_setup_tx:  	return err;  } +static void ixgbe_close_suspend(struct ixgbe_adapter *adapter) +{ +	ixgbe_ptp_suspend(adapter); + +	ixgbe_down(adapter); +	ixgbe_free_irq(adapter); + +	ixgbe_free_all_tx_resources(adapter); +	ixgbe_free_all_rx_resources(adapter); +} +  /**   * ixgbe_close - Disables a network interface   * @netdev: network interface device structure @@ -5216,14 +5689,10 @@ static int ixgbe_close(struct net_device *netdev)  	ixgbe_ptp_stop(adapter); -	ixgbe_down(adapter); -	ixgbe_free_irq(adapter); +	ixgbe_close_suspend(adapter);  	ixgbe_fdir_filter_exit(adapter); -	ixgbe_free_all_tx_resources(adapter); -	ixgbe_free_all_rx_resources(adapter); -  	ixgbe_release_hw_control(adapter);  	return 0; @@ -5236,6 +5705,7 @@ static int ixgbe_resume(struct pci_dev *pdev)  	struct net_device *netdev = adapter->netdev;  	u32 err; +	adapter->hw.hw_addr = adapter->io_addr;  	pci_set_power_state(pdev, PCI_D0);  	pci_restore_state(pdev);  	/* @@ -5249,6 +5719,8 @@ static int ixgbe_resume(struct pci_dev *pdev)  		e_dev_err("Cannot enable PCI device from suspend\n");  		return err;  	} +	smp_mb__before_atomic(); +	clear_bit(__IXGBE_DISABLED, &adapter->state);  	pci_set_master(pdev);  	pci_wake_from_d3(pdev, false); @@ -5287,12 +5759,8 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)  	netif_device_detach(netdev);  	rtnl_lock(); -	if (netif_running(netdev)) { -		ixgbe_down(adapter); -		ixgbe_free_irq(adapter); -		ixgbe_free_all_tx_resources(adapter); -		ixgbe_free_all_rx_resources(adapter); -	} +	if (netif_running(netdev)) +		ixgbe_close_suspend(adapter);  	rtnl_unlock();  	ixgbe_clear_interrupt_scheme(adapter); @@ -5346,7 +5814,8 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)  	ixgbe_release_hw_control(adapter); -	pci_disable_device(pdev); +	if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) +		pci_disable_device(pdev);  	return 0;  } @@ -5623,7 +6092,7 @@ static void ixgbe_fdir_reinit_subtask(struct ixgbe_adapter *adapter)  	if (ixgbe_reinit_fdir_tables_82599(hw) == 0) {  		for (i = 0; i < adapter->num_tx_queues; i++)  			set_bit(__IXGBE_TX_FDIR_INIT_DONE, -			        &(adapter->tx_ring[i]->state)); +				&(adapter->tx_ring[i]->state));  		/* re-enable flow director interrupts */  		IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_FLOW_DIR);  	} else { @@ -5647,8 +6116,9 @@ static void ixgbe_check_hang_subtask(struct ixgbe_adapter *adapter)  	u64 eics = 0;  	int i; -	/* If we're down or resetting, just bail */ +	/* If we're down, removing or resetting, just bail */  	if (test_bit(__IXGBE_DOWN, &adapter->state) || +	    test_bit(__IXGBE_REMOVING, &adapter->state) ||  	    test_bit(__IXGBE_RESETTING, &adapter->state))  		return; @@ -5749,6 +6219,8 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)  {  	struct net_device *netdev = adapter->netdev;  	struct ixgbe_hw *hw = &adapter->hw; +	struct net_device *upper; +	struct list_head *iter;  	u32 link_speed = adapter->link_speed;  	bool flow_rx, flow_tx; @@ -5800,6 +6272,21 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)  	netif_carrier_on(netdev);  	ixgbe_check_vf_rate_limit(adapter); +	/* enable transmits */ +	netif_tx_wake_all_queues(adapter->netdev); + +	/* enable any upper devices */ +	rtnl_lock(); +	netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) { +		if (netif_is_macvlan(upper)) { +			struct macvlan_dev *vlan = netdev_priv(upper); + +			if (vlan->fwd_priv) +				netif_tx_wake_all_queues(upper); +		} +	} +	rtnl_unlock(); +  	/* update the default user priority for VFs */  	ixgbe_update_default_up(adapter); @@ -5895,8 +6382,9 @@ static void ixgbe_spoof_check(struct ixgbe_adapter *adapter)   **/  static void ixgbe_watchdog_subtask(struct ixgbe_adapter *adapter)  { -	/* if interface is down do nothing */ +	/* if interface is down, removing or resetting, do nothing */  	if (test_bit(__IXGBE_DOWN, &adapter->state) || +	    test_bit(__IXGBE_REMOVING, &adapter->state) ||  	    test_bit(__IXGBE_RESETTING, &adapter->state))  		return; @@ -6114,8 +6602,9 @@ static void ixgbe_reset_subtask(struct ixgbe_adapter *adapter)  	adapter->flags2 &= ~IXGBE_FLAG2_RESET_REQUESTED; -	/* If we're already down or resetting, just bail */ +	/* If we're already down, removing or resetting, just bail */  	if (test_bit(__IXGBE_DOWN, &adapter->state) || +	    test_bit(__IXGBE_REMOVING, &adapter->state) ||  	    test_bit(__IXGBE_RESETTING, &adapter->state))  		return; @@ -6123,7 +6612,9 @@ static void ixgbe_reset_subtask(struct ixgbe_adapter *adapter)  	netdev_err(adapter->netdev, "Reset adapter\n");  	adapter->tx_timeout_count++; +	rtnl_lock();  	ixgbe_reinit_locked(adapter); +	rtnl_unlock();  }  /** @@ -6135,6 +6626,15 @@ static void ixgbe_service_task(struct work_struct *work)  	struct ixgbe_adapter *adapter = container_of(work,  						     struct ixgbe_adapter,  						     service_task); +	if (ixgbe_removed(adapter->hw.hw_addr)) { +		if (!test_bit(__IXGBE_DOWN, &adapter->state)) { +			rtnl_lock(); +			ixgbe_down(adapter); +			rtnl_unlock(); +		} +		ixgbe_service_event_complete(adapter); +		return; +	}  	ixgbe_reset_subtask(adapter);  	ixgbe_sfp_detection_subtask(adapter);  	ixgbe_sfp_link_config_subtask(adapter); @@ -6158,6 +6658,7 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,  	struct sk_buff *skb = first->skb;  	u32 vlan_macip_lens, type_tucmd;  	u32 mss_l4len_idx, l4len; +	int err;  	if (skb->ip_summed != CHECKSUM_PARTIAL)  		return 0; @@ -6165,16 +6666,14 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,  	if (!skb_is_gso(skb))  		return 0; -	if (skb_header_cloned(skb)) { -		int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); -		if (err) -			return err; -	} +	err = skb_cow_head(skb, 0); +	if (err < 0) +		return err;  	/* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */  	type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP; -	if (first->protocol == __constant_htons(ETH_P_IP)) { +	if (first->protocol == htons(ETH_P_IP)) {  		struct iphdr *iph = ip_hdr(skb);  		iph->tot_len = 0;  		iph->check = 0; @@ -6234,12 +6733,12 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring,  	} else {  		u8 l4_hdr = 0;  		switch (first->protocol) { -		case __constant_htons(ETH_P_IP): +		case htons(ETH_P_IP):  			vlan_macip_lens |= skb_network_header_len(skb);  			type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;  			l4_hdr = ip_hdr(skb)->protocol;  			break; -		case __constant_htons(ETH_P_IPV6): +		case htons(ETH_P_IPV6):  			vlan_macip_lens |= skb_network_header_len(skb);  			l4_hdr = ipv6_hdr(skb)->nexthdr;  			break; @@ -6466,7 +6965,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring,  	tx_ring->next_to_use = i;  	/* notify HW of packet */ -	writel(i, tx_ring->tail); +	ixgbe_write_tail(tx_ring, i);  	return;  dma_error: @@ -6514,9 +7013,9 @@ static void ixgbe_atr(struct ixgbe_ring *ring,  	hdr.network = skb_network_header(first->skb);  	/* Currently only IPv4/IPv6 with TCP is supported */ -	if ((first->protocol != __constant_htons(ETH_P_IPV6) || +	if ((first->protocol != htons(ETH_P_IPV6) ||  	     hdr.ipv6->nexthdr != IPPROTO_TCP) && -	    (first->protocol != __constant_htons(ETH_P_IP) || +	    (first->protocol != htons(ETH_P_IP) ||  	     hdr.ipv4->protocol != IPPROTO_TCP))  		return; @@ -6549,12 +7048,12 @@ static void ixgbe_atr(struct ixgbe_ring *ring,  	 * and write the value to source port portion of compressed dword  	 */  	if (first->tx_flags & (IXGBE_TX_FLAGS_SW_VLAN | IXGBE_TX_FLAGS_HW_VLAN)) -		common.port.src ^= th->dest ^ __constant_htons(ETH_P_8021Q); +		common.port.src ^= th->dest ^ htons(ETH_P_8021Q);  	else  		common.port.src ^= th->dest ^ first->protocol;  	common.port.dst ^= th->source; -	if (first->protocol == __constant_htons(ETH_P_IP)) { +	if (first->protocol == htons(ETH_P_IP)) {  		input.formatted.flow_type = IXGBE_ATR_FLOW_TYPE_TCPV4;  		common.ip ^= hdr.ipv4->saddr ^ hdr.ipv4->daddr;  	} else { @@ -6600,26 +7099,34 @@ static inline int ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size)  	return __ixgbe_maybe_stop_tx(tx_ring, size);  } -#ifdef IXGBE_FCOE -static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb) +static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb, +			      void *accel_priv, select_queue_fallback_t fallback)  { +	struct ixgbe_fwd_adapter *fwd_adapter = accel_priv; +#ifdef IXGBE_FCOE  	struct ixgbe_adapter *adapter;  	struct ixgbe_ring_feature *f;  	int txq; +#endif + +	if (fwd_adapter) +		return skb->queue_mapping + fwd_adapter->tx_base_queue; + +#ifdef IXGBE_FCOE  	/*  	 * only execute the code below if protocol is FCoE  	 * or FIP and we have FCoE enabled on the adapter  	 */  	switch (vlan_get_protocol(skb)) { -	case __constant_htons(ETH_P_FCOE): -	case __constant_htons(ETH_P_FIP): +	case htons(ETH_P_FCOE): +	case htons(ETH_P_FIP):  		adapter = netdev_priv(dev);  		if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)  			break;  	default: -		return __netdev_pick_tx(dev, skb); +		return fallback(dev, skb);  	}  	f = &adapter->ring_feature[RING_F_FCOE]; @@ -6631,9 +7138,11 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb)  		txq -= f->indices;  	return txq + f->offset; +#else +	return fallback(dev, skb); +#endif  } -#endif  netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  			  struct ixgbe_adapter *adapter,  			  struct ixgbe_ring *tx_ring) @@ -6672,7 +7181,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  		tx_flags |= vlan_tx_tag_get(skb) << IXGBE_TX_FLAGS_VLAN_SHIFT;  		tx_flags |= IXGBE_TX_FLAGS_HW_VLAN;  	/* else if it is a SW VLAN check the next protocol and store the tag */ -	} else if (protocol == __constant_htons(ETH_P_8021Q)) { +	} else if (protocol == htons(ETH_P_8021Q)) {  		struct vlan_hdr *vhdr, _vhdr;  		vhdr = skb_header_pointer(skb, ETH_HLEN, sizeof(_vhdr), &_vhdr);  		if (!vhdr) @@ -6684,9 +7193,9 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  		tx_flags |= IXGBE_TX_FLAGS_SW_VLAN;  	} -	skb_tx_timestamp(skb); - -	if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { +	if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && +		     !test_and_set_bit_lock(__IXGBE_PTP_TX_IN_PROGRESS, +					    &adapter->state))) {  		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;  		tx_flags |= IXGBE_TX_FLAGS_TSTAMP; @@ -6696,6 +7205,8 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  		schedule_work(&adapter->ptp_tx_work);  	} +	skb_tx_timestamp(skb); +  #ifdef CONFIG_PCI_IOV  	/*  	 * Use the l2switch_enable flag - would be false if the DMA @@ -6714,8 +7225,8 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  					IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT;  		if (tx_flags & IXGBE_TX_FLAGS_SW_VLAN) {  			struct vlan_ethhdr *vhdr; -			if (skb_header_cloned(skb) && -			    pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) + +			if (skb_cow_head(skb, 0))  				goto out_drop;  			vhdr = (struct vlan_ethhdr *)skb->data;  			vhdr->h_vlan_TCI = htons(tx_flags >> @@ -6731,7 +7242,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  #ifdef IXGBE_FCOE  	/* setup tx offload for FCoE */ -	if ((protocol == __constant_htons(ETH_P_FCOE)) && +	if ((protocol == htons(ETH_P_FCOE)) &&  	    (tx_ring->netdev->features & (NETIF_F_FSO | NETIF_F_FCOE_CRC))) {  		tso = ixgbe_fso(tx_ring, first, &hdr_len);  		if (tso < 0) @@ -6767,8 +7278,9 @@ out_drop:  	return NETDEV_TX_OK;  } -static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb, -				    struct net_device *netdev) +static netdev_tx_t __ixgbe_xmit_frame(struct sk_buff *skb, +				      struct net_device *netdev, +				      struct ixgbe_ring *ring)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_ring *tx_ring; @@ -6784,10 +7296,17 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,  		skb_set_tail_pointer(skb, 17);  	} -	tx_ring = adapter->tx_ring[skb->queue_mapping]; +	tx_ring = ring ? ring : adapter->tx_ring[skb->queue_mapping]; +  	return ixgbe_xmit_frame_ring(skb, adapter, tx_ring);  } +static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb, +				    struct net_device *netdev) +{ +	return __ixgbe_xmit_frame(skb, netdev, NULL); +} +  /**   * ixgbe_set_mac - Change the Ethernet Address of the NIC   * @netdev: network interface device structure @@ -6800,16 +7319,17 @@ static int ixgbe_set_mac(struct net_device *netdev, void *p)  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_hw *hw = &adapter->hw;  	struct sockaddr *addr = p; +	int ret;  	if (!is_valid_ether_addr(addr->sa_data))  		return -EADDRNOTAVAIL; +	ixgbe_del_mac_filter(adapter, hw->mac.addr, VMDQ_P(0));  	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);  	memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len); -	hw->mac.ops.set_rar(hw, 0, hw->mac.addr, VMDQ_P(0), IXGBE_RAH_AV); - -	return 0; +	ret = ixgbe_add_mac_filter(adapter, hw->mac.addr, VMDQ_P(0)); +	return ret > 0 ? 0 : ret;  }  static int @@ -6845,7 +7365,9 @@ static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd)  	switch (cmd) {  	case SIOCSHWTSTAMP: -		return ixgbe_ptp_hwtstamp_ioctl(adapter, req, cmd); +		return ixgbe_ptp_set_ts_config(adapter, req); +	case SIOCGHWTSTAMP: +		return ixgbe_ptp_get_ts_config(adapter, req);  	default:  		return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd);  	} @@ -6936,10 +7458,10 @@ static struct rtnl_link_stats64 *ixgbe_get_stats64(struct net_device *netdev,  		if (ring) {  			do { -				start = u64_stats_fetch_begin_bh(&ring->syncp); +				start = u64_stats_fetch_begin_irq(&ring->syncp);  				packets = ring->stats.packets;  				bytes   = ring->stats.bytes; -			} while (u64_stats_fetch_retry_bh(&ring->syncp, start)); +			} while (u64_stats_fetch_retry_irq(&ring->syncp, start));  			stats->rx_packets += packets;  			stats->rx_bytes   += bytes;  		} @@ -6952,10 +7474,10 @@ static struct rtnl_link_stats64 *ixgbe_get_stats64(struct net_device *netdev,  		if (ring) {  			do { -				start = u64_stats_fetch_begin_bh(&ring->syncp); +				start = u64_stats_fetch_begin_irq(&ring->syncp);  				packets = ring->stats.packets;  				bytes   = ring->stats.bytes; -			} while (u64_stats_fetch_retry_bh(&ring->syncp, start)); +			} while (u64_stats_fetch_retry_irq(&ring->syncp, start));  			stats->tx_packets += packets;  			stats->tx_bytes   += bytes;  		} @@ -7044,6 +7566,7 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)  {  	struct ixgbe_adapter *adapter = netdev_priv(dev);  	struct ixgbe_hw *hw = &adapter->hw; +	bool pools;  	/* Hardware supports up to 8 traffic classes */  	if (tc > adapter->dcb_cfg.num_tcs.pg_tcs || @@ -7051,6 +7574,10 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)  	     tc < MAX_TRAFFIC_CLASS))  		return -EINVAL; +	pools = (find_first_zero_bit(&adapter->fwd_bitmask, 32) > 1); +	if (tc && pools && adapter->num_rx_pools > IXGBE_MAX_DCBMACVLANS) +		return -EBUSY; +  	/* Hardware has to reinitialize queues and interrupts to  	 * match packet buffer alignment. Unfortunately, the  	 * hardware is not flexible enough to do this dynamically. @@ -7305,13 +7832,95 @@ static int ixgbe_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,  	return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode);  } +static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev) +{ +	struct ixgbe_fwd_adapter *fwd_adapter = NULL; +	struct ixgbe_adapter *adapter = netdev_priv(pdev); +	unsigned int limit; +	int pool, err; + +#ifdef CONFIG_RPS +	if (vdev->num_rx_queues != vdev->num_tx_queues) { +		netdev_info(pdev, "%s: Only supports a single queue count for TX and RX\n", +			    vdev->name); +		return ERR_PTR(-EINVAL); +	} +#endif +	/* Check for hardware restriction on number of rx/tx queues */ +	if (vdev->num_tx_queues > IXGBE_MAX_L2A_QUEUES || +	    vdev->num_tx_queues == IXGBE_BAD_L2A_QUEUE) { +		netdev_info(pdev, +			    "%s: Supports RX/TX Queue counts 1,2, and 4\n", +			    pdev->name); +		return ERR_PTR(-EINVAL); +	} + +	if (((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && +	      adapter->num_rx_pools > IXGBE_MAX_DCBMACVLANS - 1) || +	    (adapter->num_rx_pools > IXGBE_MAX_MACVLANS)) +		return ERR_PTR(-EBUSY); + +	fwd_adapter = kcalloc(1, sizeof(struct ixgbe_fwd_adapter), GFP_KERNEL); +	if (!fwd_adapter) +		return ERR_PTR(-ENOMEM); + +	pool = find_first_zero_bit(&adapter->fwd_bitmask, 32); +	adapter->num_rx_pools++; +	set_bit(pool, &adapter->fwd_bitmask); +	limit = find_last_bit(&adapter->fwd_bitmask, 32); + +	/* Enable VMDq flag so device will be set in VM mode */ +	adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED | IXGBE_FLAG_SRIOV_ENABLED; +	adapter->ring_feature[RING_F_VMDQ].limit = limit + 1; +	adapter->ring_feature[RING_F_RSS].limit = vdev->num_tx_queues; + +	/* Force reinit of ring allocation with VMDQ enabled */ +	err = ixgbe_setup_tc(pdev, netdev_get_num_tc(pdev)); +	if (err) +		goto fwd_add_err; +	fwd_adapter->pool = pool; +	fwd_adapter->real_adapter = adapter; +	err = ixgbe_fwd_ring_up(vdev, fwd_adapter); +	if (err) +		goto fwd_add_err; +	netif_tx_start_all_queues(vdev); +	return fwd_adapter; +fwd_add_err: +	/* unwind counter and free adapter struct */ +	netdev_info(pdev, +		    "%s: dfwd hardware acceleration failed\n", vdev->name); +	clear_bit(pool, &adapter->fwd_bitmask); +	adapter->num_rx_pools--; +	kfree(fwd_adapter); +	return ERR_PTR(err); +} + +static void ixgbe_fwd_del(struct net_device *pdev, void *priv) +{ +	struct ixgbe_fwd_adapter *fwd_adapter = priv; +	struct ixgbe_adapter *adapter = fwd_adapter->real_adapter; +	unsigned int limit; + +	clear_bit(fwd_adapter->pool, &adapter->fwd_bitmask); +	adapter->num_rx_pools--; + +	limit = find_last_bit(&adapter->fwd_bitmask, 32); +	adapter->ring_feature[RING_F_VMDQ].limit = limit + 1; +	ixgbe_fwd_ring_down(fwd_adapter->netdev, fwd_adapter); +	ixgbe_setup_tc(pdev, netdev_get_num_tc(pdev)); +	netdev_dbg(pdev, "pool %i:%i queues %i:%i VSI bitmask %lx\n", +		   fwd_adapter->pool, adapter->num_rx_pools, +		   fwd_adapter->rx_base_queue, +		   fwd_adapter->rx_base_queue + adapter->num_rx_queues_per_pool, +		   adapter->fwd_bitmask); +	kfree(fwd_adapter); +} +  static const struct net_device_ops ixgbe_netdev_ops = {  	.ndo_open		= ixgbe_open,  	.ndo_stop		= ixgbe_close,  	.ndo_start_xmit		= ixgbe_xmit_frame, -#ifdef IXGBE_FCOE  	.ndo_select_queue	= ixgbe_select_queue, -#endif  	.ndo_set_rx_mode	= ixgbe_set_rx_mode,  	.ndo_validate_addr	= eth_validate_addr,  	.ndo_set_mac_address	= ixgbe_set_mac, @@ -7322,7 +7931,7 @@ static const struct net_device_ops ixgbe_netdev_ops = {  	.ndo_do_ioctl		= ixgbe_ioctl,  	.ndo_set_vf_mac		= ixgbe_ndo_set_vf_mac,  	.ndo_set_vf_vlan	= ixgbe_ndo_set_vf_vlan, -	.ndo_set_vf_tx_rate	= ixgbe_ndo_set_vf_bw, +	.ndo_set_vf_rate	= ixgbe_ndo_set_vf_bw,  	.ndo_set_vf_spoofchk	= ixgbe_ndo_set_vf_spoofchk,  	.ndo_get_vf_config	= ixgbe_ndo_get_vf_config,  	.ndo_get_stats64	= ixgbe_get_stats64, @@ -7349,6 +7958,8 @@ static const struct net_device_ops ixgbe_netdev_ops = {  	.ndo_fdb_add		= ixgbe_ndo_fdb_add,  	.ndo_bridge_setlink	= ixgbe_ndo_bridge_setlink,  	.ndo_bridge_getlink	= ixgbe_ndo_bridge_getlink, +	.ndo_dfwd_add_station	= ixgbe_fwd_add, +	.ndo_dfwd_del_station	= ixgbe_fwd_del,  };  /** @@ -7362,19 +7973,16 @@ static const struct net_device_ops ixgbe_netdev_ops = {   **/  static inline int ixgbe_enumerate_functions(struct ixgbe_adapter *adapter)  { -	struct ixgbe_hw *hw = &adapter->hw;  	struct list_head *entry;  	int physfns = 0; -	/* Some cards can not use the generic count PCIe functions method, and -	 * so must be hardcoded to the correct value. +	/* Some cards can not use the generic count PCIe functions method, +	 * because they are behind a parent switch, so we hardcode these with +	 * the correct number of functions.  	 */ -	switch (hw->device_id) { -	case IXGBE_DEV_ID_82599_SFP_SF_QP: -	case IXGBE_DEV_ID_82599_QSFP_SF_QP: +	if (ixgbe_pcie_from_parent(&adapter->hw)) {  		physfns = 4; -		break; -	default: +	} else {  		list_for_each(entry, &adapter->pdev->bus_list) {  			struct pci_dev *pdev =  				list_entry(entry, struct pci_dev, bus_list); @@ -7408,6 +8016,7 @@ int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,  	case IXGBE_DEV_ID_82599_SFP:  		/* Only these subdevices could supports WOL */  		switch (subdevice_id) { +		case IXGBE_SUBDEV_ID_82599_SFP_WOL0:  		case IXGBE_SUBDEV_ID_82599_560FLR:  			/* only support first port */  			if (hw->bus.func != 0) @@ -7490,19 +8099,14 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	if (err)  		return err; -	if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) && -	    !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { +	if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {  		pci_using_dac = 1;  	} else { -		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); +		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));  		if (err) { -			err = dma_set_coherent_mask(&pdev->dev, -						    DMA_BIT_MASK(32)); -			if (err) { -				dev_err(&pdev->dev, -					"No usable DMA configuration, aborting\n"); -				goto err_dma; -			} +			dev_err(&pdev->dev, +				"No usable DMA configuration, aborting\n"); +			goto err_dma;  		}  		pci_using_dac = 0;  	} @@ -7548,6 +8152,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	hw->hw_addr = ioremap(pci_resource_start(pdev, 0),  			      pci_resource_len(pdev, 0)); +	adapter->io_addr = hw->hw_addr;  	if (!hw->hw_addr) {  		err = -EIO;  		goto err_ioremap; @@ -7567,6 +8172,10 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	/* EEPROM */  	memcpy(&hw->eeprom.ops, ii->eeprom_ops, sizeof(hw->eeprom.ops));  	eec = IXGBE_READ_REG(hw, IXGBE_EEC); +	if (ixgbe_removed(hw->hw_addr)) { +		err = -EIO; +		goto err_ioremap; +	}  	/* If EEPROM is valid (bit 8 = 1), use default otherwise use bit bang */  	if (!(eec & (1 << 8)))  		hw->eeprom.ops.read = &ixgbe_read_eeprom_bit_bang_generic; @@ -7589,10 +8198,6 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	if (err)  		goto err_sw_init; -	/* Cache if MNG FW is up so we don't have to read the REG later */ -	if (hw->mac.ops.mng_fw_enabled) -		hw->mng_fw_enabled = hw->mac.ops.mng_fw_enabled(hw); -  	/* Make it possible the adapter to be woken up via WOL */  	switch (adapter->hw.mac.type) {  	case ixgbe_mac_82599EB: @@ -7639,8 +8244,8 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	/* Mailbox */  	ixgbe_init_mbx_params_pf(hw);  	memcpy(&hw->mbx.ops, ii->mbx_ops, sizeof(hw->mbx.ops)); +	pci_sriov_set_totalvfs(pdev, IXGBE_MAX_VFS_DRV_LIMIT);  	ixgbe_enable_sriov(adapter); -	pci_sriov_set_totalvfs(pdev, 63);  skip_sriov:  #endif @@ -7655,7 +8260,7 @@ skip_sriov:  			   NETIF_F_RXHASH |  			   NETIF_F_RXCSUM; -	netdev->hw_features = netdev->features; +	netdev->hw_features = netdev->features | NETIF_F_HW_L2FW_DOFFLOAD;  	switch (adapter->hw.mac.type) {  	case ixgbe_mac_82599EB: @@ -7730,10 +8335,17 @@ skip_sriov:  		goto err_sw_init;  	} +	ixgbe_mac_set_default_filter(adapter, hw->mac.perm_addr); +  	setup_timer(&adapter->service_timer, &ixgbe_service_timer,  		    (unsigned long) adapter); +	if (ixgbe_removed(hw->hw_addr)) { +		err = -EIO; +		goto err_sw_init; +	}  	INIT_WORK(&adapter->service_task, ixgbe_service_task); +	set_bit(__IXGBE_SERVICE_INITED, &adapter->state);  	clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state);  	err = ixgbe_init_interrupt_scheme(adapter); @@ -7759,29 +8371,6 @@ skip_sriov:  	if (ixgbe_pcie_from_parent(hw))  		ixgbe_get_parent_bus_info(adapter); -	/* print bus type/speed/width info */ -	e_dev_info("(PCI Express:%s:%s) %pM\n", -		   (hw->bus.speed == ixgbe_bus_speed_8000 ? "8.0GT/s" : -		    hw->bus.speed == ixgbe_bus_speed_5000 ? "5.0GT/s" : -		    hw->bus.speed == ixgbe_bus_speed_2500 ? "2.5GT/s" : -		    "Unknown"), -		   (hw->bus.width == ixgbe_bus_width_pcie_x8 ? "Width x8" : -		    hw->bus.width == ixgbe_bus_width_pcie_x4 ? "Width x4" : -		    hw->bus.width == ixgbe_bus_width_pcie_x1 ? "Width x1" : -		    "Unknown"), -		   netdev->dev_addr); - -	err = ixgbe_read_pba_string_generic(hw, part_str, IXGBE_PBANUM_LENGTH); -	if (err) -		strncpy(part_str, "Unknown", IXGBE_PBANUM_LENGTH); -	if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present) -		e_dev_info("MAC: %d, PHY: %d, SFP+: %d, PBA No: %s\n", -			   hw->mac.type, hw->phy.type, hw->phy.sfp_type, -		           part_str); -	else -		e_dev_info("MAC: %d, PHY: %d, PBA No: %s\n", -			   hw->mac.type, hw->phy.type, part_str); -  	/* calculate the expected PCIe bandwidth required for optimal  	 * performance. Note that some older parts will never have enough  	 * bandwidth due to being older generation PCIe parts. We clamp these @@ -7797,6 +8386,19 @@ skip_sriov:  	}  	ixgbe_check_minimum_link(adapter, expected_gts); +	err = ixgbe_read_pba_string_generic(hw, part_str, IXGBE_PBANUM_LENGTH); +	if (err) +		strncpy(part_str, "Unknown", IXGBE_PBANUM_LENGTH); +	if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present) +		e_dev_info("MAC: %d, PHY: %d, SFP+: %d, PBA No: %s\n", +			   hw->mac.type, hw->phy.type, hw->phy.sfp_type, +			   part_str); +	else +		e_dev_info("MAC: %d, PHY: %d, PBA No: %s\n", +			   hw->mac.type, hw->phy.type, part_str); + +	e_dev_info("%pM\n", netdev->dev_addr); +  	/* reset the hardware with the new settings */  	err = hw->mac.ops.start_hw(hw);  	if (err == IXGBE_ERR_EEPROM_VERSION) { @@ -7852,8 +8454,8 @@ skip_sriov:  	ixgbe_dbg_adapter_init(adapter); -	/* Need link setup for MNG FW, else wait for IXGBE_UP */ -	if (hw->mng_fw_enabled && hw->mac.ops.setup_link) +	/* setup link for SFP devices with MNG FW, else wait for IXGBE_UP */ +	if (ixgbe_mng_enabled(hw) && ixgbe_is_sfp(hw) && hw->mac.ops.setup_link)  		hw->mac.ops.setup_link(hw,  			IXGBE_LINK_SPEED_10GB_FULL | IXGBE_LINK_SPEED_1GB_FULL,  			true); @@ -7866,7 +8468,8 @@ err_register:  err_sw_init:  	ixgbe_disable_sriov(adapter);  	adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP; -	iounmap(hw->hw_addr); +	iounmap(adapter->io_addr); +	kfree(adapter->mac_table);  err_ioremap:  	free_netdev(netdev);  err_alloc_etherdev: @@ -7874,7 +8477,8 @@ err_alloc_etherdev:  				     pci_select_bars(pdev, IORESOURCE_MEM));  err_pci_reg:  err_dma: -	pci_disable_device(pdev); +	if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) +		pci_disable_device(pdev);  	return err;  } @@ -7894,7 +8498,7 @@ static void ixgbe_remove(struct pci_dev *pdev)  	ixgbe_dbg_adapter_exit(adapter); -	set_bit(__IXGBE_DOWN, &adapter->state); +	set_bit(__IXGBE_REMOVING, &adapter->state);  	cancel_work_sync(&adapter->service_task); @@ -7933,17 +8537,19 @@ static void ixgbe_remove(struct pci_dev *pdev)  	kfree(adapter->ixgbe_ieee_ets);  #endif -	iounmap(adapter->hw.hw_addr); +	iounmap(adapter->io_addr);  	pci_release_selected_regions(pdev, pci_select_bars(pdev,  				     IORESOURCE_MEM));  	e_dev_info("complete\n"); +	kfree(adapter->mac_table);  	free_netdev(netdev);  	pci_disable_pcie_error_reporting(pdev); -	pci_disable_device(pdev); +	if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) +		pci_disable_device(pdev);  }  /** @@ -7961,6 +8567,7 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,  	struct net_device *netdev = adapter->netdev;  #ifdef CONFIG_PCI_IOV +	struct ixgbe_hw *hw = &adapter->hw;  	struct pci_dev *bdev, *vfdev;  	u32 dw0, dw1, dw2, dw3;  	int vf, pos; @@ -7981,10 +8588,12 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,  	if (!pos)  		goto skip_bad_vf_detection; -	pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG, &dw0); -	pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 4, &dw1); -	pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 8, &dw2); -	pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 12, &dw3); +	dw0 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG); +	dw1 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 4); +	dw2 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 8); +	dw3 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 12); +	if (ixgbe_removed(hw->hw_addr)) +		goto skip_bad_vf_detection;  	req_id = dw1 >> 16;  	/* On the 82599 if bit 7 of the requestor ID is set then it's a VF */ @@ -8047,14 +8656,23 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,  skip_bad_vf_detection:  #endif /* CONFIG_PCI_IOV */ +	if (!test_bit(__IXGBE_SERVICE_INITED, &adapter->state)) +		return PCI_ERS_RESULT_DISCONNECT; + +	rtnl_lock();  	netif_device_detach(netdev); -	if (state == pci_channel_io_perm_failure) +	if (state == pci_channel_io_perm_failure) { +		rtnl_unlock();  		return PCI_ERS_RESULT_DISCONNECT; +	}  	if (netif_running(netdev))  		ixgbe_down(adapter); -	pci_disable_device(pdev); + +	if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) +		pci_disable_device(pdev); +	rtnl_unlock();  	/* Request a slot reset. */  	return PCI_ERS_RESULT_NEED_RESET; @@ -8076,6 +8694,9 @@ static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev)  		e_err(probe, "Cannot re-enable PCI device after reset.\n");  		result = PCI_ERS_RESULT_DISCONNECT;  	} else { +		smp_mb__before_atomic(); +		clear_bit(__IXGBE_DISABLED, &adapter->state); +		adapter->hw.hw_addr = adapter->io_addr;  		pci_set_master(pdev);  		pci_restore_state(pdev);  		pci_save_state(pdev); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c index d4a64e66539..1918e0abf73 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -27,8 +28,7 @@  #include <linux/pci.h>  #include <linux/delay.h> -#include "ixgbe_type.h" -#include "ixgbe_common.h" +#include "ixgbe.h"  #include "ixgbe_mbx.h"  /** @@ -223,7 +223,7 @@ out:   *  received an ack to that message within delay * timeout period   **/  static s32 ixgbe_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, -                           u16 mbx_id) +			   u16 mbx_id)  {  	struct ixgbe_mbx_info *mbx = &hw->mbx;  	s32 ret_val = IXGBE_ERR_MBX; @@ -269,7 +269,7 @@ static s32 ixgbe_check_for_msg_pf(struct ixgbe_hw *hw, u16 vf_number)  	u32 vf_bit = vf_number % 16;  	if (!ixgbe_check_for_bit_pf(hw, IXGBE_MBVFICR_VFREQ_VF1 << vf_bit, -	                            index)) { +				    index)) {  		ret_val = 0;  		hw->mbx.stats.reqs++;  	} @@ -291,7 +291,7 @@ static s32 ixgbe_check_for_ack_pf(struct ixgbe_hw *hw, u16 vf_number)  	u32 vf_bit = vf_number % 16;  	if (!ixgbe_check_for_bit_pf(hw, IXGBE_MBVFICR_VFACK_VF1 << vf_bit, -	                            index)) { +				    index)) {  		ret_val = 0;  		hw->mbx.stats.acks++;  	} @@ -366,7 +366,7 @@ static s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_number)   *  returns SUCCESS if it successfully copied message into the buffer   **/  static s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size, -                              u16 vf_number) +			      u16 vf_number)  {  	s32 ret_val;  	u16 i; @@ -407,7 +407,7 @@ out_no_write:   *  a message due to a VF request so no polling for message is needed.   **/  static s32 ixgbe_read_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size, -                             u16 vf_number) +			     u16 vf_number)  {  	s32 ret_val;  	u16 i; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h index e44ff47659b..a5cb755de3a 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -53,11 +54,11 @@   * Message ACK's are the value or'd with 0xF0000000   */  #define IXGBE_VT_MSGTYPE_ACK      0x80000000  /* Messages below or'd with -                                               * this are the ACK */ +					       * this are the ACK */  #define IXGBE_VT_MSGTYPE_NACK     0x40000000  /* Messages below or'd with -                                               * this are the NACK */ +					       * this are the NACK */  #define IXGBE_VT_MSGTYPE_CTS      0x20000000  /* Indicates that VF is still -                                                 clear to send requests */ +						 clear to send requests */  #define IXGBE_VT_MSGINFO_SHIFT    16  /* bits 23:16 are used for exra info for certain messages */  #define IXGBE_VT_MSGINFO_MASK     (0xFF << IXGBE_VT_MSGINFO_SHIFT) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c index e4c676006be..ff68b7a9def 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -29,7 +30,7 @@  #include <linux/delay.h>  #include <linux/sched.h> -#include "ixgbe_common.h" +#include "ixgbe.h"  #include "ixgbe_phy.h"  static void ixgbe_i2c_start(struct ixgbe_hw *hw); @@ -46,6 +47,7 @@ static bool ixgbe_get_i2c_data(u32 *i2cctl);  static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw);  static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id);  static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw); +static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw);  /**   *  ixgbe_identify_phy_generic - Get physical layer module @@ -65,7 +67,7 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)  			if (mdio45_probe(&hw->phy.mdio, phy_addr) == 0) {  				ixgbe_get_phy_id(hw);  				hw->phy.type = -				        ixgbe_get_phy_type_from_id(hw->phy.id); +					ixgbe_get_phy_type_from_id(hw->phy.id);  				if (hw->phy.type == ixgbe_phy_unknown) {  					hw->phy.ops.read_reg(hw, @@ -97,6 +99,32 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)  }  /** + * ixgbe_check_reset_blocked - check status of MNG FW veto bit + * @hw: pointer to the hardware structure + * + * This function checks the MMNGC.MNG_VETO bit to see if there are + * any constraints on link from manageability.  For MAC's that don't + * have this bit just return false since the link can not be blocked + * via this method. + **/ +bool ixgbe_check_reset_blocked(struct ixgbe_hw *hw) +{ +	u32 mmngc; + +	/* If we don't have this bit, it can't be blocking */ +	if (hw->mac.type == ixgbe_mac_82598EB) +		return false; + +	mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC); +	if (mmngc & IXGBE_MMNGC_MNG_VETO) { +		hw_dbg(hw, "MNG_VETO bit detected.\n"); +		return true; +	} + +	return false; +} + +/**   *  ixgbe_get_phy_id - Get the phy type   *  @hw: pointer to hardware structure   * @@ -108,12 +136,12 @@ static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)  	u16 phy_id_low = 0;  	status = hw->phy.ops.read_reg(hw, MDIO_DEVID1, MDIO_MMD_PMAPMD, -	                              &phy_id_high); +				      &phy_id_high);  	if (status == 0) {  		hw->phy.id = (u32)(phy_id_high << 16);  		status = hw->phy.ops.read_reg(hw, MDIO_DEVID2, MDIO_MMD_PMAPMD, -		                              &phy_id_low); +					      &phy_id_low);  		hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);  		hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);  	} @@ -171,6 +199,10 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)  	    (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))  		goto out; +	/* Blocked by MNG FW so bail */ +	if (ixgbe_check_reset_blocked(hw)) +		goto out; +  	/*  	 * Perform soft PHY reset to the PHY_XS.  	 * This will cause a soft reset to the PHY @@ -286,7 +318,7 @@ s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,   *  @phy_data: Pointer to read data from PHY register   **/  s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, -                               u32 device_type, u16 *phy_data) +			       u32 device_type, u16 *phy_data)  {  	s32 status;  	u16 gssr; @@ -389,7 +421,7 @@ s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,   *  @phy_data: Data to write to the PHY register   **/  s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, -                                u32 device_type, u16 phy_data) +				u32 device_type, u16 phy_data)  {  	s32 status;  	u16 gssr; @@ -475,6 +507,10 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)  				      autoneg_reg);  	} +	/* Blocked by MNG FW so don't reset PHY */ +	if (ixgbe_check_reset_blocked(hw)) +		return status; +  	/* Restart PHY autonegotiation and wait for completion */  	hw->phy.ops.read_reg(hw, MDIO_CTRL1,  			     MDIO_MMD_AN, &autoneg_reg); @@ -500,7 +536,7 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)  	if (time_out == max_time_out) {  		status = IXGBE_ERR_LINK_SETUP; -		hw_dbg(hw, "ixgbe_setup_phy_link_generic: time out"); +		hw_dbg(hw, "ixgbe_setup_phy_link_generic: time out\n");  	}  	return status; @@ -512,8 +548,8 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)   *  @speed: new link speed   **/  s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw, -                                       ixgbe_link_speed speed, -                                       bool autoneg_wait_to_complete) +				       ixgbe_link_speed speed, +				       bool autoneg_wait_to_complete)  {  	/* @@ -546,8 +582,8 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,   * Determines the link capabilities by reading the AUTOC register.   */  s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw, -                                               ixgbe_link_speed *speed, -                                               bool *autoneg) +					       ixgbe_link_speed *speed, +					       bool *autoneg)  {  	s32 status = IXGBE_ERR_LINK_SETUP;  	u16 speed_ability; @@ -556,7 +592,7 @@ s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,  	*autoneg = true;  	status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD, -	                              &speed_ability); +				      &speed_ability);  	if (status == 0) {  		if (speed_ability & MDIO_SPEED_10G) @@ -681,6 +717,10 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)  				      autoneg_reg);  	} +	/* Blocked by MNG FW so don't reset PHY */ +	if (ixgbe_check_reset_blocked(hw)) +		return status; +  	/* Restart PHY autonegotiation and wait for completion */  	hw->phy.ops.read_reg(hw, MDIO_CTRL1,  			     MDIO_MMD_AN, &autoneg_reg); @@ -705,7 +745,7 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)  	if (time_out == max_time_out) {  		status = IXGBE_ERR_LINK_SETUP; -		hw_dbg(hw, "ixgbe_setup_phy_link_tnx: time out"); +		hw_dbg(hw, "ixgbe_setup_phy_link_tnx: time out\n");  	}  	return status; @@ -758,15 +798,19 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)  	s32 ret_val = 0;  	u32 i; +	/* Blocked by MNG FW so bail */ +	if (ixgbe_check_reset_blocked(hw)) +		goto out; +  	hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, &phy_data);  	/* reset the PHY and poll for completion */  	hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, -	                      (phy_data | MDIO_CTRL1_RESET)); +			      (phy_data | MDIO_CTRL1_RESET));  	for (i = 0; i < 100; i++) {  		hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, -		                     &phy_data); +				     &phy_data);  		if ((phy_data & MDIO_CTRL1_RESET) == 0)  			break;  		usleep_range(10000, 20000); @@ -780,7 +824,7 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)  	/* Get init offsets */  	ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset, -	                                              &data_offset); +						      &data_offset);  	if (ret_val != 0)  		goto out; @@ -794,7 +838,7 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)  		if (ret_val)  			goto err_eeprom;  		control = (eword & IXGBE_CONTROL_MASK_NL) >> -		           IXGBE_CONTROL_SHIFT_NL; +			   IXGBE_CONTROL_SHIFT_NL;  		edata = eword & IXGBE_DATA_MASK_NL;  		switch (control) {  		case IXGBE_DELAY_NL: @@ -815,7 +859,7 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)  				if (ret_val)  					goto err_eeprom;  				hw->phy.ops.write_reg(hw, phy_offset, -				                      MDIO_MMD_PMAPMD, eword); +						      MDIO_MMD_PMAPMD, eword);  				hw_dbg(hw, "Wrote %4.4x to %4.4x\n", eword,  				       phy_offset);  				data_offset++; @@ -966,10 +1010,10 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)  			if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {  				if (hw->bus.lan_id == 0)  					hw->phy.sfp_type = -					             ixgbe_sfp_type_da_cu_core0; +						     ixgbe_sfp_type_da_cu_core0;  				else  					hw->phy.sfp_type = -					             ixgbe_sfp_type_da_cu_core1; +						     ixgbe_sfp_type_da_cu_core1;  			} else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {  				hw->phy.ops.read_i2c_eeprom(  						hw, IXGBE_SFF_CABLE_SPEC_COMP, @@ -991,10 +1035,10 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)  				    IXGBE_SFF_10GBASELR_CAPABLE)) {  				if (hw->bus.lan_id == 0)  					hw->phy.sfp_type = -					              ixgbe_sfp_type_srlr_core0; +						      ixgbe_sfp_type_srlr_core0;  				else  					hw->phy.sfp_type = -					              ixgbe_sfp_type_srlr_core1; +						      ixgbe_sfp_type_srlr_core1;  			} else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {  				if (hw->bus.lan_id == 0)  					hw->phy.sfp_type = @@ -1043,15 +1087,15 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)  				goto err_read_i2c_eeprom;  			status = hw->phy.ops.read_i2c_eeprom(hw, -			                            IXGBE_SFF_VENDOR_OUI_BYTE1, -			                            &oui_bytes[1]); +						    IXGBE_SFF_VENDOR_OUI_BYTE1, +						    &oui_bytes[1]);  			if (status != 0)  				goto err_read_i2c_eeprom;  			status = hw->phy.ops.read_i2c_eeprom(hw, -			                            IXGBE_SFF_VENDOR_OUI_BYTE2, -			                            &oui_bytes[2]); +						    IXGBE_SFF_VENDOR_OUI_BYTE2, +						    &oui_bytes[2]);  			if (status != 0)  				goto err_read_i2c_eeprom; @@ -1131,7 +1175,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)  				status = 0;  			} else {  				if (hw->allow_unsupported_sfp) { -					e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics.  Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter.  Intel Corporation is not responsible for any harm caused by using untested modules."); +					e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics.  Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter.  Intel Corporation is not responsible for any harm caused by using untested modules.\n");  					status = 0;  				} else {  					hw_dbg(hw, @@ -1164,7 +1208,7 @@ err_read_i2c_eeprom:   *   * Searches for and identifies the QSFP module and assigns appropriate PHY type   **/ -s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) +static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)  {  	struct ixgbe_adapter *adapter = hw->back;  	s32 status = IXGBE_ERR_PHY_ADDR_INVALID; @@ -1359,8 +1403,8 @@ err_read_i2c_eeprom:   *  so it returns the offsets to the phy init sequence block.   **/  s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw, -                                        u16 *list_offset, -                                        u16 *data_offset) +					u16 *list_offset, +					u16 *data_offset)  {  	u16 sfp_id;  	u16 sfp_type = hw->phy.sfp_type; @@ -1449,11 +1493,11 @@ err_phy:   *  Performs byte read operation to SFP module's EEPROM over I2C interface.   **/  s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset, -                                  u8 *eeprom_data) +				  u8 *eeprom_data)  {  	return hw->phy.ops.read_i2c_byte(hw, byte_offset, -	                                 IXGBE_I2C_EEPROM_DEV_ADDR, -	                                 eeprom_data); +					 IXGBE_I2C_EEPROM_DEV_ADDR, +					 eeprom_data);  }  /** @@ -1481,11 +1525,11 @@ s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,   *  Performs byte write operation to SFP module's EEPROM over I2C interface.   **/  s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset, -                                   u8 eeprom_data) +				   u8 eeprom_data)  {  	return hw->phy.ops.write_i2c_byte(hw, byte_offset, -	                                  IXGBE_I2C_EEPROM_DEV_ADDR, -	                                  eeprom_data); +					  IXGBE_I2C_EEPROM_DEV_ADDR, +					  eeprom_data);  }  /** @@ -1498,7 +1542,7 @@ s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,   *  a specified device address.   **/  s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, -                                u8 dev_addr, u8 *data) +				u8 dev_addr, u8 *data)  {  	s32 status = 0;  	u32 max_retry = 10; @@ -1587,7 +1631,7 @@ read_byte_out:   *  a specified device address.   **/  s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, -                                 u8 dev_addr, u8 data) +				 u8 dev_addr, u8 data)  {  	s32 status = 0;  	u32 max_retry = 1; @@ -2002,7 +2046,7 @@ s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)  	/* Check that the LASI temp alarm status was triggered */  	hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG, -	                     MDIO_MMD_PMAPMD, &phy_data); +			     MDIO_MMD_PMAPMD, &phy_data);  	if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))  		goto out; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h index 24af12e3719..54071ed17e3 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -57,29 +58,25 @@  #define IXGBE_SFF_QSFP_DEVICE_TECH	0x93  /* Bitmasks */ -#define IXGBE_SFF_DA_PASSIVE_CABLE           0x4 -#define IXGBE_SFF_DA_ACTIVE_CABLE            0x8 -#define IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING    0x4 -#define IXGBE_SFF_1GBASESX_CAPABLE           0x1 -#define IXGBE_SFF_1GBASELX_CAPABLE           0x2 -#define IXGBE_SFF_1GBASET_CAPABLE            0x8 -#define IXGBE_SFF_10GBASESR_CAPABLE          0x10 -#define IXGBE_SFF_10GBASELR_CAPABLE          0x20 -#define IXGBE_SFF_SOFT_RS_SELECT_MASK	0x8 -#define IXGBE_SFF_SOFT_RS_SELECT_10G	0x8 -#define IXGBE_SFF_SOFT_RS_SELECT_1G	0x0 -#define IXGBE_SFF_ADDRESSING_MODE	     0x4 -#define IXGBE_SFF_QSFP_DA_ACTIVE_CABLE       0x1 -#define IXGBE_SFF_QSFP_DA_PASSIVE_CABLE      0x8 +#define IXGBE_SFF_DA_PASSIVE_CABLE		0x4 +#define IXGBE_SFF_DA_ACTIVE_CABLE		0x8 +#define IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING	0x4 +#define IXGBE_SFF_1GBASESX_CAPABLE		0x1 +#define IXGBE_SFF_1GBASELX_CAPABLE		0x2 +#define IXGBE_SFF_1GBASET_CAPABLE		0x8 +#define IXGBE_SFF_10GBASESR_CAPABLE		0x10 +#define IXGBE_SFF_10GBASELR_CAPABLE		0x20 +#define IXGBE_SFF_ADDRESSING_MODE		0x4 +#define IXGBE_SFF_QSFP_DA_ACTIVE_CABLE		0x1 +#define IXGBE_SFF_QSFP_DA_PASSIVE_CABLE		0x8  #define IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE	0x23  #define IXGBE_SFF_QSFP_TRANSMITER_850NM_VCSEL	0x0 -#define IXGBE_I2C_EEPROM_READ_MASK           0x100 -#define IXGBE_I2C_EEPROM_STATUS_MASK         0x3 -#define IXGBE_I2C_EEPROM_STATUS_NO_OPERATION 0x0 -#define IXGBE_I2C_EEPROM_STATUS_PASS         0x1 -#define IXGBE_I2C_EEPROM_STATUS_FAIL         0x2 -#define IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS  0x3 - +#define IXGBE_I2C_EEPROM_READ_MASK		0x100 +#define IXGBE_I2C_EEPROM_STATUS_MASK		0x3 +#define IXGBE_I2C_EEPROM_STATUS_NO_OPERATION	0x0 +#define IXGBE_I2C_EEPROM_STATUS_PASS		0x1 +#define IXGBE_I2C_EEPROM_STATUS_FAIL		0x2 +#define IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS	0x3  /* Flow control defines */  #define IXGBE_TAF_SYM_PAUSE                  0x400  #define IXGBE_TAF_ASM_PAUSE                  0x800 @@ -117,47 +114,47 @@ s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw);  s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw);  s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw);  s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, -                               u32 device_type, u16 *phy_data); +			       u32 device_type, u16 *phy_data);  s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, -                                u32 device_type, u16 phy_data); +				u32 device_type, u16 phy_data);  s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,  			   u32 device_type, u16 *phy_data);  s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,  			    u32 device_type, u16 phy_data);  s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw);  s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw, -                                       ixgbe_link_speed speed, -                                       bool autoneg_wait_to_complete); +				       ixgbe_link_speed speed, +				       bool autoneg_wait_to_complete);  s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw, -                                               ixgbe_link_speed *speed, -                                               bool *autoneg); +					       ixgbe_link_speed *speed, +					       bool *autoneg); +bool ixgbe_check_reset_blocked(struct ixgbe_hw *hw);  /* PHY specific */  s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, -                             ixgbe_link_speed *speed, -                             bool *link_up); +			     ixgbe_link_speed *speed, +			     bool *link_up);  s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw);  s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw, -                                       u16 *firmware_version); +				       u16 *firmware_version);  s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw, -                                           u16 *firmware_version); +					   u16 *firmware_version);  s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw);  s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw);  s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw); -s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw);  s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw, -                                        u16 *list_offset, -                                        u16 *data_offset); +					u16 *list_offset, +					u16 *data_offset);  s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw);  s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, -                                u8 dev_addr, u8 *data); +				u8 dev_addr, u8 *data);  s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, -                                 u8 dev_addr, u8 data); +				 u8 dev_addr, u8 data);  s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset, -                                  u8 *eeprom_data); +				  u8 *eeprom_data);  s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,  				   u8 *sff8472_data);  s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset, -                                   u8 eeprom_data); +				   u8 eeprom_data);  #endif /* _IXGBE_PHY_H_ */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c index 5184e2a1a7d..68f87ecb8a7 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c @@ -20,12 +20,12 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497  *******************************************************************************/  #include "ixgbe.h" -#include <linux/export.h>  #include <linux/ptp_classify.h>  /* @@ -333,7 +333,7 @@ static int ixgbe_ptp_settime(struct ptp_clock_info *ptp,  }  /** - * ixgbe_ptp_enable + * ixgbe_ptp_feature_enable   * @ptp: the ptp clock structure   * @rq: the requested feature to change   * @on: whether to enable or disable the feature @@ -341,8 +341,8 @@ static int ixgbe_ptp_settime(struct ptp_clock_info *ptp,   * enable (or disable) ancillary features of the phc subsystem.   * our driver only supports the PPS feature on the X540   */ -static int ixgbe_ptp_enable(struct ptp_clock_info *ptp, -			    struct ptp_clock_request *rq, int on) +static int ixgbe_ptp_feature_enable(struct ptp_clock_info *ptp, +				    struct ptp_clock_request *rq, int on)  {  	struct ixgbe_adapter *adapter =  		container_of(ptp, struct ixgbe_adapter, ptp_caps); @@ -434,10 +434,8 @@ void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter)  void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw; -	struct ixgbe_ring *rx_ring;  	u32 tsyncrxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);  	unsigned long rx_event; -	int n;  	/* if we don't have a valid timestamp in the registers, just update the  	 * timeout counter and exit @@ -449,18 +447,15 @@ void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter)  	/* determine the most recent watchdog or rx_timestamp event */  	rx_event = adapter->last_rx_ptp_check; -	for (n = 0; n < adapter->num_rx_queues; n++) { -		rx_ring = adapter->rx_ring[n]; -		if (time_after(rx_ring->last_rx_timestamp, rx_event)) -			rx_event = rx_ring->last_rx_timestamp; -	} +	if (time_after(adapter->last_rx_timestamp, rx_event)) +		rx_event = adapter->last_rx_timestamp;  	/* only need to read the high RXSTMP register to clear the lock */  	if (time_is_before_jiffies(rx_event + 5*HZ)) {  		IXGBE_READ_REG(hw, IXGBE_RXSTMPH);  		adapter->last_rx_ptp_check = jiffies; -		e_warn(drv, "clearing RX Timestamp hang"); +		e_warn(drv, "clearing RX Timestamp hang\n");  	}  } @@ -492,6 +487,7 @@ static void ixgbe_ptp_tx_hwtstamp(struct ixgbe_adapter *adapter)  	dev_kfree_skb_any(adapter->ptp_tx_skb);  	adapter->ptp_tx_skb = NULL; +	clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state);  }  /** @@ -511,14 +507,11 @@ static void ixgbe_ptp_tx_hwtstamp_work(struct work_struct *work)  					      IXGBE_PTP_TX_TIMEOUT);  	u32 tsynctxctl; -	/* we have to have a valid skb */ -	if (!adapter->ptp_tx_skb) -		return; -  	if (timeout) {  		dev_kfree_skb_any(adapter->ptp_tx_skb);  		adapter->ptp_tx_skb = NULL; -		e_warn(drv, "clearing Tx Timestamp hang"); +		clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); +		e_warn(drv, "clearing Tx Timestamp hang\n");  		return;  	} @@ -531,35 +524,22 @@ static void ixgbe_ptp_tx_hwtstamp_work(struct work_struct *work)  }  /** - * __ixgbe_ptp_rx_hwtstamp - utility function which checks for RX time stamp - * @q_vector: structure containing interrupt and ring information + * ixgbe_ptp_rx_hwtstamp - utility function which checks for RX time stamp + * @adapter: pointer to adapter struct   * @skb: particular skb to send timestamp with   *   * if the timestamp is valid, we convert it into the timecounter ns   * value, then store that result into the shhwtstamps structure which   * is passed up the network stack   */ -void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector, -			     struct sk_buff *skb) +void ixgbe_ptp_rx_hwtstamp(struct ixgbe_adapter *adapter, struct sk_buff *skb)  { -	struct ixgbe_adapter *adapter; -	struct ixgbe_hw *hw; +	struct ixgbe_hw *hw = &adapter->hw;  	struct skb_shared_hwtstamps *shhwtstamps;  	u64 regval = 0, ns;  	u32 tsyncrxctl;  	unsigned long flags; -	/* we cannot process timestamps on a ring without a q_vector */ -	if (!q_vector || !q_vector->adapter) -		return; - -	adapter = q_vector->adapter; -	hw = &adapter->hw; - -	/* -	 * Read the tsyncrxctl register afterwards in order to prevent taking an -	 * I/O hit on every packet. -	 */  	tsyncrxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);  	if (!(tsyncrxctl & IXGBE_TSYNCRXCTL_VALID))  		return; @@ -567,23 +547,34 @@ void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector,  	regval |= (u64)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);  	regval |= (u64)IXGBE_READ_REG(hw, IXGBE_RXSTMPH) << 32; -  	spin_lock_irqsave(&adapter->tmreg_lock, flags);  	ns = timecounter_cyc2time(&adapter->tc, regval);  	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);  	shhwtstamps = skb_hwtstamps(skb);  	shhwtstamps->hwtstamp = ns_to_ktime(ns); + +	/* Update the last_rx_timestamp timer in order to enable watchdog check +	 * for error case of latched timestamp on a dropped packet. +	 */ +	adapter->last_rx_timestamp = jiffies; +} + +int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr) +{ +	struct hwtstamp_config *config = &adapter->tstamp_config; + +	return copy_to_user(ifr->ifr_data, config, +			    sizeof(*config)) ? -EFAULT : 0;  }  /** - * ixgbe_ptp_hwtstamp_ioctl - control hardware time stamping - * @adapter: pointer to adapter struct - * @ifreq: ioctl data - * @cmd: particular ioctl requested + * ixgbe_ptp_set_timestamp_mode - setup the hardware for the requested mode + * @adapter: the private ixgbe adapter structure + * @config: the hwtstamp configuration requested   *   * Outgoing time stamping can be enabled and disabled. Play nice and - * disable it when requested, although it shouldn't case any overhead + * disable it when requested, although it shouldn't cause any overhead   * when no packet needs it. At most one packet in the queue may be   * marked for time stamping, otherwise it would be impossible to tell   * for sure to which packet the hardware time stamp belongs. @@ -598,26 +589,25 @@ void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector,   * packets, regardless of the type specified in the register, only use V2   * Event mode. This more accurately tells the user what the hardware is going   * to do anyways. + * + * Note: this may modify the hwtstamp configuration towards a more general + * mode, if required to support the specifically requested mode.   */ -int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter, -			     struct ifreq *ifr, int cmd) +static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, +				 struct hwtstamp_config *config)  {  	struct ixgbe_hw *hw = &adapter->hw; -	struct hwtstamp_config config;  	u32 tsync_tx_ctl = IXGBE_TSYNCTXCTL_ENABLED;  	u32 tsync_rx_ctl = IXGBE_TSYNCRXCTL_ENABLED;  	u32 tsync_rx_mtrl = PTP_EV_PORT << 16;  	bool is_l2 = false;  	u32 regval; -	if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) -		return -EFAULT; -  	/* reserved for future extensions */ -	if (config.flags) +	if (config->flags)  		return -EINVAL; -	switch (config.tx_type) { +	switch (config->tx_type) {  	case HWTSTAMP_TX_OFF:  		tsync_tx_ctl = 0;  	case HWTSTAMP_TX_ON: @@ -626,7 +616,7 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,  		return -ERANGE;  	} -	switch (config.rx_filter) { +	switch (config->rx_filter) {  	case HWTSTAMP_FILTER_NONE:  		tsync_rx_ctl = 0;  		tsync_rx_mtrl = 0; @@ -650,7 +640,7 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,  	case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:  		tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_EVENT_V2;  		is_l2 = true; -		config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; +		config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;  		break;  	case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:  	case HWTSTAMP_FILTER_ALL: @@ -661,7 +651,7 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,  		 * Delay_Req messages and hardware does not support  		 * timestamping all packets => return error  		 */ -		config.rx_filter = HWTSTAMP_FILTER_NONE; +		config->rx_filter = HWTSTAMP_FILTER_NONE;  		return -ERANGE;  	} @@ -680,7 +670,6 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,  	else  		IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0); -  	/* enable/disable TX */  	regval = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);  	regval &= ~IXGBE_TSYNCTXCTL_ENABLED; @@ -702,6 +691,33 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,  	regval = IXGBE_READ_REG(hw, IXGBE_TXSTMPH);  	regval = IXGBE_READ_REG(hw, IXGBE_RXSTMPH); +	return 0; +} + +/** + * ixgbe_ptp_set_ts_config - user entry point for timestamp mode + * @adapter: pointer to adapter struct + * @ifreq: ioctl data + * + * Set hardware to requested mode. If unsupported, return an error with no + * changes. Otherwise, store the mode for future reference. + */ +int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr) +{ +	struct hwtstamp_config config; +	int err; + +	if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) +		return -EFAULT; + +	err = ixgbe_ptp_set_timestamp_mode(adapter, &config); +	if (err) +		return err; + +	/* save these settings for future reference */ +	memcpy(&adapter->tstamp_config, &config, +	       sizeof(adapter->tstamp_config)); +  	return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?  		-EFAULT : 0;  } @@ -795,9 +811,13 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)   * ixgbe_ptp_reset   * @adapter: the ixgbe private board structure   * - * When the MAC resets, all timesync features are reset. This function should be - * called to re-enable the PTP clock structure. It will re-init the timecounter - * structure based on the kernel time as well as setup the cycle counter data. + * When the MAC resets, all the hardware bits for timesync are reset. This + * function is used to re-enable the device for PTP based on current settings. + * We do lose the current clock time, so just reset the cyclecounter to the + * system real clock time. + * + * This function will maintain hwtstamp_config settings, and resets the SDP + * output if it was enabled.   */  void ixgbe_ptp_reset(struct ixgbe_adapter *adapter)  { @@ -809,6 +829,9 @@ void ixgbe_ptp_reset(struct ixgbe_adapter *adapter)  	IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x00000000);  	IXGBE_WRITE_FLUSH(hw); +	/* reset the hardware timestamping mode */ +	ixgbe_ptp_set_timestamp_mode(adapter, &adapter->tstamp_config); +  	ixgbe_ptp_start_cyclecounter(adapter);  	spin_lock_irqsave(&adapter->tmreg_lock, flags); @@ -827,20 +850,29 @@ void ixgbe_ptp_reset(struct ixgbe_adapter *adapter)  }  /** - * ixgbe_ptp_init + * ixgbe_ptp_create_clock   * @adapter: the ixgbe private adapter structure   * - * This function performs the required steps for enabling ptp - * support. If ptp support has already been loaded it simply calls the - * cyclecounter init routine and exits. + * This function performs setup of the user entry point function table and + * initializes the PTP clock device, which is used to access the clock-like + * features of the PTP core. It will be called by ixgbe_ptp_init, only if + * there isn't already a clock device (such as after a suspend/resume cycle, + * where the clock device wasn't destroyed).   */ -void ixgbe_ptp_init(struct ixgbe_adapter *adapter) +static int ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter)  {  	struct net_device *netdev = adapter->netdev; +	long err; + +	/* do nothing if we already have a clock device */ +	if (!IS_ERR_OR_NULL(adapter->ptp_clock)) +		return 0;  	switch (adapter->hw.mac.type) {  	case ixgbe_mac_X540: -		snprintf(adapter->ptp_caps.name, 16, "%s", netdev->name); +		snprintf(adapter->ptp_caps.name, +			 sizeof(adapter->ptp_caps.name), +			 "%s", netdev->name);  		adapter->ptp_caps.owner = THIS_MODULE;  		adapter->ptp_caps.max_adj = 250000000;  		adapter->ptp_caps.n_alarm = 0; @@ -851,10 +883,12 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)  		adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime;  		adapter->ptp_caps.gettime = ixgbe_ptp_gettime;  		adapter->ptp_caps.settime = ixgbe_ptp_settime; -		adapter->ptp_caps.enable = ixgbe_ptp_enable; +		adapter->ptp_caps.enable = ixgbe_ptp_feature_enable;  		break;  	case ixgbe_mac_82599EB: -		snprintf(adapter->ptp_caps.name, 16, "%s", netdev->name); +		snprintf(adapter->ptp_caps.name, +			 sizeof(adapter->ptp_caps.name), +			 "%s", netdev->name);  		adapter->ptp_caps.owner = THIS_MODULE;  		adapter->ptp_caps.max_adj = 250000000;  		adapter->ptp_caps.n_alarm = 0; @@ -865,24 +899,57 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)  		adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime;  		adapter->ptp_caps.gettime = ixgbe_ptp_gettime;  		adapter->ptp_caps.settime = ixgbe_ptp_settime; -		adapter->ptp_caps.enable = ixgbe_ptp_enable; +		adapter->ptp_caps.enable = ixgbe_ptp_feature_enable;  		break;  	default:  		adapter->ptp_clock = NULL; -		return; +		return -EOPNOTSUPP;  	} -	spin_lock_init(&adapter->tmreg_lock); -	INIT_WORK(&adapter->ptp_tx_work, ixgbe_ptp_tx_hwtstamp_work); -  	adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,  						&adapter->pdev->dev);  	if (IS_ERR(adapter->ptp_clock)) { +		err = PTR_ERR(adapter->ptp_clock);  		adapter->ptp_clock = NULL;  		e_dev_err("ptp_clock_register failed\n"); +		return err;  	} else  		e_dev_info("registered PHC device on %s\n", netdev->name); +	/* set default timestamp mode to disabled here. We do this in +	 * create_clock instead of init, because we don't want to override the +	 * previous settings during a resume cycle. +	 */ +	adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; +	adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF; + +	return 0; +} + +/** + * ixgbe_ptp_init + * @adapter: the ixgbe private adapter structure + * + * This function performs the required steps for enabling PTP + * support. If PTP support has already been loaded it simply calls the + * cyclecounter init routine and exits. + */ +void ixgbe_ptp_init(struct ixgbe_adapter *adapter) +{ +	/* initialize the spin lock first since we can't control when a user +	 * will call the entry functions once we have initialized the clock +	 * device +	 */ +	spin_lock_init(&adapter->tmreg_lock); + +	/* obtain a PTP device, or re-use an existing device */ +	if (ixgbe_ptp_create_clock(adapter)) +		return; + +	/* we have a clock so we can initialize work now */ +	INIT_WORK(&adapter->ptp_tx_work, ixgbe_ptp_tx_hwtstamp_work); + +	/* reset the PTP related hardware bits */  	ixgbe_ptp_reset(adapter);  	/* enter the IXGBE_PTP_RUNNING state */ @@ -892,27 +959,45 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)  }  /** - * ixgbe_ptp_stop - disable ptp device and stop the overflow check - * @adapter: pointer to adapter struct + * ixgbe_ptp_suspend - stop PTP work items + * @ adapter: pointer to adapter struct   * - * this function stops the ptp support, and cancels the delayed work. + * this function suspends PTP activity, and prevents more PTP work from being + * generated, but does not destroy the PTP clock device.   */ -void ixgbe_ptp_stop(struct ixgbe_adapter *adapter) +void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter)  {  	/* Leave the IXGBE_PTP_RUNNING state. */  	if (!test_and_clear_bit(__IXGBE_PTP_RUNNING, &adapter->state))  		return; -	/* stop the PPS signal */ -	adapter->flags2 &= ~IXGBE_FLAG2_PTP_PPS_ENABLED; -	ixgbe_ptp_setup_sdp(adapter); +	/* since this might be called in suspend, we don't clear the state, +	 * but simply reset the auxiliary PPS signal control register +	 */ +	IXGBE_WRITE_REG(&adapter->hw, IXGBE_TSAUXC, 0x0); +	/* ensure that we cancel any pending PTP Tx work item in progress */  	cancel_work_sync(&adapter->ptp_tx_work);  	if (adapter->ptp_tx_skb) {  		dev_kfree_skb_any(adapter->ptp_tx_skb);  		adapter->ptp_tx_skb = NULL; +		clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state);  	} +} + +/** + * ixgbe_ptp_stop - close the PTP device + * @adapter: pointer to adapter struct + * + * completely destroy the PTP device, should only be called when the device is + * being fully closed. + */ +void ixgbe_ptp_stop(struct ixgbe_adapter *adapter) +{ +	/* first, suspend PTP activity */ +	ixgbe_ptp_suspend(adapter); +	/* disable the PTP clock device */  	if (adapter->ptp_clock) {  		ptp_clock_unregister(adapter->ptp_clock);  		adapter->ptp_clock = NULL; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c index 276d7b13533..16b3a1cd9db 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -71,8 +72,6 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)  		for (i = 0; i < num_vf_macvlans; i++) {  			mv_list->vf = -1;  			mv_list->free = true; -			mv_list->rar_entry = hw->mac.num_rar_entries - -				(i + adapter->num_vfs + 1);  			list_add(&mv_list->l, &adapter->vf_mvs.l);  			mv_list++;  		} @@ -129,10 +128,6 @@ void ixgbe_enable_sriov(struct ixgbe_adapter *adapter)  	if (!pre_existing_vfs && !adapter->num_vfs)  		return; -	if (!pre_existing_vfs) -		dev_warn(&adapter->pdev->dev, -			 "Enabling SR-IOV VFs using the module parameter is deprecated - please use the pci sysfs interface.\n"); -  	/* If there are pre-existing VFs then we have to force  	 * use of that many - over ride any module parameter value.  	 * This may result from the user unloading the PF driver @@ -152,7 +147,7 @@ void ixgbe_enable_sriov(struct ixgbe_adapter *adapter)  		 * physical function.  If the user requests greater thn  		 * 63 VFs then it is an error - reset to default of zero.  		 */ -		adapter->num_vfs = min_t(unsigned int, adapter->num_vfs, 63); +		adapter->num_vfs = min_t(unsigned int, adapter->num_vfs, IXGBE_MAX_VFS_DRV_LIMIT);  		err = pci_enable_sriov(adapter->pdev, adapter->num_vfs);  		if (err) { @@ -223,17 +218,19 @@ int ixgbe_disable_sriov(struct ixgbe_adapter *adapter)  	IXGBE_WRITE_FLUSH(hw);  	/* Disable VMDq flag so device will be set in VM mode */ -	if (adapter->ring_feature[RING_F_VMDQ].limit == 1) +	if (adapter->ring_feature[RING_F_VMDQ].limit == 1) {  		adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED; -	adapter->ring_feature[RING_F_VMDQ].offset = 0; +		adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED; +		rss = min_t(int, IXGBE_MAX_RSS_INDICES, num_online_cpus()); +	} else { +		rss = min_t(int, IXGBE_MAX_L2A_QUEUES, num_online_cpus()); +	} -	rss = min_t(int, IXGBE_MAX_RSS_INDICES, num_online_cpus()); +	adapter->ring_feature[RING_F_VMDQ].offset = 0;  	adapter->ring_feature[RING_F_RSS].limit = rss;  	/* take a breather then clean up driver data */  	msleep(100); - -	adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;  	return 0;  } @@ -259,7 +256,7 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs)  	 * PF.  The PCI bus driver already checks for other values out of  	 * range.  	 */ -	if (num_vfs > 63) { +	if (num_vfs > IXGBE_MAX_VFS_DRV_LIMIT) {  		err = -EPERM;  		goto err_out;  	} @@ -293,18 +290,17 @@ static int ixgbe_pci_sriov_disable(struct pci_dev *dev)  {  	struct ixgbe_adapter *adapter = pci_get_drvdata(dev);  	int err; +#ifdef CONFIG_PCI_IOV  	u32 current_flags = adapter->flags; +#endif  	err = ixgbe_disable_sriov(adapter);  	/* Only reinit if no error and state changed */ -	if (!err && current_flags != adapter->flags) { -		/* ixgbe_disable_sriov() doesn't clear VMDQ flag */ -		adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED;  #ifdef CONFIG_PCI_IOV +	if (!err && current_flags != adapter->flags)  		ixgbe_sriov_reinit(adapter);  #endif -	}  	return err;  } @@ -329,6 +325,7 @@ static int ixgbe_set_vf_multicasts(struct ixgbe_adapter *adapter,  	u32 vector_bit;  	u32 vector_reg;  	u32 mta_reg; +	u32 vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));  	/* only so many hash values supported */  	entries = min(entries, IXGBE_MAX_VF_MC_ENTRIES); @@ -355,25 +352,13 @@ static int ixgbe_set_vf_multicasts(struct ixgbe_adapter *adapter,  		mta_reg |= (1 << vector_bit);  		IXGBE_WRITE_REG(hw, IXGBE_MTA(vector_reg), mta_reg);  	} +	vmolr |= IXGBE_VMOLR_ROMPE; +	IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);  	return 0;  } -static void ixgbe_restore_vf_macvlans(struct ixgbe_adapter *adapter) -{ -	struct ixgbe_hw *hw = &adapter->hw; -	struct list_head *pos; -	struct vf_macvlans *entry; - -	list_for_each(pos, &adapter->vf_mvs.l) { -		entry = list_entry(pos, struct vf_macvlans, l); -		if (!entry->free) -			hw->mac.ops.set_rar(hw, entry->rar_entry, -					    entry->vf_macvlan, -					    entry->vf, IXGBE_RAH_AV); -	} -} - +#ifdef CONFIG_PCI_IOV  void ixgbe_restore_vf_multicasts(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw; @@ -384,6 +369,7 @@ void ixgbe_restore_vf_multicasts(struct ixgbe_adapter *adapter)  	u32 mta_reg;  	for (i = 0; i < adapter->num_vfs; i++) { +		u32 vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(i));  		vfinfo = &adapter->vfinfo[i];  		for (j = 0; j < vfinfo->num_vf_mc_hashes; j++) {  			hw->addr_ctrl.mta_in_use++; @@ -393,11 +379,18 @@ void ixgbe_restore_vf_multicasts(struct ixgbe_adapter *adapter)  			mta_reg |= (1 << vector_bit);  			IXGBE_WRITE_REG(hw, IXGBE_MTA(vector_reg), mta_reg);  		} + +		if (vfinfo->num_vf_mc_hashes) +			vmolr |= IXGBE_VMOLR_ROMPE; +		else +			vmolr &= ~IXGBE_VMOLR_ROMPE; +		IXGBE_WRITE_REG(hw, IXGBE_VMOLR(i), vmolr);  	}  	/* Restore any VF macvlans */ -	ixgbe_restore_vf_macvlans(adapter); +	ixgbe_full_sync_mac_table(adapter);  } +#endif  static int ixgbe_set_vf_vlan(struct ixgbe_adapter *adapter, int add, int vid,  			     u32 vf) @@ -497,8 +490,7 @@ static s32 ixgbe_set_vf_lpe(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)  static void ixgbe_set_vmolr(struct ixgbe_hw *hw, u32 vf, bool aupe)  {  	u32 vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf)); -	vmolr |= (IXGBE_VMOLR_ROMPE | -		  IXGBE_VMOLR_BAM); +	vmolr |= IXGBE_VMOLR_BAM;  	if (aupe)  		vmolr |= IXGBE_VMOLR_AUPE;  	else @@ -516,7 +508,6 @@ static inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)  {  	struct ixgbe_hw *hw = &adapter->hw;  	struct vf_data_storage *vfinfo = &adapter->vfinfo[vf]; -	int rar_entry = hw->mac.num_rar_entries - (vf + 1);  	u8 num_tcs = netdev_get_num_tc(adapter->netdev);  	/* add PF assigned VLAN or VLAN 0 */ @@ -546,7 +537,7 @@ static inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)  	/* Flush and reset the mta with the new values */  	ixgbe_set_rx_mode(adapter->netdev); -	hw->mac.ops.clear_rar(hw, rar_entry); +	ixgbe_del_mac_filter(adapter, adapter->vfinfo[vf].vf_mac_addresses, vf);  	/* reset VF api back to unknown */  	adapter->vfinfo[vf].vf_api = ixgbe_mbox_api_10; @@ -555,11 +546,9 @@ static inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)  static int ixgbe_set_vf_mac(struct ixgbe_adapter *adapter,  			    int vf, unsigned char *mac_addr)  { -	struct ixgbe_hw *hw = &adapter->hw; -	int rar_entry = hw->mac.num_rar_entries - (vf + 1); - -	memcpy(adapter->vfinfo[vf].vf_mac_addresses, mac_addr, 6); -	hw->mac.ops.set_rar(hw, rar_entry, mac_addr, vf, IXGBE_RAH_AV); +	ixgbe_del_mac_filter(adapter, adapter->vfinfo[vf].vf_mac_addresses, vf); +	memcpy(adapter->vfinfo[vf].vf_mac_addresses, mac_addr, ETH_ALEN); +	ixgbe_add_mac_filter(adapter, adapter->vfinfo[vf].vf_mac_addresses, vf);  	return 0;  } @@ -567,7 +556,6 @@ static int ixgbe_set_vf_mac(struct ixgbe_adapter *adapter,  static int ixgbe_set_vf_macvlan(struct ixgbe_adapter *adapter,  				int vf, int index, unsigned char *mac_addr)  { -	struct ixgbe_hw *hw = &adapter->hw;  	struct list_head *pos;  	struct vf_macvlans *entry; @@ -578,7 +566,8 @@ static int ixgbe_set_vf_macvlan(struct ixgbe_adapter *adapter,  				entry->vf = -1;  				entry->free = true;  				entry->is_macvlan = false; -				hw->mac.ops.clear_rar(hw, entry->rar_entry); +				ixgbe_del_mac_filter(adapter, +						     entry->vf_macvlan, vf);  			}  		}  	} @@ -614,34 +603,34 @@ static int ixgbe_set_vf_macvlan(struct ixgbe_adapter *adapter,  	entry->vf = vf;  	memcpy(entry->vf_macvlan, mac_addr, ETH_ALEN); -	hw->mac.ops.set_rar(hw, entry->rar_entry, mac_addr, vf, IXGBE_RAH_AV); +	ixgbe_add_mac_filter(adapter, mac_addr, vf);  	return 0;  }  int ixgbe_vf_configuration(struct pci_dev *pdev, unsigned int event_mask)  { -	unsigned char vf_mac_addr[6];  	struct ixgbe_adapter *adapter = pci_get_drvdata(pdev);  	unsigned int vfn = (event_mask & 0x3f);  	bool enable = ((event_mask & 0x10000000U) != 0); -	if (enable) { -		eth_zero_addr(vf_mac_addr); -		memcpy(adapter->vfinfo[vfn].vf_mac_addresses, vf_mac_addr, 6); -	} +	if (enable) +		eth_zero_addr(adapter->vfinfo[vfn].vf_mac_addresses);  	return 0;  }  static int ixgbe_vf_reset_msg(struct ixgbe_adapter *adapter, u32 vf)  { +	struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ];  	struct ixgbe_hw *hw = &adapter->hw;  	unsigned char *vf_mac = adapter->vfinfo[vf].vf_mac_addresses;  	u32 reg, reg_offset, vf_shift;  	u32 msgbuf[4] = {0, 0, 0, 0};  	u8 *addr = (u8 *)(&msgbuf[1]); +	u32 q_per_pool = __ALIGN_MASK(1, ~vmdq->mask); +	int i;  	e_info(probe, "VF Reset msg received from vf %d\n", vf); @@ -660,6 +649,17 @@ static int ixgbe_vf_reset_msg(struct ixgbe_adapter *adapter, u32 vf)  	reg |= 1 << vf_shift;  	IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset), reg); +	/* force drop enable for all VF Rx queues */ +	for (i = vf * q_per_pool; i < ((vf + 1) * q_per_pool); i++) { +		/* flush previous write */ +		IXGBE_WRITE_FLUSH(hw); + +		/* indicate to hardware that we want to set drop enable */ +		reg = IXGBE_QDE_WRITE | IXGBE_QDE_ENABLE; +		reg |= i <<  IXGBE_QDE_IDX_SHIFT; +		IXGBE_WRITE_REG(hw, IXGBE_QDE, reg); +	} +  	/* enable receive for vf */  	reg = IXGBE_READ_REG(hw, IXGBE_VFRE(reg_offset));  	reg |= 1 << vf_shift; @@ -690,6 +690,15 @@ static int ixgbe_vf_reset_msg(struct ixgbe_adapter *adapter, u32 vf)  	reg |= (1 << vf_shift);  	IXGBE_WRITE_REG(hw, IXGBE_VMECM(reg_offset), reg); +	/* +	 * Reset the VFs TDWBAL and TDWBAH registers +	 * which are not cleared by an FLR +	 */ +	for (i = 0; i < q_per_pool; i++) { +		IXGBE_WRITE_REG(hw, IXGBE_PVFTDWBAHn(q_per_pool, vf, i), 0); +		IXGBE_WRITE_REG(hw, IXGBE_PVFTDWBALn(q_per_pool, vf, i), 0); +	} +  	/* reply to reset with ack and vf mac address */  	msgbuf[0] = IXGBE_VF_RESET;  	if (!is_zero_ether_addr(vf_mac)) { @@ -723,8 +732,7 @@ static int ixgbe_set_vf_mac_addr(struct ixgbe_adapter *adapter,  	}  	if (adapter->vfinfo[vf].pf_set_mac && -	    memcmp(adapter->vfinfo[vf].vf_mac_addresses, new_mac, -		   ETH_ALEN)) { +	    !ether_addr_equal(adapter->vfinfo[vf].vf_mac_addresses, new_mac)) {  		e_warn(drv,  		       "VF %d attempted to override administratively set MAC address\n"  		       "Reload the VF driver to resume operations\n", @@ -1121,9 +1129,9 @@ int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)  			adapter->vfinfo[vf].vlan_count--;  		adapter->vfinfo[vf].pf_vlan = 0;  		adapter->vfinfo[vf].pf_qos = 0; -       } +	}  out: -       return err; +	return err;  }  static int ixgbe_link_mbps(struct ixgbe_adapter *adapter) @@ -1214,7 +1222,8 @@ void ixgbe_check_vf_rate_limit(struct ixgbe_adapter *adapter)  	}  } -int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate) +int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate, +			int max_tx_rate)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	int link_speed; @@ -1232,13 +1241,16 @@ int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)  	if (link_speed != 10000)  		return -EINVAL; +	if (min_tx_rate) +		return -EINVAL; +  	/* rate limit cannot be less than 10Mbs or greater than link speed */ -	if (tx_rate && ((tx_rate <= 10) || (tx_rate > link_speed))) +	if (max_tx_rate && ((max_tx_rate <= 10) || (max_tx_rate > link_speed)))  		return -EINVAL;  	/* store values */  	adapter->vf_rate_link_speed = link_speed; -	adapter->vfinfo[vf].tx_rate = tx_rate; +	adapter->vfinfo[vf].tx_rate = max_tx_rate;  	/* update hardware configuration */  	ixgbe_set_vf_rate_limit(adapter, vf); @@ -1280,7 +1292,8 @@ int ixgbe_ndo_get_vf_config(struct net_device *netdev,  		return -EINVAL;  	ivi->vf = vf;  	memcpy(&ivi->mac, adapter->vfinfo[vf].vf_mac_addresses, ETH_ALEN); -	ivi->tx_rate = adapter->vfinfo[vf].tx_rate; +	ivi->max_tx_rate = adapter->vfinfo[vf].tx_rate; +	ivi->min_tx_rate = 0;  	ivi->vlan = adapter->vfinfo[vf].pf_vlan;  	ivi->qos = adapter->vfinfo[vf].pf_qos;  	ivi->spoofchk = adapter->vfinfo[vf].spoofchk_enabled; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h index 4713f9fc7f4..32c26d586c0 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -28,7 +29,14 @@  #ifndef _IXGBE_SRIOV_H_  #define _IXGBE_SRIOV_H_ +/*  ixgbe driver limit the max number of VFs could be enabled to + *  63 (IXGBE_MAX_VF_FUNCTIONS - 1) + */ +#define IXGBE_MAX_VFS_DRV_LIMIT  (IXGBE_MAX_VF_FUNCTIONS - 1) + +#ifdef CONFIG_PCI_IOV  void ixgbe_restore_vf_multicasts(struct ixgbe_adapter *adapter); +#endif  void ixgbe_msg_task(struct ixgbe_adapter *adapter);  int ixgbe_vf_configuration(struct pci_dev *pdev, unsigned int event_mask);  void ixgbe_disable_tx_rx(struct ixgbe_adapter *adapter); @@ -36,7 +44,8 @@ void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter);  int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int queue, u8 *mac);  int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int queue, u16 vlan,  			   u8 qos); -int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate); +int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate, +			int max_tx_rate);  int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting);  int ixgbe_ndo_get_vf_config(struct net_device *netdev,  			    int vf, struct ifla_vf_info *ivi); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c index d118def16f3..ef6df3d6437 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -111,29 +112,29 @@ static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter,  	unsigned int n_attr;  	struct hwmon_attr *ixgbe_attr; -	n_attr = adapter->ixgbe_hwmon_buff.n_hwmon; -	ixgbe_attr = &adapter->ixgbe_hwmon_buff.hwmon_list[n_attr]; +	n_attr = adapter->ixgbe_hwmon_buff->n_hwmon; +	ixgbe_attr = &adapter->ixgbe_hwmon_buff->hwmon_list[n_attr];  	switch (type) {  	case IXGBE_HWMON_TYPE_LOC:  		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_location;  		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name), -			 "temp%u_label", offset); +			 "temp%u_label", offset + 1);  		break;  	case IXGBE_HWMON_TYPE_TEMP:  		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_temp;  		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name), -			 "temp%u_input", offset); +			 "temp%u_input", offset + 1);  		break;  	case IXGBE_HWMON_TYPE_CAUTION:  		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_cautionthresh;  		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name), -			 "temp%u_max", offset); +			 "temp%u_max", offset + 1);  		break;  	case IXGBE_HWMON_TYPE_MAX:  		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_maxopthresh;  		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name), -			 "temp%u_crit", offset); +			 "temp%u_crit", offset + 1);  		break;  	default:  		rc = -EPERM; @@ -147,32 +148,17 @@ static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter,  	ixgbe_attr->dev_attr.store = NULL;  	ixgbe_attr->dev_attr.attr.mode = S_IRUGO;  	ixgbe_attr->dev_attr.attr.name = ixgbe_attr->name; +	sysfs_attr_init(&ixgbe_attr->dev_attr.attr); -	rc = device_create_file(&adapter->pdev->dev, -				&ixgbe_attr->dev_attr); +	adapter->ixgbe_hwmon_buff->attrs[n_attr] = &ixgbe_attr->dev_attr.attr; -	if (rc == 0) -		++adapter->ixgbe_hwmon_buff.n_hwmon; +	++adapter->ixgbe_hwmon_buff->n_hwmon; -	return rc; +	return 0;  }  static void ixgbe_sysfs_del_adapter(struct ixgbe_adapter *adapter)  { -	int i; - -	if (adapter == NULL) -		return; - -	for (i = 0; i < adapter->ixgbe_hwmon_buff.n_hwmon; i++) { -		device_remove_file(&adapter->pdev->dev, -			   &adapter->ixgbe_hwmon_buff.hwmon_list[i].dev_attr); -	} - -	kfree(adapter->ixgbe_hwmon_buff.hwmon_list); - -	if (adapter->ixgbe_hwmon_buff.device) -		hwmon_device_unregister(adapter->ixgbe_hwmon_buff.device);  }  /* called from ixgbe_main.c */ @@ -184,9 +170,9 @@ void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter)  /* called from ixgbe_main.c */  int ixgbe_sysfs_init(struct ixgbe_adapter *adapter)  { -	struct hwmon_buff *ixgbe_hwmon = &adapter->ixgbe_hwmon_buff; +	struct hwmon_buff *ixgbe_hwmon; +	struct device *hwmon_dev;  	unsigned int i; -	int n_attrs;  	int rc = 0;  	/* If this method isn't defined we don't support thermals */ @@ -198,23 +184,13 @@ int ixgbe_sysfs_init(struct ixgbe_adapter *adapter)  	if (adapter->hw.mac.ops.init_thermal_sensor_thresh(&adapter->hw))  		goto exit; -	/* -	 * Allocation space for max attributs -	 * max num sensors * values (loc, temp, max, caution) -	 */ -	n_attrs = IXGBE_MAX_SENSORS * 4; -	ixgbe_hwmon->hwmon_list = kcalloc(n_attrs, sizeof(struct hwmon_attr), -					  GFP_KERNEL); -	if (!ixgbe_hwmon->hwmon_list) { +	ixgbe_hwmon = devm_kzalloc(&adapter->pdev->dev, sizeof(*ixgbe_hwmon), +				   GFP_KERNEL); +	if (ixgbe_hwmon == NULL) {  		rc = -ENOMEM; -		goto err; -	} - -	ixgbe_hwmon->device = hwmon_device_register(&adapter->pdev->dev); -	if (IS_ERR(ixgbe_hwmon->device)) { -		rc = PTR_ERR(ixgbe_hwmon->device); -		goto err; +		goto exit;  	} +	adapter->ixgbe_hwmon_buff = ixgbe_hwmon;  	for (i = 0; i < IXGBE_MAX_SENSORS; i++) {  		/* @@ -226,17 +202,28 @@ int ixgbe_sysfs_init(struct ixgbe_adapter *adapter)  		/* Bail if any hwmon attr struct fails to initialize */  		rc = ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_CAUTION); -		rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_LOC); -		rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_TEMP); -		rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_MAX);  		if (rc) -			goto err; +			goto exit; +		rc = ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_LOC); +		if (rc) +			goto exit; +		rc = ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_TEMP); +		if (rc) +			goto exit; +		rc = ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_MAX); +		if (rc) +			goto exit;  	} -	goto exit; +	ixgbe_hwmon->groups[0] = &ixgbe_hwmon->group; +	ixgbe_hwmon->group.attrs = ixgbe_hwmon->attrs; -err: -	ixgbe_sysfs_del_adapter(adapter); +	hwmon_dev = devm_hwmon_device_register_with_groups(&adapter->pdev->dev, +							   "ixgbe", +							   ixgbe_hwmon, +							   ixgbe_hwmon->groups); +	if (IS_ERR(hwmon_dev)) +		rc = PTR_ERR(hwmon_dev);  exit:  	return rc;  } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h index 10775cb9b6d..9a89f98b35f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2013 Intel Corporation. +  Copyright(c) 1999 - 2014 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -54,6 +55,7 @@  #define IXGBE_DEV_ID_82599_BACKPLANE_FCOE       0x152a  #define IXGBE_DEV_ID_82599_SFP_FCOE      0x1529  #define IXGBE_SUBDEV_ID_82599_SFP        0x11A9 +#define IXGBE_SUBDEV_ID_82599_SFP_WOL0   0x1071  #define IXGBE_SUBDEV_ID_82599_RNDC       0x1F72  #define IXGBE_SUBDEV_ID_82599_560FLR     0x17D0  #define IXGBE_SUBDEV_ID_82599_SP_560FLR  0x211B @@ -158,7 +160,7 @@ struct ixgbe_thermal_sensor_data {  #define IXGBE_MAX_EITR     0x00000FF8  #define IXGBE_MIN_EITR     8  #define IXGBE_EITR(_i)  (((_i) <= 23) ? (0x00820 + ((_i) * 4)) : \ -                         (0x012300 + (((_i) - 24) * 4))) +			 (0x012300 + (((_i) - 24) * 4)))  #define IXGBE_EITR_ITR_INT_MASK 0x00000FF8  #define IXGBE_EITR_LLI_MOD      0x00008000  #define IXGBE_EITR_CNT_WDIS     0x80000000 @@ -211,7 +213,7 @@ struct ixgbe_thermal_sensor_data {   * 64-127: 0x0D014 + (n-64)*0x40   */  #define IXGBE_SRRCTL(_i) (((_i) <= 15) ? (0x02100 + ((_i) * 4)) : \ -                          (((_i) < 64) ? (0x01014 + ((_i) * 0x40)) : \ +			  (((_i) < 64) ? (0x01014 + ((_i) * 0x40)) : \  			  (0x0D014 + (((_i) - 64) * 0x40))))  /*   * Rx DCA Control Register: @@ -220,11 +222,11 @@ struct ixgbe_thermal_sensor_data {   * 64-127: 0x0D00C + (n-64)*0x40   */  #define IXGBE_DCA_RXCTRL(_i)    (((_i) <= 15) ? (0x02200 + ((_i) * 4)) : \ -                                 (((_i) < 64) ? (0x0100C + ((_i) * 0x40)) : \ +				 (((_i) < 64) ? (0x0100C + ((_i) * 0x40)) : \  				 (0x0D00C + (((_i) - 64) * 0x40))))  #define IXGBE_RDRXCTL           0x02F00  #define IXGBE_RXPBSIZE(_i)      (0x03C00 + ((_i) * 4)) -                                             /* 8 of these 0x03C00 - 0x03C1C */ +					     /* 8 of these 0x03C00 - 0x03C1C */  #define IXGBE_RXCTRL    0x03000  #define IXGBE_DROPEN    0x03D04  #define IXGBE_RXPBSIZE_SHIFT 10 @@ -237,14 +239,14 @@ struct ixgbe_thermal_sensor_data {  /* Multicast Table Array - 128 entries */  #define IXGBE_MTA(_i)   (0x05200 + ((_i) * 4))  #define IXGBE_RAL(_i)   (((_i) <= 15) ? (0x05400 + ((_i) * 8)) : \ -                         (0x0A200 + ((_i) * 8))) +			 (0x0A200 + ((_i) * 8)))  #define IXGBE_RAH(_i)   (((_i) <= 15) ? (0x05404 + ((_i) * 8)) : \ -                         (0x0A204 + ((_i) * 8))) +			 (0x0A204 + ((_i) * 8)))  #define IXGBE_MPSAR_LO(_i) (0x0A600 + ((_i) * 8))  #define IXGBE_MPSAR_HI(_i) (0x0A604 + ((_i) * 8))  /* Packet split receive type */  #define IXGBE_PSRTYPE(_i)    (((_i) <= 15) ? (0x05480 + ((_i) * 4)) : \ -                              (0x0EA00 + ((_i) * 4))) +			      (0x0EA00 + ((_i) * 4)))  /* array of 4096 1-bit vlan filters */  #define IXGBE_VFTA(_i)  (0x0A000 + ((_i) * 4))  /*array of 4096 4-bit vlan vmdq indices */ @@ -561,6 +563,10 @@ struct ixgbe_thermal_sensor_data {  #define IXGBE_RTTDQSEL    0x04904  #define IXGBE_RTTDT1C     0x04908  #define IXGBE_RTTDT1S     0x0490C +#define IXGBE_RTTQCNCR    0x08B00 +#define IXGBE_RTTQCNTG    0x04A90 +#define IXGBE_RTTBCNRD    0x0498C +#define IXGBE_RTTQCNRR    0x0498C  #define IXGBE_RTTDTECC    0x04990  #define IXGBE_RTTDTECC_NO_BCN   0x00000100  #define IXGBE_RTTBCNRC    0x04984 @@ -570,6 +576,7 @@ struct ixgbe_thermal_sensor_data {  #define IXGBE_RTTBCNRC_RF_INT_MASK	\  	(IXGBE_RTTBCNRC_RF_DEC_MASK << IXGBE_RTTBCNRC_RF_INT_SHIFT)  #define IXGBE_RTTBCNRM    0x04980 +#define IXGBE_RTTQCNRM    0x04980  /* FCoE DMA Context Registers */  #define IXGBE_FCPTRL    0x02410 /* FC User Desc. PTR Low */ @@ -689,7 +696,7 @@ struct ixgbe_thermal_sensor_data {  #define IXGBE_RQSMR(_i) (0x02300 + ((_i) * 4))  #define IXGBE_TQSMR(_i) (((_i) <= 7) ? (0x07300 + ((_i) * 4)) : \ -                         (0x08600 + ((_i) * 4))) +			 (0x08600 + ((_i) * 4)))  #define IXGBE_TQSM(_i)  (0x08600 + ((_i) * 4))  #define IXGBE_QPRC(_i) (0x01030 + ((_i) * 0x40)) /* 16 of these */ @@ -813,7 +820,7 @@ struct ixgbe_thermal_sensor_data {  #define IXGBE_GCR_EXT_VT_MODE_32        0x00000002  #define IXGBE_GCR_EXT_VT_MODE_64        0x00000003  #define IXGBE_GCR_EXT_SRIOV             (IXGBE_GCR_EXT_MSIX_EN | \ -                                         IXGBE_GCR_EXT_VT_MODE_64) +					 IXGBE_GCR_EXT_VT_MODE_64)  /* Time Sync Registers */  #define IXGBE_TSYNCRXCTL 0x05188 /* Rx Time Sync Control register - RW */ @@ -1389,10 +1396,10 @@ enum {  #define IXGBE_EIMC_OTHER        IXGBE_EICR_OTHER     /* INT Cause Active */  #define IXGBE_EIMS_ENABLE_MASK ( \ -                                IXGBE_EIMS_RTX_QUEUE       | \ -                                IXGBE_EIMS_LSC             | \ -                                IXGBE_EIMS_TCP_TIMER       | \ -                                IXGBE_EIMS_OTHER) +				IXGBE_EIMS_RTX_QUEUE       | \ +				IXGBE_EIMS_LSC             | \ +				IXGBE_EIMS_TCP_TIMER       | \ +				IXGBE_EIMS_OTHER)  /* Immediate Interrupt Rx (A.K.A. Low Latency Interrupt) */  #define IXGBE_IMIR_PORT_IM_EN     0x00010000  /* TCP port enable */ @@ -1604,6 +1611,9 @@ enum {  #define IXGBE_MACC_FS        0x00040000  #define IXGBE_MAC_RX2TX_LPBK 0x00000002 +/* Veto Bit definiton */ +#define IXGBE_MMNGC_MNG_VETO  0x00000001 +  /* LINKS Bit Masks */  #define IXGBE_LINKS_KX_AN_COMP  0x80000000  #define IXGBE_LINKS_UP          0x40000000 @@ -1783,6 +1793,9 @@ enum {  #define IXGBE_EEPROM_RD_BUFFER_MAX_COUNT 512 /* EEPROM words # read in burst */  #define IXGBE_EEPROM_WR_BUFFER_MAX_COUNT 256 /* EEPROM words # wr in burst */ +#define IXGBE_EEPROM_CTRL_2	1 /* EEPROM CTRL word 2 */ +#define IXGBE_EEPROM_CCD_BIT	2 /* EEPROM Core Clock Disable bit */ +  #ifndef IXGBE_EEPROM_GRANT_ATTEMPTS  #define IXGBE_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */  #endif @@ -1848,8 +1861,19 @@ enum {  #define IXGBE_PCI_HEADER_TYPE_MULTIFUNC 0x80  #define IXGBE_PCI_DEVICE_CONTROL2_16ms  0x0005 +#define IXGBE_PCIDEVCTRL2_TIMEO_MASK	0xf +#define IXGBE_PCIDEVCTRL2_16_32ms_def	0x0 +#define IXGBE_PCIDEVCTRL2_50_100us	0x1 +#define IXGBE_PCIDEVCTRL2_1_2ms		0x2 +#define IXGBE_PCIDEVCTRL2_16_32ms	0x5 +#define IXGBE_PCIDEVCTRL2_65_130ms	0x6 +#define IXGBE_PCIDEVCTRL2_260_520ms	0x9 +#define IXGBE_PCIDEVCTRL2_1_2s		0xa +#define IXGBE_PCIDEVCTRL2_4_8s		0xd +#define IXGBE_PCIDEVCTRL2_17_34s	0xe +  /* Number of 100 microseconds we wait for PCI Express master disable */ -#define IXGBE_PCI_MASTER_DISABLE_TIMEOUT 800 +#define IXGBE_PCI_MASTER_DISABLE_TIMEOUT	800  /* RAH */  #define IXGBE_RAH_VIND_MASK     0x003C0000 @@ -1975,9 +1999,10 @@ enum {  #define IXGBE_FWSM_TS_ENABLED	0x1  /* Queue Drop Enable */ -#define IXGBE_QDE_ENABLE     0x00000001 -#define IXGBE_QDE_IDX_MASK   0x00007F00 -#define IXGBE_QDE_IDX_SHIFT           8 +#define IXGBE_QDE_ENABLE	0x00000001 +#define IXGBE_QDE_IDX_MASK	0x00007F00 +#define IXGBE_QDE_IDX_SHIFT	8 +#define IXGBE_QDE_WRITE		0x00010000  #define IXGBE_TXD_POPTS_IXSM 0x01       /* Insert IP checksum */  #define IXGBE_TXD_POPTS_TXSM 0x02       /* Insert TCP/UDP checksum */ @@ -2136,18 +2161,18 @@ enum {  /* Masks to determine if packets should be dropped due to frame errors */  #define IXGBE_RXD_ERR_FRAME_ERR_MASK ( \ -                                      IXGBE_RXD_ERR_CE | \ -                                      IXGBE_RXD_ERR_LE | \ -                                      IXGBE_RXD_ERR_PE | \ -                                      IXGBE_RXD_ERR_OSE | \ -                                      IXGBE_RXD_ERR_USE) +				      IXGBE_RXD_ERR_CE | \ +				      IXGBE_RXD_ERR_LE | \ +				      IXGBE_RXD_ERR_PE | \ +				      IXGBE_RXD_ERR_OSE | \ +				      IXGBE_RXD_ERR_USE)  #define IXGBE_RXDADV_ERR_FRAME_ERR_MASK ( \ -                                      IXGBE_RXDADV_ERR_CE | \ -                                      IXGBE_RXDADV_ERR_LE | \ -                                      IXGBE_RXDADV_ERR_PE | \ -                                      IXGBE_RXDADV_ERR_OSE | \ -                                      IXGBE_RXDADV_ERR_USE) +				      IXGBE_RXDADV_ERR_CE | \ +				      IXGBE_RXDADV_ERR_LE | \ +				      IXGBE_RXDADV_ERR_PE | \ +				      IXGBE_RXDADV_ERR_OSE | \ +				      IXGBE_RXDADV_ERR_USE)  /* Multicast bit mask */  #define IXGBE_MCSTCTRL_MFE      0x4 @@ -2168,6 +2193,14 @@ enum {  #define IXGBE_MBVFICR(_i)		(0x00710 + ((_i) * 4))  #define IXGBE_VFLRE(_i)		((((_i) & 1) ? 0x001C0 : 0x00600))  #define IXGBE_VFLREC(_i)		(0x00700 + ((_i) * 4)) +/* Translated register #defines */ +#define IXGBE_PVFTDWBAL(P)	(0x06038 + (0x40 * (P))) +#define IXGBE_PVFTDWBAH(P)	(0x0603C + (0x40 * (P))) + +#define IXGBE_PVFTDWBALn(q_per_pool, vf_number, vf_q_index) \ +		(IXGBE_PVFTDWBAL((q_per_pool)*(vf_number) + (vf_q_index))) +#define IXGBE_PVFTDWBAHn(q_per_pool, vf_number, vf_q_index) \ +		(IXGBE_PVFTDWBAH((q_per_pool)*(vf_number) + (vf_q_index)))  enum ixgbe_fdir_pballoc_type {  	IXGBE_FDIR_PBALLOC_NONE = 0, @@ -2360,9 +2393,9 @@ struct ixgbe_adv_tx_context_desc {  #define IXGBE_ADVTXD_CC         0x00000080 /* Check Context */  #define IXGBE_ADVTXD_POPTS_SHIFT      8  /* Adv desc POPTS shift */  #define IXGBE_ADVTXD_POPTS_IXSM (IXGBE_TXD_POPTS_IXSM << \ -                                 IXGBE_ADVTXD_POPTS_SHIFT) +				 IXGBE_ADVTXD_POPTS_SHIFT)  #define IXGBE_ADVTXD_POPTS_TXSM (IXGBE_TXD_POPTS_TXSM << \ -                                 IXGBE_ADVTXD_POPTS_SHIFT) +				 IXGBE_ADVTXD_POPTS_SHIFT)  #define IXGBE_ADVTXD_POPTS_ISCO_1ST  0x00000000 /* 1st TSO of iSCSI PDU */  #define IXGBE_ADVTXD_POPTS_ISCO_MDL  0x00000800 /* Middle TSO of iSCSI PDU */  #define IXGBE_ADVTXD_POPTS_ISCO_LAST 0x00001000 /* Last TSO of iSCSI PDU */ @@ -2402,10 +2435,10 @@ typedef u32 ixgbe_link_speed;  #define IXGBE_LINK_SPEED_1GB_FULL  0x0020  #define IXGBE_LINK_SPEED_10GB_FULL 0x0080  #define IXGBE_LINK_SPEED_82598_AUTONEG (IXGBE_LINK_SPEED_1GB_FULL | \ -                                        IXGBE_LINK_SPEED_10GB_FULL) +					IXGBE_LINK_SPEED_10GB_FULL)  #define IXGBE_LINK_SPEED_82599_AUTONEG (IXGBE_LINK_SPEED_100_FULL | \ -                                        IXGBE_LINK_SPEED_1GB_FULL | \ -                                        IXGBE_LINK_SPEED_10GB_FULL) +					IXGBE_LINK_SPEED_1GB_FULL | \ +					IXGBE_LINK_SPEED_10GB_FULL)  /* Physical layer type */ @@ -2631,7 +2664,6 @@ enum ixgbe_sfp_type {  enum ixgbe_media_type {  	ixgbe_media_type_unknown = 0,  	ixgbe_media_type_fiber, -	ixgbe_media_type_fiber_fixed,  	ixgbe_media_type_fiber_qsfp,  	ixgbe_media_type_fiber_lco,  	ixgbe_media_type_copper, @@ -2714,7 +2746,7 @@ struct ixgbe_bus_info {  /* Flow control parameters */  struct ixgbe_fc_info {  	u32 high_water[MAX_TRAFFIC_CLASS]; /* Flow Control High-water */ -	u32 low_water; /* Flow Control Low-water */ +	u32 low_water[MAX_TRAFFIC_CLASS]; /* Flow Control Low-water */  	u16 pause_time; /* Flow Control Pause timer */  	bool send_xon; /* Flow control send XON */  	bool strict_ieee; /* Strict IEEE mode */ @@ -2808,7 +2840,7 @@ struct ixgbe_hw;  /* iterator type for walking multicast address lists */  typedef u8* (*ixgbe_mc_addr_itr) (struct ixgbe_hw *hw, u8 **mc_addr_ptr, -                                  u32 *vmdq); +				  u32 *vmdq);  /* Function pointer table */  struct ixgbe_eeprom_operations { @@ -2844,6 +2876,8 @@ struct ixgbe_mac_operations {  	s32 (*enable_rx_dma)(struct ixgbe_hw *, u32);  	s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u16);  	void (*release_swfw_sync)(struct ixgbe_hw *, u16); +	s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *); +	s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool);  	/* Link */  	void (*disable_tx_laser)(struct ixgbe_hw *); @@ -2853,7 +2887,7 @@ struct ixgbe_mac_operations {  	s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool);  	s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);  	s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *, -	                             bool *); +				     bool *);  	/* Packet Buffer Manipulation */  	void (*set_rxpba)(struct ixgbe_hw *, int, u32, int); @@ -2887,7 +2921,6 @@ struct ixgbe_mac_operations {  	s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);  	s32 (*get_thermal_sensor_data)(struct ixgbe_hw *);  	s32 (*init_thermal_sensor_thresh)(struct ixgbe_hw *hw); -	bool (*mng_fw_enabled)(struct ixgbe_hw *hw);  };  struct ixgbe_phy_operations { @@ -2943,7 +2976,6 @@ struct ixgbe_mac_info {  	u32                             max_tx_queues;  	u32                             max_rx_queues;  	u32                             orig_autoc; -	u32                             cached_autoc;  	u32                             orig_autoc2;  	bool                            orig_link_settings_stored;  	bool                            autotry_restart; @@ -3019,7 +3051,6 @@ struct ixgbe_hw {  	bool				adapter_stopped;  	bool				force_full_reset;  	bool				allow_unsupported_sfp; -	bool				mng_fw_enabled;  	bool				wol_enabled;  }; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c index 389324f5929..40dd798e129 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c @@ -20,6 +20,7 @@    the file called "COPYING".    Contact Information: +  Linux NICS <linux.nics@intel.com>    e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@ -32,12 +33,12 @@  #include "ixgbe.h"  #include "ixgbe_phy.h" -#define IXGBE_X540_MAX_TX_QUEUES 128 -#define IXGBE_X540_MAX_RX_QUEUES 128 -#define IXGBE_X540_RAR_ENTRIES   128 -#define IXGBE_X540_MC_TBL_SIZE   128 -#define IXGBE_X540_VFT_TBL_SIZE  128 -#define IXGBE_X540_RX_PB_SIZE	 384 +#define IXGBE_X540_MAX_TX_QUEUES	128 +#define IXGBE_X540_MAX_RX_QUEUES	128 +#define IXGBE_X540_RAR_ENTRIES		128 +#define IXGBE_X540_MC_TBL_SIZE		128 +#define IXGBE_X540_VFT_TBL_SIZE		128 +#define IXGBE_X540_RX_PB_SIZE		384  static s32 ixgbe_update_flash_X540(struct ixgbe_hw *hw);  static s32 ixgbe_poll_flash_update_done_X540(struct ixgbe_hw *hw); @@ -61,6 +62,7 @@ static s32 ixgbe_get_invariants_X540(struct ixgbe_hw *hw)  	mac->mcft_size = IXGBE_X540_MC_TBL_SIZE;  	mac->vft_size = IXGBE_X540_VFT_TBL_SIZE;  	mac->num_rar_entries = IXGBE_X540_RAR_ENTRIES; +	mac->rx_pb_size = IXGBE_X540_RX_PB_SIZE;  	mac->max_rx_queues = IXGBE_X540_MAX_RX_QUEUES;  	mac->max_tx_queues = IXGBE_X540_MAX_TX_QUEUES;  	mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw); @@ -79,7 +81,7 @@ static s32 ixgbe_setup_mac_link_X540(struct ixgbe_hw *hw,  				     bool autoneg_wait_to_complete)  {  	return hw->phy.ops.setup_link_speed(hw, speed, -	                                    autoneg_wait_to_complete); +					    autoneg_wait_to_complete);  }  /** @@ -153,7 +155,7 @@ mac_reset_top:  	/* Add the SAN MAC address to the RAR only if it's a valid address */  	if (is_valid_ether_addr(hw->mac.san_addr)) {  		hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1, -		                    hw->mac.san_addr, 0, IXGBE_RAH_AV); +				    hw->mac.san_addr, 0, IXGBE_RAH_AV);  		/* Save the SAN MAC RAR index */  		hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1; @@ -164,7 +166,7 @@ mac_reset_top:  	/* Store the alternative WWNN/WWPN prefix */  	hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix, -	                           &hw->mac.wwpn_prefix); +				   &hw->mac.wwpn_prefix);  reset_hw_out:  	return status; @@ -187,7 +189,6 @@ static s32 ixgbe_start_hw_X540(struct ixgbe_hw *hw)  		goto out;  	ret_val = ixgbe_start_hw_gen2(hw); -	hw->mac.rx_pb_size = IXGBE_X540_RX_PB_SIZE;  out:  	return ret_val;  } @@ -236,9 +237,9 @@ static s32 ixgbe_init_eeprom_params_X540(struct ixgbe_hw *hw)  		eec = IXGBE_READ_REG(hw, IXGBE_EEC);  		eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >> -		                    IXGBE_EEC_SIZE_SHIFT); +				    IXGBE_EEC_SIZE_SHIFT);  		eeprom->word_size = 1 << (eeprom_size + -		                          IXGBE_EEPROM_WORD_SIZE_SHIFT); +					  IXGBE_EEPROM_WORD_SIZE_SHIFT);  		hw_dbg(hw, "Eeprom params: type = %d, size = %d\n",  		       eeprom->type, eeprom->word_size); @@ -711,8 +712,7 @@ static s32 ixgbe_get_swfw_sync_semaphore(struct ixgbe_hw *hw)  			udelay(50);  		}  	} else { -		hw_dbg(hw, "Software semaphore SMBI between device drivers " -		           "not granted.\n"); +		hw_dbg(hw, "Software semaphore SMBI between device drivers not granted.\n");  	}  	return status; @@ -812,7 +812,7 @@ static struct ixgbe_mac_operations mac_ops_X540 = {  	.clear_hw_cntrs         = &ixgbe_clear_hw_cntrs_generic,  	.get_media_type         = &ixgbe_get_media_type_X540,  	.get_supported_physical_layer = -                                  &ixgbe_get_supported_physical_layer_X540, +				  &ixgbe_get_supported_physical_layer_X540,  	.enable_rx_dma          = &ixgbe_enable_rx_dma_generic,  	.get_mac_addr           = &ixgbe_get_mac_addr_generic,  	.get_san_mac_addr       = &ixgbe_get_san_mac_addr_generic, @@ -854,7 +854,8 @@ static struct ixgbe_mac_operations mac_ops_X540 = {  	.enable_rx_buff		= &ixgbe_enable_rx_buff_generic,  	.get_thermal_sensor_data = NULL,  	.init_thermal_sensor_thresh = NULL, -	.mng_fw_enabled		= NULL, +	.prot_autoc_read	= &prot_autoc_read_generic, +	.prot_autoc_write	= &prot_autoc_write_generic,  };  static struct ixgbe_eeprom_operations eeprom_ops_X540 = {  | 
