net/smc: add pnetid support for SMC-D and ISM
authorHans Wippel <hwippel@linux.ibm.com>
Thu, 28 Jun 2018 17:05:08 +0000 (19:05 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Jun 2018 11:42:25 +0000 (20:42 +0900)
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>
include/net/smc.h
net/smc/smc_ism.c
net/smc/smc_pnet.c
net/smc/smc_pnet.h

index 824a7af8d654521497729beb190a6f8535d71b74..9ef49f8b1002a42044e3c70fb86666aacb46a074 100644 (file)
@@ -73,6 +73,7 @@ struct smcd_dev {
        struct smc_connection **conn;
        struct list_head vlan;
        struct workqueue_struct *event_wq;
+       u8 pnetid[SMC_MAX_PNETID_LEN];
 };
 
 struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
index ca1ce42fd49f3edd13fb60b339d6c41c207ba44c..f44e4dff244ae168de344da660300f968254164c 100644 (file)
@@ -13,6 +13,7 @@
 #include "smc.h"
 #include "smc_core.h"
 #include "smc_ism.h"
+#include "smc_pnet.h"
 
 struct smcd_dev_list smcd_dev_list = {
        .list = LIST_HEAD_INIT(smcd_dev_list.list),
@@ -227,6 +228,7 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
        device_initialize(&smcd->dev);
        dev_set_name(&smcd->dev, name);
        smcd->ops = ops;
+       smc_pnetid_by_dev_port(parent, 0, smcd->pnetid);
 
        spin_lock_init(&smcd->lock);
        INIT_LIST_HEAD(&smcd->vlan);
index cdc6e23b6ce1f866d76456b4b44ae3a30a9e0c03..1b6c066d34950e5e213df3826ce073f0e78b1396 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "smc_pnet.h"
 #include "smc_ib.h"
+#include "smc_ism.h"
 
 static struct nla_policy smc_pnet_policy[SMC_PNETID_MAX + 1] = {
        [SMC_PNETID_NAME] = {
@@ -564,6 +565,27 @@ static void smc_pnet_find_roce_by_pnetid(struct net_device *ndev,
        spin_unlock(&smc_ib_devices.lock);
 }
 
+static void smc_pnet_find_ism_by_pnetid(struct net_device *ndev,
+                                       struct smcd_dev **smcismdev)
+{
+       u8 ndev_pnetid[SMC_MAX_PNETID_LEN];
+       struct smcd_dev *ismdev;
+
+       ndev = pnet_find_base_ndev(ndev);
+       if (smc_pnetid_by_dev_port(ndev->dev.parent, ndev->dev_port,
+                                  ndev_pnetid))
+               return; /* pnetid could not be determined */
+
+       spin_lock(&smcd_dev_list.lock);
+       list_for_each_entry(ismdev, &smcd_dev_list.list, list) {
+               if (!memcmp(ismdev->pnetid, ndev_pnetid, SMC_MAX_PNETID_LEN)) {
+                       *smcismdev = ismdev;
+                       break;
+               }
+       }
+       spin_unlock(&smcd_dev_list.lock);
+}
+
 /* Lookup of coupled ib_device via SMC pnet table */
 static void smc_pnet_find_roce_by_table(struct net_device *netdev,
                                        struct smc_ib_device **smcibdev,
@@ -615,3 +637,22 @@ out_rel:
 out:
        return;
 }
+
+void smc_pnet_find_ism_resource(struct sock *sk, struct smcd_dev **smcismdev)
+{
+       struct dst_entry *dst = sk_dst_get(sk);
+
+       *smcismdev = NULL;
+       if (!dst)
+               goto out;
+       if (!dst->dev)
+               goto out_rel;
+
+       /* if possible, lookup via hardware-defined pnetid */
+       smc_pnet_find_ism_by_pnetid(dst->dev, smcismdev);
+
+out_rel:
+       dst_release(dst);
+out:
+       return;
+}
index ad4455cde9e77093c94fb38781ecb4a4e9b61503..1e94fd4df7bc254bdc6ba0e341e45b43e8f1489c 100644 (file)
@@ -17,6 +17,7 @@
 #endif
 
 struct smc_ib_device;
+struct smcd_dev;
 
 static inline int smc_pnetid_by_dev_port(struct device *dev,
                                         unsigned short port, u8 *pnetid)
@@ -33,5 +34,6 @@ void smc_pnet_exit(void);
 int smc_pnet_remove_by_ibdev(struct smc_ib_device *ibdev);
 void smc_pnet_find_roce_resource(struct sock *sk,
                                 struct smc_ib_device **smcibdev, u8 *ibport);
+void smc_pnet_find_ism_resource(struct sock *sk, struct smcd_dev **smcismdev);
 
 #endif