Skip to content

Commit 7ab1a2b

Browse files
Steve WiseRoland Dreier
authored andcommitted
RDMA/cxgb3: Report correct port state and MTU
Signed-off-by: Steve Wise <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 210af91 commit 7ab1a2b

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

drivers/infiniband/hw/cxgb3/iwch_provider.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <linux/spinlock.h>
4141
#include <linux/ethtool.h>
4242
#include <linux/rtnetlink.h>
43+
#include <linux/inetdevice.h>
4344

4445
#include <asm/io.h>
4546
#include <asm/irq.h>
@@ -1152,12 +1153,39 @@ static int iwch_query_device(struct ib_device *ibdev,
11521153
static int iwch_query_port(struct ib_device *ibdev,
11531154
u8 port, struct ib_port_attr *props)
11541155
{
1156+
struct iwch_dev *dev;
1157+
struct net_device *netdev;
1158+
struct in_device *inetdev;
1159+
11551160
PDBG("%s ibdev %p\n", __func__, ibdev);
11561161

1162+
dev = to_iwch_dev(ibdev);
1163+
netdev = dev->rdev.port_info.lldevs[port-1];
1164+
11571165
memset(props, 0, sizeof(struct ib_port_attr));
11581166
props->max_mtu = IB_MTU_4096;
1159-
props->active_mtu = IB_MTU_2048;
1160-
props->state = IB_PORT_ACTIVE;
1167+
if (netdev->mtu >= 4096)
1168+
props->active_mtu = IB_MTU_4096;
1169+
else if (netdev->mtu >= 2048)
1170+
props->active_mtu = IB_MTU_2048;
1171+
else if (netdev->mtu >= 1024)
1172+
props->active_mtu = IB_MTU_1024;
1173+
else if (netdev->mtu >= 512)
1174+
props->active_mtu = IB_MTU_512;
1175+
else
1176+
props->active_mtu = IB_MTU_256;
1177+
1178+
if (!netif_carrier_ok(netdev))
1179+
props->state = IB_PORT_DOWN;
1180+
else {
1181+
inetdev = in_dev_get(netdev);
1182+
if (inetdev->ifa_list)
1183+
props->state = IB_PORT_ACTIVE;
1184+
else
1185+
props->state = IB_PORT_INIT;
1186+
in_dev_put(inetdev);
1187+
}
1188+
11611189
props->port_cap_flags =
11621190
IB_PORT_CM_SUP |
11631191
IB_PORT_SNMP_TUNNEL_SUP |

0 commit comments

Comments
 (0)