xref: /linux/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h (revision e65e175b07bef5974045cc42238de99057669ca7)
1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /* Copyright 2013-2016 Freescale Semiconductor Inc.
3  * Copyright 2019 NXP
4  */
5 #ifndef _FSL_DPMAC_CMD_H
6 #define _FSL_DPMAC_CMD_H
7 
8 /* DPMAC Version */
9 #define DPMAC_VER_MAJOR				4
10 #define DPMAC_VER_MINOR				4
11 #define DPMAC_CMD_BASE_VERSION			1
12 #define DPMAC_CMD_2ND_VERSION			2
13 #define DPMAC_CMD_ID_OFFSET			4
14 
15 #define DPMAC_CMD(id)	(((id) << DPMAC_CMD_ID_OFFSET) | DPMAC_CMD_BASE_VERSION)
16 #define DPMAC_CMD_V2(id) (((id) << DPMAC_CMD_ID_OFFSET) | DPMAC_CMD_2ND_VERSION)
17 
18 /* Command IDs */
19 #define DPMAC_CMDID_CLOSE		DPMAC_CMD(0x800)
20 #define DPMAC_CMDID_OPEN		DPMAC_CMD(0x80c)
21 
22 #define DPMAC_CMDID_GET_API_VERSION	DPMAC_CMD(0xa0c)
23 
24 #define DPMAC_CMDID_GET_ATTR		DPMAC_CMD(0x004)
25 #define DPMAC_CMDID_SET_LINK_STATE	DPMAC_CMD_V2(0x0c3)
26 
27 #define DPMAC_CMDID_GET_COUNTER		DPMAC_CMD(0x0c4)
28 
29 #define DPMAC_CMDID_SET_PROTOCOL	DPMAC_CMD(0x0c7)
30 
31 /* Macros for accessing command fields smaller than 1byte */
32 #define DPMAC_MASK(field)        \
33 	GENMASK(DPMAC_##field##_SHIFT + DPMAC_##field##_SIZE - 1, \
34 		DPMAC_##field##_SHIFT)
35 
36 #define dpmac_set_field(var, field, val) \
37 	((var) |= (((val) << DPMAC_##field##_SHIFT) & DPMAC_MASK(field)))
38 #define dpmac_get_field(var, field)      \
39 	(((var) & DPMAC_MASK(field)) >> DPMAC_##field##_SHIFT)
40 
41 struct dpmac_cmd_open {
42 	__le32 dpmac_id;
43 };
44 
45 struct dpmac_rsp_get_attributes {
46 	u8 eth_if;
47 	u8 link_type;
48 	__le16 id;
49 	__le32 max_rate;
50 };
51 
52 #define DPMAC_STATE_SIZE	1
53 #define DPMAC_STATE_SHIFT	0
54 #define DPMAC_STATE_VALID_SIZE	1
55 #define DPMAC_STATE_VALID_SHIFT	1
56 
57 struct dpmac_cmd_set_link_state {
58 	__le64 options;
59 	__le32 rate;
60 	__le32 pad0;
61 	/* from lsb: up:1, state_valid:1 */
62 	u8 state;
63 	u8 pad1[7];
64 	__le64 supported;
65 	__le64 advertising;
66 };
67 
68 struct dpmac_cmd_get_counter {
69 	u8 id;
70 };
71 
72 struct dpmac_rsp_get_counter {
73 	__le64 pad;
74 	__le64 counter;
75 };
76 
77 struct dpmac_rsp_get_api_version {
78 	__le16 major;
79 	__le16 minor;
80 };
81 
82 struct dpmac_cmd_set_protocol {
83 	u8 eth_if;
84 };
85 #endif /* _FSL_DPMAC_CMD_H */
86