Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 May 2020 21:22:27 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r360548 - stable/12/sys/dev/cxgbe/iw_cxgbe
Message-ID:  <202005012122.041LMRec096034@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Fri May  1 21:22:26 2020
New Revision: 360548
URL: https://svnweb.freebsd.org/changeset/base/360548

Log:
  MFC r360211:
  
  cxgbe/iw_cxgbe: Create a LinuxKPI pci device for an adapter and use it
  as the dma_device during RDMA registration.
  
  cxgbe's struct device cannot be used as-is because it's a native FreeBSD
  driver and ibcore is LinuxKPI based.
  
  Sponsored by:	Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
  stable/12/sys/dev/cxgbe/iw_cxgbe/provider.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
==============================================================================
--- stable/12/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h	Fri May  1 20:29:51 2020	(r360547)
+++ stable/12/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h	Fri May  1 21:22:26 2020	(r360548)
@@ -261,6 +261,7 @@ out:
 
 struct c4iw_dev {
 	struct ib_device ibdev;
+	struct pci_dev pdev;
 	struct c4iw_rdev rdev;
 	u32 device_cap_flags;
 	struct idr cqidr;

Modified: stable/12/sys/dev/cxgbe/iw_cxgbe/provider.c
==============================================================================
--- stable/12/sys/dev/cxgbe/iw_cxgbe/provider.c	Fri May  1 20:29:51 2020	(r360547)
+++ stable/12/sys/dev/cxgbe/iw_cxgbe/provider.c	Fri May  1 21:22:26 2020	(r360548)
@@ -434,6 +434,9 @@ c4iw_register_device(struct c4iw_dev *dev)
 
 	CTR3(KTR_IW_CXGBE, "%s c4iw_dev %p, adapter %p", __func__, dev, sc);
 	BUG_ON(!sc->port[0]);
+	ret = linux_pci_attach_device(sc->dev, NULL, NULL, &dev->pdev);
+	if (ret)
+		return (ret);
 	strlcpy(ibdev->name, device_get_nameunit(sc->dev), sizeof(ibdev->name));
 	memset(&ibdev->node_guid, 0, sizeof(ibdev->node_guid));
 	memcpy(&ibdev->node_guid, sc->port[0]->vi[0].hw_addr, ETHER_ADDR_LEN);
@@ -465,7 +468,7 @@ c4iw_register_device(struct c4iw_dev *dev)
 	strlcpy(ibdev->node_desc, C4IW_NODE_DESC, sizeof(ibdev->node_desc));
 	ibdev->phys_port_cnt = sc->params.nports;
 	ibdev->num_comp_vectors = 1;
-	ibdev->dma_device = NULL;
+	ibdev->dma_device = &dev->pdev.dev;
 	ibdev->query_device = c4iw_query_device;
 	ibdev->query_port = c4iw_query_port;
 	ibdev->modify_port = c4iw_modify_port;
@@ -517,8 +520,10 @@ c4iw_register_device(struct c4iw_dev *dev)
 	ibdev->iwcm = iwcm;
 
 	ret = ib_register_device(&dev->ibdev, NULL);
-	if (ret)
+	if (ret) {
 		kfree(iwcm);
+		linux_pci_detach_device(&dev->pdev);
+	}
 
 	return (ret);
 }
@@ -531,6 +536,7 @@ c4iw_unregister_device(struct c4iw_dev *dev)
 	    dev->rdev.adap);
 	ib_unregister_device(&dev->ibdev);
 	kfree(dev->ibdev.iwcm);
+	linux_pci_detach_device(&dev->pdev);
 	return;
 }
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005012122.041LMRec096034>