hi_mcc_usrdev.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * This file defines data structures and interfaces for
  3. * hisilicon Multiple chips communication.
  4. *
  5. * Copyright (C) 2008 hisilicon , chanjinn@hauwei.com
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. *
  22. * MCC is short for Multi-Chips-Communication
  23. *
  24. * Create by Hisicon, 2011.1.1
  25. */
  26. #include <linux/ioctl.h>
  27. #ifndef __HI_MCC_USERDEV_HEAD__
  28. #define __HI_MCC_USERDEV_HEAD__
  29. #define MCC_USR_MODULE_NAME "MCC_USR"
  30. #define MCC_USR_VERSION __DATE__", "__TIME__
  31. #define HISI_MAX_MAP_DEV 0x1f
  32. #define NORMAL_MESSAGE_SIZE 128
  33. #define MAXIMAL_MESSAGE_SIZE 0x1000
  34. struct hi_mcc_handle_attr {
  35. int target_id;
  36. int port;
  37. int priority;
  38. /* to store remote device ids */
  39. int remote_id[HISI_MAX_MAP_DEV];
  40. };
  41. #define HI_IOC_MCC_BASE 'M'
  42. /* Create a new mcc handle. A file descriptor is only used once for one mcc handle. */
  43. #define HI_MCC_IOC_CONNECT _IOW(HI_IOC_MCC_BASE, 1, struct hi_mcc_handle_attr)
  44. #define HI_MCC_IOC_CHECK _IOW(HI_IOC_MCC_BASE, 2, struct hi_mcc_handle_attr)
  45. #define HI_MCC_IOC_GET_LOCAL_ID _IOW(HI_IOC_MCC_BASE, 4, struct hi_mcc_handle_attr)
  46. #define HI_MCC_IOC_GET_REMOTE_ID _IOW(HI_IOC_MCC_BASE, 5, struct hi_mcc_handle_attr)
  47. #define HI_MCC_IOC_ATTR_INIT _IOW(HI_IOC_MCC_BASE, 6, struct hi_mcc_handle_attr)
  48. #ifdef __KERNEL__
  49. #include <linux/module.h>
  50. #include <linux/kernel.h>
  51. #include <asm/ioctl.h>
  52. #include <linux/wait.h>
  53. #define HI_MCC_DEBUG 4
  54. #define HI_MCC_INFO 3
  55. #define HI_MCC_ERR 2
  56. #define HI_MCC_FATAL 1
  57. #define HI_MCC_DBG_LEVEL 2
  58. #define hi_mcc_trace(level, s, params...) do{ if(level <= HI_MCC_DBG_LEVEL)\
  59. printk(KERN_INFO "[%s, %d]: " s "\n", __FUNCTION__, __LINE__, ##params);\
  60. }while(0)
  61. struct hios_mcc_handle {
  62. unsigned long pci_handle; /* pci handle */
  63. struct list_head mem_list; /* mem list */
  64. wait_queue_head_t wait;
  65. };
  66. typedef struct hios_mcc_handle hios_mcc_handle_t;
  67. /*
  68. * recvfrom_notify sample
  69. *
  70. *int myrecv_notify(void *handle ,void *buf, unsigned int data_len)
  71. *{ ~~~~~~~
  72. * struct hios_mcc_handle hios_handle;
  73. * hios_mcc_handle_opt opt;
  74. * unsigned long cus_data;
  75. * hios_handle.handle = (unsigned long) handle
  76. * ~~~~~~
  77. * hios_mcc_getopt(&hios_handle, &opt);
  78. * cus_data = opt.data;
  79. * ...
  80. *}
  81. */
  82. struct hios_mcc_handle_opt {
  83. int (*recvfrom_notify)(void *handle,
  84. void *buf,
  85. unsigned int data_len);
  86. unsigned long data;
  87. };
  88. typedef struct hios_mcc_handle_opt hios_mcc_handle_opt_t;
  89. hios_mcc_handle_t *hios_mcc_open(struct hi_mcc_handle_attr *attr);
  90. void hios_mcc_handle_attr_init(struct hi_mcc_handle_attr *attr);
  91. int hios_mcc_sendto(hios_mcc_handle_t *handle, const void *buf, unsigned int len);
  92. int hios_mcc_sendto_user(hios_mcc_handle_t *handle, const void *buf, unsigned int len, int flag);
  93. int hios_mcc_close(hios_mcc_handle_t *handle);
  94. int hios_mcc_getopt(hios_mcc_handle_t *handle, hios_mcc_handle_opt_t *opt);
  95. int hios_mcc_setopt(hios_mcc_handle_t *handle, const hios_mcc_handle_opt_t *opt);
  96. int hios_mcc_getlocalid(hios_mcc_handle_t *handle);
  97. int hios_mcc_getremoteids(int ids[],hios_mcc_handle_t *handle);
  98. int hios_mcc_check_remote(int remote_id,hios_mcc_handle_t *handle);
  99. int hios_mcc_register(void);
  100. #endif /* __KERNEL__ */
  101. #endif /* __HI_MCC_USERDEV_HEAD__ */