Article View: linux.kernel.netdev
Article #19703Re: [PATCH net-next v10 3/8] hsr: Add a magic header for sending PTP packets
From: Sebastian Andrzej Siewior
Date: Fri, 20 Nov 2026 08:55
Date: Fri, 20 Nov 2026 08:55
103 lines
12847 bytes
12847 bytes
On 2026-11-10 14:12:14 [+0100], Daniel Machon wrote:
> Hi Sebastian,
Hi Daniel,
> > --- a/include/linux/if_hsr.h
> > +++ b/include/linux/if_hsr.h
> > @@ -3,6 +3,7 @@
> > #define _LINUX_IF_HSR_H_
> >
> > #include <linux/types.h>
> > +#include <uapi/linux/hsr_ptp.h>
>
> Is this needed?
hsr_device.c needs the defines and the struct hsr_inline_header from it.
Let me move it there where it used.
> >
> > struct net_device;
> >
> > --- a/net/hsr/hsr_device.c
> > +++ b/net/hsr/hsr_device.c
> > @@ -223,24 +223,71 @@ static netdev_features_t hsr_fix_features(struct net_device *dev,
> >
> > static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
> > {
> > + enum hsr_port_type req_tx_port = HSR_PT_NONE;
> > struct hsr_priv *hsr = netdev_priv(dev);
> > struct hsr_port *master;
> > + bool has_hsr_header = false;
>
> RXT.
ups.
> >
> > rcu_read_lock();
> > master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
> > - if (master) {
> > - skb->dev = master->dev;
> > - skb_reset_mac_header(skb);
> > - skb_reset_mac_len(skb);
> > - spin_lock_bh(&hsr->seqnr_lock);
> > - hsr_forward_skb(skb, master);
> > - spin_unlock_bh(&hsr->seqnr_lock);
> > - } else {
> > - dev_core_stats_tx_dropped_inc(dev);
> > - dev_kfree_skb_any(skb);
> > + if (!master)
> > + goto drop;
> > +
> > + skb->dev = master->dev;
> > + if (skb->protocol == htons(ETH_P_1588)) {
> > + struct hsr_inline_header *hsr_opt;
>
> Is 'hsr_opt' a leftover name from a previous version? I would have expected it
> to be something like hsr_inline_hdr.
Right. Let me rename it.
> > + struct ethhdr *eth_hdr;
> > + unsigned int hdr_len;
…
> > + eth_hdr = skb_pull(skb, sizeof(struct hsr_inline_header));
> > + skb_set_network_header(skb, hdr_len);
> > + skb->protocol = eth_hdr->h_proto;
> > }
>
> I think that is a big ptp-hsr specific block in a hot xmit function. Personally,
> I would probably have put that into a helper hsr_ptp_parse_header() or
> something. Not a big deal though.
Hmm. Hot or not there is a comparison at the begin and it should jump
over it. Moving into a function shouldn't change the outcome since the
compiler will inline it. It might look nicer and the "error" path is the
same so let me make it a helper as suggested. There is just req_tx_port
and has_hsr_header that needs to be passed around but that is doable.
> > +
> > + skb_reset_mac_header(skb);
> > + skb_reset_mac_len(skb);
> > + spin_lock_bh(&hsr->seqnr_lock);
> > + hsr_forward_skb(skb, master, req_tx_port, has_hsr_header);
> > + spin_unlock_bh(&hsr->seqnr_lock);
> > rcu_read_unlock();
> >
> > + return NETDEV_TX_OK;
> > +drop:
> > + rcu_read_unlock();
> > + dev_core_stats_tx_dropped_inc(dev);
> > + dev_kfree_skb_any(skb);
> > return NETDEV_TX_OK;
> > }
> >
…
> /Daniel
Sebastian
Technical Details
Message-ID:
<20261120085515.Yd_dUps9@linutronix.de>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367798-linux-kernel-netdev=dewy.ruReferences:
<20261104-hsr_ptp-v10-0-2c4a38ad973c@linutronix.de> <20261104-hsr_ptp-v10-3-2c4a38ad973c@linutronix.de> <20261110131214.5i4b3jt7iigbewsw@DEN-DL-M70577>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367798-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v10 3/8] hsr: Add a magic header for sending PTP packets Date: Fri, 20 Nov 2026 09:55:15 +0100 Organization: Usenet Network Message-ID: <20261120085515.Yd_dUps9@linutronix.de> References: <20261104-hsr_ptp-v10-0-2c4a38ad973c@linutronix.de> <20261104-hsr_ptp-v10-3-2c4a38ad973c@linutronix.de> <20261110131214.5i4b3jt7iigbewsw@DEN-DL-M70577> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="3111942"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:hFPDxQyeIC4COF5cWi0M2Jd9bpM= sha256:7ED/T5ODx0kJHywr410FCmhUV4Dp2bF02Kf/UwMx6gg= sha1:gGdrggI8/8+FmB/1ax7am4+uASo= sha256:rnMvDPRcrGCePC4iIbipVE+sIJZzQNcYUrpCF7f1JT8= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 810E5115917; Fri, 20 Nov 2026 11:55:45 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=linutronix.de header.b=E3l4bOAh; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=4HPvNy8N X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dFHHZfm7n6K1; Fri, 20 Nov 2026 11:55:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367798-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linutronix.de X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 5C80B1158F3; Fri, 20 Nov 2026 11:55:27 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 57C4B3DBF8; Fri, 20 Nov 2026 08:55:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795164920; b=aG+krBvi3zhWKGqQ8M0yKSKe/dqPatYyaxQ/fzWQZVVxtRWy8iBxgXoL47hJLYrtBzNT 8TGijuU8Lyhsz5gZiyQv9nBvtnqjYgz+WfNRxHIeRoGKrYMYIv651mmWwvftZes/sde/E vnp1/16mjwkfYcafCkPLjEhxlKIDTz2PXOe8S72W2W2+//32kvxzgnWl5jpCkHO3fCF6h 1b/XWgeuaxsLnc0Ugt47nI4rfzoUI8IClI7retNDB8w/45Oj3Ye2+v6kdfHb9fbg+guN7 5vAvJCkj5oSqAEAFL/bxrnzbAN03ACc6prGlxr2LBhGH9/r7paqheVWkexFK1KWLUaQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795164920; h=X-Original-To:Received:DMARC-Filter:Date:DKIM-Signature: DKIM-Signature:From:To:Cc:Subject:Message-ID:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; bh=wAR1oj0jWIAovH51D7/UJIXhhjioZB8Lads3EGhnueg=; b=T93CzGPZCOKN6VxOXpuBCYmbUgwIGRwPX13At64uY/J97kj5RDJ6yNFF48p5ykCq9ym2 02HXOBm11nAFQ3GvBI8ZdRaK9aGoc5ntfjsM7HMpGWCwZ3R2evhvhyIbIkq5QxRffFxsW kJj3bA6caJk1+n6EBzlsA0XJfqhPZ371x9FBpXW3YW7syEOEB2mARglorar0cDo/waYaO eW1fYK7QHscha/H0wP+FSssw60l3PRCAscjo0FM9MKX7a4F4ouVwqQ54bxaQLuxX6goxW +4PNyidpHyIwOqAomRql8sBNrkhJ1U5UE5Jy7CrY3goLkbCWz9P1LTc+NRLZIBpCOTw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=E3l4bOAh; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=4HPvNy8N; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28F0A60A260C; Fri, 20 Nov 2026 08:55:20 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=E3l4bOAh; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=4HPvNy8N X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795164919; b=IYcriv7aUQCS0bSExPesRhZTgV6bNMH8aX7T7Zg1iK80fShReZaCrTOfZNKC3IChuVl7 TdVUJQp9MX9hhQRMYfTSEcctsKkBJ+HiXiKiVRuQ8PBdNEfh5JGgMes/Dw/8RhhOsLYJW C06uD9bjJdIW9zkHUMLT2ZtCzfxeUEJtvk3I8sEtZtacPkQFtrSsB3FWziCRIYm14NEaF wmuPifJSP6Z2P/5UcMEvq/1TxfX4wnVDteXaoXuJZ5BCeY3eYwvM172t1wK/CoglhJSw/ xUtny73roQVaUKCIh8oW7lFJOqD1yT/JWAD2IQqqDfLsAe1mi8bizMEr9ZNJTsonqiw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795164919; h=DMARC-Filter:Date:DKIM-Signature:DKIM-Signature:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=wAR1oj0jWIAovH51D7/UJIXhhjioZB8Lads3EGhnueg=; b=BvJk+d3v2YRJSbPsil1jX63W6jz95xnIPzRi7c7WlkSfmVts8zjeGZlvXcPIHRnCU+Cy 1mKo/ATHZiDHi7PGfH6mfmuWODIDw/si8i3uiMX4LtrFUZyFZ2p/AEe7jmDWbi9yRvbFu tkMQNPSgtHxrgamdlaXD1Y9cHFInvNPUGy+18ryJnxwJShkknZCBEIjsTkb9axPuJyKaT 30GVT+uWkxZg6P/6i1/XBRg+p/MYqzGC0+6acFeKdRx1Q+DuIu14nhfaCVDsDyJdsKF2M NJKjyPw+02nrbmRzqZ1FSXxEEo656XBPoGYOpRqOlpQFY4VyvWXAYydnj2lUZ6X+NdQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=E3l4bOAh; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=4HPvNy8N; arc=none smtp.remote-ip=193.142.43.55 X-Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBDD7606A33C for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 08:55:18 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BBDD7606A33C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1795164916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wAR1oj0jWIAovH51D7/UJIXhhjioZB8Lads3EGhnueg=; b=E3l4bOAh4Lz+vtRgjzgzdnOA264kWgZobWfzWWE5l5r2YcXcCltD0neH4nJxOdwzbdJ0+h 7Si5CQPtPY7DOxuOfWpOutGN7m9aMTpfEmDikBrwM4vIlPvr5rgcVN6q/M6RG/g3nKCKiL nruFQqZqo06n8jp1aqMBuMaz9VPhB9mBK4qSmSdS9HHdPDEcZmmlCghL3Fts1RrG6zQ0NQ bnQWKO0HGJsOSlVJTkBSiz+biIUkV3i8FeT1hP5EdX7UbsMcB3kTP+AkXowsMBsON7f3hS PNCDSMS8KiBkurCfuMvzMOS2KVSUJbSg1AROe6JdSpAfQWNESwKXQXe+njqx1Q== X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1795164916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wAR1oj0jWIAovH51D7/UJIXhhjioZB8Lads3EGhnueg=; b=4HPvNy8NowoI7bx1eiCDLjfNa00rXxUgpeSkao88Wr8bSCperDDAiPvgRUm0+ef4RG/b7X k522PmiYBxiRZ7Aw== X-Cc: netdev@vger.kernel.org, "(JC), Jayachandran" <j-rameshbabu@ti.com>, Andrew Lunn <andrew+netdev@lunn.ch>, Chintan Vankar <c-vankar@ti.com>, Danish Anwar <danishanwar@ti.com>, Daolin Qiu <d-qiu@ti.com>, "David S. Miller" <davem@davemloft.net>, Felix Maurer <fmaurer@redhat.com>, Jakub Kicinski <kuba@kernel.org>, Neelima Muralidharan <neelima@ti.com>, Paolo Abeni <pabeni@redhat.com>, Praneeth Bajjuri <praneeth@ti.com>, Pratheesh Gangadhar TK <pratheesh@ti.com>, Richard Cochran <richardcochran@gmail.com>, Simon Horman <horms@kernel.org>, Vignesh Raghavendra <vigneshr@ti.com>, Willem de Bruijn <willemdebruijn.kernel@gmail.com>, Eric Dumazet <edumazet@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261110131214.5i4b3jt7iigbewsw@DEN-DL-M70577>