![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only 0002 * 0003 * Copyright (C) 2020-21 Intel Corporation. 0004 */ 0005 0006 #ifndef IOSM_IPC_MUX_H 0007 #define IOSM_IPC_MUX_H 0008 0009 #include "iosm_ipc_protocol.h" 0010 0011 #define IPC_MEM_MAX_UL_DG_ENTRIES 100 0012 #define IPC_MEM_MAX_TDS_MUX_AGGR_UL 60 0013 0014 #define IPC_MEM_MAX_ADB_BUF_SIZE (16 * 1024) 0015 #define IPC_MEM_MAX_UL_ADB_BUF_SIZE IPC_MEM_MAX_ADB_BUF_SIZE 0016 #define IPC_MEM_MAX_DL_ADB_BUF_SIZE IPC_MEM_MAX_ADB_BUF_SIZE 0017 0018 /* Size of the buffer for the IP MUX Lite data buffer. */ 0019 #define IPC_MEM_MAX_DL_MUX_LITE_BUF_SIZE (2 * 1024) 0020 0021 /* TD counts for IP MUX Lite */ 0022 #define IPC_MEM_MAX_TDS_MUX_LITE_UL 800 0023 #define IPC_MEM_MAX_TDS_MUX_LITE_DL 1200 0024 0025 /* open session request (AP->CP) */ 0026 #define MUX_CMD_OPEN_SESSION 1 0027 0028 /* response to open session request (CP->AP) */ 0029 #define MUX_CMD_OPEN_SESSION_RESP 2 0030 0031 /* close session request (AP->CP) */ 0032 #define MUX_CMD_CLOSE_SESSION 3 0033 0034 /* response to close session request (CP->AP) */ 0035 #define MUX_CMD_CLOSE_SESSION_RESP 4 0036 0037 /* Flow control command with mask of the flow per queue/flow. */ 0038 #define MUX_LITE_CMD_FLOW_CTL 5 0039 0040 /* ACK the flow control command. Shall have the same Transaction ID as the 0041 * matching FLOW_CTL command. 0042 */ 0043 #define MUX_LITE_CMD_FLOW_CTL_ACK 6 0044 0045 /* Command for report packet indicating link quality metrics. */ 0046 #define MUX_LITE_CMD_LINK_STATUS_REPORT 7 0047 0048 /* Response to a report packet */ 0049 #define MUX_LITE_CMD_LINK_STATUS_REPORT_RESP 8 0050 0051 /* Used to reset a command/response state. */ 0052 #define MUX_CMD_INVALID 255 0053 0054 /* command response : command processed successfully */ 0055 #define MUX_CMD_RESP_SUCCESS 0 0056 0057 /* MUX for route link devices */ 0058 #define IPC_MEM_WWAN_MUX BIT(0) 0059 0060 /* Initiated actions to change the state of the MUX object. */ 0061 enum mux_event { 0062 MUX_E_INACTIVE, /* No initiated actions. */ 0063 MUX_E_MUX_SESSION_OPEN, /* Create the MUX channel and a session. */ 0064 MUX_E_MUX_SESSION_CLOSE, /* Release a session. */ 0065 MUX_E_MUX_CHANNEL_CLOSE, /* Release the MUX channel. */ 0066 MUX_E_NO_ORDERS, /* No MUX order. */ 0067 MUX_E_NOT_APPLICABLE, /* Defect IP MUX. */ 0068 }; 0069 0070 /* MUX session open command. */ 0071 struct mux_session_open { 0072 enum mux_event event; 0073 __le32 if_id; 0074 }; 0075 0076 /* MUX session close command. */ 0077 struct mux_session_close { 0078 enum mux_event event; 0079 __le32 if_id; 0080 }; 0081 0082 /* MUX channel close command. */ 0083 struct mux_channel_close { 0084 enum mux_event event; 0085 }; 0086 0087 /* Default message type to find out the right message type. */ 0088 struct mux_common { 0089 enum mux_event event; 0090 }; 0091 0092 /* List of ops in MUX mode. */ 0093 union mux_msg { 0094 struct mux_session_open session_open; 0095 struct mux_session_close session_close; 0096 struct mux_channel_close channel_close; 0097 struct mux_common common; 0098 }; 0099 0100 /* Parameter definition of the open session command. */ 0101 struct mux_cmd_open_session { 0102 u8 flow_ctrl; /* 0: Flow control disabled (flow allowed). */ 0103 /* 1: Flow control enabled (flow not allowed)*/ 0104 u8 ipv4v6_hints; /* 0: IPv4/IPv6 hints not supported.*/ 0105 /* 1: IPv4/IPv6 hints supported*/ 0106 __le16 reserved2; /* Reserved. Set to zero. */ 0107 __le32 dl_head_pad_len; /* Maximum length supported */ 0108 /* for DL head padding on a datagram. */ 0109 }; 0110 0111 /* Parameter definition of the open session response. */ 0112 struct mux_cmd_open_session_resp { 0113 __le32 response; /* Response code */ 0114 u8 flow_ctrl; /* 0: Flow control disabled (flow allowed). */ 0115 /* 1: Flow control enabled (flow not allowed) */ 0116 u8 ipv4v6_hints; /* 0: IPv4/IPv6 hints not supported */ 0117 /* 1: IPv4/IPv6 hints supported */ 0118 __le16 reserved2; /* Reserved. Set to zero. */ 0119 __le32 ul_head_pad_len; /* Actual length supported for */ 0120 /* UL head padding on adatagram.*/ 0121 }; 0122 0123 /* Parameter definition of the close session response code */ 0124 struct mux_cmd_close_session_resp { 0125 __le32 response; 0126 }; 0127 0128 /* Parameter definition of the flow control command. */ 0129 struct mux_cmd_flow_ctl { 0130 __le32 mask; /* indicating the desired flow control */ 0131 /* state for various flows/queues */ 0132 }; 0133 0134 /* Parameter definition of the link status report code*/ 0135 struct mux_cmd_link_status_report { 0136 u8 payload; 0137 }; 0138 0139 /* Parameter definition of the link status report response code. */ 0140 struct mux_cmd_link_status_report_resp { 0141 __le32 response; 0142 }; 0143 0144 /** 0145 * union mux_cmd_param - Union-definition of the command parameters. 0146 * @open_session: Inband command for open session 0147 * @open_session_resp: Inband command for open session response 0148 * @close_session_resp: Inband command for close session response 0149 * @flow_ctl: In-band flow control on the opened interfaces 0150 * @link_status: In-band Link Status Report 0151 * @link_status_resp: In-band command for link status report response 0152 */ 0153 union mux_cmd_param { 0154 struct mux_cmd_open_session open_session; 0155 struct mux_cmd_open_session_resp open_session_resp; 0156 struct mux_cmd_close_session_resp close_session_resp; 0157 struct mux_cmd_flow_ctl flow_ctl; 0158 struct mux_cmd_link_status_report link_status; 0159 struct mux_cmd_link_status_report_resp link_status_resp; 0160 }; 0161 0162 /* States of the MUX object.. */ 0163 enum mux_state { 0164 MUX_S_INACTIVE, /* IP MUX is unused. */ 0165 MUX_S_ACTIVE, /* IP MUX channel is available. */ 0166 MUX_S_ERROR, /* Defect IP MUX. */ 0167 }; 0168 0169 /* Supported MUX protocols. */ 0170 enum ipc_mux_protocol { 0171 MUX_UNKNOWN, 0172 MUX_LITE, 0173 MUX_AGGREGATION, 0174 }; 0175 0176 /* Supported UL data transfer methods. */ 0177 enum ipc_mux_ul_flow { 0178 MUX_UL_UNKNOWN, 0179 MUX_UL, /* Normal UL data transfer */ 0180 MUX_UL_ON_CREDITS, /* UL data transfer will be based on credits */ 0181 }; 0182 0183 /* List of the MUX session. */ 0184 struct mux_session { 0185 struct iosm_wwan *wwan; /*Network i/f used for communication*/ 0186 int if_id; /* i/f id for session open message.*/ 0187 u32 flags; 0188 u32 ul_head_pad_len; /* Nr of bytes for UL head padding. */ 0189 u32 dl_head_pad_len; /* Nr of bytes for DL head padding. */ 0190 struct sk_buff_head ul_list; /* skb entries for an ADT. */ 0191 u32 flow_ctl_mask; /* UL flow control */ 0192 u32 flow_ctl_en_cnt; /* Flow control Enable cmd count */ 0193 u32 flow_ctl_dis_cnt; /* Flow Control Disable cmd count */ 0194 int ul_flow_credits; /* UL flow credits */ 0195 u8 net_tx_stop:1, 0196 flush:1; /* flush net interface ? */ 0197 }; 0198 0199 /** 0200 * struct mux_adth_dg - Structure of the datagram in the Aggregated Datagram 0201 * Table Header. 0202 * @datagram_index : Index (in bytes) to the k-th datagram in the table. 0203 * Index shall count from the start of the block including 0204 * the 16-byte header. This value shall be non-zero. 0205 * @datagram_length: Length of the k-th datagram including the head padding. 0206 * This value shall be non-zero. 0207 * @service_class: Service class identifier for the datagram. 0208 * @reserved: Reserved bytes. Set to zero 0209 */ 0210 struct mux_adth_dg { 0211 __le32 datagram_index; 0212 __le16 datagram_length; 0213 u8 service_class; 0214 u8 reserved; 0215 }; 0216 0217 /** 0218 * struct mux_qlth_ql - Structure of the queue level in the Aggregated 0219 * Datagram Queue Level Table Header. 0220 * @nr_of_bytes: Number of bytes available to transmit in the queue. 0221 */ 0222 struct mux_qlth_ql { 0223 __le32 nr_of_bytes; 0224 }; 0225 0226 /** 0227 * struct mux_qlth - Structure of Aggregated Datagram Queue Level Table 0228 * Header. 0229 * @signature: Signature of the Queue Level Table Header 0230 * Value: 0x48544C51 (ASCII characters: 'Q' 'L' 'T' 'H') 0231 * @table_length: Length (in bytes) of the datagram table. This length 0232 * shall include the queue level table header size. 0233 * Minimum value:0x10 0234 * @if_id: ID of the interface the queue levels in the table 0235 * belong to. 0236 * @reserved: Reserved byte. Set to zero. 0237 * @next_table_index: Index (in bytes) to the next table in the buffer. Index 0238 * shall count from the start of the block including the 0239 * 16-byte header. Value of zero indicates end of the list. 0240 * @reserved2: Reserved bytes. Set to zero 0241 * @ql: Queue level table with variable length 0242 */ 0243 struct mux_qlth { 0244 __le32 signature; 0245 __le16 table_length; 0246 u8 if_id; 0247 u8 reserved; 0248 __le32 next_table_index; 0249 __le32 reserved2; 0250 struct mux_qlth_ql ql; 0251 }; 0252 0253 /** 0254 * struct mux_adb - Structure of State of a single UL data block. 0255 * @dest_skb: Current UL skb for the data block. 0256 * @buf: ADB memory 0257 * @adgh: ADGH pointer 0258 * @qlth_skb: QLTH pointer 0259 * @next_table_index: Pointer to next table index. 0260 * @free_list: List of alloc. ADB for the UL sess. 0261 * @size: Size of the ADB memory. 0262 * @if_cnt: Statistic counter 0263 * @dg_cnt_total: Datagram count total 0264 * @payload_size: Payload Size 0265 * @dg: Datagram table. 0266 * @pp_qlt: Pointers to hold Queue Level Tables of session 0267 * @adbh: ADBH pointer 0268 * @qlt_updated: Queue level table updated 0269 * @dg_count: Datagram count 0270 */ 0271 struct mux_adb { 0272 struct sk_buff *dest_skb; 0273 u8 *buf; 0274 struct mux_adgh *adgh; 0275 struct sk_buff *qlth_skb; 0276 u32 *next_table_index; 0277 struct sk_buff_head free_list; 0278 int size; 0279 u32 if_cnt; 0280 u32 dg_cnt_total; 0281 u32 payload_size; 0282 struct mux_adth_dg 0283 dg[IPC_MEM_MUX_IP_SESSION_ENTRIES][IPC_MEM_MAX_UL_DG_ENTRIES]; 0284 struct mux_qlth *pp_qlt[IPC_MEM_MUX_IP_SESSION_ENTRIES]; 0285 struct mux_adbh *adbh; 0286 u32 qlt_updated[IPC_MEM_MUX_IP_SESSION_ENTRIES]; 0287 u32 dg_count[IPC_MEM_MUX_IP_SESSION_ENTRIES]; 0288 }; 0289 0290 /** 0291 * struct mux_acb - Structure of Temporary ACB state. 0292 * @skb: Used UL skb. 0293 * @if_id: Session id. 0294 * @buf_p: Command buffer. 0295 * @wanted_response: Wanted Response 0296 * @got_response: Got response 0297 * @cmd: command 0298 * @got_param: Received command/response parameter 0299 */ 0300 struct mux_acb { 0301 struct sk_buff *skb; /* Used UL skb. */ 0302 int if_id; /* Session id. */ 0303 u8 *buf_p; 0304 u32 wanted_response; 0305 u32 got_response; 0306 u32 cmd; 0307 union mux_cmd_param got_param; /* Received command/response parameter */ 0308 }; 0309 0310 /** 0311 * struct iosm_mux - Structure of the data multiplexing over an IP channel. 0312 * @dev: Pointer to device structure 0313 * @session: Array of the MUX sessions. 0314 * @channel: Reference to the IP MUX channel 0315 * @pcie: Pointer to iosm_pcie struct 0316 * @imem: Pointer to iosm_imem 0317 * @wwan: Poinetr to iosm_wwan 0318 * @ipc_protocol: Pointer to iosm_protocol 0319 * @channel_id: Channel ID for MUX 0320 * @protocol: Type of the MUX protocol 0321 * @ul_flow: UL Flow type 0322 * @nr_sessions: Number of sessions 0323 * @instance_id: Instance ID 0324 * @state: States of the MUX object 0325 * @event: Initiated actions to change the state of the MUX object 0326 * @tx_transaction_id: Transaction id for the ACB command. 0327 * @rr_next_session: Next session number for round robin. 0328 * @ul_adb: State of the UL ADB/ADGH. 0329 * @size_needed: Variable to store the size needed during ADB preparation 0330 * @ul_data_pend_bytes: Pending UL data to be processed in bytes 0331 * @acb: Temporary ACB state 0332 * @wwan_q_offset: This will hold the offset of the given instance 0333 * Useful while passing or receiving packets from 0334 * wwan/imem layer. 0335 * @adb_finish_timer: Timer for forcefully finishing the ADB 0336 * @acb_tx_sequence_nr: Sequence number for the ACB header. 0337 * @params: user configurable parameters 0338 * @adb_tx_sequence_nr: Sequence number for ADB header 0339 * @acc_adb_size: Statistic data for logging 0340 * @acc_payload_size: Statistic data for logging 0341 * @initialized: MUX object is initialized 0342 * @ev_mux_net_transmit_pending: 0343 * 0 means inform the IPC tasklet to pass the 0344 * accumulated uplink ADB to CP. 0345 * @adb_prep_ongoing: Flag for ADB preparation status 0346 */ 0347 struct iosm_mux { 0348 struct device *dev; 0349 struct mux_session session[IPC_MEM_MUX_IP_SESSION_ENTRIES]; 0350 struct ipc_mem_channel *channel; 0351 struct iosm_pcie *pcie; 0352 struct iosm_imem *imem; 0353 struct iosm_wwan *wwan; 0354 struct iosm_protocol *ipc_protocol; 0355 int channel_id; 0356 enum ipc_mux_protocol protocol; 0357 enum ipc_mux_ul_flow ul_flow; 0358 int nr_sessions; 0359 int instance_id; 0360 enum mux_state state; 0361 enum mux_event event; 0362 u32 tx_transaction_id; 0363 int rr_next_session; 0364 struct mux_adb ul_adb; 0365 int size_needed; 0366 long long ul_data_pend_bytes; 0367 struct mux_acb acb; 0368 int wwan_q_offset; 0369 struct hrtimer adb_finish_timer; 0370 u16 acb_tx_sequence_nr; 0371 struct ipc_params *params; 0372 u16 adb_tx_sequence_nr; 0373 unsigned long long acc_adb_size; 0374 unsigned long long acc_payload_size; 0375 u8 initialized:1, 0376 ev_mux_net_transmit_pending:1, 0377 adb_prep_ongoing; 0378 } __packed; 0379 0380 /* MUX configuration structure */ 0381 struct ipc_mux_config { 0382 enum ipc_mux_protocol protocol; 0383 enum ipc_mux_ul_flow ul_flow; 0384 int instance_id; 0385 }; 0386 0387 /** 0388 * ipc_mux_init - Allocates and Init MUX instance 0389 * @mux_cfg: Pointer to MUX configuration structure 0390 * @ipc_imem: Pointer to imem data-struct 0391 * 0392 * Returns: Initialized mux pointer on success else NULL 0393 */ 0394 struct iosm_mux *ipc_mux_init(struct ipc_mux_config *mux_cfg, 0395 struct iosm_imem *ipc_imem); 0396 0397 /** 0398 * ipc_mux_deinit - Deallocates MUX instance 0399 * @ipc_mux: Pointer to the MUX instance. 0400 */ 0401 void ipc_mux_deinit(struct iosm_mux *ipc_mux); 0402 0403 /** 0404 * ipc_mux_check_n_restart_tx - Checks for pending UL date bytes and then 0405 * it restarts the net interface tx queue if 0406 * device has set flow control as off. 0407 * @ipc_mux: Pointer to MUX data-struct 0408 */ 0409 void ipc_mux_check_n_restart_tx(struct iosm_mux *ipc_mux); 0410 0411 /** 0412 * ipc_mux_get_active_protocol - Returns the active MUX protocol type. 0413 * @ipc_mux: Pointer to MUX data-struct 0414 * 0415 * Returns: enum of type ipc_mux_protocol 0416 */ 0417 enum ipc_mux_protocol ipc_mux_get_active_protocol(struct iosm_mux *ipc_mux); 0418 0419 /** 0420 * ipc_mux_open_session - Opens a MUX session for IP traffic. 0421 * @ipc_mux: Pointer to MUX data-struct 0422 * @session_nr: Interface ID or session number 0423 * 0424 * Returns: channel id on success, failure value on error 0425 */ 0426 int ipc_mux_open_session(struct iosm_mux *ipc_mux, int session_nr); 0427 0428 /** 0429 * ipc_mux_close_session - Closes a MUX session. 0430 * @ipc_mux: Pointer to MUX data-struct 0431 * @session_nr: Interface ID or session number 0432 * 0433 * Returns: channel id on success, failure value on error 0434 */ 0435 int ipc_mux_close_session(struct iosm_mux *ipc_mux, int session_nr); 0436 0437 /** 0438 * ipc_mux_get_max_sessions - Retuns the maximum sessions supported on the 0439 * provided MUX instance.. 0440 * @ipc_mux: Pointer to MUX data-struct 0441 * 0442 * Returns: Number of sessions supported on Success and failure value on error 0443 */ 0444 int ipc_mux_get_max_sessions(struct iosm_mux *ipc_mux); 0445 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |