Merge branch 'for-2.6.24' of master.kernel.org:/pub/scm/linux/kernel/git/jwboyer...
[pandora-kernel.git] / drivers / infiniband / hw / ehca / ehca_hca.c
index bbd3c6a..5bd7b59 100644 (file)
@@ -77,38 +77,43 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
        }
 
        memset(props, 0, sizeof(struct ib_device_attr));
+       props->page_size_cap   = shca->hca_cap_mr_pgsize;
        props->fw_ver          = rblock->hw_ver;
        props->max_mr_size     = rblock->max_mr_size;
        props->vendor_id       = rblock->vendor_id >> 8;
        props->vendor_part_id  = rblock->vendor_part_id >> 16;
        props->hw_ver          = rblock->hw_ver;
-       props->max_qp          = min_t(int, rblock->max_qp, INT_MAX);
-       props->max_qp_wr       = min_t(int, rblock->max_wqes_wq, INT_MAX);
-       props->max_sge         = min_t(int, rblock->max_sge, INT_MAX);
-       props->max_sge_rd      = min_t(int, rblock->max_sge_rd, INT_MAX);
-       props->max_cq          = min_t(int, rblock->max_cq, INT_MAX);
-       props->max_cqe         = min_t(int, rblock->max_cqe, INT_MAX);
-       props->max_mr          = min_t(int, rblock->max_mr, INT_MAX);
-       props->max_mw          = min_t(int, rblock->max_mw, INT_MAX);
-       props->max_pd          = min_t(int, rblock->max_pd, INT_MAX);
-       props->max_ah          = min_t(int, rblock->max_ah, INT_MAX);
-       props->max_fmr         = min_t(int, rblock->max_mr, INT_MAX);
-       props->max_srq         = 0;
-       props->max_srq_wr      = 0;
-       props->max_srq_sge     = 0;
+       props->max_qp          = min_t(unsigned, rblock->max_qp, INT_MAX);
+       props->max_qp_wr       = min_t(unsigned, rblock->max_wqes_wq, INT_MAX);
+       props->max_sge         = min_t(unsigned, rblock->max_sge, INT_MAX);
+       props->max_sge_rd      = min_t(unsigned, rblock->max_sge_rd, INT_MAX);
+       props->max_cq          = min_t(unsigned, rblock->max_cq, INT_MAX);
+       props->max_cqe         = min_t(unsigned, rblock->max_cqe, INT_MAX);
+       props->max_mr          = min_t(unsigned, rblock->max_mr, INT_MAX);
+       props->max_mw          = min_t(unsigned, rblock->max_mw, INT_MAX);
+       props->max_pd          = min_t(unsigned, rblock->max_pd, INT_MAX);
+       props->max_ah          = min_t(unsigned, rblock->max_ah, INT_MAX);
+       props->max_fmr         = min_t(unsigned, rblock->max_mr, INT_MAX);
+
+       if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) {
+               props->max_srq         = props->max_qp;
+               props->max_srq_wr      = props->max_qp_wr;
+               props->max_srq_sge     = 3;
+       }
+
        props->max_pkeys       = 16;
        props->local_ca_ack_delay
                = rblock->local_ca_ack_delay;
        props->max_raw_ipv6_qp
-               = min_t(int, rblock->max_raw_ipv6_qp, INT_MAX);
+               = min_t(unsigned, rblock->max_raw_ipv6_qp, INT_MAX);
        props->max_raw_ethy_qp
-               = min_t(int, rblock->max_raw_ethy_qp, INT_MAX);
+               = min_t(unsigned, rblock->max_raw_ethy_qp, INT_MAX);
        props->max_mcast_grp
-               = min_t(int, rblock->max_mcast_grp, INT_MAX);
+               = min_t(unsigned, rblock->max_mcast_grp, INT_MAX);
        props->max_mcast_qp_attach
-               = min_t(int, rblock->max_mcast_qp_attach, INT_MAX);
+               = min_t(unsigned, rblock->max_mcast_qp_attach, INT_MAX);
        props->max_total_mcast_qp_attach
-               = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX);
+               = min_t(unsigned, rblock->max_total_mcast_qp_attach, INT_MAX);
 
        /* translate device capabilities */
        props->device_cap_flags = IB_DEVICE_SYS_IMAGE_GUID |
