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