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>
26 err = regmap_read(priv->map_reg, MCP251XFD_REG_TEFUA, &tef_ua); in mcp251xfd_tef_tail_get_from_chip()
49 netdev_err(priv->ndev, in mcp251xfd_check_tef_tail()
52 return -EILSEQ; in mcp251xfd_check_tef_tail()
61 const struct mcp251xfd_tx_ring *tx_ring = priv->tx; in mcp251xfd_handle_tefif_recover()
65 err = regmap_read(priv->map_reg, MCP251XFD_REG_TEFSTA, &tef_sta); in mcp251xfd_handle_tefif_recover()
70 netdev_err(priv->ndev, in mcp251xfd_handle_tefif_recover()
72 return -ENOBUFS; in mcp251xfd_handle_tefif_recover()
75 netdev_info(priv->ndev, in mcp251xfd_handle_tefif_recover()
80 seq, priv->tef->tail, priv->tef->head, tx_ring->head); in mcp251xfd_handle_tefif_recover()
83 return -EAGAIN; in mcp251xfd_handle_tefif_recover()
91 struct net_device_stats *stats = &priv->ndev->stats; in mcp251xfd_handle_tefif_one()
96 hw_tef_obj->flags); in mcp251xfd_handle_tefif_one()
100 * net-yet-completed, i.e. old TEF objects. in mcp251xfd_handle_tefif_one()
104 tef_tail_masked = priv->tef->tail & in mcp251xfd_handle_tefif_one()
110 skb = priv->can.echo_skb[tef_tail]; in mcp251xfd_handle_tefif_one()
112 mcp251xfd_skb_set_timestamp(priv, skb, hw_tef_obj->ts); in mcp251xfd_handle_tefif_one()
113 stats->tx_bytes += in mcp251xfd_handle_tefif_one()
114 can_rx_offload_get_echo_skb(&priv->offload, in mcp251xfd_handle_tefif_one()
115 tef_tail, hw_tef_obj->ts, in mcp251xfd_handle_tefif_one()
117 stats->tx_packets++; in mcp251xfd_handle_tefif_one()
118 priv->tef->tail++; in mcp251xfd_handle_tefif_one()
125 const struct mcp251xfd_tx_ring *tx_ring = priv->tx; in mcp251xfd_tef_ring_update()
134 /* chip_tx_tail, is the next TX-Object send by the HW. in mcp251xfd_tef_ring_update()
137 new_head = round_down(priv->tef->head, tx_ring->obj_num) + chip_tx_tail; in mcp251xfd_tef_ring_update()
138 if (new_head <= priv->tef->head) in mcp251xfd_tef_ring_update()
139 new_head += tx_ring->obj_num; in mcp251xfd_tef_ring_update()
141 /* ... but it cannot exceed the TX head. */ in mcp251xfd_tef_ring_update()
142 priv->tef->head = min(new_head, tx_ring->head); in mcp251xfd_tef_ring_update()
152 const struct mcp251xfd_tx_ring *tx_ring = priv->tx; in mcp251xfd_tef_obj_read()
153 const int val_bytes = regmap_get_val_bytes(priv->map_rx); in mcp251xfd_tef_obj_read()
156 (offset > tx_ring->obj_num || in mcp251xfd_tef_obj_read()
157 len > tx_ring->obj_num || in mcp251xfd_tef_obj_read()
158 offset + len > tx_ring->obj_num)) { in mcp251xfd_tef_obj_read()
159 netdev_err(priv->ndev, in mcp251xfd_tef_obj_read()
160 "Trying to read too many TEF objects (max=%d, offset=%d, len=%d).\n", in mcp251xfd_tef_obj_read()
161 tx_ring->obj_num, offset, len); in mcp251xfd_tef_obj_read()
162 return -ERANGE; in mcp251xfd_tef_obj_read()
165 return regmap_bulk_read(priv->map_rx, in mcp251xfd_tef_obj_read()
173 struct mcp251xfd_ecc *ecc = &priv->ecc; in mcp251xfd_ecc_tefif_successful()
175 ecc->ecc_stat = 0; in mcp251xfd_ecc_tefif_successful()
197 err = mcp251xfd_tef_obj_read(priv, &hw_tef_obj[l], 0, len - l); in mcp251xfd_handle_tefif()
206 /* -EAGAIN means the Sequence Number in the TEF in mcp251xfd_handle_tefif()
211 if (err == -EAGAIN) in mcp251xfd_handle_tefif()
222 struct mcp251xfd_tef_ring *ring = priv->tef; in mcp251xfd_handle_tefif()
223 struct mcp251xfd_tx_ring *tx_ring = priv->tx; in mcp251xfd_handle_tefif()
235 offset = ARRAY_SIZE(ring->uinc_xfer) - len; in mcp251xfd_handle_tefif()
236 err = spi_sync_transfer(priv->spi, in mcp251xfd_handle_tefif()
237 ring->uinc_xfer + offset, len); in mcp251xfd_handle_tefif()
241 tx_ring->tail += len; in mcp251xfd_handle_tefif()
242 netdev_completed_queue(priv->ndev, len, total_frame_len); in mcp251xfd_handle_tefif()
251 if (mcp251xfd_get_tx_free(priv->tx)) { in mcp251xfd_handle_tefif()
253 * this sees the new tx_ring->tail. in mcp251xfd_handle_tefif()
256 netif_wake_queue(priv->ndev); in mcp251xfd_handle_tefif()
259 if (priv->tx_coalesce_usecs_irq) in mcp251xfd_handle_tefif()
260 hrtimer_start(&priv->tx_irq_timer, in mcp251xfd_handle_tefif()
261 ns_to_ktime(priv->tx_coalesce_usecs_irq * in mcp251xfd_handle_tefif()