/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* * Copyright (c) 2023, Jaguarmicro Technologies, Inc. All rights reserved. */ #ifndef JM_RDMA_H #define JM_RDMA_H #include #ifndef USE_JM_AUX_BUS #include #else #include "linux/auxiliary_bus.h" #endif #include struct jm_rdma_core; struct jm_rdma_adev; /* * struct device *(*get_device)(struct jm_rdma_core *rdma); * Get struct device related with this auxiliary_device. * For example: * return &pci_dev.dev; * * void (*get_dev_info)(struct jm_rdma_core *rdma, u8 *feature, * u8 *rev_id, u16 *dev_id); * Get device's information. * For example: * *rev_id = pci_dev.revision; * *dev_id = pci_dev.device; * *vendor = pci_dev.vendor; * * void (*cmdq_notify)(struct jm_rdma_core *rdma, u32 event); * Notify new command to the related command queue. * For example: * iowrite32(event, cmd_db_reg); //cmd_db_reg = reg_addr + 0xEFC0 * * int (*get_irqn)(struct jm_rdma_core *rdma, int index); * Get the irq number with the index. * For example: * return pci_irq_vector(ae_dev->pdev, index); * * int (*store_bond_info)(struct jm_rdma_core *rdma, * struct net_device *master, bool flag); * Currently an empty function(return 0) is ok. * * void (*get_bar)(struct jm_rdma_core *rdma, void **base, void **eq_reg); * Get BAR mapping bar address and eq address. * For example: * *base = reg_addr; // reg_addr = ioremap(base_base, 64 * 1024) * *eq_reg = eq_db_reg; // eq_db_reg = reg_addr + 0xF000 * * void (*get_uar)(struct jm_rdma_core *rdma, phys_addr_t *base, u32 *len); * Get UAR base and length. * For example: * *base = uar_base; //bar_base + 64 * 1024 * *len = uar_size; // 64 * 1024 * * void (*get_vector)(struct jm_rdma_core *rdma, int num, int base); * Get the base and number of rdma's interrupt vector. * For example: * *base = vector_base; * *num = vector_num; * * void (*timer_db)(struct jm_rdma_core *rdma, u32 qpn, int flags); * Trigger a time DB. * Currently an empty function is ok. * * void (*reload)(struct jm_rdma_core *rdma); * Reload rdma core driver. * Currently an empty function is ok. * */ struct jm_rdma_ops { struct device *(*get_device)(struct jm_rdma_core *rdma); void (*get_dev_info)(struct jm_rdma_core *rdma, u8 *feature, u8 *rev_id, u16 *dev_id, u16 *vendor); void (*cmdq_notify)(struct jm_rdma_core *rdma, u32 event); int (*get_irqn)(struct jm_rdma_core *rdma, int index); int (*store_bond_info)(struct jm_rdma_core *rdma, struct net_device *master, bool flag); void (*get_bar)(struct jm_rdma_core *rdma, void **base, void **eq_reg); void (*get_uar)(struct jm_rdma_core *rdma, phys_addr_t *base, int *len); void (*get_vector)(struct jm_rdma_core *rdma, int *num, int *base); bool (*is_error)(struct jm_rdma_core *rdma); void (*timer_db)(struct jm_rdma_core *rdma, u32 qpn, int flags); void (*reload)(struct jm_rdma_core *rdma); }; struct jm_rdma_core { struct jm_rdma_ops *ops; struct jm_rdma_adev **adev; int adev_idx; }; struct jm_rdma_adev { struct auxiliary_device adev; struct jm_rdma_core *rdma_core; int idx; }; enum { JM_DEVICE_FEATURE_CMDQ_IS_PA = 1 << 0, JM_DEVICE_FEATURE_ATOMIC_HCA = 1 << 1, }; #endif