tehuti.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /*
  2. * Tehuti Networks(R) Network Driver
  3. * Copyright (C) 2007 Tehuti Networks Ltd. All rights reserved
  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; either version 2 of the License, or
  8. * (at your option) any later version.
  9. */
  10. #ifndef _TEHUTI_H
  11. #define _TEHUTI_H
  12. #include <linux/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/netdevice.h>
  15. #include <linux/etherdevice.h>
  16. #include <linux/pci.h>
  17. #include <linux/delay.h>
  18. #include <linux/ethtool.h>
  19. #include <linux/mii.h>
  20. #include <linux/crc32.h>
  21. #include <linux/uaccess.h>
  22. #include <linux/in.h>
  23. #include <linux/ip.h>
  24. #include <linux/tcp.h>
  25. #include <linux/sched.h>
  26. #include <linux/tty.h>
  27. #include <linux/if_vlan.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/vmalloc.h>
  30. #include <linux/firmware.h>
  31. #include <asm/byteorder.h>
  32. #include <linux/dma-mapping.h>
  33. #include <linux/slab.h>
  34. /* Compile Time Switches */
  35. /* start */
  36. #define BDX_TSO
  37. #define BDX_LLTX
  38. #define BDX_DELAY_WPTR
  39. /* #define BDX_MSI */
  40. /* end */
  41. #if !defined CONFIG_PCI_MSI
  42. # undef BDX_MSI
  43. #endif
  44. #define BDX_DEF_MSG_ENABLE (NETIF_MSG_DRV | \
  45. NETIF_MSG_PROBE | \
  46. NETIF_MSG_LINK)
  47. /* ioctl ops */
  48. #define BDX_OP_READ 1
  49. #define BDX_OP_WRITE 2
  50. /* RX copy break size */
  51. #define BDX_COPYBREAK 257
  52. #define DRIVER_AUTHOR "Tehuti Networks(R)"
  53. #define BDX_DRV_DESC "Tehuti Networks(R) Network Driver"
  54. #define BDX_DRV_NAME "tehuti"
  55. #define BDX_NIC_NAME "Tehuti 10 Giga TOE SmartNIC"
  56. #define BDX_NIC2PORT_NAME "Tehuti 2-Port 10 Giga TOE SmartNIC"
  57. #define BDX_DRV_VERSION "7.29.3"
  58. #ifdef BDX_MSI
  59. # define BDX_MSI_STRING "msi "
  60. #else
  61. # define BDX_MSI_STRING ""
  62. #endif
  63. /* netdev tx queue len for Luxor. default value is, btw, 1000
  64. * ifcontig eth1 txqueuelen 3000 - to change it at runtime */
  65. #define BDX_NDEV_TXQ_LEN 3000
  66. /* Max MTU for Jumbo Frame mode, per tehutinetworks.net Features FAQ is 16k */
  67. #define BDX_MAX_MTU (16 * 1024)
  68. #define FIFO_SIZE 4096
  69. #define FIFO_EXTRA_SPACE 1024
  70. #if BITS_PER_LONG == 64
  71. # define H32_64(x) (u32) ((u64)(x) >> 32)
  72. # define L32_64(x) (u32) ((u64)(x) & 0xffffffff)
  73. #elif BITS_PER_LONG == 32
  74. # define H32_64(x) 0
  75. # define L32_64(x) ((u32) (x))
  76. #else /* BITS_PER_LONG == ?? */
  77. # error BITS_PER_LONG is undefined. Must be 64 or 32
  78. #endif /* BITS_PER_LONG */
  79. #ifdef __BIG_ENDIAN
  80. # define CPU_CHIP_SWAP32(x) swab32(x)
  81. # define CPU_CHIP_SWAP16(x) swab16(x)
  82. #else
  83. # define CPU_CHIP_SWAP32(x) (x)
  84. # define CPU_CHIP_SWAP16(x) (x)
  85. #endif
  86. #define READ_REG(pp, reg) readl(pp->pBdxRegs + reg)
  87. #define WRITE_REG(pp, reg, val) writel(val, pp->pBdxRegs + reg)
  88. #ifndef NET_IP_ALIGN
  89. # define NET_IP_ALIGN 2
  90. #endif
  91. #ifndef NETDEV_TX_OK
  92. # define NETDEV_TX_OK 0
  93. #endif
  94. #define LUXOR_MAX_PORT 2
  95. #define BDX_MAX_RX_DONE 150
  96. #define BDX_TXF_DESC_SZ 16
  97. #define BDX_MAX_TX_LEVEL (priv->txd_fifo0.m.memsz - 16)
  98. #define BDX_MIN_TX_LEVEL 256
  99. #define BDX_NO_UPD_PACKETS 40
  100. struct pci_nic {
  101. int port_num;
  102. void __iomem *regs;
  103. int irq_type;
  104. struct bdx_priv *priv[LUXOR_MAX_PORT];
  105. };
  106. enum { IRQ_INTX, IRQ_MSI, IRQ_MSIX };
  107. #define PCK_TH_MULT 128
  108. #define INT_COAL_MULT 2
  109. #define BITS_MASK(nbits) ((1<<nbits)-1)
  110. #define GET_BITS_SHIFT(x, nbits, nshift) (((x)>>nshift)&BITS_MASK(nbits))
  111. #define BITS_SHIFT_MASK(nbits, nshift) (BITS_MASK(nbits)<<nshift)
  112. #define BITS_SHIFT_VAL(x, nbits, nshift) (((x)&BITS_MASK(nbits))<<nshift)
  113. #define BITS_SHIFT_CLEAR(x, nbits, nshift) \
  114. ((x)&(~BITS_SHIFT_MASK(nbits, nshift)))
  115. #define GET_INT_COAL(x) GET_BITS_SHIFT(x, 15, 0)
  116. #define GET_INT_COAL_RC(x) GET_BITS_SHIFT(x, 1, 15)
  117. #define GET_RXF_TH(x) GET_BITS_SHIFT(x, 4, 16)
  118. #define GET_PCK_TH(x) GET_BITS_SHIFT(x, 4, 20)
  119. #define INT_REG_VAL(coal, coal_rc, rxf_th, pck_th) \
  120. ((coal)|((coal_rc)<<15)|((rxf_th)<<16)|((pck_th)<<20))
  121. struct fifo {
  122. dma_addr_t da; /* physical address of fifo (used by HW) */
  123. char *va; /* virtual address of fifo (used by SW) */
  124. u32 rptr, wptr; /* cached values of RPTR and WPTR registers,
  125. they're 32 bits on both 32 and 64 archs */
  126. u16 reg_CFG0, reg_CFG1;
  127. u16 reg_RPTR, reg_WPTR;
  128. u16 memsz; /* memory size allocated for fifo */
  129. u16 size_mask;
  130. u16 pktsz; /* skb packet size to allocate */
  131. u16 rcvno; /* number of buffers that come from this RXF */
  132. };
  133. struct txf_fifo {
  134. struct fifo m; /* minimal set of variables used by all fifos */
  135. };
  136. struct txd_fifo {
  137. struct fifo m; /* minimal set of variables used by all fifos */
  138. };
  139. struct rxf_fifo {
  140. struct fifo m; /* minimal set of variables used by all fifos */
  141. };
  142. struct rxd_fifo {
  143. struct fifo m; /* minimal set of variables used by all fifos */
  144. };
  145. struct rx_map {
  146. u64 dma;
  147. struct sk_buff *skb;
  148. };
  149. struct rxdb {
  150. int *stack;
  151. struct rx_map *elems;
  152. int nelem;
  153. int top;
  154. };
  155. union bdx_dma_addr {
  156. dma_addr_t dma;
  157. struct sk_buff *skb;
  158. };
  159. /* Entry in the db.
  160. * if len == 0 addr is dma
  161. * if len != 0 addr is skb */
  162. struct tx_map {
  163. union bdx_dma_addr addr;
  164. int len;
  165. };
  166. /* tx database - implemented as circular fifo buffer*/
  167. struct txdb {
  168. struct tx_map *start; /* points to the first element */
  169. struct tx_map *end; /* points just AFTER the last element */
  170. struct tx_map *rptr; /* points to the next element to read */
  171. struct tx_map *wptr; /* points to the next element to write */
  172. int size; /* number of elements in the db */
  173. };
  174. /*Internal stats structure*/
  175. struct bdx_stats {
  176. u64 InUCast; /* 0x7200 */
  177. u64 InMCast; /* 0x7210 */
  178. u64 InBCast; /* 0x7220 */
  179. u64 InPkts; /* 0x7230 */
  180. u64 InErrors; /* 0x7240 */
  181. u64 InDropped; /* 0x7250 */
  182. u64 FrameTooLong; /* 0x7260 */
  183. u64 FrameSequenceErrors; /* 0x7270 */
  184. u64 InVLAN; /* 0x7280 */
  185. u64 InDroppedDFE; /* 0x7290 */
  186. u64 InDroppedIntFull; /* 0x72A0 */
  187. u64 InFrameAlignErrors; /* 0x72B0 */
  188. /* 0x72C0-0x72E0 RSRV */
  189. u64 OutUCast; /* 0x72F0 */
  190. u64 OutMCast; /* 0x7300 */
  191. u64 OutBCast; /* 0x7310 */
  192. u64 OutPkts; /* 0x7320 */
  193. /* 0x7330-0x7360 RSRV */
  194. u64 OutVLAN; /* 0x7370 */
  195. u64 InUCastOctects; /* 0x7380 */
  196. u64 OutUCastOctects; /* 0x7390 */
  197. /* 0x73A0-0x73B0 RSRV */
  198. u64 InBCastOctects; /* 0x73C0 */
  199. u64 OutBCastOctects; /* 0x73D0 */
  200. u64 InOctects; /* 0x73E0 */
  201. u64 OutOctects; /* 0x73F0 */
  202. };
  203. struct bdx_priv {
  204. void __iomem *pBdxRegs;
  205. struct net_device *ndev;
  206. struct napi_struct napi;
  207. /* RX FIFOs: 1 for data (full) descs, and 2 for free descs */
  208. struct rxd_fifo rxd_fifo0;
  209. struct rxf_fifo rxf_fifo0;
  210. struct rxdb *rxdb; /* rx dbs to store skb pointers */
  211. int napi_stop;
  212. /* Tx FIFOs: 1 for data desc, 1 for empty (acks) desc */
  213. struct txd_fifo txd_fifo0;
  214. struct txf_fifo txf_fifo0;
  215. struct txdb txdb;
  216. int tx_level;
  217. #ifdef BDX_DELAY_WPTR
  218. int tx_update_mark;
  219. int tx_noupd;
  220. #endif
  221. spinlock_t tx_lock; /* NETIF_F_LLTX mode */
  222. /* rarely used */
  223. u8 port;
  224. u32 msg_enable;
  225. int stats_flag;
  226. struct bdx_stats hw_stats;
  227. struct pci_dev *pdev;
  228. struct pci_nic *nic;
  229. u8 txd_size;
  230. u8 txf_size;
  231. u8 rxd_size;
  232. u8 rxf_size;
  233. u32 rdintcm;
  234. u32 tdintcm;
  235. };
  236. /* RX FREE descriptor - 64bit*/
  237. struct rxf_desc {
  238. u32 info; /* Buffer Count + Info - described below */
  239. u32 va_lo; /* VAdr[31:0] */
  240. u32 va_hi; /* VAdr[63:32] */
  241. u32 pa_lo; /* PAdr[31:0] */
  242. u32 pa_hi; /* PAdr[63:32] */
  243. u32 len; /* Buffer Length */
  244. };
  245. #define GET_RXD_BC(x) GET_BITS_SHIFT((x), 5, 0)
  246. #define GET_RXD_RXFQ(x) GET_BITS_SHIFT((x), 2, 8)
  247. #define GET_RXD_TO(x) GET_BITS_SHIFT((x), 1, 15)
  248. #define GET_RXD_TYPE(x) GET_BITS_SHIFT((x), 4, 16)
  249. #define GET_RXD_ERR(x) GET_BITS_SHIFT((x), 6, 21)
  250. #define GET_RXD_RXP(x) GET_BITS_SHIFT((x), 1, 27)
  251. #define GET_RXD_PKT_ID(x) GET_BITS_SHIFT((x), 3, 28)
  252. #define GET_RXD_VTAG(x) GET_BITS_SHIFT((x), 1, 31)
  253. #define GET_RXD_VLAN_ID(x) GET_BITS_SHIFT((x), 12, 0)
  254. #define GET_RXD_VLAN_TCI(x) GET_BITS_SHIFT((x), 16, 0)
  255. #define GET_RXD_CFI(x) GET_BITS_SHIFT((x), 1, 12)
  256. #define GET_RXD_PRIO(x) GET_BITS_SHIFT((x), 3, 13)
  257. struct rxd_desc {
  258. u32 rxd_val1;
  259. u16 len;
  260. u16 rxd_vlan;
  261. u32 va_lo;
  262. u32 va_hi;
  263. };
  264. /* PBL describes each virtual buffer to be */
  265. /* transmitted from the host.*/
  266. struct pbl {
  267. u32 pa_lo;
  268. u32 pa_hi;
  269. u32 len;
  270. };
  271. /* First word for TXD descriptor. It means: type = 3 for regular Tx packet,
  272. * hw_csum = 7 for ip+udp+tcp hw checksums */
  273. #define TXD_W1_VAL(bc, checksum, vtag, lgsnd, vlan_id) \
  274. ((bc) | ((checksum)<<5) | ((vtag)<<8) | \
  275. ((lgsnd)<<9) | (0x30000) | ((vlan_id)<<20))
  276. struct txd_desc {
  277. u32 txd_val1;
  278. u16 mss;
  279. u16 length;
  280. u32 va_lo;
  281. u32 va_hi;
  282. struct pbl pbl[0]; /* Fragments */
  283. } __packed;
  284. /* Register region size */
  285. #define BDX_REGS_SIZE 0x1000
  286. /* Registers from 0x0000-0x00fc were remapped to 0x4000-0x40fc */
  287. #define regTXD_CFG1_0 0x4000
  288. #define regRXF_CFG1_0 0x4010
  289. #define regRXD_CFG1_0 0x4020
  290. #define regTXF_CFG1_0 0x4030
  291. #define regTXD_CFG0_0 0x4040
  292. #define regRXF_CFG0_0 0x4050
  293. #define regRXD_CFG0_0 0x4060
  294. #define regTXF_CFG0_0 0x4070
  295. #define regTXD_WPTR_0 0x4080
  296. #define regRXF_WPTR_0 0x4090
  297. #define regRXD_WPTR_0 0x40A0
  298. #define regTXF_WPTR_0 0x40B0
  299. #define regTXD_RPTR_0 0x40C0
  300. #define regRXF_RPTR_0 0x40D0
  301. #define regRXD_RPTR_0 0x40E0
  302. #define regTXF_RPTR_0 0x40F0
  303. #define regTXF_RPTR_3 0x40FC
  304. /* hardware versioning */
  305. #define FW_VER 0x5010
  306. #define SROM_VER 0x5020
  307. #define FPGA_VER 0x5030
  308. #define FPGA_SEED 0x5040
  309. /* Registers from 0x0100-0x0150 were remapped to 0x5100-0x5150 */
  310. #define regISR regISR0
  311. #define regISR0 0x5100
  312. #define regIMR regIMR0
  313. #define regIMR0 0x5110
  314. #define regRDINTCM0 0x5120
  315. #define regRDINTCM2 0x5128
  316. #define regTDINTCM0 0x5130
  317. #define regISR_MSK0 0x5140
  318. #define regINIT_SEMAPHORE 0x5170
  319. #define regINIT_STATUS 0x5180
  320. #define regMAC_LNK_STAT 0x0200
  321. #define MAC_LINK_STAT 0x4 /* Link state */
  322. #define regGMAC_RXF_A 0x1240
  323. #define regUNC_MAC0_A 0x1250
  324. #define regUNC_MAC1_A 0x1260
  325. #define regUNC_MAC2_A 0x1270
  326. #define regVLAN_0 0x1800
  327. #define regMAX_FRAME_A 0x12C0
  328. #define regRX_MAC_MCST0 0x1A80
  329. #define regRX_MAC_MCST1 0x1A84
  330. #define MAC_MCST_NUM 15
  331. #define regRX_MCST_HASH0 0x1A00
  332. #define MAC_MCST_HASH_NUM 8
  333. #define regVPC 0x2300
  334. #define regVIC 0x2320
  335. #define regVGLB 0x2340
  336. #define regCLKPLL 0x5000
  337. /*for 10G only*/
  338. #define regREVISION 0x6000
  339. #define regSCRATCH 0x6004
  340. #define regCTRLST 0x6008
  341. #define regMAC_ADDR_0 0x600C
  342. #define regMAC_ADDR_1 0x6010
  343. #define regFRM_LENGTH 0x6014
  344. #define regPAUSE_QUANT 0x6018
  345. #define regRX_FIFO_SECTION 0x601C
  346. #define regTX_FIFO_SECTION 0x6020
  347. #define regRX_FULLNESS 0x6024
  348. #define regTX_FULLNESS 0x6028
  349. #define regHASHTABLE 0x602C
  350. #define regMDIO_ST 0x6030
  351. #define regMDIO_CTL 0x6034
  352. #define regMDIO_DATA 0x6038
  353. #define regMDIO_ADDR 0x603C
  354. #define regRST_PORT 0x7000
  355. #define regDIS_PORT 0x7010
  356. #define regRST_QU 0x7020
  357. #define regDIS_QU 0x7030
  358. #define regCTRLST_TX_ENA 0x0001
  359. #define regCTRLST_RX_ENA 0x0002
  360. #define regCTRLST_PRM_ENA 0x0010
  361. #define regCTRLST_PAD_ENA 0x0020
  362. #define regCTRLST_BASE (regCTRLST_PAD_ENA|regCTRLST_PRM_ENA)
  363. #define regRX_FLT 0x1400
  364. /* TXD TXF RXF RXD CONFIG 0x0000 --- 0x007c*/
  365. #define TX_RX_CFG1_BASE 0xffffffff /*0-31 */
  366. #define TX_RX_CFG0_BASE 0xfffff000 /*31:12 */
  367. #define TX_RX_CFG0_RSVD 0x0ffc /*11:2 */
  368. #define TX_RX_CFG0_SIZE 0x0003 /*1:0 */
  369. /* TXD TXF RXF RXD WRITE 0x0080 --- 0x00BC */
  370. #define TXF_WPTR_WR_PTR 0x7ff8 /*14:3 */
  371. /* TXD TXF RXF RXD READ 0x00CO --- 0x00FC */
  372. #define TXF_RPTR_RD_PTR 0x7ff8 /*14:3 */
  373. #define TXF_WPTR_MASK 0x7ff0 /* last 4 bits are dropped
  374. * size is rounded to 16 */
  375. /* regISR 0x0100 */
  376. /* regIMR 0x0110 */
  377. #define IMR_INPROG 0x80000000 /*31 */
  378. #define IR_LNKCHG1 0x10000000 /*28 */
  379. #define IR_LNKCHG0 0x08000000 /*27 */
  380. #define IR_GPIO 0x04000000 /*26 */
  381. #define IR_RFRSH 0x02000000 /*25 */
  382. #define IR_RSVD 0x01000000 /*24 */
  383. #define IR_SWI 0x00800000 /*23 */
  384. #define IR_RX_FREE_3 0x00400000 /*22 */
  385. #define IR_RX_FREE_2 0x00200000 /*21 */
  386. #define IR_RX_FREE_1 0x00100000 /*20 */
  387. #define IR_RX_FREE_0 0x00080000 /*19 */
  388. #define IR_TX_FREE_3 0x00040000 /*18 */
  389. #define IR_TX_FREE_2 0x00020000 /*17 */
  390. #define IR_TX_FREE_1 0x00010000 /*16 */
  391. #define IR_TX_FREE_0 0x00008000 /*15 */
  392. #define IR_RX_DESC_3 0x00004000 /*14 */
  393. #define IR_RX_DESC_2 0x00002000 /*13 */
  394. #define IR_RX_DESC_1 0x00001000 /*12 */
  395. #define IR_RX_DESC_0 0x00000800 /*11 */
  396. #define IR_PSE 0x00000400 /*10 */
  397. #define IR_TMR3 0x00000200 /*9 */
  398. #define IR_TMR2 0x00000100 /*8 */
  399. #define IR_TMR1 0x00000080 /*7 */
  400. #define IR_TMR0 0x00000040 /*6 */
  401. #define IR_VNT 0x00000020 /*5 */
  402. #define IR_RxFL 0x00000010 /*4 */
  403. #define IR_SDPERR 0x00000008 /*3 */
  404. #define IR_TR 0x00000004 /*2 */
  405. #define IR_PCIE_LINK 0x00000002 /*1 */
  406. #define IR_PCIE_TOUT 0x00000001 /*0 */
  407. #define IR_EXTRA (IR_RX_FREE_0 | IR_LNKCHG0 | IR_PSE | \
  408. IR_TMR0 | IR_PCIE_LINK | IR_PCIE_TOUT)
  409. #define IR_RUN (IR_EXTRA | IR_RX_DESC_0 | IR_TX_FREE_0)
  410. #define IR_ALL 0xfdfffff7
  411. #define IR_LNKCHG0_ofst 27
  412. #define GMAC_RX_FILTER_OSEN 0x1000 /* shared OS enable */
  413. #define GMAC_RX_FILTER_TXFC 0x0400 /* Tx flow control */
  414. #define GMAC_RX_FILTER_RSV0 0x0200 /* reserved */
  415. #define GMAC_RX_FILTER_FDA 0x0100 /* filter out direct address */
  416. #define GMAC_RX_FILTER_AOF 0x0080 /* accept over run */
  417. #define GMAC_RX_FILTER_ACF 0x0040 /* accept control frames */
  418. #define GMAC_RX_FILTER_ARUNT 0x0020 /* accept under run */
  419. #define GMAC_RX_FILTER_ACRC 0x0010 /* accept crc error */
  420. #define GMAC_RX_FILTER_AM 0x0008 /* accept multicast */
  421. #define GMAC_RX_FILTER_AB 0x0004 /* accept broadcast */
  422. #define GMAC_RX_FILTER_PRM 0x0001 /* [0:1] promiscuous mode */
  423. #define MAX_FRAME_AB_VAL 0x3fff /* 13:0 */
  424. #define CLKPLL_PLLLKD 0x0200 /*9 */
  425. #define CLKPLL_RSTEND 0x0100 /*8 */
  426. #define CLKPLL_SFTRST 0x0001 /*0 */
  427. #define CLKPLL_LKD (CLKPLL_PLLLKD|CLKPLL_RSTEND)
  428. /*
  429. * PCI-E Device Control Register (Offset 0x88)
  430. * Source: Luxor Data Sheet, 7.1.3.3.3
  431. */
  432. #define PCI_DEV_CTRL_REG 0x88
  433. #define GET_DEV_CTRL_MAXPL(x) GET_BITS_SHIFT(x, 3, 5)
  434. #define GET_DEV_CTRL_MRRS(x) GET_BITS_SHIFT(x, 3, 12)
  435. /*
  436. * PCI-E Link Status Register (Offset 0x92)
  437. * Source: Luxor Data Sheet, 7.1.3.3.7
  438. */
  439. #define PCI_LINK_STATUS_REG 0x92
  440. #define GET_LINK_STATUS_LANES(x) GET_BITS_SHIFT(x, 6, 4)
  441. /* Debugging Macros */
  442. #define DBG2(fmt, args...) \
  443. pr_err("%s:%-5d: " fmt, __func__, __LINE__, ## args)
  444. #define BDX_ASSERT(x) BUG_ON(x)
  445. #ifdef DEBUG
  446. #define ENTER \
  447. do { \
  448. pr_err("%s:%-5d: ENTER\n", __func__, __LINE__); \
  449. } while (0)
  450. #define RET(args...) \
  451. do { \
  452. pr_err("%s:%-5d: RETURN\n", __func__, __LINE__); \
  453. return args; \
  454. } while (0)
  455. #define DBG(fmt, args...) \
  456. pr_err("%s:%-5d: " fmt, __func__, __LINE__, ## args)
  457. #else
  458. #define ENTER do { } while (0)
  459. #define RET(args...) return args
  460. #define DBG(fmt, args...) \
  461. do { \
  462. if (0) \
  463. pr_err(fmt, ##args); \
  464. } while (0)
  465. #endif
  466. #endif /* _BDX__H */