From: "Gabriel L. Somlo" <gsomlo@gmail.com>
To: qemu-devel@nongnu.org
Cc: romain@dolbeau.org, mst@redhat.com, agraf@suse.de,
stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de
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 [thread overview]
Message-ID: <1400696864-22473-2-git-send-email-somlo@cmu.edu> (raw)
In-Reply-To: <1400696864-22473-1-git-send-email-somlo@cmu.edu>
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 <mst@redhat.com>
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
---
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
next prev parent reply other threads:[~2014-05-21 18:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-21 18:27 [Qemu-devel] [PATCH v2 0/3] e1000: allow model/device_id selection on command line Gabriel L. Somlo
2014-05-21 18:27 ` Gabriel L. Somlo [this message]
2014-05-21 18:27 ` [Qemu-devel] [PATCH v2 2/3] e1000: allow command-line selection of card model Gabriel L. Somlo
2014-05-21 18:27 ` [Qemu-devel] [PATCH v2 3/3] tests: e1000: test additional device IDs Gabriel L. Somlo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1400696864-22473-2-git-send-email-somlo@cmu.edu \
--to=gsomlo@gmail.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=romain@dolbeau.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).