Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15959008rwd; Mon, 26 Jun 2023 03:58:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ717SGgNF6Fe1eqHmdkqHig0+LzIWi+eAWJkHRANoCdlBIMrzRXIWvkcvxdiq8OKL/+OzWQ X-Received: by 2002:a17:907:6092:b0:94a:845c:3529 with SMTP id ht18-20020a170907609200b0094a845c3529mr28644318ejc.9.1687777126430; Mon, 26 Jun 2023 03:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687777126; cv=none; d=google.com; s=arc-20160816; b=aZgbYDqZYg0CxqM5eVvaf9uXK3ZPVdPhVey12bT5u/Dpaevq+toMP7JiQtfEH+IAxm s8eOt20+XRE2y2XK+0FP4jbtY3rYTPW3l7aY0AiGpaHUeV8blbbnx1xJw4kLkpLJd/o+ TRtH8gFWD73Af1SXNsabDTEvThLPw4HyNIGXjwZgf3RyU911R/3gK0wU+JQf4j5wkNvF ipCngr30MwkrAapoEzQjTddqa3WNIl0vezlkHCl1iRvByxH2ToQXyq1GF0m5t7B1Pk9t +U/HcNGm8j40C6wpxit4zIgOnPLsaaHM7rnla3XxtVj8TQ4wSyd+N6RlmQ0WDnDDh51M uP6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mazsyDBwrMqG5cEUSpRqrjh566EgZQcI5mBml02mWjc=; fh=6xF8j03qtYOjcfoAg/OUf8JQ8DAMvRKNufni0mBANFQ=; b=UiyFVMZ9ADgDfVPquc3g1aqR5Hx4V9mCKuzqyd9/jrlcTKxyXrVjTdGIndE5vsXlf5 7raopWCx5Ve836SR5AGwP9Rq5adPFoES/yzFd8pJHNiNLl1r3R/RTwkVtgzxL8d3BgVU uZRwAlo+0iEaOq4Sdhng0JMrDFN72HRBt8ZGAK0TePOUcY5P7NDCIoErztKWJSYCd1o3 1KKmwQa74bHI0WfbimTcMOXiXNU8WNC6ZW10YTXScLu415+AxTutSkjmf3IPz/q0qUhc LmuBDEshM6Jvq7kP9F2RCjWLwPKf0Z8TM7icrNOId7DNwRpLQ3AwjSDMyodupTY/mobd jOXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ps9ioohU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a170906490a00b0098d6097599csi2734372ejq.547.2023.06.26.03.58.22; Mon, 26 Jun 2023 03:58:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ps9ioohU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229526AbjFZKhw (ORCPT + 99 others); Mon, 26 Jun 2023 06:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjFZKhu (ORCPT ); Mon, 26 Jun 2023 06:37:50 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D41E6E for ; Mon, 26 Jun 2023 03:37:49 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31114b46d62so3760033f8f.3 for ; Mon, 26 Jun 2023 03:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687775868; x=1690367868; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mazsyDBwrMqG5cEUSpRqrjh566EgZQcI5mBml02mWjc=; b=ps9ioohUWbRYRydhRdQsMTVaFXqwiDVVAZ+fYu6xJb/RLr2MssXofL2L3LoaICvJMG vk3dCHNEDu2tq+mimqfw1D/JbHTx3D3zzEOQ8QIaBY4jnPYv6pA7u4NO2YRz8PwFUkyh tTeRFtvspqeTZuXjeWfcYhrUmDUMe2mNFysW7D2yq+HNxttvnbRwsgDSYSrl6msiB6ZO OJ3jSnWIL/DHddZKQcysyj1hC3lj0ZAtSDPA6N0iPAjYI2CtRETylN2cImVRvdrp75IZ YgMdRX55SILdGKz4DzPbf0v07cLmTUywzVKqsFccd7Ntl1UNrD0QsNpnXSqFOCEfvZgH dApQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687775868; x=1690367868; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mazsyDBwrMqG5cEUSpRqrjh566EgZQcI5mBml02mWjc=; b=JUF/gqNShsvMr32XQEGWD2mL+ef8cAgoyt8pzo7hrEagh7sHpnVDI26FYqAc3J8W2E Kd0mR78H6h3gzKxkirKaTlacGwvF1M+dxUGEbKQXEC3OgbsRVPauvXsp9LuB1GLajONr GTq/j153gcK3XQ7QxpGstYYQbG9fbE4wgKQ2Vah2pcQgBh+44p52+VoU0avGhFtmwyjr BfA4E3QpB3GSk0ChqYe3o9foqTxu/xv8r5C7zdGQxpdLEiepsCqMAPvAiUcQanKXFk/5 Esy+4uV+Cir2vwvOHf1UBcwdTIIczUh1DSZy1/9ENEMeqXcYKlde7ZqfKs63c1jCjVzW jt6A== X-Gm-Message-State: AC+VfDwOuOu3oivdGWbWkqin7I2d2aWeDrQ5rch9OcIVj/r4JaXCAd6p d/d49TyBiS15rkVkNVAZa5Kd6g== X-Received: by 2002:adf:fa06:0:b0:30f:bdc5:c150 with SMTP id m6-20020adffa06000000b0030fbdc5c150mr25240310wrr.33.1687775867720; Mon, 26 Jun 2023 03:37:47 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id j14-20020adfff8e000000b003112dbc3257sm6840973wrr.90.2023.06.26.03.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 03:37:46 -0700 (PDT) Date: Mon, 26 Jun 2023 13:37:41 +0300 From: Dan Carpenter To: Simon Horman Cc: Pawel Dembicki , netdev@vger.kernel.org, Linus Walleij , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2 4/7] net: dsa: vsc73xx: Add dsa tagging based on 8021q Message-ID: <8b34df96-daed-4b71-9281-3a7b8a315c90@kadam.mountain> References: <20230625115343.1603330-1-paweldembicki@gmail.com> <20230625115343.1603330-4-paweldembicki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 25, 2023 at 02:42:27PM +0200, Simon Horman wrote: > + Dan Carpenter > > On Sun, Jun 25, 2023 at 01:53:39PM +0200, Pawel Dembicki wrote: > > This patch is simple implementation of 8021q tagging in vsc73xx driver. > > At this moment devices with DSA_TAG_PROTO_NONE are useless. VSC73XX > > family doesn't provide any tag support for external ethernet ports. > > > > The only way is vlan-based tagging. It require constant hardware vlan > > filtering. VSC73XX family support provider bridging but QinQ only without > > fully implemented 802.1AD. It allow only doubled 0x8100 TPID. > > > > In simple port mode QinQ is enabled to preserve forwarding vlan tagged > > frames. > > > > Tag driver introduce most simple funcionality required for proper taging > > support. > > > > Reviewed-by: Linus Walleij > > Signed-off-by: Pawel Dembicki > > ... > > > +static void vsc73xx_vlan_rcv(struct sk_buff *skb, int *source_port, > > + int *switch_id, int *vbid, u16 *vid) > > +{ > > + if (vid_is_dsa_8021q(skb_vlan_tag_get(skb) & VLAN_VID_MASK)) > > + return dsa_8021q_rcv(skb, source_port, switch_id, vbid); > > + > > + /* Try our best with imprecise RX */ > > + *vid = skb_vlan_tag_get(skb) & VLAN_VID_MASK; > > +} > > + > > +static struct sk_buff *vsc73xx_rcv(struct sk_buff *skb, > > + struct net_device *netdev) > > +{ > > + int src_port = -1, switch_id = -1, vbid = -1; > > + u16 vid; > > + > > + if (skb_vlan_tag_present(skb)) > > + /* Normal traffic path. */ > > + vsc73xx_vlan_rcv(skb, &src_port, &switch_id, &vbid, &vid); > > + > > + if (vbid >= 1) > > + skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); > > + else if (src_port == -1 || switch_id == -1) > > + skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); > > Hi Pawel, > > Smatch warns that vid may be used uninitialised here. > And it's not clear to me why that cannot be the case. > The problem is only when skb_vlan_tag_present() is false. If vsc73xx_vlan_rcv() is called then actually it's fine. Either vbid, src_port and switch_id will be set or vid will be initialized. Smatch thinks the vbid is set to 0-7, src_port is set to 0-15 and switch_id is set to 0-7. Smatch kind of ignores the switch_id == -1 condition because it's known to be false given that we already checked src_port == -1. But the concern again is the skb_vlan_tag_present() is false and then vbid, src_port and switch_id would all be set to -1. regards, dan carpenter