blob: caccce36957b4695a0126d2df6050cadb3271249 [file] [log] [blame]
Scott Feldman01f2e4e2008-09-15 09:17:11 -07001/*
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 */
19
20#ifndef _VNIC_DEV_H_
21#define _VNIC_DEV_H_
22
23#include "vnic_resource.h"
24#include "vnic_devcmd.h"
25
26#ifndef VNIC_PADDR_TARGET
27#define VNIC_PADDR_TARGET 0x0000000000000000ULL
28#endif
29
David S. Miller55ed31e2008-10-09 22:13:53 -070030#ifndef readq
31static inline u64 readq(void __iomem *reg)
32{
33 return (((u64)readl(reg + 0x4UL) << 32) |
34 (u64)readl(reg));
35}
36
37static inline void writeq(u64 val, void __iomem *reg)
38{
39 writel(val & 0xffffffff, reg);
40 writel(val >> 32, reg + 0x4UL);
41}
42#endif
43
Scott Feldman4badc382009-09-03 17:01:58 +000044enum vnic_dev_hw_version {
45 VNIC_DEV_HW_VER_UNKNOWN,
46 VNIC_DEV_HW_VER_A1,
47 VNIC_DEV_HW_VER_A2,
48};
49
Scott Feldman01f2e4e2008-09-15 09:17:11 -070050enum vnic_dev_intr_mode {
51 VNIC_DEV_INTR_MODE_UNKNOWN,
52 VNIC_DEV_INTR_MODE_INTX,
53 VNIC_DEV_INTR_MODE_MSI,
54 VNIC_DEV_INTR_MODE_MSIX,
55};
56
57struct vnic_dev_bar {
58 void __iomem *vaddr;
59 dma_addr_t bus_addr;
60 unsigned long len;
61};
62
63struct vnic_dev_ring {
64 void *descs;
65 size_t size;
66 dma_addr_t base_addr;
67 size_t base_align;
68 void *descs_unaligned;
69 size_t size_unaligned;
70 dma_addr_t base_addr_unaligned;
71 unsigned int desc_size;
72 unsigned int desc_count;
73 unsigned int desc_avail;
74};
75
76struct vnic_dev;
77struct vnic_stats;
78
79void *vnic_dev_priv(struct vnic_dev *vdev);
80unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
81 enum vnic_res_type type);
82void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
83 unsigned int index);
Scott Feldman27e6c7d2009-09-03 17:01:53 +000084dma_addr_t vnic_dev_get_res_bus_addr(struct vnic_dev *vdev,
85 enum vnic_res_type type, unsigned int index);
Scott Feldman01f2e4e2008-09-15 09:17:11 -070086unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
87 unsigned int desc_count, unsigned int desc_size);
88void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
89int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
90 unsigned int desc_count, unsigned int desc_size);
91void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
92 struct vnic_dev_ring *ring);
93int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
94 u64 *a0, u64 *a1, int wait);
95int vnic_dev_fw_info(struct vnic_dev *vdev,
96 struct vnic_devcmd_fw_info **fw_info);
Scott Feldman4badc382009-09-03 17:01:58 +000097int vnic_dev_hw_version(struct vnic_dev *vdev,
98 enum vnic_dev_hw_version *hw_ver);
Scott Feldman01f2e4e2008-09-15 09:17:11 -070099int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size,
100 void *value);
101int vnic_dev_stats_clear(struct vnic_dev *vdev);
102int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
103int vnic_dev_hang_notify(struct vnic_dev *vdev);
104void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
105 int broadcast, int promisc, int allmulti);
Scott Feldmanf8bd9092010-05-17 22:50:19 -0700106int vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
107int vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
Scott Feldman01f2e4e2008-09-15 09:17:11 -0700108int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
Scott Feldmand73149f2009-09-03 17:02:35 +0000109int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr);
Vasanthy Kollurid883aa72010-03-18 16:19:59 +0000110int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
111 void *notify_addr, dma_addr_t notify_pa, u16 intr);
Scott Feldman01f2e4e2008-09-15 09:17:11 -0700112int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
Vasanthy Kollurid883aa72010-03-18 16:19:59 +0000113void vnic_dev_notify_unsetcmd(struct vnic_dev *vdev);
Scott Feldman01f2e4e2008-09-15 09:17:11 -0700114void vnic_dev_notify_unset(struct vnic_dev *vdev);
115int vnic_dev_link_status(struct vnic_dev *vdev);
116u32 vnic_dev_port_speed(struct vnic_dev *vdev);
117u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
118u32 vnic_dev_mtu(struct vnic_dev *vdev);
Scott Feldman4cdc44a2009-02-09 23:25:33 -0800119u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev);
120u32 vnic_dev_notify_status(struct vnic_dev *vdev);
Scott Feldman01f2e4e2008-09-15 09:17:11 -0700121int vnic_dev_close(struct vnic_dev *vdev);
122int vnic_dev_enable(struct vnic_dev *vdev);
123int vnic_dev_disable(struct vnic_dev *vdev);
124int vnic_dev_open(struct vnic_dev *vdev, int arg);
125int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
126int vnic_dev_init(struct vnic_dev *vdev, int arg);
Scott Feldmanf8bd9092010-05-17 22:50:19 -0700127int vnic_dev_init_done(struct vnic_dev *vdev, int *done, int *err);
128int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len);
129int vnic_dev_deinit(struct vnic_dev *vdev);
Scott Feldman01f2e4e2008-09-15 09:17:11 -0700130int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
131int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
132void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
133 enum vnic_dev_intr_mode intr_mode);
134enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
135void vnic_dev_unregister(struct vnic_dev *vdev);
136struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
Scott Feldman27e6c7d2009-09-03 17:01:53 +0000137 void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar,
138 unsigned int num_bars);
Scott Feldman01f2e4e2008-09-15 09:17:11 -0700139
140#endif /* _VNIC_DEV_H_ */