mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 09:41:03 +02:00
net: dsa: microchip: split ksz8_change_mtu()
Even among the ksz8 family, there are big differences in the MTU change procedure between KSZ87xx and KSZ88xx (KSZ8463 is like KSZ88xx here). Since we have 3 separate dsa_switch_ops for what constitutes "KSZ8", we can split those procedures into separate functions. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com> Link: https://patch.msgid.link/20260702-clean-ksz-4th-v1-1-93441e695fa4@bootlin.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
06f42c77a9
commit
1560432087
|
|
@ -158,10 +158,17 @@ static int ksz8_reset_switch(struct ksz_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ksz8863_change_mtu(struct ksz_device *dev, int frame_size)
|
||||
static int ksz88xx_change_mtu(struct dsa_switch *ds, int port, int mtu)
|
||||
{
|
||||
struct ksz_device *dev = ds->priv;
|
||||
int frame_size;
|
||||
u8 ctrl2 = 0;
|
||||
|
||||
if (!dsa_is_cpu_port(dev->ds, port))
|
||||
return 0;
|
||||
|
||||
frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
|
||||
|
||||
if (frame_size <= KSZ8_LEGAL_PACKET_SIZE)
|
||||
ctrl2 |= KSZ8863_LEGAL_PACKET_ENABLE;
|
||||
else if (frame_size > KSZ8863_NORMAL_PACKET_SIZE)
|
||||
|
|
@ -171,11 +178,18 @@ static int ksz8863_change_mtu(struct ksz_device *dev, int frame_size)
|
|||
KSZ8863_HUGE_PACKET_ENABLE, ctrl2);
|
||||
}
|
||||
|
||||
static int ksz8795_change_mtu(struct ksz_device *dev, int frame_size)
|
||||
static int ksz87xx_change_mtu(struct dsa_switch *ds, int port, int mtu)
|
||||
{
|
||||
struct ksz_device *dev = ds->priv;
|
||||
u8 ctrl1 = 0, ctrl2 = 0;
|
||||
u16 frame_size;
|
||||
int ret;
|
||||
|
||||
if (!dsa_is_cpu_port(dev->ds, port))
|
||||
return 0;
|
||||
|
||||
frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
|
||||
|
||||
if (frame_size > KSZ8_LEGAL_PACKET_SIZE)
|
||||
ctrl2 |= SW_LEGAL_PACKET_DISABLE;
|
||||
if (frame_size > KSZ8863_NORMAL_PACKET_SIZE)
|
||||
|
|
@ -188,31 +202,6 @@ static int ksz8795_change_mtu(struct ksz_device *dev, int frame_size)
|
|||
return ksz_rmw8(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, ctrl2);
|
||||
}
|
||||
|
||||
static int ksz8_change_mtu(struct dsa_switch *ds, int port, int mtu)
|
||||
{
|
||||
struct ksz_device *dev = ds->priv;
|
||||
u16 frame_size;
|
||||
|
||||
if (!dsa_is_cpu_port(dev->ds, port))
|
||||
return 0;
|
||||
|
||||
frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
|
||||
|
||||
switch (dev->chip_id) {
|
||||
case KSZ8795_CHIP_ID:
|
||||
case KSZ8794_CHIP_ID:
|
||||
case KSZ8765_CHIP_ID:
|
||||
return ksz8795_change_mtu(dev, frame_size);
|
||||
case KSZ8463_CHIP_ID:
|
||||
case KSZ88X3_CHIP_ID:
|
||||
case KSZ8864_CHIP_ID:
|
||||
case KSZ8895_CHIP_ID:
|
||||
return ksz8863_change_mtu(dev, frame_size);
|
||||
}
|
||||
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static int ksz8_port_queue_split(struct ksz_device *dev, int port, int queues)
|
||||
{
|
||||
u8 mask_4q, mask_2q;
|
||||
|
|
@ -2551,7 +2540,7 @@ const struct dsa_switch_ops ksz8463_switch_ops = {
|
|||
.port_mirror_del = ksz8_port_mirror_del,
|
||||
.get_stats64 = ksz_get_stats64,
|
||||
.get_pause_stats = ksz_get_pause_stats,
|
||||
.port_change_mtu = ksz8_change_mtu,
|
||||
.port_change_mtu = ksz88xx_change_mtu,
|
||||
.port_max_mtu = ksz_max_mtu,
|
||||
.suspend = ksz_suspend,
|
||||
.resume = ksz_resume,
|
||||
|
|
@ -2601,7 +2590,7 @@ const struct dsa_switch_ops ksz87xx_switch_ops = {
|
|||
.port_mirror_del = ksz8_port_mirror_del,
|
||||
.get_stats64 = ksz_get_stats64,
|
||||
.get_pause_stats = ksz_get_pause_stats,
|
||||
.port_change_mtu = ksz8_change_mtu,
|
||||
.port_change_mtu = ksz87xx_change_mtu,
|
||||
.port_max_mtu = ksz_max_mtu,
|
||||
.suspend = ksz_suspend,
|
||||
.resume = ksz_resume,
|
||||
|
|
@ -2652,7 +2641,7 @@ const struct dsa_switch_ops ksz88xx_switch_ops = {
|
|||
.port_mirror_del = ksz8_port_mirror_del,
|
||||
.get_stats64 = ksz_get_stats64,
|
||||
.get_pause_stats = ksz_get_pause_stats,
|
||||
.port_change_mtu = ksz8_change_mtu,
|
||||
.port_change_mtu = ksz88xx_change_mtu,
|
||||
.port_max_mtu = ksz_max_mtu,
|
||||
.get_wol = ksz_get_wol,
|
||||
.set_wol = ksz_set_wol,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user