Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1148623lqb; Thu, 30 May 2024 01:25:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQlE9iEr0OhB00vrwFzQOfQbRvT8loHm2mF8BZ5K9dzGkPoP0HfWbGGE8/+zmh+dxZgjY1Yvvn5wCxH88myu9jy+bWghkpTlESmX+6BA== X-Google-Smtp-Source: AGHT+IFWoNj9K5ORO+jNLnHIaRFjawAcGlt1rYcWwiGpr30EA6vFBn9ltryBuV8EedffG7jv5ppT X-Received: by 2002:a50:ccd7:0:b0:578:67e9:a46e with SMTP id 4fb4d7f45d1cf-57a1795316bmr830385a12.32.1717057551084; Thu, 30 May 2024 01:25:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717057551; cv=pass; d=google.com; s=arc-20160816; b=ZkfrKRPNz5AkXaSziVb2jmfs7KLhY/g4TEUieGUVySb1fOmqDyNpJVRVRRvdUgHXkl Gw0OXFAWfjAt0FmiqNcZZNLVHvamFBgyKvuqx+LbsEWjkLQlM7Auk59cxje29U+94EmR 1Ilg1JlPWPFu2TJoqHfBmRxJ0GRkFdznlbHO2rWkZKeoobO2AygAKkQrZpNPk32edyYN FxbD/o0YTHogrJiv+GDY36REFw7GO3eq/dV27Fzda5mMig5nCu7F3vQwE+jsAJYW4Qtv pjDOWp3KnRjSPflUD1Q7mWgvnoorCmTfMo5bkWN7jmJ7seyBhkO/kOrJQiyuRdtbBSHl 1lQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=JMtf54E8wSvNPwEden4YO4ER1VpqEdmJXOQOESUPlVA=; fh=fT/gOVluJkUN5t/ISa69U5angDQQBBFPWWc9pgptteU=; b=1KkdqOtiWUa3PQIvZbjaBGE33aSmFTCY8PFUCxIE/gLyJk02vLI3pPDdgHCKxsanbg M3VEKGJyl7zz624K4Tz1LuIOkt6o3pEIoffRjweEPIWa9GOno7zgXMuOwx+HNqgYXmYp gTFb5RH03WJ12nLThXVlkJwPuo1VT5RC5VPyLnEM5zqbPuuVfgDqUglu4s9oF53OXyNg 0h22+lacevKhNounZJVRJfkT+oejXSPrKjj7GF+eyBxeScgxyWVQ6kwLEnUl7aeRAEQG OGl5X0q4eoKbMjc70Oq1k7oe1WN3ETZaz5NxhlqXu6sw+5RYkbXeqqQCZr3bXLnXaBeD qf9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N1ChtY+M; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-195058-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a016f7d4asi2116400a12.216.2024.05.30.01.25.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 01:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195058-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N1ChtY+M; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-195058-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 B83F41F232A1 for ; Thu, 30 May 2024 08:25:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D48314F9D5; Thu, 30 May 2024 08:25:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="N1ChtY+M" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 C645FDDA1; Thu, 30 May 2024 08:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717057540; cv=none; b=WN8C4nSB3ZoqPJdIDoK0/kupsoK0WbZPItVQCuJ+Nr1acwwiuLm7zK/fF9aVCeyTrg7AtuMSJUwOVBsjDPU6f5gXFMFXIwH1jlpolRFTOy0LfcrlouwBthuxS4yUeynghzgpvhJRt7xmw+AayOqihF1onqdo1l4QnwG70tF7aHQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717057540; c=relaxed/simple; bh=YKqNURWS8n2g55ZrdJEWt/gjHie39zpHSbth/z2c/c4=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=Kj0+iRJYve1roXup+wFx3IFjBPaJ0bT6kvJxaiCA+TnP4OQU/XDe++3dUmhNVEircWs9OIEcgaFPxZK8T0tdt7YmQXvnWkMJScLty7XAcNQFKgJUjCtkbG9Pf7zd2ypwfmlcH58J85fyiHbZqPmC3ZHoshPCBkzVSmfLa/ZW1Dg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=N1ChtY+M; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717057539; x=1748593539; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=YKqNURWS8n2g55ZrdJEWt/gjHie39zpHSbth/z2c/c4=; b=N1ChtY+MSS33jplzjXDIVeMd7XoNBAA1Esgh/Kx8Jwnxp1wCajpJKR+i mGeRqP3K5P0a/R0c9nsoUT3s1w0XOYsgqa+sK0BIv9WrHaXaFSOKHFB5w VY9gzdVeq/WfkTyPCJXn0m6QpQ55M4kaVQroqHqvxg/j5rYTy6E7IiWSO /jP50JJurzN3kmmLzIGsv7uQagUh1fBykKNQFw6BFF7ifeYD/hJTfwu9q 7+AhUHOblFXE3Lz6IPP7yiwzhTkd2YlqpOCP/JfNm635T5P5+j0JYvp4z kaRmLsC3oJFY88agvA4FiRN3eehotmx8DW2rlxIua+O85Oqo/1Oc8pykh w==; X-CSE-ConnectionGUID: EB5Dw9BUTmOXChRBrWTYPg== X-CSE-MsgGUID: xdA9UZNcTxivVjn4qEekDQ== X-IronPort-AV: E=McAfee;i="6600,9927,11087"; a="17358450" X-IronPort-AV: E=Sophos;i="6.08,199,1712646000"; d="scan'208";a="17358450" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 01:25:27 -0700 X-CSE-ConnectionGUID: 2ClqADvBRt6M6ADjJgu1dw== X-CSE-MsgGUID: iXQlDffJQPW0rqXEQT8ZBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,199,1712646000"; d="scan'208";a="40183270" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.150]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 01:25:20 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Thu, 30 May 2024 11:25:16 +0300 (EEST) To: "Ng, Boon Khai" cc: Andrew Lunn , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , "netdev@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "Ang, Tien Sung" , "G Thomas, Rohan" , "Looi, Hong Aun" , Andy Shevchenko Subject: RE: [Enable Designware XGMAC VLAN Stripping Feature v2 1/1] net: stmmac: dwxgmac2: Add support for HW-accelerated VLAN Stripping In-Reply-To: Message-ID: <322d8745-7eae-4a68-4606-d9fdb19b4662@linux.intel.com> References: <20240527093339.30883-1-boon.khai.ng@intel.com> <20240527093339.30883-2-boon.khai.ng@intel.com> <48176576-e1d2-4c45-967a-91cabb982a21@lunn.ch> <48673551-cada-4194-865f-bc04c1e19c29@lunn.ch> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Thu, 30 May 2024, Ng, Boon Khai wrote: > > It is well know this driver is a mess. I just wanted to check you are not adding > > to be mess by simply cut/pasting rather than refactoring code. > > Okay sure Andrew, will take note on this. > > > static void dwmac4_rx_hw_vlan(struct mac_device_info *hw, > > struct dma_desc *rx_desc, struct sk_buff *skb) { > > if (hw->desc->get_rx_vlan_valid(rx_desc)) { > > u16 vid = hw->desc->get_rx_vlan_tci(rx_desc); > > > > __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid); > > } > > } > > > > Looks identical to me. > > Yes, some of the functions are identical, the driver has been divided > into dwmac4_core.c and dwxgmac2_core.c initially, so to enable the > rx_hw_vlan, it is porting from dwmac4_core to dwxgmac2_core. > > > The basic flow is the same. Lets look at the #defines: > > > Right, the basic flow is direct copy and paste, and only the function > name is updated from dwmac4 to dwxgmac2. > > +static inline bool dwxgmac2_wrback_get_rx_vlan_valid(struct dma_desc > > +*p) { > > + u32 et_lt; > > + > > + et_lt = FIELD_GET(XGMAC_RDES3_ET_LT, le32_to_cpu(p->des3)); > > + > > + return et_lt >= XGMAC_ET_LT_VLAN_STAG && > > + et_lt <= XGMAC_ET_LT_DVLAN_STAG_CTAG; } > > > > static bool dwmac4_wrback_get_rx_vlan_valid(struct dma_desc *p) { > > return ((le32_to_cpu(p->des3) & RDES3_LAST_DESCRIPTOR) && > > (le32_to_cpu(p->des3) & RDES3_RDES0_VALID)); } > > > > #define RDES3_RDES0_VALID BIT(25) > > #define RDES3_LAST_DESCRIPTOR BIT(28) > > > > #define XGMAC_RDES3_ET_LT GENMASK(19, 16) > > +#define XGMAC_ET_LT_VLAN_STAG 8 > > +#define XGMAC_ET_LT_VLAN_CTAG 9 > > +#define XGMAC_ET_LT_DVLAN_CTAG_CTAG 10 > > > > This does actually look different. > > > > Yes, this is the part in the descriptor where dwxgmac2 get the vlan Valid. > it is described in Designware cores xgmac 10G Ethernet MAC version 3.10a > page 1573. > > > Please take a step back and see if you can help clean up some of the mess in > > this driver by refactoring bits of identical code, rather than copy/pasting it. > > > > Appreciate if you could help to point out which part that I have to cleanup? > Do you mean I should combine the identical part between dwmac4_core.c > and dwxgmac2_core.c? or I should update the part that looks different and > make them the same? You should generalize the existing functions into some other file within stmmac/ folder and call those functions from both dwmac4_core and dwxgmac2_core. Do the rework of existing function & callers first and add the new bits in another patch in the patch series. Unfortunately, it's hard to catch copy-paste like this from other files when not very familiar with the driver. -- i.