tehuti.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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. struct vlan_group *vlgrp;
  211. /* Tx FIFOs: 1 for data desc, 1 for empty (acks) desc */
  212. struct txd_fifo txd_fifo0;
  213. struct txf_fifo txf_fifo0;
  214. struct txdb txdb;
  215. int tx_level;
  216. #ifdef BDX_DELAY_WPTR
  217. int tx_update_mark;
  218. int tx_noupd;
  219. #endif
  220. spinlock_t tx_lock; /* NETIF_F_LLTX mode */
  221. /* rarely used */
  222. u8 port;
  223. u32 msg_enable;
  224. int stats_flag;
  225. struct bdx_stats hw_stats;
  226. struct pci_dev *pdev;
  227. struct pci_nic *nic;
  228. u8 txd_size;
  229. u8 txf_size;
  230. u8 rxd_size;
  231. u8 rxf_size;
  232. u32 rdintcm;
  233. u32 tdintcm;
  234. };
  235. /* RX FREE descriptor - 64bit*/
  236. struct rxf_desc {
  237. u32 info; /* Buffer Count + Info - described below */
  238. u32 va_lo; /* VAdr[31:0] */
  239. u32 va_hi; /* VAdr[63:32] */
  240. u32 pa_lo; /* PAdr[31:0] */
  241. u32 pa_hi; /* PAdr[63:32] */
  242. u32 len; /* Buffer Length */
  243. };
  244. #define GET_RXD_BC(x) GET_BITS_SHIFT((x), 5, 0)
  245. #define GET_RXD_RXFQ(x) GET_BITS_SHIFT((x), 2, 8)
  246. #define GET_RXD_TO(x) GET_BITS_SHIFT((x), 1, 15)
  247. #define GET_RXD_TYPE(x) GET_BITS_SHIFT((x), 4, 16)
  248. #define GET_RXD_ERR(x) GET_BITS_SHIFT((x), 6, 21)
  249. #define GET_RXD_RXP(x) GET_BITS_SHIFT((x), 1, 27)
  250. #define GET_RXD_PKT_ID(x) GET_BITS_SHIFT((x), 3, 28)
  251. #define GET_RXD_VTAG(x) GET_BITS_SHIFT((x), 1, 31)
  252. #define GET_RXD_VLAN_ID(x) GET_BITS_SHIFT((x), 12, 0)
  253. #define GET_RXD_VLAN_TCI(x) GET_BITS_SHIFT((x), 16, 0)
  254. #define GET_RXD_CFI(x) GET_BITS_SHIFT((x), 1, 12)
  255. #define GET_RXD_PRIO(x) GET_BITS_SHIFT((x), 3, 13)
  256. struct rxd_desc {
  257. u32 rxd_val1;
  258. u16 len;
  259. u16 rxd_vlan;
  260. u32 va_lo;
  261. u32 va_hi;
  262. };
  263. /* PBL describes each virtual buffer to be */
  264. /* transmitted from the host.*/
  265. struct pbl {
  266. u32 pa_lo;
  267. u32 pa_hi;
  268. u32 len;
  269. };
  270. /* First word for TXD descriptor. It means: type = 3 for regular Tx packet,
  271. * hw_csum = 7 for ip+udp+tcp hw checksums */
  272. #define TXD_W1_VAL(bc, checksum, vtag, lgsnd, vlan_id) \
  273. ((bc) | ((checksum)<<5) | ((vtag)<<8) | \
  274. ((lgsnd)<<9) | (0x30000) | ((vlan_id)<<20))
  275. struct txd_desc {
  276. u32 txd_val1;
  277. u16 mss;
  278. u16 length;
  279. u32 va_lo;
  280. u32 va_hi;
  281. struct pbl pbl[0]; /* Fragments */
  282. } __packed;
  283. /* Register region size */
  284. #define BDX_REGS_SIZE 0x1000
  285. /* Registers from 0x0000-0x00fc were remapped to 0x4000-0x40fc */
  286. #define regTXD_CFG1_0 0x4000
  287. #define regRXF_CFG1_0 0x4010
  288. #define regRXD_CFG1_0 0x4020
  289. #define regTXF_CFG1_0 0x4030
  290. #define regTXD_CFG0_0 0x4040
  291. #define regRXF_CFG0_0 0x4050
  292. #define regRXD_CFG0_0 0x4060
  293. #define regTXF_CFG0_0 0x4070
  294. #define regTXD_WPTR_0 0x4080
  295. #define regRXF_WPTR_0 0x4090
  296. #define regRXD_WPTR_0 0x40A0
  297. #define regTXF_WPTR_0 0x40B0
  298. #define regTXD_RPTR_0 0x40C0
  299. #define regRXF_RPTR_0 0x40D0
  300. #define regRXD_RPTR_0 0x40E0
  301. #define regTXF_RPTR_0 0x40F0
  302. #define regTXF_RPTR_3 0x40FC
  303. /* hardware versioning */
  304. #define FW_VER 0x5010
  305. #define SROM_VER 0x5020
  306. #define FPGA_VER 0x5030
  307. #define FPGA_SEED 0x5040
  308. /* Registers from 0x0100-0x0150 were remapped to 0x5100-0x5150 */
  309. #define regISR regISR0
  310. #define regISR0 0x5100
  311. #define regIMR regIMR0
  312. #define regIMR0 0x5110
  313. #define regRDINTCM0 0x5120
  314. #define regRDINTCM2 0x5128
  315. #define regTDINTCM0 0x5130
  316. #define regISR_MSK0 0x5140
  317. #define regINIT_SEMAPHORE 0x5170
  318. #define regINIT_STATUS 0x5180
  319. #define regMAC_LNK_STAT 0x0200
  320. #define MAC_LINK_STAT 0x4 /* Link state */
  321. #define regGMAC_RXF_A 0x1240
  322. #define regUNC_MAC0_A 0x1250
  323. #define regUNC_MAC1_A 0x1260
  324. #define regUNC_MAC2_A 0x1270
  325. #define regVLAN_0 0x1800
  326. #define regMAX_FRAME_A 0x12C0
  327. #define regRX_MAC_MCST0 0x1A80
  328. #define regRX_MAC_MCST1 0x1A84
  329. #define MAC_MCST_NUM 15
  330. #define regRX_MCST_HASH0 0x1A00
  331. #define MAC_MCST_HASH_NUM 8
  332. #define regVPC 0x2300
  333. #define regVIC 0x2320
  334. #define regVGLB 0x2340
  335. #define regCLKPLL 0x5000
  336. /*for 10G only*/
  337. #define regREVISION 0x6000
  338. #define regSCRATCH 0x6004
  339. #define regCTRLST 0x6008
  340. #define regMAC_ADDR_0 0x600C
  341. #define regMAC_ADDR_1 0x6010
  342. #define regFRM_LENGTH 0x6014
  343. #define regPAUSE_QUANT 0x6018
  344. #define regRX_FIFO_SECTION 0x601C
  345. #define regTX_FIFO_SECTION 0x6020
  346. #define regRX_FULLNESS 0x6024
  347. #define regTX_FULLNESS 0x6028
  348. #define regHASHTABLE 0x602C
  349. #define regMDIO_ST 0x6030
  350. #define regMDIO_CTL 0x6034
  351. #define regMDIO_DATA 0x6038
  352. #define regMDIO_ADDR 0x603C
  353. #define regRST_PORT 0x7000
  354. #define regDIS_PORT 0x7010
  355. #define regRST_QU 0x7020
  356. #define regDIS_QU 0x7030
  357. #define regCTRLST_TX_ENA 0x0001
  358. #define regCTRLST_RX_ENA 0x0002
  359. #define regCTRLST_PRM_ENA 0x0010
  360. #define regCTRLST_PAD_ENA 0x0020
  361. #define regCTRLST_BASE (regCTRLST_PAD_ENA|regCTRLST_PRM_ENA)
  362. #define regRX_FLT 0x1400
  363. /* TXD TXF RXF RXD CONFIG 0x0000 --- 0x007c*/
  364. #define TX_RX_CFG1_BASE 0xffffffff /*0-31 */
  365. #define TX_RX_CFG0_BASE 0xfffff000 /*31:12 */
  366. #define TX_RX_CFG0_RSVD 0x0ffc /*11:2 */
  367. #define TX_RX_CFG0_SIZE 0x0003 /*1:0 */
  368. /* TXD TXF RXF RXD WRITE 0x0080 --- 0x00BC */
  369. #define TXF_WPTR_WR_PTR 0x7ff8 /*14:3 */
  370. /* TXD TXF RXF RXD READ 0x00CO --- 0x00FC */
  371. #define TXF_RPTR_RD_PTR 0x7ff8 /*14:3 */
  372. #define TXF_WPTR_MASK 0x7ff0 /* last 4 bits are dropped
  373. * size is rounded to 16 */
  374. /* regISR 0x0100 */
  375. /* regIMR 0x0110 */
  376. #define IMR_INPROG 0x80000000 /*31 */
  377. #define IR_LNKCHG1 0x10000000 /*28 */
  378. #define IR_LNKCHG0 0x08000000 /*27 */
  379. #define IR_GPIO 0x04000000 /*26 */
  380. #define IR_RFRSH 0x02000000 /*25 */
  381. #define IR_RSVD 0x01000000 /*24 */
  382. #define IR_SWI 0x00800000 /*23 */
  383. #define IR_RX_FREE_3 0x00400000 /*22 */
  384. #define IR_RX_FREE_2 0x00200000 /*21 */
  385. #define IR_RX_FREE_1 0x00100000 /*20 */
  386. #define IR_RX_FREE_0 0x00080000 /*19 */
  387. #define IR_TX_FREE_3 0x00040000 /*18 */
  388. #define IR_TX_FREE_2 0x00020000 /*17 */
  389. #define IR_TX_FREE_1 0x00010000 /*16 */
  390. #define IR_TX_FREE_0 0x00008000 /*15 */
  391. #define IR_RX_DESC_3 0x00004000 /*14 */
  392. #define IR_RX_DESC_2 0x00002000 /*13 */
  393. #define IR_RX_DESC_1 0x00001000 /*12 */
  394. #define IR_RX_DESC_0 0x00000800 /*11 */
  395. #define IR_PSE 0x00000400 /*10 */
  396. #define IR_TMR3 0x00000200 /*9 */
  397. #define IR_TMR2 0x00000100 /*8 */
  398. #define IR_TMR1 0x00000080 /*7 */
  399. #define IR_TMR0 0x00000040 /*6 */
  400. #define IR_VNT 0x00000020 /*5 */
  401. #define IR_RxFL 0x00000010 /*4 */
  402. #define IR_SDPERR 0x00000008 /*3 */
  403. #define IR_TR 0x00000004 /*2 */
  404. #define IR_PCIE_LINK 0x00000002 /*1 */
  405. #define IR_PCIE_TOUT 0x00000001 /*0 */
  406. #define IR_EXTRA (IR_RX_FREE_0 | IR_LNKCHG0 | IR_PSE | \
  407. IR_TMR0 | IR_PCIE_LINK | IR_PCIE_TOUT)
  408. #define IR_RUN (IR_EXTRA | IR_RX_DESC_0 | IR_TX_FREE_0)
  409. #define IR_ALL 0xfdfffff7
  410. #define IR_LNKCHG0_ofst 27
  411. #define GMAC_RX_FILTER_OSEN 0x1000 /* shared OS enable */
  412. #define GMAC_RX_FILTER_TXFC 0x0400 /* Tx flow control */
  413. #define GMAC_RX_FILTER_RSV0 0x0200 /* reserved */
  414. #define GMAC_RX_FILTER_FDA 0x0100 /* filter out direct address */
  415. #define GMAC_RX_FILTER_AOF 0x0080 /* accept over run */
  416. #define GMAC_RX_FILTER_ACF 0x0040 /* accept control frames */
  417. #define GMAC_RX_FILTER_ARUNT 0x0020 /* accept under run */
  418. #define GMAC_RX_FILTER_ACRC 0x0010 /* accept crc error */
  419. #define GMAC_RX_FILTER_AM 0x0008 /* accept multicast */
  420. #define GMAC_RX_FILTER_AB 0x0004 /* accept broadcast */
  421. #define GMAC_RX_FILTER_PRM 0x0001 /* [0:1] promiscuous mode */
  422. #define MAX_FRAME_AB_VAL 0x3fff /* 13:0 */
  423. #define CLKPLL_PLLLKD 0x0200 /*9 */
  424. #define CLKPLL_RSTEND 0x0100 /*8 */
  425. #define CLKPLL_SFTRST 0x0001 /*0 */
  426. #define CLKPLL_LKD (CLKPLL_PLLLKD|CLKPLL_RSTEND)
  427. /*
  428. * PCI-E Device Control Register (Offset 0x88)
  429. * Source: Luxor Data Sheet, 7.1.3.3.3
  430. */
  431. #define PCI_DEV_CTRL_REG 0x88
  432. #define GET_DEV_CTRL_MAXPL(x) GET_BITS_SHIFT(x, 3, 5)
  433. #define GET_DEV_CTRL_MRRS(x) GET_BITS_SHIFT(x, 3, 12)
  434. /*
  435. * PCI-E Link Status Register (Offset 0x92)
  436. * Source: Luxor Data Sheet, 7.1.3.3.7
  437. */
  438. #define PCI_LINK_STATUS_REG 0x92
  439. #define GET_LINK_STATUS_LANES(x) GET_BITS_SHIFT(x, 6, 4)
  440. /* Debugging Macros */
  441. #define DBG2(fmt, args...) \
  442. pr_err("%s:%-5d: " fmt, __func__, __LINE__, ## args)
  443. #define BDX_ASSERT(x) BUG_ON(x)
  444. #ifdef DEBUG
  445. #define ENTER \
  446. do { \
  447. pr_err("%s:%-5d: ENTER\n", __func__, __LINE__); \
  448. } while (0)
  449. #define RET(args...) \
  450. do { \
  451. pr_err("%s:%-5d: RETURN\n", __func__, __LINE__); \
  452. return args; \
  453. } while (0)
  454. #define DBG(fmt, args...) \
  455. pr_err("%s:%-5d: " fmt, __func__, __LINE__, ## args)
  456. #else
  457. #define ENTER do { } while (0)
  458. #define RET(args...) return args
  459. #define DBG(fmt, args...) \
  460. do { \
  461. if (0) \
  462. pr_err(fmt, ##args); \
  463. } while (0)
  464. #endif
  465. #endif /* _BDX__H */