xref: /openbmc/linux/drivers/scsi/fnic/vnic_dev.h (revision fb574682)
1 /*
2  * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
3  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
4  *
5  * This program is free software; you may redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; version 2 of the License.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16  * SOFTWARE.
17  */
18 #ifndef _VNIC_DEV_H_
19 #define _VNIC_DEV_H_
20 
21 #include "vnic_resource.h"
22 #include "vnic_devcmd.h"
23 
24 /*
25  * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
26  * Driver) when both are built with CONFIG options =y
27  */
28 #define vnic_dev_priv fnic_dev_priv
29 #define vnic_dev_get_res_count fnic_dev_get_res_count
30 #define vnic_dev_get_res fnic_dev_get_res
31 #define vnic_dev_desc_ring_size fnic_dev_desc_ring_siz
32 #define vnic_dev_clear_desc_ring fnic_dev_clear_desc_ring
33 #define vnic_dev_alloc_desc_ring fnic_dev_alloc_desc_ring
34 #define vnic_dev_free_desc_ring fnic_dev_free_desc_ring
35 #define vnic_dev_cmd fnic_dev_cmd
36 #define vnic_dev_fw_info fnic_dev_fw_info
37 #define vnic_dev_spec fnic_dev_spec
38 #define vnic_dev_stats_clear fnic_dev_stats_clear
39 #define vnic_dev_cmd_init fnic_dev_cmd_init
40 #define vnic_dev_stats_dump fnic_dev_stats_dump
41 #define vnic_dev_hang_notify fnic_dev_hang_notify
42 #define vnic_dev_packet_filter fnic_dev_packet_filter
43 #define vnic_dev_add_addr fnic_dev_add_addr
44 #define vnic_dev_del_addr fnic_dev_del_addr
45 #define vnic_dev_mac_addr fnic_dev_mac_addr
46 #define vnic_dev_notify_set fnic_dev_notify_set
47 #define vnic_dev_notify_unset fnic_dev_notify_unset
48 #define vnic_dev_link_status fnic_dev_link_status
49 #define vnic_dev_port_speed fnic_dev_port_speed
50 #define vnic_dev_msg_lvl fnic_dev_msg_lvl
51 #define vnic_dev_mtu fnic_dev_mtu
52 #define vnic_dev_link_down_cnt fnic_dev_link_down_cnt
53 #define vnic_dev_close fnic_dev_close
54 #define vnic_dev_enable fnic_dev_enable
55 #define vnic_dev_disable fnic_dev_disable
56 #define vnic_dev_open fnic_dev_open
57 #define vnic_dev_open_done fnic_dev_open_done
58 #define vnic_dev_init fnic_dev_init
59 #define vnic_dev_soft_reset fnic_dev_soft_reset
60 #define vnic_dev_soft_reset_done fnic_dev_soft_reset_done
61 #define vnic_dev_set_intr_mode fnic_dev_set_intr_mode
62 #define vnic_dev_get_intr_mode fnic_dev_get_intr_mode
63 #define vnic_dev_unregister fnic_dev_unregister
64 #define vnic_dev_register fnic_dev_register
65 
66 #ifndef VNIC_PADDR_TARGET
67 #define VNIC_PADDR_TARGET	0x0000000000000000ULL
68 #endif
69 
70 #ifndef readq
71 static inline u64 readq(void __iomem *reg)
72 {
73 	return ((u64)readl(reg + 0x4UL) << 32) | (u64)readl(reg);
74 }
75 
76 static inline void writeq(u64 val, void __iomem *reg)
77 {
78 	writel(val & 0xffffffff, reg);
79 	writel(val >> 32, reg + 0x4UL);
80 }
81 #endif
82 
83 enum vnic_dev_intr_mode {
84 	VNIC_DEV_INTR_MODE_UNKNOWN,
85 	VNIC_DEV_INTR_MODE_INTX,
86 	VNIC_DEV_INTR_MODE_MSI,
87 	VNIC_DEV_INTR_MODE_MSIX,
88 };
89 
90 struct vnic_dev_bar {
91 	void __iomem *vaddr;
92 	dma_addr_t bus_addr;
93 	unsigned long len;
94 };
95 
96 struct vnic_dev_ring {
97 	void *descs;
98 	size_t size;
99 	dma_addr_t base_addr;
100 	size_t base_align;
101 	void *descs_unaligned;
102 	size_t size_unaligned;
103 	dma_addr_t base_addr_unaligned;
104 	unsigned int desc_size;
105 	unsigned int desc_count;
106 	unsigned int desc_avail;
107 };
108 
109 struct vnic_dev;
110 struct vnic_stats;
111 
112 void *vnic_dev_priv(struct vnic_dev *vdev);
113 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
114 				    enum vnic_res_type type);
115 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
116 			       unsigned int index);
117 unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
118 				     unsigned int desc_count,
119 				     unsigned int desc_size);
120 void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
121 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
122 			     unsigned int desc_count, unsigned int desc_size);
123 void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
124 			     struct vnic_dev_ring *ring);
125 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
126 		 u64 *a0, u64 *a1, int wait);
127 int vnic_dev_fw_info(struct vnic_dev *vdev,
128 		     struct vnic_devcmd_fw_info **fw_info);
129 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset,
130 		  unsigned int size, void *value);
131 int vnic_dev_stats_clear(struct vnic_dev *vdev);
132 int vnic_dev_cmd_init(struct vnic_dev *vdev);
133 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
134 int vnic_dev_hang_notify(struct vnic_dev *vdev);
135 void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
136 			    int broadcast, int promisc, int allmulti);
137 void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
138 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
139 int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
140 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
141 void vnic_dev_notify_unset(struct vnic_dev *vdev);
142 int vnic_dev_link_status(struct vnic_dev *vdev);
143 u32 vnic_dev_port_speed(struct vnic_dev *vdev);
144 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
145 u32 vnic_dev_mtu(struct vnic_dev *vdev);
146 u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev);
147 int vnic_dev_close(struct vnic_dev *vdev);
148 int vnic_dev_enable(struct vnic_dev *vdev);
149 int vnic_dev_disable(struct vnic_dev *vdev);
150 int vnic_dev_open(struct vnic_dev *vdev, int arg);
151 int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
152 int vnic_dev_init(struct vnic_dev *vdev, int arg);
153 u16 vnic_dev_set_default_vlan(struct vnic_dev *vdev,
154 				u16 new_default_vlan);
155 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
156 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
157 void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
158 			    enum vnic_dev_intr_mode intr_mode);
159 enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
160 void vnic_dev_unregister(struct vnic_dev *vdev);
161 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
162 				   void *priv, struct pci_dev *pdev,
163 				   struct vnic_dev_bar *bar);
164 
165 #endif /* _VNIC_DEV_H_ */
166