Re: [PATCH net-next v3 1/3] net: ti: icssm-prueth: Adds helper functions to configure and maintain FDB

Parvathi Pudi
2025-11-10T11:32:25Z

Hi,

> Hi,
>
>>> +void icssm_prueth_sw_fdb_tbl_init(struct prueth *prueth)
>>> +{
>>> + struct fdb_tbl *t = prueth->fdb_tbl;
>>> +
>>> + t->index_a = (struct fdb_index_array_t *)((__force const void *)
>>> + prueth->mem[V2_1_FDB_TBL_LOC].va +
>>> + V2_1_FDB_TBL_OFFSET);
>>
>> We have
>>
>>> +#define V2_1_FDB_TBL_LOC PRUETH_MEM_SHARED_RAM
>>
>> and existing code like:
>>
>> void __iomem *sram_base = prueth->mem[PRUETH_MEM_SHARED_RAM].va;
>>
>> so it seems like
>>
>> t->index_a = sram_base + V2_1_FDB_TBL_OFFSET;
>>
>> with no needs for any casts, since sram_base is a void * so can be
>> assigned to any pointer type.
>>
>> And there are lots of cascading defines like:
>>
>> /* 4 queue descriptors for port 0 (host receive). 32 bytes */
>> #define HOST_QUEUE_DESC_OFFSET (HOST_QUEUE_SIZE_ADDR + 16)
>>
>> /* table offset for queue size:
>> * 3 ports * 4 Queues * 1 byte offset = 12 bytes
>> */
>> #define HOST_QUEUE_SIZE_ADDR (HOST_QUEUE_OFFSET_ADDR + 8)
>> /* table offset for queue:
>> * 4 Queues * 2 byte offset = 8 bytes
>> */
>> #define HOST_QUEUE_OFFSET_ADDR (HOST_QUEUE_DESCRIPTOR_OFFSET_ADDR + 8)
>> /* table offset for Host queue descriptors:
>> * 1 ports * 4 Queues * 2 byte offset = 8 bytes
>> */
>> #define HOST_QUEUE_DESCRIPTOR_OFFSET_ADDR (HOST_Q4_RX_CONTEXT_OFFSET + 8)
>>
>> allowing code like:
>>
>> sram = sram_base + HOST_QUEUE_SIZE_ADDR;
>> sram = sram_base + HOST_Q1_RX_CONTEXT_OFFSET;
>> sram = sram_base + HOST_QUEUE_OFFSET_ADDR;
>> sram = sram_base + HOST_QUEUE_DESCRIPTOR_OFFSET_ADDR;
>> sram = sram_base + HOST_QUEUE_DESC_OFFSET;
>>
>
> Sure, we will check the feasibility and come back.
>

We have updated the code to use sram_base + offset directly without any casts,
added the __iomem attribute to the structure, and modified the usage of its
members at all related places accordingly. With these modifications sparse is
able to check all such accesses.

We will post these changes in the next version for review.

Thanks and Regards,
Parvathi.