From patchwork Thu Apr 30 12:37:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 26682 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id C9B1AB6F56 for ; Thu, 30 Apr 2009 22:37:51 +1000 (EST) Received: by ozlabs.org (Postfix) id BAEC0DDF8C; Thu, 30 Apr 2009 22:37:51 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 3FF3ADDF87 for ; Thu, 30 Apr 2009 22:37:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762276AbZD3Mhq (ORCPT ); Thu, 30 Apr 2009 08:37:46 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762243AbZD3Mhp (ORCPT ); Thu, 30 Apr 2009 08:37:45 -0400 Received: from smarthost01.mail.zen.net.uk ([212.23.3.140]:36347 "EHLO smarthost01.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756703AbZD3Mhp (ORCPT ); Thu, 30 Apr 2009 08:37:45 -0400 Received: from [82.69.137.158] (helo=opal.uk.level5networks.com) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1LzVWK-0001VY-8B; Thu, 30 Apr 2009 12:37:44 +0000 Received: from [10.17.20.50] (achroite.uk.level5networks.com [10.17.20.50]) by opal.uk.level5networks.com (8.12.8/8.12.8) with ESMTP id n3UCbiXx030091; Thu, 30 Apr 2009 13:37:44 +0100 Subject: [PATCH 4/5] ethtool: Report link partner advertising From: Ben Hutchings To: Jeff Garzik Cc: netdev In-Reply-To: <1241094796.3185.2.camel@achroite> References: <1241094796.3185.2.camel@achroite> Organization: Solarflare Communications Date: Thu, 30 Apr 2009 13:37:43 +0100 Message-Id: <1241095063.3185.10.camel@achroite> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) X-Originating-Smarthost01-IP: [82.69.137.158] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Ben Hutchings --- ethtool.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ethtool.c b/ethtool.c index 08165eb..0d188af 100644 --- a/ethtool.c +++ b/ethtool.c @@ -839,12 +839,13 @@ static void dump_supported(struct ethtool_cmd *ep) fprintf(stdout, "No\n"); } -static void dump_advertised(struct ethtool_cmd *ep) +static void dump_advertised(struct ethtool_cmd *ep, + const char *prefix, u_int32_t mask) { - u_int32_t mask = ep->advertising; + int indent = strlen(prefix) + 14; int did1; - fprintf(stdout, " Advertised link modes: "); + fprintf(stdout, " %s link modes: ", prefix); did1 = 0; if (mask & ADVERTISED_10baseT_Half) { did1++; fprintf(stdout, "10baseT/Half "); @@ -854,7 +855,7 @@ static void dump_advertised(struct ethtool_cmd *ep) } if (did1 && (mask & (ADVERTISED_100baseT_Half|ADVERTISED_100baseT_Full))) { fprintf(stdout, "\n"); - fprintf(stdout, " "); + fprintf(stdout, " %*s", indent, ""); } if (mask & ADVERTISED_100baseT_Half) { did1++; fprintf(stdout, "100baseT/Half "); @@ -864,7 +865,7 @@ static void dump_advertised(struct ethtool_cmd *ep) } if (did1 && (mask & (ADVERTISED_1000baseT_Half|ADVERTISED_1000baseT_Full))) { fprintf(stdout, "\n"); - fprintf(stdout, " "); + fprintf(stdout, " %*s", indent, ""); } if (mask & ADVERTISED_1000baseT_Half) { did1++; fprintf(stdout, "1000baseT/Half "); @@ -874,14 +875,14 @@ static void dump_advertised(struct ethtool_cmd *ep) } if (did1 && (mask & ADVERTISED_2500baseX_Full)) { fprintf(stdout, "\n"); - fprintf(stdout, " "); + fprintf(stdout, " %*s", indent, ""); } if (mask & ADVERTISED_2500baseX_Full) { did1++; fprintf(stdout, "2500baseX/Full "); } if (did1 && (mask & ADVERTISED_10000baseT_Full)) { fprintf(stdout, "\n"); - fprintf(stdout, " "); + fprintf(stdout, " %*s", indent, ""); } if (mask & ADVERTISED_10000baseT_Full) { did1++; fprintf(stdout, "10000baseT/Full "); @@ -890,7 +891,7 @@ static void dump_advertised(struct ethtool_cmd *ep) fprintf(stdout, "Not reported"); fprintf(stdout, "\n"); - fprintf(stdout, " Advertised auto-negotiation: "); + fprintf(stdout, " %s auto-negotiation: ", prefix); if (mask & ADVERTISED_Autoneg) fprintf(stdout, "Yes\n"); else @@ -902,7 +903,8 @@ static int dump_ecmd(struct ethtool_cmd *ep) u32 speed; dump_supported(ep); - dump_advertised(ep); + dump_advertised(ep, "Advertised", ep->advertising); + dump_advertised(ep, "Link partner advertised", ep->lp_advertising); fprintf(stdout, " Speed: "); speed = ethtool_cmd_speed(ep);