Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp580560lqg; Fri, 1 Mar 2024 14:21:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbCKkNPaOkGuyIbAwCPpBSowTNypZZ9fStiM26CyPBUeG5bPe7WS5Hc7hRgvKSbLnwZacOyrOaDMAOe+PYacf74xB5m1e1n5veGKIZTw== X-Google-Smtp-Source: AGHT+IHVIUZsTMqApcWLF/l/JwspEBgeF9+ykF66nGyy1nxmeUYm9MUcGMV04atoqqIuowApJi7I X-Received: by 2002:a05:620a:1367:b0:787:4caf:2542 with SMTP id d7-20020a05620a136700b007874caf2542mr2903717qkl.72.1709331715790; Fri, 01 Mar 2024 14:21:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331715; cv=pass; d=google.com; s=arc-20160816; b=tIJJ7jHMBzw+3XXrJYXWAQdIHtRNEFyx9ydb/oqj+Jj2fl/fuSej+MrX/EAJK2o1HU gufbje40X50hnhA7uIsdn37urBJ0mAibJq6+mnMP2ecEFs4PsWNBzQUhEZcLShaVw6GL ZKRWoyhKNavwOv+Vkcpi9mqp4ikTUbH/PlymX9CVmovAeEGtTCYqTnGW9nSjhoVGW0UQ ITu2mBgtVTicHt67FIxUxCcUu7my2+q44uvmrM7po34FlbHurp107N+Q63wYf5zxVOsT 83BFukNeTr9NgPzLJUJcJn3C5oONRe0EQTgSjw939A4rOSt4LWdYL96ABnKrLdNmu11z e1/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=79CWB+FAWzBWpGynqkW+uoHcutiDjMhuchSIrgf3T2E=; fh=Ublt/Wfp2zCBaqmX3OOoC99OeWaP7CSsVxmOAdt1mZ8=; b=VquFKXjUNlRRjdaYbVklJwlL88QQQB4tuhEcYXgtEtRU1/rKKI6QdNZNtiEW7IGS0v SB6AFG2pbOGxytrjjzZmg7FfaWGxe3EOK9GHtfMQ+aSR0HVxcRE6PYlctL2F2r53tyl0 IhaWGhHwCQnCQivja8o592i+7MH41w9QssPtOdkfJ6OtClIMadfSZeWtb+xUnYIAA7eJ 1KqZiVYvc2gLPXNKY39MSdX1arDbJqIV8D3CA3QCLiuQjbKjy02LxEr+WO9bQkaheSYd gfe58gg7deLpoeyMzdo2pQhdr3htJRWbFM/pP8qGcuQDxsrLVdWTYF0cve6kKHYX+Exg ByoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jqhhlJJc; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-89187-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89187-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dt31-20020a05620a479f00b00787ac643457si4387437qkb.70.2024.03.01.14.21.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:21:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89187-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jqhhlJJc; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-89187-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89187-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2EF971C242F0 for ; Fri, 1 Mar 2024 22:21:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B3725D467; Fri, 1 Mar 2024 22:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jqhhlJJc" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 95F235C90B; Fri, 1 Mar 2024 22:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331494; cv=none; b=XFX0U1fcYRDjS3kd4itItKx5p9j2rb7Dkz39+QkkK0q1Q9rb4Cwjbsh7SewULhivGYtaRhy2baEFSe0A2HXnUFkL1GK+W0TNIOkML+YkW3hrFjqYUgY4/85IVg74K451R7I8l+Cr+4ztzp2eDz83mKk5NR+a0riMSW2roNTPQFw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331494; c=relaxed/simple; bh=IfQrtti16WuHwjOGf3KP2KKdwU/2ZkAy/e81LJ1LFZ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B0RDCAT/7ro2W3w007rfbfzbhad3qTp5PqUJdGaf+ymXAl8Rcch9I+eVuMnWiSwzoZ4hkCp4KpwMPpEkEBhYtSS6Ua2vrGVg4Q7/h6go9RYDb9MalFwIKOLCA0TT6k+BXsaM3CPLlpgiAqwiEeyztpSpEnStZG4fBDLoTDZ5Qxc= 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=jqhhlJJc; arc=none smtp.client-ip=209.85.218.48 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 Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a44b0b2c7cdso121140066b.0; Fri, 01 Mar 2024 14:18:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331490; x=1709936290; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=79CWB+FAWzBWpGynqkW+uoHcutiDjMhuchSIrgf3T2E=; b=jqhhlJJcT8eCacloxSwAtv3jZOCu9cDz99177FW1J1U/ryrKP6QEJMfmKOZtYQKSqk usBVTDULyqBoAoYfvehNTO2dGGfYctHT0wTl8m6qNJv6iyjn4UkkEzuzf8CQUvEzvIpz Avi5yMBRXNJ/effZMsvTHb82rLQ7wclARuENC/TdM5CDLj95z+2kbC3Lrdo7jGZ7VFU+ HIXkqxbqAHeZKwWMfr8dai70xjRg+OHnQyurJZkIUkdaCh1Bg/jhBtxFUYIXPc+1Wewi 2uL3KwPCoNFqFMjAk16/F/ZWeRvzfDpvAa9yK19x+8Y7TnfzfVTq84ow7NCNdIZlVMFj 7WeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331490; x=1709936290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=79CWB+FAWzBWpGynqkW+uoHcutiDjMhuchSIrgf3T2E=; b=MovO2M526IsZejSl7Lzw1BTvMOCDSNGbwSKNzH0T29+9SNS+KzO0mYf48WRXAiLkgs VqLFvLXUkQDxMZDTl/TED/H1YO2e5BWnYCGigYQUB/dGq8STachhW7Q/CPDUsKt+Z5cH U+Vn+RxntZLErRpuqqGN28ddmYPg6Bmle7unDKMPb1eBJow9hyIWRm3RCBvIK2t+bUlt HrlB1EhGwCWfUZhnsP4QV1eZDsskYKujrZ+OA/34fNJpDXwNGO8WCDITX/IzLfhZcyDG aLP/tzmMyruOxibYqNFl4pdO+gBObZesOgh/WtoRYb+rAFy4ZWccLwjF1kgKGxhnFCU6 wfUg== X-Forwarded-Encrypted: i=1; AJvYcCVpnVLtVU7ha2vc7eWvIQpjOWClzyDJK9WNikTgZ0pGuvQaJ9M5I/ZcaO/zcMzrbZdeIY8HLBHX/XQxETCrCBSmWrVuSk0Sza+rDyLr X-Gm-Message-State: AOJu0YwtRafdiiTHElY8pRTXwL2pxchY7x74srX2bUl3N4xjuvqMrY5X PsOJmDiQ5wcRGtRTCTQOkOtrsvnexS6I1tOLRVqOlC2I/OA3+oa2kUwKAdpa+Gw= X-Received: by 2002:a17:906:fa92:b0:a3e:d5ac:9995 with SMTP id lt18-20020a170906fa9200b00a3ed5ac9995mr2106250ejb.59.1709331490348; Fri, 01 Mar 2024 14:18:10 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:09 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , Vladimir Oltean , Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v6 11/16] net: dsa: tag_sja1105: refactor skb->dev assignment to dsa_tag_8021q_find_user() Date: Fri, 1 Mar 2024 23:16:33 +0100 Message-Id: <20240301221641.159542-12-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Vladimir Oltean A new tagging protocol implementation based on tag_8021q is on the horizon, and it appears that it also has to open-code the complicated logic of finding a source port based on a VLAN header. Create a single dsa_tag_8021q_find_user() and make sja1105 call it. Signed-off-by: Vladimir Oltean Signed-off-by: Pawel Dembicki --- v6, v5: - resend only v4: - introduce patch and change from master to conduit and slave to user net/dsa/tag_8021q.c | 19 ++++++++++++++++--- net/dsa/tag_8021q.h | 5 +++-- net/dsa/tag_sja1105.c | 17 +++++------------ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index 332b0ae02645..454d36c84671 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -468,8 +468,8 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, } EXPORT_SYMBOL_GPL(dsa_8021q_xmit); -struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, - int vbid) +static struct net_device * +dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, int vbid) { struct dsa_port *cpu_dp = conduit->dsa_ptr; struct dsa_switch_tree *dst = cpu_dp->dst; @@ -495,7 +495,20 @@ struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, return NULL; } -EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_port_by_vbid); + +struct net_device *dsa_tag_8021q_find_user(struct net_device *conduit, + int source_port, int switch_id, + int vid, int vbid) +{ + /* Always prefer precise source port information, if available */ + if (source_port != -1 && switch_id != -1) + return dsa_conduit_find_user(conduit, switch_id, source_port); + else if (vbid >= 1) + return dsa_tag_8021q_find_port_by_vbid(conduit, vbid); + + return dsa_find_designated_bridge_port_by_vid(conduit, vid); +} +EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_user); /** * dsa_8021q_rcv - Decode source information from tag_8021q header diff --git a/net/dsa/tag_8021q.h b/net/dsa/tag_8021q.h index 0c6671d7c1c2..27b8906f99ec 100644 --- a/net/dsa/tag_8021q.h +++ b/net/dsa/tag_8021q.h @@ -16,8 +16,9 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, int *vbid, int *vid); -struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, - int vbid); +struct net_device *dsa_tag_8021q_find_user(struct net_device *conduit, + int source_port, int switch_id, + int vid, int vbid); int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds, struct dsa_notifier_tag_8021q_vlan_info *info); diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 35a6346549f2..3e902af7eea6 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -509,12 +509,8 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, */ return NULL; - if (source_port != -1 && switch_id != -1) - skb->dev = dsa_conduit_find_user(netdev, switch_id, source_port); - else if (vbid >= 1) - skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); - else - skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); + skb->dev = dsa_tag_8021q_find_user(netdev, source_port, switch_id, + vid, vbid); if (!skb->dev) { netdev_warn(netdev, "Couldn't decode source port\n"); return NULL; @@ -652,12 +648,9 @@ static struct sk_buff *sja1110_rcv(struct sk_buff *skb, if (likely(sja1105_skb_has_tag_8021q(skb))) dsa_8021q_rcv(skb, &source_port, &switch_id, &vbid, &vid); - if (source_port != -1 && switch_id != -1) - skb->dev = dsa_conduit_find_user(netdev, switch_id, source_port); - else if (vbid >= 1) - skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); - else - skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); + skb->dev = dsa_tag_8021q_find_user(netdev, source_port, switch_id, + vid, vbid); + if (!skb->dev) { netdev_warn(netdev, "Couldn't decode source port\n"); return NULL; -- 2.34.1