diff options
author | Hans Wippel <hwippel@linux.ibm.com> | 2018-06-28 13:05:08 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-06-30 07:42:25 -0400 |
commit | 1619f770589a183af56f248de261534b255122de (patch) | |
tree | e26d650e439f5a73e08726c8cb978c15020152fc | |
parent | c6ba7c9ba43de1b57e9a53946e7ff988554c84ed (diff) |
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 <hwippel@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Suggested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/smc.h | 1 | ||||
-rw-r--r-- | net/smc/smc_ism.c | 2 | ||||
-rw-r--r-- | net/smc/smc_pnet.c | 41 | ||||
-rw-r--r-- | net/smc/smc_pnet.h | 2 |
4 files changed, 46 insertions, 0 deletions
diff --git a/include/net/smc.h b/include/net/smc.h index 824a7af8d654..9ef49f8b1002 100644 --- a/include/net/smc.h +++ b/include/net/smc.h | |||
@@ -73,6 +73,7 @@ struct smcd_dev { | |||
73 | struct smc_connection **conn; | 73 | struct smc_connection **conn; |
74 | struct list_head vlan; | 74 | struct list_head vlan; |
75 | struct workqueue_struct *event_wq; | 75 | struct workqueue_struct *event_wq; |
76 | u8 pnetid[SMC_MAX_PNETID_LEN]; | ||
76 | }; | 77 | }; |
77 | 78 | ||
78 | struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name, | 79 | struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name, |
diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index ca1ce42fd49f..f44e4dff244a 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "smc.h" | 13 | #include "smc.h" |
14 | #include "smc_core.h" | 14 | #include "smc_core.h" |
15 | #include "smc_ism.h" | 15 | #include "smc_ism.h" |
16 | #include "smc_pnet.h" | ||
16 | 17 | ||
17 | struct smcd_dev_list smcd_dev_list = { | 18 | struct smcd_dev_list smcd_dev_list = { |
18 | .list = LIST_HEAD_INIT(smcd_dev_list.list), | 19 | .list = LIST_HEAD_INIT(smcd_dev_list.list), |
@@ -227,6 +228,7 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name, | |||
227 | device_initialize(&smcd->dev); | 228 | device_initialize(&smcd->dev); |
228 | dev_set_name(&smcd->dev, name); | 229 | dev_set_name(&smcd->dev, name); |
229 | smcd->ops = ops; | 230 | smcd->ops = ops; |
231 | smc_pnetid_by_dev_port(parent, 0, smcd->pnetid); | ||
230 | 232 | ||
231 | spin_lock_init(&smcd->lock); | 233 | spin_lock_init(&smcd->lock); |
232 | INIT_LIST_HEAD(&smcd->vlan); | 234 | INIT_LIST_HEAD(&smcd->vlan); |
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c index cdc6e23b6ce1..1b6c066d3495 100644 --- a/net/smc/smc_pnet.c +++ b/net/smc/smc_pnet.c | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include "smc_pnet.h" | 23 | #include "smc_pnet.h" |
24 | #include "smc_ib.h" | 24 | #include "smc_ib.h" |
25 | #include "smc_ism.h" | ||
25 | 26 | ||
26 | static struct nla_policy smc_pnet_policy[SMC_PNETID_MAX + 1] = { | 27 | static struct nla_policy smc_pnet_policy[SMC_PNETID_MAX + 1] = { |
27 | [SMC_PNETID_NAME] = { | 28 | [SMC_PNETID_NAME] = { |
@@ -564,6 +565,27 @@ static void smc_pnet_find_roce_by_pnetid(struct net_device *ndev, | |||
564 | spin_unlock(&smc_ib_devices.lock); | 565 | spin_unlock(&smc_ib_devices.lock); |
565 | } | 566 | } |
566 | 567 | ||
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 | |||
567 | /* Lookup of coupled ib_device via SMC pnet table */ | 589 | /* Lookup of coupled ib_device via SMC pnet table */ |
568 | static void smc_pnet_find_roce_by_table(struct net_device *netdev, | 590 | static void smc_pnet_find_roce_by_table(struct net_device *netdev, |
569 | struct smc_ib_device **smcibdev, | 591 | struct smc_ib_device **smcibdev, |
@@ -615,3 +637,22 @@ out_rel: | |||
615 | out: | 637 | out: |
616 | return; | 638 | return; |
617 | } | 639 | } |
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 | } | ||
diff --git a/net/smc/smc_pnet.h b/net/smc/smc_pnet.h index ad4455cde9e7..1e94fd4df7bc 100644 --- a/net/smc/smc_pnet.h +++ b/net/smc/smc_pnet.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | struct smc_ib_device; | 19 | struct smc_ib_device; |
20 | struct smcd_dev; | ||
20 | 21 | ||
21 | static inline int smc_pnetid_by_dev_port(struct device *dev, | 22 | static inline int smc_pnetid_by_dev_port(struct device *dev, |
22 | unsigned short port, u8 *pnetid) | 23 | unsigned short port, u8 *pnetid) |
@@ -33,5 +34,6 @@ void smc_pnet_exit(void); | |||
33 | int smc_pnet_remove_by_ibdev(struct smc_ib_device *ibdev); | 34 | int smc_pnet_remove_by_ibdev(struct smc_ib_device *ibdev); |
34 | void smc_pnet_find_roce_resource(struct sock *sk, | 35 | void smc_pnet_find_roce_resource(struct sock *sk, |
35 | struct smc_ib_device **smcibdev, u8 *ibport); | 36 | struct smc_ib_device **smcibdev, u8 *ibport); |
37 | void smc_pnet_find_ism_resource(struct sock *sk, struct smcd_dev **smcismdev); | ||
36 | 38 | ||
37 | #endif | 39 | #endif |