aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2011-08-26 03:46:03 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-10-08 01:49:19 -0400
commit3ceb90fd4898853cdac43084f0c6ee7270cb15f3 (patch)
tree97526ddf3e00da217061063a30fba616e982d4b5 /drivers/net/ethernet/intel
parent294e7d78f5b929536b81620ed33c6507f2921463 (diff)
igb: leave staterr in place and instead us a helper function to check bits
Instead of doing a byte swap on the staterr bits in the Rx descriptor we can save ourselves a bit of space and some CPU time by instead just testing for the various bits out of the Rx descriptor directly. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel')
-rw-r--r--drivers/net/ethernet/intel/igb/igb.h7
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ethtool.c5
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c55
3 files changed, 39 insertions, 28 deletions
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index fde381a9d23c..11d17f14aeeb 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -259,6 +259,13 @@ enum e1000_ring_flags_t {
259#define IGB_TX_CTXTDESC(R, i) \ 259#define IGB_TX_CTXTDESC(R, i) \
260 (&(((struct e1000_adv_tx_context_desc *)((R)->desc))[i])) 260 (&(((struct e1000_adv_tx_context_desc *)((R)->desc))[i]))
261 261
262/* igb_test_staterr - tests bits within Rx descriptor status and error fields */
263static inline __le32 igb_test_staterr(union e1000_adv_rx_desc *rx_desc,
264 const u32 stat_err_bits)
265{
266 return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
267}
268
262/* igb_desc_unused - calculate if we have unused descriptors */ 269/* igb_desc_unused - calculate if we have unused descriptors */
263static inline int igb_desc_unused(struct igb_ring *ring) 270static inline int igb_desc_unused(struct igb_ring *ring)
264{ 271{
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 5ebe992010d6..bc198ea2bc14 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -1581,16 +1581,14 @@ static int igb_clean_test_rings(struct igb_ring *rx_ring,
1581 union e1000_adv_rx_desc *rx_desc; 1581 union e1000_adv_rx_desc *rx_desc;
1582 struct igb_rx_buffer *rx_buffer_info; 1582 struct igb_rx_buffer *rx_buffer_info;
1583 struct igb_tx_buffer *tx_buffer_info; 1583 struct igb_tx_buffer *tx_buffer_info;
1584 u32 staterr;
1585 u16 rx_ntc, tx_ntc, count = 0; 1584 u16 rx_ntc, tx_ntc, count = 0;
1586 1585
1587 /* initialize next to clean and descriptor values */ 1586 /* initialize next to clean and descriptor values */
1588 rx_ntc = rx_ring->next_to_clean; 1587 rx_ntc = rx_ring->next_to_clean;
1589 tx_ntc = tx_ring->next_to_clean; 1588 tx_ntc = tx_ring->next_to_clean;
1590 rx_desc = IGB_RX_DESC(rx_ring, rx_ntc); 1589 rx_desc = IGB_RX_DESC(rx_ring, rx_ntc);
1591 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
1592 1590
1593 while (staterr & E1000_RXD_STAT_DD) { 1591 while (igb_test_staterr(rx_desc, E1000_RXD_STAT_DD)) {
1594 /* check rx buffer */ 1592 /* check rx buffer */
1595 rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc]; 1593 rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc];
1596 1594
@@ -1619,7 +1617,6 @@ static int igb_clean_test_rings(struct igb_ring *rx_ring,
1619 1617
1620 /* fetch next descriptor */ 1618 /* fetch next descriptor */
1621 rx_desc = IGB_RX_DESC(rx_ring, rx_ntc); 1619 rx_desc = IGB_RX_DESC(rx_ring, rx_ntc);
1622 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
1623 } 1620 }
1624 1621
1625 /* re-map buffers to ring, store next to clean values */ 1622 /* re-map buffers to ring, store next to clean values */
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index cae4abb48501..1419ae89e29c 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -5790,12 +5790,13 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
5790} 5790}
5791 5791
5792static inline void igb_rx_checksum(struct igb_ring *ring, 5792static inline void igb_rx_checksum(struct igb_ring *ring,
5793 u32 status_err, struct sk_buff *skb) 5793 union e1000_adv_rx_desc *rx_desc,
5794 struct sk_buff *skb)
5794{ 5795{
5795 skb_checksum_none_assert(skb); 5796 skb_checksum_none_assert(skb);
5796 5797
5797 /* Ignore Checksum bit is set */ 5798 /* Ignore Checksum bit is set */
5798 if (status_err & E1000_RXD_STAT_IXSM) 5799 if (igb_test_staterr(rx_desc, E1000_RXD_STAT_IXSM))
5799 return; 5800 return;
5800 5801
5801 /* Rx checksum disabled via ethtool */ 5802 /* Rx checksum disabled via ethtool */
@@ -5803,8 +5804,9 @@ static inline void igb_rx_checksum(struct igb_ring *ring,
5803 return; 5804 return;
5804 5805
5805 /* TCP/UDP checksum error bit is set */ 5806 /* TCP/UDP checksum error bit is set */
5806 if (status_err & 5807 if (igb_test_staterr(rx_desc,
5807 (E1000_RXDEXT_STATERR_TCPE | E1000_RXDEXT_STATERR_IPE)) { 5808 E1000_RXDEXT_STATERR_TCPE |
5809 E1000_RXDEXT_STATERR_IPE)) {
5808 /* 5810 /*
5809 * work around errata with sctp packets where the TCPE aka 5811 * work around errata with sctp packets where the TCPE aka
5810 * L4E bit is set incorrectly on 64 byte (60 byte w/o crc) 5812 * L4E bit is set incorrectly on 64 byte (60 byte w/o crc)
@@ -5820,19 +5822,26 @@ static inline void igb_rx_checksum(struct igb_ring *ring,
5820 return; 5822 return;
5821 } 5823 }
5822 /* It must be a TCP or UDP packet with a valid checksum */ 5824 /* It must be a TCP or UDP packet with a valid checksum */
5823 if (status_err & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)) 5825 if (igb_test_staterr(rx_desc, E1000_RXD_STAT_TCPCS |
5826 E1000_RXD_STAT_UDPCS))
5824 skb->ip_summed = CHECKSUM_UNNECESSARY; 5827 skb->ip_summed = CHECKSUM_UNNECESSARY;
5825 5828
5826 dev_dbg(ring->dev, "cksum success: bits %08X\n", status_err); 5829 dev_dbg(ring->dev, "cksum success: bits %08X\n",
5830 le32_to_cpu(rx_desc->wb.upper.status_error));
5827} 5831}
5828 5832
5829static void igb_rx_hwtstamp(struct igb_q_vector *q_vector, u32 staterr, 5833static void igb_rx_hwtstamp(struct igb_q_vector *q_vector,
5830 struct sk_buff *skb) 5834 union e1000_adv_rx_desc *rx_desc,
5835 struct sk_buff *skb)
5831{ 5836{
5832 struct igb_adapter *adapter = q_vector->adapter; 5837 struct igb_adapter *adapter = q_vector->adapter;
5833 struct e1000_hw *hw = &adapter->hw; 5838 struct e1000_hw *hw = &adapter->hw;
5834 u64 regval; 5839 u64 regval;
5835 5840
5841 if (!igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP |
5842 E1000_RXDADV_STAT_TS))
5843 return;
5844
5836 /* 5845 /*
5837 * If this bit is set, then the RX registers contain the time stamp. No 5846 * If this bit is set, then the RX registers contain the time stamp. No
5838 * other packet will be time stamped until we read these registers, so 5847 * other packet will be time stamped until we read these registers, so
@@ -5844,7 +5853,7 @@ static void igb_rx_hwtstamp(struct igb_q_vector *q_vector, u32 staterr,
5844 * If nothing went wrong, then it should have a shared tx_flags that we 5853 * If nothing went wrong, then it should have a shared tx_flags that we
5845 * can turn into a skb_shared_hwtstamps. 5854 * can turn into a skb_shared_hwtstamps.
5846 */ 5855 */
5847 if (staterr & E1000_RXDADV_STAT_TSIP) { 5856 if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) {
5848 u32 *stamp = (u32 *)skb->data; 5857 u32 *stamp = (u32 *)skb->data;
5849 regval = le32_to_cpu(*(stamp + 2)); 5858 regval = le32_to_cpu(*(stamp + 2));
5850 regval |= (u64)le32_to_cpu(*(stamp + 3)) << 32; 5859 regval |= (u64)le32_to_cpu(*(stamp + 3)) << 32;
@@ -5878,14 +5887,12 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget)
5878 union e1000_adv_rx_desc *rx_desc; 5887 union e1000_adv_rx_desc *rx_desc;
5879 const int current_node = numa_node_id(); 5888 const int current_node = numa_node_id();
5880 unsigned int total_bytes = 0, total_packets = 0; 5889 unsigned int total_bytes = 0, total_packets = 0;
5881 u32 staterr;
5882 u16 cleaned_count = igb_desc_unused(rx_ring); 5890 u16 cleaned_count = igb_desc_unused(rx_ring);
5883 u16 i = rx_ring->next_to_clean; 5891 u16 i = rx_ring->next_to_clean;
5884 5892
5885 rx_desc = IGB_RX_DESC(rx_ring, i); 5893 rx_desc = IGB_RX_DESC(rx_ring, i);
5886 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
5887 5894
5888 while (staterr & E1000_RXD_STAT_DD) { 5895 while (igb_test_staterr(rx_desc, E1000_RXD_STAT_DD)) {
5889 struct igb_rx_buffer *buffer_info = &rx_ring->rx_buffer_info[i]; 5896 struct igb_rx_buffer *buffer_info = &rx_ring->rx_buffer_info[i];
5890 struct sk_buff *skb = buffer_info->skb; 5897 struct sk_buff *skb = buffer_info->skb;
5891 union e1000_adv_rx_desc *next_rxd; 5898 union e1000_adv_rx_desc *next_rxd;
@@ -5938,7 +5945,7 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget)
5938 buffer_info->page_dma = 0; 5945 buffer_info->page_dma = 0;
5939 } 5946 }
5940 5947
5941 if (!(staterr & E1000_RXD_STAT_EOP)) { 5948 if (!igb_test_staterr(rx_desc, E1000_RXD_STAT_EOP)) {
5942 struct igb_rx_buffer *next_buffer; 5949 struct igb_rx_buffer *next_buffer;
5943 next_buffer = &rx_ring->rx_buffer_info[i]; 5950 next_buffer = &rx_ring->rx_buffer_info[i];
5944 buffer_info->skb = next_buffer->skb; 5951 buffer_info->skb = next_buffer->skb;
@@ -5948,25 +5955,26 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget)
5948 goto next_desc; 5955 goto next_desc;
5949 } 5956 }
5950 5957
5951 if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) { 5958 if (igb_test_staterr(rx_desc,
5959 E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
5952 dev_kfree_skb_any(skb); 5960 dev_kfree_skb_any(skb);
5953 goto next_desc; 5961 goto next_desc;
5954 } 5962 }
5955 5963
5956 if (staterr & (E1000_RXDADV_STAT_TSIP | E1000_RXDADV_STAT_TS)) 5964 igb_rx_hwtstamp(q_vector, rx_desc, skb);
5957 igb_rx_hwtstamp(q_vector, staterr, skb); 5965 igb_rx_checksum(rx_ring, rx_desc, skb);
5958 total_bytes += skb->len;
5959 total_packets++;
5960
5961 igb_rx_checksum(rx_ring, staterr, skb);
5962
5963 skb->protocol = eth_type_trans(skb, rx_ring->netdev);
5964 5966
5965 if (staterr & E1000_RXD_STAT_VP) { 5967 if (igb_test_staterr(rx_desc, E1000_RXD_STAT_VP)) {
5966 u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); 5968 u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan);
5967 5969
5968 __vlan_hwaccel_put_tag(skb, vid); 5970 __vlan_hwaccel_put_tag(skb, vid);
5969 } 5971 }
5972
5973 total_bytes += skb->len;
5974 total_packets++;
5975
5976 skb->protocol = eth_type_trans(skb, rx_ring->netdev);
5977
5970 napi_gro_receive(&q_vector->napi, skb); 5978 napi_gro_receive(&q_vector->napi, skb);
5971 5979
5972 budget--; 5980 budget--;
@@ -5983,7 +5991,6 @@ next_desc:
5983 5991
5984 /* use prefetched values */ 5992 /* use prefetched values */
5985 rx_desc = next_rxd; 5993 rx_desc = next_rxd;
5986 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
5987 } 5994 }
5988 5995
5989 rx_ring->next_to_clean = i; 5996 rx_ring->next_to_clean = i;