aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKim Lilliestierna XX <kim.xx.lilliestierna@stericsson.com>2010-05-10 14:15:21 +0200
committerJohn Rigby <john.rigby@linaro.org>2010-09-02 22:45:24 -0600
commitd1f6f0d7ed9629237ed73783f5f34a18c4f5c714 (patch)
tree0e02cdfe2a835350e74f51d9e26a62e01dec35fa /include
parent1f63c78f8a3cf5d00d8dd6701103d51d6a00d883 (diff)
CAIF: Changes to core include files
Change-Id: I9cf8c6948ebecf1e2f6cfb498581bfef2536cefd
Diffstat (limited to 'include')
-rw-r--r--include/net/caif/caif_actions.h6
-rw-r--r--include/net/caif/caif_chr.h16
-rw-r--r--include/net/caif/caif_dev.h109
-rw-r--r--include/net/caif/caif_device.h39
-rw-r--r--include/net/caif/caif_kernel.h340
-rw-r--r--include/net/caif/caif_shm.h4
-rw-r--r--include/net/caif/caif_spi.h78
-rw-r--r--include/net/caif/cfglue.h110
-rw-r--r--include/net/caif/cflst.h19
9 files changed, 370 insertions, 351 deletions
diff --git a/include/net/caif/caif_actions.h b/include/net/caif/caif_actions.h
index 538fbce9de3..27d357e6300 100644
--- a/include/net/caif/caif_actions.h
+++ b/include/net/caif/caif_actions.h
@@ -1,6 +1,6 @@
/*
- * Copyright (C) ST-Ericsson AB 2009
- * Author: Daniel Martensson / Daniel.Martensson@stericsson.com
+ * Copyright (C) ST-Ericsson AB 2010
+ * Author: Sjur Brendeland / sjur.brandeland@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
@@ -16,7 +16,7 @@
#define CAIF_ACT_CREATE_DEVICE 7
/*
- * Remove a CAIF device. Requires the device to be previously disconnected.
+ * Remove a CAIF device. Requires the device to be previously disconnected.
* Type is struct caif_device_name)
*/
#define CAIF_ACT_DELETE_DEVICE 8
diff --git a/include/net/caif/caif_chr.h b/include/net/caif/caif_chr.h
index 81dcea190c9..9c371969eae 100644
--- a/include/net/caif/caif_chr.h
+++ b/include/net/caif/caif_chr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) ST-Ericsson AB 2009
+ * Copyright (C) ST-Ericsson AB 2010
* Author: Daniel Martensson / Daniel.Martensson@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
@@ -7,8 +7,8 @@
#ifndef CAIF_CHR_H_
#define CAIF_CHR_H_
-#include <net/caif/generic/caif_layer.h>
-#include <net/caif/generic/cfcnfg.h>
+#include <net/caif/caif_layer.h>
+#include <net/caif/cfcnfg.h>
#include <linux/caif/caif_config.h>
#include <linux/if.h>
#include <net/caif/caif_actions.h>
@@ -174,19 +174,19 @@ struct caif_packet_funcs {
struct cfpkt *(*cfpkt_dequeue)(struct cfpktq *pktq);
/* Get length of a packet */
- uint16(*cfpkt_getlen)(struct cfpkt *pkt);
+ u16(*cfpkt_getlen)(struct cfpkt *pkt);
};
struct caif_service_config;
extern int (*netdev_mgmt_func) (int action, union caif_action *param);
-int caifdev_phy_register(struct layer *phyif, enum cfcnfg_phy_type phy_type,
+int caifdev_phy_register(struct cflayer *phyif, enum cfcnfg_phy_type phy_type,
enum cfcnfg_phy_preference phy_pref,
bool fcs, bool stx);
-int caifdev_phy_unregister(struct layer *phyif);
-int caifdev_phy_loop_register(struct layer *phyif,
+int caifdev_phy_unregister(struct cflayer *phyif);
+int caifdev_phy_loop_register(struct cflayer *phyif,
enum cfcnfg_phy_type phy_type,
bool fcs, bool stx);
int caif_register_chrdev(int (*chrdev_mgmt)
@@ -196,6 +196,8 @@ struct caif_packet_funcs cfcnfg_get_packet_funcs(void);
struct net_device *chnl_net_create(char *name,
struct caif_channel_config *config);
struct caif_packet_funcs caif_get_packet_funcs(void);
+int add_adaptation_layer(struct caif_channel_config *config,
+ struct cflayer *adap_layer);
#endif /* CAIF_CHR_H_ */
diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h
index 7f2c28e6afa..24d734774e6 100644
--- a/include/net/caif/caif_dev.h
+++ b/include/net/caif/caif_dev.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) ST-Ericsson AB 2009
+ * Copyright (C) ST-Ericsson AB 2010
* Author: Sjur Brendeland/ sjur.brandeland@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
@@ -7,23 +7,108 @@
#ifndef CAIF_DEV_H_
#define CAIF_DEV_H_
-#include <net/caif/generic/caif_layer.h>
-#include <net/caif/generic/cfcnfg.h>
-#include <linux/caif/caif_config.h>
+#include <net/caif/caif_layer.h>
+#include <net/caif/cfcnfg.h>
+#include <linux/caif/caif_socket.h>
#include <linux/if.h>
-struct caif_service_config;
-int caifdev_adapt_register(struct caif_channel_config *config,
- struct layer *adap_layer);
-int caifdev_adapt_unregister(struct layer *adap_layer);
+/**
+ * struct caif_param - CAIF parameters.
+ * @size: Length of data
+ * @data: Binary Data Blob
+ */
+struct caif_param {
+ u16 size;
+ u8 data[256];
+};
+
+/**
+ * struct caif_connect_request - Request data for CAIF channel setup.
+ * @protocol: Type of CAIF protocol to use (at, datagram etc)
+ * @sockaddr: Socket address to connect.
+ * @priority: Priority of the connection.
+ * @link_selector: Link selector (high bandwidth or low latency)
+ * @link_name: Name of the CAIF Link Layer to use.
+ * @param: Connect Request parameters (CAIF_SO_REQ_PARAM).
+ *
+ * This struct is used when connecting a CAIF channel.
+ * It contains all CAIF channel configuration options.
+ */
+struct caif_connect_request {
+ enum caif_protocol_type protocol;
+ struct sockaddr_caif sockaddr;
+ enum caif_channel_priority priority;
+ enum caif_link_selector link_selector;
+ char link_name[16];
+ struct caif_param param;
+};
+
+/**
+ * caif_connect_client - Connect a client to CAIF Core Stack.
+ * @config: Channel setup parameters, specifying what address
+ * to connect on the Modem.
+ * @client_layer: User implementation of client layer. This layer
+ * MUST have receive and control callback functions
+ * implemented.
+ *
+ * This function connects a CAIF channel. The Client must implement
+ * the struct cflayer. This layer represents the Client layer and holds
+ * receive functions and control callback functions. Control callback
+ * function will receive information about connect/disconnect responses,
+ * flow control etc (see enum caif_control).
+ * E.g. CAIF Socket will call this function for each socket it connects
+ * and have one client_layer instance for each socket.
+ */
+int caif_connect_client(struct caif_connect_request *config,
+ struct cflayer *client_layer);
+
+/**
+ * caif_disconnect_client - Disconnects a client from the CAIF stack.
+ *
+ * @client_layer: Client layer to be removed.
+ */
+int caif_disconnect_client(struct cflayer *client_layer);
+
+/**
+ * caif_release_client - Release adaptation layer reference to client.
+ *
+ * @client_layer: Client layer.
+ *
+ * Releases a client/adaptation layer use of the caif stack.
+ * This function must be used after caif_disconnect_client to
+ * decrease the reference count of the service layer.
+ */
+void caif_release_client(struct cflayer *client_layer);
+
+/**
+ * connect_req_to_link_param - Translate configuration parameters
+ * from socket format to internal format.
+ * @cnfg: Pointer to configuration handler
+ * @con_req: Configuration parameters supplied in function
+ * caif_connect_client
+ * @channel_setup_param: Parameters supplied to the CAIF Core stack for
+ * setting up channels.
+ *
+ */
+int connect_req_to_link_param(struct cfcnfg *cnfg,
+ struct caif_connect_request *con_req,
+ struct cfctrl_link_param *channel_setup_param);
+
+/**
+ * get_caif_conf() - Get the configuration handler.
+ */
struct cfcnfg *get_caif_conf(void);
+
+//deprecated-functionality-below
+#include <net/caif/caif_chr.h>
+int
+channel_config_2_link_param(struct cfcnfg *cnfg,
+ struct caif_channel_config *s, struct cfctrl_link_param *l);
+
void caif_register_ioctl(int (*ioctl)(unsigned int cmd,
unsigned long arg,
bool));
int caif_ioctl(unsigned int cmd, unsigned long arg, bool from_use_land);
-void caif_unregister_netdev(void);
-int channel_config_2_link_param(struct cfcnfg *cnfg,
- struct caif_channel_config *s,
- struct cfctrl_link_param *l);
+//deprecated-functionality-above
#endif /* CAIF_DEV_H_ */
diff --git a/include/net/caif/caif_device.h b/include/net/caif/caif_device.h
index 2e0ac689b0d..3cdbce313bc 100644
--- a/include/net/caif/caif_device.h
+++ b/include/net/caif/caif_device.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) ST-Ericsson AB 2009
+ * Copyright (C) ST-Ericsson AB 2010
* Author: Sjur Brendeland/ sjur.brandeland@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
@@ -12,7 +12,7 @@
#include <linux/caif/caif_socket.h>
#include <net/caif/caif_device.h>
-//official-kernel-patch-cut-here
+//deprecated-functionality-below
/* FIXME: Remove ETH_P_CAIF when included in include/linux/if_ether.h */
#ifndef ETH_P_CAIF
#define ETH_P_CAIF 0x00F7 // ST-Ericsson CAIF protocol
@@ -21,18 +21,40 @@
#ifndef ARPHRD_CAIF
#define ARPHRD_CAIF 822 // CAIF media type
#endif /* ARPHRD_CAIF */
-//official-kernel-patch-resume-here
+//deprecated-functionality-above
/**
- * struct caif_dev_common - shared between CAIF drivers and stack .
- * @flowctrl: Flow Control callback function.
- * @link_select: Indicate bandwidth and latency of device.
- * @use_frag: CAIF Frames may be framented.
+ * struct caif_dev_common - data shared between CAIF drivers and stack.
+ * @flowctrl: Flow Control callback function. This function is
+ * supplied by CAIF Core Stack and is used by CAIF
+ * Link Layer to send flow-stop to CAIF Core.
+ * The flow information will be distributed to all
+ * clients of CAIF.
+ *
+ * @link_select: Profile of device, either high-bandwidth or
+ * low-latency. This member is set by CAIF Link
+ * Layer Device in order to indicate if this device
+ * is a high bandwidth or low latency device.
+ *
+ * @use_frag: CAIF Frames may be fragmented.
+ * Is set by CAIF Link Layer in order to indicate if the
+ * interface receives fragmented frames that must be
+ * assembled by CAIF Core Layer.
+ *
* @use_fcs: Indicate if Frame CheckSum (fcs) is used.
+ * Is set if the physical interface is
+ * using Frame Checksum on the CAIF Frames.
+ *
* @use_stx: Indicate STart of frame eXtension (stx) in use.
+ * Is set if the CAIF Link Layer expects
+ * CAIF Frames to start with the STX byte.
*
* This structure is shared between the CAIF drivers and the CAIF stack.
+ * It is used by the device to register its behavior.
+ * CAIF Core layer must set the member flowctrl in order to supply
+ * CAIF Link Layer with the flow control function.
+ *
*/
-struct caif_dev_common {
+ struct caif_dev_common {
void (*flowctrl)(struct net_device *net, int on);
enum caif_link_selector link_select;
int use_frag;
@@ -41,4 +63,3 @@ struct caif_dev_common {
};
#endif /* CAIF_DEVICE_H_ */
-
diff --git a/include/net/caif/caif_kernel.h b/include/net/caif/caif_kernel.h
index 96cbec7e5bc..67feaa00414 100644
--- a/include/net/caif/caif_kernel.h
+++ b/include/net/caif/caif_kernel.h
@@ -1,7 +1,7 @@
/*
* CAIF Kernel Internal interface for configuring and accessing
* CAIF Channels.
- * Copyright (C) ST-Ericsson AB 2009
+ * Copyright (C) ST-Ericsson AB 2010
* Author: Sjur Brendeland/ sjur.brandeland@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
@@ -11,30 +11,27 @@
#include <linux/caif/caif_config.h>
struct sk_buff;
-/*!\page caif_kernel.h
+/*
* This is the specification of the CAIF kernel internal interface to
* CAIF Channels.
* This interface follows the pattern used in Linux device drivers with a
- * struct \ref caif_device
+ * struct caif_device
* holding control data handling each device instance.
*
* The functional interface consists of a few basic functions:
- * - \ref caif_add_device Configure and connect the CAIF
- * channel to the remote end. Configuration is described in
- * \ref caif_channel_config.
- * - \ref caif_remove_device Disconnect and remove the channel.
- * - \ref caif_transmit Sends a CAIF message on the link.
- * - \ref caif_device.receive_cb Receive callback function for
- * receiving packets.
- * - \ref caif_device.control_cb Control information from the CAIF stack.
- * - \ref caif_flow_control Send flow control message to remote end.
- *
+ * - caif_add_device Configure and connect the CAIF
+ * channel to the remote end. Configuration is
+ * described in caif_channel_config.
+ * - caif_remove_device Disconnect and remove the channel.
+ * - caif_transmit Sends a CAIF message on the link.
+ * - caif_device.receive_cb Receive callback function for
+ * receiving packets.
+ * - caif_device.control_cb Control information from the CAIF stack.
+ * - caif_flow_control Send flow control message to remote end.
*
- * Details:
- * \see { caif_kernel }
- *
- * \code
*
+ * EXAMPLE:
+
#include <net/caif/caif_kernel.h>"
static void my_receive(struct caif_device *dev, struct sk_buff *skb)
@@ -85,225 +82,228 @@ struct sk_buff;
}
-* \endcode
-*
-* \section Linux Socket Buffer (SKB)
- * When sending out packets on a connection (\ref caif_transmit)
- * the CAIF stack will add CAIF protocol headers.
- * This requires space in the SKB.
- * CAIF has defined \ref CAIF_SKB_HEAD_RESERVE for minimum
- * required reserved head-space in the packet and
- * \ref CAIF_SKB_TAIL_RESERVE for minimum reserved tail-space.
- *
- * \b NOTE The Linux kernel SKB operations panic if not
- * enough space is available!
- *
- */
+ *
+ * Linux Socket Buffer (SKB)
+ * When sending out packets on a connection ( caif_transmit)
+ * the CAIF stack will add CAIF protocol headers.
+ * This requires space in the SKB.
+ * CAIF has defined CAIF_SKB_HEAD_RESERVE for minimum
+ * required reserved head-space in the packet and
+ * CAIF_SKB_TAIL_RESERVE for minimum reserved tail-space.
+ *
+ *
+ */
- /*! \addtogroup caif_kernel
- * @{
- */
struct caif_device;
- /** Minimum required CAIF socket buffer head-space */
+/*
+ * CAIF_SKB_HEAD_RESERVE - Minimum required CAIF socket buffer head-space.
+ */
#define CAIF_SKB_HEAD_RESERVE 32
- /** Minimum required CAIF socket buffer tail-space */
+/*
+ * CAIF_SKB_TAIL_RESERVE - Minimum required CAIF socket buffer tail-space.
+ */
#define CAIF_SKB_TAIL_RESERVE 32
- /** CAIF control information (used in \ref caif_device.control_cb)
- * used for receiving control information from the modem.
- */
+/**
+ * enum caif_control - Kernel API: CAIF control information.
+ * used for receiving control information from the modem.
+ *
+ * @CAIF_CONTROL_FLOW_ON: Modem has sent Flow-ON, Clients can start
+ * transmitting data using caif_transmit.
+ *
+ * @CAIF_CONTROL_FLOW_OFF: Modem has sent Flow-OFF, Clients must stop
+ * transmitting data using caif_transmit.
+ *
+ * @CAIF_CONTROL_DEV_INIT: Channel creation is complete. This is an
+ * acknowledgement to caif_add_device from the
+ * modem. The channel is ready for transmit
+ * (Flow-state is ON).
+ * @CAIF_CONTROL_REMOTE_SHUTDOWN:
+ * Spontaneous close request from the modem.
+ * This may be caused by modem requesting
+ * shutdown or CAIF Link Layer going down.
+ * The client should respond by calling
+ * caif_remove_device.
+ * @CAIF_CONTROL_DEV_DEINIT: Channel disconnect is complete. This is an
+ * acknowledgement to caif_remove_device from
+ * the modem. caif_transmit or caif_flow_control
+ * must not be called after this.
+ * @CAIF_CONTROL_DEV_INIT_FAILED:
+ * Channel creation has failed. This is a
+ * negative acknowledgement to caif_add_device
+ * from the modem.
+ */
+
enum caif_control {
- /** Modem has sent Flow-ON, Clients can start transmitting
- * data using \ref caif_transmit.
- */
CAIF_CONTROL_FLOW_ON = 0,
- /** Modem has sent Flow-OFF, Clients must stop transmitting
- * data using \ref caif_transmit.
- */
CAIF_CONTROL_FLOW_OFF = 1,
-
- /** Channel creation is complete. This is an acknowledgement to
- * \ref caif_add_device from the modem.
- * The channel is ready for transmit (Flow-state is ON).
- */
CAIF_CONTROL_DEV_INIT = 3,
-
- /** Spontaneous close request from the modem, only applicable
- * for utility link. The client should respond by calling
- * \ref caif_remove_device.
- */
CAIF_CONTROL_REMOTE_SHUTDOWN = 4,
-
- /** Channel disconnect is complete. This is an acknowledgement to
- * \ref caif_remove_device from the modem.
- * \ref caif_transmit or \ref caif_flow_control must not be
- * called after this.
- */
CAIF_CONTROL_DEV_DEINIT = 5,
-
- /** Channel creation has failed. This is a negative acknowledgement
- * to \ref caif_add_device from the modem.
- */
CAIF_CONTROL_DEV_INIT_FAILED = 6
};
-/** Flow control information (used in \ref caif_device.control_cb) used
- * for controlling outgoing flow.
+/**
+ * enum caif_flowctrl - Kernel API: Flow control information.
+ *
+ * @CAIF_FLOWCTRL_ON: Flow Control is ON, transmit function can start
+ * sending data.
+ *
+ * @CAIF_FLOWCTRL_OFF: Flow Control is OFF, transmit function should stop
+ * sending data.
+ * Used in caif_device.control_cb) for controlling outgoing flow.
*/
enum caif_flowctrl {
- /** Flow Control is ON, transmit function can start sending data */
- CAIF_FLOWCTRL_ON = 0,
- /** Flow Control is OFF, transmit function should stop sending data */
- CAIF_FLOWCTRL_OFF = 1,
+ CAIF_FLOWCTRL_ON,
+ CAIF_FLOWCTRL_OFF
};
-/** Transmits CAIF packets on channel.
+/**
+ * caif_tranmit() - Kernel API: Transmits CAIF packets on channel.
+ *
+ * @skb: Socket buffer holding data to be written.
+ * @dev: Structure used when creating the channel
+ *
* This function is non-blocking and safe to use in tasklet context.
* The CAIF stack takes ownership of the socket buffer (SKB) after calling
- * \ref caif_transmit.
+ * caif_transmit.
* This means that the user cannot access the SKB afterwards; this applies
* even in error situations.
*
- * @return 0 on success, < 0 upon error.
+ * returns 0 on success, < 0 upon error.
*
- * @param[in] skb Socket buffer holding data to be written.
- * @param[in] dev Structure used when creating the channel
+ * Error codes:
+ * -ENOTCONN: The channel is not connected.
*
+ * -EPROTO: Protocol error (or SKB is faulty)
*
- * Error codes:
- * - \b ENOTCONN, The channel is not connected.
- * - \b EPROTO, Protocol error (or SKB is faulty)
- * - \b EIO IO error (unspecified error)
+ * -EIO: IO error (unspecified error)
*/
int caif_transmit(struct caif_device *dev, struct sk_buff *skb);
-/** Function for sending flow ON / OFF to remote end.
+/**
+ * caif_flow_control() - Kernel API: Function for sending flow ON/OFF
+ * to remote end.
+ * @dev: Reference to device data.
+ * @flow: Flow control information.
+ *
* This function is non-blocking and safe to use in tasklet context.
+ * It returns 0 on success, < 0 upon error.
*
- * @param[in] dev Reference to device data.
- * @param[in] flow Flow control information.
-
- * @return 0 on success, < 0 upon error.
* Error codes:
- * - \b ENOTCONN, The channel is not connected.
- * - \b EPROTO, Protocol error.
- * - \b EIO IO error (unspecified error).
+ * -ENOTCONN: The channel is not connected.
+ *
+ * -EPROTO: Protocol error.
+ *
+ * -EIO: IO error (unspecified error).
*/
int caif_flow_control(struct caif_device *dev, enum caif_flowctrl flow);
-/** Handle for kernel internal CAIF channels.
+/**
+ * struct caif_device - Kernel API: Handle for kernel internal CAIF channels.
+ *
+ * @caif_config: Channel configuration parameter. Contains information
+ * about type and configuration of the channel.
+ * This must be set before calling caif_add_device.
+ *
+ * @receive_cb: Callback function for receiving CAIF Packets from
+ * channel. This callback is called from softirq
+ * context (tasklet). The receiver MUST free the SKB.
+ * If the client has to do blocking operations then
+ * it must start its own work queue (or kernel thread).
+ * @control_cb: Callback function for notifying flow control from
+ * remote end - see caif_control.
+ * This callback is called from from softirq context
+ * (tasklet). Client must not call caif_transmit from
+ * this function. If the client has queued packets to
+ * send then it must start its own thread to do
+ * caif_transmit.
+ *
+ * @user_data: This field may be filled in by client for their
+ * own usage.
+ *
* All fields in this structure must be filled in by client before calling
- * \ref caif_add_device (except _caif_handle).
+ * caif_add_device (except _caif_handle).
+ *
*/
struct caif_device {
-
- /** Channel configuration parameter. Contains information about type
- * and configuration of the channel.
- * This must be set before calling \ref caif_add_device.
- */
struct caif_channel_config caif_config;
-
-
- /** Callback function for receiving CAIF Packets from channel.
- * This callback is called from softirq context (tasklet).
- * The receiver <b> must </b> free the SKB.
- * <b> DO NOT BLOCK IN THIS FUNCTION! </b>
- *
- * If the client has to do blocking operations then
- * it must start its own work queue (or kernel thread).
- *
- * @param[in] dev Reference to device data.
- * @param[in] skb Socket buffer with received data.
- */
void (*receive_cb) (struct caif_device *dev, struct sk_buff *skb);
-
-
- /** Callback function for notifying flow control from remote end - see
- * \ref caif_control.
- * This callback is called from from softirq context (tasklet).
- *
- * <b> DO NOT BLOCK IN THIS FUNCTION! </b>
- *
- * Client must not call \ref caif_transmit from this function.
- *
- * If the client has queued packets to send then
- * it must start its own thread to do \ref caif_transmit.
- *
- * @param[in] dev Reference to device data.
- * @param[in] ctrl CAIF control info \ref caif_control.
- * e.g. Flow control
- * \ref CAIF_CONTROL_FLOW_ON or
- * \ref CAIF_CONTROL_FLOW_OFF
- */
void (*control_cb) (struct caif_device *dev, enum caif_control ctrl);
-
- /** This is a CAIF private attribute, holding CAIF internal reference
- * to the CAIF stack. Do not update this field.
- */
- void *_caif_handle;
-
- /** This field may be filled in by client for their own usage. */
+ /* This field may be filled in by client for their own usage. */
void *user_data;
+ void *_caif_handle; /* Internal reference used by CAIF */
};
-/** Add (connect) a CAIF Channel.
+/**
+ * caif_add_device() - Kernel API: Add (connect) a CAIF Channel.
+ * @dev: Pointer to caif device.
+ *
* This function is non-blocking. The channel connect is reported in
- * \ref caif_device.control_cb.
- * The channel is not open until \ref caif_device.control_cb is called with
- * \ref CAIF_CONTROL_DEV_INIT.
- * If setting up the channel fails then \ref caif_device.control_cb is called
- * with \ref CAIF_CONTROL_DEV_INIT_FAILED.
+ * caif_device.control_cb.
+ * The channel is not open until caif_device.control_cb is called with
+ * CAIF_CONTROL_DEV_INIT.
+ * If setting up the channel fails then caif_device.control_cb is called
+ * with CAIF_CONTROL_DEV_INIT_FAILED.
*
- * \ref caif_transmit, \ref caif_flow_control or \ref caif_remove_device must
- * not be called before receiveing CAIF_CONTROL_DEV_INIT.
- * @return 0 on success, < 0 on failure.
+ * caif_transmit, caif_flow_control or caif_remove_device must
+ * not be called before receiving CAIF_CONTROL_DEV_INIT.
+ * returns 0 on success, < 0 on failure.
*
* Error codes:
- * - \b -EINVAL Invalid arguments
- * - \b -ENODEV No PHY device exists.
- * - \b -EIO IO error (unspecified error)
+ * -EINVAL: Invalid arguments
+ *
+ * -ENODEV: No PHY device exists.
+ *
+ * -EIO: IO error (unspecified error)
*/
int caif_add_device(struct caif_device *dev);
-/** Disconnect a CAIF Channel
+/**
+ * caif_remove_device() - Kernel API: Disconnect a CAIF Channel.
+ * @dev: Pointer to caif device.
+ *
* This function is non-blocking.
- * The channel has not been disconnected until \ref caif_device : control_cb is
- * called with \ref CAIF_CONTROL_DEV_DEINIT.
- * \ref caif_transmit or \ref caif_flow_control \b must not be called after
- * receiving \ref CAIF_CONTROL_DEV_DEINIT.
- * The client is responsible for freeing the \ref caif_device structure after
- * receiving \ref CAIF_CONTROL_DEV_DEINIT (if applicable).
- * @return 0 on success.
- *
- * - \b EIO IO error (unspecified error)
+ * The channel has not been disconnected until caif_device : control_cb is
+ * called with CAIF_CONTROL_DEV_DEINIT.
+ * caif_transmit or caif_flow_control must not be called after
+ * receiving CAIF_CONTROL_DEV_DEINIT.
+ * The client is responsible for freeing the caif_device structure after
+ * receiving CAIF_CONTROL_DEV_DEINIT (if applicable).
+ * returns 0 on success.
+ *
*/
-int caif_remove_device(struct caif_device *caif_dev);
+int caif_remove_device(struct caif_device *dev);
-/** Convenience function for allocating a socket buffer for usage with CAIF
+/**
+ * caif_create_skb() - Kerne API: Create SKB for CAIF payload.
+ * @data: User data to send with CAIF.
+ * @data_length: Length of data to send.
+ *
+ * Convenience function for allocating a socket buffer for usage with CAIF
* and copy user data into the socket buffer.
- * @param[in] data User data to send with CAIF.
- * @param[in] data_length Length of data to send.
- * @return New socket buffer containing user data.
*/
struct sk_buff *caif_create_skb(unsigned char *data, unsigned int data_length);
-/** Convenience function for extracting data from a socket buffer (SKB) and
- * then destroying the SKB.
- * Copies data from the SKB and then frees the SKB.
- * @param[in] skb SKB to extract data from. SKB will be freed after
+/**
+ * caif_extrace_and_destroy_skb() - Kernel API: Extract and destroy skb.
+ * @skb: SKB to extract data from. SKB will be freed after
* extracting data.
*
- * @param[in] data User data buffer to extract packet data into.
- * @param[in] max_length User data buffer length,
- * @return number of bytes extracted; < 0 upon error.
+ * @data: User data buffer to extract packet data into.
+ * @max_length: User data buffer length,
+ *
+ * Convenience function for extracting data from a socket buffer (SKB) and
+ * then destroying the SKB.
+ * Copies data from the SKB and then frees the SKB.
+ *
+ * returns number of bytes extracted; < 0 upon error.
*
*/
int caif_extract_and_destroy_skb(struct sk_buff *skb, unsigned char *data,
unsigned int max_length);
-/*! @} */
-
#endif /* CAIF_KERNEL_H_ */
diff --git a/include/net/caif/caif_shm.h b/include/net/caif/caif_shm.h
index c5fb35963e5..77feda4f0f8 100644
--- a/include/net/caif/caif_shm.h
+++ b/include/net/caif/caif_shm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) ST-Ericsson AB 2009
+ * Copyright (C) ST-Ericsson AB 2010
* Author: Daniel Martensson / Daniel.Martensson@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
@@ -10,7 +10,7 @@
#include <linux/list.h>
/*#include <linux/init.h>
#include <linux/workqueue.h>*/
-#include <net/caif/generic/caif_layer.h>
+#include <net/caif/caif_layer.h>
#define ESUCCESS 0
diff --git a/include/net/caif/caif_spi.h b/include/net/caif/caif_spi.h
index f16d02f775e..11df2c5f7ec 100644
--- a/include/net/caif/caif_spi.h
+++ b/include/net/caif/caif_spi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) ST-Ericsson AB 2009
+ * Copyright (C) ST-Ericsson AB 2010
* Author: Daniel Martensson / Daniel.Martensson@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
@@ -7,6 +7,8 @@
#ifndef CAIF_SPI_H_
#define CAIF_SPI_H_
+#include <net/caif/caif_device.h>
+
#define SPI_CMD_WR 0x00
#define SPI_CMD_RD 0x01
#define SPI_CMD_EOT 0x02
@@ -21,6 +23,7 @@
#define SPI_XFER 0
#define SPI_SS_ON 1
#define SPI_SS_OFF 2
+#define SPI_TERMINATE 3
/* Minimum time between different levels is 50 microseconds. */
#define MIN_TRANSITION_TIME_USEC 50
@@ -31,14 +34,27 @@
#define SPI_MASTER_CLK_MHZ 13
#define SPI_XFER_TIME_USEC(bytes, clk) (((bytes) * 8) / clk)
-#define SPI_TX_DEBUG 1
-#define SPI_RX_DEBUG 2
-#define SPI_LOG_DEBUG 4
+/* Normally this should be aligned on the modem in order to benefit from full
+ * duplex transfers. However a size of 8188 provokes errors when running with
+ * the modem. These errors occur when packet sizes approaches 4 kB of data.
+ */
+#define CAIF_MAX_SPI_FRAME 4092
+
+/* Maximum number of uplink CAIF frames that can reside in the same SPI frame.
+ * This number should correspond with the modem setting. The application side
+ * CAIF accepts any number of embedded downlink CAIF frames.
+ */
+#define CAIF_MAX_SPI_PKTS 9
+
+/* Decides if SPI buffers should be prefilled with 0xFF pattern for easier
+ * debugging. Both TX and RX buffers will be filled before the transfer.
+ */
+#define CFSPI_DBG_PREFILL 0
/* Structure describing a SPI transfer. */
struct cfspi_xfer {
- uint16 tx_dma_len;
- uint16 rx_dma_len;
+ uint16_t tx_dma_len;
+ uint16_t rx_dma_len;
void *va_tx;
dma_addr_t pa_tx;
void *va_rx;
@@ -58,11 +74,10 @@ struct cfspi_dev {
void (*sig_xfer) (bool xfer, struct cfspi_dev *dev);
struct cfspi_ifc *ifc;
char *name;
- uint32 clk_mhz;
+ uint32_t clk_mhz;
void *priv;
};
-#ifdef CONFIG_DEBUG_FS
/* Enumeration describing the CAIF SPI state. */
enum cfspi_state {
CFSPI_STATE_WAITING = 0,
@@ -79,16 +94,19 @@ enum cfspi_state {
CFSPI_STATE_DELIVER_PKT,
CFSPI_STATE_MAX,
};
-#endif /* CONFIG_DEBUG_FS */
/* Structure implemented by SPI physical interfaces. */
-struct cfspi_phy {
- uint16 cmd;
- uint16 tx_cpck_len;
- uint16 tx_npck_len;
- uint16 rx_cpck_len;
- uint16 rx_npck_len;
- struct layer layer;
+struct cfspi {
+ struct caif_dev_common cfdev;
+ struct net_device *ndev;
+ struct platform_device *pdev;
+ struct sk_buff_head qhead;
+ struct sk_buff_head chead;
+ uint16_t cmd;
+ uint16_t tx_cpck_len;
+ uint16_t tx_npck_len;
+ uint16_t rx_cpck_len;
+ uint16_t rx_npck_len;
struct cfspi_ifc ifc;
struct cfspi_xfer xfer;
struct cfspi_dev *dev;
@@ -96,18 +114,40 @@ struct cfspi_phy {
struct work_struct work;
struct workqueue_struct *wq;
struct list_head list;
+ int flow_off_sent;
+ uint32_t qd_low_mark;
+ uint32_t qd_high_mark;
struct completion comp;
wait_queue_head_t wait;
spinlock_t lock;
+ bool flow_stop;
#ifdef CONFIG_DEBUG_FS
enum cfspi_state dbg_state;
- uint16 pcmd;
- uint16 tx_ppck_len;
- uint16 rx_ppck_len;
+ uint16_t pcmd;
+ uint16_t tx_ppck_len;
+ uint16_t rx_ppck_len;
struct dentry *dbgfs_dir;
struct dentry *dbgfs_state;
struct dentry *dbgfs_frame;
#endif /* CONFIG_DEBUG_FS */
};
+extern int spi_frm_align;
+extern int spi_up_head_align;
+extern int spi_up_tail_align;
+extern int spi_down_head_align;
+extern int spi_down_tail_align;
+extern struct platform_driver cfspi_spi_driver;
+
+void cfspi_dbg_state(struct cfspi *cfspi, int state);
+int cfspi_xmitfrm(struct cfspi *cfspi, uint8_t *buf, size_t len);
+int cfspi_xmitlen(struct cfspi *cfspi);
+int cfspi_rxfrm(struct cfspi *cfspi, uint8_t *buf, size_t len);
+int cfspi_spi_remove(struct platform_device *pdev);
+int cfspi_spi_probe(struct platform_device *pdev);
+int cfspi_xmitfrm(struct cfspi *cfspi, uint8_t *buf, size_t len);
+int cfspi_xmitlen(struct cfspi *cfspi);
+int cfspi_rxfrm(struct cfspi *cfspi, uint8_t *buf, size_t len);
+void cfspi_xfer(struct work_struct *work);
+
#endif /* CAIF_SPI_H_ */
diff --git a/include/net/caif/cfglue.h b/include/net/caif/cfglue.h
deleted file mode 100644
index bbd186e4dd3..00000000000
--- a/include/net/caif/cfglue.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * This file contains the OS and HW dependencies for CAIF.
- * Copyright (C) ST-Ericsson AB 2009
- * Author: Sjur Brendeland/sjur.brandeland@stericsson.com
- * License terms: GNU General Public License (GPL) version 2
- */
-
-#ifndef CFGLUE_H_
-#define CFGLUE_H_
-
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/kernel.h>
-#include <linux/hardirq.h>
-#include <linux/stddef.h>
-#include <linux/types.h>
-#include <linux/crc-ccitt.h>
-
-/* Unsigned 8 bit */
-typedef __u8 uint8;
-
-/* Unsigned 16 bit */
-typedef __u16 uint16;
-
-/* Unsigned 32 bit */
-typedef __u32 uint32;
-
-/*
- * Handling endiannes:
- * CAIF uses little-endian byte order.
- */
-
-/* CAIF Endian handling Net to Host of 16 bits unsigned */
-#define cfglu_le16_to_cpu(v) le16_to_cpu(v)
-
-/* CAIF Endian handling Host to Net of 16 bits unsigned */
-#define cfglu_cpu_to_le16(v) cpu_to_le16(v)
-
-/* CAIF Endian handling Host to Net of 32 bits unsigned */
-#define cfglu_le32_to_cpu(v) le32_to_cpu(v)
-
-/* CAIF Endian handling Net to Host of 32 bits unsigned */
-#define cfglu_cpu_to_le32(v) cpu_to_le32(v)
-
-
-/* Critical Section support, one thread only between startsync
- * and endsync
- */
-#define cfglu_lock_t spinlock_t
-#define cfglu_init_lock(sync) spin_lock_init(&(sync))
-#define cfglu_lock(sync) spin_lock(&(sync))
-#define cfglu_unlock(sync) spin_unlock(&(sync))
-#define cfglu_deinit_lock(sync)
-
-/* Atomic counting */
-#define cfglu_atomic_t atomic_t
-#define cfglu_atomic_read(a) atomic_read(&a)
-#define cfglu_atomic_set(a, val) atomic_set(&a, val)
-#define cfglu_atomic_inc(a) atomic_inc(&a)
-#define cfglu_atomic_dec(a) atomic_dec(&a)
-
-/* HEAP */
-static inline void *cfglu_alloc(size_t size)
-{
- if (in_interrupt())
- return kmalloc(size, GFP_ATOMIC);
- else
- return kmalloc(size, GFP_KERNEL);
-}
-
-#define cfglu_free(ptr) kfree(ptr)
-#define cfglu_container_of(p, t, m) container_of(p, t, m)
-
-/* Checksum */
-static inline uint16 fcs16(uint16 fcs, uint8 *cp, uint16 len)
-{
- return crc_ccitt(fcs, cp, len);
-}
-
-
-#ifndef caif_assert
-#define caif_assert(assert)\
-do if (!(assert)) { \
- pr_err("caif:Assert detected:'%s'\n", #assert); \
- WARN_ON(!(assert));\
-} while (0)
-#endif
-
-/*FIXME: Comment error codes*/
-enum cfglu_errno {
- CFGLU_EOK = 0,
- CFGLU_EPKT = -EPROTO,
- CFGLU_EADDRINUSE = -EADDRINUSE,
- CFGLU_EIO = -EIO,
- CFGLU_EFCS = -EILSEQ,
- CFGLU_EBADPARAM = -EINVAL,
- CFGLU_EINVAL = -EINVAL,
- CFGLU_ENODEV = -ENODEV,
- CFGLU_ENOTCONN = -ENOTCONN,
- CFGLU_EPROTO = -EPROTO,
- CFGLU_EOVERFLOW = -EOVERFLOW,
- CFGLU_ENOMEM = -ENOMEM,
- CFGLU_ERETRY = -EAGAIN,
- CFGLU_ENOSPC = -ENOSPC,
- CFGLU_ENXIO = -ENXIO
-};
-
-#endif /* CFGLUE_H_ */
diff --git a/include/net/caif/cflst.h b/include/net/caif/cflst.h
deleted file mode 100644
index 7bba5508904..00000000000
--- a/include/net/caif/cflst.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) ST-Ericsson AB 2009
- * Author: Sjur Brendeland/sjur.brandeland@stericsson.com
- * License terms: GNU General Public License (GPL) version 2
- */
-
-#ifndef CFLST_H_
-#define CFLST_H_
-
-#include <net/caif/generic/cfglue.h>
-
-int cflst_put(struct layer **lst, uint8 id, struct layer *node);
-struct layer *cflst_get(struct layer **lst, uint8 id);
-struct layer *cflst_del(struct layer **lst, uint8 id);
-#define CFLST_FIRST(lst) lst
-#define CFLST_MORE(node) ((node) != NULL)
-#define CFLST_NEXT(node) ((node)->next)
-void cflst_init(struct layer **lst);
-#endif /* CFLST_H_ */