title: How to communicate between Network card and the Ethernet driver?
body: <p>I am trying to build an unikernel in Rust,which will boot and start a web server. I am using <strong>Qemu</strong> for testing purposes.</p>
  
  <p>So far, I have managed to write an OS with segmentation, paging and interrupts enabled by following various blogs online and projects on github. The kernel is up and running and is able to detect software interrupts and also hardware interrupts if an interrupt of kind <code>int 32</code> is explicitly called. 
  After this I enabled IO Ports and implemented all the Port I/O functions like <code>inb</code>,<code>outb</code>,<code>inl</code>,<code>outl</code>,<code>inw</code>,<code>outw</code> that helps me to read and write to the port. I read somewhere that this is how the driver and the device communicate with each other. Using these I used the probe method to detect the peripheral devices. In qemu, 3 devices were detected. </p>
  
  <p>One of those devices is <code>Intel 82540EM Ethernet Controller</code> with device id <code>0x100e</code> and vendor id <code>0x8086</code>. I am trying to communicate with this driver to implement the transmission and reception of the packets that will complete my project. I understood that all the communication that happens between the network card and the driver happens through the device's IO ports.  </p>
  
  <p>But, I couldn't clearly understand what happens in the background. So, can someone explain me-
  <strong>How do we detect that some new packet has arrived to the Network card?</strong> </p>