From: Jakub Kicinski <kuba@kernel.org>
To: Wei Fang <wei.fang@nxp.com>
Cc: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com,
xiaoning.wang@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
frank.li@nxp.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v4 net-next 2/5] net: enetc: add Tx checksum offload for i.MX95 ENETC
Date: Fri, 15 Nov 2024 19:00:33 -0800 [thread overview]
Message-ID: <20241115190033.7452392e@kernel.org> (raw)
In-Reply-To: <20241115024744.1903377-3-wei.fang@nxp.com>
On Fri, 15 Nov 2024 10:47:41 +0800 Wei Fang wrote:
> +static inline bool enetc_skb_is_ipv6(struct sk_buff *skb)
> +{
> + return vlan_get_protocol(skb) == htons(ETH_P_IPV6);
> +}
> +
> +static inline bool enetc_skb_is_tcp(struct sk_buff *skb)
> +{
> + return skb->csum_offset == offsetof(struct tcphdr, check);
> +}
Please don't use "inline" for trivial functions, compiler will inline
them anyway, and it hides unused code. In addition to being pointless.
> static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
> {
> bool do_vlan, do_onestep_tstamp = false, do_twostep_tstamp = false;
> @@ -160,6 +181,27 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
> dma_addr_t dma;
> u8 flags = 0;
>
> + enetc_clear_tx_bd(&temp_bd);
> + if (skb->ip_summed == CHECKSUM_PARTIAL) {
> + /* Can not support TSD and checksum offload at the same time */
> + if (priv->active_offloads & ENETC_F_TXCSUM &&
> + enetc_tx_csum_offload_check(skb) && !tx_ring->tsd_enable) {
> + temp_bd.l3_start = skb_network_offset(skb);
> + temp_bd.ipcs = enetc_skb_is_ipv6(skb) ? 0 : 1;
Linux calculates the IPv4 csum, always, no need.
> + temp_bd.l3_hdr_size = skb_network_header_len(skb) / 4;
> + temp_bd.l3t = enetc_skb_is_ipv6(skb) ? 1 : 0;
no need for ternary op, simply :
temp_bd.l3t = enetc_skb_is_ipv6(skb);
> + temp_bd.l4t = enetc_skb_is_tcp(skb) ? ENETC_TXBD_L4T_TCP :
> + ENETC_TXBD_L4T_UDP;
> + flags |= ENETC_TXBD_FLAGS_CSUM_LSO | ENETC_TXBD_FLAGS_L4CS;
> + } else {
> + if (skb_checksum_help(skb)) {
> + dev_err(tx_ring->dev, "skb_checksum_help() error\n");
> +
> + return 0;
don't print errors on the datapath, it may flood the logs
--
pw-bot: cr
next prev parent reply other threads:[~2024-11-16 3:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 2:47 [PATCH v4 net-next 0/5] Add more feautues for ENETC v4 - round 1 Wei Fang
2024-11-15 2:47 ` [PATCH v4 net-next 1/5] net: enetc: add Rx checksum offload for i.MX95 ENETC Wei Fang
2024-11-15 2:47 ` [PATCH v4 net-next 2/5] net: enetc: add Tx " Wei Fang
2024-11-16 3:00 ` Jakub Kicinski [this message]
2024-11-18 1:23 ` Wei Fang
2024-11-15 2:47 ` [PATCH v4 net-next 3/5] net: enetc: update max chained Tx BD number " Wei Fang
2024-11-15 2:47 ` [PATCH v4 net-next 4/5] net: enetc: add LSO support for i.MX95 ENETC PF Wei Fang
2024-11-15 2:47 ` [PATCH v4 net-next 5/5] net: enetc: add UDP segmentation offload support Wei Fang
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=20241115190033.7452392e@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=frank.li@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.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).