Network driver ( dma, iomem.. )

Oscar Salvador osalvador.vilardaga at gmail.com
Tue Aug 5 11:49:58 EDT 2014


Hi People!, How are you doing?

I write to you because I'm writing a driver for a Realtek8139D 10/100Mbps, just for fun and for practice my knowledge.
I spent some time reading about PCI specifications, but I have some doubts about that:

1- I/O Port or I/O memory mapping ( RTL8139 has BAR0 for I/O PORT and BAR1 for I/O Memory )

        * I've read about the diferences, and since I understood, the best way to do is with memory mapping. I/O PORT has some limitations like limited instructions can be used. Do you know more about that? More diferences?
        
2- DMA and memory region

        * When I request for the I/O memory region of pci device:

                memr_start = pci_resource_start(dev, IO_MEM);
                memr_end = pci_resource_end(dev, IO_MEM);

        The memr_start is the address for reach the device and send data to him?

        * I've seen that pci_bus_master is supported by RTL8139D:

                pci_set_master(dev);
                pci_read_config_word(dev, 0x4, &is_master);
                pr_info("PCI_BUS_MASTER: %d\n", is_master);

        it returns 111b, so it can be enabled.
        Then I think I should call pci_alloc_consistent() to take a DMA address.
        This DMA address is the address of the BUS (where device is). This should be the address that I have to use for incoming/outgoing data from/to the device?

I'm a little bit stuck in these terms

Could you help me?

Best Regards
Oscar



More information about the Kernelnewbies mailing list