linux/drivers/net/dsa/microchip/ksz9477.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Microchip KSZ9477 switch driver main logic
 *
 * Copyright (C) 2017-2019 Microchip Technology Inc.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/iopoll.h>
#include <linux/platform_data/microchip-ksz.h>
#include <linux/phy.h>
#include <linux/if_bridge.h>
#include <linux/if_vlan.h>
#include <net/dsa.h>
#include <net/switchdev.h>

#include "ksz9477_reg.h"
#include "ksz_common.h"
#include "ksz9477.h"

static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
{}

static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,
			 bool set)
{}

static void ksz9477_cfg32(struct ksz_device *dev, u32 addr, u32 bits, bool set)
{}

static void ksz9477_port_cfg32(struct ksz_device *dev, int port, int offset,
			       u32 bits, bool set)
{}

int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu)
{}

/**
 * ksz9477_handle_wake_reason - Handle wake reason on a specified port.
 * @dev: The device structure.
 * @port: The port number.
 *
 * This function reads the PME (Power Management Event) status register of a
 * specified port to determine the wake reason. If there is no wake event, it
 * returns early. Otherwise, it logs the wake reason which could be due to a
 * "Magic Packet", "Link Up", or "Energy Detect" event. The PME status register
 * is then cleared to acknowledge the handling of the wake event.
 *
 * Return: 0 on success, or an error code on failure.
 */
static int ksz9477_handle_wake_reason(struct ksz_device *dev, int port)
{}

/**
 * ksz9477_get_wol - Get Wake-on-LAN settings for a specified port.
 * @dev: The device structure.
 * @port: The port number.
 * @wol: Pointer to ethtool Wake-on-LAN settings structure.
 *
 * This function checks the PME Pin Control Register to see if  PME Pin Output
 * Enable is set, indicating PME is enabled. If enabled, it sets the supported
 * and active WoL flags.
 */
void ksz9477_get_wol(struct ksz_device *dev, int port,
		     struct ethtool_wolinfo *wol)
{}

/**
 * ksz9477_set_wol - Set Wake-on-LAN settings for a specified port.
 * @dev: The device structure.
 * @port: The port number.
 * @wol: Pointer to ethtool Wake-on-LAN settings structure.
 *
 * This function configures Wake-on-LAN (WoL) settings for a specified port.
 * It validates the provided WoL options, checks if PME is enabled via the
 * switch's PME Pin Control Register, clears any previous wake reasons,
 * and sets the Magic Packet flag in the port's PME control register if
 * specified.
 *
 * Return: 0 on success, or other error codes on failure.
 */
int ksz9477_set_wol(struct ksz_device *dev, int port,
		    struct ethtool_wolinfo *wol)
{}

/**
 * ksz9477_wol_pre_shutdown - Prepares the switch device for shutdown while
 *                            considering Wake-on-LAN (WoL) settings.
 * @dev: The switch device structure.
 * @wol_enabled: Pointer to a boolean which will be set to true if WoL is
 *               enabled on any port.
 *
 * This function prepares the switch device for a safe shutdown while taking
 * into account the Wake-on-LAN (WoL) settings on the user ports. It updates
 * the wol_enabled flag accordingly to reflect whether WoL is active on any
 * port.
 */
void ksz9477_wol_pre_shutdown(struct ksz_device *dev, bool *wol_enabled)
{}

static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev)
{}

static int ksz9477_get_vlan_table(struct ksz_device *dev, u16 vid,
				  u32 *vlan_table)
{}

static int ksz9477_set_vlan_table(struct ksz_device *dev, u16 vid,
				  u32 *vlan_table)
{}

static void ksz9477_read_table(struct ksz_device *dev, u32 *table)
{}

static void ksz9477_write_table(struct ksz_device *dev, u32 *table)
{}

static int ksz9477_wait_alu_ready(struct ksz_device *dev)
{}

static int ksz9477_wait_alu_sta_ready(struct ksz_device *dev)
{}

int ksz9477_reset_switch(struct ksz_device *dev)
{}

void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt)
{}

void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
		       u64 *dropped, u64 *cnt)
{}

void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze)
{}

int ksz9477_errata_monitor(struct ksz_device *dev, int port,
			   u64 tx_late_col)
{}

