mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Justin Lai <justinlai0215@realtek.com>, kuba@kernel.org
Cc: davem@davemloft.net, edumazet@google.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	andrew@lunn.ch, pkshih@realtek.com, larry.chiu@realtek.com
Subject: Re: [PATCH net-next v14 07/13] rtase: Implement a function to receive packets
Date: Tue, 12 Dec 2023 11:04:52 +0100	[thread overview]
Message-ID: <18552cff6fe32d4c21b4751cd6be4ff4757c63e8.camel@redhat.com> (raw)
In-Reply-To: <20231208094733.1671296-8-justinlai0215@realtek.com>

On Fri, 2023-12-08 at 17:47 +0800, Justin Lai wrote:
> Implement rx_handler to read the information of the rx descriptor,
> thereby checking the packet accordingly and storing the packet
> in the socket buffer to complete the reception of the packet.
> 
> Signed-off-by: Justin Lai <justinlai0215@realtek.com>
> ---
>  .../net/ethernet/realtek/rtase/rtase_main.c   | 148 ++++++++++++++++++
>  1 file changed, 148 insertions(+)
> 
> diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> index eee792ea4760..83a119389110 100644
> --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> @@ -451,6 +451,154 @@ static void rtase_rx_ring_clear(struct rtase_ring *ring)
>  	}
>  }
>  
> +static int rtase_fragmented_frame(u32 status)
> +{
> +	return (status & (RX_FIRST_FRAG | RX_LAST_FRAG)) !=
> +		(RX_FIRST_FRAG | RX_LAST_FRAG);
> +}
> +
> +static void rtase_rx_csum(const struct rtase_private *tp, struct sk_buff *skb,
> +			  const union rx_desc *desc)
> +{
> +	u32 opts2 = le32_to_cpu(desc->desc_status.opts2);
> +
> +	/* rx csum offload */
> +	if (((opts2 & RX_V4F) && !(opts2 & RX_IPF)) || (opts2 & RX_V6F)) {
> +		if (((opts2 & RX_TCPT) && !(opts2 & RX_TCPF)) ||
> +		    ((opts2 & RX_UDPT) && !(opts2 & RX_UDPF))) {
> +			skb->ip_summed = CHECKSUM_UNNECESSARY;
> +		} else {
> +			skb->ip_summed = CHECKSUM_NONE;
> +		}
> +	} else {
> +		skb->ip_summed = CHECKSUM_NONE;
> +	}
> +}
> +
> +static void rtase_rx_vlan_skb(union rx_desc *desc, struct sk_buff *skb)
> +{
> +	u32 opts2 = le32_to_cpu(desc->desc_status.opts2);
> +
> +	if (!(opts2 & RX_VLAN_TAG))
> +		return;
> +
> +	__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), swab16(opts2 & VLAN_TAG_MASK));
> +}
> +
> +static void rtase_rx_skb(const struct rtase_ring *ring, struct sk_buff *skb)
> +{
> +	struct rtase_int_vector *ivec = ring->ivec;
> +
> +	napi_gro_receive(&ivec->napi, skb);
> +}
> +
> +static int rx_handler(struct rtase_ring *ring, int budget)
> +{
> +	const struct rtase_private *tp = ring->ivec->tp;
> +	u32 pkt_size, cur_rx, delta, entry, status;
> +	union rx_desc *desc_base = ring->desc;
> +	struct net_device *dev = tp->dev;
> +	struct sk_buff *skb;
> +	union rx_desc *desc;
> +	int workdone = 0;
> +
> +	if (!ring->desc)
> +		return workdone;

Why is the above test required? How can be ring->desc NULL here?

> +
> +	cur_rx = ring->cur_idx;
> +	entry = cur_rx % NUM_DESC;
> +	desc = &desc_base[entry];
> +
> +	do {
> +		/* make sure discriptor has been updated */
> +		rmb();
> +		status = le32_to_cpu(desc->desc_status.opts1);
> +
> +		if (status & DESC_OWN)
> +			break;
> +
> +		if (unlikely(status & RX_RES)) {
> +			if (net_ratelimit())
> +				netdev_warn(dev, "Rx ERROR. status = %08x\n",
> +					    status);
> +
> +			dev->stats.rx_errors++;
> +
> +			if (status & (RX_RWT | RX_RUNT))
> +				dev->stats.rx_length_errors++;

The device has a single RX queue, right? Otherwise this kind of stats
accounting is going to be costly.

Cheers,

Paolo


  reply	other threads:[~2023-12-12 10:10 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  9:47 [PATCH net-next v14 00/13] Add Realtek automotive PCIe driver Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 01/13] rtase: Add pci table supported in this module Justin Lai
2023-12-12  9:36   ` Paolo Abeni
2023-12-12 16:05     ` Jakub Kicinski
2023-12-14 12:42     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 02/13] rtase: Implement the .ndo_open function Justin Lai
2023-12-12  9:49   ` Paolo Abeni
2023-12-14 12:44     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 03/13] rtase: Implement the rtase_down function Justin Lai
2023-12-12 19:27   ` Jakub Kicinski
2023-12-14 12:54     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 04/13] rtase: Implement the interrupt routine and rtase_poll Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 05/13] rtase: Implement hardware configuration function Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 06/13] rtase: Implement .ndo_start_xmit function Justin Lai
2023-12-12 19:32   ` Jakub Kicinski
2023-12-14 13:00     ` JustinLai0215
2023-12-14 17:24       ` Jakub Kicinski
2023-12-18 10:27     ` Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 07/13] rtase: Implement a function to receive packets Justin Lai
2023-12-12 10:04   ` Paolo Abeni [this message]
2023-12-14 12:45     ` JustinLai0215
2023-12-18 10:18     ` Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 08/13] rtase: Implement net_device_ops Justin Lai
2023-12-12 10:09   ` Paolo Abeni
2023-12-14 12:47     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 09/13] rtase: Implement pci_driver suspend and resume function Justin Lai
2023-12-12 19:19   ` Jakub Kicinski
2023-12-14 12:48     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 10/13] rtase: Implement ethtool function Justin Lai
2023-12-12 19:21   ` Jakub Kicinski
2023-12-08  9:47 ` [PATCH net-next v14 11/13] rtase: Add a Makefile in the rtase folder Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 12/13] realtek: Update the Makefile and Kconfig in the realtek folder Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 13/13] MAINTAINERS: Add the rtase ethernet driver entry Justin Lai
2023-12-12 19:22   ` Jakub Kicinski
2023-12-14 12:51     ` JustinLai0215
2023-12-14 17:27       ` Jakub Kicinski

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=18552cff6fe32d4c21b4751cd6be4ff4757c63e8.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=justinlai0215@realtek.com \
    --cc=kuba@kernel.org \
    --cc=larry.chiu@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pkshih@realtek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®