xref: /openbmc/linux/drivers/scsi/fnic/vnic_dev.h (revision 7cc39531)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
4  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
5  */
6 #ifndef _VNIC_DEV_H_
7 #define _VNIC_DEV_H_
8 
9 #include "vnic_resource.h"
10 #include "vnic_devcmd.h"
11 
12 /*
13  * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
14  * Driver) when both are built with CONFIG options =y
15  */
16 #define vnic_dev_priv fnic_dev_priv
17 #define vnic_dev_get_res_count fnic_dev_get_res_count
18 #define vnic_dev_get_res fnic_dev_get_res
19 #define vnic_dev_desc_ring_size fnic_dev_desc_ring_siz
20 #define vnic_dev_clear_desc_ring fnic_dev_clear_desc_ring
21 #define vnic_dev_alloc_desc_ring fnic_dev_alloc_desc_ring
22 #define vnic_dev_free_desc_ring fnic_dev_free_desc_ring
23 #define vnic_dev_cmd fnic_dev_cmd
24 #define vnic_dev_fw_info fnic_dev_fw_info
25 #define vnic_dev_spec fnic_dev_spec
26 #define vnic_dev_stats_clear fnic_dev_stats_clear
27 #define vnic_dev_cmd_init fnic_dev_cmd_init
28 #define vnic_dev_stats_dump fnic_dev_stats_dump
29 #define vnic_dev_hang_notify fnic_dev_hang_notify
30 #define vnic_dev_packet_filter fnic_dev_packet_filter
31 #define vnic_dev_add_addr fnic_dev_add_addr
32 #define vnic_dev_del_addr fnic_dev_del_addr
33 #define vnic_dev_mac_addr fnic_dev_mac_addr
34 #define vnic_dev_notify_set fnic_dev_notify_set
35 #define vnic_dev_notify_unset fnic_dev_notify_unset
36 #define vnic_dev_link_status fnic_dev_link_status
37 #define vnic_dev_port_speed fnic_dev_port_speed
38 #define vnic_dev_msg_lvl fnic_dev_msg_lvl
39 #define vnic_dev_mtu fnic_dev_mtu
40 #define vnic_dev_link_down_cnt fnic_dev_link_down_cnt
41 #define vnic_dev_close fnic_dev_close
42 #define vnic_dev_enable fnic_dev_enable
43 #define vnic_dev_disable fnic_dev_disable
44 #define vnic_dev_open fnic_dev_open
45 #define vnic_dev_open_done fnic_dev_open_done
46 #define vnic_dev_init fnic_dev_init
47 #define vnic_dev_soft_reset fnic_dev_soft_reset
48 #define vnic_dev_soft_reset_done fnic_dev_soft_reset_done
49 #define vnic_dev_set_intr_mode fnic_dev_set_intr_mode
50 #define vnic_dev_get_intr_mode fnic_dev_get_intr_mode
51 #define vnic_dev_unregister fnic_dev_unregister
52 #define vnic_dev_register fnic_dev_register
53 
54 #ifndef VNIC_PADDR_TARGET
55 #define VNIC_PADDR_TARGET	0x0000000000000000ULL
56 #endif
57 
58 #ifndef readq
59 static inline u64 readq(void __iomem *reg)
60 {
61 	return ((u64)readl(reg + 0x4UL) << 32) | (u64)readl(reg);
62 }
63 
64 static inline void writeq(u64 val, void __iomem *reg)
65 {
66 	writel(val & 0xffffffff, reg);
67 	writel(val >> 32, reg + 0x4UL);
68 }
69 #endif
70 
71 enum vnic_dev_intr_mode {
72 	VNIC_DEV_INTR_MODE_UNKNOWN,
73 	VNIC_DEV_INTR_MODE_INTX,
74 	VNIC_DEV_INTR_MODE_MSI,
75 	VNIC_DEV_INTR_MODE_MSIX,
76 };
77 
78 struct vnic_dev_bar {
79 	void __iomem *vaddr;
80 	dma_addr_t bus_addr;
81 	unsigned long len;
82 };
83 
84 struct vnic_dev_ring {
85 	void *descs;
86 	size_t size;
87 	dma_addr_t base_addr;
88 	size_t base_align;
89 	void *descs_unaligned;
90 	size_t size_unaligned;
91 	dma_addr_t base_addr_unaligned;
92 	unsigned int desc_size;
93 	unsigned int desc_count;
94 	unsigned int desc_avail;
95 };
96 
97 struct vnic_dev;
98 struct vnic_stats;
99 
100 void *vnic_dev_priv(struct vnic_dev *vdev);
101 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
102 				    enum vnic_res_type type);
103 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
104 			       unsigned int index);
105 unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
106 				     unsigned int desc_count,
107 				     unsigned int desc_size);
108 void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
109 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
110 			     unsigned int desc_count, unsigned int desc_size);
111 void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
112 			     struct vnic_dev_ring *ring);
113 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
114 		 u64 *a0, u64 *a1, int wait);
115 int vnic_dev_fw_info(struct vnic_dev *vdev,
116 		     struct vnic_devcmd_fw_info **fw_info);
117 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset,
118 		  unsigned int size, void *value);
119 int vnic_dev_stats_clear(struct vnic_dev *vdev);
120 int vnic_dev_cmd_init(struct vnic_dev *vdev);
121 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
122 int vnic_dev_hang_notify(struct vnic_dev *vdev);
123 void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
124 			    int broadcast, int promisc, int allmulti);
125 void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
126 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
127 int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
128 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
129 void vnic_dev_notify_unset(struct vnic_dev *vdev);
130 int vnic_dev_link_status(struct vnic_dev *vdev);
131 u32 vnic_dev_port_speed(struct vnic_dev *vdev);
132 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
133 u32 vnic_dev_mtu(struct vnic_dev *vdev);
134 u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev);
135 int vnic_dev_close(struct vnic_dev *vdev);
136 int vnic_dev_enable(struct vnic_dev *vdev);
137 int vnic_dev_disable(struct vnic_dev *vdev);
138 int vnic_dev_open(struct vnic_dev *vdev, int arg);
139 int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
140 int vnic_dev_init(struct vnic_dev *vdev, int arg);
141 u16 vnic_dev_set_default_vlan(struct vnic_dev *vdev,
142 				u16 new_default_vlan);
143 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
144 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
145 void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
146 			    enum vnic_dev_intr_mode intr_mode);
147 enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
148 void vnic_dev_unregister(struct vnic_dev *vdev);
149 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
150 				   void *priv, struct pci_dev *pdev,
151 				   struct vnic_dev_bar *bar);
152 
153 #endif /* _VNIC_DEV_H_ */
154