> You should start by looking at and copying an existing, working > driver. bnx2x and ixgbe are examples for some current hardware, but > they are big and complicated. e100 is older but simpler. A > networking person could give better advice. Thank you Bjorn.. This is really helpful. I'll go through the examples you've suggested. > The BAR determines the size in MMIO space. I'm not sure what you mean > by "have only 128MB at my disposal." If you have limited virtual > memory space and your driver doesn't need the whole MMIO region, you > can just map the part you need. > Yes. I had limited virtual memory space. Thanks for explaining that I can map just selective parts. I didn't know that. I was thinking all or none. > pci_iomap() is a good place to start. That gives you an __iomem > address that you can then pass to ioread*() and iowrite*() to access > the MMIO region. It maps the entire region, so if you need less, > you'd probably use ioremap() directly. > Thanks so much. You're really helpful. Now I have an idea what kernel calls I should be looking at. Thank you so much!! Best Regards, Marc On Wed, Mar 26, 2014 at 10:58 PM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote: > On Wed, Mar 26, 2014 at 5:50 AM, Bob Biloxi <iambobbiloxi@xxxxxxxxx> wrote: >> Hi All, >> >> I am writing a driver for PCIe network device. I am still trying to >> learn, so my question might be like a simple one as I do not >> understand most of the things. > > You should start by looking at and copying an existing, working > driver. bnx2x and ixgbe are examples for some current hardware, but > they are big and complicated. e100 is older but simpler. A > networking person could give better advice. > >> From the BAR0 address that I read, the memory size is around 256MB. >> But I have only 128MB at my disposal. > > The BAR determines the size in MMIO space. I'm not sure what you mean > by "have only 128MB at my disposal." If you have limited virtual > memory space and your driver doesn't need the whole MMIO region, you > can just map the part you need. > >> So my question is how do i map this BAR so as to access the MMIO region. > > pci_iomap() is a good place to start. That gives you an __iomem > address that you can then pass to ioread*() and iowrite*() to access > the MMIO region. It maps the entire region, so if you need less, > you'd probably use ioremap() directly. > > Bjorn -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html