mlx4_en.h 17 KB

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