Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef _EFA_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define _EFA_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <rdma/efa-abi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <rdma/ib_verbs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "efa_com_cmd.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define DRV_MODULE_NAME         "efa"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define DEVICE_NAME             "Elastic Fabric Adapter (EFA)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define EFA_IRQNAME_SIZE        40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /* 1 for AENQ + ADMIN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define EFA_NUM_MSIX_VEC                  1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define EFA_MGMNT_MSIX_VEC_IDX            0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) struct efa_irq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	irq_handler_t handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	u32 vector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	cpumask_t affinity_hint_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	char name[EFA_IRQNAME_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) /* Don't use anything other than atomic64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) struct efa_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	atomic64_t alloc_pd_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	atomic64_t create_qp_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	atomic64_t create_cq_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	atomic64_t reg_mr_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	atomic64_t alloc_ucontext_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	atomic64_t create_ah_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	atomic64_t mmap_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	atomic64_t keep_alive_rcvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) struct efa_dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	struct ib_device ibdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct efa_com_dev edev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct pci_dev *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct efa_com_get_device_attr_result dev_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	u64 reg_bar_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	u64 reg_bar_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	u64 mem_bar_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	u64 mem_bar_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	u64 db_bar_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	u64 db_bar_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	int admin_msix_vector_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct efa_irq admin_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct efa_stats stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct efa_ucontext {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct ib_ucontext ibucontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	u16 uarn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) struct efa_pd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct ib_pd ibpd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	u16 pdn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) struct efa_mr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	struct ib_mr ibmr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct ib_umem *umem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) struct efa_cq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct ib_cq ibcq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct efa_ucontext *ucontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	dma_addr_t dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	void *cpu_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct rdma_user_mmap_entry *mmap_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	size_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	u16 cq_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) struct efa_qp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	struct ib_qp ibqp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	dma_addr_t rq_dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	void *rq_cpu_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	size_t rq_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	enum ib_qp_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	/* Used for saving mmap_xa entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct rdma_user_mmap_entry *sq_db_mmap_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct rdma_user_mmap_entry *llq_desc_mmap_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct rdma_user_mmap_entry *rq_db_mmap_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	struct rdma_user_mmap_entry *rq_mmap_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	u32 qp_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	u32 max_send_wr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	u32 max_recv_wr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	u32 max_send_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	u32 max_recv_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	u32 max_inline_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct efa_ah {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct ib_ah ibah;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	u16 ah;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	/* dest_addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	u8 id[EFA_GID_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int efa_query_device(struct ib_device *ibdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		     struct ib_device_attr *props,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		     struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int efa_query_port(struct ib_device *ibdev, u8 port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		   struct ib_port_attr *props);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int efa_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		 int qp_attr_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		 struct ib_qp_init_attr *qp_init_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int efa_query_gid(struct ib_device *ibdev, u8 port, int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		  union ib_gid *gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int efa_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		   u16 *pkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int efa_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int efa_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			    struct ib_qp_init_attr *init_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			    struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		  struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			 u64 virt_addr, int access_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			 struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int efa_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int efa_get_port_immutable(struct ib_device *ibdev, u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			   struct ib_port_immutable *immutable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) void efa_dealloc_ucontext(struct ib_ucontext *ibucontext);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) int efa_mmap(struct ib_ucontext *ibucontext,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	     struct vm_area_struct *vma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void efa_mmap_free(struct rdma_user_mmap_entry *rdma_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) int efa_create_ah(struct ib_ah *ibah,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		  struct rdma_ah_init_attr *init_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		  struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) int efa_destroy_ah(struct ib_ah *ibah, u32 flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) int efa_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		  int qp_attr_mask, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) enum rdma_link_layer efa_port_link_layer(struct ib_device *ibdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 					 u8 port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct rdma_hw_stats *efa_alloc_hw_stats(struct ib_device *ibdev, u8 port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) int efa_get_hw_stats(struct ib_device *ibdev, struct rdma_hw_stats *stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		     u8 port_num, int index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #endif /* _EFA_H_ */