From: Parvathi Pudi <parvathi@couthit.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: parvathi <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>, Prajith Jayarajan <prajith@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: [PATCH net-next 1/3] net: ti: icssm-prueth: Adds helper functions to configure and maintain FDB
Date: Fri, 26 Sep 2025 18:44:09 +0530 (IST) [thread overview]
Message-ID: <464535038.433548.1758892449616.JavaMail.zimbra@couthit.local> (raw)
In-Reply-To: <02f2c50f-31f6-4d4a-9cbe-5f77d1d60706@lunn.ch>
Hi,
>> +++ b/drivers/net/ethernet/ti/icssm/icssm_prueth_fdb_tbl.h
>> @@ -0,0 +1,66 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/* Copyright (C) 2019-2021 Texas Instruments Incorporated - https://www.ti.com
>> */
>> +#ifndef __NET_TI_PRUSS_FDB_TBL_H
>> +#define __NET_TI_PRUSS_FDB_TBL_H
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/debugfs.h>
>> +#include "icssm_prueth.h"
>> +
>> +#define ETHER_ADDR_LEN 6
>
> Please use ETH_ALEN everywhere.
>
Sure, we will address this in the next version.
>> +static void icssm_prueth_sw_fdb_spin_lock(struct fdb_tbl *fdb_tbl)
>> +{
>> + /* Take the host lock */
>> + writeb(1, (u8 __iomem *)&fdb_tbl->locks->host_lock);
>> +
>> + /* Wait for the PRUs to release their locks */
>> + while (readb((u8 __iomem *)&fdb_tbl->locks->pru_locks))
>> + ;
>
> Don't use endless loops. What happens if the firmware crashed. Please
> use something from iopoll.h and handle -ETIMEDOUT.
>
Sure, we will replace the while loop with “read_poll_timeout()” API from
iopoll.h and handle the return value appropriately in the next version.
>> +static void icssm_mac_copy(u8 *dst, const u8 *src)
>> +{
>> + u8 i;
>> +
>> + for (i = 0; i < ETHER_ADDR_LEN; i++) {
>> + *(dst) = *(src);
>> + dst++;
>> + src++;
>> + }
>> +}
>
> There is a kernel helper for this.
>
We will use the “ether_addr_copy()” API where ever it is applicable.
>> +
>> +static s8 icssm_mac_cmp(const u8 *mac_a, const u8 *mac_b)
>> +{
>> + s8 ret = 0, i;
>> +
>> + for (i = 0; i < ETHER_ADDR_LEN; i++) {
>> + if (mac_a[i] == mac_b[i])
>> + continue;
>> +
>> + ret = mac_a[i] < mac_b[i] ? -1 : 1;
>> + break;
>> + }
>> +
>> + return ret;
>> +}
>
> I suspect there is also a helper for this. Please don't reinvent what
> the kernel already has.
>
Sure, we will check and address this as well.
>> +static s16
>> +icssm_prueth_sw_fdb_find_bucket_insert_point(struct fdb_tbl *fdb,
>> + struct fdb_index_tbl_entry_t
>> + *bkt_info,
>> + const u8 *mac, const u8 port)
>> +{
>> + struct fdb_mac_tbl_array_t *mac_tbl = fdb->mac_tbl_a;
>> + struct fdb_mac_tbl_entry_t *e;
>> + u8 mac_tbl_idx;
>> + s8 cmp;
>> + int i;
>> +
>> + mac_tbl_idx = bkt_info->bucket_idx;
>> +
>> + for (i = 0; i < bkt_info->bucket_entries; i++, mac_tbl_idx++) {
>> + e = &mac_tbl->mac_tbl_entry[mac_tbl_idx];
>> + cmp = icssm_mac_cmp(mac, e->mac);
>> + if (cmp < 0) {
>> + return mac_tbl_idx;
>> + } else if (cmp == 0) {
>> + if (e->port != port) {
>> + /* MAC is already in FDB, only port is
>> + * different. So just update the port.
>> + * Note: total_entries and bucket_entries
>> + * remain the same.
>> + */
>> + icssm_prueth_sw_fdb_spin_lock(fdb);
>> + e->port = port;
>> + icssm_prueth_sw_fdb_spin_unlock(fdb);
>> + }
>> +
>> + /* MAC and port are the same, touch the fdb */
>> + e->age = 0;
>> + return -1;
>
> Returning values like this can result in bugs. It is better to use a
> real error code, just in case this ever makes it way back to
> userspace.
>
> Andrew
Sure, we will check and address this in the next version.
Thanks and Regards,
Parvathi.
next prev parent reply other threads:[~2025-09-26 13:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-25 14:02 [PATCH net-next 0/3] RSTP SWITCH support for PRU-ICSSM Ethernet driver Parvathi Pudi
2025-09-25 14:02 ` [PATCH net-next 1/3] net: ti: icssm-prueth: Adds helper functions to configure and maintain FDB Parvathi Pudi
2025-09-25 14:33 ` Andrew Lunn
2025-09-26 13:14 ` Parvathi Pudi [this message]
2025-09-25 14:02 ` [PATCH net-next 2/3] net: ti: icssm-prueth: Adds switchdev support for icssm_prueth driver Parvathi Pudi
2025-09-25 14:02 ` [PATCH net-next 3/3] net: ti: icssm-prueth: Adds support for ICSSM RSTP switch Parvathi Pudi
2025-09-25 14:19 ` [PATCH net-next 0/3] RSTP SWITCH support for PRU-ICSSM Ethernet driver Andrew Lunn
2025-09-26 13:09 ` Parvathi Pudi
2025-09-26 13:13 ` Andrew Lunn
2025-09-29 6:14 ` 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=464535038.433548.1758892449616.JavaMail.zimbra@couthit.local \
--to=parvathi@couthit.com \
--cc=afd@ti.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=basharath@couthit.com \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.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=prajith@ti.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