1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifndef TransporterInternalDefinitions_H
17
#define TransporterInternalDefinitions_H
19
#if defined DEBUG_TRANSPORTER || defined VM_TRACE
23
#define NDB_TCP_TRANSPORTER
26
#define NDB_SHM_TRANSPORTER
30
#define NDB_SCI_TRANSPORTER
33
#ifdef DEBUG_TRANSPORTER
34
#define DEBUG(x) ndbout << x << endl
39
#if defined VM_TRACE || defined DEBUG_TRANSPORTER
40
#define WARNING(X) ndbout << X << endl;
45
// Calculate a checksum
48
computeChecksum(const Uint32 * const startOfData, int nWords) {
49
Uint32 chksum = startOfData[0];
50
for (int i=1; i < nWords; i++)
51
chksum ^= startOfData[i];
62
* b = Byte order - 4 Bits (Note 1 significant bit)
65
* c = Checksum included - 1 Bit
66
* z = Compression - 1 Bit
67
* v = Version id - 4 Bits
68
* i = Signal id included - 1 Bit
69
* m = Message length - 16 Bits (0-65536) (In word -> 0-256k bytes)
70
* d = Signal data length - 5 Bits (0-31)
71
* t = trace - 6 Bits (0-63)
72
* r = Recievers block no - 16 Bits
73
* s = Senders block no - 16 Bits
75
* f = FragmentInfo1 - 1 Bit
76
* h = FragmentInfo2 - 1 bit
77
* n = No of segments - 2 Bits
82
* 1111111111222222222233
83
* 01234567890123456789012345678901
84
* bfizcppbmmmmmmmmmmmmmmmmbhdddddb
89
* 1111111111222222222233
90
* 01234567890123456789012345678901
91
* ggggggggggggggggvvvvttttttnn
96
* 1111111111222222222233
97
* 01234567890123456789012345678901
98
* rrrrrrrrrrrrrrrrssssssssssssssss
101
* Word 4 (Optional Signal Id)
105
* 0 = Big endian (Sparc), 1 = Little endian (Intel)
107
static Uint32 getByteOrder (const Uint32 & word1);
108
static Uint32 getCompressed (const Uint32 & word1);
109
static Uint32 getSignalIdIncluded(const Uint32 & word1);
110
static Uint32 getCheckSumIncluded(const Uint32 & word1);
111
static Uint32 getPrio (const Uint32 & word1);
112
static Uint32 getMessageLength (const Uint32 & word1);
114
static void setByteOrder (Uint32 & word1, Uint32 byteOrder);
115
static void setCompressed (Uint32 & word1, Uint32 compressed);
116
static void setSignalIdIncluded(Uint32 & word1, Uint32 signalId);
117
static void setCheckSumIncluded(Uint32 & word1, Uint32 checkSum);
118
static void setPrio (Uint32 & word1, Uint32 prio);
119
static void setMessageLength (Uint32 & word1, Uint32 messageLen);
121
static void createSignalHeader(SignalHeader * const dst,
122
const Uint32 & word1,
123
const Uint32 & word2,
124
const Uint32 & word3);
126
static void createProtocol6Header(Uint32 & word1,
129
const SignalHeader * const src);
132
#define WORD1_BYTEORDER_MASK (0x81000081)
133
#define WORD1_SIGNALID_MASK (0x00000004)
134
#define WORD1_COMPRESSED_MASK (0x00000008)
135
#define WORD1_CHECKSUM_MASK (0x00000010)
136
#define WORD1_PRIO_MASK (0x00000060)
137
#define WORD1_MESSAGELEN_MASK (0x00FFFF00)
138
#define WORD1_SIGNAL_LEN_MASK (0x7C000000)
139
#define WORD1_FRAG_INF_MASK (0x00000002)
140
#define WORD1_FRAG_INF2_MASK (0x02000000)
142
#define WORD1_FRAG_INF_SHIFT (1)
143
#define WORD1_SIGNALID_SHIFT (2)
144
#define WORD1_COMPRESSED_SHIFT (3)
145
#define WORD1_CHECKSUM_SHIFT (4)
146
#define WORD1_PRIO_SHIFT (5)
147
#define WORD1_MESSAGELEN_SHIFT (8)
148
#define WORD1_FRAG_INF2_SHIFT (25)
149
#define WORD1_SIGNAL_LEN_SHIFT (26)
151
#define WORD2_VERID_GSN_MASK (0x000FFFFF)
152
#define WORD2_TRACE_MASK (0x03f00000)
153
#define WORD2_SEC_COUNT_MASK (0x0c000000)
155
#define WORD2_TRACE_SHIFT (20)
156
#define WORD2_SEC_COUNT_SHIFT (26)
158
#define WORD3_SENDER_MASK (0x0000FFFF)
159
#define WORD3_RECEIVER_MASK (0xFFFF0000)
161
#define WORD3_RECEIVER_SHIFT (16)
165
Protocol6::getByteOrder(const Uint32 & word1){
171
Protocol6::getCompressed(const Uint32 & word1){
172
return (word1 & WORD1_COMPRESSED_MASK) >> WORD1_COMPRESSED_SHIFT;
177
Protocol6::getSignalIdIncluded(const Uint32 & word1){
178
return (word1 & WORD1_SIGNALID_MASK) >> WORD1_SIGNALID_SHIFT;
183
Protocol6::getCheckSumIncluded(const Uint32 & word1){
184
return (word1 & WORD1_CHECKSUM_MASK) >> WORD1_CHECKSUM_SHIFT;
189
Protocol6::getMessageLength(const Uint32 & word1){
190
return (word1 & WORD1_MESSAGELEN_MASK) >> WORD1_MESSAGELEN_SHIFT;
195
Protocol6::getPrio(const Uint32 & word1){
196
return (word1 & WORD1_PRIO_MASK) >> WORD1_PRIO_SHIFT;
201
Protocol6::setByteOrder(Uint32 & word1, Uint32 byteOrder){
202
Uint32 tmp = byteOrder;
205
word1 |= (tmp & WORD1_BYTEORDER_MASK);
210
Protocol6::setCompressed(Uint32 & word1, Uint32 compressed){
211
word1 |= ((compressed << WORD1_COMPRESSED_SHIFT) & WORD1_COMPRESSED_MASK);
216
Protocol6::setSignalIdIncluded(Uint32 & word1, Uint32 signalId){
217
word1 |= ((signalId << WORD1_SIGNALID_SHIFT) & WORD1_SIGNALID_MASK);
222
Protocol6::setCheckSumIncluded(Uint32 & word1, Uint32 checkSum){
223
word1 |= ((checkSum << WORD1_CHECKSUM_SHIFT) & WORD1_CHECKSUM_MASK);
228
Protocol6::setMessageLength(Uint32 & word1, Uint32 messageLen){
229
word1 |= ((messageLen << WORD1_MESSAGELEN_SHIFT) & WORD1_MESSAGELEN_MASK);
234
Protocol6::setPrio(Uint32 & word1, Uint32 prio){
235
word1 |= ((prio << WORD1_PRIO_SHIFT) & WORD1_PRIO_MASK);
240
Protocol6::createSignalHeader(SignalHeader * const dst,
241
const Uint32 & word1,
242
const Uint32 & word2,
243
const Uint32 & word3){
245
Uint32 signal_len = (word1 & WORD1_SIGNAL_LEN_MASK)>> WORD1_SIGNAL_LEN_SHIFT;
246
Uint32 fragInfo1 = (word1 & WORD1_FRAG_INF_MASK) >> (WORD1_FRAG_INF_SHIFT-1);
247
Uint32 fragInfo2 = (word1 & WORD1_FRAG_INF2_MASK) >> (WORD1_FRAG_INF2_SHIFT);
248
Uint32 trace = (word2 & WORD2_TRACE_MASK) >> WORD2_TRACE_SHIFT;
249
Uint32 verid_gsn = (word2 & WORD2_VERID_GSN_MASK);
250
Uint32 secCount = (word2 & WORD2_SEC_COUNT_MASK) >> WORD2_SEC_COUNT_SHIFT;
252
dst->theTrace = trace;
253
dst->m_noOfSections = secCount;
254
dst->m_fragmentInfo = fragInfo1 | fragInfo2;
256
dst->theLength = signal_len;
257
dst->theVerId_signalNumber = verid_gsn;
259
Uint32 sBlockNum = (word3 & WORD3_SENDER_MASK);
260
Uint32 rBlockNum = (word3 & WORD3_RECEIVER_MASK) >> WORD3_RECEIVER_SHIFT;
262
dst->theSendersBlockRef = sBlockNum;
263
dst->theReceiversBlockNumber = rBlockNum;
268
Protocol6::createProtocol6Header(Uint32 & word1,
271
const SignalHeader * const src){
272
const Uint32 signal_len = src->theLength;
273
const Uint32 fragInfo = src->m_fragmentInfo;
274
const Uint32 fragInfo1 = (fragInfo & 2);
275
const Uint32 fragInfo2 = (fragInfo & 1);
277
const Uint32 trace = src->theTrace;
278
const Uint32 verid_gsn = src->theVerId_signalNumber;
279
const Uint32 secCount = src->m_noOfSections;
281
word1 |= ((signal_len << WORD1_SIGNAL_LEN_SHIFT) & WORD1_SIGNAL_LEN_MASK);
282
word1 |= ((fragInfo1 << (WORD1_FRAG_INF_SHIFT-1)) & WORD1_FRAG_INF_MASK);
283
word1 |= ((fragInfo2 << WORD1_FRAG_INF2_SHIFT) & WORD1_FRAG_INF2_MASK);
285
word2 |= ((trace << WORD2_TRACE_SHIFT) & WORD2_TRACE_MASK);
286
word2 |= (verid_gsn & WORD2_VERID_GSN_MASK);
287
word2 |= ((secCount << WORD2_SEC_COUNT_SHIFT) & WORD2_SEC_COUNT_MASK);
289
Uint32 sBlockNum = src->theSendersBlockRef ;
290
Uint32 rBlockNum = src->theReceiversBlockNumber ;
292
word3 |= (sBlockNum & WORD3_SENDER_MASK);
293
word3 |= ((rBlockNum << WORD3_RECEIVER_SHIFT) & WORD3_RECEIVER_MASK);
296
// Define of TransporterInternalDefinitions_H