cnic.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /* cnic.h: Broadcom CNIC core network driver.
  2. *
  3. * Copyright (c) 2006-2009 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_H
  11. #define CNIC_H
  12. #define KWQ_PAGE_CNT 4
  13. #define KCQ_PAGE_CNT 16
  14. #define KWQ_CID 24
  15. #define KCQ_CID 25
  16. /*
  17. * krnlq_context definition
  18. */
  19. #define L5_KRNLQ_FLAGS 0x00000000
  20. #define L5_KRNLQ_SIZE 0x00000000
  21. #define L5_KRNLQ_TYPE 0x00000000
  22. #define KRNLQ_FLAGS_PG_SZ (0xf<<0)
  23. #define KRNLQ_FLAGS_PG_SZ_256 (0<<0)
  24. #define KRNLQ_FLAGS_PG_SZ_512 (1<<0)
  25. #define KRNLQ_FLAGS_PG_SZ_1K (2<<0)
  26. #define KRNLQ_FLAGS_PG_SZ_2K (3<<0)
  27. #define KRNLQ_FLAGS_PG_SZ_4K (4<<0)
  28. #define KRNLQ_FLAGS_PG_SZ_8K (5<<0)
  29. #define KRNLQ_FLAGS_PG_SZ_16K (6<<0)
  30. #define KRNLQ_FLAGS_PG_SZ_32K (7<<0)
  31. #define KRNLQ_FLAGS_PG_SZ_64K (8<<0)
  32. #define KRNLQ_FLAGS_PG_SZ_128K (9<<0)
  33. #define KRNLQ_FLAGS_PG_SZ_256K (10<<0)
  34. #define KRNLQ_FLAGS_PG_SZ_512K (11<<0)
  35. #define KRNLQ_FLAGS_PG_SZ_1M (12<<0)
  36. #define KRNLQ_FLAGS_PG_SZ_2M (13<<0)
  37. #define KRNLQ_FLAGS_QE_SELF_SEQ (1<<15)
  38. #define KRNLQ_SIZE_TYPE_SIZE ((((0x28 + 0x1f) & ~0x1f) / 0x20) << 16)
  39. #define KRNLQ_TYPE_TYPE (0xf<<28)
  40. #define KRNLQ_TYPE_TYPE_EMPTY (0<<28)
  41. #define KRNLQ_TYPE_TYPE_KRNLQ (6<<28)
  42. #define L5_KRNLQ_HOST_QIDX 0x00000004
  43. #define L5_KRNLQ_HOST_FW_QIDX 0x00000008
  44. #define L5_KRNLQ_NX_QE_SELF_SEQ 0x0000000c
  45. #define L5_KRNLQ_QE_SELF_SEQ_MAX 0x0000000c
  46. #define L5_KRNLQ_NX_QE_HADDR_HI 0x00000010
  47. #define L5_KRNLQ_NX_QE_HADDR_LO 0x00000014
  48. #define L5_KRNLQ_PGTBL_PGIDX 0x00000018
  49. #define L5_KRNLQ_NX_PG_QIDX 0x00000018
  50. #define L5_KRNLQ_PGTBL_NPAGES 0x0000001c
  51. #define L5_KRNLQ_QIDX_INCR 0x0000001c
  52. #define L5_KRNLQ_PGTBL_HADDR_HI 0x00000020
  53. #define L5_KRNLQ_PGTBL_HADDR_LO 0x00000024
  54. #define BNX2_PG_CTX_MAP 0x1a0034
  55. #define BNX2_ISCSI_CTX_MAP 0x1a0074
  56. struct cnic_redirect_entry {
  57. struct dst_entry *old_dst;
  58. struct dst_entry *new_dst;
  59. };
  60. #define MAX_COMPLETED_KCQE 64
  61. #define MAX_CNIC_L5_CONTEXT 256
  62. #define MAX_CM_SK_TBL_SZ MAX_CNIC_L5_CONTEXT
  63. #define MAX_ISCSI_TBL_SZ 256
  64. #define CNIC_LOCAL_PORT_MIN 60000
  65. #define CNIC_LOCAL_PORT_MAX 61000
  66. #define CNIC_LOCAL_PORT_RANGE (CNIC_LOCAL_PORT_MAX - CNIC_LOCAL_PORT_MIN)
  67. #define KWQE_CNT (BCM_PAGE_SIZE / sizeof(struct kwqe))
  68. #define KCQE_CNT (BCM_PAGE_SIZE / sizeof(struct kcqe))
  69. #define MAX_KWQE_CNT (KWQE_CNT - 1)
  70. #define MAX_KCQE_CNT (KCQE_CNT - 1)
  71. #define MAX_KWQ_IDX ((KWQ_PAGE_CNT * KWQE_CNT) - 1)
  72. #define MAX_KCQ_IDX ((KCQ_PAGE_CNT * KCQE_CNT) - 1)
  73. #define KWQ_PG(x) (((x) & ~MAX_KWQE_CNT) >> (BCM_PAGE_BITS - 5))
  74. #define KWQ_IDX(x) ((x) & MAX_KWQE_CNT)
  75. #define KCQ_PG(x) (((x) & ~MAX_KCQE_CNT) >> (BCM_PAGE_BITS - 5))
  76. #define KCQ_IDX(x) ((x) & MAX_KCQE_CNT)
  77. #define BNX2X_NEXT_KCQE(x) (((x) & (MAX_KCQE_CNT - 1)) == \
  78. (MAX_KCQE_CNT - 1)) ? \
  79. (x) + 2 : (x) + 1
  80. #define BNX2X_KWQ_DATA_PG(cp, x) ((x) / (cp)->kwq_16_data_pp)
  81. #define BNX2X_KWQ_DATA_IDX(cp, x) ((x) % (cp)->kwq_16_data_pp)
  82. #define BNX2X_KWQ_DATA(cp, x) \
  83. &(cp)->kwq_16_data[BNX2X_KWQ_DATA_PG(cp, x)][BNX2X_KWQ_DATA_IDX(cp, x)]
  84. #define DEF_IPID_COUNT 0xc001
  85. #define DEF_KA_TIMEOUT 10000
  86. #define DEF_KA_INTERVAL 300000
  87. #define DEF_KA_MAX_PROBE_COUNT 3
  88. #define DEF_TOS 0
  89. #define DEF_TTL 0xfe
  90. #define DEF_SND_SEQ_SCALE 0
  91. #define DEF_RCV_BUF 0xffff
  92. #define DEF_SND_BUF 0xffff
  93. #define DEF_SEED 0
  94. #define DEF_MAX_RT_TIME 500
  95. #define DEF_MAX_DA_COUNT 2
  96. #define DEF_SWS_TIMER 1000
  97. #define DEF_MAX_CWND 0xffff
  98. struct cnic_ctx {
  99. u32 cid;
  100. void *ctx;
  101. dma_addr_t mapping;
  102. };
  103. #define BNX2_MAX_CID 0x2000
  104. struct cnic_dma {
  105. int num_pages;
  106. void **pg_arr;
  107. dma_addr_t *pg_map_arr;
  108. int pgtbl_size;
  109. u32 *pgtbl;
  110. dma_addr_t pgtbl_map;
  111. };
  112. struct cnic_id_tbl {
  113. spinlock_t lock;
  114. u32 start;
  115. u32 max;
  116. u32 next;
  117. unsigned long *table;
  118. };
  119. #define CNIC_KWQ16_DATA_SIZE 128
  120. struct kwqe_16_data {
  121. u8 data[CNIC_KWQ16_DATA_SIZE];
  122. };
  123. struct cnic_iscsi {
  124. struct cnic_dma task_array_info;
  125. struct cnic_dma r2tq_info;
  126. struct cnic_dma hq_info;
  127. };
  128. struct cnic_context {
  129. u32 cid;
  130. struct kwqe_16_data *kwqe_data;
  131. dma_addr_t kwqe_data_mapping;
  132. wait_queue_head_t waitq;
  133. int wait_cond;
  134. unsigned long timestamp;
  135. u32 ctx_flags;
  136. #define CTX_FL_OFFLD_START 0x00000001
  137. u8 ulp_proto_id;
  138. union {
  139. struct cnic_iscsi *iscsi;
  140. } proto;
  141. };
  142. struct cnic_local {
  143. spinlock_t cnic_ulp_lock;
  144. void *ulp_handle[MAX_CNIC_ULP_TYPE];
  145. unsigned long ulp_flags[MAX_CNIC_ULP_TYPE];
  146. #define ULP_F_INIT 0
  147. #define ULP_F_START 1
  148. struct cnic_ulp_ops *ulp_ops[MAX_CNIC_ULP_TYPE];
  149. /* protected by ulp_lock */
  150. u32 cnic_local_flags;
  151. #define CNIC_LCL_FL_KWQ_INIT 0x00000001
  152. struct cnic_dev *dev;
  153. struct cnic_eth_dev *ethdev;
  154. void *l2_ring;
  155. dma_addr_t l2_ring_map;
  156. int l2_ring_size;
  157. int l2_rx_ring_size;
  158. void *l2_buf;
  159. dma_addr_t l2_buf_map;
  160. int l2_buf_size;
  161. int l2_single_buf_size;
  162. u16 *rx_cons_ptr;
  163. u16 *tx_cons_ptr;
  164. u16 rx_cons;
  165. u16 tx_cons;
  166. u32 kwq_cid_addr;
  167. u32 kcq_cid_addr;
  168. struct cnic_dma kwq_info;
  169. struct kwqe **kwq;
  170. struct cnic_dma kwq_16_data_info;
  171. u16 max_kwq_idx;
  172. u16 kwq_prod_idx;
  173. u32 kwq_io_addr;
  174. u16 *kwq_con_idx_ptr;
  175. u16 kwq_con_idx;
  176. struct cnic_dma kcq_info;
  177. struct kcqe **kcq;
  178. u16 kcq_prod_idx;
  179. u32 kcq_io_addr;
  180. void *status_blk;
  181. struct status_block_msix *bnx2_status_blk;
  182. struct host_status_block *bnx2x_status_blk;
  183. u32 status_blk_num;
  184. u32 int_num;
  185. u32 last_status_idx;
  186. struct tasklet_struct cnic_irq_task;
  187. struct kcqe *completed_kcq[MAX_COMPLETED_KCQE];
  188. struct cnic_sock *csk_tbl;
  189. struct cnic_id_tbl csk_port_tbl;
  190. struct cnic_dma conn_buf_info;
  191. struct cnic_dma gbl_buf_info;
  192. struct cnic_iscsi *iscsi_tbl;
  193. struct cnic_context *ctx_tbl;
  194. struct cnic_id_tbl cid_tbl;
  195. int max_iscsi_conn;
  196. atomic_t iscsi_conn;
  197. /* per connection parameters */
  198. int num_iscsi_tasks;
  199. int num_ccells;
  200. int task_array_size;
  201. int r2tq_size;
  202. int hq_size;
  203. int num_cqs;
  204. struct cnic_ctx *ctx_arr;
  205. int ctx_blks;
  206. int ctx_blk_size;
  207. int cids_per_blk;
  208. u32 chip_id;
  209. int func;
  210. u32 shmem_base;
  211. u32 uio_dev;
  212. struct uio_info *cnic_uinfo;
  213. struct cnic_ops *cnic_ops;
  214. int (*start_hw)(struct cnic_dev *);
  215. void (*stop_hw)(struct cnic_dev *);
  216. void (*setup_pgtbl)(struct cnic_dev *,
  217. struct cnic_dma *);
  218. int (*alloc_resc)(struct cnic_dev *);
  219. void (*free_resc)(struct cnic_dev *);
  220. int (*start_cm)(struct cnic_dev *);
  221. void (*stop_cm)(struct cnic_dev *);
  222. void (*enable_int)(struct cnic_dev *);
  223. void (*disable_int_sync)(struct cnic_dev *);
  224. void (*ack_int)(struct cnic_dev *);
  225. void (*close_conn)(struct cnic_sock *, u32 opcode);
  226. u16 (*next_idx)(u16);
  227. u16 (*hw_idx)(u16);
  228. };
  229. struct bnx2x_bd_chain_next {
  230. u32 addr_lo;
  231. u32 addr_hi;
  232. u8 reserved[8];
  233. };
  234. #define ISCSI_RAMROD_CMD_ID_UPDATE_CONN (ISCSI_KCQE_OPCODE_UPDATE_CONN)
  235. #define ISCSI_RAMROD_CMD_ID_INIT (ISCSI_KCQE_OPCODE_INIT)
  236. #define CDU_REGION_NUMBER_XCM_AG 2
  237. #define CDU_REGION_NUMBER_UCM_AG 4
  238. #endif