mlx4_en.h 17 KB

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