1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3 * Copyright (c) 2014 Piotr Gawlowicz
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Piotr Gawlowicz <gawlowicz.p@gmail.com>
19 *
20 */
21
22 #ifndef LTE_FFR_SAP_H
23 #define LTE_FFR_SAP_H
24
25 #include <ns3/lte-rrc-sap.h>
26 #include <ns3/ff-mac-sched-sap.h>
27 #include <map>
28
29 namespace ns3 {
30
31 /**
32 * \brief Service Access Point (SAP) offered by the Frequency Reuse algorithm
33 * instance to the MAC Scheduler instance.
34 *
35 * This is the *LteFfrSapProvider*, i.e., the part of the SAP
36 * that contains the Frequency Reuse algorithm methods called by the MAC Scheduler
37 * instance.
38 */
39 class LteFfrSapProvider
40 {
41 public:
42 virtual ~LteFfrSapProvider ();
43
44 /**
45 * \brief Get vector of available RBG in DL for this Cell
46 * \return vector of size (m_dlBandwidth/RbgSize); false indicates
47 * that RBG is free to use, true otherwise
48 *
49 * This function is called by MAC Scheduler in the beginning of DL
50 * scheduling process. Frequency Reuse Algorithm based on its policy
51 * generates vector of RBG which can be used and which can not be used
52 * by Scheduler to schedule transmission.
53 */
54 virtual std::vector <bool> GetAvailableDlRbg () = 0;
55
56 /**
57 * \brief Check if UE can be served on i-th RB in DL
58 * \param i RBG ID
59 * \param rnti Radio Network Temporary Identity, an integer identifying the UE
60 * where the report originates from
61 * \return true if UE can be served on i-th RB, false otherwise
62 *
63 * This function is called by MAC Scheduler during DL scheduling process
64 * to check if UE is allowed to be served with i-th RBG. Frequency Reuse
65 * Algorithm based on its policy decides if RBG is allowed to UE.
66 * If yes, Scheduler will try to allocate this RBG for UE, if not this UE
67 * will not be served with this RBG.
68 */
69 virtual bool IsDlRbgAvailableForUe (int i, uint16_t rnti) = 0;
70
71 /**
72 * \brief Get vector of available RB in UL for this Cell
73 * \return vector of size m_ulBandwidth; false indicates
74 * that RB is free to use, true otherwise
75 *
76 * This function is called by MAC Scheduler in the beginning of UL
77 * scheduling process. Frequency Reuse Algorithm based on its policy
78 * generates vector of RB which can be used and which can not be used
79 * by Scheduler to schedule transmission.
80 */
81 virtual std::vector <bool> GetAvailableUlRbg () = 0;
82
83 /**
84 * \brief Check if UE can be served on i-th RB in UL
85 * \param i RB ID
86 * \param rnti Radio Network Temporary Identity, an integer identifying the UE
87 * where the report originates from
88 * \return true if UE can be served on i-th RB, false otherwise
89 *
90 * This function is called by MAC Scheduler during UL scheduling process
91 * to check if UE is allowed to be served with i-th RB. Frequency Reuse
92 * Algorithm based on its policy decides if RB is allowed to UE.
93 * If yes, Scheduler will try to allocate this RB for UE, if not this UE
94 * will not be served with this RB.
95 */
96 virtual bool IsUlRbgAvailableForUe (int i, uint16_t rnti) = 0;
97
98 /**
99 * \brief ReportDlCqiInfo
100 * \param params the struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters
101 */
102 virtual void ReportDlCqiInfo (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) = 0;
103
104 /**
105 * \brief ReportUlCqiInfo
106 * \param params the struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters
107 */
108 virtual void ReportUlCqiInfo (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) = 0;
109
110 /**
111 * \brief ReportUlCqiInfo
112 * \param ulCqiMap the UL CQI map
113 */
114 virtual void ReportUlCqiInfo ( std::map <uint16_t, std::vector <double> > ulCqiMap ) = 0;
115
116 /**
117 * \brief GetTpc
118 * \param rnti the RNTI
119 * \returns the TCP
120 */
121 virtual uint8_t GetTpc (uint16_t rnti) = 0;
122
123 /**
124 * \brief Get the minimum continuous Ul bandwidth
125 * \returns the minimum continuous UL bandwidth
126 */
127 virtual uint16_t GetMinContinuousUlBandwidth () = 0;
128 }; // end of class LteFfrSapProvider
129
130
131 /**
132 * \brief Service Access Point (SAP) offered by the eNodeB RRC instance to the
133 * Frequency Reuse algorithm instance.
134 *
135 * This is the *LteFfrSapUser*, i.e., the part of the SAP that
136 * contains the MAC Scheduler methods called by the Frequency Reuse algorithm instance.
137 */
138 class LteFfrSapUser
139 {
140 public:
141 virtual ~LteFfrSapUser ();
142
143 }; // end of class LteFfrSapUser
144
145
146 /**
147 * \brief Template for the implementation of the LteFfrSapProvider
148 * as a member of an owner class of type C to which all methods are
149 * forwarded.
150 */
151 template <class C>
152 class MemberLteFfrSapProvider : public LteFfrSapProvider
153 {
154 public:
155 /**
156 * Constructor
157 *
158 * \param owner the owner class
159 */
160 MemberLteFfrSapProvider (C* owner);
161
162 // inherited from LteFfrSapProvider
163 virtual std::vector <bool> GetAvailableDlRbg ();
164 virtual bool IsDlRbgAvailableForUe (int i, uint16_t rnti);
165 virtual std::vector <bool> GetAvailableUlRbg ();
166 virtual bool IsUlRbgAvailableForUe (int i, uint16_t rnti);
167 virtual void ReportDlCqiInfo (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params);
168 virtual void ReportUlCqiInfo (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params);
169 virtual void ReportUlCqiInfo ( std::map <uint16_t, std::vector <double> > ulCqiMap );
170 virtual uint8_t GetTpc (uint16_t rnti);
171 virtual uint16_t GetMinContinuousUlBandwidth ();
172 private:
173 MemberLteFfrSapProvider ();
174 C* m_owner; ///< the owner class
175
176 }; // end of class MemberLteFfrSapProvider
177
178
179 template <class C>
MemberLteFfrSapProvider(C * owner)180 MemberLteFfrSapProvider<C>::MemberLteFfrSapProvider (C* owner)
181 : m_owner (owner)
182 {
183 }
184
185
186 template <class C>
187 std::vector <bool>
GetAvailableDlRbg()188 MemberLteFfrSapProvider<C>::GetAvailableDlRbg ()
189 {
190 return m_owner->DoGetAvailableDlRbg ();
191 }
192
193 template <class C>
194 bool
IsDlRbgAvailableForUe(int i,uint16_t rnti)195 MemberLteFfrSapProvider<C>::IsDlRbgAvailableForUe (int i, uint16_t rnti)
196 {
197 return m_owner->DoIsDlRbgAvailableForUe (i,rnti);
198 }
199
200 template <class C>
201 std::vector <bool>
GetAvailableUlRbg()202 MemberLteFfrSapProvider<C>::GetAvailableUlRbg ()
203 {
204 return m_owner->DoGetAvailableUlRbg ();
205 }
206
207 template <class C>
208 bool
IsUlRbgAvailableForUe(int i,uint16_t rnti)209 MemberLteFfrSapProvider<C>::IsUlRbgAvailableForUe (int i, uint16_t rnti)
210 {
211 return m_owner->DoIsUlRbgAvailableForUe (i,rnti);
212 }
213
214 template <class C>
215 void
ReportDlCqiInfo(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters & params)216 MemberLteFfrSapProvider<C>::ReportDlCqiInfo (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params)
217 {
218 m_owner->DoReportDlCqiInfo (params);
219 }
220
221 template <class C>
222 void
ReportUlCqiInfo(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters & params)223 MemberLteFfrSapProvider<C>::ReportUlCqiInfo (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params)
224 {
225 m_owner->DoReportUlCqiInfo (params);
226 }
227
228 template <class C>
229 void
ReportUlCqiInfo(std::map<uint16_t,std::vector<double>> ulCqiMap)230 MemberLteFfrSapProvider<C>::ReportUlCqiInfo ( std::map <uint16_t, std::vector <double> > ulCqiMap )
231 {
232 m_owner->DoReportUlCqiInfo (ulCqiMap);
233 }
234
235 template <class C>
236 uint8_t
GetTpc(uint16_t rnti)237 MemberLteFfrSapProvider<C>::GetTpc ( uint16_t rnti )
238 {
239 return m_owner->DoGetTpc (rnti);
240 }
241
242 template <class C>
243 uint16_t
GetMinContinuousUlBandwidth()244 MemberLteFfrSapProvider<C>::GetMinContinuousUlBandwidth ()
245 {
246 return m_owner->DoGetMinContinuousUlBandwidth ();
247 }
248
249 /**
250 * \brief Template for the implementation of the LteFfrSapUser
251 * as a member of an owner class of type C to which all methods are
252 * forwarded.
253 */
254 template <class C>
255 class MemberLteFfrSapUser : public LteFfrSapUser
256 {
257 public:
258 /**
259 * Constructor
260 *
261 * \param owner the owner class
262 */
263 MemberLteFfrSapUser (C* owner);
264
265 // inherited from LteFfrSapUser
266 private:
267 MemberLteFfrSapUser ();
268 C* m_owner; ///< the owner class
269
270 }; // end of class LteFfrSapUser
271
272 template <class C>
MemberLteFfrSapUser(C * owner)273 MemberLteFfrSapUser<C>::MemberLteFfrSapUser (C* owner)
274 : m_owner (owner)
275 {
276 }
277
278 } // end of namespace ns3
279
280
281 #endif /* LTE_FFR_SAP_H */
282