[PATCH] Linux Device Driver for Xilinx LL TEMAC 10/100/1000 Ethernet NIC

Sergey Temerkhanov temerkhanov at yandex.ru
Sat Aug 23 02:10:34 EST 2008


On Tuesday 19 August 2008 13:34:04 David H. Lynch Jr. wrote:
> Pass II

> +       cur_p->phys = (unsigned char *)pci_map_single(NULL,
> +                       skb->data, skb->len,
> +                       PCI_DMA_TODEVICE);
> +       cur_p->app4 = (unsigned long)skb;
> +
> +       for (ii = 0; ii < num_frag; ii++) {
> +               lp->tx_bd_tail++;
> +               if (lp->tx_bd_tail >= TX_BD_NUM)
> +                       lp->tx_bd_tail = 0;
> +
> +               cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
> +               cur_p->phys = (unsigned char *)pci_map_single(NULL,
> +                               (void *)page_address(frag->page)
> +                               + frag->page_offset,
> +                               frag->size,
> +                               PCI_DMA_TODEVICE);

1. Why is pci_* API is used instead of dma_*?
2. Why pci_map_single() in skb_shinfo(skb)->frags processing instead of 
dma_map_page()?

> +               if (ii == (TX_BD_NUM - 1))
> +                       lp->tx_bd_v[ii].next = &lp->tx_bd_p[0];
> +               else
> +                       lp->tx_bd_v[ii].next = &lp->tx_bd_p[ii + 1];

3. It would be much simpler to use masking by (TX_BD_NUM - 1) instead of  "if 
(ii == (TX_BD_NUM - 1))" constructs.

4. There is a need of global locking mechanism for indirect registers access, 
as according to Xilinx documentation only one hard core at a a time can be 
accessed.


More information about the Linuxppc-embedded mailing list