diff mbox

[net-next-2.6,02/13] net-caif: add CAIF header files

Message ID 1264028130-14364-3-git-send-email-sjur.brandeland@stericsson.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

sjur.brandeland@stericsson.com Jan. 20, 2010, 10:55 p.m. UTC
From: Sjur Braendeland <sjur.brandeland@stericsson.com>

Add CAIF types for Socket Address, Socket Options,
and configuration parameters for the GPRS IP network interface.

Signed-off-by: Sjur Braendeland <sjur.brandeland@stericsson.com>
---
 include/linux/caif/caif_config.h |  155 ++++++++++++++++++++++++++++++++++++
 include/linux/caif/caif_socket.h |  161 ++++++++++++++++++++++++++++++++++++++
 include/linux/caif/if_caif.h     |   71 +++++++++++++++++
 3 files changed, 387 insertions(+), 0 deletions(-)

Comments

Patrick McHardy Jan. 21, 2010, 7:44 a.m. UTC | #1
sjur.brandeland@stericsson.com wrote:
> +/**
> + * enum ifla_caif
> + * When using RT Netlink to create, destroy or configure a CAIF IP interface,
> + * enum ifla_caif is used to specify the configuration attributes.
> + *
> + * @IFLA_CAIF_IPV4_CONNID:  Connection ID for IPv4 PDP Context.
> + *			    The type of attribute is NLA_U32.
> + * @IFLA_CAIF_IPV6_CONNID:  Connection ID for IPv6 PDP Context.
> + *			    The type of attribute is NLA_U32.
> + * @IFLA_CAIF_LOOPBACK:	    If different from zero, device is doing loopback
> + *			    The type of attribute is NLA_U8.
> + */
> +enum ifla_caif {
> +	IFLA_CAIF_IPV4_CONNID,
> +	IFLA_CAIF_IPV6_CONNID,
> +	IFLA_CAIF_LOOPBACK,
> +	__IFLA_CAIF_MAX
> +};
> +#define	IFLA_CAIF_MAX (__IFLA_CAIF_MAX-1)
> +
> +#endif /*IF_CAIF_H_*/

You should add an IFLA_CAIF_UNSPEC at the beginning, some of the
nlattr helpers skip attributes with a value of zero.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Holtmann Jan. 22, 2010, 7:51 a.m. UTC | #2
Hi Sjur,

> +/**
> + * struct sockaddr_caif - the sockaddr structure for CAIF sockets.
> + * @u:			     Union of address data 'switched' by familty.
> + * @at:			     Applies when family = CAIFPROTO_AT.
> + * @at.type:		     Type of AT link to set up (enum caif_at_type).
> + * @util:		     Applies when family = CAIFPROTO_UTIL
> + * @util.service:	     Service name.
> + * @dgm:		     Applies when family = CAIFPROTO_DATAGRAM
> + * @dgm.connection_id:	     Datagram connection id.
> + * @dgm.nsapi:		     NSAPI of the PDP-Context.
> + * @rfm:		     Applies when family = CAIFPROTO_RFM
> + * @rfm.connection_id:       Connection ID for RFM.
> + * @rfm.volume:	     	     Volume to mount.
> + */
> +struct sockaddr_caif {
> +	sa_family_t  family;
> +	union {
> +		struct {
> +			u_int8_t  type;		/* type: enum caif_at_type */
> +		} at;				/* CAIFPROTO_AT */
> +		struct {
> +			char	  service[16];
> +		} util;				/* CAIFPROTO_UTIL */
> +		union {
> +			u_int32_t connection_id;
> +			u_int8_t  nsapi;
> +		} dgm;				/* CAIFPROTO_DATAGRAM(_LOOP)*/
> +		struct {
> +			u_int32_t connection_id;
> +			char	  volume[16];
> +		} rfm;				/* CAIFPROTO_RFM */
> +	} u;
> +};

as mentioned on the oFono mailing list, what is the right procedure to
select a local CAIF device for usage with doing bing(). The use case I
am thinking of is that you have multiple CAIF device attached to the
same system. Think of desktops with USB or even Dual-SIM phones. Before
we set the API in stone, we need to have a way o bind the socket to a
specific device. Maybe it is possible, but I am missing it.

Regards

Marcel


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
sjur.brandeland@stericsson.com Jan. 22, 2010, 8:18 a.m. UTC | #3
Hi Marcel.

