updated on Thu Jan 19 16:10:29 UTC 2012
[aur-mirror.git] / kvm-opensuse / kvm-qemu-rtl8139-link.patch
blobc318476893472d1b2f3d0de7bd23a72d44086c64
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 {
19 uint16_t CpCmd;
20 uint8_t TxThresh;
21 + enum NICLink link;
23 PCIDevice *pci_dev;
24 VLANClientState *vc;
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 */
29 - s->Config5 = 0x0;
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 *
35 s->TimerInt = 0;
36 s->TCTR_base = 0;
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
49 break;
51 case MediaStatus:
52 - ret = 0xd0;
53 + ret = 0xd0 | ((s->link == Link_10mbps) << 3);
54 DEBUG_PRINT(("RTL8139: MediaStatus read 0x%x\n", ret));
55 break;
57 @@ -3440,6 +3451,15 @@ PCIDevice *pci_rtl8139_init(PCIBus *bus,
59 s->pci_dev = (PCIDevice *)d;
60 memcpy(s->macaddr, nd->macaddr, 6);
61 + switch(nd->link) {
62 + case Link_10mbps:
63 + case Link_100mbps:
64 + s->link = nd->link;
65 + break;
66 + default:
67 + s->link = Link_100mbps;
68 + break;
69 + }
70 rtl8139_reset(s);
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
76 +++ kvm-83/qemu/net.h
77 @@ -57,6 +57,13 @@ void tap_using_vnet_hdr(void *opaque, in
79 #define MAX_NICS 8
81 +enum NICLink {
82 + Link_default,
83 + Link_10mbps,
84 + Link_100mbps,
85 + Link_1000mbps,
86 +};
88 struct NICInfo {
89 uint8_t macaddr[6];
90 const char *model;
91 @@ -64,6 +71,7 @@ struct NICInfo {
92 VLANState *vlan;
93 int devfn;
94 int used;
95 + enum NICLink link;
98 extern int nb_nics;
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,
105 nd->vlan = vlan;
106 nd->name = name;
107 + nd->link = Link_default;
108 name = NULL;
109 nb_nics++;
110 vlan->nb_guest_devs++;