Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only
0002  *
0003  * Copyright (C) 2020-21 Intel Corporation.
0004  */
0005 
0006 #ifndef IOSM_IPC_MUX_CODEC_H
0007 #define IOSM_IPC_MUX_CODEC_H
0008 
0009 #include "iosm_ipc_mux.h"
0010 
0011 /* Queue level size and reporting
0012  * >1 is enable, 0 is disable
0013  */
0014 #define MUX_QUEUE_LEVEL 1
0015 
0016 /* ADB finish timer value */
0017 #define IOSM_AGGR_MUX_ADB_FINISH_TIMEOUT_NSEC (500 * 1000)
0018 
0019 /* Enables the flow control (Flow is not allowed) */
0020 #define IOSM_AGGR_MUX_CMD_FLOW_CTL_ENABLE 5
0021 
0022 /* Disables the flow control (Flow is allowed) */
0023 #define IOSM_AGGR_MUX_CMD_FLOW_CTL_DISABLE 6
0024 
0025 /* ACK the flow control command. Shall have the same Transaction ID as the
0026  * matching FLOW_CTL command
0027  */
0028 #define IOSM_AGGR_MUX_CMD_FLOW_CTL_ACK 7
0029 
0030 /* Aggregation Protocol Command for report packet indicating link quality
0031  */
0032 #define IOSM_AGGR_MUX_CMD_LINK_STATUS_REPORT 8
0033 
0034 /* Response to a report packet */
0035 #define IOSM_AGGR_MUX_CMD_LINK_STATUS_REPORT_RESP 9
0036 
0037 /* ACBH: Signature of the Aggregated Command Block Header. */
0038 #define IOSM_AGGR_MUX_SIG_ACBH 0x48424341
0039 
0040 /* ADTH: Signature of the Aggregated Datagram Table Header. */
0041 #define IOSM_AGGR_MUX_SIG_ADTH 0x48544441
0042 
0043 /* ADBH: Signature of the Aggregated Data Block Header. */
0044 #define IOSM_AGGR_MUX_SIG_ADBH 0x48424441
0045 
0046 /* ADGH: Signature of the Datagram Header. */
0047 #define IOSM_AGGR_MUX_SIG_ADGH 0x48474441
0048 
0049 /* Size of the buffer for the IP MUX commands. */
0050 #define MUX_MAX_UL_ACB_BUF_SIZE 256
0051 
0052 /* Maximum number of packets in a go per session */
0053 #define MUX_MAX_UL_DG_ENTRIES 100
0054 
0055 /* ADGH: Signature of the Datagram Header. */
0056 #define MUX_SIG_ADGH 0x48474441
0057 
0058 /* CMDH: Signature of the Command Header. */
0059 #define MUX_SIG_CMDH 0x48444D43
0060 
0061 /* QLTH: Signature of the Queue Level Table */
0062 #define MUX_SIG_QLTH 0x48544C51
0063 
0064 /* FCTH: Signature of the Flow Credit Table */
0065 #define MUX_SIG_FCTH 0x48544346
0066 
0067 /* MUX UL session threshold factor */
0068 #define IPC_MEM_MUX_UL_SESS_FCOFF_THRESHOLD_FACTOR (4)
0069 
0070 /* Size of the buffer for the IP MUX Lite data buffer. */
0071 #define IPC_MEM_MAX_DL_MUX_LITE_BUF_SIZE (2 * 1024)
0072 
0073 /* MUX UL session threshold in number of packets */
0074 #define IPC_MEM_MUX_UL_SESS_FCON_THRESHOLD (64)
0075 
0076 /* Default time out for sending IPC session commands like
0077  * open session, close session etc
0078  * unit : milliseconds
0079  */
0080 #define IPC_MUX_CMD_RUN_DEFAULT_TIMEOUT 1000 /* 1 second */
0081 
0082 /* MUX UL flow control lower threshold in bytes */
0083 #define IPC_MEM_MUX_UL_FLOWCTRL_LOW_B 10240 /* 10KB */
0084 
0085 /* MUX UL flow control higher threshold in bytes (5ms worth of data)*/
0086 #define IPC_MEM_MUX_UL_FLOWCTRL_HIGH_B (110 * 1024)
0087 
0088 /**
0089  * struct mux_cmdh - Structure of Command Header.
0090  * @signature:      Signature of the Command Header.
0091  * @cmd_len:        Length (in bytes) of the Aggregated Command Block.
0092  * @if_id:      ID of the interface the commands in the table belong to.
0093  * @reserved:       Reserved. Set to zero.
0094  * @next_cmd_index: Index (in bytes) to the next command in the buffer.
0095  * @command_type:   Command Enum. See table Session Management chapter for
0096  *          details.
0097  * @transaction_id: The Transaction ID shall be unique to the command
0098  * @param:      Optional parameters used with the command.
0099  */
0100 struct mux_cmdh {
0101     __le32 signature;
0102     __le16 cmd_len;
0103     u8 if_id;
0104     u8 reserved;
0105     __le32 next_cmd_index;
0106     __le32 command_type;
0107     __le32 transaction_id;
0108     union mux_cmd_param param;
0109 };
0110 
0111 /**
0112  * struct mux_acbh -    Structure of the Aggregated Command Block Header.
0113  * @signature:          Signature of the Aggregated Command Block Header.
0114  * @reserved:           Reserved bytes. Set to zero.
0115  * @sequence_nr:        Block sequence number.
0116  * @block_length:       Length (in bytes) of the Aggregated Command Block.
0117  * @first_cmd_index:    Index (in bytes) to the first command in the buffer.
0118  */
0119 struct mux_acbh {
0120     __le32 signature;
0121     __le16 reserved;
0122     __le16 sequence_nr;
0123     __le32 block_length;
0124     __le32 first_cmd_index;
0125 };
0126 
0127 /**
0128  * struct mux_adbh - Structure of the Aggregated Data Block Header.
0129  * @signature:      Signature of the Aggregated Data Block Header.
0130  * @reserved:       Reserved bytes. Set to zero.
0131  * @sequence_nr:    Block sequence number.
0132  * @block_length:   Length (in bytes) of the Aggregated Data Block.
0133  * @first_table_index:  Index (in bytes) to the first Datagram Table in
0134  *          the buffer.
0135  */
0136 struct mux_adbh {
0137     __le32 signature;
0138     __le16 reserved;
0139     __le16 sequence_nr;
0140     __le32 block_length;
0141     __le32 first_table_index;
0142 };
0143 
0144 /**
0145  * struct mux_adth - Structure of the Aggregated Datagram Table Header.
0146  * @signature:          Signature of the Aggregated Datagram Table Header.
0147  * @table_length:       Length (in bytes) of the datagram table.
0148  * @if_id:              ID of the interface the datagrams in the table
0149  *                      belong to.
0150  * @opt_ipv4v6:         Indicates IPv4(=0)/IPv6(=1) hint.
0151  * @reserved:           Reserved bits. Set to zero.
0152  * @next_table_index:   Index (in bytes) to the next Datagram Table in
0153  *                      the buffer.
0154  * @reserved2:          Reserved bytes. Set to zero
0155  * @dg:                 datagramm table with variable length
0156  */
0157 struct mux_adth {
0158     __le32 signature;
0159     __le16 table_length;
0160     u8 if_id;
0161     u8 opt_ipv4v6;
0162     __le32 next_table_index;
0163     __le32 reserved2;
0164     struct mux_adth_dg dg;
0165 };
0166 
0167 /**
0168  * struct mux_adgh - Aggregated Datagram Header.
0169  * @signature:      Signature of the Aggregated Datagram Header(0x48474441)
0170  * @length:     Length (in bytes) of the datagram header. This length
0171  *          shall include the header size. Min value: 0x10
0172  * @if_id:      ID of the interface the datagrams belong to
0173  * @opt_ipv4v6:     Indicates IPv4(=0)/IPv6(=1), It is optional if not
0174  *          used set it to zero.
0175  * @reserved:       Reserved bits. Set to zero.
0176  * @service_class:  Service class identifier for the datagram.
0177  * @next_count:     Count of the datagrams that shall be following this
0178  *          datagrams for this interface. A count of zero means
0179  *          the next datagram may not belong to this interface.
0180  * @reserved1:      Reserved bytes, Set to zero
0181  */
0182 struct mux_adgh {
0183     __le32 signature;
0184     __le16 length;
0185     u8 if_id;
0186     u8 opt_ipv4v6;
0187     u8 service_class;
0188     u8 next_count;
0189     u8 reserved1[6];
0190 };
0191 
0192 /**
0193  * struct mux_lite_cmdh - MUX Lite Command Header
0194  * @signature:      Signature of the Command Header(0x48444D43)
0195  * @cmd_len:        Length (in bytes) of the command. This length shall
0196  *          include the header size. Minimum value: 0x10
0197  * @if_id:      ID of the interface the commands in the table belong to.
0198  * @reserved:       Reserved Set to zero.
0199  * @command_type:   Command Enum.
0200  * @transaction_id: 4 byte value shall be generated and sent along with a
0201  *          command Responses and ACKs shall have the same
0202  *          Transaction ID as their commands. It shall be unique to
0203  *          the command transaction on the given interface.
0204  * @param:      Optional parameters used with the command.
0205  */
0206 struct mux_lite_cmdh {
0207     __le32 signature;
0208     __le16 cmd_len;
0209     u8 if_id;
0210     u8 reserved;
0211     __le32 command_type;
0212     __le32 transaction_id;
0213     union mux_cmd_param param;
0214 };
0215 
0216 /**
0217  * struct mux_lite_vfl - value field in generic table
0218  * @nr_of_bytes:    Number of bytes available to transmit in the queue.
0219  */
0220 struct mux_lite_vfl {
0221     __le32 nr_of_bytes;
0222 };
0223 
0224 /**
0225  * struct ipc_mem_lite_gen_tbl - Generic table format for Queue Level
0226  *               and Flow Credit
0227  * @signature:  Signature of the table
0228  * @length: Length of the table
0229  * @if_id:  ID of the interface the table belongs to
0230  * @vfl_length: Value field length
0231  * @reserved:   Reserved
0232  * @vfl:    Value field of variable length
0233  */
0234 struct ipc_mem_lite_gen_tbl {
0235     __le32 signature;
0236     __le16 length;
0237     u8 if_id;
0238     u8 vfl_length;
0239     u32 reserved[2];
0240     struct mux_lite_vfl vfl;
0241 };
0242 
0243 /**
0244  * struct mux_type_cmdh - Structure of command header for mux lite and aggr
0245  * @ack_lite:   MUX Lite Command Header pointer
0246  * @ack_aggr:   Command Header pointer
0247  */
0248 union mux_type_cmdh {
0249     struct mux_lite_cmdh *ack_lite;
0250     struct mux_cmdh *ack_aggr;
0251 };
0252 
0253 /**
0254  * struct mux_type_header - Structure of mux header type
0255  * @adgh:   Aggregated Datagram Header pointer
0256  * @adbh:   Aggregated Data Block Header pointer
0257  */
0258 union mux_type_header {
0259     struct mux_adgh *adgh;
0260     struct mux_adbh *adbh;
0261 };
0262 
0263 void ipc_mux_dl_decode(struct iosm_mux *ipc_mux, struct sk_buff *skb);
0264 
0265 /**
0266  * ipc_mux_dl_acb_send_cmds - Respond to the Command blocks.
0267  * @ipc_mux:        Pointer to MUX data-struct
0268  * @cmd_type:       Command
0269  * @if_id:      Session interface id.
0270  * @transaction_id: Command transaction id.
0271  * @param:      Pointer to command params.
0272  * @res_size:       Response size
0273  * @blocking:       True for blocking send
0274  * @respond:        If true return transaction ID
0275  *
0276  * Returns:     0 in success and failure value on error
0277  */
0278 int ipc_mux_dl_acb_send_cmds(struct iosm_mux *ipc_mux, u32 cmd_type, u8 if_id,
0279                  u32 transaction_id, union mux_cmd_param *param,
0280                  size_t res_size, bool blocking, bool respond);
0281 
0282 /**
0283  * ipc_mux_netif_tx_flowctrl - Enable/Disable TX flow control on MUX sessions.
0284  * @session:    Pointer to mux_session struct
0285  * @idx:    Session ID
0286  * @on:     true for Enable and false for disable flow control
0287  */
0288 void ipc_mux_netif_tx_flowctrl(struct mux_session *session, int idx, bool on);
0289 
0290 /**
0291  * ipc_mux_ul_trigger_encode - Route the UL packet through the IP MUX layer
0292  *                 for encoding.
0293  * @ipc_mux:    Pointer to MUX data-struct
0294  * @if_id:  Session ID.
0295  * @skb:    Pointer to ipc_skb.
0296  *
0297  * Returns: 0 if successfully encoded
0298  *      failure value on error
0299  *      -EBUSY if packet has to be retransmitted.
0300  */
0301 int ipc_mux_ul_trigger_encode(struct iosm_mux *ipc_mux, int if_id,
0302                   struct sk_buff *skb);
0303 /**
0304  * ipc_mux_ul_data_encode - UL encode function for calling from Tasklet context.
0305  * @ipc_mux:    Pointer to MUX data-struct
0306  *
0307  * Returns: TRUE if any packet of any session is encoded FALSE otherwise.
0308  */
0309 bool ipc_mux_ul_data_encode(struct iosm_mux *ipc_mux);
0310 
0311 /**
0312  * ipc_mux_ul_encoded_process - Handles the Modem processed UL data by adding
0313  *              the SKB to the UL free list.
0314  * @ipc_mux:    Pointer to MUX data-struct
0315  * @skb:    Pointer to ipc_skb.
0316  */
0317 void ipc_mux_ul_encoded_process(struct iosm_mux *ipc_mux, struct sk_buff *skb);
0318 
0319 void ipc_mux_ul_adb_finish(struct iosm_mux *ipc_mux);
0320 
0321 void ipc_mux_ul_adb_update_ql(struct iosm_mux *ipc_mux, struct mux_adb *p_adb,
0322                   int session_id, int qlth_n_ql_size,
0323                   struct sk_buff_head *ul_list);
0324 
0325 #endif