diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2007-10-14 14:41:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-14 15:41:52 -0400 |
commit | 325a80715f6dba4b12479f8bb011d96093a47374 (patch) | |
tree | 4c262402f52ea91379acda114d7b8dc47f175cc4 | |
parent | 857e37dc367142f25836fac42e045f08114bd4be (diff) |
ipg: endianness fixes
if your mask is host-endian, you should apply it after le64_to_cpu();
if it's little-endian - before. Doing both (for the same mask and
little-endian value) is broken.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/net/ipg.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c index 59898ce54dcf..68887235d7e9 100644 --- a/drivers/net/ipg.c +++ b/drivers/net/ipg.c | |||
@@ -754,7 +754,7 @@ static int init_rfdlist(struct net_device *dev) | |||
754 | 754 | ||
755 | if (sp->RxBuff[i]) { | 755 | if (sp->RxBuff[i]) { |
756 | pci_unmap_single(sp->pdev, | 756 | pci_unmap_single(sp->pdev, |
757 | le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), | 757 | le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, |
758 | sp->rx_buf_sz, PCI_DMA_FROMDEVICE); | 758 | sp->rx_buf_sz, PCI_DMA_FROMDEVICE); |
759 | IPG_DEV_KFREE_SKB(sp->RxBuff[i]); | 759 | IPG_DEV_KFREE_SKB(sp->RxBuff[i]); |
760 | sp->RxBuff[i] = NULL; | 760 | sp->RxBuff[i] = NULL; |
@@ -871,7 +871,7 @@ static void ipg_nic_txfree(struct net_device *dev) | |||
871 | /* Free the transmit buffer. */ | 871 | /* Free the transmit buffer. */ |
872 | if (skb) { | 872 | if (skb) { |
873 | pci_unmap_single(sp->pdev, | 873 | pci_unmap_single(sp->pdev, |
874 | le64_to_cpu(txfd->frag_info & ~IPG_TFI_FRAGLEN), | 874 | le64_to_cpu(txfd->frag_info) & ~IPG_TFI_FRAGLEN, |
875 | skb->len, PCI_DMA_TODEVICE); | 875 | skb->len, PCI_DMA_TODEVICE); |
876 | 876 | ||
877 | IPG_DEV_KFREE_SKB(skb); | 877 | IPG_DEV_KFREE_SKB(skb); |
@@ -1413,10 +1413,10 @@ static int ipg_nic_rx(struct net_device *dev) | |||
1413 | framelen = IPG_RXFRAG_SIZE; | 1413 | framelen = IPG_RXFRAG_SIZE; |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | if ((IPG_DROP_ON_RX_ETH_ERRORS && (le64_to_cpu(rxfd->rfs & | 1416 | if ((IPG_DROP_ON_RX_ETH_ERRORS && (le64_to_cpu(rxfd->rfs) & |
1417 | (IPG_RFS_RXFIFOOVERRUN | IPG_RFS_RXRUNTFRAME | | 1417 | (IPG_RFS_RXFIFOOVERRUN | IPG_RFS_RXRUNTFRAME | |
1418 | IPG_RFS_RXALIGNMENTERROR | IPG_RFS_RXFCSERROR | | 1418 | IPG_RFS_RXALIGNMENTERROR | IPG_RFS_RXFCSERROR | |
1419 | IPG_RFS_RXOVERSIZEDFRAME | IPG_RFS_RXLENGTHERROR))))) { | 1419 | IPG_RFS_RXOVERSIZEDFRAME | IPG_RFS_RXLENGTHERROR)))) { |
1420 | 1420 | ||
1421 | IPG_DEBUG_MSG("Rx error, RFS = %16.16lx\n", | 1421 | IPG_DEBUG_MSG("Rx error, RFS = %16.16lx\n", |
1422 | (unsigned long int) rxfd->rfs); | 1422 | (unsigned long int) rxfd->rfs); |
@@ -1425,27 +1425,27 @@ static int ipg_nic_rx(struct net_device *dev) | |||
1425 | sp->stats.rx_errors++; | 1425 | sp->stats.rx_errors++; |
1426 | 1426 | ||
1427 | /* Increment detailed receive error statistics. */ | 1427 | /* Increment detailed receive error statistics. */ |
1428 | if (le64_to_cpu(rxfd->rfs & IPG_RFS_RXFIFOOVERRUN)) { | 1428 | if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFIFOOVERRUN) { |
1429 | IPG_DEBUG_MSG("RX FIFO overrun occured.\n"); | 1429 | IPG_DEBUG_MSG("RX FIFO overrun occured.\n"); |
1430 | sp->stats.rx_fifo_errors++; | 1430 | sp->stats.rx_fifo_errors++; |
1431 | } | 1431 | } |
1432 | 1432 | ||
1433 | if (le64_to_cpu(rxfd->rfs & IPG_RFS_RXRUNTFRAME)) { | 1433 | if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXRUNTFRAME) { |
1434 | IPG_DEBUG_MSG("RX runt occured.\n"); | 1434 | IPG_DEBUG_MSG("RX runt occured.\n"); |
1435 | sp->stats.rx_length_errors++; | 1435 | sp->stats.rx_length_errors++; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | if (le64_to_cpu(rxfd->rfs & IPG_RFS_RXOVERSIZEDFRAME)) ; | 1438 | if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXOVERSIZEDFRAME) ; |
1439 | /* Do nothing, error count handled by a IPG | 1439 | /* Do nothing, error count handled by a IPG |
1440 | * statistic register. | 1440 | * statistic register. |
1441 | */ | 1441 | */ |
1442 | 1442 | ||
1443 | if (le64_to_cpu(rxfd->rfs & IPG_RFS_RXALIGNMENTERROR)) { | 1443 | if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXALIGNMENTERROR) { |
1444 | IPG_DEBUG_MSG("RX alignment error occured.\n"); | 1444 | IPG_DEBUG_MSG("RX alignment error occured.\n"); |
1445 | sp->stats.rx_frame_errors++; | 1445 | sp->stats.rx_frame_errors++; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | if (le64_to_cpu(rxfd->rfs & IPG_RFS_RXFCSERROR)) ; | 1448 | if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFCSERROR) ; |
1449 | /* Do nothing, error count handled by a IPG | 1449 | /* Do nothing, error count handled by a IPG |
1450 | * statistic register. | 1450 | * statistic register. |
1451 | */ | 1451 | */ |
@@ -1455,10 +1455,10 @@ static int ipg_nic_rx(struct net_device *dev) | |||
1455 | * not pass it to higher layer processes. | 1455 | * not pass it to higher layer processes. |
1456 | */ | 1456 | */ |
1457 | if (skb) { | 1457 | if (skb) { |
1458 | u64 info = rxfd->frag_info; | 1458 | __le64 info = rxfd->frag_info; |
1459 | 1459 | ||
1460 | pci_unmap_single(sp->pdev, | 1460 | pci_unmap_single(sp->pdev, |
1461 | le64_to_cpu(info & ~IPG_RFI_FRAGLEN), | 1461 | le64_to_cpu(info) & ~IPG_RFI_FRAGLEN, |
1462 | sp->rx_buf_sz, PCI_DMA_FROMDEVICE); | 1462 | sp->rx_buf_sz, PCI_DMA_FROMDEVICE); |
1463 | 1463 | ||
1464 | IPG_DEV_KFREE_SKB(skb); | 1464 | IPG_DEV_KFREE_SKB(skb); |
@@ -1532,9 +1532,9 @@ static int ipg_nic_rx(struct net_device *dev) | |||
1532 | if (!i) | 1532 | if (!i) |
1533 | sp->EmptyRFDListCount++; | 1533 | sp->EmptyRFDListCount++; |
1534 | #endif | 1534 | #endif |
1535 | while ((le64_to_cpu(rxfd->rfs & IPG_RFS_RFDDONE)) && | 1535 | while ((le64_to_cpu(rxfd->rfs) & IPG_RFS_RFDDONE) && |
1536 | !((le64_to_cpu(rxfd->rfs & IPG_RFS_FRAMESTART)) && | 1536 | !((le64_to_cpu(rxfd->rfs) & IPG_RFS_FRAMESTART) && |
1537 | (le64_to_cpu(rxfd->rfs & IPG_RFS_FRAMEEND)))) { | 1537 | (le64_to_cpu(rxfd->rfs) & IPG_RFS_FRAMEEND))) { |
1538 | unsigned int entry = curr++ % IPG_RFDLIST_LENGTH; | 1538 | unsigned int entry = curr++ % IPG_RFDLIST_LENGTH; |
1539 | 1539 | ||
1540 | rxfd = sp->rxd + entry; | 1540 | rxfd = sp->rxd + entry; |
@@ -1552,7 +1552,7 @@ static int ipg_nic_rx(struct net_device *dev) | |||
1552 | */ | 1552 | */ |
1553 | if (sp->RxBuff[entry]) { | 1553 | if (sp->RxBuff[entry]) { |
1554 | pci_unmap_single(sp->pdev, | 1554 | pci_unmap_single(sp->pdev, |
1555 | le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), | 1555 | le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, |
1556 | sp->rx_buf_sz, PCI_DMA_FROMDEVICE); | 1556 | sp->rx_buf_sz, PCI_DMA_FROMDEVICE); |
1557 | IPG_DEV_KFREE_SKB(sp->RxBuff[entry]); | 1557 | IPG_DEV_KFREE_SKB(sp->RxBuff[entry]); |
1558 | } | 1558 | } |
@@ -1730,7 +1730,7 @@ static void ipg_rx_clear(struct ipg_nic_private *sp) | |||
1730 | IPG_DEV_KFREE_SKB(sp->RxBuff[i]); | 1730 | IPG_DEV_KFREE_SKB(sp->RxBuff[i]); |
1731 | sp->RxBuff[i] = NULL; | 1731 | sp->RxBuff[i] = NULL; |
1732 | pci_unmap_single(sp->pdev, | 1732 | pci_unmap_single(sp->pdev, |
1733 | le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), | 1733 | le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, |
1734 | sp->rx_buf_sz, PCI_DMA_FROMDEVICE); | 1734 | sp->rx_buf_sz, PCI_DMA_FROMDEVICE); |
1735 | } | 1735 | } |
1736 | } | 1736 | } |
@@ -1745,7 +1745,7 @@ static void ipg_tx_clear(struct ipg_nic_private *sp) | |||
1745 | struct ipg_tx *txfd = sp->txd + i; | 1745 | struct ipg_tx *txfd = sp->txd + i; |
1746 | 1746 | ||
1747 | pci_unmap_single(sp->pdev, | 1747 | pci_unmap_single(sp->pdev, |
1748 | le64_to_cpu(txfd->frag_info & ~IPG_TFI_FRAGLEN), | 1748 | le64_to_cpu(txfd->frag_info) & ~IPG_TFI_FRAGLEN, |
1749 | sp->TxBuff[i]->len, PCI_DMA_TODEVICE); | 1749 | sp->TxBuff[i]->len, PCI_DMA_TODEVICE); |
1750 | 1750 | ||
1751 | IPG_DEV_KFREE_SKB(sp->TxBuff[i]); | 1751 | IPG_DEV_KFREE_SKB(sp->TxBuff[i]); |