linux/include/net/caif/caif_dev.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/*
   3 * Copyright (C) ST-Ericsson AB 2010
   4 * Author:      Sjur Brendeland
   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 <net/caif/caif_device.h>
  13#include <linux/caif/caif_socket.h>
  14#include <linux/if.h>
  15#include <linux/net.h>
  16
  17/**
  18 * struct caif_param - CAIF parameters.
  19 * @size:       Length of data
  20 * @data:       Binary Data Blob
  21 */
  22struct caif_param {
  23        u16  size;
  24        u8   data[256];
  25};
  26
  27/**
  28 * struct caif_connect_request - Request data for CAIF channel setup.
  29 * @protocol:           Type of CAIF protocol to use (at, datagram etc)
  30 * @sockaddr:           Socket address to connect.
  31 * @priority:           Priority of the connection.
  32 * @link_selector:      Link selector (high bandwidth or low latency)
  33 * @ifindex:            kernel index of the interface.
  34 * @param:              Connect Request parameters (CAIF_SO_REQ_PARAM).
  35 *
  36 * This struct is used when connecting a CAIF channel.
  37 * It contains all CAIF channel configuration options.
  38 */
  39struct caif_connect_request {
  40        enum caif_protocol_type protocol;
  41        struct sockaddr_caif sockaddr;
  42        enum caif_channel_priority priority;
  43        enum caif_link_selector link_selector;
  44        int ifindex;
  45        struct caif_param param;
  46};
  47
  48/**
  49 * caif_connect_client - Connect a client to CAIF Core Stack.
  50 * @config:             Channel setup parameters, specifying what address
  51 *                      to connect on the Modem.
  52 * @client_layer:       User implementation of client layer. This layer
  53 *                      MUST have receive and control callback functions
  54 *                      implemented.
  55 * @ifindex:            Link layer interface index used for this connection.
  56 * @headroom:           Head room needed by CAIF protocol.
  57 * @tailroom:           Tail room needed by CAIF protocol.
  58 *
  59 * This function connects a CAIF channel. The Client must implement
  60 * the struct cflayer. This layer represents the Client layer and holds
  61 * receive functions and control callback functions. Control callback
  62 * function will receive information about connect/disconnect responses,
  63 * flow control etc (see enum caif_control).
  64 * E.g. CAIF Socket will call this function for each socket it connects
  65 * and have one client_layer instance for each socket.
  66 */
  67int caif_connect_client(struct net *net,
  68                        struct caif_connect_request *conn_req,
  69                        struct cflayer *client_layer, int *ifindex,
  70                        int *headroom, int *tailroom);
  71
  72/**
  73 * caif_disconnect_client - Disconnects a client from the CAIF stack.
  74 *
  75 * @client_layer: Client layer to be disconnected.
  76 */
  77int caif_disconnect_client(struct net *net, struct cflayer *client_layer);
  78
  79
  80/**
  81 * caif_client_register_refcnt - register ref-count functions provided by client.
  82 *
  83 * @adapt_layer: Client layer using CAIF Stack.
  84 * @hold:       Function provided by client layer increasing ref-count
  85 * @put:        Function provided by client layer decreasing ref-count
  86 *
  87 * Client of the CAIF Stack must register functions for reference counting.
  88 * These functions are called by the CAIF Stack for every upstream packet,
  89 * and must therefore be implemented efficiently.
  90 *
  91 * Client should call caif_free_client when reference count degrease to zero.
  92 */
  93
  94void caif_client_register_refcnt(struct cflayer *adapt_layer,
  95                                        void (*hold)(struct cflayer *lyr),
  96                                        void (*put)(struct cflayer *lyr));
  97/**
  98 * caif_free_client - Free memory used to manage the client in the CAIF Stack.
  99 *
 100 * @client_layer: Client layer to be removed.
 101 *
 102 * This function must be called from client layer in order to free memory.
 103 * Caller must guarantee that no packets are in flight upstream when calling
 104 * this function.
 105 */
 106void caif_free_client(struct cflayer *adap_layer);
 107
 108/**
 109 * struct caif_enroll_dev - Enroll a net-device as a CAIF Link layer
 110 * @dev:                Network device to enroll.
 111 * @caifdev:            Configuration information from CAIF Link Layer
 112 * @link_support:       Link layer support layer
 113 * @head_room:          Head room needed by link support layer
 114 * @layer:              Lowest layer in CAIF stack
 115 * @rcv_fun:            Receive function for CAIF stack.
 116 *
 117 * This function enroll a CAIF link layer into CAIF Stack and
 118 * expects the interface to be able to handle CAIF payload.
 119 * The link_support layer is used to add any Link Layer specific
 120 * framing.
 121 */
 122void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
 123                        struct cflayer *link_support, int head_room,
 124                        struct cflayer **layer, int (**rcv_func)(
 125                                struct sk_buff *, struct net_device *,
 126                                struct packet_type *, struct net_device *));
 127
 128#endif /* CAIF_DEV_H_ */
 129