|
40 | 40 | #include <linux/spinlock.h>
|
41 | 41 | #include <linux/ethtool.h>
|
42 | 42 | #include <linux/rtnetlink.h>
|
| 43 | +#include <linux/inetdevice.h> |
43 | 44 |
|
44 | 45 | #include <asm/io.h>
|
45 | 46 | #include <asm/irq.h>
|
@@ -1152,12 +1153,39 @@ static int iwch_query_device(struct ib_device *ibdev,
|
1152 | 1153 | static int iwch_query_port(struct ib_device *ibdev,
|
1153 | 1154 | u8 port, struct ib_port_attr *props)
|
1154 | 1155 | {
|
| 1156 | + struct iwch_dev *dev; |
| 1157 | + struct net_device *netdev; |
| 1158 | + struct in_device *inetdev; |
| 1159 | + |
1155 | 1160 | PDBG("%s ibdev %p\n", __func__, ibdev);
|
1156 | 1161 |
|
| 1162 | + dev = to_iwch_dev(ibdev); |
| 1163 | + netdev = dev->rdev.port_info.lldevs[port-1]; |
| 1164 | + |
1157 | 1165 | memset(props, 0, sizeof(struct ib_port_attr));
|
1158 | 1166 | 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 | + |
1161 | 1189 | props->port_cap_flags =
|
1162 | 1190 | IB_PORT_CM_SUP |
|
1163 | 1191 | IB_PORT_SNMP_TUNNEL_SUP |
|
|
0 commit comments