void ksz9477_port_init_cnt(struct ksz_device *dev, int port)
{}

static void ksz9477_r_phy_quirks(struct ksz_device *dev, u16 addr, u16 reg,
				 u16 *data)
{}

int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data)
{}

int ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val)
{}

void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member)
{}

void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port)
{}

int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port,
				bool flag, struct netlink_ext_ack *extack)
{}

int ksz9477_port_vlan_add(struct ksz_device *dev, int port,
			  const struct switchdev_obj_port_vlan *vlan,
			  struct netlink_ext_ack *extack)
{}

int ksz9477_port_vlan_del(struct ksz_device *dev, int port,
			  const struct switchdev_obj_port_vlan *vlan)
{}

int ksz9477_fdb_add(struct ksz_device *dev, int port,
		    const unsigned char *addr, u16 vid, struct dsa_db db)
{}

int ksz9477_fdb_del(struct ksz_device *dev, int port,
		    const unsigned char *addr, u16 vid, struct dsa_db db)
{}

static void ksz9477_convert_alu(struct alu_struct *alu, u32 *alu_table)
{}

int ksz9477_fdb_dump(struct ksz_device *dev, int port,
		     dsa_fdb_dump_cb_t *cb, void *data)
{}

int ksz9477_mdb_add(struct ksz_device *dev, int port,
		    const struct switchdev_obj_port_mdb *mdb, struct dsa_db db)
{}

int ksz9477_mdb_del(struct ksz_device *dev, int port,
		    const struct switchdev_obj_port_mdb *mdb, struct dsa_db db)
{}

int ksz9477_port_mirror_add(struct ksz_device *dev, int port,
			    struct dsa_mall_mirror_tc_entry *mirror,
			    bool ingress, struct netlink_ext_ack *extack)
{}

void ksz9477_port_mirror_del(struct ksz_device *dev, int port,
			     struct dsa_mall_mirror_tc_entry *mirror)
{}

static phy_interface_t ksz9477_get_interface(struct ksz_device *dev, int port)
{}

void ksz9477_get_caps(struct ksz_device *dev, int port,
		      struct phylink_config *config)
{}

int ksz9477_set_ageing_time(struct ksz_device *dev, unsigned int msecs)
{}

void ksz9477_port_queue_split(struct ksz_device *dev, int port)
{}

void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
{}

void ksz9477_config_cpu_port(struct dsa_switch *ds)
{}

int ksz9477_enable_stp_addr(struct ksz_device *dev)
{}

int ksz9477_setup(struct dsa_switch *ds)
{}

u32 ksz9477_get_port_addr(int port, int offset)
{}

int ksz9477_tc_cbs_set_cinc(struct ksz_device *dev, int port, u32 val)
{}

/* The KSZ9477 provides following HW features to accelerate
 * HSR frames handling:
 *
 * 1. TX PACKET DUPLICATION FROM HOST TO SWITCH
 * 2. RX PACKET DUPLICATION DISCARDING
 * 3. PREVENTING PACKET LOOP IN THE RING BY SELF-ADDRESS FILTERING
 *
 * Only one from point 1. has the NETIF_F* flag available.
 *
 * Ones from point 2 and 3 are "best effort" - i.e. those will
 * work correctly most of the time, but it may happen that some
 * frames will not be caught - to be more specific; there is a race
 * condition in hardware such that, when duplicate packets are received
 * on member ports very close in time to each other, the hardware fails
 * to detect that they are duplicates.
 *
 * Hence, the SW needs to handle those special cases. However, the speed
 * up gain is considerable when above features are used.
 *
 * Moreover, the NETIF_F_HW_HSR_FWD feature is also enabled, as HSR frames
 * can be forwarded in the switch fabric between HSR ports.
 */
#define KSZ9477_SUPPORTED_HSR_FEATURES

void ksz9477_hsr_join(struct dsa_switch *ds, int port, struct net_device *hsr)
{}

void ksz9477_hsr_leave(struct dsa_switch *ds, int port, struct net_device *hsr)
{}

int ksz9477_switch_init(struct ksz_device *dev)
{}

void ksz9477_switch_exit(struct ksz_device *dev)
{}

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();