tehuti.h 15 KB

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