1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved. 3 * Copyright 2007 Nuova Systems, Inc. All rights reserved. 4 */ 5 6 #ifndef _VNIC_DEV_H_ 7 #define _VNIC_DEV_H_ 8 9 #include "enic_compat.h" 10 #include "vnic_resource.h" 11 #include "vnic_devcmd.h" 12 13 #ifndef VNIC_PADDR_TARGET 14 #define VNIC_PADDR_TARGET 0x0000000000000000ULL 15 #endif 16 17 enum vnic_dev_intr_mode { 18 VNIC_DEV_INTR_MODE_UNKNOWN, 19 VNIC_DEV_INTR_MODE_INTX, 20 VNIC_DEV_INTR_MODE_MSI, 21 VNIC_DEV_INTR_MODE_MSIX, 22 }; 23 24 struct vnic_dev_bar { 25 void __iomem *vaddr; 26 unsigned long len; 27 }; 28 29 struct vnic_dev_ring { 30 void *descs; /* vaddr */ 31 size_t size; 32 bus_addr_t base_addr; /* paddr */ 33 size_t base_align; 34 void *descs_unaligned; 35 size_t size_unaligned; 36 bus_addr_t base_addr_unaligned; 37 unsigned int desc_size; 38 unsigned int desc_count; 39 unsigned int desc_avail; 40 unsigned int last_count; 41 iflib_dma_info_t ifdip; 42 }; 43 44 struct vnic_dev_iomap_info { 45 bus_addr_t bus_addr; 46 unsigned long len; 47 void __iomem *vaddr; 48 }; 49 50 struct vnic_dev; 51 struct vnic_stats; 52 53 void *vnic_dev_priv(struct vnic_dev *vdev); 54 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev, 55 enum vnic_res_type type); 56 void vnic_register_cbacks(struct vnic_dev *vdev, 57 void *(*alloc_consistent)(void *priv, size_t size, 58 bus_addr_t *dma_handle, struct iflib_dma_info *res, u8 *name), 59 void (*free_consistent)(void *priv, 60 size_t size, void *vaddr, 61 bus_addr_t dma_handle, struct iflib_dma_info *res)); 62 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type, 63 unsigned int index); 64 uint8_t vnic_dev_get_res_bar(struct vnic_dev *vdev, 65 enum vnic_res_type type); 66 uint32_t vnic_dev_get_res_offset(struct vnic_dev *vdev, 67 enum vnic_res_type type, unsigned int index); 68 unsigned long vnic_dev_get_res_type_len(struct vnic_dev *vdev, 69 enum vnic_res_type type); 70 unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring, 71 unsigned int desc_count, unsigned int desc_size); 72 void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring); 73 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring, 74 unsigned int desc_count, unsigned int desc_size); 75 void vnic_dev_free_desc_ring(struct vnic_dev *vdev, 76 struct vnic_dev_ring *ring); 77 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, 78 u64 *a0, u64 *a1, int wait); 79 int vnic_dev_cmd_args(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, 80 u64 *args, int nargs, int wait); 81 void vnic_dev_cmd_proxy_by_index_start(struct vnic_dev *vdev, u16 index); 82 void vnic_dev_cmd_proxy_by_bdf_start(struct vnic_dev *vdev, u16 bdf); 83 void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev); 84 int vnic_dev_fw_info(struct vnic_dev *vdev, 85 struct vnic_devcmd_fw_info **fw_info); 86 int vnic_dev_capable_adv_filters(struct vnic_dev *vdev); 87 int vnic_dev_capable(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd); 88 int vnic_dev_capable_filter_mode(struct vnic_dev *vdev, u32 *mode, 89 u8 *filter_actions); 90 void vnic_dev_capable_udp_rss_weak(struct vnic_dev *vdev, bool *cfg_chk, 91 bool *weak); 92 int vnic_dev_asic_info(struct vnic_dev *vdev, u16 *asic_type, u16 *asic_rev); 93 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, size_t size, 94 void *value); 95 int vnic_dev_stats_clear(struct vnic_dev *vdev); 96 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats); 97 int vnic_dev_counter_dma_cfg(struct vnic_dev *vdev, u32 period, 98 u32 num_counters); 99 int vnic_dev_hang_notify(struct vnic_dev *vdev); 100 int vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast, 101 int broadcast, int promisc, int allmulti); 102 int vnic_dev_packet_filter_all(struct vnic_dev *vdev, int directed, 103 int multicast, int broadcast, int promisc, int allmulti); 104 int vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr); 105 int vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr); 106 int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr); 107 int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr); 108 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr); 109 void vnic_dev_set_reset_flag(struct vnic_dev *vdev, int state); 110 int vnic_dev_notify_unset(struct vnic_dev *vdev); 111 int vnic_dev_notify_setcmd(struct vnic_dev *vdev, 112 void *notify_addr, bus_addr_t notify_pa, u16 intr); 113 int vnic_dev_notify_unsetcmd(struct vnic_dev *vdev); 114 int vnic_dev_link_status(struct vnic_dev *vdev); 115 u32 vnic_dev_port_speed(struct vnic_dev *vdev); 116 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev); 117 u32 vnic_dev_mtu(struct vnic_dev *vdev); 118 u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev); 119 u32 vnic_dev_notify_status(struct vnic_dev *vdev); 120 u32 vnic_dev_uif(struct vnic_dev *vdev); 121 int vnic_dev_close(struct vnic_dev *vdev); 122 int vnic_dev_enable(struct vnic_dev *vdev); 123 int vnic_dev_enable_wait(struct vnic_dev *vdev); 124 int vnic_dev_disable(struct vnic_dev *vdev); 125 int vnic_dev_open(struct vnic_dev *vdev, int arg); 126 int vnic_dev_open_done(struct vnic_dev *vdev, int *done); 127 int vnic_dev_init(struct vnic_dev *vdev, int arg); 128 int vnic_dev_init_done(struct vnic_dev *vdev, int *done, int *err); 129 int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len); 130 int vnic_dev_deinit(struct vnic_dev *vdev); 131 void vnic_dev_intr_coal_timer_info_default(struct vnic_dev *vdev); 132 int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev); 133 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg); 134 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done); 135 int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg); 136 int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done); 137 void vnic_dev_set_intr_mode(struct vnic_dev *vdev, 138 enum vnic_dev_intr_mode intr_mode); 139 enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev); 140 u32 vnic_dev_intr_coal_timer_usec_to_hw(struct vnic_dev *vdev, u32 usec); 141 u32 vnic_dev_intr_coal_timer_hw_to_usec(struct vnic_dev *vdev, u32 hw_cycles); 142 u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev); 143 int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev, 144 u8 ig_vlan_rewrite_mode); 145 struct enic; 146 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev, 147 struct enic_bar_info *mem, unsigned int num_bars); 148 struct rte_pci_device *vnic_dev_get_pdev(struct vnic_dev *vdev); 149 int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev); 150 int vnic_dev_alloc_counter_mem(struct vnic_dev *vdev); 151 int vnic_dev_cmd_init(struct vnic_dev *vdev); 152 int vnic_dev_get_size(void); 153 int vnic_dev_int13(struct vnic_dev *vdev, u64 arg, u32 op); 154 int vnic_dev_perbi(struct vnic_dev *vdev, u64 arg, u32 op); 155 u32 vnic_dev_perbi_rebuild_cnt(struct vnic_dev *vdev); 156 int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len); 157 int vnic_dev_enable2(struct vnic_dev *vdev, int active); 158 int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status); 159 int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status); 160 int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr); 161 int vnic_dev_classifier(struct vnic_dev *vdev, u8 cmd, u16 *entry, 162 struct filter_v2 *data, struct filter_action_v2 *action_v2); 163 int vnic_dev_overlay_offload_ctrl(struct vnic_dev *vdev, 164 u8 overlay, u8 config); 165 int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay, 166 u16 vxlan_udp_port_number); 167 int vnic_dev_capable_vxlan(struct vnic_dev *vdev); 168 bool vnic_dev_counter_alloc(struct vnic_dev *vdev, uint32_t *idx); 169 bool vnic_dev_counter_free(struct vnic_dev *vdev, uint32_t idx); 170 bool vnic_dev_counter_query(struct vnic_dev *vdev, uint32_t idx, 171 bool reset, uint64_t *packets, uint64_t *bytes); 172 void vnic_dev_deinit_devcmd2(struct vnic_dev *vdev); 173 174 device_t dev_from_vnic_dev(struct vnic_dev *vdev); 175 176 #endif /* _VNIC_DEV_H_ */ 177