Added fillmeup support for the e1000 driver
authorKevin Klues <klueska@parcad.millennium.berkeley.edu>
Wed, 28 Apr 2010 05:18:42 +0000 (22:18 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:45 +0000 (17:35 -0700)
kern/arch/i686/e1000.c

index 956941b..5ae1233 100644 (file)
@@ -696,6 +696,37 @@ void e1000_handle_rx_packet() {
 
        } while ((status & E1000_RXD_STAT_EOP) == 0);
 
+#ifdef __CONFIG_OSDI__
+       struct packetizer_packet *p = (struct packetizer_packet*)rx_buffer;
+       if(ntohs(p->ethertype) == PACKETIZER_ETH_TYPE) {
+               assert(fillmeup_data.proc != NULL);
+               assert(fillmeup_data.bufs != NULL);
+               struct proc *proc = fillmeup_data.proc;
+
+               int32_t lw;
+               uint32_t backupcr3;
+               memcpy_from_user(proc, &lw, fillmeup_data.last_written, sizeof(lw));
+               lw = (lw + 1) % (fillmeup_data.num_bufs);
+               memcpy_to_user(proc, &fillmeup_data.bufs[PACKETIZER_MAX_PAYLOAD * lw], 
+                              p->payload, ntohl(p->payload_size));
+                       
+               // memcpy_to_user(proc, fillmeup_data.last_written, &lw, sizeof(lw));
+               backupcr3 = rcr3();
+               lcr3(proc->env_cr3);
+               *(fillmeup_data.last_written) = lw;
+               lcr3(backupcr3);
+               //print_packetizer_packet(p);
+               proc_notify(fillmeup_data.proc, NE_ETC_ETC_ETC, 0);
+
+               // Advance the tail pointer                             
+               e1000_rx_index = rx_des_loop_cur;
+               e1000_wr32(E1000_RDT, e1000_rx_index);
+               kfree(rx_buffer);
+               return;
+       }
+#endif
+
+#ifdef __CONFIG_APPSERVER__
        // Treat as a syscall frontend response packet if eth_type says so
        // Will eventually go away, so not too worried about elegance here...
        uint16_t eth_type = htons(*(uint16_t*)(rx_buffer + 12));
@@ -708,6 +739,7 @@ void e1000_handle_rx_packet() {
                e1000_wr32(E1000_RDT, e1000_rx_index);
                return;
        }
+#endif
 
        spin_lock(&packet_buffers_lock);