1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
4 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
10 #include "vnic_resource.h"
11 #include "vnic_devcmd.h"
13 #ifndef VNIC_PADDR_TARGET
14 #define VNIC_PADDR_TARGET 0x0000000000000000ULL
18 static inline u64
readq(void __iomem
*reg
)
20 return (((u64
)readl(reg
+ 0x4UL
) << 32) |
24 static inline void writeq(u64 val
, void __iomem
*reg
)
26 writel(val
& 0xffffffff, reg
);
27 writel(val
>> 32, reg
+ 0x4UL
);
32 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34 #define VNIC_DESC_SIZE_ALIGN 16
35 #define VNIC_DESC_COUNT_ALIGN 32
36 #define VNIC_DESC_BASE_ALIGN 512
37 #define VNIC_DESC_MAX_COUNT 4096
39 enum vnic_dev_intr_mode
{
40 VNIC_DEV_INTR_MODE_UNKNOWN
,
41 VNIC_DEV_INTR_MODE_INTX
,
42 VNIC_DEV_INTR_MODE_MSI
,
43 VNIC_DEV_INTR_MODE_MSIX
,
52 struct vnic_dev_ring
{
57 void *descs_unaligned
;
58 size_t size_unaligned
;
59 dma_addr_t base_addr_unaligned
;
60 unsigned int desc_size
;
61 unsigned int desc_count
;
62 unsigned int desc_avail
;
65 enum vnic_proxy_type
{
77 struct vnic_intr_coal_timer_info
{
86 struct vnic_res res
[RES_TYPE_MAX
];
87 enum vnic_dev_intr_mode intr_mode
;
88 struct vnic_devcmd __iomem
*devcmd
;
89 struct vnic_devcmd_notify
*notify
;
90 struct vnic_devcmd_notify notify_copy
;
93 dma_addr_t linkstatus_pa
;
94 struct vnic_stats
*stats
;
96 struct vnic_devcmd_fw_info
*fw_info
;
97 dma_addr_t fw_info_pa
;
98 enum vnic_proxy_type proxy
;
100 u64 args
[VNIC_DEVCMD_NARGS
];
101 struct vnic_intr_coal_timer_info intr_coal_timer_info
;
102 struct devcmd2_controller
*devcmd2
;
103 int (*devcmd_rtn
)(struct vnic_dev
*vdev
, enum vnic_devcmd_cmd cmd
,
109 void *vnic_dev_priv(struct vnic_dev
*vdev
);
110 unsigned int vnic_dev_get_res_count(struct vnic_dev
*vdev
,
111 enum vnic_res_type type
);
112 void __iomem
*vnic_dev_get_res(struct vnic_dev
*vdev
, enum vnic_res_type type
,
114 void vnic_dev_clear_desc_ring(struct vnic_dev_ring
*ring
);
115 int vnic_dev_alloc_desc_ring(struct vnic_dev
*vdev
, struct vnic_dev_ring
*ring
,
116 unsigned int desc_count
, unsigned int desc_size
);
117 void vnic_dev_free_desc_ring(struct vnic_dev
*vdev
,
118 struct vnic_dev_ring
*ring
);
119 int vnic_dev_cmd(struct vnic_dev
*vdev
, enum vnic_devcmd_cmd cmd
,
120 u64
*a0
, u64
*a1
, int wait
);
121 void vnic_dev_cmd_proxy_by_index_start(struct vnic_dev
*vdev
, u16 index
);
122 void vnic_dev_cmd_proxy_end(struct vnic_dev
*vdev
);
123 int vnic_dev_fw_info(struct vnic_dev
*vdev
,
124 struct vnic_devcmd_fw_info
**fw_info
);
125 int vnic_dev_spec(struct vnic_dev
*vdev
, unsigned int offset
, unsigned int size
,
127 int vnic_dev_stats_dump(struct vnic_dev
*vdev
, struct vnic_stats
**stats
);
128 int vnic_dev_hang_notify(struct vnic_dev
*vdev
);
129 int vnic_dev_packet_filter(struct vnic_dev
*vdev
, int directed
, int multicast
,
130 int broadcast
, int promisc
, int allmulti
);
131 int vnic_dev_add_addr(struct vnic_dev
*vdev
, const u8
*addr
);
132 int vnic_dev_del_addr(struct vnic_dev
*vdev
, const u8
*addr
);
133 int vnic_dev_get_mac_addr(struct vnic_dev
*vdev
, u8
*mac_addr
);
134 int vnic_dev_notify_set(struct vnic_dev
*vdev
, u16 intr
);
135 int vnic_dev_notify_unset(struct vnic_dev
*vdev
);
136 int vnic_dev_link_status(struct vnic_dev
*vdev
);
137 u32
vnic_dev_port_speed(struct vnic_dev
*vdev
);
138 u32
vnic_dev_msg_lvl(struct vnic_dev
*vdev
);
139 u32
vnic_dev_mtu(struct vnic_dev
*vdev
);
140 int vnic_dev_close(struct vnic_dev
*vdev
);
141 int vnic_dev_enable_wait(struct vnic_dev
*vdev
);
142 int vnic_dev_disable(struct vnic_dev
*vdev
);
143 int vnic_dev_open(struct vnic_dev
*vdev
, int arg
);
144 int vnic_dev_open_done(struct vnic_dev
*vdev
, int *done
);
145 int vnic_dev_init(struct vnic_dev
*vdev
, int arg
);
146 int vnic_dev_deinit(struct vnic_dev
*vdev
);
147 void vnic_dev_intr_coal_timer_info_default(struct vnic_dev
*vdev
);
148 int vnic_dev_intr_coal_timer_info(struct vnic_dev
*vdev
);
149 int vnic_dev_hang_reset(struct vnic_dev
*vdev
, int arg
);
150 int vnic_dev_soft_reset(struct vnic_dev
*vdev
, int arg
);
151 int vnic_dev_hang_reset_done(struct vnic_dev
*vdev
, int *done
);
152 int vnic_dev_soft_reset_done(struct vnic_dev
*vdev
, int *done
);
153 void vnic_dev_set_intr_mode(struct vnic_dev
*vdev
,
154 enum vnic_dev_intr_mode intr_mode
);
155 enum vnic_dev_intr_mode
vnic_dev_get_intr_mode(struct vnic_dev
*vdev
);
156 u32
vnic_dev_intr_coal_timer_usec_to_hw(struct vnic_dev
*vdev
, u32 usec
);
157 u32
vnic_dev_intr_coal_timer_hw_to_usec(struct vnic_dev
*vdev
, u32 hw_cycles
);
158 u32
vnic_dev_get_intr_coal_timer_max(struct vnic_dev
*vdev
);
159 void vnic_dev_unregister(struct vnic_dev
*vdev
);
160 int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev
*vdev
,
161 u8 ig_vlan_rewrite_mode
);
162 struct vnic_dev
*vnic_dev_register(struct vnic_dev
*vdev
,
163 void *priv
, struct pci_dev
*pdev
, struct vnic_dev_bar
*bar
,
164 unsigned int num_bars
);
165 struct pci_dev
*vnic_dev_get_pdev(struct vnic_dev
*vdev
);
166 int vnic_dev_init_prov2(struct vnic_dev
*vdev
, u8
*buf
, u32 len
);
167 int vnic_dev_enable2(struct vnic_dev
*vdev
, int active
);
168 int vnic_dev_enable2_done(struct vnic_dev
*vdev
, int *status
);
169 int vnic_dev_deinit_done(struct vnic_dev
*vdev
, int *status
);
170 int vnic_dev_set_mac_addr(struct vnic_dev
*vdev
, u8
*mac_addr
);
171 int vnic_dev_classifier(struct vnic_dev
*vdev
, u8 cmd
, u16
*entry
,
172 struct filter
*data
);
173 int vnic_devcmd_init(struct vnic_dev
*vdev
);
174 int vnic_dev_overlay_offload_ctrl(struct vnic_dev
*vdev
, u8 overlay
, u8 config
);
175 int vnic_dev_overlay_offload_cfg(struct vnic_dev
*vdev
, u8 overlay
,
176 u16 vxlan_udp_port_number
);
177 int vnic_dev_get_supported_feature_ver(struct vnic_dev
*vdev
, u8 feature
,
178 u64
*supported_versions
, u64
*a1
);
179 int vnic_dev_capable_rss_hash_type(struct vnic_dev
*vdev
, u8
*rss_hash_type
);
181 #endif /* _VNIC_DEV_H_ */