123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- #ifndef _GOOGLE_EASEL_COMM_PRIVATE_H
- #define _GOOGLE_EASEL_COMM_PRIVATE_H
- #include "google-easel-comm-shared.h"
- #include <linux/completion.h>
- #include <linux/list.h>
- #include <linux/miscdevice.h>
- #include <linux/mutex.h>
- #include <linux/spinlock.h>
- #include <linux/types.h>
- enum easelcomm_msg_type {
- TYPE_LOCAL = 0,
- TYPE_REMOTE_NONREPLY,
- TYPE_REMOTE_REPLY,
- };
- struct easelcomm_dma_xfer_info {
-
- void *sg_local;
-
- uint32_t sg_local_size;
-
- void *sg_local_localdata;
-
- void *sg_remote;
-
- uint32_t sg_remote_size;
-
- struct completion sg_remote_ready;
-
- uint32_t xfer_type;
-
- uint64_t server_addr;
-
- struct completion xfer_ready;
-
- struct completion xfer_done;
-
- bool aborting;
-
- int32_t errcode;
- };
- struct easelcomm_message_metadata {
-
- int reference_count;
-
- bool free_message;
-
- bool flushing;
-
- enum easelcomm_msg_type msg_type;
-
- struct list_head list;
-
- bool queued;
-
- struct list_head rcvq_list;
-
- struct completion reply_received;
-
- struct easelcomm_message_metadata *reply_metadata;
-
- struct easelcomm_dma_xfer_info dma_xfer;
-
- struct easelcomm_kmsg *msg;
- };
- struct easelcomm_user_state;
- struct easelcomm_service {
-
- unsigned int service_id;
-
- struct mutex lock;
-
- struct easelcomm_user_state *user;
-
- bool shutdown_local;
-
- bool shutdown_remote;
-
- easelcomm_msgid_t next_id;
-
- struct list_head local_list;
-
- struct list_head receivemsg_queue;
-
- struct completion receivemsg_queue_new;
-
- struct list_head remote_list;
-
- struct completion flush_done;
- };
- #ifdef CONFIG_GOOGLE_EASEL_AP
- #define easelcomm_is_client() (true)
- #define easelcomm_is_server() (false)
- #else
- #define easelcomm_is_client() (false)
- #define easelcomm_is_server() (true)
- #endif
- extern struct miscdevice easelcomm_miscdev;
- static inline char *easelcomm_msgid_prefix(
- struct easelcomm_message_metadata *msg_metadata)
- {
- return msg_metadata->msg_type == TYPE_LOCAL ? "l" : "r";
- }
- extern void easelcomm_handle_cmd_dma_sg(
- struct easelcomm_service *service, char *command_args,
- size_t command_arg_len);
- extern void easelcomm_handle_cmd_dma_xfer(
- struct easelcomm_service *service, char *command_args,
- size_t command_arg_len);
- extern void easelcomm_handle_cmd_dma_done(
- struct easelcomm_service *service, char *command_args,
- size_t command_arg_len);
- extern int easelcomm_receive_dma(
- struct easelcomm_service *service,
- struct easelcomm_kbuf_desc *buf_desc);
- extern int easelcomm_send_dma(
- struct easelcomm_service *service,
- struct easelcomm_kbuf_desc *buf_desc);
- extern void easelcomm_drop_reference(
- struct easelcomm_service *service,
- struct easelcomm_message_metadata *msg_metadata, bool mark_free);
- extern struct easelcomm_message_metadata *easelcomm_find_local_message(
- struct easelcomm_service *service, easelcomm_msgid_t message_id);
- extern struct easelcomm_message_metadata *easelcomm_find_remote_message(
- struct easelcomm_service *service, easelcomm_msgid_t message_id);
- extern int easelcomm_start_cmd(
- struct easelcomm_service *service, int command_code,
- size_t command_arg_len);
- extern int easelcomm_append_cmd_args(
- struct easelcomm_service *service, void *cmd_args,
- size_t cmd_args_len);
- extern int easelcomm_send_cmd(struct easelcomm_service *service);
- extern int easelcomm_send_cmd_noargs(
- struct easelcomm_service *service, int command_code);
- extern int easelcomm_hw_init(void);
- extern int easelcomm_hw_ap_setup_cmdchans(void);
- extern int easelcomm_hw_send_data_interrupt(void);
- extern int easelcomm_hw_send_wrap_interrupt(void);
- extern int easelcomm_hw_remote_read(
- void *local_addr, size_t len, uint64_t remote_offset);
- extern int easelcomm_hw_remote_write(
- void *local_addr, size_t len, uint64_t remote_offset);
- extern void *easelcomm_hw_build_scatterlist(
- struct easelcomm_kbuf_desc *buf_desc,
- uint32_t *scatterlist_size,
- void **sglocaldata, enum easelcomm_dma_direction dma_dir);
- extern int easelcomm_hw_scatterlist_block_count(uint32_t scatterlist_size);
- extern uint64_t easelcomm_hw_scatterlist_sblk_addr(void *sglist);
- extern void easelcomm_hw_destroy_scatterlist(void *sglocaldata);
- extern int easelcomm_hw_verify_scatterlist(
- struct easelcomm_dma_xfer_info *xfer);
- extern int easelcomm_hw_easel_build_ll(
- void *src_sg, void *dest_sg, void **ll_data);
- extern uint64_t easelcomm_hw_easel_ll_addr(void *ll_data);
- extern int easelcomm_hw_easel_destroy_ll(void *ll_data);
- extern int easelcomm_hw_ap_dma_sblk_transfer(
- uint64_t ap_paddr, uint64_t easel_paddr, uint32_t xfer_len,
- bool to_easel);
- extern int easelcomm_hw_ap_dma_mblk_transfer(uint64_t ll_paddr, bool to_easel);
- int easelcomm_init_pcie_ready(void *local_cmdchan_buffer);
- int easelcomm_pcie_hotplug_out(void);
- extern void easelcomm_cmd_channel_data_handler(void);
- extern void easelcomm_cmd_channel_wrap_handler(void);
- extern int easelcomm_client_remote_cmdchan_ready_handler(void);
- #endif
|