From patchwork Mon Jun 16 17:29:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 360207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F2516140080 for ; Tue, 17 Jun 2014 03:29:59 +1000 (EST) Received: from localhost ([::1]:45688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwajF-0006yJ-Vs for incoming@patchwork.ozlabs.org; Mon, 16 Jun 2014 13:29:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwaii-00065r-GL for qemu-devel@nongnu.org; Mon, 16 Jun 2014 13:29:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wwaic-0000Fp-OX for qemu-devel@nongnu.org; Mon, 16 Jun 2014 13:29:24 -0400 Received: from mail-vc0-x22a.google.com ([2607:f8b0:400c:c03::22a]:39292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwaic-0000Ff-KG for qemu-devel@nongnu.org; Mon, 16 Jun 2014 13:29:18 -0400 Received: by mail-vc0-f170.google.com with SMTP id hy10so5343666vcb.29 for ; Mon, 16 Jun 2014 10:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OPZrZ+NzBCD82sFo9L++VbP+m0UbbDM95KP57Q8nRrw=; b=Hz28p98+77J/nYl5IRxvoKM1JdTWEYy7790m05z0L6FyQIQ0ggITc2H2y1xkAdyinI rpPQKT+RRv8zmr2ZMqekRTDLUiPCqRHVJxKxtE/YyJj0cZ4WQdaGA2xQa9hadLK6uojR yMRjysSTRLGk73v6Uqqh6XIcCqCu7bcVkiRraG+QJOfKgUJdjoBeDmRfps8OE04OauZR 98AKeGpFNjq2jnW2D3VpNBqorhH4JqusfO3n+ihoyO0/NKVcjEa+urQVNciillaNskEg Fne22xFH9F6ODI8htZvd4oAEx4InIjUxOFK3QAb+A413pO9b6d70JGfmQCyw1avFCYJs HvPw== X-Received: by 10.140.47.16 with SMTP id l16mr27274118qga.24.1402939758101; Mon, 16 Jun 2014 10:29:18 -0700 (PDT) Received: from ERROL.ini.cmu.edu (ERROL.INI.CMU.EDU. [128.2.16.43]) by mx.google.com with ESMTPSA id d8sm22649164qas.24.2014.06.16.10.29.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jun 2014 10:29:17 -0700 (PDT) From: "Gabriel L. Somlo" X-Google-Original-From: "Gabriel L. Somlo" To: qemu-devel@nongnu.org Date: Mon, 16 Jun 2014 13:29:10 -0400 Message-Id: <1402939751-8371-3-git-send-email-somlo@cmu.edu> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1402939751-8371-1-git-send-email-somlo@cmu.edu> References: <1402939751-8371-1-git-send-email-somlo@cmu.edu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c03::22a Cc: romain@dolbeau.org, mst@redhat.com, agraf@suse.de, stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v1 2/3] e1000: improve auto-negotiation reporting via mii-tool X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Using mii-tool (on F20-live), the following output is produced: SIOCGMIIREG on ens3 failed: Input/output error ens3: no autonegotiation, 1000baseT-FD flow-control, link ok The first line (SIOCGMIIREG error) is due to mii-tool's inability to read the PHY auto-negotiation expansion register. On the second line, "no autonegotiation" is wrong, and caused by the absence of a flag in the link partner ability register which would indicate that our link partner has acked us. This flag not documented in the Intel e1000 manual (bit shown as "reserved"), but mii-tool uses it as LPA_LPACK from /usr/include/linux/mii.h. This patch adds read access to PHY_AUTONEG_EXP and defines the link partner ack flag, allowing mii-tool to generate output as normally expected: ens3: negotiated 1000baseT-FD flow-control, link ok Signed-off-by: Gabriel Somlo --- Checkpatch generates two errors for this patch, related to where PHY_AUTONEG_EXP is added to phy_regcap: ERROR: code indent should never use tabs #56: FILE: hw/net/e1000.c:232: + [PHY_ID2] = PHY_R,^I^I[M88E1000_PHY_SPEC_STATUS] = PHY_R,$ ERROR: space prohibited before open square bracket '[' #56: FILE: hw/net/e1000.c:232: + [PHY_ID2] = PHY_R, [M88E1000_PHY_SPEC_STATUS] = PHY_R, total: 2 errors, 0 warnings, 32 lines checked I merely added a comma at the end of the [PHY_ID2]... line, so I can add the entry for PHY_AUTONEG_EXP. Tabs are there in all previous lines, so not much of a choice unless we want to rat-hole into replacing tabs everywhere first... Thanks, Gabriel hw/net/e1000.c | 5 ++++- hw/net/e1000_regs.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index f0070ca..04e4044 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -176,6 +176,7 @@ e1000_link_down(E1000State *s) s->mac_reg[STATUS] &= ~E1000_STATUS_LU; s->phy_reg[PHY_STATUS] &= ~MII_SR_LINK_STATUS; s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE; + s->phy_reg[PHY_LP_ABILITY] &= ~MII_LPAR_LPACK; } static void @@ -209,6 +210,7 @@ e1000_autoneg_timer(void *opaque) E1000State *s = opaque; if (!qemu_get_queue(s->nic)->link_down) { e1000_link_up(s); + s->phy_reg[PHY_LP_ABILITY] |= MII_LPAR_LPACK; s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE; DBGOUT(PHY, "Auto negotiation is completed\n"); } @@ -227,7 +229,8 @@ static const char phy_regcap[0x20] = { [PHY_CTRL] = PHY_RW, [PHY_1000T_CTRL] = PHY_RW, [PHY_LP_ABILITY] = PHY_R, [PHY_1000T_STATUS] = PHY_R, [PHY_AUTONEG_ADV] = PHY_RW, [M88E1000_RX_ERR_CNTR] = PHY_R, - [PHY_ID2] = PHY_R, [M88E1000_PHY_SPEC_STATUS] = PHY_R + [PHY_ID2] = PHY_R, [M88E1000_PHY_SPEC_STATUS] = PHY_R, + [PHY_AUTONEG_EXP] = PHY_R, }; /* PHY_ID2 documented in 8254x_GBe_SDM.pdf, pp. 250 */ diff --git a/hw/net/e1000_regs.h b/hw/net/e1000_regs.h index 13ac671..60b96aa 100644 --- a/hw/net/e1000_regs.h +++ b/hw/net/e1000_regs.h @@ -384,6 +384,9 @@ #define MII_SR_100X_FD_CAPS 0x4000 /* 100X Full Duplex Capable */ #define MII_SR_100T4_CAPS 0x8000 /* 100T4 Capable */ +/* PHY Link Partner Ability Register */ +#define MII_LPAR_LPACK 0x4000 /* Acked by link partner */ + /* Interrupt Cause Read */ #define E1000_ICR_TXDW 0x00000001 /* Transmit desc written back */ #define E1000_ICR_TXQE 0x00000002 /* Transmit Queue empty */