[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/3] e1000: avoid relying on device id (and soon,
From: |
Gabriel L. Somlo |
Subject: |
[Qemu-devel] [PATCH v2 1/3] e1000: avoid relying on device id (and soon, QOM) on data path |
Date: |
Wed, 21 May 2014 14:27:42 -0400 |
Introduce "is_8257x" boolean flag to E1000State, and set it during
pci_e1000_init(), to avoid having to dynamically figure out device_id
during set_interrupt_cause(). This will come in handy once we have
a wider range of possible device IDs, and begin using QOM.
Suggested-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Gabriel Somlo <address@hidden>
---
hw/net/e1000.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 8387443..1b8c513 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -149,6 +149,8 @@ typedef struct E1000State_st {
#define E1000_FLAG_AUTONEG (1 << E1000_FLAG_AUTONEG_BIT)
#define E1000_FLAG_MIT (1 << E1000_FLAG_MIT_BIT)
uint32_t compat_flags;
+
+ bool is_8257x;
} E1000State;
#define TYPE_E1000 "e1000"
@@ -272,7 +274,7 @@ set_interrupt_cause(E1000State *s, int index, uint32_t val)
uint32_t pending_ints;
uint32_t mit_delay;
- if (val && (E1000_DEVID >= E1000_DEV_ID_82547EI_MOBILE)) {
+ if (val && s->is_8257x) {
/* Only for 8257x */
val |= E1000_ICR_INT_ASSERTED;
}
@@ -1503,6 +1505,32 @@ static NetClientInfo net_e1000_info = {
.link_status_changed = e1000_set_link_status,
};
+static inline bool
+e1000_is_8257x(uint16_t device_id)
+{
+ switch (device_id) {
+ case E1000_DEV_ID_82571EB_COPPER:
+ case E1000_DEV_ID_82571EB_FIBER:
+ case E1000_DEV_ID_82571EB_SERDES:
+ case E1000_DEV_ID_82571EB_QUAD_COPPER:
+ case E1000_DEV_ID_82571PT_QUAD_COPPER:
+ case E1000_DEV_ID_82571EB_QUAD_FIBER:
+ case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
+ case E1000_DEV_ID_82571EB_SERDES_DUAL:
+ case E1000_DEV_ID_82571EB_SERDES_QUAD:
+ case E1000_DEV_ID_82572EI_COPPER:
+ case E1000_DEV_ID_82572EI_FIBER:
+ case E1000_DEV_ID_82572EI_SERDES:
+ case E1000_DEV_ID_82572EI:
+ case E1000_DEV_ID_82573E:
+ case E1000_DEV_ID_82573E_IAMT:
+ case E1000_DEV_ID_82573L:
+ return true;
+ default:
+ return false;
+ }
+}
+
static int pci_e1000_init(PCIDevice *pci_dev)
{
DeviceState *dev = DEVICE(pci_dev);
@@ -1546,6 +1574,8 @@ static int pci_e1000_init(PCIDevice *pci_dev)
d->autoneg_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, e1000_autoneg_timer,
d);
d->mit_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, e1000_mit_timer, d);
+ d->is_8257x = e1000_is_8257x(pdc->device_id);
+
return 0;
}
--
1.9.0
- [Qemu-devel] [PATCH v2 0/3] e1000: allow model/device_id selection on command line, Gabriel L. Somlo, 2014/05/21
- [Qemu-devel] [PATCH v2 1/3] e1000: avoid relying on device id (and soon, QOM) on data path,
Gabriel L. Somlo <=
- [Qemu-devel] [PATCH v2 3/3] tests: e1000: test additional device IDs, Gabriel L. Somlo, 2014/05/21
- Re: [Qemu-devel] [ping: PATCH v2 0/3] e1000: allow model/device_id selection on command line, Gabriel L. Somlo, 2014/05/27
- Re: [Qemu-devel] [PATCH v2 0/3] e1000: allow model/device_id selection on command line, Michael S. Tsirkin, 2014/05/27