greybus: ap: process the UniPro link up message
authorMatt Porter <mporter@linaro.org>
Wed, 22 Oct 2014 02:43:31 +0000 (22:43 -0400)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 22 Oct 2014 05:57:49 +0000 (13:57 +0800)
The link up message is the event that tells the AP what device ID
has been assigned to a particular interface on a module during
enumeration. The link up is sent *only* after the hotplug event
for a particular module has been sent to the AP.

The link up payload must carry the Module ID and Interface ID
to uniquely identify the struct gb_interface to which the
Device ID has been assigned.

After processing of the link up message, the interface's device_id
field will contain the assigned Device ID so that the AP has the
information necessary to issue network route commands.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/ap.c
drivers/staging/greybus/svc_msg.h

index 5b63356..c8f30f6 100644 (file)
@@ -106,6 +106,9 @@ static void svc_handshake(struct svc_function_handshake *handshake,
 static void svc_management(struct svc_function_unipro_management *management,
                           int payload_length, struct greybus_host_device *hd)
 {
+       struct gb_module *module;
+       struct gb_interface *interface;
+
        if (payload_length != sizeof(struct svc_function_unipro_management)) {
                dev_err(hd->parent,
                        "Illegal size of svc management message %d\n",
@@ -114,6 +117,22 @@ static void svc_management(struct svc_function_unipro_management *management,
        }
 
        switch (management->management_packet_type) {
+       case SVC_MANAGEMENT_LINK_UP:
+               module = gb_module_find(hd, management->link_up.module_id);
+               if (!module) {
+                       dev_err(hd->parent, "Module ID %d not found\n",
+                               management->link_up.module_id);
+                       return;
+               }
+               interface = gb_interface_find(module,
+                                             management->link_up.interface_id);
+               if (!interface) {
+                       dev_err(hd->parent, "Interface ID %d not found\n",
+                               management->link_up.interface_id);
+                       return;
+               }
+               interface->device_id = management->link_up.device_id;
+               break;
        case SVC_MANAGEMENT_AP_DEVICE_ID:
                hd->device_id = management->ap_device_id.device_id;
                break;
index 4aa7e17..47597e6 100644 (file)
@@ -55,6 +55,8 @@ struct svc_function_unipro_set_route {
 };
 
 struct svc_function_unipro_link_up {
+       __u8    module_id;
+       __u8    interface_id;
        __u8    device_id;
 };