Skip to content

Commit 93c5d5a

Browse files
Wei Fangkuba-moo
authored andcommitted
net: enetc: update max chained Tx BD number for i.MX95 ENETC
The max chained Tx BDs of latest ENETC (i.MX95 ENETC, rev 4.1) has been increased to 63, but since the range of MAX_SKB_FRAGS is 17~45, so for i.MX95 ENETC and later revision, it is better to set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS. In addition, add max_frags in struct enetc_drvdata to indicate the max chained BDs supported by device. Because the max number of chained BDs supported by LS1028A and i.MX95 ENETC is different. Signed-off-by: Wei Fang <[email protected]> Reviewed-by: Frank Li <[email protected]> Reviewed-by: Claudiu Manoil <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d9a093d commit 93c5d5a

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

drivers/net/ethernet/freescale/enetc/enetc.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ static void enetc_tso_complete_csum(struct enetc_bdr *tx_ring, struct tso_t *tso
534534

535535
static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
536536
{
537+
struct enetc_ndev_priv *priv = netdev_priv(tx_ring->ndev);
537538
int hdr_len, total_len, data_len;
538539
struct enetc_tx_swbd *tx_swbd;
539540
union enetc_tx_bd *txbd;
@@ -599,7 +600,7 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
599600
bd_data_num++;
600601
tso_build_data(skb, &tso, size);
601602

602-
if (unlikely(bd_data_num >= ENETC_MAX_SKB_FRAGS && data_len))
603+
if (unlikely(bd_data_num >= priv->max_frags && data_len))
603604
goto err_chained_bd;
604605
}
605606

@@ -660,7 +661,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb,
660661
count = enetc_map_tx_tso_buffs(tx_ring, skb);
661662
enetc_unlock_mdio();
662663
} else {
663-
if (unlikely(skb_shinfo(skb)->nr_frags > ENETC_MAX_SKB_FRAGS))
664+
if (unlikely(skb_shinfo(skb)->nr_frags > priv->max_frags))
664665
if (unlikely(skb_linearize(skb)))
665666
goto drop_packet_err;
666667

@@ -678,7 +679,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb,
678679
if (unlikely(!count))
679680
goto drop_packet_err;
680681

681-
if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED)
682+
if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED(priv->max_frags))
682683
netif_stop_subqueue(ndev, tx_ring->index);
683684

684685
return NETDEV_TX_OK;
@@ -946,7 +947,8 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
946947
if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) &&
947948
__netif_subqueue_stopped(ndev, tx_ring->index) &&
948949
!test_bit(ENETC_TX_DOWN, &priv->flags) &&
949-
(enetc_bd_unused(tx_ring) >= ENETC_TXBDS_MAX_NEEDED))) {
950+
(enetc_bd_unused(tx_ring) >=
951+
ENETC_TXBDS_MAX_NEEDED(priv->max_frags)))) {
950952
netif_wake_subqueue(ndev, tx_ring->index);
951953
}
952954

@@ -3307,18 +3309,21 @@ EXPORT_SYMBOL_GPL(enetc_pci_remove);
33073309
static const struct enetc_drvdata enetc_pf_data = {
33083310
.sysclk_freq = ENETC_CLK_400M,
33093311
.pmac_offset = ENETC_PMAC_OFFSET,
3312+
.max_frags = ENETC_MAX_SKB_FRAGS,
33103313
.eth_ops = &enetc_pf_ethtool_ops,
33113314
};
33123315

33133316
static const struct enetc_drvdata enetc4_pf_data = {
33143317
.sysclk_freq = ENETC_CLK_333M,
33153318
.tx_csum = true,
3319+
.max_frags = ENETC4_MAX_SKB_FRAGS,
33163320
.pmac_offset = ENETC4_PMAC_OFFSET,
33173321
.eth_ops = &enetc4_pf_ethtool_ops,
33183322
};
33193323

33203324
static const struct enetc_drvdata enetc_vf_data = {
33213325
.sysclk_freq = ENETC_CLK_400M,
3326+
.max_frags = ENETC_MAX_SKB_FRAGS,
33223327
.eth_ops = &enetc_vf_ethtool_ops,
33233328
};
33243329

drivers/net/ethernet/freescale/enetc/enetc.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,16 @@ struct enetc_rx_swbd {
5959

6060
/* ENETC overhead: optional extension BD + 1 BD gap */
6161
#define ENETC_TXBDS_NEEDED(val) ((val) + 2)
62-
/* max # of chained Tx BDs is 15, including head and extension BD */
62+
/* For LS1028A, max # of chained Tx BDs is 15, including head and
63+
* extension BD.
64+
*/
6365
#define ENETC_MAX_SKB_FRAGS 13
64-
#define ENETC_TXBDS_MAX_NEEDED ENETC_TXBDS_NEEDED(ENETC_MAX_SKB_FRAGS + 1)
66+
/* For ENETC v4 and later versions, max # of chained Tx BDs is 63,
67+
* including head and extension BD, but the range of MAX_SKB_FRAGS
68+
* is 17 ~ 45, so set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS.
69+
*/
70+
#define ENETC4_MAX_SKB_FRAGS MAX_SKB_FRAGS
71+
#define ENETC_TXBDS_MAX_NEEDED(x) ENETC_TXBDS_NEEDED((x) + 1)
6572

6673
struct enetc_ring_stats {
6774
unsigned int packets;
@@ -235,6 +242,7 @@ enum enetc_errata {
235242
struct enetc_drvdata {
236243
u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */
237244
u8 tx_csum:1;
245+
u8 max_frags;
238246
u64 sysclk_freq;
239247
const struct ethtool_ops *eth_ops;
240248
};
@@ -377,6 +385,7 @@ struct enetc_ndev_priv {
377385
u16 msg_enable;
378386

379387
u8 preemptible_tcs;
388+
u8 max_frags; /* The maximum number of BDs for fragments */
380389

381390
enum enetc_active_offloads active_offloads;
382391

drivers/net/ethernet/freescale/enetc/enetc_pf_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
101101

102102
priv->msg_enable = (NETIF_MSG_WOL << 1) - 1;
103103
priv->sysclk_freq = si->drvdata->sysclk_freq;
104+
priv->max_frags = si->drvdata->max_frags;
104105
ndev->netdev_ops = ndev_ops;
105106
enetc_set_ethtool_ops(ndev);
106107
ndev->watchdog_timeo = 5 * HZ;

drivers/net/ethernet/freescale/enetc/enetc_vf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
136136

137137
priv->msg_enable = (NETIF_MSG_IFUP << 1) - 1;
138138
priv->sysclk_freq = si->drvdata->sysclk_freq;
139+
priv->max_frags = si->drvdata->max_frags;
139140
ndev->netdev_ops = ndev_ops;
140141
enetc_set_ethtool_ops(ndev);
141142
ndev->watchdog_timeo = 5 * HZ;

0 commit comments

Comments
 (0)