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 static char mlx4_version[] __devinitdata =
79 DRV_NAME ": Mellanox ConnectX core driver v"
80 DRV_VERSION " (" DRV_RELDATE ")\n";
82 static struct mlx4_profile default_profile = {
85 .rdmarc_per_qp = 1 << 4,
92 static int log_num_mac = 2;
93 module_param_named(log_num_mac, log_num_mac, int, 0444);
94 MODULE_PARM_DESC(log_num_mac, "Log2 max number of MACs per ETH port (1-7)");
96 static int log_num_vlan;
97 module_param_named(log_num_vlan, log_num_vlan, int, 0444);
98 MODULE_PARM_DESC(log_num_vlan, "Log2 max number of VLANs per ETH port (0-7)");
99 /* Log2 max number of VLANs per ETH port (0-7) */
100 #define MLX4_LOG_NUM_VLANS 7
103 module_param_named(use_prio, use_prio, bool, 0444);
104 MODULE_PARM_DESC(use_prio, "Enable steering by VLAN priority on ETH ports "
107 static int log_mtts_per_seg = ilog2(MLX4_MTT_ENTRY_PER_SEG);
108 module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444);
109 MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment (1-7)");
111 int mlx4_check_port_params(struct mlx4_dev *dev,
112 enum mlx4_port_type *port_type)
116 for (i = 0; i < dev->caps.num_ports - 1; i++) {
117 if (port_type[i] != port_type[i + 1]) {
118 if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) {
119 mlx4_err(dev, "Only same port types supported "
120 "on this HCA, aborting.\n");
123 if (port_type[i] == MLX4_PORT_TYPE_ETH &&
124 port_type[i + 1] == MLX4_PORT_TYPE_IB)
129 for (i = 0; i < dev->caps.num_ports; i++) {
130 if (!(port_type[i] & dev->caps.supported_type[i+1])) {
131 mlx4_err(dev, "Requested port type for port %d is not "
132 "supported on this HCA\n", i + 1);
139 static void mlx4_set_port_mask(struct mlx4_dev *dev)
143 dev->caps.port_mask = 0;
144 for (i = 1; i <= dev->caps.num_ports; ++i)
145 if (dev->caps.port_type[i] == MLX4_PORT_TYPE_IB)
146 dev->caps.port_mask |= 1 << (i - 1);
149 static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
154 err = mlx4_QUERY_DEV_CAP(dev, dev_cap);
156 mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
160 if (dev_cap->min_page_sz > PAGE_SIZE) {
161 mlx4_err(dev, "HCA minimum page size of %d bigger than "
162 "kernel PAGE_SIZE of %ld, aborting.\n",
163 dev_cap->min_page_sz, PAGE_SIZE);
166 if (dev_cap->num_ports > MLX4_MAX_PORTS) {
167 mlx4_err(dev, "HCA has %d ports, but we only support %d, "
169 dev_cap->num_ports, MLX4_MAX_PORTS);
173 if (dev_cap->uar_size > pci_resource_len(dev->pdev, 2)) {
174 mlx4_err(dev, "HCA reported UAR size of 0x%x bigger than "
175 "PCI resource 2 size of 0x%llx, aborting.\n",
177 (unsigned long long) pci_resource_len(dev->pdev, 2));
181 dev->caps.num_ports = dev_cap->num_ports;
182 for (i = 1; i <= dev->caps.num_ports; ++i) {
183 dev->caps.vl_cap[i] = dev_cap->max_vl[i];
184 dev->caps.ib_mtu_cap[i] = dev_cap->ib_mtu[i];
185 dev->caps.gid_table_len[i] = dev_cap->max_gids[i];
186 dev->caps.pkey_table_len[i] = dev_cap->max_pkeys[i];
187 dev->caps.port_width_cap[i] = dev_cap->max_port_width[i];
188 dev->caps.eth_mtu_cap[i] = dev_cap->eth_mtu[i];
189 dev->caps.def_mac[i] = dev_cap->def_mac[i];
190 dev->caps.supported_type[i] = dev_cap->supported_port_types[i];
191 dev->caps.trans_type[i] = dev_cap->trans_type[i];
192 dev->caps.vendor_oui[i] = dev_cap->vendor_oui[i];
193 dev->caps.wavelength[i] = dev_cap->wavelength[i];
194 dev->caps.trans_code[i] = dev_cap->trans_code[i];
197 dev->caps.num_uars = dev_cap->uar_size / PAGE_SIZE;
198 dev->caps.local_ca_ack_delay = dev_cap->local_ca_ack_delay;
199 dev->caps.bf_reg_size = dev_cap->bf_reg_size;
200 dev->caps.bf_regs_per_page = dev_cap->bf_regs_per_page;
201 dev->caps.max_sq_sg = dev_cap->max_sq_sg;
202 dev->caps.max_rq_sg = dev_cap->max_rq_sg;
203 dev->caps.max_wqes = dev_cap->max_qp_sz;
204 dev->caps.max_qp_init_rdma = dev_cap->max_requester_per_qp;
205 dev->caps.max_srq_wqes = dev_cap->max_srq_sz;
206 dev->caps.max_srq_sge = dev_cap->max_rq_sg - 1;
207 dev->caps.reserved_srqs = dev_cap->reserved_srqs;
208 dev->caps.max_sq_desc_sz = dev_cap->max_sq_desc_sz;
209 dev->caps.max_rq_desc_sz = dev_cap->max_rq_desc_sz;
210 dev->caps.num_qp_per_mgm = MLX4_QP_PER_MGM;
212 * Subtract 1 from the limit because we need to allocate a
213 * spare CQE so the HCA HW can tell the difference between an
214 * empty CQ and a full CQ.
216 dev->caps.max_cqes = dev_cap->max_cq_sz - 1;
217 dev->caps.reserved_cqs = dev_cap->reserved_cqs;
218 dev->caps.reserved_eqs = dev_cap->reserved_eqs;
219 dev->caps.mtts_per_seg = 1 << log_mtts_per_seg;
220 dev->caps.reserved_mtts = DIV_ROUND_UP(dev_cap->reserved_mtts,
221 dev->caps.mtts_per_seg);
222 dev->caps.reserved_mrws = dev_cap->reserved_mrws;
223 dev->caps.reserved_uars = dev_cap->reserved_uars;
224 dev->caps.reserved_pds = dev_cap->reserved_pds;
225 dev->caps.mtt_entry_sz = dev->caps.mtts_per_seg * dev_cap->mtt_entry_sz;
226 dev->caps.max_msg_sz = dev_cap->max_msg_sz;
227 dev->caps.page_size_cap = ~(u32) (dev_cap->min_page_sz - 1);
228 dev->caps.flags = dev_cap->flags;
229 dev->caps.bmme_flags = dev_cap->bmme_flags;
230 dev->caps.reserved_lkey = dev_cap->reserved_lkey;
231 dev->caps.stat_rate_support = dev_cap->stat_rate_support;
232 dev->caps.max_gso_sz = dev_cap->max_gso_sz;
234 dev->caps.log_num_macs = log_num_mac;
235 dev->caps.log_num_vlans = MLX4_LOG_NUM_VLANS;
236 dev->caps.log_num_prios = use_prio ? 3 : 0;
238 for (i = 1; i <= dev->caps.num_ports; ++i) {
239 if (dev->caps.supported_type[i] != MLX4_PORT_TYPE_ETH)
240 dev->caps.port_type[i] = MLX4_PORT_TYPE_IB;
242 dev->caps.port_type[i] = MLX4_PORT_TYPE_ETH;
243 dev->caps.possible_type[i] = dev->caps.port_type[i];
244 mlx4_priv(dev)->sense.sense_allowed[i] =
245 dev->caps.supported_type[i] == MLX4_PORT_TYPE_AUTO;
247 if (dev->caps.log_num_macs > dev_cap->log_max_macs[i]) {
248 dev->caps.log_num_macs = dev_cap->log_max_macs[i];
249 mlx4_warn(dev, "Requested number of MACs is too much "
250 "for port %d, reducing to %d.\n",
251 i, 1 << dev->caps.log_num_macs);
253 if (dev->caps.log_num_vlans > dev_cap->log_max_vlans[i]) {
254 dev->caps.log_num_vlans = dev_cap->log_max_vlans[i];
255 mlx4_warn(dev, "Requested number of VLANs is too much "
256 "for port %d, reducing to %d.\n",
257 i, 1 << dev->caps.log_num_vlans);
261 mlx4_set_port_mask(dev);
263 dev->caps.max_counters = 1 << ilog2(dev_cap->max_counters);
265 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps;
266 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] =
267 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] =
268 (1 << dev->caps.log_num_macs) *
269 (1 << dev->caps.log_num_vlans) *
270 (1 << dev->caps.log_num_prios) *
272 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH] = MLX4_NUM_FEXCH;
274 dev->caps.reserved_qps = dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] +
275 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] +
276 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] +
277 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH];
283 * Change the port configuration of the device.
284 * Every user of this function must hold the port mutex.
286 int mlx4_change_port_types(struct mlx4_dev *dev,
287 enum mlx4_port_type *port_types)
293 for (port = 0; port < dev->caps.num_ports; port++) {
294 /* Change the port type only if the new type is different
295 * from the current, and not set to Auto */
296 if (port_types[port] != dev->caps.port_type[port + 1]) {
298 dev->caps.port_type[port + 1] = port_types[port];
302 mlx4_unregister_device(dev);
303 for (port = 1; port <= dev->caps.num_ports; port++) {
304 mlx4_CLOSE_PORT(dev, port);
305 err = mlx4_SET_PORT(dev, port);
307 mlx4_err(dev, "Failed to set port %d, "
312 mlx4_set_port_mask(dev);
313 err = mlx4_register_device(dev);
320 static ssize_t show_port_type(struct device *dev,
321 struct device_attribute *attr,
324 struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
326 struct mlx4_dev *mdev = info->dev;
330 (mdev->caps.port_type[info->port] == MLX4_PORT_TYPE_IB) ?
332 if (mdev->caps.possible_type[info->port] == MLX4_PORT_TYPE_AUTO)
333 sprintf(buf, "auto (%s)\n", type);
335 sprintf(buf, "%s\n", type);
340 static ssize_t set_port_type(struct device *dev,
341 struct device_attribute *attr,
342 const char *buf, size_t count)
344 struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
346 struct mlx4_dev *mdev = info->dev;
347 struct mlx4_priv *priv = mlx4_priv(mdev);
348 enum mlx4_port_type types[MLX4_MAX_PORTS];
349 enum mlx4_port_type new_types[MLX4_MAX_PORTS];
353 if (!strcmp(buf, "ib\n"))
354 info->tmp_type = MLX4_PORT_TYPE_IB;
355 else if (!strcmp(buf, "eth\n"))
356 info->tmp_type = MLX4_PORT_TYPE_ETH;
357 else if (!strcmp(buf, "auto\n"))
358 info->tmp_type = MLX4_PORT_TYPE_AUTO;
360 mlx4_err(mdev, "%s is not supported port type\n", buf);
364 mlx4_stop_sense(mdev);
365 mutex_lock(&priv->port_mutex);
366 /* Possible type is always the one that was delivered */
367 mdev->caps.possible_type[info->port] = info->tmp_type;
369 for (i = 0; i < mdev->caps.num_ports; i++) {
370 types[i] = priv->port[i+1].tmp_type ? priv->port[i+1].tmp_type :
371 mdev->caps.possible_type[i+1];
372 if (types[i] == MLX4_PORT_TYPE_AUTO)
373 types[i] = mdev->caps.port_type[i+1];
376 if (!(mdev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) {
377 for (i = 1; i <= mdev->caps.num_ports; i++) {
378 if (mdev->caps.possible_type[i] == MLX4_PORT_TYPE_AUTO) {
379 mdev->caps.possible_type[i] = mdev->caps.port_type[i];
385 mlx4_err(mdev, "Auto sensing is not supported on this HCA. "
386 "Set only 'eth' or 'ib' for both ports "
387 "(should be the same)\n");
391 mlx4_do_sense_ports(mdev, new_types, types);
393 err = mlx4_check_port_params(mdev, new_types);
397 /* We are about to apply the changes after the configuration
398 * was verified, no need to remember the temporary types
400 for (i = 0; i < mdev->caps.num_ports; i++)
401 priv->port[i + 1].tmp_type = 0;
403 err = mlx4_change_port_types(mdev, new_types);
406 mlx4_start_sense(mdev);
407 mutex_unlock(&priv->port_mutex);
408 return err ? err : count;
411 static int mlx4_load_fw(struct mlx4_dev *dev)
413 struct mlx4_priv *priv = mlx4_priv(dev);
416 priv->fw.fw_icm = mlx4_alloc_icm(dev, priv->fw.fw_pages,
417 GFP_HIGHUSER | __GFP_NOWARN, 0);
418 if (!priv->fw.fw_icm) {
419 mlx4_err(dev, "Couldn't allocate FW area, aborting.\n");
423 err = mlx4_MAP_FA(dev, priv->fw.fw_icm);
425 mlx4_err(dev, "MAP_FA command failed, aborting.\n");
429 err = mlx4_RUN_FW(dev);
431 mlx4_err(dev, "RUN_FW command failed, aborting.\n");
441 mlx4_free_icm(dev, priv->fw.fw_icm, 0);
445 static int mlx4_init_cmpt_table(struct mlx4_dev *dev, u64 cmpt_base,
448 struct mlx4_priv *priv = mlx4_priv(dev);
451 err = mlx4_init_icm_table(dev, &priv->qp_table.cmpt_table,
453 ((u64) (MLX4_CMPT_TYPE_QP *
454 cmpt_entry_sz) << MLX4_CMPT_SHIFT),
455 cmpt_entry_sz, dev->caps.num_qps,
456 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
461 err = mlx4_init_icm_table(dev, &priv->srq_table.cmpt_table,
463 ((u64) (MLX4_CMPT_TYPE_SRQ *
464 cmpt_entry_sz) << MLX4_CMPT_SHIFT),
465 cmpt_entry_sz, dev->caps.num_srqs,
466 dev->caps.reserved_srqs, 0, 0);
470 err = mlx4_init_icm_table(dev, &priv->cq_table.cmpt_table,
472 ((u64) (MLX4_CMPT_TYPE_CQ *
473 cmpt_entry_sz) << MLX4_CMPT_SHIFT),
474 cmpt_entry_sz, dev->caps.num_cqs,
475 dev->caps.reserved_cqs, 0, 0);
479 err = mlx4_init_icm_table(dev, &priv->eq_table.cmpt_table,
481 ((u64) (MLX4_CMPT_TYPE_EQ *
482 cmpt_entry_sz) << MLX4_CMPT_SHIFT),
484 dev->caps.num_eqs, dev->caps.num_eqs, 0, 0);
491 mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
494 mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
497 mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
503 static int mlx4_init_icm(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap,
504 struct mlx4_init_hca_param *init_hca, u64 icm_size)
506 struct mlx4_priv *priv = mlx4_priv(dev);
510 err = mlx4_SET_ICM_SIZE(dev, icm_size, &aux_pages);
512 mlx4_err(dev, "SET_ICM_SIZE command failed, aborting.\n");
516 mlx4_dbg(dev, "%lld KB of HCA context requires %lld KB aux memory.\n",
517 (unsigned long long) icm_size >> 10,
518 (unsigned long long) aux_pages << 2);
520 priv->fw.aux_icm = mlx4_alloc_icm(dev, aux_pages,
521 GFP_HIGHUSER | __GFP_NOWARN, 0);
522 if (!priv->fw.aux_icm) {
523 mlx4_err(dev, "Couldn't allocate aux memory, aborting.\n");
527 err = mlx4_MAP_ICM_AUX(dev, priv->fw.aux_icm);
529 mlx4_err(dev, "MAP_ICM_AUX command failed, aborting.\n");
533 err = mlx4_init_cmpt_table(dev, init_hca->cmpt_base, dev_cap->cmpt_entry_sz);
535 mlx4_err(dev, "Failed to map cMPT context memory, aborting.\n");
539 err = mlx4_init_icm_table(dev, &priv->eq_table.table,
540 init_hca->eqc_base, dev_cap->eqc_entry_sz,
541 dev->caps.num_eqs, dev->caps.num_eqs,
544 mlx4_err(dev, "Failed to map EQ context memory, aborting.\n");
549 * Reserved MTT entries must be aligned up to a cacheline
550 * boundary, since the FW will write to them, while the driver
551 * writes to all other MTT entries. (The variable
552 * dev->caps.mtt_entry_sz below is really the MTT segment
553 * size, not the raw entry size)
555 dev->caps.reserved_mtts =
556 ALIGN(dev->caps.reserved_mtts * dev->caps.mtt_entry_sz,
557 dma_get_cache_alignment()) / dev->caps.mtt_entry_sz;
559 err = mlx4_init_icm_table(dev, &priv->mr_table.mtt_table,
561 dev->caps.mtt_entry_sz,
562 dev->caps.num_mtt_segs,
563 dev->caps.reserved_mtts, 1, 0);
565 mlx4_err(dev, "Failed to map MTT context memory, aborting.\n");
569 err = mlx4_init_icm_table(dev, &priv->mr_table.dmpt_table,
571 dev_cap->dmpt_entry_sz,
573 dev->caps.reserved_mrws, 1, 1);
575 mlx4_err(dev, "Failed to map dMPT context memory, aborting.\n");
579 err = mlx4_init_icm_table(dev, &priv->qp_table.qp_table,
581 dev_cap->qpc_entry_sz,
583 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
586 mlx4_err(dev, "Failed to map QP context memory, aborting.\n");
590 err = mlx4_init_icm_table(dev, &priv->qp_table.auxc_table,
592 dev_cap->aux_entry_sz,
594 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
597 mlx4_err(dev, "Failed to map AUXC context memory, aborting.\n");
601 err = mlx4_init_icm_table(dev, &priv->qp_table.altc_table,
603 dev_cap->altc_entry_sz,
605 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
608 mlx4_err(dev, "Failed to map ALTC context memory, aborting.\n");
612 err = mlx4_init_icm_table(dev, &priv->qp_table.rdmarc_table,
613 init_hca->rdmarc_base,
614 dev_cap->rdmarc_entry_sz << priv->qp_table.rdmarc_shift,
616 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
619 mlx4_err(dev, "Failed to map RDMARC context memory, aborting\n");
623 err = mlx4_init_icm_table(dev, &priv->cq_table.table,
625 dev_cap->cqc_entry_sz,
627 dev->caps.reserved_cqs, 0, 0);
629 mlx4_err(dev, "Failed to map CQ context memory, aborting.\n");
630 goto err_unmap_rdmarc;
633 err = mlx4_init_icm_table(dev, &priv->srq_table.table,
635 dev_cap->srq_entry_sz,
637 dev->caps.reserved_srqs, 0, 0);
639 mlx4_err(dev, "Failed to map SRQ context memory, aborting.\n");
644 * It's not strictly required, but for simplicity just map the
645 * whole multicast group table now. The table isn't very big
646 * and it's a lot easier than trying to track ref counts.
648 err = mlx4_init_icm_table(dev, &priv->mcg_table.table,
649 init_hca->mc_base, MLX4_MGM_ENTRY_SIZE,
650 dev->caps.num_mgms + dev->caps.num_amgms,
651 dev->caps.num_mgms + dev->caps.num_amgms,
654 mlx4_err(dev, "Failed to map MCG context memory, aborting.\n");
661 mlx4_cleanup_icm_table(dev, &priv->srq_table.table);
664 mlx4_cleanup_icm_table(dev, &priv->cq_table.table);
667 mlx4_cleanup_icm_table(dev, &priv->qp_table.rdmarc_table);
670 mlx4_cleanup_icm_table(dev, &priv->qp_table.altc_table);
673 mlx4_cleanup_icm_table(dev, &priv->qp_table.auxc_table);
676 mlx4_cleanup_icm_table(dev, &priv->qp_table.qp_table);
679 mlx4_cleanup_icm_table(dev, &priv->mr_table.dmpt_table);
682 mlx4_cleanup_icm_table(dev, &priv->mr_table.mtt_table);
685 mlx4_cleanup_icm_table(dev, &priv->eq_table.table);
688 mlx4_cleanup_icm_table(dev, &priv->eq_table.cmpt_table);
689 mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
690 mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
691 mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
694 mlx4_UNMAP_ICM_AUX(dev);
697 mlx4_free_icm(dev, priv->fw.aux_icm, 0);
702 static void mlx4_free_icms(struct mlx4_dev *dev)
704 struct mlx4_priv *priv = mlx4_priv(dev);
706 mlx4_cleanup_icm_table(dev, &priv->mcg_table.table);
707 mlx4_cleanup_icm_table(dev, &priv->srq_table.table);
708 mlx4_cleanup_icm_table(dev, &priv->cq_table.table);
709 mlx4_cleanup_icm_table(dev, &priv->qp_table.rdmarc_table);
710 mlx4_cleanup_icm_table(dev, &priv->qp_table.altc_table);
711 mlx4_cleanup_icm_table(dev, &priv->qp_table.auxc_table);
712 mlx4_cleanup_icm_table(dev, &priv->qp_table.qp_table);
713 mlx4_cleanup_icm_table(dev, &priv->mr_table.dmpt_table);
714 mlx4_cleanup_icm_table(dev, &priv->mr_table.mtt_table);
715 mlx4_cleanup_icm_table(dev, &priv->eq_table.table);
716 mlx4_cleanup_icm_table(dev, &priv->eq_table.cmpt_table);
717 mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
718 mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
719 mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
721 mlx4_UNMAP_ICM_AUX(dev);
722 mlx4_free_icm(dev, priv->fw.aux_icm, 0);
725 static int map_bf_area(struct mlx4_dev *dev)
727 struct mlx4_priv *priv = mlx4_priv(dev);
728 resource_size_t bf_start;
729 resource_size_t bf_len;
732 bf_start = pci_resource_start(dev->pdev, 2) + (dev->caps.num_uars << PAGE_SHIFT);
733 bf_len = pci_resource_len(dev->pdev, 2) - (dev->caps.num_uars << PAGE_SHIFT);
734 priv->bf_mapping = io_mapping_create_wc(bf_start, bf_len);
735 if (!priv->bf_mapping)
741 static void unmap_bf_area(struct mlx4_dev *dev)
743 if (mlx4_priv(dev)->bf_mapping)
744 io_mapping_free(mlx4_priv(dev)->bf_mapping);
747 static void mlx4_close_hca(struct mlx4_dev *dev)
750 mlx4_CLOSE_HCA(dev, 0);
753 mlx4_free_icm(dev, mlx4_priv(dev)->fw.fw_icm, 0);
756 static int mlx4_init_hca(struct mlx4_dev *dev)
758 struct mlx4_priv *priv = mlx4_priv(dev);
759 struct mlx4_adapter adapter;
760 struct mlx4_dev_cap dev_cap;
761 struct mlx4_mod_stat_cfg mlx4_cfg;
762 struct mlx4_profile profile;
763 struct mlx4_init_hca_param init_hca;
767 err = mlx4_QUERY_FW(dev);
770 mlx4_info(dev, "non-primary physical function, skipping.\n");
772 mlx4_err(dev, "QUERY_FW command failed, aborting.\n");
776 err = mlx4_load_fw(dev);
778 mlx4_err(dev, "Failed to start FW, aborting.\n");
782 mlx4_cfg.log_pg_sz_m = 1;
783 mlx4_cfg.log_pg_sz = 0;
784 err = mlx4_MOD_STAT_CFG(dev, &mlx4_cfg);
786 mlx4_warn(dev, "Failed to override log_pg_sz parameter\n");
788 err = mlx4_dev_cap(dev, &dev_cap);
790 mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
794 profile = default_profile;
796 icm_size = mlx4_make_profile(dev, &profile, &dev_cap, &init_hca);
797 if ((long long) icm_size < 0) {
802 if (map_bf_area(dev))
803 mlx4_dbg(dev, "Failed to map blue flame area\n");
805 init_hca.log_uar_sz = ilog2(dev->caps.num_uars);
807 err = mlx4_init_icm(dev, &dev_cap, &init_hca, icm_size);
811 err = mlx4_INIT_HCA(dev, &init_hca);
813 mlx4_err(dev, "INIT_HCA command failed, aborting.\n");
817 err = mlx4_QUERY_ADAPTER(dev, &adapter);
819 mlx4_err(dev, "QUERY_ADAPTER command failed, aborting.\n");
823 priv->eq_table.inta_pin = adapter.inta_pin;
824 memcpy(dev->board_id, adapter.board_id, sizeof dev->board_id);
829 mlx4_CLOSE_HCA(dev, 0);
837 mlx4_free_icm(dev, priv->fw.fw_icm, 0);
842 static int mlx4_init_counters_table(struct mlx4_dev *dev)
844 struct mlx4_priv *priv = mlx4_priv(dev);
847 if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
850 nent = dev->caps.max_counters;
851 return mlx4_bitmap_init(&priv->counters_bitmap, nent, nent - 1, 0, 0);
854 static void mlx4_cleanup_counters_table(struct mlx4_dev *dev)
856 mlx4_bitmap_cleanup(&mlx4_priv(dev)->counters_bitmap);
859 int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx)
861 struct mlx4_priv *priv = mlx4_priv(dev);
863 if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
866 *idx = mlx4_bitmap_alloc(&priv->counters_bitmap);
872 EXPORT_SYMBOL_GPL(mlx4_counter_alloc);
874 void mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
876 mlx4_bitmap_free(&mlx4_priv(dev)->counters_bitmap, idx);
879 EXPORT_SYMBOL_GPL(mlx4_counter_free);
881 static int mlx4_setup_hca(struct mlx4_dev *dev)
883 struct mlx4_priv *priv = mlx4_priv(dev);
886 __be32 ib_port_default_caps;
888 err = mlx4_init_uar_table(dev);
890 mlx4_err(dev, "Failed to initialize "
891 "user access region table, aborting.\n");
895 err = mlx4_uar_alloc(dev, &priv->driver_uar);
897 mlx4_err(dev, "Failed to allocate driver access region, "
899 goto err_uar_table_free;
902 priv->kar = ioremap((phys_addr_t) priv->driver_uar.pfn << PAGE_SHIFT, PAGE_SIZE);
904 mlx4_err(dev, "Couldn't map kernel access region, "
910 err = mlx4_init_pd_table(dev);
912 mlx4_err(dev, "Failed to initialize "
913 "protection domain table, aborting.\n");
917 err = mlx4_init_mr_table(dev);
919 mlx4_err(dev, "Failed to initialize "
920 "memory region table, aborting.\n");
921 goto err_pd_table_free;
924 err = mlx4_init_eq_table(dev);
926 mlx4_err(dev, "Failed to initialize "
927 "event queue table, aborting.\n");
928 goto err_mr_table_free;
931 err = mlx4_cmd_use_events(dev);
933 mlx4_err(dev, "Failed to switch to event-driven "
934 "firmware commands, aborting.\n");
935 goto err_eq_table_free;
940 if (dev->flags & MLX4_FLAG_MSI_X) {
941 mlx4_warn(dev, "NOP command failed to generate MSI-X "
942 "interrupt IRQ %d).\n",
943 priv->eq_table.eq[dev->caps.num_comp_vectors].irq);
944 mlx4_warn(dev, "Trying again without MSI-X.\n");
946 mlx4_err(dev, "NOP command failed to generate interrupt "
947 "(IRQ %d), aborting.\n",
948 priv->eq_table.eq[dev->caps.num_comp_vectors].irq);
949 mlx4_err(dev, "BIOS or ACPI interrupt routing problem?\n");
955 mlx4_dbg(dev, "NOP command IRQ test passed\n");
957 err = mlx4_init_cq_table(dev);
959 mlx4_err(dev, "Failed to initialize "
960 "completion queue table, aborting.\n");
964 err = mlx4_init_srq_table(dev);
966 mlx4_err(dev, "Failed to initialize "
967 "shared receive queue table, aborting.\n");
968 goto err_cq_table_free;
971 err = mlx4_init_qp_table(dev);
973 mlx4_err(dev, "Failed to initialize "
974 "queue pair table, aborting.\n");
975 goto err_srq_table_free;
978 err = mlx4_init_mcg_table(dev);
980 mlx4_err(dev, "Failed to initialize "
981 "multicast group table, aborting.\n");
982 goto err_qp_table_free;
985 err = mlx4_init_counters_table(dev);
986 if (err && err != -ENOENT) {
987 mlx4_err(dev, "Failed to initialize counters table, aborting.\n");
988 goto err_counters_table_free;
991 for (port = 1; port <= dev->caps.num_ports; port++) {
992 enum mlx4_port_type port_type = 0;
993 mlx4_SENSE_PORT(dev, port, &port_type);
995 dev->caps.port_type[port] = port_type;
996 ib_port_default_caps = 0;
997 err = mlx4_get_port_ib_caps(dev, port, &ib_port_default_caps);
999 mlx4_warn(dev, "failed to get port %d default "
1000 "ib capabilities (%d). Continuing with "
1001 "caps = 0\n", port, err);
1002 dev->caps.ib_port_def_cap[port] = ib_port_default_caps;
1003 err = mlx4_SET_PORT(dev, port);
1005 mlx4_err(dev, "Failed to set port %d, aborting\n",
1007 goto err_mcg_table_free;
1010 mlx4_set_port_mask(dev);
1015 mlx4_cleanup_mcg_table(dev);
1017 err_counters_table_free:
1018 mlx4_cleanup_counters_table(dev);
1021 mlx4_cleanup_qp_table(dev);
1024 mlx4_cleanup_srq_table(dev);
1027 mlx4_cleanup_cq_table(dev);
1030 mlx4_cmd_use_polling(dev);
1033 mlx4_cleanup_eq_table(dev);
1036 mlx4_cleanup_mr_table(dev);
1039 mlx4_cleanup_pd_table(dev);
1045 mlx4_uar_free(dev, &priv->driver_uar);
1048 mlx4_cleanup_uar_table(dev);
1052 static void mlx4_enable_msi_x(struct mlx4_dev *dev)
1054 struct mlx4_priv *priv = mlx4_priv(dev);
1055 struct msix_entry *entries;
1056 int nreq = min_t(int, dev->caps.num_ports *
1057 min_t(int, num_online_cpus() + 1, MAX_MSIX_P_PORT)
1058 + MSIX_LEGACY_SZ, MAX_MSIX);
1063 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
1065 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
1069 for (i = 0; i < nreq; ++i)
1070 entries[i].entry = i;
1073 err = pci_enable_msix(dev->pdev, entries, nreq);
1075 /* Try again if at least 2 vectors are available */
1077 mlx4_info(dev, "Requested %d vectors, "
1078 "but only %d MSI-X vectors available, "
1079 "trying again\n", nreq, err);
1088 MSIX_LEGACY_SZ + dev->caps.num_ports * MIN_MSIX_P_PORT) {
1089 /*Working in legacy mode , all EQ's shared*/
1090 dev->caps.comp_pool = 0;
1091 dev->caps.num_comp_vectors = nreq - 1;
1093 dev->caps.comp_pool = nreq - MSIX_LEGACY_SZ;
1094 dev->caps.num_comp_vectors = MSIX_LEGACY_SZ - 1;
1096 for (i = 0; i < nreq; ++i)
1097 priv->eq_table.eq[i].irq = entries[i].vector;
1099 dev->flags |= MLX4_FLAG_MSI_X;
1106 dev->caps.num_comp_vectors = 1;
1107 dev->caps.comp_pool = 0;
1109 for (i = 0; i < 2; ++i)
1110 priv->eq_table.eq[i].irq = dev->pdev->irq;
1113 static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
1115 struct mlx4_port_info *info = &mlx4_priv(dev)->port[port];
1120 mlx4_init_mac_table(dev, &info->mac_table);
1121 mlx4_init_vlan_table(dev, &info->vlan_table);
1122 info->base_qpn = dev->caps.reserved_qps_base[MLX4_QP_REGION_ETH_ADDR] +
1123 (port - 1) * (1 << log_num_mac);
1125 sprintf(info->dev_name, "mlx4_port%d", port);
1126 info->port_attr.attr.name = info->dev_name;
1127 info->port_attr.attr.mode = S_IRUGO | S_IWUSR;
1128 info->port_attr.show = show_port_type;
1129 info->port_attr.store = set_port_type;
1130 sysfs_attr_init(&info->port_attr.attr);
1132 err = device_create_file(&dev->pdev->dev, &info->port_attr);
1134 mlx4_err(dev, "Failed to create file for port %d\n", port);
1141 static void mlx4_cleanup_port_info(struct mlx4_port_info *info)
1146 device_remove_file(&info->dev->pdev->dev, &info->port_attr);
1149 static int mlx4_init_steering(struct mlx4_dev *dev)
1151 struct mlx4_priv *priv = mlx4_priv(dev);
1152 int num_entries = dev->caps.num_ports;
1155 priv->steer = kzalloc(sizeof(struct mlx4_steer) * num_entries, GFP_KERNEL);
1159 for (i = 0; i < num_entries; i++) {
1160 for (j = 0; j < MLX4_NUM_STEERS; j++) {
1161 INIT_LIST_HEAD(&priv->steer[i].promisc_qps[j]);
1162 INIT_LIST_HEAD(&priv->steer[i].steer_entries[j]);
1164 INIT_LIST_HEAD(&priv->steer[i].high_prios);
1169 static void mlx4_clear_steering(struct mlx4_dev *dev)
1171 struct mlx4_priv *priv = mlx4_priv(dev);
1172 struct mlx4_steer_index *entry, *tmp_entry;
1173 struct mlx4_promisc_qp *pqp, *tmp_pqp;
1174 int num_entries = dev->caps.num_ports;
1177 for (i = 0; i < num_entries; i++) {
1178 for (j = 0; j < MLX4_NUM_STEERS; j++) {
1179 list_for_each_entry_safe(pqp, tmp_pqp,
1180 &priv->steer[i].promisc_qps[j],
1182 list_del(&pqp->list);
1185 list_for_each_entry_safe(entry, tmp_entry,
1186 &priv->steer[i].steer_entries[j],
1188 list_del(&entry->list);
1189 list_for_each_entry_safe(pqp, tmp_pqp,
1192 list_del(&pqp->list);
1202 static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1204 struct mlx4_priv *priv;
1205 struct mlx4_dev *dev;
1209 pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev));
1211 err = pci_enable_device(pdev);
1213 dev_err(&pdev->dev, "Cannot enable PCI device, "
1219 * Check for BARs. We expect 0: 1MB
1221 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
1222 pci_resource_len(pdev, 0) != 1 << 20) {
1223 dev_err(&pdev->dev, "Missing DCS, aborting.\n");
1225 goto err_disable_pdev;
1227 if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
1228 dev_err(&pdev->dev, "Missing UAR, aborting.\n");
1230 goto err_disable_pdev;
1233 err = pci_request_regions(pdev, DRV_NAME);
1235 dev_err(&pdev->dev, "Couldn't get PCI resources, aborting\n");
1236 goto err_disable_pdev;
1239 pci_set_master(pdev);
1241 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
1243 dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask.\n");
1244 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
1246 dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n");
1247 goto err_release_regions;
1250 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
1252 dev_warn(&pdev->dev, "Warning: couldn't set 64-bit "
1253 "consistent PCI DMA mask.\n");
1254 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
1256 dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, "
1258 goto err_release_regions;
1262 /* Allow large DMA segments, up to the firmware limit of 1 GB */
1263 dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024);
1265 priv = kzalloc(sizeof *priv, GFP_KERNEL);
1267 dev_err(&pdev->dev, "Device struct alloc failed, "
1270 goto err_release_regions;
1275 INIT_LIST_HEAD(&priv->ctx_list);
1276 spin_lock_init(&priv->ctx_lock);
1278 mutex_init(&priv->port_mutex);
1280 INIT_LIST_HEAD(&priv->pgdir_list);
1281 mutex_init(&priv->pgdir_mutex);
1283 INIT_LIST_HEAD(&priv->bf_list);
1284 mutex_init(&priv->bf_mutex);
1286 dev->rev_id = pdev->revision;
1289 * Now reset the HCA before we touch the PCI capabilities or
1290 * attempt a firmware command, since a boot ROM may have left
1291 * the HCA in an undefined state.
1293 err = mlx4_reset(dev);
1295 mlx4_err(dev, "Failed to reset HCA, aborting.\n");
1299 if (mlx4_cmd_init(dev)) {
1300 mlx4_err(dev, "Failed to init command interface, aborting.\n");
1304 err = mlx4_init_hca(dev);
1308 err = mlx4_alloc_eq_table(dev);
1312 priv->msix_ctl.pool_bm = 0;
1313 spin_lock_init(&priv->msix_ctl.pool_lock);
1315 mlx4_enable_msi_x(dev);
1317 err = mlx4_init_steering(dev);
1321 err = mlx4_setup_hca(dev);
1322 if (err == -EBUSY && (dev->flags & MLX4_FLAG_MSI_X)) {
1323 dev->flags &= ~MLX4_FLAG_MSI_X;
1324 pci_disable_msix(pdev);
1325 err = mlx4_setup_hca(dev);
1331 for (port = 1; port <= dev->caps.num_ports; port++) {
1332 err = mlx4_init_port_info(dev, port);
1337 err = mlx4_register_device(dev);
1341 mlx4_sense_init(dev);
1342 mlx4_start_sense(dev);
1344 pci_set_drvdata(pdev, dev);
1349 for (--port; port >= 1; --port)
1350 mlx4_cleanup_port_info(&priv->port[port]);
1352 mlx4_cleanup_counters_table(dev);
1353 mlx4_cleanup_mcg_table(dev);
1354 mlx4_cleanup_qp_table(dev);
1355 mlx4_cleanup_srq_table(dev);
1356 mlx4_cleanup_cq_table(dev);
1357 mlx4_cmd_use_polling(dev);
1358 mlx4_cleanup_eq_table(dev);
1359 mlx4_cleanup_mr_table(dev);
1360 mlx4_cleanup_pd_table(dev);
1361 mlx4_cleanup_uar_table(dev);
1364 mlx4_clear_steering(dev);
1367 mlx4_free_eq_table(dev);
1370 if (dev->flags & MLX4_FLAG_MSI_X)
1371 pci_disable_msix(pdev);
1373 mlx4_close_hca(dev);
1376 mlx4_cmd_cleanup(dev);
1381 err_release_regions:
1382 pci_release_regions(pdev);
1385 pci_disable_device(pdev);
1386 pci_set_drvdata(pdev, NULL);
1390 static int __devinit mlx4_init_one(struct pci_dev *pdev,
1391 const struct pci_device_id *id)
1393 printk_once(KERN_INFO "%s", mlx4_version);
1395 return __mlx4_init_one(pdev, id);
1398 static void mlx4_remove_one(struct pci_dev *pdev)
1400 struct mlx4_dev *dev = pci_get_drvdata(pdev);
1401 struct mlx4_priv *priv = mlx4_priv(dev);
1405 mlx4_stop_sense(dev);
1406 mlx4_unregister_device(dev);
1408 for (p = 1; p <= dev->caps.num_ports; p++) {
1409 mlx4_cleanup_port_info(&priv->port[p]);
1410 mlx4_CLOSE_PORT(dev, p);
1413 mlx4_cleanup_counters_table(dev);
1414 mlx4_cleanup_mcg_table(dev);
1415 mlx4_cleanup_qp_table(dev);
1416 mlx4_cleanup_srq_table(dev);
1417 mlx4_cleanup_cq_table(dev);
1418 mlx4_cmd_use_polling(dev);
1419 mlx4_cleanup_eq_table(dev);
1420 mlx4_cleanup_mr_table(dev);
1421 mlx4_cleanup_pd_table(dev);
1424 mlx4_uar_free(dev, &priv->driver_uar);
1425 mlx4_cleanup_uar_table(dev);
1426 mlx4_clear_steering(dev);
1427 mlx4_free_eq_table(dev);
1428 mlx4_close_hca(dev);
1429 mlx4_cmd_cleanup(dev);
1431 if (dev->flags & MLX4_FLAG_MSI_X)
1432 pci_disable_msix(pdev);
1435 pci_release_regions(pdev);
1436 pci_disable_device(pdev);
1437 pci_set_drvdata(pdev, NULL);
1441 int mlx4_restart_one(struct pci_dev *pdev)
1443 mlx4_remove_one(pdev);
1444 return __mlx4_init_one(pdev, NULL);
1447 static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = {
1448 { PCI_VDEVICE(MELLANOX, 0x6340) }, /* MT25408 "Hermon" SDR */
1449 { PCI_VDEVICE(MELLANOX, 0x634a) }, /* MT25408 "Hermon" DDR */
1450 { PCI_VDEVICE(MELLANOX, 0x6354) }, /* MT25408 "Hermon" QDR */
1451 { PCI_VDEVICE(MELLANOX, 0x6732) }, /* MT25408 "Hermon" DDR PCIe gen2 */
1452 { PCI_VDEVICE(MELLANOX, 0x673c) }, /* MT25408 "Hermon" QDR PCIe gen2 */
1453 { PCI_VDEVICE(MELLANOX, 0x6368) }, /* MT25408 "Hermon" EN 10GigE */
1454 { PCI_VDEVICE(MELLANOX, 0x6750) }, /* MT25408 "Hermon" EN 10GigE PCIe gen2 */
1455 { PCI_VDEVICE(MELLANOX, 0x6372) }, /* MT25458 ConnectX EN 10GBASE-T 10GigE */
1456 { PCI_VDEVICE(MELLANOX, 0x675a) }, /* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */
1457 { PCI_VDEVICE(MELLANOX, 0x6764) }, /* MT26468 ConnectX EN 10GigE PCIe gen2*/
1458 { PCI_VDEVICE(MELLANOX, 0x6746) }, /* MT26438 ConnectX EN 40GigE PCIe gen2 5GT/s */
1459 { PCI_VDEVICE(MELLANOX, 0x676e) }, /* MT26478 ConnectX2 40GigE PCIe gen2 */
1460 { PCI_VDEVICE(MELLANOX, 0x1002) }, /* MT25400 Family [ConnectX-2 Virtual Function] */
1461 { PCI_VDEVICE(MELLANOX, 0x1003) }, /* MT27500 Family [ConnectX-3] */
1462 { PCI_VDEVICE(MELLANOX, 0x1004) }, /* MT27500 Family [ConnectX-3 Virtual Function] */
1463 { PCI_VDEVICE(MELLANOX, 0x1005) }, /* MT27510 Family */
1464 { PCI_VDEVICE(MELLANOX, 0x1006) }, /* MT27511 Family */
1465 { PCI_VDEVICE(MELLANOX, 0x1007) }, /* MT27520 Family */
1466 { PCI_VDEVICE(MELLANOX, 0x1008) }, /* MT27521 Family */
1467 { PCI_VDEVICE(MELLANOX, 0x1009) }, /* MT27530 Family */
1468 { PCI_VDEVICE(MELLANOX, 0x100a) }, /* MT27531 Family */
1469 { PCI_VDEVICE(MELLANOX, 0x100b) }, /* MT27540 Family */
1470 { PCI_VDEVICE(MELLANOX, 0x100c) }, /* MT27541 Family */
1471 { PCI_VDEVICE(MELLANOX, 0x100d) }, /* MT27550 Family */
1472 { PCI_VDEVICE(MELLANOX, 0x100e) }, /* MT27551 Family */
1473 { PCI_VDEVICE(MELLANOX, 0x100f) }, /* MT27560 Family */
1474 { PCI_VDEVICE(MELLANOX, 0x1010) }, /* MT27561 Family */
1478 MODULE_DEVICE_TABLE(pci, mlx4_pci_table);
1480 static struct pci_driver mlx4_driver = {
1482 .id_table = mlx4_pci_table,
1483 .probe = mlx4_init_one,
1484 .remove = __devexit_p(mlx4_remove_one)
1487 static int __init mlx4_verify_params(void)
1489 if ((log_num_mac < 0) || (log_num_mac > 7)) {
1490 pr_warning("mlx4_core: bad num_mac: %d\n", log_num_mac);
1494 if (log_num_vlan != 0)
1495 pr_warning("mlx4_core: log_num_vlan - obsolete module param, using %d\n",
1496 MLX4_LOG_NUM_VLANS);
1498 if ((log_mtts_per_seg < 1) || (log_mtts_per_seg > 7)) {
1499 pr_warning("mlx4_core: bad log_mtts_per_seg: %d\n", log_mtts_per_seg);
1506 static int __init mlx4_init(void)
1510 if (mlx4_verify_params())
1515 mlx4_wq = create_singlethread_workqueue("mlx4");
1519 ret = pci_register_driver(&mlx4_driver);
1520 return ret < 0 ? ret : 0;
1523 static void __exit mlx4_cleanup(void)
1525 pci_unregister_driver(&mlx4_driver);
1526 destroy_workqueue(mlx4_wq);
1529 module_init(mlx4_init);
1530 module_exit(mlx4_cleanup);