1 /*
2 Copyright (c) 2003, 2021, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #ifndef TC_KEY_CONF_H
26 #define TC_KEY_CONF_H
27
28 #include "SignalData.hpp"
29
30 #define JAM_FILE_ID 58
31
32
33 /**
34 *
35 */
36 class TcKeyConf {
37 /**
38 * Reciver(s)
39 */
40 friend class NdbImpl;
41 friend class NdbTransaction;
42 friend class Ndbcntr;
43 friend class DbUtil;
44
45 friend class TransporterFacade;
46
47 /**
48 * Sender(s)
49 */
50 friend class Dbtc;
51 friend class Dbspj;
52
53 /**
54 * For printing
55 */
56 friend bool printTCKEYCONF(FILE *, const Uint32 *, Uint32, Uint16);
57
58 public:
59 /**
60 * Length of signal
61 */
62 STATIC_CONST( StaticLength = 5 );
63 STATIC_CONST( OperationLength = 2 );
64 STATIC_CONST( DirtyReadBit = (((Uint32)1) << 31) );
65
66 protected:
67 /**
68 * DATA VARIABLES
69 */
70 //-------------------------------------------------------------
71 // Unconditional part. First 5 words
72 //-------------------------------------------------------------
73
74 Uint32 apiConnectPtr; // if RNIL, transaction is found from op
75 Uint32 gci_hi; // gci_lo is stored after operations...
76 Uint32 confInfo;
77 Uint32 transId1;
78 Uint32 transId2;
79
80 struct OperationConf {
81 Uint32 apiOperationPtr;
82 Uint32 attrInfoLen;
83 };
84 //-------------------------------------------------------------
85 // Operations confirmations,
86 // No of actually sent = getNoOfOperations(confInfo)
87 //-------------------------------------------------------------
88 OperationConf operations[10];
89
90 /**
91 * Get:ers for confInfo
92 */
93 static Uint32 getNoOfOperations(const Uint32 & confInfo);
94 static Uint32 getCommitFlag(const Uint32 & confInfo);
95 static bool getMarkerFlag(const Uint32 & confInfo);
96
97 /**
98 * Set:ers for confInfo
99 */
100 static void setCommitFlag(Uint32 & confInfo, Uint8 flag);
101 static void setNoOfOperations(Uint32 & confInfo, Uint32 noOfOps);
102 static void setMarkerFlag(Uint32 & confInfo, Uint32 flag);
103 };
104
105 inline
106 Uint32
getNoOfOperations(const Uint32 & confInfo)107 TcKeyConf::getNoOfOperations(const Uint32 & confInfo){
108 return confInfo & 65535;
109 }
110
111 inline
112 Uint32
getCommitFlag(const Uint32 & confInfo)113 TcKeyConf::getCommitFlag(const Uint32 & confInfo){
114 return ((confInfo >> 16) & 1);
115 }
116
117 inline
118 bool
getMarkerFlag(const Uint32 & confInfo)119 TcKeyConf::getMarkerFlag(const Uint32 & confInfo){
120 const Uint32 bits = 3 << 16; // Marker only valid when doing commit
121 return (confInfo & bits) == bits;
122 }
123
124 inline
125 void
setNoOfOperations(Uint32 & confInfo,Uint32 noOfOps)126 TcKeyConf::setNoOfOperations(Uint32 & confInfo, Uint32 noOfOps){
127 ASSERT_MAX(noOfOps, 65535, "TcKeyConf::setNoOfOperations");
128 confInfo = (confInfo & 0xFFFF0000) | noOfOps;
129 }
130
131 inline
132 void
setCommitFlag(Uint32 & confInfo,Uint8 flag)133 TcKeyConf::setCommitFlag(Uint32 & confInfo, Uint8 flag){
134 ASSERT_BOOL(flag, "TcKeyConf::setCommitFlag");
135 confInfo |= (flag << 16);
136 }
137
138 inline
139 void
setMarkerFlag(Uint32 & confInfo,Uint32 flag)140 TcKeyConf::setMarkerFlag(Uint32 & confInfo, Uint32 flag){
141 ASSERT_BOOL(flag, "TcKeyConf::setMarkerFlag");
142 confInfo |= (flag << 17);
143 }
144
145
146 #undef JAM_FILE_ID
147
148 #endif
149