1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2021 Mellanox Technologies. */
3 
4 #ifndef __MLX5_IRQ_H__
5 #define __MLX5_IRQ_H__
6 
7 #include <linux/mlx5/driver.h>
8 
9 #define MLX5_COMP_EQS_PER_SF 8
10 
11 struct mlx5_irq;
12 struct cpu_rmap;
13 
14 int mlx5_irq_table_init(struct mlx5_core_dev *dev);
15 void mlx5_irq_table_cleanup(struct mlx5_core_dev *dev);
16 int mlx5_irq_table_create(struct mlx5_core_dev *dev);
17 void mlx5_irq_table_destroy(struct mlx5_core_dev *dev);
18 void mlx5_irq_table_free_irqs(struct mlx5_core_dev *dev);
19 int mlx5_irq_table_get_num_comp(struct mlx5_irq_table *table);
20 int mlx5_irq_table_get_sfs_vec(struct mlx5_irq_table *table);
21 struct mlx5_irq_table *mlx5_irq_table_get(struct mlx5_core_dev *dev);
22 
23 int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int devfn,
24 			    int msix_vec_count);
25 int mlx5_get_default_msix_vec_count(struct mlx5_core_dev *dev, int num_vfs);
26 
27 struct mlx5_irq *mlx5_ctrl_irq_request(struct mlx5_core_dev *dev);
28 void mlx5_ctrl_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *ctrl_irq);
29 struct mlx5_irq *mlx5_irq_request(struct mlx5_core_dev *dev, u16 vecidx,
30 				  struct irq_affinity_desc *af_desc,
31 				  struct cpu_rmap **rmap);
32 struct mlx5_irq *mlx5_irq_request_vector(struct mlx5_core_dev *dev, u16 cpu,
33 					 u16 vecidx, struct cpu_rmap **rmap);
34 void mlx5_irq_release_vector(struct mlx5_irq *irq);
35 int mlx5_irq_attach_nb(struct mlx5_irq *irq, struct notifier_block *nb);
36 int mlx5_irq_detach_nb(struct mlx5_irq *irq, struct notifier_block *nb);
37 struct cpumask *mlx5_irq_get_affinity_mask(struct mlx5_irq *irq);
38 int mlx5_irq_get_index(struct mlx5_irq *irq);
39 int mlx5_irq_get_irq(const struct mlx5_irq *irq);
40 
41 struct mlx5_irq_pool;
42 #ifdef CONFIG_MLX5_SF
43 struct mlx5_irq *mlx5_irq_affinity_irq_request_auto(struct mlx5_core_dev *dev,
44 						    struct cpumask *used_cpus, u16 vecidx);
45 struct mlx5_irq *
46 mlx5_irq_affinity_request(struct mlx5_core_dev *dev, struct mlx5_irq_pool *pool,
47 			  struct irq_affinity_desc *af_desc);
48 void mlx5_irq_affinity_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *irq);
49 #else
50 static inline
mlx5_irq_affinity_irq_request_auto(struct mlx5_core_dev * dev,struct cpumask * used_cpus,u16 vecidx)51 struct mlx5_irq *mlx5_irq_affinity_irq_request_auto(struct mlx5_core_dev *dev,
52 						    struct cpumask *used_cpus, u16 vecidx)
53 {
54 	return ERR_PTR(-EOPNOTSUPP);
55 }
56 
57 static inline struct mlx5_irq *
mlx5_irq_affinity_request(struct mlx5_core_dev * dev,struct mlx5_irq_pool * pool,struct irq_affinity_desc * af_desc)58 mlx5_irq_affinity_request(struct mlx5_core_dev *dev, struct mlx5_irq_pool *pool,
59 			  struct irq_affinity_desc *af_desc)
60 {
61 	return ERR_PTR(-EOPNOTSUPP);
62 }
63 
64 static inline
mlx5_irq_affinity_irq_release(struct mlx5_core_dev * dev,struct mlx5_irq * irq)65 void mlx5_irq_affinity_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *irq)
66 {
67 	mlx5_irq_release_vector(irq);
68 }
69 #endif
70 #endif /* __MLX5_IRQ_H__ */
71