dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Howard Wang <howard_wang@realsil.com.cn>
Cc: <dev@dpdk.org>, <pro_nic_dpdk@realtek.com>
Subject: Re: [PATCH v3 12/18] net/r8169: implement Tx path
Date: Tue, 22 Oct 2024 22:22:53 -0700	[thread overview]
Message-ID: <20241022222253.5a4e905f@hermes.local> (raw)
In-Reply-To: <20241023033328.191827-13-howard_wang@realsil.com.cn>

On Wed, 23 Oct 2024 11:33:22 +0800
Howard Wang <howard_wang@realsil.com.cn> wrote:

> +static uint32_t
> +rtl8125_get_patch_pad_len(struct rte_mbuf *tx_pkt)
> +{
> +	uint16_t dest_port = 0;
> +	uint32_t pad_len = 0;
> +	int udp_hdr_len = 8;
> +	int trans_data_len, l4_offset;
> +
> +	if (!(tx_pkt->l4_len && (tx_pkt->data_len < 175)))
> +		goto no_padding;
> +
> +	l4_offset = tx_pkt->l2_len + tx_pkt->l3_len;
> +	trans_data_len = tx_pkt->data_len - l4_offset;
> +
> +	if (trans_data_len > 3 && trans_data_len < MIN_PATCH_LENGTH) {
> +		rte_memcpy(&dest_port, rte_pktmbuf_mtod(tx_pkt,
> +							struct rte_ether_hdr *) + l4_offset + 2, 2);
> +		dest_port = ntohs(dest_port);

A couple things here.
1. Use the function rte_pktmbuf_mtod_offset to pick up the header.
2. Don't use hard coded offset from that use a local pointer to the type
3. Don't hard code the size of uint16.
4. Don't use rte_memcpy() for trivially small fixed size objects.
5. Avoid useless initializations (like dest_port)
6. Don't hard code size of UDP header.

  reply	other threads:[~2024-10-23  5:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23  3:33 [PATCH v3 00/18] Modify some code as suggested by the maintainer Howard Wang
2024-10-23  3:33 ` [PATCH v3 01/18] net/r8169: add PMD driver skeleton Howard Wang
2024-10-23  5:17   ` Stephen Hemminger
2024-10-23  5:59     ` 答复: " 王颢
2024-10-23  6:16       ` Stephen Hemminger
2024-10-31  7:47     ` 答复: " 王颢
2024-10-31 15:49       ` Stephen Hemminger
2024-10-23  3:33 ` [PATCH v3 02/18] net/r8169: add logging structure Howard Wang
2024-10-23  3:33 ` [PATCH v3 03/18] net/r8169: add hardware registers access routines Howard Wang
2024-10-23  3:33 ` [PATCH v3 04/18] net/r8169: implement core logic for Tx/Rx Howard Wang
2024-10-23  3:33 ` [PATCH v3 05/18] net/r8169: add support for hw config Howard Wang
2024-10-23  3:33 ` [PATCH v3 06/18] net/r8169: add phy registers access routines Howard Wang
2024-10-23  3:33 ` [PATCH v3 07/18] net/r8169: add support for hardware operations Howard Wang
2024-10-23  3:33 ` [PATCH v3 08/18] net/r8169: add support for phy configuration Howard Wang
2024-10-23  3:33 ` [PATCH v3 09/18] net/r8169: add support for hw initialization Howard Wang
2024-10-23  3:33 ` [PATCH v3 10/18] net/r8169: add link status and interrupt management Howard Wang
2024-10-23  3:33 ` [PATCH v3 11/18] net/r8169: implement Rx path Howard Wang
2024-10-23  3:33 ` [PATCH v3 12/18] net/r8169: implement Tx path Howard Wang
2024-10-23  5:22   ` Stephen Hemminger [this message]
2024-10-23  3:33 ` [PATCH v3 13/18] net/r8169: implement device statistics Howard Wang
2024-10-23  3:33 ` [PATCH v3 14/18] net/r8169: implement promisc and allmulti modes Howard Wang
2024-10-23  3:33 ` [PATCH v3 15/18] net/r8169: impelment MTU configuration Howard Wang
2024-10-23  3:33 ` [PATCH v3 16/18] net/r8169: add support for getting fw version Howard Wang
2024-10-23  3:33 ` [PATCH v3 17/18] net/r8169: add driver_start and driver_stop Howard Wang
2024-10-23  3:33 ` [PATCH v3 18/18] doc/guides/nics: add documents for r8169 pmd Howard Wang

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=20241022222253.5a4e905f@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=howard_wang@realsil.com.cn \
    --cc=pro_nic_dpdk@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;
as well as URLs for NNTP newsgroup(s).