18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _PRESTERA_HW_H_
58c2ecf20Sopenharmony_ci#define _PRESTERA_HW_H_
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/types.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cienum prestera_accept_frm_type {
108c2ecf20Sopenharmony_ci	PRESTERA_ACCEPT_FRAME_TYPE_TAGGED,
118c2ecf20Sopenharmony_ci	PRESTERA_ACCEPT_FRAME_TYPE_UNTAGGED,
128c2ecf20Sopenharmony_ci	PRESTERA_ACCEPT_FRAME_TYPE_ALL,
138c2ecf20Sopenharmony_ci};
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cienum prestera_fdb_flush_mode {
168c2ecf20Sopenharmony_ci	PRESTERA_FDB_FLUSH_MODE_DYNAMIC = BIT(0),
178c2ecf20Sopenharmony_ci	PRESTERA_FDB_FLUSH_MODE_STATIC = BIT(1),
188c2ecf20Sopenharmony_ci	PRESTERA_FDB_FLUSH_MODE_ALL = PRESTERA_FDB_FLUSH_MODE_DYNAMIC
198c2ecf20Sopenharmony_ci					| PRESTERA_FDB_FLUSH_MODE_STATIC,
208c2ecf20Sopenharmony_ci};
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cienum {
238c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_10baseT_Half,
248c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_10baseT_Full,
258c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_100baseT_Half,
268c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_100baseT_Full,
278c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_1000baseT_Half,
288c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_1000baseT_Full,
298c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_1000baseX_Full,
308c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_1000baseKX_Full,
318c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_2500baseX_Full,
328c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_10GbaseKR_Full,
338c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_10GbaseSR_Full,
348c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_10GbaseLR_Full,
358c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_20GbaseKR2_Full,
368c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_25GbaseCR_Full,
378c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_25GbaseKR_Full,
388c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_25GbaseSR_Full,
398c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_40GbaseKR4_Full,
408c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_40GbaseCR4_Full,
418c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_40GbaseSR4_Full,
428c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_50GbaseCR2_Full,
438c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_50GbaseKR2_Full,
448c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_50GbaseSR2_Full,
458c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_100GbaseKR4_Full,
468c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_100GbaseSR4_Full,
478c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_100GbaseCR4_Full,
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	PRESTERA_LINK_MODE_MAX
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cienum {
538c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_NONE,
548c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_TP,
558c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_AUI,
568c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_MII,
578c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_FIBRE,
588c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_BNC,
598c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_DA,
608c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_OTHER,
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	PRESTERA_PORT_TYPE_MAX
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_cienum {
668c2ecf20Sopenharmony_ci	PRESTERA_PORT_TCVR_COPPER,
678c2ecf20Sopenharmony_ci	PRESTERA_PORT_TCVR_SFP,
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	PRESTERA_PORT_TCVR_MAX
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cienum {
738c2ecf20Sopenharmony_ci	PRESTERA_PORT_FEC_OFF,
748c2ecf20Sopenharmony_ci	PRESTERA_PORT_FEC_BASER,
758c2ecf20Sopenharmony_ci	PRESTERA_PORT_FEC_RS,
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	PRESTERA_PORT_FEC_MAX
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cienum {
818c2ecf20Sopenharmony_ci	PRESTERA_PORT_DUPLEX_HALF,
828c2ecf20Sopenharmony_ci	PRESTERA_PORT_DUPLEX_FULL,
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_cienum {
868c2ecf20Sopenharmony_ci	PRESTERA_STP_DISABLED,
878c2ecf20Sopenharmony_ci	PRESTERA_STP_BLOCK_LISTEN,
888c2ecf20Sopenharmony_ci	PRESTERA_STP_LEARN,
898c2ecf20Sopenharmony_ci	PRESTERA_STP_FORWARD,
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistruct prestera_switch;
938c2ecf20Sopenharmony_cistruct prestera_port;
948c2ecf20Sopenharmony_cistruct prestera_port_stats;
958c2ecf20Sopenharmony_cistruct prestera_port_caps;
968c2ecf20Sopenharmony_cienum prestera_event_type;
978c2ecf20Sopenharmony_cistruct prestera_event;
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_citypedef void (*prestera_event_cb_t)
1008c2ecf20Sopenharmony_ci	(struct prestera_switch *sw, struct prestera_event *evt, void *arg);
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistruct prestera_rxtx_params;
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/* Switch API */
1058c2ecf20Sopenharmony_ciint prestera_hw_switch_init(struct prestera_switch *sw);
1068c2ecf20Sopenharmony_civoid prestera_hw_switch_fini(struct prestera_switch *sw);
1078c2ecf20Sopenharmony_ciint prestera_hw_switch_ageing_set(struct prestera_switch *sw, u32 ageing_ms);
1088c2ecf20Sopenharmony_ciint prestera_hw_switch_mac_set(struct prestera_switch *sw, const char *mac);
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/* Port API */
1118c2ecf20Sopenharmony_ciint prestera_hw_port_info_get(const struct prestera_port *port,
1128c2ecf20Sopenharmony_ci			      u32 *dev_id, u32 *hw_id, u16 *fp_id);
1138c2ecf20Sopenharmony_ciint prestera_hw_port_state_set(const struct prestera_port *port,
1148c2ecf20Sopenharmony_ci			       bool admin_state);
1158c2ecf20Sopenharmony_ciint prestera_hw_port_mtu_set(const struct prestera_port *port, u32 mtu);
1168c2ecf20Sopenharmony_ciint prestera_hw_port_mtu_get(const struct prestera_port *port, u32 *mtu);
1178c2ecf20Sopenharmony_ciint prestera_hw_port_mac_set(const struct prestera_port *port, const char *mac);
1188c2ecf20Sopenharmony_ciint prestera_hw_port_mac_get(const struct prestera_port *port, char *mac);
1198c2ecf20Sopenharmony_ciint prestera_hw_port_cap_get(const struct prestera_port *port,
1208c2ecf20Sopenharmony_ci			     struct prestera_port_caps *caps);
1218c2ecf20Sopenharmony_ciint prestera_hw_port_remote_cap_get(const struct prestera_port *port,
1228c2ecf20Sopenharmony_ci				    u64 *link_mode_bitmap);
1238c2ecf20Sopenharmony_ciint prestera_hw_port_remote_fc_get(const struct prestera_port *port,
1248c2ecf20Sopenharmony_ci				   bool *pause, bool *asym_pause);
1258c2ecf20Sopenharmony_ciint prestera_hw_port_type_get(const struct prestera_port *port, u8 *type);
1268c2ecf20Sopenharmony_ciint prestera_hw_port_fec_get(const struct prestera_port *port, u8 *fec);
1278c2ecf20Sopenharmony_ciint prestera_hw_port_fec_set(const struct prestera_port *port, u8 fec);
1288c2ecf20Sopenharmony_ciint prestera_hw_port_autoneg_set(const struct prestera_port *port,
1298c2ecf20Sopenharmony_ci				 bool autoneg, u64 link_modes, u8 fec);
1308c2ecf20Sopenharmony_ciint prestera_hw_port_autoneg_restart(struct prestera_port *port);
1318c2ecf20Sopenharmony_ciint prestera_hw_port_duplex_get(const struct prestera_port *port, u8 *duplex);
1328c2ecf20Sopenharmony_ciint prestera_hw_port_stats_get(const struct prestera_port *port,
1338c2ecf20Sopenharmony_ci			       struct prestera_port_stats *stats);
1348c2ecf20Sopenharmony_ciint prestera_hw_port_link_mode_set(const struct prestera_port *port, u32 mode);
1358c2ecf20Sopenharmony_ciint prestera_hw_port_link_mode_get(const struct prestera_port *port, u32 *mode);
1368c2ecf20Sopenharmony_ciint prestera_hw_port_mdix_get(const struct prestera_port *port, u8 *status,
1378c2ecf20Sopenharmony_ci			      u8 *admin_mode);
1388c2ecf20Sopenharmony_ciint prestera_hw_port_mdix_set(const struct prestera_port *port, u8 mode);
1398c2ecf20Sopenharmony_ciint prestera_hw_port_speed_get(const struct prestera_port *port, u32 *speed);
1408c2ecf20Sopenharmony_ciint prestera_hw_port_learning_set(struct prestera_port *port, bool enable);
1418c2ecf20Sopenharmony_ciint prestera_hw_port_flood_set(struct prestera_port *port, bool flood);
1428c2ecf20Sopenharmony_ciint prestera_hw_port_accept_frm_type(struct prestera_port *port,
1438c2ecf20Sopenharmony_ci				     enum prestera_accept_frm_type type);
1448c2ecf20Sopenharmony_ci/* Vlan API */
1458c2ecf20Sopenharmony_ciint prestera_hw_vlan_create(struct prestera_switch *sw, u16 vid);
1468c2ecf20Sopenharmony_ciint prestera_hw_vlan_delete(struct prestera_switch *sw, u16 vid);
1478c2ecf20Sopenharmony_ciint prestera_hw_vlan_port_set(struct prestera_port *port, u16 vid,
1488c2ecf20Sopenharmony_ci			      bool is_member, bool untagged);
1498c2ecf20Sopenharmony_ciint prestera_hw_vlan_port_vid_set(struct prestera_port *port, u16 vid);
1508c2ecf20Sopenharmony_ciint prestera_hw_vlan_port_stp_set(struct prestera_port *port, u16 vid, u8 state);
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci/* FDB API */
1538c2ecf20Sopenharmony_ciint prestera_hw_fdb_add(struct prestera_port *port, const unsigned char *mac,
1548c2ecf20Sopenharmony_ci			u16 vid, bool dynamic);
1558c2ecf20Sopenharmony_ciint prestera_hw_fdb_del(struct prestera_port *port, const unsigned char *mac,
1568c2ecf20Sopenharmony_ci			u16 vid);
1578c2ecf20Sopenharmony_ciint prestera_hw_fdb_flush_port(struct prestera_port *port, u32 mode);
1588c2ecf20Sopenharmony_ciint prestera_hw_fdb_flush_vlan(struct prestera_switch *sw, u16 vid, u32 mode);
1598c2ecf20Sopenharmony_ciint prestera_hw_fdb_flush_port_vlan(struct prestera_port *port, u16 vid,
1608c2ecf20Sopenharmony_ci				    u32 mode);
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci/* Bridge API */
1638c2ecf20Sopenharmony_ciint prestera_hw_bridge_create(struct prestera_switch *sw, u16 *bridge_id);
1648c2ecf20Sopenharmony_ciint prestera_hw_bridge_delete(struct prestera_switch *sw, u16 bridge_id);
1658c2ecf20Sopenharmony_ciint prestera_hw_bridge_port_add(struct prestera_port *port, u16 bridge_id);
1668c2ecf20Sopenharmony_ciint prestera_hw_bridge_port_delete(struct prestera_port *port, u16 bridge_id);
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/* Event handlers */
1698c2ecf20Sopenharmony_ciint prestera_hw_event_handler_register(struct prestera_switch *sw,
1708c2ecf20Sopenharmony_ci				       enum prestera_event_type type,
1718c2ecf20Sopenharmony_ci				       prestera_event_cb_t fn,
1728c2ecf20Sopenharmony_ci				       void *arg);
1738c2ecf20Sopenharmony_civoid prestera_hw_event_handler_unregister(struct prestera_switch *sw,
1748c2ecf20Sopenharmony_ci					  enum prestera_event_type type,
1758c2ecf20Sopenharmony_ci					  prestera_event_cb_t fn);
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci/* RX/TX */
1788c2ecf20Sopenharmony_ciint prestera_hw_rxtx_init(struct prestera_switch *sw,
1798c2ecf20Sopenharmony_ci			  struct prestera_rxtx_params *params);
1808c2ecf20Sopenharmony_ciint prestera_hw_rxtx_port_init(struct prestera_port *port);
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci#endif /* _PRESTERA_HW_H_ */
183