/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) ST-Ericsson AB 20103* Author: Sjur Brendeland4*/56#ifndef CAIF_DEV_H_7#define CAIF_DEV_H_89#include <net/caif/caif_layer.h>10#include <net/caif/cfcnfg.h>11#include <net/caif/caif_device.h>12#include <linux/caif/caif_socket.h>13#include <linux/if.h>14#include <linux/net.h>1516/**17* struct caif_param - CAIF parameters.18* @size: Length of data19* @data: Binary Data Blob20*/21struct caif_param {22u16 size;23u8 data[256];24};2526/**27* struct caif_connect_request - Request data for CAIF channel setup.28* @protocol: Type of CAIF protocol to use (at, datagram etc)29* @sockaddr: Socket address to connect.30* @priority: Priority of the connection.31* @link_selector: Link selector (high bandwidth or low latency)32* @ifindex: kernel index of the interface.33* @param: Connect Request parameters (CAIF_SO_REQ_PARAM).34*35* This struct is used when connecting a CAIF channel.36* It contains all CAIF channel configuration options.37*/38struct caif_connect_request {39enum caif_protocol_type protocol;40struct sockaddr_caif sockaddr;41enum caif_channel_priority priority;42enum caif_link_selector link_selector;43int ifindex;44struct caif_param param;45};4647/**48* caif_connect_client - Connect a client to CAIF Core Stack.49* @config: Channel setup parameters, specifying what address50* to connect on the Modem.51* @client_layer: User implementation of client layer. This layer52* MUST have receive and control callback functions53* implemented.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.57*58* This function connects a CAIF channel. The Client must implement59* the struct cflayer. This layer represents the Client layer and holds60* receive functions and control callback functions. Control callback61* 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 connects64* and have one client_layer instance for each socket.65*/66int caif_connect_client(struct net *net,67struct caif_connect_request *conn_req,68struct cflayer *client_layer, int *ifindex,69int *headroom, int *tailroom);7071/**72* caif_disconnect_client - Disconnects a client from the CAIF stack.73*74* @client_layer: Client layer to be disconnected.75*/76int caif_disconnect_client(struct net *net, struct cflayer *client_layer);777879/**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-count84* @put: Function provided by client layer decreasing ref-count85*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*/9293void caif_client_register_refcnt(struct cflayer *adapt_layer,94void (*hold)(struct cflayer *lyr),95void (*put)(struct cflayer *lyr));96/**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 calling103* this function.104*/105void caif_free_client(struct cflayer *adap_layer);106107/**108* struct caif_enroll_dev - Enroll a net-device as a CAIF Link layer109* @dev: Network device to enroll.110* @caifdev: Configuration information from CAIF Link Layer111* @link_support: Link layer support layer112* @head_room: Head room needed by link support layer113* @layer: Lowest layer in CAIF stack114* @rcv_fun: Receive function for CAIF stack.115*116* This function enroll a CAIF link layer into CAIF Stack and117* expects the interface to be able to handle CAIF payload.118* The link_support layer is used to add any Link Layer specific119* framing.120*/121int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,122struct cflayer *link_support, int head_room,123struct cflayer **layer, int (**rcv_func)(124struct sk_buff *, struct net_device *,125struct packet_type *, struct net_device *));126127#endif /* CAIF_DEV_H_ */128129130