Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 2 | /* |
| 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 Westphal | 282ccf6 | 2017-03-29 17:17:31 +0200 | [diff] [blame] | 15 | #include <linux/interrupt.h> |
Ursula Braun | 143c017 | 2017-01-12 14:57:15 +0100 | [diff] [blame] | 16 | #include <linux/if_ether.h> |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 17 | #include <rdma/ib_verbs.h> |
| 18 | |
| 19 | #define SMC_MAX_PORTS 2 /* Max # of ports */ |
| 20 | #define SMC_GID_SIZE sizeof(union ib_gid) |
| 21 | |
Ursula Braun | f38ba179 | 2017-01-09 16:55:19 +0100 | [diff] [blame] | 22 | #define SMC_IB_MAX_SEND_SGE 2 |
| 23 | |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 24 | struct smc_ib_devices { /* list of smc ib devices definition */ |
| 25 | struct list_head list; |
| 26 | spinlock_t lock; /* protects list of smc ib devices */ |
| 27 | }; |
| 28 | |
| 29 | extern struct smc_ib_devices smc_ib_devices; /* list of smc ib devices */ |
| 30 | |
| 31 | struct smc_ib_device { /* ib-device infos for smc */ |
| 32 | struct list_head list; |
| 33 | struct ib_device *ibdev; |
| 34 | struct ib_port_attr pattr[SMC_MAX_PORTS]; /* ib dev. port attrs */ |
Ursula Braun | bd4ad57 | 2017-01-09 16:55:20 +0100 | [diff] [blame] | 35 | struct ib_event_handler event_handler; /* global ib_event handler */ |
Ursula Braun | f38ba179 | 2017-01-09 16:55:19 +0100 | [diff] [blame] | 36 | struct ib_cq *roce_cq_send; /* send completion queue */ |
| 37 | struct ib_cq *roce_cq_recv; /* recv completion queue */ |
| 38 | struct tasklet_struct send_tasklet; /* called by send cq handler */ |
| 39 | struct tasklet_struct recv_tasklet; /* called by recv cq handler */ |
Ursula Braun | 143c017 | 2017-01-12 14:57:15 +0100 | [diff] [blame] | 40 | char mac[SMC_MAX_PORTS][ETH_ALEN]; |
| 41 | /* mac address per port*/ |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 42 | union ib_gid gid[SMC_MAX_PORTS]; /* gid per port */ |
| 43 | u8 initialized : 1; /* ib dev CQ, evthdl done */ |
Ursula Braun | bd4ad57 | 2017-01-09 16:55:20 +0100 | [diff] [blame] | 44 | struct work_struct port_event_work; |
| 45 | unsigned long port_event_mask; |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 46 | }; |
| 47 | |
Ursula Braun | cd6851f | 2017-01-09 16:55:18 +0100 | [diff] [blame] | 48 | struct smc_buf_desc; |
Ursula Braun | f38ba179 | 2017-01-09 16:55:19 +0100 | [diff] [blame] | 49 | struct smc_link; |
Ursula Braun | cd6851f | 2017-01-09 16:55:18 +0100 | [diff] [blame] | 50 | |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 51 | int smc_ib_register_client(void) __init; |
| 52 | void smc_ib_unregister_client(void); |
| 53 | bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport); |
| 54 | int smc_ib_remember_port_attr(struct smc_ib_device *smcibdev, u8 ibport); |
Ursula Braun | a3fe3d0 | 2017-07-28 13:56:15 +0200 | [diff] [blame] | 55 | int smc_ib_buf_map_sg(struct smc_ib_device *smcibdev, |
| 56 | struct smc_buf_desc *buf_slot, |
| 57 | enum dma_data_direction data_direction); |
| 58 | void smc_ib_buf_unmap_sg(struct smc_ib_device *smcibdev, |
| 59 | struct smc_buf_desc *buf_slot, |
| 60 | enum dma_data_direction data_direction); |
Ursula Braun | f38ba179 | 2017-01-09 16:55:19 +0100 | [diff] [blame] | 61 | void smc_ib_dealloc_protection_domain(struct smc_link *lnk); |
| 62 | int smc_ib_create_protection_domain(struct smc_link *lnk); |
| 63 | void smc_ib_destroy_queue_pair(struct smc_link *lnk); |
| 64 | int smc_ib_create_queue_pair(struct smc_link *lnk); |
Ursula Braun | bd4ad57 | 2017-01-09 16:55:20 +0100 | [diff] [blame] | 65 | int smc_ib_ready_link(struct smc_link *lnk); |
| 66 | int smc_ib_modify_qp_rts(struct smc_link *lnk); |
| 67 | int smc_ib_modify_qp_reset(struct smc_link *lnk); |
| 68 | long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev); |
Ursula Braun | 897e1c2 | 2017-07-28 13:56:16 +0200 | [diff] [blame] | 69 | int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags, |
| 70 | struct smc_buf_desc *buf_slot); |
| 71 | void smc_ib_put_memory_region(struct ib_mr *mr); |
Ursula Braun | 10428dd | 2017-07-28 13:56:22 +0200 | [diff] [blame] | 72 | void smc_ib_sync_sg_for_cpu(struct smc_ib_device *smcibdev, |
| 73 | struct smc_buf_desc *buf_slot, |
| 74 | enum dma_data_direction data_direction); |
| 75 | void smc_ib_sync_sg_for_device(struct smc_ib_device *smcibdev, |
| 76 | struct smc_buf_desc *buf_slot, |
| 77 | enum dma_data_direction data_direction); |
Ursula Braun | a4cf044 | 2017-01-09 16:55:14 +0100 | [diff] [blame] | 78 | #endif |