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 	u8 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 	u8 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, u8 local_port);
86 
87 struct mlxsw_rx_listener {
88 	void (*func)(struct sk_buff *skb, u8 local_port, void *priv);
89 	u8 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 	u8 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, u8 local_port);
222 u8 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, u8 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, u8 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, u8 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, u8 local_port,
240 			     void *port_driver_priv, struct net_device *dev);
241 void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u8 local_port,
242 			    void *port_driver_priv);
243 void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
244 			   void *port_driver_priv);
245 enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
246 						u8 local_port);
247 struct devlink_port *
248 mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
249 				 u8 local_port);
250 bool mlxsw_core_port_is_xm(const struct mlxsw_core *mlxsw_core, u8 local_port);
251 struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core);
252 bool mlxsw_core_is_initialized(const struct mlxsw_core *mlxsw_core);
253 int mlxsw_core_module_max_width(struct mlxsw_core *mlxsw_core, u8 module);
254 
255 int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
256 bool mlxsw_core_schedule_work(struct work_struct *work);
257 void mlxsw_core_flush_owq(void);
258 int mlxsw_core_resources_query(struct mlxsw_core *mlxsw_core, char *mbox,
259 			       struct mlxsw_res *res);
260 
261 #define MLXSW_CONFIG_PROFILE_SWID_COUNT 8
262 
263 struct mlxsw_swid_config {
264 	u8	used_type:1,
265 		used_properties:1;
266 	u8	type;
267 	u8	properties;
268 };
269 
270 struct mlxsw_config_profile {
271 	u16	used_max_vepa_channels:1,
272 		used_max_mid:1,
273 		used_max_pgt:1,
274 		used_max_system_port:1,
275 		used_max_vlan_groups:1,
276 		used_max_regions:1,
277 		used_flood_tables:1,
278 		used_flood_mode:1,
279 		used_max_ib_mc:1,
280 		used_max_pkey:1,
281 		used_ar_sec:1,
282 		used_adaptive_routing_group_cap:1,
283 		used_kvd_sizes:1,
284 		used_kvh_xlt_cache_mode:1;
285 	u8	max_vepa_channels;
286 	u16	max_mid;
287 	u16	max_pgt;
288 	u16	max_system_port;
289 	u16	max_vlan_groups;
290 	u16	max_regions;
291 	u8	max_flood_tables;
292 	u8	max_vid_flood_tables;
293 	u8	flood_mode;
294 	u8	max_fid_offset_flood_tables;
295 	u16	fid_offset_flood_table_size;
296 	u8	max_fid_flood_tables;
297 	u16	fid_flood_table_size;
298 	u16	max_ib_mc;
299 	u16	max_pkey;
300 	u8	ar_sec;
301 	u16	adaptive_routing_group_cap;
302 	u8	arn;
303 	u32	kvd_linear_size;
304 	u8	kvd_hash_single_parts;
305 	u8	kvd_hash_double_parts;
306 	u8	kvh_xlt_cache_mode;
307 	struct mlxsw_swid_config swid_config[MLXSW_CONFIG_PROFILE_SWID_COUNT];
308 };
309 
310 struct mlxsw_driver {
311 	struct list_head list;
312 	const char *kind;
313 	size_t priv_size;
314 	const struct mlxsw_fw_rev *fw_req_rev;
315 	const char *fw_filename;
316 	int (*init)(struct mlxsw_core *mlxsw_core,
317 		    const struct mlxsw_bus_info *mlxsw_bus_info,
318 		    struct netlink_ext_ack *extack);
319 	void (*fini)(struct mlxsw_core *mlxsw_core);
320 	int (*basic_trap_groups_set)(struct mlxsw_core *mlxsw_core);
321 	int (*port_type_set)(struct mlxsw_core *mlxsw_core, u8 local_port,
322 			     enum devlink_port_type new_type);
323 	int (*port_split)(struct mlxsw_core *mlxsw_core, u8 local_port,
324 			  unsigned int count, struct netlink_ext_ack *extack);
325 	int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u8 local_port,
326 			    struct netlink_ext_ack *extack);
327 	int (*sb_pool_get)(struct mlxsw_core *mlxsw_core,
328 			   unsigned int sb_index, u16 pool_index,
329 			   struct devlink_sb_pool_info *pool_info);
330 	int (*sb_pool_set)(struct mlxsw_core *mlxsw_core,
331 			   unsigned int sb_index, u16 pool_index, u32 size,
332 			   enum devlink_sb_threshold_type threshold_type,
333 			   struct netlink_ext_ack *extack);
334 	int (*sb_port_pool_get)(struct mlxsw_core_port *mlxsw_core_port,
335 				unsigned int sb_index, u16 pool_index,
336 				u32 *p_threshold);
337 	int (*sb_port_pool_set)(struct mlxsw_core_port *mlxsw_core_port,
338 				unsigned int sb_index, u16 pool_index,
339 				u32 threshold, struct netlink_ext_ack *extack);
340 	int (*sb_tc_pool_bind_get)(struct mlxsw_core_port *mlxsw_core_port,
341 				   unsigned int sb_index, u16 tc_index,
342 				   enum devlink_sb_pool_type pool_type,
343 				   u16 *p_pool_index, u32 *p_threshold);
344 	int (*sb_tc_pool_bind_set)(struct mlxsw_core_port *mlxsw_core_port,
345 				   unsigned int sb_index, u16 tc_index,
346 				   enum devlink_sb_pool_type pool_type,
347 				   u16 pool_index, u32 threshold,
348 				   struct netlink_ext_ack *extack);
349 	int (*sb_occ_snapshot)(struct mlxsw_core *mlxsw_core,
350 			       unsigned int sb_index);
351 	int (*sb_occ_max_clear)(struct mlxsw_core *mlxsw_core,
352 				unsigned int sb_index);
353 	int (*sb_occ_port_pool_get)(struct mlxsw_core_port *mlxsw_core_port,
354 				    unsigned int sb_index, u16 pool_index,
355 				    u32 *p_cur, u32 *p_max);
356 	int (*sb_occ_tc_port_bind_get)(struct mlxsw_core_port *mlxsw_core_port,
357 				       unsigned int sb_index, u16 tc_index,
358 				       enum devlink_sb_pool_type pool_type,
359 				       u32 *p_cur, u32 *p_max);
360 	int (*trap_init)(struct mlxsw_core *mlxsw_core,
361 			 const struct devlink_trap *trap, void *trap_ctx);
362 	void (*trap_fini)(struct mlxsw_core *mlxsw_core,
363 			  const struct devlink_trap *trap, void *trap_ctx);
364 	int (*trap_action_set)(struct mlxsw_core *mlxsw_core,
365 			       const struct devlink_trap *trap,
366 			       enum devlink_trap_action action,
367 			       struct netlink_ext_ack *extack);
368 	int (*trap_group_init)(struct mlxsw_core *mlxsw_core,
369 			       const struct devlink_trap_group *group);
370 	int (*trap_group_set)(struct mlxsw_core *mlxsw_core,
371 			      const struct devlink_trap_group *group,
372 			      const struct devlink_trap_policer *policer,
373 			      struct netlink_ext_ack *extack);
374 	int (*trap_policer_init)(struct mlxsw_core *mlxsw_core,
375 				 const struct devlink_trap_policer *policer);
376 	void (*trap_policer_fini)(struct mlxsw_core *mlxsw_core,
377 				  const struct devlink_trap_policer *policer);
378 	int (*trap_policer_set)(struct mlxsw_core *mlxsw_core,
379 				const struct devlink_trap_policer *policer,
380 				u64 rate, u64 burst,
381 				struct netlink_ext_ack *extack);
382 	int (*trap_policer_counter_get)(struct mlxsw_core *mlxsw_core,
383 					const struct devlink_trap_policer *policer,
384 					u64 *p_drops);
385 	void (*txhdr_construct)(struct sk_buff *skb,
386 				const struct mlxsw_tx_info *tx_info);
387 	int (*resources_register)(struct mlxsw_core *mlxsw_core);
388 	int (*kvd_sizes_get)(struct mlxsw_core *mlxsw_core,
389 			     const struct mlxsw_config_profile *profile,
390 			     u64 *p_single_size, u64 *p_double_size,
391 			     u64 *p_linear_size);
392 	int (*params_register)(struct mlxsw_core *mlxsw_core);
393 	void (*params_unregister)(struct mlxsw_core *mlxsw_core);
394 
395 	/* Notify a driver that a timestamped packet was transmitted. Driver
396 	 * is responsible for freeing the passed-in SKB.
397 	 */
398 	void (*ptp_transmitted)(struct mlxsw_core *mlxsw_core,
399 				struct sk_buff *skb, u8 local_port);
400 
401 	u8 txhdr_len;
402 	const struct mlxsw_config_profile *profile;
403 	bool res_query_enabled;
404 	bool fw_fatal_enabled;
405 	bool temp_warn_enabled;
406 };
407 
408 int mlxsw_core_kvd_sizes_get(struct mlxsw_core *mlxsw_core,
409 			     const struct mlxsw_config_profile *profile,
410 			     u64 *p_single_size, u64 *p_double_size,
411 			     u64 *p_linear_size);
412 
413 u32 mlxsw_core_read_frc_h(struct mlxsw_core *mlxsw_core);
414 u32 mlxsw_core_read_frc_l(struct mlxsw_core *mlxsw_core);
415 
416 void mlxsw_core_emad_string_tlv_enable(struct mlxsw_core *mlxsw_core);
417 
418 bool mlxsw_core_res_valid(struct mlxsw_core *mlxsw_core,
419 			  enum mlxsw_res_id res_id);
420 
421 #define MLXSW_CORE_RES_VALID(mlxsw_core, short_res_id)			\
422 	mlxsw_core_res_valid(mlxsw_core, MLXSW_RES_ID_##short_res_id)
423 
424 u64 mlxsw_core_res_get(struct mlxsw_core *mlxsw_core,
425 		       enum mlxsw_res_id res_id);
426 
427 #define MLXSW_CORE_RES_GET(mlxsw_core, short_res_id)			\
428 	mlxsw_core_res_get(mlxsw_core, MLXSW_RES_ID_##short_res_id)
429 
430 static inline struct net *mlxsw_core_net(struct mlxsw_core *mlxsw_core)
431 {
432 	return devlink_net(priv_to_devlink(mlxsw_core));
433 }
434 
435 #define MLXSW_BUS_F_TXRX	BIT(0)
436 #define MLXSW_BUS_F_RESET	BIT(1)
437 
438 struct mlxsw_bus {
439 	const char *kind;
440 	int (*init)(void *bus_priv, struct mlxsw_core *mlxsw_core,
441 		    const struct mlxsw_config_profile *profile,
442 		    struct mlxsw_res *res);
443 	void (*fini)(void *bus_priv);
444 	bool (*skb_transmit_busy)(void *bus_priv,
445 				  const struct mlxsw_tx_info *tx_info);
446 	int (*skb_transmit)(void *bus_priv, struct sk_buff *skb,
447 			    const struct mlxsw_tx_info *tx_info);
448 	int (*cmd_exec)(void *bus_priv, u16 opcode, u8 opcode_mod,
449 			u32 in_mod, bool out_mbox_direct,
450 			char *in_mbox, size_t in_mbox_size,
451 			char *out_mbox, size_t out_mbox_size,
452 			u8 *p_status);
453 	u32 (*read_frc_h)(void *bus_priv);
454 	u32 (*read_frc_l)(void *bus_priv);
455 	u8 features;
456 };
457 
458 struct mlxsw_fw_rev {
459 	u16 major;
460 	u16 minor;
461 	u16 subminor;
462 	u16 can_reset_minor;
463 };
464 
465 #define MLXSW_BUS_INFO_XM_LOCAL_PORTS_MAX 4
466 
467 struct mlxsw_bus_info {
468 	const char *device_kind;
469 	const char *device_name;
470 	struct device *dev;
471 	struct mlxsw_fw_rev fw_rev;
472 	u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN];
473 	u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN];
474 	u8 low_frequency:1,
475 	   read_frc_capable:1,
476 	   xm_exists:1;
477 	u8 xm_local_ports_count;
478 	u8 xm_local_ports[MLXSW_BUS_INFO_XM_LOCAL_PORTS_MAX];
479 };
480 
481 struct mlxsw_hwmon;
482 
483 #ifdef CONFIG_MLXSW_CORE_HWMON
484 
485 int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
486 		     const struct mlxsw_bus_info *mlxsw_bus_info,
487 		     struct mlxsw_hwmon **p_hwmon);
488 void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon);
489 
490 #else
491 
492 static inline int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
493 				   const struct mlxsw_bus_info *mlxsw_bus_info,
494 				   struct mlxsw_hwmon **p_hwmon)
495 {
496 	return 0;
497 }
498 
499 static inline void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon)
500 {
501 }
502 
503 #endif
504 
505 struct mlxsw_thermal;
506 
507 #ifdef CONFIG_MLXSW_CORE_THERMAL
508 
509 int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core,
510 		       const struct mlxsw_bus_info *mlxsw_bus_info,
511 		       struct mlxsw_thermal **p_thermal);
512 void mlxsw_thermal_fini(struct mlxsw_thermal *thermal);
513 
514 #else
515 
516 static inline int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core,
517 				     const struct mlxsw_bus_info *mlxsw_bus_info,
518 				     struct mlxsw_thermal **p_thermal)
519 {
520 	return 0;
521 }
522 
523 static inline void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
524 {
525 }
526 
527 #endif
528 
529 enum mlxsw_devlink_param_id {
530 	MLXSW_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
531 	MLXSW_DEVLINK_PARAM_ID_ACL_REGION_REHASH_INTERVAL,
532 };
533 
534 struct mlxsw_skb_cb {
535 	union {
536 		struct mlxsw_tx_info tx_info;
537 		struct mlxsw_rx_md_info rx_md_info;
538 	};
539 };
540 
541 static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb)
542 {
543 	BUILD_BUG_ON(sizeof(mlxsw_skb_cb) > sizeof(skb->cb));
544 	return (struct mlxsw_skb_cb *) skb->cb;
545 }
546 
547 #endif
548