Marcel Holtmann wrote:
>> +/**
>> + * struct sockaddr_caif - the sockaddr structure for CAIF sockets.
>> + * @u:			     Union of address data 'switched' by familty.
>> + * @at:			     Applies when family = CAIFPROTO_AT.
>> + * @at.type:		     Type of AT link to set up (enum caif_at_type).
>> + * @util:		     Applies when family = CAIFPROTO_UTIL
>> + * @util.service:	     Service name.
>> + * @dgm:		     Applies when family = CAIFPROTO_DATAGRAM
>> + * @dgm.connection_id:	     Datagram connection id.
>> + * @dgm.nsapi:		     NSAPI of the PDP-Context.
>> + * @rfm:		     Applies when family = CAIFPROTO_RFM
>> + * @rfm.connection_id:       Connection ID for RFM.
>> + * @rfm.volume:	     	     Volume to mount.
>> + */
>> +struct sockaddr_caif {
>> +	sa_family_t  family;
>> +	union {
>> +		struct {
>> +			u_int8_t  type;		/* type: enum caif_at_type */
>> +		} at;				/* CAIFPROTO_AT */
>> +		struct {
>> +			char	  service[16];
>> +		} util;				/* CAIFPROTO_UTIL */
>> +		union {
>> +			u_int32_t connection_id;
>> +			u_int8_t  nsapi;
>> +		} dgm;				/* CAIFPROTO_DATAGRAM(_LOOP)*/
>> +		struct {
>> +			u_int32_t connection_id;
>> +			char	  volume[16];
>> +		} rfm;				/* CAIFPROTO_RFM */
>> +	} u;
>> +};
> 
> as mentioned on the oFono mailing list, what is the right procedure
> to select a local CAIF device for usage with doing bing(). The use
> case I am thinking of is that you have multiple CAIF device attached
> to the same system. Think of desktops with USB or even Dual-SIM
> phones. Before we set the API in stone, we need to have a way o bind
> the socket to a specific device. Maybe it is possible, but I am
> missing it.      

The CAIF interface can be selected by using the following types:
[snip caif_config.h]
/**
 * enum caif_phy_preference  - Types of physical HW interfaces
 *				       towards modem defined in CAIF stack
 * @CAIF_PHYPREF_UNSPECIFIED:	Default physical interface
 * @CAIF_PHYPREF_LOW_LAT:	Default physical interface for low-latency
 *				      traffic
 * @CAIF_PHYPREF_HIGH_BW:	Default physical interface for high-bandwidth
 *				      traffic
 * @CAIF_PHYPREF_LOOP:		TEST Loopback interface, simulating modem
 *				      responses
 *
 * For client convenience, two special types are defined:
 * CAIF_PHYPREF_LOW_LAT is the preferred low-latency physical link.
 * Typically used for "control" purposes.
 * CAIF_PHYPREF_HIGH_BW is the preferred high-bandwidth physical link.
 * Typically used for "payload" purposes.
 */
...
enum caif_phy_preference {
	CAIF_PHYPREF_UNSPECIFIED,
	CAIF_PHYPREF_LOW_LAT,
	CAIF_PHYPREF_HIGH_BW,
	CAIF_PHYPREF_LOOP
};
[snip caif_socket.h]
...
/**
 * struct caif_channel_opt - CAIF channel connect options.
 * @priority:		Priority of the channel (between 0 and 0x1f)
 * @link_selector:	Selector for the physical link.
 *			      (see enum caif_phy_preference in caif_config.h)
 * @link_name:		Physical link to use. This is the instance name of the
 *			      CAIF Physical Driver.
 */
