From: Parvathi Pudi <parvathi@couthit.com>
To: ALOK TIWARI <alok.a.tiwari@oracle.com>
Cc: Parvathi Pudi <parvathi@couthit.com>,
andrew+netdev <andrew+netdev@lunn.ch>,
davem <davem@davemloft.net>, edumazet <edumazet@google.com>,
kuba <kuba@kernel.org>, pabeni <pabeni@redhat.com>,
danishanwar <danishanwar@ti.com>, rogerq <rogerq@kernel.org>,
pmohan <pmohan@couthit.com>, basharath <basharath@couthit.com>,
afd <afd@ti.com>, linux-kernel <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
pratheesh <pratheesh@ti.com>, j-rameshbabu <j-rameshbabu@ti.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
praneeth <praneeth@ti.com>, srk <srk@ti.com>,
rogerq <rogerq@ti.com>, krishna <krishna@couthit.com>,
mohan <mohan@couthit.com>
Subject: Re: [External] : [PATCH net-next v4 1/3] net: ti: icssm-prueth: Adds helper functions to configure and maintain FDB
Date: Wed, 12 Nov 2025 18:37:59 +0530 (IST) [thread overview]
Message-ID: <482294584.44920.1762952879480.JavaMail.zimbra@couthit.local> (raw)
In-Reply-To: <a29c40ff-7209-4b60-a17f-2aab09318dc1@oracle.com>
Hi,
>> +static int icssm_prueth_sw_insert_fdb_entry(struct prueth_emac *emac,
>> + const u8 *mac, u8 is_static)
>> +{
>> + struct fdb_index_tbl_entry __iomem *bucket_info;
>> + struct fdb_mac_tbl_entry __iomem *mac_info;
>> + struct prueth *prueth = emac->prueth;
>> + struct prueth_emac *other_emac;
>> + enum prueth_port other_port_id;
>> + u8 hash_val, mac_tbl_idx;
>> + struct fdb_tbl *fdb;
>> + u8 flags;
>> + u16 val;
>> + s16 ret;
>> + int err;
>> +
>> + fdb = prueth->fdb_tbl;
>> + other_port_id = (emac->port_id == PRUETH_PORT_MII0) ?
>> + PRUETH_PORT_MII1 : PRUETH_PORT_MII0;
>> +
>> + other_emac = prueth->emac[other_port_id - 1];
>> +
>> + if (fdb->total_entries == FDB_MAC_TBL_MAX_ENTRIES)
>> + return -ENOMEM;
>> +
>> + if (ether_addr_equal(mac, emac->mac_addr) ||
>> + ether_addr_equal(mac, other_emac->mac_addr)) {
>> + /* Don't insert fdb of own mac addr */
>> + return -EINVAL;
>> + }
>> +
>> + /* Get the bucket that the mac belongs to */
>> + hash_val = icssm_prueth_sw_fdb_hash(mac);
>> + bucket_info = FDB_IDX_TBL_ENTRY(hash_val);
>> +
>> + if (!readw(&bucket_info->bucket_entries)) {
>> + mac_tbl_idx = icssm_prueth_sw_fdb_find_open_slot(fdb);
>> + writew(mac_tbl_idx, &bucket_info->bucket_idx);
>> + }
>> +
>> + ret = icssm_prueth_sw_find_fdb_insert(fdb, prueth, bucket_info, mac,
>> + emac->port_id - 1);
>> + if (ret < 0)
>> + /* mac is already in fdb table */
>> + return 0;
>> +
>> + mac_tbl_idx = ret;
>
> If ret == -1 mac_tbl_idx wraps to 255 silently.
>
Thanks. Theoretically, assigning -1 to an unsigned variable would
result in 255 due to signed-to-unsigned conversion. However, in
this case, the above code already checks if (ret < 0) and returns early,
so the assignment to mac_tbl_idx never happens when ret is negative.
>> +
>> + err = icssm_prueth_sw_fdb_spin_lock(fdb);
>> + if (err) {
>> + dev_err(prueth->dev, "PRU lock timeout %d\n", ret);
>
> wrong var ret print.
> return ret or err here ?
>
We will address this in the next version.
Thanks and Regards,
Parvathi.
next prev parent reply other threads:[~2025-11-12 13:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 12:53 [PATCH net-next v4 0/3] STP/RSTP SWITCH support for PRU-ICSSM Ethernet driver Parvathi Pudi
2025-11-10 12:53 ` [PATCH net-next v4 1/3] net: ti: icssm-prueth: Adds helper functions to configure and maintain FDB Parvathi Pudi
2025-11-10 16:51 ` [External] : " ALOK TIWARI
2025-11-12 13:07 ` Parvathi Pudi [this message]
2025-11-10 12:53 ` [PATCH net-next v4 2/3] net: ti: icssm-prueth: Adds switchdev support for icssm_prueth driver Parvathi Pudi
2025-11-10 12:53 ` [PATCH net-next v4 3/3] net: ti: icssm-prueth: Adds support for ICSSM RSTP switch Parvathi Pudi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=482294584.44920.1762952879480.JavaMail.zimbra@couthit.local \
--to=parvathi@couthit.com \
--cc=afd@ti.com \
--cc=alok.a.tiwari@oracle.com \
--cc=andrew+netdev@lunn.ch \
--cc=basharath@couthit.com \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=j-rameshbabu@ti.com \
--cc=krishna@couthit.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mohan@couthit.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pmohan@couthit.com \
--cc=praneeth@ti.com \
--cc=pratheesh@ti.com \
--cc=rogerq@kernel.org \
--cc=rogerq@ti.com \
--cc=srk@ti.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).