aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2007-06-18 11:15:02 -0400
committerRoland Dreier <rolandd@cisco.com>2007-06-18 11:15:02 -0400
commit5ae2a7a836be660ff1621cce1c46930f19200589 (patch)
tree655b94b9a016cec92f319761afe6bb3000f5f4fa /drivers/infiniband
parent082dee3216c99a838af40be403799f60bcea2e97 (diff)
IB/mlx4: Handle FW command interface rev 3
Upcoming firmware introduces command interface revision 3, which changes the way port capabilities are queried and set. Update the driver to handle both the new and old command interfaces by adding a new MLX4_FLAG_OLD_PORT_CMDS that it is set after querying the firmware interface revision and then using the correct interface based on the setting of the flag. Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/mlx4/main.c16
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c44
2 files changed, 26 insertions, 34 deletions
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 402f3a20ec0a..1095c82b38c2 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -125,7 +125,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
125 props->local_ca_ack_delay = dev->dev->caps.local_ca_ack_delay; 125 props->local_ca_ack_delay = dev->dev->caps.local_ca_ack_delay;
126 props->atomic_cap = dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_ATOMIC ? 126 props->atomic_cap = dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_ATOMIC ?
127 IB_ATOMIC_HCA : IB_ATOMIC_NONE; 127 IB_ATOMIC_HCA : IB_ATOMIC_NONE;
128 props->max_pkeys = dev->dev->caps.pkey_table_len; 128 props->max_pkeys = dev->dev->caps.pkey_table_len[1];
129 props->max_mcast_grp = dev->dev->caps.num_mgms + dev->dev->caps.num_amgms; 129 props->max_mcast_grp = dev->dev->caps.num_mgms + dev->dev->caps.num_amgms;
130 props->max_mcast_qp_attach = dev->dev->caps.num_qp_per_mgm; 130 props->max_mcast_qp_attach = dev->dev->caps.num_qp_per_mgm;
131 props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * 131 props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
@@ -168,9 +168,9 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
168 props->state = out_mad->data[32] & 0xf; 168 props->state = out_mad->data[32] & 0xf;
169 props->phys_state = out_mad->data[33] >> 4; 169 props->phys_state = out_mad->data[33] >> 4;
170 props->port_cap_flags = be32_to_cpup((__be32 *) (out_mad->data + 20)); 170 props->port_cap_flags = be32_to_cpup((__be32 *) (out_mad->data + 20));
171 props->gid_tbl_len = to_mdev(ibdev)->dev->caps.gid_table_len; 171 props->gid_tbl_len = to_mdev(ibdev)->dev->caps.gid_table_len[port];
172 props->max_msg_sz = 0x80000000; 172 props->max_msg_sz = 0x80000000;
173 props->pkey_tbl_len = to_mdev(ibdev)->dev->caps.pkey_table_len; 173 props->pkey_tbl_len = to_mdev(ibdev)->dev->caps.pkey_table_len[port];
174 props->bad_pkey_cntr = be16_to_cpup((__be16 *) (out_mad->data + 46)); 174 props->bad_pkey_cntr = be16_to_cpup((__be16 *) (out_mad->data + 46));
175 props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48)); 175 props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48));
176 props->active_width = out_mad->data[31] & 0xf; 176 props->active_width = out_mad->data[31] & 0xf;
@@ -280,8 +280,14 @@ static int mlx4_SET_PORT(struct mlx4_ib_dev *dev, u8 port, int reset_qkey_viols,
280 return PTR_ERR(mailbox); 280 return PTR_ERR(mailbox);
281 281
282 memset(mailbox->buf, 0, 256); 282 memset(mailbox->buf, 0, 256);
283 *(u8 *) mailbox->buf = !!reset_qkey_viols << 6; 283
284 ((__be32 *) mailbox->buf)[2] = cpu_to_be32(cap_mask); 284 if (dev->dev->flags & MLX4_FLAG_OLD_PORT_CMDS) {
285 *(u8 *) mailbox->buf = !!reset_qkey_viols << 6;
286 ((__be32 *) mailbox->buf)[2] = cpu_to_be32(cap_mask);
287 } else {
288 ((u8 *) mailbox->buf)[3] = !!reset_qkey_viols;
289 ((__be32 *) mailbox->buf)[1] = cpu_to_be32(cap_mask);
290 }
285 291
286 err = mlx4_cmd(dev->dev, mailbox->dma, port, 0, MLX4_CMD_SET_PORT, 292 err = mlx4_cmd(dev->dev, mailbox->dma, port, 0, MLX4_CMD_SET_PORT,
287 MLX4_CMD_TIME_CLASS_B); 293 MLX4_CMD_TIME_CLASS_B);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 95d4a9d6994c..355a31f9c03c 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -603,24 +603,6 @@ int mlx4_ib_destroy_qp(struct ib_qp *qp)
603 return 0; 603 return 0;
604} 604}
605 605
606static void init_port(struct mlx4_ib_dev *dev, int port)
607{
608 struct mlx4_init_port_param param;
609 int err;
610
611 memset(&param, 0, sizeof param);
612
613 param.port_width_cap = dev->dev->caps.port_width_cap;
614 param.vl_cap = dev->dev->caps.vl_cap;
615 param.mtu = ib_mtu_enum_to_int(dev->dev->caps.mtu_cap);
616 param.max_gid = dev->dev->caps.gid_table_len;
617 param.max_pkey = dev->dev->caps.pkey_table_len;
618
619 err = mlx4_INIT_PORT(dev->dev, &param, port);
620 if (err)
621 printk(KERN_WARNING "INIT_PORT failed, return code %d.\n", err);
622}
623
624static int to_mlx4_st(enum ib_qp_type type) 606static int to_mlx4_st(enum ib_qp_type type)
625{ 607{
626 switch (type) { 608 switch (type) {
@@ -694,9 +676,9 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
694 path->counter_index = 0xff; 676 path->counter_index = 0xff;
695 677
696 if (ah->ah_flags & IB_AH_GRH) { 678 if (ah->ah_flags & IB_AH_GRH) {
697 if (ah->grh.sgid_index >= dev->dev->caps.gid_table_len) { 679 if (ah->grh.sgid_index >= dev->dev->caps.gid_table_len[port]) {
698 printk(KERN_ERR "sgid_index (%u) too large. max is %d\n", 680 printk(KERN_ERR "sgid_index (%u) too large. max is %d\n",
699 ah->grh.sgid_index, dev->dev->caps.gid_table_len - 1); 681 ah->grh.sgid_index, dev->dev->caps.gid_table_len[port] - 1);
700 return -1; 682 return -1;
701 } 683 }
702 684
@@ -812,13 +794,14 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
812 } 794 }
813 795
814 if (attr_mask & IB_QP_ALT_PATH) { 796 if (attr_mask & IB_QP_ALT_PATH) {
815 if (attr->alt_pkey_index >= dev->dev->caps.pkey_table_len)
816 return -EINVAL;
817
818 if (attr->alt_port_num == 0 || 797 if (attr->alt_port_num == 0 ||
819 attr->alt_port_num > dev->dev->caps.num_ports) 798 attr->alt_port_num > dev->dev->caps.num_ports)
820 return -EINVAL; 799 return -EINVAL;
821 800
801 if (attr->alt_pkey_index >=
802 dev->dev->caps.pkey_table_len[attr->alt_port_num])
803 return -EINVAL;
804
822 if (mlx4_set_path(dev, &attr->alt_ah_attr, &context->alt_path, 805 if (mlx4_set_path(dev, &attr->alt_ah_attr, &context->alt_path,
823 attr->alt_port_num)) 806 attr->alt_port_num))
824 return -EINVAL; 807 return -EINVAL;
@@ -949,7 +932,9 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
949 */ 932 */
950 if (is_qp0(dev, qp)) { 933 if (is_qp0(dev, qp)) {
951 if (cur_state != IB_QPS_RTR && new_state == IB_QPS_RTR) 934 if (cur_state != IB_QPS_RTR && new_state == IB_QPS_RTR)
952 init_port(dev, qp->port); 935 if (mlx4_INIT_PORT(dev->dev, qp->port))
936 printk(KERN_WARNING "INIT_PORT failed for port %d\n",
937 qp->port);
953 938
954 if (cur_state != IB_QPS_RESET && cur_state != IB_QPS_ERR && 939 if (cur_state != IB_QPS_RESET && cur_state != IB_QPS_ERR &&
955 (new_state == IB_QPS_RESET || new_state == IB_QPS_ERR)) 940 (new_state == IB_QPS_RESET || new_state == IB_QPS_ERR))
@@ -1012,16 +997,17 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1012 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask)) 997 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask))
1013 goto out; 998 goto out;
1014 999
1015 if ((attr_mask & IB_QP_PKEY_INDEX) &&
1016 attr->pkey_index >= dev->dev->caps.pkey_table_len) {
1017 goto out;
1018 }
1019
1020 if ((attr_mask & IB_QP_PORT) && 1000 if ((attr_mask & IB_QP_PORT) &&
1021 (attr->port_num == 0 || attr->port_num > dev->dev->caps.num_ports)) { 1001 (attr->port_num == 0 || attr->port_num > dev->dev->caps.num_ports)) {
1022 goto out; 1002 goto out;
1023 } 1003 }
1024 1004
1005 if (attr_mask & IB_QP_PKEY_INDEX) {
1006 int p = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
1007 if (attr->pkey_index >= dev->dev->caps.pkey_table_len[p])
1008 goto out;
1009 }
1010
1025 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC && 1011 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
1026 attr->max_rd_atomic > dev->dev->caps.max_qp_init_rdma) { 1012 attr->max_rd_atomic > dev->dev->caps.max_qp_init_rdma) {
1027 goto out; 1013 goto out;