netdev
[Top] [All Lists]

Re: r8169 with big-endian (patch)

To: "Alexandra N. Kossovsky" <sasha@xxxxxxxx>
Subject: Re: r8169 with big-endian (patch)
From: Francois Romieu <romieu@xxxxxxxxxxxxx>
Date: Wed, 5 Nov 2003 19:34:00 +0100
Cc: linux-kernel@xxxxxxxxxxxxxxx, ShuChen <shuchen@xxxxxxxxxxxxxx>, netdev@xxxxxxxxxxx
In-reply-to: <20031105104625.D26209@xxxxxxxx>; from sasha@xxxxxxxx on Wed, Nov 05, 2003 at 10:46:26AM +0300
References: <20031105104625.D26209@xxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.2.5.1i
Greetings,

Alexandra N. Kossovsky <sasha@xxxxxxxx> :
[...]
> Here is the patch to make RTL-8169 PCI Gbit ethernet card to work with
> big-endian host. The patch is against 2.4.22 kernel.

Please Cc: such patches to netdev@xxxxxxxxxxx as well as jgarzik@xxxxxxxxxx

[...]
> @@ -664,19 +675,21 @@
>       }
>  
>       tp->TxDescArrays =
> -         kmalloc(NUM_TX_DESC * sizeof (struct TxDesc) + 256, GFP_KERNEL);
> +         pci_alloc_consistent(tp->pci_dev,
> +                              NUM_TX_DESC * sizeof (struct TxDesc) + 256, 
> +                              &tp->TxDescDmaAddrs);
> -     TxPhyAddr = virt_to_bus(tp->TxDescArrays);
> -     diff = 256 - (TxPhyAddr - ((TxPhyAddr >> 8) << 8));
> -     TxPhyAddr += diff;
> +     diff = 256 - (tp->TxDescDmaAddrs - ((tp->TxDescDmaAddrs >> 8) << 8));
> +     tp->TxDescDmaAddr = tp->TxDescDmaAddrs + diff;
>       tp->TxDescArray = (struct TxDesc *) (tp->TxDescArrays + diff);

Remove the alignment stuff. pci_alloc_consistent() does it for you,
see Documentation/DMA-mapping.txt:
[...]
The cpu return address and the DMA bus master address are both
guaranteed to be aligned to the smallest PAGE_SIZE order which
is greater than or equal to the requested size.  This invariant


@@ -684,12 +697,18 @@
[...]
-       tp->RxBufferRings = kmalloc(RX_BUF_SIZE * NUM_RX_DESC, GFP_KERNEL);
+       tp->RxBufferRings = pci_alloc_consistent(tp->pci_dev,
+                                                RX_BUF_SIZE * NUM_RX_DESC,
+                                                &tp->RxBufferDmas);

You don't want consistent mapping for the data buffer.
Either you pci_map_single() the whole kmalloced() area and you sync it
when needed or you turn this code into usual, per skb, pci_map_single()
calls and you remove the big Rx data buffer.

--
Ueimor

<Prev in Thread] Current Thread [Next in Thread>