xref: /openbmc/linux/drivers/net/ethernet/emulex/benet/be_roce.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*6e9ef509SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2045508a8SParav Pandit /*
37dfbe7d7SSomnath Kotur  * Copyright (C) 2005 - 2016 Broadcom
4045508a8SParav Pandit  * All rights reserved.
5045508a8SParav Pandit  *
6045508a8SParav Pandit  * Contact Information:
7045508a8SParav Pandit  * linux-drivers@emulex.com
8045508a8SParav Pandit  *
9045508a8SParav Pandit  * Emulex
10045508a8SParav Pandit  * 3333 Susan Street
11045508a8SParav Pandit  * Costa Mesa, CA 92626
12045508a8SParav Pandit  */
13045508a8SParav Pandit 
14045508a8SParav Pandit #ifndef BE_ROCE_H
15045508a8SParav Pandit #define BE_ROCE_H
16045508a8SParav Pandit 
17045508a8SParav Pandit #include <linux/pci.h>
18045508a8SParav Pandit #include <linux/netdevice.h>
19045508a8SParav Pandit 
202407116eSDevesh Sharma #define BE_ROCE_ABI_VERSION	1
212407116eSDevesh Sharma 
22045508a8SParav Pandit struct ocrdma_dev;
23045508a8SParav Pandit 
24045508a8SParav Pandit enum be_interrupt_mode {
25045508a8SParav Pandit 	BE_INTERRUPT_MODE_MSIX	= 0,
26045508a8SParav Pandit 	BE_INTERRUPT_MODE_INTX	= 1,
27045508a8SParav Pandit 	BE_INTERRUPT_MODE_MSI	= 2,
28045508a8SParav Pandit };
29045508a8SParav Pandit 
3092bf14abSSathya Perla #define MAX_MSIX_VECTORS		32
31045508a8SParav Pandit struct be_dev_info {
32045508a8SParav Pandit 	u8 __iomem *db;
33045508a8SParav Pandit 	u64 unmapped_db;
34045508a8SParav Pandit 	u32 db_page_size;
35045508a8SParav Pandit 	u32 db_total_size;
36045508a8SParav Pandit 	u64 dpp_unmapped_addr;
37045508a8SParav Pandit 	u32 dpp_unmapped_len;
38045508a8SParav Pandit 	struct pci_dev *pdev;
39045508a8SParav Pandit 	struct net_device *netdev;
40045508a8SParav Pandit 	u8 mac_addr[ETH_ALEN];
41045508a8SParav Pandit 	u32 dev_family;
42045508a8SParav Pandit 	enum be_interrupt_mode intr_mode;
43045508a8SParav Pandit 	struct {
44045508a8SParav Pandit 		int num_vectors;
45045508a8SParav Pandit 		int start_vector;
4692bf14abSSathya Perla 		u32 vector_list[MAX_MSIX_VECTORS];
47045508a8SParav Pandit 	} msix;
48045508a8SParav Pandit };
49045508a8SParav Pandit 
50045508a8SParav Pandit /* ocrdma driver register's the callback functions with nic driver. */
51045508a8SParav Pandit struct ocrdma_driver {
52045508a8SParav Pandit 	unsigned char name[32];
532407116eSDevesh Sharma 	u32 be_abi_version;
54045508a8SParav Pandit 	struct ocrdma_dev *(*add) (struct be_dev_info *dev_info);
55045508a8SParav Pandit 	void (*remove) (struct ocrdma_dev *);
56045508a8SParav Pandit 	void (*state_change_handler) (struct ocrdma_dev *, u32 new_state);
57045508a8SParav Pandit };
58045508a8SParav Pandit 
59f41647efSDevesh Sharma enum be_roce_event {
60d114f99aSDevesh Sharma 	BE_DEV_SHUTDOWN = 2
61045508a8SParav Pandit };
62045508a8SParav Pandit 
63045508a8SParav Pandit /* APIs for RoCE driver to register callback handlers,
64045508a8SParav Pandit  * which will be invoked when device is added, removed, ifup, ifdown
65045508a8SParav Pandit  */
66045508a8SParav Pandit int be_roce_register_driver(struct ocrdma_driver *drv);
67045508a8SParav Pandit void be_roce_unregister_driver(struct ocrdma_driver *drv);
68045508a8SParav Pandit 
69045508a8SParav Pandit /* API for RoCE driver to issue mailbox commands */
70045508a8SParav Pandit int be_roce_mcc_cmd(void *netdev_handle, void *wrb_payload,
71045508a8SParav Pandit 		    int wrb_payload_size, u16 *cmd_status, u16 *ext_status);
72045508a8SParav Pandit 
73045508a8SParav Pandit #endif /* BE_ROCE_H */
74