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