Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2939074lqp; Mon, 25 Mar 2024 13:48:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWyiEKTYQQg+fSaebbzdFtVWLLN8g2Z3slJv7BNfyxSTHX+u5rKpBxLGDJszGue59hiNPLy+Pa3vKrSKt27VYBeIHKt6Upttxj8RvJUwg== X-Google-Smtp-Source: AGHT+IE037BSt+lhhFttS3UVIL2qcwASri+CrV/oX44rJOIXJTki2ENx+7EKOONhT7ow7m43rFXh X-Received: by 2002:a17:906:f284:b0:a46:ecc1:8a2e with SMTP id gu4-20020a170906f28400b00a46ecc18a2emr6407173ejb.16.1711399717656; Mon, 25 Mar 2024 13:48:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711399717; cv=pass; d=google.com; s=arc-20160816; b=uhvK8Q6nnCUUHUmhyNVeQiCG0A7oU+48cJy2w1ps+aZpoOqguOROtIQucVpjOi3ukE NpAc1SvVR34a00klXeQIc51kb7Hislbsyn5zZN/ZogDGjN2dlYfWLBtrZcPANu+134TP MjWHM7WBAdXT1pO7QK/2JIbZBfFGo1tu3bLrhByMtYNPjMuKAIyTWjIUxfclJUiAs+X2 3rm4mJ4IPwxNzSWGCCEcB8ETs0q5VXiOE8w/6NRiVqj1KOkja2wPAQfr/Bt+ucwi2Zfc beAAUnnamjJkj4gQZED3e9ikEJVauyN4gEkoULFxWqugjY7GcUSfq0eCoK53VpgWRYeH AmqA== 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=VwxiH5lx/9RYIz3hxmE1liFC9ih5JE9dAbG25/LF7X4=; fh=Lr0ycMHLpVARiDRoYYYUP+Bpfli/q3pIyV0+G6n9N9E=; b=QzcmhqsgYKO3n9vpVuC5gDc83bWBbMybwuLigoKlDi/RGBNz2+6oHxhiDUyaDeTClq qXV6TIDIvYFhQ0GchjnfN5vE0nP7Fokrs1BDzqHsTZB49hD0Fsv1jWtPYnsV4hqvu/nF P8gdmTBjTFs9ghFQeSK1180tJ3tZVoyj8QygzmAZCClHguyRGhOfXoxhBegGXsAWnguB cPwYQcfT2gBH3sXCATuD7/rhOfP+V4LIOh00nHP1+FFVRqmRvLrhz66wfcVi0JeSBPix KG5MDwkMR/Km5AQHKvtlJKyVbg4KXtwmVXStBaqes1cE3J+z04+Zh9y/HpJrZCTyxcOz Q8rQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ml2qq5G5; 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-117973-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117973-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s13-20020a1709062ecd00b00a470e612bdesi2801147eji.588.2024.03.25.13.48.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:48:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117973-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ml2qq5G5; 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-117973-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117973-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0DC661F36366 for ; Mon, 25 Mar 2024 20:48:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAF60839EE; Mon, 25 Mar 2024 20:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ml2qq5G5" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 06DE482D9A; Mon, 25 Mar 2024 20:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711399520; cv=none; b=TCXR+GMW91/WqjJmrY97NbWRlM1Cxk8p8Skg5v40QiPsXH5vc3prE7r9DVUj/VuT7R3WigvnIBi61MfJm/vn+7yxIqiHUkbjbJbUBNbQP9tJziK9+VKw2h8z5njSIxtcPCuyv5TQGtAJD0IxPENls2/m5vZqUE+IuJOX5e0mmw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711399520; c=relaxed/simple; bh=DDE/rUmOMNE04KTgH51pZZVtXb9QkzU4zP3jG4SK+6M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EgWrwaxS2/OzyK+vsRQX7GcHGuVRGW7ATbec5BXjraW9NPkb/bkRh7+69Q1t+Yxac7g7yygyYeEJ5nBGrwaMXBdFGXJaOFYubebiJrE7At2ICzCjEKH3Ao7G33JEB+mLlfxKWyUmcoMlJsFGRRCpFVf1FumDSon6TQrWYlLokRw= 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=Ml2qq5G5; arc=none smtp.client-ip=209.85.208.49 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-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-56a2bb1d84eso8507670a12.1; Mon, 25 Mar 2024 13:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711399517; x=1712004317; 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=VwxiH5lx/9RYIz3hxmE1liFC9ih5JE9dAbG25/LF7X4=; b=Ml2qq5G5lthLobtLP7auQ3nfVVfexDAxpfro1HstXyaIXAE5bD2ZxAIsBTUUafmLSU thzno4knsqqPP/xPMLR6NmAyDcNH5SGsaTaVNo0ic98ktDhhlY9vOEVDmsv6YSwDXzbj +QDsZWvPZv/EJvIhoRyiCv5Ic0Q/yNrB9QBVN6nzcUXRTLzbQ686KLIExrU5vZtxBffz nC0BZ/cd/gnrkGn0m6JOWVFbbd4xkAEqkpsAwTEfFS/NOux05SEiG9g8inuaRL3ehAID xrF3qCJh/CTTDUnhmj/vpOvIwRGTkxn1I0gwCeOjsR4uvfFU17PYoFDaiKpaNdIP9T1b AxQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711399517; x=1712004317; 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=VwxiH5lx/9RYIz3hxmE1liFC9ih5JE9dAbG25/LF7X4=; b=Im7CF1bIhFC8kSXEvcqoMzIY0Vz1kiUofEsadI4GMD1eJIPRJuXQJjBS361nbDvw5q TeC9yjd3t9X/bY1Z4QzAqgDC7TavDpNWhdM5DBYQkk+B5xoNXmhvzELqpomjDiYhqm2l aJlM8ch8Bsg4ta9s9TzJ8iD+IRQqHvA8N0IdzvC2d2bbJRzayoO3049/YGJodMR5l4hm dyVnd5VikKaDB13o8ujswBC0DAizP4GBNLuxyKw4U4ECv6bW8eFVTAzmqaFhhRCkWarA CeV/a9YKsXWf83QFFH1qBJYGBp1TAkH1t+/kEjUExXXISyJWfu0GkAsIPQMiBxavt877 cy6w== X-Forwarded-Encrypted: i=1; AJvYcCWoZCyG3XGtKbgazsOd1oXR5Avv8OR92sd8iRyuQ8iKPpMis4dz3AGVXxXwvfCnLADgyuO+fEQg6YcuZqtY/A6J2AVug7TvtczXDxeZ X-Gm-Message-State: AOJu0YzPoNjTqtAxyw7j/fQeLp6VsLWpIb+sUOsg/NUlpFFBDuzmp5j6 L4X23jvbai/XBpoM0zWtWltTedSAa2z39pphi956zdFxSu29xRz0xd3LuJuu3To= X-Received: by 2002:a50:8e1c:0:b0:567:800c:f6c6 with SMTP id 28-20020a508e1c000000b00567800cf6c6mr6352731edw.15.1711399517099; Mon, 25 Mar 2024 13:45:17 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id k18-20020a056402049200b0056c1cba8480sm591751edv.25.2024.03.25.13.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:45:16 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , Vladimir Oltean , Pawel Dembicki , Florian Fainelli , 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 v7 11/16] net: dsa: tag_sja1105: refactor skb->dev assignment to dsa_tag_8021q_find_user() Date: Mon, 25 Mar 2024 21:43:36 +0100 Message-Id: <20240325204344.2298241-12-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325204344.2298241-1-paweldembicki@gmail.com> References: <20240325204344.2298241-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 Reviewed-by: Florian Fainelli --- 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