162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _MLXSW_SPECTRUM_H 562306a36Sopenharmony_ci#define _MLXSW_SPECTRUM_H 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/ethtool.h> 862306a36Sopenharmony_ci#include <linux/types.h> 962306a36Sopenharmony_ci#include <linux/netdevice.h> 1062306a36Sopenharmony_ci#include <linux/rhashtable.h> 1162306a36Sopenharmony_ci#include <linux/bitops.h> 1262306a36Sopenharmony_ci#include <linux/if_bridge.h> 1362306a36Sopenharmony_ci#include <linux/if_vlan.h> 1462306a36Sopenharmony_ci#include <linux/list.h> 1562306a36Sopenharmony_ci#include <linux/dcbnl.h> 1662306a36Sopenharmony_ci#include <linux/in6.h> 1762306a36Sopenharmony_ci#include <linux/notifier.h> 1862306a36Sopenharmony_ci#include <linux/net_namespace.h> 1962306a36Sopenharmony_ci#include <linux/spinlock.h> 2062306a36Sopenharmony_ci#include <net/psample.h> 2162306a36Sopenharmony_ci#include <net/pkt_cls.h> 2262306a36Sopenharmony_ci#include <net/red.h> 2362306a36Sopenharmony_ci#include <net/vxlan.h> 2462306a36Sopenharmony_ci#include <net/flow_offload.h> 2562306a36Sopenharmony_ci#include <net/inet_ecn.h> 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#include "port.h" 2862306a36Sopenharmony_ci#include "core.h" 2962306a36Sopenharmony_ci#include "core_acl_flex_keys.h" 3062306a36Sopenharmony_ci#include "core_acl_flex_actions.h" 3162306a36Sopenharmony_ci#include "reg.h" 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define MLXSW_SP_FID_8021D_MAX 1024 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#define MLXSW_SP_MID_MAX 7000 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */ 4062306a36Sopenharmony_ci#define MLXSW_SP_KVD_GRANULARITY 128 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD "kvd" 4362306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR "linear" 4462306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_HASH_SINGLE "hash_single" 4562306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_HASH_DOUBLE "hash_double" 4662306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_SINGLES "singles" 4762306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_CHUNKS "chunks" 4862306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_LARGE_CHUNKS "large_chunks" 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_SPAN "span_agents" 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_COUNTERS "counters" 5362306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_COUNTERS_FLOW "flow" 5462306a36Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_COUNTERS_RIF "rif" 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_cienum mlxsw_sp_resource_id { 5762306a36Sopenharmony_ci MLXSW_SP_RESOURCE_KVD = MLXSW_CORE_RESOURCE_MAX, 5862306a36Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_LINEAR, 5962306a36Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_HASH_SINGLE, 6062306a36Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE, 6162306a36Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE, 6262306a36Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS, 6362306a36Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS, 6462306a36Sopenharmony_ci MLXSW_SP_RESOURCE_SPAN, 6562306a36Sopenharmony_ci MLXSW_SP_RESOURCE_COUNTERS, 6662306a36Sopenharmony_ci MLXSW_SP_RESOURCE_COUNTERS_FLOW, 6762306a36Sopenharmony_ci MLXSW_SP_RESOURCE_COUNTERS_RIF, 6862306a36Sopenharmony_ci MLXSW_SP_RESOURCE_GLOBAL_POLICERS, 6962306a36Sopenharmony_ci MLXSW_SP_RESOURCE_SINGLE_RATE_POLICERS, 7062306a36Sopenharmony_ci MLXSW_SP_RESOURCE_RIF_MAC_PROFILES, 7162306a36Sopenharmony_ci MLXSW_SP_RESOURCE_RIFS, 7262306a36Sopenharmony_ci MLXSW_SP_RESOURCE_PORT_RANGE_REGISTERS, 7362306a36Sopenharmony_ci}; 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_cistruct mlxsw_sp_port; 7662306a36Sopenharmony_cistruct mlxsw_sp_rif; 7762306a36Sopenharmony_cistruct mlxsw_sp_span_entry; 7862306a36Sopenharmony_cienum mlxsw_sp_l3proto; 7962306a36Sopenharmony_ciunion mlxsw_sp_l3addr; 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_cistruct mlxsw_sp_upper { 8262306a36Sopenharmony_ci struct net_device *dev; 8362306a36Sopenharmony_ci unsigned int ref_count; 8462306a36Sopenharmony_ci}; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_cienum mlxsw_sp_rif_type { 8762306a36Sopenharmony_ci MLXSW_SP_RIF_TYPE_SUBPORT, 8862306a36Sopenharmony_ci MLXSW_SP_RIF_TYPE_VLAN, 8962306a36Sopenharmony_ci MLXSW_SP_RIF_TYPE_FID, 9062306a36Sopenharmony_ci MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */ 9162306a36Sopenharmony_ci MLXSW_SP_RIF_TYPE_MAX, 9262306a36Sopenharmony_ci}; 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_cistruct mlxsw_sp_router_ops; 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ciextern const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops; 9762306a36Sopenharmony_ciextern const struct mlxsw_sp_router_ops mlxsw_sp2_router_ops; 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_cistruct mlxsw_sp_switchdev_ops; 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ciextern const struct mlxsw_sp_switchdev_ops mlxsw_sp1_switchdev_ops; 10262306a36Sopenharmony_ciextern const struct mlxsw_sp_switchdev_ops mlxsw_sp2_switchdev_ops; 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_cienum mlxsw_sp_fid_type { 10562306a36Sopenharmony_ci MLXSW_SP_FID_TYPE_8021Q, 10662306a36Sopenharmony_ci MLXSW_SP_FID_TYPE_8021D, 10762306a36Sopenharmony_ci MLXSW_SP_FID_TYPE_RFID, 10862306a36Sopenharmony_ci MLXSW_SP_FID_TYPE_DUMMY, 10962306a36Sopenharmony_ci MLXSW_SP_FID_TYPE_MAX, 11062306a36Sopenharmony_ci}; 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_cienum mlxsw_sp_nve_type { 11362306a36Sopenharmony_ci MLXSW_SP_NVE_TYPE_VXLAN, 11462306a36Sopenharmony_ci}; 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_cistruct mlxsw_sp_sb; 11762306a36Sopenharmony_cistruct mlxsw_sp_bridge; 11862306a36Sopenharmony_cistruct mlxsw_sp_router; 11962306a36Sopenharmony_cistruct mlxsw_sp_mr; 12062306a36Sopenharmony_cistruct mlxsw_sp_acl; 12162306a36Sopenharmony_cistruct mlxsw_sp_counter_pool; 12262306a36Sopenharmony_cistruct mlxsw_sp_fid_core; 12362306a36Sopenharmony_cistruct mlxsw_sp_kvdl; 12462306a36Sopenharmony_cistruct mlxsw_sp_nve; 12562306a36Sopenharmony_cistruct mlxsw_sp_kvdl_ops; 12662306a36Sopenharmony_cistruct mlxsw_sp_mr_tcam_ops; 12762306a36Sopenharmony_cistruct mlxsw_sp_acl_rulei_ops; 12862306a36Sopenharmony_cistruct mlxsw_sp_acl_tcam_ops; 12962306a36Sopenharmony_cistruct mlxsw_sp_nve_ops; 13062306a36Sopenharmony_cistruct mlxsw_sp_sb_ops; 13162306a36Sopenharmony_cistruct mlxsw_sp_sb_vals; 13262306a36Sopenharmony_cistruct mlxsw_sp_port_type_speed_ops; 13362306a36Sopenharmony_cistruct mlxsw_sp_ptp_state; 13462306a36Sopenharmony_cistruct mlxsw_sp_ptp_ops; 13562306a36Sopenharmony_cistruct mlxsw_sp_span_ops; 13662306a36Sopenharmony_cistruct mlxsw_sp_qdisc_state; 13762306a36Sopenharmony_cistruct mlxsw_sp_mall_entry; 13862306a36Sopenharmony_cistruct mlxsw_sp_pgt; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_cistruct mlxsw_sp_port_mapping { 14162306a36Sopenharmony_ci u8 module; 14262306a36Sopenharmony_ci u8 slot_index; 14362306a36Sopenharmony_ci u8 width; /* Number of lanes used by the port */ 14462306a36Sopenharmony_ci u8 module_width; /* Number of lanes in the module (static) */ 14562306a36Sopenharmony_ci u8 lane; 14662306a36Sopenharmony_ci}; 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_cistruct mlxsw_sp_port_mapping_events { 14962306a36Sopenharmony_ci struct list_head queue; 15062306a36Sopenharmony_ci spinlock_t queue_lock; /* protects queue */ 15162306a36Sopenharmony_ci struct work_struct work; 15262306a36Sopenharmony_ci}; 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_cistruct mlxsw_sp_parsing { 15562306a36Sopenharmony_ci refcount_t parsing_depth_ref; 15662306a36Sopenharmony_ci u16 parsing_depth; 15762306a36Sopenharmony_ci u16 vxlan_udp_dport; 15862306a36Sopenharmony_ci struct mutex lock; /* Protects parsing configuration */ 15962306a36Sopenharmony_ci}; 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_cistruct mlxsw_sp { 16262306a36Sopenharmony_ci struct mlxsw_sp_port **ports; 16362306a36Sopenharmony_ci struct mlxsw_core *core; 16462306a36Sopenharmony_ci const struct mlxsw_bus_info *bus_info; 16562306a36Sopenharmony_ci unsigned char base_mac[ETH_ALEN]; 16662306a36Sopenharmony_ci const unsigned char *mac_mask; 16762306a36Sopenharmony_ci struct mlxsw_sp_upper *lags; 16862306a36Sopenharmony_ci struct mlxsw_sp_port_mapping *port_mapping; 16962306a36Sopenharmony_ci struct mlxsw_sp_port_mapping_events port_mapping_events; 17062306a36Sopenharmony_ci struct rhashtable sample_trigger_ht; 17162306a36Sopenharmony_ci struct mlxsw_sp_sb *sb; 17262306a36Sopenharmony_ci struct mlxsw_sp_bridge *bridge; 17362306a36Sopenharmony_ci struct mlxsw_sp_router *router; 17462306a36Sopenharmony_ci struct mlxsw_sp_mr *mr; 17562306a36Sopenharmony_ci struct mlxsw_afa *afa; 17662306a36Sopenharmony_ci struct mlxsw_sp_acl *acl; 17762306a36Sopenharmony_ci struct mlxsw_sp_fid_core *fid_core; 17862306a36Sopenharmony_ci struct mlxsw_sp_policer_core *policer_core; 17962306a36Sopenharmony_ci struct mlxsw_sp_port_range_core *pr_core; 18062306a36Sopenharmony_ci struct mlxsw_sp_kvdl *kvdl; 18162306a36Sopenharmony_ci struct mlxsw_sp_nve *nve; 18262306a36Sopenharmony_ci struct notifier_block netdevice_nb; 18362306a36Sopenharmony_ci struct mlxsw_sp_ptp_clock *clock; 18462306a36Sopenharmony_ci struct mlxsw_sp_ptp_state *ptp_state; 18562306a36Sopenharmony_ci struct mlxsw_sp_counter_pool *counter_pool; 18662306a36Sopenharmony_ci struct mlxsw_sp_span *span; 18762306a36Sopenharmony_ci struct mlxsw_sp_trap *trap; 18862306a36Sopenharmony_ci struct mlxsw_sp_parsing parsing; 18962306a36Sopenharmony_ci const struct mlxsw_sp_switchdev_ops *switchdev_ops; 19062306a36Sopenharmony_ci const struct mlxsw_sp_kvdl_ops *kvdl_ops; 19162306a36Sopenharmony_ci const struct mlxsw_afa_ops *afa_ops; 19262306a36Sopenharmony_ci const struct mlxsw_afk_ops *afk_ops; 19362306a36Sopenharmony_ci const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops; 19462306a36Sopenharmony_ci const struct mlxsw_sp_acl_rulei_ops *acl_rulei_ops; 19562306a36Sopenharmony_ci const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops; 19662306a36Sopenharmony_ci const struct mlxsw_sp_acl_bf_ops *acl_bf_ops; 19762306a36Sopenharmony_ci const struct mlxsw_sp_nve_ops **nve_ops_arr; 19862306a36Sopenharmony_ci const struct mlxsw_sp_sb_vals *sb_vals; 19962306a36Sopenharmony_ci const struct mlxsw_sp_sb_ops *sb_ops; 20062306a36Sopenharmony_ci const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops; 20162306a36Sopenharmony_ci const struct mlxsw_sp_ptp_ops *ptp_ops; 20262306a36Sopenharmony_ci const struct mlxsw_sp_span_ops *span_ops; 20362306a36Sopenharmony_ci const struct mlxsw_sp_policer_core_ops *policer_core_ops; 20462306a36Sopenharmony_ci const struct mlxsw_sp_trap_ops *trap_ops; 20562306a36Sopenharmony_ci const struct mlxsw_sp_mall_ops *mall_ops; 20662306a36Sopenharmony_ci const struct mlxsw_sp_router_ops *router_ops; 20762306a36Sopenharmony_ci const struct mlxsw_listener *listeners; 20862306a36Sopenharmony_ci const struct mlxsw_sp_fid_family **fid_family_arr; 20962306a36Sopenharmony_ci size_t listeners_count; 21062306a36Sopenharmony_ci u32 lowest_shaper_bs; 21162306a36Sopenharmony_ci struct rhashtable ipv6_addr_ht; 21262306a36Sopenharmony_ci struct mutex ipv6_addr_ht_lock; /* Protects ipv6_addr_ht */ 21362306a36Sopenharmony_ci struct mlxsw_sp_pgt *pgt; 21462306a36Sopenharmony_ci bool pgt_smpe_index_valid; 21562306a36Sopenharmony_ci}; 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_cistruct mlxsw_sp_ptp_ops { 21862306a36Sopenharmony_ci struct mlxsw_sp_ptp_clock * 21962306a36Sopenharmony_ci (*clock_init)(struct mlxsw_sp *mlxsw_sp, struct device *dev); 22062306a36Sopenharmony_ci void (*clock_fini)(struct mlxsw_sp_ptp_clock *clock); 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci struct mlxsw_sp_ptp_state *(*init)(struct mlxsw_sp *mlxsw_sp); 22362306a36Sopenharmony_ci void (*fini)(struct mlxsw_sp_ptp_state *ptp_state); 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci /* Notify a driver that a packet that might be PTP was received. Driver 22662306a36Sopenharmony_ci * is responsible for freeing the passed-in SKB. 22762306a36Sopenharmony_ci */ 22862306a36Sopenharmony_ci void (*receive)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 22962306a36Sopenharmony_ci u16 local_port); 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci /* Notify a driver that a timestamped packet was transmitted. Driver 23262306a36Sopenharmony_ci * is responsible for freeing the passed-in SKB. 23362306a36Sopenharmony_ci */ 23462306a36Sopenharmony_ci void (*transmitted)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 23562306a36Sopenharmony_ci u16 local_port); 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci int (*hwtstamp_get)(struct mlxsw_sp_port *mlxsw_sp_port, 23862306a36Sopenharmony_ci struct hwtstamp_config *config); 23962306a36Sopenharmony_ci int (*hwtstamp_set)(struct mlxsw_sp_port *mlxsw_sp_port, 24062306a36Sopenharmony_ci struct hwtstamp_config *config); 24162306a36Sopenharmony_ci void (*shaper_work)(struct work_struct *work); 24262306a36Sopenharmony_ci int (*get_ts_info)(struct mlxsw_sp *mlxsw_sp, 24362306a36Sopenharmony_ci struct ethtool_ts_info *info); 24462306a36Sopenharmony_ci int (*get_stats_count)(void); 24562306a36Sopenharmony_ci void (*get_stats_strings)(u8 **p); 24662306a36Sopenharmony_ci void (*get_stats)(struct mlxsw_sp_port *mlxsw_sp_port, 24762306a36Sopenharmony_ci u64 *data, int data_index); 24862306a36Sopenharmony_ci int (*txhdr_construct)(struct mlxsw_core *mlxsw_core, 24962306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, 25062306a36Sopenharmony_ci struct sk_buff *skb, 25162306a36Sopenharmony_ci const struct mlxsw_tx_info *tx_info); 25262306a36Sopenharmony_ci}; 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_cistatic inline struct mlxsw_sp_upper * 25562306a36Sopenharmony_cimlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id) 25662306a36Sopenharmony_ci{ 25762306a36Sopenharmony_ci return &mlxsw_sp->lags[lag_id]; 25862306a36Sopenharmony_ci} 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_cistruct mlxsw_sp_port_pcpu_stats { 26162306a36Sopenharmony_ci u64 rx_packets; 26262306a36Sopenharmony_ci u64 rx_bytes; 26362306a36Sopenharmony_ci u64 tx_packets; 26462306a36Sopenharmony_ci u64 tx_bytes; 26562306a36Sopenharmony_ci struct u64_stats_sync syncp; 26662306a36Sopenharmony_ci u32 tx_dropped; 26762306a36Sopenharmony_ci}; 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_cienum mlxsw_sp_sample_trigger_type { 27062306a36Sopenharmony_ci MLXSW_SP_SAMPLE_TRIGGER_TYPE_INGRESS, 27162306a36Sopenharmony_ci MLXSW_SP_SAMPLE_TRIGGER_TYPE_EGRESS, 27262306a36Sopenharmony_ci MLXSW_SP_SAMPLE_TRIGGER_TYPE_POLICY_ENGINE, 27362306a36Sopenharmony_ci}; 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_cistruct mlxsw_sp_sample_trigger { 27662306a36Sopenharmony_ci enum mlxsw_sp_sample_trigger_type type; 27762306a36Sopenharmony_ci u16 local_port; /* Reserved when trigger type is not ingress / egress. */ 27862306a36Sopenharmony_ci}; 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_cistruct mlxsw_sp_sample_params { 28162306a36Sopenharmony_ci struct psample_group *psample_group; 28262306a36Sopenharmony_ci u32 trunc_size; 28362306a36Sopenharmony_ci u32 rate; 28462306a36Sopenharmony_ci bool truncate; 28562306a36Sopenharmony_ci}; 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_cistruct mlxsw_sp_bridge_port; 28862306a36Sopenharmony_cistruct mlxsw_sp_fid; 28962306a36Sopenharmony_ci 29062306a36Sopenharmony_cistruct mlxsw_sp_port_vlan { 29162306a36Sopenharmony_ci struct list_head list; 29262306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port; 29362306a36Sopenharmony_ci struct mlxsw_sp_fid *fid; 29462306a36Sopenharmony_ci u16 vid; 29562306a36Sopenharmony_ci struct mlxsw_sp_bridge_port *bridge_port; 29662306a36Sopenharmony_ci struct list_head bridge_vlan_node; 29762306a36Sopenharmony_ci}; 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ci/* No need an internal lock; At worse - miss a single periodic iteration */ 30062306a36Sopenharmony_cistruct mlxsw_sp_port_xstats { 30162306a36Sopenharmony_ci u64 ecn; 30262306a36Sopenharmony_ci u64 tc_ecn[TC_MAX_QUEUE]; 30362306a36Sopenharmony_ci u64 wred_drop[TC_MAX_QUEUE]; 30462306a36Sopenharmony_ci u64 tail_drop[TC_MAX_QUEUE]; 30562306a36Sopenharmony_ci u64 backlog[TC_MAX_QUEUE]; 30662306a36Sopenharmony_ci u64 tx_bytes[IEEE_8021QAZ_MAX_TCS]; 30762306a36Sopenharmony_ci u64 tx_packets[IEEE_8021QAZ_MAX_TCS]; 30862306a36Sopenharmony_ci}; 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_cistruct mlxsw_sp_ptp_port_dir_stats { 31162306a36Sopenharmony_ci u64 packets; 31262306a36Sopenharmony_ci u64 timestamps; 31362306a36Sopenharmony_ci}; 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_cistruct mlxsw_sp_ptp_port_stats { 31662306a36Sopenharmony_ci struct mlxsw_sp_ptp_port_dir_stats rx_gcd; 31762306a36Sopenharmony_ci struct mlxsw_sp_ptp_port_dir_stats tx_gcd; 31862306a36Sopenharmony_ci}; 31962306a36Sopenharmony_ci 32062306a36Sopenharmony_cistruct mlxsw_sp_port { 32162306a36Sopenharmony_ci struct net_device *dev; 32262306a36Sopenharmony_ci struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats; 32362306a36Sopenharmony_ci struct mlxsw_sp *mlxsw_sp; 32462306a36Sopenharmony_ci u16 local_port; 32562306a36Sopenharmony_ci u8 lagged:1, 32662306a36Sopenharmony_ci split:1, 32762306a36Sopenharmony_ci security:1; 32862306a36Sopenharmony_ci u16 pvid; 32962306a36Sopenharmony_ci u16 lag_id; 33062306a36Sopenharmony_ci struct { 33162306a36Sopenharmony_ci u8 tx_pause:1, 33262306a36Sopenharmony_ci rx_pause:1, 33362306a36Sopenharmony_ci autoneg:1; 33462306a36Sopenharmony_ci } link; 33562306a36Sopenharmony_ci struct { 33662306a36Sopenharmony_ci struct ieee_ets *ets; 33762306a36Sopenharmony_ci struct ieee_maxrate *maxrate; 33862306a36Sopenharmony_ci struct ieee_pfc *pfc; 33962306a36Sopenharmony_ci enum mlxsw_reg_qpts_trust_state trust_state; 34062306a36Sopenharmony_ci } dcb; 34162306a36Sopenharmony_ci struct mlxsw_sp_port_mapping mapping; /* mapping is constant during the 34262306a36Sopenharmony_ci * mlxsw_sp_port lifetime, however 34362306a36Sopenharmony_ci * the same localport can have 34462306a36Sopenharmony_ci * different mapping. 34562306a36Sopenharmony_ci */ 34662306a36Sopenharmony_ci struct { 34762306a36Sopenharmony_ci #define MLXSW_HW_STATS_UPDATE_TIME HZ 34862306a36Sopenharmony_ci struct rtnl_link_stats64 stats; 34962306a36Sopenharmony_ci struct mlxsw_sp_port_xstats xstats; 35062306a36Sopenharmony_ci struct delayed_work update_dw; 35162306a36Sopenharmony_ci } periodic_hw_stats; 35262306a36Sopenharmony_ci struct list_head vlans_list; 35362306a36Sopenharmony_ci struct mlxsw_sp_port_vlan *default_vlan; 35462306a36Sopenharmony_ci struct mlxsw_sp_qdisc_state *qdisc; 35562306a36Sopenharmony_ci unsigned acl_rule_count; 35662306a36Sopenharmony_ci struct mlxsw_sp_flow_block *ing_flow_block; 35762306a36Sopenharmony_ci struct mlxsw_sp_flow_block *eg_flow_block; 35862306a36Sopenharmony_ci struct { 35962306a36Sopenharmony_ci struct delayed_work shaper_dw; 36062306a36Sopenharmony_ci struct hwtstamp_config hwtstamp_config; 36162306a36Sopenharmony_ci u16 ing_types; 36262306a36Sopenharmony_ci u16 egr_types; 36362306a36Sopenharmony_ci struct mlxsw_sp_ptp_port_stats stats; 36462306a36Sopenharmony_ci } ptp; 36562306a36Sopenharmony_ci int max_mtu; 36662306a36Sopenharmony_ci u32 max_speed; 36762306a36Sopenharmony_ci struct mlxsw_sp_hdroom *hdroom; 36862306a36Sopenharmony_ci u64 module_overheat_initial_val; 36962306a36Sopenharmony_ci}; 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_cistruct mlxsw_sp_port_type_speed_ops { 37262306a36Sopenharmony_ci void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp, 37362306a36Sopenharmony_ci u32 ptys_eth_proto, 37462306a36Sopenharmony_ci struct ethtool_link_ksettings *cmd); 37562306a36Sopenharmony_ci void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto, 37662306a36Sopenharmony_ci unsigned long *mode); 37762306a36Sopenharmony_ci u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto); 37862306a36Sopenharmony_ci void (*from_ptys_link_mode)(struct mlxsw_sp *mlxsw_sp, 37962306a36Sopenharmony_ci bool carrier_ok, u32 ptys_eth_proto, 38062306a36Sopenharmony_ci struct ethtool_link_ksettings *cmd); 38162306a36Sopenharmony_ci int (*ptys_max_speed)(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed); 38262306a36Sopenharmony_ci u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp, 38362306a36Sopenharmony_ci const struct ethtool_link_ksettings *cmd); 38462306a36Sopenharmony_ci u32 (*to_ptys_speed_lanes)(struct mlxsw_sp *mlxsw_sp, u8 width, 38562306a36Sopenharmony_ci const struct ethtool_link_ksettings *cmd); 38662306a36Sopenharmony_ci void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload, 38762306a36Sopenharmony_ci u16 local_port, u32 proto_admin, bool autoneg); 38862306a36Sopenharmony_ci void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload, 38962306a36Sopenharmony_ci u32 *p_eth_proto_cap, 39062306a36Sopenharmony_ci u32 *p_eth_proto_admin, 39162306a36Sopenharmony_ci u32 *p_eth_proto_oper); 39262306a36Sopenharmony_ci u32 (*ptys_proto_cap_masked_get)(u32 eth_proto_cap); 39362306a36Sopenharmony_ci}; 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_cistruct mlxsw_sp_ports_bitmap { 39662306a36Sopenharmony_ci unsigned long *bitmap; 39762306a36Sopenharmony_ci unsigned int nbits; 39862306a36Sopenharmony_ci}; 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_cistatic inline int 40162306a36Sopenharmony_cimlxsw_sp_port_bitmap_init(struct mlxsw_sp *mlxsw_sp, 40262306a36Sopenharmony_ci struct mlxsw_sp_ports_bitmap *ports_bm) 40362306a36Sopenharmony_ci{ 40462306a36Sopenharmony_ci unsigned int nbits = mlxsw_core_max_ports(mlxsw_sp->core); 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ci ports_bm->nbits = nbits; 40762306a36Sopenharmony_ci ports_bm->bitmap = bitmap_zalloc(nbits, GFP_KERNEL); 40862306a36Sopenharmony_ci if (!ports_bm->bitmap) 40962306a36Sopenharmony_ci return -ENOMEM; 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci return 0; 41262306a36Sopenharmony_ci} 41362306a36Sopenharmony_ci 41462306a36Sopenharmony_cistatic inline void 41562306a36Sopenharmony_cimlxsw_sp_port_bitmap_fini(struct mlxsw_sp_ports_bitmap *ports_bm) 41662306a36Sopenharmony_ci{ 41762306a36Sopenharmony_ci bitmap_free(ports_bm->bitmap); 41862306a36Sopenharmony_ci} 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_cistatic inline u8 mlxsw_sp_tunnel_ecn_decap(u8 outer_ecn, u8 inner_ecn, 42162306a36Sopenharmony_ci bool *trap_en) 42262306a36Sopenharmony_ci{ 42362306a36Sopenharmony_ci bool set_ce = false; 42462306a36Sopenharmony_ci 42562306a36Sopenharmony_ci *trap_en = !!__INET_ECN_decapsulate(outer_ecn, inner_ecn, &set_ce); 42662306a36Sopenharmony_ci if (set_ce) 42762306a36Sopenharmony_ci return INET_ECN_CE; 42862306a36Sopenharmony_ci else if (outer_ecn == INET_ECN_ECT_1 && inner_ecn == INET_ECN_ECT_0) 42962306a36Sopenharmony_ci return INET_ECN_ECT_1; 43062306a36Sopenharmony_ci else 43162306a36Sopenharmony_ci return inner_ecn; 43262306a36Sopenharmony_ci} 43362306a36Sopenharmony_ci 43462306a36Sopenharmony_cistatic inline struct net_device * 43562306a36Sopenharmony_cimlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev) 43662306a36Sopenharmony_ci{ 43762306a36Sopenharmony_ci struct net_device *dev; 43862306a36Sopenharmony_ci struct list_head *iter; 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ci netdev_for_each_lower_dev(br_dev, dev, iter) { 44162306a36Sopenharmony_ci if (netif_is_vxlan(dev)) 44262306a36Sopenharmony_ci return dev; 44362306a36Sopenharmony_ci } 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci return NULL; 44662306a36Sopenharmony_ci} 44762306a36Sopenharmony_ci 44862306a36Sopenharmony_cistatic inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev) 44962306a36Sopenharmony_ci{ 45062306a36Sopenharmony_ci return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev); 45162306a36Sopenharmony_ci} 45262306a36Sopenharmony_ci 45362306a36Sopenharmony_cistatic inline int 45462306a36Sopenharmony_cimlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid) 45562306a36Sopenharmony_ci{ 45662306a36Sopenharmony_ci struct bridge_vlan_info vinfo; 45762306a36Sopenharmony_ci u16 vid = 0; 45862306a36Sopenharmony_ci int err; 45962306a36Sopenharmony_ci 46062306a36Sopenharmony_ci err = br_vlan_get_pvid(vxlan_dev, &vid); 46162306a36Sopenharmony_ci if (err || !vid) 46262306a36Sopenharmony_ci goto out; 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci err = br_vlan_get_info(vxlan_dev, vid, &vinfo); 46562306a36Sopenharmony_ci if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED)) 46662306a36Sopenharmony_ci vid = 0; 46762306a36Sopenharmony_ci 46862306a36Sopenharmony_ciout: 46962306a36Sopenharmony_ci *p_vid = vid; 47062306a36Sopenharmony_ci return err; 47162306a36Sopenharmony_ci} 47262306a36Sopenharmony_ci 47362306a36Sopenharmony_cistatic inline bool 47462306a36Sopenharmony_cimlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) 47562306a36Sopenharmony_ci{ 47662306a36Sopenharmony_ci return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause; 47762306a36Sopenharmony_ci} 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_cistatic inline struct mlxsw_sp_port * 48062306a36Sopenharmony_cimlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index) 48162306a36Sopenharmony_ci{ 48262306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port; 48362306a36Sopenharmony_ci u16 local_port; 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_ci local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core, 48662306a36Sopenharmony_ci lag_id, port_index); 48762306a36Sopenharmony_ci mlxsw_sp_port = mlxsw_sp->ports[local_port]; 48862306a36Sopenharmony_ci return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL; 48962306a36Sopenharmony_ci} 49062306a36Sopenharmony_ci 49162306a36Sopenharmony_cistatic inline struct mlxsw_sp_port_vlan * 49262306a36Sopenharmony_cimlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port, 49362306a36Sopenharmony_ci u16 vid) 49462306a36Sopenharmony_ci{ 49562306a36Sopenharmony_ci struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list, 49862306a36Sopenharmony_ci list) { 49962306a36Sopenharmony_ci if (mlxsw_sp_port_vlan->vid == vid) 50062306a36Sopenharmony_ci return mlxsw_sp_port_vlan; 50162306a36Sopenharmony_ci } 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ci return NULL; 50462306a36Sopenharmony_ci} 50562306a36Sopenharmony_ci 50662306a36Sopenharmony_cienum mlxsw_sp_flood_type { 50762306a36Sopenharmony_ci MLXSW_SP_FLOOD_TYPE_UC, 50862306a36Sopenharmony_ci MLXSW_SP_FLOOD_TYPE_BC, 50962306a36Sopenharmony_ci MLXSW_SP_FLOOD_TYPE_MC, 51062306a36Sopenharmony_ci}; 51162306a36Sopenharmony_ci 51262306a36Sopenharmony_ciint mlxsw_sp_port_get_stats_raw(struct net_device *dev, int grp, 51362306a36Sopenharmony_ci int prio, char *ppcnt_pl); 51462306a36Sopenharmony_ciint mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port, 51562306a36Sopenharmony_ci bool is_up); 51662306a36Sopenharmony_ciint 51762306a36Sopenharmony_cimlxsw_sp_port_vlan_classification_set(struct mlxsw_sp_port *mlxsw_sp_port, 51862306a36Sopenharmony_ci bool is_8021ad_tagged, 51962306a36Sopenharmony_ci bool is_8021q_tagged); 52062306a36Sopenharmony_cistatic inline bool 52162306a36Sopenharmony_cimlxsw_sp_local_port_is_valid(struct mlxsw_sp *mlxsw_sp, u16 local_port) 52262306a36Sopenharmony_ci{ 52362306a36Sopenharmony_ci unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); 52462306a36Sopenharmony_ci 52562306a36Sopenharmony_ci return local_port < max_ports && local_port; 52662306a36Sopenharmony_ci} 52762306a36Sopenharmony_ci 52862306a36Sopenharmony_ci/* spectrum_buffers.c */ 52962306a36Sopenharmony_cistruct mlxsw_sp_hdroom_prio { 53062306a36Sopenharmony_ci /* Number of port buffer associated with this priority. This is the 53162306a36Sopenharmony_ci * actually configured value. 53262306a36Sopenharmony_ci */ 53362306a36Sopenharmony_ci u8 buf_idx; 53462306a36Sopenharmony_ci /* Value of buf_idx deduced from the DCB ETS configuration. */ 53562306a36Sopenharmony_ci u8 ets_buf_idx; 53662306a36Sopenharmony_ci /* Value of buf_idx taken from the dcbnl_setbuffer configuration. */ 53762306a36Sopenharmony_ci u8 set_buf_idx; 53862306a36Sopenharmony_ci bool lossy; 53962306a36Sopenharmony_ci}; 54062306a36Sopenharmony_ci 54162306a36Sopenharmony_cistruct mlxsw_sp_hdroom_buf { 54262306a36Sopenharmony_ci u32 thres_cells; 54362306a36Sopenharmony_ci u32 size_cells; 54462306a36Sopenharmony_ci /* Size requirement form dcbnl_setbuffer. */ 54562306a36Sopenharmony_ci u32 set_size_cells; 54662306a36Sopenharmony_ci bool lossy; 54762306a36Sopenharmony_ci}; 54862306a36Sopenharmony_ci 54962306a36Sopenharmony_cienum mlxsw_sp_hdroom_mode { 55062306a36Sopenharmony_ci MLXSW_SP_HDROOM_MODE_DCB, 55162306a36Sopenharmony_ci MLXSW_SP_HDROOM_MODE_TC, 55262306a36Sopenharmony_ci}; 55362306a36Sopenharmony_ci 55462306a36Sopenharmony_ci#define MLXSW_SP_PB_COUNT 10 55562306a36Sopenharmony_ci 55662306a36Sopenharmony_cistruct mlxsw_sp_hdroom { 55762306a36Sopenharmony_ci enum mlxsw_sp_hdroom_mode mode; 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_ci struct { 56062306a36Sopenharmony_ci struct mlxsw_sp_hdroom_prio prio[IEEE_8021Q_MAX_PRIORITIES]; 56162306a36Sopenharmony_ci } prios; 56262306a36Sopenharmony_ci struct { 56362306a36Sopenharmony_ci struct mlxsw_sp_hdroom_buf buf[MLXSW_SP_PB_COUNT]; 56462306a36Sopenharmony_ci } bufs; 56562306a36Sopenharmony_ci struct { 56662306a36Sopenharmony_ci /* Size actually configured for the internal buffer. Equal to 56762306a36Sopenharmony_ci * reserve when internal buffer is enabled. 56862306a36Sopenharmony_ci */ 56962306a36Sopenharmony_ci u32 size_cells; 57062306a36Sopenharmony_ci /* Space reserved in the headroom for the internal buffer. Port 57162306a36Sopenharmony_ci * buffers are not allowed to grow into this space. 57262306a36Sopenharmony_ci */ 57362306a36Sopenharmony_ci u32 reserve_cells; 57462306a36Sopenharmony_ci bool enable; 57562306a36Sopenharmony_ci } int_buf; 57662306a36Sopenharmony_ci int delay_bytes; 57762306a36Sopenharmony_ci int mtu; 57862306a36Sopenharmony_ci}; 57962306a36Sopenharmony_ci 58062306a36Sopenharmony_ciint mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); 58162306a36Sopenharmony_civoid mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); 58262306a36Sopenharmony_ciint mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); 58362306a36Sopenharmony_civoid mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port); 58462306a36Sopenharmony_ciint mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, 58562306a36Sopenharmony_ci unsigned int sb_index, u16 pool_index, 58662306a36Sopenharmony_ci struct devlink_sb_pool_info *pool_info); 58762306a36Sopenharmony_ciint mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core, 58862306a36Sopenharmony_ci unsigned int sb_index, u16 pool_index, u32 size, 58962306a36Sopenharmony_ci enum devlink_sb_threshold_type threshold_type, 59062306a36Sopenharmony_ci struct netlink_ext_ack *extack); 59162306a36Sopenharmony_ciint mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, 59262306a36Sopenharmony_ci unsigned int sb_index, u16 pool_index, 59362306a36Sopenharmony_ci u32 *p_threshold); 59462306a36Sopenharmony_ciint mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port, 59562306a36Sopenharmony_ci unsigned int sb_index, u16 pool_index, 59662306a36Sopenharmony_ci u32 threshold, struct netlink_ext_ack *extack); 59762306a36Sopenharmony_ciint mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port, 59862306a36Sopenharmony_ci unsigned int sb_index, u16 tc_index, 59962306a36Sopenharmony_ci enum devlink_sb_pool_type pool_type, 60062306a36Sopenharmony_ci u16 *p_pool_index, u32 *p_threshold); 60162306a36Sopenharmony_ciint mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, 60262306a36Sopenharmony_ci unsigned int sb_index, u16 tc_index, 60362306a36Sopenharmony_ci enum devlink_sb_pool_type pool_type, 60462306a36Sopenharmony_ci u16 pool_index, u32 threshold, 60562306a36Sopenharmony_ci struct netlink_ext_ack *extack); 60662306a36Sopenharmony_ciint mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, 60762306a36Sopenharmony_ci unsigned int sb_index); 60862306a36Sopenharmony_ciint mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, 60962306a36Sopenharmony_ci unsigned int sb_index); 61062306a36Sopenharmony_ciint mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, 61162306a36Sopenharmony_ci unsigned int sb_index, u16 pool_index, 61262306a36Sopenharmony_ci u32 *p_cur, u32 *p_max); 61362306a36Sopenharmony_ciint mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port, 61462306a36Sopenharmony_ci unsigned int sb_index, u16 tc_index, 61562306a36Sopenharmony_ci enum devlink_sb_pool_type pool_type, 61662306a36Sopenharmony_ci u32 *p_cur, u32 *p_max); 61762306a36Sopenharmony_ciu32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); 61862306a36Sopenharmony_ciu32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); 61962306a36Sopenharmony_civoid mlxsw_sp_hdroom_prios_reset_buf_idx(struct mlxsw_sp_hdroom *hdroom); 62062306a36Sopenharmony_civoid mlxsw_sp_hdroom_bufs_reset_lossiness(struct mlxsw_sp_hdroom *hdroom); 62162306a36Sopenharmony_civoid mlxsw_sp_hdroom_bufs_reset_sizes(struct mlxsw_sp_port *mlxsw_sp_port, 62262306a36Sopenharmony_ci struct mlxsw_sp_hdroom *hdroom); 62362306a36Sopenharmony_ciint mlxsw_sp_hdroom_configure(struct mlxsw_sp_port *mlxsw_sp_port, 62462306a36Sopenharmony_ci const struct mlxsw_sp_hdroom *hdroom); 62562306a36Sopenharmony_cistruct mlxsw_sp_sample_params * 62662306a36Sopenharmony_cimlxsw_sp_sample_trigger_params_lookup(struct mlxsw_sp *mlxsw_sp, 62762306a36Sopenharmony_ci const struct mlxsw_sp_sample_trigger *trigger); 62862306a36Sopenharmony_ciint 62962306a36Sopenharmony_cimlxsw_sp_sample_trigger_params_set(struct mlxsw_sp *mlxsw_sp, 63062306a36Sopenharmony_ci const struct mlxsw_sp_sample_trigger *trigger, 63162306a36Sopenharmony_ci const struct mlxsw_sp_sample_params *params, 63262306a36Sopenharmony_ci struct netlink_ext_ack *extack); 63362306a36Sopenharmony_civoid 63462306a36Sopenharmony_cimlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp, 63562306a36Sopenharmony_ci const struct mlxsw_sp_sample_trigger *trigger); 63662306a36Sopenharmony_ciint mlxsw_sp_ipv6_addr_kvdl_index_get(struct mlxsw_sp *mlxsw_sp, 63762306a36Sopenharmony_ci const struct in6_addr *addr6, 63862306a36Sopenharmony_ci u32 *p_kvdl_index); 63962306a36Sopenharmony_civoid 64062306a36Sopenharmony_cimlxsw_sp_ipv6_addr_put(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6); 64162306a36Sopenharmony_ci 64262306a36Sopenharmony_ciextern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals; 64362306a36Sopenharmony_ciextern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals; 64462306a36Sopenharmony_ci 64562306a36Sopenharmony_ciextern const struct mlxsw_sp_sb_ops mlxsw_sp1_sb_ops; 64662306a36Sopenharmony_ciextern const struct mlxsw_sp_sb_ops mlxsw_sp2_sb_ops; 64762306a36Sopenharmony_ciextern const struct mlxsw_sp_sb_ops mlxsw_sp3_sb_ops; 64862306a36Sopenharmony_ci 64962306a36Sopenharmony_ci/* spectrum_switchdev.c */ 65062306a36Sopenharmony_ciint mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); 65162306a36Sopenharmony_civoid mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); 65262306a36Sopenharmony_ciint mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, 65362306a36Sopenharmony_ci bool adding); 65462306a36Sopenharmony_civoid 65562306a36Sopenharmony_cimlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 65662306a36Sopenharmony_ciint mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, 65762306a36Sopenharmony_ci struct net_device *brport_dev, 65862306a36Sopenharmony_ci struct net_device *br_dev, 65962306a36Sopenharmony_ci struct netlink_ext_ack *extack); 66062306a36Sopenharmony_civoid mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, 66162306a36Sopenharmony_ci struct net_device *brport_dev, 66262306a36Sopenharmony_ci struct net_device *br_dev); 66362306a36Sopenharmony_cibool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, 66462306a36Sopenharmony_ci const struct net_device *br_dev); 66562306a36Sopenharmony_ciint mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp, 66662306a36Sopenharmony_ci const struct net_device *br_dev, 66762306a36Sopenharmony_ci const struct net_device *vxlan_dev, u16 vid, 66862306a36Sopenharmony_ci struct netlink_ext_ack *extack); 66962306a36Sopenharmony_civoid mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp, 67062306a36Sopenharmony_ci const struct net_device *vxlan_dev); 67162306a36Sopenharmony_ciextern struct notifier_block mlxsw_sp_switchdev_notifier; 67262306a36Sopenharmony_ci 67362306a36Sopenharmony_ci/* spectrum.c */ 67462306a36Sopenharmony_civoid mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb, 67562306a36Sopenharmony_ci u16 local_port, void *priv); 67662306a36Sopenharmony_civoid mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 67762306a36Sopenharmony_ci u16 local_port); 67862306a36Sopenharmony_ciint mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed); 67962306a36Sopenharmony_ciint mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, 68062306a36Sopenharmony_ci enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, 68162306a36Sopenharmony_ci bool dwrr, u8 dwrr_weight); 68262306a36Sopenharmony_ciint mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, 68362306a36Sopenharmony_ci u8 switch_prio, u8 tclass); 68462306a36Sopenharmony_ciint mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, 68562306a36Sopenharmony_ci enum mlxsw_reg_qeec_hr hr, u8 index, 68662306a36Sopenharmony_ci u8 next_index, u32 maxrate, u8 burst_size); 68762306a36Sopenharmony_cienum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state); 68862306a36Sopenharmony_ciint mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 68962306a36Sopenharmony_ci u8 state); 69062306a36Sopenharmony_ciint mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable); 69162306a36Sopenharmony_ciint mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 69262306a36Sopenharmony_ci bool learn_enable); 69362306a36Sopenharmony_ciint mlxsw_sp_port_security_set(struct mlxsw_sp_port *mlxsw_sp_port, 69462306a36Sopenharmony_ci bool enable); 69562306a36Sopenharmony_ciint mlxsw_sp_ethtype_to_sver_type(u16 ethtype, u8 *p_sver_type); 69662306a36Sopenharmony_ciint mlxsw_sp_port_egress_ethtype_set(struct mlxsw_sp_port *mlxsw_sp_port, 69762306a36Sopenharmony_ci u16 ethtype); 69862306a36Sopenharmony_ciint mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 69962306a36Sopenharmony_ci u16 ethtype); 70062306a36Sopenharmony_cistruct mlxsw_sp_port_vlan * 70162306a36Sopenharmony_cimlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 70262306a36Sopenharmony_civoid mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 70362306a36Sopenharmony_ciint mlxsw_sp_port_kill_vid(struct net_device *dev, 70462306a36Sopenharmony_ci __be16 __always_unused proto, u16 vid); 70562306a36Sopenharmony_ciint mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, 70662306a36Sopenharmony_ci u16 vid_end, bool is_member, bool untagged); 70762306a36Sopenharmony_ciint mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, 70862306a36Sopenharmony_ci unsigned int counter_index, u64 *packets, 70962306a36Sopenharmony_ci u64 *bytes); 71062306a36Sopenharmony_ciint mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, 71162306a36Sopenharmony_ci unsigned int *p_counter_index); 71262306a36Sopenharmony_civoid mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, 71362306a36Sopenharmony_ci unsigned int counter_index); 71462306a36Sopenharmony_civoid mlxsw_sp_txhdr_construct(struct sk_buff *skb, 71562306a36Sopenharmony_ci const struct mlxsw_tx_info *tx_info); 71662306a36Sopenharmony_ciint mlxsw_sp_txhdr_ptp_data_construct(struct mlxsw_core *mlxsw_core, 71762306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, 71862306a36Sopenharmony_ci struct sk_buff *skb, 71962306a36Sopenharmony_ci const struct mlxsw_tx_info *tx_info); 72062306a36Sopenharmony_cibool mlxsw_sp_port_dev_check(const struct net_device *dev); 72162306a36Sopenharmony_cistruct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); 72262306a36Sopenharmony_cistruct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); 72362306a36Sopenharmony_cistruct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev); 72462306a36Sopenharmony_ciint mlxsw_sp_parsing_depth_inc(struct mlxsw_sp *mlxsw_sp); 72562306a36Sopenharmony_civoid mlxsw_sp_parsing_depth_dec(struct mlxsw_sp *mlxsw_sp); 72662306a36Sopenharmony_ciint mlxsw_sp_parsing_vxlan_udp_dport_set(struct mlxsw_sp *mlxsw_sp, 72762306a36Sopenharmony_ci __be16 udp_dport); 72862306a36Sopenharmony_ci 72962306a36Sopenharmony_ci/* spectrum_dcb.c */ 73062306a36Sopenharmony_ci#ifdef CONFIG_MLXSW_SPECTRUM_DCB 73162306a36Sopenharmony_ciint mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); 73262306a36Sopenharmony_civoid mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); 73362306a36Sopenharmony_ci#else 73462306a36Sopenharmony_cistatic inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) 73562306a36Sopenharmony_ci{ 73662306a36Sopenharmony_ci return 0; 73762306a36Sopenharmony_ci} 73862306a36Sopenharmony_cistatic inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) 73962306a36Sopenharmony_ci{} 74062306a36Sopenharmony_ci#endif 74162306a36Sopenharmony_ci 74262306a36Sopenharmony_ci/* spectrum_router.c */ 74362306a36Sopenharmony_cienum mlxsw_sp_l3proto { 74462306a36Sopenharmony_ci MLXSW_SP_L3_PROTO_IPV4, 74562306a36Sopenharmony_ci MLXSW_SP_L3_PROTO_IPV6, 74662306a36Sopenharmony_ci#define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1) 74762306a36Sopenharmony_ci}; 74862306a36Sopenharmony_ci 74962306a36Sopenharmony_ciunion mlxsw_sp_l3addr { 75062306a36Sopenharmony_ci __be32 addr4; 75162306a36Sopenharmony_ci struct in6_addr addr6; 75262306a36Sopenharmony_ci}; 75362306a36Sopenharmony_ci 75462306a36Sopenharmony_ciu16 mlxsw_sp_rif_index(const struct mlxsw_sp_rif *rif); 75562306a36Sopenharmony_ciint mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp, 75662306a36Sopenharmony_ci struct netlink_ext_ack *extack); 75762306a36Sopenharmony_civoid mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); 75862306a36Sopenharmony_civoid mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp, 75962306a36Sopenharmony_ci const struct net_device *macvlan_dev); 76062306a36Sopenharmony_civoid 76162306a36Sopenharmony_cimlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 76262306a36Sopenharmony_civoid mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, 76362306a36Sopenharmony_ci struct net_device *dev); 76462306a36Sopenharmony_cibool mlxsw_sp_rif_exists(struct mlxsw_sp *mlxsw_sp, 76562306a36Sopenharmony_ci const struct net_device *dev); 76662306a36Sopenharmony_ciu16 mlxsw_sp_rif_vid(struct mlxsw_sp *mlxsw_sp, const struct net_device *dev); 76762306a36Sopenharmony_ciu16 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp); 76862306a36Sopenharmony_ciint mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 76962306a36Sopenharmony_ci enum mlxsw_sp_l3proto ul_proto, 77062306a36Sopenharmony_ci const union mlxsw_sp_l3addr *ul_sip, 77162306a36Sopenharmony_ci u32 tunnel_index); 77262306a36Sopenharmony_civoid mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 77362306a36Sopenharmony_ci enum mlxsw_sp_l3proto ul_proto, 77462306a36Sopenharmony_ci const union mlxsw_sp_l3addr *ul_sip); 77562306a36Sopenharmony_ciint mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id, 77662306a36Sopenharmony_ci u16 *vr_id); 77762306a36Sopenharmony_ciint mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 77862306a36Sopenharmony_ci u16 *ul_rif_index); 77962306a36Sopenharmony_civoid mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index); 78062306a36Sopenharmony_ci 78162306a36Sopenharmony_ci/* spectrum_kvdl.c */ 78262306a36Sopenharmony_cienum mlxsw_sp_kvdl_entry_type { 78362306a36Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 78462306a36Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET, 78562306a36Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_PBS, 78662306a36Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR, 78762306a36Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 78862306a36Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT, 78962306a36Sopenharmony_ci}; 79062306a36Sopenharmony_ci 79162306a36Sopenharmony_cistatic inline unsigned int 79262306a36Sopenharmony_cimlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type) 79362306a36Sopenharmony_ci{ 79462306a36Sopenharmony_ci switch (type) { 79562306a36Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ: 79662306a36Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET: 79762306a36Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_PBS: 79862306a36Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR: 79962306a36Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS: 80062306a36Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT: 80162306a36Sopenharmony_ci default: 80262306a36Sopenharmony_ci return 1; 80362306a36Sopenharmony_ci } 80462306a36Sopenharmony_ci} 80562306a36Sopenharmony_ci 80662306a36Sopenharmony_cistruct mlxsw_sp_kvdl_ops { 80762306a36Sopenharmony_ci size_t priv_size; 80862306a36Sopenharmony_ci int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 80962306a36Sopenharmony_ci void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 81062306a36Sopenharmony_ci int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv, 81162306a36Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 81262306a36Sopenharmony_ci unsigned int entry_count, u32 *p_entry_index); 81362306a36Sopenharmony_ci void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv, 81462306a36Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 81562306a36Sopenharmony_ci unsigned int entry_count, int entry_index); 81662306a36Sopenharmony_ci int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv, 81762306a36Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 81862306a36Sopenharmony_ci unsigned int entry_count, 81962306a36Sopenharmony_ci unsigned int *p_alloc_count); 82062306a36Sopenharmony_ci int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv); 82162306a36Sopenharmony_ci}; 82262306a36Sopenharmony_ci 82362306a36Sopenharmony_ciint mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp); 82462306a36Sopenharmony_civoid mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp); 82562306a36Sopenharmony_ciint mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, 82662306a36Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 82762306a36Sopenharmony_ci unsigned int entry_count, u32 *p_entry_index); 82862306a36Sopenharmony_civoid mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, 82962306a36Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 83062306a36Sopenharmony_ci unsigned int entry_count, int entry_index); 83162306a36Sopenharmony_ciint mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp, 83262306a36Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 83362306a36Sopenharmony_ci unsigned int entry_count, 83462306a36Sopenharmony_ci unsigned int *p_alloc_count); 83562306a36Sopenharmony_ci 83662306a36Sopenharmony_ci/* spectrum1_kvdl.c */ 83762306a36Sopenharmony_ciextern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops; 83862306a36Sopenharmony_ciint mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core); 83962306a36Sopenharmony_ci 84062306a36Sopenharmony_ci/* spectrum2_kvdl.c */ 84162306a36Sopenharmony_ciextern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops; 84262306a36Sopenharmony_ci 84362306a36Sopenharmony_cienum mlxsw_sp_acl_mangle_field { 84462306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP_DSFIELD, 84562306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP_DSCP, 84662306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP_ECN, 84762306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP_SPORT, 84862306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT, 84962306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP, 85062306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP, 85162306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_1, 85262306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_2, 85362306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_3, 85462306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_4, 85562306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_1, 85662306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_2, 85762306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_3, 85862306a36Sopenharmony_ci MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_4, 85962306a36Sopenharmony_ci}; 86062306a36Sopenharmony_ci 86162306a36Sopenharmony_cistruct mlxsw_sp_acl_rule_info { 86262306a36Sopenharmony_ci unsigned int priority; 86362306a36Sopenharmony_ci struct mlxsw_afk_element_values values; 86462306a36Sopenharmony_ci struct mlxsw_afa_block *act_block; 86562306a36Sopenharmony_ci u8 action_created:1, 86662306a36Sopenharmony_ci ingress_bind_blocker:1, 86762306a36Sopenharmony_ci egress_bind_blocker:1, 86862306a36Sopenharmony_ci counter_valid:1, 86962306a36Sopenharmony_ci policer_index_valid:1, 87062306a36Sopenharmony_ci ipv6_valid:1, 87162306a36Sopenharmony_ci src_port_range_reg_valid:1, 87262306a36Sopenharmony_ci dst_port_range_reg_valid:1; 87362306a36Sopenharmony_ci unsigned int counter_index; 87462306a36Sopenharmony_ci u16 policer_index; 87562306a36Sopenharmony_ci u8 src_port_range_reg_index; 87662306a36Sopenharmony_ci u8 dst_port_range_reg_index; 87762306a36Sopenharmony_ci struct { 87862306a36Sopenharmony_ci u32 prev_val; 87962306a36Sopenharmony_ci enum mlxsw_sp_acl_mangle_field prev_field; 88062306a36Sopenharmony_ci } ipv6; 88162306a36Sopenharmony_ci}; 88262306a36Sopenharmony_ci 88362306a36Sopenharmony_ci/* spectrum_flow.c */ 88462306a36Sopenharmony_cistruct mlxsw_sp_flow_block { 88562306a36Sopenharmony_ci struct list_head binding_list; 88662306a36Sopenharmony_ci struct { 88762306a36Sopenharmony_ci struct list_head list; 88862306a36Sopenharmony_ci unsigned int min_prio; 88962306a36Sopenharmony_ci unsigned int max_prio; 89062306a36Sopenharmony_ci } mall; 89162306a36Sopenharmony_ci struct mlxsw_sp_acl_ruleset *ruleset_zero; 89262306a36Sopenharmony_ci struct mlxsw_sp *mlxsw_sp; 89362306a36Sopenharmony_ci unsigned int rule_count; 89462306a36Sopenharmony_ci unsigned int disable_count; 89562306a36Sopenharmony_ci unsigned int ingress_blocker_rule_count; 89662306a36Sopenharmony_ci unsigned int egress_blocker_rule_count; 89762306a36Sopenharmony_ci unsigned int ingress_binding_count; 89862306a36Sopenharmony_ci unsigned int egress_binding_count; 89962306a36Sopenharmony_ci struct net *net; 90062306a36Sopenharmony_ci}; 90162306a36Sopenharmony_ci 90262306a36Sopenharmony_cistruct mlxsw_sp_flow_block_binding { 90362306a36Sopenharmony_ci struct list_head list; 90462306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port; 90562306a36Sopenharmony_ci bool ingress; 90662306a36Sopenharmony_ci}; 90762306a36Sopenharmony_ci 90862306a36Sopenharmony_cistatic inline struct mlxsw_sp * 90962306a36Sopenharmony_cimlxsw_sp_flow_block_mlxsw_sp(struct mlxsw_sp_flow_block *block) 91062306a36Sopenharmony_ci{ 91162306a36Sopenharmony_ci return block->mlxsw_sp; 91262306a36Sopenharmony_ci} 91362306a36Sopenharmony_ci 91462306a36Sopenharmony_cistatic inline unsigned int 91562306a36Sopenharmony_cimlxsw_sp_flow_block_rule_count(const struct mlxsw_sp_flow_block *block) 91662306a36Sopenharmony_ci{ 91762306a36Sopenharmony_ci return block ? block->rule_count : 0; 91862306a36Sopenharmony_ci} 91962306a36Sopenharmony_ci 92062306a36Sopenharmony_cistatic inline void 92162306a36Sopenharmony_cimlxsw_sp_flow_block_disable_inc(struct mlxsw_sp_flow_block *block) 92262306a36Sopenharmony_ci{ 92362306a36Sopenharmony_ci if (block) 92462306a36Sopenharmony_ci block->disable_count++; 92562306a36Sopenharmony_ci} 92662306a36Sopenharmony_ci 92762306a36Sopenharmony_cistatic inline void 92862306a36Sopenharmony_cimlxsw_sp_flow_block_disable_dec(struct mlxsw_sp_flow_block *block) 92962306a36Sopenharmony_ci{ 93062306a36Sopenharmony_ci if (block) 93162306a36Sopenharmony_ci block->disable_count--; 93262306a36Sopenharmony_ci} 93362306a36Sopenharmony_ci 93462306a36Sopenharmony_cistatic inline bool 93562306a36Sopenharmony_cimlxsw_sp_flow_block_disabled(const struct mlxsw_sp_flow_block *block) 93662306a36Sopenharmony_ci{ 93762306a36Sopenharmony_ci return block->disable_count; 93862306a36Sopenharmony_ci} 93962306a36Sopenharmony_ci 94062306a36Sopenharmony_cistatic inline bool 94162306a36Sopenharmony_cimlxsw_sp_flow_block_is_egress_bound(const struct mlxsw_sp_flow_block *block) 94262306a36Sopenharmony_ci{ 94362306a36Sopenharmony_ci return block->egress_binding_count; 94462306a36Sopenharmony_ci} 94562306a36Sopenharmony_ci 94662306a36Sopenharmony_cistatic inline bool 94762306a36Sopenharmony_cimlxsw_sp_flow_block_is_ingress_bound(const struct mlxsw_sp_flow_block *block) 94862306a36Sopenharmony_ci{ 94962306a36Sopenharmony_ci return block->ingress_binding_count; 95062306a36Sopenharmony_ci} 95162306a36Sopenharmony_ci 95262306a36Sopenharmony_cistatic inline bool 95362306a36Sopenharmony_cimlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block) 95462306a36Sopenharmony_ci{ 95562306a36Sopenharmony_ci return block->ingress_binding_count && block->egress_binding_count; 95662306a36Sopenharmony_ci} 95762306a36Sopenharmony_ci 95862306a36Sopenharmony_cistruct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create(struct mlxsw_sp *mlxsw_sp, 95962306a36Sopenharmony_ci struct net *net); 96062306a36Sopenharmony_civoid mlxsw_sp_flow_block_destroy(struct mlxsw_sp_flow_block *block); 96162306a36Sopenharmony_ciint mlxsw_sp_setup_tc_block_clsact(struct mlxsw_sp_port *mlxsw_sp_port, 96262306a36Sopenharmony_ci struct flow_block_offload *f, 96362306a36Sopenharmony_ci bool ingress); 96462306a36Sopenharmony_ci 96562306a36Sopenharmony_ci/* spectrum_acl.c */ 96662306a36Sopenharmony_cistruct mlxsw_sp_acl_ruleset; 96762306a36Sopenharmony_ci 96862306a36Sopenharmony_cienum mlxsw_sp_acl_profile { 96962306a36Sopenharmony_ci MLXSW_SP_ACL_PROFILE_FLOWER, 97062306a36Sopenharmony_ci MLXSW_SP_ACL_PROFILE_MR, 97162306a36Sopenharmony_ci}; 97262306a36Sopenharmony_ci 97362306a36Sopenharmony_cistruct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); 97462306a36Sopenharmony_cistruct mlxsw_sp_acl_tcam *mlxsw_sp_acl_to_tcam(struct mlxsw_sp_acl *acl); 97562306a36Sopenharmony_ci 97662306a36Sopenharmony_ciint mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp, 97762306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 97862306a36Sopenharmony_ci struct mlxsw_sp_flow_block_binding *binding); 97962306a36Sopenharmony_civoid mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp, 98062306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 98162306a36Sopenharmony_ci struct mlxsw_sp_flow_block_binding *binding); 98262306a36Sopenharmony_cistruct mlxsw_sp_acl_ruleset * 98362306a36Sopenharmony_cimlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, 98462306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, u32 chain_index, 98562306a36Sopenharmony_ci enum mlxsw_sp_acl_profile profile); 98662306a36Sopenharmony_cistruct mlxsw_sp_acl_ruleset * 98762306a36Sopenharmony_cimlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, 98862306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, u32 chain_index, 98962306a36Sopenharmony_ci enum mlxsw_sp_acl_profile profile, 99062306a36Sopenharmony_ci struct mlxsw_afk_element_usage *tmplt_elusage); 99162306a36Sopenharmony_civoid mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, 99262306a36Sopenharmony_ci struct mlxsw_sp_acl_ruleset *ruleset); 99362306a36Sopenharmony_ciu16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset); 99462306a36Sopenharmony_civoid mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset, 99562306a36Sopenharmony_ci unsigned int *p_min_prio, 99662306a36Sopenharmony_ci unsigned int *p_max_prio); 99762306a36Sopenharmony_ci 99862306a36Sopenharmony_cistruct mlxsw_sp_acl_rule_info * 99962306a36Sopenharmony_cimlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl, 100062306a36Sopenharmony_ci struct mlxsw_afa_block *afa_block); 100162306a36Sopenharmony_civoid mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, 100262306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei); 100362306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); 100462306a36Sopenharmony_civoid mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, 100562306a36Sopenharmony_ci unsigned int priority); 100662306a36Sopenharmony_civoid mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, 100762306a36Sopenharmony_ci enum mlxsw_afk_element element, 100862306a36Sopenharmony_ci u32 key_value, u32 mask_value); 100962306a36Sopenharmony_civoid mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, 101062306a36Sopenharmony_ci enum mlxsw_afk_element element, 101162306a36Sopenharmony_ci const char *key_value, 101262306a36Sopenharmony_ci const char *mask_value, unsigned int len); 101362306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); 101462306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, 101562306a36Sopenharmony_ci u16 group_id); 101662306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei); 101762306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei, 101862306a36Sopenharmony_ci bool ingress, 101962306a36Sopenharmony_ci const struct flow_action_cookie *fa_cookie, 102062306a36Sopenharmony_ci struct netlink_ext_ack *extack); 102162306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); 102262306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp, 102362306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 102462306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 102562306a36Sopenharmony_ci struct net_device *out_dev, 102662306a36Sopenharmony_ci struct netlink_ext_ack *extack); 102762306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, 102862306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 102962306a36Sopenharmony_ci struct net_device *out_dev, 103062306a36Sopenharmony_ci struct netlink_ext_ack *extack); 103162306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp, 103262306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 103362306a36Sopenharmony_ci u32 action, u16 vid, u16 proto, u8 prio, 103462306a36Sopenharmony_ci struct netlink_ext_ack *extack); 103562306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp, 103662306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 103762306a36Sopenharmony_ci u32 prio, struct netlink_ext_ack *extack); 103862306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_mangle(struct mlxsw_sp *mlxsw_sp, 103962306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 104062306a36Sopenharmony_ci enum flow_action_mangle_base htype, 104162306a36Sopenharmony_ci u32 offset, u32 mask, u32 val, 104262306a36Sopenharmony_ci struct netlink_ext_ack *extack); 104362306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_police(struct mlxsw_sp *mlxsw_sp, 104462306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 104562306a36Sopenharmony_ci u32 index, u64 rate_bytes_ps, 104662306a36Sopenharmony_ci u32 burst, struct netlink_ext_ack *extack); 104762306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp, 104862306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 104962306a36Sopenharmony_ci struct netlink_ext_ack *extack); 105062306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp, 105162306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 105262306a36Sopenharmony_ci u16 fid, struct netlink_ext_ack *extack); 105362306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_ignore(struct mlxsw_sp *mlxsw_sp, 105462306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 105562306a36Sopenharmony_ci bool disable_learning, bool disable_security); 105662306a36Sopenharmony_ciint mlxsw_sp_acl_rulei_act_sample(struct mlxsw_sp *mlxsw_sp, 105762306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 105862306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 105962306a36Sopenharmony_ci struct psample_group *psample_group, u32 rate, 106062306a36Sopenharmony_ci u32 trunc_size, bool truncate, 106162306a36Sopenharmony_ci struct netlink_ext_ack *extack); 106262306a36Sopenharmony_ci 106362306a36Sopenharmony_cistruct mlxsw_sp_acl_rule; 106462306a36Sopenharmony_ci 106562306a36Sopenharmony_cistruct mlxsw_sp_acl_rule * 106662306a36Sopenharmony_cimlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp, 106762306a36Sopenharmony_ci struct mlxsw_sp_acl_ruleset *ruleset, 106862306a36Sopenharmony_ci unsigned long cookie, 106962306a36Sopenharmony_ci struct mlxsw_afa_block *afa_block, 107062306a36Sopenharmony_ci struct netlink_ext_ack *extack); 107162306a36Sopenharmony_civoid mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp, 107262306a36Sopenharmony_ci struct mlxsw_sp_acl_rule *rule); 107362306a36Sopenharmony_ciint mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp, 107462306a36Sopenharmony_ci struct mlxsw_sp_acl_rule *rule); 107562306a36Sopenharmony_civoid mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp, 107662306a36Sopenharmony_ci struct mlxsw_sp_acl_rule *rule); 107762306a36Sopenharmony_ciint mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp, 107862306a36Sopenharmony_ci struct mlxsw_sp_acl_rule *rule, 107962306a36Sopenharmony_ci struct mlxsw_afa_block *afa_block); 108062306a36Sopenharmony_cistruct mlxsw_sp_acl_rule * 108162306a36Sopenharmony_cimlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp, 108262306a36Sopenharmony_ci struct mlxsw_sp_acl_ruleset *ruleset, 108362306a36Sopenharmony_ci unsigned long cookie); 108462306a36Sopenharmony_cistruct mlxsw_sp_acl_rule_info * 108562306a36Sopenharmony_cimlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule); 108662306a36Sopenharmony_ciint mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, 108762306a36Sopenharmony_ci struct mlxsw_sp_acl_rule *rule, 108862306a36Sopenharmony_ci u64 *packets, u64 *bytes, u64 *drops, 108962306a36Sopenharmony_ci u64 *last_use, 109062306a36Sopenharmony_ci enum flow_action_hw_stats *used_hw_stats); 109162306a36Sopenharmony_ci 109262306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); 109362306a36Sopenharmony_ci 109462306a36Sopenharmony_cistatic inline const struct flow_action_cookie * 109562306a36Sopenharmony_cimlxsw_sp_acl_act_cookie_lookup(struct mlxsw_sp *mlxsw_sp, u32 cookie_index) 109662306a36Sopenharmony_ci{ 109762306a36Sopenharmony_ci return mlxsw_afa_cookie_lookup(mlxsw_sp->afa, cookie_index); 109862306a36Sopenharmony_ci} 109962306a36Sopenharmony_ci 110062306a36Sopenharmony_ciint mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); 110162306a36Sopenharmony_civoid mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); 110262306a36Sopenharmony_ci 110362306a36Sopenharmony_cistruct mlxsw_sp_acl_mangle_action; 110462306a36Sopenharmony_ci 110562306a36Sopenharmony_cistruct mlxsw_sp_acl_rulei_ops { 110662306a36Sopenharmony_ci int (*act_mangle_field)(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei, 110762306a36Sopenharmony_ci struct mlxsw_sp_acl_mangle_action *mact, u32 val, 110862306a36Sopenharmony_ci struct netlink_ext_ack *extack); 110962306a36Sopenharmony_ci}; 111062306a36Sopenharmony_ci 111162306a36Sopenharmony_ciextern struct mlxsw_sp_acl_rulei_ops mlxsw_sp1_acl_rulei_ops; 111262306a36Sopenharmony_ciextern struct mlxsw_sp_acl_rulei_ops mlxsw_sp2_acl_rulei_ops; 111362306a36Sopenharmony_ci 111462306a36Sopenharmony_ci/* spectrum_acl_tcam.c */ 111562306a36Sopenharmony_cistruct mlxsw_sp_acl_tcam; 111662306a36Sopenharmony_cistruct mlxsw_sp_acl_tcam_region; 111762306a36Sopenharmony_ci 111862306a36Sopenharmony_cistruct mlxsw_sp_acl_tcam_ops { 111962306a36Sopenharmony_ci enum mlxsw_reg_ptar_key_type key_type; 112062306a36Sopenharmony_ci size_t priv_size; 112162306a36Sopenharmony_ci int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv, 112262306a36Sopenharmony_ci struct mlxsw_sp_acl_tcam *tcam); 112362306a36Sopenharmony_ci void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 112462306a36Sopenharmony_ci size_t region_priv_size; 112562306a36Sopenharmony_ci int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv, 112662306a36Sopenharmony_ci void *tcam_priv, 112762306a36Sopenharmony_ci struct mlxsw_sp_acl_tcam_region *region, 112862306a36Sopenharmony_ci void *hints_priv); 112962306a36Sopenharmony_ci void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv); 113062306a36Sopenharmony_ci int (*region_associate)(struct mlxsw_sp *mlxsw_sp, 113162306a36Sopenharmony_ci struct mlxsw_sp_acl_tcam_region *region); 113262306a36Sopenharmony_ci void * (*region_rehash_hints_get)(void *region_priv); 113362306a36Sopenharmony_ci void (*region_rehash_hints_put)(void *hints_priv); 113462306a36Sopenharmony_ci size_t chunk_priv_size; 113562306a36Sopenharmony_ci void (*chunk_init)(void *region_priv, void *chunk_priv, 113662306a36Sopenharmony_ci unsigned int priority); 113762306a36Sopenharmony_ci void (*chunk_fini)(void *chunk_priv); 113862306a36Sopenharmony_ci size_t entry_priv_size; 113962306a36Sopenharmony_ci int (*entry_add)(struct mlxsw_sp *mlxsw_sp, 114062306a36Sopenharmony_ci void *region_priv, void *chunk_priv, 114162306a36Sopenharmony_ci void *entry_priv, 114262306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei); 114362306a36Sopenharmony_ci void (*entry_del)(struct mlxsw_sp *mlxsw_sp, 114462306a36Sopenharmony_ci void *region_priv, void *chunk_priv, 114562306a36Sopenharmony_ci void *entry_priv); 114662306a36Sopenharmony_ci int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp, 114762306a36Sopenharmony_ci void *region_priv, void *entry_priv, 114862306a36Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei); 114962306a36Sopenharmony_ci int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp, 115062306a36Sopenharmony_ci void *region_priv, void *entry_priv, 115162306a36Sopenharmony_ci bool *activity); 115262306a36Sopenharmony_ci}; 115362306a36Sopenharmony_ci 115462306a36Sopenharmony_ci/* spectrum1_acl_tcam.c */ 115562306a36Sopenharmony_ciextern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops; 115662306a36Sopenharmony_ci 115762306a36Sopenharmony_ci/* spectrum2_acl_tcam.c */ 115862306a36Sopenharmony_ciextern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops; 115962306a36Sopenharmony_ci 116062306a36Sopenharmony_ci/* spectrum_acl_flex_actions.c */ 116162306a36Sopenharmony_ciextern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops; 116262306a36Sopenharmony_ciextern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops; 116362306a36Sopenharmony_ci 116462306a36Sopenharmony_ci/* spectrum_acl_flex_keys.c */ 116562306a36Sopenharmony_ciextern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops; 116662306a36Sopenharmony_ciextern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops; 116762306a36Sopenharmony_ciextern const struct mlxsw_afk_ops mlxsw_sp4_afk_ops; 116862306a36Sopenharmony_ci 116962306a36Sopenharmony_ci/* spectrum_acl_bloom_filter.c */ 117062306a36Sopenharmony_ciextern const struct mlxsw_sp_acl_bf_ops mlxsw_sp2_acl_bf_ops; 117162306a36Sopenharmony_ciextern const struct mlxsw_sp_acl_bf_ops mlxsw_sp4_acl_bf_ops; 117262306a36Sopenharmony_ci 117362306a36Sopenharmony_ci/* spectrum_matchall.c */ 117462306a36Sopenharmony_cistruct mlxsw_sp_mall_ops { 117562306a36Sopenharmony_ci int (*sample_add)(struct mlxsw_sp *mlxsw_sp, 117662306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, 117762306a36Sopenharmony_ci struct mlxsw_sp_mall_entry *mall_entry, 117862306a36Sopenharmony_ci struct netlink_ext_ack *extack); 117962306a36Sopenharmony_ci void (*sample_del)(struct mlxsw_sp *mlxsw_sp, 118062306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, 118162306a36Sopenharmony_ci struct mlxsw_sp_mall_entry *mall_entry); 118262306a36Sopenharmony_ci}; 118362306a36Sopenharmony_ci 118462306a36Sopenharmony_ciextern const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops; 118562306a36Sopenharmony_ciextern const struct mlxsw_sp_mall_ops mlxsw_sp2_mall_ops; 118662306a36Sopenharmony_ci 118762306a36Sopenharmony_cienum mlxsw_sp_mall_action_type { 118862306a36Sopenharmony_ci MLXSW_SP_MALL_ACTION_TYPE_MIRROR, 118962306a36Sopenharmony_ci MLXSW_SP_MALL_ACTION_TYPE_SAMPLE, 119062306a36Sopenharmony_ci MLXSW_SP_MALL_ACTION_TYPE_TRAP, 119162306a36Sopenharmony_ci}; 119262306a36Sopenharmony_ci 119362306a36Sopenharmony_cistruct mlxsw_sp_mall_mirror_entry { 119462306a36Sopenharmony_ci const struct net_device *to_dev; 119562306a36Sopenharmony_ci int span_id; 119662306a36Sopenharmony_ci}; 119762306a36Sopenharmony_ci 119862306a36Sopenharmony_cistruct mlxsw_sp_mall_trap_entry { 119962306a36Sopenharmony_ci int span_id; 120062306a36Sopenharmony_ci}; 120162306a36Sopenharmony_ci 120262306a36Sopenharmony_cistruct mlxsw_sp_mall_sample_entry { 120362306a36Sopenharmony_ci struct mlxsw_sp_sample_params params; 120462306a36Sopenharmony_ci int span_id; /* Relevant for Spectrum-2 onwards. */ 120562306a36Sopenharmony_ci}; 120662306a36Sopenharmony_ci 120762306a36Sopenharmony_cistruct mlxsw_sp_mall_entry { 120862306a36Sopenharmony_ci struct list_head list; 120962306a36Sopenharmony_ci unsigned long cookie; 121062306a36Sopenharmony_ci unsigned int priority; 121162306a36Sopenharmony_ci enum mlxsw_sp_mall_action_type type; 121262306a36Sopenharmony_ci bool ingress; 121362306a36Sopenharmony_ci union { 121462306a36Sopenharmony_ci struct mlxsw_sp_mall_mirror_entry mirror; 121562306a36Sopenharmony_ci struct mlxsw_sp_mall_trap_entry trap; 121662306a36Sopenharmony_ci struct mlxsw_sp_mall_sample_entry sample; 121762306a36Sopenharmony_ci }; 121862306a36Sopenharmony_ci struct rcu_head rcu; 121962306a36Sopenharmony_ci}; 122062306a36Sopenharmony_ci 122162306a36Sopenharmony_ciint mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp, 122262306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 122362306a36Sopenharmony_ci struct tc_cls_matchall_offload *f); 122462306a36Sopenharmony_civoid mlxsw_sp_mall_destroy(struct mlxsw_sp_flow_block *block, 122562306a36Sopenharmony_ci struct tc_cls_matchall_offload *f); 122662306a36Sopenharmony_ciint mlxsw_sp_mall_port_bind(struct mlxsw_sp_flow_block *block, 122762306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, 122862306a36Sopenharmony_ci struct netlink_ext_ack *extack); 122962306a36Sopenharmony_civoid mlxsw_sp_mall_port_unbind(struct mlxsw_sp_flow_block *block, 123062306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port); 123162306a36Sopenharmony_ciint mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index, 123262306a36Sopenharmony_ci unsigned int *p_min_prio, unsigned int *p_max_prio); 123362306a36Sopenharmony_ci 123462306a36Sopenharmony_ci/* spectrum_flower.c */ 123562306a36Sopenharmony_ciint mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp, 123662306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 123762306a36Sopenharmony_ci struct flow_cls_offload *f); 123862306a36Sopenharmony_civoid mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp, 123962306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 124062306a36Sopenharmony_ci struct flow_cls_offload *f); 124162306a36Sopenharmony_ciint mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp, 124262306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 124362306a36Sopenharmony_ci struct flow_cls_offload *f); 124462306a36Sopenharmony_ciint mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp, 124562306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 124662306a36Sopenharmony_ci struct flow_cls_offload *f); 124762306a36Sopenharmony_civoid mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp, 124862306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 124962306a36Sopenharmony_ci struct flow_cls_offload *f); 125062306a36Sopenharmony_ciint mlxsw_sp_flower_prio_get(struct mlxsw_sp *mlxsw_sp, 125162306a36Sopenharmony_ci struct mlxsw_sp_flow_block *block, 125262306a36Sopenharmony_ci u32 chain_index, unsigned int *p_min_prio, 125362306a36Sopenharmony_ci unsigned int *p_max_prio); 125462306a36Sopenharmony_ci 125562306a36Sopenharmony_ci/* spectrum_qdisc.c */ 125662306a36Sopenharmony_ciint mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port); 125762306a36Sopenharmony_civoid mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port); 125862306a36Sopenharmony_ciint mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, 125962306a36Sopenharmony_ci struct tc_red_qopt_offload *p); 126062306a36Sopenharmony_ciint mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port, 126162306a36Sopenharmony_ci struct tc_prio_qopt_offload *p); 126262306a36Sopenharmony_ciint mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port, 126362306a36Sopenharmony_ci struct tc_ets_qopt_offload *p); 126462306a36Sopenharmony_ciint mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port, 126562306a36Sopenharmony_ci struct tc_tbf_qopt_offload *p); 126662306a36Sopenharmony_ciint mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port, 126762306a36Sopenharmony_ci struct tc_fifo_qopt_offload *p); 126862306a36Sopenharmony_ciint mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port, 126962306a36Sopenharmony_ci struct flow_block_offload *f); 127062306a36Sopenharmony_ciint mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port, 127162306a36Sopenharmony_ci struct flow_block_offload *f); 127262306a36Sopenharmony_ci 127362306a36Sopenharmony_ci/* spectrum_fid.c */ 127462306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp, 127562306a36Sopenharmony_ci u16 fid_index); 127662306a36Sopenharmony_ciint mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex); 127762306a36Sopenharmony_ciint mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid, 127862306a36Sopenharmony_ci enum mlxsw_sp_nve_type *p_type); 127962306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp, 128062306a36Sopenharmony_ci __be32 vni); 128162306a36Sopenharmony_ciint mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni); 128262306a36Sopenharmony_ciint mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid, 128362306a36Sopenharmony_ci u32 nve_flood_index); 128462306a36Sopenharmony_civoid mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid); 128562306a36Sopenharmony_cibool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid); 128662306a36Sopenharmony_ciint mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type, 128762306a36Sopenharmony_ci __be32 vni, int nve_ifindex); 128862306a36Sopenharmony_civoid mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid); 128962306a36Sopenharmony_cibool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid); 129062306a36Sopenharmony_civoid mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid, 129162306a36Sopenharmony_ci const struct net_device *nve_dev); 129262306a36Sopenharmony_ciint mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, 129362306a36Sopenharmony_ci enum mlxsw_sp_flood_type packet_type, u16 local_port, 129462306a36Sopenharmony_ci bool member); 129562306a36Sopenharmony_ciint mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid, 129662306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 129762306a36Sopenharmony_civoid mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid, 129862306a36Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 129962306a36Sopenharmony_ciu16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid); 130062306a36Sopenharmony_cienum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid); 130162306a36Sopenharmony_ciint mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif); 130262306a36Sopenharmony_civoid mlxsw_sp_fid_rif_unset(struct mlxsw_sp_fid *fid); 130362306a36Sopenharmony_cistruct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid); 130462306a36Sopenharmony_cienum mlxsw_sp_rif_type 130562306a36Sopenharmony_cimlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp, 130662306a36Sopenharmony_ci enum mlxsw_sp_fid_type type); 130762306a36Sopenharmony_ciu16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid); 130862306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid); 130962306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp, 131062306a36Sopenharmony_ci int br_ifindex); 131162306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp, 131262306a36Sopenharmony_ci u16 vid); 131362306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp, 131462306a36Sopenharmony_ci int br_ifindex); 131562306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp, 131662306a36Sopenharmony_ci u16 rif_index); 131762306a36Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp); 131862306a36Sopenharmony_civoid mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid); 131962306a36Sopenharmony_ciint mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port); 132062306a36Sopenharmony_civoid mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port); 132162306a36Sopenharmony_ciint mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp); 132262306a36Sopenharmony_civoid mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp); 132362306a36Sopenharmony_ci 132462306a36Sopenharmony_ciextern const struct mlxsw_sp_fid_family *mlxsw_sp1_fid_family_arr[]; 132562306a36Sopenharmony_ciextern const struct mlxsw_sp_fid_family *mlxsw_sp2_fid_family_arr[]; 132662306a36Sopenharmony_ci 132762306a36Sopenharmony_ci/* spectrum_mr.c */ 132862306a36Sopenharmony_cienum mlxsw_sp_mr_route_prio { 132962306a36Sopenharmony_ci MLXSW_SP_MR_ROUTE_PRIO_SG, 133062306a36Sopenharmony_ci MLXSW_SP_MR_ROUTE_PRIO_STARG, 133162306a36Sopenharmony_ci MLXSW_SP_MR_ROUTE_PRIO_CATCHALL, 133262306a36Sopenharmony_ci __MLXSW_SP_MR_ROUTE_PRIO_MAX 133362306a36Sopenharmony_ci}; 133462306a36Sopenharmony_ci 133562306a36Sopenharmony_ci#define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1) 133662306a36Sopenharmony_ci 133762306a36Sopenharmony_cistruct mlxsw_sp_mr_route_key; 133862306a36Sopenharmony_ci 133962306a36Sopenharmony_cistruct mlxsw_sp_mr_tcam_ops { 134062306a36Sopenharmony_ci size_t priv_size; 134162306a36Sopenharmony_ci int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 134262306a36Sopenharmony_ci void (*fini)(void *priv); 134362306a36Sopenharmony_ci size_t route_priv_size; 134462306a36Sopenharmony_ci int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv, 134562306a36Sopenharmony_ci void *route_priv, 134662306a36Sopenharmony_ci struct mlxsw_sp_mr_route_key *key, 134762306a36Sopenharmony_ci struct mlxsw_afa_block *afa_block, 134862306a36Sopenharmony_ci enum mlxsw_sp_mr_route_prio prio); 134962306a36Sopenharmony_ci void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv, 135062306a36Sopenharmony_ci void *route_priv, 135162306a36Sopenharmony_ci struct mlxsw_sp_mr_route_key *key); 135262306a36Sopenharmony_ci int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 135362306a36Sopenharmony_ci struct mlxsw_sp_mr_route_key *key, 135462306a36Sopenharmony_ci struct mlxsw_afa_block *afa_block); 135562306a36Sopenharmony_ci}; 135662306a36Sopenharmony_ci 135762306a36Sopenharmony_ci/* spectrum1_mr_tcam.c */ 135862306a36Sopenharmony_ciextern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops; 135962306a36Sopenharmony_ci 136062306a36Sopenharmony_ci/* spectrum2_mr_tcam.c */ 136162306a36Sopenharmony_ciextern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops; 136262306a36Sopenharmony_ci 136362306a36Sopenharmony_ci/* spectrum_nve.c */ 136462306a36Sopenharmony_cistruct mlxsw_sp_nve_params { 136562306a36Sopenharmony_ci enum mlxsw_sp_nve_type type; 136662306a36Sopenharmony_ci __be32 vni; 136762306a36Sopenharmony_ci const struct net_device *dev; 136862306a36Sopenharmony_ci u16 ethertype; 136962306a36Sopenharmony_ci}; 137062306a36Sopenharmony_ci 137162306a36Sopenharmony_ciextern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[]; 137262306a36Sopenharmony_ciextern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[]; 137362306a36Sopenharmony_ci 137462306a36Sopenharmony_ciint mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip, 137562306a36Sopenharmony_ci enum mlxsw_sp_l3proto proto, 137662306a36Sopenharmony_ci union mlxsw_sp_l3addr *addr); 137762306a36Sopenharmony_ciint mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp, 137862306a36Sopenharmony_ci struct mlxsw_sp_fid *fid, 137962306a36Sopenharmony_ci enum mlxsw_sp_l3proto proto, 138062306a36Sopenharmony_ci union mlxsw_sp_l3addr *addr); 138162306a36Sopenharmony_civoid mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp, 138262306a36Sopenharmony_ci struct mlxsw_sp_fid *fid, 138362306a36Sopenharmony_ci enum mlxsw_sp_l3proto proto, 138462306a36Sopenharmony_ci union mlxsw_sp_l3addr *addr); 138562306a36Sopenharmony_ciint mlxsw_sp_nve_ipv6_addr_kvdl_set(struct mlxsw_sp *mlxsw_sp, 138662306a36Sopenharmony_ci const struct in6_addr *addr6, 138762306a36Sopenharmony_ci u32 *p_kvdl_index); 138862306a36Sopenharmony_civoid mlxsw_sp_nve_ipv6_addr_kvdl_unset(struct mlxsw_sp *mlxsw_sp, 138962306a36Sopenharmony_ci const struct in6_addr *addr6); 139062306a36Sopenharmony_ciint 139162306a36Sopenharmony_cimlxsw_sp_nve_ipv6_addr_map_replace(struct mlxsw_sp *mlxsw_sp, const char *mac, 139262306a36Sopenharmony_ci u16 fid_index, 139362306a36Sopenharmony_ci const struct in6_addr *new_addr6); 139462306a36Sopenharmony_civoid mlxsw_sp_nve_ipv6_addr_map_del(struct mlxsw_sp *mlxsw_sp, const char *mac, 139562306a36Sopenharmony_ci u16 fid_index); 139662306a36Sopenharmony_ciint mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, 139762306a36Sopenharmony_ci struct mlxsw_sp_nve_params *params, 139862306a36Sopenharmony_ci struct netlink_ext_ack *extack); 139962306a36Sopenharmony_civoid mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp, 140062306a36Sopenharmony_ci struct mlxsw_sp_fid *fid); 140162306a36Sopenharmony_ciint mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port); 140262306a36Sopenharmony_civoid mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port); 140362306a36Sopenharmony_ciint mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp); 140462306a36Sopenharmony_civoid mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp); 140562306a36Sopenharmony_ci 140662306a36Sopenharmony_ci/* spectrum_trap.c */ 140762306a36Sopenharmony_ciint mlxsw_sp_devlink_traps_init(struct mlxsw_sp *mlxsw_sp); 140862306a36Sopenharmony_civoid mlxsw_sp_devlink_traps_fini(struct mlxsw_sp *mlxsw_sp); 140962306a36Sopenharmony_ciint mlxsw_sp_trap_init(struct mlxsw_core *mlxsw_core, 141062306a36Sopenharmony_ci const struct devlink_trap *trap, void *trap_ctx); 141162306a36Sopenharmony_civoid mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core, 141262306a36Sopenharmony_ci const struct devlink_trap *trap, void *trap_ctx); 141362306a36Sopenharmony_ciint mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, 141462306a36Sopenharmony_ci const struct devlink_trap *trap, 141562306a36Sopenharmony_ci enum devlink_trap_action action, 141662306a36Sopenharmony_ci struct netlink_ext_ack *extack); 141762306a36Sopenharmony_ciint mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, 141862306a36Sopenharmony_ci const struct devlink_trap_group *group); 141962306a36Sopenharmony_ciint mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core, 142062306a36Sopenharmony_ci const struct devlink_trap_group *group, 142162306a36Sopenharmony_ci const struct devlink_trap_policer *policer, 142262306a36Sopenharmony_ci struct netlink_ext_ack *extack); 142362306a36Sopenharmony_ciint 142462306a36Sopenharmony_cimlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core, 142562306a36Sopenharmony_ci const struct devlink_trap_policer *policer); 142662306a36Sopenharmony_civoid mlxsw_sp_trap_policer_fini(struct mlxsw_core *mlxsw_core, 142762306a36Sopenharmony_ci const struct devlink_trap_policer *policer); 142862306a36Sopenharmony_ciint 142962306a36Sopenharmony_cimlxsw_sp_trap_policer_set(struct mlxsw_core *mlxsw_core, 143062306a36Sopenharmony_ci const struct devlink_trap_policer *policer, 143162306a36Sopenharmony_ci u64 rate, u64 burst, struct netlink_ext_ack *extack); 143262306a36Sopenharmony_ciint 143362306a36Sopenharmony_cimlxsw_sp_trap_policer_counter_get(struct mlxsw_core *mlxsw_core, 143462306a36Sopenharmony_ci const struct devlink_trap_policer *policer, 143562306a36Sopenharmony_ci u64 *p_drops); 143662306a36Sopenharmony_ciint mlxsw_sp_trap_group_policer_hw_id_get(struct mlxsw_sp *mlxsw_sp, u16 id, 143762306a36Sopenharmony_ci bool *p_enabled, u16 *p_hw_id); 143862306a36Sopenharmony_ci 143962306a36Sopenharmony_cistatic inline struct net *mlxsw_sp_net(struct mlxsw_sp *mlxsw_sp) 144062306a36Sopenharmony_ci{ 144162306a36Sopenharmony_ci return mlxsw_core_net(mlxsw_sp->core); 144262306a36Sopenharmony_ci} 144362306a36Sopenharmony_ci 144462306a36Sopenharmony_ci/* spectrum_ethtool.c */ 144562306a36Sopenharmony_ciextern const struct ethtool_ops mlxsw_sp_port_ethtool_ops; 144662306a36Sopenharmony_ciextern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops; 144762306a36Sopenharmony_ciextern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops; 144862306a36Sopenharmony_ci 144962306a36Sopenharmony_ci/* spectrum_policer.c */ 145062306a36Sopenharmony_ciextern const struct mlxsw_sp_policer_core_ops mlxsw_sp1_policer_core_ops; 145162306a36Sopenharmony_ciextern const struct mlxsw_sp_policer_core_ops mlxsw_sp2_policer_core_ops; 145262306a36Sopenharmony_ci 145362306a36Sopenharmony_cienum mlxsw_sp_policer_type { 145462306a36Sopenharmony_ci MLXSW_SP_POLICER_TYPE_SINGLE_RATE, 145562306a36Sopenharmony_ci 145662306a36Sopenharmony_ci __MLXSW_SP_POLICER_TYPE_MAX, 145762306a36Sopenharmony_ci MLXSW_SP_POLICER_TYPE_MAX = __MLXSW_SP_POLICER_TYPE_MAX - 1, 145862306a36Sopenharmony_ci}; 145962306a36Sopenharmony_ci 146062306a36Sopenharmony_cistruct mlxsw_sp_policer_params { 146162306a36Sopenharmony_ci u64 rate; 146262306a36Sopenharmony_ci u64 burst; 146362306a36Sopenharmony_ci bool bytes; 146462306a36Sopenharmony_ci}; 146562306a36Sopenharmony_ci 146662306a36Sopenharmony_ciint mlxsw_sp_policer_add(struct mlxsw_sp *mlxsw_sp, 146762306a36Sopenharmony_ci enum mlxsw_sp_policer_type type, 146862306a36Sopenharmony_ci const struct mlxsw_sp_policer_params *params, 146962306a36Sopenharmony_ci struct netlink_ext_ack *extack, u16 *p_policer_index); 147062306a36Sopenharmony_civoid mlxsw_sp_policer_del(struct mlxsw_sp *mlxsw_sp, 147162306a36Sopenharmony_ci enum mlxsw_sp_policer_type type, 147262306a36Sopenharmony_ci u16 policer_index); 147362306a36Sopenharmony_ciint mlxsw_sp_policer_drops_counter_get(struct mlxsw_sp *mlxsw_sp, 147462306a36Sopenharmony_ci enum mlxsw_sp_policer_type type, 147562306a36Sopenharmony_ci u16 policer_index, u64 *p_drops); 147662306a36Sopenharmony_ciint mlxsw_sp_policers_init(struct mlxsw_sp *mlxsw_sp); 147762306a36Sopenharmony_civoid mlxsw_sp_policers_fini(struct mlxsw_sp *mlxsw_sp); 147862306a36Sopenharmony_ciint mlxsw_sp_policer_resources_register(struct mlxsw_core *mlxsw_core); 147962306a36Sopenharmony_ci 148062306a36Sopenharmony_ci/* spectrum_pgt.c */ 148162306a36Sopenharmony_ciint mlxsw_sp_pgt_mid_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_mid); 148262306a36Sopenharmony_civoid mlxsw_sp_pgt_mid_free(struct mlxsw_sp *mlxsw_sp, u16 mid_base); 148362306a36Sopenharmony_ciint mlxsw_sp_pgt_mid_alloc_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base, 148462306a36Sopenharmony_ci u16 count); 148562306a36Sopenharmony_civoid mlxsw_sp_pgt_mid_free_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base, 148662306a36Sopenharmony_ci u16 count); 148762306a36Sopenharmony_ciint mlxsw_sp_pgt_entry_port_set(struct mlxsw_sp *mlxsw_sp, u16 mid, 148862306a36Sopenharmony_ci u16 smpe, u16 local_port, bool member); 148962306a36Sopenharmony_ciint mlxsw_sp_pgt_init(struct mlxsw_sp *mlxsw_sp); 149062306a36Sopenharmony_civoid mlxsw_sp_pgt_fini(struct mlxsw_sp *mlxsw_sp); 149162306a36Sopenharmony_ci 149262306a36Sopenharmony_ci/* spectrum_port_range.c */ 149362306a36Sopenharmony_cistruct mlxsw_sp_port_range { 149462306a36Sopenharmony_ci u16 min; 149562306a36Sopenharmony_ci u16 max; 149662306a36Sopenharmony_ci u8 source:1; /* Source or destination */ 149762306a36Sopenharmony_ci}; 149862306a36Sopenharmony_ci 149962306a36Sopenharmony_ciint mlxsw_sp_port_range_reg_get(struct mlxsw_sp *mlxsw_sp, 150062306a36Sopenharmony_ci const struct mlxsw_sp_port_range *range, 150162306a36Sopenharmony_ci struct netlink_ext_ack *extack, 150262306a36Sopenharmony_ci u8 *p_prr_index); 150362306a36Sopenharmony_civoid mlxsw_sp_port_range_reg_put(struct mlxsw_sp *mlxsw_sp, u8 prr_index); 150462306a36Sopenharmony_ciint mlxsw_sp_port_range_init(struct mlxsw_sp *mlxsw_sp); 150562306a36Sopenharmony_civoid mlxsw_sp_port_range_fini(struct mlxsw_sp *mlxsw_sp); 150662306a36Sopenharmony_ci#endif 1507