18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef _MLXSW_SPECTRUM_H 58c2ecf20Sopenharmony_ci#define _MLXSW_SPECTRUM_H 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/types.h> 88c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 98c2ecf20Sopenharmony_ci#include <linux/rhashtable.h> 108c2ecf20Sopenharmony_ci#include <linux/bitops.h> 118c2ecf20Sopenharmony_ci#include <linux/if_bridge.h> 128c2ecf20Sopenharmony_ci#include <linux/if_vlan.h> 138c2ecf20Sopenharmony_ci#include <linux/list.h> 148c2ecf20Sopenharmony_ci#include <linux/dcbnl.h> 158c2ecf20Sopenharmony_ci#include <linux/in6.h> 168c2ecf20Sopenharmony_ci#include <linux/notifier.h> 178c2ecf20Sopenharmony_ci#include <linux/net_namespace.h> 188c2ecf20Sopenharmony_ci#include <net/psample.h> 198c2ecf20Sopenharmony_ci#include <net/pkt_cls.h> 208c2ecf20Sopenharmony_ci#include <net/red.h> 218c2ecf20Sopenharmony_ci#include <net/vxlan.h> 228c2ecf20Sopenharmony_ci#include <net/flow_offload.h> 238c2ecf20Sopenharmony_ci#include <net/inet_ecn.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include "port.h" 268c2ecf20Sopenharmony_ci#include "core.h" 278c2ecf20Sopenharmony_ci#include "core_acl_flex_keys.h" 288c2ecf20Sopenharmony_ci#include "core_acl_flex_actions.h" 298c2ecf20Sopenharmony_ci#include "reg.h" 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define MLXSW_SP_FID_8021D_MAX 1024 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define MLXSW_SP_MID_MAX 7000 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */ 388c2ecf20Sopenharmony_ci#define MLXSW_SP_KVD_GRANULARITY 128 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD "kvd" 418c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR "linear" 428c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_HASH_SINGLE "hash_single" 438c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_HASH_DOUBLE "hash_double" 448c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_SINGLES "singles" 458c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_CHUNKS "chunks" 468c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_LARGE_CHUNKS "large_chunks" 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_SPAN "span_agents" 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_COUNTERS "counters" 518c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_COUNTERS_FLOW "flow" 528c2ecf20Sopenharmony_ci#define MLXSW_SP_RESOURCE_NAME_COUNTERS_RIF "rif" 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cienum mlxsw_sp_resource_id { 558c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_KVD = 1, 568c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_LINEAR, 578c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_HASH_SINGLE, 588c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE, 598c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE, 608c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS, 618c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS, 628c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_SPAN, 638c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_COUNTERS, 648c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_COUNTERS_FLOW, 658c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_COUNTERS_RIF, 668c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_GLOBAL_POLICERS, 678c2ecf20Sopenharmony_ci MLXSW_SP_RESOURCE_SINGLE_RATE_POLICERS, 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct mlxsw_sp_port; 718c2ecf20Sopenharmony_cistruct mlxsw_sp_rif; 728c2ecf20Sopenharmony_cistruct mlxsw_sp_span_entry; 738c2ecf20Sopenharmony_cienum mlxsw_sp_l3proto; 748c2ecf20Sopenharmony_ciunion mlxsw_sp_l3addr; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistruct mlxsw_sp_upper { 778c2ecf20Sopenharmony_ci struct net_device *dev; 788c2ecf20Sopenharmony_ci unsigned int ref_count; 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cienum mlxsw_sp_rif_type { 828c2ecf20Sopenharmony_ci MLXSW_SP_RIF_TYPE_SUBPORT, 838c2ecf20Sopenharmony_ci MLXSW_SP_RIF_TYPE_VLAN, 848c2ecf20Sopenharmony_ci MLXSW_SP_RIF_TYPE_FID, 858c2ecf20Sopenharmony_ci MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */ 868c2ecf20Sopenharmony_ci MLXSW_SP_RIF_TYPE_MAX, 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_cistruct mlxsw_sp_rif_ops; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[]; 928c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[]; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cienum mlxsw_sp_fid_type { 958c2ecf20Sopenharmony_ci MLXSW_SP_FID_TYPE_8021Q, 968c2ecf20Sopenharmony_ci MLXSW_SP_FID_TYPE_8021D, 978c2ecf20Sopenharmony_ci MLXSW_SP_FID_TYPE_RFID, 988c2ecf20Sopenharmony_ci MLXSW_SP_FID_TYPE_DUMMY, 998c2ecf20Sopenharmony_ci MLXSW_SP_FID_TYPE_MAX, 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cienum mlxsw_sp_nve_type { 1038c2ecf20Sopenharmony_ci MLXSW_SP_NVE_TYPE_VXLAN, 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistruct mlxsw_sp_mid { 1078c2ecf20Sopenharmony_ci struct list_head list; 1088c2ecf20Sopenharmony_ci unsigned char addr[ETH_ALEN]; 1098c2ecf20Sopenharmony_ci u16 fid; 1108c2ecf20Sopenharmony_ci u16 mid; 1118c2ecf20Sopenharmony_ci bool in_hw; 1128c2ecf20Sopenharmony_ci unsigned long *ports_in_mid; /* bits array */ 1138c2ecf20Sopenharmony_ci}; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistruct mlxsw_sp_sb; 1168c2ecf20Sopenharmony_cistruct mlxsw_sp_bridge; 1178c2ecf20Sopenharmony_cistruct mlxsw_sp_router; 1188c2ecf20Sopenharmony_cistruct mlxsw_sp_mr; 1198c2ecf20Sopenharmony_cistruct mlxsw_sp_acl; 1208c2ecf20Sopenharmony_cistruct mlxsw_sp_counter_pool; 1218c2ecf20Sopenharmony_cistruct mlxsw_sp_fid_core; 1228c2ecf20Sopenharmony_cistruct mlxsw_sp_kvdl; 1238c2ecf20Sopenharmony_cistruct mlxsw_sp_nve; 1248c2ecf20Sopenharmony_cistruct mlxsw_sp_kvdl_ops; 1258c2ecf20Sopenharmony_cistruct mlxsw_sp_mr_tcam_ops; 1268c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_rulei_ops; 1278c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_tcam_ops; 1288c2ecf20Sopenharmony_cistruct mlxsw_sp_nve_ops; 1298c2ecf20Sopenharmony_cistruct mlxsw_sp_sb_ops; 1308c2ecf20Sopenharmony_cistruct mlxsw_sp_sb_vals; 1318c2ecf20Sopenharmony_cistruct mlxsw_sp_port_type_speed_ops; 1328c2ecf20Sopenharmony_cistruct mlxsw_sp_ptp_state; 1338c2ecf20Sopenharmony_cistruct mlxsw_sp_ptp_ops; 1348c2ecf20Sopenharmony_cistruct mlxsw_sp_span_ops; 1358c2ecf20Sopenharmony_cistruct mlxsw_sp_qdisc_state; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cistruct mlxsw_sp_port_mapping { 1388c2ecf20Sopenharmony_ci u8 module; 1398c2ecf20Sopenharmony_ci u8 width; 1408c2ecf20Sopenharmony_ci u8 lane; 1418c2ecf20Sopenharmony_ci}; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_cistruct mlxsw_sp { 1448c2ecf20Sopenharmony_ci struct mlxsw_sp_port **ports; 1458c2ecf20Sopenharmony_ci struct mlxsw_core *core; 1468c2ecf20Sopenharmony_ci const struct mlxsw_bus_info *bus_info; 1478c2ecf20Sopenharmony_ci unsigned char base_mac[ETH_ALEN]; 1488c2ecf20Sopenharmony_ci const unsigned char *mac_mask; 1498c2ecf20Sopenharmony_ci struct mlxsw_sp_upper *lags; 1508c2ecf20Sopenharmony_ci struct mlxsw_sp_port_mapping **port_mapping; 1518c2ecf20Sopenharmony_ci struct mlxsw_sp_sb *sb; 1528c2ecf20Sopenharmony_ci struct mlxsw_sp_bridge *bridge; 1538c2ecf20Sopenharmony_ci struct mlxsw_sp_router *router; 1548c2ecf20Sopenharmony_ci struct mlxsw_sp_mr *mr; 1558c2ecf20Sopenharmony_ci struct mlxsw_afa *afa; 1568c2ecf20Sopenharmony_ci struct mlxsw_sp_acl *acl; 1578c2ecf20Sopenharmony_ci struct mlxsw_sp_fid_core *fid_core; 1588c2ecf20Sopenharmony_ci struct mlxsw_sp_policer_core *policer_core; 1598c2ecf20Sopenharmony_ci struct mlxsw_sp_kvdl *kvdl; 1608c2ecf20Sopenharmony_ci struct mlxsw_sp_nve *nve; 1618c2ecf20Sopenharmony_ci struct notifier_block netdevice_nb; 1628c2ecf20Sopenharmony_ci struct mlxsw_sp_ptp_clock *clock; 1638c2ecf20Sopenharmony_ci struct mlxsw_sp_ptp_state *ptp_state; 1648c2ecf20Sopenharmony_ci struct mlxsw_sp_counter_pool *counter_pool; 1658c2ecf20Sopenharmony_ci struct mlxsw_sp_span *span; 1668c2ecf20Sopenharmony_ci struct mlxsw_sp_trap *trap; 1678c2ecf20Sopenharmony_ci const struct mlxsw_sp_kvdl_ops *kvdl_ops; 1688c2ecf20Sopenharmony_ci const struct mlxsw_afa_ops *afa_ops; 1698c2ecf20Sopenharmony_ci const struct mlxsw_afk_ops *afk_ops; 1708c2ecf20Sopenharmony_ci const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops; 1718c2ecf20Sopenharmony_ci const struct mlxsw_sp_acl_rulei_ops *acl_rulei_ops; 1728c2ecf20Sopenharmony_ci const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops; 1738c2ecf20Sopenharmony_ci const struct mlxsw_sp_nve_ops **nve_ops_arr; 1748c2ecf20Sopenharmony_ci const struct mlxsw_sp_rif_ops **rif_ops_arr; 1758c2ecf20Sopenharmony_ci const struct mlxsw_sp_sb_vals *sb_vals; 1768c2ecf20Sopenharmony_ci const struct mlxsw_sp_sb_ops *sb_ops; 1778c2ecf20Sopenharmony_ci const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops; 1788c2ecf20Sopenharmony_ci const struct mlxsw_sp_ptp_ops *ptp_ops; 1798c2ecf20Sopenharmony_ci const struct mlxsw_sp_span_ops *span_ops; 1808c2ecf20Sopenharmony_ci const struct mlxsw_sp_policer_core_ops *policer_core_ops; 1818c2ecf20Sopenharmony_ci const struct mlxsw_sp_trap_ops *trap_ops; 1828c2ecf20Sopenharmony_ci const struct mlxsw_listener *listeners; 1838c2ecf20Sopenharmony_ci size_t listeners_count; 1848c2ecf20Sopenharmony_ci u32 lowest_shaper_bs; 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistruct mlxsw_sp_ptp_ops { 1888c2ecf20Sopenharmony_ci struct mlxsw_sp_ptp_clock * 1898c2ecf20Sopenharmony_ci (*clock_init)(struct mlxsw_sp *mlxsw_sp, struct device *dev); 1908c2ecf20Sopenharmony_ci void (*clock_fini)(struct mlxsw_sp_ptp_clock *clock); 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci struct mlxsw_sp_ptp_state *(*init)(struct mlxsw_sp *mlxsw_sp); 1938c2ecf20Sopenharmony_ci void (*fini)(struct mlxsw_sp_ptp_state *ptp_state); 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci /* Notify a driver that a packet that might be PTP was received. Driver 1968c2ecf20Sopenharmony_ci * is responsible for freeing the passed-in SKB. 1978c2ecf20Sopenharmony_ci */ 1988c2ecf20Sopenharmony_ci void (*receive)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 1998c2ecf20Sopenharmony_ci u8 local_port); 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci /* Notify a driver that a timestamped packet was transmitted. Driver 2028c2ecf20Sopenharmony_ci * is responsible for freeing the passed-in SKB. 2038c2ecf20Sopenharmony_ci */ 2048c2ecf20Sopenharmony_ci void (*transmitted)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 2058c2ecf20Sopenharmony_ci u8 local_port); 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci int (*hwtstamp_get)(struct mlxsw_sp_port *mlxsw_sp_port, 2088c2ecf20Sopenharmony_ci struct hwtstamp_config *config); 2098c2ecf20Sopenharmony_ci int (*hwtstamp_set)(struct mlxsw_sp_port *mlxsw_sp_port, 2108c2ecf20Sopenharmony_ci struct hwtstamp_config *config); 2118c2ecf20Sopenharmony_ci void (*shaper_work)(struct work_struct *work); 2128c2ecf20Sopenharmony_ci int (*get_ts_info)(struct mlxsw_sp *mlxsw_sp, 2138c2ecf20Sopenharmony_ci struct ethtool_ts_info *info); 2148c2ecf20Sopenharmony_ci int (*get_stats_count)(void); 2158c2ecf20Sopenharmony_ci void (*get_stats_strings)(u8 **p); 2168c2ecf20Sopenharmony_ci void (*get_stats)(struct mlxsw_sp_port *mlxsw_sp_port, 2178c2ecf20Sopenharmony_ci u64 *data, int data_index); 2188c2ecf20Sopenharmony_ci}; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_cistatic inline struct mlxsw_sp_upper * 2218c2ecf20Sopenharmony_cimlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id) 2228c2ecf20Sopenharmony_ci{ 2238c2ecf20Sopenharmony_ci return &mlxsw_sp->lags[lag_id]; 2248c2ecf20Sopenharmony_ci} 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_cistruct mlxsw_sp_port_pcpu_stats { 2278c2ecf20Sopenharmony_ci u64 rx_packets; 2288c2ecf20Sopenharmony_ci u64 rx_bytes; 2298c2ecf20Sopenharmony_ci u64 tx_packets; 2308c2ecf20Sopenharmony_ci u64 tx_bytes; 2318c2ecf20Sopenharmony_ci struct u64_stats_sync syncp; 2328c2ecf20Sopenharmony_ci u32 tx_dropped; 2338c2ecf20Sopenharmony_ci}; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_cistruct mlxsw_sp_port_sample { 2368c2ecf20Sopenharmony_ci struct psample_group *psample_group; 2378c2ecf20Sopenharmony_ci u32 trunc_size; 2388c2ecf20Sopenharmony_ci u32 rate; 2398c2ecf20Sopenharmony_ci bool truncate; 2408c2ecf20Sopenharmony_ci}; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_cistruct mlxsw_sp_bridge_port; 2438c2ecf20Sopenharmony_cistruct mlxsw_sp_fid; 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_cistruct mlxsw_sp_port_vlan { 2468c2ecf20Sopenharmony_ci struct list_head list; 2478c2ecf20Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port; 2488c2ecf20Sopenharmony_ci struct mlxsw_sp_fid *fid; 2498c2ecf20Sopenharmony_ci u16 vid; 2508c2ecf20Sopenharmony_ci struct mlxsw_sp_bridge_port *bridge_port; 2518c2ecf20Sopenharmony_ci struct list_head bridge_vlan_node; 2528c2ecf20Sopenharmony_ci}; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci/* No need an internal lock; At worse - miss a single periodic iteration */ 2558c2ecf20Sopenharmony_cistruct mlxsw_sp_port_xstats { 2568c2ecf20Sopenharmony_ci u64 ecn; 2578c2ecf20Sopenharmony_ci u64 wred_drop[TC_MAX_QUEUE]; 2588c2ecf20Sopenharmony_ci u64 tail_drop[TC_MAX_QUEUE]; 2598c2ecf20Sopenharmony_ci u64 backlog[TC_MAX_QUEUE]; 2608c2ecf20Sopenharmony_ci u64 tx_bytes[IEEE_8021QAZ_MAX_TCS]; 2618c2ecf20Sopenharmony_ci u64 tx_packets[IEEE_8021QAZ_MAX_TCS]; 2628c2ecf20Sopenharmony_ci}; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_cistruct mlxsw_sp_ptp_port_dir_stats { 2658c2ecf20Sopenharmony_ci u64 packets; 2668c2ecf20Sopenharmony_ci u64 timestamps; 2678c2ecf20Sopenharmony_ci}; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_cistruct mlxsw_sp_ptp_port_stats { 2708c2ecf20Sopenharmony_ci struct mlxsw_sp_ptp_port_dir_stats rx_gcd; 2718c2ecf20Sopenharmony_ci struct mlxsw_sp_ptp_port_dir_stats tx_gcd; 2728c2ecf20Sopenharmony_ci}; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_cistruct mlxsw_sp_port { 2758c2ecf20Sopenharmony_ci struct net_device *dev; 2768c2ecf20Sopenharmony_ci struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats; 2778c2ecf20Sopenharmony_ci struct mlxsw_sp *mlxsw_sp; 2788c2ecf20Sopenharmony_ci u8 local_port; 2798c2ecf20Sopenharmony_ci u8 lagged:1, 2808c2ecf20Sopenharmony_ci split:1; 2818c2ecf20Sopenharmony_ci u16 pvid; 2828c2ecf20Sopenharmony_ci u16 lag_id; 2838c2ecf20Sopenharmony_ci struct { 2848c2ecf20Sopenharmony_ci u8 tx_pause:1, 2858c2ecf20Sopenharmony_ci rx_pause:1, 2868c2ecf20Sopenharmony_ci autoneg:1; 2878c2ecf20Sopenharmony_ci } link; 2888c2ecf20Sopenharmony_ci struct { 2898c2ecf20Sopenharmony_ci struct ieee_ets *ets; 2908c2ecf20Sopenharmony_ci struct ieee_maxrate *maxrate; 2918c2ecf20Sopenharmony_ci struct ieee_pfc *pfc; 2928c2ecf20Sopenharmony_ci enum mlxsw_reg_qpts_trust_state trust_state; 2938c2ecf20Sopenharmony_ci } dcb; 2948c2ecf20Sopenharmony_ci struct mlxsw_sp_port_mapping mapping; /* mapping is constant during the 2958c2ecf20Sopenharmony_ci * mlxsw_sp_port lifetime, however 2968c2ecf20Sopenharmony_ci * the same localport can have 2978c2ecf20Sopenharmony_ci * different mapping. 2988c2ecf20Sopenharmony_ci */ 2998c2ecf20Sopenharmony_ci struct { 3008c2ecf20Sopenharmony_ci #define MLXSW_HW_STATS_UPDATE_TIME HZ 3018c2ecf20Sopenharmony_ci struct rtnl_link_stats64 stats; 3028c2ecf20Sopenharmony_ci struct mlxsw_sp_port_xstats xstats; 3038c2ecf20Sopenharmony_ci struct delayed_work update_dw; 3048c2ecf20Sopenharmony_ci } periodic_hw_stats; 3058c2ecf20Sopenharmony_ci struct mlxsw_sp_port_sample __rcu *sample; 3068c2ecf20Sopenharmony_ci struct list_head vlans_list; 3078c2ecf20Sopenharmony_ci struct mlxsw_sp_port_vlan *default_vlan; 3088c2ecf20Sopenharmony_ci struct mlxsw_sp_qdisc_state *qdisc; 3098c2ecf20Sopenharmony_ci unsigned acl_rule_count; 3108c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *ing_flow_block; 3118c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *eg_flow_block; 3128c2ecf20Sopenharmony_ci struct { 3138c2ecf20Sopenharmony_ci struct delayed_work shaper_dw; 3148c2ecf20Sopenharmony_ci struct hwtstamp_config hwtstamp_config; 3158c2ecf20Sopenharmony_ci u16 ing_types; 3168c2ecf20Sopenharmony_ci u16 egr_types; 3178c2ecf20Sopenharmony_ci struct mlxsw_sp_ptp_port_stats stats; 3188c2ecf20Sopenharmony_ci } ptp; 3198c2ecf20Sopenharmony_ci u8 split_base_local_port; 3208c2ecf20Sopenharmony_ci int max_mtu; 3218c2ecf20Sopenharmony_ci u32 max_speed; 3228c2ecf20Sopenharmony_ci struct mlxsw_sp_hdroom *hdroom; 3238c2ecf20Sopenharmony_ci u64 module_overheat_initial_val; 3248c2ecf20Sopenharmony_ci}; 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_cistruct mlxsw_sp_port_type_speed_ops { 3278c2ecf20Sopenharmony_ci void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp, 3288c2ecf20Sopenharmony_ci u32 ptys_eth_proto, 3298c2ecf20Sopenharmony_ci struct ethtool_link_ksettings *cmd); 3308c2ecf20Sopenharmony_ci void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto, 3318c2ecf20Sopenharmony_ci u8 width, unsigned long *mode); 3328c2ecf20Sopenharmony_ci u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto); 3338c2ecf20Sopenharmony_ci void (*from_ptys_speed_duplex)(struct mlxsw_sp *mlxsw_sp, 3348c2ecf20Sopenharmony_ci bool carrier_ok, u32 ptys_eth_proto, 3358c2ecf20Sopenharmony_ci struct ethtool_link_ksettings *cmd); 3368c2ecf20Sopenharmony_ci int (*ptys_max_speed)(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed); 3378c2ecf20Sopenharmony_ci u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp, u8 width, 3388c2ecf20Sopenharmony_ci const struct ethtool_link_ksettings *cmd); 3398c2ecf20Sopenharmony_ci u32 (*to_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u8 width, u32 speed); 3408c2ecf20Sopenharmony_ci void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload, 3418c2ecf20Sopenharmony_ci u8 local_port, u32 proto_admin, bool autoneg); 3428c2ecf20Sopenharmony_ci void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload, 3438c2ecf20Sopenharmony_ci u32 *p_eth_proto_cap, 3448c2ecf20Sopenharmony_ci u32 *p_eth_proto_admin, 3458c2ecf20Sopenharmony_ci u32 *p_eth_proto_oper); 3468c2ecf20Sopenharmony_ci u32 (*ptys_proto_cap_masked_get)(u32 eth_proto_cap); 3478c2ecf20Sopenharmony_ci}; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_cistatic inline u8 mlxsw_sp_tunnel_ecn_decap(u8 outer_ecn, u8 inner_ecn, 3508c2ecf20Sopenharmony_ci bool *trap_en) 3518c2ecf20Sopenharmony_ci{ 3528c2ecf20Sopenharmony_ci bool set_ce = false; 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci *trap_en = !!__INET_ECN_decapsulate(outer_ecn, inner_ecn, &set_ce); 3558c2ecf20Sopenharmony_ci if (set_ce) 3568c2ecf20Sopenharmony_ci return INET_ECN_CE; 3578c2ecf20Sopenharmony_ci else if (outer_ecn == INET_ECN_ECT_1 && inner_ecn == INET_ECN_ECT_0) 3588c2ecf20Sopenharmony_ci return INET_ECN_ECT_1; 3598c2ecf20Sopenharmony_ci else 3608c2ecf20Sopenharmony_ci return inner_ecn; 3618c2ecf20Sopenharmony_ci} 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_cistatic inline struct net_device * 3648c2ecf20Sopenharmony_cimlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev) 3658c2ecf20Sopenharmony_ci{ 3668c2ecf20Sopenharmony_ci struct net_device *dev; 3678c2ecf20Sopenharmony_ci struct list_head *iter; 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci netdev_for_each_lower_dev(br_dev, dev, iter) { 3708c2ecf20Sopenharmony_ci if (netif_is_vxlan(dev)) 3718c2ecf20Sopenharmony_ci return dev; 3728c2ecf20Sopenharmony_ci } 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci return NULL; 3758c2ecf20Sopenharmony_ci} 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_cistatic inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev) 3788c2ecf20Sopenharmony_ci{ 3798c2ecf20Sopenharmony_ci return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev); 3808c2ecf20Sopenharmony_ci} 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_cistatic inline int 3838c2ecf20Sopenharmony_cimlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid) 3848c2ecf20Sopenharmony_ci{ 3858c2ecf20Sopenharmony_ci struct bridge_vlan_info vinfo; 3868c2ecf20Sopenharmony_ci u16 vid = 0; 3878c2ecf20Sopenharmony_ci int err; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci err = br_vlan_get_pvid(vxlan_dev, &vid); 3908c2ecf20Sopenharmony_ci if (err || !vid) 3918c2ecf20Sopenharmony_ci goto out; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ci err = br_vlan_get_info(vxlan_dev, vid, &vinfo); 3948c2ecf20Sopenharmony_ci if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED)) 3958c2ecf20Sopenharmony_ci vid = 0; 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ciout: 3988c2ecf20Sopenharmony_ci *p_vid = vid; 3998c2ecf20Sopenharmony_ci return err; 4008c2ecf20Sopenharmony_ci} 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_cistatic inline bool 4038c2ecf20Sopenharmony_cimlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) 4048c2ecf20Sopenharmony_ci{ 4058c2ecf20Sopenharmony_ci return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause; 4068c2ecf20Sopenharmony_ci} 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_cistatic inline struct mlxsw_sp_port * 4098c2ecf20Sopenharmony_cimlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index) 4108c2ecf20Sopenharmony_ci{ 4118c2ecf20Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port; 4128c2ecf20Sopenharmony_ci u8 local_port; 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core, 4158c2ecf20Sopenharmony_ci lag_id, port_index); 4168c2ecf20Sopenharmony_ci mlxsw_sp_port = mlxsw_sp->ports[local_port]; 4178c2ecf20Sopenharmony_ci return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL; 4188c2ecf20Sopenharmony_ci} 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_cistatic inline struct mlxsw_sp_port_vlan * 4218c2ecf20Sopenharmony_cimlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port, 4228c2ecf20Sopenharmony_ci u16 vid) 4238c2ecf20Sopenharmony_ci{ 4248c2ecf20Sopenharmony_ci struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list, 4278c2ecf20Sopenharmony_ci list) { 4288c2ecf20Sopenharmony_ci if (mlxsw_sp_port_vlan->vid == vid) 4298c2ecf20Sopenharmony_ci return mlxsw_sp_port_vlan; 4308c2ecf20Sopenharmony_ci } 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ci return NULL; 4338c2ecf20Sopenharmony_ci} 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_cienum mlxsw_sp_flood_type { 4368c2ecf20Sopenharmony_ci MLXSW_SP_FLOOD_TYPE_UC, 4378c2ecf20Sopenharmony_ci MLXSW_SP_FLOOD_TYPE_BC, 4388c2ecf20Sopenharmony_ci MLXSW_SP_FLOOD_TYPE_MC, 4398c2ecf20Sopenharmony_ci}; 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ciint mlxsw_sp_port_get_stats_raw(struct net_device *dev, int grp, 4428c2ecf20Sopenharmony_ci int prio, char *ppcnt_pl); 4438c2ecf20Sopenharmony_ciint mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port, 4448c2ecf20Sopenharmony_ci bool is_up); 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci/* spectrum_buffers.c */ 4478c2ecf20Sopenharmony_cistruct mlxsw_sp_hdroom_prio { 4488c2ecf20Sopenharmony_ci /* Number of port buffer associated with this priority. This is the 4498c2ecf20Sopenharmony_ci * actually configured value. 4508c2ecf20Sopenharmony_ci */ 4518c2ecf20Sopenharmony_ci u8 buf_idx; 4528c2ecf20Sopenharmony_ci /* Value of buf_idx deduced from the DCB ETS configuration. */ 4538c2ecf20Sopenharmony_ci u8 ets_buf_idx; 4548c2ecf20Sopenharmony_ci /* Value of buf_idx taken from the dcbnl_setbuffer configuration. */ 4558c2ecf20Sopenharmony_ci u8 set_buf_idx; 4568c2ecf20Sopenharmony_ci bool lossy; 4578c2ecf20Sopenharmony_ci}; 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_cistruct mlxsw_sp_hdroom_buf { 4608c2ecf20Sopenharmony_ci u32 thres_cells; 4618c2ecf20Sopenharmony_ci u32 size_cells; 4628c2ecf20Sopenharmony_ci /* Size requirement form dcbnl_setbuffer. */ 4638c2ecf20Sopenharmony_ci u32 set_size_cells; 4648c2ecf20Sopenharmony_ci bool lossy; 4658c2ecf20Sopenharmony_ci}; 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_cienum mlxsw_sp_hdroom_mode { 4688c2ecf20Sopenharmony_ci MLXSW_SP_HDROOM_MODE_DCB, 4698c2ecf20Sopenharmony_ci MLXSW_SP_HDROOM_MODE_TC, 4708c2ecf20Sopenharmony_ci}; 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_ci#define MLXSW_SP_PB_COUNT 10 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_cistruct mlxsw_sp_hdroom { 4758c2ecf20Sopenharmony_ci enum mlxsw_sp_hdroom_mode mode; 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci struct { 4788c2ecf20Sopenharmony_ci struct mlxsw_sp_hdroom_prio prio[IEEE_8021Q_MAX_PRIORITIES]; 4798c2ecf20Sopenharmony_ci } prios; 4808c2ecf20Sopenharmony_ci struct { 4818c2ecf20Sopenharmony_ci struct mlxsw_sp_hdroom_buf buf[MLXSW_SP_PB_COUNT]; 4828c2ecf20Sopenharmony_ci } bufs; 4838c2ecf20Sopenharmony_ci struct { 4848c2ecf20Sopenharmony_ci /* Size actually configured for the internal buffer. Equal to 4858c2ecf20Sopenharmony_ci * reserve when internal buffer is enabled. 4868c2ecf20Sopenharmony_ci */ 4878c2ecf20Sopenharmony_ci u32 size_cells; 4888c2ecf20Sopenharmony_ci /* Space reserved in the headroom for the internal buffer. Port 4898c2ecf20Sopenharmony_ci * buffers are not allowed to grow into this space. 4908c2ecf20Sopenharmony_ci */ 4918c2ecf20Sopenharmony_ci u32 reserve_cells; 4928c2ecf20Sopenharmony_ci bool enable; 4938c2ecf20Sopenharmony_ci } int_buf; 4948c2ecf20Sopenharmony_ci int delay_bytes; 4958c2ecf20Sopenharmony_ci int mtu; 4968c2ecf20Sopenharmony_ci}; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ciint mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); 4998c2ecf20Sopenharmony_civoid mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); 5008c2ecf20Sopenharmony_ciint mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); 5018c2ecf20Sopenharmony_civoid mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port); 5028c2ecf20Sopenharmony_ciint mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, 5038c2ecf20Sopenharmony_ci unsigned int sb_index, u16 pool_index, 5048c2ecf20Sopenharmony_ci struct devlink_sb_pool_info *pool_info); 5058c2ecf20Sopenharmony_ciint mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core, 5068c2ecf20Sopenharmony_ci unsigned int sb_index, u16 pool_index, u32 size, 5078c2ecf20Sopenharmony_ci enum devlink_sb_threshold_type threshold_type, 5088c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 5098c2ecf20Sopenharmony_ciint mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, 5108c2ecf20Sopenharmony_ci unsigned int sb_index, u16 pool_index, 5118c2ecf20Sopenharmony_ci u32 *p_threshold); 5128c2ecf20Sopenharmony_ciint mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port, 5138c2ecf20Sopenharmony_ci unsigned int sb_index, u16 pool_index, 5148c2ecf20Sopenharmony_ci u32 threshold, struct netlink_ext_ack *extack); 5158c2ecf20Sopenharmony_ciint mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port, 5168c2ecf20Sopenharmony_ci unsigned int sb_index, u16 tc_index, 5178c2ecf20Sopenharmony_ci enum devlink_sb_pool_type pool_type, 5188c2ecf20Sopenharmony_ci u16 *p_pool_index, u32 *p_threshold); 5198c2ecf20Sopenharmony_ciint mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, 5208c2ecf20Sopenharmony_ci unsigned int sb_index, u16 tc_index, 5218c2ecf20Sopenharmony_ci enum devlink_sb_pool_type pool_type, 5228c2ecf20Sopenharmony_ci u16 pool_index, u32 threshold, 5238c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 5248c2ecf20Sopenharmony_ciint mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, 5258c2ecf20Sopenharmony_ci unsigned int sb_index); 5268c2ecf20Sopenharmony_ciint mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, 5278c2ecf20Sopenharmony_ci unsigned int sb_index); 5288c2ecf20Sopenharmony_ciint mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, 5298c2ecf20Sopenharmony_ci unsigned int sb_index, u16 pool_index, 5308c2ecf20Sopenharmony_ci u32 *p_cur, u32 *p_max); 5318c2ecf20Sopenharmony_ciint mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port, 5328c2ecf20Sopenharmony_ci unsigned int sb_index, u16 tc_index, 5338c2ecf20Sopenharmony_ci enum devlink_sb_pool_type pool_type, 5348c2ecf20Sopenharmony_ci u32 *p_cur, u32 *p_max); 5358c2ecf20Sopenharmony_ciu32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); 5368c2ecf20Sopenharmony_ciu32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); 5378c2ecf20Sopenharmony_civoid mlxsw_sp_hdroom_prios_reset_buf_idx(struct mlxsw_sp_hdroom *hdroom); 5388c2ecf20Sopenharmony_civoid mlxsw_sp_hdroom_bufs_reset_lossiness(struct mlxsw_sp_hdroom *hdroom); 5398c2ecf20Sopenharmony_civoid mlxsw_sp_hdroom_bufs_reset_sizes(struct mlxsw_sp_port *mlxsw_sp_port, 5408c2ecf20Sopenharmony_ci struct mlxsw_sp_hdroom *hdroom); 5418c2ecf20Sopenharmony_ciint mlxsw_sp_hdroom_configure(struct mlxsw_sp_port *mlxsw_sp_port, 5428c2ecf20Sopenharmony_ci const struct mlxsw_sp_hdroom *hdroom); 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals; 5458c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals; 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_sb_ops mlxsw_sp1_sb_ops; 5488c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_sb_ops mlxsw_sp2_sb_ops; 5498c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_sb_ops mlxsw_sp3_sb_ops; 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci/* spectrum_switchdev.c */ 5528c2ecf20Sopenharmony_ciint mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); 5538c2ecf20Sopenharmony_civoid mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); 5548c2ecf20Sopenharmony_ciint mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, 5558c2ecf20Sopenharmony_ci bool adding); 5568c2ecf20Sopenharmony_civoid 5578c2ecf20Sopenharmony_cimlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 5588c2ecf20Sopenharmony_ciint mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, 5598c2ecf20Sopenharmony_ci struct net_device *brport_dev, 5608c2ecf20Sopenharmony_ci struct net_device *br_dev, 5618c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 5628c2ecf20Sopenharmony_civoid mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, 5638c2ecf20Sopenharmony_ci struct net_device *brport_dev, 5648c2ecf20Sopenharmony_ci struct net_device *br_dev); 5658c2ecf20Sopenharmony_cibool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, 5668c2ecf20Sopenharmony_ci const struct net_device *br_dev); 5678c2ecf20Sopenharmony_ciint mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp, 5688c2ecf20Sopenharmony_ci const struct net_device *br_dev, 5698c2ecf20Sopenharmony_ci const struct net_device *vxlan_dev, u16 vid, 5708c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 5718c2ecf20Sopenharmony_civoid mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp, 5728c2ecf20Sopenharmony_ci const struct net_device *vxlan_dev); 5738c2ecf20Sopenharmony_ciextern struct notifier_block mlxsw_sp_switchdev_notifier; 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci/* spectrum.c */ 5768c2ecf20Sopenharmony_civoid mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb, 5778c2ecf20Sopenharmony_ci u8 local_port, void *priv); 5788c2ecf20Sopenharmony_civoid mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 5798c2ecf20Sopenharmony_ci u8 local_port); 5808c2ecf20Sopenharmony_civoid mlxsw_sp_sample_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 5818c2ecf20Sopenharmony_ci u8 local_port); 5828c2ecf20Sopenharmony_ciint mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed); 5838c2ecf20Sopenharmony_ciint mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, 5848c2ecf20Sopenharmony_ci enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, 5858c2ecf20Sopenharmony_ci bool dwrr, u8 dwrr_weight); 5868c2ecf20Sopenharmony_ciint mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, 5878c2ecf20Sopenharmony_ci u8 switch_prio, u8 tclass); 5888c2ecf20Sopenharmony_ciint mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, 5898c2ecf20Sopenharmony_ci enum mlxsw_reg_qeec_hr hr, u8 index, 5908c2ecf20Sopenharmony_ci u8 next_index, u32 maxrate, u8 burst_size); 5918c2ecf20Sopenharmony_cienum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state); 5928c2ecf20Sopenharmony_ciint mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 5938c2ecf20Sopenharmony_ci u8 state); 5948c2ecf20Sopenharmony_ciint mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable); 5958c2ecf20Sopenharmony_ciint mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 5968c2ecf20Sopenharmony_ci bool learn_enable); 5978c2ecf20Sopenharmony_ciint mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 5988c2ecf20Sopenharmony_cistruct mlxsw_sp_port_vlan * 5998c2ecf20Sopenharmony_cimlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 6008c2ecf20Sopenharmony_civoid mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 6018c2ecf20Sopenharmony_ciint mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, 6028c2ecf20Sopenharmony_ci u16 vid_end, bool is_member, bool untagged); 6038c2ecf20Sopenharmony_ciint mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, 6048c2ecf20Sopenharmony_ci unsigned int counter_index, u64 *packets, 6058c2ecf20Sopenharmony_ci u64 *bytes); 6068c2ecf20Sopenharmony_ciint mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, 6078c2ecf20Sopenharmony_ci unsigned int *p_counter_index); 6088c2ecf20Sopenharmony_civoid mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, 6098c2ecf20Sopenharmony_ci unsigned int counter_index); 6108c2ecf20Sopenharmony_cibool mlxsw_sp_port_dev_check(const struct net_device *dev); 6118c2ecf20Sopenharmony_cistruct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); 6128c2ecf20Sopenharmony_cistruct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); 6138c2ecf20Sopenharmony_cistruct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); 6148c2ecf20Sopenharmony_civoid mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); 6158c2ecf20Sopenharmony_cistruct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev); 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci/* spectrum_dcb.c */ 6188c2ecf20Sopenharmony_ci#ifdef CONFIG_MLXSW_SPECTRUM_DCB 6198c2ecf20Sopenharmony_ciint mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); 6208c2ecf20Sopenharmony_civoid mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); 6218c2ecf20Sopenharmony_ci#else 6228c2ecf20Sopenharmony_cistatic inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) 6238c2ecf20Sopenharmony_ci{ 6248c2ecf20Sopenharmony_ci return 0; 6258c2ecf20Sopenharmony_ci} 6268c2ecf20Sopenharmony_cistatic inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) 6278c2ecf20Sopenharmony_ci{} 6288c2ecf20Sopenharmony_ci#endif 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci/* spectrum_router.c */ 6318c2ecf20Sopenharmony_cienum mlxsw_sp_l3proto { 6328c2ecf20Sopenharmony_ci MLXSW_SP_L3_PROTO_IPV4, 6338c2ecf20Sopenharmony_ci MLXSW_SP_L3_PROTO_IPV6, 6348c2ecf20Sopenharmony_ci#define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1) 6358c2ecf20Sopenharmony_ci}; 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ciunion mlxsw_sp_l3addr { 6388c2ecf20Sopenharmony_ci __be32 addr4; 6398c2ecf20Sopenharmony_ci struct in6_addr addr6; 6408c2ecf20Sopenharmony_ci}; 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ciint mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp, 6438c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 6448c2ecf20Sopenharmony_civoid mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); 6458c2ecf20Sopenharmony_ciint mlxsw_sp_netdevice_router_port_event(struct net_device *dev, 6468c2ecf20Sopenharmony_ci unsigned long event, void *ptr); 6478c2ecf20Sopenharmony_civoid mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp, 6488c2ecf20Sopenharmony_ci const struct net_device *macvlan_dev); 6498c2ecf20Sopenharmony_ciint mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused, 6508c2ecf20Sopenharmony_ci unsigned long event, void *ptr); 6518c2ecf20Sopenharmony_ciint mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, 6528c2ecf20Sopenharmony_ci unsigned long event, void *ptr); 6538c2ecf20Sopenharmony_ciint mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, 6548c2ecf20Sopenharmony_ci struct netdev_notifier_changeupper_info *info); 6558c2ecf20Sopenharmony_cibool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp, 6568c2ecf20Sopenharmony_ci const struct net_device *dev); 6578c2ecf20Sopenharmony_cibool mlxsw_sp_netdev_is_ipip_ul(struct mlxsw_sp *mlxsw_sp, 6588c2ecf20Sopenharmony_ci const struct net_device *dev); 6598c2ecf20Sopenharmony_ciint mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp, 6608c2ecf20Sopenharmony_ci struct net_device *l3_dev, 6618c2ecf20Sopenharmony_ci unsigned long event, 6628c2ecf20Sopenharmony_ci struct netdev_notifier_info *info); 6638c2ecf20Sopenharmony_ciint 6648c2ecf20Sopenharmony_cimlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, 6658c2ecf20Sopenharmony_ci struct net_device *l3_dev, 6668c2ecf20Sopenharmony_ci unsigned long event, 6678c2ecf20Sopenharmony_ci struct netdev_notifier_info *info); 6688c2ecf20Sopenharmony_civoid 6698c2ecf20Sopenharmony_cimlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 6708c2ecf20Sopenharmony_civoid mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, 6718c2ecf20Sopenharmony_ci struct net_device *dev); 6728c2ecf20Sopenharmony_cibool mlxsw_sp_rif_exists(struct mlxsw_sp *mlxsw_sp, 6738c2ecf20Sopenharmony_ci const struct net_device *dev); 6748c2ecf20Sopenharmony_ciu16 mlxsw_sp_rif_vid(struct mlxsw_sp *mlxsw_sp, const struct net_device *dev); 6758c2ecf20Sopenharmony_ciu8 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp); 6768c2ecf20Sopenharmony_ciint mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 6778c2ecf20Sopenharmony_ci enum mlxsw_sp_l3proto ul_proto, 6788c2ecf20Sopenharmony_ci const union mlxsw_sp_l3addr *ul_sip, 6798c2ecf20Sopenharmony_ci u32 tunnel_index); 6808c2ecf20Sopenharmony_civoid mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 6818c2ecf20Sopenharmony_ci enum mlxsw_sp_l3proto ul_proto, 6828c2ecf20Sopenharmony_ci const union mlxsw_sp_l3addr *ul_sip); 6838c2ecf20Sopenharmony_ciint mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id, 6848c2ecf20Sopenharmony_ci u16 *vr_id); 6858c2ecf20Sopenharmony_ciint mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 6868c2ecf20Sopenharmony_ci u16 *ul_rif_index); 6878c2ecf20Sopenharmony_civoid mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index); 6888c2ecf20Sopenharmony_ci 6898c2ecf20Sopenharmony_ci/* spectrum_kvdl.c */ 6908c2ecf20Sopenharmony_cienum mlxsw_sp_kvdl_entry_type { 6918c2ecf20Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 6928c2ecf20Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET, 6938c2ecf20Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_PBS, 6948c2ecf20Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR, 6958c2ecf20Sopenharmony_ci MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT, 6968c2ecf20Sopenharmony_ci}; 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_cistatic inline unsigned int 6998c2ecf20Sopenharmony_cimlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type) 7008c2ecf20Sopenharmony_ci{ 7018c2ecf20Sopenharmony_ci switch (type) { 7028c2ecf20Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ: 7038c2ecf20Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET: 7048c2ecf20Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_PBS: 7058c2ecf20Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR: 7068c2ecf20Sopenharmony_ci case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT: 7078c2ecf20Sopenharmony_ci default: 7088c2ecf20Sopenharmony_ci return 1; 7098c2ecf20Sopenharmony_ci } 7108c2ecf20Sopenharmony_ci} 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_cistruct mlxsw_sp_kvdl_ops { 7138c2ecf20Sopenharmony_ci size_t priv_size; 7148c2ecf20Sopenharmony_ci int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 7158c2ecf20Sopenharmony_ci void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 7168c2ecf20Sopenharmony_ci int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv, 7178c2ecf20Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 7188c2ecf20Sopenharmony_ci unsigned int entry_count, u32 *p_entry_index); 7198c2ecf20Sopenharmony_ci void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv, 7208c2ecf20Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 7218c2ecf20Sopenharmony_ci unsigned int entry_count, int entry_index); 7228c2ecf20Sopenharmony_ci int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv, 7238c2ecf20Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 7248c2ecf20Sopenharmony_ci unsigned int entry_count, 7258c2ecf20Sopenharmony_ci unsigned int *p_alloc_count); 7268c2ecf20Sopenharmony_ci int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv); 7278c2ecf20Sopenharmony_ci}; 7288c2ecf20Sopenharmony_ci 7298c2ecf20Sopenharmony_ciint mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp); 7308c2ecf20Sopenharmony_civoid mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp); 7318c2ecf20Sopenharmony_ciint mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, 7328c2ecf20Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 7338c2ecf20Sopenharmony_ci unsigned int entry_count, u32 *p_entry_index); 7348c2ecf20Sopenharmony_civoid mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, 7358c2ecf20Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 7368c2ecf20Sopenharmony_ci unsigned int entry_count, int entry_index); 7378c2ecf20Sopenharmony_ciint mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp, 7388c2ecf20Sopenharmony_ci enum mlxsw_sp_kvdl_entry_type type, 7398c2ecf20Sopenharmony_ci unsigned int entry_count, 7408c2ecf20Sopenharmony_ci unsigned int *p_alloc_count); 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_ci/* spectrum1_kvdl.c */ 7438c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops; 7448c2ecf20Sopenharmony_ciint mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core); 7458c2ecf20Sopenharmony_ci 7468c2ecf20Sopenharmony_ci/* spectrum2_kvdl.c */ 7478c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops; 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_rule_info { 7508c2ecf20Sopenharmony_ci unsigned int priority; 7518c2ecf20Sopenharmony_ci struct mlxsw_afk_element_values values; 7528c2ecf20Sopenharmony_ci struct mlxsw_afa_block *act_block; 7538c2ecf20Sopenharmony_ci u8 action_created:1, 7548c2ecf20Sopenharmony_ci ingress_bind_blocker:1, 7558c2ecf20Sopenharmony_ci egress_bind_blocker:1, 7568c2ecf20Sopenharmony_ci counter_valid:1, 7578c2ecf20Sopenharmony_ci policer_index_valid:1; 7588c2ecf20Sopenharmony_ci unsigned int counter_index; 7598c2ecf20Sopenharmony_ci u16 policer_index; 7608c2ecf20Sopenharmony_ci}; 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci/* spectrum_flow.c */ 7638c2ecf20Sopenharmony_cistruct mlxsw_sp_flow_block { 7648c2ecf20Sopenharmony_ci struct list_head binding_list; 7658c2ecf20Sopenharmony_ci struct { 7668c2ecf20Sopenharmony_ci struct list_head list; 7678c2ecf20Sopenharmony_ci unsigned int min_prio; 7688c2ecf20Sopenharmony_ci unsigned int max_prio; 7698c2ecf20Sopenharmony_ci } mall; 7708c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_ruleset *ruleset_zero; 7718c2ecf20Sopenharmony_ci struct mlxsw_sp *mlxsw_sp; 7728c2ecf20Sopenharmony_ci unsigned int rule_count; 7738c2ecf20Sopenharmony_ci unsigned int disable_count; 7748c2ecf20Sopenharmony_ci unsigned int ingress_blocker_rule_count; 7758c2ecf20Sopenharmony_ci unsigned int egress_blocker_rule_count; 7768c2ecf20Sopenharmony_ci unsigned int ingress_binding_count; 7778c2ecf20Sopenharmony_ci unsigned int egress_binding_count; 7788c2ecf20Sopenharmony_ci struct net *net; 7798c2ecf20Sopenharmony_ci}; 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_cistruct mlxsw_sp_flow_block_binding { 7828c2ecf20Sopenharmony_ci struct list_head list; 7838c2ecf20Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port; 7848c2ecf20Sopenharmony_ci bool ingress; 7858c2ecf20Sopenharmony_ci}; 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_cistatic inline struct mlxsw_sp * 7888c2ecf20Sopenharmony_cimlxsw_sp_flow_block_mlxsw_sp(struct mlxsw_sp_flow_block *block) 7898c2ecf20Sopenharmony_ci{ 7908c2ecf20Sopenharmony_ci return block->mlxsw_sp; 7918c2ecf20Sopenharmony_ci} 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_cistatic inline unsigned int 7948c2ecf20Sopenharmony_cimlxsw_sp_flow_block_rule_count(const struct mlxsw_sp_flow_block *block) 7958c2ecf20Sopenharmony_ci{ 7968c2ecf20Sopenharmony_ci return block ? block->rule_count : 0; 7978c2ecf20Sopenharmony_ci} 7988c2ecf20Sopenharmony_ci 7998c2ecf20Sopenharmony_cistatic inline void 8008c2ecf20Sopenharmony_cimlxsw_sp_flow_block_disable_inc(struct mlxsw_sp_flow_block *block) 8018c2ecf20Sopenharmony_ci{ 8028c2ecf20Sopenharmony_ci if (block) 8038c2ecf20Sopenharmony_ci block->disable_count++; 8048c2ecf20Sopenharmony_ci} 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_cistatic inline void 8078c2ecf20Sopenharmony_cimlxsw_sp_flow_block_disable_dec(struct mlxsw_sp_flow_block *block) 8088c2ecf20Sopenharmony_ci{ 8098c2ecf20Sopenharmony_ci if (block) 8108c2ecf20Sopenharmony_ci block->disable_count--; 8118c2ecf20Sopenharmony_ci} 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_cistatic inline bool 8148c2ecf20Sopenharmony_cimlxsw_sp_flow_block_disabled(const struct mlxsw_sp_flow_block *block) 8158c2ecf20Sopenharmony_ci{ 8168c2ecf20Sopenharmony_ci return block->disable_count; 8178c2ecf20Sopenharmony_ci} 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_cistatic inline bool 8208c2ecf20Sopenharmony_cimlxsw_sp_flow_block_is_egress_bound(const struct mlxsw_sp_flow_block *block) 8218c2ecf20Sopenharmony_ci{ 8228c2ecf20Sopenharmony_ci return block->egress_binding_count; 8238c2ecf20Sopenharmony_ci} 8248c2ecf20Sopenharmony_ci 8258c2ecf20Sopenharmony_cistatic inline bool 8268c2ecf20Sopenharmony_cimlxsw_sp_flow_block_is_ingress_bound(const struct mlxsw_sp_flow_block *block) 8278c2ecf20Sopenharmony_ci{ 8288c2ecf20Sopenharmony_ci return block->ingress_binding_count; 8298c2ecf20Sopenharmony_ci} 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_cistatic inline bool 8328c2ecf20Sopenharmony_cimlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block) 8338c2ecf20Sopenharmony_ci{ 8348c2ecf20Sopenharmony_ci return block->ingress_binding_count && block->egress_binding_count; 8358c2ecf20Sopenharmony_ci} 8368c2ecf20Sopenharmony_ci 8378c2ecf20Sopenharmony_cistruct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create(struct mlxsw_sp *mlxsw_sp, 8388c2ecf20Sopenharmony_ci struct net *net); 8398c2ecf20Sopenharmony_civoid mlxsw_sp_flow_block_destroy(struct mlxsw_sp_flow_block *block); 8408c2ecf20Sopenharmony_ciint mlxsw_sp_setup_tc_block_clsact(struct mlxsw_sp_port *mlxsw_sp_port, 8418c2ecf20Sopenharmony_ci struct flow_block_offload *f, 8428c2ecf20Sopenharmony_ci bool ingress); 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci/* spectrum_acl.c */ 8458c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_ruleset; 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_cienum mlxsw_sp_acl_profile { 8488c2ecf20Sopenharmony_ci MLXSW_SP_ACL_PROFILE_FLOWER, 8498c2ecf20Sopenharmony_ci MLXSW_SP_ACL_PROFILE_MR, 8508c2ecf20Sopenharmony_ci}; 8518c2ecf20Sopenharmony_ci 8528c2ecf20Sopenharmony_cistruct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_ciint mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp, 8558c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 8568c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block_binding *binding); 8578c2ecf20Sopenharmony_civoid mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp, 8588c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 8598c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block_binding *binding); 8608c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_ruleset * 8618c2ecf20Sopenharmony_cimlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, 8628c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, u32 chain_index, 8638c2ecf20Sopenharmony_ci enum mlxsw_sp_acl_profile profile); 8648c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_ruleset * 8658c2ecf20Sopenharmony_cimlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, 8668c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, u32 chain_index, 8678c2ecf20Sopenharmony_ci enum mlxsw_sp_acl_profile profile, 8688c2ecf20Sopenharmony_ci struct mlxsw_afk_element_usage *tmplt_elusage); 8698c2ecf20Sopenharmony_civoid mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, 8708c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_ruleset *ruleset); 8718c2ecf20Sopenharmony_ciu16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset); 8728c2ecf20Sopenharmony_civoid mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset, 8738c2ecf20Sopenharmony_ci unsigned int *p_min_prio, 8748c2ecf20Sopenharmony_ci unsigned int *p_max_prio); 8758c2ecf20Sopenharmony_ci 8768c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_rule_info * 8778c2ecf20Sopenharmony_cimlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl, 8788c2ecf20Sopenharmony_ci struct mlxsw_afa_block *afa_block); 8798c2ecf20Sopenharmony_civoid mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei); 8808c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); 8818c2ecf20Sopenharmony_civoid mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, 8828c2ecf20Sopenharmony_ci unsigned int priority); 8838c2ecf20Sopenharmony_civoid mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, 8848c2ecf20Sopenharmony_ci enum mlxsw_afk_element element, 8858c2ecf20Sopenharmony_ci u32 key_value, u32 mask_value); 8868c2ecf20Sopenharmony_civoid mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, 8878c2ecf20Sopenharmony_ci enum mlxsw_afk_element element, 8888c2ecf20Sopenharmony_ci const char *key_value, 8898c2ecf20Sopenharmony_ci const char *mask_value, unsigned int len); 8908c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); 8918c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, 8928c2ecf20Sopenharmony_ci u16 group_id); 8938c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei); 8948c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei, 8958c2ecf20Sopenharmony_ci bool ingress, 8968c2ecf20Sopenharmony_ci const struct flow_action_cookie *fa_cookie, 8978c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 8988c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); 8998c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp, 9008c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 9018c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 9028c2ecf20Sopenharmony_ci struct net_device *out_dev, 9038c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 9048c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, 9058c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 9068c2ecf20Sopenharmony_ci struct net_device *out_dev, 9078c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 9088c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp, 9098c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 9108c2ecf20Sopenharmony_ci u32 action, u16 vid, u16 proto, u8 prio, 9118c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 9128c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp, 9138c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 9148c2ecf20Sopenharmony_ci u32 prio, struct netlink_ext_ack *extack); 9158c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_mangle(struct mlxsw_sp *mlxsw_sp, 9168c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 9178c2ecf20Sopenharmony_ci enum flow_action_mangle_base htype, 9188c2ecf20Sopenharmony_ci u32 offset, u32 mask, u32 val, 9198c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 9208c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_police(struct mlxsw_sp *mlxsw_sp, 9218c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 9228c2ecf20Sopenharmony_ci u32 index, u64 rate_bytes_ps, 9238c2ecf20Sopenharmony_ci u32 burst, struct netlink_ext_ack *extack); 9248c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp, 9258c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 9268c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 9278c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp, 9288c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei, 9298c2ecf20Sopenharmony_ci u16 fid, struct netlink_ext_ack *extack); 9308c2ecf20Sopenharmony_ci 9318c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_rule; 9328c2ecf20Sopenharmony_ci 9338c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_rule * 9348c2ecf20Sopenharmony_cimlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp, 9358c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_ruleset *ruleset, 9368c2ecf20Sopenharmony_ci unsigned long cookie, 9378c2ecf20Sopenharmony_ci struct mlxsw_afa_block *afa_block, 9388c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 9398c2ecf20Sopenharmony_civoid mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp, 9408c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule *rule); 9418c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp, 9428c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule *rule); 9438c2ecf20Sopenharmony_civoid mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp, 9448c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule *rule); 9458c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp, 9468c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule *rule, 9478c2ecf20Sopenharmony_ci struct mlxsw_afa_block *afa_block); 9488c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_rule * 9498c2ecf20Sopenharmony_cimlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp, 9508c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_ruleset *ruleset, 9518c2ecf20Sopenharmony_ci unsigned long cookie); 9528c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_rule_info * 9538c2ecf20Sopenharmony_cimlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule); 9548c2ecf20Sopenharmony_ciint mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, 9558c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule *rule, 9568c2ecf20Sopenharmony_ci u64 *packets, u64 *bytes, u64 *drops, 9578c2ecf20Sopenharmony_ci u64 *last_use, 9588c2ecf20Sopenharmony_ci enum flow_action_hw_stats *used_hw_stats); 9598c2ecf20Sopenharmony_ci 9608c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); 9618c2ecf20Sopenharmony_ci 9628c2ecf20Sopenharmony_cistatic inline const struct flow_action_cookie * 9638c2ecf20Sopenharmony_cimlxsw_sp_acl_act_cookie_lookup(struct mlxsw_sp *mlxsw_sp, u32 cookie_index) 9648c2ecf20Sopenharmony_ci{ 9658c2ecf20Sopenharmony_ci return mlxsw_afa_cookie_lookup(mlxsw_sp->afa, cookie_index); 9668c2ecf20Sopenharmony_ci} 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_ciint mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); 9698c2ecf20Sopenharmony_civoid mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); 9708c2ecf20Sopenharmony_ciu32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp); 9718c2ecf20Sopenharmony_ciint mlxsw_sp_acl_region_rehash_intrvl_set(struct mlxsw_sp *mlxsw_sp, u32 val); 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_mangle_action; 9748c2ecf20Sopenharmony_ci 9758c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_rulei_ops { 9768c2ecf20Sopenharmony_ci int (*act_mangle_field)(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei, 9778c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_mangle_action *mact, u32 val, 9788c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 9798c2ecf20Sopenharmony_ci}; 9808c2ecf20Sopenharmony_ci 9818c2ecf20Sopenharmony_ciextern struct mlxsw_sp_acl_rulei_ops mlxsw_sp1_acl_rulei_ops; 9828c2ecf20Sopenharmony_ciextern struct mlxsw_sp_acl_rulei_ops mlxsw_sp2_acl_rulei_ops; 9838c2ecf20Sopenharmony_ci 9848c2ecf20Sopenharmony_ci/* spectrum_acl_tcam.c */ 9858c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_tcam; 9868c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_tcam_region; 9878c2ecf20Sopenharmony_ci 9888c2ecf20Sopenharmony_cistruct mlxsw_sp_acl_tcam_ops { 9898c2ecf20Sopenharmony_ci enum mlxsw_reg_ptar_key_type key_type; 9908c2ecf20Sopenharmony_ci size_t priv_size; 9918c2ecf20Sopenharmony_ci int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv, 9928c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_tcam *tcam); 9938c2ecf20Sopenharmony_ci void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 9948c2ecf20Sopenharmony_ci size_t region_priv_size; 9958c2ecf20Sopenharmony_ci int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv, 9968c2ecf20Sopenharmony_ci void *tcam_priv, 9978c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_tcam_region *region, 9988c2ecf20Sopenharmony_ci void *hints_priv); 9998c2ecf20Sopenharmony_ci void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv); 10008c2ecf20Sopenharmony_ci int (*region_associate)(struct mlxsw_sp *mlxsw_sp, 10018c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_tcam_region *region); 10028c2ecf20Sopenharmony_ci void * (*region_rehash_hints_get)(void *region_priv); 10038c2ecf20Sopenharmony_ci void (*region_rehash_hints_put)(void *hints_priv); 10048c2ecf20Sopenharmony_ci size_t chunk_priv_size; 10058c2ecf20Sopenharmony_ci void (*chunk_init)(void *region_priv, void *chunk_priv, 10068c2ecf20Sopenharmony_ci unsigned int priority); 10078c2ecf20Sopenharmony_ci void (*chunk_fini)(void *chunk_priv); 10088c2ecf20Sopenharmony_ci size_t entry_priv_size; 10098c2ecf20Sopenharmony_ci int (*entry_add)(struct mlxsw_sp *mlxsw_sp, 10108c2ecf20Sopenharmony_ci void *region_priv, void *chunk_priv, 10118c2ecf20Sopenharmony_ci void *entry_priv, 10128c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei); 10138c2ecf20Sopenharmony_ci void (*entry_del)(struct mlxsw_sp *mlxsw_sp, 10148c2ecf20Sopenharmony_ci void *region_priv, void *chunk_priv, 10158c2ecf20Sopenharmony_ci void *entry_priv); 10168c2ecf20Sopenharmony_ci int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp, 10178c2ecf20Sopenharmony_ci void *region_priv, void *entry_priv, 10188c2ecf20Sopenharmony_ci struct mlxsw_sp_acl_rule_info *rulei); 10198c2ecf20Sopenharmony_ci int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp, 10208c2ecf20Sopenharmony_ci void *region_priv, void *entry_priv, 10218c2ecf20Sopenharmony_ci bool *activity); 10228c2ecf20Sopenharmony_ci}; 10238c2ecf20Sopenharmony_ci 10248c2ecf20Sopenharmony_ci/* spectrum1_acl_tcam.c */ 10258c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops; 10268c2ecf20Sopenharmony_ci 10278c2ecf20Sopenharmony_ci/* spectrum2_acl_tcam.c */ 10288c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops; 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci/* spectrum_acl_flex_actions.c */ 10318c2ecf20Sopenharmony_ciextern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops; 10328c2ecf20Sopenharmony_ciextern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops; 10338c2ecf20Sopenharmony_ci 10348c2ecf20Sopenharmony_ci/* spectrum_acl_flex_keys.c */ 10358c2ecf20Sopenharmony_ciextern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops; 10368c2ecf20Sopenharmony_ciextern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops; 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_ci/* spectrum_matchall.c */ 10398c2ecf20Sopenharmony_cienum mlxsw_sp_mall_action_type { 10408c2ecf20Sopenharmony_ci MLXSW_SP_MALL_ACTION_TYPE_MIRROR, 10418c2ecf20Sopenharmony_ci MLXSW_SP_MALL_ACTION_TYPE_SAMPLE, 10428c2ecf20Sopenharmony_ci MLXSW_SP_MALL_ACTION_TYPE_TRAP, 10438c2ecf20Sopenharmony_ci}; 10448c2ecf20Sopenharmony_ci 10458c2ecf20Sopenharmony_cistruct mlxsw_sp_mall_mirror_entry { 10468c2ecf20Sopenharmony_ci const struct net_device *to_dev; 10478c2ecf20Sopenharmony_ci int span_id; 10488c2ecf20Sopenharmony_ci}; 10498c2ecf20Sopenharmony_ci 10508c2ecf20Sopenharmony_cistruct mlxsw_sp_mall_trap_entry { 10518c2ecf20Sopenharmony_ci int span_id; 10528c2ecf20Sopenharmony_ci}; 10538c2ecf20Sopenharmony_ci 10548c2ecf20Sopenharmony_cistruct mlxsw_sp_mall_entry { 10558c2ecf20Sopenharmony_ci struct list_head list; 10568c2ecf20Sopenharmony_ci unsigned long cookie; 10578c2ecf20Sopenharmony_ci unsigned int priority; 10588c2ecf20Sopenharmony_ci enum mlxsw_sp_mall_action_type type; 10598c2ecf20Sopenharmony_ci bool ingress; 10608c2ecf20Sopenharmony_ci union { 10618c2ecf20Sopenharmony_ci struct mlxsw_sp_mall_mirror_entry mirror; 10628c2ecf20Sopenharmony_ci struct mlxsw_sp_mall_trap_entry trap; 10638c2ecf20Sopenharmony_ci struct mlxsw_sp_port_sample sample; 10648c2ecf20Sopenharmony_ci }; 10658c2ecf20Sopenharmony_ci struct rcu_head rcu; 10668c2ecf20Sopenharmony_ci}; 10678c2ecf20Sopenharmony_ci 10688c2ecf20Sopenharmony_ciint mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp, 10698c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 10708c2ecf20Sopenharmony_ci struct tc_cls_matchall_offload *f); 10718c2ecf20Sopenharmony_civoid mlxsw_sp_mall_destroy(struct mlxsw_sp_flow_block *block, 10728c2ecf20Sopenharmony_ci struct tc_cls_matchall_offload *f); 10738c2ecf20Sopenharmony_ciint mlxsw_sp_mall_port_bind(struct mlxsw_sp_flow_block *block, 10748c2ecf20Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port); 10758c2ecf20Sopenharmony_civoid mlxsw_sp_mall_port_unbind(struct mlxsw_sp_flow_block *block, 10768c2ecf20Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port); 10778c2ecf20Sopenharmony_ciint mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index, 10788c2ecf20Sopenharmony_ci unsigned int *p_min_prio, unsigned int *p_max_prio); 10798c2ecf20Sopenharmony_ci 10808c2ecf20Sopenharmony_ci/* spectrum_flower.c */ 10818c2ecf20Sopenharmony_ciint mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp, 10828c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 10838c2ecf20Sopenharmony_ci struct flow_cls_offload *f); 10848c2ecf20Sopenharmony_civoid mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp, 10858c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 10868c2ecf20Sopenharmony_ci struct flow_cls_offload *f); 10878c2ecf20Sopenharmony_ciint mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp, 10888c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 10898c2ecf20Sopenharmony_ci struct flow_cls_offload *f); 10908c2ecf20Sopenharmony_ciint mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp, 10918c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 10928c2ecf20Sopenharmony_ci struct flow_cls_offload *f); 10938c2ecf20Sopenharmony_civoid mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp, 10948c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 10958c2ecf20Sopenharmony_ci struct flow_cls_offload *f); 10968c2ecf20Sopenharmony_ciint mlxsw_sp_flower_prio_get(struct mlxsw_sp *mlxsw_sp, 10978c2ecf20Sopenharmony_ci struct mlxsw_sp_flow_block *block, 10988c2ecf20Sopenharmony_ci u32 chain_index, unsigned int *p_min_prio, 10998c2ecf20Sopenharmony_ci unsigned int *p_max_prio); 11008c2ecf20Sopenharmony_ci 11018c2ecf20Sopenharmony_ci/* spectrum_qdisc.c */ 11028c2ecf20Sopenharmony_ciint mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port); 11038c2ecf20Sopenharmony_civoid mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port); 11048c2ecf20Sopenharmony_ciint mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, 11058c2ecf20Sopenharmony_ci struct tc_red_qopt_offload *p); 11068c2ecf20Sopenharmony_ciint mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port, 11078c2ecf20Sopenharmony_ci struct tc_prio_qopt_offload *p); 11088c2ecf20Sopenharmony_ciint mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port, 11098c2ecf20Sopenharmony_ci struct tc_ets_qopt_offload *p); 11108c2ecf20Sopenharmony_ciint mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port, 11118c2ecf20Sopenharmony_ci struct tc_tbf_qopt_offload *p); 11128c2ecf20Sopenharmony_ciint mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port, 11138c2ecf20Sopenharmony_ci struct tc_fifo_qopt_offload *p); 11148c2ecf20Sopenharmony_ciint mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port, 11158c2ecf20Sopenharmony_ci struct flow_block_offload *f); 11168c2ecf20Sopenharmony_ci 11178c2ecf20Sopenharmony_ci/* spectrum_fid.c */ 11188c2ecf20Sopenharmony_cibool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index); 11198c2ecf20Sopenharmony_cibool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid); 11208c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp, 11218c2ecf20Sopenharmony_ci u16 fid_index); 11228c2ecf20Sopenharmony_ciint mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex); 11238c2ecf20Sopenharmony_ciint mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid, 11248c2ecf20Sopenharmony_ci enum mlxsw_sp_nve_type *p_type); 11258c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp, 11268c2ecf20Sopenharmony_ci __be32 vni); 11278c2ecf20Sopenharmony_ciint mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni); 11288c2ecf20Sopenharmony_ciint mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid, 11298c2ecf20Sopenharmony_ci u32 nve_flood_index); 11308c2ecf20Sopenharmony_civoid mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid); 11318c2ecf20Sopenharmony_cibool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid); 11328c2ecf20Sopenharmony_ciint mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type, 11338c2ecf20Sopenharmony_ci __be32 vni, int nve_ifindex); 11348c2ecf20Sopenharmony_civoid mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid); 11358c2ecf20Sopenharmony_cibool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid); 11368c2ecf20Sopenharmony_civoid mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid, 11378c2ecf20Sopenharmony_ci const struct net_device *nve_dev); 11388c2ecf20Sopenharmony_ciint mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, 11398c2ecf20Sopenharmony_ci enum mlxsw_sp_flood_type packet_type, u8 local_port, 11408c2ecf20Sopenharmony_ci bool member); 11418c2ecf20Sopenharmony_ciint mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid, 11428c2ecf20Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 11438c2ecf20Sopenharmony_civoid mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid, 11448c2ecf20Sopenharmony_ci struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 11458c2ecf20Sopenharmony_ciu16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid); 11468c2ecf20Sopenharmony_cienum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid); 11478c2ecf20Sopenharmony_civoid mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif); 11488c2ecf20Sopenharmony_cistruct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid); 11498c2ecf20Sopenharmony_cienum mlxsw_sp_rif_type 11508c2ecf20Sopenharmony_cimlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp, 11518c2ecf20Sopenharmony_ci enum mlxsw_sp_fid_type type); 11528c2ecf20Sopenharmony_ciu16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid); 11538c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid); 11548c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp, 11558c2ecf20Sopenharmony_ci int br_ifindex); 11568c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp, 11578c2ecf20Sopenharmony_ci u16 vid); 11588c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp, 11598c2ecf20Sopenharmony_ci int br_ifindex); 11608c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp, 11618c2ecf20Sopenharmony_ci u16 rif_index); 11628c2ecf20Sopenharmony_cistruct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp); 11638c2ecf20Sopenharmony_civoid mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid); 11648c2ecf20Sopenharmony_ciint mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port); 11658c2ecf20Sopenharmony_civoid mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port); 11668c2ecf20Sopenharmony_ciint mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp); 11678c2ecf20Sopenharmony_civoid mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp); 11688c2ecf20Sopenharmony_ci 11698c2ecf20Sopenharmony_ci/* spectrum_mr.c */ 11708c2ecf20Sopenharmony_cienum mlxsw_sp_mr_route_prio { 11718c2ecf20Sopenharmony_ci MLXSW_SP_MR_ROUTE_PRIO_SG, 11728c2ecf20Sopenharmony_ci MLXSW_SP_MR_ROUTE_PRIO_STARG, 11738c2ecf20Sopenharmony_ci MLXSW_SP_MR_ROUTE_PRIO_CATCHALL, 11748c2ecf20Sopenharmony_ci __MLXSW_SP_MR_ROUTE_PRIO_MAX 11758c2ecf20Sopenharmony_ci}; 11768c2ecf20Sopenharmony_ci 11778c2ecf20Sopenharmony_ci#define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1) 11788c2ecf20Sopenharmony_ci 11798c2ecf20Sopenharmony_cistruct mlxsw_sp_mr_route_key; 11808c2ecf20Sopenharmony_ci 11818c2ecf20Sopenharmony_cistruct mlxsw_sp_mr_tcam_ops { 11828c2ecf20Sopenharmony_ci size_t priv_size; 11838c2ecf20Sopenharmony_ci int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 11848c2ecf20Sopenharmony_ci void (*fini)(void *priv); 11858c2ecf20Sopenharmony_ci size_t route_priv_size; 11868c2ecf20Sopenharmony_ci int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv, 11878c2ecf20Sopenharmony_ci void *route_priv, 11888c2ecf20Sopenharmony_ci struct mlxsw_sp_mr_route_key *key, 11898c2ecf20Sopenharmony_ci struct mlxsw_afa_block *afa_block, 11908c2ecf20Sopenharmony_ci enum mlxsw_sp_mr_route_prio prio); 11918c2ecf20Sopenharmony_ci void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv, 11928c2ecf20Sopenharmony_ci void *route_priv, 11938c2ecf20Sopenharmony_ci struct mlxsw_sp_mr_route_key *key); 11948c2ecf20Sopenharmony_ci int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 11958c2ecf20Sopenharmony_ci struct mlxsw_sp_mr_route_key *key, 11968c2ecf20Sopenharmony_ci struct mlxsw_afa_block *afa_block); 11978c2ecf20Sopenharmony_ci}; 11988c2ecf20Sopenharmony_ci 11998c2ecf20Sopenharmony_ci/* spectrum1_mr_tcam.c */ 12008c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops; 12018c2ecf20Sopenharmony_ci 12028c2ecf20Sopenharmony_ci/* spectrum2_mr_tcam.c */ 12038c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops; 12048c2ecf20Sopenharmony_ci 12058c2ecf20Sopenharmony_ci/* spectrum_nve.c */ 12068c2ecf20Sopenharmony_cistruct mlxsw_sp_nve_params { 12078c2ecf20Sopenharmony_ci enum mlxsw_sp_nve_type type; 12088c2ecf20Sopenharmony_ci __be32 vni; 12098c2ecf20Sopenharmony_ci const struct net_device *dev; 12108c2ecf20Sopenharmony_ci}; 12118c2ecf20Sopenharmony_ci 12128c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[]; 12138c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[]; 12148c2ecf20Sopenharmony_ci 12158c2ecf20Sopenharmony_ciint mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip, 12168c2ecf20Sopenharmony_ci enum mlxsw_sp_l3proto proto, 12178c2ecf20Sopenharmony_ci union mlxsw_sp_l3addr *addr); 12188c2ecf20Sopenharmony_ciint mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp, 12198c2ecf20Sopenharmony_ci struct mlxsw_sp_fid *fid, 12208c2ecf20Sopenharmony_ci enum mlxsw_sp_l3proto proto, 12218c2ecf20Sopenharmony_ci union mlxsw_sp_l3addr *addr); 12228c2ecf20Sopenharmony_civoid mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp, 12238c2ecf20Sopenharmony_ci struct mlxsw_sp_fid *fid, 12248c2ecf20Sopenharmony_ci enum mlxsw_sp_l3proto proto, 12258c2ecf20Sopenharmony_ci union mlxsw_sp_l3addr *addr); 12268c2ecf20Sopenharmony_ciint mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, 12278c2ecf20Sopenharmony_ci struct mlxsw_sp_nve_params *params, 12288c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12298c2ecf20Sopenharmony_civoid mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp, 12308c2ecf20Sopenharmony_ci struct mlxsw_sp_fid *fid); 12318c2ecf20Sopenharmony_ciint mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port); 12328c2ecf20Sopenharmony_civoid mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port); 12338c2ecf20Sopenharmony_ciint mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp); 12348c2ecf20Sopenharmony_civoid mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp); 12358c2ecf20Sopenharmony_ci 12368c2ecf20Sopenharmony_ci/* spectrum_nve_vxlan.c */ 12378c2ecf20Sopenharmony_ciint mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp); 12388c2ecf20Sopenharmony_civoid mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp); 12398c2ecf20Sopenharmony_ci 12408c2ecf20Sopenharmony_ci/* spectrum_trap.c */ 12418c2ecf20Sopenharmony_ciint mlxsw_sp_devlink_traps_init(struct mlxsw_sp *mlxsw_sp); 12428c2ecf20Sopenharmony_civoid mlxsw_sp_devlink_traps_fini(struct mlxsw_sp *mlxsw_sp); 12438c2ecf20Sopenharmony_ciint mlxsw_sp_trap_init(struct mlxsw_core *mlxsw_core, 12448c2ecf20Sopenharmony_ci const struct devlink_trap *trap, void *trap_ctx); 12458c2ecf20Sopenharmony_civoid mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core, 12468c2ecf20Sopenharmony_ci const struct devlink_trap *trap, void *trap_ctx); 12478c2ecf20Sopenharmony_ciint mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, 12488c2ecf20Sopenharmony_ci const struct devlink_trap *trap, 12498c2ecf20Sopenharmony_ci enum devlink_trap_action action, 12508c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12518c2ecf20Sopenharmony_ciint mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, 12528c2ecf20Sopenharmony_ci const struct devlink_trap_group *group); 12538c2ecf20Sopenharmony_ciint mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core, 12548c2ecf20Sopenharmony_ci const struct devlink_trap_group *group, 12558c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer, 12568c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 12578c2ecf20Sopenharmony_ciint 12588c2ecf20Sopenharmony_cimlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core, 12598c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer); 12608c2ecf20Sopenharmony_civoid mlxsw_sp_trap_policer_fini(struct mlxsw_core *mlxsw_core, 12618c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer); 12628c2ecf20Sopenharmony_ciint 12638c2ecf20Sopenharmony_cimlxsw_sp_trap_policer_set(struct mlxsw_core *mlxsw_core, 12648c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer, 12658c2ecf20Sopenharmony_ci u64 rate, u64 burst, struct netlink_ext_ack *extack); 12668c2ecf20Sopenharmony_ciint 12678c2ecf20Sopenharmony_cimlxsw_sp_trap_policer_counter_get(struct mlxsw_core *mlxsw_core, 12688c2ecf20Sopenharmony_ci const struct devlink_trap_policer *policer, 12698c2ecf20Sopenharmony_ci u64 *p_drops); 12708c2ecf20Sopenharmony_ciint mlxsw_sp_trap_group_policer_hw_id_get(struct mlxsw_sp *mlxsw_sp, u16 id, 12718c2ecf20Sopenharmony_ci bool *p_enabled, u16 *p_hw_id); 12728c2ecf20Sopenharmony_ci 12738c2ecf20Sopenharmony_cistatic inline struct net *mlxsw_sp_net(struct mlxsw_sp *mlxsw_sp) 12748c2ecf20Sopenharmony_ci{ 12758c2ecf20Sopenharmony_ci return mlxsw_core_net(mlxsw_sp->core); 12768c2ecf20Sopenharmony_ci} 12778c2ecf20Sopenharmony_ci 12788c2ecf20Sopenharmony_ci/* spectrum_ethtool.c */ 12798c2ecf20Sopenharmony_ciextern const struct ethtool_ops mlxsw_sp_port_ethtool_ops; 12808c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops; 12818c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops; 12828c2ecf20Sopenharmony_ci 12838c2ecf20Sopenharmony_ci/* spectrum_policer.c */ 12848c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_policer_core_ops mlxsw_sp1_policer_core_ops; 12858c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_policer_core_ops mlxsw_sp2_policer_core_ops; 12868c2ecf20Sopenharmony_ci 12878c2ecf20Sopenharmony_cienum mlxsw_sp_policer_type { 12888c2ecf20Sopenharmony_ci MLXSW_SP_POLICER_TYPE_SINGLE_RATE, 12898c2ecf20Sopenharmony_ci 12908c2ecf20Sopenharmony_ci __MLXSW_SP_POLICER_TYPE_MAX, 12918c2ecf20Sopenharmony_ci MLXSW_SP_POLICER_TYPE_MAX = __MLXSW_SP_POLICER_TYPE_MAX - 1, 12928c2ecf20Sopenharmony_ci}; 12938c2ecf20Sopenharmony_ci 12948c2ecf20Sopenharmony_cistruct mlxsw_sp_policer_params { 12958c2ecf20Sopenharmony_ci u64 rate; 12968c2ecf20Sopenharmony_ci u64 burst; 12978c2ecf20Sopenharmony_ci bool bytes; 12988c2ecf20Sopenharmony_ci}; 12998c2ecf20Sopenharmony_ci 13008c2ecf20Sopenharmony_ciint mlxsw_sp_policer_add(struct mlxsw_sp *mlxsw_sp, 13018c2ecf20Sopenharmony_ci enum mlxsw_sp_policer_type type, 13028c2ecf20Sopenharmony_ci const struct mlxsw_sp_policer_params *params, 13038c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack, u16 *p_policer_index); 13048c2ecf20Sopenharmony_civoid mlxsw_sp_policer_del(struct mlxsw_sp *mlxsw_sp, 13058c2ecf20Sopenharmony_ci enum mlxsw_sp_policer_type type, 13068c2ecf20Sopenharmony_ci u16 policer_index); 13078c2ecf20Sopenharmony_ciint mlxsw_sp_policer_drops_counter_get(struct mlxsw_sp *mlxsw_sp, 13088c2ecf20Sopenharmony_ci enum mlxsw_sp_policer_type type, 13098c2ecf20Sopenharmony_ci u16 policer_index, u64 *p_drops); 13108c2ecf20Sopenharmony_ciint mlxsw_sp_policers_init(struct mlxsw_sp *mlxsw_sp); 13118c2ecf20Sopenharmony_civoid mlxsw_sp_policers_fini(struct mlxsw_sp *mlxsw_sp); 13128c2ecf20Sopenharmony_ciint mlxsw_sp_policer_resources_register(struct mlxsw_core *mlxsw_core); 13138c2ecf20Sopenharmony_ci 13148c2ecf20Sopenharmony_ci#endif 1315