123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- #ifndef SCIF_MAIN_H
- #define SCIF_MAIN_H
- #include <linux/sched.h>
- #include <linux/pci.h>
- #include <linux/miscdevice.h>
- #include <linux/dmaengine.h>
- #include <linux/file.h>
- #include <linux/scif.h>
- #include "../common/mic_dev.h"
- #define SCIF_MGMT_NODE 0
- #define SCIF_DEFAULT_WATCHDOG_TO 30
- #define SCIF_NODE_ACCEPT_TIMEOUT (3 * HZ)
- #define SCIF_NODE_ALIVE_TIMEOUT (SCIF_DEFAULT_WATCHDOG_TO * HZ)
- enum scif_msg_state {
- OP_IDLE = 1,
- OP_IN_PROGRESS,
- OP_COMPLETED,
- OP_FAILED
- };
- struct scif_info {
- u8 nodeid;
- u8 maxid;
- u8 total;
- u32 nr_zombies;
- spinlock_t eplock;
- struct mutex connlock;
- spinlock_t nb_connect_lock;
- spinlock_t port_lock;
- struct list_head uaccept;
- struct list_head listen;
- struct list_head zombie;
- struct list_head connected;
- struct list_head disconnected;
- struct list_head nb_connect_list;
- struct work_struct misc_work;
- struct mutex conflock;
- u8 en_msg_log;
- u8 p2p_enable;
- struct miscdevice mdev;
- struct work_struct conn_work;
- wait_queue_head_t exitwq;
- struct scif_dev *loopb_dev;
- struct workqueue_struct *loopb_wq;
- char loopb_wqname[16];
- struct work_struct loopb_work;
- struct list_head loopb_recv_q;
- bool card_initiated_exit;
- };
- struct scif_p2p_info {
- u8 ppi_peer_id;
- struct scatterlist *ppi_sg[2];
- u64 sg_nentries[2];
- dma_addr_t ppi_da[2];
- u64 ppi_len[2];
- #define SCIF_PPI_MMIO 0
- #define SCIF_PPI_APER 1
- struct list_head ppi_list;
- };
- struct scif_dev {
- u8 node;
- struct list_head p2p;
- struct scif_qp *qpairs;
- struct workqueue_struct *intr_wq;
- char intr_wqname[16];
- struct work_struct intr_bh;
- struct mutex lock;
- struct scif_hw_dev *sdev;
- int db;
- int rdb;
- struct mic_irq *cookie;
- struct work_struct init_msg_work;
- struct delayed_work p2p_dwork;
- struct delayed_work qp_dwork;
- int p2p_retry;
- dma_addr_t base_addr;
- struct mic_mw mmio;
- struct scif_peer_dev __rcu *spdev;
- bool node_remove_ack_pending;
- bool exit_ack_pending;
- wait_queue_head_t disconn_wq;
- atomic_t disconn_rescnt;
- enum scif_msg_state exit;
- dma_addr_t qp_dma_addr;
- };
- extern struct scif_info scif_info;
- extern struct idr scif_ports;
- extern struct scif_dev *scif_dev;
- extern const struct file_operations scif_fops;
- #define SCIF_NODE_QP_SIZE 0x10000
- #include "scif_nodeqp.h"
- static inline int scifdev_self(struct scif_dev *dev)
- {
- return dev->node == scif_info.nodeid;
- }
- static inline bool scif_is_mgmt_node(void)
- {
- return !scif_info.nodeid;
- }
- static inline bool scifdev_is_p2p(struct scif_dev *dev)
- {
- if (scif_is_mgmt_node())
- return false;
- else
- return dev != &scif_dev[SCIF_MGMT_NODE] &&
- !scifdev_self(dev);
- }
- static inline int _scifdev_alive(struct scif_dev *scifdev)
- {
- struct scif_peer_dev *spdev;
- rcu_read_lock();
- spdev = rcu_dereference(scifdev->spdev);
- rcu_read_unlock();
- return !!spdev;
- }
- #include "scif_epd.h"
- void __init scif_init_debugfs(void);
- void scif_exit_debugfs(void);
- int scif_setup_intr_wq(struct scif_dev *scifdev);
- void scif_destroy_intr_wq(struct scif_dev *scifdev);
- void scif_cleanup_scifdev(struct scif_dev *dev);
- void scif_handle_remove_node(int node);
- void scif_disconnect_node(u32 node_id, bool mgmt_initiated);
- void scif_free_qp(struct scif_dev *dev);
- void scif_misc_handler(struct work_struct *work);
- void scif_stop(struct scif_dev *scifdev);
- irqreturn_t scif_intr_handler(int irq, void *data);
- #endif
|