xref: /linux/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h (revision fd7d598270724cc787982ea48bbe17ad383a8b7f)
1 /* Broadcom NetXtreme-C/E network driver.
2  *
3  * Copyright (c) 2016-2018 Broadcom Limited
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation.
8  */
9 
10 #ifndef BNXT_ULP_H
11 #define BNXT_ULP_H
12 
13 #define BNXT_ROCE_ULP	0
14 #define BNXT_MAX_ULP	1
15 
16 #define BNXT_MIN_ROCE_CP_RINGS	2
17 #define BNXT_MIN_ROCE_STAT_CTXS	1
18 #define BNXT_MAX_ROCE_MSIX	9
19 #define BNXT_MAX_VF_ROCE_MSIX	2
20 
21 struct hwrm_async_event_cmpl;
22 struct bnxt;
23 
24 struct bnxt_msix_entry {
25 	u32	vector;
26 	u32	ring_idx;
27 	u32	db_offset;
28 };
29 
30 struct bnxt_ulp_ops {
31 	void (*ulp_irq_stop)(void *);
32 	void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *);
33 };
34 
35 struct bnxt_fw_msg {
36 	void	*msg;
37 	int	msg_len;
38 	void	*resp;
39 	int	resp_max_len;
40 	int	timeout;
41 };
42 
43 struct bnxt_ulp {
44 	void		*handle;
45 	struct bnxt_ulp_ops __rcu *ulp_ops;
46 	unsigned long	*async_events_bmap;
47 	u16		max_async_event_id;
48 	u16		msix_requested;
49 	u16		msix_base;
50 	atomic_t	ref_count;
51 };
52 
53 struct bnxt_en_dev {
54 	struct net_device *net;
55 	struct pci_dev *pdev;
56 	struct bnxt_msix_entry			msix_entries[BNXT_MAX_ROCE_MSIX];
57 	u32 flags;
58 	#define BNXT_EN_FLAG_ROCEV1_CAP		0x1
59 	#define BNXT_EN_FLAG_ROCEV2_CAP		0x2
60 	#define BNXT_EN_FLAG_ROCE_CAP		(BNXT_EN_FLAG_ROCEV1_CAP | \
61 						 BNXT_EN_FLAG_ROCEV2_CAP)
62 	#define BNXT_EN_FLAG_MSIX_REQUESTED	0x4
63 	#define BNXT_EN_FLAG_ULP_STOPPED	0x8
64 	#define BNXT_EN_FLAG_VF			0x10
65 #define BNXT_EN_VF(edev)	((edev)->flags & BNXT_EN_FLAG_VF)
66 
67 	struct bnxt_ulp			*ulp_tbl;
68 	int				l2_db_size;	/* Doorbell BAR size in
69 							 * bytes mapped by L2
70 							 * driver.
71 							 */
72 	int				l2_db_size_nc;	/* Doorbell BAR size in
73 							 * bytes mapped as non-
74 							 * cacheable.
75 							 */
76 	u16				chip_num;
77 	u16				hw_ring_stats_size;
78 	u16				pf_port_id;
79 	unsigned long			en_state;	/* Could be checked in
80 							 * RoCE driver suspend
81 							 * mode only. Will be
82 							 * updated in resume.
83 							 */
84 	void __iomem                    *bar0;
85 };
86 
87 static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
88 {
89 	if (edev && edev->ulp_tbl)
90 		return true;
91 	return false;
92 }
93 
94 int bnxt_get_ulp_msix_num(struct bnxt *bp);
95 int bnxt_get_ulp_msix_base(struct bnxt *bp);
96 int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
97 void bnxt_ulp_stop(struct bnxt *bp);
98 void bnxt_ulp_start(struct bnxt *bp, int err);
99 void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
100 void bnxt_ulp_irq_stop(struct bnxt *bp);
101 void bnxt_ulp_irq_restart(struct bnxt *bp, int err);
102 void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
103 void bnxt_rdma_aux_device_uninit(struct bnxt *bp);
104 void bnxt_rdma_aux_device_init(struct bnxt *bp);
105 int bnxt_register_dev(struct bnxt_en_dev *edev, struct bnxt_ulp_ops *ulp_ops,
106 		      void *handle);
107 void bnxt_unregister_dev(struct bnxt_en_dev *edev);
108 int bnxt_send_msg(struct bnxt_en_dev *edev, struct bnxt_fw_msg *fw_msg);
109 int bnxt_register_async_events(struct bnxt_en_dev *edev,
110 			       unsigned long *events_bmap, u16 max_id);
111 #endif
112