From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 E49A415D5C9; Wed, 19 Jun 2024 20:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718830379; cv=none; b=GCSWqdf3I5PpgadWagB9rmxNsAHrLsEfqWT3iZouBT4Ulb7eq5rduWmL5CNFw6SIT++Nwt1eck8WIVGZEqZremVRXjFAbk6yRTJSC5Ycgdke0ceiCtUKlSZTCsjqUtTDekpSXGr7LdyjD35b/3LOU6L+of0v2MAbn9c2lvvlrmQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718830379; c=relaxed/simple; bh=PVs/oBSPYLZtlVEy+yQlgnu2BJds3qC9/Uzfc51hjh4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b1gSLegDN7xLu3MRP0wZ2UsHI+rbRbL9oD/mJJ0aEg1ubqXFk/wdExjy9WCcIBtxf0qjHd0tgGJRkivjMDLE3rxJap2CRM6eipVEc+jT3zIQ5ZGCie2yJNzeKu8ZEBJds7kQgPEpAASxR/+7ULcuG2PjWUKcazCm4CatpyhQEIE= 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=fITiLM8j; arc=none smtp.client-ip=209.85.218.52 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="fITiLM8j" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a6fb507fef3so17053666b.2; Wed, 19 Jun 2024 13:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718830375; x=1719435175; 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=8Vwg1gdM0zWT1wQvMXZKbfw4Um5Tz1dMCHe3knzq4kg=; b=fITiLM8jJ7JnREDU8kYfBFtiBqiDfaJpTI3w18iWT4J8dpXl9wJZ73THkzq5SLmfxf xVrIQt1JYnCoOqWG205SKw/IYr0BvYacAd+GK0W9SuJE1bNviRrLJq3rngpoxiauJnRs cx6e3citabJmk6WNwvsMqqw51iab5s7iPTtzIaqtQQTcqpQJg168xFWH5v1UXbi1NDHj rQT/c4vWpzASNygwhPpAq4r2SOP2renEjFlvaDqVwegTjhgO1pw9i0pS2cAJPTrdpZne 0h1sa4FEkOYCw1XEMUUz5GJ2YueZvJ6W5KBnGlTks2BKopI4JZoDpcftfJHqyqoTsPm4 FrtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718830375; x=1719435175; 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=8Vwg1gdM0zWT1wQvMXZKbfw4Um5Tz1dMCHe3knzq4kg=; b=h2NCnO59L5yz9IFcn6P5Fe7PTLmLJp3s7o/DkYEE77fhwJdH1tKjfHEmR90tKeP7Uf JwL9GMUdhVQBE4W+yX0uZnq+CMG+uK9+GHw/s3+CmO4ehs6s0660r1Q4REp1PD6hEXbF ItjSmp2n7AAEIT4eAq5ABLVeahWNmnLSae4LUN9MOwit04WiuBLgWYS80hFsoeWxxokf L2wIQBlSS1OvKEbKcbOFT6fQag5jsLduTWPD9F2AriK2MO1tcwMkWsj8j+jnd++JsOmI pGGzMQhCkxEkOACrGS9UhG7YiEzTLS5/WSjhXn6feKH6jpVfZsVXBT0G9K/HKq6qkl5l 620g== X-Forwarded-Encrypted: i=1; AJvYcCVGhv4hWkz+WjOX1npcRYRIEdY81TRE1O9kupbxMvFBKzU5/QLcqaLpmWA6Xn+Q4supIegB1FwwCeoa7RtWPoIfBG6fUBEGp2WUlKkv X-Gm-Message-State: AOJu0YyUavG0HZRIHJIIueHAwtTa2eeBmjPgeHbgCqvt9hdx+8bAzF0L +z0PHkz9+3LveP4CgLuVvSKDklt7EkfQSFmvsIWDf/CWJOnDNrNmWQhU1DA8qps= X-Google-Smtp-Source: AGHT+IF5plJI2+q2Hb/fCL0yLfO1jM0yFei3XbCBFM+wmMu7yfa4RU96hK0xIYpg1org/0X7ZqhNfQ== X-Received: by 2002:a17:906:7943:b0:a6f:51b3:cbbd with SMTP id a640c23a62f3a-a6fab608d8dmr272377866b.4.1718830375383; Wed, 19 Jun 2024 13:52:55 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56db5b2fsm697329566b.47.2024.06.19.13.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 13:52:54 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Paolo Abeni , Vladimir Oltean , Pawel Dembicki , Florian Fainelli , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 06/12] net: dsa: tag_sja1105: refactor skb->dev assignment to dsa_tag_8021q_find_user() Date: Wed, 19 Jun 2024 22:52:12 +0200 Message-Id: <20240619205220.965844-7-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619205220.965844-1-paweldembicki@gmail.com> References: <20240619205220.965844-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: netdev@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 Reviewed-by: Florian Fainelli --- v2,v1: - resend only --- Before patch series split: https://patchwork.kernel.org/project/netdevbpf/list/?series=841034&state=%2A&archive=both v8: - resend only v7: - added 'Reviewed-by' only 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