#ifndef __LAN966X_MAIN_H__
#define __LAN966X_MAIN_H__
#include <linux/debugfs.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/jiffies.h>
#include <linux/phy.h>
#include <linux/phylink.h>
#include <linux/ptp_clock_kernel.h>
#include <net/page_pool/types.h>
#include <net/pkt_cls.h>
#include <net/pkt_sched.h>
#include <net/switchdev.h>
#include <net/xdp.h>
#include <vcap_api.h>
#include <vcap_api_client.h>
#include "lan966x_regs.h"
#include "lan966x_ifh.h"
#define TABLE_UPDATE_SLEEP_US …
#define TABLE_UPDATE_TIMEOUT_US …
#define READL_SLEEP_US …
#define READL_TIMEOUT_US …
#define LAN966X_BUFFER_CELL_SZ …
#define LAN966X_BUFFER_MEMORY …
#define LAN966X_BUFFER_MIN_SZ …
#define LAN966X_HW_MTU(mtu) …
#define PGID_AGGR …
#define PGID_SRC …
#define PGID_ENTRIES …
#define UNAWARE_PVID …
#define HOST_PVID …
#define QSYS_Q_RSRV …
#define NUM_PHYS_PORTS …
#define CPU_PORT …
#define NUM_PRIO_QUEUES …
#define PGID_CPU …
#define PGID_UC …
#define PGID_BC …
#define PGID_MC …
#define PGID_MCIPV4 …
#define PGID_MCIPV6 …
#define PGID_GP_START …
#define PGID_GP_END …
#define LAN966X_SPEED_NONE …
#define LAN966X_SPEED_2500 …
#define LAN966X_SPEED_1000 …
#define LAN966X_SPEED_100 …
#define LAN966X_SPEED_10 …
#define LAN966X_PHC_COUNT …
#define LAN966X_PHC_PORT …
#define LAN966X_PHC_PINS_NUM …
#define IFH_REW_OP_NOOP …
#define IFH_REW_OP_ONE_STEP_PTP …
#define IFH_REW_OP_TWO_STEP_PTP …
#define FDMA_RX_DCB_MAX_DBS …
#define FDMA_TX_DCB_MAX_DBS …
#define FDMA_DCB_INFO_DATAL(x) …
#define FDMA_DCB_STATUS_BLOCKL(x) …
#define FDMA_DCB_STATUS_SOF …
#define FDMA_DCB_STATUS_EOF …
#define FDMA_DCB_STATUS_INTR …
#define FDMA_DCB_STATUS_DONE …
#define FDMA_DCB_STATUS_BLOCKO(x) …
#define FDMA_DCB_INVALID_DATA …
#define FDMA_XTR_CHANNEL …
#define FDMA_INJ_CHANNEL …
#define FDMA_DCB_MAX …
#define SE_IDX_QUEUE …
#define SE_IDX_PORT …
#define LAN966X_VCAP_CID_IS1_L0 …
#define LAN966X_VCAP_CID_IS1_L1 …
#define LAN966X_VCAP_CID_IS1_L2 …
#define LAN966X_VCAP_CID_IS1_MAX …
#define LAN966X_VCAP_CID_IS2_L0 …
#define LAN966X_VCAP_CID_IS2_L1 …
#define LAN966X_VCAP_CID_IS2_MAX …
#define LAN966X_VCAP_CID_ES0_L0 …
#define LAN966X_VCAP_CID_ES0_MAX …
#define LAN966X_PORT_QOS_PCP_COUNT …
#define LAN966X_PORT_QOS_DEI_COUNT …
#define LAN966X_PORT_QOS_PCP_DEI_COUNT …
#define LAN966X_PORT_QOS_DSCP_COUNT …
#define LAN966X_PORT_REW_TAG_CTRL_CLASSIFIED …
#define LAN966X_PORT_REW_TAG_CTRL_MAPPED …
#define LAN966X_PORT_REW_DSCP_FRAME …
#define LAN966X_PORT_REW_DSCP_ANALIZER …
#define LAN966X_PORT_QOS_REWR_DSCP_ALL …
enum macaccess_entry_type { … };
enum lan966x_fdma_action { … };
enum LAN966X_PORT_MASK_MODE { … };
enum vcap_is2_port_sel_ipv6 { … };
enum vcap_is1_port_sel_other { … };
enum vcap_is1_port_sel_ipv4 { … };
enum vcap_is1_port_sel_ipv6 { … };
enum vcap_is1_port_sel_rt { … };
struct lan966x_port;
struct lan966x_db { … };
struct lan966x_rx_dcb { … };
struct lan966x_tx_dcb { … };
struct lan966x_rx { … };
struct lan966x_tx_dcb_buf { … };
struct lan966x_tx { … };
struct lan966x_stat_layout { … };
struct lan966x_phc { … };
struct lan966x_skb_cb { … };
#define LAN966X_PTP_TIMEOUT …
#define LAN966X_SKB_CB(skb) …
struct lan966x { … };
struct lan966x_port_config { … };
struct lan966x_port_tc { … };
struct lan966x_port_qos_pcp { … };
struct lan966x_port_qos_dscp { … };
struct lan966x_port_qos_pcp_rewr { … };
struct lan966x_port_qos_dscp_rewr { … };
struct lan966x_port_qos { … };
struct lan966x_port { … };
extern const struct phylink_mac_ops lan966x_phylink_mac_ops;
extern const struct phylink_pcs_ops lan966x_phylink_pcs_ops;
extern const struct ethtool_ops lan966x_ethtool_ops;
extern struct notifier_block lan966x_switchdev_nb __read_mostly;
extern struct notifier_block lan966x_switchdev_blocking_nb __read_mostly;
bool lan966x_netdevice_check(const struct net_device *dev);
void lan966x_register_notifier_blocks(void);
void lan966x_unregister_notifier_blocks(void);
bool lan966x_hw_offload(struct lan966x *lan966x, u32 port, struct sk_buff *skb);
void lan966x_ifh_get_src_port(void *ifh, u64 *src_port);
void lan966x_ifh_get_timestamp(void *ifh, u64 *timestamp);
void lan966x_ifh_set_bypass(void *ifh, u64 bypass);
void lan966x_ifh_set_port(void *ifh, u64 bypass);
void lan966x_stats_get(struct net_device *dev,
struct rtnl_link_stats64 *stats);
int lan966x_stats_init(struct lan966x *lan966x);
void lan966x_port_config_down(struct lan966x_port *port);
void lan966x_port_config_up(struct lan966x_port *port);
void lan966x_port_status_get(struct lan966x_port *port,
struct phylink_link_state *state);
int lan966x_port_pcs_set(struct lan966x_port *port,
struct lan966x_port_config *config);
void lan966x_port_init(struct lan966x_port *port);
void lan966x_port_qos_set(struct lan966x_port *port,
struct lan966x_port_qos *qos);
void lan966x_port_qos_dscp_rewr_mode_set(struct lan966x_port *port,
int mode);
int lan966x_mac_ip_learn(struct lan966x *lan966x,
bool cpu_copy,
const unsigned char mac[ETH_ALEN],
unsigned int vid,
enum macaccess_entry_type type);
int lan966x_mac_learn(struct lan966x *lan966x, int port,
const unsigned char mac[ETH_ALEN],
unsigned int vid,
enum macaccess_entry_type type);
int lan966x_mac_forget(struct lan966x *lan966x,
const unsigned char mac[ETH_ALEN],
unsigned int vid,
enum macaccess_entry_type type);
int lan966x_mac_cpu_learn(struct lan966x *lan966x, const char *addr, u16 vid);
int lan966x_mac_cpu_forget(struct lan966x *lan966x, const char *addr, u16 vid);
void lan966x_mac_init(struct lan966x *lan966x);
void lan966x_mac_set_ageing(struct lan966x *lan966x,
u32 ageing);
int lan966x_mac_del_entry(struct lan966x *lan966x,
const unsigned char *addr,
u16 vid);
int lan966x_mac_add_entry(struct lan966x *lan966x,
struct lan966x_port *port,
const unsigned char *addr,
u16 vid);
void lan966x_mac_lag_replace_port_entry(struct lan966x *lan966x,
struct lan966x_port *src,
struct lan966x_port *dst);
void lan966x_mac_lag_remove_port_entry(struct lan966x *lan966x,
struct lan966x_port *src);
void lan966x_mac_purge_entries(struct lan966x *lan966x);
irqreturn_t lan966x_mac_irq_handler(struct lan966x *lan966x);
void lan966x_vlan_init(struct lan966x *lan966x);
void lan966x_vlan_port_apply(struct lan966x_port *port);
bool lan966x_vlan_cpu_member_cpu_vlan_mask(struct lan966x *lan966x, u16 vid);
void lan966x_vlan_port_set_vlan_aware(struct lan966x_port *port,
bool vlan_aware);
int lan966x_vlan_port_set_vid(struct lan966x_port *port,
u16 vid,
bool pvid,
bool untagged);
void lan966x_vlan_port_add_vlan(struct lan966x_port *port,
u16 vid,
bool pvid,
bool untagged);
void lan966x_vlan_port_del_vlan(struct lan966x_port *port, u16 vid);
void lan966x_vlan_cpu_add_vlan(struct lan966x *lan966x, u16 vid);
void lan966x_vlan_cpu_del_vlan(struct lan966x *lan966x, u16 vid);
void lan966x_fdb_write_entries(struct lan966x *lan966x, u16 vid);
void lan966x_fdb_erase_entries(struct lan966x *lan966x, u16 vid);
int lan966x_fdb_init(struct lan966x *lan966x);
void lan966x_fdb_deinit(struct lan966x *lan966x);
void lan966x_fdb_flush_workqueue(struct lan966x *lan966x);
int lan966x_handle_fdb(struct net_device *dev,
struct net_device *orig_dev,
unsigned long event, const void *ctx,
const struct switchdev_notifier_fdb_info *fdb_info);
void lan966x_mdb_init(struct lan966x *lan966x);
void lan966x_mdb_deinit(struct lan966x *lan966x);
int lan966x_handle_port_mdb_add(struct lan966x_port *port,
const struct switchdev_obj *obj);
int lan966x_handle_port_mdb_del(struct lan966x_port *port,
const struct switchdev_obj *obj);
void lan966x_mdb_erase_entries(struct lan966x *lan966x, u16 vid);
void lan966x_mdb_write_entries(struct lan966x *lan966x, u16 vid);
void lan966x_mdb_clear_entries(struct lan966x *lan966x);
void lan966x_mdb_restore_entries(struct lan966x *lan966x);
int lan966x_ptp_init(struct lan966x *lan966x);
void lan966x_ptp_deinit(struct lan966x *lan966x);
int lan966x_ptp_hwtstamp_set(struct lan966x_port *port,
struct kernel_hwtstamp_config *cfg,
struct netlink_ext_ack *extack);
void lan966x_ptp_hwtstamp_get(struct lan966x_port *port,
struct kernel_hwtstamp_config *cfg);
void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb,
u64 src_port, u64 timestamp);
int lan966x_ptp_txtstamp_request(struct lan966x_port *port,
struct sk_buff *skb);
void lan966x_ptp_txtstamp_release(struct lan966x_port *port,
struct sk_buff *skb);
irqreturn_t lan966x_ptp_irq_handler(int irq, void *args);
irqreturn_t lan966x_ptp_ext_irq_handler(int irq, void *args);
u32 lan966x_ptp_get_period_ps(void);
int lan966x_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts);
int lan966x_ptp_setup_traps(struct lan966x_port *port,
struct kernel_hwtstamp_config *cfg);
int lan966x_ptp_del_traps(struct lan966x_port *port);
int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev);
int lan966x_fdma_xmit_xdpf(struct lan966x_port *port, void *ptr, u32 len);
int lan966x_fdma_change_mtu(struct lan966x *lan966x);
void lan966x_fdma_netdev_init(struct lan966x *lan966x, struct net_device *dev);
void lan966x_fdma_netdev_deinit(struct lan966x *lan966x, struct net_device *dev);
int lan966x_fdma_init(struct lan966x *lan966x);
void lan966x_fdma_deinit(struct lan966x *lan966x);
irqreturn_t lan966x_fdma_irq_handler(int irq, void *args);
int lan966x_fdma_reload_page_pool(struct lan966x *lan966x);
int lan966x_lag_port_join(struct lan966x_port *port,
struct net_device *brport_dev,
struct net_device *bond,
struct netlink_ext_ack *extack);
void lan966x_lag_port_leave(struct lan966x_port *port, struct net_device *bond);
int lan966x_lag_port_prechangeupper(struct net_device *dev,
struct netdev_notifier_changeupper_info *info);
int lan966x_lag_port_changelowerstate(struct net_device *dev,
struct netdev_notifier_changelowerstate_info *info);
int lan966x_lag_netdev_prechangeupper(struct net_device *dev,
struct netdev_notifier_changeupper_info *info);
int lan966x_lag_netdev_changeupper(struct net_device *dev,
struct netdev_notifier_changeupper_info *info);
bool lan966x_lag_first_port(struct net_device *lag, struct net_device *dev);
u32 lan966x_lag_get_mask(struct lan966x *lan966x, struct net_device *bond);
int lan966x_port_changeupper(struct net_device *dev,
struct net_device *brport_dev,
struct netdev_notifier_changeupper_info *info);
int lan966x_port_prechangeupper(struct net_device *dev,
struct net_device *brport_dev,
struct netdev_notifier_changeupper_info *info);
void lan966x_port_stp_state_set(struct lan966x_port *port, u8 state);
void lan966x_port_ageing_set(struct lan966x_port *port,
unsigned long ageing_clock_t);
void lan966x_update_fwd_mask(struct lan966x *lan966x);
int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type,
void *type_data);
int lan966x_mqprio_add(struct lan966x_port *port, u8 num_tc);
int lan966x_mqprio_del(struct lan966x_port *port);
void lan966x_taprio_init(struct lan966x *lan966x);
void lan966x_taprio_deinit(struct lan966x *lan966x);
int lan966x_taprio_add(struct lan966x_port *port,
struct tc_taprio_qopt_offload *qopt);
int lan966x_taprio_del(struct lan966x_port *port);
int lan966x_taprio_speed_set(struct lan966x_port *port, int speed);
int lan966x_tbf_add(struct lan966x_port *port,
struct tc_tbf_qopt_offload *qopt);
int lan966x_tbf_del(struct lan966x_port *port,
struct tc_tbf_qopt_offload *qopt);
int lan966x_cbs_add(struct lan966x_port *port,
struct tc_cbs_qopt_offload *qopt);
int lan966x_cbs_del(struct lan966x_port *port,
struct tc_cbs_qopt_offload *qopt);
int lan966x_ets_add(struct lan966x_port *port,
struct tc_ets_qopt_offload *qopt);
int lan966x_ets_del(struct lan966x_port *port,
struct tc_ets_qopt_offload *qopt);
int lan966x_tc_matchall(struct lan966x_port *port,
struct tc_cls_matchall_offload *f,
bool ingress);
int lan966x_police_port_add(struct lan966x_port *port,
struct flow_action *action,
struct flow_action_entry *act,
unsigned long police_id,
bool ingress,
struct netlink_ext_ack *extack);
int lan966x_police_port_del(struct lan966x_port *port,
unsigned long police_id,
struct netlink_ext_ack *extack);
void lan966x_police_port_stats(struct lan966x_port *port,
struct flow_stats *stats);
int lan966x_mirror_port_add(struct lan966x_port *port,
struct flow_action_entry *action,
unsigned long mirror_id,
bool ingress,
struct netlink_ext_ack *extack);
int lan966x_mirror_port_del(struct lan966x_port *port,
bool ingress,
struct netlink_ext_ack *extack);
void lan966x_mirror_port_stats(struct lan966x_port *port,
struct flow_stats *stats,
bool ingress);
int lan966x_xdp_port_init(struct lan966x_port *port);
void lan966x_xdp_port_deinit(struct lan966x_port *port);
int lan966x_xdp(struct net_device *dev, struct netdev_bpf *xdp);
int lan966x_xdp_run(struct lan966x_port *port,
struct page *page,
u32 data_len);
int lan966x_xdp_xmit(struct net_device *dev,
int n,
struct xdp_frame **frames,
u32 flags);
bool lan966x_xdp_present(struct lan966x *lan966x);
static inline bool lan966x_xdp_port_present(struct lan966x_port *port)
{ … }
int lan966x_vcap_init(struct lan966x *lan966x);
void lan966x_vcap_deinit(struct lan966x *lan966x);
#if defined(CONFIG_DEBUG_FS)
int lan966x_vcap_port_info(struct net_device *dev,
struct vcap_admin *admin,
struct vcap_output_print *out);
#else
static inline int lan966x_vcap_port_info(struct net_device *dev,
struct vcap_admin *admin,
struct vcap_output_print *out)
{
return 0;
}
#endif
int lan966x_tc_flower(struct lan966x_port *port,
struct flow_cls_offload *f,
bool ingress);
int lan966x_goto_port_add(struct lan966x_port *port,
int from_cid, int to_cid,
unsigned long goto_id,
struct netlink_ext_ack *extack);
int lan966x_goto_port_del(struct lan966x_port *port,
unsigned long goto_id,
struct netlink_ext_ack *extack);
#ifdef CONFIG_LAN966X_DCB
void lan966x_dcb_init(struct lan966x *lan966x);
#else
static inline void lan966x_dcb_init(struct lan966x *lan966x)
{
}
#endif
static inline void __iomem *lan_addr(void __iomem *base[],
int id, int tinst, int tcnt,
int gbase, int ginst,
int gcnt, int gwidth,
int raddr, int rinst,
int rcnt, int rwidth)
{ … }
static inline u32 lan_rd(struct lan966x *lan966x, int id, int tinst, int tcnt,
int gbase, int ginst, int gcnt, int gwidth,
int raddr, int rinst, int rcnt, int rwidth)
{ … }
static inline void lan_wr(u32 val, struct lan966x *lan966x,
int id, int tinst, int tcnt,
int gbase, int ginst, int gcnt, int gwidth,
int raddr, int rinst, int rcnt, int rwidth)
{ … }
static inline void lan_rmw(u32 val, u32 mask, struct lan966x *lan966x,
int id, int tinst, int tcnt,
int gbase, int ginst, int gcnt, int gwidth,
int raddr, int rinst, int rcnt, int rwidth)
{ … }
#endif