|
22 | 22 |
|
23 | 23 | #include "smc_pnet.h" |
24 | 24 | #include "smc_ib.h" |
| 25 | +#include "smc_ism.h" |
25 | 26 |
|
26 | 27 | static struct nla_policy smc_pnet_policy[SMC_PNETID_MAX + 1] = { |
27 | 28 | [SMC_PNETID_NAME] = { |
@@ -564,6 +565,27 @@ static void smc_pnet_find_roce_by_pnetid(struct net_device *ndev, |
564 | 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 | 589 | /* Lookup of coupled ib_device via SMC pnet table */ |
568 | 590 | static void smc_pnet_find_roce_by_table(struct net_device *netdev, |
569 | 591 | struct smc_ib_device **smcibdev, |
@@ -615,3 +637,22 @@ void smc_pnet_find_roce_resource(struct sock *sk, |
615 | 637 | out: |
616 | 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 | +} |
0 commit comments