tehuti.h 15 KB

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