]> Git Repo - linux.git/blame - net/smc/smc_ib.h
net/smc: fix kernel panic caused by race of smc_sock
[linux.git] / net / smc / smc_ib.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
a4cf0443
UB
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 [email protected]>
10 */
11
12#ifndef _SMC_IB_H
13#define _SMC_IB_H
14
282ccf6e 15#include <linux/interrupt.h>
143c0171 16#include <linux/if_ether.h>
92f3cb0e 17#include <linux/mutex.h>
6dabd405 18#include <linux/wait.h>
a4cf0443 19#include <rdma/ib_verbs.h>
0afff91c 20#include <net/smc.h>
a4cf0443
UB
21
22#define SMC_MAX_PORTS 2 /* Max # of ports */
23#define SMC_GID_SIZE sizeof(union ib_gid)
24
f38ba179
UB
25#define SMC_IB_MAX_SEND_SGE 2
26
a4cf0443
UB
27struct smc_ib_devices { /* list of smc ib devices definition */
28 struct list_head list;
92f3cb0e 29 struct mutex mutex; /* protects list of smc ib devices */
a4cf0443
UB
30};
31
32extern struct smc_ib_devices smc_ib_devices; /* list of smc ib devices */
a3db10ef 33extern struct smc_lgr_list smc_lgr_list; /* list of linkgroups */
a4cf0443
UB
34
35struct smc_ib_device { /* ib-device infos for smc */
36 struct list_head list;
37 struct ib_device *ibdev;
38 struct ib_port_attr pattr[SMC_MAX_PORTS]; /* ib dev. port attrs */
bd4ad577 39 struct ib_event_handler event_handler; /* global ib_event handler */
f38ba179
UB
40 struct ib_cq *roce_cq_send; /* send completion queue */
41 struct ib_cq *roce_cq_recv; /* recv completion queue */
42 struct tasklet_struct send_tasklet; /* called by send cq handler */
43 struct tasklet_struct recv_tasklet; /* called by recv cq handler */
143c0171
UB
44 char mac[SMC_MAX_PORTS][ETH_ALEN];
45 /* mac address per port*/
0afff91c
UB
46 u8 pnetid[SMC_MAX_PORTS][SMC_MAX_PNETID_LEN];
47 /* pnetid per port */
890a2cb4
HW
48 bool pnetid_by_user[SMC_MAX_PORTS];
49 /* pnetid defined by user? */
a4cf0443 50 u8 initialized : 1; /* ib dev CQ, evthdl done */
bd4ad577
UB
51 struct work_struct port_event_work;
52 unsigned long port_event_mask;
c3d9494e 53 DECLARE_BITMAP(ports_going_away, SMC_MAX_PORTS);
6dabd405
UB
54 atomic_t lnk_cnt; /* number of links on ibdev */
55 wait_queue_head_t lnks_deleted; /* wait 4 removal of all links*/
63673597 56 struct mutex mutex; /* protect dev setup+cleanup */
ddc99286
GG
57 atomic_t lnk_cnt_by_port[SMC_MAX_PORTS];
58 /* number of links per port */
3d453f53 59 int ndev_ifidx[SMC_MAX_PORTS]; /* ndev if indexes */
a4cf0443
UB
60};
61
e5c4744c
KG
62static inline __be32 smc_ib_gid_to_ipv4(u8 gid[SMC_GID_SIZE])
63{
64 struct in6_addr *addr6 = (struct in6_addr *)gid;
65
66 if (ipv6_addr_v4mapped(addr6) ||
67 !(addr6->s6_addr32[0] | addr6->s6_addr32[1] | addr6->s6_addr32[2]))
68 return addr6->s6_addr32[3];
69 return cpu_to_be32(INADDR_NONE);
70}
71
72struct smc_init_info_smcrv2;
cd6851f3 73struct smc_buf_desc;
f38ba179 74struct smc_link;
cd6851f3 75
3d453f53 76void smc_ib_ndev_change(struct net_device *ndev, unsigned long event);
a4cf0443
UB
77int smc_ib_register_client(void) __init;
78void smc_ib_unregister_client(void);
79bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport);
387707fd 80int smc_ib_buf_map_sg(struct smc_link *lnk,
a3fe3d01
UB
81 struct smc_buf_desc *buf_slot,
82 enum dma_data_direction data_direction);
387707fd 83void smc_ib_buf_unmap_sg(struct smc_link *lnk,
a3fe3d01
UB
84 struct smc_buf_desc *buf_slot,
85 enum dma_data_direction data_direction);
f38ba179
UB
86void smc_ib_dealloc_protection_domain(struct smc_link *lnk);
87int smc_ib_create_protection_domain(struct smc_link *lnk);
88void smc_ib_destroy_queue_pair(struct smc_link *lnk);
89int smc_ib_create_queue_pair(struct smc_link *lnk);
bd4ad577
UB
90int smc_ib_ready_link(struct smc_link *lnk);
91int smc_ib_modify_qp_rts(struct smc_link *lnk);
92int smc_ib_modify_qp_reset(struct smc_link *lnk);
349d4312 93int smc_ib_modify_qp_error(struct smc_link *lnk);
bd4ad577 94long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev);
897e1c24 95int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
387707fd 96 struct smc_buf_desc *buf_slot, u8 link_idx);
897e1c24 97void smc_ib_put_memory_region(struct ib_mr *mr);
387707fd 98void smc_ib_sync_sg_for_cpu(struct smc_link *lnk,
10428dd8
UB
99 struct smc_buf_desc *buf_slot,
100 enum dma_data_direction data_direction);
387707fd 101void smc_ib_sync_sg_for_device(struct smc_link *lnk,
10428dd8
UB
102 struct smc_buf_desc *buf_slot,
103 enum dma_data_direction data_direction);
7005ada6 104int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport,
24fb6811
KG
105 unsigned short vlan_id, u8 gid[], u8 *sgid_index,
106 struct smc_init_info_smcrv2 *smcrv2);
e5c4744c
KG
107int smc_ib_find_route(__be32 saddr, __be32 daddr,
108 u8 nexthop_mac[], u8 *uses_gateway);
a082ec89 109bool smc_ib_is_valid_local_systemid(void);
a3db10ef 110int smcr_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb);
a4cf0443 111#endif
This page took 0.338004 seconds and 4 git commands to generate.