[U-Boot] [PATCH 7/9] net: tsec: Use portable types and accessors for BDs
Scott Wood
scottwood at freescale.com
Tue Oct 1 01:22:47 CEST 2013
On Mon, 2013-09-30 at 12:44 +0300, Claudiu Manoil wrote:
> +static RTXBD rtx __aligned(8);
> +#define RXBD(i) rtx.rxbd[i]
> +#define TXBD(i) rtx.txbd[i]
> +#define GET_BD_STAT(T, i) be16_to_cpu((__force __be16)T##BD(i).status)
> +#define SET_BD_STAT(T, i, v) T##BD(i).status = (__force __u16)cpu_to_be16(v)
> +#define GET_BD_BLEN(T, i) be16_to_cpu((__force __be16)T##BD(i).length)
> +#define SET_BD_BLEN(T, i, v) T##BD(i).length = (__force __u16)cpu_to_be16(v)
> +#define GET_BD_BPTR(T, i) be32_to_cpu((__force __be32)T##BD(i).bufptr)
> +#define SET_BD_BPTR(T, i, v) T##BD(i).bufptr = (__force __u32)cpu_to_be32(v)
Why the forcing? Can't you declare the data with __be16/__be32?
> #else
> #error "rtx must be 64-bit aligned"
> #endif
> @@ -275,10 +283,11 @@ void redundant_init(struct eth_device *dev)
> clrbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
>
> do {
> + uint16_t status;
> tsec_send(dev, (void *)pkt, sizeof(pkt));
>
> /* Wait for buffer to be received */
> - for (t = 0; rtx.rxbd[rx_idx].status & RXBD_EMPTY; t++) {
> + for (t = 0; GET_BD_STAT(RX, rx_idx) & RXBD_EMPTY; t++) {
What's wrong with:
for (t = 0; in_be16(&rtx.rxbd[rx_idx].status) & RXBD_EMPTY; t++) {
Or if you don't want to use I/O accessors on the DMA descriptors (Is
synchronization ensured some other way? We had problems with this in
the Linux driver before...):
for (t = 0; be16_to_cpup(&rtx.rxbd[rx_idx].status) & RXBD_EMPTY; t++) {
-Scott
More information about the U-Boot
mailing list