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_IMEM_OPS_H
0007 #define IOSM_IPC_IMEM_OPS_H
0008 
0009 #include "iosm_ipc_mux_codec.h"
0010 
0011 /* Maximum wait time for blocking read */
0012 #define IPC_READ_TIMEOUT 3000
0013 
0014 /* The delay in ms for defering the unregister */
0015 #define SIO_UNREGISTER_DEFER_DELAY_MS 1
0016 
0017 /* Default delay till CP PSI image is running and modem updates the
0018  * execution stage.
0019  * unit : milliseconds
0020  */
0021 #define PSI_START_DEFAULT_TIMEOUT 3000
0022 
0023 /* Default time out when closing SIO, till the modem is in
0024  * running state.
0025  * unit : milliseconds
0026  */
0027 #define BOOT_CHECK_DEFAULT_TIMEOUT 400
0028 
0029 /* IP MUX channel range */
0030 #define IP_MUX_SESSION_START 0
0031 #define IP_MUX_SESSION_END 7
0032 
0033 /* Default IP MUX channel */
0034 #define IP_MUX_SESSION_DEFAULT  0
0035 
0036 /**
0037  * ipc_imem_sys_port_open - Open a port link to CP.
0038  * @ipc_imem:   Imem instance.
0039  * @chl_id: Channel Indentifier.
0040  * @hp_id:  HP Indentifier.
0041  *
0042  * Return: channel instance on success, NULL for failure
0043  */
0044 struct ipc_mem_channel *ipc_imem_sys_port_open(struct iosm_imem *ipc_imem,
0045                            int chl_id, int hp_id);
0046 void ipc_imem_sys_port_close(struct iosm_imem *ipc_imem,
0047                  struct ipc_mem_channel *channel);
0048 
0049 /**
0050  * ipc_imem_sys_cdev_write - Route the uplink buffer to CP.
0051  * @ipc_cdev:       iosm_cdev instance.
0052  * @skb:        Pointer to skb.
0053  *
0054  * Return: 0 on success and failure value on error
0055  */
0056 int ipc_imem_sys_cdev_write(struct iosm_cdev *ipc_cdev, struct sk_buff *skb);
0057 
0058 /**
0059  * ipc_imem_sys_wwan_open - Open packet data online channel between network
0060  *          layer and CP.
0061  * @ipc_imem:       Imem instance.
0062  * @if_id:      ip link tag of the net device.
0063  *
0064  * Return: Channel ID on success and failure value on error
0065  */
0066 int ipc_imem_sys_wwan_open(struct iosm_imem *ipc_imem, int if_id);
0067 
0068 /**
0069  * ipc_imem_sys_wwan_close - Close packet data online channel between network
0070  *           layer and CP.
0071  * @ipc_imem:       Imem instance.
0072  * @if_id:      IP link id net device.
0073  * @channel_id:     Channel ID to be closed.
0074  */
0075 void ipc_imem_sys_wwan_close(struct iosm_imem *ipc_imem, int if_id,
0076                  int channel_id);
0077 
0078 /**
0079  * ipc_imem_sys_wwan_transmit - Function for transfer UL data
0080  * @ipc_imem:       Imem instance.
0081  * @if_id:      link ID of the device.
0082  * @channel_id:     Channel ID used
0083  * @skb:        Pointer to sk buffer
0084  *
0085  * Return: 0 on success and failure value on error
0086  */
0087 int ipc_imem_sys_wwan_transmit(struct iosm_imem *ipc_imem, int if_id,
0088                    int channel_id, struct sk_buff *skb);
0089 /**
0090  * ipc_imem_wwan_channel_init - Initializes WWAN channels and the channel for
0091  *              MUX.
0092  * @ipc_imem:       Pointer to iosm_imem struct.
0093  * @mux_type:       Type of mux protocol.
0094  */
0095 void ipc_imem_wwan_channel_init(struct iosm_imem *ipc_imem,
0096                 enum ipc_mux_protocol mux_type);
0097 
0098 /**
0099  * ipc_imem_sys_devlink_open - Open a Flash/CD Channel link to CP
0100  * @ipc_imem:   iosm_imem instance
0101  *
0102  * Return:  channel instance on success, NULL for failure
0103  */
0104 struct ipc_mem_channel *ipc_imem_sys_devlink_open(struct iosm_imem *ipc_imem);
0105 
0106 /**
0107  * ipc_imem_sys_devlink_close - Release a Flash/CD channel link to CP
0108  * @ipc_devlink:    Pointer to ipc_devlink data-struct
0109  *
0110  */
0111 void ipc_imem_sys_devlink_close(struct iosm_devlink *ipc_devlink);
0112 
0113 /**
0114  * ipc_imem_sys_devlink_notify_rx - Receive downlink characters from CP,
0115  *              the downlink skbuf is added at the end of the
0116  *              downlink or rx list
0117  * @ipc_devlink:    Pointer to ipc_devlink data-struct
0118  * @skb:        Pointer to sk buffer
0119  */
0120 void ipc_imem_sys_devlink_notify_rx(struct iosm_devlink *ipc_devlink,
0121                     struct sk_buff *skb);
0122 
0123 /**
0124  * ipc_imem_sys_devlink_read - Copy the rx data and free the skbuf
0125  * @ipc_devlink:    Devlink instance
0126  * @data:       Buffer to read the data from modem
0127  * @bytes_to_read:  Size of destination buffer
0128  * @bytes_read:     Number of bytes read
0129  *
0130  * Return: 0 on success and failure value on error
0131  */
0132 int ipc_imem_sys_devlink_read(struct iosm_devlink *ipc_devlink, u8 *data,
0133                   u32 bytes_to_read, u32 *bytes_read);
0134 
0135 /**
0136  * ipc_imem_sys_devlink_write - Route the uplink buffer to CP
0137  * @ipc_devlink:    Devlink_sio instance
0138  * @buf:        Pointer to buffer
0139  * @count:      Number of data bytes to write
0140  * Return:      0 on success and failure value on error
0141  */
0142 int ipc_imem_sys_devlink_write(struct iosm_devlink *ipc_devlink,
0143                    unsigned char *buf, int count);
0144 
0145 #endif