Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net-caif: add CAIF core protocol stack header files

Add include files for the CAIF Core protocol stack.

caif_layer.h - Defines the structure of the CAIF protocol layers
cfcnfg.h - CAIF Configuration Module for services and link layers
cfctrl.h - CAIF Control Protocol Layer
cffrml.h - CAIF Framing Layer
cfmuxl.h - CAIF Muxing Layer
cfpkt.h - CAIF Packet layer (skb helper functions)
cfserl.h - CAIF Serial Layer
cfsrvl.h - CAIF Service Layer

Signed-off-by: Sjur Braendeland <sjur.brandeland@stericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Sjur Braendeland and committed by
David S. Miller
09009f30 f671c542

+912
+283
include/net/caif/caif_layer.h
··· 1 + /* 2 + * Copyright (C) ST-Ericsson AB 2010 3 + * Author: Sjur Brendeland / sjur.brandeland@stericsson.com 4 + * License terms: GNU General Public License (GPL) version 2 5 + */ 6 + 7 + #ifndef CAIF_LAYER_H_ 8 + #define CAIF_LAYER_H_ 9 + 10 + #include <linux/list.h> 11 + 12 + struct cflayer; 13 + struct cfpkt; 14 + struct cfpktq; 15 + struct caif_payload_info; 16 + struct caif_packet_funcs; 17 + 18 + #define CAIF_MAX_FRAMESIZE 4096 19 + #define CAIF_MAX_PAYLOAD_SIZE (4096 - 64) 20 + #define CAIF_NEEDED_HEADROOM (10) 21 + #define CAIF_NEEDED_TAILROOM (2) 22 + 23 + #define CAIF_LAYER_NAME_SZ 16 24 + #define CAIF_SUCCESS 1 25 + #define CAIF_FAILURE 0 26 + 27 + /** 28 + * caif_assert() - Assert function for CAIF. 29 + * @assert: expression to evaluate. 30 + * 31 + * This function will print a error message and a do WARN_ON if the 32 + * assertion failes. Normally this will do a stack up at the current location. 33 + */ 34 + #define caif_assert(assert) \ 35 + do { \ 36 + if (!(assert)) { \ 37 + pr_err("caif:Assert detected:'%s'\n", #assert); \ 38 + WARN_ON(!(assert)); \ 39 + } \ 40 + } while (0) 41 + 42 + 43 + /** 44 + * enum caif_ctrlcmd - CAIF Stack Control Signaling sent in layer.ctrlcmd(). 45 + * 46 + * @CAIF_CTRLCMD_FLOW_OFF_IND: Flow Control is OFF, transmit function 47 + * should stop sending data 48 + * 49 + * @CAIF_CTRLCMD_FLOW_ON_IND: Flow Control is ON, transmit function 50 + * can start sending data 51 + * 52 + * @CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND: Remote end modem has decided to close 53 + * down channel 54 + * 55 + * @CAIF_CTRLCMD_INIT_RSP: Called initially when the layer below 56 + * has finished initialization 57 + * 58 + * @CAIF_CTRLCMD_DEINIT_RSP: Called when de-initialization is 59 + * complete 60 + * 61 + * @CAIF_CTRLCMD_INIT_FAIL_RSP: Called if initialization fails 62 + * 63 + * @_CAIF_CTRLCMD_PHYIF_FLOW_OFF_IND: CAIF Link layer temporarily cannot 64 + * send more packets. 65 + * @_CAIF_CTRLCMD_PHYIF_FLOW_ON_IND: Called if CAIF Link layer is able 66 + * to send packets again. 67 + * @_CAIF_CTRLCMD_PHYIF_DOWN_IND: Called if CAIF Link layer is going 68 + * down. 69 + * 70 + * These commands are sent upwards in the CAIF stack to the CAIF Client. 71 + * They are used for signaling originating from the modem or CAIF Link Layer. 72 + * These are either responses (*_RSP) or events (*_IND). 73 + */ 74 + enum caif_ctrlcmd { 75 + CAIF_CTRLCMD_FLOW_OFF_IND, 76 + CAIF_CTRLCMD_FLOW_ON_IND, 77 + CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND, 78 + CAIF_CTRLCMD_INIT_RSP, 79 + CAIF_CTRLCMD_DEINIT_RSP, 80 + CAIF_CTRLCMD_INIT_FAIL_RSP, 81 + _CAIF_CTRLCMD_PHYIF_FLOW_OFF_IND, 82 + _CAIF_CTRLCMD_PHYIF_FLOW_ON_IND, 83 + _CAIF_CTRLCMD_PHYIF_DOWN_IND, 84 + }; 85 + 86 + /** 87 + * enum caif_modemcmd - Modem Control Signaling, sent from CAIF Client 88 + * to the CAIF Link Layer or modem. 89 + * 90 + * @CAIF_MODEMCMD_FLOW_ON_REQ: Flow Control is ON, transmit function 91 + * can start sending data. 92 + * 93 + * @CAIF_MODEMCMD_FLOW_OFF_REQ: Flow Control is OFF, transmit function 94 + * should stop sending data. 95 + * 96 + * @_CAIF_MODEMCMD_PHYIF_USEFULL: Notify physical layer that it is in use 97 + * 98 + * @_CAIF_MODEMCMD_PHYIF_USELESS: Notify physical layer that it is 99 + * no longer in use. 100 + * 101 + * These are requests sent 'downwards' in the stack. 102 + * Flow ON, OFF can be indicated to the modem. 103 + */ 104 + enum caif_modemcmd { 105 + CAIF_MODEMCMD_FLOW_ON_REQ = 0, 106 + CAIF_MODEMCMD_FLOW_OFF_REQ = 1, 107 + _CAIF_MODEMCMD_PHYIF_USEFULL = 3, 108 + _CAIF_MODEMCMD_PHYIF_USELESS = 4 109 + }; 110 + 111 + /** 112 + * enum caif_direction - CAIF Packet Direction. 113 + * Indicate if a packet is to be sent out or to be received in. 114 + * @CAIF_DIR_IN: Incoming packet received. 115 + * @CAIF_DIR_OUT: Outgoing packet to be transmitted. 116 + */ 117 + enum caif_direction { 118 + CAIF_DIR_IN = 0, 119 + CAIF_DIR_OUT = 1 120 + }; 121 + 122 + /** 123 + * struct cflayer - CAIF Stack layer. 124 + * Defines the framework for the CAIF Core Stack. 125 + * @up: Pointer up to the layer above. 126 + * @dn: Pointer down to the layer below. 127 + * @node: List node used when layer participate in a list. 128 + * @receive: Packet receive function. 129 + * @transmit: Packet transmit funciton. 130 + * @ctrlcmd: Used for control signalling upwards in the stack. 131 + * @modemcmd: Used for control signaling downwards in the stack. 132 + * @prio: Priority of this layer. 133 + * @id: The identity of this layer 134 + * @type: The type of this layer 135 + * @name: Name of the layer. 136 + * 137 + * This structure defines the layered structure in CAIF. 138 + * 139 + * It defines CAIF layering structure, used by all CAIF Layers and the 140 + * layers interfacing CAIF. 141 + * 142 + * In order to integrate with CAIF an adaptation layer on top of the CAIF stack 143 + * and PHY layer below the CAIF stack 144 + * must be implemented. These layer must follow the design principles below. 145 + * 146 + * Principles for layering of protocol layers: 147 + * - All layers must use this structure. If embedding it, then place this 148 + * structure first in the layer specific structure. 149 + * 150 + * - Each layer should not depend on any others layer private data. 151 + * 152 + * - In order to send data upwards do 153 + * layer->up->receive(layer->up, packet); 154 + * 155 + * - In order to send data downwards do 156 + * layer->dn->transmit(layer->dn, info, packet); 157 + */ 158 + struct cflayer { 159 + struct cflayer *up; 160 + struct cflayer *dn; 161 + struct list_head node; 162 + 163 + /* 164 + * receive() - Receive Function. 165 + * Contract: Each layer must implement a receive function passing the 166 + * CAIF packets upwards in the stack. 167 + * Packet handling rules: 168 + * - The CAIF packet (cfpkt) cannot be accessed after 169 + * passing it to the next layer using up->receive(). 170 + * - If parsing of the packet fails, the packet must be 171 + * destroyed and -1 returned from the function. 172 + * - If parsing succeeds (and above layers return OK) then 173 + * the function must return a value > 0. 174 + * 175 + * Returns result < 0 indicates an error, 0 or positive value 176 + * indicates success. 177 + * 178 + * @layr: Pointer to the current layer the receive function is 179 + * implemented for (this pointer). 180 + * @cfpkt: Pointer to CaifPacket to be handled. 181 + */ 182 + int (*receive)(struct cflayer *layr, struct cfpkt *cfpkt); 183 + 184 + /* 185 + * transmit() - Transmit Function. 186 + * Contract: Each layer must implement a transmit function passing the 187 + * CAIF packet downwards in the stack. 188 + * Packet handling rules: 189 + * - The CAIF packet (cfpkt) ownership is passed to the 190 + * transmit function. This means that the the packet 191 + * cannot be accessed after passing it to the below 192 + * layer using dn->transmit(). 193 + * 194 + * - If transmit fails, however, the ownership is returned 195 + * to thecaller. The caller of "dn->transmit()" must 196 + * destroy or resend packet. 197 + * 198 + * - Return value less than zero means error, zero or 199 + * greater than zero means OK. 200 + * 201 + * result < 0 indicates an error, 0 or positive value 202 + * indicate success. 203 + * 204 + * @layr: Pointer to the current layer the receive function 205 + * isimplemented for (this pointer). 206 + * @cfpkt: Pointer to CaifPacket to be handled. 207 + */ 208 + int (*transmit) (struct cflayer *layr, struct cfpkt *cfpkt); 209 + 210 + /* 211 + * cttrlcmd() - Control Function upwards in CAIF Stack. 212 + * Used for signaling responses (CAIF_CTRLCMD_*_RSP) 213 + * and asynchronous events from the modem (CAIF_CTRLCMD_*_IND) 214 + * 215 + * @layr: Pointer to the current layer the receive function 216 + * is implemented for (this pointer). 217 + * @ctrl: Control Command. 218 + */ 219 + void (*ctrlcmd) (struct cflayer *layr, enum caif_ctrlcmd ctrl, 220 + int phyid); 221 + 222 + /* 223 + * modemctrl() - Control Function used for controlling the modem. 224 + * Used to signal down-wards in the CAIF stack. 225 + * Returns 0 on success, < 0 upon failure. 226 + * 227 + * @layr: Pointer to the current layer the receive function 228 + * is implemented for (this pointer). 229 + * @ctrl: Control Command. 230 + */ 231 + int (*modemcmd) (struct cflayer *layr, enum caif_modemcmd ctrl); 232 + 233 + unsigned short prio; 234 + unsigned int id; 235 + unsigned int type; 236 + char name[CAIF_LAYER_NAME_SZ]; 237 + }; 238 + 239 + /** 240 + * layer_set_up() - Set the up pointer for a specified layer. 241 + * @layr: Layer where up pointer shall be set. 242 + * @above: Layer above. 243 + */ 244 + #define layer_set_up(layr, above) ((layr)->up = (struct cflayer *)(above)) 245 + 246 + /** 247 + * layer_set_dn() - Set the down pointer for a specified layer. 248 + * @layr: Layer where down pointer shall be set. 249 + * @below: Layer below. 250 + */ 251 + #define layer_set_dn(layr, below) ((layr)->dn = (struct cflayer *)(below)) 252 + 253 + /** 254 + * struct dev_info - Physical Device info information about physical layer. 255 + * @dev: Pointer to native physical device. 256 + * @id: Physical ID of the physical connection used by the 257 + * logical CAIF connection. Used by service layers to 258 + * identify their physical id to Caif MUX (CFMUXL)so 259 + * that the MUX can add the correct physical ID to the 260 + * packet. 261 + */ 262 + struct dev_info { 263 + void *dev; 264 + unsigned int id; 265 + }; 266 + 267 + /** 268 + * struct caif_payload_info - Payload information embedded in packet (sk_buff). 269 + * 270 + * @dev_info: Information about the receiving device. 271 + * 272 + * @hdr_len: Header length, used to align pay load on 32bit boundary. 273 + * 274 + * @channel_id: Channel ID of the logical CAIF connection. 275 + * Used by mux to insert channel id into the caif packet. 276 + */ 277 + struct caif_payload_info { 278 + struct dev_info *dev_info; 279 + unsigned short hdr_len; 280 + unsigned short channel_id; 281 + }; 282 + 283 + #endif /* CAIF_LAYER_H_ */
+133
include/net/caif/cfcnfg.h
··· 1 + /* 2 + * Copyright (C) ST-Ericsson AB 2010 3 + * Author: Sjur Brendeland/sjur.brandeland@stericsson.com 4 + * License terms: GNU General Public License (GPL) version 2 5 + */ 6 + 7 + #ifndef CFCNFG_H_ 8 + #define CFCNFG_H_ 9 + #include <linux/spinlock.h> 10 + #include <net/caif/caif_layer.h> 11 + #include <net/caif/cfctrl.h> 12 + 13 + struct cfcnfg; 14 + 15 + /** 16 + * enum cfcnfg_phy_type - Types of physical layers defined in CAIF Stack 17 + * 18 + * @CFPHYTYPE_FRAG: Fragmented frames physical interface. 19 + * @CFPHYTYPE_CAIF: Generic CAIF physical interface 20 + */ 21 + enum cfcnfg_phy_type { 22 + CFPHYTYPE_FRAG = 1, 23 + CFPHYTYPE_CAIF, 24 + CFPHYTYPE_MAX 25 + }; 26 + 27 + /** 28 + * enum cfcnfg_phy_preference - Physical preference HW Abstraction 29 + * 30 + * @CFPHYPREF_UNSPECIFIED: Default physical interface 31 + * 32 + * @CFPHYPREF_LOW_LAT: Default physical interface for low-latency 33 + * traffic 34 + * @CFPHYPREF_HIGH_BW: Default physical interface for high-bandwidth 35 + * traffic 36 + * @CFPHYPREF_LOOP: TEST only Loopback interface simulating modem 37 + * responses. 38 + * 39 + */ 40 + enum cfcnfg_phy_preference { 41 + CFPHYPREF_UNSPECIFIED, 42 + CFPHYPREF_LOW_LAT, 43 + CFPHYPREF_HIGH_BW, 44 + CFPHYPREF_LOOP 45 + }; 46 + 47 + /** 48 + * cfcnfg_create() - Create the CAIF configuration object. 49 + */ 50 + struct cfcnfg *cfcnfg_create(void); 51 + 52 + /** 53 + * cfcnfg_remove() - Remove the CFCNFG object 54 + * @cfg: config object 55 + */ 56 + void cfcnfg_remove(struct cfcnfg *cfg); 57 + 58 + /** 59 + * cfcnfg_add_phy_layer() - Adds a physical layer to the CAIF stack. 60 + * @cnfg: Pointer to a CAIF configuration object, created by 61 + * cfcnfg_create(). 62 + * @phy_type: Specifies the type of physical interface, e.g. 63 + * CFPHYTYPE_FRAG. 64 + * @dev: Pointer to link layer device 65 + * @phy_layer: Specify the physical layer. The transmit function 66 + * MUST be set in the structure. 67 + * @phyid: The assigned physical ID for this layer, used in 68 + * cfcnfg_add_adapt_layer to specify PHY for the link. 69 + * @pref: The phy (link layer) preference. 70 + * @fcs: Specify if checksum is used in CAIF Framing Layer. 71 + * @stx: Specify if Start Of Frame eXtention is used. 72 + */ 73 + 74 + void 75 + cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, 76 + void *dev, struct cflayer *phy_layer, u16 *phyid, 77 + enum cfcnfg_phy_preference pref, 78 + bool fcs, bool stx); 79 + 80 + /** 81 + * cfcnfg_del_phy_layer - Deletes an phy layer from the CAIF stack. 82 + * 83 + * @cnfg: Pointer to a CAIF configuration object, created by 84 + * cfcnfg_create(). 85 + * @phy_layer: Adaptation layer to be removed. 86 + */ 87 + int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer); 88 + 89 + /** 90 + * cfcnfg_del_adapt_layer - Deletes an adaptation layer from the CAIF stack. 91 + * 92 + * @cnfg: Pointer to a CAIF configuration object, created by 93 + * cfcnfg_create(). 94 + * @adap_layer: Adaptation layer to be removed. 95 + */ 96 + int cfcnfg_del_adapt_layer(struct cfcnfg *cnfg, struct cflayer *adap_layer); 97 + 98 + /** 99 + * cfcnfg_add_adaptation_layer - Add an adaptation layer to the CAIF stack. 100 + * 101 + * The adaptation Layer is where the interface to application or higher-level 102 + * driver functionality is implemented. 103 + * 104 + * @cnfg: Pointer to a CAIF configuration object, created by 105 + * cfcnfg_create(). 106 + * @param: Link setup parameters. 107 + * @adap_layer: Specify the adaptation layer; the receive and 108 + * flow-control functions MUST be set in the structure. 109 + * 110 + */ 111 + int 112 + cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, 113 + struct cfctrl_link_param *param, 114 + struct cflayer *adap_layer); 115 + 116 + /** 117 + * cfcnfg_get_phyid() - Get physical ID, given type. 118 + * Returns one of the physical interfaces matching the given type. 119 + * Zero if no match is found. 120 + * @cnfg: Configuration object 121 + * @phy_pref: Caif Link Layer preference 122 + */ 123 + struct dev_info *cfcnfg_get_phyid(struct cfcnfg *cnfg, 124 + enum cfcnfg_phy_preference phy_pref); 125 + 126 + /** 127 + * cfcnfg_get_named() - Get the Physical Identifier of CAIF Link Layer 128 + * @cnfg: Configuration object 129 + * @name: Name of the Physical Layer (Caif Link Layer) 130 + */ 131 + int cfcnfg_get_named(struct cfcnfg *cnfg, char *name); 132 + 133 + #endif /* CFCNFG_H_ */
+138
include/net/caif/cfctrl.h
··· 1 + /* 2 + * Copyright (C) ST-Ericsson AB 2010 3 + * Author: Sjur Brendeland/sjur.brandeland@stericsson.com 4 + * License terms: GNU General Public License (GPL) version 2 5 + */ 6 + 7 + #ifndef CFCTRL_H_ 8 + #define CFCTRL_H_ 9 + #include <net/caif/caif_layer.h> 10 + #include <net/caif/cfsrvl.h> 11 + 12 + /* CAIF Control packet commands */ 13 + enum cfctrl_cmd { 14 + CFCTRL_CMD_LINK_SETUP = 0, 15 + CFCTRL_CMD_LINK_DESTROY = 1, 16 + CFCTRL_CMD_LINK_ERR = 2, 17 + CFCTRL_CMD_ENUM = 3, 18 + CFCTRL_CMD_SLEEP = 4, 19 + CFCTRL_CMD_WAKE = 5, 20 + CFCTRL_CMD_LINK_RECONF = 6, 21 + CFCTRL_CMD_START_REASON = 7, 22 + CFCTRL_CMD_RADIO_SET = 8, 23 + CFCTRL_CMD_MODEM_SET = 9, 24 + CFCTRL_CMD_MASK = 0xf 25 + }; 26 + 27 + /* Channel types */ 28 + enum cfctrl_srv { 29 + CFCTRL_SRV_DECM = 0, 30 + CFCTRL_SRV_VEI = 1, 31 + CFCTRL_SRV_VIDEO = 2, 32 + CFCTRL_SRV_DBG = 3, 33 + CFCTRL_SRV_DATAGRAM = 4, 34 + CFCTRL_SRV_RFM = 5, 35 + CFCTRL_SRV_UTIL = 6, 36 + CFCTRL_SRV_MASK = 0xf 37 + }; 38 + 39 + #define CFCTRL_RSP_BIT 0x20 40 + #define CFCTRL_ERR_BIT 0x10 41 + 42 + struct cfctrl_rsp { 43 + void (*linksetup_rsp)(struct cflayer *layer, u8 linkid, 44 + enum cfctrl_srv serv, u8 phyid, 45 + struct cflayer *adapt_layer); 46 + void (*linkdestroy_rsp)(struct cflayer *layer, u8 linkid, 47 + struct cflayer *client_layer); 48 + void (*linkerror_ind)(void); 49 + void (*enum_rsp)(void); 50 + void (*sleep_rsp)(void); 51 + void (*wake_rsp)(void); 52 + void (*restart_rsp)(void); 53 + void (*radioset_rsp)(void); 54 + void (*reject_rsp)(struct cflayer *layer, u8 linkid, 55 + struct cflayer *client_layer);; 56 + }; 57 + 58 + /* Link Setup Parameters for CAIF-Links. */ 59 + struct cfctrl_link_param { 60 + enum cfctrl_srv linktype;/* (T3,T0) Type of Channel */ 61 + u8 priority; /* (P4,P0) Priority of the channel */ 62 + u8 phyid; /* (U2-U0) Physical interface to connect */ 63 + u8 endpoint; /* (E1,E0) Endpoint for data channels */ 64 + u8 chtype; /* (H1,H0) Channel-Type, applies to 65 + * VEI, DEBUG */ 66 + union { 67 + struct { 68 + u8 connid; /* (D7,D0) Video LinkId */ 69 + } video; 70 + 71 + struct { 72 + u32 connid; /* (N31,Ngit0) Connection ID used 73 + * for Datagram */ 74 + } datagram; 75 + 76 + struct { 77 + u32 connid; /* Connection ID used for RFM */ 78 + char volume[20]; /* Volume to mount for RFM */ 79 + } rfm; /* Configuration for RFM */ 80 + 81 + struct { 82 + u16 fifosize_kb; /* Psock FIFO size in KB */ 83 + u16 fifosize_bufs; /* Psock # signal buffers */ 84 + char name[16]; /* Name of the PSOCK service */ 85 + u8 params[255]; /* Link setup Parameters> */ 86 + u16 paramlen; /* Length of Link Setup 87 + * Parameters */ 88 + } utility; /* Configuration for Utility Links (Psock) */ 89 + } u; 90 + }; 91 + 92 + /* This structure is used internally in CFCTRL */ 93 + struct cfctrl_request_info { 94 + int sequence_no; 95 + enum cfctrl_cmd cmd; 96 + u8 channel_id; 97 + struct cfctrl_link_param param; 98 + struct cfctrl_request_info *next; 99 + struct cflayer *client_layer; 100 + }; 101 + 102 + struct cfctrl { 103 + struct cfsrvl serv; 104 + struct cfctrl_rsp res; 105 + atomic_t req_seq_no; 106 + atomic_t rsp_seq_no; 107 + struct cfctrl_request_info *first_req; 108 + /* Protects from simultaneous access to first_req list */ 109 + spinlock_t info_list_lock; 110 + #ifndef CAIF_NO_LOOP 111 + u8 loop_linkid; 112 + int loop_linkused[256]; 113 + /* Protects simultaneous access to loop_linkid and loop_linkused */ 114 + spinlock_t loop_linkid_lock; 115 + #endif 116 + 117 + }; 118 + 119 + void cfctrl_enum_req(struct cflayer *cfctrl, u8 physlinkid); 120 + void cfctrl_linkup_request(struct cflayer *cfctrl, 121 + struct cfctrl_link_param *param, 122 + struct cflayer *user_layer); 123 + int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid, 124 + struct cflayer *client); 125 + void cfctrl_sleep_req(struct cflayer *cfctrl); 126 + void cfctrl_wake_req(struct cflayer *cfctrl); 127 + void cfctrl_getstartreason_req(struct cflayer *cfctrl); 128 + struct cflayer *cfctrl_create(void); 129 + void cfctrl_set_dnlayer(struct cflayer *this, struct cflayer *dn); 130 + void cfctrl_set_uplayer(struct cflayer *this, struct cflayer *up); 131 + struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer); 132 + bool cfctrl_req_eq(struct cfctrl_request_info *r1, 133 + struct cfctrl_request_info *r2); 134 + void cfctrl_insert_req(struct cfctrl *ctrl, 135 + struct cfctrl_request_info *req); 136 + struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl, 137 + struct cfctrl_request_info *req); 138 + #endif /* CFCTRL_H_ */
+16
include/net/caif/cffrml.h
··· 1 + /* 2 + * Copyright (C) ST-Ericsson AB 2010 3 + * Author: Sjur Brendeland/sjur.brandeland@stericsson.com 4 + * License terms: GNU General Public License (GPL) version 2 5 + */ 6 + 7 + #ifndef CFFRML_H_ 8 + #define CFFRML_H_ 9 + #include <net/caif/caif_layer.h> 10 + 11 + struct cffrml; 12 + struct cflayer *cffrml_create(u16 phyid, bool DoFCS); 13 + void cffrml_set_uplayer(struct cflayer *this, struct cflayer *up); 14 + void cffrml_set_dnlayer(struct cflayer *this, struct cflayer *dn); 15 + 16 + #endif /* CFFRML_H_ */
+22
include/net/caif/cfmuxl.h
··· 1 + /* 2 + * Copyright (C) ST-Ericsson AB 2010 3 + * Author: Sjur Brendeland/sjur.brandeland@stericsson.com 4 + * License terms: GNU General Public License (GPL) version 2 5 + */ 6 + 7 + #ifndef CFMUXL_H_ 8 + #define CFMUXL_H_ 9 + #include <net/caif/caif_layer.h> 10 + 11 + struct cfsrvl; 12 + struct cffrml; 13 + 14 + struct cflayer *cfmuxl_create(void); 15 + int cfmuxl_set_uplayer(struct cflayer *layr, struct cflayer *up, u8 linkid); 16 + struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid); 17 + int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid); 18 + struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid); 19 + bool cfmuxl_is_phy_inuse(struct cflayer *layr, u8 phyid); 20 + u8 cfmuxl_get_phyid(struct cflayer *layr, u8 channel_id); 21 + 22 + #endif /* CFMUXL_H_ */
+274
include/net/caif/cfpkt.h
··· 1 + /* 2 + * Copyright (C) ST-Ericsson AB 2010 3 + * Author: Sjur Brendeland/sjur.brandeland@stericsson.com 4 + * License terms: GNU General Public License (GPL) version 2 5 + */ 6 + 7 + #ifndef CFPKT_H_ 8 + #define CFPKT_H_ 9 + #include <net/caif/caif_layer.h> 10 + #include <linux/types.h> 11 + struct cfpkt; 12 + 13 + /* Create a CAIF packet. 14 + * len: Length of packet to be created 15 + * @return New packet. 16 + */ 17 + struct cfpkt *cfpkt_create(u16 len); 18 + 19 + /* Create a CAIF packet. 20 + * data Data to copy. 21 + * len Length of packet to be created 22 + * @return New packet. 23 + */ 24 + struct cfpkt *cfpkt_create_uplink(const unsigned char *data, unsigned int len); 25 + /* 26 + * Destroy a CAIF Packet. 27 + * pkt Packet to be destoyed. 28 + */ 29 + void cfpkt_destroy(struct cfpkt *pkt); 30 + 31 + /* 32 + * Extract header from packet. 33 + * 34 + * pkt Packet to extract header data from. 35 + * data Pointer to copy the header data into. 36 + * len Length of head data to copy. 37 + * @return zero on success and error code upon failure 38 + */ 39 + int cfpkt_extr_head(struct cfpkt *pkt, void *data, u16 len); 40 + 41 + /* 42 + * Peek header from packet. 43 + * Reads data from packet without changing packet. 44 + * 45 + * pkt Packet to extract header data from. 46 + * data Pointer to copy the header data into. 47 + * len Length of head data to copy. 48 + * @return zero on success and error code upon failure 49 + */ 50 + int cfpkt_peek_head(struct cfpkt *pkt, void *data, u16 len); 51 + 52 + /* 53 + * Extract header from trailer (end of packet). 54 + * 55 + * pkt Packet to extract header data from. 56 + * data Pointer to copy the trailer data into. 57 + * len Length of header data to copy. 58 + * @return zero on success and error code upon failure 59 + */ 60 + int cfpkt_extr_trail(struct cfpkt *pkt, void *data, u16 len); 61 + 62 + /* 63 + * Add header to packet. 64 + * 65 + * 66 + * pkt Packet to add header data to. 67 + * data Pointer to data to copy into the header. 68 + * len Length of header data to copy. 69 + * @return zero on success and error code upon failure 70 + */ 71 + int cfpkt_add_head(struct cfpkt *pkt, const void *data, u16 len); 72 + 73 + /* 74 + * Add trailer to packet. 75 + * 76 + * 77 + * pkt Packet to add trailer data to. 78 + * data Pointer to data to copy into the trailer. 79 + * len Length of trailer data to copy. 80 + * @return zero on success and error code upon failure 81 + */ 82 + int cfpkt_add_trail(struct cfpkt *pkt, const void *data, u16 len); 83 + 84 + /* 85 + * Pad trailer on packet. 86 + * Moves data pointer in packet, no content copied. 87 + * 88 + * pkt Packet in which to pad trailer. 89 + * len Length of padding to add. 90 + * @return zero on success and error code upon failure 91 + */ 92 + int cfpkt_pad_trail(struct cfpkt *pkt, u16 len); 93 + 94 + /* 95 + * Add a single byte to packet body (tail). 96 + * 97 + * pkt Packet in which to add byte. 98 + * data Byte to add. 99 + * @return zero on success and error code upon failure 100 + */ 101 + int cfpkt_addbdy(struct cfpkt *pkt, const u8 data); 102 + 103 + /* 104 + * Add a data to packet body (tail). 105 + * 106 + * pkt Packet in which to add data. 107 + * data Pointer to data to copy into the packet body. 108 + * len Length of data to add. 109 + * @return zero on success and error code upon failure 110 + */ 111 + int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len); 112 + 113 + /* 114 + * Checks whether there are more data to process in packet. 115 + * pkt Packet to check. 116 + * @return true if more data are available in packet false otherwise 117 + */ 118 + bool cfpkt_more(struct cfpkt *pkt); 119 + 120 + /* 121 + * Checks whether the packet is erroneous, 122 + * i.e. if it has been attempted to extract more data than available in packet 123 + * or writing more data than has been allocated in cfpkt_create(). 124 + * pkt Packet to check. 125 + * @return true on error false otherwise 126 + */ 127 + bool cfpkt_erroneous(struct cfpkt *pkt); 128 + 129 + /* 130 + * Get the packet length. 131 + * pkt Packet to get length from. 132 + * @return Number of bytes in packet. 133 + */ 134 + u16 cfpkt_getlen(struct cfpkt *pkt); 135 + 136 + /* 137 + * Set the packet length, by adjusting the trailer pointer according to length. 138 + * pkt Packet to set length. 139 + * len Packet length. 140 + * @return Number of bytes in packet. 141 + */ 142 + int cfpkt_setlen(struct cfpkt *pkt, u16 len); 143 + 144 + /* 145 + * cfpkt_append - Appends a packet's data to another packet. 146 + * dstpkt: Packet to append data into, WILL BE FREED BY THIS FUNCTION 147 + * addpkt: Packet to be appended and automatically released, 148 + * WILL BE FREED BY THIS FUNCTION. 149 + * expectlen: Packet's expected total length. This should be considered 150 + * as a hint. 151 + * NB: Input packets will be destroyed after appending and cannot be used 152 + * after calling this function. 153 + * @return The new appended packet. 154 + */ 155 + struct cfpkt *cfpkt_append(struct cfpkt *dstpkt, struct cfpkt *addpkt, 156 + u16 expectlen); 157 + 158 + /* 159 + * cfpkt_split - Split a packet into two packets at the specified split point. 160 + * pkt: Packet to be split (will contain the first part of the data on exit) 161 + * pos: Position to split packet in two parts. 162 + * @return The new packet, containing the second part of the data. 163 + */ 164 + struct cfpkt *cfpkt_split(struct cfpkt *pkt, u16 pos); 165 + 166 + /* 167 + * Iteration function, iterates the packet buffers from start to end. 168 + * 169 + * Checksum iteration function used to iterate buffers 170 + * (we may have packets consisting of a chain of buffers) 171 + * pkt: Packet to calculate checksum for 172 + * iter_func: Function pointer to iteration function 173 + * chks: Checksum calculated so far. 174 + * buf: Pointer to the buffer to checksum 175 + * len: Length of buf. 176 + * data: Initial checksum value. 177 + * @return Checksum of buffer. 178 + */ 179 + 180 + u16 cfpkt_iterate(struct cfpkt *pkt, 181 + u16 (*iter_func)(u16 chks, void *buf, u16 len), 182 + u16 data); 183 + 184 + /* Append by giving user access to packet buffer 185 + * cfpkt Packet to append to 186 + * buf Buffer inside pkt that user shall copy data into 187 + * buflen Length of buffer and number of bytes added to packet 188 + * @return 0 on error, 1 on success 189 + */ 190 + int cfpkt_raw_append(struct cfpkt *cfpkt, void **buf, unsigned int buflen); 191 + 192 + /* Extract by giving user access to packet buffer 193 + * cfpkt Packet to extract from 194 + * buf Buffer inside pkt that user shall copy data from 195 + * buflen Length of buffer and number of bytes removed from packet 196 + * @return 0 on error, 1 on success 197 + */ 198 + int cfpkt_raw_extract(struct cfpkt *cfpkt, void **buf, unsigned int buflen); 199 + 200 + /* Map from a "native" packet (e.g. Linux Socket Buffer) to a CAIF packet. 201 + * dir - Direction indicating whether this packet is to be sent or received. 202 + * nativepkt - The native packet to be transformed to a CAIF packet 203 + * @return The mapped CAIF Packet CFPKT. 204 + */ 205 + struct cfpkt *cfpkt_fromnative(enum caif_direction dir, void *nativepkt); 206 + 207 + /* Map from a CAIF packet to a "native" packet (e.g. Linux Socket Buffer). 208 + * pkt - The CAIF packet to be transformed into a "native" packet. 209 + * @return The native packet transformed from a CAIF packet. 210 + */ 211 + void *cfpkt_tonative(struct cfpkt *pkt); 212 + 213 + /* 214 + * Insert a packet in the packet queue. 215 + * pktq Packet queue to insert into 216 + * pkt Packet to be inserted in queue 217 + * prio Priority of packet 218 + */ 219 + void cfpkt_queue(struct cfpktq *pktq, struct cfpkt *pkt, 220 + unsigned short prio); 221 + 222 + /* 223 + * Remove a packet from the packet queue. 224 + * pktq Packet queue to fetch packets from. 225 + * @return Dequeued packet. 226 + */ 227 + struct cfpkt *cfpkt_dequeue(struct cfpktq *pktq); 228 + 229 + /* 230 + * Peek into a packet from the packet queue. 231 + * pktq Packet queue to fetch packets from. 232 + * @return Peeked packet. 233 + */ 234 + struct cfpkt *cfpkt_qpeek(struct cfpktq *pktq); 235 + 236 + /* 237 + * Initiates the packet queue. 238 + * @return Pointer to new packet queue. 239 + */ 240 + struct cfpktq *cfpktq_create(void); 241 + 242 + /* 243 + * Get the number of packets in the queue. 244 + * pktq Packet queue to fetch count from. 245 + * @return Number of packets in queue. 246 + */ 247 + int cfpkt_qcount(struct cfpktq *pktq); 248 + 249 + /* 250 + * Put content of packet into buffer for debuging purposes. 251 + * pkt Packet to copy data from 252 + * buf Buffer to copy data into 253 + * buflen Length of data to copy 254 + * @return Pointer to copied data 255 + */ 256 + char *cfpkt_log_pkt(struct cfpkt *pkt, char *buf, int buflen); 257 + 258 + /* 259 + * Clones a packet and releases the original packet. 260 + * This is used for taking ownership of a packet e.g queueing. 261 + * pkt Packet to clone and release. 262 + * @return Cloned packet. 263 + */ 264 + struct cfpkt *cfpkt_clone_release(struct cfpkt *pkt); 265 + 266 + 267 + /* 268 + * Returns packet information for a packet. 269 + * pkt Packet to get info from; 270 + * @return Packet information 271 + */ 272 + struct caif_payload_info *cfpkt_info(struct cfpkt *pkt); 273 + /*! @} */ 274 + #endif /* CFPKT_H_ */
+12
include/net/caif/cfserl.h
··· 1 + /* 2 + * Copyright (C) ST-Ericsson AB 2010 3 + * Author: Sjur Brendeland/sjur.brandeland@stericsson.com 4 + * License terms: GNU General Public License (GPL) version 2 5 + */ 6 + 7 + #ifndef CFSERL_H_ 8 + #define CFSERL_H_ 9 + #include <net/caif/caif_layer.h> 10 + 11 + struct cflayer *cfserl_create(int type, int instance, bool use_stx); 12 + #endif /* CFSERL_H_ */
+34
include/net/caif/cfsrvl.h
··· 1 + /* 2 + * Copyright (C) ST-Ericsson AB 2010 3 + * Author: Sjur Brendeland/sjur.brandeland@stericsson.com 4 + * License terms: GNU General Public License (GPL) version 2 5 + */ 6 + 7 + #ifndef CFSRVL_H_ 8 + #define CFSRVL_H_ 9 + #include <linux/list.h> 10 + #include <linux/stddef.h> 11 + #include <linux/types.h> 12 + struct cfsrvl { 13 + struct cflayer layer; 14 + bool open; 15 + bool phy_flow_on; 16 + bool modem_flow_on; 17 + struct dev_info dev_info; 18 + }; 19 + 20 + struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); 21 + struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); 22 + struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); 23 + struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info); 24 + struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info); 25 + struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); 26 + bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); 27 + void cfservl_destroy(struct cflayer *layer); 28 + void cfsrvl_init(struct cfsrvl *service, 29 + u8 channel_id, 30 + struct dev_info *dev_info); 31 + bool cfsrvl_ready(struct cfsrvl *service, int *err); 32 + u8 cfsrvl_getphyid(struct cflayer *layer); 33 + 34 + #endif /* CFSRVL_H_ */