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/mutex.h>
18#include <linux/wait.h>
19#include <rdma/ib_verbs.h>
20#include <net/smc.h>
21
22#define SMC_MAX_PORTS 2
23#define SMC_GID_SIZE sizeof(union ib_gid)
24
25#define SMC_IB_MAX_SEND_SGE 2
26
27struct smc_ib_devices {
28 struct list_head list;
29 struct mutex mutex;
30};
31
32extern struct smc_ib_devices smc_ib_devices;
33extern struct smc_lgr_list smc_lgr_list;
34
35struct smc_ib_device {
36 struct list_head list;
37 struct ib_device *ibdev;
38 struct ib_port_attr pattr[SMC_MAX_PORTS];
39 struct ib_event_handler event_handler;
40 struct ib_cq *roce_cq_send;
41 struct ib_cq *roce_cq_recv;
42 struct tasklet_struct send_tasklet;
43 struct tasklet_struct recv_tasklet;
44 char mac[SMC_MAX_PORTS][ETH_ALEN];
45
46 u8 pnetid[SMC_MAX_PORTS][SMC_MAX_PNETID_LEN];
47
48 bool pnetid_by_user[SMC_MAX_PORTS];
49
50 u8 initialized : 1;
51 struct work_struct port_event_work;
52 unsigned long port_event_mask;
53 DECLARE_BITMAP(ports_going_away, SMC_MAX_PORTS);
54 atomic_t lnk_cnt;
55 wait_queue_head_t lnks_deleted;
56 struct mutex mutex;
57 atomic_t lnk_cnt_by_port[SMC_MAX_PORTS];
58
59 int ndev_ifidx[SMC_MAX_PORTS];
60};
61
62struct smc_buf_desc;
63struct smc_link;
64
65void smc_ib_ndev_change(struct net_device *ndev, unsigned long event);
66int smc_ib_register_client(void) __init;
67void smc_ib_unregister_client(void);
68bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport);
69int smc_ib_buf_map_sg(struct smc_link *lnk,
70 struct smc_buf_desc *buf_slot,
71 enum dma_data_direction data_direction);
72void smc_ib_buf_unmap_sg(struct smc_link *lnk,
73 struct smc_buf_desc *buf_slot,
74 enum dma_data_direction data_direction);
75void smc_ib_dealloc_protection_domain(struct smc_link *lnk);
76int smc_ib_create_protection_domain(struct smc_link *lnk);
77void smc_ib_destroy_queue_pair(struct smc_link *lnk);
78int smc_ib_create_queue_pair(struct smc_link *lnk);
79int smc_ib_ready_link(struct smc_link *lnk);
80int smc_ib_modify_qp_rts(struct smc_link *lnk);
81int smc_ib_modify_qp_reset(struct smc_link *lnk);
82long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev);
83int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
84 struct smc_buf_desc *buf_slot, u8 link_idx);
85void smc_ib_put_memory_region(struct ib_mr *mr);
86void smc_ib_sync_sg_for_cpu(struct smc_link *lnk,
87 struct smc_buf_desc *buf_slot,
88 enum dma_data_direction data_direction);
89void smc_ib_sync_sg_for_device(struct smc_link *lnk,
90 struct smc_buf_desc *buf_slot,
91 enum dma_data_direction data_direction);
92int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport,
93 unsigned short vlan_id, u8 gid[], u8 *sgid_index);
94bool smc_ib_is_valid_local_systemid(void);
95int smcr_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb);
96#endif
97