diff options
author | Claudiu Manoil <claudiu.manoil@nxp.com> | 2020-03-10 15:51:24 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-03-11 01:48:54 +0300 |
commit | 434cebabd3a2470881dd69fe65c0986c470b6fb8 (patch) | |
tree | 363680c0ab8decb5043ea42f1f7ceb268885845c /drivers/net/ethernet/freescale/enetc/enetc.h | |
parent | 714239ac630a85919839f200d4499b7f811c7003 (diff) | |
download | linux-434cebabd3a2470881dd69fe65c0986c470b6fb8.tar.xz |
enetc: Add dynamic allocation of extended Rx BD rings
Hardware timestamping support (PTP) on Rx requires extended
buffer descriptors, double the size of normal Rx descriptors.
On the current controller revision only the timestamping offload
requires extended Rx descriptors.
Since Rx timestamping can be turned on/off at runtime, make Rx ring
allocation configurable at runtime too. As a result, the static
config option FSL_ENETC_HW_TIMESTAMPING can be dropped and the
extended descriptors can be used only when Rx timestamping gets
activated.
The extension has the same size as the base descriptor, making
the descriptor iterators easy to update for the extended case.
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/freescale/enetc/enetc.h')
-rw-r--r-- | drivers/net/ethernet/freescale/enetc/enetc.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 1cd4cddd5c58..56c43f35b633 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -73,6 +73,7 @@ struct enetc_bdr { dma_addr_t bd_dma_base; u8 tsd_enable; /* Time specific departure */ + bool ext_en; /* enable h/w descriptor extensions */ } ____cacheline_aligned_in_smp; static inline void enetc_bdr_idx_inc(struct enetc_bdr *bdr, int *i) @@ -107,7 +108,13 @@ struct enetc_cbdr { static inline union enetc_rx_bd *enetc_rxbd(struct enetc_bdr *rx_ring, int i) { - return &(((union enetc_rx_bd *)rx_ring->bd_base)[i]); + int hw_idx = i; + +#ifdef CONFIG_FSL_ENETC_PTP_CLOCK + if (rx_ring->ext_en) + hw_idx = 2 * i; +#endif + return &(((union enetc_rx_bd *)rx_ring->bd_base)[hw_idx]); } static inline union enetc_rx_bd *enetc_rxbd_next(struct enetc_bdr *rx_ring, @@ -115,12 +122,21 @@ static inline union enetc_rx_bd *enetc_rxbd_next(struct enetc_bdr *rx_ring, int i) { rxbd++; +#ifdef CONFIG_FSL_ENETC_PTP_CLOCK + if (rx_ring->ext_en) + rxbd++; +#endif if (unlikely(++i == rx_ring->bd_count)) rxbd = rx_ring->bd_base; return rxbd; } +static inline union enetc_rx_bd *enetc_rxbd_ext(union enetc_rx_bd *rxbd) +{ + return ++rxbd; +} + struct enetc_msg_swbd { void *vaddr; dma_addr_t dma; |