aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Apfelbaum <marcela@dev.mellanox.co.il>2011-10-24 05:02:34 -0400
committerRoland Dreier <roland@purestorage.com>2011-10-28 14:33:38 -0400
commit97285b78174423e5576b2e06aa45f64df009da5b (patch)
treed6f44a503b98f385e22fc9243d1abaf98d68947d
parente36fb88a9a0fb8ac4b87c8ac709214a408de6d97 (diff)
mlx4_core: Add extended port capabilities support
An Extended Port Info packet is sent to each hw port during HCA init. If it returns without error, we assume the port supports extended port capabilities. Signed-off-by: Marcel Apfelbaum <marcela@dev.mellanox.co.il> Reviewed-by: Jack Morgenstein <jackm@dev.mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r--drivers/net/mlx4/main.c7
-rw-r--r--drivers/net/mlx4/mlx4.h1
-rw-r--r--drivers/net/mlx4/port.c42
-rw-r--r--include/linux/mlx4/device.h7
4 files changed, 57 insertions, 0 deletions
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index f0ee35df4dd7..017616a722d7 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -998,6 +998,13 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
998 "ib capabilities (%d). Continuing with " 998 "ib capabilities (%d). Continuing with "
999 "caps = 0\n", port, err); 999 "caps = 0\n", port, err);
1000 dev->caps.ib_port_def_cap[port] = ib_port_default_caps; 1000 dev->caps.ib_port_def_cap[port] = ib_port_default_caps;
1001
1002 err = mlx4_check_ext_port_caps(dev, port);
1003 if (err)
1004 mlx4_warn(dev, "failed to get port %d extended "
1005 "port capabilities support info (%d)."
1006 " Assuming not supported\n", port, err);
1007
1001 err = mlx4_SET_PORT(dev, port); 1008 err = mlx4_SET_PORT(dev, port);
1002 if (err) { 1009 if (err) {
1003 mlx4_err(dev, "Failed to set port %d, aborting\n", 1010 mlx4_err(dev, "Failed to set port %d, aborting\n",
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h
index a2fcd8402d37..9ba9c565b1a0 100644
--- a/drivers/net/mlx4/mlx4.h
+++ b/drivers/net/mlx4/mlx4.h
@@ -450,6 +450,7 @@ void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
450 450
451int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port); 451int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port);
452int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps); 452int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
453int mlx4_check_ext_port_caps(struct mlx4_dev *dev, u8 port);
453 454
454int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], 455int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
455 enum mlx4_protocol prot, enum mlx4_steer_type steer); 456 enum mlx4_protocol prot, enum mlx4_steer_type steer);
diff --git a/drivers/net/mlx4/port.c b/drivers/net/mlx4/port.c
index 609e0ec14cee..7b2a2dafbaa4 100644
--- a/drivers/net/mlx4/port.c
+++ b/drivers/net/mlx4/port.c
@@ -464,6 +464,48 @@ int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps)
464 return err; 464 return err;
465} 465}
466 466
467int mlx4_check_ext_port_caps(struct mlx4_dev *dev, u8 port)
468{
469 struct mlx4_cmd_mailbox *inmailbox, *outmailbox;
470 u8 *inbuf, *outbuf;
471 int err, packet_error;
472
473 inmailbox = mlx4_alloc_cmd_mailbox(dev);
474 if (IS_ERR(inmailbox))
475 return PTR_ERR(inmailbox);
476
477 outmailbox = mlx4_alloc_cmd_mailbox(dev);
478 if (IS_ERR(outmailbox)) {
479 mlx4_free_cmd_mailbox(dev, inmailbox);
480 return PTR_ERR(outmailbox);
481 }
482
483 inbuf = inmailbox->buf;
484 outbuf = outmailbox->buf;
485 memset(inbuf, 0, 256);
486 memset(outbuf, 0, 256);
487 inbuf[0] = 1;
488 inbuf[1] = 1;
489 inbuf[2] = 1;
490 inbuf[3] = 1;
491
492 *(__be16 *) (&inbuf[16]) = MLX4_ATTR_EXTENDED_PORT_INFO;
493 *(__be32 *) (&inbuf[20]) = cpu_to_be32(port);
494
495 err = mlx4_cmd_box(dev, inmailbox->dma, outmailbox->dma, port, 3,
496 MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C);
497
498 packet_error = be16_to_cpu(*(__be16 *) (outbuf + 4));
499
500 dev->caps.ext_port_cap[port] = (!err && !packet_error) ?
501 MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO
502 : 0;
503
504 mlx4_free_cmd_mailbox(dev, inmailbox);
505 mlx4_free_cmd_mailbox(dev, outmailbox);
506 return err;
507}
508
467int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port) 509int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port)
468{ 510{
469 struct mlx4_cmd_mailbox *mailbox; 511 struct mlx4_cmd_mailbox *mailbox;
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 53ef894bfa05..ce9ef491addf 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -82,6 +82,12 @@ enum {
82 MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48 82 MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48
83}; 83};
84 84
85#define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90)
86
87enum {
88 MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO = 1 << 0
89};
90
85enum { 91enum {
86 MLX4_BMME_FLAG_LOCAL_INV = 1 << 6, 92 MLX4_BMME_FLAG_LOCAL_INV = 1 << 6,
87 MLX4_BMME_FLAG_REMOTE_INV = 1 << 7, 93 MLX4_BMME_FLAG_REMOTE_INV = 1 << 7,
@@ -276,6 +282,7 @@ struct mlx4_caps {
276 u32 port_mask; 282 u32 port_mask;
277 enum mlx4_port_type possible_type[MLX4_MAX_PORTS + 1]; 283 enum mlx4_port_type possible_type[MLX4_MAX_PORTS + 1];
278 u32 max_counters; 284 u32 max_counters;
285 u8 ext_port_cap[MLX4_MAX_PORTS + 1];
279}; 286};
280 287
281struct mlx4_buf_list { 288struct mlx4_buf_list {