summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Fang <wei.fang@nxp.com>2026-05-18 11:24:59 +0300
committerPaolo Abeni <pabeni@redhat.com>2026-05-21 14:04:42 +0300
commitc5aed83ddc5328b55eabeee7568bbcf40985d5ed (patch)
treea06b1b32c82edf0126a257cf8cdd5e5cb378c64e
parent123db6a2751144f3e86cb029ebac4ef4777a5507 (diff)
downloadlinux-c5aed83ddc5328b55eabeee7568bbcf40985d5ed.tar.xz
net: enetc: add multiple command BD rings support
All the tables of NETC switch are managed through the command BD ring, but unlike ENETC, the switch has two command BD rings, if the current ring is busy, the switch driver can switch to another ring to manage the table. Currently, the NTMP driver does not support multiple rings. Therefore, update ntmp_select_and_lock_cbdr() to select a appropriate ring to execute the command for the switch. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260518082506.1318236-9-wei.fang@nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--drivers/net/ethernet/freescale/enetc/ntmp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/ethernet/freescale/enetc/ntmp.c b/drivers/net/ethernet/freescale/enetc/ntmp.c
index 635032d24dc7..f71cad943424 100644
--- a/drivers/net/ethernet/freescale/enetc/ntmp.c
+++ b/drivers/net/ethernet/freescale/enetc/ntmp.c
@@ -146,11 +146,16 @@ static void ntmp_clean_cbdr(struct netc_cbdr *cbdr)
static void ntmp_select_and_lock_cbdr(struct ntmp_user *user,
struct netc_cbdr **cbdr)
{
- /* Currently only ENETC is supported, and it has only one command
- * BD ring.
- */
- *cbdr = &user->ring[0];
+ for (int i = 0; i < user->cbdr_num; i++) {
+ *cbdr = &user->ring[i];
+ if (mutex_trylock(&(*cbdr)->ring_lock))
+ return;
+ }
+ /* If all command BD rings are locked, we need to select one of
+ * them and wait for it.
+ */
+ *cbdr = &user->ring[raw_smp_processor_id() % user->cbdr_num];
mutex_lock(&(*cbdr)->ring_lock);
}