Skip to content

Commit 1619f77

Browse files
Hans Wippeldavem330
authored andcommitted
net/smc: add pnetid support for SMC-D and ISM
SMC-D relies on PNETIDs to find usable SMC-D/ISM devices for a SMC connection. This patch adds SMC-D/ISM support to the current PNETID implementation. Signed-off-by: Hans Wippel <[email protected]> Signed-off-by: Ursula Braun <[email protected]> Suggested-by: Thomas Richter <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c6ba7c9 commit 1619f77

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

include/net/smc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct smcd_dev {
7373
struct smc_connection **conn;
7474
struct list_head vlan;
7575
struct workqueue_struct *event_wq;
76+
u8 pnetid[SMC_MAX_PNETID_LEN];
7677
};
7778

7879
struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,

net/smc/smc_ism.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "smc.h"
1414
#include "smc_core.h"
1515
#include "smc_ism.h"
16+
#include "smc_pnet.h"
1617

1718
struct smcd_dev_list smcd_dev_list = {
1819
.list = LIST_HEAD_INIT(smcd_dev_list.list),
@@ -227,6 +228,7 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
227228
device_initialize(&smcd->dev);
228229
dev_set_name(&smcd->dev, name);
229230
smcd->ops = ops;
231+
smc_pnetid_by_dev_port(parent, 0, smcd->pnetid);
230232

231233
spin_lock_init(&smcd->lock);
232234
INIT_LIST_HEAD(&smcd->vlan);

net/smc/smc_pnet.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "smc_pnet.h"
2424
#include "smc_ib.h"
25+
#include "smc_ism.h"
2526

2627
static struct nla_policy smc_pnet_policy[SMC_PNETID_MAX + 1] = {
2728
[SMC_PNETID_NAME] = {
@@ -564,6 +565,27 @@ static void smc_pnet_find_roce_by_pnetid(struct net_device *ndev,
564565
spin_unlock(&smc_ib_devices.lock);
565566
}
566567

568+
static void smc_pnet_find_ism_by_pnetid(struct net_device *ndev,
569+
struct smcd_dev **smcismdev)
570+
{
571+
u8 ndev_pnetid[SMC_MAX_PNETID_LEN];
572+
struct smcd_dev *ismdev;
573+
574+
ndev = pnet_find_base_ndev(ndev);
575+
if (smc_pnetid_by_dev_port(ndev->dev.parent, ndev->dev_port,
576+
ndev_pnetid))
577+
return; /* pnetid could not be determined */
578+
579+
spin_lock(&smcd_dev_list.lock);
580+
list_for_each_entry(ismdev, &smcd_dev_list.list, list) {
581+
if (!memcmp(ismdev->pnetid, ndev_pnetid, SMC_MAX_PNETID_LEN)) {
582+
*smcismdev = ismdev;
583+
break;
584+
}
585+
}
586+
spin_unlock(&smcd_dev_list.lock);
587+
}
588+
567589
/* Lookup of coupled ib_device via SMC pnet table */
568590
static void smc_pnet_find_roce_by_table(struct net_device *netdev,
569591
struct smc_ib_device **smcibdev,
@@ -615,3 +637,22 @@ void smc_pnet_find_roce_resource(struct sock *sk,
615637
out:
616638
return;
617639
}
640+
641+
void smc_pnet_find_ism_resource(struct sock *sk, struct smcd_dev **smcismdev)
642+
{
643+
struct dst_entry *dst = sk_dst_get(sk);
644+
645+
*smcismdev = NULL;
646+
if (!dst)
647+
goto out;
648+
if (!dst->dev)
649+
goto out_rel;
650+
651+
/* if possible, lookup via hardware-defined pnetid */
652+
smc_pnet_find_ism_by_pnetid(dst->dev, smcismdev);
653+
654+
out_rel:
655+
dst_release(dst);
656+
out:
657+
return;
658+
}

net/smc/smc_pnet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#endif
1818

1919
struct smc_ib_device;
20+
struct smcd_dev;
2021

2122
static inline int smc_pnetid_by_dev_port(struct device *dev,
2223
unsigned short port, u8 *pnetid)
@@ -33,5 +34,6 @@ void smc_pnet_exit(void);
3334
int smc_pnet_remove_by_ibdev(struct smc_ib_device *ibdev);
3435
void smc_pnet_find_roce_resource(struct sock *sk,
3536
struct smc_ib_device **smcibdev, u8 *ibport);
37+
void smc_pnet_find_ism_resource(struct sock *sk, struct smcd_dev **smcismdev);
3638

3739
#endif

0 commit comments

Comments
 (0)