| 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> | 
|  | 14 |  | 
|  | 15 | /** | 
|  | 16 | * struct caif_param - CAIF parameters. | 
|  | 17 | * @size:	Length of data | 
|  | 18 | * @data:	Binary Data Blob | 
|  | 19 | */ | 
|  | 20 | struct caif_param { | 
|  | 21 | u16  size; | 
|  | 22 | u8   data[256]; | 
|  | 23 | }; | 
|  | 24 |  | 
|  | 25 | /** | 
| Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 26 | * struct caif_connect_request - Request data for CAIF channel setup. | 
|  | 27 | * @protocol:		Type of CAIF protocol to use (at, datagram etc) | 
| Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 28 | * @sockaddr:		Socket address to connect. | 
|  | 29 | * @priority:		Priority of the connection. | 
|  | 30 | * @link_selector:	Link selector (high bandwidth or low latency) | 
|  | 31 | * @link_name:		Name of the CAIF Link Layer to use. | 
| Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 32 | * @param:		Connect Request parameters (CAIF_SO_REQ_PARAM). | 
| Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 33 | * | 
|  | 34 | * This struct is used when connecting a CAIF channel. | 
|  | 35 | * It contains all CAIF channel configuration options. | 
|  | 36 | */ | 
|  | 37 | struct caif_connect_request { | 
| Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 38 | enum caif_protocol_type protocol; | 
| Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 39 | struct sockaddr_caif sockaddr; | 
|  | 40 | enum caif_channel_priority priority; | 
|  | 41 | enum caif_link_selector link_selector; | 
|  | 42 | char link_name[16]; | 
|  | 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. | 
| Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 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. | 
| Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 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 | */ | 
| Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 65 | int caif_connect_client(struct caif_connect_request *conn_req, | 
|  | 66 | struct cflayer *client_layer, int *ifindex, | 
|  | 67 | int *headroom, int *tailroom); | 
| Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 68 |  | 
|  | 69 | /** | 
|  | 70 | * caif_disconnect_client - Disconnects a client from the CAIF stack. | 
|  | 71 | * | 
|  | 72 | * @client_layer: Client layer to be removed. | 
|  | 73 | */ | 
|  | 74 | int caif_disconnect_client(struct cflayer *client_layer); | 
|  | 75 |  | 
|  | 76 | /** | 
| Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 77 | * caif_release_client - Release adaptation layer reference to client. | 
|  | 78 | * | 
|  | 79 | * @client_layer: Client layer. | 
|  | 80 | * | 
|  | 81 | * Releases a client/adaptation layer use of the caif stack. | 
|  | 82 | * This function must be used after caif_disconnect_client to | 
|  | 83 | * decrease the reference count of the service layer. | 
|  | 84 | */ | 
|  | 85 | void caif_release_client(struct cflayer *client_layer); | 
|  | 86 |  | 
|  | 87 | /** | 
| Sjur Braendeland | 2721c5b | 2010-03-30 13:56:22 +0000 | [diff] [blame] | 88 | * connect_req_to_link_param - Translate configuration parameters | 
|  | 89 | *				from socket format to internal format. | 
|  | 90 | * @cnfg:	Pointer to configuration handler | 
|  | 91 | * @con_req:	Configuration parameters supplied in function | 
|  | 92 | *		caif_connect_client | 
|  | 93 | * @channel_setup_param: Parameters supplied to the CAIF Core stack for | 
|  | 94 | *			 setting up channels. | 
|  | 95 | * | 
|  | 96 | */ | 
|  | 97 | int connect_req_to_link_param(struct cfcnfg *cnfg, | 
|  | 98 | struct caif_connect_request *con_req, | 
|  | 99 | struct cfctrl_link_param *channel_setup_param); | 
|  | 100 |  | 
|  | 101 | /** | 
|  | 102 | * get_caif_conf() - Get the configuration handler. | 
|  | 103 | */ | 
|  | 104 | struct cfcnfg *get_caif_conf(void); | 
|  | 105 |  | 
|  | 106 |  | 
|  | 107 | #endif /* CAIF_DEV_H_ */ |