struct ksz_mib_names { int index; char string[ETH_GSTRING_LEN];
};
struct ksz_chip_data {
u32 chip_id; constchar *dev_name; int num_vlans; int num_alus; int num_statics; int cpu_ports; int port_cnt;
u8 port_nirqs;
u8 num_tx_queues;
u8 num_ipms; /* number of Internal Priority Maps */ bool tc_cbs_supported;
/** * @phy_side_mdio_supported: Indicates if the chip supports an additional * side MDIO channel for accessing integrated PHYs.
*/ bool phy_side_mdio_supported; conststruct ksz_dev_ops *ops; conststruct phylink_mac_ops *phylink_mac_ops; bool phy_errata_9477; bool ksz87xx_eee_link_erratum; conststruct ksz_mib_names *mib_names; int mib_cnt;
u8 reg_mib_cnt; const u16 *regs; const u32 *masks; const u8 *shifts; const u8 *xmii_ctrl0; const u8 *xmii_ctrl1; int stp_ctrl_reg; int broadcast_ctrl_reg; int multicast_ctrl_reg; int start_ctrl_reg; bool supports_mii[KSZ_MAX_NUM_PORTS]; bool supports_rmii[KSZ_MAX_NUM_PORTS]; bool supports_rgmii[KSZ_MAX_NUM_PORTS]; bool internal_phy[KSZ_MAX_NUM_PORTS]; bool gbit_capable[KSZ_MAX_NUM_PORTS]; bool ptp_capable;
u8 sgmii_port; conststruct regmap_access_table *wr_table; conststruct regmap_access_table *rd_table;
};
/* chip specific data */
u32 chip_id;
u8 chip_rev; int cpu_port; /* port connected to CPU */ int phy_port_cnt;
phy_interface_t compat_interface; bool synclko_125; bool synclko_disable; bool wakeup_source; bool pme_active_high;
/** * @phy_addr_map: Array mapping switch ports to their corresponding PHY * addresses.
*/
u8 phy_addr_map[KSZ_MAX_NUM_PORTS];
/** * @parent_mdio_bus: Pointer to the external MDIO bus controller. * * This points to an external MDIO bus controller that is used to access * the PHYs integrated within the switch. Unlike an integrated MDIO * bus, this external controller provides a direct path for managing * the switch’s internal PHYs, bypassing the main SPI interface.
*/ struct mii_bus *parent_mdio_bus;
};
struct ksz_dev_ops { int (*setup)(struct dsa_switch *ds); void (*teardown)(struct dsa_switch *ds);
u32 (*get_port_addr)(int port, int offset); void (*cfg_port_member)(struct ksz_device *dev, int port, u8 member); void (*flush_dyn_mac_table)(struct ksz_device *dev, int port); void (*port_cleanup)(struct ksz_device *dev, int port); void (*port_setup)(struct ksz_device *dev, int port, bool cpu_port); int (*set_ageing_time)(struct ksz_device *dev, unsignedint msecs);
/** * @mdio_bus_preinit: Function pointer to pre-initialize the MDIO bus * for accessing PHYs. * @dev: Pointer to device structure. * @side_mdio: Boolean indicating if the PHYs are accessed over a side * MDIO bus. * * This function pointer is used to configure the MDIO bus for PHY * access before initiating regular PHY operations. It enables either * SPI/I2C or side MDIO access modes by unlocking necessary registers * and setting up access permissions for the selected mode. * * Return: * - 0 on success. * - Negative error code on failure.
*/ int (*mdio_bus_preinit)(struct ksz_device *dev, bool side_mdio);
/** * @create_phy_addr_map: Function pointer to create a port-to-PHY * address map. * @dev: Pointer to device structure. * @side_mdio: Boolean indicating if the PHYs are accessed over a side * MDIO bus. * * This function pointer is responsible for mapping switch ports to PHY * addresses according to the configured access mode (SPI or side MDIO) * and the device’s strap configuration. The mapping setup may vary * depending on the chip variant and configuration. Ensures the correct * address mapping for PHY communication. * * Return: * - 0 on success. * - Negative error code on failure (e.g., invalid configuration).
*/ int (*create_phy_addr_map)(struct ksz_device *dev, bool side_mdio); int (*r_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 *val); int (*w_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 val); void (*r_mib_cnt)(struct ksz_device *dev, int port, u16 addr,
u64 *cnt); void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr,
u64 *dropped, u64 *cnt); void (*r_mib_stat64)(struct ksz_device *dev, int port); int (*vlan_filtering)(struct ksz_device *dev, int port, bool flag, struct netlink_ext_ack *extack); int (*vlan_add)(struct ksz_device *dev, int port, conststruct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack); int (*vlan_del)(struct ksz_device *dev, int port, conststruct switchdev_obj_port_vlan *vlan); int (*mirror_add)(struct ksz_device *dev, int port, struct dsa_mall_mirror_tc_entry *mirror, bool ingress, struct netlink_ext_ack *extack); void (*mirror_del)(struct ksz_device *dev, int port, struct dsa_mall_mirror_tc_entry *mirror); int (*fdb_add)(struct ksz_device *dev, int port, constunsignedchar *addr, u16 vid, struct dsa_db db); int (*fdb_del)(struct ksz_device *dev, int port, constunsignedchar *addr, u16 vid, struct dsa_db db); int (*fdb_dump)(struct ksz_device *dev, int port,
dsa_fdb_dump_cb_t *cb, void *data); int (*mdb_add)(struct ksz_device *dev, int port, conststruct switchdev_obj_port_mdb *mdb, struct dsa_db db); int (*mdb_del)(struct ksz_device *dev, int port, conststruct switchdev_obj_port_mdb *mdb, struct dsa_db db); 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 (*pme_write8)(struct ksz_device *dev, u32 reg, u8 value); int (*pme_pread8)(struct ksz_device *dev, int port, int offset,
u8 *data); int (*pme_pwrite8)(struct ksz_device *dev, int port, int offset,
u8 data); void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze); void (*port_init_cnt)(struct ksz_device *dev, int port); void (*phylink_mac_link_up)(struct ksz_device *dev, int port, unsignedint mode,
phy_interface_t interface, struct phy_device *phydev, int speed, int duplex, bool tx_pause, bool rx_pause); void (*setup_rgmii_delay)(struct ksz_device *dev, int port); int (*tc_cbs_set_cinc)(struct ksz_device *dev, int port, u32 val); void (*config_cpu_port)(struct dsa_switch *ds); int (*enable_stp_addr)(struct ksz_device *dev); int (*reset)(struct ksz_device *dev); int (*init)(struct ksz_device *dev); void (*exit)(struct ksz_device *dev);
int (*pcs_create)(struct ksz_device *dev);
};
struct ksz_device *ksz_switch_alloc(struct device *base, void *priv); int ksz_switch_register(struct ksz_device *dev); void ksz_switch_remove(struct ksz_device *dev); int ksz_switch_suspend(struct device *dev); int ksz_switch_resume(struct device *dev);
void ksz_init_mib_timer(struct ksz_device *dev); bool ksz_is_port_mac_global_usable(struct dsa_switch *ds, int port); void ksz_r_mib_stats64(struct ksz_device *dev, int port); void ksz88xx_r_mib_stats64(struct ksz_device *dev, int port); void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state); bool ksz_get_gbit(struct ksz_device *dev, int port);
phy_interface_t ksz_get_xmii(struct ksz_device *dev, int port, bool gbit); externconststruct ksz_chip_data ksz_switch_chips[]; int ksz_switch_macaddr_get(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack); void ksz_switch_macaddr_put(struct dsa_switch *ds); void ksz_switch_shutdown(struct ksz_device *dev); int ksz_handle_wake_reason(struct ksz_device *dev, int port);
/* TXQ Split Control Register for per-port, per-queue configuration. * Register 0xAF is TXQ Split for Q3 on Port 1. * Register offset formula: 0xAF + (port * 4) + (3 - queue) * where: port = 0..2, queue = 0..3
*/ #define KSZ8873_TXQ_SPLIT_CTRL_REG(port, queue) \
(0xAF + ((port) * 4) + (3 - (queue)))
/* Bit 7 selects between: * 0 = Strict priority mode (highest-priority queue first) * 1 = Weighted Fair Queuing (WFQ) mode: * Queue weights: Q3:Q2:Q1:Q0 = 8:4:2:1 * If any queues are empty, weight is redistributed. * * Note: This is referred to as "Weighted Fair Queuing" (WFQ) in KSZ8863/8873 * documentation, and as "Weighted Round Robin" (WRR) in KSZ9477 family docs.
*/ #define KSZ8873_TXQ_WFQ_ENABLE BIT(7)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.