Lines Matching defs:gcl

38 static void tsnep_write_gcl_operation(struct tsnep_gcl *gcl, int index,
41 void __iomem *addr = gcl->addr +
44 gcl->operation[index].properties = properties;
45 gcl->operation[index].interval = interval;
56 static u64 tsnep_change_duration(struct tsnep_gcl *gcl, int index)
75 duration += gcl->operation[index].interval;
79 index = gcl->count - 1;
87 static void tsnep_write_gcl(struct tsnep_gcl *gcl,
95 gcl->base_time = ktime_to_ns(qopt->base_time);
96 gcl->cycle_time = qopt->cycle_time;
97 gcl->cycle_time_extension = qopt->cycle_time_extension;
104 tsnep_write_gcl_operation(gcl, i, properties,
107 gcl->count = qopt->num_entries;
117 extend = tsnep_change_duration(gcl, gcl->count - 1);
118 extend += gcl->cycle_time_extension;
124 for (i = 0; i < gcl->count; i++)
125 cut = max(cut, tsnep_change_duration(gcl, i));
130 gcl->change_limit = max(extend, cut);
133 static u64 tsnep_gcl_start_after(struct tsnep_gcl *gcl, u64 limit)
135 u64 start = gcl->base_time;
139 n = div64_u64(limit - start, gcl->cycle_time);
140 start += (n + 1) * gcl->cycle_time;
146 static u64 tsnep_gcl_start_before(struct tsnep_gcl *gcl, u64 limit)
148 u64 start = gcl->base_time;
151 n = div64_u64(limit - start, gcl->cycle_time);
152 start += n * gcl->cycle_time;
154 start -= gcl->cycle_time;
159 static u64 tsnep_set_gcl_change(struct tsnep_gcl *gcl, int index, u64 change,
166 index = gcl->count - 1;
169 change -= gcl->operation[index].interval;
173 void __iomem *addr = gcl->addr +
176 gcl->operation[index].properties |= TSNEP_GCL_INSERT;
177 iowrite32(gcl->operation[index].properties, addr);
183 static void tsnep_clean_gcl(struct tsnep_gcl *gcl)
190 for (i = 0; i < gcl->count; i++) {
191 if (gcl->operation[i].properties & ~mask) {
192 addr = gcl->addr +
195 gcl->operation[i].properties &= mask;
196 iowrite32(gcl->operation[i].properties, addr);
203 static u64 tsnep_insert_gcl_operation(struct tsnep_gcl *gcl, int ref,
208 properties = gcl->operation[ref].properties & TSNEP_GCL_MASK;
213 tsnep_write_gcl_operation(gcl, TSNEP_GCL_COUNT - 1, properties,
216 return tsnep_set_gcl_change(gcl, ref, change, true);
219 static u64 tsnep_extend_gcl(struct tsnep_gcl *gcl, u64 start, u32 extension)
221 int ref = gcl->count - 1;
222 u32 interval = gcl->operation[ref].interval + extension;
224 start -= gcl->operation[ref].interval;
226 return tsnep_insert_gcl_operation(gcl, ref, start, interval);
229 static u64 tsnep_cut_gcl(struct tsnep_gcl *gcl, u64 start, u64 cycle_time)
235 for (i = 0; i < gcl->count; i++) {
236 u64 sum_tmp = sum + gcl->operation[i].interval;
254 return tsnep_set_gcl_change(gcl, i, start + sum, false);
256 return tsnep_insert_gcl_operation(gcl, i, start + sum,
261 struct tsnep_gcl *gcl, struct tsnep_gcl *curr)
278 gcl->start_time = tsnep_gcl_start_after(gcl, limit);
283 if ((gcl->start_time - system_time) >= U32_MAX)
291 last = tsnep_gcl_start_before(curr, gcl->start_time);
292 if ((last + curr->cycle_time) == gcl->start_time)
294 gcl->start_time - last);
295 else if (((gcl->start_time - last) <=
297 ((gcl->start_time - last) <= TSNEP_GCL_MIN_INTERVAL))
299 gcl->start_time - last);
302 gcl->start_time - last);
305 gcl->change = true;
309 WARN_ON(gcl->start_time <= timeout);
310 gcl->change = false;
311 iowrite32(gcl->start_time & 0xFFFFFFFF,
321 struct tsnep_gcl *gcl;
350 gcl = &adapter->gcl[adapter->next_gcl];
351 tsnep_write_gcl(gcl, qopt);
356 curr = &adapter->gcl[1];
358 curr = &adapter->gcl[0];
369 retval = tsnep_enable_gcl(adapter, gcl, curr);
451 adapter->gcl[0].addr = adapter->addr + TSNEP_GCL_A;
452 adapter->gcl[1].addr = adapter->addr + TSNEP_GCL_B;