struct caif_channel_opt {
	u_int16_t  priority;
	u_int16_t  link_selector;
	char	   link_name[16];
};
...
/** enum caif_socket_opts - CAIF option values for getsockopt and setsockopt
 * @CAIFSO_CHANNEL:		Used to set the connect options on a CAIF
 *				socket. (struct caif_config_opt). This can only
 *				be set before connecting.
[end snip]

CAIFSO_CHANNEL is used for specifying the physical interface to use for the 
CAIF Channel. You can select the type of interface to use
by setting link_selector:
CAIF_PHYPREF_LOW_LAT will typically be used for AT (or other control traffic),
and CAIF_PHYPREF_HIGH_BW for IP traffic.
When the CAIF interfaces registers itself it will inform about their type,
(low-latency or high-bandwidth). This approach assumes that you have only one
modem, but multiple links to it (e.g. USB and UART). 

But you can also specify interface by name using link_name. In this case
you specify the name of the interface to use. I think this would support
your use case with multiple modems attached.

BR/Sjur
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Holtmann Jan. 22, 2010, 8:39 a.m. UTC | #4
Hi Sjur,

> >> +/**
> >> + * struct sockaddr_caif - the sockaddr structure for CAIF sockets.
> >> + * @u:			     Union of address data 'switched' by familty.
> >> + * @at:			     Applies when family = CAIFPROTO_AT.
> >> + * @at.type:		     Type of AT link to set up (enum caif_at_type).
> >> + * @util:		     Applies when family = CAIFPROTO_UTIL
> >> + * @util.service:	     Service name.
> >> + * @dgm:		     Applies when family = CAIFPROTO_DATAGRAM
> >> + * @dgm.connection_id:	     Datagram connection id.
> >> + * @dgm.nsapi:		     NSAPI of the PDP-Context.
> >> + * @rfm:		     Applies when family = CAIFPROTO_RFM
> >> + * @rfm.connection_id:       Connection ID for RFM.
> >> + * @rfm.volume:	     	     Volume to mount.
> >> + */
> >> +struct sockaddr_caif {
> >> +	sa_family_t  family;
> >> +	union {
> >> +		struct {
> >> +			u_int8_t  type;		/* type: enum caif_at_type */
> >> +		} at;				/* CAIFPROTO_AT */
> >> +		struct {
> >> +			char	  service[16];
> >> +		} util;				/* CAIFPROTO_UTIL */
> >> +		union {
> >> +			u_int32_t connection_id;
> >> +			u_int8_t  nsapi;
> >> +		} dgm;				/* CAIFPROTO_DATAGRAM(_LOOP)*/
> >> +		struct {
> >> +			u_int32_t connection_id;
> >> +			char	  volume[16];
> >> +		} rfm;				/* CAIFPROTO_RFM */
> >> +	} u;
> >> +};
> > 
> > as mentioned on the oFono mailing list, what is the right procedure
> > to select a local CAIF device for usage with doing bing(). The use
> > case I am thinking of is that you have multiple CAIF device attached
> > to the same system. Think of desktops with USB or even Dual-SIM
> > phones. Before we set the API in stone, we need to have a way o bind
> > the socket to a specific device. Maybe it is possible, but I am
> > missing it.      
> 
> The CAIF interface can be selected by using the following types:
> [snip caif_config.h]
> /**
>  * enum caif_phy_preference  - Types of physical HW interfaces
>  *				       towards modem defined in CAIF stack
>  * @CAIF_PHYPREF_UNSPECIFIED:	Default physical interface
>  * @CAIF_PHYPREF_LOW_LAT:	Default physical interface for low-latency
>  *				      traffic
>  * @CAIF_PHYPREF_HIGH_BW:	Default physical interface for high-bandwidth
>  *				      traffic
>  * @CAIF_PHYPREF_LOOP:		TEST Loopback interface, simulating modem
>  *				      responses
>  *
>  * For client convenience, two special types are defined:
>  * CAIF_PHYPREF_LOW_LAT is the preferred low-latency physical link.
>  * Typically used for "control" purposes.
>  * CAIF_PHYPREF_HIGH_BW is the preferred high-bandwidth physical link.
>  * Typically used for "payload" purposes.
>  */
> ...
> enum caif_phy_preference {
> 	CAIF_PHYPREF_UNSPECIFIED,
> 	CAIF_PHYPREF_LOW_LAT,
> 	CAIF_PHYPREF_HIGH_BW,
> 	CAIF_PHYPREF_LOOP
> };
> [snip caif_socket.h]
> ...
> /**
>  * struct caif_channel_opt - CAIF channel connect options.
>  * @priority:		Priority of the channel (between 0 and 0x1f)
>  * @link_selector:	Selector for the physical link.
>  *			      (see enum caif_phy_preference in caif_config.h)
>  * @link_name:		Physical link to use. This is the instance name of the
>  *			      CAIF Physical Driver.
>  */
> struct caif_channel_opt {
> 	u_int16_t  priority;
> 	u_int16_t  link_selector;
> 	char	   link_name[16];
> };
> ...
> /** enum caif_socket_opts - CAIF option values for getsockopt and setsockopt
>  * @CAIFSO_CHANNEL:		Used to set the connect options on a CAIF
>  *				socket. (struct caif_config_opt). This can only
>  *				be set before connecting.
> [end snip]
> 
> CAIFSO_CHANNEL is used for specifying the physical interface to use for the 
> CAIF Channel. You can select the type of interface to use
> by setting link_selector:
> CAIF_PHYPREF_LOW_LAT will typically be used for AT (or other control traffic),
> and CAIF_PHYPREF_HIGH_BW for IP traffic.
> When the CAIF interfaces registers itself it will inform about their type,
> (low-latency or high-bandwidth). This approach assumes that you have only one
> modem, but multiple links to it (e.g. USB and UART). 
> 
> But you can also specify interface by name using link_name. In this case
> you specify the name of the interface to use. I think this would support
> your use case with multiple modems attached.

sounds good, but why using a socket option and not allowing to just use
bind(). Maybe it is just my personal preference, because I am used to do
it like this for TCP and Bluetooth.

Regards

Marcel


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
sjur.brandeland@stericsson.com Jan. 22, 2010, 8:56 a.m. UTC | #5
Marcel Holtmann wrote:
>> ...
>> CAIFSO_CHANNEL is used for specifying the physical interface to use
>> for the CAIF Channel. You can select the type of interface to use by
>> setting link_selector: CAIF_PHYPREF_LOW_LAT will typically be used
>> for AT (or other control traffic), and CAIF_PHYPREF_HIGH_BW for IP
>> traffic. 
>> When the CAIF interfaces registers itself it will inform about their
>> type, (low-latency or high-bandwidth). This approach assumes that you
>> have only one modem, but multiple links to it (e.g. USB and UART).
>> 
>> But you can also specify interface by name using link_name. In this
>> case you specify the name of the interface to use. I think this would
>> support your use case with multiple modems attached.
> 
> sounds good, but why using a socket option and not allowing to just
> use bind(). Maybe it is just my personal preference, because I am
> used to do it like this for TCP and Bluetooth.  

We actually considered this when designing the interface,
but I don't feel bind() fits in this case. bind() would normally bind
an address to the client socket. An interface did not seem
like a client socket address to us, so we decided to use sockopt instead.
Conceptually I don't think CAIF has a client address at all, it only
connects to a server side address.

BR/Sjur

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Holtmann Jan. 22, 2010, 9:16 a.m. UTC | #6
Hi Sjur,

> >> CAIFSO_CHANNEL is used for specifying the physical interface to use
> >> for the CAIF Channel. You can select the type of interface to use by
> >> setting link_selector: CAIF_PHYPREF_LOW_LAT will typically be used
> >> for AT (or other control traffic), and CAIF_PHYPREF_HIGH_BW for IP
> >> traffic. 
> >> When the CAIF interfaces registers itself it will inform about their
> >> type, (low-latency or high-bandwidth). This approach assumes that you
> >> have only one modem, but multiple links to it (e.g. USB and UART).
> >> 
> >> But you can also specify interface by name using link_name. In this
> >> case you specify the name of the interface to use. I think this would
> >> support your use case with multiple modems attached.
> > 
> > sounds good, but why using a socket option and not allowing to just
> > use bind(). Maybe it is just my personal preference, because I am
> > used to do it like this for TCP and Bluetooth.  
> 
> We actually considered this when designing the interface,
> but I don't feel bind() fits in this case. bind() would normally bind
> an address to the client socket. An interface did not seem
> like a client socket address to us, so we decided to use sockopt instead.
> Conceptually I don't think CAIF has a client address at all, it only
> connects to a server side address.

seems fair enough to me. My personal preference would just be bind, but
I can follow your argumentation. I just wanted to make sure that we have
that option before setting CAIF socket address in stone.

Any reason why not just supporting SO_PRIORITY and SO_BINDTODEVICE on
CAIF sockets then?

Regards

Marcel


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
sjur.brandeland@stericsson.com Jan. 22, 2010, 9:43 a.m. UTC | #7
Marcel Holtmann wrote:
> Hi Sjur,
> 
>>>> CAIFSO_CHANNEL is used for specifying the physical interface to use
>>>> for the CAIF Channel. You can select the type of interface to use
>>>> by setting link_selector: CAIF_PHYPREF_LOW_LAT will typically be
>>>> used for AT (or other control traffic), and CAIF_PHYPREF_HIGH_BW
>>>> for IP traffic.
>>>> When the CAIF interfaces registers itself it will inform about
>>>> their type, (low-latency or high-bandwidth). This approach assumes
>>>> that you have only one modem, but multiple links to it (e.g. USB
>>>> and UART). 
>>>> 
>>>> But you can also specify interface by name using link_name. In this
>>>> case you specify the name of the interface to use. I think this
>>>> would support your use case with multiple modems attached.
>>> 
>>> sounds good, but why using a socket option and not allowing to just
>>> use bind(). Maybe it is just my personal preference, because I am
>>> used to do it like this for TCP and Bluetooth.
>> 
>> We actually considered this when designing the interface, but I don't
>> feel bind() fits in this case. bind() would normally bind an address
>> to the client socket. An interface did not seem like a client socket
>> address to us, so we decided to use sockopt instead.
>> Conceptually I don't think CAIF has a client address at all, it only
>> connects to a server side address.
> 
> seems fair enough to me. My personal preference would just be bind,
> but I can follow your argumentation. I just wanted to make sure that
> we have that option before setting CAIF socket address in stone.  
> 
> Any reason why not just supporting SO_PRIORITY and SO_BINDTODEVICE on
> CAIF sockets then? 

Sounds like a good idea, I'll definitely look into that, thanks.

BR/Sjur
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
sjur.brandeland@stericsson.com Jan. 22, 2010, 10:53 a.m. UTC | #8
Hi Patrick.

Patrick McHardy wrote:
> sjur.brandeland@stericsson.com wrote:
>> +/**
>> + * enum ifla_caif
>> + * When using RT Netlink to create, destroy or configure a CAIF IP
>> +interface, + * enum ifla_caif is used to specify the configuration
>> attributes. + * + * @IFLA_CAIF_IPV4_CONNID:  Connection ID for IPv4
>> PDP Context. + *			    The type of attribute is NLA_U32.
>> + * @IFLA_CAIF_IPV6_CONNID:  Connection ID for IPv6 PDP Context.
>> + *			    The type of attribute is NLA_U32.
>> + * @IFLA_CAIF_LOOPBACK:	    If different from zero, device is doing
>> loopback + *			    The type of attribute is NLA_U8.
>> + */
>> +enum ifla_caif {
>> +	IFLA_CAIF_IPV4_CONNID,
>> +	IFLA_CAIF_IPV6_CONNID,
>> +	IFLA_CAIF_LOOPBACK,
>> +	__IFLA_CAIF_MAX
>> +};
>> +#define	IFLA_CAIF_MAX (__IFLA_CAIF_MAX-1)
>> +
>> +#endif /*IF_CAIF_H_*/
> 
> You should add an IFLA_CAIF_UNSPEC at the beginning, some of the
> nlattr helpers skip attributes with a value of zero. 

