1  /* SPDX-License-Identifier: GPL-2.0
2   *
3   * mcp251xfd - Microchip MCP251xFD Family CAN controller driver
4   *
5   * Copyright (c) 2021, 2022 Pengutronix,
6   *               Marc Kleine-Budde <kernel@pengutronix.de>
7   */
8  
9  #ifndef _MCP251XFD_RAM_H
10  #define _MCP251XFD_RAM_H
11  
12  #include <linux/ethtool.h>
13  
14  #define CAN_RAM_NUM_MAX (-1)
15  
16  enum can_ram_mode {
17  	CAN_RAM_MODE_CAN,
18  	CAN_RAM_MODE_CANFD,
19  	__CAN_RAM_MODE_MAX
20  };
21  
22  struct can_ram_obj_config {
23  	u8 size[__CAN_RAM_MODE_MAX];
24  
25  	u8 def[__CAN_RAM_MODE_MAX];
26  	u8 min;
27  	u8 max;
28  
29  	u8 fifo_num;
30  	u8 fifo_depth_min;
31  	u8 fifo_depth_coalesce_min;
32  };
33  
34  struct can_ram_config {
35  	const struct can_ram_obj_config rx;
36  	const struct can_ram_obj_config tx;
37  
38  	u16 size;
39  	u8 fifo_depth;
40  };
41  
42  struct can_ram_layout {
43  	u8 default_rx;
44  	u8 default_tx;
45  
46  	u8 max_rx;
47  	u8 max_tx;
48  
49  	u8 cur_rx;
50  	u8 cur_tx;
51  
52  	u8 rx_coalesce;
53  	u8 tx_coalesce;
54  };
55  
56  void can_ram_get_layout(struct can_ram_layout *layout,
57  			const struct can_ram_config *config,
58  			const struct ethtool_ringparam *ring,
59  			const struct ethtool_coalesce *ec,
60  			const bool fd_mode);
61  
62  #endif
63