2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
4 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
5 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
13 * Redistribution and use in source and binary forms, with or
14 * without modification, are permitted provided that the following
17 * - Redistributions of source code must retain the above
18 * copyright notice, this list of conditions and the following
21 * - Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 #include <linux/module.h>
37 #include <linux/init.h>
38 #include <linux/errno.h>
39 #include <linux/pci.h>
40 #include <linux/dma-mapping.h>
41 #include <linux/slab.h>
42 #include <linux/io-mapping.h>
44 #include <linux/mlx4/device.h>
45 #include <linux/mlx4/doorbell.h>
51 MODULE_AUTHOR("Roland Dreier");
52 MODULE_DESCRIPTION("Mellanox ConnectX HCA low-level driver");
53 MODULE_LICENSE("Dual BSD/GPL");
54 MODULE_VERSION(DRV_VERSION);
56 struct workqueue_struct *mlx4_wq;
58 #ifdef CONFIG_MLX4_DEBUG
60 int mlx4_debug_level = 0;
61 module_param_named(debug_level, mlx4_debug_level, int, 0644);
62 MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
64 #endif /* CONFIG_MLX4_DEBUG */
69 module_param(msi_x, int, 0444);
70 MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
72 #else /* CONFIG_PCI_MSI */
76 #endif /* CONFIG_PCI_MSI */
78 int mlx4_log_num_mgm_entry_size = 10;
79 module_param_named(log_num_mgm_entry_size,
80 mlx4_log_num_mgm_entry_size, int, 0444);
81 MODULE_PARM_DESC(log_num_mgm_entry_size, "log mgm size, that defines the num"
82 " of qp per mcg, for example:"
83 " 10 gives 248.range: 9<="
84 " log_num_mgm_entry_size <= 12");
86 static char mlx4_version[] __devinitdata =
87 DRV_NAME ": Mellanox ConnectX core driver v"
88 DRV_VERSION " (" DRV_RELDATE ")\n";
90 static struct mlx4_profile default_profile = {
93 .rdmarc_per_qp = 1 << 4,
100 static int log_num_mac = 2;
101 module_param_named(log_num_mac, log_num_mac, int, 0444);
102 MODULE_PARM_DESC(log_num_mac, "Log2 max number of MACs per ETH port (1-7)");
104 static int log_num_vlan;
105 module_param_named(log_num_vlan, log_num_vlan, int, 0444);
106 MODULE_PARM_DESC(log_num_vlan, "Log2 max number of VLANs per ETH port (0-7)");
107 /* Log2 max number of VLANs per ETH port (0-7) */
108 #define MLX4_LOG_NUM_VLANS 7
111 module_param_named(use_prio, use_prio, bool, 0444);
112 MODULE_PARM_DESC(use_prio, "Enable steering by VLAN priority on ETH ports "
115 int log_mtts_per_seg = ilog2(MLX4_MTT_ENTRY_PER_SEG);
116 module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444);
117 MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment (1-7)");
119 int mlx4_check_port_params(struct mlx4_dev *dev,
120 enum mlx4_port_type *port_type)
124 for (i = 0; i < dev->caps.num_ports - 1; i++) {
125 if (port_type[i] != port_type[i + 1]) {
126 if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) {
127 mlx4_err(dev, "Only same port types supported "
128 "on this HCA, aborting.\n");
131 if (port_type[i] == MLX4_PORT_TYPE_ETH &&
132 port_type[i + 1] == MLX4_PORT_TYPE_IB)
137 for (i = 0; i < dev->caps.num_ports; i++) {
138 if (!(port_type[i] & dev->caps.supported_type[i+1])) {
139 mlx4_err(dev, "Requested port type for port %d is not "
140 "supported on this HCA\n", i + 1);
147 static void mlx4_set_port_mask(struct mlx4_dev *dev)
151 for (i = 1; i <= dev->caps.num_ports; ++i)
152 dev->caps.port_mask[i] = dev->caps.port_type[i];
155 static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
160 err = mlx4_QUERY_DEV_CAP(dev, dev_cap);
162 mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
166 if (dev_cap->min_page_sz > PAGE_SIZE) {
167 mlx4_err(dev, "HCA minimum page size of %d bigger than "
168 "kernel PAGE_SIZE of %ld, aborting.\n",
169 dev_cap->min_page_sz, PAGE_SIZE);
172 if (dev_cap->num_ports > MLX4_MAX_PORTS) {
173 mlx4_err(dev, "HCA has %d ports, but we only support %d, "
175 dev_cap->num_ports, MLX4_MAX_PORTS);
179 if (dev_cap->uar_size > pci_resource_len(dev->pdev, 2)) {
180 mlx4_err(dev, "HCA reported UAR size of 0x%x bigger than "
181 "PCI resource 2 size of 0x%llx, aborting.\n",
183 (unsigned long long) pci_resource_len(dev->pdev, 2));
187 dev->caps.num_ports = dev_cap->num_ports;
188 for (i = 1; i <= dev->caps.num_ports; ++i) {
189 dev->caps.vl_cap[i] = dev_cap->max_vl[i];
190 dev->caps.ib_mtu_cap[i] = dev_cap->ib_mtu[i];
191 dev->caps.gid_table_len[i] = dev_cap->max_gids[i];
192 dev->caps.pkey_table_len[i] = dev_cap->max_pkeys[i];
193 dev->caps.port_width_cap[i] = dev_cap->max_port_width[i];
194 dev->caps.eth_mtu_cap[i] = dev_cap->eth_mtu[i];
195 dev->caps.def_mac[i] = dev_cap->def_mac[i];
196 dev->caps.supported_type[i] = dev_cap->supported_port_types[i];
197 dev->caps.trans_type[i] = dev_cap->trans_type[i];
198 dev->caps.vendor_oui[i] = dev_cap->vendor_oui[i];
199 dev->caps.wavelength[i] = dev_cap->wavelength[i];
200 dev->caps.trans_code[i] = dev_cap->trans_code[i];
203 dev->caps.num_uars = dev_cap->uar_size / PAGE_SIZE;
204 dev->caps.local_ca_ack_delay = dev_cap->local_ca_ack_delay;
205 dev->caps.bf_reg_size = dev_cap->bf_reg_size;
206 dev->caps.bf_regs_per_page = dev_cap->bf_regs_per_page;
207 dev->caps.max_sq_sg = dev_cap->max_sq_sg;
208 dev->caps.max_rq_sg = dev_cap->max_rq_sg;
209 dev->caps.max_wqes = dev_cap->max_qp_sz;
210 dev->caps.max_qp_init_rdma = dev_cap->max_requester_per_qp;
211 dev->caps.max_srq_wqes = dev_cap->max_srq_sz;
212 dev->caps.max_srq_sge = dev_cap->max_rq_sg - 1;
213 dev->caps.reserved_srqs = dev_cap->reserved_srqs;
214 dev->caps.max_sq_desc_sz = dev_cap->max_sq_desc_sz;
215 dev->caps.max_rq_desc_sz = dev_cap->max_rq_desc_sz;
216 dev->caps.num_qp_per_mgm = mlx4_get_qp_per_mgm(dev);
218 * Subtract 1 from the limit because we need to allocate a
219 * spare CQE so the HCA HW can tell the difference between an
220 * empty CQ and a full CQ.
222 dev->caps.max_cqes = dev_cap->max_cq_sz - 1;
223 dev->caps.reserved_cqs = dev_cap->reserved_cqs;
224 dev->caps.reserved_eqs = dev_cap->reserved_eqs;
225 dev->caps.reserved_mtts = dev_cap->reserved_mtts;
226 dev->caps.reserved_mrws = dev_cap->reserved_mrws;
227 dev->caps.reserved_uars = dev_cap->reserved_uars;
228 dev->caps.reserved_pds = dev_cap->reserved_pds;
229 dev->caps.reserved_xrcds = (dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC) ?
230 dev_cap->reserved_xrcds : 0;
231 dev->caps.max_xrcds = (dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC) ?
232 dev_cap->max_xrcds : 0;
233 dev->caps.mtt_entry_sz = dev_cap->mtt_entry_sz;
235 dev->caps.max_msg_sz = dev_cap->max_msg_sz;
236 dev->caps.page_size_cap = ~(u32) (dev_cap->min_page_sz - 1);
237 dev->caps.flags = dev_cap->flags;
238 dev->caps.bmme_flags = dev_cap->bmme_flags;
239 dev->caps.reserved_lkey = dev_cap->reserved_lkey;
240 dev->caps.stat_rate_support = dev_cap->stat_rate_support;
241 dev->caps.max_gso_sz = dev_cap->max_gso_sz;
243 dev->caps.log_num_macs = log_num_mac;
244 dev->caps.log_num_vlans = MLX4_LOG_NUM_VLANS;
245 dev->caps.log_num_prios = use_prio ? 3 : 0;
247 for (i = 1; i <= dev->caps.num_ports; ++i) {
248 if (dev->caps.supported_type[i] != MLX4_PORT_TYPE_ETH)
249 dev->caps.port_type[i] = MLX4_PORT_TYPE_IB;
251 dev->caps.port_type[i] = MLX4_PORT_TYPE_ETH;
252 dev->caps.possible_type[i] = dev->caps.port_type[i];
253 mlx4_priv(dev)->sense.sense_allowed[i] =
254 dev->caps.supported_type[i] == MLX4_PORT_TYPE_AUTO;
256 if (dev->caps.log_num_macs > dev_cap->log_max_macs[i]) {
257 dev->caps.log_num_macs = dev_cap->log_max_macs[i];
258 mlx4_warn(dev, "Requested number of MACs is too much "
259 "for port %d, reducing to %d.\n",
260 i, 1 << dev->caps.log_num_macs);
262 if (dev->caps.log_num_vlans > dev_cap->log_max_vlans[i]) {
263 dev->caps.log_num_vlans = dev_cap->log_max_vlans[i];
264 mlx4_warn(dev, "Requested number of VLANs is too much "
265 "for port %d, reducing to %d.\n",
266 i, 1 << dev->caps.log_num_vlans);
270 mlx4_set_port_mask(dev);
272 dev->caps.max_counters = 1 << ilog2(dev_cap->max_counters);
274 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps;
275 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] =
276 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] =
277 (1 << dev->caps.log_num_macs) *
278 (1 << dev->caps.log_num_vlans) *
279 (1 << dev->caps.log_num_prios) *
281 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH] = MLX4_NUM_FEXCH;
283 dev->caps.reserved_qps = dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] +
284 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] +
285 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] +
286 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH];
292 * Change the port configuration of the device.
293 * Every user of this function must hold the port mutex.
295 int mlx4_change_port_types(struct mlx4_dev *dev,
296 enum mlx4_port_type *port_types)
302 for (port = 0; port < dev->caps.num_ports; port++) {
303 /* Change the port type only if the new type is different
304 * from the current, and not set to Auto */
305 if (port_types[port] != dev->caps.port_type[port + 1]) {
307 dev->caps.port_type[port + 1] = port_types[port];
311 mlx4_unregister_device(dev);
312 for (port = 1; port <= dev->caps.num_ports; port++) {
313 mlx4_CLOSE_PORT(dev, port);
314 err = mlx4_SET_PORT(dev, port);
316 mlx4_err(dev, "Failed to set port %d, "
321 mlx4_set_port_mask(dev);
322 err = mlx4_register_device(dev);
329 static ssize_t show_port_type(struct device *dev,
330 struct device_attribute *attr,
333 struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
335 struct mlx4_dev *mdev = info->dev;
339 (mdev->caps.port_type[info->port] == MLX4_PORT_TYPE_IB) ?
341 if (mdev->caps.possible_type[info->port] == MLX4_PORT_TYPE_AUTO)
342 sprintf(buf, "auto (%s)\n", type);
344 sprintf(buf, "%s\n", type);
349 static ssize_t set_port_type(struct device *dev,
350 struct device_attribute *attr,
351 const char *buf, size_t count)
353 struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
355 struct mlx4_dev *mdev = info->dev;
356 struct mlx4_priv *priv = mlx4_priv(mdev);
357 enum mlx4_port_type types[MLX4_MAX_PORTS];
358 enum mlx4_port_type new_types[MLX4_MAX_PORTS];
362 if (!strcmp(buf, "ib\n"))
363 info->tmp_type = MLX4_PORT_TYPE_IB;
364 else if (!strcmp(buf, "eth\n"))
365 info->tmp_type = MLX4_PORT_TYPE_ETH;
366 else if (!strcmp(buf, "auto\n"))
367 info->tmp_type = MLX4_PORT_TYPE_AUTO;
369 mlx4_err(mdev, "%s is not supported port type\n", buf);
373 mlx4_stop_sense(mdev);
374 mutex_lock(&priv->port_mutex);
375 /* Possible type is always the one that was delivered */
376 mdev->caps.possible_type[info->port] = info->tmp_type;
378 for (i = 0; i < mdev->caps.num_ports; i++) {
379 types[i] = priv->port[i+1].tmp_type ? priv->port[i+1].tmp_type :
380 mdev->caps.possible_type[i+1];
381 if (types[i] == MLX4_PORT_TYPE_AUTO)
382 types[i] = mdev->caps.port_type[i+1];
385 if (!(mdev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) {
386 for (i = 1; i <= mdev->caps.num_ports; i++) {
387 if (mdev->caps.possible_type[i] == MLX4_PORT_TYPE_AUTO) {
388 mdev->caps.possible_type[i] = mdev->caps.port_type[i];
394 mlx4_err(mdev, "Auto sensing is not supported on this HCA. "
395 "Set only 'eth' or 'ib' for both ports "
396 "(should be the same)\n");
400 mlx4_do_sense_ports(mdev, new_types, types);
402 err = mlx4_check_port_params(mdev, new_types);
406 /* We are about to apply the changes after the configuration
407 * was verified, no need to remember the temporary types
409 for (i = 0; i < mdev->caps.num_ports; i++)
410 priv->port[i + 1].tmp_type = 0;
412 err = mlx4_change_port_types(mdev, new_types);
415 mlx4_start_sense(mdev);
416 mutex_unlock(&priv->port_mutex);
417 return err ? err : count;
420 static int mlx4_load_fw(struct mlx4_dev *dev)
422 struct mlx4_priv *priv = mlx4_priv(dev);
425 priv->fw.fw_icm = mlx4_alloc_icm(dev, priv->fw.fw_pages,
426 GFP_HIGHUSER | __GFP_NOWARN, 0);
427 if (!priv->fw.fw_icm) {
428 mlx4_err(dev, "Couldn't allocate FW area, aborting.\n");
432 err = mlx4_MAP_FA(dev, priv->fw.fw_icm);
434 mlx4_err(dev, "MAP_FA command failed, aborting.\n");
438 err = mlx4_RUN_FW(dev);
440 mlx4_err(dev, "RUN_FW command failed, aborting.\n");
450 mlx4_free_icm(dev, priv->fw.fw_icm, 0);
454 static int mlx4_init_cmpt_table(struct mlx4_dev *dev, u64 cmpt_base,
457 struct mlx4_priv *priv = mlx4_priv(dev);
460 err = mlx4_init_icm_table(dev, &priv->qp_table.cmpt_table,
462 ((u64) (MLX4_CMPT_TYPE_QP *
463 cmpt_entry_sz) << MLX4_CMPT_SHIFT),
464 cmpt_entry_sz, dev->caps.num_qps,
465 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
470 err = mlx4_init_icm_table(dev, &priv->srq_table.cmpt_table,
472 ((u64) (MLX4_CMPT_TYPE_SRQ *
473 cmpt_entry_sz) << MLX4_CMPT_SHIFT),
474 cmpt_entry_sz, dev->caps.num_srqs,
475 dev->caps.reserved_srqs, 0, 0);
479 err = mlx4_init_icm_table(dev, &priv->cq_table.cmpt_table,
481 ((u64) (MLX4_CMPT_TYPE_CQ *
482 cmpt_entry_sz) << MLX4_CMPT_SHIFT),
483 cmpt_entry_sz, dev->caps.num_cqs,
484 dev->caps.reserved_cqs, 0, 0);
488 err = mlx4_init_icm_table(dev, &priv->eq_table.cmpt_table,
490 ((u64) (MLX4_CMPT_TYPE_EQ *
491 cmpt_entry_sz) << MLX4_CMPT_SHIFT),
493 dev->caps.num_eqs, dev->caps.num_eqs, 0, 0);
500 mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
503 mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
506 mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
512 static int mlx4_init_icm(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap,
513 struct mlx4_init_hca_param *init_hca, u64 icm_size)
515 struct mlx4_priv *priv = mlx4_priv(dev);
519 err = mlx4_SET_ICM_SIZE(dev, icm_size, &aux_pages);
521 mlx4_err(dev, "SET_ICM_SIZE command failed, aborting.\n");
525 mlx4_dbg(dev, "%lld KB of HCA context requires %lld KB aux memory.\n",
526 (unsigned long long) icm_size >> 10,
527 (unsigned long long) aux_pages << 2);
529 priv->fw.aux_icm = mlx4_alloc_icm(dev, aux_pages,
530 GFP_HIGHUSER | __GFP_NOWARN, 0);
531 if (!priv->fw.aux_icm) {
532 mlx4_err(dev, "Couldn't allocate aux memory, aborting.\n");
536 err = mlx4_MAP_ICM_AUX(dev, priv->fw.aux_icm);
538 mlx4_err(dev, "MAP_ICM_AUX command failed, aborting.\n");
542 err = mlx4_init_cmpt_table(dev, init_hca->cmpt_base, dev_cap->cmpt_entry_sz);
544 mlx4_err(dev, "Failed to map cMPT context memory, aborting.\n");
548 err = mlx4_init_icm_table(dev, &priv->eq_table.table,
549 init_hca->eqc_base, dev_cap->eqc_entry_sz,
550 dev->caps.num_eqs, dev->caps.num_eqs,
553 mlx4_err(dev, "Failed to map EQ context memory, aborting.\n");
558 * Reserved MTT entries must be aligned up to a cacheline
559 * boundary, since the FW will write to them, while the driver
560 * writes to all other MTT entries. (The variable
561 * dev->caps.mtt_entry_sz below is really the MTT segment
562 * size, not the raw entry size)
564 dev->caps.reserved_mtts =
565 ALIGN(dev->caps.reserved_mtts * dev->caps.mtt_entry_sz,
566 dma_get_cache_alignment()) / dev->caps.mtt_entry_sz;
568 err = mlx4_init_icm_table(dev, &priv->mr_table.mtt_table,
570 dev->caps.mtt_entry_sz,
572 dev->caps.reserved_mtts, 1, 0);
574 mlx4_err(dev, "Failed to map MTT context memory, aborting.\n");
578 err = mlx4_init_icm_table(dev, &priv->mr_table.dmpt_table,
580 dev_cap->dmpt_entry_sz,
582 dev->caps.reserved_mrws, 1, 1);
584 mlx4_err(dev, "Failed to map dMPT context memory, aborting.\n");
588 err = mlx4_init_icm_table(dev, &priv->qp_table.qp_table,
590 dev_cap->qpc_entry_sz,
592 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
595 mlx4_err(dev, "Failed to map QP context memory, aborting.\n");
599 err = mlx4_init_icm_table(dev, &priv->qp_table.auxc_table,
601 dev_cap->aux_entry_sz,
603 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
606 mlx4_err(dev, "Failed to map AUXC context memory, aborting.\n");
610 err = mlx4_init_icm_table(dev, &priv->qp_table.altc_table,
612 dev_cap->altc_entry_sz,
614 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
617 mlx4_err(dev, "Failed to map ALTC context memory, aborting.\n");
621 err = mlx4_init_icm_table(dev, &priv->qp_table.rdmarc_table,
622 init_hca->rdmarc_base,
623 dev_cap->rdmarc_entry_sz << priv->qp_table.rdmarc_shift,
625 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
628 mlx4_err(dev, "Failed to map RDMARC context memory, aborting\n");
632 err = mlx4_init_icm_table(dev, &priv->cq_table.table,
634 dev_cap->cqc_entry_sz,
636 dev->caps.reserved_cqs, 0, 0);
638 mlx4_err(dev, "Failed to map CQ context memory, aborting.\n");
639 goto err_unmap_rdmarc;
642 err = mlx4_init_icm_table(dev, &priv->srq_table.table,
644 dev_cap->srq_entry_sz,
646 dev->caps.reserved_srqs, 0, 0);
648 mlx4_err(dev, "Failed to map SRQ context memory, aborting.\n");
653 * It's not strictly required, but for simplicity just map the
654 * whole multicast group table now. The table isn't very big
655 * and it's a lot easier than trying to track ref counts.
657 err = mlx4_init_icm_table(dev, &priv->mcg_table.table,
659 mlx4_get_mgm_entry_size(dev),
660 dev->caps.num_mgms + dev->caps.num_amgms,
661 dev->caps.num_mgms + dev->caps.num_amgms,
664 mlx4_err(dev, "Failed to map MCG context memory, aborting.\n");
671 mlx4_cleanup_icm_table(dev, &priv->srq_table.table);
674 mlx4_cleanup_icm_table(dev, &priv->cq_table.table);
677 mlx4_cleanup_icm_table(dev, &priv->qp_table.rdmarc_table);
680 mlx4_cleanup_icm_table(dev, &priv->qp_table.altc_table);
683 mlx4_cleanup_icm_table(dev, &priv->qp_table.auxc_table);
686 mlx4_cleanup_icm_table(dev, &priv->qp_table.qp_table);
689 mlx4_cleanup_icm_table(dev, &priv->mr_table.dmpt_table);
692 mlx4_cleanup_icm_table(dev, &priv->mr_table.mtt_table);
695 mlx4_cleanup_icm_table(dev, &priv->eq_table.table);
698 mlx4_cleanup_icm_table(dev, &priv->eq_table.cmpt_table);
699 mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
700 mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
701 mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
704 mlx4_UNMAP_ICM_AUX(dev);
707 mlx4_free_icm(dev, priv->fw.aux_icm, 0);
712 static void mlx4_free_icms(struct mlx4_dev *dev)
714 struct mlx4_priv *priv = mlx4_priv(dev);
716 mlx4_cleanup_icm_table(dev, &priv->mcg_table.table);
717 mlx4_cleanup_icm_table(dev, &priv->srq_table.table);
718 mlx4_cleanup_icm_table(dev, &priv->cq_table.table);
719 mlx4_cleanup_icm_table(dev, &priv->qp_table.rdmarc_table);
720 mlx4_cleanup_icm_table(dev, &priv->qp_table.altc_table);
721 mlx4_cleanup_icm_table(dev, &priv->qp_table.auxc_table);
722 mlx4_cleanup_icm_table(dev, &priv->qp_table.qp_table);
723 mlx4_cleanup_icm_table(dev, &priv->mr_table.dmpt_table);
724 mlx4_cleanup_icm_table(dev, &priv->mr_table.mtt_table);
725 mlx4_cleanup_icm_table(dev, &priv->eq_table.table);
726 mlx4_cleanup_icm_table(dev, &priv->eq_table.cmpt_table);
727 mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
728 mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
729 mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
731 mlx4_UNMAP_ICM_AUX(dev);
732 mlx4_free_icm(dev, priv->fw.aux_icm, 0);
735 static int map_bf_area(struct mlx4_dev *dev)
737 struct mlx4_priv *priv = mlx4_priv(dev);
738 resource_size_t bf_start;
739 resource_size_t bf_len;
742 bf_start = pci_resource_start(dev->pdev, 2) + (dev->caps.num_uars << PAGE_SHIFT);
743 bf_len = pci_resource_len(dev->pdev, 2) - (dev->caps.num_uars << PAGE_SHIFT);
744 priv->bf_mapping = io_mapping_create_wc(bf_start, bf_len);
745 if (!priv->bf_mapping)
751 static void unmap_bf_area(struct mlx4_dev *dev)
753 if (mlx4_priv(dev)->bf_mapping)
754 io_mapping_free(mlx4_priv(dev)->bf_mapping);
757 static void mlx4_close_hca(struct mlx4_dev *dev)
760 mlx4_CLOSE_HCA(dev, 0);
763 mlx4_free_icm(dev, mlx4_priv(dev)->fw.fw_icm, 0);
766 static int mlx4_init_hca(struct mlx4_dev *dev)
768 struct mlx4_priv *priv = mlx4_priv(dev);
769 struct mlx4_adapter adapter;
770 struct mlx4_dev_cap dev_cap;
771 struct mlx4_mod_stat_cfg mlx4_cfg;
772 struct mlx4_profile profile;
773 struct mlx4_init_hca_param init_hca;
777 err = mlx4_QUERY_FW(dev);
780 mlx4_info(dev, "non-primary physical function, skipping.\n");
782 mlx4_err(dev, "QUERY_FW command failed, aborting.\n");
786 err = mlx4_load_fw(dev);
788 mlx4_err(dev, "Failed to start FW, aborting.\n");
792 mlx4_cfg.log_pg_sz_m = 1;
793 mlx4_cfg.log_pg_sz = 0;
794 err = mlx4_MOD_STAT_CFG(dev, &mlx4_cfg);
796 mlx4_warn(dev, "Failed to override log_pg_sz parameter\n");
798 err = mlx4_dev_cap(dev, &dev_cap);
800 mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
804 profile = default_profile;
806 icm_size = mlx4_make_profile(dev, &profile, &dev_cap, &init_hca);
807 if ((long long) icm_size < 0) {
812 if (map_bf_area(dev))
813 mlx4_dbg(dev, "Failed to map blue flame area\n");
815 init_hca.log_uar_sz = ilog2(dev->caps.num_uars);
817 err = mlx4_init_icm(dev, &dev_cap, &init_hca, icm_size);
821 err = mlx4_INIT_HCA(dev, &init_hca);
823 mlx4_err(dev, "INIT_HCA command failed, aborting.\n");
827 err = mlx4_QUERY_ADAPTER(dev, &adapter);
829 mlx4_err(dev, "QUERY_ADAPTER command failed, aborting.\n");
833 priv->eq_table.inta_pin = adapter.inta_pin;
834 memcpy(dev->board_id, adapter.board_id, sizeof dev->board_id);
839 mlx4_CLOSE_HCA(dev, 0);
847 mlx4_free_icm(dev, priv->fw.fw_icm, 0);
852 static int mlx4_init_counters_table(struct mlx4_dev *dev)
854 struct mlx4_priv *priv = mlx4_priv(dev);
857 if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
860 nent = dev->caps.max_counters;
861 return mlx4_bitmap_init(&priv->counters_bitmap, nent, nent - 1, 0, 0);
864 static void mlx4_cleanup_counters_table(struct mlx4_dev *dev)
866 mlx4_bitmap_cleanup(&mlx4_priv(dev)->counters_bitmap);
869 int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx)
871 struct mlx4_priv *priv = mlx4_priv(dev);
873 if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
876 *idx = mlx4_bitmap_alloc(&priv->counters_bitmap);
882 EXPORT_SYMBOL_GPL(mlx4_counter_alloc);
884 void mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
886 mlx4_bitmap_free(&mlx4_priv(dev)->counters_bitmap, idx);
889 EXPORT_SYMBOL_GPL(mlx4_counter_free);
891 static int mlx4_setup_hca(struct mlx4_dev *dev)
893 struct mlx4_priv *priv = mlx4_priv(dev);
896 __be32 ib_port_default_caps;
898 err = mlx4_init_uar_table(dev);
900 mlx4_err(dev, "Failed to initialize "
901 "user access region table, aborting.\n");
905 err = mlx4_uar_alloc(dev, &priv->driver_uar);
907 mlx4_err(dev, "Failed to allocate driver access region, "
909 goto err_uar_table_free;
912 priv->kar = ioremap((phys_addr_t) priv->driver_uar.pfn << PAGE_SHIFT, PAGE_SIZE);
914 mlx4_err(dev, "Couldn't map kernel access region, "
920 err = mlx4_init_pd_table(dev);
922 mlx4_err(dev, "Failed to initialize "
923 "protection domain table, aborting.\n");
927 err = mlx4_init_xrcd_table(dev);
929 mlx4_err(dev, "Failed to initialize "
930 "reliable connection domain table, aborting.\n");
931 goto err_pd_table_free;
934 err = mlx4_init_mr_table(dev);
936 mlx4_err(dev, "Failed to initialize "
937 "memory region table, aborting.\n");
938 goto err_xrcd_table_free;
941 err = mlx4_init_eq_table(dev);
943 mlx4_err(dev, "Failed to initialize "
944 "event queue table, aborting.\n");
945 goto err_mr_table_free;
948 err = mlx4_cmd_use_events(dev);
950 mlx4_err(dev, "Failed to switch to event-driven "
951 "firmware commands, aborting.\n");
952 goto err_eq_table_free;
957 if (dev->flags & MLX4_FLAG_MSI_X) {
958 mlx4_warn(dev, "NOP command failed to generate MSI-X "
959 "interrupt IRQ %d).\n",
960 priv->eq_table.eq[dev->caps.num_comp_vectors].irq);
961 mlx4_warn(dev, "Trying again without MSI-X.\n");
963 mlx4_err(dev, "NOP command failed to generate interrupt "
964 "(IRQ %d), aborting.\n",
965 priv->eq_table.eq[dev->caps.num_comp_vectors].irq);
966 mlx4_err(dev, "BIOS or ACPI interrupt routing problem?\n");
972 mlx4_dbg(dev, "NOP command IRQ test passed\n");
974 err = mlx4_init_cq_table(dev);
976 mlx4_err(dev, "Failed to initialize "
977 "completion queue table, aborting.\n");
981 err = mlx4_init_srq_table(dev);
983 mlx4_err(dev, "Failed to initialize "
984 "shared receive queue table, aborting.\n");
985 goto err_cq_table_free;
988 err = mlx4_init_qp_table(dev);
990 mlx4_err(dev, "Failed to initialize "
991 "queue pair table, aborting.\n");
992 goto err_srq_table_free;
995 err = mlx4_init_mcg_table(dev);
997 mlx4_err(dev, "Failed to initialize "
998 "multicast group table, aborting.\n");
999 goto err_qp_table_free;
1002 err = mlx4_init_counters_table(dev);
1003 if (err && err != -ENOENT) {
1004 mlx4_err(dev, "Failed to initialize counters table, aborting.\n");
1005 goto err_counters_table_free;
1008 for (port = 1; port <= dev->caps.num_ports; port++) {
1009 enum mlx4_port_type port_type = 0;
1010 mlx4_SENSE_PORT(dev, port, &port_type);
1012 dev->caps.port_type[port] = port_type;
1013 ib_port_default_caps = 0;
1014 err = mlx4_get_port_ib_caps(dev, port, &ib_port_default_caps);
1016 mlx4_warn(dev, "failed to get port %d default "
1017 "ib capabilities (%d). Continuing with "
1018 "caps = 0\n", port, err);
1019 dev->caps.ib_port_def_cap[port] = ib_port_default_caps;
1021 err = mlx4_check_ext_port_caps(dev, port);
1023 mlx4_warn(dev, "failed to get port %d extended "
1024 "port capabilities support info (%d)."
1025 " Assuming not supported\n", port, err);
1027 err = mlx4_SET_PORT(dev, port);
1029 mlx4_err(dev, "Failed to set port %d, aborting\n",
1031 goto err_mcg_table_free;
1034 mlx4_set_port_mask(dev);
1039 mlx4_cleanup_mcg_table(dev);
1041 err_counters_table_free:
1042 mlx4_cleanup_counters_table(dev);
1045 mlx4_cleanup_qp_table(dev);
1048 mlx4_cleanup_srq_table(dev);
1051 mlx4_cleanup_cq_table(dev);
1054 mlx4_cmd_use_polling(dev);
1057 mlx4_cleanup_eq_table(dev);
1060 mlx4_cleanup_mr_table(dev);
1062 err_xrcd_table_free:
1063 mlx4_cleanup_xrcd_table(dev);
1066 mlx4_cleanup_pd_table(dev);
1072 mlx4_uar_free(dev, &priv->driver_uar);
1075 mlx4_cleanup_uar_table(dev);
1079 static void mlx4_enable_msi_x(struct mlx4_dev *dev)
1081 struct mlx4_priv *priv = mlx4_priv(dev);
1082 struct msix_entry *entries;
1083 int nreq = min_t(int, dev->caps.num_ports *
1084 min_t(int, num_online_cpus() + 1, MAX_MSIX_P_PORT)
1085 + MSIX_LEGACY_SZ, MAX_MSIX);
1090 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
1092 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
1096 for (i = 0; i < nreq; ++i)
1097 entries[i].entry = i;
1100 err = pci_enable_msix(dev->pdev, entries, nreq);
1102 /* Try again if at least 2 vectors are available */
1104 mlx4_info(dev, "Requested %d vectors, "
1105 "but only %d MSI-X vectors available, "
1106 "trying again\n", nreq, err);
1115 MSIX_LEGACY_SZ + dev->caps.num_ports * MIN_MSIX_P_PORT) {
1116 /*Working in legacy mode , all EQ's shared*/
1117 dev->caps.comp_pool = 0;
1118 dev->caps.num_comp_vectors = nreq - 1;
1120 dev->caps.comp_pool = nreq - MSIX_LEGACY_SZ;
1121 dev->caps.num_comp_vectors = MSIX_LEGACY_SZ - 1;
1123 for (i = 0; i < nreq; ++i)
1124 priv->eq_table.eq[i].irq = entries[i].vector;
1126 dev->flags |= MLX4_FLAG_MSI_X;
1133 dev->caps.num_comp_vectors = 1;
1134 dev->caps.comp_pool = 0;
1136 for (i = 0; i < 2; ++i)
1137 priv->eq_table.eq[i].irq = dev->pdev->irq;
1140 static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
1142 struct mlx4_port_info *info = &mlx4_priv(dev)->port[port];
1147 mlx4_init_mac_table(dev, &info->mac_table);
1148 mlx4_init_vlan_table(dev, &info->vlan_table);
1149 info->base_qpn = dev->caps.reserved_qps_base[MLX4_QP_REGION_ETH_ADDR] +
1150 (port - 1) * (1 << log_num_mac);
1152 sprintf(info->dev_name, "mlx4_port%d", port);
1153 info->port_attr.attr.name = info->dev_name;
1154 info->port_attr.attr.mode = S_IRUGO | S_IWUSR;
1155 info->port_attr.show = show_port_type;
1156 info->port_attr.store = set_port_type;
1157 sysfs_attr_init(&info->port_attr.attr);
1159 err = device_create_file(&dev->pdev->dev, &info->port_attr);
1161 mlx4_err(dev, "Failed to create file for port %d\n", port);
1168 static void mlx4_cleanup_port_info(struct mlx4_port_info *info)
1173 device_remove_file(&info->dev->pdev->dev, &info->port_attr);
1176 static int mlx4_init_steering(struct mlx4_dev *dev)
1178 struct mlx4_priv *priv = mlx4_priv(dev);
1179 int num_entries = dev->caps.num_ports;
1182 priv->steer = kzalloc(sizeof(struct mlx4_steer) * num_entries, GFP_KERNEL);
1186 for (i = 0; i < num_entries; i++) {
1187 for (j = 0; j < MLX4_NUM_STEERS; j++) {
1188 INIT_LIST_HEAD(&priv->steer[i].promisc_qps[j]);
1189 INIT_LIST_HEAD(&priv->steer[i].steer_entries[j]);
1191 INIT_LIST_HEAD(&priv->steer[i].high_prios);
1196 static void mlx4_clear_steering(struct mlx4_dev *dev)
1198 struct mlx4_priv *priv = mlx4_priv(dev);
1199 struct mlx4_steer_index *entry, *tmp_entry;
1200 struct mlx4_promisc_qp *pqp, *tmp_pqp;
1201 int num_entries = dev->caps.num_ports;
1204 for (i = 0; i < num_entries; i++) {
1205 for (j = 0; j < MLX4_NUM_STEERS; j++) {
1206 list_for_each_entry_safe(pqp, tmp_pqp,
1207 &priv->steer[i].promisc_qps[j],
1209 list_del(&pqp->list);
1212 list_for_each_entry_safe(entry, tmp_entry,
1213 &priv->steer[i].steer_entries[j],
1215 list_del(&entry->list);
1216 list_for_each_entry_safe(pqp, tmp_pqp,
1219 list_del(&pqp->list);
1229 static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1231 struct mlx4_priv *priv;
1232 struct mlx4_dev *dev;
1236 pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev));
1238 err = pci_enable_device(pdev);
1240 dev_err(&pdev->dev, "Cannot enable PCI device, "
1246 * Check for BARs. We expect 0: 1MB
1248 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
1249 pci_resource_len(pdev, 0) != 1 << 20) {
1250 dev_err(&pdev->dev, "Missing DCS, aborting.\n");
1252 goto err_disable_pdev;
1254 if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
1255 dev_err(&pdev->dev, "Missing UAR, aborting.\n");
1257 goto err_disable_pdev;
1260 err = pci_request_regions(pdev, DRV_NAME);
1262 dev_err(&pdev->dev, "Couldn't get PCI resources, aborting\n");
1263 goto err_disable_pdev;
1266 pci_set_master(pdev);
1268 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
1270 dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask.\n");
1271 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
1273 dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n");
1274 goto err_release_regions;
1277 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
1279 dev_warn(&pdev->dev, "Warning: couldn't set 64-bit "
1280 "consistent PCI DMA mask.\n");
1281 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
1283 dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, "
1285 goto err_release_regions;
1289 /* Allow large DMA segments, up to the firmware limit of 1 GB */
1290 dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024);
1292 priv = kzalloc(sizeof *priv, GFP_KERNEL);
1294 dev_err(&pdev->dev, "Device struct alloc failed, "
1297 goto err_release_regions;
1302 INIT_LIST_HEAD(&priv->ctx_list);
1303 spin_lock_init(&priv->ctx_lock);
1305 mutex_init(&priv->port_mutex);
1307 INIT_LIST_HEAD(&priv->pgdir_list);
1308 mutex_init(&priv->pgdir_mutex);
1310 INIT_LIST_HEAD(&priv->bf_list);
1311 mutex_init(&priv->bf_mutex);
1313 dev->rev_id = pdev->revision;
1316 * Now reset the HCA before we touch the PCI capabilities or
1317 * attempt a firmware command, since a boot ROM may have left
1318 * the HCA in an undefined state.
1320 err = mlx4_reset(dev);
1322 mlx4_err(dev, "Failed to reset HCA, aborting.\n");
1326 if (mlx4_cmd_init(dev)) {
1327 mlx4_err(dev, "Failed to init command interface, aborting.\n");
1331 err = mlx4_init_hca(dev);
1335 err = mlx4_alloc_eq_table(dev);
1339 priv->msix_ctl.pool_bm = 0;
1340 spin_lock_init(&priv->msix_ctl.pool_lock);
1342 mlx4_enable_msi_x(dev);
1344 err = mlx4_init_steering(dev);
1348 err = mlx4_setup_hca(dev);
1349 if (err == -EBUSY && (dev->flags & MLX4_FLAG_MSI_X)) {
1350 dev->flags &= ~MLX4_FLAG_MSI_X;
1351 pci_disable_msix(pdev);
1352 err = mlx4_setup_hca(dev);
1358 for (port = 1; port <= dev->caps.num_ports; port++) {
1359 err = mlx4_init_port_info(dev, port);
1364 err = mlx4_register_device(dev);
1368 mlx4_sense_init(dev);
1369 mlx4_start_sense(dev);
1371 pci_set_drvdata(pdev, dev);
1376 for (--port; port >= 1; --port)
1377 mlx4_cleanup_port_info(&priv->port[port]);
1379 mlx4_cleanup_counters_table(dev);
1380 mlx4_cleanup_mcg_table(dev);
1381 mlx4_cleanup_qp_table(dev);
1382 mlx4_cleanup_srq_table(dev);
1383 mlx4_cleanup_cq_table(dev);
1384 mlx4_cmd_use_polling(dev);
1385 mlx4_cleanup_eq_table(dev);
1386 mlx4_cleanup_mr_table(dev);
1387 mlx4_cleanup_xrcd_table(dev);
1388 mlx4_cleanup_pd_table(dev);
1389 mlx4_cleanup_uar_table(dev);
1392 mlx4_clear_steering(dev);
1395 mlx4_free_eq_table(dev);
1398 if (dev->flags & MLX4_FLAG_MSI_X)
1399 pci_disable_msix(pdev);
1401 mlx4_close_hca(dev);
1404 mlx4_cmd_cleanup(dev);
1409 err_release_regions:
1410 pci_release_regions(pdev);
1413 pci_disable_device(pdev);
1414 pci_set_drvdata(pdev, NULL);
1418 static int __devinit mlx4_init_one(struct pci_dev *pdev,
1419 const struct pci_device_id *id)
1421 printk_once(KERN_INFO "%s", mlx4_version);
1423 return __mlx4_init_one(pdev, id);
1426 static void mlx4_remove_one(struct pci_dev *pdev)
1428 struct mlx4_dev *dev = pci_get_drvdata(pdev);
1429 struct mlx4_priv *priv = mlx4_priv(dev);
1433 mlx4_stop_sense(dev);
1434 mlx4_unregister_device(dev);
1436 for (p = 1; p <= dev->caps.num_ports; p++) {
1437 mlx4_cleanup_port_info(&priv->port[p]);
1438 mlx4_CLOSE_PORT(dev, p);
1441 mlx4_cleanup_counters_table(dev);
1442 mlx4_cleanup_mcg_table(dev);
1443 mlx4_cleanup_qp_table(dev);
1444 mlx4_cleanup_srq_table(dev);
1445 mlx4_cleanup_cq_table(dev);
1446 mlx4_cmd_use_polling(dev);
1447 mlx4_cleanup_eq_table(dev);
1448 mlx4_cleanup_mr_table(dev);
1449 mlx4_cleanup_xrcd_table(dev);
1450 mlx4_cleanup_pd_table(dev);
1453 mlx4_uar_free(dev, &priv->driver_uar);
1454 mlx4_cleanup_uar_table(dev);
1455 mlx4_clear_steering(dev);
1456 mlx4_free_eq_table(dev);
1457 mlx4_close_hca(dev);
1458 mlx4_cmd_cleanup(dev);
1460 if (dev->flags & MLX4_FLAG_MSI_X)
1461 pci_disable_msix(pdev);
1464 pci_release_regions(pdev);
1465 pci_disable_device(pdev);
1466 pci_set_drvdata(pdev, NULL);
1470 int mlx4_restart_one(struct pci_dev *pdev)
1472 mlx4_remove_one(pdev);
1473 return __mlx4_init_one(pdev, NULL);
1476 static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = {
1477 { PCI_VDEVICE(MELLANOX, 0x6340) }, /* MT25408 "Hermon" SDR */
1478 { PCI_VDEVICE(MELLANOX, 0x634a) }, /* MT25408 "Hermon" DDR */
1479 { PCI_VDEVICE(MELLANOX, 0x6354) }, /* MT25408 "Hermon" QDR */
1480 { PCI_VDEVICE(MELLANOX, 0x6732) }, /* MT25408 "Hermon" DDR PCIe gen2 */
1481 { PCI_VDEVICE(MELLANOX, 0x673c) }, /* MT25408 "Hermon" QDR PCIe gen2 */
1482 { PCI_VDEVICE(MELLANOX, 0x6368) }, /* MT25408 "Hermon" EN 10GigE */
1483 { PCI_VDEVICE(MELLANOX, 0x6750) }, /* MT25408 "Hermon" EN 10GigE PCIe gen2 */
1484 { PCI_VDEVICE(MELLANOX, 0x6372) }, /* MT25458 ConnectX EN 10GBASE-T 10GigE */
1485 { PCI_VDEVICE(MELLANOX, 0x675a) }, /* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */
1486 { PCI_VDEVICE(MELLANOX, 0x6764) }, /* MT26468 ConnectX EN 10GigE PCIe gen2*/
1487 { PCI_VDEVICE(MELLANOX, 0x6746) }, /* MT26438 ConnectX EN 40GigE PCIe gen2 5GT/s */
1488 { PCI_VDEVICE(MELLANOX, 0x676e) }, /* MT26478 ConnectX2 40GigE PCIe gen2 */
1489 { PCI_VDEVICE(MELLANOX, 0x1002) }, /* MT25400 Family [ConnectX-2 Virtual Function] */
1490 { PCI_VDEVICE(MELLANOX, 0x1003) }, /* MT27500 Family [ConnectX-3] */
1491 { PCI_VDEVICE(MELLANOX, 0x1004) }, /* MT27500 Family [ConnectX-3 Virtual Function] */
1492 { PCI_VDEVICE(MELLANOX, 0x1005) }, /* MT27510 Family */
1493 { PCI_VDEVICE(MELLANOX, 0x1006) }, /* MT27511 Family */
1494 { PCI_VDEVICE(MELLANOX, 0x1007) }, /* MT27520 Family */
1495 { PCI_VDEVICE(MELLANOX, 0x1008) }, /* MT27521 Family */
1496 { PCI_VDEVICE(MELLANOX, 0x1009) }, /* MT27530 Family */
1497 { PCI_VDEVICE(MELLANOX, 0x100a) }, /* MT27531 Family */
1498 { PCI_VDEVICE(MELLANOX, 0x100b) }, /* MT27540 Family */
1499 { PCI_VDEVICE(MELLANOX, 0x100c) }, /* MT27541 Family */
1500 { PCI_VDEVICE(MELLANOX, 0x100d) }, /* MT27550 Family */
1501 { PCI_VDEVICE(MELLANOX, 0x100e) }, /* MT27551 Family */
1502 { PCI_VDEVICE(MELLANOX, 0x100f) }, /* MT27560 Family */
1503 { PCI_VDEVICE(MELLANOX, 0x1010) }, /* MT27561 Family */
1507 MODULE_DEVICE_TABLE(pci, mlx4_pci_table);
1509 static struct pci_driver mlx4_driver = {
1511 .id_table = mlx4_pci_table,
1512 .probe = mlx4_init_one,
1513 .remove = __devexit_p(mlx4_remove_one)
1516 static int __init mlx4_verify_params(void)
1518 if ((log_num_mac < 0) || (log_num_mac > 7)) {
1519 pr_warning("mlx4_core: bad num_mac: %d\n", log_num_mac);
1523 if (log_num_vlan != 0)
1524 pr_warning("mlx4_core: log_num_vlan - obsolete module param, using %d\n",
1525 MLX4_LOG_NUM_VLANS);
1527 if ((log_mtts_per_seg < 1) || (log_mtts_per_seg > 7)) {
1528 pr_warning("mlx4_core: bad log_mtts_per_seg: %d\n", log_mtts_per_seg);
1535 static int __init mlx4_init(void)
1539 if (mlx4_verify_params())
1544 mlx4_wq = create_singlethread_workqueue("mlx4");
1548 ret = pci_register_driver(&mlx4_driver);
1549 return ret < 0 ? ret : 0;
1552 static void __exit mlx4_cleanup(void)
1554 pci_unregister_driver(&mlx4_driver);
1555 destroy_workqueue(mlx4_wq);
1558 module_init(mlx4_init);
1559 module_exit(mlx4_cleanup);