Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) ST-Ericsson AB 2010
0004  * Author:  Sjur Brendeland
0005  */
0006 
0007 #ifndef CAIF_DEV_H_
0008 #define CAIF_DEV_H_
0009 
0010 #include <net/caif/caif_layer.h>
0011 #include <net/caif/cfcnfg.h>
0012 #include <net/caif/caif_device.h>
0013 #include <linux/caif/caif_socket.h>
0014 #include <linux/if.h>
0015 #include <linux/net.h>
0016 
0017 /**
0018  * struct caif_param - CAIF parameters.
0019  * @size:   Length of data
0020  * @data:   Binary Data Blob
0021  */
0022 struct caif_param {
0023     u16  size;
0024     u8   data[256];
0025 };
0026 
0027 /**
0028  * struct caif_connect_request - Request data for CAIF channel setup.
0029  * @protocol:       Type of CAIF protocol to use (at, datagram etc)
0030  * @sockaddr:       Socket address to connect.
0031  * @priority:       Priority of the connection.
0032  * @link_selector:  Link selector (high bandwidth or low latency)
0033  * @ifindex:        kernel index of the interface.
0034  * @param:      Connect Request parameters (CAIF_SO_REQ_PARAM).
0035  *
0036  * This struct is used when connecting a CAIF channel.
0037  * It contains all CAIF channel configuration options.
0038  */
0039 struct caif_connect_request {
0040     enum caif_protocol_type protocol;
0041     struct sockaddr_caif sockaddr;
0042     enum caif_channel_priority priority;
0043     enum caif_link_selector link_selector;
0044     int ifindex;
0045     struct caif_param param;
0046 };
0047 
0048 /**
0049  * caif_connect_client - Connect a client to CAIF Core Stack.
0050  * @config:     Channel setup parameters, specifying what address
0051  *          to connect on the Modem.
0052  * @client_layer:   User implementation of client layer. This layer
0053  *          MUST have receive and control callback functions
0054  *          implemented.
0055  * @ifindex:        Link layer interface index used for this connection.
0056  * @headroom:       Head room needed by CAIF protocol.
0057  * @tailroom:       Tail room needed by CAIF protocol.
0058  *
0059  * This function connects a CAIF channel. The Client must implement
0060  * the struct cflayer. This layer represents the Client layer and holds
0061  * receive functions and control callback functions. Control callback
0062  * function will receive information about connect/disconnect responses,
0063  * flow control etc (see enum caif_control).
0064  * E.g. CAIF Socket will call this function for each socket it connects
0065  * and have one client_layer instance for each socket.
0066  */
0067 int caif_connect_client(struct net *net,
0068             struct caif_connect_request *conn_req,
0069             struct cflayer *client_layer, int *ifindex,
0070             int *headroom, int *tailroom);
0071 
0072 /**
0073  * caif_disconnect_client - Disconnects a client from the CAIF stack.
0074  *
0075  * @client_layer: Client layer to be disconnected.
0076  */
0077 int caif_disconnect_client(struct net *net, struct cflayer *client_layer);
0078 
0079 
0080 /**
0081  * caif_client_register_refcnt - register ref-count functions provided by client.
0082  *
0083  * @adapt_layer: Client layer using CAIF Stack.
0084  * @hold:   Function provided by client layer increasing ref-count
0085  * @put:    Function provided by client layer decreasing ref-count
0086  *
0087  * Client of the CAIF Stack must register functions for reference counting.
0088  * These functions are called by the CAIF Stack for every upstream packet,
0089  * and must therefore be implemented efficiently.
0090  *
0091  * Client should call caif_free_client when reference count degrease to zero.
0092  */
0093 
0094 void caif_client_register_refcnt(struct cflayer *adapt_layer,
0095                     void (*hold)(struct cflayer *lyr),
0096                     void (*put)(struct cflayer *lyr));
0097 /**
0098  * caif_free_client - Free memory used to manage the client in the CAIF Stack.
0099  *
0100  * @client_layer: Client layer to be removed.
0101  *
0102  * This function must be called from client layer in order to free memory.
0103  * Caller must guarantee that no packets are in flight upstream when calling
0104  * this function.
0105  */
0106 void caif_free_client(struct cflayer *adap_layer);
0107 
0108 /**
0109  * struct caif_enroll_dev - Enroll a net-device as a CAIF Link layer
0110  * @dev:        Network device to enroll.
0111  * @caifdev:        Configuration information from CAIF Link Layer
0112  * @link_support:   Link layer support layer
0113  * @head_room:      Head room needed by link support layer
0114  * @layer:      Lowest layer in CAIF stack
0115  * @rcv_fun:        Receive function for CAIF stack.
0116  *
0117  * This function enroll a CAIF link layer into CAIF Stack and
0118  * expects the interface to be able to handle CAIF payload.
0119  * The link_support layer is used to add any Link Layer specific
0120  * framing.
0121  */
0122 int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
0123             struct cflayer *link_support, int head_room,
0124             struct cflayer **layer, int (**rcv_func)(
0125                 struct sk_buff *, struct net_device *,
0126                 struct packet_type *, struct net_device *));
0127 
0128 #endif /* CAIF_DEV_H_ */