0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _ISHTP_CLIENT_H_
0009 #define _ISHTP_CLIENT_H_
0010
0011 #include <linux/types.h>
0012 #include "ishtp-dev.h"
0013
0014
0015 #define CL_DEF_RX_RING_SIZE 2
0016 #define CL_DEF_TX_RING_SIZE 2
0017 #define CL_MAX_RX_RING_SIZE 32
0018 #define CL_MAX_TX_RING_SIZE 32
0019
0020 #define DMA_SLOT_SIZE 4096
0021
0022 #define DMA_WORTH_THRESHOLD 3
0023
0024
0025 #define CL_TX_PATH_DEFAULT 0
0026 #define CL_TX_PATH_IPC 1
0027 #define CL_TX_PATH_DMA 2
0028
0029
0030 struct ishtp_cl_tx_ring {
0031 struct list_head list;
0032 struct ishtp_msg_data send_buf;
0033 };
0034
0035
0036 struct ishtp_cl {
0037 struct list_head link;
0038 struct ishtp_device *dev;
0039 enum cl_state state;
0040 int status;
0041
0042
0043 struct ishtp_cl_device *device;
0044
0045
0046 uint8_t host_client_id;
0047 uint8_t fw_client_id;
0048 uint8_t ishtp_flow_ctrl_creds;
0049 uint8_t out_flow_ctrl_creds;
0050
0051
0052 int last_tx_path;
0053
0054 int last_dma_acked;
0055 unsigned char *last_dma_addr;
0056
0057 int last_ipc_acked;
0058
0059
0060 unsigned int rx_ring_size;
0061 struct ishtp_cl_rb free_rb_list;
0062 spinlock_t free_list_spinlock;
0063
0064 struct ishtp_cl_rb in_process_list;
0065 spinlock_t in_process_spinlock;
0066
0067
0068 unsigned int tx_ring_size;
0069 struct ishtp_cl_tx_ring tx_list, tx_free_list;
0070 int tx_ring_free_size;
0071 spinlock_t tx_list_spinlock;
0072 spinlock_t tx_free_list_spinlock;
0073 size_t tx_offs;
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 int sending;
0084
0085
0086 spinlock_t fc_spinlock;
0087
0088
0089 wait_queue_head_t wait_ctrl_res;
0090
0091
0092 unsigned int err_send_msg;
0093 unsigned int err_send_fc;
0094
0095
0096 unsigned int send_msg_cnt_ipc;
0097 unsigned int send_msg_cnt_dma;
0098 unsigned int recv_msg_cnt_ipc;
0099 unsigned int recv_msg_cnt_dma;
0100 unsigned int recv_msg_num_frags;
0101 unsigned int ishtp_flow_ctrl_cnt;
0102 unsigned int out_flow_ctrl_cnt;
0103
0104
0105 ktime_t ts_rx;
0106 ktime_t ts_out_fc;
0107 ktime_t ts_max_fc_delay;
0108 void *client_data;
0109 };
0110
0111
0112 int ishtp_can_client_connect(struct ishtp_device *ishtp_dev, guid_t *uuid);
0113 int ishtp_fw_cl_by_id(struct ishtp_device *dev, uint8_t client_id);
0114 void ishtp_cl_send_msg(struct ishtp_device *dev, struct ishtp_cl *cl);
0115 void recv_ishtp_cl_msg(struct ishtp_device *dev,
0116 struct ishtp_msg_hdr *ishtp_hdr);
0117 int ishtp_cl_read_start(struct ishtp_cl *cl);
0118
0119
0120 int ishtp_cl_alloc_rx_ring(struct ishtp_cl *cl);
0121 int ishtp_cl_alloc_tx_ring(struct ishtp_cl *cl);
0122 void ishtp_cl_free_rx_ring(struct ishtp_cl *cl);
0123 void ishtp_cl_free_tx_ring(struct ishtp_cl *cl);
0124 int ishtp_cl_get_tx_free_buffer_size(struct ishtp_cl *cl);
0125 int ishtp_cl_get_tx_free_rings(struct ishtp_cl *cl);
0126
0127
0128 void recv_ishtp_cl_msg_dma(struct ishtp_device *dev, void *msg,
0129 struct dma_xfer_hbm *hbm);
0130 void ishtp_cl_alloc_dma_buf(struct ishtp_device *dev);
0131 void ishtp_cl_free_dma_buf(struct ishtp_device *dev);
0132 void *ishtp_cl_get_dma_send_buf(struct ishtp_device *dev,
0133 uint32_t size);
0134 void ishtp_cl_release_dma_acked_mem(struct ishtp_device *dev,
0135 void *msg_addr,
0136 uint8_t size);
0137
0138
0139 struct ishtp_cl_rb *ishtp_io_rb_init(struct ishtp_cl *cl);
0140 void ishtp_io_rb_free(struct ishtp_cl_rb *priv_rb);
0141 int ishtp_io_rb_alloc_buf(struct ishtp_cl_rb *rb, size_t length);
0142
0143
0144
0145
0146
0147 static inline bool ishtp_cl_cmp_id(const struct ishtp_cl *cl1,
0148 const struct ishtp_cl *cl2)
0149 {
0150 return cl1 && cl2 &&
0151 (cl1->host_client_id == cl2->host_client_id) &&
0152 (cl1->fw_client_id == cl2->fw_client_id);
0153 }
0154
0155 #endif