openMMC
Open Source Modular MMC for AMCs
Loading...
Searching...
No Matches
ipmb.h
Go to the documentation of this file.
1/*
2 * openMMC -- Open Source modular IPM Controller firmware
3 *
4 * Copyright (C) 2015-2016 Henrique Silva <henrique.silva@lnls.br>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
20 */
21
29#ifndef IPMB_H_
30#define IPMB_H_
31
32/* FreeRTOS includes */
33#include "FreeRTOS.h"
34#include "task.h"
35#include "queue.h"
36#include "semphr.h"
37#include "board_ipmb.h"
38
39
43#define IPMB_ADDR_DISCONNECTED 0xA2
44
48#define IPMB_TXQUEUE_LEN 10
49
53#define IPMB_CLIENT_QUEUE_LEN 10
54
58#define IPMB_MAX_RETRIES 3
59
63#define IPMB_MSG_TIMEOUT 250/portTICK_PERIOD_MS
64
68#define CLIENT_NOTIFY_TIMEOUT 5
69
73#define IPMI_HEADER_CHECKSUM_POSITION 2
74
78#define IPMI_MSG_MAX_LENGTH 32
79
92#define IPMB_REQ_HEADER_LENGTH 6
93
108#define IPMB_RESP_HEADER_LENGTH 7
109
110#define IPMB_NETFN_MASK 0xFC
111#define IPMB_DEST_LUN_MASK 0x03
112#define IPMB_SEQ_MASK 0xFC
113#define IPMB_SRC_LUN_MASK 0x03
114
118#define MCH_ADDRESS 0x20
119
123#define IS_RESPONSE(msg) (msg.netfn & 0x01)
124
128#define IPMBL_TABLE_SIZE 27
129
138
142typedef struct ipmi_msg {
143 uint8_t dest_addr;
144 uint8_t netfn;
147 uint8_t dest_LUN;
148 uint8_t hdr_chksum;
149 uint8_t src_addr;
150 uint8_t seq;
151 uint8_t src_LUN;
152 uint8_t cmd;
158 uint8_t data_len;
163 uint8_t msg_chksum;
165
171typedef struct ipmi_msg_cfg {
173 TaskHandle_t caller_task;
174 uint8_t retries;
175 uint32_t timestamp;
177
191
199extern uint8_t ipmb_addr;
200
201/* Function Prototypes */
202
220void IPMB_TXTask ( void *pvParameters );
221
237void IPMB_RXTask ( void *pvParameters );
238
244void ipmb_init ( void );
245
250
255
267ipmb_error ipmb_register_rxqueue ( QueueHandle_t * queue );
268
279ipmb_error ipmb_assert_chksum ( uint8_t * buffer, uint8_t buffer_len );
280
328uint8_t get_ipmb_addr( void );
329
330#endif
Board specific definitions used in IPMB Layer.
ipmb_error ipmb_register_rxqueue(QueueHandle_t *queue)
Creates and returns a queue in which the client can block to receive the incoming requests.
Definition ipmb.c:329
void ipmb_init(void)
Initializes the IPMB Layer.
Definition ipmb.c:236
uint8_t get_ipmb_addr(void)
Reads own I2C slave address using GA pins.
Definition board_ipmb.c:44
ipmb_error ipmb_assert_chksum(uint8_t *buffer, uint8_t buffer_len)
Asserts the input message checksums by comparing them with our calculated ones.
Definition ipmb.c:344
void IPMB_RXTask(void *pvParameters)
IPMB Receiver Task.
Definition ipmb.c:179
ipmb_error
IPMB errors enumeration.
Definition ipmb.h:181
@ ipmb_error_timeout
Definition ipmb.h:185
@ ipmb_error_invalid_req
Definition ipmb.h:186
@ ipmb_error_unknown
Definition ipmb.h:182
@ ipmb_error_queue_creation
Definition ipmb.h:189
@ ipmb_error_success
Definition ipmb.h:183
@ ipmb_error_hdr_chksum
Definition ipmb.h:187
@ ipmb_error_msg_chksum
Definition ipmb.h:188
@ ipmb_error_failure
Definition ipmb.h:184
#define IPMI_MSG_MAX_LENGTH
Maximum length in bytes of a IPMI message (including connection header)
Definition ipmb.h:78
void IPMB_TXTask(void *pvParameters)
IPMB Transmitter Task.
Definition ipmb.c:99
ipmb_error ipmb_send_request(ipmi_msg *req)
Format and send a request via IPMB channel.
Definition ipmb.c:250
ipmb_error ipmb_send_response(ipmi_msg *req, ipmi_msg *resp)
Format and send a response via IPMB channel.
Definition ipmb.c:277
GA_Pin_state
GA pins definition.
Definition ipmb.h:133
@ UNCONNECTED
Definition ipmb.h:136
@ POWERED
Definition ipmb.h:135
@ GROUNDED
Definition ipmb.h:134
uint8_t ipmb_addr
AMC IPMB Address.
Definition ipmb.c:91
struct ipmi_msg_cfg ipmi_msg_cfg
IPMI message configuration struct.
struct ipmi_msg ipmi_msg
IPMI message struct.
IPMI message configuration struct.
Definition ipmb.h:171
uint8_t retries
Definition ipmb.h:174
TaskHandle_t caller_task
Definition ipmb.h:173
ipmi_msg buffer
Definition ipmb.h:172
uint32_t timestamp
Definition ipmb.h:175
IPMI message struct.
Definition ipmb.h:142
uint8_t data[IPMI_MSG_MAX_LENGTH]
Definition ipmb.h:159
uint8_t src_addr
Definition ipmb.h:149
uint8_t dest_LUN
Definition ipmb.h:147
uint8_t netfn
Definition ipmb.h:144
uint8_t seq
Definition ipmb.h:150
uint8_t completion_code
Definition ipmb.h:155
uint8_t data_len
Definition ipmb.h:158
uint8_t dest_addr
Definition ipmb.h:143
uint8_t cmd
Definition ipmb.h:152
uint8_t hdr_chksum
Definition ipmb.h:148
uint8_t msg_chksum
Definition ipmb.h:163
uint8_t src_LUN
Definition ipmb.h:151