summaryrefslogtreecommitdiffstats
path: root/src/usr/secureboot/node_comm/node_comm_transfer.H
blob: 93f45a512d303585f7a22b08fc3bd9553b6fe5d9 (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/secureboot/node_comm/node_comm_transfer.H $           */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2019                             */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __NODE_COMM_TRANSFER_H
#define __NODE_COMM_TRANSFER_H

// ----------------------------------------------
// Includes
// ----------------------------------------------
#include "node_comm.H"
#include <map>

// ----------------------------------------------
// Defines
// ----------------------------------------------


namespace SECUREBOOT
{

namespace NODECOMM
{


/*
 * @brief Node Comm Transfer Types - descriptions of messages sent between nodes
 */
enum node_comm_transfer_types_t : uint8_t
{
    // Size of 1 byte due to its inclusion in node_comm_msg_format_t

    // Invalid Type for node_comm_msg_format_t initialization
    NCT_INVALID_TYPE               =  0x00,

    // Types of ACKs (Ackowledgments)
    NCT_ACK_OF_INTIATION           =  0x01,
    NCT_ACK_OF_DATA                =  0x02,

    // Message Transfer Types
    NCT_TRANSFER_SBID              =  0x10,
    NCT_TRANSFER_QUOTE_REQUEST     =  0x11,
    NCT_TRANSFER_QUOTE_RESPONSE    =  0x12,
};

/**
 * @brief Node Comm Message Format
 *
 * @note: msg sequence 0: Initiation Message
 *        msg sequence 1..N: 8-byte data messages
 *
 */
union node_comm_msg_format_t
{
    uint64_t value;
    struct
    {
        uint64_t sendingNode   :  4; // Sending Node
        uint64_t recvingNode   :  4; // Receiving Node
        uint64_t msgType       :  8; // Msg Type (node_comm_transfer_types_t)
        uint64_t msgSeqNum     : 16; // Msg Sequence Number
        uint64_t totalDataMsgs : 16; // Total Number of Expected Data Messages
        uint64_t totalDataSize : 16; // Total Size of Data in bytes
    } PACKED;
};

/**
 * @brief Map of expected sizes associated with Message Transfer Types
 */
const std::map<node_comm_transfer_types_t, size_t>
    TransferSizeMap = {{NCT_TRANSFER_SBID,
                            sizeof(uint64_t)},
                         {NCT_TRANSFER_QUOTE_REQUEST,
                            sizeof(MasterQuoteRequestBlob)}};


/**
 *  @brief This function sends multiple messages with data over the ABUS from
           the processor of the current node to a processor on another node.
 *
 *  @param[in] i_pProc         - Processor target that is sending the data
 *                               Can't be nullptr
 *  @param[in] i_linkId        - Link Id Message is sent from
 *  @param[in] i_mboxId        - Mailbox Id Message is sent from
 *  @param[in] i_recvNode      - Node expected to receive the message
 *  @param[in] i_transferType  - Transfer Message Type to send
 *  @param[in] i_data          - Data to be sent
 *  @param[in] i_dataSize      - Size of Data to be sent in bytes
 *
 *  @note i_dataSize is verified to match i_transferType when applicable
 *        based on TransferSizeMap.
 *
 *  @return errlHndl_t Error log handle
 *  @retval nullptr Operation was successful
 *  @retval !nullptr Operation failed with valid error log
 */
errlHndl_t nodeCommTransferSend(TARGETING::Target* i_pProc,
                                uint8_t i_linkId,
                                uint8_t i_mboxId,
                                uint8_t i_recvNode,
                                node_comm_transfer_types_t i_transferType,
                                const uint8_t * i_data,
                                size_t i_dataSize);

/**
 *  @brief This function waits to receive multiple messages over the ABUS
 *         from a processor on another node.
 *
 *  @param[in]  i_pProc         - Processor target to receive messages on
 *                                Can't be nullptr
 *  @param[in]  i_linkId        - Link Id Message is expected from
 *  @param[in]  i_mboxId        - Mailbox Id Message is expected from
 *  @param[in]  i_sentNode      - Node expected to have sent the message
 *  @param[in]  i_transferType  - Expected Transfer Message Type to receive
 *                                Failure if different type is received
 *  @param[out] o_data          - Data received
 *  @param[out] o_dataSize      - Size of Data received
 *
 *  @note - While this function will dynamically create o_data buffer of size
 *          o_dataSize, the caller is responsible for deleting this buffer.
 *          If an error is returned, o_data will be nullptr and o_dataSize
 *          will be zero.
 *
 *  @note o_dataSize is verified to match i_transferType when applicable
 *        based on TransferSizeMap.
 *
 *  @return errlHndl_t Error log handle
 *  @retval nullptr Operation was successful
 *  @retval !nullptr Operation failed with valid error log
 */
errlHndl_t nodeCommTransferRecv(TARGETING::Target* i_pProc,
                                uint8_t i_linkId,
                                uint8_t i_mboxId,
                                uint8_t i_sentNode,
                                node_comm_transfer_types_t i_transferType,
                                uint8_t*& o_data,
                                size_t & o_dataSize);

} // end NODECOMM namespace

} // end SECUREBOOT namespace

#endif // End __NODE_COMM_TRANSFER_H

OpenPOWER on IntegriCloud