cnic_if.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /* cnic_if.h: Broadcom CNIC core network driver.
  2. *
  3. * Copyright (c) 2006-2010 Broadcom Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation.
  8. *
  9. */
  10. #ifndef CNIC_IF_H
  11. #define CNIC_IF_H
  12. #define CNIC_MODULE_VERSION "2.2.6"
  13. #define CNIC_MODULE_RELDATE "Oct 12, 2010"
  14. #define CNIC_ULP_RDMA 0
  15. #define CNIC_ULP_ISCSI 1
  16. #define CNIC_ULP_L4 2
  17. #define MAX_CNIC_ULP_TYPE_EXT 2
  18. #define MAX_CNIC_ULP_TYPE 3
  19. struct kwqe {
  20. u32 kwqe_op_flag;
  21. #define KWQE_OPCODE_MASK 0x00ff0000
  22. #define KWQE_OPCODE_SHIFT 16
  23. #define KWQE_FLAGS_LAYER_SHIFT 28
  24. #define KWQE_OPCODE(x) ((x & KWQE_OPCODE_MASK) >> KWQE_OPCODE_SHIFT)
  25. u32 kwqe_info0;
  26. u32 kwqe_info1;
  27. u32 kwqe_info2;
  28. u32 kwqe_info3;
  29. u32 kwqe_info4;
  30. u32 kwqe_info5;
  31. u32 kwqe_info6;
  32. };
  33. struct kwqe_16 {
  34. u32 kwqe_info0;
  35. u32 kwqe_info1;
  36. u32 kwqe_info2;
  37. u32 kwqe_info3;
  38. };
  39. struct kcqe {
  40. u32 kcqe_info0;
  41. u32 kcqe_info1;
  42. u32 kcqe_info2;
  43. u32 kcqe_info3;
  44. u32 kcqe_info4;
  45. u32 kcqe_info5;
  46. u32 kcqe_info6;
  47. u32 kcqe_op_flag;
  48. #define KCQE_RAMROD_COMPLETION (0x1<<27) /* Everest */
  49. #define KCQE_FLAGS_LAYER_MASK (0x7<<28)
  50. #define KCQE_FLAGS_LAYER_MASK_MISC (0<<28)
  51. #define KCQE_FLAGS_LAYER_MASK_L2 (2<<28)
  52. #define KCQE_FLAGS_LAYER_MASK_L3 (3<<28)
  53. #define KCQE_FLAGS_LAYER_MASK_L4 (4<<28)
  54. #define KCQE_FLAGS_LAYER_MASK_L5_RDMA (5<<28)
  55. #define KCQE_FLAGS_LAYER_MASK_L5_ISCSI (6<<28)
  56. #define KCQE_FLAGS_NEXT (1<<31)
  57. #define KCQE_FLAGS_OPCODE_MASK (0xff<<16)
  58. #define KCQE_FLAGS_OPCODE_SHIFT (16)
  59. #define KCQE_OPCODE(op) \
  60. (((op) & KCQE_FLAGS_OPCODE_MASK) >> KCQE_FLAGS_OPCODE_SHIFT)
  61. };
  62. #define MAX_CNIC_CTL_DATA 64
  63. #define MAX_DRV_CTL_DATA 64
  64. #define CNIC_CTL_STOP_CMD 1
  65. #define CNIC_CTL_START_CMD 2
  66. #define CNIC_CTL_COMPLETION_CMD 3
  67. #define DRV_CTL_IO_WR_CMD 0x101
  68. #define DRV_CTL_IO_RD_CMD 0x102
  69. #define DRV_CTL_CTX_WR_CMD 0x103
  70. #define DRV_CTL_CTXTBL_WR_CMD 0x104
  71. #define DRV_CTL_RET_L5_SPQ_CREDIT_CMD 0x105
  72. #define DRV_CTL_START_L2_CMD 0x106
  73. #define DRV_CTL_STOP_L2_CMD 0x107
  74. #define DRV_CTL_RET_L2_SPQ_CREDIT_CMD 0x10c
  75. struct cnic_ctl_completion {
  76. u32 cid;
  77. };
  78. struct cnic_ctl_info {
  79. int cmd;
  80. union {
  81. struct cnic_ctl_completion comp;
  82. char bytes[MAX_CNIC_CTL_DATA];
  83. } data;
  84. };
  85. struct drv_ctl_spq_credit {
  86. u32 credit_count;
  87. };
  88. struct drv_ctl_io {
  89. u32 cid_addr;
  90. u32 offset;
  91. u32 data;
  92. dma_addr_t dma_addr;
  93. };
  94. struct drv_ctl_l2_ring {
  95. u32 client_id;
  96. u32 cid;
  97. };
  98. struct drv_ctl_info {
  99. int cmd;
  100. union {
  101. struct drv_ctl_spq_credit credit;
  102. struct drv_ctl_io io;
  103. struct drv_ctl_l2_ring ring;
  104. char bytes[MAX_DRV_CTL_DATA];
  105. } data;
  106. };
  107. struct cnic_ops {
  108. struct module *cnic_owner;
  109. /* Calls to these functions are protected by RCU. When
  110. * unregistering, we wait for any calls to complete before
  111. * continuing.
  112. */
  113. int (*cnic_handler)(void *, void *);
  114. int (*cnic_ctl)(void *, struct cnic_ctl_info *);
  115. };
  116. #define MAX_CNIC_VEC 8
  117. struct cnic_irq {
  118. unsigned int vector;
  119. void *status_blk;
  120. u32 status_blk_num;
  121. u32 status_blk_num2;
  122. u32 irq_flags;
  123. #define CNIC_IRQ_FL_MSIX 0x00000001
  124. };
  125. struct cnic_eth_dev {
  126. struct module *drv_owner;
  127. u32 drv_state;
  128. #define CNIC_DRV_STATE_REGD 0x00000001
  129. #define CNIC_DRV_STATE_USING_MSIX 0x00000002
  130. u32 chip_id;
  131. u32 max_kwqe_pending;
  132. struct pci_dev *pdev;
  133. void __iomem *io_base;
  134. void __iomem *io_base2;
  135. void *iro_arr;
  136. u32 ctx_tbl_offset;
  137. u32 ctx_tbl_len;
  138. int ctx_blk_size;
  139. u32 starting_cid;
  140. u32 max_iscsi_conn;
  141. u32 max_fcoe_conn;
  142. u32 max_rdma_conn;
  143. u32 fcoe_init_cid;
  144. u16 iscsi_l2_client_id;
  145. u16 iscsi_l2_cid;
  146. int num_irq;
  147. struct cnic_irq irq_arr[MAX_CNIC_VEC];
  148. int (*drv_register_cnic)(struct net_device *,
  149. struct cnic_ops *, void *);
  150. int (*drv_unregister_cnic)(struct net_device *);
  151. int (*drv_submit_kwqes_32)(struct net_device *,
  152. struct kwqe *[], u32);
  153. int (*drv_submit_kwqes_16)(struct net_device *,
  154. struct kwqe_16 *[], u32);
  155. int (*drv_ctl)(struct net_device *, struct drv_ctl_info *);
  156. unsigned long reserved1[2];
  157. };
  158. struct cnic_sockaddr {
  159. union {
  160. struct sockaddr_in v4;
  161. struct sockaddr_in6 v6;
  162. } local;
  163. union {
  164. struct sockaddr_in v4;
  165. struct sockaddr_in6 v6;
  166. } remote;
  167. };
  168. struct cnic_sock {
  169. struct cnic_dev *dev;
  170. void *context;
  171. u32 src_ip[4];
  172. u32 dst_ip[4];
  173. u16 src_port;
  174. u16 dst_port;
  175. u16 vlan_id;
  176. unsigned char old_ha[6];
  177. unsigned char ha[6];
  178. u32 mtu;
  179. u32 cid;
  180. u32 l5_cid;
  181. u32 pg_cid;
  182. int ulp_type;
  183. u32 ka_timeout;
  184. u32 ka_interval;
  185. u8 ka_max_probe_count;
  186. u8 tos;
  187. u8 ttl;
  188. u8 snd_seq_scale;
  189. u32 rcv_buf;
  190. u32 snd_buf;
  191. u32 seed;
  192. unsigned long tcp_flags;
  193. #define SK_TCP_NO_DELAY_ACK 0x1
  194. #define SK_TCP_KEEP_ALIVE 0x2
  195. #define SK_TCP_NAGLE 0x4
  196. #define SK_TCP_TIMESTAMP 0x8
  197. #define SK_TCP_SACK 0x10
  198. #define SK_TCP_SEG_SCALING 0x20
  199. unsigned long flags;
  200. #define SK_F_INUSE 0
  201. #define SK_F_OFFLD_COMPLETE 1
  202. #define SK_F_OFFLD_SCHED 2
  203. #define SK_F_PG_OFFLD_COMPLETE 3
  204. #define SK_F_CONNECT_START 4
  205. #define SK_F_IPV6 5
  206. #define SK_F_CLOSING 7
  207. atomic_t ref_count;
  208. u32 state;
  209. struct kwqe kwqe1;
  210. struct kwqe kwqe2;
  211. struct kwqe kwqe3;
  212. };
  213. struct cnic_dev {
  214. struct net_device *netdev;
  215. struct pci_dev *pcidev;
  216. void __iomem *regview;
  217. struct list_head list;
  218. int (*register_device)(struct cnic_dev *dev, int ulp_type,
  219. void *ulp_ctx);
  220. int (*unregister_device)(struct cnic_dev *dev, int ulp_type);
  221. int (*submit_kwqes)(struct cnic_dev *dev, struct kwqe *wqes[],
  222. u32 num_wqes);
  223. int (*submit_kwqes_16)(struct cnic_dev *dev, struct kwqe_16 *wqes[],
  224. u32 num_wqes);
  225. int (*cm_create)(struct cnic_dev *, int, u32, u32, struct cnic_sock **,
  226. void *);
  227. int (*cm_destroy)(struct cnic_sock *);
  228. int (*cm_connect)(struct cnic_sock *, struct cnic_sockaddr *);
  229. int (*cm_abort)(struct cnic_sock *);
  230. int (*cm_close)(struct cnic_sock *);
  231. struct cnic_dev *(*cm_select_dev)(struct sockaddr_in *, int ulp_type);
  232. int (*iscsi_nl_msg_recv)(struct cnic_dev *dev, u32 msg_type,
  233. char *data, u16 data_size);
  234. unsigned long flags;
  235. #define CNIC_F_CNIC_UP 1
  236. #define CNIC_F_BNX2_CLASS 3
  237. #define CNIC_F_BNX2X_CLASS 4
  238. atomic_t ref_count;
  239. u8 mac_addr[6];
  240. int max_iscsi_conn;
  241. int max_fcoe_conn;
  242. int max_rdma_conn;
  243. void *cnic_priv;
  244. };
  245. #define CNIC_WR(dev, off, val) writel(val, dev->regview + off)
  246. #define CNIC_WR16(dev, off, val) writew(val, dev->regview + off)
  247. #define CNIC_WR8(dev, off, val) writeb(val, dev->regview + off)
  248. #define CNIC_RD(dev, off) readl(dev->regview + off)
  249. #define CNIC_RD16(dev, off) readw(dev->regview + off)
  250. struct cnic_ulp_ops {
  251. /* Calls to these functions are protected by RCU. When
  252. * unregistering, we wait for any calls to complete before
  253. * continuing.
  254. */
  255. void (*cnic_init)(struct cnic_dev *dev);
  256. void (*cnic_exit)(struct cnic_dev *dev);
  257. void (*cnic_start)(void *ulp_ctx);
  258. void (*cnic_stop)(void *ulp_ctx);
  259. void (*indicate_kcqes)(void *ulp_ctx, struct kcqe *cqes[],
  260. u32 num_cqes);
  261. void (*indicate_netevent)(void *ulp_ctx, unsigned long event);
  262. void (*cm_connect_complete)(struct cnic_sock *);
  263. void (*cm_close_complete)(struct cnic_sock *);
  264. void (*cm_abort_complete)(struct cnic_sock *);
  265. void (*cm_remote_close)(struct cnic_sock *);
  266. void (*cm_remote_abort)(struct cnic_sock *);
  267. void (*iscsi_nl_send_msg)(struct cnic_dev *dev, u32 msg_type,
  268. char *data, u16 data_size);
  269. struct module *owner;
  270. atomic_t ref_count;
  271. };
  272. extern int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops);
  273. extern int cnic_unregister_driver(int ulp_type);
  274. extern struct cnic_eth_dev *bnx2_cnic_probe(struct net_device *dev);
  275. extern struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev);
  276. #endif