All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: Biju Das <biju.das.jz@bp.renesas.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Sergei Shtylyov <sergei.shtylyov@gmail.com>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	Adam Ford <aford173@gmail.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	<netdev@vger.kernel.org>, <linux-renesas-soc@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>
Subject: Re: [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet
Date: Fri, 1 Oct 2021 20:27:56 +0300	[thread overview]
Message-ID: <82f58946-b88b-8990-8788-a58f8d1468c2@omp.ru> (raw)
In-Reply-To: <20210923140813.13541-17-biju.das.jz@bp.renesas.com>

On 9/23/21 5:08 PM, Biju Das wrote:

> This patch series adds RX(packet receive) function for
> Gigabit Ethernet found on RZ/G2L SoC.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |   1 +
>  drivers/net/ethernet/renesas/ravb_main.c | 157 ++++++++++++++++++++++-
>  2 files changed, 156 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index b0e067a6a8ee..85260f89e1cd 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -1092,6 +1092,7 @@ struct ravb_private {
>  
>  	int duplex;
>  	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
> +	struct sk_buff *rxtop_skb;

   I'd prefer for this one declared earler in the *struct*, as well. And why not e.g 'rx_1st_skb'?

>  
>  	const struct ravb_hw_info *info;
>  	struct reset_control *rstc;
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index a08da7a37b92..867e180e6655 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -705,6 +705,23 @@ static void ravb_get_tx_tstamp(struct net_device *ndev)
>  	}
>  }
>  
> +static void ravb_rx_csum_rgeth(struct sk_buff *skb)
> +{
> +	u8 *hw_csum;
> +
> +	/* The hardware checksum is contained in sizeof(__sum16) (2) bytes
> +	 * appended to packet data
> +	 */
> +	if (unlikely(skb->len < sizeof(__sum16)))
> +		return;
> +	hw_csum = skb_tail_pointer(skb) - sizeof(__sum16);
> +
> +	if (*hw_csum == 0)
> +		skb->ip_summed = CHECKSUM_UNNECESSARY;
> +	else
> +		skb->ip_summed = CHECKSUM_NONE;

   Mhm, what's the point of this whole function then? Why it can't be a copy of the R-Car analog?

[...]
> @@ -720,11 +737,147 @@ static void ravb_rx_csum(struct sk_buff *skb)
[...]
>  /* Packet receive function for Gigabit Ethernet */
>  static bool ravb_rgeth_rx(struct net_device *ndev, int *quota, int q)
>  {
> -	/* Place holder */
> -	return true;
> +	struct ravb_private *priv = netdev_priv(ndev);
> +	int entry = priv->cur_rx[q] % priv->num_rx_ring[q];
> +	int boguscnt = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q];
> +	struct net_device_stats *stats = &priv->stats[q];

   [q] should be dropped, as we've agreed...

> +	struct ravb_rx_desc *desc;
> +	struct sk_buff *skb;
> +	dma_addr_t dma_addr;
> +	u8  desc_status;
> +	u8  die_dt;
> +	u16 pkt_len;
> +	int limit;
> +
> +	boguscnt = min(boguscnt, *quota);
> +	limit = boguscnt;
> +	desc = &priv->rgeth_rx_ring[q][entry];
> +	while (desc->die_dt != DT_FEMPTY) {
> +		/* Descriptor type must be checked before all other reads */
> +		dma_rmb();
> +		desc_status = desc->msc;
> +		pkt_len = le16_to_cpu(desc->ds_cc) & RX_DS;
> +
> +		if (--boguscnt < 0)
> +			break;
> +
> +		/* We use 0-byte descriptors to mark the DMA mapping errors */
> +		if (!pkt_len)
> +			continue;
> +
> +		if (desc_status & MSC_MC)
> +			stats->multicast++;
> +
> +		if (desc_status & (MSC_CRC | MSC_RFE | MSC_RTSF | MSC_RTLF | MSC_CEEF)) {
> +			stats->rx_errors++;
> +			if (desc_status & MSC_CRC)
> +				stats->rx_crc_errors++;
> +			if (desc_status & MSC_RFE)
> +				stats->rx_frame_errors++;
> +			if (desc_status & (MSC_RTLF | MSC_RTSF))
> +				stats->rx_length_errors++;
> +			if (desc_status & MSC_CEEF)
> +				stats->rx_missed_errors++;
> +		} else {
> +			die_dt = desc->die_dt & 0xF0;
> +			switch (die_dt) {
> +			case DT_FSINGLE:
> +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> +				skb_put(skb, pkt_len);
> +				skb->protocol = eth_type_trans(skb, ndev);
> +				if (ndev->features & NETIF_F_RXCSUM)
> +					ravb_rx_csum_rgeth(skb);
> +				napi_gro_receive(&priv->napi[q], skb);
> +				stats->rx_packets++;
> +				stats->rx_bytes += pkt_len;
> +				break;
> +			case DT_FSTART:
> +				priv->rxtop_skb = ravb_get_skb_rgeth(ndev, q, entry, desc);

   But don't you need to  copy the data in this case?

> +				skb_put(priv->rxtop_skb, pkt_len);
> +				break;
> +			case DT_FMID:
> +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> +				skb_copy_to_linear_data_offset(priv->rxtop_skb,
> +							       priv->rxtop_skb->len,
> +							       skb->data,
> +							       pkt_len);
> +				skb_put(priv->rxtop_skb, pkt_len);
> +				dev_kfree_skb(skb);
> +				break;
> +			case DT_FEND:
> +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> +				skb_copy_to_linear_data_offset(priv->rxtop_skb,
> +							       priv->rxtop_skb->len,
> +							       skb->data,
> +							       pkt_len);
> +				skb_put(priv->rxtop_skb, pkt_len);
> +				dev_kfree_skb(skb);
> +				priv->rxtop_skb->protocol =
> +					eth_type_trans(priv->rxtop_skb, ndev);
> +				if (ndev->features & NETIF_F_RXCSUM)
> +					ravb_rx_csum_rgeth(skb);
> +				napi_gro_receive(&priv->napi[q],
> +						 priv->rxtop_skb);
> +				stats->rx_packets++;
> +				stats->rx_bytes += priv->rxtop_skb->len;
> +				break;
> +			}
> +		}
> +
> +		entry = (++priv->cur_rx[q]) % priv->num_rx_ring[q];
> +		desc = &priv->rgeth_rx_ring[q][entry];
> +	}
> +
> +	/* Refill the RX ring buffers. */
> +	for (; priv->cur_rx[q] - priv->dirty_rx[q] > 0; priv->dirty_rx[q]++) {
> +		entry = priv->dirty_rx[q] % priv->num_rx_ring[q];
> +		desc = &priv->rgeth_rx_ring[q][entry];
> +		desc->ds_cc = cpu_to_le16(RGETH_RX_DESC_DATA_SIZE);
> +
> +		if (!priv->rx_skb[q][entry]) {
> +			skb = netdev_alloc_skb(ndev,
> +					       RGETH_RX_BUFF_MAX + RAVB_ALIGN - 1);

   ALIGN(RGETH_RX_BUFF_MAX, RAVB_ALIGN)?

[...]

MBR, Sergey

  reply	other threads:[~2021-10-01 17:28 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
2021-09-23 14:07 ` [RFC/PATCH 01/18] ravb: Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar" Biju Das
2021-09-27 19:54   ` Sergey Shtylyov
2021-09-23 14:07 ` [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active" Biju Das
2021-09-23 16:07   ` Sergey Shtylyov
2021-09-23 16:35     ` Biju Das
2021-09-23 17:57       ` Sergey Shtylyov
2021-09-23 18:20         ` Biju Das
2021-09-26 13:34           ` Biju Das
2021-09-23 14:07 ` [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac Biju Das
2021-09-23 17:41   ` Sergey Shtylyov
2021-09-23 18:42     ` Biju Das
2021-09-23 19:07   ` Sergey Shtylyov
2021-09-23 19:22     ` Biju Das
2021-09-23 19:29       ` Biju Das
2021-09-26 13:38         ` Biju Das
2021-09-23 14:07 ` [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L Biju Das
2021-09-23 18:05   ` Sergey Shtylyov
2021-09-23 18:10     ` Sergey Shtylyov
2021-09-23 18:13     ` Biju Das
2021-09-26 13:40       ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 05/18] ravb: Exclude gPTP feature support " Biju Das
2021-09-23 19:00   ` Sergey Shtylyov
2021-09-23 19:13     ` Biju Das
2021-09-23 19:41       ` Sergey Shtylyov
2021-09-23 19:45         ` Biju Das
2021-09-26 13:48           ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info Biju Das
2021-09-23 20:19   ` Sergey Shtylyov
2021-09-24  6:19     ` Biju Das
2021-09-26 13:54       ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 07/18] ravb: Add magic_pkt " Biju Das
2021-09-23 20:42   ` Sergey Shtylyov
2021-09-24  6:24     ` Biju Das
2021-09-26 13:56       ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection " Biju Das
2021-09-24 19:49   ` Sergey Shtylyov
2021-09-25  6:23     ` Biju Das
2021-09-26 15:49       ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 09/18] ravb: Add half_duplex " Biju Das
2021-09-24 20:07   ` Sergey Shtylyov
2021-09-25  6:37     ` Biju Das
2021-09-26 15:51     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC Biju Das
2021-09-24 20:44   ` Sergey Shtylyov
2021-09-25  6:38     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct ravb_hw_info Biju Das
2021-09-24 19:35   ` Sergey Shtylyov
2021-09-26 15:48     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 12/18] ravb: Add timestamp " Biju Das
2021-09-25 20:52   ` Sergey Shtylyov
2021-09-26  6:34     ` Biju Das
2021-09-26 16:52       ` Biju Das
2021-09-26 20:45       ` Sergey Shtylyov
2021-09-26 20:48         ` Sergei Shtylyov
2021-09-27  6:10           ` Biju Das
2021-09-27  6:04         ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for GbEthernet Biju Das
2021-09-27 19:28   ` Sergey Shtylyov
2021-09-28  9:24     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 14/18] ravb: Add rx_ring_format function " Biju Das
2021-09-27 20:32   ` Sergey Shtylyov
2021-09-29  7:49     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 15/18] ravb: Add rx_alloc helper " Biju Das
2021-09-23 14:08 ` [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet Biju Das
2021-10-01 17:27   ` Sergey Shtylyov [this message]
2021-10-04 14:56     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 17/18] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
2021-09-28 20:50   ` Sergey Shtylyov
2021-09-23 14:08 ` [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L Biju Das
2021-09-30 20:39   ` Sergey Shtylyov
2021-10-01  6:53     ` Biju Das
2021-10-01  9:13       ` Sergey Shtylyov
2021-10-01  9:26         ` Biju Das
2021-10-01  8:22     ` Biju Das
2021-09-23 15:11 ` [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Sergey Shtylyov
2021-09-23 15:13   ` Sergey Shtylyov
2021-09-23 15:37   ` Jakub Kicinski
2021-09-23 17:43     ` Sergey Shtylyov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=82f58946-b88b-8990-8788-a58f8d1468c2@omp.ru \
    --to=s.shtylyov@omp.ru \
    --cc=Chris.Paterson2@renesas.com \
    --cc=aford173@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=biju.das@bp.renesas.com \
    --cc=davem@davemloft.net \
    --cc=geert+renesas@glider.be \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=sergei.shtylyov@gmail.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.