Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1275011pxb; Thu, 28 Jan 2021 12:08:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnYE6c7yfD/CCrJ9HQJNhxS0s+b59bx0ttKxhbUh1yliEiod5ZT1YP77ZvX0f5qWdvfb40 X-Received: by 2002:a17:906:f246:: with SMTP id gy6mr1136215ejb.264.1611864501530; Thu, 28 Jan 2021 12:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611864501; cv=none; d=google.com; s=arc-20160816; b=vVQeDjEn1geLGg9nPHV4sy+KKd1x60Q/KsR25WpqlkZVDwUR3AnS+PpsRZPFWGYllb rHkRZddI+1qqsahCnlEU5WrCryurAOmBFq6aebUjSwcJ3lLt1V08tyzu5VdOBq1PR/Qx n9U/SSnK4hpr8itC0V9/u45jxPhNXYaxh0S70h6rNh7OYu76K6Dem115upHhNdUly9iO nLUPQvTP31Z8U/ayO5nbGNvP6hksYgpr+qNO8i1If596hXohQVoHlghmR0wpPovor2R7 vr1CFcfxVW1/e60RXnLKL0rrMMa/WVzMFvL/aNHyBVu0YfPhNpGUQOUD71r1UP5hOVCM HCbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=05Je/VtZIj31gY2VCQ1m6e2XQzIE+K1ITxYcXH04REQ=; b=kNuMZuJF3yQK56e7fMH+ukmRvc+3Wba4CYn2WPedPgZvx1GaEPe/0MnSuisIJ9gw/7 yaNtqjWHmr27FDZrh04BFdOTYa3CBTBrGIgx9G+zzsK0bSylvXh0+c/GORG+PCxE4kNQ ynK7p31gkdEkC1pG61HyAKAg42fdD8b/jeaaAzwldiXis2XSdDcGpK8DynBqf+Sc4x+3 k7B7QHp44UFxsi7iFMi3tLh7jd1Xb0nOhlK5uk7FonsmfRWPDpATn25TFAR7+tUbEvvz 3N1cXy7cmLT7liPNNhvUO+jFwDD7wl2cHdgmvf59NGUFEzJ0D+Qk/zinx72/+9dz33Kk QZhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AWdLNwAS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j9si4626799edf.438.2021.01.28.12.07.57; Thu, 28 Jan 2021 12:08:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AWdLNwAS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbhA1UGx (ORCPT + 99 others); Thu, 28 Jan 2021 15:06:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:55192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbhA1UEC (ORCPT ); Thu, 28 Jan 2021 15:04:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id ECCFF64E36; Thu, 28 Jan 2021 19:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611863221; bh=H6v8ZXXV2Uym43MsLOBYTQXBG2B+5yMYkUpZPMWn644=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AWdLNwASDJjkawvi33IHgk2Zd43mbPji3juUCNIX4wOLf/YIWLq/ohWIu74Bdp56c k8WDDTuMUgrR9CQc7KWw5qZaVGtMi+F1V+H/Y4eBiitIXngFAvga3kq0T+jAKErfqM t2JjcA1OmZ11Je5t/wXUm4DaWXCgdRYsZhJ9xXHA4pFWKg2kdGkjkXl8V7igYVckCQ /OT0MGwzNLGKOPSnagKaBtaN3KLRHHeOyT88a4VJru6albHvmMZCFnSv7SPHF5h0YK whBdhho3ffywPJY1RAy/bjgn/GSiOzU8GRlNJ6QOsNHO1FKpULm8PFPbjz+HhVYK6V yQCAhFD8f9EtA== Date: Thu, 28 Jan 2021 11:46:59 -0800 From: Jakub Kicinski To: Xie He Cc: "David S. Miller" , linux-x25@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Schiller , Krzysztof Halasa Subject: Re: [PATCH net] net: hdlc_x25: Use qdisc to queue outgoing LAPB frames Message-ID: <20210128114659.2d81a85f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210127090747.364951-1-xie.he.0141@gmail.com> References: <20210127090747.364951-1-xie.he.0141@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Jan 2021 01:07:47 -0800 Xie He wrote: > An HDLC hardware driver may call netif_stop_queue to temporarily stop > the TX queue when the hardware is busy sending a frame, and after the > hardware has finished sending the frame, call netif_wake_queue to > resume the TX queue. > > However, the LAPB module doesn't know about this. Whether or not the > hardware driver has stopped the TX queue, the LAPB module still feeds > outgoing frames to the hardware driver for transmission. This can cause > frames to be dropped by the hardware driver. > > It's not easy to fix this issue in the LAPB module. We can indeed let the > LAPB module check whether the TX queue has been stopped before feeding > each frame to the hardware driver, but when the hardware driver resumes > the TX queue, it's not easy to immediately notify the LAPB module and ask > it to resume transmission. > > Instead, we can fix this issue at the hdlc_x25 layer, by using qdisc TX > queues to queue outgoing LAPB frames. The qdisc TX queue will then > automatically be controlled by netif_stop_queue and netif_wake_queue. Noob question - could you point at or provide a quick guide to layering here? I take there is only one netdev, and something maintains an internal queue which is not stopped when HW driver stops the qdisc? > This way, when sending, we will use the qdisc queue to queue and send > the data twice: once as the L3 packet and then (after processed by the > LAPB module) as an LAPB (L2) frame. This does not make the logic of the > code messy, because when receiving, data are already "received" on the > device twice: once as an LAPB (L2) frame and then (after processed by > the LAPB module) as the L3 packet. > > Some more details about the code change: > > 1. dev_queue_xmit_nit is removed because we already have it when we send > the skb through the qdisc TX queue (in xmit_one). > > 2. hdlc_type_trans is replaced by assigning skb->dev and skb->protocol > directly. skb_reset_mac_header in hdlc_type_trans is no longer necessary > because it will be called in __dev_queue_xmit. Sounds like we're optimizing to prevent drops, and this was not reported from production, rather thru code inspection. Ergo I think net-next will be more appropriate here, unless Martin disagrees. > diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c > index bb164805804e..b7f2823bf100 100644 > --- a/drivers/net/wan/hdlc_x25.c > +++ b/drivers/net/wan/hdlc_x25.c > @@ -89,15 +89,10 @@ static int x25_data_indication(struct net_device *dev, struct sk_buff *skb) > > static void x25_data_transmit(struct net_device *dev, struct sk_buff *skb) > { > - hdlc_device *hdlc = dev_to_hdlc(dev); > - > + skb->dev = dev; > + skb->protocol = htons(ETH_P_HDLC); > skb_reset_network_header(skb); > - skb->protocol = hdlc_type_trans(skb, dev); > - > - if (dev_nit_active(dev)) > - dev_queue_xmit_nit(skb, dev); > - > - hdlc->xmit(skb, dev); /* Ignore return value :-( */ > + dev_queue_xmit(skb); > } > > > @@ -106,6 +101,12 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev) > { > int result; > > + if (skb->protocol == htons(ETH_P_HDLC)) { > + hdlc_device *hdlc = dev_to_hdlc(dev); > + > + return hdlc->xmit(skb, dev); > + } > + > /* There should be a pseudo header of 1 byte added by upper layers. > * Check to make sure it is there before reading it. > */