Skip to content

Commit 3ce4bee

Browse files
Avinash Repakagerd-rausch
authored andcommitted
RDS: IB: Include ethernet devices during initialization of active bonding
Extend RDS active bonding code to include Ethernet interfaces(RoCE links). For ethernet devices, the failover/failback needs to be between interfaces of same vlan, so substitute the pkey with vlan ID for ethernet devices. Orabug: 26096238 Signed-off-by: Avinash Repaka <[email protected]> Tested-by: Geral Gibson <[email protected]> Reviewed-by: Gerd Rausch <[email protected]> Signed-off-by: Aron Silverton <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 5cf053f commit 3ce4bee

File tree

1 file changed

+80
-32
lines changed

1 file changed

+80
-32
lines changed

net/rds/ib.c

Lines changed: 80 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,25 @@ sched_initial_failovers(unsigned int tot_devs,
20812081
trigger_delay_min_jiffies);
20822082
}
20832083

2084+
static struct rds_ib_device *rds_ib_find_device_pair(struct net_device *dev,
2085+
u8 *port_num)
2086+
{
2087+
struct net_device *real_dev = rdma_vlan_dev_real_dev(dev) ? : dev;
2088+
struct rds_ib_device *rds_ibdev;
2089+
struct ib_device *ibdev;
2090+
2091+
list_for_each_entry_rcu(rds_ibdev, &rds_ib_devices, list) {
2092+
ibdev = rds_ibdev->dev;
2093+
for (*port_num = 1; *port_num <= ibdev->phys_port_cnt;
2094+
(*port_num)++) {
2095+
if (real_dev == ibdev->get_netdev(ibdev, *port_num))
2096+
return rds_ibdev;
2097+
}
2098+
}
2099+
2100+
return NULL;
2101+
}
2102+
20842103
static int rds_ib_ip_config_init(void)
20852104
{
20862105
struct net_device *dev;
@@ -2123,38 +2142,53 @@ static int rds_ib_ip_config_init(void)
21232142
in6_dev = NULL;
21242143
tot_devs++;
21252144
/*
2126-
* Note: Enumerate all Infiniband devices
2145+
* Note: Enumerate all Infiniband and Ethernet(RoCE) devices
21272146
* that are:
21282147
* - UP
21292148
* - not part of a bond(master or slave)
21302149
*/
2131-
if ((dev->type == ARPHRD_INFINIBAND) &&
2150+
if ((dev->type == ARPHRD_INFINIBAND ||
2151+
dev->type == ARPHRD_ETHER) &&
21322152
(dev->flags & IFF_UP) &&
21332153
!(dev->flags & IFF_SLAVE) &&
21342154
!(dev->flags & IFF_MASTER) &&
21352155
(in_dev || in6_dev)) {
21362156
u16 pkey = 0;
21372157

2138-
if (ipoib_get_netdev_pkey(dev, &pkey) != 0) {
2139-
printk(KERN_ERR "RDS/IB: failed to get pkey "
2140-
"for devname %s\n", dev->name);
2158+
if (dev->type == ARPHRD_INFINIBAND) {
2159+
if (ipoib_get_netdev_pkey(dev, &pkey) != 0) {
2160+
pr_err("RDS/IB: failed to get pkey for devname %s\n",
2161+
dev->name);
2162+
}
2163+
} else {
2164+
/* Use vlan id instead of pkey for
2165+
* Ethernet(RoCE) devices
2166+
*/
2167+
pkey = rdma_vlan_dev_vlan_id(dev);
21412168
}
21422169

2143-
memcpy(&gid, dev->dev_addr + 4, sizeof gid);
2144-
2145-
tot_ibdevs++;
2146-
list_for_each_entry_rcu(rds_ibdev,
2147-
&rds_ib_devices, list) {
2148-
ret = ib_find_cached_gid(rds_ibdev->dev, &gid,
2149-
IB_GID_TYPE_IB, NULL,
2150-
&port_num, NULL);
2151-
if (!ret)
2152-
break;
2170+
if (dev->type == ARPHRD_INFINIBAND) {
2171+
memcpy(&gid, dev->dev_addr + 4, sizeof(gid));
2172+
list_for_each_entry_rcu(rds_ibdev,
2173+
&rds_ib_devices, list) {
2174+
ret = ib_find_cached_gid(rds_ibdev->dev,
2175+
&gid,
2176+
IB_GID_TYPE_IB,
2177+
NULL,
2178+
&port_num,
2179+
NULL);
2180+
if (!ret)
2181+
break;
2182+
}
2183+
} else {
2184+
rds_ibdev = rds_ib_find_device_pair(dev,
2185+
&port_num);
2186+
ret = rds_ibdev ? 0 : 1;
21532187
}
21542188

21552189
if (ret) {
2156-
pr_err("RDS/IB: netdevice %s has no associated ibdevice\n",
2157-
dev->name);
2190+
pr_info("RDS/IB: netdevice %s has no associated ibdevice\n",
2191+
dev->name);
21582192
} else {
21592193
port = rds_ib_init_port(rds_ibdev, dev,
21602194
port_num, pkey);
@@ -2166,7 +2200,7 @@ static int rds_ib_ip_config_init(void)
21662200
rds_ib_set_port6(dev, in6_dev,
21672201
port);
21682202
}
2169-
2203+
tot_ibdevs++;
21702204
}
21712205
}
21722206
if (in_dev)
@@ -2629,23 +2663,36 @@ static void rds_ib_addintf_after_initscripts(struct work_struct *_work)
26292663
(in6_dev && !list_empty(&in6_dev->addr_list))) {
26302664
u16 pkey = 0;
26312665

2632-
if (ipoib_get_netdev_pkey(ndev, &pkey) != 0) {
2633-
printk(KERN_ERR "RDS/IB: failed to get pkey "
2634-
"for devname %s\n", ndev->name);
2666+
if (ndev->type == ARPHRD_INFINIBAND) {
2667+
if (ipoib_get_netdev_pkey(ndev, &pkey) != 0) {
2668+
pr_err("RDS/IB: failed to get pkey for devname %s\n",
2669+
ndev->name);
2670+
}
2671+
} else {
2672+
/* Use vlan id instead of pkey for
2673+
* Ethernet(RoCE) devices
2674+
*/
2675+
pkey = rdma_vlan_dev_vlan_id(ndev);
26352676
}
26362677

2637-
memcpy(&gid, ndev->dev_addr + 4, sizeof gid);
2638-
list_for_each_entry_rcu(rds_ibdev,
2639-
&rds_ib_devices, list) {
2640-
ret = ib_find_cached_gid(rds_ibdev->dev, &gid,
2641-
IB_GID_TYPE_IB, NULL,
2642-
&port_num, NULL);
2643-
if (!ret)
2644-
break;
2678+
if (ndev->type == ARPHRD_INFINIBAND) {
2679+
memcpy(&gid, ndev->dev_addr + 4, sizeof(gid));
2680+
list_for_each_entry_rcu(rds_ibdev,
2681+
&rds_ib_devices, list) {
2682+
ret = ib_find_cached_gid(rds_ibdev->dev, &gid,
2683+
IB_GID_TYPE_IB, NULL,
2684+
&port_num, NULL);
2685+
if (!ret)
2686+
break;
2687+
}
2688+
} else {
2689+
rds_ibdev = rds_ib_find_device_pair(ndev, &port_num);
2690+
ret = rds_ibdev ? 0 : 1;
26452691
}
2692+
26462693
if (ret) {
2647-
pr_err("RDS/IB: netdevice %s has no associated ibdevice\n",
2648-
ndev->name);
2694+
pr_info("RDS/IB: netdevice %s has no associated ibdevice\n",
2695+
ndev->name);
26492696
} else {
26502697
port = rds_ib_init_port(rds_ibdev, ndev,
26512698
port_num, pkey);
@@ -2785,7 +2832,8 @@ static int rds_ib_netdev_callback(struct notifier_block *self, unsigned long eve
27852832
* structures.
27862833
*/
27872834
if (!port && event == NETDEV_UP) {
2788-
if ((ndev->type == ARPHRD_INFINIBAND) &&
2835+
if ((ndev->type == ARPHRD_INFINIBAND ||
2836+
ndev->type == ARPHRD_ETHER) &&
27892837
(ndev->flags & IFF_UP) &&
27902838
!(ndev->flags & IFF_SLAVE) &&
27912839
!(ndev->flags & IFF_MASTER)) {

0 commit comments

Comments
 (0)