Lines Matching +full:tx +full:- +full:ts +full:- +full:max
1 // SPDX-License-Identifier: GPL-2.0
3 // mcp251xfd - Microchip MCP251xFD Family CAN controller driver
6 // Marc Kleine-Budde <kernel@pengutronix.de>
31 err = regmap_read(priv->map_reg, MCP251XFD_REG_TEFUA, &tef_ua); in mcp251xfd_tef_tail_get_from_chip()
54 netdev_err(priv->ndev, in mcp251xfd_check_tef_tail()
57 return -EILSEQ; in mcp251xfd_check_tef_tail()
68 struct net_device_stats *stats = &priv->ndev->stats; in mcp251xfd_handle_tefif_one()
76 hw_tef_obj->flags); in mcp251xfd_handle_tefif_one()
77 tef_tail_masked = priv->tef->tail & in mcp251xfd_handle_tefif_one()
81 * bits of a FIFOSTA register, here the TX FIFO tail index in mcp251xfd_handle_tefif_one()
87 * -EBADMSG if an old CAN frame is detected. in mcp251xfd_handle_tefif_one()
90 netdev_dbg(priv->ndev, "%s: chip=0x%02x ring=0x%02x\n", __func__, in mcp251xfd_handle_tefif_one()
92 stats->tx_fifo_errors++; in mcp251xfd_handle_tefif_one()
94 return -EBADMSG; in mcp251xfd_handle_tefif_one()
98 skb = priv->can.echo_skb[tef_tail]; in mcp251xfd_handle_tefif_one()
100 mcp251xfd_skb_set_timestamp_raw(priv, skb, hw_tef_obj->ts); in mcp251xfd_handle_tefif_one()
101 stats->tx_bytes += in mcp251xfd_handle_tefif_one()
102 can_rx_offload_get_echo_skb_queue_timestamp(&priv->offload, in mcp251xfd_handle_tefif_one()
103 tef_tail, hw_tef_obj->ts, in mcp251xfd_handle_tefif_one()
105 stats->tx_packets++; in mcp251xfd_handle_tefif_one()
106 priv->tef->tail++; in mcp251xfd_handle_tefif_one()
114 const struct mcp251xfd_tx_ring *tx_ring = priv->tx; in mcp251xfd_get_tef_len()
115 const u8 shift = tx_ring->obj_num_shift_to_u8; in mcp251xfd_get_tef_len()
120 err = regmap_read(priv->map_reg, MCP251XFD_REG_FIFOSTA(priv->tx->fifo_nr), in mcp251xfd_get_tef_len()
125 /* If the chip says the TX-FIFO is empty, but there are no TX in mcp251xfd_get_tef_len()
130 *len_p = tx_ring->obj_num; in mcp251xfd_get_tef_len()
145 BUILD_BUG_ON(sizeof(tx_ring->obj_num) != sizeof(chip_tx_tail)); in mcp251xfd_get_tef_len()
146 BUILD_BUG_ON(sizeof(tx_ring->obj_num) != sizeof(tail)); in mcp251xfd_get_tef_len()
147 BUILD_BUG_ON(sizeof(tx_ring->obj_num) != sizeof(len)); in mcp251xfd_get_tef_len()
149 len = (chip_tx_tail << shift) - (tail << shift); in mcp251xfd_get_tef_len()
160 const struct mcp251xfd_tx_ring *tx_ring = priv->tx; in mcp251xfd_tef_obj_read()
161 const int val_bytes = regmap_get_val_bytes(priv->map_rx); in mcp251xfd_tef_obj_read()
164 (offset > tx_ring->obj_num || in mcp251xfd_tef_obj_read()
165 len > tx_ring->obj_num || in mcp251xfd_tef_obj_read()
166 offset + len > tx_ring->obj_num)) { in mcp251xfd_tef_obj_read()
167 netdev_err(priv->ndev, in mcp251xfd_tef_obj_read()
168 "Trying to read too many TEF objects (max=%d, offset=%d, len=%d).\n", in mcp251xfd_tef_obj_read()
169 tx_ring->obj_num, offset, len); in mcp251xfd_tef_obj_read()
170 return -ERANGE; in mcp251xfd_tef_obj_read()
173 return regmap_bulk_read(priv->map_rx, in mcp251xfd_tef_obj_read()
181 struct mcp251xfd_ecc *ecc = &priv->ecc; in mcp251xfd_ecc_tefif_successful()
183 ecc->ecc_stat = 0; in mcp251xfd_ecc_tefif_successful()
204 err = mcp251xfd_tef_obj_read(priv, &hw_tef_obj[l], 0, len - l); in mcp251xfd_handle_tefif()
213 /* -EBADMSG means we're affected by mcp2518fd erratum in mcp251xfd_handle_tefif()
218 if (err == -EBADMSG) in mcp251xfd_handle_tefif()
229 struct mcp251xfd_tef_ring *ring = priv->tef; in mcp251xfd_handle_tefif()
230 struct mcp251xfd_tx_ring *tx_ring = priv->tx; in mcp251xfd_handle_tefif()
233 ring->head += len; in mcp251xfd_handle_tefif()
244 offset = ARRAY_SIZE(ring->uinc_xfer) - len; in mcp251xfd_handle_tefif()
245 err = spi_sync_transfer(priv->spi, in mcp251xfd_handle_tefif()
246 ring->uinc_xfer + offset, len); in mcp251xfd_handle_tefif()
250 tx_ring->tail += len; in mcp251xfd_handle_tefif()
251 netdev_completed_queue(priv->ndev, len, total_frame_len); in mcp251xfd_handle_tefif()
260 if (mcp251xfd_get_tx_free(priv->tx)) { in mcp251xfd_handle_tefif()
262 * this sees the new tx_ring->tail. in mcp251xfd_handle_tefif()
265 netif_wake_queue(priv->ndev); in mcp251xfd_handle_tefif()
268 if (priv->tx_coalesce_usecs_irq) in mcp251xfd_handle_tefif()
269 hrtimer_start(&priv->tx_irq_timer, in mcp251xfd_handle_tefif()
270 ns_to_ktime(priv->tx_coalesce_usecs_irq * in mcp251xfd_handle_tefif()