From: Alexander Lobakin <aleksander.lobakin@intel.com>
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>, <kuba@kernel.org>,
<pabeni@redhat.com>, <frank.li@nxp.com>, <horms@kernel.org>,
<idosch@idosch.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <imx@lists.linux.dev>
Subject: Re: [PATCH v8 net-next 1/4] net: enetc: add Tx checksum offload for i.MX95 ENETC
Date: Tue, 17 Dec 2024 16:13:13 +0100 [thread overview]
Message-ID: <5f2eb433-479c-49d2-bc2f-07f6c0a52c60@intel.com> (raw)
In-Reply-To: <20241213021731.1157535-2-wei.fang@nxp.com>
From: Wei Fang <wei.fang@nxp.com>
Date: Fri, 13 Dec 2024 10:17:28 +0800
> In addition to supporting Rx checksum offload, i.MX95 ENETC also supports
> Tx checksum offload. The transmit checksum offload is implemented through
> the Tx BD. To support Tx checksum offload, software needs to fill some
> auxiliary information in Tx BD, such as IP version, IP header offset and
> size, whether L4 is UDP or TCP, etc.
>
> Same as Rx checksum offload, Tx checksum offload capability isn't defined
> in register, so tx_csum bit is added to struct enetc_drvdata to indicate
> whether the device supports Tx checksum offload.
[...]
> @@ -163,6 +184,30 @@ 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_aux0 = FIELD_PREP(ENETC_TX_BD_L3_START,
> + skb_network_offset(skb));
> + temp_bd.l3_aux1 = FIELD_PREP(ENETC_TX_BD_L3_HDR_LEN,
> + skb_network_header_len(skb) / 4);
> + temp_bd.l3_aux1 |= FIELD_PREP(ENETC_TX_BD_L3T,
> + enetc_skb_is_ipv6(skb));
> + if (enetc_skb_is_tcp(skb))
> + temp_bd.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T,
> + ENETC_TXBD_L4T_TCP);
> + else
> + temp_bd.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T,
> + ENETC_TXBD_L4T_UDP);
> + flags |= ENETC_TXBD_FLAGS_CSUM_LSO | ENETC_TXBD_FLAGS_L4CS;
> + } else {
> + if (skb_checksum_help(skb))
Why not
} else if (skb_checksum_help(skb)) {
?
> + return 0;
> + }
> + }
> +
> i = tx_ring->next_to_use;
> txbd = ENETC_TXBD(*tx_ring, i);
> prefetchw(txbd);
> @@ -173,7 +218,6 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
>
> temp_bd.addr = cpu_to_le64(dma);
> temp_bd.buf_len = cpu_to_le16(len);
> - temp_bd.lstatus = 0;
Why is this removed and how is this change related to the checksum offload?
>
> tx_swbd = &tx_ring->tx_swbd[i];
> tx_swbd->dma = dma;
> @@ -594,7 +638,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb,
> {
> struct enetc_ndev_priv *priv = netdev_priv(ndev);
> struct enetc_bdr *tx_ring;
> - int count, err;
> + int count;
>
> /* Queue one-step Sync packet if already locked */
> if (skb->cb[0] & ENETC_F_TX_ONESTEP_SYNC_TSTAMP) {
> @@ -627,11 +671,6 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb,
> return NETDEV_TX_BUSY;
> }
>
> - if (skb->ip_summed == CHECKSUM_PARTIAL) {
> - err = skb_checksum_help(skb);
> - if (err)
> - goto drop_packet_err;
> - }
> enetc_lock_mdio();
> count = enetc_map_tx_buffs(tx_ring, skb);
> enetc_unlock_mdio();
> @@ -3274,6 +3313,7 @@ static const struct enetc_drvdata enetc_pf_data = {
>
> static const struct enetc_drvdata enetc4_pf_data = {
> .sysclk_freq = ENETC_CLK_333M,
> + .tx_csum = 1,
Maybe make it `bool tx_csum:1` instead of u8 and assign `true` here?
> .pmac_offset = ENETC4_PMAC_OFFSET,
> .eth_ops = &enetc4_pf_ethtool_ops,
> };
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
> index 72fa03dbc2dd..e82eb9a9137c 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.h
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.h
> @@ -234,6 +234,7 @@ enum enetc_errata {
>
> struct enetc_drvdata {
> u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */
> + u8 tx_csum:1;
> u64 sysclk_freq;
> const struct ethtool_ops *eth_ops;
> };
Thanks,
Olek
next prev parent reply other threads:[~2024-12-17 15:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 2:17 [PATCH v8 net-next 0/4] Add more feautues for ENETC v4 - round 1 Wei Fang
2024-12-13 2:17 ` [PATCH v8 net-next 1/4] net: enetc: add Tx checksum offload for i.MX95 ENETC Wei Fang
2024-12-17 15:13 ` Alexander Lobakin [this message]
2024-12-18 1:53 ` Wei Fang
2024-12-13 2:17 ` [PATCH v8 net-next 2/4] net: enetc: update max chained Tx BD number " Wei Fang
2024-12-13 2:17 ` [PATCH v8 net-next 3/4] net: enetc: add LSO support for i.MX95 ENETC PF Wei Fang
2024-12-17 9:20 ` Paolo Abeni
2024-12-17 12:52 ` Wei Fang
2024-12-17 15:32 ` Alexander Lobakin
2024-12-18 3:06 ` Wei Fang
2024-12-18 5:45 ` Wei Fang
2024-12-18 14:30 ` Alexander Lobakin
2024-12-19 1:32 ` Wei Fang
2024-12-19 15:16 ` Alexander Lobakin
2024-12-13 2:17 ` [PATCH v8 net-next 4/4] 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=5f2eb433-479c-49d2-bc2f-07f6c0a52c60@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=frank.li@nxp.com \
--cc=horms@kernel.org \
--cc=idosch@idosch.org \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--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