/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef __MXL862XX_API_H
#define __MXL862XX_API_H
#include <linux/bits.h>
#include <linux/if_ether.h>
/**
* struct mdio_relay_data - relayed access to the switch internal MDIO bus
* @data: data to be read or written
* @phy: PHY index
* @mmd: MMD device
* @reg: register index
*/
struct mdio_relay_data {
__le16 data;
u8 phy;
u8 mmd;
__le16 reg;
} __packed;
/**
* struct mxl862xx_register_mod - Register access parameter to directly
* modify internal registers
* @addr: Register address offset for modification
* @data: Value to write to the register address
* @mask: Mask of bits to be modified (1 to modify, 0 to ignore)
*
* Used for direct register modification operations.
*/
struct mxl862xx_register_mod {
__le16 addr;
__le16 data;
__le16 mask;
} __packed;
/**
* enum mxl862xx_mac_table_filter - Source/Destination MAC address filtering
*
* @MXL862XX_MAC_FILTER_NONE: no filter
* @MXL862XX_MAC_FILTER_SRC: source address filter
* @MXL862XX_MAC_FILTER_DEST: destination address filter
* @MXL862XX_MAC_FILTER_BOTH: both source and destination filter
*/
enum mxl862xx_mac_table_filter {
MXL862XX_MAC_FILTER_NONE = 0,
MXL862XX_MAC_FILTER_SRC = BIT(0),
MXL862XX_MAC_FILTER_DEST = BIT(1),
MXL862XX_MAC_FILTER_BOTH = BIT(0) | BIT(1),
};
#define MXL862XX_TCI_VLAN_ID GENMASK(11, 0)
#define MXL862XX_TCI_VLAN_CFI_DEI BIT(12)
#define MXL862XX_TCI_VLAN_PRI GENMASK(15, 13)
/* Set in port_id to use port_map[] as a portmap bitmap instead of a single
* port ID. When clear, port_id selects one port; when set, the firmware
* ignores the lower bits of port_id and writes port_map[] directly into
* the PCE bridge port map.
*/
#define MXL862XX_PORTMAP_FLAG BIT(31)
/**
* struct mxl862xx_mac_table_add - MAC Table Entry to be added
* @fid: Filtering Identifier (FID) (not supported by all switches)
* @port_id: Ethernet Port number
* @port_map: Bridge Port Map
* @sub_if_id: Sub-Interface Identifier Destination
* @age_timer: Aging Time in seconds
* @vlan_id: STAG VLAN Id
* @static_entry: Static Entry (value will be aged out if not set to static)
* @traffic_class: Egress queue traffic class
* @mac: MAC Address to add to the table
* @filter_flag: See &enum mxl862xx_mac_table_filter
* @igmp_controlled: Packet is marked as IGMP controlled if destination MAC
* address matches MAC in this entry
* @associated_mac: Associated Mac address
* @tci: TCI for B-Step
* Bit [0:11] - VLAN ID
* Bit [12] - VLAN CFI/DEI
* Bit [13:15] - VLAN PRI
*/
struct mxl862xx_mac_table_add {
__le16 fid;
__le32 port_id;
__le16 port_map[8];
__le16 sub_if_id;
__le32 age_timer;
__le16 vlan_id;
u8 static_entry;
u8 traffic_class;
u8 mac[ETH_ALEN];
u8 filter_flag;
u8 igmp_controlled;
u8 associated_mac[ETH_ALEN];
__le16 tci;
}