mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
The buffer pool is a quantity of memory available for buffering a group of flows (e.g. frames having the same priority, frames received from the same port), while waiting to be transmitted on a port. The buffer pool tracks internal memory consumption with upper bound limits and optionally a non-shared portion when associated with a shared buffer pool. Currently the shared buffer pool is not supported, it will be added in the future. For i.MX94, the switch has 4 ports and 8 buffer pools, so each port is allocated two buffer pools. For frames with priorities of 0 to 3, they will be mapped to the first buffer pool; For frames with priorities of 4 to 7, they will be mapped to the second buffer pool. Each buffer pool has a flow control on threshold and a flow control off threshold. By setting these threshold, add the flow control support to each port. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260518082506.1318236-14-wei.fang@nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
88 lines
2.0 KiB
C
88 lines
2.0 KiB
C
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
|
|
/*
|
|
* NXP NETC switch driver
|
|
* Copyright 2025-2026 NXP
|
|
*/
|
|
|
|
#include "netc_switch.h"
|
|
|
|
struct netc_switch_platform {
|
|
u16 revision;
|
|
const struct netc_switch_info *info;
|
|
};
|
|
|
|
static void imx94_switch_phylink_get_caps(int port,
|
|
struct phylink_config *config)
|
|
{
|
|
config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_1000FD;
|
|
|
|
switch (port) {
|
|
case 0 ... 1:
|
|
__set_bit(PHY_INTERFACE_MODE_SGMII,
|
|
config->supported_interfaces);
|
|
__set_bit(PHY_INTERFACE_MODE_2500BASEX,
|
|
config->supported_interfaces);
|
|
config->mac_capabilities |= MAC_2500FD;
|
|
fallthrough;
|
|
case 2:
|
|
config->mac_capabilities |= MAC_10 | MAC_100;
|
|
__set_bit(PHY_INTERFACE_MODE_MII,
|
|
config->supported_interfaces);
|
|
__set_bit(PHY_INTERFACE_MODE_RMII,
|
|
config->supported_interfaces);
|
|
/* Port 0 and 1 do not support REVMII */
|
|
if (port == 2)
|
|
__set_bit(PHY_INTERFACE_MODE_REVMII,
|
|
config->supported_interfaces);
|
|
|
|
phy_interface_set_rgmii(config->supported_interfaces);
|
|
break;
|
|
case 3: /* CPU port */
|
|
__set_bit(PHY_INTERFACE_MODE_INTERNAL,
|
|
config->supported_interfaces);
|
|
config->mac_capabilities |= MAC_10FD | MAC_100FD |
|
|
MAC_2500FD;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
static const struct netc_switch_info imx94_info = {
|
|
.num_ports = 4,
|
|
.phylink_get_caps = imx94_switch_phylink_get_caps,
|
|
};
|
|
|
|
static const struct netc_switch_platform netc_platforms[] = {
|
|
{ .revision = NETC_SWITCH_REV_4_3, .info = &imx94_info, },
|
|
{ }
|
|
};
|
|
|
|
static const struct netc_switch_info *
|
|
netc_switch_get_info(struct netc_switch *priv)
|
|
{
|
|
int i;
|
|
|
|
/* Matching based on IP revision */
|
|
for (i = 0; i < ARRAY_SIZE(netc_platforms); i++) {
|
|
if (priv->revision == netc_platforms[i].revision)
|
|
return netc_platforms[i].info;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
int netc_switch_platform_probe(struct netc_switch *priv)
|
|
{
|
|
const struct netc_switch_info *info = netc_switch_get_info(priv);
|
|
|
|
if (!info) {
|
|
dev_err(priv->dev, "Cannot find switch platform info\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
priv->info = info;
|
|
|
|
return 0;
|
|
}
|