aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-04-13 07:05:07 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-13 20:10:07 -0400
commit4852a8614f63999e38539ad16615054dcd20a05d (patch)
treed26c200550fcdc957ce78f82db375861d766b40c /drivers/net
parent48fa55a0a5e20b9e2a28a72c66c7027678cae6bb (diff)
tg3: Add jumbo frame loopback tests to selftest
This patch adds jumbo frame loopback test support to the ethtool selftest. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Reviewed-by: Michael Chan <mchan@broadcom.com> Reviewed-by: Benjamin Li <benli@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/tg3.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 9975cdb38831..52dd516ba786 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -10935,7 +10935,7 @@ static int tg3_test_memory(struct tg3 *tp)
10935#define TG3_MAC_LOOPBACK 0 10935#define TG3_MAC_LOOPBACK 0
10936#define TG3_PHY_LOOPBACK 1 10936#define TG3_PHY_LOOPBACK 1
10937 10937
10938static int tg3_run_loopback(struct tg3 *tp, int loopback_mode) 10938static int tg3_run_loopback(struct tg3 *tp, u32 pktsz, int loopback_mode)
10939{ 10939{
10940 u32 mac_mode, rx_start_idx, rx_idx, tx_idx, opaque_key; 10940 u32 mac_mode, rx_start_idx, rx_idx, tx_idx, opaque_key;
10941 u32 desc_idx, coal_now; 10941 u32 desc_idx, coal_now;
@@ -11033,7 +11033,7 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
11033 11033
11034 err = -EIO; 11034 err = -EIO;
11035 11035
11036 tx_len = 1514; 11036 tx_len = pktsz;
11037 skb = netdev_alloc_skb(tp->dev, tx_len); 11037 skb = netdev_alloc_skb(tp->dev, tx_len);
11038 if (!skb) 11038 if (!skb)
11039 return -ENOMEM; 11039 return -ENOMEM;
@@ -11042,7 +11042,7 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
11042 memcpy(tx_data, tp->dev->dev_addr, 6); 11042 memcpy(tx_data, tp->dev->dev_addr, 6);
11043 memset(tx_data + 6, 0x0, 8); 11043 memset(tx_data + 6, 0x0, 8);
11044 11044
11045 tw32(MAC_RX_MTU_SIZE, tx_len + 4); 11045 tw32(MAC_RX_MTU_SIZE, tx_len + ETH_FCS_LEN);
11046 11046
11047 for (i = 14; i < tx_len; i++) 11047 for (i = 14; i < tx_len; i++)
11048 tx_data[i] = (u8) (i & 0xff); 11048 tx_data[i] = (u8) (i & 0xff);
@@ -11098,8 +11098,6 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
11098 desc = &rnapi->rx_rcb[rx_start_idx]; 11098 desc = &rnapi->rx_rcb[rx_start_idx];
11099 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; 11099 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK;
11100 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; 11100 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK;
11101 if (opaque_key != RXD_OPAQUE_RING_STD)
11102 goto out;
11103 11101
11104 if ((desc->err_vlan & RXD_ERR_MASK) != 0 && 11102 if ((desc->err_vlan & RXD_ERR_MASK) != 0 &&
11105 (desc->err_vlan != RXD_ERR_ODD_NIBBLE_RCVD_MII)) 11103 (desc->err_vlan != RXD_ERR_ODD_NIBBLE_RCVD_MII))
@@ -11109,9 +11107,20 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
11109 if (rx_len != tx_len) 11107 if (rx_len != tx_len)
11110 goto out; 11108 goto out;
11111 11109
11112 rx_skb = tpr->rx_std_buffers[desc_idx].skb; 11110 if (pktsz <= TG3_RX_STD_DMA_SZ - ETH_FCS_LEN) {
11111 if (opaque_key != RXD_OPAQUE_RING_STD)
11112 goto out;
11113
11114 rx_skb = tpr->rx_std_buffers[desc_idx].skb;
11115 map = dma_unmap_addr(&tpr->rx_std_buffers[desc_idx], mapping);
11116 } else {
11117 if (opaque_key != RXD_OPAQUE_RING_JUMBO)
11118 goto out;
11119
11120 rx_skb = tpr->rx_jmb_buffers[desc_idx].skb;
11121 map = dma_unmap_addr(&tpr->rx_jmb_buffers[desc_idx], mapping);
11122 }
11113 11123
11114 map = dma_unmap_addr(&tpr->rx_std_buffers[desc_idx], mapping);
11115 pci_dma_sync_single_for_cpu(tp->pdev, map, rx_len, PCI_DMA_FROMDEVICE); 11124 pci_dma_sync_single_for_cpu(tp->pdev, map, rx_len, PCI_DMA_FROMDEVICE);
11116 11125
11117 for (i = 14; i < tx_len; i++) { 11126 for (i = 14; i < tx_len; i++) {
@@ -11177,9 +11186,13 @@ static int tg3_test_loopback(struct tg3 *tp)
11177 CPMU_CTRL_LINK_AWARE_MODE)); 11186 CPMU_CTRL_LINK_AWARE_MODE));
11178 } 11187 }
11179 11188
11180 if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) 11189 if (tg3_run_loopback(tp, ETH_FRAME_LEN, TG3_MAC_LOOPBACK))
11181 err |= TG3_MAC_LOOPBACK_FAILED; 11190 err |= TG3_MAC_LOOPBACK_FAILED;
11182 11191
11192 if ((tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) &&
11193 tg3_run_loopback(tp, 9000 + ETH_HLEN, TG3_MAC_LOOPBACK))
11194 err |= (TG3_MAC_LOOPBACK_FAILED << 2);
11195
11183 if (tp->tg3_flags & TG3_FLAG_CPMU_PRESENT) { 11196 if (tp->tg3_flags & TG3_FLAG_CPMU_PRESENT) {
11184 tw32(TG3_CPMU_CTRL, cpmuctrl); 11197 tw32(TG3_CPMU_CTRL, cpmuctrl);
11185 11198
@@ -11189,8 +11202,11 @@ static int tg3_test_loopback(struct tg3 *tp)
11189 11202
11190 if (!(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) && 11203 if (!(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) &&
11191 !(tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB)) { 11204 !(tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB)) {
11192 if (tg3_run_loopback(tp, TG3_PHY_LOOPBACK)) 11205 if (tg3_run_loopback(tp, ETH_FRAME_LEN, TG3_PHY_LOOPBACK))
11193 err |= TG3_PHY_LOOPBACK_FAILED; 11206 err |= TG3_PHY_LOOPBACK_FAILED;
11207 if ((tp->tg3_flags & TG3_FLAG_JUMBO_RING_ENABLE) &&
11208 tg3_run_loopback(tp, 9000 + ETH_HLEN, TG3_PHY_LOOPBACK))
11209 err |= (TG3_PHY_LOOPBACK_FAILED << 2);
11194 } 11210 }
11195 11211
11196 /* Re-enable gphy autopowerdown. */ 11212 /* Re-enable gphy autopowerdown. */