RDMA/nes: Map MTU to IB_MTU_* and correctly report link state
authorChien Tung <chien.tin.tung@intel.com>
Sun, 6 Sep 2009 03:36:39 +0000 (20:36 -0700)
committerRoland Dreier <rolandd@cisco.com>
Sun, 6 Sep 2009 03:36:39 +0000 (20:36 -0700)
Old query_port code reports static MTU and link state values.
Instead, map actual MTU to next largest IB_MTU_* constant and
correctly report link state.

Cc: Steve Wise <swise@opengridcomputing.com>
Reported-by: Jeff Squyres <jsquyres@cisco.com>
Signed-off-by: Chien Tung <chien.tin.tung@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/nes/nes_verbs.c

index 993c1d4e0618ad11d0a25a634fe7fafa7bf648c9..a680c42d6e8cb3b72a33c5a6c707d15cc294b202 100644 (file)
@@ -667,15 +667,32 @@ static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *prop
  */
 static int nes_query_port(struct ib_device *ibdev, u8 port, struct ib_port_attr *props)
 {
+       struct nes_vnic *nesvnic = to_nesvnic(ibdev);
+       struct net_device *netdev = nesvnic->netdev;
+
        memset(props, 0, sizeof(*props));
 
-       props->max_mtu = IB_MTU_2048;
-       props->active_mtu = IB_MTU_2048;
+       props->max_mtu = IB_MTU_4096;
+
+       if (netdev->mtu  >= 4096)
+               props->active_mtu = IB_MTU_4096;
+       else if (netdev->mtu  >= 2048)
+               props->active_mtu = IB_MTU_2048;
+       else if (netdev->mtu  >= 1024)
+               props->active_mtu = IB_MTU_1024;
+       else if (netdev->mtu  >= 512)
+               props->active_mtu = IB_MTU_512;
+       else
+               props->active_mtu = IB_MTU_256;
+
        props->lid = 1;
        props->lmc = 0;
        props->sm_lid = 0;
        props->sm_sl = 0;
-       props->state = IB_PORT_ACTIVE;
+       if (nesvnic->linkup)
+               props->state = IB_PORT_ACTIVE;
+       else
+               props->state = IB_PORT_DOWN;
        props->phys_state = 0;
        props->port_cap_flags = IB_PORT_CM_SUP | IB_PORT_REINIT_SUP |
                        IB_PORT_VENDOR_CLASS_SUP | IB_PORT_BOOT_MGMT_SUP;