Export connector type on Port objects
authorDavid Zeuthen <davidz@redhat.com>
Fri, 4 Dec 2009 21:03:56 +0000 (16:03 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Fri, 4 Dec 2009 21:03:56 +0000 (16:03 -0500)
Also add a quirk for my CardBus based eSATA controller.

data/80-udisks.rules
data/org.freedesktop.UDisks.Port.xml
src/daemon.c
src/daemon.h
src/port-private.c
src/port-private.h
src/port.c

index d7b7740..206e37a 100644 (file)
@@ -5,6 +5,18 @@
 #
 SUBSYSTEM=="pci", ACTION=="add|change", ENV{ID_MODEL_FROM_DATABASE}=="", ATTR{class}=="0x01*", IMPORT{program}="pci-db %p"
 
+# Set eSATA port type for known eSATA CardBus adapters - first we want to ensure
+# the device is on a cardbus controller (upper PCI device) - then we check
+# vid/pid (lower PCI device)
+#
+SUBSYSTEM=="scsi_host", ATTRS{class}=="0x060700", GOTO="ata_port_cardbus"
+GOTO="ata_port_cardbus_end"
+LABEL="ata_port_cardbus"
+# Mass storage controller: Silicon Image, Inc. SiI 3512 [SATALink/SATARaid] Serial ATA Controller (rev 01)
+#
+ATTRS{vendor}=="0x1095", ATTRS{device}=="0x3512", ENV{UDISKS_ATA_PORT_CONNECTOR_TYPE}="ata_sata_external"
+LABEL="ata_port_cardbus_end"
+
 # probe SAS expanders
 #
 # (hmm, this might be racy, we might not have the BSG device just yet - if
index 8e4820f..eaf4a5f 100644 (file)
       </doc:para></doc:description></doc:doc>
     </property>
 
+    <property name="ConnectorType" type="s" access="read">
+      <doc:doc><doc:description><doc:para>
+            The connector type for the port (or for wide connectors, that the port is part of) or blank if unknown.
+            <doc:list>
+              <doc:item>
+                <doc:term>ata</doc:term><doc:definition>Some kind of ATA connector</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>ata_pata</doc:term><doc:definition>Parallel ATA</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>ata_sata</doc:term><doc:definition>Serial ATA - not sure whether it's an internal or external port.</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>ata_sata_internal</doc:term><doc:definition>Internal Serial ATA</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>ata_sata_external</doc:term><doc:definition>External Serial ATA</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi</doc:term><doc:definition>Some kind of SCSI connector</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas</doc:term><doc:definition>Some kind of SAS connector</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas_internal</doc:term><doc:definition>SAS (SFF-8482)</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas_2x</doc:term><doc:definition>SAS connector with 2 lanes</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas_2x_wideband</doc:term><doc:definition>SAS Hi-Density with 2 lanes (SFF-8484)</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas_4x</doc:term><doc:definition>Some kind of SAS connector with 4 lanes</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas_4x_wideband</doc:term><doc:definition>SAS Hi-Density with 4 lanes (SFF-8484)</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas_4x_mini</doc:term><doc:definition>Mini-SAS with 4 lanes (SFF-8087, iPass)</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas_4x_mini_external</doc:term><doc:definition>External Mini-SAS with 4 lanes (SFF-8088)</doc:definition>
+              </doc:item>
+              <doc:item>
+                <doc:term>scsi_sas_4x_infiband</doc:term><doc:definition>Infiniband with 4 lanes (SFF-8470)</doc:definition>
+              </doc:item>
+            </doc:list>
+            TODO: include other connector types
+      </doc:para></doc:description></doc:doc>
+    </property>
+
   </interface>
 
 </node>
index 6a8c7fa..6492734 100644 (file)
@@ -1060,8 +1060,7 @@ _device_changed (Daemon *daemon,
 }
 
 void
-daemon_local_synthesize_changed (Daemon *daemon,
-                                 Device *device)
+daemon_local_synthesize_changed (Daemon *daemon, Device *device)
 {
   g_object_ref (device->priv->d);
   _device_changed (daemon, device->priv->d, TRUE);
index 621e734..170fd21 100644 (file)
@@ -124,8 +124,7 @@ gboolean daemon_local_get_uid (Daemon *daemon,
 
 void daemon_local_synthesize_changed_on_all_devices (Daemon *daemon);
 
-void daemon_local_synthesize_changed (Daemon *daemon,
-                                 Device *device);
+void daemon_local_synthesize_changed (Daemon *daemon, Device *device);
 
 void daemon_local_update_poller (Daemon *daemon);
 
index 7b28cf4..b868b92 100644 (file)
@@ -89,6 +89,18 @@ port_set_parent (Port        *port,
 }
 
 void
+port_set_connector_type (Port        *port,
+                         const gchar *value)
+{
+  if (G_UNLIKELY (g_strcmp0 (port->priv->connector_type, value) != 0))
+    {
+      g_free (port->priv->connector_type);
+      port->priv->connector_type = g_strdup (value);
+      emit_changed (port, "connector_type");
+    }
+}
+
+void
 port_set_number (Port *port,
                  gint value)
 {
index e83d151..cc48376 100644 (file)
@@ -58,6 +58,7 @@ struct PortPrivate
 
   gchar *adapter;
   gchar *parent;
+  gchar *connector_type;
   gint number;
 };
 
@@ -67,6 +68,8 @@ void port_set_adapter (Port         *port,
                        const gchar  *value);
 void port_set_parent  (Port         *port,
                        const gchar  *value);
+void port_set_connector_type  (Port         *port,
+                               const gchar  *value);
 void port_set_number  (Port         *port,
                        gint          value);
 
index c202991..f52ae51 100644 (file)
 /*--------------------------------------------------------------------------------------------------------------*/
 #include "port-glue.h"
 
-static void
-port_class_init (PortClass *klass);
-static void
-port_init (Port *seat);
-static void
-port_finalize (GObject *object);
+static void port_class_init (PortClass *klass);
+static void port_init (Port *seat);
+static void port_finalize (GObject *object);
 
-static gboolean
-update_info (Port *port);
+static gboolean update_info (Port *port);
 
 static void
 drain_pending_changes (Port *port,
@@ -65,6 +61,7 @@ enum
     PROP_ADAPTER,
     PROP_PARENT,
     PROP_NUMBER,
+    PROP_CONNECTOR_TYPE,
   };
 
 enum
@@ -112,6 +109,10 @@ get_property (GObject *object,
       g_value_set_int (value, port->priv->number);
       break;
 
+    case PROP_CONNECTOR_TYPE:
+      g_value_set_string (value, port->priv->connector_type);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -162,6 +163,11 @@ port_class_init (PortClass *klass)
                                                                                 G_MAXINT,
                                                                                 -1,
                                                                                 G_PARAM_READABLE));
+  g_object_class_install_property (object_class, PROP_CONNECTOR_TYPE, g_param_spec_string ("connector-type",
+                                                                                           NULL,
+                                                                                           NULL,
+                                                                                           NULL,
+                                                                                           G_PARAM_READABLE));
 }
 
 static void
@@ -197,6 +203,7 @@ port_finalize (GObject *object)
   /* free properties */
   g_free (port->priv->adapter);
   g_free (port->priv->parent);
+  g_free (port->priv->connector_type);
 
   G_OBJECT_CLASS (port_parent_class)->finalize (object);
 }
