qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items
@ 2014-08-06 18:07 Gabriel L. Somlo
  2014-08-06 18:07 ` [Qemu-devel] [PATCH 1/2] e1000: correctly handle phy_ctrl reserved & self-clearing bits Gabriel L. Somlo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gabriel L. Somlo @ 2014-08-06 18:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, mst

Michael,

As discussed earlier here are my e1000 phy_ctrl and phy_status
cleanup patches we decided to delay until after the 2.1 release.

Thanks,
  Gabriel

Gabriel L. Somlo (2):
  e1000: correctly handle phy_ctrl reserved & self-clearing bits
  e1000: use symbolic constants to init phy ctrl & status registers

 hw/net/e1000.c | 60 ++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 20 deletions(-)

-- 
1.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 1/2] e1000: correctly handle phy_ctrl reserved & self-clearing bits
  2014-08-06 18:07 [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items Gabriel L. Somlo
@ 2014-08-06 18:07 ` Gabriel L. Somlo
  2014-08-06 18:07 ` [Qemu-devel] [PATCH 2/2] e1000: use symbolic constants to init phy ctrl & status registers Gabriel L. Somlo
  2014-08-06 21:25 ` [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items Michael S. Tsirkin
  2 siblings, 0 replies; 4+ messages in thread
From: Gabriel L. Somlo @ 2014-08-06 18:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, mst

Make phyreg_writeops responsible for actually writing their
respective phy registers, rather than rely on set_mdic() to
do it on their behalf.

The only current instance of phyreg_writeops is set_phy_ctrl();
modify it to write the register on its own, while also correctly
handling reserved and self-clearing bits.

have_autoneg() does not need to check for MII_CR_RESTART_AUTO_NEG,
since the only time the flag comes into play is during set_phy_ctrl(),
and, following this patch, never actually gets written to the phy
control register.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/net/e1000.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 0fc29a0..04c0f91 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -186,21 +186,31 @@ e1000_link_up(E1000State *s)
     s->phy_reg[PHY_STATUS] |= MII_SR_LINK_STATUS;
 }
 
+static bool
+have_autoneg(E1000State *s)
+{
+    return (s->compat_flags & E1000_FLAG_AUTONEG) &&
+           (s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN);
+}
+
 static void
 set_phy_ctrl(E1000State *s, int index, uint16_t val)
 {
+    /* bits 0-5 reserved; MII_CR_[RESTART_AUTO_NEG,RESET] are self clearing */
+    s->phy_reg[PHY_CTRL] = val & ~(0x3f |
+                                   MII_CR_RESET |
+                                   MII_CR_RESTART_AUTO_NEG);
+
     /*
      * QEMU 1.3 does not support link auto-negotiation emulation, so if we
      * migrate during auto negotiation, after migration the link will be
      * down.
      */
-    if (!(s->compat_flags & E1000_FLAG_AUTONEG)) {
-        return;
-    }
-    if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) {
+    if (have_autoneg(s) && (val & MII_CR_RESTART_AUTO_NEG)) {
         e1000_link_down(s);
         DBGOUT(PHY, "Start link auto negotiation\n");
-        timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500);
+        timer_mod(s->autoneg_timer,
+                  qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500);
     }
 }
 
@@ -446,8 +456,9 @@ set_mdic(E1000State *s, int index, uint32_t val)
         } else {
             if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) {
                 phyreg_writeops[addr](s, index, data);
+            } else {
+                s->phy_reg[addr] = data;
             }
-            s->phy_reg[addr] = data;
         }
     }
     s->mac_reg[MDIC] = val | E1000_MDIC_READY;
@@ -848,14 +859,6 @@ receive_filter(E1000State *s, const uint8_t *buf, int size)
     return 0;
 }
 
