18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2008 Cisco Systems, Inc. All rights reserved. 38c2ecf20Sopenharmony_ci * Copyright 2007 Nuova Systems, Inc. All rights reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * This program is free software; you may redistribute it and/or modify 68c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by 78c2ecf20Sopenharmony_ci * the Free Software Foundation; version 2 of the License. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 108c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 118c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 128c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 138c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 158c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 168c2ecf20Sopenharmony_ci * SOFTWARE. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#ifndef _VNIC_DEV_H_ 198c2ecf20Sopenharmony_ci#define _VNIC_DEV_H_ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include "vnic_resource.h" 228c2ecf20Sopenharmony_ci#include "vnic_devcmd.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_ci * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth 268c2ecf20Sopenharmony_ci * Driver) when both are built with CONFIG options =y 278c2ecf20Sopenharmony_ci */ 288c2ecf20Sopenharmony_ci#define vnic_dev_priv fnic_dev_priv 298c2ecf20Sopenharmony_ci#define vnic_dev_get_res_count fnic_dev_get_res_count 308c2ecf20Sopenharmony_ci#define vnic_dev_get_res fnic_dev_get_res 318c2ecf20Sopenharmony_ci#define vnic_dev_desc_ring_size fnic_dev_desc_ring_siz 328c2ecf20Sopenharmony_ci#define vnic_dev_clear_desc_ring fnic_dev_clear_desc_ring 338c2ecf20Sopenharmony_ci#define vnic_dev_alloc_desc_ring fnic_dev_alloc_desc_ring 348c2ecf20Sopenharmony_ci#define vnic_dev_free_desc_ring fnic_dev_free_desc_ring 358c2ecf20Sopenharmony_ci#define vnic_dev_cmd fnic_dev_cmd 368c2ecf20Sopenharmony_ci#define vnic_dev_fw_info fnic_dev_fw_info 378c2ecf20Sopenharmony_ci#define vnic_dev_spec fnic_dev_spec 388c2ecf20Sopenharmony_ci#define vnic_dev_stats_clear fnic_dev_stats_clear 398c2ecf20Sopenharmony_ci#define vnic_dev_cmd_init fnic_dev_cmd_init 408c2ecf20Sopenharmony_ci#define vnic_dev_stats_dump fnic_dev_stats_dump 418c2ecf20Sopenharmony_ci#define vnic_dev_hang_notify fnic_dev_hang_notify 428c2ecf20Sopenharmony_ci#define vnic_dev_packet_filter fnic_dev_packet_filter 438c2ecf20Sopenharmony_ci#define vnic_dev_add_addr fnic_dev_add_addr 448c2ecf20Sopenharmony_ci#define vnic_dev_del_addr fnic_dev_del_addr 458c2ecf20Sopenharmony_ci#define vnic_dev_mac_addr fnic_dev_mac_addr 468c2ecf20Sopenharmony_ci#define vnic_dev_notify_set fnic_dev_notify_set 478c2ecf20Sopenharmony_ci#define vnic_dev_notify_unset fnic_dev_notify_unset 488c2ecf20Sopenharmony_ci#define vnic_dev_link_status fnic_dev_link_status 498c2ecf20Sopenharmony_ci#define vnic_dev_port_speed fnic_dev_port_speed 508c2ecf20Sopenharmony_ci#define vnic_dev_msg_lvl fnic_dev_msg_lvl 518c2ecf20Sopenharmony_ci#define vnic_dev_mtu fnic_dev_mtu 528c2ecf20Sopenharmony_ci#define vnic_dev_link_down_cnt fnic_dev_link_down_cnt 538c2ecf20Sopenharmony_ci#define vnic_dev_close fnic_dev_close 548c2ecf20Sopenharmony_ci#define vnic_dev_enable fnic_dev_enable 558c2ecf20Sopenharmony_ci#define vnic_dev_disable fnic_dev_disable 568c2ecf20Sopenharmony_ci#define vnic_dev_open fnic_dev_open 578c2ecf20Sopenharmony_ci#define vnic_dev_open_done fnic_dev_open_done 588c2ecf20Sopenharmony_ci#define vnic_dev_init fnic_dev_init 598c2ecf20Sopenharmony_ci#define vnic_dev_soft_reset fnic_dev_soft_reset 608c2ecf20Sopenharmony_ci#define vnic_dev_soft_reset_done fnic_dev_soft_reset_done 618c2ecf20Sopenharmony_ci#define vnic_dev_set_intr_mode fnic_dev_set_intr_mode 628c2ecf20Sopenharmony_ci#define vnic_dev_get_intr_mode fnic_dev_get_intr_mode 638c2ecf20Sopenharmony_ci#define vnic_dev_unregister fnic_dev_unregister 648c2ecf20Sopenharmony_ci#define vnic_dev_register fnic_dev_register 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#ifndef VNIC_PADDR_TARGET 678c2ecf20Sopenharmony_ci#define VNIC_PADDR_TARGET 0x0000000000000000ULL 688c2ecf20Sopenharmony_ci#endif 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#ifndef readq 718c2ecf20Sopenharmony_cistatic inline u64 readq(void __iomem *reg) 728c2ecf20Sopenharmony_ci{ 738c2ecf20Sopenharmony_ci return ((u64)readl(reg + 0x4UL) << 32) | (u64)readl(reg); 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistatic inline void writeq(u64 val, void __iomem *reg) 778c2ecf20Sopenharmony_ci{ 788c2ecf20Sopenharmony_ci writel(val & 0xffffffff, reg); 798c2ecf20Sopenharmony_ci writel(val >> 32, reg + 0x4UL); 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci#endif 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cienum vnic_dev_intr_mode { 848c2ecf20Sopenharmony_ci VNIC_DEV_INTR_MODE_UNKNOWN, 858c2ecf20Sopenharmony_ci VNIC_DEV_INTR_MODE_INTX, 868c2ecf20Sopenharmony_ci VNIC_DEV_INTR_MODE_MSI, 878c2ecf20Sopenharmony_ci VNIC_DEV_INTR_MODE_MSIX, 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistruct vnic_dev_bar { 918c2ecf20Sopenharmony_ci void __iomem *vaddr; 928c2ecf20Sopenharmony_ci dma_addr_t bus_addr; 938c2ecf20Sopenharmony_ci unsigned long len; 948c2ecf20Sopenharmony_ci}; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cistruct vnic_dev_ring { 978c2ecf20Sopenharmony_ci void *descs; 988c2ecf20Sopenharmony_ci size_t size; 998c2ecf20Sopenharmony_ci dma_addr_t base_addr; 1008c2ecf20Sopenharmony_ci size_t base_align; 1018c2ecf20Sopenharmony_ci void *descs_unaligned; 1028c2ecf20Sopenharmony_ci size_t size_unaligned; 1038c2ecf20Sopenharmony_ci dma_addr_t base_addr_unaligned; 1048c2ecf20Sopenharmony_ci unsigned int desc_size; 1058c2ecf20Sopenharmony_ci unsigned int desc_count; 1068c2ecf20Sopenharmony_ci unsigned int desc_avail; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistruct vnic_dev; 1108c2ecf20Sopenharmony_cistruct vnic_stats; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_civoid *vnic_dev_priv(struct vnic_dev *vdev); 1138c2ecf20Sopenharmony_ciunsigned int vnic_dev_get_res_count(struct vnic_dev *vdev, 1148c2ecf20Sopenharmony_ci enum vnic_res_type type); 1158c2ecf20Sopenharmony_civoid __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type, 1168c2ecf20Sopenharmony_ci unsigned int index); 1178c2ecf20Sopenharmony_ciunsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring, 1188c2ecf20Sopenharmony_ci unsigned int desc_count, 1198c2ecf20Sopenharmony_ci unsigned int desc_size); 1208c2ecf20Sopenharmony_civoid vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring); 1218c2ecf20Sopenharmony_ciint vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring, 1228c2ecf20Sopenharmony_ci unsigned int desc_count, unsigned int desc_size); 1238c2ecf20Sopenharmony_civoid vnic_dev_free_desc_ring(struct vnic_dev *vdev, 1248c2ecf20Sopenharmony_ci struct vnic_dev_ring *ring); 1258c2ecf20Sopenharmony_ciint vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, 1268c2ecf20Sopenharmony_ci u64 *a0, u64 *a1, int wait); 1278c2ecf20Sopenharmony_ciint vnic_dev_fw_info(struct vnic_dev *vdev, 1288c2ecf20Sopenharmony_ci struct vnic_devcmd_fw_info **fw_info); 1298c2ecf20Sopenharmony_ciint vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, 1308c2ecf20Sopenharmony_ci unsigned int size, void *value); 1318c2ecf20Sopenharmony_ciint vnic_dev_stats_clear(struct vnic_dev *vdev); 1328c2ecf20Sopenharmony_ciint vnic_dev_cmd_init(struct vnic_dev *vdev); 1338c2ecf20Sopenharmony_ciint vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats); 1348c2ecf20Sopenharmony_ciint vnic_dev_hang_notify(struct vnic_dev *vdev); 1358c2ecf20Sopenharmony_civoid vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast, 1368c2ecf20Sopenharmony_ci int broadcast, int promisc, int allmulti); 1378c2ecf20Sopenharmony_civoid vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr); 1388c2ecf20Sopenharmony_civoid vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr); 1398c2ecf20Sopenharmony_ciint vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr); 1408c2ecf20Sopenharmony_ciint vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr); 1418c2ecf20Sopenharmony_civoid vnic_dev_notify_unset(struct vnic_dev *vdev); 1428c2ecf20Sopenharmony_ciint vnic_dev_link_status(struct vnic_dev *vdev); 1438c2ecf20Sopenharmony_ciu32 vnic_dev_port_speed(struct vnic_dev *vdev); 1448c2ecf20Sopenharmony_ciu32 vnic_dev_msg_lvl(struct vnic_dev *vdev); 1458c2ecf20Sopenharmony_ciu32 vnic_dev_mtu(struct vnic_dev *vdev); 1468c2ecf20Sopenharmony_ciu32 vnic_dev_link_down_cnt(struct vnic_dev *vdev); 1478c2ecf20Sopenharmony_ciint vnic_dev_close(struct vnic_dev *vdev); 1488c2ecf20Sopenharmony_ciint vnic_dev_enable(struct vnic_dev *vdev); 1498c2ecf20Sopenharmony_ciint vnic_dev_disable(struct vnic_dev *vdev); 1508c2ecf20Sopenharmony_ciint vnic_dev_open(struct vnic_dev *vdev, int arg); 1518c2ecf20Sopenharmony_ciint vnic_dev_open_done(struct vnic_dev *vdev, int *done); 1528c2ecf20Sopenharmony_ciint vnic_dev_init(struct vnic_dev *vdev, int arg); 1538c2ecf20Sopenharmony_ciu16 vnic_dev_set_default_vlan(struct vnic_dev *vdev, 1548c2ecf20Sopenharmony_ci u16 new_default_vlan); 1558c2ecf20Sopenharmony_ciint vnic_dev_soft_reset(struct vnic_dev *vdev, int arg); 1568c2ecf20Sopenharmony_ciint vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done); 1578c2ecf20Sopenharmony_civoid vnic_dev_set_intr_mode(struct vnic_dev *vdev, 1588c2ecf20Sopenharmony_ci enum vnic_dev_intr_mode intr_mode); 1598c2ecf20Sopenharmony_cienum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev); 1608c2ecf20Sopenharmony_civoid vnic_dev_unregister(struct vnic_dev *vdev); 1618c2ecf20Sopenharmony_cistruct vnic_dev *vnic_dev_register(struct vnic_dev *vdev, 1628c2ecf20Sopenharmony_ci void *priv, struct pci_dev *pdev, 1638c2ecf20Sopenharmony_ci struct vnic_dev_bar *bar); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci#endif /* _VNIC_DEV_H_ */ 166