summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/0001-Smbus-changes-for-libmctp.patch
blob: e456c10ad32f867188e3481ab8925f79bf801bb2 (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
142
143
144
145
146
147
148
From cb330f4bf1f519032ee50d60f473c28df7b772d8 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] Smbus changes for libmctp

---
 CMakeLists.txt |  6 ++++--
 core.c         |  2 ++
 libmctp.h      | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a5b1042..249b12b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,9 @@ cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
 
 add_definitions (-DMCTP_LOG_STDERR)
 add_definitions (-DMCTP_FILEIO)
+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}>
@@ -18,5 +19,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 b855ced..8be7407 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;
@@ -50,6 +51,7 @@ struct mctp {
 	 */
 	struct mctp_msg_ctx	msg_ctxs[16];
 };
+/* clang-format on */
 
 #ifndef BUILD_ASSERT
 #define BUILD_ASSERT(x) \
diff --git a/libmctp.h b/libmctp.h
index f0633e3..cec7c00 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,12 +31,47 @@ struct mctp_hdr {
 #define MCTP_HDR_SEQ_MASK	(0x3)
 #define MCTP_HDR_TAG_SHIFT	(0)
 #define MCTP_HDR_TAG_MASK	(0x7)
+/* clang-format on */
 
 /* Maximum size of *payload* data in a MCTP packet
  * @todo: dynamic sixing based on channel implementation.
  */
 #define MCTP_MTU	64
 
+#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 */
 
 /* Allow a little space before the MCTP header in the packet, for bindings that
@@ -46,12 +82,14 @@ struct mctp_hdr {
 #define MCTP_PKTBUF_SIZE	(MCTP_PKTBUF_BINDING_PAD + \
 		(sizeof(struct mctp_hdr) + MCTP_MTU))
 
+/* clang-format off */
 struct mctp_pktbuf {
 	unsigned char	data[MCTP_PKTBUF_SIZE];
 	uint8_t		start, end;
 	uint8_t		mctp_hdr_off;
 	struct mctp_pktbuf *next;
 };
+/* clang-format on */
 
 struct mctp_pktbuf *mctp_pktbuf_alloc(uint8_t len);
 void mctp_pktbuf_free(struct mctp_pktbuf *pkt);
@@ -85,6 +123,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;
@@ -93,6 +132,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