Author: jhb
Date: Wed Aug  3 17:11:08 2016
New Revision: 303722
URL: https://svnweb.freebsd.org/changeset/base/303722

Log:
  Use the port device name for the iov device for Chelsio T4/T5 cards.
  
  Chelsio T4/T5 adapters are multifunction cards.  The main driver uses
  physical function 4 (PF4).  However, VF devices for SR-IOV are only
  supported on physical functions 0 through 3, where PF0 creates VFs tied
  to port 0, etc.  The t4iov/t5iov driver was previously added to
  create VF devices for ports that are present on each adapter.  This
  change uses the recently added pci_iov_attach_name() function to
  name the character device in /dev/iov after the associated port on
  the card (e.g. /dev/iov/cxl0 is used to create VFs that share the
  cxl0 port).  With this in place, mark the t4iov/t5iov devices quiet
  to prevent them from cluttering dmesg.
  
  Reviewed by:  rstone
  Sponsored by: Chelsio Communications
  Differential Revision:        https://reviews.freebsd.org/D7402

Modified:
  head/sys/dev/cxgbe/t4_if.m
  head/sys/dev/cxgbe/t4_iov.c
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_if.m
==============================================================================
--- head/sys/dev/cxgbe/t4_if.m  Wed Aug  3 17:09:12 2016        (r303721)
+++ head/sys/dev/cxgbe/t4_if.m  Wed Aug  3 17:11:08 2016        (r303722)
@@ -55,11 +55,11 @@ METHOD int detach_child {
        device_t        dev;
 };
 
-# Called by a driver to query the PF4 driver for the unit number to use
-# for a given port.  If the port is not enabled on the adapter, this
-# will fail.
-METHOD int read_port_unit {
+# Called by a driver to query the PF4 driver for the child device
+# associated with a given port.  If the port is not enabled on the adapter,
+# this will fail.
+METHOD int read_port_device {
        device_t        dev;
        int             port;
-       int             *unit;
+       device_t        *child;
 };

Modified: head/sys/dev/cxgbe/t4_iov.c
==============================================================================
--- head/sys/dev/cxgbe/t4_iov.c Wed Aug  3 17:09:12 2016        (r303721)
+++ head/sys/dev/cxgbe/t4_iov.c Wed Aug  3 17:11:08 2016        (r303722)
@@ -104,6 +104,7 @@ t4iov_probe(device_t dev)
        for (i = 0; i < nitems(t4iov_pciids); i++) {
                if (d == t4iov_pciids[i].device) {
                        device_set_desc(dev, t4iov_pciids[i].desc);
+                       device_quiet(dev);
                        return (BUS_PROBE_DEFAULT);
                }
        }
@@ -120,6 +121,7 @@ t5iov_probe(device_t dev)
        for (i = 0; i < nitems(t5iov_pciids); i++) {
                if (d == t5iov_pciids[i].device) {
                        device_set_desc(dev, t5iov_pciids[i].desc);
+                       device_quiet(dev);
                        return (BUS_PROBE_DEFAULT);
                }
        }
@@ -148,25 +150,27 @@ t4iov_attach_child(device_t dev)
 #ifdef PCI_IOV
        nvlist_t *pf_schema, *vf_schema;
 #endif
-       int error, unit;
+       device_t pdev;
+       int error;
 
        sc = device_get_softc(dev);
        MPASS(!sc->sc_attached);
 
        /*
         * PF0-3 are associated with a specific port on the NIC (PF0
-        * with port 0, etc.).  Ask the PF4 driver for the unit number
-        * for this function's associated port to determine if the port
-        * is present.
+        * with port 0, etc.).  Ask the PF4 driver for the device for
+        * this function's associated port to determine if the port is
+        * present.
         */
-       error = T4_READ_PORT_UNIT(sc->sc_main, pci_get_function(dev), &unit);
+       error = T4_READ_PORT_DEVICE(sc->sc_main, pci_get_function(dev), &pdev);
        if (error)
                return (0);
 
 #ifdef PCI_IOV
        pf_schema = pci_iov_schema_alloc_node();
        vf_schema = pci_iov_schema_alloc_node();
-       error = pci_iov_attach(dev, pf_schema, vf_schema);
+       error = pci_iov_attach_name(dev, pf_schema, vf_schema, "%s",
+           device_get_nameunit(pdev));
        if (error) {
                device_printf(dev, "Failed to initialize SR-IOV: %d\n", error);
                return (0);

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c        Wed Aug  3 17:09:12 2016        
(r303721)
+++ head/sys/dev/cxgbe/t4_main.c        Wed Aug  3 17:11:08 2016        
(r303722)
@@ -83,14 +83,14 @@ static int t4_probe(device_t);
 static int t4_attach(device_t);
 static int t4_detach(device_t);
 static int t4_ready(device_t);
-static int t4_read_port_unit(device_t, int, int *);
+static int t4_read_port_device(device_t, int, device_t *);
 static device_method_t t4_methods[] = {
        DEVMETHOD(device_probe,         t4_probe),
        DEVMETHOD(device_attach,        t4_attach),
        DEVMETHOD(device_detach,        t4_detach),
 
        DEVMETHOD(t4_is_main_ready,     t4_ready),
-       DEVMETHOD(t4_read_port_unit,    t4_read_port_unit),
+       DEVMETHOD(t4_read_port_device,  t4_read_port_device),
 
        DEVMETHOD_END
 };
@@ -149,7 +149,7 @@ static device_method_t t5_methods[] = {
        DEVMETHOD(device_detach,        t4_detach),
 
        DEVMETHOD(t4_is_main_ready,     t4_ready),
-       DEVMETHOD(t4_read_port_unit,    t4_read_port_unit),
+       DEVMETHOD(t4_read_port_device,  t4_read_port_device),
 
        DEVMETHOD_END
 };
@@ -1094,7 +1094,7 @@ t4_ready(device_t dev)
 }
 
 static int
-t4_read_port_unit(device_t dev, int port, int *unit)
+t4_read_port_device(device_t dev, int port, device_t *child)
 {
        struct adapter *sc;
        struct port_info *pi;
@@ -1105,7 +1105,7 @@ t4_read_port_unit(device_t dev, int port
        pi = sc->port[port];
        if (pi == NULL || pi->dev == NULL)
                return (ENXIO);
-       *unit = device_get_unit(pi->dev);
+       *child = pi->dev;
        return (0);
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to