1
2
3
4
5
6
7
8
9
10
11
12#ifndef _SMC_IB_H
13#define _SMC_IB_H
14
15#include <linux/interrupt.h>
16#include <linux/if_ether.h>
17#include <linux/wait.h>
18#include <rdma/ib_verbs.h>
19#include <net/smc.h>
20
21#define SMC_MAX_PORTS 2
22#define SMC_GID_SIZE sizeof(union ib_gid)
23
24#define SMC_IB_MAX_SEND_SGE 2
25
26struct smc_ib_devices {
27 struct list_head list;
28 spinlock_t lock;
29};
30
31extern struct smc_ib_devices smc_ib_devices;
32
33struct smc_ib_device {
34 struct list_head list;
35 struct ib_device *ibdev;
36 struct ib_port_attr pattr[SMC_MAX_PORTS];
37 struct ib_event_handler event_handler;
38 struct ib_cq *roce_cq_send;
39 struct ib_cq *roce_cq_recv;
40 struct tasklet_struct send_tasklet;
41 struct tasklet_struct recv_tasklet;
42 char mac[SMC_MAX_PORTS][ETH_ALEN];
43
44 u8 pnetid[SMC_MAX_PORTS][SMC_MAX_PNETID_LEN];
45
46 bool pnetid_by_user[SMC_MAX_PORTS];
47
48 u8 initialized : 1;
49 struct work_struct port_event_work;
50 unsigned long port_event_mask;
51 DECLARE_BITMAP(ports_going_away, SMC_MAX_PORTS);
52 atomic_t lnk_cnt;
53 wait_queue_head_t lnks_deleted;
54};
55
56struct smc_buf_desc;
57struct smc_link;
58
59int smc_ib_register_client(void) __init;
60void smc_ib_unregister_client(void);
61bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport);
62int smc_ib_buf_map_sg(struct smc_ib_device *smcibdev,
63 struct smc_buf_desc *buf_slot,
64 enum dma_data_direction data_direction);
65void smc_ib_buf_unmap_sg(struct smc_ib_device *smcibdev,
66 struct smc_buf_desc *buf_slot,
67 enum dma_data_direction data_direction);
68void smc_ib_dealloc_protection_domain(struct smc_link *lnk);
69int smc_ib_create_protection_domain(struct smc_link *lnk);
70void smc_ib_destroy_queue_pair(struct smc_link *lnk);
71int smc_ib_create_queue_pair(struct smc_link *lnk);
72int smc_ib_ready_link(struct smc_link *lnk);
73int smc_ib_modify_qp_rts(struct smc_link *lnk);
74int smc_ib_modify_qp_reset(struct smc_link *lnk);
75long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev);
76int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
77 struct smc_buf_desc *buf_slot);
78void smc_ib_put_memory_region(struct ib_mr *mr);
79void smc_ib_sync_sg_for_cpu(struct smc_ib_device *smcibdev,
80 struct smc_buf_desc *buf_slot,
81 enum dma_data_direction data_direction);
82void smc_ib_sync_sg_for_device(struct smc_ib_device *smcibdev,
83 struct smc_buf_desc *buf_slot,
84 enum dma_data_direction data_direction);
85int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport,
86 unsigned short vlan_id, u8 gid[], u8 *sgid_index);
87#endif
88