@@ -577,6 +584,8 @@ update_info_ata (Port *port,
   const gchar *basename;
   gint port_host_number;
   gint port_number;
+  const gchar *adapter_fabric;
+  const gchar *connector_type;
 
   ret = FALSE;
   port_number = -1;
@@ -642,7 +651,28 @@ update_info_ata (Port *port,
         }
     }
 
+  /* Third, guess the connector type.
+   *
+   * This can be overriden via the udev property UDISKS_ATA_PORT_CONNECTOR_TYPE -
+   * see the data/80-udisks.rules for an example.
+   */
+  connector_type = g_udev_device_get_property (port->priv->d, "UDISKS_ATA_PORT_CONNECTOR_TYPE");
+  if (connector_type == NULL)
+    {
+      connector_type = "ata";
+      adapter_fabric = adapter_local_get_fabric (adapter);
+      if (g_strcmp0 (adapter_fabric, "ata_pata") == 0)
+        {
+          connector_type = "ata_pata";
+        }
+      else if (g_strcmp0 (adapter_fabric, "ata_sata") == 0)
+        {
+          connector_type = "ata_sata";
+        }
+    }
+
   port_set_number (port, port_number);
+  port_set_connector_type (port, connector_type);
   port->priv->port_type = PORT_TYPE_ATA;
   ret = TRUE;
 
@@ -666,6 +696,9 @@ update_info_sas_phy (Port *port,
 
   port_number = g_udev_device_get_sysfs_attr_as_int (port->priv->d, "phy_identifier");
   port_set_number (port, port_number);
+  /* We can't get it any more precise than this until we read SES-2 or SAS-2.0 info */
+  port_set_connector_type (port, "scsi_sas");
+
   port->priv->port_type = PORT_TYPE_SAS;
 
   return TRUE;