In Ethernet PCI device driver if the driver allows applications to map user-space buffer to Driver virtual memory and allow the user to call MMAP on device driver file after opening it. Then how do implement MMAP in the PCI ETHERNET Network device driver?
I have already looked in the dev_pci struct. There are some members that are named as they have something to do with MMAP but I could not pinpoint how to make a device driver implement MMAP.
In the book Linux Device Driver, the author did not specifically relate Memory Mapping in device driver with PCI device driver or Network device driver.
Any help on how to enable my PCI/Network/Ethernet device driver to handle MMAP calls from user space and mapping the user is given buffer into the driver's virtual memory I am looking for especially how to register XX___mmap(...)
implementation function in the device driver with PCI and network device driver. I have dev_pci and net_dev device drivers in a device driver.
vm_area_struct
and in it I have vm_start & vm_end & offset then how to write packets to virtual address of kernel mapped user buffer which I will do in poll handler of netdev_ops for receiving packets – Chitaif I use char driver with file operations for mmap
andpci driver for pci device
for ethernet device and "BOTH Combined in One driver c file" with single__init
. I guess this is the only way to do this. unless if there is any other option. Please explain – Chitae1000e
Ethernet pci device driver – Chitaint pci_mmap_page_range
function declared in pci.h for building new page in kernel virtual memory that I will be used in mmap implemented function in the driver – Chitatp = netdev_priv(dev);
private data. because I like to maintain linkedList of tcp only packets received in Napipoll
handler and to send packets just maintain another linkedList of userspace-write ethernet frames and just send insidendo_start_xmit
of netdevice – ChitaShould you find this interesting / helpful, let me know. I then should be able to elaborate a little bit on this suggestion in an answer below.
thanks for info on Packet_MMAP, actually I tried and I am getting packet frames. Now I like to add simple BPF filter to attach to my socket getting frames using PACKET_MMAP. Can u tell me about this please. Its really interesting I like to find more. can u help. thanks again – Chita