diff options
| -rw-r--r-- | driver/e1000.c | 8 | ||||
| -rw-r--r-- | net/icmp.c | 6 | ||||
| -rw-r--r-- | net/inet.c | 3 |
3 files changed, 11 insertions, 6 deletions
diff --git a/driver/e1000.c b/driver/e1000.c index 4964dd1..31e1b45 100644 --- a/driver/e1000.c +++ b/driver/e1000.c @@ -132,7 +132,7 @@ */ // buffers -#define E1000_NUM_RX_DESC 32 +#define E1000_NUM_RX_DESC 16 #define E1000_NUM_TX_DESC 8 // TODO: move all global stuff to some struct so we can run multiple e1000 cards! @@ -412,7 +412,7 @@ void txinit() void e1000_handleReceive() { - while((rx_descs[rx_cur]->status !=0)) + while((rx_descs[rx_cur]->status & 0x1 )) { uint16_t old_cur; uint8_t *buf = rx_descs[rx_cur]->addr_lo; @@ -426,6 +426,8 @@ void e1000_handleReceive() old_cur = rx_cur; rx_cur = (rx_cur + 1) % E1000_NUM_RX_DESC; writeCommand(REG_RDT, old_cur ); + klog("RDT %d",readCommand(REG_RDT)); + klog("RDH %d",readCommand(REG_RDH)); } } @@ -440,6 +442,8 @@ int e1000_sendPacket(const void * p_data, uint16_t p_len) uint8_t old_cur = tx_cur; tx_cur = (tx_cur + 1) % E1000_NUM_TX_DESC; writeCommand(REG_TDT, tx_cur); + klog("TDT %d",readCommand(REG_TDT)); + klog("TDH %d",readCommand(REG_TDH)); while(!(tx_descs[old_cur]->status & 0xff)); // TODO: seriously wait here!?!?!? return 0; } @@ -26,8 +26,8 @@ bool icmp_reply(struct netdev *dev,struct eth_hdr *hdr) data->csum=0; ipv4->csum=0; - data->csum=htons(checksum(data,ipv4->len-ipv4->ihl*4)); - ipv4->csum=htons(checksum(ipv4,ntohs(ipv4->len))); + data->csum=(checksum(data,ntohs(ipv4->len)-ipv4->ihl*4)); + ipv4->csum=(checksum(ipv4,ntohs(ipv4->len))); dev->transmit(hdr,ntohs(ipv4->len)+14); // 14bytes for link2 @@ -43,7 +43,7 @@ bool icmp_incoming(struct netdev *dev,struct eth_hdr *hdr) klog ("icmp code=%d",data->code); klog ("icmp csum=0x%04x",ntohs(data->csum)); data->csum=0; - klog("expected checksum = 0x%04X",checksum(data,ipv4->len-ipv4->ihl*4)); + klog("expected checksum = 0x%04X",checksum(data,ntohs(ipv4->len)-ipv4->ihl*4)); if(data->type==ICMP_ECHO_REQUEST) // echo request { @@ -21,7 +21,8 @@ uint16_t checksum(void *addr, int count) while( count > 1 ) { /* This is the inner loop */ - sum += ntohs(* ptr++); + //sum += ntohs(* ptr++); + sum += *ptr++; count -= 2; } |
