cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

hinic_hw_wq.h (2973B)


      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_WQ_H
      8#define HINIC_HW_WQ_H
      9
     10#include <linux/types.h>
     11#include <linux/semaphore.h>
     12#include <linux/atomic.h>
     13
     14#include "hinic_hw_if.h"
     15#include "hinic_hw_wqe.h"
     16
     17struct hinic_free_block {
     18	int     page_idx;
     19	int     block_idx;
     20};
     21
     22struct hinic_wq {
     23	struct hinic_hwif       *hwif;
     24
     25	int             page_idx;
     26	int             block_idx;
     27
     28	u16             wqebb_size;
     29	u32             wq_page_size;
     30	u16             q_depth;
     31	u16             max_wqe_size;
     32	u16             num_wqebbs_per_page;
     33	u16		wqebbs_per_page_shift;
     34	u16		wqebb_size_shift;
     35	/* The addresses are 64 bit in the HW */
     36	u64             block_paddr;
     37	void            **shadow_block_vaddr;
     38	u64             *block_vaddr;
     39
     40	int             num_q_pages;
     41	u8              *shadow_wqe;
     42	u16             *shadow_idx;
     43
     44	atomic_t        cons_idx;
     45	atomic_t        prod_idx;
     46	atomic_t        delta;
     47	u16             mask;
     48};
     49
     50struct hinic_wqs {
     51	struct hinic_hwif       *hwif;
     52	int                     num_pages;
     53
     54	/* The addresses are 64 bit in the HW */
     55	u64                     *page_paddr;
     56	u64                     **page_vaddr;
     57	void                    ***shadow_page_vaddr;
     58
     59	struct hinic_free_block *free_blocks;
     60	int                     alloc_blk_pos;
     61	int                     return_blk_pos;
     62	int                     num_free_blks;
     63
     64	/* Lock for getting a free block from the WQ set */
     65	struct semaphore        alloc_blocks_lock;
     66};
     67
     68struct hinic_cmdq_pages {
     69	/* The addresses are 64 bit in the HW */
     70	u64                     page_paddr;
     71	u64                     *page_vaddr;
     72	void                    **shadow_page_vaddr;
     73
     74	struct hinic_hwif       *hwif;
     75};
     76
     77int hinic_wqs_cmdq_alloc(struct hinic_cmdq_pages *cmdq_pages,
     78			 struct hinic_wq *wq, struct hinic_hwif *hwif,
     79			 int cmdq_blocks, u16 wqebb_size, u32 wq_page_size,
     80			 u16 q_depth, u16 max_wqe_size);
     81
     82void hinic_wqs_cmdq_free(struct hinic_cmdq_pages *cmdq_pages,
     83			 struct hinic_wq *wq, int cmdq_blocks);
     84
     85int hinic_wqs_alloc(struct hinic_wqs *wqs, int num_wqs,
     86		    struct hinic_hwif *hwif);
     87
     88void hinic_wqs_free(struct hinic_wqs *wqs);
     89
     90int hinic_wq_allocate(struct hinic_wqs *wqs, struct hinic_wq *wq,
     91		      u16 wqebb_size, u32 wq_page_size, u16 q_depth,
     92		      u16 max_wqe_size);
     93
     94void hinic_wq_free(struct hinic_wqs *wqs, struct hinic_wq *wq);
     95
     96struct hinic_hw_wqe *hinic_get_wqe(struct hinic_wq *wq, unsigned int wqe_size,
     97				   u16 *prod_idx);
     98
     99void hinic_return_wqe(struct hinic_wq *wq, unsigned int wqe_size);
    100
    101void hinic_put_wqe(struct hinic_wq *wq, unsigned int wqe_size);
    102
    103struct hinic_hw_wqe *hinic_read_wqe(struct hinic_wq *wq, unsigned int wqe_size,
    104				    u16 *cons_idx);
    105
    106struct hinic_hw_wqe *hinic_read_wqe_direct(struct hinic_wq *wq, u16 cons_idx);
    107
    108void hinic_write_wqe(struct hinic_wq *wq, struct hinic_hw_wqe *wqe,
    109		     unsigned int wqe_size);
    110
    111#endif