summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-09-05 10:45:05 -0500
committerAleksander Morgado <aleksander@lanedo.com>2012-09-08 10:34:13 +0200
commitaf5966923ff3631686e2b1da9948c0e9430eeff3 (patch)
treed3d0817e47a18f76def1395d637db5f5967c715d
parent33cf86b703b6c12e0cd0d9cb50935840ca66d1ab (diff)
ctl: implement Set Data Format command
-rw-r--r--data/qmi-service-ctl.json26
-rw-r--r--libqmi-glib/qmi-device.c78
-rw-r--r--libqmi-glib/qmi-device.h14
-rw-r--r--libqmi-glib/qmi-enums.h27
4 files changed, 142 insertions, 3 deletions
diff --git a/data/qmi-service-ctl.json b/data/qmi-service-ctl.json
index c789bff..1ce2ddc 100644
--- a/data/qmi-service-ctl.json
+++ b/data/qmi-service-ctl.json
@@ -109,6 +109,32 @@
"prerequisites": [ { "common-ref" : "Success" } ] } ] },
// *********************************************************************************
+ { "name" : "Set Data Format",
+ "type" : "Message",
+ "service" : "CTL",
+ "id" : "0x0026",
+ "input" : [ { "name" : "Format",
+ "id" : "0x01",
+ "mandatory" : "yes",
+ "type" : "TLV",
+ "format" : "guint8",
+ "public-format" : "QmiCtlDataFormat" },
+ { "name" : "Protocol",
+ "id" : "0x10",
+ "mandatory" : "yes",
+ "type" : "TLV",
+ "format" : "guint16",
+ "public-format" : "QmiCtlDataLinkProtocol" } ],
+ "output" : [ { "common-ref" : "Operation Result" },
+ { "name" : "Protocol",
+ "id" : "0x10",
+ "mandatory" : "no",
+ "type" : "TLV",
+ "format" : "guint16",
+ "public-format" : "QmiCtlDataLinkProtocol" } ],
+ "prerequisites" : [ { "common-ref" : "Success" } ] },
+
+ // *********************************************************************************
{ "name" : "Sync",
"type" : "Message",
"service" : "CTL",
diff --git a/libqmi-glib/qmi-device.c b/libqmi-glib/qmi-device.c
index e220e88..794838f 100644
--- a/libqmi-glib/qmi-device.c
+++ b/libqmi-glib/qmi-device.c
@@ -1324,6 +1324,38 @@ qmi_device_open_finish (QmiDevice *self,
static void process_open_flags (DeviceOpenContext *ctx);
static void
+ctl_set_data_format_ready (QmiClientCtl *client,
+ GAsyncResult *res,
+ DeviceOpenContext *ctx)
+{
+ QmiMessageCtlSetDataFormatOutput *output = NULL;
+ GError *error = NULL;
+
+ output = qmi_client_ctl_set_data_format_finish (client, res, &error);
+ /* Check result of the async operation */
+ if (!output) {
+ g_simple_async_result_take_error (ctx->result, error);
+ device_open_context_complete_and_free (ctx);
+ return;
+ }
+
+ /* Check result of the QMI operation */
+ if (!qmi_message_ctl_set_data_format_output_get_result (output, &error)) {
+ g_simple_async_result_take_error (ctx->result, error);
+ device_open_context_complete_and_free (ctx);
+ qmi_message_ctl_set_data_format_output_unref (output);
+ return;
+ }
+
+ g_debug ("[%s] Network port data format operation finished",
+ ctx->self->priv->path_display);
+
+ /* Keep on with next flags */
+ process_open_flags (ctx);
+ qmi_message_ctl_set_data_format_output_unref (output);
+}
+
+static void
sync_ready (QmiClientCtl *client_ctl,
GAsyncResult *res,
DeviceOpenContext *ctx)
@@ -1435,6 +1467,11 @@ version_info_ready (QmiClientCtl *client_ctl,
qmi_message_ctl_get_version_info_output_unref (output);
}
+#define NETPORT_FLAGS (QMI_DEVICE_OPEN_FLAGS_NET_802_3 | \
+ QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP | \
+ QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER | \
+ QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER)
+
static void
process_open_flags (DeviceOpenContext *ctx)
{
@@ -1469,6 +1506,35 @@ process_open_flags (DeviceOpenContext *ctx)
return;
}
+ /* Network port setup */
+ if (ctx->flags & NETPORT_FLAGS) {
+ QmiMessageCtlSetDataFormatInput *input;
+ QmiCtlDataFormat qos = QMI_CTL_DATA_FORMAT_QOS_FLOW_HEADER_ABSENT;
+ QmiCtlDataLinkProtocol link = QMI_CTL_DATA_LINK_PROTOCOL_802_3;
+
+ g_debug ("[%s] Setting network port data format...",
+ ctx->self->priv->path_display);
+
+ input = qmi_message_ctl_set_data_format_input_new ();
+
+ if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER)
+ qos = QMI_CTL_DATA_FORMAT_QOS_FLOW_HEADER_PRESENT;
+ qmi_message_ctl_set_data_format_input_set_format (input, qos, NULL);
+
+ if (ctx->flags & QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP)
+ link = QMI_CTL_DATA_LINK_PROTOCOL_RAW_IP;
+ qmi_message_ctl_set_data_format_input_set_protocol (input, link, NULL);
+
+ ctx->flags &= ~NETPORT_FLAGS;
+ qmi_client_ctl_set_data_format (ctx->self->priv->client_ctl,
+ input,
+ 5,
+ NULL,
+ (GAsyncReadyCallback)ctl_set_data_format_ready,
+ ctx);
+ return;
+ }
+
/* No more flags to process, done we are */
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
device_open_context_complete_and_free (ctx);
@@ -1499,6 +1565,18 @@ qmi_device_open (QmiDevice *self,
DeviceOpenContext *ctx;
GError *error = NULL;
+ /* Raw IP and 802.3 are mutually exclusive */
+ g_return_if_fail (!((flags & QMI_DEVICE_OPEN_FLAGS_NET_802_3) &&
+ (flags & QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP)));
+ /* QoS and no QoS are mutually exclusive */
+ g_return_if_fail (!((flags & QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER) &&
+ (flags & QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER)));
+ /* At least one of both link protocol and QoS must be specified */
+ if (flags & (QMI_DEVICE_OPEN_FLAGS_NET_802_3 | QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP))
+ g_return_if_fail (flags & (QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER | QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER));
+ if (flags & (QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER | QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER))
+ g_return_if_fail (flags & (QMI_DEVICE_OPEN_FLAGS_NET_802_3 | QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP));
+
g_return_if_fail (QMI_IS_DEVICE (self));
ctx = g_slice_new (DeviceOpenContext);
diff --git a/libqmi-glib/qmi-device.h b/libqmi-glib/qmi-device.h
index 6e04562..694b47a 100644
--- a/libqmi-glib/qmi-device.h
+++ b/libqmi-glib/qmi-device.h
@@ -75,13 +75,21 @@ gboolean qmi_device_is_open (QmiDevice *self);
* @QMI_DEVICE_OPEN_FLAGS_NONE: No flags.
* @QMI_DEVICE_OPEN_FLAGS_VERSION_INFO: Run version info check when opening.
* @QMI_DEVICE_OPEN_FLAGS_SYNC: Synchronize with endpoint once the device is open. Will release any previously allocated client ID.
+ * @QMI_DEVICE_OPEN_FLAGS_NET_802_3: set network port to "802.3" mode; mutually exclusive with @QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP
+ * @QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP: set network port to "raw IP" mode; mutally exclusive with @QMI_DEVICE_OPEN_FLAGS_NET_802_3
+ * @QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER: set network port to transmit/receive QoS headers; mutually exclusive with @QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER
+ * @QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER: set network port to not transmit/receive QoS headers; mutually exclusive with @QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER
*
* Flags to specify which actions to be performed when the device is open.
*/
typedef enum {
- QMI_DEVICE_OPEN_FLAGS_NONE = 0,
- QMI_DEVICE_OPEN_FLAGS_VERSION_INFO = 1 << 0,
- QMI_DEVICE_OPEN_FLAGS_SYNC = 1 << 1
+ QMI_DEVICE_OPEN_FLAGS_NONE = 0,
+ QMI_DEVICE_OPEN_FLAGS_VERSION_INFO = 1 << 0,
+ QMI_DEVICE_OPEN_FLAGS_SYNC = 1 << 1,
+ QMI_DEVICE_OPEN_FLAGS_NET_802_3 = 1 << 2,
+ QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP = 1 << 3,
+ QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER = 1 << 4,
+ QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER = 1 << 5
} QmiDeviceOpenFlags;
void qmi_device_open (QmiDevice *self,
diff --git a/libqmi-glib/qmi-enums.h b/libqmi-glib/qmi-enums.h
index 5710eba..4a3476a 100644
--- a/libqmi-glib/qmi-enums.h
+++ b/libqmi-glib/qmi-enums.h
@@ -73,6 +73,33 @@ typedef enum {
QMI_CTL_FLAG_INDICATION = 1 << 1
} QmiCtlFlag;
+/**
+ * QmiCtlDataFormat:
+ * @QMI_CTL_DATA_FORMAT_QOS_FLOW_HEADER_ABSENT: QoS header absent
+ * @QMI_CTL_DATA_FORMAT_QOS_FLOW_HEADER_PRESENT: QoS header present
+ *
+ * Controls whether the network port data format includes a QoS header or not.
+ * Should normally be set to ABSENT.
+ */
+typedef enum {
+ QMI_CTL_DATA_FORMAT_QOS_FLOW_HEADER_ABSENT = 0,
+ QMI_CTL_DATA_FORMAT_QOS_FLOW_HEADER_PRESENT = 1,
+} QmiCtlDataFormat;
+
+
+/**
+ * QmiCtlDataLinkProtocol:
+ * @QMI_CTL_DATA_LINK_PROTOCOL_802_3: data frames formatted as 802.3 Ethernet
+ * @QMI_CTL_DATA_LINK_PROTOCOL_RAW_IP: data frames are raw IP packets
+ *
+ * Determines the network port data format. Despite looking like flags, these
+ * values are actually mutually exclusive.
+ */
+typedef enum {
+ QMI_CTL_DATA_LINK_PROTOCOL_802_3 = 1 << 0,
+ QMI_CTL_DATA_LINK_PROTOCOL_RAW_IP = 1 << 1,
+} QmiCtlDataLinkProtocol;
+
/*****************************************************************************/
/* QMI Services */