Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 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> |
sjur.brandeland@stericsson.com | bee925d | 2011-05-13 02:44:05 +0000 | [diff] [blame] | 14 | #include <linux/net.h> |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 15 | |
| 16 | /** |
| 17 | * struct caif_param - CAIF parameters. |
| 18 | * @size: Length of data |
| 19 | * @data: Binary Data Blob |
| 20 | */ |
| 21 | struct caif_param { |
| 22 | u16 size; |
| 23 | u8 data[256]; |
| 24 | }; |
| 25 | |
| 26 | /** |
Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 27 | * struct caif_connect_request - Request data for CAIF channel setup. |
| 28 | * @protocol: Type of CAIF protocol to use (at, datagram etc) |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 29 | * @sockaddr: Socket address to connect. |
| 30 | * @priority: Priority of the connection. |
| 31 | * @link_selector: Link selector (high bandwidth or low latency) |
André Carvalho de Matos | f2527ec | 2010-11-01 11:52:47 +0000 | [diff] [blame] | 32 | * @ifindex: kernel index of the interface. |
Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 33 | * @param: Connect Request parameters (CAIF_SO_REQ_PARAM). |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 34 | * |
| 35 | * This struct is used when connecting a CAIF channel. |
| 36 | * It contains all CAIF channel configuration options. |
| 37 | */ |
| 38 | struct caif_connect_request { |
Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 39 | enum caif_protocol_type protocol; |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 40 | struct sockaddr_caif sockaddr; |
| 41 | enum caif_channel_priority priority; |
| 42 | enum caif_link_selector link_selector; |
André Carvalho de Matos | f2527ec | 2010-11-01 11:52:47 +0000 | [diff] [blame] | 43 | int ifindex; |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 44 | struct caif_param param; |
| 45 | }; |
| 46 | |
| 47 | /** |
| 48 | * caif_connect_client - Connect a client to CAIF Core Stack. |
| 49 | * @config: Channel setup parameters, specifying what address |
| 50 | * to connect on the Modem. |
| 51 | * @client_layer: User implementation of client layer. This layer |
| 52 | * MUST have receive and control callback functions |
| 53 | * implemented. |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 54 | * @ifindex: Link layer interface index used for this connection. |
| 55 | * @headroom: Head room needed by CAIF protocol. |
| 56 | * @tailroom: Tail room needed by CAIF protocol. |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 57 | * |
| 58 | * This function connects a CAIF channel. The Client must implement |
| 59 | * the struct cflayer. This layer represents the Client layer and holds |
| 60 | * receive functions and control callback functions. Control callback |
| 61 | * function will receive information about connect/disconnect responses, |
| 62 | * flow control etc (see enum caif_control). |
| 63 | * E.g. CAIF Socket will call this function for each socket it connects |
| 64 | * and have one client_layer instance for each socket. |
| 65 | */ |
sjur.brandeland@stericsson.com | bee925d | 2011-05-13 02:44:05 +0000 | [diff] [blame] | 66 | int caif_connect_client(struct net *net, |
| 67 | struct caif_connect_request *conn_req, |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 68 | struct cflayer *client_layer, int *ifindex, |
| 69 | int *headroom, int *tailroom); |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * caif_disconnect_client - Disconnects a client from the CAIF stack. |
| 73 | * |
sjur.brandeland@stericsson.com | bee925d | 2011-05-13 02:44:05 +0000 | [diff] [blame] | 74 | * @client_layer: Client layer to be disconnected. |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 75 | */ |
sjur.brandeland@stericsson.com | bee925d | 2011-05-13 02:44:05 +0000 | [diff] [blame] | 76 | int caif_disconnect_client(struct net *net, struct cflayer *client_layer); |
| 77 | |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 78 | |
| 79 | /** |
sjur.brandeland@stericsson.com | b3ccfbe | 2011-05-13 02:44:04 +0000 | [diff] [blame] | 80 | * caif_client_register_refcnt - register ref-count functions provided by client. |
| 81 | * |
| 82 | * @adapt_layer: Client layer using CAIF Stack. |
| 83 | * @hold: Function provided by client layer increasing ref-count |
| 84 | * @put: Function provided by client layer decreasing ref-count |
| 85 | * |
| 86 | * Client of the CAIF Stack must register functions for reference counting. |
| 87 | * These functions are called by the CAIF Stack for every upstream packet, |
| 88 | * and must therefore be implemented efficiently. |
| 89 | * |
| 90 | * Client should call caif_free_client when reference count degrease to zero. |
| 91 | */ |
| 92 | |
| 93 | void caif_client_register_refcnt(struct cflayer *adapt_layer, |
| 94 | void (*hold)(struct cflayer *lyr), |
| 95 | void (*put)(struct cflayer *lyr)); |
| 96 | /** |
sjur.brandeland@stericsson.com | b3ccfbe | 2011-05-13 02:44:04 +0000 | [diff] [blame] | 97 | * caif_free_client - Free memory used to manage the client in the CAIF Stack. |
| 98 | * |
| 99 | * @client_layer: Client layer to be removed. |
| 100 | * |
| 101 | * This function must be called from client layer in order to free memory. |
| 102 | * Caller must guarantee that no packets are in flight upstream when calling |
| 103 | * this function. |
| 104 | */ |
| 105 | void caif_free_client(struct cflayer *adap_layer); |
| 106 | |
Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 107 | #endif /* CAIF_DEV_H_ */ |