* [PATCH v3 net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs()
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
@ 2025-02-24 11:12 ` Wei Fang
2025-02-24 16:43 ` Vladimir Oltean
2025-02-24 17:24 ` Claudiu Manoil
2025-02-24 11:12 ` [PATCH v3 net 2/8] net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs() Wei Fang
` (7 subsequent siblings)
8 siblings, 2 replies; 16+ messages in thread
From: Wei Fang @ 2025-02-24 11:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni
Cc: ioana.ciornei, yangbo.lu, michal.swiatkowski, netdev,
linux-kernel, imx, stable
When a DMA mapping error occurs while processing skb frags, it will free
one more tx_swbd than expected, so fix this off-by-one issue.
Fixes: d4fd0404c1c9 ("enetc: Introduce basic PF and VF ENETC ethernet drivers")
Cc: stable@vger.kernel.org
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Suggested-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
drivers/net/ethernet/freescale/enetc/enetc.c | 26 ++++++++++++++------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 6a6fc819dfde..55ad31a5073e 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -167,6 +167,24 @@ static bool enetc_skb_is_tcp(struct sk_buff *skb)
return skb->csum_offset == offsetof(struct tcphdr, check);
}
+/**
+ * enetc_unwind_tx_frame() - Unwind the DMA mappings of a multi-buffer Tx frame
+ * @tx_ring: Pointer to the Tx ring on which the buffer descriptors are located
+ * @count: Number of Tx buffer descriptors which need to be unmapped
+ * @i: Index of the last successfully mapped Tx buffer descriptor
+ */
+static void enetc_unwind_tx_frame(struct enetc_bdr *tx_ring, int count, int i)
+{
+ while (count--) {
+ struct enetc_tx_swbd *tx_swbd = &tx_ring->tx_swbd[i];
+
+ enetc_free_tx_frame(tx_ring, tx_swbd);
+ if (i == 0)
+ i = tx_ring->bd_count;
+ i--;
+ }
+}
+
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;
@@ -372,13 +390,7 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
dma_err:
dev_err(tx_ring->dev, "DMA map error");
- do {
- tx_swbd = &tx_ring->tx_swbd[i];
- enetc_free_tx_frame(tx_ring, tx_swbd);
- if (i == 0)
- i = tx_ring->bd_count;
- i--;
- } while (count--);
+ enetc_unwind_tx_frame(tx_ring, count, i);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH v3 net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs()
2025-02-24 11:12 ` [PATCH v3 net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs() Wei Fang
@ 2025-02-24 16:43 ` Vladimir Oltean
2025-02-24 17:24 ` Claudiu Manoil
1 sibling, 0 replies; 16+ messages in thread
From: Vladimir Oltean @ 2025-02-24 16:43 UTC (permalink / raw)
To: Wei Fang
Cc: claudiu.manoil, xiaoning.wang, andrew+netdev, davem, edumazet,
kuba, pabeni, ioana.ciornei, yangbo.lu, michal.swiatkowski,
netdev, linux-kernel, imx, stable
On Mon, Feb 24, 2025 at 07:12:44PM +0800, Wei Fang wrote:
> When a DMA mapping error occurs while processing skb frags, it will free
> one more tx_swbd than expected, so fix this off-by-one issue.
>
> Fixes: d4fd0404c1c9 ("enetc: Introduce basic PF and VF ENETC ethernet drivers")
> Cc: stable@vger.kernel.org
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Suggested-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
^ permalink raw reply [flat|nested] 16+ messages in thread* RE: [PATCH v3 net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs()
2025-02-24 11:12 ` [PATCH v3 net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs() Wei Fang
2025-02-24 16:43 ` Vladimir Oltean
@ 2025-02-24 17:24 ` Claudiu Manoil
1 sibling, 0 replies; 16+ messages in thread
From: Claudiu Manoil @ 2025-02-24 17:24 UTC (permalink / raw)
To: Wei Fang, Vladimir Oltean, Clark Wang, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: Ioana Ciornei, Y.B. Lu, michal.swiatkowski@linux.intel.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, stable@vger.kernel.org
> -----Original Message-----
> From: Wei Fang <wei.fang@nxp.com>
> Sent: Monday, February 24, 2025 1:13 PM
[...]
> Subject: [PATCH v3 net 1/8] net: enetc: fix the off-by-one issue in
> enetc_map_tx_buffs()
>
> When a DMA mapping error occurs while processing skb frags, it will free
> one more tx_swbd than expected, so fix this off-by-one issue.
>
> Fixes: d4fd0404c1c9 ("enetc: Introduce basic PF and VF ENETC ethernet
> drivers")
> Cc: stable@vger.kernel.org
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Suggested-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 net 2/8] net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs()
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
2025-02-24 11:12 ` [PATCH v3 net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs() Wei Fang
@ 2025-02-24 11:12 ` Wei Fang
2025-02-24 16:44 ` Vladimir Oltean
2025-02-24 17:27 ` Claudiu Manoil
2025-02-24 11:12 ` [PATCH v3 net 3/8] net: enetc: correct the xdp_tx statistics Wei Fang
` (6 subsequent siblings)
8 siblings, 2 replies; 16+ messages in thread
From: Wei Fang @ 2025-02-24 11:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni
Cc: ioana.ciornei, yangbo.lu, michal.swiatkowski, netdev,
linux-kernel, imx, stable
When creating a TSO header, if the skb is VLAN tagged, the extended BD
will be used and the 'count' should be increased by 2 instead of 1.
Otherwise, when an error occurs, less tx_swbd will be freed than the
actual number.
Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO")
Cc: stable@vger.kernel.org
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
drivers/net/ethernet/freescale/enetc/enetc.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 55ad31a5073e..174db9e2ce81 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -395,14 +395,15 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
return 0;
}
-static void enetc_map_tx_tso_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb,
- struct enetc_tx_swbd *tx_swbd,
- union enetc_tx_bd *txbd, int *i, int hdr_len,
- int data_len)
+static int enetc_map_tx_tso_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb,
+ struct enetc_tx_swbd *tx_swbd,
+ union enetc_tx_bd *txbd, int *i, int hdr_len,
+ int data_len)
{
union enetc_tx_bd txbd_tmp;
u8 flags = 0, e_flags = 0;
dma_addr_t addr;
+ int count = 1;
enetc_clear_tx_bd(&txbd_tmp);
addr = tx_ring->tso_headers_dma + *i * TSO_HEADER_SIZE;
@@ -445,7 +446,10 @@ static void enetc_map_tx_tso_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb,
/* Write the BD */
txbd_tmp.ext.e_flags = e_flags;
*txbd = txbd_tmp;
+ count++;
}
+
+ return count;
}
static int enetc_map_tx_tso_data(struct enetc_bdr *tx_ring, struct sk_buff *skb,
@@ -802,9 +806,9 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
/* compute the csum over the L4 header */
csum = enetc_tso_hdr_csum(&tso, skb, hdr, hdr_len, &pos);
- enetc_map_tx_tso_hdr(tx_ring, skb, tx_swbd, txbd, &i, hdr_len, data_len);
+ count += enetc_map_tx_tso_hdr(tx_ring, skb, tx_swbd, txbd,
+ &i, hdr_len, data_len);
bd_data_num = 0;
- count++;
while (data_len > 0) {
int size;
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH v3 net 2/8] net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs()
2025-02-24 11:12 ` [PATCH v3 net 2/8] net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs() Wei Fang
@ 2025-02-24 16:44 ` Vladimir Oltean
2025-02-24 17:27 ` Claudiu Manoil
1 sibling, 0 replies; 16+ messages in thread
From: Vladimir Oltean @ 2025-02-24 16:44 UTC (permalink / raw)
To: Wei Fang
Cc: claudiu.manoil, xiaoning.wang, andrew+netdev, davem, edumazet,
kuba, pabeni, ioana.ciornei, yangbo.lu, michal.swiatkowski,
netdev, linux-kernel, imx, stable
On Mon, Feb 24, 2025 at 07:12:45PM +0800, Wei Fang wrote:
> When creating a TSO header, if the skb is VLAN tagged, the extended BD
> will be used and the 'count' should be increased by 2 instead of 1.
> Otherwise, when an error occurs, less tx_swbd will be freed than the
> actual number.
>
> Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO")
> Cc: stable@vger.kernel.org
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
^ permalink raw reply [flat|nested] 16+ messages in thread* RE: [PATCH v3 net 2/8] net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs()
2025-02-24 11:12 ` [PATCH v3 net 2/8] net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs() Wei Fang
2025-02-24 16:44 ` Vladimir Oltean
@ 2025-02-24 17:27 ` Claudiu Manoil
1 sibling, 0 replies; 16+ messages in thread
From: Claudiu Manoil @ 2025-02-24 17:27 UTC (permalink / raw)
To: Wei Fang, Vladimir Oltean, Clark Wang, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: Ioana Ciornei, Y.B. Lu, michal.swiatkowski@linux.intel.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, stable@vger.kernel.org
> -----Original Message-----
> From: Wei Fang <wei.fang@nxp.com>
> Sent: Monday, February 24, 2025 1:13 PM
[...]
> Subject: [PATCH v3 net 2/8] net: enetc: keep track of correct Tx BD count in
> enetc_map_tx_tso_buffs()
>
> When creating a TSO header, if the skb is VLAN tagged, the extended BD
> will be used and the 'count' should be increased by 2 instead of 1.
> Otherwise, when an error occurs, less tx_swbd will be freed than the
> actual number.
>
> Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO")
> Cc: stable@vger.kernel.org
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 net 3/8] net: enetc: correct the xdp_tx statistics
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
2025-02-24 11:12 ` [PATCH v3 net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs() Wei Fang
2025-02-24 11:12 ` [PATCH v3 net 2/8] net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs() Wei Fang
@ 2025-02-24 11:12 ` Wei Fang
2025-02-24 11:12 ` [PATCH v3 net 4/8] net: enetc: VFs do not support HWTSTAMP_TX_ONESTEP_SYNC Wei Fang
` (5 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Wei Fang @ 2025-02-24 11:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni
Cc: ioana.ciornei, yangbo.lu, michal.swiatkowski, netdev,
linux-kernel, imx, stable
The 'xdp_tx' is used to count the number of XDP_TX frames sent, not the
number of Tx BDs.
Fixes: 7ed2bc80074e ("net: enetc: add support for XDP_TX")
Cc: stable@vger.kernel.org
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/ethernet/freescale/enetc/enetc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 174db9e2ce81..3cb9ebb13b19 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -1917,7 +1917,7 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
enetc_xdp_drop(rx_ring, orig_i, i);
tx_ring->stats.xdp_tx_drops++;
} else {
- tx_ring->stats.xdp_tx += xdp_tx_bd_cnt;
+ tx_ring->stats.xdp_tx++;
rx_ring->xdp.xdp_tx_in_flight += xdp_tx_bd_cnt;
xdp_tx_frm_cnt++;
/* The XDP_TX enqueue was successful, so we
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 net 4/8] net: enetc: VFs do not support HWTSTAMP_TX_ONESTEP_SYNC
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
` (2 preceding siblings ...)
2025-02-24 11:12 ` [PATCH v3 net 3/8] net: enetc: correct the xdp_tx statistics Wei Fang
@ 2025-02-24 11:12 ` Wei Fang
2025-02-24 11:12 ` [PATCH v3 net 5/8] net: enetc: update UDP checksum when updating originTimestamp field Wei Fang
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Wei Fang @ 2025-02-24 11:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni
Cc: ioana.ciornei, yangbo.lu, michal.swiatkowski, netdev,
linux-kernel, imx, stable
Actually ENETC VFs do not support HWTSTAMP_TX_ONESTEP_SYNC because only
ENETC PF can access PMa_SINGLE_STEP registers. And there will be a crash
if VFs are used to test one-step timestamp, the crash log as follows.
[ 129.110909] Unable to handle kernel paging request at virtual address 00000000000080c0
[ 129.287769] Call trace:
[ 129.290219] enetc_port_mac_wr+0x30/0xec (P)
[ 129.294504] enetc_start_xmit+0xda4/0xe74
[ 129.298525] enetc_xmit+0x70/0xec
[ 129.301848] dev_hard_start_xmit+0x98/0x118
Fixes: 41514737ecaa ("enetc: add get_ts_info interface for ethtool")
Cc: stable@vger.kernel.org
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/ethernet/freescale/enetc/enetc.c | 3 +++
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 7 +++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 3cb9ebb13b19..e946d8652790 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -3244,6 +3244,9 @@ static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
new_offloads |= ENETC_F_TX_TSTAMP;
break;
case HWTSTAMP_TX_ONESTEP_SYNC:
+ if (!enetc_si_is_pf(priv->si))
+ return -EOPNOTSUPP;
+
new_offloads &= ~ENETC_F_TX_TSTAMP_MASK;
new_offloads |= ENETC_F_TX_ONESTEP_SYNC_TSTAMP;
break;
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
index bf34b5bb1e35..ece3ae28ba82 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
@@ -832,6 +832,7 @@ static int enetc_set_coalesce(struct net_device *ndev,
static int enetc_get_ts_info(struct net_device *ndev,
struct kernel_ethtool_ts_info *info)
{
+ struct enetc_ndev_priv *priv = netdev_priv(ndev);
int *phc_idx;
phc_idx = symbol_get(enetc_phc_index);
@@ -852,8 +853,10 @@ static int enetc_get_ts_info(struct net_device *ndev,
SOF_TIMESTAMPING_TX_SOFTWARE;
info->tx_types = (1 << HWTSTAMP_TX_OFF) |
- (1 << HWTSTAMP_TX_ON) |
- (1 << HWTSTAMP_TX_ONESTEP_SYNC);
+ (1 << HWTSTAMP_TX_ON);
+
+ if (enetc_si_is_pf(priv->si))
+ info->tx_types |= (1 << HWTSTAMP_TX_ONESTEP_SYNC);
info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
(1 << HWTSTAMP_FILTER_ALL);
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 net 5/8] net: enetc: update UDP checksum when updating originTimestamp field
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
` (3 preceding siblings ...)
2025-02-24 11:12 ` [PATCH v3 net 4/8] net: enetc: VFs do not support HWTSTAMP_TX_ONESTEP_SYNC Wei Fang
@ 2025-02-24 11:12 ` Wei Fang
2025-02-24 11:12 ` [PATCH v3 net 6/8] net: enetc: add missing enetc4_link_deinit() Wei Fang
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Wei Fang @ 2025-02-24 11:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni
Cc: ioana.ciornei, yangbo.lu, michal.swiatkowski, netdev,
linux-kernel, imx, stable
There is an issue with one-step timestamp based on UDP/IP. The peer will
discard the sync packet because of the wrong UDP checksum. For ENETC v1,
the software needs to update the UDP checksum when updating the
originTimestamp field, so that the hardware can correctly update the UDP
checksum when updating the correction field. Otherwise, the UDP checksum
in the sync packet will be wrong.
Fixes: 7294380c5211 ("enetc: support PTP Sync packet one-step timestamping")
Cc: stable@vger.kernel.org
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/ethernet/freescale/enetc/enetc.c | 41 ++++++++++++++++----
1 file changed, 34 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index e946d8652790..9801c51b6a59 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -297,9 +297,11 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
}
if (do_onestep_tstamp) {
- u32 lo, hi, val;
- u64 sec, nsec;
+ __be32 new_sec_l, new_nsec;
+ u32 lo, hi, nsec, val;
+ __be16 new_sec_h;
u8 *data;
+ u64 sec;
lo = enetc_rd_hot(hw, ENETC_SICTR0);
hi = enetc_rd_hot(hw, ENETC_SICTR1);
@@ -313,13 +315,38 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
/* Update originTimestamp field of Sync packet
* - 48 bits seconds field
* - 32 bits nanseconds field
+ *
+ * In addition, the UDP checksum needs to be updated
+ * by software after updating originTimestamp field,
+ * otherwise the hardware will calculate the wrong
+ * checksum when updating the correction field and
+ * update it to the packet.
*/
data = skb_mac_header(skb);
- *(__be16 *)(data + offset2) =
- htons((sec >> 32) & 0xffff);
- *(__be32 *)(data + offset2 + 2) =
- htonl(sec & 0xffffffff);
- *(__be32 *)(data + offset2 + 6) = htonl(nsec);
+ new_sec_h = htons((sec >> 32) & 0xffff);
+ new_sec_l = htonl(sec & 0xffffffff);
+ new_nsec = htonl(nsec);
+ if (udp) {
+ struct udphdr *uh = udp_hdr(skb);
+ __be32 old_sec_l, old_nsec;
+ __be16 old_sec_h;
+
+ old_sec_h = *(__be16 *)(data + offset2);
+ inet_proto_csum_replace2(&uh->check, skb, old_sec_h,
+ new_sec_h, false);
+
+ old_sec_l = *(__be32 *)(data + offset2 + 2);
+ inet_proto_csum_replace4(&uh->check, skb, old_sec_l,
+ new_sec_l, false);
+
+ old_nsec = *(__be32 *)(data + offset2 + 6);
+ inet_proto_csum_replace4(&uh->check, skb, old_nsec,
+ new_nsec, false);
+ }
+
+ *(__be16 *)(data + offset2) = new_sec_h;
+ *(__be32 *)(data + offset2 + 2) = new_sec_l;
+ *(__be32 *)(data + offset2 + 6) = new_nsec;
/* Configure single-step register */
val = ENETC_PM0_SINGLE_STEP_EN;
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 net 6/8] net: enetc: add missing enetc4_link_deinit()
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
` (4 preceding siblings ...)
2025-02-24 11:12 ` [PATCH v3 net 5/8] net: enetc: update UDP checksum when updating originTimestamp field Wei Fang
@ 2025-02-24 11:12 ` Wei Fang
2025-02-24 11:12 ` [PATCH v3 net 7/8] net: enetc: remove the mm_lock from the ENETC v4 driver Wei Fang
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Wei Fang @ 2025-02-24 11:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni
Cc: ioana.ciornei, yangbo.lu, michal.swiatkowski, netdev,
linux-kernel, imx, stable
The enetc4_link_init() is called when the PF driver probes to create
phylink and MDIO bus, but we forgot to call enetc4_link_deinit() to
free the phylink and MDIO bus when the driver was unbound. so add
missing enetc4_link_deinit() to enetc4_pf_netdev_destroy().
Fixes: 99100d0d9922 ("net: enetc: add preliminary support for i.MX95 ENETC PF")
Cc: stable@vger.kernel.org
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/ethernet/freescale/enetc/enetc4_pf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
index fc41078c4f5d..48861c8b499a 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
@@ -684,6 +684,7 @@ static void enetc4_pf_netdev_destroy(struct enetc_si *si)
struct net_device *ndev = si->ndev;
unregister_netdev(ndev);
+ enetc4_link_deinit(priv);
enetc_free_msix(priv);
free_netdev(ndev);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 net 7/8] net: enetc: remove the mm_lock from the ENETC v4 driver
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
` (5 preceding siblings ...)
2025-02-24 11:12 ` [PATCH v3 net 6/8] net: enetc: add missing enetc4_link_deinit() Wei Fang
@ 2025-02-24 11:12 ` Wei Fang
2025-02-24 11:12 ` [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs() Wei Fang
2025-02-26 3:20 ` [PATCH v3 net 0/8] net: enetc: fix some known issues patchwork-bot+netdevbpf
8 siblings, 0 replies; 16+ messages in thread
From: Wei Fang @ 2025-02-24 11:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni
Cc: ioana.ciornei, yangbo.lu, michal.swiatkowski, netdev,
linux-kernel, imx, stable
Currently, the ENETC v4 driver has not added the MAC merge layer support
in the upstream, so the mm_lock is not initialized and used, so remove
the mm_lock from the driver.
Fixes: 99100d0d9922 ("net: enetc: add preliminary support for i.MX95 ENETC PF")
Cc: stable@vger.kernel.org
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/ethernet/freescale/enetc/enetc4_pf.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
index 48861c8b499a..73ac8c6afb3a 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
@@ -672,7 +672,6 @@ static int enetc4_pf_netdev_create(struct enetc_si *si)
err_alloc_msix:
err_config_si:
err_clk_get:
- mutex_destroy(&priv->mm_lock);
free_netdev(ndev);
return err;
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs()
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
` (6 preceding siblings ...)
2025-02-24 11:12 ` [PATCH v3 net 7/8] net: enetc: remove the mm_lock from the ENETC v4 driver Wei Fang
@ 2025-02-24 11:12 ` Wei Fang
2025-02-24 16:47 ` Vladimir Oltean
2025-02-24 17:37 ` Claudiu Manoil
2025-02-26 3:20 ` [PATCH v3 net 0/8] net: enetc: fix some known issues patchwork-bot+netdevbpf
8 siblings, 2 replies; 16+ messages in thread
From: Wei Fang @ 2025-02-24 11:12 UTC (permalink / raw)
To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni
Cc: ioana.ciornei, yangbo.lu, michal.swiatkowski, netdev,
linux-kernel, imx, stable
There is an off-by-one issue for the err_chained_bd path, it will free
one more tx_swbd than expected. But there is no such issue for the
err_map_data path. To fix this off-by-one issue and make the two error
handling consistent, the increment of 'i' and 'count' remain in sync
and enetc_unwind_tx_frame() is called for error handling.
Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO")
Cc: stable@vger.kernel.org
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
drivers/net/ethernet/freescale/enetc/enetc.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 9801c51b6a59..2106861463e4 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -859,8 +859,13 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
err = enetc_map_tx_tso_data(tx_ring, skb, tx_swbd, txbd,
tso.data, size,
size == data_len);
- if (err)
+ if (err) {
+ if (i == 0)
+ i = tx_ring->bd_count;
+ i--;
+
goto err_map_data;
+ }
data_len -= size;
count++;
@@ -889,13 +894,7 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
dev_err(tx_ring->dev, "DMA map error");
err_chained_bd:
- do {
- tx_swbd = &tx_ring->tx_swbd[i];
- enetc_free_tx_frame(tx_ring, tx_swbd);
- if (i == 0)
- i = tx_ring->bd_count;
- i--;
- } while (count--);
+ enetc_unwind_tx_frame(tx_ring, count, i);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs()
2025-02-24 11:12 ` [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs() Wei Fang
@ 2025-02-24 16:47 ` Vladimir Oltean
2025-02-24 17:37 ` Claudiu Manoil
1 sibling, 0 replies; 16+ messages in thread
From: Vladimir Oltean @ 2025-02-24 16:47 UTC (permalink / raw)
To: Wei Fang
Cc: claudiu.manoil, xiaoning.wang, andrew+netdev, davem, edumazet,
kuba, pabeni, ioana.ciornei, yangbo.lu, michal.swiatkowski,
netdev, linux-kernel, imx, stable
On Mon, Feb 24, 2025 at 07:12:51PM +0800, Wei Fang wrote:
> There is an off-by-one issue for the err_chained_bd path, it will free
> one more tx_swbd than expected. But there is no such issue for the
> err_map_data path. To fix this off-by-one issue and make the two error
> handling consistent, the increment of 'i' and 'count' remain in sync
> and enetc_unwind_tx_frame() is called for error handling.
>
> Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO")
> Cc: stable@vger.kernel.org
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
^ permalink raw reply [flat|nested] 16+ messages in thread* RE: [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs()
2025-02-24 11:12 ` [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs() Wei Fang
2025-02-24 16:47 ` Vladimir Oltean
@ 2025-02-24 17:37 ` Claudiu Manoil
1 sibling, 0 replies; 16+ messages in thread
From: Claudiu Manoil @ 2025-02-24 17:37 UTC (permalink / raw)
To: Wei Fang, Vladimir Oltean, Clark Wang, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: Ioana Ciornei, Y.B. Lu, michal.swiatkowski@linux.intel.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, stable@vger.kernel.org
> -----Original Message-----
> From: Wei Fang <wei.fang@nxp.com>
> Sent: Monday, February 24, 2025 1:13 PM
[...]
> Subject: [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in
> enetc_map_tx_tso_buffs()
>
> There is an off-by-one issue for the err_chained_bd path, it will free
> one more tx_swbd than expected. But there is no such issue for the
> err_map_data path. To fix this off-by-one issue and make the two error
> handling consistent, the increment of 'i' and 'count' remain in sync
> and enetc_unwind_tx_frame() is called for error handling.
>
> Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO")
> Cc: stable@vger.kernel.org
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 net 0/8] net: enetc: fix some known issues
2025-02-24 11:12 [PATCH v3 net 0/8] net: enetc: fix some known issues Wei Fang
` (7 preceding siblings ...)
2025-02-24 11:12 ` [PATCH v3 net 8/8] net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs() Wei Fang
@ 2025-02-26 3:20 ` patchwork-bot+netdevbpf
8 siblings, 0 replies; 16+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-26 3:20 UTC (permalink / raw)
To: Wei Fang
Cc: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
davem, edumazet, kuba, pabeni, ioana.ciornei, yangbo.lu,
michal.swiatkowski, netdev, linux-kernel, imx, stable
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 24 Feb 2025 19:12:43 +0800 you wrote:
> There are some issues with the enetc driver, some of which are specific
> to the LS1028A platform, and some of which were introduced recently when
> i.MX95 ENETC support was added, so this patch set aims to clean up those
> issues.
>
> ---
> v1 link: https://lore.kernel.org/imx/20250217093906.506214-1-wei.fang@nxp.com/
> v2 changes:
> 1. Remove the unneeded semicolon from patch 1
> 2. Modify the commit message of patch 1
> 3. Add new patch 9 to fix another off-by-one issue
>
> [...]
Here is the summary with links:
- [v3,net,1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs()
https://git.kernel.org/netdev/net/c/39ab773e4c12
- [v3,net,2/8] net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs()
https://git.kernel.org/netdev/net/c/da291996b16e
- [v3,net,3/8] net: enetc: correct the xdp_tx statistics
https://git.kernel.org/netdev/net/c/432a2cb3ee97
- [v3,net,4/8] net: enetc: VFs do not support HWTSTAMP_TX_ONESTEP_SYNC
https://git.kernel.org/netdev/net/c/a562d0c4a893
- [v3,net,5/8] net: enetc: update UDP checksum when updating originTimestamp field
https://git.kernel.org/netdev/net/c/bbcbc906ab7b
- [v3,net,6/8] net: enetc: add missing enetc4_link_deinit()
https://git.kernel.org/netdev/net/c/8e43decdfbb4
- [v3,net,7/8] net: enetc: remove the mm_lock from the ENETC v4 driver
https://git.kernel.org/netdev/net/c/119049b66b88
- [v3,net,8/8] net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs()
https://git.kernel.org/netdev/net/c/249df695c3ff
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 16+ messages in thread