Commit 219fb125039e175a92aa14684ac688305b5143bd

Authored by bellard
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 29  
30 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 32 //#define PCNET_DEBUG
38 33 //#define PCNET_DEBUG_IO
39 34 //#define PCNET_DEBUG_BCR
... ... @@ -70,6 +65,12 @@ struct PCNetState_st {
70 65 #error FixMe
71 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 74 /* BUS CONFIGURATION REGISTERS */
74 75 #define BCR_MSRDA 0
75 76 #define BCR_MSWRA 1
... ... @@ -441,7 +442,7 @@ static inline void pcnet_rmd_store(PCNetState *s, struct pcnet_RMD *rmd, target_
441 442 #endif
442 443  
443 444 #define PRINT_PKTHDR(BUF) do { \
444   - struct ether_header *hdr = (void *)(BUF); \
  445 + struct qemu_ether_header *hdr = (void *)(BUF); \
445 446 printf("packet dhost=%02x:%02x:%02x:%02x:%02x:%02x, " \
446 447 "shost=%02x:%02x:%02x:%02x:%02x:%02x, " \
447 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 450 hdr->ether_dhost[3],hdr->ether_dhost[4],hdr->ether_dhost[5], \
450 451 hdr->ether_shost[0],hdr->ether_shost[1],hdr->ether_shost[2], \
451 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 454 !!ETHER_IS_MULTICAST(hdr->ether_dhost)); \
454 455 } while (0)
455 456  
... ... @@ -462,7 +463,7 @@ static inline uint32_t lnc_mchash(const uint8_t *ether_addr)
462 463 int idx, bit;
463 464 uint8_t data;
464 465  
465   - for (idx = 0; idx < ETHER_ADDR_LEN; idx++) {
  466 + for (idx = 0; idx < 6; idx++) {
466 467 for (data = *ether_addr++, bit = 0; bit < MULTICAST_FILTER_LEN; bit++) {
467 468 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? LNC_POLYNOMIAL : 0);
468 469 data >>= 1;
... ... @@ -547,7 +548,7 @@ static const uint32_t crctab[256] = {
547 548  
548 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 552 uint8_t padr[6] = {
552 553 s->csr[12] & 0xff, s->csr[12] >> 8,
553 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 569 static inline int padr_bcast(PCNetState *s, const uint8_t *buf, int size)
569 570 {
570 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 573 int result = !CSR_DRCVBC(s) && !bcmp(hdr->ether_dhost, BCAST, 6);
573 574 #ifdef PCNET_DEBUG_MATCH
574 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 579  
579 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 583 if ((*(hdr->ether_dhost)&0x01) &&
583 584 ((uint64_t *)&s->csr[8])[0] != 0LL) {
584 585 uint8_t ladr[8] = {
... ... @@ -993,17 +994,18 @@ static void pcnet_receive(void *opaque, const uint8_t *buf, int size)
993 994  
994 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 1005 /* XXX: avoid CRC generation */
997 1006 if (!CSR_ASTRP_RCV(s)) {
998 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 1008 uint8_t *p = src;
1006   -#endif
1007 1009  
1008 1010 while (size < 46) {
1009 1011 src[size++] = 0;
... ... @@ -1015,6 +1017,7 @@ static void pcnet_receive(void *opaque, const uint8_t *buf, int size)
1015 1017 ((uint32_t *)&src[size])[0] = htonl(fcs);
1016 1018 size += 4; /* FCS at end of packet */
1017 1019 } else size += 4;
  1020 +#endif
1018 1021  
1019 1022 #ifdef PCNET_DEBUG_MATCH
1020 1023 PRINT_PKTHDR(buf);
... ...