From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from APAC01-SG1-obe.outbound.protection.outlook.com (mail-sg1on0132.outbound.protection.outlook.com [134.170.132.132]) by dpdk.org (Postfix) with ESMTP id A5E355A35 for ; Fri, 3 Apr 2015 17:19:09 +0200 (CEST) Received: from localhost.localdomain (123.139.55.75) by SINPR04MB155.apcprd04.prod.outlook.com (10.242.56.144) with Microsoft SMTP Server (TLS) id 15.1.130.23; Fri, 3 Apr 2015 15:19:00 +0000 From: Shelton Chia To: Date: Fri, 3 Apr 2015 23:18:49 +0800 Message-ID: <1428074329-20469-1-git-send-email-jiaxt@sinogrid.com> X-Mailer: git-send-email 2.3.5 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [123.139.55.75] X-ClientProxiedBy: SIXPR04CA001.apcprd04.prod.outlook.com (10.242.58.31) To SINPR04MB155.apcprd04.prod.outlook.com (10.242.56.144) Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SINPR04MB155; X-Microsoft-Antispam-PRVS: X-Forefront-Antispam-Report: BMV:1; SFV:NSPM; SFS:(10019020)(6069001)(6009001)(229853001)(2351001)(110136001)(66066001)(47776003)(42186005)(36756003)(92566002)(86362001)(122386002)(77096005)(40100003)(33646002)(50466002)(50226001)(48376002)(87976001)(19580405001)(19580395003)(450100001)(62966003)(77156002)(50986999)(46102003)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR04MB155; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(5002010); SRVR:SINPR04MB155; BCL:0; PCL:0; RULEID:; SRVR:SINPR04MB155; X-Forefront-PRVS: 05352A48BE X-OriginatorOrg: sinogrid.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2015 15:19:00.5885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SINPR04MB155 Subject: [dpdk-dev] [PATCH] kni: fix igb and ixgbe kni ethtool get_link op X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2015 15:19:10 -0000 igb and ixgbe's link detected always return yes, fix get_link func refer to get_settings, it works correctly for my i350 and 82599es nic. Signed-off-by: Shelton Chia --- .../linuxapp/kni/ethtool/igb/igb_ethtool.c | 18 ++++++--------- .../linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c | 26 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c index f3c48b2..5457f48 100644 --- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c +++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c @@ -383,19 +383,15 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) static u32 igb_get_link(struct net_device *netdev) { struct igb_adapter *adapter = netdev_priv(netdev); - struct e1000_mac_info *mac = &adapter->hw.mac; + struct e1000_hw *hw = &adapter->hw; + u32 status; - /* - * If the link is not reported up to netdev, interrupts are disabled, - * and so the physical link state may have changed since we last - * looked. Set get_link_status to make sure that the true link - * state is interrogated, rather than pulling a cached and possibly - * stale link state from the driver. - */ - if (!netif_carrier_ok(netdev)) - mac->get_link_status = 1; + status = E1000_READ_REG(hw, E1000_STATUS); - return igb_has_link(adapter); + if (status & E1000_STATUS_LU) + return 1; + else + return 0; } static void igb_get_pauseparam(struct net_device *netdev, diff --git a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c index 11472bd..184b14f 100644 --- a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c +++ b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c @@ -801,6 +801,30 @@ static void ixgbe_get_regs(struct net_device *netdev, struct ethtool_regs *regs, regs_buff[1128] = IXGBE_READ_REG(hw, IXGBE_MFLCN); } +static u32 ixgbe_get_link(struct net_device *netdev) +{ + struct ixgbe_adapter *adapter = netdev_priv(netdev); + struct ixgbe_hw *hw = &adapter->hw; + u32 link_speed = 0; + bool link_up; + + if (!in_interrupt()) { + hw->mac.ops.check_link(hw, &link_speed, &link_up, false); + } else { + /* + * this case is a special workaround for RHEL5 bonding + * that calls this routine from interrupt context + */ + link_speed = adapter->link_speed; + link_up = adapter->link_up; + } + + if (link_up) + return 1; + else + return 0; +} + static int ixgbe_get_eeprom_len(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -2838,7 +2862,7 @@ struct ethtool_ops ixgbe_ethtool_ops = { .get_wol = ixgbe_get_wol, .set_wol = ixgbe_set_wol, .nway_reset = ixgbe_nway_reset, - .get_link = ethtool_op_get_link, + .get_link = ixgbe_get_link, .get_eeprom_len = ixgbe_get_eeprom_len, .get_eeprom = ixgbe_get_eeprom, .set_eeprom = ixgbe_set_eeprom, -- 2.3.5