^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) ST-Ericsson AB 2010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Sjur Brendeland
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef CAIF_LAYER_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define CAIF_LAYER_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct cflayer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct cfpkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct cfpktq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct caif_payload_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct caif_packet_funcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define CAIF_LAYER_NAME_SZ 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * caif_assert() - Assert function for CAIF.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * @assert: expression to evaluate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * This function will print a error message and a do WARN_ON if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * assertion failes. Normally this will do a stack up at the current location.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define caif_assert(assert) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) if (!(assert)) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) pr_err("caif:Assert detected:'%s'\n", #assert); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) WARN_ON(!(assert)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * enum caif_ctrlcmd - CAIF Stack Control Signaling sent in layer.ctrlcmd().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * @CAIF_CTRLCMD_FLOW_OFF_IND: Flow Control is OFF, transmit function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * should stop sending data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * @CAIF_CTRLCMD_FLOW_ON_IND: Flow Control is ON, transmit function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * can start sending data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND: Remote end modem has decided to close
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * down channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @CAIF_CTRLCMD_INIT_RSP: Called initially when the layer below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * has finished initialization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * @CAIF_CTRLCMD_DEINIT_RSP: Called when de-initialization is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * @CAIF_CTRLCMD_INIT_FAIL_RSP: Called if initialization fails
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * @_CAIF_CTRLCMD_PHYIF_FLOW_OFF_IND: CAIF Link layer temporarily cannot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * send more packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @_CAIF_CTRLCMD_PHYIF_FLOW_ON_IND: Called if CAIF Link layer is able
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * to send packets again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @_CAIF_CTRLCMD_PHYIF_DOWN_IND: Called if CAIF Link layer is going
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * down.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * These commands are sent upwards in the CAIF stack to the CAIF Client.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * They are used for signaling originating from the modem or CAIF Link Layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * These are either responses (*_RSP) or events (*_IND).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) enum caif_ctrlcmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) CAIF_CTRLCMD_FLOW_OFF_IND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) CAIF_CTRLCMD_FLOW_ON_IND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) CAIF_CTRLCMD_INIT_RSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) CAIF_CTRLCMD_DEINIT_RSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) CAIF_CTRLCMD_INIT_FAIL_RSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) _CAIF_CTRLCMD_PHYIF_FLOW_OFF_IND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) _CAIF_CTRLCMD_PHYIF_FLOW_ON_IND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) _CAIF_CTRLCMD_PHYIF_DOWN_IND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * enum caif_modemcmd - Modem Control Signaling, sent from CAIF Client
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * to the CAIF Link Layer or modem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * @CAIF_MODEMCMD_FLOW_ON_REQ: Flow Control is ON, transmit function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * can start sending data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * @CAIF_MODEMCMD_FLOW_OFF_REQ: Flow Control is OFF, transmit function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * should stop sending data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * @_CAIF_MODEMCMD_PHYIF_USEFULL: Notify physical layer that it is in use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * @_CAIF_MODEMCMD_PHYIF_USELESS: Notify physical layer that it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * no longer in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * These are requests sent 'downwards' in the stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * Flow ON, OFF can be indicated to the modem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) enum caif_modemcmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) CAIF_MODEMCMD_FLOW_ON_REQ = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) CAIF_MODEMCMD_FLOW_OFF_REQ = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) _CAIF_MODEMCMD_PHYIF_USEFULL = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) _CAIF_MODEMCMD_PHYIF_USELESS = 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * enum caif_direction - CAIF Packet Direction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * Indicate if a packet is to be sent out or to be received in.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * @CAIF_DIR_IN: Incoming packet received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * @CAIF_DIR_OUT: Outgoing packet to be transmitted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) enum caif_direction {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) CAIF_DIR_IN = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) CAIF_DIR_OUT = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * struct cflayer - CAIF Stack layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * Defines the framework for the CAIF Core Stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * @up: Pointer up to the layer above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * @dn: Pointer down to the layer below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * @node: List node used when layer participate in a list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * @receive: Packet receive function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * @transmit: Packet transmit funciton.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * @ctrlcmd: Used for control signalling upwards in the stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * @modemcmd: Used for control signaling downwards in the stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * @id: The identity of this layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * @name: Name of the layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * This structure defines the layered structure in CAIF.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * It defines CAIF layering structure, used by all CAIF Layers and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * layers interfacing CAIF.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * In order to integrate with CAIF an adaptation layer on top of the CAIF stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * and PHY layer below the CAIF stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * must be implemented. These layer must follow the design principles below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * Principles for layering of protocol layers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * - All layers must use this structure. If embedding it, then place this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * structure first in the layer specific structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * - Each layer should not depend on any others layer's private data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * - In order to send data upwards do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * layer->up->receive(layer->up, packet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * - In order to send data downwards do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * layer->dn->transmit(layer->dn, info, packet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct cflayer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct cflayer *up;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct cflayer *dn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * receive() - Receive Function (non-blocking).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * Contract: Each layer must implement a receive function passing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * CAIF packets upwards in the stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * Packet handling rules:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * - The CAIF packet (cfpkt) ownership is passed to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * called receive function. This means that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * packet cannot be accessed after passing it to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * above layer using up->receive().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * - If parsing of the packet fails, the packet must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * destroyed and negative error code returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * from the function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * EXCEPTION: If the framing layer (cffrml) returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * -EILSEQ, the packet is not freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * - If parsing succeeds (and above layers return OK) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * the function must return a value >= 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * Returns result < 0 indicates an error, 0 or positive value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * indicates success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * @layr: Pointer to the current layer the receive function is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * implemented for (this pointer).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * @cfpkt: Pointer to CaifPacket to be handled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) int (*receive)(struct cflayer *layr, struct cfpkt *cfpkt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * transmit() - Transmit Function (non-blocking).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * Contract: Each layer must implement a transmit function passing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * CAIF packet downwards in the stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * Packet handling rules:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * - The CAIF packet (cfpkt) ownership is passed to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * transmit function. This means that the packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * cannot be accessed after passing it to the below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * layer using dn->transmit().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * - Upon error the packet ownership is still passed on,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * so the packet shall be freed where error is detected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * Callers of the transmit function shall not free packets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * but errors shall be returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * - Return value less than zero means error, zero or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * greater than zero means OK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * Returns result < 0 indicates an error, 0 or positive value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * indicates success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * @layr: Pointer to the current layer the receive function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * isimplemented for (this pointer).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * @cfpkt: Pointer to CaifPacket to be handled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) int (*transmit) (struct cflayer *layr, struct cfpkt *cfpkt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * cttrlcmd() - Control Function upwards in CAIF Stack (non-blocking).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * Used for signaling responses (CAIF_CTRLCMD_*_RSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * and asynchronous events from the modem (CAIF_CTRLCMD_*_IND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * @layr: Pointer to the current layer the receive function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * is implemented for (this pointer).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * @ctrl: Control Command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) void (*ctrlcmd) (struct cflayer *layr, enum caif_ctrlcmd ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int phyid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * modemctrl() - Control Function used for controlling the modem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * Used to signal down-wards in the CAIF stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * Returns 0 on success, < 0 upon failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * @layr: Pointer to the current layer the receive function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * is implemented for (this pointer).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * @ctrl: Control Command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) int (*modemcmd) (struct cflayer *layr, enum caif_modemcmd ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) unsigned int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) char name[CAIF_LAYER_NAME_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * layer_set_up() - Set the up pointer for a specified layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * @layr: Layer where up pointer shall be set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * @above: Layer above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #define layer_set_up(layr, above) ((layr)->up = (struct cflayer *)(above))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * layer_set_dn() - Set the down pointer for a specified layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * @layr: Layer where down pointer shall be set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * @below: Layer below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #define layer_set_dn(layr, below) ((layr)->dn = (struct cflayer *)(below))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * struct dev_info - Physical Device info information about physical layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * @dev: Pointer to native physical device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * @id: Physical ID of the physical connection used by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * logical CAIF connection. Used by service layers to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * identify their physical id to Caif MUX (CFMUXL)so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * that the MUX can add the correct physical ID to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * packet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct dev_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) void *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) unsigned int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * struct caif_payload_info - Payload information embedded in packet (sk_buff).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * @dev_info: Information about the receiving device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * @hdr_len: Header length, used to align pay load on 32bit boundary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * @channel_id: Channel ID of the logical CAIF connection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * Used by mux to insert channel id into the caif packet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct caif_payload_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct dev_info *dev_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) unsigned short hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) unsigned short channel_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #endif /* CAIF_LAYER_H_ */