@@ -127,6 +132,7 @@ int ehca_query_port(struct ib_device *ibdev,
                    u8 port, struct ib_port_attr *props)
 {
        int ret = 0;
+       u64 h_ret;
        struct ehca_shca *shca = container_of(ibdev, struct ehca_shca,
                                              ib_device);
        struct hipz_query_port *rblock;
@@ -137,14 +143,14 @@ int ehca_query_port(struct ib_device *ibdev,
                return -ENOMEM;
        }
 
-       if (hipz_h_query_port(shca->ipz_hca_handle, port, rblock) != H_SUCCESS) {
+       h_ret = hipz_h_query_port(shca->ipz_hca_handle, port, rblock);
+       if (h_ret != H_SUCCESS) {
                ehca_err(&shca->ib_device, "Can't query port properties");
                ret = -EINVAL;
                goto query_port1;
        }
 
        memset(props, 0, sizeof(struct ib_port_attr));
-       props->state = rblock->state;
 
        switch (rblock->max_mtu) {
        case 0x1:
@@ -181,11 +187,20 @@ int ehca_query_port(struct ib_device *ibdev,
        props->subnet_timeout  = rblock->subnet_timeout;
        props->init_type_reply = rblock->init_type_reply;
 
-       props->active_width    = IB_WIDTH_12X;
-       props->active_speed    = 0x1;
-
-       /* at the moment (logical) link state is always LINK_UP */
-       props->phys_state      = 0x5;
+       if (rblock->state && rblock->phys_width) {
+               props->phys_state      = rblock->phys_pstate;
+               props->state           = rblock->phys_state;
+               props->active_width    = rblock->phys_width;
+               props->active_speed    = rblock->phys_speed;
+       } else {
+               /* old firmware releases don't report physical
+                * port info, so use default values
+                */
+               props->phys_state      = 5;
+               props->state           = rblock->state;
+               props->active_width    = IB_WIDTH_12X;
+               props->active_speed    = 0x1;
+       }
 
 query_port1:
        ehca_free_fw_ctrlblock(rblock);
@@ -197,6 +212,7 @@ int ehca_query_sma_attr(struct ehca_shca *shca,
                        u8 port, struct ehca_sma_attr *attr)
 {
        int ret = 0;
+       u64 h_ret;
        struct hipz_query_port *rblock;
 
        rblock = ehca_alloc_fw_ctrlblock(GFP_ATOMIC);
@@ -205,7 +221,8 @@ int ehca_query_sma_attr(struct ehca_shca *shca,
                return -ENOMEM;
        }
 
-       if (hipz_h_query_port(shca->ipz_hca_handle, port, rblock) != H_SUCCESS) {
+       h_ret = hipz_h_query_port(shca->ipz_hca_handle, port, rblock);
+       if (h_ret != H_SUCCESS) {
                ehca_err(&shca->ib_device, "Can't query port properties");
                ret = -EINVAL;
                goto query_sma_attr1;
@@ -230,9 +247,11 @@ query_sma_attr1:
 int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
 {
        int ret = 0;
-       struct ehca_shca *shca = container_of(ibdev, struct ehca_shca, ib_device);
+       u64 h_ret;
+       struct ehca_shca *shca;
        struct hipz_query_port *rblock;
 
+       shca = container_of(ibdev, struct ehca_shca, ib_device);
        if (index > 16) {
                ehca_err(&shca->ib_device, "Invalid index: %x.", index);
                return -EINVAL;
@@ -244,7 +263,8 @@ int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
                return -ENOMEM;
        }
 
-       if (hipz_h_query_port(shca->ipz_hca_handle, port, rblock) != H_SUCCESS) {
+       h_ret = hipz_h_query_port(shca->ipz_hca_handle, port, rblock);
+       if (h_ret != H_SUCCESS) {
                ehca_err(&shca->ib_device, "Can't query port properties");
                ret = -EINVAL;
                goto query_pkey1;
@@ -262,6 +282,7 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port,
                   int index, union ib_gid *gid)
 {
        int ret = 0;
+       u64 h_ret;
        struct ehca_shca *shca = container_of(ibdev, struct ehca_shca,
                                              ib_device);
        struct hipz_query_port *rblock;
@@ -277,7 +298,8 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port,
                return -ENOMEM;
        }
 
-       if (hipz_h_query_port(shca->ipz_hca_handle, port, rblock) != H_SUCCESS) {
+       h_ret = hipz_h_query_port(shca->ipz_hca_handle, port, rblock);
+       if (h_ret != H_SUCCESS) {
                ehca_err(&shca->ib_device, "Can't query port properties");
                ret = -EINVAL;
                goto query_gid1;
@@ -302,11 +324,12 @@ int ehca_modify_port(struct ib_device *ibdev,
                     struct ib_port_modify *props)
 {
        int ret = 0;
-       struct ehca_shca *shca = container_of(ibdev, struct ehca_shca, ib_device);
+       struct ehca_shca *shca;
        struct hipz_query_port *rblock;
        u32 cap;
        u64 hret;
 
+       shca = container_of(ibdev, struct ehca_shca, ib_device);
        if ((props->set_port_cap_mask | props->clr_port_cap_mask)
            & ~allowed_port_caps) {
                ehca_err(&shca->ib_device, "Non-changeable bits set in masks  "
@@ -325,7 +348,8 @@ int ehca_modify_port(struct ib_device *ibdev,
                goto modify_port1;
        }
 
-       if (hipz_h_query_port(shca->ipz_hca_handle, port, rblock) != H_SUCCESS) {
+       hret = hipz_h_query_port(shca->ipz_hca_handle, port, rblock);
+       if (hret != H_SUCCESS) {
                ehca_err(&shca->ib_device, "Can't query port properties");
                ret = -EINVAL;
                goto modify_port2;
@@ -337,7 +361,8 @@ int ehca_modify_port(struct ib_device *ibdev,
        hret = hipz_h_modify_port(shca->ipz_hca_handle, port,
                                  cap, props->init_type, port_modify_mask);
        if (hret != H_SUCCESS) {
-               ehca_err(&shca->ib_device, "Modify port failed  hret=%lx", hret);
+               ehca_err(&shca->ib_device, "Modify port failed  h_ret=%li",
+                        hret);
                ret = -EINVAL;
        }