caif: Protected in-flight packets using dev or sock refcont.
[deliverable/linux.git] / include / net / caif / caif_dev.h
CommitLineData
2721c5b9
SB
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_DEV_H_
8#define CAIF_DEV_H_
9
10#include <net/caif/caif_layer.h>
11#include <net/caif/cfcnfg.h>
12#include <linux/caif/caif_socket.h>
13#include <linux/if.h>
14
15/**
16 * struct caif_param - CAIF parameters.
17 * @size: Length of data
18 * @data: Binary Data Blob
19 */
20struct caif_param {
21 u16 size;
22 u8 data[256];
23};
24
25/**
e539d83c
SB
26 * struct caif_connect_request - Request data for CAIF channel setup.
27 * @protocol: Type of CAIF protocol to use (at, datagram etc)
2721c5b9
SB
28 * @sockaddr: Socket address to connect.
29 * @priority: Priority of the connection.
30 * @link_selector: Link selector (high bandwidth or low latency)
f2527ec4 31 * @ifindex: kernel index of the interface.
e539d83c 32 * @param: Connect Request parameters (CAIF_SO_REQ_PARAM).
2721c5b9
SB
33 *
34 * This struct is used when connecting a CAIF channel.
35 * It contains all CAIF channel configuration options.
36 */
37struct caif_connect_request {
e539d83c 38 enum caif_protocol_type protocol;
2721c5b9
SB
39 struct sockaddr_caif sockaddr;
40 enum caif_channel_priority priority;
41 enum caif_link_selector link_selector;
f2527ec4 42 int ifindex;
2721c5b9
SB
43 struct caif_param param;
44};
45
46/**
47 * caif_connect_client - Connect a client to CAIF Core Stack.
48 * @config: Channel setup parameters, specifying what address
49 * to connect on the Modem.
50 * @client_layer: User implementation of client layer. This layer
51 * MUST have receive and control callback functions
52 * implemented.
2aa40aef
SB
53 * @ifindex: Link layer interface index used for this connection.
54 * @headroom: Head room needed by CAIF protocol.
55 * @tailroom: Tail room needed by CAIF protocol.
2721c5b9
SB
56 *
57 * This function connects a CAIF channel. The Client must implement
58 * the struct cflayer. This layer represents the Client layer and holds
59 * receive functions and control callback functions. Control callback
60 * function will receive information about connect/disconnect responses,
61 * flow control etc (see enum caif_control).
62 * E.g. CAIF Socket will call this function for each socket it connects
63 * and have one client_layer instance for each socket.
64 */
2aa40aef
SB
65int caif_connect_client(struct caif_connect_request *conn_req,
66 struct cflayer *client_layer, int *ifindex,
67 int *headroom, int *tailroom);
2721c5b9
SB
68
69/**
70 * caif_disconnect_client - Disconnects a client from the CAIF stack.
71 *
72 * @client_layer: Client layer to be removed.
73 */
74int caif_disconnect_client(struct cflayer *client_layer);
75
b3ccfbe4 76/**
77 * caif_client_register_refcnt - register ref-count functions provided by client.
78 *
79 * @adapt_layer: Client layer using CAIF Stack.
80 * @hold: Function provided by client layer increasing ref-count
81 * @put: Function provided by client layer decreasing ref-count
82 *
83 * Client of the CAIF Stack must register functions for reference counting.
84 * These functions are called by the CAIF Stack for every upstream packet,
85 * and must therefore be implemented efficiently.
86 *
87 * Client should call caif_free_client when reference count degrease to zero.
88 */
89
90void caif_client_register_refcnt(struct cflayer *adapt_layer,
91 void (*hold)(struct cflayer *lyr),
92 void (*put)(struct cflayer *lyr));
5b208656 93/**
73d6ac63
SH
94 * caif_connect_req_to_link_param - Translate configuration parameters
95 * from socket format to internal format.
2721c5b9
SB
96 * @cnfg: Pointer to configuration handler
97 * @con_req: Configuration parameters supplied in function
98 * caif_connect_client
99 * @channel_setup_param: Parameters supplied to the CAIF Core stack for
100 * setting up channels.
101 *
102 */
b3ccfbe4 103
73d6ac63
SH
104int caif_connect_req_to_link_param(struct cfcnfg *cnfg,
105 struct caif_connect_request *con_req,
106 struct cfctrl_link_param *setup_param);
2721c5b9 107
b3ccfbe4 108/**
109 * caif_free_client - Free memory used to manage the client in the CAIF Stack.
110 *
111 * @client_layer: Client layer to be removed.
112 *
113 * This function must be called from client layer in order to free memory.
114 * Caller must guarantee that no packets are in flight upstream when calling
115 * this function.
116 */
117void caif_free_client(struct cflayer *adap_layer);
118
2721c5b9 119#endif /* CAIF_DEV_H_ */
This page took 0.099177 seconds and 5 git commands to generate.