blob: 14039272f7e4263a3d86f29d0c4f048731af387f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Thomas Richter6812baa2017-01-09 16:55:15 +01002/*
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
4 *
5 * PNET table queries
6 *
7 * Copyright IBM Corp. 2016
8 *
9 * Author(s): Thomas Richter <tmricht@linux.vnet.ibm.com>
10 */
11
12#ifndef _SMC_PNET_H
13#define _SMC_PNET_H
14
Ursula Braune888a2e2020-09-26 12:44:26 +020015#include <net/smc.h>
16
Ursula Braun0afff912018-06-28 19:05:05 +020017#if IS_ENABLED(CONFIG_HAVE_PNETID)
18#include <asm/pnet.h>
19#endif
20
Thomas Richter6812baa2017-01-09 16:55:15 +010021struct smc_ib_device;
Hans Wippel1619f772018-06-28 19:05:08 +020022struct smcd_dev;
Karsten Graulbc36d2f2019-04-12 12:57:26 +020023struct smc_init_info;
Karsten Graul6c868a32020-05-01 12:48:11 +020024struct smc_link_group;
Thomas Richter6812baa2017-01-09 16:55:15 +010025
Hans Wippel64e28b52019-02-21 13:01:02 +010026/**
27 * struct smc_pnettable - SMC PNET table anchor
28 * @lock: Lock for list action
29 * @pnetlist: List of PNETIDs
30 */
31struct smc_pnettable {
32 rwlock_t lock;
33 struct list_head pnetlist;
34};
35
Ursula Braune888a2e2020-09-26 12:44:26 +020036struct smc_pnetids_ndev { /* list of pnetids for net devices in UP state*/
37 struct list_head list;
38 rwlock_t lock;
39};
40
41struct smc_pnetids_ndev_entry {
42 struct list_head list;
43 u8 pnetid[SMC_MAX_PNETID_LEN];
44 refcount_t refcnt;
45};
46
Ursula Braun0afff912018-06-28 19:05:05 +020047static inline int smc_pnetid_by_dev_port(struct device *dev,
48 unsigned short port, u8 *pnetid)
49{
50#if IS_ENABLED(CONFIG_HAVE_PNETID)
51 return pnet_id_by_dev_port(dev, port, pnetid);
52#else
53 return -ENOENT;
54#endif
55}
56
Thomas Richter6812baa2017-01-09 16:55:15 +010057int smc_pnet_init(void) __init;
Hans Wippel64e28b52019-02-21 13:01:02 +010058int smc_pnet_net_init(struct net *net);
Thomas Richter6812baa2017-01-09 16:55:15 +010059void smc_pnet_exit(void);
Hans Wippel64e28b52019-02-21 13:01:02 +010060void smc_pnet_net_exit(struct net *net);
Karsten Graulbc36d2f2019-04-12 12:57:26 +020061void smc_pnet_find_roce_resource(struct sock *sk, struct smc_init_info *ini);
62void smc_pnet_find_ism_resource(struct sock *sk, struct smc_init_info *ini);
Karsten Graulfdff7042020-04-29 17:10:37 +020063int smc_pnetid_by_table_ib(struct smc_ib_device *smcibdev, u8 ib_port);
64int smc_pnetid_by_table_smcd(struct smcd_dev *smcd);
Karsten Graul6c868a32020-05-01 12:48:11 +020065void smc_pnet_find_alt_roce(struct smc_link_group *lgr,
66 struct smc_init_info *ini,
67 struct smc_ib_device *known_dev);
Ursula Braune888a2e2020-09-26 12:44:26 +020068bool smc_pnet_is_ndev_pnetid(struct net *net, u8 *pnetid);
Ursula Braund70bf4f2020-09-26 12:44:27 +020069bool smc_pnet_is_pnetid_set(u8 *pnetid);
Thomas Richter6812baa2017-01-09 16:55:15 +010070#endif