1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
3 
4 #ifndef _MLXSW_CORE_H
5 #define _MLXSW_CORE_H
6 
7 #include <linux/module.h>
8 #include <linux/device.h>
9 #include <linux/slab.h>
10 #include <linux/gfp.h>
11 #include <linux/types.h>
12 #include <linux/skbuff.h>
13 #include <linux/workqueue.h>
14 #include <linux/net_namespace.h>
15 #include <net/devlink.h>
16 
17 #include "trap.h"
18 #include "reg.h"
19 #include "cmd.h"
20 #include "resources.h"
21 
22 enum mlxsw_core_resource_id {
23 	MLXSW_CORE_RESOURCE_PORTS = 1,
24 	MLXSW_CORE_RESOURCE_MAX,
25 };
26 
27 struct mlxsw_core;
28 struct mlxsw_core_port;
29 struct mlxsw_driver;
30 struct mlxsw_bus;
31 struct mlxsw_bus_info;
32 struct mlxsw_fw_rev;
33 
34 unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
35 
36 void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
37 
38 bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
39 
40 bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core);
41 
42 bool
43 mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
44 					  const struct mlxsw_fw_rev *req_rev);
45 
46 int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
47 void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
48 
49 int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
50 				   const struct mlxsw_bus *mlxsw_bus,
51 				   void *bus_priv, bool reload,
52 				   struct devlink *devlink,
53 				   struct netlink_ext_ack *extack);
54 void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, bool reload);
55 
56 struct mlxsw_tx_info {
57 	u16 local_port;
58 	bool is_emad;
59 };
60 
61 struct mlxsw_rx_md_info {
62 	u32 cookie_index;
63 	u32 latency;
64 	u32 tx_congestion;
65 	union {
66 		/* Valid when 'tx_port_valid' is set. */
67 		u16 tx_sys_port;
68 		u16 tx_lag_id;
69 	};
70 	u16 tx_lag_port_index; /* Valid when 'tx_port_is_lag' is set. */
71 	u8 tx_tc;
72 	u8 latency_valid:1,
73 	   tx_congestion_valid:1,
74 	   tx_tc_valid:1,
75 	   tx_port_valid:1,
76 	   tx_port_is_lag:1,
77 	   unused:3;
78 };
79 
80 bool mlxsw_core_skb_transmit_busy(struct mlxsw_core *mlxsw_core,
81 				  const struct mlxsw_tx_info *tx_info);
82 int mlxsw_core_skb_transmit(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
83 			    const struct mlxsw_tx_info *tx_info);
84 void mlxsw_core_ptp_transmitted(struct mlxsw_core *mlxsw_core,
85 				struct sk_buff *skb, u16 local_port);
86 
87 struct mlxsw_rx_listener {
88 	void (*func)(struct sk_buff *skb, u16 local_port, void *priv);
89 	u16 local_port;
90 	u8 mirror_reason;
91 	u16 trap_id;
92 };
93 
94 struct mlxsw_event_listener {
95 	void (*func)(const struct mlxsw_reg_info *reg,
96 		     char *payload, void *priv);
97 	enum mlxsw_event_trap_id trap_id;
98 };
99 
100 struct mlxsw_listener {
101 	u16 trap_id;
102 	union {
103 		struct mlxsw_rx_listener rx_listener;
104 		struct mlxsw_event_listener event_listener;
105 	};
106 	enum mlxsw_reg_hpkt_action en_action; /* Action when enabled */
107 	enum mlxsw_reg_hpkt_action dis_action; /* Action when disabled */
108 	u8 en_trap_group; /* Trap group when enabled */
109 	u8 dis_trap_group; /* Trap group when disabled */
110 	u8 is_ctrl:1, /* should go via control buffer or not */
111 	   is_event:1,
112 	   enabled_on_register:1; /* Trap should be enabled when listener
113 				   * is registered.
114 				   */
115 };
116 
117 #define __MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _en_trap_group,	\
118 		    _dis_action, _enabled_on_register, _dis_trap_group,		\
119 		    _mirror_reason)						\
120 	{									\
121 		.trap_id = MLXSW_TRAP_ID_##_trap_id,				\
122 		.rx_listener =							\
123 		{								\
124 			.func = _func,						\
125 			.local_port = MLXSW_PORT_DONT_CARE,			\
126 			.mirror_reason = _mirror_reason,			\
127 			.trap_id = MLXSW_TRAP_ID_##_trap_id,			\
128 		},								\
129 		.en_action = MLXSW_REG_HPKT_ACTION_##_en_action,		\
130 		.dis_action = MLXSW_REG_HPKT_ACTION_##_dis_action,		\
131 		.en_trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_en_trap_group,	\
132 		.dis_trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_dis_trap_group,	\
133 		.is_ctrl = _is_ctrl,						\
134 		.enabled_on_register = _enabled_on_register,			\
135 	}
136 
137 #define MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _trap_group,		\
138 		  _dis_action)							\
139 	__MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _trap_group,		\
140 		    _dis_action, true, _trap_group, 0)
141 
142 #define MLXSW_RXL_DIS(_func, _trap_id, _en_action, _is_ctrl, _en_trap_group,	\
143 		      _dis_action, _dis_trap_group)				\
144 	__MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _en_trap_group,	\
145 		    _dis_action, false, _dis_trap_group, 0)
146 
147 #define MLXSW_RXL_MIRROR(_func, _session_id, _trap_group, _mirror_reason)	\
148 	__MLXSW_RXL(_func, MIRROR_SESSION##_session_id,	TRAP_TO_CPU, false,	\
149 		    _trap_group, TRAP_TO_CPU, true, _trap_group,		\
150 		    _mirror_reason)
151 
152 #define MLXSW_EVENTL(_func, _trap_id, _trap_group)				\
153 	{									\
154 		.trap_id = MLXSW_TRAP_ID_##_trap_id,				\
155 		.event_listener =						\
156 		{								\
157 			.func = _func,						\
158 			.trap_id = MLXSW_TRAP_ID_##_trap_id,			\
159 		},								\
160 		.en_action = MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,			\
161 		.en_trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_trap_group,	\
162 		.is_event = true,						\
163 		.enabled_on_register = true,					\
164 	}
165 
166 int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core,
167 				    const struct mlxsw_rx_listener *rxl,
168 				    void *priv, bool enabled);
169 void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core,
170 				       const struct mlxsw_rx_listener *rxl);
171 
172 int mlxsw_core_event_listener_register(struct mlxsw_core *mlxsw_core,
173 				       const struct mlxsw_event_listener *el,
174 				       void *priv);
175 void mlxsw_core_event_listener_unregister(struct mlxsw_core *mlxsw_core,
176 					  const struct mlxsw_event_listener *el);
177 
178 int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core,
179 			     const struct mlxsw_listener *listener,
180 			     void *priv);
181 void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core,
182 				const struct mlxsw_listener *listener,
183 				void *priv);
184 int mlxsw_core_trap_state_set(struct mlxsw_core *mlxsw_core,
185 			      const struct mlxsw_listener *listener,
186 			      bool enabled);
187 
188 typedef void mlxsw_reg_trans_cb_t(struct mlxsw_core *mlxsw_core, char *payload,
189 				  size_t payload_len, unsigned long cb_priv);
190 
191 int mlxsw_reg_trans_query(struct mlxsw_core *mlxsw_core,
192 			  const struct mlxsw_reg_info *reg, char *payload,
193 			  struct list_head *bulk_list,
194 			  mlxsw_reg_trans_cb_t *cb, unsigned long cb_priv);
195 int mlxsw_reg_trans_write(struct mlxsw_core *mlxsw_core,
196 			  const struct mlxsw_reg_info *reg, char *payload,
197 			  struct list_head *bulk_list,
198 			  mlxsw_reg_trans_cb_t *cb, unsigned long cb_priv);
199 int mlxsw_reg_trans_bulk_wait(struct list_head *bulk_list);
200 
201 int mlxsw_reg_query(struct mlxsw_core *mlxsw_core,
202 		    const struct mlxsw_reg_info *reg, char *payload);
203 int mlxsw_reg_write(struct mlxsw_core *mlxsw_core,
204 		    const struct mlxsw_reg_info *reg, char *payload);
205 
206 struct mlxsw_rx_info {
207 	bool is_lag;
208 	union {
209 		u16 sys_port;
210 		u16 lag_id;
211 	} u;
212 	u16 lag_port_index;
213 	u8 mirror_reason;
214 	int trap_id;
215 };
216 
217 void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
218 			    struct mlxsw_rx_info *rx_info);
219 
220 void mlxsw_core_lag_mapping_set(struct mlxsw_core *mlxsw_core,
221 				u16 lag_id, u8 port_index, u16 local_port);
222 u16 mlxsw_core_lag_mapping_get(struct mlxsw_core *mlxsw_core,
223 			       u16 lag_id, u8 port_index);
224 void mlxsw_core_lag_mapping_clear(struct mlxsw_core *mlxsw_core,
225 				  u16 lag_id, u16 local_port);
226 
227 void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port);
228 int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u16 local_port,
229 			 u32 port_number, bool split, u32 split_port_subnumber,
230 			 bool splittable, u32 lanes,
231 			 const unsigned char *switch_id,
232 			 unsigned char switch_id_len);
233 void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u16 local_port);
234 int mlxsw_core_cpu_port_init(struct mlxsw_core *mlxsw_core,
235 			     void *port_driver_priv,
236 			     const unsigned char *switch_id,
237 			     unsigned char switch_id_len);
238 void mlxsw_core_cpu_port_fini(struct mlxsw_core *mlxsw_core);
239 void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u16 local_port,
240 			     void *port_driver_priv, struct net_device *dev);
241 void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u16 local_port,
242 			    void *port_driver_priv);
243 void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u16 local_port,
244 			   void *port_driver_priv);
245 enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
246 						u16 local_port);
247 struct devlink_port *
248 mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
249 				 u16 local_port);
250 bool mlxsw_core_port_is_xm(const struct mlxsw_core *mlxsw_core, u16 local_port);
251 struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core);
252 
253 int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
254 bool mlxsw_core_schedule_work(struct work_struct *work);
255 void mlxsw_core_flush_owq(void);
256 int mlxsw_core_resources_query(struct mlxsw_core *mlxsw_core, char *mbox,
257 			       struct mlxsw_res *res);
258 
259 #define MLXSW_CONFIG_PROFILE_SWID_COUNT 8
260 
261 struct mlxsw_swid_config {
262 	u8	used_type:1,
263 		used_properties:1;
264 	u8	type;
265 	u8	properties;
266 };
267 
268 struct mlxsw_config_profile {
269 	u16	used_max_vepa_channels:1,
270 		used_max_mid:1,
271 		used_max_pgt:1,
272 		used_max_system_port:1,
273 		used_max_vlan_groups:1,
274 		used_max_regions:1,
275 		used_flood_tables:1,
276 		used_flood_mode:1,
277 		used_max_ib_mc:1,
278 		used_max_pkey:1,
279 		used_ar_sec:1,
280 		used_adaptive_routing_group_cap:1,
281 		used_kvd_sizes:1,
282 		used_kvh_xlt_cache_mode:1;
283 	u8	max_vepa_channels;
284 	u16	max_mid;
285 	u16	max_pgt;
286 	u16	max_system_port;
287 	u16	max_vlan_groups;
288 	u16	max_regions;
289 	u8	max_flood_tables;
290 	u8	max_vid_flood_tables;
291 	u8	flood_mode;
292 	u8	max_fid_offset_flood_tables;
293 	u16	fid_offset_flood_table_size;
294 	u8	max_fid_flood_tables;
295 	u16	fid_flood_table_size;
296 	u16	max_ib_mc;
297 	u16	max_pkey;
298 	u8	ar_sec;
299 	u16	adaptive_routing_group_cap;
300 	u8	arn;
301 	u32	kvd_linear_size;
302 	u8	kvd_hash_single_parts;
303 	u8	kvd_hash_double_parts;
304 	u8	kvh_xlt_cache_mode;
305 	struct mlxsw_swid_config swid_config[MLXSW_CONFIG_PROFILE_SWID_COUNT];
306 };
307 
308 struct mlxsw_driver {
309 	struct list_head list;
310 	const char *kind;
311 	size_t priv_size;
312 	const struct mlxsw_fw_rev *fw_req_rev;
313 	const char *fw_filename;
314 	int (*init)(struct mlxsw_core *mlxsw_core,
315 		    const struct mlxsw_bus_info *mlxsw_bus_info,
316 		    struct netlink_ext_ack *extack);
317 	void (*fini)(struct mlxsw_core *mlxsw_core);
318 	int (*basic_trap_groups_set)(struct mlxsw_core *mlxsw_core);
319 	int (*port_type_set)(struct mlxsw_core *mlxsw_core, u16 local_port,
320 			     enum devlink_port_type new_type);
321 	int (*port_split)(struct mlxsw_core *mlxsw_core, u16 local_port,
322 			  unsigned int count, struct netlink_ext_ack *extack);
323 	int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u16 local_port,
324 			    struct netlink_ext_ack *extack);
325 	int (*sb_pool_get)(struct mlxsw_core *mlxsw_core,
326 			   unsigned int sb_index, u16 pool_index,
327 			   struct devlink_sb_pool_info *pool_info);
328 	int (*sb_pool_set)(struct mlxsw_core *mlxsw_core,
329 			   unsigned int sb_index, u16 pool_index, u32 size,
330 			   enum devlink_sb_threshold_type threshold_type,
331 			   struct netlink_ext_ack *extack);
332 	int (*sb_port_pool_get)(struct mlxsw_core_port *mlxsw_core_port,
333 				unsigned int sb_index, u16 pool_index,
334 				u32 *p_threshold);
335 	int (*sb_port_pool_set)(struct mlxsw_core_port *mlxsw_core_port,
336 				unsigned int sb_index, u16 pool_index,
337 				u32 threshold, struct netlink_ext_ack *extack);
338 	int (*sb_tc_pool_bind_get)(struct mlxsw_core_port *mlxsw_core_port,
339 				   unsigned int sb_index, u16 tc_index,
340 				   enum devlink_sb_pool_type pool_type,
341 				   u16 *p_pool_index, u32 *p_threshold);
342 	int (*sb_tc_pool_bind_set)(struct mlxsw_core_port *mlxsw_core_port,
343 				   unsigned int sb_index, u16 tc_index,
344 				   enum devlink_sb_pool_type pool_type,
345 				   u16 pool_index, u32 threshold,
346 				   struct netlink_ext_ack *extack);
347 	int (*sb_occ_snapshot)(struct mlxsw_core *mlxsw_core,
348 			       unsigned int sb_index);
349 	int (*sb_occ_max_clear)(struct mlxsw_core *mlxsw_core,
350 				unsigned int sb_index);
351 	int (*sb_occ_port_pool_get)(struct mlxsw_core_port *mlxsw_core_port,
352 				    unsigned int sb_index, u16 pool_index,
353 				    u32 *p_cur, u32 *p_max);
354 	int (*sb_occ_tc_port_bind_get)(struct mlxsw_core_port *mlxsw_core_port,
355 				       unsigned int sb_index, u16 tc_index,
356 				       enum devlink_sb_pool_type pool_type,
357 				       u32 *p_cur, u32 *p_max);
358 	int (*trap_init)(struct mlxsw_core *mlxsw_core,
359 			 const struct devlink_trap *trap, void *trap_ctx);
360 	void (*trap_fini)(struct mlxsw_core *mlxsw_core,
361 			  const struct devlink_trap *trap, void *trap_ctx);
362 	int (*trap_action_set)(struct mlxsw_core *mlxsw_core,
363 			       const struct devlink_trap *trap,
364 			       enum devlink_trap_action action,
365 			       struct netlink_ext_ack *extack);
366 	int (*trap_group_init)(struct mlxsw_core *mlxsw_core,
367 			       const struct devlink_trap_group *group);
368 	int (*trap_group_set)(struct mlxsw_core *mlxsw_core,
369 			      const struct devlink_trap_group *group,
370 			      const struct devlink_trap_policer *policer,
371 			      struct netlink_ext_ack *extack);
372 	int (*trap_policer_init)(struct mlxsw_core *mlxsw_core,
373 				 const struct devlink_trap_policer *policer);
374 	void (*trap_policer_fini)(struct mlxsw_core *mlxsw_core,
375 				  const struct devlink_trap_policer *policer);
376 	int (*trap_policer_set)(struct mlxsw_core *mlxsw_core,
377 				const struct devlink_trap_policer *policer,
378 				u64 rate, u64 burst,
379 				struct netlink_ext_ack *extack);
380 	int (*trap_policer_counter_get)(struct mlxsw_core *mlxsw_core,
381 					const struct devlink_trap_policer *policer,
382 					u64 *p_drops);
383 	void (*txhdr_construct)(struct sk_buff *skb,
384 				const struct mlxsw_tx_info *tx_info);
385 	int (*resources_register)(struct mlxsw_core *mlxsw_core);
386 	int (*kvd_sizes_get)(struct mlxsw_core *mlxsw_core,
387 			     const struct mlxsw_config_profile *profile,
388 			     u64 *p_single_size, u64 *p_double_size,
389 			     u64 *p_linear_size);
390 	int (*params_register)(struct mlxsw_core *mlxsw_core);
391 	void (*params_unregister)(struct mlxsw_core *mlxsw_core);
392 
393 	/* Notify a driver that a timestamped packet was transmitted. Driver
394 	 * is responsible for freeing the passed-in SKB.
395 	 */
396 	void (*ptp_transmitted)(struct mlxsw_core *mlxsw_core,
397 				struct sk_buff *skb, u16 local_port);
398 
399 	u8 txhdr_len;
400 	const struct mlxsw_config_profile *profile;
401 	bool res_query_enabled;
402 	bool fw_fatal_enabled;
403 	bool temp_warn_enabled;
404 };
405 
406 int mlxsw_core_kvd_sizes_get(struct mlxsw_core *mlxsw_core,
407 			     const struct mlxsw_config_profile *profile,
408 			     u64 *p_single_size, u64 *p_double_size,
409 			     u64 *p_linear_size);
410 
411 u32 mlxsw_core_read_frc_h(struct mlxsw_core *mlxsw_core);
412 u32 mlxsw_core_read_frc_l(struct mlxsw_core *mlxsw_core);
413 
414 void mlxsw_core_emad_string_tlv_enable(struct mlxsw_core *mlxsw_core);
415 
416 bool mlxsw_core_res_valid(struct mlxsw_core *mlxsw_core,
417 			  enum mlxsw_res_id res_id);
418 
419 #define MLXSW_CORE_RES_VALID(mlxsw_core, short_res_id)			\
420 	mlxsw_core_res_valid(mlxsw_core, MLXSW_RES_ID_##short_res_id)
421 
422 u64 mlxsw_core_res_get(struct mlxsw_core *mlxsw_core,
423 		       enum mlxsw_res_id res_id);
424 
425 #define MLXSW_CORE_RES_GET(mlxsw_core, short_res_id)			\
426 	mlxsw_core_res_get(mlxsw_core, MLXSW_RES_ID_##short_res_id)
427 
428 static inline struct net *mlxsw_core_net(struct mlxsw_core *mlxsw_core)
429 {
430 	return devlink_net(priv_to_devlink(mlxsw_core));
431 }
432 
433 #define MLXSW_BUS_F_TXRX	BIT(0)
434 #define MLXSW_BUS_F_RESET	BIT(1)
435 
436 struct mlxsw_bus {
437 	const char *kind;
438 	int (*init)(void *bus_priv, struct mlxsw_core *mlxsw_core,
439 		    const struct mlxsw_config_profile *profile,
440 		    struct mlxsw_res *res);
441 	void (*fini)(void *bus_priv);
442 	bool (*skb_transmit_busy)(void *bus_priv,
443 				  const struct mlxsw_tx_info *tx_info);
444 	int (*skb_transmit)(void *bus_priv, struct sk_buff *skb,
445 			    const struct mlxsw_tx_info *tx_info);
446 	int (*cmd_exec)(void *bus_priv, u16 opcode, u8 opcode_mod,
447 			u32 in_mod, bool out_mbox_direct,
448 			char *in_mbox, size_t in_mbox_size,
449 			char *out_mbox, size_t out_mbox_size,
450 			u8 *p_status);
451 	u32 (*read_frc_h)(void *bus_priv);
452 	u32 (*read_frc_l)(void *bus_priv);
453 	u8 features;
454 };
455 
456 struct mlxsw_fw_rev {
457 	u16 major;
458 	u16 minor;
459 	u16 subminor;
460 	u16 can_reset_minor;
461 };
462 
463 #define MLXSW_BUS_INFO_XM_LOCAL_PORTS_MAX 4
464 
465 struct mlxsw_bus_info {
466 	const char *device_kind;
467 	const char *device_name;
468 	struct device *dev;
469 	struct mlxsw_fw_rev fw_rev;
470 	u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN];
471 	u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN];
472 	u8 low_frequency:1,
473 	   read_frc_capable:1,
474 	   xm_exists:1;
475 	u8 xm_local_ports_count;
476 	u8 xm_local_ports[MLXSW_BUS_INFO_XM_LOCAL_PORTS_MAX];
477 };
478 
479 struct mlxsw_hwmon;
480 
481 #ifdef CONFIG_MLXSW_CORE_HWMON
482 
483 int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
484 		     const struct mlxsw_bus_info *mlxsw_bus_info,
485 		     struct mlxsw_hwmon **p_hwmon);
486 void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon);
487 
488 #else
489 
490 static inline int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
491 				   const struct mlxsw_bus_info *mlxsw_bus_info,
492 				   struct mlxsw_hwmon **p_hwmon)
493 {
494 	return 0;
495 }
496 
497 static inline void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon)
498 {
499 }
500 
501 #endif
502 
503 struct mlxsw_thermal;
504 
505 #ifdef CONFIG_MLXSW_CORE_THERMAL
506 
507 int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core,
508 		       const struct mlxsw_bus_info *mlxsw_bus_info,
509 		       struct mlxsw_thermal **p_thermal);
510 void mlxsw_thermal_fini(struct mlxsw_thermal *thermal);
511 
512 #else
513 
514 static inline int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core,
515 				     const struct mlxsw_bus_info *mlxsw_bus_info,
516 				     struct mlxsw_thermal **p_thermal)
517 {
518 	return 0;
519 }
520 
521 static inline void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
522 {
523 }
524 
525 #endif
526 
527 enum mlxsw_devlink_param_id {
528 	MLXSW_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
529 	MLXSW_DEVLINK_PARAM_ID_ACL_REGION_REHASH_INTERVAL,
530 };
531 
532 struct mlxsw_skb_cb {
533 	union {
534 		struct mlxsw_tx_info tx_info;
535 		struct mlxsw_rx_md_info rx_md_info;
536 	};
537 };
538 
539 static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb)
540 {
541 	BUILD_BUG_ON(sizeof(mlxsw_skb_cb) > sizeof(skb->cb));
542 	return (struct mlxsw_skb_cb *) skb->cb;
543 }
544 
545 #endif
546