mlx4_en.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /*
  2. * Copyright (c) 2007 Mellanox Technologies. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. *
  32. */
  33. #ifndef _MLX4_EN_H_
  34. #define _MLX4_EN_H_
  35. #include <linux/compiler.h>
  36. #include <linux/list.h>
  37. #include <linux/mutex.h>
  38. #include <linux/netdevice.h>
  39. #include <linux/mlx4/device.h>
  40. #include <linux/mlx4/qp.h>
  41. #include <linux/mlx4/cq.h>
  42. #include <linux/mlx4/srq.h>
  43. #include <linux/mlx4/doorbell.h>
  44. #include <linux/mlx4/cmd.h>
  45. #include "en_port.h"
  46. #define DRV_NAME "mlx4_en"
  47. #define DRV_VERSION "1.5.1.6"
  48. #define DRV_RELDATE "August 2010"
  49. #define MLX4_EN_MSG_LEVEL (NETIF_MSG_LINK | NETIF_MSG_IFDOWN)
  50. /*
  51. * Device constants
  52. */
  53. #define MLX4_EN_PAGE_SHIFT 12
  54. #define MLX4_EN_PAGE_SIZE (1 << MLX4_EN_PAGE_SHIFT)
  55. #define MAX_RX_RINGS 16
  56. #define TXBB_SIZE 64
  57. #define HEADROOM (2048 / TXBB_SIZE + 1)
  58. #define STAMP_STRIDE 64
  59. #define STAMP_DWORDS (STAMP_STRIDE / 4)
  60. #define STAMP_SHIFT 31
  61. #define STAMP_VAL 0x7fffffff
  62. #define STATS_DELAY (HZ / 4)
  63. /* Typical TSO descriptor with 16 gather entries is 352 bytes... */
  64. #define MAX_DESC_SIZE 512
  65. #define MAX_DESC_TXBBS (MAX_DESC_SIZE / TXBB_SIZE)
  66. /*
  67. * OS related constants and tunables
  68. */
  69. #define MLX4_EN_WATCHDOG_TIMEOUT (15 * HZ)
  70. #define MLX4_EN_ALLOC_ORDER 2
  71. #define MLX4_EN_ALLOC_SIZE (PAGE_SIZE << MLX4_EN_ALLOC_ORDER)
  72. #define MLX4_EN_MAX_LRO_DESCRIPTORS 32
  73. /* Receive fragment sizes; we use at most 4 fragments (for 9600 byte MTU
  74. * and 4K allocations) */
  75. enum {
  76. FRAG_SZ0 = 512 - NET_IP_ALIGN,
  77. FRAG_SZ1 = 1024,
  78. FRAG_SZ2 = 4096,
  79. FRAG_SZ3 = MLX4_EN_ALLOC_SIZE
  80. };
  81. #define MLX4_EN_MAX_RX_FRAGS 4
  82. /* Maximum ring sizes */
  83. #define MLX4_EN_MAX_TX_SIZE 8192
  84. #define MLX4_EN_MAX_RX_SIZE 8192
  85. /* Minimum ring size for our page-allocation sceme to work */
  86. #define MLX4_EN_MIN_RX_SIZE (MLX4_EN_ALLOC_SIZE / SMP_CACHE_BYTES)
  87. #define MLX4_EN_MIN_TX_SIZE (4096 / TXBB_SIZE)
  88. #define MLX4_EN_SMALL_PKT_SIZE 64
  89. #define MLX4_EN_NUM_TX_RINGS 8
  90. #define MLX4_EN_NUM_PPP_RINGS 8
  91. #define MAX_TX_RINGS (MLX4_EN_NUM_TX_RINGS + MLX4_EN_NUM_PPP_RINGS)
  92. #define MLX4_EN_DEF_TX_RING_SIZE 512
  93. #define MLX4_EN_DEF_RX_RING_SIZE 1024
  94. /* Target number of packets to coalesce with interrupt moderation */
  95. #define MLX4_EN_RX_COAL_TARGET 44
  96. #define MLX4_EN_RX_COAL_TIME 0x10
  97. #define MLX4_EN_TX_COAL_PKTS 5
  98. #define MLX4_EN_TX_COAL_TIME 0x80
  99. #define MLX4_EN_RX_RATE_LOW 400000
  100. #define MLX4_EN_RX_COAL_TIME_LOW 0
  101. #define MLX4_EN_RX_RATE_HIGH 450000
  102. #define MLX4_EN_RX_COAL_TIME_HIGH 128
  103. #define MLX4_EN_RX_SIZE_THRESH 1024
  104. #define MLX4_EN_RX_RATE_THRESH (1000000 / MLX4_EN_RX_COAL_TIME_HIGH)
  105. #define MLX4_EN_SAMPLE_INTERVAL 0
  106. #define MLX4_EN_AVG_PKT_SMALL 256
  107. #define MLX4_EN_AUTO_CONF 0xffff
  108. #define MLX4_EN_DEF_RX_PAUSE 1
  109. #define MLX4_EN_DEF_TX_PAUSE 1
  110. /* Interval between successive polls in the Tx routine when polling is used
  111. instead of interrupts (in per-core Tx rings) - should be power of 2 */
  112. #define MLX4_EN_TX_POLL_MODER 16
  113. #define MLX4_EN_TX_POLL_TIMEOUT (HZ / 4)
  114. #define ETH_LLC_SNAP_SIZE 8
  115. #define SMALL_PACKET_SIZE (256 - NET_IP_ALIGN)
  116. #define HEADER_COPY_SIZE (128 - NET_IP_ALIGN)
  117. #define MLX4_LOOPBACK_TEST_PAYLOAD (HEADER_COPY_SIZE - ETH_HLEN)
  118. #define MLX4_EN_MIN_MTU 46
  119. #define ETH_BCAST 0xffffffffffffULL
  120. #define MLX4_EN_LOOPBACK_RETRIES 5
  121. #define MLX4_EN_LOOPBACK_TIMEOUT 100
  122. #ifdef MLX4_EN_PERF_STAT
  123. /* Number of samples to 'average' */
  124. #define AVG_SIZE 128
  125. #define AVG_FACTOR 1024
  126. #define NUM_PERF_STATS NUM_PERF_COUNTERS
  127. #define INC_PERF_COUNTER(cnt) (++(cnt))
  128. #define ADD_PERF_COUNTER(cnt, add) ((cnt) += (add))
  129. #define AVG_PERF_COUNTER(cnt, sample) \
  130. ((cnt) = ((cnt) * (AVG_SIZE - 1) + (sample) * AVG_FACTOR) / AVG_SIZE)
  131. #define GET_PERF_COUNTER(cnt) (cnt)
  132. #define GET_AVG_PERF_COUNTER(cnt) ((cnt) / AVG_FACTOR)
  133. #else
  134. #define NUM_PERF_STATS 0
  135. #define INC_PERF_COUNTER(cnt) do {} while (0)
  136. #define ADD_PERF_COUNTER(cnt, add) do {} while (0)
  137. #define AVG_PERF_COUNTER(cnt, sample) do {} while (0)
  138. #define GET_PERF_COUNTER(cnt) (0)
  139. #define GET_AVG_PERF_COUNTER(cnt) (0)
  140. #endif /* MLX4_EN_PERF_STAT */
  141. /*
  142. * Configurables
  143. */
  144. enum cq_type {
  145. RX = 0,
  146. TX = 1,
  147. };
  148. /*
  149. * Useful macros
  150. */
  151. #define ROUNDUP_LOG2(x) ilog2(roundup_pow_of_two(x))
  152. #define XNOR(x, y) (!(x) == !(y))
  153. #define ILLEGAL_MAC(addr) (addr == 0xffffffffffffULL || addr == 0x0)
  154. struct mlx4_en_tx_info {
  155. struct sk_buff *skb;
  156. u32 nr_txbb;
  157. u8 linear;
  158. u8 data_offset;
  159. u8 inl;
  160. };
  161. #define MLX4_EN_BIT_DESC_OWN 0x80000000
  162. #define CTRL_SIZE sizeof(struct mlx4_wqe_ctrl_seg)
  163. #define MLX4_EN_MEMTYPE_PAD 0x100
  164. #define DS_SIZE sizeof(struct mlx4_wqe_data_seg)
  165. struct mlx4_en_tx_desc {
  166. struct mlx4_wqe_ctrl_seg ctrl;
  167. union {
  168. struct mlx4_wqe_data_seg data; /* at least one data segment */
  169. struct mlx4_wqe_lso_seg lso;
  170. struct mlx4_wqe_inline_seg inl;
  171. };
  172. };
  173. #define MLX4_EN_USE_SRQ 0x01000000
  174. struct mlx4_en_rx_alloc {
  175. struct page *page;
  176. u16 offset;
  177. };
  178. struct mlx4_en_tx_ring {
  179. struct mlx4_hwq_resources wqres;
  180. u32 size ; /* number of TXBBs */
  181. u32 size_mask;
  182. u16 stride;
  183. u16 cqn; /* index of port CQ associated with this ring */
  184. u32 prod;
  185. u32 cons;
  186. u32 buf_size;
  187. u32 doorbell_qpn;
  188. void *buf;
  189. u16 poll_cnt;
  190. int blocked;
  191. struct mlx4_en_tx_info *tx_info;
  192. u8 *bounce_buf;
  193. u32 last_nr_txbb;
  194. struct mlx4_qp qp;
  195. struct mlx4_qp_context context;
  196. int qpn;
  197. enum mlx4_qp_state qp_state;
  198. struct mlx4_srq dummy;
  199. unsigned long bytes;
  200. unsigned long packets;
  201. spinlock_t comp_lock;
  202. };
  203. struct mlx4_en_rx_desc {
  204. /* actual number of entries depends on rx ring stride */
  205. struct mlx4_wqe_data_seg data[0];
  206. };
  207. struct mlx4_en_rx_ring {
  208. struct mlx4_hwq_resources wqres;
  209. struct mlx4_en_rx_alloc page_alloc[MLX4_EN_MAX_RX_FRAGS];
  210. u32 size ; /* number of Rx descs*/
  211. u32 actual_size;
  212. u32 size_mask;
  213. u16 stride;
  214. u16 log_stride;
  215. u16 cqn; /* index of port CQ associated with this ring */
  216. u32 prod;
  217. u32 cons;
  218. u32 buf_size;
  219. void *buf;
  220. void *rx_info;
  221. unsigned long bytes;
  222. unsigned long packets;
  223. };
  224. static inline int mlx4_en_can_lro(__be16 status)
  225. {
  226. return (status & cpu_to_be16(MLX4_CQE_STATUS_IPV4 |
  227. MLX4_CQE_STATUS_IPV4F |
  228. MLX4_CQE_STATUS_IPV6 |
  229. MLX4_CQE_STATUS_IPV4OPT |
  230. MLX4_CQE_STATUS_TCP |
  231. MLX4_CQE_STATUS_UDP |
  232. MLX4_CQE_STATUS_IPOK)) ==
  233. cpu_to_be16(MLX4_CQE_STATUS_IPV4 |
  234. MLX4_CQE_STATUS_IPOK |
  235. MLX4_CQE_STATUS_TCP);
  236. }
  237. struct mlx4_en_cq {
  238. struct mlx4_cq mcq;
  239. struct mlx4_hwq_resources wqres;
  240. int ring;
  241. spinlock_t lock;
  242. struct net_device *dev;
  243. struct napi_struct napi;
  244. /* Per-core Tx cq processing support */
  245. struct timer_list timer;
  246. int size;
  247. int buf_size;
  248. unsigned vector;
  249. enum cq_type is_tx;
  250. u16 moder_time;
  251. u16 moder_cnt;
  252. struct mlx4_cqe *buf;
  253. #define MLX4_EN_OPCODE_ERROR 0x1e
  254. };
  255. struct mlx4_en_port_profile {
  256. u32 flags;
  257. u32 tx_ring_num;
  258. u32 rx_ring_num;
  259. u32 tx_ring_size;
  260. u32 rx_ring_size;
  261. u8 rx_pause;
  262. u8 rx_ppp;
  263. u8 tx_pause;
  264. u8 tx_ppp;
  265. };
  266. struct mlx4_en_profile {
  267. int rss_xor;
  268. int tcp_rss;
  269. int udp_rss;
  270. u8 rss_mask;
  271. u32 active_ports;
  272. u32 small_pkt_int;
  273. u8 no_reset;
  274. struct mlx4_en_port_profile prof[MLX4_MAX_PORTS + 1];
  275. };
  276. struct mlx4_en_dev {
  277. struct mlx4_dev *dev;
  278. struct pci_dev *pdev;
  279. struct mutex state_lock;
  280. struct net_device *pndev[MLX4_MAX_PORTS + 1];
  281. u32 port_cnt;
  282. bool device_up;
  283. struct mlx4_en_profile profile;
  284. u32 LSO_support;
  285. struct workqueue_struct *workqueue;
  286. struct device *dma_device;
  287. void __iomem *uar_map;
  288. struct mlx4_uar priv_uar;
  289. struct mlx4_mr mr;
  290. u32 priv_pdn;
  291. spinlock_t uar_lock;
  292. u8 mac_removed[MLX4_MAX_PORTS + 1];
  293. };
  294. struct mlx4_en_rss_map {
  295. int base_qpn;
  296. struct mlx4_qp qps[MAX_RX_RINGS];
  297. enum mlx4_qp_state state[MAX_RX_RINGS];
  298. struct mlx4_qp indir_qp;
  299. enum mlx4_qp_state indir_state;
  300. };
  301. struct mlx4_en_rss_context {
  302. __be32 base_qpn;
  303. __be32 default_qpn;
  304. u16 reserved;
  305. u8 hash_fn;
  306. u8 flags;
  307. __be32 rss_key[10];
  308. __be32 base_qpn_udp;
  309. };
  310. struct mlx4_en_port_state {
  311. int link_state;
  312. int link_speed;
  313. int transciver;
  314. };
  315. struct mlx4_en_pkt_stats {
  316. unsigned long broadcast;
  317. unsigned long rx_prio[8];
  318. unsigned long tx_prio[8];
  319. #define NUM_PKT_STATS 17
  320. };
  321. struct mlx4_en_port_stats {
  322. unsigned long tso_packets;
  323. unsigned long queue_stopped;
  324. unsigned long wake_queue;
  325. unsigned long tx_timeout;
  326. unsigned long rx_alloc_failed;
  327. unsigned long rx_chksum_good;
  328. unsigned long rx_chksum_none;
  329. unsigned long tx_chksum_offload;
  330. #define NUM_PORT_STATS 8
  331. };
  332. struct mlx4_en_perf_stats {
  333. u32 tx_poll;
  334. u64 tx_pktsz_avg;
  335. u32 inflight_avg;
  336. u16 tx_coal_avg;
  337. u16 rx_coal_avg;
  338. u32 napi_quota;
  339. #define NUM_PERF_COUNTERS 6
  340. };
  341. struct mlx4_en_frag_info {
  342. u16 frag_size;
  343. u16 frag_prefix_size;
  344. u16 frag_stride;
  345. u16 frag_align;
  346. u16 last_offset;
  347. };
  348. struct mlx4_en_priv {
  349. struct mlx4_en_dev *mdev;
  350. struct mlx4_en_port_profile *prof;
  351. struct net_device *dev;
  352. struct vlan_group *vlgrp;
  353. struct net_device_stats stats;
  354. struct net_device_stats ret_stats;
  355. struct mlx4_en_port_state port_state;
  356. spinlock_t stats_lock;
  357. unsigned long last_moder_packets;
  358. unsigned long last_moder_tx_packets;
  359. unsigned long last_moder_bytes;
  360. unsigned long last_moder_jiffies;
  361. int last_moder_time;
  362. u16 rx_usecs;
  363. u16 rx_frames;
  364. u16 tx_usecs;
  365. u16 tx_frames;
  366. u32 pkt_rate_low;
  367. u16 rx_usecs_low;
  368. u32 pkt_rate_high;
  369. u16 rx_usecs_high;
  370. u16 sample_interval;
  371. u16 adaptive_rx_coal;
  372. u32 msg_enable;
  373. u32 loopback_ok;
  374. u32 validate_loopback;
  375. struct mlx4_hwq_resources res;
  376. int link_state;
  377. int last_link_state;
  378. bool port_up;
  379. int port;
  380. int registered;
  381. int allocated;
  382. int stride;
  383. int rx_csum;
  384. u64 mac;
  385. int mac_index;
  386. unsigned max_mtu;
  387. int base_qpn;
  388. struct mlx4_en_rss_map rss_map;
  389. u32 flags;
  390. #define MLX4_EN_FLAG_PROMISC 0x1
  391. u32 tx_ring_num;
  392. u32 rx_ring_num;
  393. u32 rx_skb_size;
  394. struct mlx4_en_frag_info frag_info[MLX4_EN_MAX_RX_FRAGS];
  395. u16 num_frags;
  396. u16 log_rx_info;
  397. struct mlx4_en_tx_ring tx_ring[MAX_TX_RINGS];
  398. struct mlx4_en_rx_ring rx_ring[MAX_RX_RINGS];
  399. struct mlx4_en_cq tx_cq[MAX_TX_RINGS];
  400. struct mlx4_en_cq rx_cq[MAX_RX_RINGS];
  401. struct work_struct mcast_task;
  402. struct work_struct mac_task;
  403. struct work_struct watchdog_task;
  404. struct work_struct linkstate_task;
  405. struct delayed_work stats_task;
  406. struct mlx4_en_perf_stats pstats;
  407. struct mlx4_en_pkt_stats pkstats;
  408. struct mlx4_en_port_stats port_stats;
  409. char *mc_addrs;
  410. int mc_addrs_cnt;
  411. struct mlx4_en_stat_out_mbox hw_stats;
  412. int vids[128];
  413. };
  414. void mlx4_en_destroy_netdev(struct net_device *dev);
  415. int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
  416. struct mlx4_en_port_profile *prof);
  417. int mlx4_en_start_port(struct net_device *dev);
  418. void mlx4_en_stop_port(struct net_device *dev);
  419. void mlx4_en_free_resources(struct mlx4_en_priv *priv);
  420. int mlx4_en_alloc_resources(struct mlx4_en_priv *priv);
  421. int mlx4_en_create_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
  422. int entries, int ring, enum cq_type mode);
  423. void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
  424. int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
  425. void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
  426. int mlx4_en_set_cq_moder(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
  427. int mlx4_en_arm_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
  428. void mlx4_en_poll_tx_cq(unsigned long data);
  429. void mlx4_en_tx_irq(struct mlx4_cq *mcq);
  430. u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb);
  431. netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev);
  432. int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring,
  433. u32 size, u16 stride);
  434. void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring);
  435. int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
  436. struct mlx4_en_tx_ring *ring,
  437. int cq);
  438. void mlx4_en_deactivate_tx_ring(struct mlx4_en_priv *priv,
  439. struct mlx4_en_tx_ring *ring);
  440. int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
  441. struct mlx4_en_rx_ring *ring,
  442. u32 size, u16 stride);
  443. void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
  444. struct mlx4_en_rx_ring *ring);
  445. int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv);
  446. void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv,
  447. struct mlx4_en_rx_ring *ring);
  448. int mlx4_en_process_rx_cq(struct net_device *dev,
  449. struct mlx4_en_cq *cq,
  450. int budget);
  451. int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget);
  452. void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
  453. int is_tx, int rss, int qpn, int cqn,
  454. struct mlx4_qp_context *context);
  455. void mlx4_en_sqp_event(struct mlx4_qp *qp, enum mlx4_event event);
  456. int mlx4_en_map_buffer(struct mlx4_buf *buf);
  457. void mlx4_en_unmap_buffer(struct mlx4_buf *buf);
  458. void mlx4_en_calc_rx_buf(struct net_device *dev);
  459. int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv);
  460. void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv);
  461. int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring);
  462. void mlx4_en_rx_irq(struct mlx4_cq *mcq);
  463. int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode);
  464. int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, struct vlan_group *grp);
  465. int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
  466. u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
  467. int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
  468. u8 promisc);
  469. int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset);
  470. int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port);
  471. #define MLX4_EN_NUM_SELF_TEST 5
  472. void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf);
  473. u64 mlx4_en_mac_to_u64(u8 *addr);
  474. /*
  475. * Globals
  476. */
  477. extern const struct ethtool_ops mlx4_en_ethtool_ops;
  478. /*
  479. * printk / logging functions
  480. */
  481. int en_print(const char *level, const struct mlx4_en_priv *priv,
  482. const char *format, ...) __attribute__ ((format (printf, 3, 4)));
  483. #define en_dbg(mlevel, priv, format, arg...) \
  484. do { \
  485. if (NETIF_MSG_##mlevel & priv->msg_enable) \
  486. en_print(KERN_DEBUG, priv, format, ##arg); \
  487. } while (0)
  488. #define en_warn(priv, format, arg...) \
  489. en_print(KERN_WARNING, priv, format, ##arg)
  490. #define en_err(priv, format, arg...) \
  491. en_print(KERN_ERR, priv, format, ##arg)
  492. #define en_info(priv, format, arg...) \
  493. en_print(KERN_INFO, priv, format, ## arg)
  494. #define mlx4_err(mdev, format, arg...) \
  495. pr_err("%s %s: " format, DRV_NAME, \
  496. dev_name(&mdev->pdev->dev), ##arg)
  497. #define mlx4_info(mdev, format, arg...) \
  498. pr_info("%s %s: " format, DRV_NAME, \
  499. dev_name(&mdev->pdev->dev), ##arg)
  500. #define mlx4_warn(mdev, format, arg...) \
  501. pr_warning("%s %s: " format, DRV_NAME, \
  502. dev_name(&mdev->pdev->dev), ##arg)
  503. #endif