1 /* SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2020-21 Intel Corporation.
6 #ifndef IOSM_IPC_MUX_CODEC_H
7 #define IOSM_IPC_MUX_CODEC_H
9 #include "iosm_ipc_mux.h"
11 /* Queue level size and reporting
12 * >1 is enable, 0 is disable
14 #define MUX_QUEUE_LEVEL 1
16 /* Size of the buffer for the IP MUX commands. */
17 #define MUX_MAX_UL_ACB_BUF_SIZE 256
19 /* Maximum number of packets in a go per session */
20 #define MUX_MAX_UL_DG_ENTRIES 100
22 /* ADGH: Signature of the Datagram Header. */
23 #define MUX_SIG_ADGH 0x48474441
25 /* CMDH: Signature of the Command Header. */
26 #define MUX_SIG_CMDH 0x48444D43
28 /* QLTH: Signature of the Queue Level Table */
29 #define MUX_SIG_QLTH 0x48544C51
31 /* FCTH: Signature of the Flow Credit Table */
32 #define MUX_SIG_FCTH 0x48544346
34 /* MUX UL session threshold factor */
35 #define IPC_MEM_MUX_UL_SESS_FCOFF_THRESHOLD_FACTOR (4)
37 /* Size of the buffer for the IP MUX Lite data buffer. */
38 #define IPC_MEM_MAX_DL_MUX_LITE_BUF_SIZE (2 * 1024)
40 /* MUX UL session threshold in number of packets */
41 #define IPC_MEM_MUX_UL_SESS_FCON_THRESHOLD (64)
43 /* Default time out for sending IPC session commands like
44 * open session, close session etc
47 #define IPC_MUX_CMD_RUN_DEFAULT_TIMEOUT 1000 /* 1 second */
49 /* MUX UL flow control lower threshold in bytes */
50 #define IPC_MEM_MUX_UL_FLOWCTRL_LOW_B 10240 /* 10KB */
52 /* MUX UL flow control higher threshold in bytes (5ms worth of data)*/
53 #define IPC_MEM_MUX_UL_FLOWCTRL_HIGH_B (110 * 1024)
56 * struct mux_adgh - Aggregated Datagram Header.
57 * @signature: Signature of the Aggregated Datagram Header(0x48474441)
58 * @length: Length (in bytes) of the datagram header. This length
59 * shall include the header size. Min value: 0x10
60 * @if_id: ID of the interface the datagrams belong to
61 * @opt_ipv4v6: Indicates IPv4(=0)/IPv6(=1), It is optional if not
62 * used set it to zero.
63 * @reserved: Reserved bits. Set to zero.
64 * @service_class: Service class identifier for the datagram.
65 * @next_count: Count of the datagrams that shall be following this
66 * datagrams for this interface. A count of zero means
67 * the next datagram may not belong to this interface.
68 * @reserved1: Reserved bytes, Set to zero
81 * struct mux_lite_cmdh - MUX Lite Command Header
82 * @signature: Signature of the Command Header(0x48444D43)
83 * @cmd_len: Length (in bytes) of the command. This length shall
84 * include the header size. Minimum value: 0x10
85 * @if_id: ID of the interface the commands in the table belong to.
86 * @reserved: Reserved Set to zero.
87 * @command_type: Command Enum.
88 * @transaction_id: 4 byte value shall be generated and sent along with a
89 * command Responses and ACKs shall have the same
90 * Transaction ID as their commands. It shall be unique to
91 * the command transaction on the given interface.
92 * @param: Optional parameters used with the command.
94 struct mux_lite_cmdh {
100 __le32 transaction_id;
101 union mux_cmd_param param;
105 * struct mux_lite_vfl - value field in generic table
106 * @nr_of_bytes: Number of bytes available to transmit in the queue.
108 struct mux_lite_vfl {
113 * struct ipc_mem_lite_gen_tbl - Generic table format for Queue Level
115 * @signature: Signature of the table
116 * @length: Length of the table
117 * @if_id: ID of the interface the table belongs to
118 * @vfl_length: Value field length
119 * @reserved: Reserved
120 * @vfl: Value field of variable length
122 struct ipc_mem_lite_gen_tbl {
128 struct mux_lite_vfl vfl;
132 * ipc_mux_dl_decode -Route the DL packet through the IP MUX layer
133 * depending on Header.
134 * @ipc_mux: Pointer to MUX data-struct
135 * @skb: Pointer to ipc_skb.
137 void ipc_mux_dl_decode(struct iosm_mux *ipc_mux, struct sk_buff *skb);
140 * ipc_mux_dl_acb_send_cmds - Respond to the Command blocks.
141 * @ipc_mux: Pointer to MUX data-struct
143 * @if_id: Session interface id.
144 * @transaction_id: Command transaction id.
145 * @param: Pointer to command params.
146 * @res_size: Response size
147 * @blocking: True for blocking send
148 * @respond: If true return transaction ID
150 * Returns: 0 in success and failure value on error
152 int ipc_mux_dl_acb_send_cmds(struct iosm_mux *ipc_mux, u32 cmd_type, u8 if_id,
153 u32 transaction_id, union mux_cmd_param *param,
154 size_t res_size, bool blocking, bool respond);
157 * ipc_mux_netif_tx_flowctrl - Enable/Disable TX flow control on MUX sessions.
158 * @session: Pointer to mux_session struct
160 * @on: true for Enable and false for disable flow control
162 void ipc_mux_netif_tx_flowctrl(struct mux_session *session, int idx, bool on);
165 * ipc_mux_ul_trigger_encode - Route the UL packet through the IP MUX layer
167 * @ipc_mux: Pointer to MUX data-struct
168 * @if_id: Session ID.
169 * @skb: Pointer to ipc_skb.
171 * Returns: 0 if successfully encoded
172 * failure value on error
173 * -EBUSY if packet has to be retransmitted.
175 int ipc_mux_ul_trigger_encode(struct iosm_mux *ipc_mux, int if_id,
176 struct sk_buff *skb);
178 * ipc_mux_ul_data_encode - UL encode function for calling from Tasklet context.
179 * @ipc_mux: Pointer to MUX data-struct
181 * Returns: TRUE if any packet of any session is encoded FALSE otherwise.
183 bool ipc_mux_ul_data_encode(struct iosm_mux *ipc_mux);
186 * ipc_mux_ul_encoded_process - Handles the Modem processed UL data by adding
187 * the SKB to the UL free list.
188 * @ipc_mux: Pointer to MUX data-struct
189 * @skb: Pointer to ipc_skb.
191 void ipc_mux_ul_encoded_process(struct iosm_mux *ipc_mux, struct sk_buff *skb);