Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dl2k endianness fixes (.24 fodder?)

* shift before cpu_to_le64(), not after it
* writel() converts to l-e itself
* misc missing conversions
* in set_multicast() hash_table[] is host-endian; we feed it to card
via writel() and populate it as host-endian, so we'd better put the
first element into it also in host-endian
* pci_unmap_single() et.al. expect host-endian, not little-endian

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by

Al Viro and committed by
Jeff Garzik
78ce8d3d e5a31421

+30 -27
+27 -24
drivers/net/dl2k.c
··· 332 332 #endif 333 333 /* Read eeprom */ 334 334 for (i = 0; i < 128; i++) { 335 - ((u16 *) sromdata)[i] = le16_to_cpu (read_eeprom (ioaddr, i)); 335 + ((__le16 *) sromdata)[i] = cpu_to_le16(read_eeprom (ioaddr, i)); 336 336 } 337 337 #ifdef MEM_MAPPING 338 338 ioaddr = dev->base_addr; ··· 516 516 PCI_DMA_FROMDEVICE)); 517 517 } 518 518 np->rx_ring[entry].fraginfo |= 519 - cpu_to_le64 (np->rx_buf_sz) << 48; 519 + cpu_to_le64((u64)np->rx_buf_sz << 48); 520 520 np->rx_ring[entry].status = 0; 521 521 } /* end for */ 522 522 } /* end if */ ··· 584 584 cpu_to_le64 ( pci_map_single ( 585 585 np->pdev, skb->data, np->rx_buf_sz, 586 586 PCI_DMA_FROMDEVICE)); 587 - np->rx_ring[i].fraginfo |= cpu_to_le64 (np->rx_buf_sz) << 48; 587 + np->rx_ring[i].fraginfo |= cpu_to_le64((u64)np->rx_buf_sz << 48); 588 588 } 589 589 590 590 /* Set RFDListPtr */ 591 - writel (cpu_to_le32 (np->rx_ring_dma), dev->base_addr + RFDListPtr0); 591 + writel (np->rx_ring_dma, dev->base_addr + RFDListPtr0); 592 592 writel (0, dev->base_addr + RFDListPtr1); 593 593 594 594 return; ··· 620 620 } 621 621 #endif 622 622 if (np->vlan) { 623 - tfc_vlan_tag = 624 - cpu_to_le64 (VLANTagInsert) | 625 - (cpu_to_le64 (np->vlan) << 32) | 626 - (cpu_to_le64 (skb->priority) << 45); 623 + tfc_vlan_tag = VLANTagInsert | 624 + ((u64)np->vlan << 32) | 625 + ((u64)skb->priority << 45); 627 626 } 628 627 txdesc->fraginfo = cpu_to_le64 (pci_map_single (np->pdev, skb->data, 629 628 skb->len, 630 629 PCI_DMA_TODEVICE)); 631 - txdesc->fraginfo |= cpu_to_le64 (skb->len) << 48; 630 + txdesc->fraginfo |= cpu_to_le64((u64)skb->len << 48); 632 631 633 632 /* DL2K bug: DMA fails to get next descriptor ptr in 10Mbps mode 634 633 * Work around: Always use 1 descriptor in 10Mbps mode */ ··· 707 708 return IRQ_RETVAL(handled); 708 709 } 709 710 711 + static inline dma_addr_t desc_to_dma(struct netdev_desc *desc) 712 + { 713 + return le64_to_cpu(desc->fraginfo) & DMA_48BIT_MASK; 714 + } 715 + 710 716 static void 711 717 rio_free_tx (struct net_device *dev, int irq) 712 718 { ··· 729 725 while (entry != np->cur_tx) { 730 726 struct sk_buff *skb; 731 727 732 - if (!(np->tx_ring[entry].status & TFDDone)) 728 + if (!(np->tx_ring[entry].status & cpu_to_le64(TFDDone))) 733 729 break; 734 730 skb = np->tx_skbuff[entry]; 735 731 pci_unmap_single (np->pdev, 736 - np->tx_ring[entry].fraginfo & DMA_48BIT_MASK, 732 + desc_to_dma(&np->tx_ring[entry]), 737 733 skb->len, PCI_DMA_TODEVICE); 738 734 if (irq) 739 735 dev_kfree_skb_irq (skb); ··· 835 831 int pkt_len; 836 832 u64 frame_status; 837 833 838 - if (!(desc->status & RFDDone) || 839 - !(desc->status & FrameStart) || !(desc->status & FrameEnd)) 834 + if (!(desc->status & cpu_to_le64(RFDDone)) || 835 + !(desc->status & cpu_to_le64(FrameStart)) || 836 + !(desc->status & cpu_to_le64(FrameEnd))) 840 837 break; 841 838 842 839 /* Chip omits the CRC. */ 843 - pkt_len = le64_to_cpu (desc->status & 0xffff); 844 - frame_status = le64_to_cpu (desc->status); 840 + frame_status = le64_to_cpu(desc->status); 841 + pkt_len = frame_status & 0xffff; 845 842 if (--cnt < 0) 846 843 break; 847 844 /* Update rx error statistics, drop packet. */ ··· 862 857 /* Small skbuffs for short packets */ 863 858 if (pkt_len > copy_thresh) { 864 859 pci_unmap_single (np->pdev, 865 - desc->fraginfo & DMA_48BIT_MASK, 860 + desc_to_dma(desc), 866 861 np->rx_buf_sz, 867 862 PCI_DMA_FROMDEVICE); 868 863 skb_put (skb = np->rx_skbuff[entry], pkt_len); 869 864 np->rx_skbuff[entry] = NULL; 870 865 } else if ((skb = dev_alloc_skb (pkt_len + 2)) != NULL) { 871 866 pci_dma_sync_single_for_cpu(np->pdev, 872 - desc->fraginfo & 873 - DMA_48BIT_MASK, 867 + desc_to_dma(desc), 874 868 np->rx_buf_sz, 875 869 PCI_DMA_FROMDEVICE); 876 870 /* 16 byte align the IP header */ ··· 879 875 pkt_len); 880 876 skb_put (skb, pkt_len); 881 877 pci_dma_sync_single_for_device(np->pdev, 882 - desc->fraginfo & 883 - DMA_48BIT_MASK, 878 + desc_to_dma(desc), 884 879 np->rx_buf_sz, 885 880 PCI_DMA_FROMDEVICE); 886 881 } ··· 922 919 PCI_DMA_FROMDEVICE)); 923 920 } 924 921 np->rx_ring[entry].fraginfo |= 925 - cpu_to_le64 (np->rx_buf_sz) << 48; 922 + cpu_to_le64((u64)np->rx_buf_sz << 48); 926 923 np->rx_ring[entry].status = 0; 927 924 entry = (entry + 1) % RX_RING_SIZE; 928 925 } ··· 1124 1121 1125 1122 hash_table[0] = hash_table[1] = 0; 1126 1123 /* RxFlowcontrol DA: 01-80-C2-00-00-01. Hash index=0x39 */ 1127 - hash_table[1] |= cpu_to_le32(0x02000000); 1124 + hash_table[1] |= 0x02000000; 1128 1125 if (dev->flags & IFF_PROMISC) { 1129 1126 /* Receive all frames promiscuously. */ 1130 1127 rx_mode = ReceiveAllFrames; ··· 1765 1762 skb = np->rx_skbuff[i]; 1766 1763 if (skb) { 1767 1764 pci_unmap_single(np->pdev, 1768 - np->rx_ring[i].fraginfo & DMA_48BIT_MASK, 1765 + desc_to_dma(&np->rx_ring[i]), 1769 1766 skb->len, PCI_DMA_FROMDEVICE); 1770 1767 dev_kfree_skb (skb); 1771 1768 np->rx_skbuff[i] = NULL; ··· 1775 1772 skb = np->tx_skbuff[i]; 1776 1773 if (skb) { 1777 1774 pci_unmap_single(np->pdev, 1778 - np->tx_ring[i].fraginfo & DMA_48BIT_MASK, 1775 + desc_to_dma(&np->tx_ring[i]), 1779 1776 skb->len, PCI_DMA_TODEVICE); 1780 1777 dev_kfree_skb (skb); 1781 1778 np->tx_skbuff[i] = NULL;
+3 -3
drivers/net/dl2k.h
··· 633 633 634 634 /* The Rx and Tx buffer descriptors. */ 635 635 struct netdev_desc { 636 - u64 next_desc; 637 - u64 status; 638 - u64 fraginfo; 636 + __le64 next_desc; 637 + __le64 status; 638 + __le64 fraginfo; 639 639 }; 640 640 641 641 #define PRIV_ALIGN 15 /* Required alignment mask */