mlx4_en.h 17 KB

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