OK, thanks. I'll fix this in the next patch set.

BR/Sjur
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/caif/caif_config.h b/include/linux/caif/caif_config.h
new file mode 100644
index 0000000..5de8bd2
--- /dev/null
+++ b/include/linux/caif/caif_config.h
@@ -0,0 +1,155 @@ 
+/*
+ * CAIF Channel Configuration definitions.
+ * Copyright (C) ST-Ericsson AB 2010
+ * Author:	Sjur Brendeland/ sjur.brandeland@stericsson.com
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#ifndef CAIF_CONFIG_H_
+#define CAIF_CONFIG_H_
+
+/**
+ * enum caif_phy_preference  -	Types of physical HW interfaces
+ *				towards modem defined in CAIF stack
+ * @CAIF_PHYPREF_UNSPECIFIED:	Default physical interface
+ * @CAIF_PHYPREF_LOW_LAT:	Default physical interface for low-latency
+ *				traffic
+ * @CAIF_PHYPREF_HIGH_BW:	Default physical interface for high-bandwidth
+ *				traffic
+ * @CAIF_PHYPREF_LOOP:		TEST Loopback interface, simulating modem
+ *				responses
+ *
+ * For client convenience, two special types are defined:
+ * CAIF_PHYPREF_LOW_LAT is the preferred low-latency physical link.
+ * Typically used for "control" purposes.
+ * CAIF_PHYPREF_HIGH_BW is the preferred high-bandwidth physical link.
+ * Typically used for "payload" purposes.
+ */
+enum caif_phy_preference {
+	CAIF_PHYPREF_UNSPECIFIED,
+	CAIF_PHYPREF_LOW_LAT,
+	CAIF_PHYPREF_HIGH_BW,
+	CAIF_PHYPREF_LOOP
+};
+
+/*
+ * Define CAIF channel priority.
+ * Used when setting up a channel to specify the
+ * priority level of the channel.
+ */
+#define CAIF_PRIO_MIN	       0x01	/* Min priority for a channel */
+#define CAIF_PRIO_LOW	       0x04	/* low-priority channel. */
+#define CAIF_PRIO_NORMAL       0x0f	/* normal/default priority level. */
+#define CAIF_PRIO_HIGH	       0x14	/* high priority level */
+#define CAIF_PRIO_MAX	       0x1F	/* Max priority for channel */
+
+
+/**
+ * enum caif_channel_type - Types of CAIF channel type defined in CAIF Stack.
+ * @CAIF_CHTY_AT:		Classical AT
+ * @CAIF_CHTY_AT_CTRL:		AT control only
+ * @CAIF_CHTY_AT_PAIRED:	Paired control and data
+ * @CAIF_CHTY_DATAGRAM:		Datagram. Requires: connection_id
+ * @CAIF_CHTY_DATAGRAM_LOOP:	Datagram loopback (testing purposes only)
+ * @CAIF_CHTY_VIDEO:		Video channel
+ * @CAIF_CHTY_DEBUG:		Debug service (Debug server and
+ *					       interactive debug)
+ * @CAIF_CHTY_DEBUG_TRACE:	Debug server only
+ * @CAIF_CHTY_DEBUG_INTERACT:	Debug interactive
+ * @CAIF_CHTY_RFM:		RFM service. Params: connection_id, volume
+ * @CAIF_CHTY_UTILITY:		Utility (Psock) service.
+ *				Params: fifo_kb,fifo_pkt, name, psock_param
+ *
+ * This is used for channel configuration, specifying the type of channel.
+ */
+enum caif_channel_type {
+	CAIF_CHTY_AT,
+	CAIF_CHTY_AT_CTRL,
+	CAIF_CHTY_AT_PAIRED,
+	CAIF_CHTY_DATAGRAM,
+	CAIF_CHTY_DATAGRAM_LOOP,
+	CAIF_CHTY_VIDEO,
+	CAIF_CHTY_DEBUG,
+	CAIF_CHTY_DEBUG_TRACE,
+	CAIF_CHTY_DEBUG_INTERACT,
+	CAIF_CHTY_RFM,
+	CAIF_CHTY_UTILITY
+};
+
+/**
+ *struct caif_channel_config - This structure is used for configuring
+ *			     CAIF channels.
+ * @name:		     Mandatory - Nickname for this device
+ * @type:		     Mandatory - Define the type of caif service
+ * @priority:		     Mandatory - Value between	CAIF_PRIO_MIN and
+ *			     CAIF_PRIO_MAX.
+ *			     CAIF_PRIO_LOW, CAIF_PRIO_NORMAL, CAIF_PRIO_HIGH
+ *			     are suggested values.
+ * @phy_pref:		     Either: Specify type of physical interface to use.
+ * @phy_name:		     Or: Specify identity of the physical interface.
+ *
+ * @u:			     Union of channel type-specific configuration
+ *			     parameters
+ *
+ * @u.dgm:		     CAIF_CHTYPE_DATAGRAM
+ * @u.dgm.connection_id:     Mandatory - Connection ID must be specified.
+ *
+ * @u.video:		     CAIF_CHTYPE_VIDEO
+ * @u.video.connection_id:   Mandatory - Connection ID must be specified.
+ *
+ * @u.rfm		     CAIF_CHTYPE_RFM
+ * @u.rfm.connection_id:     Mandatory - Connection ID must be specified.
+ * @u.rfm.volume:	     Mandatory - Volume to mount.
+ *
+ * @u.utility:		     CAIF_CHTYPE_UTILITY
+ * @u.utility.fifosize_kb:   Psock: FIFO size in KB
+ * @u.utility.fifosize_bufs: Psock: Number of signal buffers
+ * @u.utility.name:	     Psock: Name of service
+ * @u.utility.params:	     Psock: Channel config parameters
+ * @u.utility.paramlen:	     Psock: Length of channel config parameters
+ *
+ *
+ * It holds configuration parameters for setting up all defined CAIF
+ * channel types.
+ * The four first fields are mandatory, then physical interface can be specified
+ * either by name or by prefered characteristics.
+ * The rest of the configuration fields are held in a union for each
+ * channel type and are channel type specific.
+ */
+struct caif_channel_config {
+	char name[16];
+	enum caif_channel_type type;
+	unsigned priority;
+	enum caif_phy_preference phy_pref;
+	char phy_name[16];
+
+	/** Union of channel type-specific configuration parameters.
+	 * 'switched' by attribute type.
+	 */
+	union {
+		/* CAIF_CHTYPE_DATAGRAM */
+		struct {
+			unsigned connection_id;
+		} dgm;
+		/* CAIF_CHTYPE_VIDEO */
+		struct {
+			unsigned connection_id;
+		} video;
+		/* CAIF_CHTYPE_RFM */
+		struct {
+			unsigned connection_id;
+			char volume[20];
+		} rfm;
+		/* CAIF_CHTYPE_UTILITY */
+		struct {
+			unsigned fifosize_kb;
+			unsigned fifosize_bufs;
+			char name[16];
+			unsigned char params[256];
+			int paramlen;
+		} utility;
+
+	} u;
+};
+
+#endif				/* CAIF_CONFIG_H_ */
diff --git a/include/linux/caif/caif_socket.h b/include/linux/caif/caif_socket.h
new file mode 100644
index 0000000..44774e8
--- /dev/null
+++ b/include/linux/caif/caif_socket.h
@@ -0,0 +1,161 @@ 
+/* linux/caif_socket.h
+ * CAIF Definitions for CAIF socket and network layer
+ * Copyright (C) ST-Ericsson AB 2010
+ * Author:	 Sjur Brendeland/ sjur.brandeland@stericsson.com
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#ifndef _LINUX_CAIF_SOCKET_H
+#define _LINUX_CAIF_SOCKET_H
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/socket.h>
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * enum caif_link_selector -   Physical Link Selection.
+ * @CAIF_LINK_HIGH_BANDW:	Default physical interface for high-bandwidth
+ *				traffic.
+ * @CAIF_LINK_LOW_LATENCY:	Default physical interface for low-latency
+ *				traffic.
+ */
+enum caif_link_selector {
+	CAIF_LINK_HIGH_BANDW,
+	CAIF_LINK_LOW_LATENCY
+};
+
+/**
+ * enum caif_protocol_type  -	Types of CAIF protocols in the CAIF Stack.
+ * @CAIFPROTO_AT:		Classic AT channel.
+ * @CAIFPROTO_DATAGRAM:		Datagram channel.
+ * @CAIFPROTO_DATAGRAM_LOOP:	Datagram loopback channel, used for testing.
+ * @CAIFPROTO_UTIL:		Utility (Psock) channel.
+ * @CAIFPROTO_RFM:		Remote File Manager
+ */
+enum caif_protocol_type {
+	CAIFPROTO_AT,
+	CAIFPROTO_DATAGRAM,
+	CAIFPROTO_DATAGRAM_LOOP,
+	CAIFPROTO_UTIL,
+	CAIFPROTO_RFM,
+	_CAIFPROTO_MAX
+};
+#define	CAIFPROTO_MAX _CAIFPROTO_MAX
+
+/**
+ * enum caif_at_type - AT Service Endpoint
+ * @CAIF_ATTYPE_PLAIN:	     Connects to a plain vanilla AT channel.
+ */
+enum caif_at_type {
+	CAIF_ATTYPE_PLAIN
+};
+
+/**
+ * struct sockaddr_caif - the sockaddr structure for CAIF sockets.
+ * @u:			     Union of address data 'switched' by familty.
+ * @at:			     Applies when family = CAIFPROTO_AT.
+ * @at.type:		     Type of AT link to set up (enum caif_at_type).
+ * @util:		     Applies when family = CAIFPROTO_UTIL
+ * @util.service:	     Service name.
+ * @dgm:		     Applies when family = CAIFPROTO_DATAGRAM
+ * @dgm.connection_id:	     Datagram connection id.
+ * @dgm.nsapi:		     NSAPI of the PDP-Context.
+ * @rfm:		     Applies when family = CAIFPROTO_RFM
+ * @rfm.connection_id:       Connection ID for RFM.
+ * @rfm.volume:	     	     Volume to mount.
+ */
+struct sockaddr_caif {
+	sa_family_t  family;
+	union {
+		struct {
+			u_int8_t  type;		/* type: enum caif_at_type */
+		} at;				/* CAIFPROTO_AT */
+		struct {
+			char	  service[16];
+		} util;				/* CAIFPROTO_UTIL */
+		union {
+			u_int32_t connection_id;
+			u_int8_t  nsapi;
+		} dgm;				/* CAIFPROTO_DATAGRAM(_LOOP)*/
+		struct {
+			u_int32_t connection_id;
+			char	  volume[16];
+		} rfm;				/* CAIFPROTO_RFM */
+	} u;
+};
+
+/**
+ * struct caif_channel_opt - CAIF channel connect options.
+ * @priority:		Priority of the channel (between 0 and 0x1f)
+ * @link_selector:	Selector for the physical link.
+ *			(see enum caif_phy_preference in caif_config.h)
+ * @link_name:		Physical link to use. This is the instance name of the
+ *			CAIF Physical Driver.
+ */
+struct caif_channel_opt {
+	u_int16_t  priority;
+	u_int16_t  link_selector;
+	char	   link_name[16];
+};
+
+/**
+ * struct caif_param - CAIF parameters.
+ * @size:	Length of data
+ * @data:	Binary Data Blob
+ */
+struct caif_param {
+	u_int16_t  size;
+	u_int8_t   data[256];
+};
+
+
+/** enum caif_socket_opts - CAIF option values for getsockopt and setsockopt
+ * @CAIFSO_CHANNEL:		Used to set the connect options on a CAIF
+ *				socket. (struct caif_config_opt). This can only
+ *				be set before connecting.
+ * @CAIFSO_REQ_PARAM:		Used to set the request parameters for a
+ *				utility channel. (struct caif_param). This
+ *				can only be set before connecting.
+ *
+ * @CAIFSO_RSP_PARAM:		Gets the request parameters for a utility
+ *				channel. (struct caif_param). This can only be
+ *				fetched after connecting the socket.
+ *
+ * @CAIFSO_UTIL_FLOW:		Sets the utility channels flow options.
+ *				This can only be set before connecting.
+ *				(struct caif_util_modem_flow_opt)
+ *
+ * @CAIFSO_CONN_ID:		Gets the channel id on a CAIF Channel.
+ *				This can only be done after connect.
+ *				( u_int32_t)
+ *
+ * @CAIFSO_NEXT_PAKCET_LEN:	Gets the size of next received packet.
+ *				Value is 0 if no packet is available.
+ *				This can only be done after connect.
+ *				( u_int32_t)
+ *
+ * @CAIFSO_MAX_PAKCET_LEN:	Gets the maximum packet size for this
+ *				connection. ( u_int32_t)
+ */
+enum caif_socket_opts {
+	CAIFSO_CHANNEL_CONFIG	= 127,
+	CAIFSO_REQ_PARAM	= 128,
+	CAIFSO_RSP_PARAM	= 129,
+	CAIFSO_UTIL_FLOW	= 130,
+	CAIFSO_CONN_ID		= 131,
+	CAIFSO_NEXT_PACKET_LEN	= 132,
+	CAIFSO_MAX_PACKET_LEN	= 133,
+};
+
+#ifdef __cplusplus
+}				/* extern "C" */
+#endif
+#endif /* _LINUX_CAIF_SOCKET_H */
diff --git a/include/linux/caif/if_caif.h b/include/linux/caif/if_caif.h
new file mode 100644
index 0000000..e1991b1
--- /dev/null
+++ b/include/linux/caif/if_caif.h
@@ -0,0 +1,71 @@ 
+/*
+ * Copyright (C) ST-Ericsson AB 2010
+ * Author:	Sjur Brendeland/ sjur.brandeland@stericsson.com
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#ifndef IF_CAIF_H_
+#define IF_CAIF_H_
+#include <linux/sockios.h>
+#include <linux/types.h>
+#include <linux/socket.h>
+
+/**
+ * enum sioc_caif -	SOCKIO for creating new CAIF Net Devices.
+ * @SIOCCAIFNETNEW:	Used to create a new instance of the CAIF IP Interface.
+ *			struct ifreq containing struct ifcaif_param are used
+ *			as parameters. ifr_name must be filled in.
+ * @SIOCCAIFNETCHANGE:	As above, but changes a disconnected CAIF IP Inteface.
+ * @SIOCCAIFNETREMOVE:	Removes a CAIF IP Interface.
+ *
+ * CAIF IP Interface can be created, changed and deleted,
+ * by this enum. In addition standard Socket IO Controls (SIGIOC*)
+ * can be used to manage standard IP Interface parameters.
+ * The struct ifreq are used to carry parameters.
+ */
+enum sioc_caif {
+	SIOCCAIFNETNEW = SIOCPROTOPRIVATE,
+	SIOCCAIFNETCHANGE,
+	SIOCCAIFNETREMOVE
+};
+
+
+/**
+ * struct ifcaif_param - Parameters for creating CAIF Network Interface.
+ *
+ * When using SIOCCAIFNETNEW to create a CAIF IP interface, this structure
+ * is used for configuration data.
+ * The attribute ifr_ifru.ifru_data in struct struct ifreq must be set
+ * point at an instance of struct ifcaif_param.
+ *
+ * @ipv4_connid:  Connection ID for IPv4 PDP Context.
+ * @ipv6_connid:  Connection ID for IPv6 PDP Context.
+ * @loop:	  If different from zero, device is doing loopback
+ */
+struct ifcaif_param {
+	__u32			ipv4_connid;
+	__u32			ipv6_connid;
+	__u8			loop;
+};
+
+/**
+ * enum ifla_caif
+ * When using RT Netlink to create, destroy or configure a CAIF IP interface,
+ * enum ifla_caif is used to specify the configuration attributes.
+ *
+ * @IFLA_CAIF_IPV4_CONNID:  Connection ID for IPv4 PDP Context.
+ *			    The type of attribute is NLA_U32.
+ * @IFLA_CAIF_IPV6_CONNID:  Connection ID for IPv6 PDP Context.
+ *			    The type of attribute is NLA_U32.
+ * @IFLA_CAIF_LOOPBACK:	    If different from zero, device is doing loopback
+ *			    The type of attribute is NLA_U8.
+ */
+enum ifla_caif {
+	IFLA_CAIF_IPV4_CONNID,
+	IFLA_CAIF_IPV6_CONNID,
+	IFLA_CAIF_LOOPBACK,
+	__IFLA_CAIF_MAX
+};
+#define	IFLA_CAIF_MAX (__IFLA_CAIF_MAX-1)
+
+#endif /*IF_CAIF_H_*/