From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D4F94A2E34 for ; Tue, 3 Mar 2026 16:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772554316; cv=none; b=buzsKIxKtmt+v1ux18MlEqlen8mNmd1jea76ruX7urd0YiM9uCUYFOqyIGDKamvQkiISldKtQDek7ZlBhs/5jCUVoaMRnblqCu8XAw0mfdkKbEKe4HL10qH2UMpGU9Kkw/j4LRQEQPsFTsmC1Tltj0xRwDkRNCWJtmEx+UHW1EQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772554316; c=relaxed/simple; bh=N5wngUdyded7KLhNkbgdzRFgxGMoyVrZJXhVV1uEP6Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=grAQQNcy2pBuYLQZ1GIk4ol4kj39N22yBr51SGm1qfu483wnGa7uFXhfMxQDCX5JjBgnVIP8sojScKluHfSmO5+gLF4RnELYQ/ti4nMTa/s/kyqjBnm+DBpnt/+vUTf2WhSzEeeIvieRH2F54RA8V2n1Lf+TAZlO1oT+B2mF9hg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eBM61BXf; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eBM61BXf" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4830b67aa6bso6027225e9.0 for ; Tue, 03 Mar 2026 08:11:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772554312; x=1773159112; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=NDQRso0/6pRmOjXwAwr8jsWZ+364LBr9GQ56Vp8aC/g=; b=eBM61BXfnbJy0UckVUXOhCU2cReA5ZyEYx5F5QGZ2cAyVYWVbHrvCfDJmiMczJbf8b NyWvVsi4rBQgvwgHpv+e0O09JH0IIexCE84OsL6MzdMn+5YDdFiBI3cdqSOhBx6cRWC3 OTbkzdvZ8yXQUAjZkyphKXAxGGPidCwqlkcama0rYPC8ggaavExNYgg7u6BMyYE5pPK2 DP8amZtMEYd2hExifoU8raYbR3AGZOIXBCrRNyuCUYb9QsTWOiUR1jiGhMif22QinGhu Awz5C2MqAIScdwaz2T4p4p1dprxkc29ZQFhnZlF7KIAin/5+F245He5ikHsL/LDg/EhV ZCWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772554312; x=1773159112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NDQRso0/6pRmOjXwAwr8jsWZ+364LBr9GQ56Vp8aC/g=; b=Vtev19fqVQt7n24+TytRhXP9ugrkm7xbv5EggqTiHFS1Xzl6/dsP5K2K900dj5sX8A ttYbSXFxv+I/XKQDuIfH6BLGwipCHcgrlZnZrd90JeHMUHu97QNyttMexSm3hLjiXJ/d lw/s1Wf12HlhKaiI5RJaFlR4Mz3HX/nQNOi44wnVutGj2iFJsMtRu1kDni+olucohJiU pGWFViYWgBWsdJAW9BKOv0fycf1o6zGFsXIViEvRnT3ml87hnMb1TQN8+MSMPDM7RgMT TtFleXAimT1EdsCCdKxXs/4lOKNgGREc9NhREEuZ1knFC+fSA4FGRGWnEUQbusBbb/jW kbXA== X-Forwarded-Encrypted: i=1; AJvYcCX9n8aN0Acq2YFT+aRziAusEYbWshUVkoWS0c72Ji38VqLlc9/9Hv3YHRP+D9JNOJoceROI5wagZZzy@vger.kernel.org X-Gm-Message-State: AOJu0YyKxLiwprmCWHgMRDyqs0aPu58ImPX/UuRzNEeLMT3RwRK9ASZw qkZu0E7fy4v/LMGAbhRY0mEzLyEp9mcdWxr5oC50bmFuPy5tFVcStNiE X-Gm-Gg: ATEYQzy8yxqpYtyDmEsfFLUUYWkbbLICNupznCd9dp8ET1Nco5XPN9gMUuTlG2rQDS2 USebBfjmlHMe8cvjRiFldjZKVaEiU7eovHyD7FG86QohskUuE00NzE44c7XNoQgJhcQtrfiGmfR pCkWJj6OgB1Z43JIM3KUCoVsNsLTROtW707EmXVOpPpQRKfItb9GUTqQoAn2odZsKde2N6EK5W5 tL+dCj86qIQVir8HSRuDTvtppRf5RZSBgud7KFMj5DjXj6hRSJK6N+Li2ttd/7D3AXo43rfgzaD /fAChM6wCwkqlp092XyH4RzvTu/BXyRK/vQ7IQP5RJxgurZ5qwqMQzq0wh+kqKNGTTMYIMt0aju Lhkmy9omuxhIbIeXKbNcwuRFbtmb6QTWD57uNtASmRLOC1Yk15TV2D44qpBDqTzJtk1VVdHSuVt ytMR1zmPJxloiROnw= X-Received: by 2002:a05:600c:34d0:b0:47b:d992:601e with SMTP id 5b1f17b1804b1-483c9ba712emr179672085e9.2.1772554311582; Tue, 03 Mar 2026 08:11:51 -0800 (PST) Received: from skbuf ([2a02:2f04:d00e:3600:2472:8e4a:cf12:bb30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439b1116698sm23197781f8f.16.2026.03.03.08.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 08:11:50 -0800 (PST) Date: Tue, 3 Mar 2026 18:11:47 +0200 From: Vladimir Oltean To: Jens Emil Schulz =?utf-8?Q?=C3=98stergaard?= Cc: UNGLinuxDriver@microchip.com, Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Woojung Huh , Russell King , Steen Hegelund , Daniel Machon , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH net-next 1/8] net: dsa: add tag driver for LAN9645X Message-ID: <20260303161147.bgbltslwrl2gtd7p@skbuf> References: <20260303-dsa_lan9645x_switch_driver_base-v1-0-bff8ca1396f5@microchip.com> <20260303-dsa_lan9645x_switch_driver_base-v1-1-bff8ca1396f5@microchip.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260303-dsa_lan9645x_switch_driver_base-v1-1-bff8ca1396f5@microchip.com> On Tue, Mar 03, 2026 at 01:22:27PM +0100, Jens Emil Schulz Østergaard wrote: > Use long prefix on extraction (RX) and no prefix on injection (TX). A > long prefix on extraction helps get through the conduit port on host > side, since it will see a broadcast MAC. (...) > The format can be configured asymmetrically on RX and TX. Do you foresee a need to configure the prefix length? It would be possible to do that by changing the tagging protocol. But it implies that the "lan9645x" string as found in /sys/class/net/.../dsa/tagging becomes user ABI that is set in stone. It will mean long extraction prefix and no injection prefix. Otherwise user space will get very confused (libpcap, XDP, whatever else might get written). > +static inline u32 lan9645x_ifh_get(const u8 *ifh, size_t pos, size_t length) > +{ > + size_t end = (pos + length) - 1; > + size_t start_u8 = pos >> 3; > + size_t end_u8 = end >> 3; > + size_t end_rem = end & 0x7; > + size_t pos_rem = pos & 0x7; > + u8 end_mask, start_mask; > + const u8 *ptr; > + u32 val; > + > + end_mask = BTM_MSK(end_rem); > + start_mask = TOP_MSK(pos_rem); > + > + ptr = &ifh[LAN9645X_IFH_LEN - 1 - end_u8]; > + > + if (end_u8 == start_u8) > + return (*ptr & end_mask & start_mask) >> pos_rem; > + > + val = *ptr++ & end_mask; > + > + for (size_t j = 1; j < end_u8 - start_u8; j++) > + val = val << 8 | *ptr++; > + > + return val << (8 - pos_rem) | (*ptr & start_mask) >> pos_rem; > +} If performance isn't a huge concern, pack() and unpack() certainly seem simpler than having your own implementation. > + > +static inline void lan9645x_xmit_get_vlan_info(struct sk_buff *skb, > + struct net_device *br, > + u32 *vlan_tci, u32 *tag_type) > +{ > + struct vlan_ethhdr *hdr; > + u16 proto, tci; > + > + if (!br || !br_vlan_enabled(br)) { > + *vlan_tci = 0; > + *tag_type = LAN9645X_IFH_TAG_TYPE_C; > + return; > + } > + > + hdr = (struct vlan_ethhdr *)skb_mac_header(skb); > + br_vlan_get_proto(br, &proto); > + > + if (ntohs(hdr->h_vlan_proto) == proto) { > + vlan_remove_tag(skb, &tci); > + *vlan_tci = tci; > + } else { > + rcu_read_lock(); > + br_vlan_get_pvid_rcu(br, &tci); > + rcu_read_unlock(); > + *vlan_tci = tci; > + } > + > + *tag_type = (proto != ETH_P_8021Q) ? LAN9645X_IFH_TAG_TYPE_S : > + LAN9645X_IFH_TAG_TYPE_C; > +} > + > +#endif /* _NET_DSA_TAG_LAN9645X_H_ */ Why do these need to live in a separate include file? Who else needs access to them other than the tagger? > +static const struct dsa_device_ops lan9645x_netdev_ops = { > + .name = LAN9645X_NAME, > + .proto = DSA_TAG_PROTO_LAN9645X, > + .xmit = lan9645x_xmit, > + .rcv = lan9645x_rcv, > + .needed_headroom = LAN9645X_TOTAL_TAG_LEN, > + .promisc_on_conduit = false, Initializing with false is unnecessary. > +}; > + > +MODULE_DESCRIPTION("DSA tag driver for LAN9645x family of switches, using NPI port"); > +MODULE_LICENSE("GPL"); > +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_LAN9645X, LAN9645X_NAME); > + > +module_dsa_tag_driver(lan9645x_netdev_ops); > > -- > 2.52.0 >