Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp32580lqb; Tue, 28 May 2024 08:08:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUq80Hp6BTBo7UCSmLdzupbBpTlA69uTIcYDsXY66RWayS2mmFd9X09ApPavwnuwRaroyNYU0xljH/Iy0+XBfP0grxF3QnSO5WyJIsgLw== X-Google-Smtp-Source: AGHT+IEPePGprlcpFRT2UcmvzIHeFCRxp2JYINrWskdZca5W2AItMIAjxrh2MKNpwuW4wGVNxdyv X-Received: by 2002:a05:6a00:1f12:b0:6f6:7c6a:2c14 with SMTP id d2e1a72fcca58-6f8f2c56e53mr12819210b3a.4.1716908883288; Tue, 28 May 2024 08:08:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716908883; cv=pass; d=google.com; s=arc-20160816; b=rjuB2T8pmkyhNwhZ2dd177mIP0ASaCVAnSA+NB36K6cZhi66MUUrNJxUoWctBrmAdu cGgjD8Gi8h2EG288Of3aA4rKLFYFDtxnIo7UNa36XG+y35cwGPil1olaMgrrNnnJCHmm /uNlbZI1Wmyf7PPaf7NDiuAKC/ULz2VH8loTbQVBi1T7X/PqBGXOYWVAK6Wo4gvA4/g3 o9mYMltz6BBGcNY9goB2hncqQH40VWhBnH65KlnE8SNrLBOA89edDb/bzBFI2wwKDJDc J/v/qIxq3e8H0UC7bNI8siLJjkS4A8gBm33rJLmPTyI2yqB9IpnFLuimuZTeJe1K3cCk DnIw== 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; bh=NUFXfcrJYGpKPZ3yqjilW1jTZxVL1Rw5VkRHifrCDaY=; fh=sUSjRpK/Wu5cmnXAa9+f+Tp7sXIZjWkQDF+/Uu3kmYo=; b=Rf4e7cT66EEWAULe5A1gbfK3mWCzBZY3oE0aFNk4x+ZhNMYSOxUjtVaMUvpJsf5Kwl utybwN+jFTz4NXL+oDf9hdiQNj5+pujeNzv2s8V1gD7oc8Sij5LIhE/NpPImJlOldxBw lFxoUMqozh69rLFWHj3HyOFeXmYN95jwGN0ypOLjWyYzEGzhDA6SVn0yFO3Selt3CnKK 93nUM7DDunmkswIj3jOqY0mhwf3qvO79eJ8ZNaV5pwM3pRT0t3pBqrakL94XGKUlANOJ 1/gyp3AcDjW7utK3ZWZF5wSySCLejcdyt1ksgpWUpLgHykHd54VjRAEnHnZfjO0eiNBR Vqog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=bp.renesas.com dmarc=pass fromdomain=bp.renesas.com); spf=pass (google.com: domain of linux-kernel+bounces-192607-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f91c1eee7bsi8078137b3a.367.2024.05.28.08.08.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 08:08:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192607-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=bp.renesas.com dmarc=pass fromdomain=bp.renesas.com); spf=pass (google.com: domain of linux-kernel+bounces-192607-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B8D51286187 for ; Tue, 28 May 2024 15:07:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46815178361; Tue, 28 May 2024 15:04:13 +0000 (UTC) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB0B2178366; Tue, 28 May 2024 15:04:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716908652; cv=none; b=QzyV+rw18mqGxxZ6BYMZcOXnsAqrTYPP8KXLete84qN2CY7JoCYjs6DFtk5S/Ay1cj3Bavszgw9wa7Lc09F5UtvK3fiQ1nED2sgVzQNJBzMsgm1iIgR+lS7S94b2MAib8MVJP+mjFSamms02fGZ+DmDU71kq3E6F0jl0NsyqfOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716908652; c=relaxed/simple; bh=sWGKmu8ASdPFfq8tc+XcJUTwK7fQaboV4PSwnXO22rc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B08vG522sNshMvldgEVG/HejHzBJ5tH8zEYkOYa2EQZAhJwM24gAJD2JLNGgB9SRvt33xV0UrkSJ6Ee2wkRru8O/lvwD4rODOFhRiSftX43USzYXr01bi0+mc05jC0oaJNmmqkeH6PWVcoVVjuzteKNtaQHYpVkea7kM9gFxxyc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-IronPort-AV: E=Sophos;i="6.08,195,1712588400"; d="scan'208";a="205944545" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 29 May 2024 00:04:09 +0900 Received: from renesas-deb12.cephei.uk (unknown [10.226.93.69]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 20D26400CF19; Wed, 29 May 2024 00:04:04 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Cc: Paul Barker , Biju Das , Claudiu Beznea , Yoshihiro Shimoda , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v4 4/7] net: ravb: Refactor GbEth RX code path Date: Tue, 28 May 2024 16:03:36 +0100 Message-Id: <20240528150339.6791-5-paul.barker.ct@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240528150339.6791-1-paul.barker.ct@bp.renesas.com> References: <20240528150339.6791-1-paul.barker.ct@bp.renesas.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 We can reduce code duplication in ravb_rx_gbeth(). Signed-off-by: Paul Barker --- Changes v3->v4: * Used switch statements instead of if statements in ravb_rx_gbeth(). drivers/net/ethernet/renesas/ravb_main.c | 73 +++++++++++++----------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7df7d2e93a3a..c9c5cc641589 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -817,47 +817,54 @@ static int ravb_rx_gbeth(struct net_device *ndev, int budget, int q) stats->rx_missed_errors++; } else { die_dt = desc->die_dt & 0xF0; + skb = ravb_get_skb_gbeth(ndev, entry, desc); switch (die_dt) { case DT_FSINGLE: - skb = ravb_get_skb_gbeth(ndev, entry, desc); + case DT_FSTART: + /* Start of packet: + * Set initial data length. + */ skb_put(skb, desc_len); + + /* Save this SKB if the packet spans multiple + * descriptors. + */ + if (die_dt == DT_FSTART) + priv->rx_1st_skb = skb; + break; + + case DT_FMID: + case DT_FEND: + /* Continuing a packet: + * Move data into the saved SKB. + */ + skb_copy_to_linear_data_offset(priv->rx_1st_skb, + priv->rx_1st_skb->len, + skb->data, + desc_len); + skb_put(priv->rx_1st_skb, desc_len); + dev_kfree_skb(skb); + + /* Set skb to point at the whole packet so that + * we only need one code path for finishing a + * packet. + */ + skb = priv->rx_1st_skb; + } + + switch (die_dt) { + case DT_FSINGLE: + case DT_FEND: + /* Finishing a packet: + * Determine protocol & checksum, hand off to + * NAPI and update our stats. + */ skb->protocol = eth_type_trans(skb, ndev); if (ndev->features & NETIF_F_RXCSUM) ravb_rx_csum_gbeth(skb); + stats->rx_bytes += skb->len; napi_gro_receive(&priv->napi[q], skb); rx_packets++; - stats->rx_bytes += desc_len; - break; - case DT_FSTART: - priv->rx_1st_skb = ravb_get_skb_gbeth(ndev, entry, desc); - skb_put(priv->rx_1st_skb, desc_len); - break; - case DT_FMID: - skb = ravb_get_skb_gbeth(ndev, entry, desc); - skb_copy_to_linear_data_offset(priv->rx_1st_skb, - priv->rx_1st_skb->len, - skb->data, - desc_len); - skb_put(priv->rx_1st_skb, desc_len); - dev_kfree_skb(skb); - break; - case DT_FEND: - skb = ravb_get_skb_gbeth(ndev, entry, desc); - skb_copy_to_linear_data_offset(priv->rx_1st_skb, - priv->rx_1st_skb->len, - skb->data, - desc_len); - skb_put(priv->rx_1st_skb, desc_len); - dev_kfree_skb(skb); - priv->rx_1st_skb->protocol = - eth_type_trans(priv->rx_1st_skb, ndev); - if (ndev->features & NETIF_F_RXCSUM) - ravb_rx_csum_gbeth(priv->rx_1st_skb); - stats->rx_bytes += priv->rx_1st_skb->len; - napi_gro_receive(&priv->napi[q], - priv->rx_1st_skb); - rx_packets++; - break; } } } -- 2.39.2