mlx4_core: Add extended port capabilities support
authorMarcel Apfelbaum <marcela@dev.mellanox.co.il>
Mon, 24 Oct 2011 09:02:34 +0000 (11:02 +0200)
committerRoland Dreier <roland@purestorage.com>
Fri, 28 Oct 2011 18:33:38 +0000 (11:33 -0700)
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>
drivers/net/mlx4/main.c
drivers/net/mlx4/mlx4.h
drivers/net/mlx4/port.c
include/linux/mlx4/device.h

index f0ee35df4dd7779aa971fec3d7fa7555d9bc058a..017616a722d77b2a3eef3358972115b41c1e6dd6 100644 (file)
@@ -998,6 +998,13 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
                                  "ib capabilities (%d). Continuing with "
                                  "caps = 0\n", port, err);
                dev->caps.ib_port_def_cap[port] = ib_port_default_caps;
+
+               err = mlx4_check_ext_port_caps(dev, port);
+               if (err)
+                       mlx4_warn(dev, "failed to get port %d extended "
+                                 "port capabilities support info (%d)."
+                                 " Assuming not supported\n", port, err);
+
                err = mlx4_SET_PORT(dev, port);
                if (err) {
                        mlx4_err(dev, "Failed to set port %d, aborting\n",
index a2fcd8402d37295a04474e502a8594dfb8a4a188..9ba9c565b1a08097b59ae9eae305489f54632fa2 100644 (file)
@@ -450,6 +450,7 @@ void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
 
 int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port);
 int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
+int mlx4_check_ext_port_caps(struct mlx4_dev *dev, u8 port);
 
 int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
                          enum mlx4_protocol prot, enum mlx4_steer_type steer);
index 609e0ec14ceebf495c6ddff49ea2cff09738e2cd..7b2a2dafbaa4fed406dbb25f0273a517ec78e3d3 100644 (file)
@@ -464,6 +464,48 @@ int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps)
        return err;
 }
 
+int mlx4_check_ext_port_caps(struct mlx4_dev *dev, u8 port)
+{
+       struct mlx4_cmd_mailbox *inmailbox, *outmailbox;
+       u8 *inbuf, *outbuf;
+       int err, packet_error;
+
+       inmailbox = mlx4_alloc_cmd_mailbox(dev);
+       if (IS_ERR(inmailbox))
+               return PTR_ERR(inmailbox);
+
+       outmailbox = mlx4_alloc_cmd_mailbox(dev);
+       if (IS_ERR(outmailbox)) {
+               mlx4_free_cmd_mailbox(dev, inmailbox);
+               return PTR_ERR(outmailbox);
+       }
+
+       inbuf = inmailbox->buf;
+       outbuf = outmailbox->buf;
+       memset(inbuf, 0, 256);
+       memset(outbuf, 0, 256);
+       inbuf[0] = 1;
+       inbuf[1] = 1;
+       inbuf[2] = 1;
+       inbuf[3] = 1;
+
+       *(__be16 *) (&inbuf[16]) = MLX4_ATTR_EXTENDED_PORT_INFO;
+       *(__be32 *) (&inbuf[20]) = cpu_to_be32(port);
+
+       err = mlx4_cmd_box(dev, inmailbox->dma, outmailbox->dma, port, 3,
+                          MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C);
+
+       packet_error = be16_to_cpu(*(__be16 *) (outbuf + 4));
+
+       dev->caps.ext_port_cap[port] = (!err && !packet_error) ?
+                                      MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO
+                                      : 0;
+
+       mlx4_free_cmd_mailbox(dev, inmailbox);
+       mlx4_free_cmd_mailbox(dev, outmailbox);
+       return err;
+}
+
 int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port)
 {
        struct mlx4_cmd_mailbox *mailbox;
index 53ef894bfa05aa26e9cb42bd24a002de6e299b4c..ce9ef491addf82e7855e53db2b19849d0dfe6316 100644 (file)
@@ -82,6 +82,12 @@ enum {
        MLX4_DEV_CAP_FLAG_COUNTERS      = 1LL << 48
 };
 
+#define MLX4_ATTR_EXTENDED_PORT_INFO   cpu_to_be16(0xff90)
+
+enum {
+       MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO        = 1 <<  0
+};
+
 enum {
        MLX4_BMME_FLAG_LOCAL_INV        = 1 <<  6,
        MLX4_BMME_FLAG_REMOTE_INV       = 1 <<  7,
@@ -276,6 +282,7 @@ struct mlx4_caps {
        u32                     port_mask;
        enum mlx4_port_type     possible_type[MLX4_MAX_PORTS + 1];
        u32                     max_counters;
+       u8                      ext_port_cap[MLX4_MAX_PORTS + 1];
 };
 
 struct mlx4_buf_list {