summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/0001-Smbus-changes-for-libmctp.patch
blob: 7bba22ede75d752f3a7aa77c5741512485d3550d (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
From ab1634441f4dd218486f6bb3b94e90e2110ccc2a Mon Sep 17 00:00:00 2001
From: Nikhil Potade <nikhil.potade@linux.intel.com>
Date: Tue, 19 Feb 2019 14:16:20 +0800
Subject: [PATCH 1/1] Smbus changes for libmctp

Signed-off-by: James Feist <james.feist@linux.intel.com>
---
 CMakeLists.txt |  5 +++--
 core.c         |  2 ++
 libmctp.h      | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f3f05bd..7991b11 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,7 @@ add_definitions (-DMCTP_HAVE_FILEIO)
 add_definitions (-DMCTP_HAVE_STDIO)
 add_definitions (-DMCTP_DEFAULT_ALLOC)
 
-add_library (libmctp STATIC alloc.c core.c log.c libmctp.h serial.c)
+add_library (libmctp STATIC alloc.c core.c log.c libmctp.h serial.c smbus.c crc32c.c)
 
 target_include_directories (libmctp PUBLIC
                             $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
@@ -20,5 +20,6 @@ add_executable (test_seq tests/test_seq.c tests/test-utils.c)
 target_link_libraries (test_seq libmctp)
 
 install (TARGETS libmctp DESTINATION lib)
-install (FILES libmctp.h DESTINATION include)
+install (FILES libmctp.h libmctp-smbus.h libmctp-serial.h crc32c.h DESTINATION
+       include)
 
diff --git a/core.c b/core.c
index f8abbb1..79a681c 100644
--- a/core.c
+++ b/core.c
@@ -17,6 +17,7 @@
 
 /* Internal data structures */
 
+/* clang-format off */
 struct mctp_bus {
 	mctp_eid_t		eid;
 	struct mctp_binding	*binding;
@@ -56,6 +57,7 @@ struct mctp {
 		ROUTE_BRIDGE,
 	}			route_policy;
 };
+/* clang-format on */
 
 #ifndef BUILD_ASSERT
 #define BUILD_ASSERT(x) \
diff --git a/libmctp.h b/libmctp.h
index 69ec46a..b7212be 100644
--- a/libmctp.h
+++ b/libmctp.h
@@ -15,6 +15,7 @@ extern "C" {
 typedef uint8_t mctp_eid_t;
 
 /* MCTP packet definitions */
+/* clang-format off */
 struct mctp_hdr {
 	uint8_t	ver;
 	uint8_t	dest;
@@ -30,19 +31,56 @@ struct mctp_hdr {
 #define MCTP_HDR_SEQ_MASK	(0x3)
 #define MCTP_HDR_TAG_SHIFT	(0)
 #define MCTP_HDR_TAG_MASK	(0x7)
+/* clang-format on */
 
 /* Baseline Transmission Unit and packet size */
 #define MCTP_BTU		64
 #define MCTP_PACKET_SIZE(unit)	((unit) + sizeof(struct mctp_hdr))
 
+#define MCTP_CONTROL_MESSAGE_TYPE	0x00
+
+enum MCTP_COMMAND_CODE {
+	MCTP_COMMAND_CODE_SET_EID			= 0x01,
+	MCTP_COMMAND_CODE_GET_EID			= 0x02,
+	MCTP_COMMAND_CODE_GET_ENDPOINT_UUID		= 0x03,
+	MCTP_COMMAND_CODE_GET_MCTP_VERSION_SUPPORT	= 0x04,
+	MCTP_COMMAND_CODE_GET_MESSAGE_TYPE_SUPPORT	= 0x05,
+	MCTP_COMMAND_CODE_GET_VENDOR_DEFINED_MSG_SUPPORT= 0x06,
+	MCTP_COMMAND_CODE_RESOLVE_ENDPOINT_ID		= 0x07,
+	MCTP_COMMAND_CODE_ALLOCATE_ENDPOINT_IDS		= 0x08,
+	MCTP_COMMAND_CODE_ROUTING_INFORMATION_UPDATE	= 0x09,
+	MCTP_COMMAND_CODE_GET_ROUTING_TABLE_ENTRIES	= 0x0A,
+	MCTP_COMMAND_CODE_PREPARE_FOR_ENDPOINT_DISCOVERY= 0x0B,
+	MCTP_COMMAND_CODE_ENDPOINT_DISCOVERY		= 0x0C,
+	MCTP_COMMAND_CODE_DISCOVERY_NOTIFY		= 0x0D,
+	MCTP_COMMAND_CODE_GET_NETWORK_ID		= 0x0E,
+	MCTP_COMMAND_CODE_QUERY_HOP			= 0x0F,
+	MCTP_COMMAND_CODE_RESOLVE_UUID			= 0x10,
+	MCTP_COMMAND_CODE_QUERY_RATE_LIMIT		= 0x11,
+	MCTP_COMMAND_CODE_REQUEST_TX_RATE_LIMIT		= 0x12,
+	MCTP_COMMAND_CODE_UPDATE_RATE_LIMIT		= 0x13,
+	MCTP_COMMAND_CODE_QUERY_SUPPORTED_INTERFACES	= 0x14
+};
+
+enum MCTP_CONTROL_MSG_COMPLETION_CODE {
+	MCTP_CONTROL_MSG_STATUS_SUCCESS			= 0x00,
+	MCTP_CONTROL_MSG_STATUS_ERROR			= 0x01,
+	MCTP_CONTROL_MSG_STATUS_ERROR_INVALID_DATA	= 0x02,
+	MCTP_CONTROL_MSG_STATUS_ERROR_INVALID_LENGTH	= 0x03,
+	MCTP_CONTROL_MSG_STATUS_ERROR_NOT_READY		= 0x04,
+	MCTP_CONTROL_MSG_STATUS_ERROR_UNSUPPORTED_CMD	= 0x05
+};
+
 /* packet buffers */
 
+/* clang-format off */
 struct mctp_pktbuf {
 	size_t		start, end, size;
 	size_t		mctp_hdr_off;
 	struct mctp_pktbuf *next;
 	unsigned char	data[];
 };
+/* clang-format on */
 
 struct mctp_binding;
 
@@ -90,6 +128,7 @@ int mctp_message_tx(struct mctp *mctp, mctp_eid_t eid,
 		void *msg, size_t msg_len);
 
 /* hardware bindings */
+/* clang-format off */
 struct mctp_binding {
 	const char	*name;
 	uint8_t		version;
@@ -101,6 +140,7 @@ struct mctp_binding {
 	int		(*tx)(struct mctp_binding *binding,
 				struct mctp_pktbuf *pkt);
 };
+/* clang-format on */
 
 void mctp_binding_set_tx_enabled(struct mctp_binding *binding, bool enable);
 
-- 
2.17.1