From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03682175BF for ; Thu, 31 Oct 2024 14:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730385434; cv=none; b=A/E4iwrseJorT/3RGuM8Ebgje0XcnXWD5r/jpCqAIsjVLmgs8ZWrAYU2zf1XDTF/ELBufymBM01Pwsixg7RHgP4hHFdB0shLG5vq0bKzl/HBNp8+oLose4IdK2J4VUSoXBMIiwTrftrHvOpZGp4Kb/kESgOvrtrd7r3+DwrJfOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730385434; c=relaxed/simple; bh=YEUISV/64SzjZW8yf+F9ak/Z634GVYmrT+x+0I2OYqI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eX7wplFBMRJXLQdubogn76NKu37wQKWgAsrTqVPXYjZWOH8DL9ngX9+AwlNuSZV7aqFRzJVMd+lUkeaUOJRDbS1T4GSX2MB7swGUCqub2p4bJAEW4075jI3zT7y3BufTE+L2zt8xhwGWF7YCotubSn9xYf0I+M5cmU4aiuyXSzQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DRTvOd23; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DRTvOd23" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730385431; 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=X6O/3GBw63p0l5BBCUi73LPu6bFx6muuGDbHydYXVPs=; b=DRTvOd23LsUsnlhT8t8EmZsa91pRNSz9+alapXE80oMItZ3qLf75iX0hS4wAzF34HD5/48 XplLBstFUsfImuqCPs6VUdJ2S8Db4l/A+ovnEkf1Pr2BExnQufgrhqmlyW8t5JKaOlvHw+ R2cJmeO4CJTfUS9xR/a7bL8RwAzYioc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-Zlk4RYMzPvqHg_Xn8aLYRg-1; Thu, 31 Oct 2024 10:37:09 -0400 X-MC-Unique: Zlk4RYMzPvqHg_Xn8aLYRg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4316e350d6aso6193515e9.3 for ; Thu, 31 Oct 2024 07:37:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730385428; x=1730990228; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X6O/3GBw63p0l5BBCUi73LPu6bFx6muuGDbHydYXVPs=; b=MNADfqV6J035QEKR0g62mp05R7JGILMUKMocN2D+II9FoWAN/FiWgoY1EoQYjovUKm o4NOI8MH69jFSWLrCGtMmi6Patl/w71R0vkGr+0W6lEb+Awj35+mJ5wAK5ymLMiVMyVh s0HJ7TXHiKeRZbFI+S3eGVaBCeOY5VUDSkIx8vzRGUXzGlZ/PJxDGBtUy4ThzlhGxAr6 Xqt9R0k+OQOTmMoTY55z/W0db6hRqSIn3Sejv7qBI13dD4GIVUvOHuJu3gZieE2buwmp tnFWjwk9etN0x7Nc5S3dMM05kFFIozQM2a6jdbeI+RXdaJB+HdYcpeIdMVXlVrZA6Rat 8nWQ== X-Forwarded-Encrypted: i=1; AJvYcCWJPY//zsiFOz/n8/zu4XulmP1o+/WGiEm+c4WDSVoldv7+F2YRNCVrUuh/Vydu/ieu/A84zR4ysTm9Lk8=@vger.kernel.org X-Gm-Message-State: AOJu0YyOe27bpgBqnoaYmezRbedQT3HpWcIWMtiso64DZoPdz0yW4pea BbiODla0H4iJufUjiXxNPbAkB+u554bWwdnQiufH5sz2S5xGiKkacXHCBWjT/UyptT/QZZwi2eP hVrIqltm4xoregLwHv2zsL3wdvflyx4XNSYnSKv3l3iTbDs23B+CyQ5kvpRTdCA== X-Received: by 2002:a05:600c:1ca9:b0:431:50cb:2398 with SMTP id 5b1f17b1804b1-4328323f576mr839915e9.2.1730385428448; Thu, 31 Oct 2024 07:37:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF4O9nwX/ru8zq05nFqcPwDY9v0i5+K7TjXF+z12dzOML3szYJAwB82EVvIHl/2zaVGkEuAw== X-Received: by 2002:a05:600c:1ca9:b0:431:50cb:2398 with SMTP id 5b1f17b1804b1-4328323f576mr839685e9.2.1730385428000; Thu, 31 Oct 2024 07:37:08 -0700 (PDT) Received: from [192.168.88.248] (146-241-44-112.dyn.eolo.it. [146.241.44.112]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10e7387sm2268534f8f.51.2024.10.31.07.37.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 31 Oct 2024 07:37:07 -0700 (PDT) Message-ID: <96516e40-5b1b-4bce-a041-7618c03c5de3@redhat.com> Date: Thu, 31 Oct 2024 15:37:05 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v2 2/4] net: hsr: Add VLAN CTAG filter support To: MD Danish Anwar , geliang@kernel.org, liuhangbin@gmail.com, dan.carpenter@linaro.org, jiri@resnulli.us, n.zhandarovich@fintech.ru, aleksander.lobakin@intel.com, lukma@denx.de, horms@kernel.org, jan.kiszka@siemens.com, diogo.ivo@siemens.com, shuah@kernel.org, kuba@kernel.org, edumazet@google.com, davem@davemloft.net, andrew+netdev@lunn.ch Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, srk@ti.com, Vignesh Raghavendra , Roger Quadros , m-malladi@ti.com References: <20241024103056.3201071-1-danishanwar@ti.com> <20241024103056.3201071-3-danishanwar@ti.com> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20241024103056.3201071-3-danishanwar@ti.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/24/24 12:30, MD Danish Anwar wrote: > From: Murali Karicheri > > This patch adds support for VLAN ctag based filtering at slave devices. > The slave ethernet device may be capable of filtering ethernet packets > based on VLAN ID. This requires that when the VLAN interface is created > over an HSR/PRP interface, it passes the VID information to the > associated slave ethernet devices so that it updates the hardware > filters to filter ethernet frames based on VID. This patch adds the > required functions to propagate the vid information to the slave > devices. > > Signed-off-by: Murali Karicheri > Signed-off-by: MD Danish Anwar > --- > net/hsr/hsr_device.c | 71 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 70 insertions(+), 1 deletion(-) > > diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c > index 0ca47ebb01d3..ff586bdc2bde 100644 > --- a/net/hsr/hsr_device.c > +++ b/net/hsr/hsr_device.c > @@ -515,6 +515,68 @@ static void hsr_change_rx_flags(struct net_device *dev, int change) > } > } > > +static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, > + __be16 proto, u16 vid) > +{ > + struct hsr_port *port; > + struct hsr_priv *hsr; > + int ret = 0; > + > + hsr = netdev_priv(dev); > + > + hsr_for_each_port(hsr, port) { > + if (port->type == HSR_PT_MASTER) > + continue; If the desired behavior is to ignore INTERLINK port, I think you should explicitly skip them here, otherwise you will end-up in a nondeterministic state. > + ret = vlan_vid_add(port->dev, proto, vid); > + switch (port->type) { > + case HSR_PT_SLAVE_A: > + if (ret) { > + netdev_err(dev, "add vid failed for Slave-A\n"); > + return ret; > + } > + break; > + > + case HSR_PT_SLAVE_B: > + if (ret) { > + /* clean up Slave-A */ > + netdev_err(dev, "add vid failed for Slave-B\n"); > + vlan_vid_del(port->dev, proto, vid); This code relies on a specific port_list order - which is actually respected at list creation time. Still such assumption looks fragile and may lead to long term bugs. I think would be better to refactor the above loop handling arbitrary HSR_PT_SLAVE_A, HSR_PT_SLAVE_B order. Guestimate is that the complexity will not increase measurably. > + return ret; > + } > + break; > + default: > + break; > + } > + } > + > + return 0; > +} > + > +static int hsr_ndo_vlan_rx_kill_vid(struct net_device *dev, > + __be16 proto, u16 vid) > +{ > + struct hsr_port *port; > + struct hsr_priv *hsr; > + > + hsr = netdev_priv(dev); > + > + hsr_for_each_port(hsr, port) { > + if (port->type == HSR_PT_MASTER) > + continue; I think it would be more consistent just removing the above statement... > + switch (port->type) { > + case HSR_PT_SLAVE_A: > + case HSR_PT_SLAVE_B: > + vlan_vid_del(port->dev, proto, vid); > + break; > + default:> + break; ... MASTER and INTERLINK port will be ignored anyway. > + } > + } > + > + return 0; > +} > + > static const struct net_device_ops hsr_device_ops = { > .ndo_change_mtu = hsr_dev_change_mtu, > .ndo_open = hsr_dev_open, Cheers, Paolo