Commit 219fb125039e175a92aa14684ac688305b5143bd
1 parent
8ead62cf
avoid unneeded dependencies
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2041 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
21 additions
and
18 deletions
hw/pcnet.c
| @@ -29,11 +29,6 @@ | @@ -29,11 +29,6 @@ | ||
| 29 | 29 | ||
| 30 | #include "vl.h" | 30 | #include "vl.h" |
| 31 | 31 | ||
| 32 | -/* XXX: suppress those headers */ | ||
| 33 | -#include <sys/times.h> | ||
| 34 | -#include <arpa/inet.h> | ||
| 35 | -#include <net/ethernet.h> | ||
| 36 | - | ||
| 37 | //#define PCNET_DEBUG | 32 | //#define PCNET_DEBUG |
| 38 | //#define PCNET_DEBUG_IO | 33 | //#define PCNET_DEBUG_IO |
| 39 | //#define PCNET_DEBUG_BCR | 34 | //#define PCNET_DEBUG_BCR |
| @@ -70,6 +65,12 @@ struct PCNetState_st { | @@ -70,6 +65,12 @@ struct PCNetState_st { | ||
| 70 | #error FixMe | 65 | #error FixMe |
| 71 | #endif | 66 | #endif |
| 72 | 67 | ||
| 68 | +struct qemu_ether_header { | ||
| 69 | + uint8_t ether_dhost[6]; | ||
| 70 | + uint8_t ether_shost[6]; | ||
| 71 | + uint16_t ether_type; | ||
| 72 | +}; | ||
| 73 | + | ||
| 73 | /* BUS CONFIGURATION REGISTERS */ | 74 | /* BUS CONFIGURATION REGISTERS */ |
| 74 | #define BCR_MSRDA 0 | 75 | #define BCR_MSRDA 0 |
| 75 | #define BCR_MSWRA 1 | 76 | #define BCR_MSWRA 1 |
| @@ -441,7 +442,7 @@ static inline void pcnet_rmd_store(PCNetState *s, struct pcnet_RMD *rmd, target_ | @@ -441,7 +442,7 @@ static inline void pcnet_rmd_store(PCNetState *s, struct pcnet_RMD *rmd, target_ | ||
| 441 | #endif | 442 | #endif |
| 442 | 443 | ||
| 443 | #define PRINT_PKTHDR(BUF) do { \ | 444 | #define PRINT_PKTHDR(BUF) do { \ |
| 444 | - struct ether_header *hdr = (void *)(BUF); \ | 445 | + struct qemu_ether_header *hdr = (void *)(BUF); \ |
| 445 | printf("packet dhost=%02x:%02x:%02x:%02x:%02x:%02x, " \ | 446 | printf("packet dhost=%02x:%02x:%02x:%02x:%02x:%02x, " \ |
| 446 | "shost=%02x:%02x:%02x:%02x:%02x:%02x, " \ | 447 | "shost=%02x:%02x:%02x:%02x:%02x:%02x, " \ |
| 447 | "type=0x%04x (bcast=%d)\n", \ | 448 | "type=0x%04x (bcast=%d)\n", \ |
| @@ -449,7 +450,7 @@ static inline void pcnet_rmd_store(PCNetState *s, struct pcnet_RMD *rmd, target_ | @@ -449,7 +450,7 @@ static inline void pcnet_rmd_store(PCNetState *s, struct pcnet_RMD *rmd, target_ | ||
| 449 | hdr->ether_dhost[3],hdr->ether_dhost[4],hdr->ether_dhost[5], \ | 450 | hdr->ether_dhost[3],hdr->ether_dhost[4],hdr->ether_dhost[5], \ |
| 450 | hdr->ether_shost[0],hdr->ether_shost[1],hdr->ether_shost[2], \ | 451 | hdr->ether_shost[0],hdr->ether_shost[1],hdr->ether_shost[2], \ |
| 451 | hdr->ether_shost[3],hdr->ether_shost[4],hdr->ether_shost[5], \ | 452 | hdr->ether_shost[3],hdr->ether_shost[4],hdr->ether_shost[5], \ |
| 452 | - htons(hdr->ether_type), \ | 453 | + be16_to_cpu(hdr->ether_type), \ |
| 453 | !!ETHER_IS_MULTICAST(hdr->ether_dhost)); \ | 454 | !!ETHER_IS_MULTICAST(hdr->ether_dhost)); \ |
| 454 | } while (0) | 455 | } while (0) |
| 455 | 456 | ||
| @@ -462,7 +463,7 @@ static inline uint32_t lnc_mchash(const uint8_t *ether_addr) | @@ -462,7 +463,7 @@ static inline uint32_t lnc_mchash(const uint8_t *ether_addr) | ||
| 462 | int idx, bit; | 463 | int idx, bit; |
| 463 | uint8_t data; | 464 | uint8_t data; |
| 464 | 465 | ||
| 465 | - for (idx = 0; idx < ETHER_ADDR_LEN; idx++) { | 466 | + for (idx = 0; idx < 6; idx++) { |
| 466 | for (data = *ether_addr++, bit = 0; bit < MULTICAST_FILTER_LEN; bit++) { | 467 | for (data = *ether_addr++, bit = 0; bit < MULTICAST_FILTER_LEN; bit++) { |
| 467 | crc = (crc >> 1) ^ (((crc ^ data) & 1) ? LNC_POLYNOMIAL : 0); | 468 | crc = (crc >> 1) ^ (((crc ^ data) & 1) ? LNC_POLYNOMIAL : 0); |
| 468 | data >>= 1; | 469 | data >>= 1; |
| @@ -547,7 +548,7 @@ static const uint32_t crctab[256] = { | @@ -547,7 +548,7 @@ static const uint32_t crctab[256] = { | ||
| 547 | 548 | ||
| 548 | static inline int padr_match(PCNetState *s, const uint8_t *buf, int size) | 549 | static inline int padr_match(PCNetState *s, const uint8_t *buf, int size) |
| 549 | { | 550 | { |
| 550 | - struct ether_header *hdr = (void *)buf; | 551 | + struct qemu_ether_header *hdr = (void *)buf; |
| 551 | uint8_t padr[6] = { | 552 | uint8_t padr[6] = { |
| 552 | s->csr[12] & 0xff, s->csr[12] >> 8, | 553 | s->csr[12] & 0xff, s->csr[12] >> 8, |
| 553 | s->csr[13] & 0xff, s->csr[13] >> 8, | 554 | s->csr[13] & 0xff, s->csr[13] >> 8, |
| @@ -568,7 +569,7 @@ static inline int padr_match(PCNetState *s, const uint8_t *buf, int size) | @@ -568,7 +569,7 @@ static inline int padr_match(PCNetState *s, const uint8_t *buf, int size) | ||
| 568 | static inline int padr_bcast(PCNetState *s, const uint8_t *buf, int size) | 569 | static inline int padr_bcast(PCNetState *s, const uint8_t *buf, int size) |
| 569 | { | 570 | { |
| 570 | static uint8_t BCAST[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 571 | static uint8_t BCAST[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 571 | - struct ether_header *hdr = (void *)buf; | 572 | + struct qemu_ether_header *hdr = (void *)buf; |
| 572 | int result = !CSR_DRCVBC(s) && !bcmp(hdr->ether_dhost, BCAST, 6); | 573 | int result = !CSR_DRCVBC(s) && !bcmp(hdr->ether_dhost, BCAST, 6); |
| 573 | #ifdef PCNET_DEBUG_MATCH | 574 | #ifdef PCNET_DEBUG_MATCH |
| 574 | printf("padr_bcast result=%d\n", result); | 575 | printf("padr_bcast result=%d\n", result); |
| @@ -578,7 +579,7 @@ static inline int padr_bcast(PCNetState *s, const uint8_t *buf, int size) | @@ -578,7 +579,7 @@ static inline int padr_bcast(PCNetState *s, const uint8_t *buf, int size) | ||
| 578 | 579 | ||
| 579 | static inline int ladr_match(PCNetState *s, const uint8_t *buf, int size) | 580 | static inline int ladr_match(PCNetState *s, const uint8_t *buf, int size) |
| 580 | { | 581 | { |
| 581 | - struct ether_header *hdr = (void *)buf; | 582 | + struct qemu_ether_header *hdr = (void *)buf; |
| 582 | if ((*(hdr->ether_dhost)&0x01) && | 583 | if ((*(hdr->ether_dhost)&0x01) && |
| 583 | ((uint64_t *)&s->csr[8])[0] != 0LL) { | 584 | ((uint64_t *)&s->csr[8])[0] != 0LL) { |
| 584 | uint8_t ladr[8] = { | 585 | uint8_t ladr[8] = { |
| @@ -993,17 +994,18 @@ static void pcnet_receive(void *opaque, const uint8_t *buf, int size) | @@ -993,17 +994,18 @@ static void pcnet_receive(void *opaque, const uint8_t *buf, int size) | ||
| 993 | 994 | ||
| 994 | memcpy(src, buf, size); | 995 | memcpy(src, buf, size); |
| 995 | 996 | ||
| 997 | +#if 1 | ||
| 998 | + /* no need to compute the CRC */ | ||
| 999 | + src[size] = 0; | ||
| 1000 | + src[size + 1] = 0; | ||
| 1001 | + src[size + 2] = 0; | ||
| 1002 | + src[size + 3] = 0; | ||
| 1003 | + size += 4; | ||
| 1004 | +#else | ||
| 996 | /* XXX: avoid CRC generation */ | 1005 | /* XXX: avoid CRC generation */ |
| 997 | if (!CSR_ASTRP_RCV(s)) { | 1006 | if (!CSR_ASTRP_RCV(s)) { |
| 998 | uint32_t fcs = ~0; | 1007 | uint32_t fcs = ~0; |
| 999 | -#if 0 | ||
| 1000 | - uint8_t *p = s->buffer; | ||
| 1001 | - | ||
| 1002 | - ((uint32_t *)p)[0] = ((uint32_t *)p)[1] = 0xaaaaaaaa; | ||
| 1003 | - p[7] = 0xab; | ||
| 1004 | -#else | ||
| 1005 | uint8_t *p = src; | 1008 | uint8_t *p = src; |
| 1006 | -#endif | ||
| 1007 | 1009 | ||
| 1008 | while (size < 46) { | 1010 | while (size < 46) { |
| 1009 | src[size++] = 0; | 1011 | src[size++] = 0; |
| @@ -1015,6 +1017,7 @@ static void pcnet_receive(void *opaque, const uint8_t *buf, int size) | @@ -1015,6 +1017,7 @@ static void pcnet_receive(void *opaque, const uint8_t *buf, int size) | ||
| 1015 | ((uint32_t *)&src[size])[0] = htonl(fcs); | 1017 | ((uint32_t *)&src[size])[0] = htonl(fcs); |
| 1016 | size += 4; /* FCS at end of packet */ | 1018 | size += 4; /* FCS at end of packet */ |
| 1017 | } else size += 4; | 1019 | } else size += 4; |
| 1020 | +#endif | ||
| 1018 | 1021 | ||
| 1019 | #ifdef PCNET_DEBUG_MATCH | 1022 | #ifdef PCNET_DEBUG_MATCH |
| 1020 | PRINT_PKTHDR(buf); | 1023 | PRINT_PKTHDR(buf); |