Lines Matching +full:tx +full:- +full:only
1 // SPDX-License-Identifier: GPL-2.0
3 // mcp251xfd - Microchip MCP251xFD Family CAN controller driver
6 // Marc Kleine-Budde <kernel@pengutronix.de>
9 #include "mcp251xfd-ram.h"
17 max = min_t(u8, obj->max, obj->fifo_num * config->fifo_depth); in can_ram_clamp()
18 return clamp(val, obj->min, max); in can_ram_clamp()
26 u8 fifo_num = obj->fifo_num; in can_ram_rounddown_pow_of_two()
35 * coalescing or only half of FIFO (FIFO Half Full in can_ram_rounddown_pow_of_two()
38 ret = min_t(u8, coalesce * 2, config->fifo_depth); in can_ram_rounddown_pow_of_two()
39 val -= ret; in can_ram_rounddown_pow_of_two()
40 fifo_num--; in can_ram_rounddown_pow_of_two()
47 config->fifo_depth); in can_ram_rounddown_pow_of_two()
50 if (n < obj->fifo_depth_min) in can_ram_rounddown_pow_of_two()
54 val -= n; in can_ram_rounddown_pow_of_two()
71 num_tx = config->tx.def[fd_mode]; in can_ram_get_layout()
72 num_tx = can_ram_rounddown_pow_of_two(config, &config->tx, 0, num_tx); in can_ram_get_layout()
74 ram_free = config->size; in can_ram_get_layout()
75 ram_free -= config->tx.size[fd_mode] * num_tx; in can_ram_get_layout()
77 num_rx = ram_free / config->rx.size[fd_mode]; in can_ram_get_layout()
79 layout->default_rx = can_ram_rounddown_pow_of_two(config, &config->rx, 0, num_rx); in can_ram_get_layout()
80 layout->default_tx = num_tx; in can_ram_get_layout()
84 ram_free = config->size; in can_ram_get_layout()
85 ram_free -= config->tx.size[fd_mode] * config->tx.min; in can_ram_get_layout()
86 num_rx = ram_free / config->rx.size[fd_mode]; in can_ram_get_layout()
88 ram_free = config->size; in can_ram_get_layout()
89 ram_free -= config->rx.size[fd_mode] * config->rx.min; in can_ram_get_layout()
90 num_tx = ram_free / config->tx.size[fd_mode]; in can_ram_get_layout()
92 layout->max_rx = can_ram_rounddown_pow_of_two(config, &config->rx, 0, num_rx); in can_ram_get_layout()
93 layout->max_tx = can_ram_rounddown_pow_of_two(config, &config->tx, 0, num_tx); in can_ram_get_layout()
101 * CAN-CC mode, but and we are in CAN-FD mode now, in can_ram_get_layout()
102 * they might be to big. Use the default CAN-FD values in can_ram_get_layout()
105 num_rx = ring->rx_pending; in can_ram_get_layout()
106 if (num_rx > layout->max_rx) in can_ram_get_layout()
107 num_rx = layout->default_rx; in can_ram_get_layout()
109 num_rx = can_ram_rounddown_pow_of_two(config, &config->rx, 0, num_rx); in can_ram_get_layout()
114 if (ec && !(ec->rx_coalesce_usecs_irq == 0 && in can_ram_get_layout()
115 ec->rx_max_coalesced_frames_irq == 1)) { in can_ram_get_layout()
118 /* use only max half of available objects for coalescing */ in can_ram_get_layout()
119 max = min_t(u8, num_rx / 2, config->fifo_depth); in can_ram_get_layout()
120 num_rx_coalesce = clamp(ec->rx_max_coalesced_frames_irq, in can_ram_get_layout()
121 (u32)config->rx.fifo_depth_coalesce_min, in can_ram_get_layout()
125 num_rx = can_ram_rounddown_pow_of_two(config, &config->rx, in can_ram_get_layout()
129 ram_free = config->size - config->rx.size[fd_mode] * num_rx; in can_ram_get_layout()
130 num_tx = ram_free / config->tx.size[fd_mode]; in can_ram_get_layout()
131 num_tx = min_t(u8, ring->tx_pending, num_tx); in can_ram_get_layout()
132 num_tx = can_ram_rounddown_pow_of_two(config, &config->tx, 0, num_tx); in can_ram_get_layout()
137 if (ec && !(ec->tx_coalesce_usecs_irq == 0 && in can_ram_get_layout()
138 ec->tx_max_coalesced_frames_irq == 1)) { in can_ram_get_layout()
141 /* use only max half of available objects for coalescing */ in can_ram_get_layout()
142 max = min_t(u8, num_tx / 2, config->fifo_depth); in can_ram_get_layout()
143 num_tx_coalesce = clamp(ec->tx_max_coalesced_frames_irq, in can_ram_get_layout()
144 (u32)config->tx.fifo_depth_coalesce_min, in can_ram_get_layout()
148 num_tx = can_ram_rounddown_pow_of_two(config, &config->tx, in can_ram_get_layout()
152 layout->cur_rx = num_rx; in can_ram_get_layout()
153 layout->cur_tx = num_tx; in can_ram_get_layout()
154 layout->rx_coalesce = num_rx_coalesce; in can_ram_get_layout()
155 layout->tx_coalesce = num_tx_coalesce; in can_ram_get_layout()
157 layout->cur_rx = layout->default_rx; in can_ram_get_layout()
158 layout->cur_tx = layout->default_tx; in can_ram_get_layout()
159 layout->rx_coalesce = 0; in can_ram_get_layout()
160 layout->tx_coalesce = 0; in can_ram_get_layout()