Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50E5DC433E0 for ; Wed, 17 Jun 2020 16:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2ED1921789 for ; Wed, 17 Jun 2020 16:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbgFQQsD (ORCPT ); Wed, 17 Jun 2020 12:48:03 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:44400 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727001AbgFQQsC (ORCPT ); Wed, 17 Jun 2020 12:48:02 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1jlbEG-000yzg-BC; Wed, 17 Jun 2020 18:48:00 +0200 Date: Wed, 17 Jun 2020 18:48:00 +0200 From: Andrew Lunn To: Tanjeff-Nicolai Moos Cc: netdev@vger.kernel.org Subject: Re: qmi_wwan not using netif_carrier_*() Message-ID: <20200617164800.GG205574@lunn.ch> References: <20200617152153.2e66ccaf@pm-tm-ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200617152153.2e66ccaf@pm-tm-ubuntu> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Jun 17, 2020 at 03:21:53PM +0200, Tanjeff-Nicolai Moos wrote: > Hi netdevs, > > Kernel version: > > I'm working with kernel 4.14.137 (OpenWRT project). But I looked at > the source of kernel 5.7 and found the same situation. > > Problem: > > I'm using the qmi_wwan driver for a Sierra Wireless EM7455 LTE > modem. This driver does not use > netif_carrier_on()/netif_carrier_off() to update its link status. > This confuses ledtrig_netdev which uses netif_carrier_ok() to obtain > the link status. > > My solution: > > As a solution (or workaround?) I would try: > > 1) In drivers/net/usb/qmi_wwan.c, lines 904/913: Add the flag > FLAG_LINK_INTR. > > 2) In drivers/net/usb/usbnet.c, functions usbnet_open() and > usbnet_stop(): Add a call to netif_carrier_*(), > but only if FLAG_LINK_INTR is set. > > Question: > > Is this the intended way to use FLAG_LINK_INTR and netif_carrier_*()? > Or is there another recommended way to obtain the link status of > network devices (I could change ledtrig_netdev)? Hi Tanjeff With Ethernet, having a carrier means there is a link partner, the layer 2 of the OSI 7 layer stack model is working. If the interface is not open()ed, it clearly should not have carrier. However, just because it is open, does not mean it has carrier. The cable could be unplugged, etc. This is an LTE modem. What does carrier mean here? I don't know if it is well defined, but i would guess it is connected to a base station which is offering service. I'm assuming you are interested in data here, not wanting to make a 911/999/112/$EMERGENCY_SERVICE call which in theory all base stations should accept. Is there a way to get this state information from the hardware? That would be the correct way to set the carrier. Andrew