blob: 5c2b115d36daa26bfc3c6ceceea395c52289b2f7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Ursula Brauna4cf0442017-01-09 16:55:14 +01002/*
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
4 *
5 * Definitions for IB environment
6 *
7 * Copyright IBM Corp. 2016
8 *
9 * Author(s): Ursula Braun <Ursula Braun@linux.vnet.ibm.com>
10 */
11
12#ifndef _SMC_IB_H
13#define _SMC_IB_H
14
Florian Westphal282ccf62017-03-29 17:17:31 +020015#include <linux/interrupt.h>
Ursula Braun143c0172017-01-12 14:57:15 +010016#include <linux/if_ether.h>
Ursula Braun6dabd402019-11-16 17:47:29 +010017#include <linux/wait.h>
Ursula Brauna4cf0442017-01-09 16:55:14 +010018#include <rdma/ib_verbs.h>
Ursula Braun0afff912018-06-28 19:05:05 +020019#include <net/smc.h>
Ursula Brauna4cf0442017-01-09 16:55:14 +010020
21#define SMC_MAX_PORTS 2 /* Max # of ports */
22#define SMC_GID_SIZE sizeof(union ib_gid)
23
Ursula Braunf38ba1792017-01-09 16:55:19 +010024#define SMC_IB_MAX_SEND_SGE 2
25
Ursula Brauna4cf0442017-01-09 16:55:14 +010026struct smc_ib_devices { /* list of smc ib devices definition */
27 struct list_head list;
28 spinlock_t lock; /* protects list of smc ib devices */
29};
30
31extern struct smc_ib_devices smc_ib_devices; /* list of smc ib devices */
32
33struct smc_ib_device { /* ib-device infos for smc */
34 struct list_head list;
35 struct ib_device *ibdev;
36 struct ib_port_attr pattr[SMC_MAX_PORTS]; /* ib dev. port attrs */
Ursula Braunbd4ad572017-01-09 16:55:20 +010037 struct ib_event_handler event_handler; /* global ib_event handler */
Ursula Braunf38ba1792017-01-09 16:55:19 +010038 struct ib_cq *roce_cq_send; /* send completion queue */
39 struct ib_cq *roce_cq_recv; /* recv completion queue */
40 struct tasklet_struct send_tasklet; /* called by send cq handler */
41 struct tasklet_struct recv_tasklet; /* called by recv cq handler */
Ursula Braun143c0172017-01-12 14:57:15 +010042 char mac[SMC_MAX_PORTS][ETH_ALEN];
43 /* mac address per port*/
Ursula Braun0afff912018-06-28 19:05:05 +020044 u8 pnetid[SMC_MAX_PORTS][SMC_MAX_PNETID_LEN];
45 /* pnetid per port */
Hans Wippel890a2cb2019-02-21 13:01:00 +010046 bool pnetid_by_user[SMC_MAX_PORTS];
47 /* pnetid defined by user? */
Ursula Brauna4cf0442017-01-09 16:55:14 +010048 u8 initialized : 1; /* ib dev CQ, evthdl done */
Ursula Braunbd4ad572017-01-09 16:55:20 +010049 struct work_struct port_event_work;
50 unsigned long port_event_mask;
Ursula Braunc3d94942019-10-09 10:07:46 +020051 DECLARE_BITMAP(ports_going_away, SMC_MAX_PORTS);
Ursula Braun6dabd402019-11-16 17:47:29 +010052 atomic_t lnk_cnt; /* number of links on ibdev */
53 wait_queue_head_t lnks_deleted; /* wait 4 removal of all links*/
Ursula Brauna4cf0442017-01-09 16:55:14 +010054};
55
Ursula Brauncd6851f2017-01-09 16:55:18 +010056struct smc_buf_desc;
Ursula Braunf38ba1792017-01-09 16:55:19 +010057struct smc_link;
Ursula Brauncd6851f2017-01-09 16:55:18 +010058
Ursula Brauna4cf0442017-01-09 16:55:14 +010059int smc_ib_register_client(void) __init;
60void smc_ib_unregister_client(void);
61bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport);
Ursula Brauna3fe3d02017-07-28 13:56:15 +020062int 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);
Ursula Braunf38ba1792017-01-09 16:55:19 +010068void 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);
Ursula Braunbd4ad572017-01-09 16:55:20 +010072int 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);
Ursula Braun897e1c22017-07-28 13:56:16 +020076int 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);
Ursula Braun10428dd2017-07-28 13:56:22 +020079void 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);
Ursula Braun7005ada2018-07-25 16:35:31 +020085int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport,
86 unsigned short vlan_id, u8 gid[], u8 *sgid_index);
Hans Wippela082ec82020-02-25 22:41:22 +010087bool smc_ib_is_valid_local_systemid(void);
Ursula Brauna4cf0442017-01-09 16:55:14 +010088#endif