Skip to content

Commit 5490357

Browse files
Ursula Braundavem330
authored andcommitted
net/smc: allow pnetid-less configuration
Without hardware pnetid support there must currently be a pnet table configured to determine the IB device port to be used for SMC RDMA traffic. This patch enables a setup without pnet table, if the used handshake interface belongs already to a RoCE port. Signed-off-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6c97da1 commit 5490357

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

net/smc/smc_pnet.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,47 @@ static int smc_pnet_find_ndev_pnetid_by_table(struct net_device *ndev,
754754
return rc;
755755
}
756756

757+
/* if handshake network device belongs to a roce device, return its
758+
* IB device and port
759+
*/
760+
static void smc_pnet_find_rdma_dev(struct net_device *netdev,
761+
struct smc_ib_device **smcibdev,
762+
u8 *ibport, unsigned short vlan_id, u8 gid[])
763+
{
764+
struct smc_ib_device *ibdev;
765+
766+
spin_lock(&smc_ib_devices.lock);
767+
list_for_each_entry(ibdev, &smc_ib_devices.list, list) {
768+
struct net_device *ndev;
769+
int i;
770+
771+
for (i = 1; i <= SMC_MAX_PORTS; i++) {
772+
if (!rdma_is_port_valid(ibdev->ibdev, i))
773+
continue;
774+
if (!ibdev->ibdev->ops.get_netdev)
775+
continue;
776+
ndev = ibdev->ibdev->ops.get_netdev(ibdev->ibdev, i);
777+
if (!ndev)
778+
continue;
779+
dev_put(ndev);
780+
if (netdev == ndev &&
781+
smc_ib_port_active(ibdev, i) &&
782+
!smc_ib_determine_gid(ibdev, i, vlan_id, gid,
783+
NULL)) {
784+
*smcibdev = ibdev;
785+
*ibport = i;
786+
break;
787+
}
788+
}
789+
}
790+
spin_unlock(&smc_ib_devices.lock);
791+
}
792+
757793
/* Determine the corresponding IB device port based on the hardware PNETID.
758794
* Searching stops at the first matching active IB device port with vlan_id
759795
* configured.
796+
* If nothing found, check pnetid table.
797+
* If nothing found, try to use handshake device
760798
*/
761799
static void smc_pnet_find_roce_by_pnetid(struct net_device *ndev,
762800
struct smc_ib_device **smcibdev,
@@ -770,8 +808,10 @@ static void smc_pnet_find_roce_by_pnetid(struct net_device *ndev,
770808
ndev = pnet_find_base_ndev(ndev);
771809
if (smc_pnetid_by_dev_port(ndev->dev.parent, ndev->dev_port,
772810
ndev_pnetid) &&
773-
smc_pnet_find_ndev_pnetid_by_table(ndev, ndev_pnetid))
811+
smc_pnet_find_ndev_pnetid_by_table(ndev, ndev_pnetid)) {
812+
smc_pnet_find_rdma_dev(ndev, smcibdev, ibport, vlan_id, gid);
774813
return; /* pnetid could not be determined */
814+
}
775815

776816
spin_lock(&smc_ib_devices.lock);
777817
list_for_each_entry(ibdev, &smc_ib_devices.list, list) {

0 commit comments

Comments
 (0)