xref: /linux/drivers/infiniband/hw/bng_re/bng_re.h (revision 55aa394a5ed871208eac11c5f4677cafd258c4dd)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (c) 2025 Broadcom.
3 
4 #ifndef __BNG_RE_H__
5 #define __BNG_RE_H__
6 
7 #include "bng_res.h"
8 
9 #define BNG_RE_ADEV_NAME		"bng_en"
10 
11 #define BNG_RE_DESC	"Broadcom 800G RoCE Driver"
12 
13 #define	rdev_to_dev(rdev)	((rdev) ? (&(rdev)->ibdev.dev) : NULL)
14 
15 #define BNG_RE_MIN_MSIX		2
16 #define BNG_RE_MAX_MSIX		BNGE_MAX_ROCE_MSIX
17 
18 #define BNG_RE_CREQ_NQ_IDX	0
19 
20 #define BNGE_INVALID_STATS_CTX_ID	-1
21 /* NQ specific structures  */
22 struct bng_re_nq_db {
23 	struct bng_re_reg_desc	reg;
24 	struct bng_re_db_info	dbinfo;
25 };
26 
27 struct bng_re_nq {
28 	struct pci_dev			*pdev;
29 	struct bng_re_res		*res;
30 	char				*name;
31 	struct bng_re_hwq		hwq;
32 	struct bng_re_nq_db		nq_db;
33 	u16				ring_id;
34 	int				msix_vec;
35 	cpumask_t			mask;
36 	struct tasklet_struct		nq_tasklet;
37 	bool				requested;
38 	int				budget;
39 	u32				load;
40 
41 	struct workqueue_struct		*cqn_wq;
42 };
43 
44 struct bng_re_nq_record {
45 	struct bnge_msix_info	msix_entries[BNG_RE_MAX_MSIX];
46 	struct bng_re_nq	nq[BNG_RE_MAX_MSIX];
47 	int			num_msix;
48 	/* serialize NQ access */
49 	struct mutex		load_lock;
50 };
51 
52 struct bng_re_en_dev_info {
53 	struct bng_re_dev *rdev;
54 	struct bnge_auxr_dev *auxr_dev;
55 };
56 
57 struct bng_re_ring_attr {
58 	dma_addr_t	*dma_arr;
59 	int		pages;
60 	int		type;
61 	u32		depth;
62 	u32		lrid; /* Logical ring id */
63 	u8		mode;
64 };
65 
66 struct bng_re_dev {
67 	struct ib_device		ibdev;
68 	unsigned long			flags;
69 #define BNG_RE_FLAG_NETDEV_REGISTERED		0
70 #define BNG_RE_FLAG_RCFW_CHANNEL_EN		1
71 	struct net_device		*netdev;
72 	struct auxiliary_device         *adev;
73 	struct bnge_auxr_dev		*aux_dev;
74 	struct bng_re_chip_ctx		*chip_ctx;
75 	int				fn_id;
76 	struct bng_re_res		bng_res;
77 	struct bng_re_rcfw		rcfw;
78 	struct bng_re_nq_record		*nqr;
79 	/* Device Resources */
80 	struct bng_re_dev_attr		*dev_attr;
81 	struct dentry			*dbg_root;
82 	struct bng_re_stats		stats_ctx;
83 };
84 
85 #endif
86