1 # Fix the Link detection in MacOS
2 # Author Alex Graf - agraf@suse
3 Index: kvm-83/qemu/hw/rtl8139.c
4 ===================================================================
5 --- kvm-83.orig/qemu/hw/rtl8139.c
6 +++ kvm-83/qemu/hw/rtl8139.c
7 @@ -422,6 +422,9 @@ static void RTL8139TallyCounters_load(QE
8 /* Saves values of tally counters to VM state file */
9 static void RTL8139TallyCounters_save(QEMUFile* f, RTL8139TallyCounters *tally_counters);
11 +static uint32_t rtl8139_io_readb(void *opaque, uint8_t addr);
12 +static uint32_t rtl8139_io_readw(void *opaque, uint8_t addr);
14 typedef struct RTL8139State {
15 uint8_t phys[8]; /* mac address */
16 uint8_t mult[8]; /* multicast mask array */
17 @@ -462,6 +465,7 @@ typedef struct RTL8139State {
25 @@ -1227,7 +1231,7 @@ static void rtl8139_reset(RTL8139State *
26 s->Config0 = 0x0; /* No boot ROM */
27 s->Config1 = 0xC; /* IO mapped and MEM mapped registers available */
28 s->Config3 = 0x1; /* fast back-to-back compatible */
30 + s->Config5 = Cfg5_LDPS;
32 s->CSCR = CSCR_F_LINK_100 | CSCR_HEART_BIT | CSCR_LD;
34 @@ -1251,6 +1255,13 @@ static void rtl8139_reset(RTL8139State *
38 + s->eeprom.contents[10] = s->Config0 | s->Config1 << 8;
39 + s->eeprom.contents[6] = (rtl8139_io_readb(s, MediaStatus) & 0xc0) | ((rtl8139_io_readw(s, BasicModeCtrl) >> 8) & 0x23)
40 + | (s->Config3 << 8);
41 + s->eeprom.contents[12] = s->Config4 << 8;
43 + s->eeprom.contents[15] = s->Config5 << 8;
45 /* reset tally counters */
46 RTL8139TallyCounters_clear(&s->tally_counters);
48 @@ -2846,7 +2857,7 @@ static uint32_t rtl8139_io_readb(void *o
53 + ret = 0xd0 | ((s->link == Link_10mbps) << 3);
54 DEBUG_PRINT(("RTL8139: MediaStatus read 0x%x\n", ret));
57 @@ -3440,6 +3451,15 @@ PCIDevice *pci_rtl8139_init(PCIBus *bus,
59 s->pci_dev = (PCIDevice *)d;
60 memcpy(s->macaddr, nd->macaddr, 6);
67 + s->link = Link_100mbps;
71 s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
72 rtl8139_receive, rtl8139_can_receive, s);
73 Index: kvm-83/qemu/net.h
74 ===================================================================
75 --- kvm-83.orig/qemu/net.h
77 @@ -57,6 +57,13 @@ void tap_using_vnet_hdr(void *opaque, in
91 @@ -64,6 +71,7 @@ struct NICInfo {
99 Index: kvm-83/qemu/net.c
100 ===================================================================
101 --- kvm-83.orig/qemu/net.c
102 +++ kvm-83/qemu/net.c
103 @@ -1721,6 +1721,7 @@ int net_client_init(const char *device,
107 + nd->link = Link_default;
110 vlan->nb_guest_devs++;