#include <linux/interrupt.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/ntb.h>
#include <linux/pci.h>
#include <linux/switchtec.h>
MODULE_DESCRIPTION(…) …;
MODULE_VERSION(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
static ulong max_mw_size = …;
module_param(max_mw_size, ulong, 0644);
MODULE_PARM_DESC(…) …;
static bool use_lut_mws;
module_param(use_lut_mws, bool, 0644);
MODULE_PARM_DESC(…) …;
#define SWITCHTEC_NTB_MAGIC …
#define MAX_MWS …
struct shared_mw { … };
#define MAX_DIRECT_MW …
#define LUT_SIZE …
struct switchtec_ntb { … };
static struct switchtec_ntb *ntb_sndev(struct ntb_dev *ntb)
{ … }
static int switchtec_ntb_part_op(struct switchtec_ntb *sndev,
struct ntb_ctrl_regs __iomem *ctl,
u32 op, int wait_status)
{ … }
static int switchtec_ntb_send_msg(struct switchtec_ntb *sndev, int idx,
u32 val)
{ … }
static int switchtec_ntb_mw_count(struct ntb_dev *ntb, int pidx)
{ … }
static int lut_index(struct switchtec_ntb *sndev, int mw_idx)
{ … }
static int peer_lut_index(struct switchtec_ntb *sndev, int mw_idx)
{ … }
static int switchtec_ntb_mw_get_align(struct ntb_dev *ntb, int pidx,
int widx, resource_size_t *addr_align,
resource_size_t *size_align,
resource_size_t *size_max)
{ … }
static void switchtec_ntb_mw_clr_direct(struct switchtec_ntb *sndev, int idx)
{ … }
static void switchtec_ntb_mw_clr_lut(struct switchtec_ntb *sndev, int idx)
{ … }
static void switchtec_ntb_mw_set_direct(struct switchtec_ntb *sndev, int idx,
dma_addr_t addr, resource_size_t size)
{ … }
static void switchtec_ntb_mw_set_lut(struct switchtec_ntb *sndev, int idx,
dma_addr_t addr, resource_size_t size)
{ … }
static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
dma_addr_t addr, resource_size_t size)
{ … }
static int switchtec_ntb_peer_mw_count(struct ntb_dev *ntb)
{ … }
static int switchtec_ntb_direct_get_addr(struct switchtec_ntb *sndev,
int idx, phys_addr_t *base,
resource_size_t *size)
{ … }
static int switchtec_ntb_lut_get_addr(struct switchtec_ntb *sndev,
int idx, phys_addr_t *base,
resource_size_t *size)
{ … }
static int switchtec_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx,
phys_addr_t *base,
resource_size_t *size)
{ … }
static void switchtec_ntb_part_link_speed(struct switchtec_ntb *sndev,
int partition,
enum ntb_speed *speed,
enum ntb_width *width)
{ … }
static void switchtec_ntb_set_link_speed(struct switchtec_ntb *sndev)
{ … }
static int crosslink_is_enabled(struct switchtec_ntb *sndev)
{ … }
static void crosslink_init_dbmsgs(struct switchtec_ntb *sndev)
{ … }
enum switchtec_msg { … };
static int switchtec_ntb_reinit_peer(struct switchtec_ntb *sndev);
static void switchtec_ntb_link_status_update(struct switchtec_ntb *sndev)
{ … }
static void check_link_status_work(struct work_struct *work)
{ … }
static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
enum switchtec_msg msg)
{ … }
static void switchtec_ntb_link_notification(struct switchtec_dev *stdev)
{ … }
static u64 switchtec_ntb_link_is_up(struct ntb_dev *ntb,
enum ntb_speed *speed,
enum ntb_width *width)
{ … }
static int switchtec_ntb_link_enable(struct ntb_dev *ntb,
enum ntb_speed max_speed,
enum ntb_width max_width)
{ … }
static int switchtec_ntb_link_disable(struct ntb_dev *ntb)
{ … }
static u64 switchtec_ntb_db_valid_mask(struct ntb_dev *ntb)
{ … }
static int switchtec_ntb_db_vector_count(struct ntb_dev *ntb)
{ … }
static u64 switchtec_ntb_db_vector_mask(struct ntb_dev *ntb, int db_vector)
{ … }
static u64 switchtec_ntb_db_read(struct ntb_dev *ntb)
{ … }
static int switchtec_ntb_db_clear(struct ntb_dev *ntb, u64 db_bits)
{ … }
static int switchtec_ntb_db_set_mask(struct ntb_dev *ntb, u64 db_bits)
{ … }
static int switchtec_ntb_db_clear_mask(struct ntb_dev *ntb, u64 db_bits)
{ … }
static u64 switchtec_ntb_db_read_mask(struct ntb_dev *ntb)
{ … }
static int switchtec_ntb_peer_db_addr(struct ntb_dev *ntb,
phys_addr_t *db_addr,
resource_size_t *db_size,
u64 *db_data,
int db_bit)
{ … }
static int switchtec_ntb_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
{ … }
static int switchtec_ntb_spad_count(struct ntb_dev *ntb)
{ … }
static u32 switchtec_ntb_spad_read(struct ntb_dev *ntb, int idx)
{ … }
static int switchtec_ntb_spad_write(struct ntb_dev *ntb, int idx, u32 val)
{ … }
static u32 switchtec_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx,
int sidx)
{ … }
static int switchtec_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx,
int sidx, u32 val)
{ … }
static int switchtec_ntb_peer_spad_addr(struct ntb_dev *ntb, int pidx,
int sidx, phys_addr_t *spad_addr)
{ … }
static const struct ntb_dev_ops switchtec_ntb_ops = …;
static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
{ … }
static int config_rsvd_lut_win(struct switchtec_ntb *sndev,
struct ntb_ctrl_regs __iomem *ctl,
int lut_idx, int partition, u64 addr)
{ … }
static int config_req_id_table(struct switchtec_ntb *sndev,
struct ntb_ctrl_regs __iomem *mmio_ctrl,
int *req_ids, int count)
{ … }
static int crosslink_setup_mws(struct switchtec_ntb *sndev, int ntb_lut_idx,
u64 *mw_addrs, int mw_count)
{ … }
static int crosslink_setup_req_ids(struct switchtec_ntb *sndev,
struct ntb_ctrl_regs __iomem *mmio_ctrl)
{ … }
static int crosslink_enum_partition(struct switchtec_ntb *sndev,
u64 *bar_addrs)
{ … }
static int switchtec_ntb_init_crosslink(struct switchtec_ntb *sndev)
{ … }
static void switchtec_ntb_deinit_crosslink(struct switchtec_ntb *sndev)
{ … }
static int map_bars(int *map, struct ntb_ctrl_regs __iomem *ctrl)
{ … }
static void switchtec_ntb_init_mw(struct switchtec_ntb *sndev)
{ … }
static void switchtec_ntb_init_db(struct switchtec_ntb *sndev)
{ … }
static void switchtec_ntb_init_msgs(struct switchtec_ntb *sndev)
{ … }
static int
switchtec_ntb_init_req_id_table(struct switchtec_ntb *sndev)
{ … }
static void switchtec_ntb_init_shared(struct switchtec_ntb *sndev)
{ … }
static int switchtec_ntb_init_shared_mw(struct switchtec_ntb *sndev)
{ … }
static void switchtec_ntb_deinit_shared_mw(struct switchtec_ntb *sndev)
{ … }
static irqreturn_t switchtec_ntb_doorbell_isr(int irq, void *dev)
{ … }
static irqreturn_t switchtec_ntb_message_isr(int irq, void *dev)
{ … }
static int switchtec_ntb_init_db_msg_irq(struct switchtec_ntb *sndev)
{ … }
static void switchtec_ntb_deinit_db_msg_irq(struct switchtec_ntb *sndev)
{ … }
static int switchtec_ntb_reinit_peer(struct switchtec_ntb *sndev)
{ … }
static int switchtec_ntb_add(struct device *dev)
{ … }
static void switchtec_ntb_remove(struct device *dev)
{ … }
static struct class_interface switchtec_interface = …;
static int __init switchtec_ntb_init(void)
{ … }
module_init(…) …;
static void __exit switchtec_ntb_exit(void)
{ … }
module_exit(switchtec_ntb_exit);