summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/broadcom/bnge/bnge_auxr.h
blob: 6c5c15ef2b0a7df2117c5eb0db8234a5d4293ad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2025 Broadcom */

#ifndef _BNGE_AUXR_H_
#define _BNGE_AUXR_H_

#include <linux/auxiliary_bus.h>

#define BNGE_MIN_ROCE_CP_RINGS	2
#define BNGE_MIN_ROCE_STAT_CTXS	1

#define BNGE_MAX_ROCE_MSIX	64

struct hwrm_async_event_cmpl;
struct bnge;

struct bnge_msix_info {
	u32	vector;
	u32	ring_idx;
	u32	db_offset;
};

struct bnge_fw_msg {
	void	*msg;
	int	msg_len;
	void	*resp;
	int	resp_max_len;
	int	timeout;
};

struct bnge_auxr_info {
	void		*handle;
	u16		msix_requested;
};

enum {
	BNGE_ARDEV_ROCEV1_SUPP		= BIT(0),
	BNGE_ARDEV_ROCEV2_SUPP		= BIT(1),
	BNGE_ARDEV_MSIX_ALLOC		= BIT(2),
};

#define BNGE_ARDEV_ROCE_SUPP	(BNGE_ARDEV_ROCEV1_SUPP | \
				 BNGE_ARDEV_ROCEV2_SUPP)

struct bnge_auxr_dev {
	struct net_device	*net;
	struct pci_dev		*pdev;
	void __iomem		*bar0;

	struct bnge_msix_info	msix_info[BNGE_MAX_ROCE_MSIX];

	u32 flags;

	struct bnge_auxr_info	*auxr_info;

	/* Doorbell BAR size in bytes mapped by L2 driver. */
	int	l2_db_size;
	/* Doorbell BAR size in bytes mapped as non-cacheable. */
	int	l2_db_size_nc;
	/* Doorbell offset in bytes within l2_db_size_nc. */
	int	l2_db_offset;

	u16		chip_num;
	u16		hw_ring_stats_size;
	u16		pf_port_id;
	unsigned long	en_state;

	u16	auxr_num_msix_vec;
	u16	auxr_num_ctxs;

	/* serialize auxr operations */
	struct mutex	auxr_dev_lock;
};

void bnge_rdma_aux_device_uninit(struct bnge_dev *bdev);
void bnge_rdma_aux_device_del(struct bnge_dev *bdev);
void bnge_rdma_aux_device_add(struct bnge_dev *bdev);
void bnge_rdma_aux_device_init(struct bnge_dev *bdev);
int bnge_register_dev(struct bnge_auxr_dev *adev,
		      void *handle);
void bnge_unregister_dev(struct bnge_auxr_dev *adev);
int bnge_send_msg(struct bnge_auxr_dev *adev, struct bnge_fw_msg *fw_msg);

#endif /* _BNGE_AUXR_H_ */