summaryrefslogtreecommitdiffstats
path: root/drivers/net/can/spi/mcp251xfd/mcp251xfd-ram.h
blob: 7558c1510cbf29619498f8e74a61210f30a539c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* SPDX-License-Identifier: GPL-2.0
 *
 * mcp251xfd - Microchip MCP251xFD Family CAN controller driver
 *
 * Copyright (c) 2021, 2022 Pengutronix,
 *               Marc Kleine-Budde <kernel@pengutronix.de>
 */

#ifndef _MCP251XFD_RAM_H
#define _MCP251XFD_RAM_H

#include <linux/ethtool.h>

#define CAN_RAM_NUM_MAX (-1)

enum can_ram_mode {
	CAN_RAM_MODE_CAN,
	CAN_RAM_MODE_CANFD,
	__CAN_RAM_MODE_MAX
};

struct can_ram_obj_config {
	u8 size[__CAN_RAM_MODE_MAX];

	u8 def[__CAN_RAM_MODE_MAX];
	u8 min;
	u8 max;

	u8 fifo_num;
	u8 fifo_depth_min;
	u8 fifo_depth_coalesce_min;
};

struct can_ram_config {
	const struct can_ram_obj_config rx;
	const struct can_ram_obj_config tx;

	u16 size;
	u8 fifo_depth;
};

struct can_ram_layout {
	u8 default_rx;
	u8 default_tx;

	u8 max_rx;
	u8 max_tx;

	u8 cur_rx;
	u8 cur_tx;

	u8 rx_coalesce;
	u8 tx_coalesce;
};

void can_ram_get_layout(struct can_ram_layout *layout,
			const struct can_ram_config *config,
			const struct ethtool_ringparam *ring,
			const struct ethtool_coalesce *ec,
			const bool fd_mode);

#endif