From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 47B062BDC0C for ; Wed, 14 Jan 2026 13:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768398438; cv=none; b=DM+TvH2atGhNmHeOszAFtJDw1dSwWONW5tg9KqqFK4XAi7Md77Sr2HbewS5jpc3cVtKpJJB3gOl/XUT6RD+46pE6M+QlB9gEHAwE4keTMsY3KwGe6A9Q0zJOWQw7BIVoFgjah2otyJv3Md2a7qEZ7U95WR0gZY56VcANmLQ2DDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768398438; c=relaxed/simple; bh=L3dR8NudphjzOLY06rRJEZjL9fEEuauxwFNrQodgmbk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qos9N74OTeH0A1UU8Hu/aP734/DHjRwYBTC2RXp5PLRQq8zQinzsKXX+d6inCcMobizcbvDh3op5d7WtrVXMAxXitl8xMrbRpud79UVpJu9DaWB/+MudNmu7CIrFev7Q6rc1E4LYrkexos9Wjtrqg+7ij2davyBqyVxBo2Rn3LU= 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=RCtYn47l; arc=none smtp.client-ip=209.85.128.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RCtYn47l" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-47ee07570deso9417695e9.1 for ; Wed, 14 Jan 2026 05:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768398436; x=1769003236; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=9jT5+6PNxAsiSLc4phs+HsvpCwG6ks9aQbUheKgFsmM=; b=RCtYn47luvoQ8q4+NaUZlfWWBG/l/k5+End8lqN0K9CXWV+mUFe0dIM/4PZ+VqxFHL Yn3pQGr6wWd4aISC/GalrilNj5bjK8CVpn0SRul/jW5bECMWBcUq4ZzT8PJwzN2WpoQ2 lMheyYHC7o8lKLhvrMO08ebk4F8xR19U1VBGoK2QI7yH8BPIkRc+sIiPLbdQhrU92NeG fZs+IdcEKjMy1lUAmeGQDU5S/0qZMCJSOvsgDNXKkS49C/WOXPQg+kRZLODNGXLlO3uV tNIUfhMGz5BEf2P99bFttYU0pDxCqUw0HoAra7Ey+saD2eFw9p7IGzjAY+xIk0Ibgo0i Im9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768398436; x=1769003236; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=9jT5+6PNxAsiSLc4phs+HsvpCwG6ks9aQbUheKgFsmM=; b=MGmBWImfEKM7FAMc6m3EBXBD7tzmqO5djeo4ZZcY9cY2XPvipvwsBz0MPgnSA+mxDw yMmWY0N7NL9ArRBhifktLk6MB38HzbWI4PaeFckGmWv/qR0qHusoz2iPIEu5S25Lpo4h wLb5Q7aEIIvVoQ9nHNAjPWiffwghYMWApkhH9cRbTs0xhbNsH/dck7WCZcTqkfULTu1D 7E5+650F8rtXPFMDzXphJFXn/eb6TCxROliVqzUR3nMSKEqIf0j8bBwFmqL0q2MHWaUz 71QzvKsk9ZpQwSV67Pozcv2S7WSoA4Si4DHmNZMfQbDJ0yQOptc+uOMWora4E3JEIk5J 09+Q== X-Forwarded-Encrypted: i=1; AJvYcCW2eKAf75NAyVCHS4n38kRhdST5pDKGcLy7lvYXPDkx/MFr8YpnZ2F5FrqY9484t4JeB5xrp2Jv0/IgQkc=@vger.kernel.org X-Gm-Message-State: AOJu0Yyp7q4SFvPI9Qs+JdBOvzPHPz6uMzH7wxQcuZ4ax+EeVPsCu+oN XK4QVmGcy5EaEtv3tjTs8T0RGX4b/cS23A0UlfyCeNiZXekPSZRn/W3k X-Gm-Gg: AY/fxX6aL7RBloKlCtTI3iRiL0/7EXS82c9Tw+h5Nz05A77b1/nMTWm5jtXd17DC2nq Vu+UpYlfdliWPSEN7bEY2mEdTj+u2ZOYsyrBfu2LiqMVHAK5rhErGy/HguiJ+ay4UaVcLL2g+FO WLvEOnt1PJBaCyfxUJefN7+LxfM79lNI53bD1yYMcM8+ykK6Ctyp6/ufdPN91F43al995EbnSkA mYEBKH+Dfdc/tJrksY3n/wKmFPH2bKA9DOvjzwID1KtwWdGZvlP6EZMD4W7mUvRLlc6LAXze+CR DSCbSW+4A8oBNZcEJpr/yclGML9DENh4YTNSABc9JWYYScCbu1r5x7CDvJFQRztuYZkQDbiPuIM Xccd+6eoeYAOKKbzUqHINCPiR4jYzVeZTsRc9njb3y25aMOAW9okektJ88GANxckXHdtueVlyKP InUryzEUTv3WcWeuUtfbReq8qM4BLheH+oTnVL5RRbH+SepxJi+nvH X-Received: by 2002:a05:600c:83c3:b0:477:8a2a:1244 with SMTP id 5b1f17b1804b1-47ee32fcf0amr27966825e9.11.1768398435487; Wed, 14 Jan 2026 05:47:15 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47ee85e8807sm5184825e9.16.2026.01.14.05.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 05:47:15 -0800 (PST) Date: Wed, 14 Jan 2026 13:47:13 +0000 From: David Laight To: Wei Fang Cc: shenwei.wang@nxp.com, xiaoning.wang@nxp.com, frank.li@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, bpf@vger.kernel.org Subject: Re: [PATCH net-next 07/11] net: fec: use switch statement to check the type of tx_buf Message-ID: <20260114134713.565f2b3c@pumpkin> In-Reply-To: <20260113032939.3705137-8-wei.fang@nxp.com> References: <20260113032939.3705137-1-wei.fang@nxp.com> <20260113032939.3705137-8-wei.fang@nxp.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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 Content-Transfer-Encoding: 7bit On Tue, 13 Jan 2026 11:29:35 +0800 Wei Fang wrote: > The tx_buf has three types: FEC_TXBUF_T_SKB, FEC_TXBUF_T_XDP_NDO and > FEC_TXBUF_T_XDP_TX. Currently, the driver uses 'if...else...' statements > to check the type and perform the corresponding processing. This is very > detrimental to future expansion. For example, if new types are added to > support XDP zero copy in the future, continuing to use 'if...else...' > would be a very bad coding style. So the 'if...else...' statements in > the current driver are replaced with switch statements to support XDP > zero copy in the future. The if...else... sequence has the advantage that the common 'cases' can be put first. The compiler will use a branch tree for a switch statement (jumps tables are pretty much not allowed because of speculative execution issues) and limit the maximum number of branches. That is likely to be pessimal in many cases - especially if it generates mispredicted branches for the common cases. So not clear cut at all. David