Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1745164pxk; Fri, 4 Sep 2020 18:59:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrAJCk8OUC09hPHx1EzPWnemDVC/Mcs9LSRnmBf5nvTvF+8I2zo27N8/Ako4bbnxBN2JTt X-Received: by 2002:a17:906:b756:: with SMTP id fx22mr10011910ejb.245.1599271147490; Fri, 04 Sep 2020 18:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599271147; cv=none; d=google.com; s=arc-20160816; b=pknwMuHFvNlt2/6d94skp5+CgOTUz2jhPrmoERb4bmz5inxdOAhp5CwT5BTvTPgMC4 BWkncUDBwFH7395iN2qcsQ98+qeeOQrAOsYf8Ljeyiz5H9DhBh3a6kERNoNQ6FqzmJHM 8b0sjEPyKdGfRY9b8m6FhBZZCKSR7sGc2E3Wl/nGbTBVLC+MH9c8z0iwozAgepsWlvET 6bpKiM/w0XxDI73IEwN9uCGX2P8b6fj76AAoHdp2jWKC/hl3z3o1dt2jOeFYojWLb8Yf xDzXDtWxgXXwpXWhIGUvxFr9myPgU6zzCLmgSHgRqaWRXDqzS4Rf2FtjXY/123PP6YED 1ZMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RyQJwHrGSIVSTLClykihDJ8SgQVVB4xZyNAi/4QjuPU=; b=X/8XoTOjDWvAMA43xqNQZxceLKxwurhjMmritR0ZHMkhQpILvv0v4XCuLpKSrbG844 AfVDNfR4bLG/EotfbkZDWsE6zZK242GtkPjopBOV28dD7bCa90P0qkfjLEacak+MS19K sH4QsVVOXjBb5RWOvJGFeaRlCwhBDXr89UG58T4BQanLiyVfl0Fbd2UTLsSCm1vomVWz rvrCpiE1AxDPmqeB1C/YflILctowzpqoXaXqm9ExWjjAQW/RfkExEs+ybwY6CgaadKK/ vjbVCySkmwIWMTLloSJqAx9ed21K2q72klZkG9lrzUz5jvsZZCdGq6507BPAMqn64gQW DHtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="LMy/q7W2"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w25si5392148ejy.124.2020.09.04.18.58.29; Fri, 04 Sep 2020 18:59:07 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b="LMy/q7W2"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727860AbgIEB5n (ORCPT + 99 others); Fri, 4 Sep 2020 21:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbgIEB5k (ORCPT ); Fri, 4 Sep 2020 21:57:40 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38680C061244; Fri, 4 Sep 2020 18:57:39 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 31so5180121pgy.13; Fri, 04 Sep 2020 18:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RyQJwHrGSIVSTLClykihDJ8SgQVVB4xZyNAi/4QjuPU=; b=LMy/q7W2rePDkk9NscKsx4a3JdLsPa3+1BU/IkFaBzOrPN/BU4IEm4XUWaWZeLa2Yd aNAWcGQwx0rajltIwajdf0kSNqIAoBZElI8NMXfmb18jt0d8VjgMmuN+NDlPnOyu6juB j1R7H4MZ3jFXBYpG9U3Mop2LKZsJt+GUdyZX8+k2KN4EUdsGHKHpIcDT+4s6wlDtq2dQ quqmdA5BmGTOrFZPbJAMTzlsKz8djeUYUxa5qVKReajJpvdaKVeNgI6xHn28aYQx6WbE iGCI+w6ycUJtLeX4SI6wNopkwMp7NgIR1ad8YS6wGV1Oze05DZV7z5NrvPnncN3u/lY7 Kr/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RyQJwHrGSIVSTLClykihDJ8SgQVVB4xZyNAi/4QjuPU=; b=BCs9LWJVogwCW4k7o3ebFZ8LDBSMs40KivIcDjaag00PU1g/bCWy9Pj271YwWaygmD aQ5BPeq0SwFdDSrKwqq3OVWm0yuShNCVSWSJtFnVuBIsK8tNRlejfiZW8bUugi99mpon ioTGLuX7w2cdfSO1EXk7S8xK93KPvzEsynQLmlnbS8+l5WDZVn0rxi/KIUBGcwEfk+sA BzxXJZD7y51zGhd9ki541mAbyxsS8g2P0FvE6WPoZAeO9iE+fpR4BDUI2poEjnk3ZN6d Owu8zXZvd3cvKWXFe2GsMM7oMK/1bYJ3PjVdqXxNKaj57Es/i5mkYyAfyUGf7npsgatS mxjg== X-Gm-Message-State: AOAM533H1Exjo0A0KVG3fZ41wkm5IqO/jU0DQfbuj5hY6O7DMeINGNrE UTghY6EsAN6G8IQC/J2TPY+gu3jOzPvYm8dn+TWVIhUszcY= X-Received: by 2002:a63:b24b:: with SMTP id t11mr9334548pgo.233.1599271058264; Fri, 04 Sep 2020 18:57:38 -0700 (PDT) MIME-Version: 1.0 References: <20200903000658.89944-1-xie.he.0141@gmail.com> <20200904151441.27c97d80@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: From: Xie He Date: Fri, 4 Sep 2020 18:57:27 -0700 Message-ID: Subject: Re: [PATCH net v2] drivers/net/wan/hdlc_fr: Add needed_headroom for PVC devices To: Jakub Kicinski Cc: Krzysztof Halasa , "David S. Miller" , Linux Kernel Network Developers , LKML , Martin Schiller , Willem de Bruijn Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 4, 2020 at 6:28 PM Xie He wrote: > > The HDLC device is not actually prepending any header when it is used > with this driver. When the PVC device has prepended its header and > handed over the skb to the HDLC device, the HDLC device just hands it > over to the hardware driver for transmission without prepending any > header. > > If we grep "header_ops" and "skb_push" in "hdlc.c" and "hdlc_fr.c", we > can see there is no "header_ops" implemented in these two files and > all "skb_push" happen in the PVC device in hdlc_fr.c. I want to provide a little more information about the flow after an HDLC device's ndo_start_xmit is called. An HDLC hardware driver's ndo_start_xmit is required to point to hdlc_start_xmit in hdlc.c. When a HDLC device receives a call to its ndo_start_xmit, hdlc_start_xmit will check if the protocol driver has provided a xmit function. If it has provided this function, hdlc_start_xmit will call it to start transmission. If it has not, hdlc_start_xmit will directly call the hardware driver's function to start transmission. This driver (hdlc_fr) has not provided a xmit function in its hdlc_proto struct, so hdlc_start_xmit will directly call the hardware driver's function to transmit. So no header will be prepended after ndo_start_xmit is called. There would not be any header prepended before ndo_start_xmit is called, either, because there is no header_ops implemented in either hdlc.c or hdlc_fr.c. On Fri, Sep 4, 2020 at 6:28 PM Xie He wrote: > > Thank you for your email, Jakub! > > On Fri, Sep 4, 2020 at 3:14 PM Jakub Kicinski wrote: > > > > Since this is a tunnel protocol on top of HDLC interfaces, and > > hdlc_setup_dev() sets dev->hard_header_len = 16; should we actually > > set the needed_headroom to 10 + 16 = 26? I'm not clear on where/if > > hdlc devices actually prepend 16 bytes of header, though. > > The HDLC device is not actually prepending any header when it is used > with this driver. When the PVC device has prepended its header and > handed over the skb to the HDLC device, the HDLC device just hands it > over to the hardware driver for transmission without prepending any > header. > > If we grep "header_ops" and "skb_push" in "hdlc.c" and "hdlc_fr.c", we > can see there is no "header_ops" implemented in these two files and > all "skb_push" happen in the PVC device in hdlc_fr.c. > > For this reason, I have previously submitted a patch to change the > value of hard_header_len of the HDLC device from 16 to 0, because it > is not actually used. > > See: > 2b7bcd967a0f (drivers/net/wan/hdlc: Change the default of hard_header_len to 0) > > > > diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c > > > index 9acad651ea1f..12b35404cd8e 100644 > > > --- a/drivers/net/wan/hdlc_fr.c > > > +++ b/drivers/net/wan/hdlc_fr.c > > > @@ -1041,7 +1041,7 @@ static void pvc_setup(struct net_device *dev) > > > { > > > dev->type = ARPHRD_DLCI; > > > dev->flags = IFF_POINTOPOINT; > > > - dev->hard_header_len = 10; > > > + dev->hard_header_len = 0; > > > > Is there a need to set this to 0? Will it not be zero after allocation? > > Oh. I understand your point. Theoretically we don't need to set it to > 0 because it already has the default value of 0. I'm setting it to 0 > only because I want to tell future developers that this value is > intentionally set to 0, and it is not carelessly missed out.