net: dsa: microchip: move max mtu to one location
There are no HW specific registers, so we can process all of them in one location. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Tested-by: Arun Ramadoss <arun.ramadoss@microchip.com> (KSZ9893 and LAN937x) Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
e22dcbc9aa
commit
838c19f894
|
@ -60,11 +60,6 @@ int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu)
|
|||
REG_SW_MTU_MASK, max_frame);
|
||||
}
|
||||
|
||||
int ksz9477_max_mtu(struct ksz_device *dev, int port)
|
||||
{
|
||||
return KSZ9477_MAX_FRAME_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
|
||||
}
|
||||
|
||||
static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev)
|
||||
{
|
||||
unsigned int val;
|
||||
|
|
|
@ -50,7 +50,6 @@ int ksz9477_mdb_add(struct ksz_device *dev, int port,
|
|||
int ksz9477_mdb_del(struct ksz_device *dev, int port,
|
||||
const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
|
||||
int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu);
|
||||
int ksz9477_max_mtu(struct ksz_device *dev, int port);
|
||||
void ksz9477_config_cpu_port(struct dsa_switch *ds);
|
||||
int ksz9477_enable_stp_addr(struct ksz_device *dev);
|
||||
int ksz9477_reset_switch(struct ksz_device *dev);
|
||||
|
|
|
@ -1615,6 +1615,4 @@
|
|||
#define PTP_TRIG_UNIT_M (BIT(MAX_TRIG_UNIT) - 1)
|
||||
#define PTP_TS_UNIT_M (BIT(MAX_TIMESTAMP_UNIT) - 1)
|
||||
|
||||
#define KSZ9477_MAX_FRAME_SIZE 9000
|
||||
|
||||
#endif /* KSZ9477_REGS_H */
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <linux/phy.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/if_bridge.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/of_mdio.h>
|
||||
|
@ -206,7 +207,6 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
|
|||
.mdb_add = ksz9477_mdb_add,
|
||||
.mdb_del = ksz9477_mdb_del,
|
||||
.change_mtu = ksz9477_change_mtu,
|
||||
.max_mtu = ksz9477_max_mtu,
|
||||
.phylink_mac_link_up = ksz9477_phylink_mac_link_up,
|
||||
.config_cpu_port = ksz9477_config_cpu_port,
|
||||
.enable_stp_addr = ksz9477_enable_stp_addr,
|
||||
|
@ -243,7 +243,6 @@ static const struct ksz_dev_ops lan937x_dev_ops = {
|
|||
.mdb_add = ksz9477_mdb_add,
|
||||
.mdb_del = ksz9477_mdb_del,
|
||||
.change_mtu = lan937x_change_mtu,
|
||||
.max_mtu = ksz9477_max_mtu,
|
||||
.phylink_mac_link_up = ksz9477_phylink_mac_link_up,
|
||||
.config_cpu_port = lan937x_config_cpu_port,
|
||||
.enable_stp_addr = ksz9477_enable_stp_addr,
|
||||
|
@ -2500,10 +2499,23 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
|
|||
{
|
||||
struct ksz_device *dev = ds->priv;
|
||||
|
||||
if (!dev->dev_ops->max_mtu)
|
||||
return -EOPNOTSUPP;
|
||||
switch (dev->chip_id) {
|
||||
case KSZ8563_CHIP_ID:
|
||||
case KSZ9477_CHIP_ID:
|
||||
case KSZ9563_CHIP_ID:
|
||||
case KSZ9567_CHIP_ID:
|
||||
case KSZ9893_CHIP_ID:
|
||||
case KSZ9896_CHIP_ID:
|
||||
case KSZ9897_CHIP_ID:
|
||||
case LAN9370_CHIP_ID:
|
||||
case LAN9371_CHIP_ID:
|
||||
case LAN9372_CHIP_ID:
|
||||
case LAN9373_CHIP_ID:
|
||||
case LAN9374_CHIP_ID:
|
||||
return KSZ9477_MAX_FRAME_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
|
||||
}
|
||||
|
||||
return dev->dev_ops->max_mtu(dev, port);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static void ksz_set_xmii(struct ksz_device *dev, int port,
|
||||
|
|
|
@ -322,7 +322,6 @@ struct ksz_dev_ops {
|
|||
void (*get_caps)(struct ksz_device *dev, int port,
|
||||
struct phylink_config *config);
|
||||
int (*change_mtu)(struct ksz_device *dev, int port, int mtu);
|
||||
int (*max_mtu)(struct ksz_device *dev, int port);
|
||||
void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze);
|
||||
void (*port_init_cnt)(struct ksz_device *dev, int port);
|
||||
void (*phylink_mac_config)(struct ksz_device *dev, int port,
|
||||
|
@ -588,6 +587,8 @@ static inline int is_lan937x(struct ksz_device *dev)
|
|||
|
||||
#define PORT_SRC_PHY_INT 1
|
||||
|
||||
#define KSZ9477_MAX_FRAME_SIZE 9000
|
||||
|
||||
/* Regmap tables generation */
|
||||
#define KSZ_SPI_OP_RD 3
|
||||
#define KSZ_SPI_OP_WR 2
|
||||
|
|
Loading…
Reference in New Issue