RDMA: Use ib_gid_attr during GID modification
Now that ib_gid_attr contains device, port and index, simplify the provider APIs add_gid() and del_gid() to use device, port and index fields from the ib_gid_attr attributes structure. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:

committed by
Jason Gunthorpe

orang tua
3e44e0ee08
melakukan
414448d249
@@ -246,14 +246,11 @@ static int mlx4_ib_update_gids(struct gid_entry *gids,
|
||||
return mlx4_ib_update_gids_v1(gids, ibdev, port_num);
|
||||
}
|
||||
|
||||
static int mlx4_ib_add_gid(struct ib_device *device,
|
||||
u8 port_num,
|
||||
unsigned int index,
|
||||
const union ib_gid *gid,
|
||||
static int mlx4_ib_add_gid(const union ib_gid *gid,
|
||||
const struct ib_gid_attr *attr,
|
||||
void **context)
|
||||
{
|
||||
struct mlx4_ib_dev *ibdev = to_mdev(device);
|
||||
struct mlx4_ib_dev *ibdev = to_mdev(attr->device);
|
||||
struct mlx4_ib_iboe *iboe = &ibdev->iboe;
|
||||
struct mlx4_port_gid_table *port_gid_table;
|
||||
int free = -1, found = -1;
|
||||
@@ -262,16 +259,16 @@ static int mlx4_ib_add_gid(struct ib_device *device,
|
||||
int i;
|
||||
struct gid_entry *gids = NULL;
|
||||
|
||||
if (!rdma_cap_roce_gid_table(device, port_num))
|
||||
if (!rdma_cap_roce_gid_table(attr->device, attr->port_num))
|
||||
return -EINVAL;
|
||||
|
||||
if (port_num > MLX4_MAX_PORTS)
|
||||
if (attr->port_num > MLX4_MAX_PORTS)
|
||||
return -EINVAL;
|
||||
|
||||
if (!context)
|
||||
return -EINVAL;
|
||||
|
||||
port_gid_table = &iboe->gids[port_num - 1];
|
||||
port_gid_table = &iboe->gids[attr->port_num - 1];
|
||||
spin_lock_bh(&iboe->lock);
|
||||
for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i) {
|
||||
if (!memcmp(&port_gid_table->gids[i].gid, gid, sizeof(*gid)) &&
|
||||
@@ -318,33 +315,30 @@ static int mlx4_ib_add_gid(struct ib_device *device,
|
||||
spin_unlock_bh(&iboe->lock);
|
||||
|
||||
if (!ret && hw_update) {
|
||||
ret = mlx4_ib_update_gids(gids, ibdev, port_num);
|
||||
ret = mlx4_ib_update_gids(gids, ibdev, attr->port_num);
|
||||
kfree(gids);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mlx4_ib_del_gid(struct ib_device *device,
|
||||
u8 port_num,
|
||||
unsigned int index,
|
||||
void **context)
|
||||
static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context)
|
||||
{
|
||||
struct gid_cache_context *ctx = *context;
|
||||
struct mlx4_ib_dev *ibdev = to_mdev(device);
|
||||
struct mlx4_ib_dev *ibdev = to_mdev(attr->device);
|
||||
struct mlx4_ib_iboe *iboe = &ibdev->iboe;
|
||||
struct mlx4_port_gid_table *port_gid_table;
|
||||
int ret = 0;
|
||||
int hw_update = 0;
|
||||
struct gid_entry *gids = NULL;
|
||||
|
||||
if (!rdma_cap_roce_gid_table(device, port_num))
|
||||
if (!rdma_cap_roce_gid_table(attr->device, attr->port_num))
|
||||
return -EINVAL;
|
||||
|
||||
if (port_num > MLX4_MAX_PORTS)
|
||||
if (attr->port_num > MLX4_MAX_PORTS)
|
||||
return -EINVAL;
|
||||
|
||||
port_gid_table = &iboe->gids[port_num - 1];
|
||||
port_gid_table = &iboe->gids[attr->port_num - 1];
|
||||
spin_lock_bh(&iboe->lock);
|
||||
if (ctx) {
|
||||
ctx->refcount--;
|
||||
@@ -376,7 +370,7 @@ static int mlx4_ib_del_gid(struct ib_device *device,
|
||||
spin_unlock_bh(&iboe->lock);
|
||||
|
||||
if (!ret && hw_update) {
|
||||
ret = mlx4_ib_update_gids(gids, ibdev, port_num);
|
||||
ret = mlx4_ib_update_gids(gids, ibdev, attr->port_num);
|
||||
kfree(gids);
|
||||
}
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user