From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnBF7-0001lW-BF for qemu-devel@nongnu.org; Wed, 21 May 2014 14:28:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WnBF1-0002Ep-LN for qemu-devel@nongnu.org; Wed, 21 May 2014 14:27:57 -0400 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:46540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnBF1-0002El-Ga for qemu-devel@nongnu.org; Wed, 21 May 2014 14:27:51 -0400 Received: by mail-qg0-f50.google.com with SMTP id z60so3899697qgd.9 for ; Wed, 21 May 2014 11:27:51 -0700 (PDT) From: "Gabriel L. Somlo" Date: Wed, 21 May 2014 14:27:42 -0400 Message-Id: <1400696864-22473-2-git-send-email-somlo@cmu.edu> In-Reply-To: <1400696864-22473-1-git-send-email-somlo@cmu.edu> References: <1400696864-22473-1-git-send-email-somlo@cmu.edu> Subject: [Qemu-devel] [PATCH v2 1/3] e1000: avoid relying on device id (and soon, QOM) on data path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: romain@dolbeau.org, mst@redhat.com, agraf@suse.de, stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de 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 Signed-off-by: Gabriel Somlo --- 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