aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKim Lilliestierna XX <kim.xx.lilliestierna@stericsson.com>2010-05-10 14:13:37 +0200
committerJohn Rigby <john.rigby@linaro.org>2010-09-02 22:45:24 -0600
commit1f63c78f8a3cf5d00d8dd6701103d51d6a00d883 (patch)
treee05b5a8f26526a5c09bf7d7238fdf350b843a436 /include
parentcbb288966b220015b17de4749129d4e007ce0552 (diff)
CAIF: changes to former "generic" files
Change-Id: I9d8ec46b2066cb7bd1bab0827638a87110942f29
Diffstat (limited to 'include')
-rw-r--r--include/net/caif/caif_layer.h308
-rw-r--r--include/net/caif/cfcnfg.h144
-rw-r--r--include/net/caif/cfctrl.h83
-rw-r--r--include/net/caif/cffrml.h13
-rw-r--r--include/net/caif/cfloopcfg.h8
-rw-r--r--include/net/caif/cfmuxl.h18
-rw-r--r--include/net/caif/cfpkt.h40
-rw-r--r--include/net/caif/cfserl.h8
-rw-r--r--include/net/caif/cfsrvl.h49
9 files changed, 390 insertions, 281 deletions
diff --git a/include/net/caif/caif_layer.h b/include/net/caif/caif_layer.h
index 357e250b66f..25c472f0e5b 100644
--- a/include/net/caif/caif_layer.h
+++ b/include/net/caif/caif_layer.h
@@ -1,18 +1,18 @@
/*
- * Copyright (C) ST-Ericsson AB 2009
- * Author: Sjur Braendeland/sjur.brandeland@stericsson.com
+ * Copyright (C) ST-Ericsson AB 2010
+ * Author: Sjur Brendeland / sjur.brandeland@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
#ifndef CAIF_LAYER_H_
#define CAIF_LAYER_H_
-#include <net/caif/generic/cfglue.h>
+#include <linux/list.h>
-struct layer;
+struct cflayer;
struct cfpkt;
struct cfpktq;
-struct payload_info;
+struct caif_payload_info;
struct caif_packet_funcs;
#define CAIF_MAX_FRAMESIZE 4096
@@ -20,68 +20,123 @@ struct caif_packet_funcs;
#define CAIF_NEEDED_HEADROOM (10)
#define CAIF_NEEDED_TAILROOM (2)
-
#define CAIF_LAYER_NAME_SZ 16
-#define CAIF_SUCCESS 1
-#define CAIF_FAILURE 0
+#define CAIF_SUCCESS 1
+#define CAIF_FAILURE 0
-/*
- * CAIF Control Signaling.
- * These commands are sent upwards in the CAIF stack. They are used for
- * signaling originating from the modem.
- * These are either responses (*_RSP) or events (*_IND).
+/**
+ * caif_assert() - Assert function for CAIF.
+ * @assert: expression to evaluate.
+ *
+ * This function will print a error message and a do WARN_ON if the
+ * assertion failes. Normally this will do a stack up at the current location.
+ */
+#define caif_assert(assert) \
+do { \
+ if (!(assert)) { \
+ pr_err("caif:Assert detected:'%s'\n", #assert); \
+ WARN_ON(!(assert)); \
+ } \
+} while (0)
+
+
+/**
+ * enum caif_ctrlcmd - CAIF Stack Control Signaling sent in layer.ctrlcmd().
+ *
+ * @CAIF_CTRLCMD_FLOW_OFF_IND: Flow Control is OFF, transmit function
+ * should stop sending data
+ *
+ * @CAIF_CTRLCMD_FLOW_ON_IND: Flow Control is ON, transmit function
+ * can start sending data
+ *
+ * @CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND: Remote end modem has decided to close
+ * down channel
+ *
+ * @CAIF_CTRLCMD_INIT_RSP: Called initially when the layer below
+ * has finished initialization
+ *
+ * @CAIF_CTRLCMD_DEINIT_RSP: Called when de-initialization is
+ * complete
+ *
+ * @CAIF_CTRLCMD_INIT_FAIL_RSP: Called if initialization fails
+ *
+ * @_CAIF_CTRLCMD_PHYIF_FLOW_OFF_IND: CAIF Link layer temporarily cannot
+ * send more packets.
+ * @_CAIF_CTRLCMD_PHYIF_FLOW_ON_IND: Called if CAIF Link layer is able
+ * to send packets again.
+ * @_CAIF_CTRLCMD_PHYIF_DOWN_IND: Called if CAIF Link layer is going
+ * down.
+ *
+ * These commands are sent upwards in the CAIF stack to the CAIF Client.
+ * They are used for signaling originating from the modem or CAIF Link Layer.
+ * These are either responses (*_RSP) or events (*_IND).
*/
enum caif_ctrlcmd {
- /* Flow Control is OFF, transmit function should stop sending data */
CAIF_CTRLCMD_FLOW_OFF_IND,
- /* Flow Control is ON, transmit function can start sending data */
CAIF_CTRLCMD_FLOW_ON_IND,
- /* Remote end modem has decided to close down channel */
CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND,
- /* Called initially when the layer below has finished initialization */
CAIF_CTRLCMD_INIT_RSP,
- /* Called when de-initialization is complete */
CAIF_CTRLCMD_DEINIT_RSP,
- /* Called if initialization fails */
CAIF_CTRLCMD_INIT_FAIL_RSP,
- /* Called if physical interface cannot send more packets. */
_CAIF_CTRLCMD_PHYIF_FLOW_OFF_IND,
- /* Called if physical interface is able to send packets again. */
_CAIF_CTRLCMD_PHYIF_FLOW_ON_IND,
- /* Called if physical interface is going down. */
_CAIF_CTRLCMD_PHYIF_DOWN_IND,
};
-/*
- * Modem Control Signaling.
- * These are requests sent 'downwards' in the stack.
- * Flow ON, OFF can be indicated to the modem.
+/**
+ * enum caif_modemcmd - Modem Control Signaling, sent from CAIF Client
+ * to the CAIF Link Layer or modem.
+ *
+ * @CAIF_MODEMCMD_FLOW_ON_REQ: Flow Control is ON, transmit function
+ * can start sending data.
+ *
+ * @CAIF_MODEMCMD_FLOW_OFF_REQ: Flow Control is OFF, transmit function
+ * should stop sending data.
+ *
+ * @_CAIF_MODEMCMD_PHYIF_USEFULL: Notify physical layer that it is in use
+ *
+ * @_CAIF_MODEMCMD_PHYIF_USELESS: Notify physical layer that it is
+ * no longer in use.
+ *
+ * These are requests sent 'downwards' in the stack.
+ * Flow ON, OFF can be indicated to the modem.
*/
enum caif_modemcmd {
- /* Flow Control is ON, transmit function can start sending data */
CAIF_MODEMCMD_FLOW_ON_REQ = 0,
- /* Flow Control is OFF, transmit function should stop sending data */
CAIF_MODEMCMD_FLOW_OFF_REQ = 1,
- /* Notify physical layer that it is in use */
_CAIF_MODEMCMD_PHYIF_USEFULL = 3,
- /* Notify physical layer that it is no longer in use */
_CAIF_MODEMCMD_PHYIF_USELESS = 4
};
-/*
- * CAIF Packet Direction.
+/**
+ * enum caif_direction - CAIF Packet Direction.
* Indicate if a packet is to be sent out or to be received in.
+ * @CAIF_DIR_IN: Incoming packet received.
+ * @CAIF_DIR_OUT: Outgoing packet to be transmitted.
*/
enum caif_direction {
- CAIF_DIR_IN = 0, /* Incoming packet received. */
- CAIF_DIR_OUT = 1 /* Outgoing packet to be transmitted. */
+ CAIF_DIR_IN = 0,
+ CAIF_DIR_OUT = 1
};
-/*
- * This structure defines the generic layered structure in CAIF.
- * It is inspired by the "Protocol Layer Design Pattern" (Streams).
+/**
+ * struct cflayer - CAIF Stack layer.
+ * Defines the framework for the CAIF Core Stack.
+ * @up: Pointer up to the layer above.
+ * @dn: Pointer down to the layer below.
+ * @node: List node used when layer participate in a list.
+ * @receive: Packet receive function.
+ * @transmit: Packet transmit funciton.
+ * @ctrlcmd: Used for control signalling upwards in the stack.
+ * @modemcmd: Used for control signaling downwards in the stack.
+ * @prio: Priority of this layer.
+ * @id: The identity of this layer
+ * @type: The type of this layer
+ * @name: Name of the layer.
+ *
+ * This structure defines the layered structure in CAIF.
*
- * It defines a generic layering structure, used by all CAIF Layers and the
+ * It defines CAIF layering structure, used by all CAIF Layers and the
* layers interfacing CAIF.
*
* In order to integrate with CAIF an adaptation layer on top of the CAIF stack
@@ -89,136 +144,139 @@ enum caif_direction {
* must be implemented. These layer must follow the design principles below.
*
* Principles for layering of protocol layers:
- * -# All layers must use this structure. If embedding it, then place this
- * structure first in the layer specific structure.
- * -# Each layer should not depend on any others layer private data.
- * -# In order to send data upwards do
- * layer->up->receive(layer->up, packet);
- * -# In order to send data downwards do
- * layer->dn->transmit(layer->dn, info, packet);
+ * - All layers must use this structure. If embedding it, then place this
+ * structure first in the layer specific structure.
+ *
+ * - Each layer should not depend on any others layer private data.
+ *
+ * - In order to send data upwards do
+ * layer->up->receive(layer->up, packet);
+ *
+ * - In order to send data downwards do
+ * layer->dn->transmit(layer->dn, info, packet);
*/
-struct layer {
+struct cflayer {
+ struct cflayer *up;
+ struct cflayer *dn;
+ struct list_head node;
- struct layer *up; /* Pointer to the layer above */
- struct layer *dn; /* Pointer to the layer below */
/*
- * Receive Function.
+ * receive() - Receive Function.
* Contract: Each layer must implement a receive function passing the
* CAIF packets upwards in the stack.
* Packet handling rules:
- * -# The CAIF packet (cfpkt) cannot be accessed after
+ * - The CAIF packet (cfpkt) cannot be accessed after
* passing it to the next layer using up->receive().
- * -# If parsing of the packet fails, the packet must be
+ * - If parsing of the packet fails, the packet must be
* destroyed and -1 returned from the function.
- * -# If parsing succeeds (and above layers return OK) then
+ * - If parsing succeeds (and above layers return OK) then
* the function must return a value > 0.
*
- * @param[in] layr Pointer to the current layer the receive function is
- * implemented for (this pointer).
- * @param[in] cfpkt Pointer to CaifPacket to be handled.
- * @return result < 0 indicates an error, 0 or positive value
+ * Returns result < 0 indicates an error, 0 or positive value
* indicates success.
+ *
+ * @layr: Pointer to the current layer the receive function is
+ * implemented for (this pointer).
+ * @cfpkt: Pointer to CaifPacket to be handled.
*/
- int (*receive)(struct layer *layr, struct cfpkt *cfpkt);
+ int (*receive)(struct cflayer *layr, struct cfpkt *cfpkt);
/*
- * Transmit Function.
+ * transmit() - Transmit Function.
* Contract: Each layer must implement a transmit function passing the
* CAIF packet downwards in the stack.
* Packet handling rules:
- * -# The CAIF packet (cfpkt) ownership is passed to the
- * transmit function. This means that the the packet
- * cannot be accessed after passing it to the below
- * layer using dn->transmit().
+ * - The CAIF packet (cfpkt) ownership is passed to the
+ * transmit function. This means that the the packet
+ * cannot be accessed after passing it to the below
+ * layer using dn->transmit().
+ *
+ * - If transmit fails, however, the ownership is returned
+ * to thecaller. The caller of "dn->transmit()" must
+ * destroy or resend packet.
*
- * -# If transmit fails, however, the ownership is returned
- * to thecaller. The caller of "dn->transmit()" must
- * destroy or resend packet.
+ * - Return value less than zero means error, zero or
+ * greater than zero means OK.
*
- * -# Return value less than zero means error, zero or
- * greater than zero means OK.
+ * result < 0 indicates an error, 0 or positive value
+ * indicate success.
*
- * @param[in] layr Pointer to the current layer the receive function
- * is implemented for (this pointer).
- * @param[in] cfpkt Pointer to CaifPacket to be handled.
- * @return result < 0 indicates an error, 0 or positive value
- * indicate success.
+ * @layr: Pointer to the current layer the receive function
+ * isimplemented for (this pointer).
+ * @cfpkt: Pointer to CaifPacket to be handled.
*/
- int (*transmit) (struct layer *layr, struct cfpkt *cfpkt);
+ int (*transmit) (struct cflayer *layr, struct cfpkt *cfpkt);
/*
- * Control Function used to signal upwards in the CAIF stack.
+ * cttrlcmd() - Control Function upwards in CAIF Stack.
* Used for signaling responses (CAIF_CTRLCMD_*_RSP)
* and asynchronous events from the modem (CAIF_CTRLCMD_*_IND)
*
- * @param[in] layr Pointer to the current layer the receive function
- * is implemented for (this pointer).
- * @param[in] ctrl Control Command.
+ * @layr: Pointer to the current layer the receive function
+ * is implemented for (this pointer).
+ * @ctrl: Control Command.
*/
- void (*ctrlcmd) (struct layer *layr, enum caif_ctrlcmd ctrl,
+ void (*ctrlcmd) (struct cflayer *layr, enum caif_ctrlcmd ctrl,
int phyid);
/*
- * Control Function used for controlling the modem. Used to signal
- * down-wards in the CAIF stack.
- * @returns 0 on success, < 0 upon failure.
- * @param[in] layr Pointer to the current layer the receive function
- * is implemented for (this pointer).
- * @param[in] ctrl Control Command.
+ * modemctrl() - Control Function used for controlling the modem.
+ * Used to signal down-wards in the CAIF stack.
+ * Returns 0 on success, < 0 upon failure.
+ *
+ * @layr: Pointer to the current layer the receive function
+ * is implemented for (this pointer).
+ * @ctrl: Control Command.
*/
- int (*modemcmd) (struct layer *layr, enum caif_modemcmd ctrl);
-
- struct layer *next; /*
- * Pointer to chain of layers, up/dn will
- * then point at the first element of a
- * which then should be iterated through
- * the next pointer.
- */
- unsigned short prio; /* Priority of this layer */
- unsigned int id; /* The identity of this layer. */
- unsigned int type; /* The type of this layer */
- char name[CAIF_LAYER_NAME_SZ]; /* Name of the layer */
+ int (*modemcmd) (struct cflayer *layr, enum caif_modemcmd ctrl);
+
+ unsigned short prio;
+ unsigned int id;
+ unsigned int type;
+ char name[CAIF_LAYER_NAME_SZ];
};
-/*
- * Set the up pointer for a specified layer.
- * @param layr Layer where up pointer shall be set.
- * @param above Layer above.
+
+/**
+ * layer_set_up() - Set the up pointer for a specified layer.
+ * @layr: Layer where up pointer shall be set.
+ * @above: Layer above.
*/
-#define layer_set_up(layr, above) ((layr)->up = (struct layer *)(above))
+#define layer_set_up(layr, above) ((layr)->up = (struct cflayer *)(above))
-/*
- * Set the dn pointer for a specified layer.
- * @param layr Layer where down pointer shall be set.
- * @param below Layer below.
+/**
+ * layer_set_dn() - Set the down pointer for a specified layer.
+ * @layr: Layer where down pointer shall be set.
+ * @below: Layer below.
*/
-#define layer_set_dn(layr, below) ((layr)->dn = (struct layer *)(below))
+#define layer_set_dn(layr, below) ((layr)->dn = (struct cflayer *)(below))
-/* Physical Device info, holding information about physical layer. */
+/**
+ * struct dev_info - Physical Device info information about physical layer.
+ * @dev: Pointer to native physical device.
+ * @id: Physical ID of the physical connection used by the
+ * logical CAIF connection. Used by service layers to
+ * identify their physical id to Caif MUX (CFMUXL)so
+ * that the MUX can add the correct physical ID to the
+ * packet.
+ */
struct dev_info {
- /* Pointer to native physical device */
void *dev;
-
- /*
- * Physical ID of the physical connection used by the logical CAIF
- * connection. Used by service layers to identify their physical id
- * to Caif MUX (CFMUXL)so that the MUX can add the correct physical
- * ID to the packet.
- */
unsigned int id;
};
-/* Transmit info, passed downwards in protocol layers. */
-struct payload_info {
- /* Information about the receiving device */
+/**
+ * struct caif_payload_info - Payload information embedded in packet (sk_buff).
+ *
+ * @dev_info: Information about the receiving device.
+ *
+ * @hdr_len: Header length, used to align pay load on 32bit boundary.
+ *
+ * @channel_id: Channel ID of the logical CAIF connection.
+ * Used by mux to insert channel id into the caif packet.
+ */
+struct caif_payload_info {
struct dev_info *dev_info;
-
- /* Header length, used to align pay load on 32bit boundary. */
unsigned short hdr_len;
-
- /*
- * Channel ID of the logical CAIF connection.
- * Used by mux to insert channel id into the caif packet.
- */
unsigned short channel_id;
};
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h
index a3cb37e0986..9fc2fc20b88 100644
--- a/include/net/caif/cfcnfg.h
+++ b/include/net/caif/cfcnfg.h
@@ -1,110 +1,140 @@
/*
- * 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
*/
#ifndef CFCNFG_H_
#define CFCNFG_H_
-#include <net/caif/generic/caif_layer.h>
-#include <net/caif/generic/cfctrl.h>
+#include <linux/spinlock.h>
+#include <net/caif/caif_layer.h>
+#include <net/caif/cfctrl.h>
struct cfcnfg;
-/* Types of physical layers defined in CAIF Stack */
+/**
+ * enum cfcnfg_phy_type - Types of physical layers defined in CAIF Stack
+ *
+ * @CFPHYTYPE_FRAG: Fragmented frames physical interface.
+ * @CFPHYTYPE_CAIF: Generic CAIF physical interface
+ */
enum cfcnfg_phy_type {
- /* Fragmented frames physical interface */
CFPHYTYPE_FRAG = 1,
- /* Generic CAIF physical interface */
CFPHYTYPE_CAIF,
CFPHYTYPE_MAX
};
-/* Physical preference - HW Abstraction */
+/**
+ * enum cfcnfg_phy_preference - Physical preference HW Abstraction
+ *
+ * @CFPHYPREF_UNSPECIFIED: Default physical interface
+ *
+ * @CFPHYPREF_LOW_LAT: Default physical interface for low-latency
+ * traffic
+ * @CFPHYPREF_HIGH_BW: Default physical interface for high-bandwidth
+ * traffic
+ * @CFPHYPREF_LOOP: TEST only Loopback interface simulating modem
+ * responses.
+ *
+ */
enum cfcnfg_phy_preference {
- /* Default physical interface */
CFPHYPREF_UNSPECIFIED,
- /* Default physical interface for low-latency traffic */
CFPHYPREF_LOW_LAT,
- /* Default physical interface for high-bandwidth traffic */
CFPHYPREF_HIGH_BW,
- /* TEST only Loopback interface simulating modem responses */
CFPHYPREF_LOOP
};
-/*
- * Create the CAIF configuration object.
- * @return The created instance of a CFCNFG object.
+/**
+ * cfcnfg_create() - Create the CAIF configuration object.
*/
struct cfcnfg *cfcnfg_create(void);
-/* Remove the CFCNFG object */
+/**
+ * cfcnfg_remove() - Remove the CFCNFG object
+ * @cfg: config object
+ */
void cfcnfg_remove(struct cfcnfg *cfg);
-/*
- * Adds a physical layer to the CAIF stack.
- * @param cnfg Pointer to a CAIF configuration object, created by
- * cfcnfg_create().
- * @param phy_type Specifies the type of physical interface, e.g.
- * CFPHYTYPE_FRAG.
- * @param phy_layer Specify the physical layer. The transmit function
- * MUST be set in the structure.
- * @param phyid [out] The assigned physical ID for this layer,
- * used in \ref cfcnfg_add_adapt_layer to specify
- * PHY for the link.
+/**
+ * cfcnfg_add_phy_layer() - Adds a physical layer to the CAIF stack.
+ * @cnfg: Pointer to a CAIF configuration object, created by
+ * cfcnfg_create().
+ * @phy_type: Specifies the type of physical interface, e.g.
+ * CFPHYTYPE_FRAG.
+ * @dev: Pointer to link layer device
+ * @phy_layer: Specify the physical layer. The transmit function
+ * MUST be set in the structure.
+ * @phyid: The assigned physical ID for this layer, used in
+ * cfcnfg_add_adapt_layer to specify PHY for the link.
+ * @pref: The phy (link layer) preference.
+ * @fcs: Specify if checksum is used in CAIF Framing Layer.
+ * @stx: Specify if Start Of Frame eXtention is used.
*/
void
cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
- void *dev, struct layer *phy_layer, uint16 *phyid,
+ void *dev, struct cflayer *phy_layer, u16 *phyid,
enum cfcnfg_phy_preference pref,
bool fcs, bool stx);
-/*
- * Deletes an phy layer from the CAIF stack.
+/**
+ * cfcnfg_del_phy_layer - Deletes an phy layer from the CAIF stack.
*
- * @param cnfg Pointer to a CAIF configuration object, created by
- * cfcnfg_create().
- * @param phy_layer Adaptation layer to be removed.
- * @return 0 on success.
+ * @cnfg: Pointer to a CAIF configuration object, created by
+ * cfcnfg_create().
+ * @phy_layer: Adaptation layer to be removed.
*/
-int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct layer *phy_layer);
-
+int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer);
-/*
- * Deletes an adaptation layer from the CAIF stack.
+/**
+ * cfcnfg_disconn_adapt_layer - Disconnects an adaptation layer.
*
- * @param cnfg Pointer to a CAIF configuration object, created by
- * cfcnfg_create().
- * @param adap_layer Adaptation layer to be removed.
- * @return 0 on success.
+ * @cnfg: Pointer to a CAIF configuration object, created by
+ * cfcnfg_create().
+ * @adap_layer: Adaptation layer to be removed.
*/
-int cfcnfg_del_adapt_layer(struct cfcnfg *cnfg, struct layer *adap_layer);
+int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg,
+ struct cflayer *adap_layer);
+/**
+ * cfcnfg_release_adap_layer - Used by client to release the adaptation layer.
+ *
+ * @adap_layer: Adaptation layer.
+ */
+void cfcnfg_release_adap_layer(struct cflayer *adap_layer);
-/*
- * Adds an adaptation layer to the CAIF stack.
+/**
+ * cfcnfg_add_adaptation_layer - Add an adaptation layer to the CAIF stack.
+ *
* The adaptation Layer is where the interface to application or higher-level
* driver functionality is implemented.
*
- * @param cnfg Pointer to a CAIF configuration object, created by
- * cfcnfg_create().
- * @param param Link setup parameters.
- * @param adap_layer Specify the adaptation layer; the receive and flow-control
- functions MUST be set in the structure.
- * @return true on success, false upon failure.
+ * @cnfg: Pointer to a CAIF configuration object, created by
+ * cfcnfg_create().
+ * @param: Link setup parameters.
+ * @adap_layer: Specify the adaptation layer; the receive and
+ * flow-control functions MUST be set in the structure.
+ *
*/
-bool
-cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg,
+int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg,
struct cfctrl_link_param *param,
- struct layer *adap_layer);
-/*
- * Get physical ID, given type.
- * @return Returns one of the physical interfaces matching the given type.
- * Zero if no match is found.
+ struct cflayer *adap_layer);
+
+/**
+ * cfcnfg_get_phyid() - Get physical ID, given type.
+ * Returns one of the physical interfaces matching the given type.
+ * Zero if no match is found.
+ * @cnfg: Configuration object
+ * @phy_pref: Caif Link Layer preference
*/
struct dev_info *cfcnfg_get_phyid(struct cfcnfg *cnfg,
enum cfcnfg_phy_preference phy_pref);
+
+/**
+ * cfcnfg_get_named() - Get the Physical Identifier of CAIF Link Layer
+ * @cnfg: Configuration object
+ * @name: Name of the Physical Layer (Caif Link Layer)
+ */
int cfcnfg_get_named(struct cfcnfg *cnfg, char *name);
#endif /* CFCNFG_H_ */
diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
index fc9a1fa8533..997603f2bf4 100644
--- a/include/net/caif/cfctrl.h
+++ b/include/net/caif/cfctrl.h
@@ -1,13 +1,13 @@
/*
- * 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
*/
#ifndef CFCTRL_H_
#define CFCTRL_H_
-#include <net/caif/generic/caif_layer.h>
-#include <net/caif/generic/cfsrvl.h>
+#include <net/caif/caif_layer.h>
+#include <net/caif/cfsrvl.h>
/* CAIF Control packet commands */
enum cfctrl_cmd {
@@ -40,50 +40,49 @@ enum cfctrl_srv {
#define CFCTRL_ERR_BIT 0x10
struct cfctrl_rsp {
- void (*linksetup_rsp)(struct layer *layer, uint8 linkid,
- enum cfctrl_srv serv, uint8 phyid,
- struct layer *adapt_layer);
- void (*linkdestroy_rsp)(struct layer *layer, uint8 linkid,
- struct layer *client_layer);
+ void (*linksetup_rsp)(struct cflayer *layer, u8 linkid,
+ enum cfctrl_srv serv, u8 phyid,
+ struct cflayer *adapt_layer);
+ void (*linkdestroy_rsp)(struct cflayer *layer, u8 linkid);
void (*linkerror_ind)(void);
void (*enum_rsp)(void);
void (*sleep_rsp)(void);
void (*wake_rsp)(void);
void (*restart_rsp)(void);
void (*radioset_rsp)(void);
- void (*reject_rsp)(struct layer *layer, uint8 linkid,
- struct layer *client_layer);;
+ void (*reject_rsp)(struct cflayer *layer, u8 linkid,
+ struct cflayer *client_layer);;
};
/* Link Setup Parameters for CAIF-Links. */
struct cfctrl_link_param {
enum cfctrl_srv linktype;/* (T3,T0) Type of Channel */
- uint8 priority; /* (P4,P0) Priority of the channel */
- uint8 phyid; /* (U2-U0) Physical interface to connect */
- uint8 endpoint; /* (E1,E0) Endpoint for data channels */
- uint8 chtype; /* (H1,H0) Channel-Type, applies to
+ u8 priority; /* (P4,P0) Priority of the channel */
+ u8 phyid; /* (U2-U0) Physical interface to connect */
+ u8 endpoint; /* (E1,E0) Endpoint for data channels */
+ u8 chtype; /* (H1,H0) Channel-Type, applies to
* VEI, DEBUG */
union {
struct {
- uint8 connid; /* (D7,D0) Video LinkId */
+ u8 connid; /* (D7,D0) Video LinkId */
} video;
struct {
- uint32 connid; /* (N31,Ngit0) Connection ID used
+ u32 connid; /* (N31,Ngit0) Connection ID used
* for Datagram */
} datagram;
struct {
- uint32 connid; /* Connection ID used for RFM */
+ u32 connid; /* Connection ID used for RFM */
char volume[20]; /* Volume to mount for RFM */
} rfm; /* Configuration for RFM */
struct {
- uint16 fifosize_kb; /* Psock FIFO size in KB */
- uint16 fifosize_bufs; /* Psock # signal buffers */
+ u16 fifosize_kb; /* Psock FIFO size in KB */
+ u16 fifosize_bufs; /* Psock # signal buffers */
char name[16]; /* Name of the PSOCK service */
- uint8 params[255]; /* Link setup Parameters> */
- uint16 paramlen; /* Length of Link Setup
+ u8 params[255]; /* Link setup Parameters> */
+ u16 paramlen; /* Length of Link Setup
* Parameters */
} utility; /* Configuration for Utility Links (Psock) */
} u;
@@ -93,44 +92,48 @@ struct cfctrl_link_param {
struct cfctrl_request_info {
int sequence_no;
enum cfctrl_cmd cmd;
- uint8 channel_id;
+ u8 channel_id;
struct cfctrl_link_param param;
struct cfctrl_request_info *next;
- struct layer *client_layer;
+ struct cflayer *client_layer;
};
struct cfctrl {
struct cfsrvl serv;
struct cfctrl_rsp res;
- cfglu_atomic_t req_seq_no;
- cfglu_atomic_t rsp_seq_no;
+ atomic_t req_seq_no;
+ atomic_t rsp_seq_no;
struct cfctrl_request_info *first_req;
- cfglu_lock_t info_list_lock;
+ /* Protects from simultaneous access to first_req list */
+ spinlock_t info_list_lock;
#ifndef CAIF_NO_LOOP
- uint8 loop_linkid;
+ u8 loop_linkid;
int loop_linkused[256];
- cfglu_lock_t loop_linkid_lock;
+ /* Protects simultaneous access to loop_linkid and loop_linkused */
+ spinlock_t loop_linkid_lock;
#endif
};
-void cfctrl_enum_req(struct layer *cfctrl, uint8 physlinkid);
-void cfctrl_linkup_request(struct layer *cfctrl,
+void cfctrl_enum_req(struct cflayer *cfctrl, u8 physlinkid);
+int cfctrl_linkup_request(struct cflayer *cfctrl,
struct cfctrl_link_param *param,
- struct layer *user_layer);
-int cfctrl_linkdown_req(struct layer *cfctrl, uint8 linkid,
- struct layer *client);
-void cfctrl_sleep_req(struct layer *cfctrl);
-void cfctrl_wake_req(struct layer *cfctrl);
-void cfctrl_getstartreason_req(struct layer *cfctrl);
-struct layer *cfctrl_create(void);
-void cfctrl_set_dnlayer(struct layer *this, struct layer *dn);
-void cfctrl_set_uplayer(struct layer *this, struct layer *up);
-struct cfctrl_rsp *cfctrl_get_respfuncs(struct layer *layer);
+ struct cflayer *user_layer);
+int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid,
+ struct cflayer *client);
+void cfctrl_sleep_req(struct cflayer *cfctrl);
+void cfctrl_wake_req(struct cflayer *cfctrl);
+void cfctrl_getstartreason_req(struct cflayer *cfctrl);
+struct cflayer *cfctrl_create(void);
+void cfctrl_set_dnlayer(struct cflayer *this, struct cflayer *dn);
+void cfctrl_set_uplayer(struct cflayer *this, struct cflayer *up);
+struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer);
bool cfctrl_req_eq(struct cfctrl_request_info *r1,
struct cfctrl_request_info *r2);
void cfctrl_insert_req(struct cfctrl *ctrl,
struct cfctrl_request_info *req);
struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
struct cfctrl_request_info *req);
+void cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer);
+
#endif /* CFCTRL_H_ */
diff --git a/include/net/caif/cffrml.h b/include/net/caif/cffrml.h
index 111435bf61e..3f14d2e1ce6 100644
--- a/include/net/caif/cffrml.h
+++ b/include/net/caif/cffrml.h
@@ -1,19 +1,16 @@
/*
- * 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
*/
#ifndef CFFRML_H_
#define CFFRML_H_
-#include <net/caif/generic/cfglue.h>
-#include <net/caif/generic/caif_layer.h>
-#include <net/caif/generic/cflst.h>
+#include <net/caif/caif_layer.h>
struct cffrml;
-struct layer *cffrml_create(uint16 phyid, bool DoFCS);
-void cffrml_set_uplayer(struct layer *this, struct layer *up);
-void cffrml_set_dnlayer(struct layer *this, struct layer *dn);
-void cffrml_destroy(struct layer *layer);
+struct cflayer *cffrml_create(u16 phyid, bool DoFCS);
+void cffrml_set_uplayer(struct cflayer *this, struct cflayer *up);
+void cffrml_set_dnlayer(struct cflayer *this, struct cflayer *dn);
#endif /* CFFRML_H_ */
diff --git a/include/net/caif/cfloopcfg.h b/include/net/caif/cfloopcfg.h
index 3cffd73628f..6c527cc86e4 100644
--- a/include/net/caif/cfloopcfg.h
+++ b/include/net/caif/cfloopcfg.h
@@ -1,16 +1,16 @@
/*
- * 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
*/
#ifndef CFLOOPCFG_H_
#define CFLOOPCFG_H_
-#include <net/caif/generic/caif_layer.h>
+#include <net/caif/caif_layer.h>
struct cfloopcfg *cfloopcfg_create(void);
void cfloopcfg_add_phy_layer(struct cfloopcfg *cnfg,
enum cfcnfg_phy_type phy_type,
- struct layer *phy_layer);
-struct layer *cflooplayer_create(void);
+ struct cflayer *phy_layer);
+struct cflayer *cflooplayer_create(void);
#endif /* CFLOOPCFG_H_ */
diff --git a/include/net/caif/cfmuxl.h b/include/net/caif/cfmuxl.h
index 7c15a7f4a78..4e1b4f33423 100644
--- a/include/net/caif/cfmuxl.h
+++ b/include/net/caif/cfmuxl.h
@@ -1,22 +1,22 @@
/*
- * 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
*/
#ifndef CFMUXL_H_
#define CFMUXL_H_
-#include <net/caif/generic/caif_layer.h>
+#include <net/caif/caif_layer.h>
struct cfsrvl;
struct cffrml;
-struct layer *cfmuxl_create(void);
-int cfmuxl_set_uplayer(struct layer *layr, struct layer *up, uint8 linkid);
-struct layer *cfmuxl_remove_dnlayer(struct layer *layr, uint8 phyid);
-int cfmuxl_set_dnlayer(struct layer *layr, struct layer *up, uint8 phyid);
-struct layer *cfmuxl_remove_uplayer(struct layer *layr, uint8 linkid);
-bool cfmuxl_is_phy_inuse(struct layer *layr, uint8 phyid);
-uint8 cfmuxl_get_phyid(struct layer *layr, uint8 channel_id);
+struct cflayer *cfmuxl_create(void);
+int cfmuxl_set_uplayer(struct cflayer *layr, struct cflayer *up, u8 linkid);
+struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid);
+int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid);
+struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid);
+bool cfmuxl_is_phy_inuse(struct cflayer *layr, u8 phyid);
+u8 cfmuxl_get_phyid(struct cflayer *layr, u8 channel_id);
#endif /* CFMUXL_H_ */
diff --git a/include/net/caif/cfpkt.h b/include/net/caif/cfpkt.h
index 9f4976426c5..fbc681beff5 100644
--- a/include/net/caif/cfpkt.h
+++ b/include/net/caif/cfpkt.h
@@ -1,20 +1,20 @@
/*
- * 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
*/
#ifndef CFPKT_H_
#define CFPKT_H_
-#include <net/caif/generic/caif_layer.h>
-
+#include <net/caif/caif_layer.h>
+#include <linux/types.h>
struct cfpkt;
/* Create a CAIF packet.
* len: Length of packet to be created
* @return New packet.
*/
-struct cfpkt *cfpkt_create(uint16 len);
+struct cfpkt *cfpkt_create(u16 len);
/* Create a CAIF packet.
* data Data to copy.
@@ -36,7 +36,7 @@ void cfpkt_destroy(struct cfpkt *pkt);
* len Length of head data to copy.
* @return zero on success and error code upon failure
*/
-int cfpkt_extr_head(struct cfpkt *pkt, void *data, uint16 len);
+int cfpkt_extr_head(struct cfpkt *pkt, void *data, u16 len);
/*
* Peek header from packet.
@@ -47,7 +47,7 @@ int cfpkt_extr_head(struct cfpkt *pkt, void *data, uint16 len);
* len Length of head data to copy.
* @return zero on success and error code upon failure
*/
-int cfpkt_peek_head(struct cfpkt *pkt, void *data, uint16 len);
+int cfpkt_peek_head(struct cfpkt *pkt, void *data, u16 len);
/*
* Extract header from trailer (end of packet).
@@ -57,7 +57,7 @@ int cfpkt_peek_head(struct cfpkt *pkt, void *data, uint16 len);
* len Length of header data to copy.
* @return zero on success and error code upon failure
*/
-int cfpkt_extr_trail(struct cfpkt *pkt, void *data, uint16 len);
+int cfpkt_extr_trail(struct cfpkt *pkt, void *data, u16 len);
/*
* Add header to packet.
@@ -68,7 +68,7 @@ int cfpkt_extr_trail(struct cfpkt *pkt, void *data, uint16 len);
* len Length of header data to copy.
* @return zero on success and error code upon failure
*/
-int cfpkt_add_head(struct cfpkt *pkt, const void *data, uint16 len);
+int cfpkt_add_head(struct cfpkt *pkt, const void *data, u16 len);
/*
* Add trailer to packet.
@@ -79,7 +79,7 @@ int cfpkt_add_head(struct cfpkt *pkt, const void *data, uint16 len);
* len Length of trailer data to copy.
* @return zero on success and error code upon failure
*/
-int cfpkt_add_trail(struct cfpkt *pkt, const void *data, uint16 len);
+int cfpkt_add_trail(struct cfpkt *pkt, const void *data, u16 len);
/*
* Pad trailer on packet.
@@ -89,7 +89,7 @@ int cfpkt_add_trail(struct cfpkt *pkt, const void *data, uint16 len);
* len Length of padding to add.
* @return zero on success and error code upon failure
*/
-int cfpkt_pad_trail(struct cfpkt *pkt, uint16 len);
+int cfpkt_pad_trail(struct cfpkt *pkt, u16 len);
/*
* Add a single byte to packet body (tail).
@@ -98,7 +98,7 @@ int cfpkt_pad_trail(struct cfpkt *pkt, uint16 len);
* data Byte to add.
* @return zero on success and error code upon failure
*/
-int cfpkt_addbdy(struct cfpkt *pkt, const uint8 data);
+int cfpkt_addbdy(struct cfpkt *pkt, const u8 data);
/*
* Add a data to packet body (tail).
@@ -108,7 +108,7 @@ int cfpkt_addbdy(struct cfpkt *pkt, const uint8 data);
* len Length of data to add.
* @return zero on success and error code upon failure
*/
-int cfpkt_add_body(struct cfpkt *pkt, const void *data, uint16 len);
+int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len);
/*
* Checks whether there are more data to process in packet.
@@ -131,7 +131,7 @@ bool cfpkt_erroneous(struct cfpkt *pkt);
* pkt Packet to get length from.
* @return Number of bytes in packet.
*/
-uint16 cfpkt_getlen(struct cfpkt *pkt);
+u16 cfpkt_getlen(struct cfpkt *pkt);
/*
* Set the packet length, by adjusting the trailer pointer according to length.
@@ -139,7 +139,7 @@ uint16 cfpkt_getlen(struct cfpkt *pkt);
* len Packet length.
* @return Number of bytes in packet.
*/
-int cfpkt_setlen(struct cfpkt *pkt, uint16 len);
+int cfpkt_setlen(struct cfpkt *pkt, u16 len);
/*
* cfpkt_append - Appends a packet's data to another packet.
@@ -153,7 +153,7 @@ int cfpkt_setlen(struct cfpkt *pkt, uint16 len);
* @return The new appended packet.
*/
struct cfpkt *cfpkt_append(struct cfpkt *dstpkt, struct cfpkt *addpkt,
- uint16 expectlen);
+ u16 expectlen);
/*
* cfpkt_split - Split a packet into two packets at the specified split point.
@@ -161,7 +161,7 @@ struct cfpkt *cfpkt_append(struct cfpkt *dstpkt, struct cfpkt *addpkt,
* pos: Position to split packet in two parts.
* @return The new packet, containing the second part of the data.
*/
-struct cfpkt *cfpkt_split(struct cfpkt *pkt, uint16 pos);
+struct cfpkt *cfpkt_split(struct cfpkt *pkt, u16 pos);
/*
* Iteration function, iterates the packet buffers from start to end.
@@ -177,9 +177,9 @@ struct cfpkt *cfpkt_split(struct cfpkt *pkt, uint16 pos);
* @return Checksum of buffer.
*/
-uint16 cfpkt_iterate(struct cfpkt *pkt,
- uint16 (*iter_func)(uint16 chks, void *buf, uint16 len),
- uint16 data);
+u16 cfpkt_iterate(struct cfpkt *pkt,
+ u16 (*iter_func)(u16 chks, void *buf, u16 len),
+ u16 data);
/* Append by giving user access to packet buffer
* cfpkt Packet to append to
@@ -269,6 +269,6 @@ struct cfpkt *cfpkt_clone_release(struct cfpkt *pkt);
* pkt Packet to get info from;
* @return Packet information
*/
-struct payload_info *cfpkt_info(struct cfpkt *pkt);
+struct caif_payload_info *cfpkt_info(struct cfpkt *pkt);
/*! @} */
#endif /* CFPKT_H_ */
diff --git a/include/net/caif/cfserl.h b/include/net/caif/cfserl.h
index b5c968f4107..b8374321b36 100644
--- a/include/net/caif/cfserl.h
+++ b/include/net/caif/cfserl.h
@@ -1,14 +1,12 @@
/*
- * 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
*/
#ifndef CFSERL_H_
#define CFSERL_H_
-#include <net/caif/generic/caif_layer.h>
-#include <net/caif/generic/cfglue.h>
-
-struct layer *cfserl_create(int type, int instance, bool use_stx);
+#include <net/caif/caif_layer.h>
+struct cflayer *cfserl_create(int type, int instance, bool use_stx);
#endif /* CFSERL_H_ */
diff --git a/include/net/caif/cfsrvl.h b/include/net/caif/cfsrvl.h
index 301860953ac..2dc9eb193ec 100644
--- a/include/net/caif/cfsrvl.h
+++ b/include/net/caif/cfsrvl.h
@@ -1,33 +1,56 @@
/*
- * 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
*/
#ifndef CFSRVL_H_
#define CFSRVL_H_
-#include <net/caif/generic/cfglue.h>
-#include <stddef.h>
+#include <linux/list.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+#include <linux/kref.h>
struct cfsrvl {
- struct layer layer;
+ struct cflayer layer;
bool open;
bool phy_flow_on;
bool modem_flow_on;
struct dev_info dev_info;
+ struct kref ref;
};
-struct layer *cfvei_create(uint8 linkid, struct dev_info *dev_info);
-struct layer *cfdgml_create(uint8 linkid, struct dev_info *dev_info);
-struct layer *cfutill_create(uint8 linkid, struct dev_info *dev_info);
-struct layer *cfvidl_create(uint8 linkid, struct dev_info *dev_info);
-struct layer *cfrfml_create(uint8 linkid, struct dev_info *dev_info);
-bool cfsrvl_phyid_match(struct layer *layer, int phyid);
-void cfservl_destroy(struct layer *layer);
+void cfsrvl_release(struct kref *kref);
+struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info);
+struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info);
+struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info);
+struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info);
+struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info);
+struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info);
+bool cfsrvl_phyid_match(struct cflayer *layer, int phyid);
+void cfservl_destroy(struct cflayer *layer);
void cfsrvl_init(struct cfsrvl *service,
- uint8 channel_id,
+ u8 channel_id,
struct dev_info *dev_info);
bool cfsrvl_ready(struct cfsrvl *service, int *err);
-uint8 cfsrvl_getphyid(struct layer *layer);
+u8 cfsrvl_getphyid(struct cflayer *layer);
+
+static inline void cfsrvl_get(struct cflayer *layr)
+{
+ struct cfsrvl *s;
+ if (layr == NULL)
+ return;
+ s = container_of(layr, struct cfsrvl, layer);
+ kref_get(&s->ref);
+}
+
+static inline void cfsrvl_put(struct cflayer *layr)
+{
+ struct cfsrvl *s;
+ if (layr == NULL)
+ return;
+ s = container_of(layr, struct cfsrvl, layer);
+ kref_put(&s->ref, cfsrvl_release);
+}
#endif /* CFSRVL_H_ */