mlx4_en.h 16 KB

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