-static bool
-have_autoneg(E1000State *s)
-{
-    return (s->compat_flags & E1000_FLAG_AUTONEG) &&
-           (s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN) &&
-           (s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG);
-}
-
 static void
 e1000_set_link_status(NetClientState *nc)
 {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 2/2] e1000: use symbolic constants to init phy ctrl & status registers
  2014-08-06 18:07 [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items Gabriel L. Somlo
  2014-08-06 18:07 ` [Qemu-devel] [PATCH 1/2] e1000: correctly handle phy_ctrl reserved & self-clearing bits Gabriel L. Somlo
@ 2014-08-06 18:07 ` Gabriel L. Somlo
  2014-08-06 21:25 ` [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items Michael S. Tsirkin
  2 siblings, 0 replies; 4+ messages in thread
From: Gabriel L. Somlo @ 2014-08-06 18:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, mst

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
---
 hw/net/e1000.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 04c0f91..a2c4608 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -233,13 +233,30 @@ static const char phy_regcap[0x20] = {
 
 /* PHY_ID2 documented in 8254x_GBe_SDM.pdf, pp. 250 */
 static const uint16_t phy_reg_init[] = {
-    [PHY_CTRL] = 0x1140,
-    [PHY_STATUS] = 0x794d, /* link initially up with not completed autoneg */
-    [PHY_ID1] = 0x141, /* [PHY_ID2] configured per DevId, from e1000_reset() */
-    [PHY_1000T_CTRL] = 0x0e00,			[M88E1000_PHY_SPEC_CTRL] = 0x360,
-    [M88E1000_EXT_PHY_SPEC_CTRL] = 0x0d60,	[PHY_AUTONEG_ADV] = 0xde1,
-    [PHY_LP_ABILITY] = 0x1e0,			[PHY_1000T_STATUS] = 0x3c00,
+    [PHY_CTRL] =   MII_CR_SPEED_SELECT_MSB |
+                   MII_CR_FULL_DUPLEX |
+                   MII_CR_AUTO_NEG_EN,
+
+    [PHY_STATUS] = MII_SR_EXTENDED_CAPS |
+                   MII_SR_LINK_STATUS |   /* link initially up */
+                   MII_SR_AUTONEG_CAPS |
+                   /* MII_SR_AUTONEG_COMPLETE: initially NOT completed */
+                   MII_SR_PREAMBLE_SUPPRESS |
+                   MII_SR_EXTENDED_STATUS |
+                   MII_SR_10T_HD_CAPS |
+                   MII_SR_10T_FD_CAPS |
+                   MII_SR_100X_HD_CAPS |
+                   MII_SR_100X_FD_CAPS,
+
+    [PHY_ID1] = 0x141,
+    /* [PHY_ID2] configured per DevId, from e1000_reset() */
+    [PHY_AUTONEG_ADV] = 0xde1,
+    [PHY_LP_ABILITY] = 0x1e0,
+    [PHY_1000T_CTRL] = 0x0e00,
+    [PHY_1000T_STATUS] = 0x3c00,
+    [M88E1000_PHY_SPEC_CTRL] = 0x360,
     [M88E1000_PHY_SPEC_STATUS] = 0xac00,
+    [M88E1000_EXT_PHY_SPEC_CTRL] = 0x0d60,
 };
 
 static const uint32_t mac_reg_init[] = {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items
  2014-08-06 18:07 [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items Gabriel L. Somlo
  2014-08-06 18:07 ` [Qemu-devel] [PATCH 1/2] e1000: correctly handle phy_ctrl reserved & self-clearing bits Gabriel L. Somlo
  2014-08-06 18:07 ` [Qemu-devel] [PATCH 2/2] e1000: use symbolic constants to init phy ctrl & status registers Gabriel L. Somlo
@ 2014-08-06 21:25 ` Michael S. Tsirkin
  2 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2014-08-06 21:25 UTC (permalink / raw)
  To: Gabriel L. Somlo; +Cc: qemu-devel, stefanha

On Wed, Aug 06, 2014 at 02:07:09PM -0400, Gabriel L. Somlo wrote:
> Michael,
> 
> As discussed earlier here are my e1000 phy_ctrl and phy_status
> cleanup patches we decided to delay until after the 2.1 release.
> 
> Thanks,
>   Gabriel

Applied, thanks!

> Gabriel L. Somlo (2):
>   e1000: correctly handle phy_ctrl reserved & self-clearing bits
>   e1000: use symbolic constants to init phy ctrl & status registers
> 
>  hw/net/e1000.c | 60 ++++++++++++++++++++++++++++++++++++++--------------------
>  1 file changed, 40 insertions(+), 20 deletions(-)
> 
> -- 
> 1.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-06 21:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-06 18:07 [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items Gabriel L. Somlo
2014-08-06 18:07 ` [Qemu-devel] [PATCH 1/2] e1000: correctly handle phy_ctrl reserved & self-clearing bits Gabriel L. Somlo
2014-08-06 18:07 ` [Qemu-devel] [PATCH 2/2] e1000: use symbolic constants to init phy ctrl & status registers Gabriel L. Somlo
2014-08-06 21:25 ` [Qemu-devel] [PATCH 0/2] e1000: post-2.1-freeze cleanup items Michael S. Tsirkin

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).