hinic_hw_io.h (2605B)
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Huawei HiNIC PCI Express Linux driver 4 * Copyright(c) 2017 Huawei Technologies Co., Ltd 5 */ 6 7#ifndef HINIC_HW_IO_H 8#define HINIC_HW_IO_H 9 10#include <linux/types.h> 11#include <linux/pci.h> 12#include <linux/semaphore.h> 13#include <linux/sizes.h> 14 15#include "hinic_hw_if.h" 16#include "hinic_hw_eqs.h" 17#include "hinic_hw_wq.h" 18#include "hinic_hw_cmdq.h" 19#include "hinic_hw_qp.h" 20 21#define HINIC_DB_PAGE_SIZE SZ_4K 22#define HINIC_DB_SIZE SZ_4M 23#define HINIC_HW_WQ_PAGE_SIZE SZ_4K 24#define HINIC_DEFAULT_WQ_PAGE_SIZE SZ_256K 25 26#define HINIC_DB_MAX_AREAS (HINIC_DB_SIZE / HINIC_DB_PAGE_SIZE) 27 28enum hinic_db_type { 29 HINIC_DB_CMDQ_TYPE, 30 HINIC_DB_SQ_TYPE, 31}; 32 33enum hinic_io_path { 34 HINIC_CTRL_PATH, 35 HINIC_DATA_PATH, 36}; 37 38struct hinic_free_db_area { 39 int db_idx[HINIC_DB_MAX_AREAS]; 40 41 int alloc_pos; 42 int return_pos; 43 44 int num_free; 45 46 /* Lock for getting db area */ 47 struct semaphore idx_lock; 48}; 49 50struct hinic_nic_cfg { 51 /* lock for getting nic cfg */ 52 struct mutex cfg_mutex; 53 bool pause_set; 54 u32 auto_neg; 55 u32 rx_pause; 56 u32 tx_pause; 57}; 58 59struct hinic_func_to_io { 60 struct hinic_hwif *hwif; 61 struct hinic_hwdev *hwdev; 62 u16 global_qpn; 63 struct hinic_ceqs ceqs; 64 65 struct hinic_wqs wqs; 66 67 struct hinic_wq *sq_wq; 68 struct hinic_wq *rq_wq; 69 70 struct hinic_qp *qps; 71 u16 max_qps; 72 73 u16 sq_depth; 74 u16 rq_depth; 75 76 void __iomem **sq_db; 77 void __iomem *db_base; 78 79 void *ci_addr_base; 80 dma_addr_t ci_dma_base; 81 82 struct hinic_free_db_area free_db_area; 83 84 void __iomem *cmdq_db_area[HINIC_MAX_CMDQ_TYPES]; 85 86 struct hinic_cmdqs cmdqs; 87 88 u16 max_vfs; 89 struct vf_data_storage *vf_infos; 90 u8 link_status; 91 struct hinic_nic_cfg nic_cfg; 92}; 93 94struct hinic_wq_page_size { 95 u8 status; 96 u8 version; 97 u8 rsvd0[6]; 98 99 u16 func_idx; 100 u8 ppf_idx; 101 u8 page_size; 102 103 u32 rsvd1; 104}; 105 106int hinic_set_wq_page_size(struct hinic_hwdev *hwdev, u16 func_idx, 107 u32 page_size); 108 109int hinic_io_create_qps(struct hinic_func_to_io *func_to_io, 110 u16 base_qpn, int num_qps, 111 struct msix_entry *sq_msix_entries, 112 struct msix_entry *rq_msix_entries); 113 114void hinic_io_destroy_qps(struct hinic_func_to_io *func_to_io, 115 int num_qps); 116 117int hinic_io_init(struct hinic_func_to_io *func_to_io, 118 struct hinic_hwif *hwif, u16 max_qps, int num_ceqs, 119 struct msix_entry *ceq_msix_entries); 120 121void hinic_io_free(struct hinic_func_to_io *func_to_io); 122 123#endif