@@ -288,52 +288,79 @@ static int prueth_fw_offload_buffer_setup(struct prueth_emac *emac)
288
288
int i ;
289
289
290
290
addr = lower_32_bits (prueth -> msmcram .pa );
291
- if (slice )
292
- addr += PRUETH_NUM_BUF_POOLS * PRUETH_EMAC_BUF_POOL_SIZE ;
291
+ if (slice ) {
292
+ if (prueth -> pdata .banked_ms_ram )
293
+ addr += MSMC_RAM_BANK_SIZE ;
294
+ else
295
+ addr += PRUETH_SW_TOTAL_BUF_SIZE_PER_SLICE ;
296
+ }
293
297
294
298
if (addr % SZ_64K ) {
295
299
dev_warn (prueth -> dev , "buffer pool needs to be 64KB aligned\n" );
296
300
return - EINVAL ;
297
301
}
298
302
299
303
bpool_cfg = emac -> dram .va + BUFFER_POOL_0_ADDR_OFFSET ;
300
- /* workaround for f/w bug. bpool 0 needs to be initialized */
301
- for (i = 0 ; i < PRUETH_NUM_BUF_POOLS ; i ++ ) {
304
+
305
+ /* Configure buffer pools for forwarding buffers
306
+ * - used by firmware to store packets to be forwarded to other port
307
+ * - 8 total pools per slice
308
+ */
309
+ for (i = 0 ; i < PRUETH_NUM_FWD_BUF_POOLS_PER_SLICE ; i ++ ) {
302
310
writel (addr , & bpool_cfg [i ].addr );
303
- writel (PRUETH_EMAC_BUF_POOL_SIZE , & bpool_cfg [i ].len );
304
- addr += PRUETH_EMAC_BUF_POOL_SIZE ;
311
+ writel (PRUETH_SW_FWD_BUF_POOL_SIZE , & bpool_cfg [i ].len );
312
+ addr += PRUETH_SW_FWD_BUF_POOL_SIZE ;
305
313
}
306
314
307
- if (!slice )
308
- addr += PRUETH_NUM_BUF_POOLS * PRUETH_EMAC_BUF_POOL_SIZE ;
309
- else
310
- addr += PRUETH_SW_NUM_BUF_POOLS_HOST * PRUETH_SW_BUF_POOL_SIZE_HOST ;
311
-
312
- for (i = PRUETH_NUM_BUF_POOLS ;
313
- i < 2 * PRUETH_SW_NUM_BUF_POOLS_HOST + PRUETH_NUM_BUF_POOLS ;
314
- i ++ ) {
315
- /* The driver only uses first 4 queues per PRU so only initialize them */
316
- if (i % PRUETH_SW_NUM_BUF_POOLS_HOST < PRUETH_SW_NUM_BUF_POOLS_PER_PRU ) {
317
- writel (addr , & bpool_cfg [i ].addr );
318
- writel (PRUETH_SW_BUF_POOL_SIZE_HOST , & bpool_cfg [i ].len );
319
- addr += PRUETH_SW_BUF_POOL_SIZE_HOST ;
315
+ /* Configure buffer pools for Local Injection buffers
316
+ * - used by firmware to store packets received from host core
317
+ * - 16 total pools per slice
318
+ */
319
+ for (i = 0 ; i < PRUETH_NUM_LI_BUF_POOLS_PER_SLICE ; i ++ ) {
320
+ int cfg_idx = i + PRUETH_NUM_FWD_BUF_POOLS_PER_SLICE ;
321
+
322
+ /* The driver only uses first 4 queues per PRU,
323
+ * so only initialize buffer for them
324
+ */
325
+ if ((i % PRUETH_NUM_LI_BUF_POOLS_PER_PORT_PER_SLICE )
326
+ < PRUETH_SW_USED_LI_BUF_POOLS_PER_PORT_PER_SLICE ) {
327
+ writel (addr , & bpool_cfg [cfg_idx ].addr );
328
+ writel (PRUETH_SW_LI_BUF_POOL_SIZE ,
329
+ & bpool_cfg [cfg_idx ].len );
330
+ addr += PRUETH_SW_LI_BUF_POOL_SIZE ;
320
331
} else {
321
- writel (0 , & bpool_cfg [i ].addr );
322
- writel (0 , & bpool_cfg [i ].len );
332
+ writel (0 , & bpool_cfg [cfg_idx ].addr );
333
+ writel (0 , & bpool_cfg [cfg_idx ].len );
323
334
}
324
335
}
325
336
326
- if (!slice )
327
- addr += PRUETH_SW_NUM_BUF_POOLS_HOST * PRUETH_SW_BUF_POOL_SIZE_HOST ;
328
- else
329
- addr += PRUETH_EMAC_RX_CTX_BUF_SIZE ;
337
+ /* Express RX buffer queue
338
+ * - used by firmware to store express packets to be transmitted
339
+ * to the host core
340
+ */
341
+ rxq_ctx = emac -> dram .va + HOST_RX_Q_EXP_CONTEXT_OFFSET ;
342
+ for (i = 0 ; i < 3 ; i ++ )
343
+ writel (addr , & rxq_ctx -> start [i ]);
344
+
345
+ addr += PRUETH_SW_HOST_EXP_BUF_POOL_SIZE ;
346
+ writel (addr , & rxq_ctx -> end );
330
347
348
+ /* Pre-emptible RX buffer queue
349
+ * - used by firmware to store preemptible packets to be transmitted
350
+ * to the host core
351
+ */
331
352
rxq_ctx = emac -> dram .va + HOST_RX_Q_PRE_CONTEXT_OFFSET ;
332
353
for (i = 0 ; i < 3 ; i ++ )
333
354
writel (addr , & rxq_ctx -> start [i ]);
334
355
335
- addr += PRUETH_EMAC_RX_CTX_BUF_SIZE ;
336
- writel (addr - SZ_2K , & rxq_ctx -> end );
356
+ addr += PRUETH_SW_HOST_PRE_BUF_POOL_SIZE ;
357
+ writel (addr , & rxq_ctx -> end );
358
+
359
+ /* Set pointer for default dropped packet write
360
+ * - used by firmware to temporarily store packet to be dropped
361
+ */
362
+ rxq_ctx = emac -> dram .va + DEFAULT_MSMC_Q_OFFSET ;
363
+ writel (addr , & rxq_ctx -> start [0 ]);
337
364
338
365
return 0 ;
339
366
}
@@ -347,53 +374,80 @@ static int prueth_emac_buffer_setup(struct prueth_emac *emac)
347
374
u32 addr ;
348
375
int i ;
349
376
350
- /* Layout to have 64KB aligned buffer pool
351
- * |BPOOL0|BPOOL1|RX_CTX0|RX_CTX1|
352
- */
353
-
354
377
addr = lower_32_bits (prueth -> msmcram .pa );
355
- if (slice )
356
- addr += PRUETH_NUM_BUF_POOLS * PRUETH_EMAC_BUF_POOL_SIZE ;
378
+ if (slice ) {
379
+ if (prueth -> pdata .banked_ms_ram )
380
+ addr += MSMC_RAM_BANK_SIZE ;
381
+ else
382
+ addr += PRUETH_EMAC_TOTAL_BUF_SIZE_PER_SLICE ;
383
+ }
357
384
358
385
if (addr % SZ_64K ) {
359
386
dev_warn (prueth -> dev , "buffer pool needs to be 64KB aligned\n" );
360
387
return - EINVAL ;
361
388
}
362
389
363
390
bpool_cfg = emac -> dram .va + BUFFER_POOL_0_ADDR_OFFSET ;
364
- /* workaround for f/w bug. bpool 0 needs to be initilalized */
365
- writel (addr , & bpool_cfg [0 ].addr );
366
- writel (0 , & bpool_cfg [0 ].len );
367
391
368
- for (i = PRUETH_EMAC_BUF_POOL_START ;
369
- i < PRUETH_EMAC_BUF_POOL_START + PRUETH_NUM_BUF_POOLS ;
370
- i ++ ) {
371
- writel (addr , & bpool_cfg [i ].addr );
372
- writel (PRUETH_EMAC_BUF_POOL_SIZE , & bpool_cfg [i ].len );
373
- addr += PRUETH_EMAC_BUF_POOL_SIZE ;
392
+ /* Configure buffer pools for forwarding buffers
393
+ * - in mac mode - no forwarding so initialize all pools to 0
394
+ * - 8 total pools per slice
395
+ */
396
+ for (i = 0 ; i < PRUETH_NUM_FWD_BUF_POOLS_PER_SLICE ; i ++ ) {
397
+ writel (0 , & bpool_cfg [i ].addr );
398
+ writel (0 , & bpool_cfg [i ].len );
374
399
}
375
400
376
- if (!slice )
377
- addr += PRUETH_NUM_BUF_POOLS * PRUETH_EMAC_BUF_POOL_SIZE ;
378
- else
379
- addr += PRUETH_EMAC_RX_CTX_BUF_SIZE * 2 ;
401
+ /* Configure buffer pools for Local Injection buffers
402
+ * - used by firmware to store packets received from host core
403
+ * - 16 total pools per slice
404
+ */
405
+ bpool_cfg = emac -> dram .va + BUFFER_POOL_0_ADDR_OFFSET ;
406
+ for (i = 0 ; i < PRUETH_NUM_LI_BUF_POOLS_PER_SLICE ; i ++ ) {
407
+ int cfg_idx = i + PRUETH_NUM_FWD_BUF_POOLS_PER_SLICE ;
408
+
409
+ /* In EMAC mode, only first 4 buffers are used,
410
+ * as 1 slice needs to handle only 1 port
411
+ */
412
+ if (i < PRUETH_EMAC_USED_LI_BUF_POOLS_PER_PORT_PER_SLICE ) {
413
+ writel (addr , & bpool_cfg [cfg_idx ].addr );
414
+ writel (PRUETH_EMAC_LI_BUF_POOL_SIZE ,
415
+ & bpool_cfg [cfg_idx ].len );
416
+ addr += PRUETH_EMAC_LI_BUF_POOL_SIZE ;
417
+ } else {
418
+ writel (0 , & bpool_cfg [cfg_idx ].addr );
419
+ writel (0 , & bpool_cfg [cfg_idx ].len );
420
+ }
421
+ }
380
422
381
- /* Pre-emptible RX buffer queue */
382
- rxq_ctx = emac -> dram .va + HOST_RX_Q_PRE_CONTEXT_OFFSET ;
423
+ /* Express RX buffer queue
424
+ * - used by firmware to store express packets to be transmitted
425
+ * to host core
426
+ */
427
+ rxq_ctx = emac -> dram .va + HOST_RX_Q_EXP_CONTEXT_OFFSET ;
383
428
for (i = 0 ; i < 3 ; i ++ )
384
429
writel (addr , & rxq_ctx -> start [i ]);
385
430
386
- addr += PRUETH_EMAC_RX_CTX_BUF_SIZE ;
431
+ addr += PRUETH_EMAC_HOST_EXP_BUF_POOL_SIZE ;
387
432
writel (addr , & rxq_ctx -> end );
388
433
389
- /* Express RX buffer queue */
390
- rxq_ctx = emac -> dram .va + HOST_RX_Q_EXP_CONTEXT_OFFSET ;
434
+ /* Pre-emptible RX buffer queue
435
+ * - used by firmware to store preemptible packets to be transmitted
436
+ * to host core
437
+ */
438
+ rxq_ctx = emac -> dram .va + HOST_RX_Q_PRE_CONTEXT_OFFSET ;
391
439
for (i = 0 ; i < 3 ; i ++ )
392
440
writel (addr , & rxq_ctx -> start [i ]);
393
441
394
- addr += PRUETH_EMAC_RX_CTX_BUF_SIZE ;
442
+ addr += PRUETH_EMAC_HOST_PRE_BUF_POOL_SIZE ;
395
443
writel (addr , & rxq_ctx -> end );
396
444
445
+ /* Set pointer for default dropped packet write
446
+ * - used by firmware to temporarily store packet to be dropped
447
+ */
448
+ rxq_ctx = emac -> dram .va + DEFAULT_MSMC_Q_OFFSET ;
449
+ writel (addr , & rxq_ctx -> start [0 ]);
450
+
397
451
return 0 ;
398
452
}
399
453
0 commit comments