aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2012-02-08 02:50:09 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-03-12 23:56:52 -0400
commit3832b26e49ad9e585239b32f763c31679f9e41fe (patch)
tree2b3bff5e5bac2b5150e91c5fac410322898fc493
parenta557928e26b08496c8f4b6c04e3838ad8048ad85 (diff)
ixgbe: Simplify logic for ethtool loopback frame creation and testing
This change makes it a bit easier to do the loopback frame creating and testing. Previously we were doing an and to drop the last bit, and then dividing the frame_size by 2 in order to get locations for frame bytes and testing. Instead we can simplify it by just shifting the register one bit to the right and using that for the frame offsets. This change also replaces all instances of rx_buffer_info with just rx_buffer since that is closer to the name of the actual structure being used and can save a few extra characters. In addition I have updated the logic for cleaning up a test frame so that we pass an rx_buffer instead of the sk_buff. The main motivation behind this is changes that will replace the sk_buff with just a page in the future. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Tested-by: Stephen Ko <stephen.s.ko@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 51d159b130b3..1216bae913e3 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -1701,63 +1701,65 @@ static void ixgbe_loopback_cleanup(struct ixgbe_adapter *adapter)
1701} 1701}
1702 1702
1703static void ixgbe_create_lbtest_frame(struct sk_buff *skb, 1703static void ixgbe_create_lbtest_frame(struct sk_buff *skb,
1704 unsigned int frame_size) 1704 unsigned int frame_size)
1705{ 1705{
1706 memset(skb->data, 0xFF, frame_size); 1706 memset(skb->data, 0xFF, frame_size);
1707 frame_size &= ~1; 1707 frame_size >>= 1;
1708 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1); 1708 memset(&skb->data[frame_size], 0xAA, frame_size / 2 - 1);
1709 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1); 1709 memset(&skb->data[frame_size + 10], 0xBE, 1);
1710 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1); 1710 memset(&skb->data[frame_size + 12], 0xAF, 1);
1711} 1711}
1712 1712
1713static int ixgbe_check_lbtest_frame(struct sk_buff *skb, 1713static bool ixgbe_check_lbtest_frame(struct ixgbe_rx_buffer *rx_buffer,
1714 unsigned int frame_size) 1714 unsigned int frame_size)
1715{ 1715{
1716 frame_size &= ~1; 1716 unsigned char *data;
1717 if (*(skb->data + 3) == 0xFF) { 1717 bool match = true;
1718 if ((*(skb->data + frame_size / 2 + 10) == 0xBE) && 1718
1719 (*(skb->data + frame_size / 2 + 12) == 0xAF)) { 1719 frame_size >>= 1;
1720 return 0; 1720
1721 } 1721 data = rx_buffer->skb->data;
1722 } 1722
1723 return 13; 1723 if (data[3] != 0xFF ||
1724 data[frame_size + 10] != 0xBE ||
1725 data[frame_size + 12] != 0xAF)
1726 match = false;
1727
1728 return match;
1724} 1729}
1725 1730
1726static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring, 1731static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring,
1727 struct ixgbe_ring *tx_ring, 1732 struct ixgbe_ring *tx_ring,
1728 unsigned int size) 1733 unsigned int size)
1729{ 1734{
1730 union ixgbe_adv_rx_desc *rx_desc; 1735 union ixgbe_adv_rx_desc *rx_desc;
1731 struct ixgbe_rx_buffer *rx_buffer_info; 1736 struct ixgbe_rx_buffer *rx_buffer;
1732 struct ixgbe_tx_buffer *tx_buffer_info; 1737 struct ixgbe_tx_buffer *tx_buffer;
1733 const int bufsz = rx_ring->rx_buf_len;
1734 u32 staterr;
1735 u16 rx_ntc, tx_ntc, count = 0; 1738 u16 rx_ntc, tx_ntc, count = 0;
1736 1739
1737 /* initialize next to clean and descriptor values */ 1740 /* initialize next to clean and descriptor values */
1738 rx_ntc = rx_ring->next_to_clean; 1741 rx_ntc = rx_ring->next_to_clean;
1739 tx_ntc = tx_ring->next_to_clean; 1742 tx_ntc = tx_ring->next_to_clean;
1740 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ntc); 1743 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ntc);
1741 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
1742 1744
1743 while (staterr & IXGBE_RXD_STAT_DD) { 1745 while (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_DD)) {
1744 /* check Rx buffer */ 1746 /* check Rx buffer */
1745 rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc]; 1747 rx_buffer = &rx_ring->rx_buffer_info[rx_ntc];
1746 1748
1747 /* unmap Rx buffer, will be remapped by alloc_rx_buffers */ 1749 /* unmap Rx buffer, will be remapped by alloc_rx_buffers */
1748 dma_unmap_single(rx_ring->dev, 1750 dma_unmap_single(rx_ring->dev,
1749 rx_buffer_info->dma, 1751 rx_buffer->dma,
1750 bufsz, 1752 rx_ring->rx_buf_len,
1751 DMA_FROM_DEVICE); 1753 DMA_FROM_DEVICE);
1752 rx_buffer_info->dma = 0; 1754 rx_buffer->dma = 0;
1753 1755
1754 /* verify contents of skb */ 1756 /* verify contents of skb */
1755 if (!ixgbe_check_lbtest_frame(rx_buffer_info->skb, size)) 1757 if (ixgbe_check_lbtest_frame(rx_buffer, size))
1756 count++; 1758 count++;
1757 1759
1758 /* unmap buffer on Tx side */ 1760 /* unmap buffer on Tx side */
1759 tx_buffer_info = &tx_ring->tx_buffer_info[tx_ntc]; 1761 tx_buffer = &tx_ring->tx_buffer_info[tx_ntc];
1760 ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer_info); 1762 ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer);
1761 1763
1762 /* increment Rx/Tx next to clean counters */ 1764 /* increment Rx/Tx next to clean counters */
1763 rx_ntc++; 1765 rx_ntc++;
@@ -1769,7 +1771,6 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring,
1769 1771
1770 /* fetch next descriptor */ 1772 /* fetch next descriptor */
1771 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ntc); 1773 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ntc);
1772 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
1773 } 1774 }
1774 1775
1775 /* re-map buffers to ring, store next to clean values */ 1776 /* re-map buffers to ring, store next to clean values */