Skip to content

Commit 76cf404

Browse files
committed
Merge branch 'ipa-mem-2'
Alex Elder says: ==================== net: ipa: memory region rework, part 2 This is the second portion of a set of patches updating the IPA memory region code. In this portion (part 2), the focus is on adjusting the code so that it no longer assumes the memory region descriptor array is indexed by the region identifier. This brings with it some related cleanup. Three loops are changed so their loop index variable is an unsigned rather than an enumerated type. A set of functions is changed so a region identifier (rather than a memory region descriptor pointer) is passed as argument, to simplify their call sites. This isn't entirely related or required, but I think it improves the code. A validation function for filter and route table memory regions is changed to take memory region IDs, rather than determining which region to validate based on a set of Boolean flags. Finally, ipa_mem_find() is created to abstract getting a memory descriptor based on its ID, and it is used everywhere rather than indexing the array. With that implemented, all of the memory regions can be defined by arrays of entries defined without providing index designators. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 53f8b1b + c61cfb9 commit 76cf404

File tree

11 files changed

+242
-240
lines changed

11 files changed

+242
-240
lines changed

drivers/net/ipa/ipa_cmd.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,41 +200,55 @@ bool ipa_cmd_table_valid(struct ipa *ipa, const struct ipa_mem *mem,
200200
/* Validate the memory region that holds headers */
201201
static bool ipa_cmd_header_valid(struct ipa *ipa)
202202
{
203-
const struct ipa_mem *mem = &ipa->mem[IPA_MEM_MODEM_HEADER];
204203
struct device *dev = &ipa->pdev->dev;
204+
const struct ipa_mem *mem;
205205
u32 offset_max;
206206
u32 size_max;
207+
u32 offset;
207208
u32 size;
208209

209-
/* In ipa_cmd_hdr_init_local_add() we record the offset and size
210-
* of the header table memory area. Make sure the offset and size
211-
* fit in the fields that need to hold them, and that the entire
212-
* range is within the overall IPA memory range.
210+
/* In ipa_cmd_hdr_init_local_add() we record the offset and size of
211+
* the header table memory area in an immediate command. Make sure
212+
* the offset and size fit in the fields that need to hold them, and
213+
* that the entire range is within the overall IPA memory range.
213214
*/
214215
offset_max = field_max(HDR_INIT_LOCAL_FLAGS_HDR_ADDR_FMASK);
215-
if (mem->offset > offset_max ||
216-
ipa->mem_offset > offset_max - mem->offset) {
216+
size_max = field_max(HDR_INIT_LOCAL_FLAGS_TABLE_SIZE_FMASK);
217+
218+
/* The header memory area contains both the modem and AP header
219+
* regions. The modem portion defines the address of the region.
220+
*/
221+
mem = ipa_mem_find(ipa, IPA_MEM_MODEM_HEADER);
222+
offset = mem->offset;
223+
size = mem->size;
224+
225+
/* Make sure the offset fits in the IPA command */
226+
if (offset > offset_max || ipa->mem_offset > offset_max - offset) {
217227
dev_err(dev, "header table region offset too large\n");
218228
dev_err(dev, " (0x%04x + 0x%04x > 0x%04x)\n",
219-
ipa->mem_offset, mem->offset, offset_max);
229+
ipa->mem_offset, offset, offset_max);
220230

221231
return false;
222232
}
223233

224-
size_max = field_max(HDR_INIT_LOCAL_FLAGS_TABLE_SIZE_FMASK);
225-
size = ipa->mem[IPA_MEM_MODEM_HEADER].size;
226-
size += ipa->mem[IPA_MEM_AP_HEADER].size;
234+
/* Add the size of the AP portion (if defined) to the combined size */
235+
mem = ipa_mem_find(ipa, IPA_MEM_AP_HEADER);
236+
if (mem)
237+
size += mem->size;
227238

239+
/* Make sure the combined size fits in the IPA command */
228240
if (size > size_max) {
229241
dev_err(dev, "header table region size too large\n");
230242
dev_err(dev, " (0x%04x > 0x%08x)\n", size, size_max);
231243

232244
return false;
233245
}
234-
if (size > ipa->mem_size || mem->offset > ipa->mem_size - size) {
246+
247+
/* Make sure the entire combined area fits in IPA memory */
248+
if (size > ipa->mem_size || offset > ipa->mem_size - size) {
235249
dev_err(dev, "header table region out of range\n");
236250
dev_err(dev, " (0x%04x + 0x%04x > 0x%04x)\n",
237-
mem->offset, size, ipa->mem_size);
251+
offset, size, ipa->mem_size);
238252

239253
return false;
240254
}

drivers/net/ipa/ipa_data-v3.5.1.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -271,91 +271,91 @@ static const struct ipa_resource_data ipa_resource_data = {
271271

272272
/* IPA-resident memory region data for an SoC having IPA v3.5.1 */
273273
static const struct ipa_mem ipa_mem_local_data[] = {
274-
[IPA_MEM_UC_SHARED] = {
274+
{
275275
.id = IPA_MEM_UC_SHARED,
276276
.offset = 0x0000,
277277
.size = 0x0080,
278278
.canary_count = 0,
279279
},
280-
[IPA_MEM_UC_INFO] = {
280+
{
281281
.id = IPA_MEM_UC_INFO,
282282
.offset = 0x0080,
283283
.size = 0x0200,
284284
.canary_count = 0,
285285
},
286-
[IPA_MEM_V4_FILTER_HASHED] = {
286+
{
287287
.id = IPA_MEM_V4_FILTER_HASHED,
288288
.offset = 0x0288,
289289
.size = 0x0078,
290290
.canary_count = 2,
291291
},
292-
[IPA_MEM_V4_FILTER] = {
292+
{
293293
.id = IPA_MEM_V4_FILTER,
294294
.offset = 0x0308,
295295
.size = 0x0078,
296296
.canary_count = 2,
297297
},
298-
[IPA_MEM_V6_FILTER_HASHED] = {
298+
{
299299
.id = IPA_MEM_V6_FILTER_HASHED,
300300
.offset = 0x0388,
301301
.size = 0x0078,
302302
.canary_count = 2,
303303
},
304-
[IPA_MEM_V6_FILTER] = {
304+
{
305305
.id = IPA_MEM_V6_FILTER,
306306
.offset = 0x0408,
307307
.size = 0x0078,
308308
.canary_count = 2,
309309
},
310-
[IPA_MEM_V4_ROUTE_HASHED] = {
310+
{
311311
.id = IPA_MEM_V4_ROUTE_HASHED,
312312
.offset = 0x0488,
313313
.size = 0x0078,
314314
.canary_count = 2,
315315
},
316-
[IPA_MEM_V4_ROUTE] = {
316+
{
317317
.id = IPA_MEM_V4_ROUTE,
318318
.offset = 0x0508,
319319
.size = 0x0078,
320320
.canary_count = 2,
321321
},
322-
[IPA_MEM_V6_ROUTE_HASHED] = {
322+
{
323323
.id = IPA_MEM_V6_ROUTE_HASHED,
324324
.offset = 0x0588,
325325
.size = 0x0078,
326326
.canary_count = 2,
327327
},
328-
[IPA_MEM_V6_ROUTE] = {
328+
{
329329
.id = IPA_MEM_V6_ROUTE,
330330
.offset = 0x0608,
331331
.size = 0x0078,
332332
.canary_count = 2,
333333
},
334-
[IPA_MEM_MODEM_HEADER] = {
334+
{
335335
.id = IPA_MEM_MODEM_HEADER,
336336
.offset = 0x0688,
337337
.size = 0x0140,
338338
.canary_count = 2,
339339
},
340-
[IPA_MEM_MODEM_PROC_CTX] = {
340+
{
341341
.id = IPA_MEM_MODEM_PROC_CTX,
342342
.offset = 0x07d0,
343343
.size = 0x0200,
344344
.canary_count = 2,
345345
},
346-
[IPA_MEM_AP_PROC_CTX] = {
346+
{
347347
.id = IPA_MEM_AP_PROC_CTX,
348348
.offset = 0x09d0,
349349
.size = 0x0200,
350350
.canary_count = 0,
351351
},
352-
[IPA_MEM_MODEM] = {
352+
{
353353
.id = IPA_MEM_MODEM,
354354
.offset = 0x0bd8,
355355
.size = 0x1024,
356356
.canary_count = 0,
357357
},
358-
[IPA_MEM_UC_EVENT_RING] = {
358+
{
359359
.id = IPA_MEM_UC_EVENT_RING,
360360
.offset = 0x1c00,
361361
.size = 0x0400,

drivers/net/ipa/ipa_data-v4.11.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -220,133 +220,133 @@ static const struct ipa_resource_data ipa_resource_data = {
220220

221221
/* IPA-resident memory region data for an SoC having IPA v4.11 */
222222
static const struct ipa_mem ipa_mem_local_data[] = {
223-
[IPA_MEM_UC_SHARED] = {
223+
{
224224
.id = IPA_MEM_UC_SHARED,
225225
.offset = 0x0000,
226226
.size = 0x0080,
227227
.canary_count = 0,
228228
},
229-
[IPA_MEM_UC_INFO] = {
229+
{
230230
.id = IPA_MEM_UC_INFO,
231231
.offset = 0x0080,
232232
.size = 0x0200,
233233
.canary_count = 0,
234234
},
235-
[IPA_MEM_V4_FILTER_HASHED] = {
235+
{
236236
.id = IPA_MEM_V4_FILTER_HASHED,
237237
.offset = 0x0288,
238238
.size = 0x0078,
239239
.canary_count = 2,
240240
},
241-
[IPA_MEM_V4_FILTER] = {
241+
{
242242
.id = IPA_MEM_V4_FILTER,
243243
.offset = 0x0308,
244244
.size = 0x0078,
245245
.canary_count = 2,
246246
},
247-
[IPA_MEM_V6_FILTER_HASHED] = {
247+
{
248248
.id = IPA_MEM_V6_FILTER_HASHED,
249249
.offset = 0x0388,
250250
.size = 0x0078,
251251
.canary_count = 2,
252252
},
253-
[IPA_MEM_V6_FILTER] = {
253+
{
254254
.id = IPA_MEM_V6_FILTER,
255255
.offset = 0x0408,
256256
.size = 0x0078,
257257
.canary_count = 2,
258258
},
259-
[IPA_MEM_V4_ROUTE_HASHED] = {
259+
{
260260
.id = IPA_MEM_V4_ROUTE_HASHED,
261261
.offset = 0x0488,
262262
.size = 0x0078,
263263
.canary_count = 2,
264264
},
265-
[IPA_MEM_V4_ROUTE] = {
265+
{
266266
.id = IPA_MEM_V4_ROUTE,
267267
.offset = 0x0508,
268268
.size = 0x0078,
269269
.canary_count = 2,
270270
},
271-
[IPA_MEM_V6_ROUTE_HASHED] = {
271+
{
272272
.id = IPA_MEM_V6_ROUTE_HASHED,
273273
.offset = 0x0588,
274274
.size = 0x0078,
275275
.canary_count = 2,
276276
},
277-
[IPA_MEM_V6_ROUTE] = {
277+
{
278278
.id = IPA_MEM_V6_ROUTE,
279279
.offset = 0x0608,
280280
.size = 0x0078,
281281
.canary_count = 2,
282282
},
283-
[IPA_MEM_MODEM_HEADER] = {
283+
{
284284
.id = IPA_MEM_MODEM_HEADER,
285285
.offset = 0x0688,
286286
.size = 0x0240,
287287
.canary_count = 2,
288288
},
289-
[IPA_MEM_AP_HEADER] = {
289+
{
290290
.id = IPA_MEM_AP_HEADER,
291291
.offset = 0x08c8,
292292
.size = 0x0200,
293293
.canary_count = 0,
294294
},
295-
[IPA_MEM_MODEM_PROC_CTX] = {
295+
{
296296
.id = IPA_MEM_MODEM_PROC_CTX,
297297
.offset = 0x0ad0,
298298
.size = 0x0200,
299299
.canary_count = 2,
300300
},
301-
[IPA_MEM_AP_PROC_CTX] = {
301+
{
302302
.id = IPA_MEM_AP_PROC_CTX,
303303
.offset = 0x0cd0,
304304
.size = 0x0200,
305305
.canary_count = 0,
306306
},
307-
[IPA_MEM_NAT_TABLE] = {
307+
{
308308
.id = IPA_MEM_NAT_TABLE,
309309
.offset = 0x0ee0,
310310
.size = 0x0d00,
311311
.canary_count = 4,
312312
},
313-
[IPA_MEM_PDN_CONFIG] = {
313+
{
314314
.id = IPA_MEM_PDN_CONFIG,
315315
.offset = 0x1be8,
316316
.size = 0x0050,
317317
.canary_count = 0,
318318
},
319-
[IPA_MEM_STATS_QUOTA_MODEM] = {
319+
{
320320
.id = IPA_MEM_STATS_QUOTA_MODEM,
321321
.offset = 0x1c40,
322322
.size = 0x0030,
323323
.canary_count = 4,
324324
},
325-
[IPA_MEM_STATS_QUOTA_AP] = {
325+
{
326326
.id = IPA_MEM_STATS_QUOTA_AP,
327327
.offset = 0x1c70,
328328
.size = 0x0048,
329329
.canary_count = 0,
330330
},
331-
[IPA_MEM_STATS_TETHERING] = {
331+
{
332332
.id = IPA_MEM_STATS_TETHERING,
333333
.offset = 0x1cb8,
334334
.size = 0x0238,
335335
.canary_count = 0,
336336
},
337-
[IPA_MEM_STATS_DROP] = {
337+
{
338338
.id = IPA_MEM_STATS_DROP,
339339
.offset = 0x1ef0,
340340
.size = 0x0020,
341341
.canary_count = 0,
342342
},
343-
[IPA_MEM_MODEM] = {
343+
{
344344
.id = IPA_MEM_MODEM,
345345
.offset = 0x1f18,
346346
.size = 0x100c,
347347
.canary_count = 2,
348348
},
349-
[IPA_MEM_END_MARKER] = {
349+
{
350350
.id = IPA_MEM_END_MARKER,
351351
.offset = 0x3000,
352352
.size = 0x0000,

0 commit comments

Comments
 (0)