Skip to content

Commit 1fb7f89

Browse files
mark-blochjgunthorpe
authored andcommitted
RDMA: Support more than 255 rdma ports
Current code uses many different types when dealing with a port of a RDMA device: u8, unsigned int and u32. Switch to u32 to clean up the logic. This allows us to make (at least) the core view consistent and use the same type. Unfortunately not all places can be converted. Many uverbs functions expect port to be u8 so keep those places in order not to break UAPIs. HW/Spec defined values must also not be changed. With the switch to u32 we now can support devices with more than 255 ports. U32_MAX is reserved to make control logic a bit easier to deal with. As a device with U32_MAX ports probably isn't going to happen any time soon this seems like a non issue. When a device with more than 255 ports is created uverbs will report the RDMA device as having 255 ports as this is the max currently supported. The verbs interface is not changed yet because the IBTA spec limits the port size in too many places to be u8 and all applications that relies in verbs won't be able to cope with this change. At this stage, we are extending the interfaces that are using vendor channel solely Once the limitation is lifted mlx5 in switchdev mode will be able to have thousands of SFs created by the device. As the only instance of an RDMA device that reports more than 255 ports will be a representor device and it exposes itself as a RAW Ethernet only device CM/MAD/IPoIB and other ULPs aren't effected by this change and their sysfs/interfaces that are exposes to userspace can remain unchanged. While here cleanup some alignment issues and remove unneeded sanity checks (mainly in rdmavt), Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Bloch <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 847d19a commit 1fb7f89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+776
-776
lines changed

drivers/infiniband/core/cache.c

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ struct ib_gid_table {
121121
u32 default_gid_indices;
122122
};
123123

124-
static void dispatch_gid_change_event(struct ib_device *ib_dev, u8 port)
124+
static void dispatch_gid_change_event(struct ib_device *ib_dev, u32 port)
125125
{
126126
struct ib_event event;
127127

@@ -197,7 +197,7 @@ int ib_cache_gid_parse_type_str(const char *buf)
197197
}
198198
EXPORT_SYMBOL(ib_cache_gid_parse_type_str);
199199

200-
static struct ib_gid_table *rdma_gid_table(struct ib_device *device, u8 port)
200+
static struct ib_gid_table *rdma_gid_table(struct ib_device *device, u32 port)
201201
{
202202
return device->port_data[port].cache.gid;
203203
}
@@ -237,10 +237,10 @@ static void put_gid_ndev(struct rcu_head *head)
237237
static void free_gid_entry_locked(struct ib_gid_table_entry *entry)
238238
{
239239
struct ib_device *device = entry->attr.device;
240-
u8 port_num = entry->attr.port_num;
240+
u32 port_num = entry->attr.port_num;
241241
struct ib_gid_table *table = rdma_gid_table(device, port_num);
242242

243-
dev_dbg(&device->dev, "%s port=%d index=%d gid %pI6\n", __func__,
243+
dev_dbg(&device->dev, "%s port=%u index=%d gid %pI6\n", __func__,
244244
port_num, entry->attr.index, entry->attr.gid.raw);
245245

246246
write_lock_irq(&table->rwlock);
@@ -282,7 +282,7 @@ static void free_gid_work(struct work_struct *work)
282282
struct ib_gid_table_entry *entry =
283283
container_of(work, struct ib_gid_table_entry, del_work);
284284
struct ib_device *device = entry->attr.device;
285-
u8 port_num = entry->attr.port_num;
285+
u32 port_num = entry->attr.port_num;
286286
struct ib_gid_table *table = rdma_gid_table(device, port_num);
287287

288288
mutex_lock(&table->lock);
@@ -379,15 +379,15 @@ static int add_roce_gid(struct ib_gid_table_entry *entry)
379379
* @ix: GID entry index to delete
380380
*
381381
*/
382-
static void del_gid(struct ib_device *ib_dev, u8 port,
382+
static void del_gid(struct ib_device *ib_dev, u32 port,
383383
struct ib_gid_table *table, int ix)
384384
{
385385
struct roce_gid_ndev_storage *ndev_storage;
386386
struct ib_gid_table_entry *entry;
387387

388388
lockdep_assert_held(&table->lock);
389389

390-
dev_dbg(&ib_dev->dev, "%s port=%d index=%d gid %pI6\n", __func__, port,
390+
dev_dbg(&ib_dev->dev, "%s port=%u index=%d gid %pI6\n", __func__, port,
391391
ix, table->data_vec[ix]->attr.gid.raw);
392392

393393
write_lock_irq(&table->rwlock);
@@ -543,7 +543,7 @@ static void make_default_gid(struct net_device *dev, union ib_gid *gid)
543543
addrconf_ifid_eui48(&gid->raw[8], dev);
544544
}
545545

546-
static int __ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
546+
static int __ib_cache_gid_add(struct ib_device *ib_dev, u32 port,
547547
union ib_gid *gid, struct ib_gid_attr *attr,
548548
unsigned long mask, bool default_gid)
549549
{
@@ -587,7 +587,7 @@ static int __ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
587587
return ret;
588588
}
589589

590-
int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
590+
int ib_cache_gid_add(struct ib_device *ib_dev, u32 port,
591591
union ib_gid *gid, struct ib_gid_attr *attr)
592592
{
593593
unsigned long mask = GID_ATTR_FIND_MASK_GID |
@@ -598,7 +598,7 @@ int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
598598
}
599599

600600
static int
601-
_ib_cache_gid_del(struct ib_device *ib_dev, u8 port,
601+
_ib_cache_gid_del(struct ib_device *ib_dev, u32 port,
602602
union ib_gid *gid, struct ib_gid_attr *attr,
603603
unsigned long mask, bool default_gid)
604604
{
@@ -627,7 +627,7 @@ _ib_cache_gid_del(struct ib_device *ib_dev, u8 port,
627627
return ret;
628628
}
629629

630-
int ib_cache_gid_del(struct ib_device *ib_dev, u8 port,
630+
int ib_cache_gid_del(struct ib_device *ib_dev, u32 port,
631631
union ib_gid *gid, struct ib_gid_attr *attr)
632632
{
633633
unsigned long mask = GID_ATTR_FIND_MASK_GID |
@@ -638,7 +638,7 @@ int ib_cache_gid_del(struct ib_device *ib_dev, u8 port,
638638
return _ib_cache_gid_del(ib_dev, port, gid, attr, mask, false);
639639
}
640640

641-
int ib_cache_gid_del_all_netdev_gids(struct ib_device *ib_dev, u8 port,
641+
int ib_cache_gid_del_all_netdev_gids(struct ib_device *ib_dev, u32 port,
642642
struct net_device *ndev)
643643
{
644644
struct ib_gid_table *table;
@@ -683,7 +683,7 @@ const struct ib_gid_attr *
683683
rdma_find_gid_by_port(struct ib_device *ib_dev,
684684
const union ib_gid *gid,
685685
enum ib_gid_type gid_type,
686-
u8 port, struct net_device *ndev)
686+
u32 port, struct net_device *ndev)
687687
{
688688
int local_index;
689689
struct ib_gid_table *table;
@@ -734,7 +734,7 @@ EXPORT_SYMBOL(rdma_find_gid_by_port);
734734
*
735735
*/
736736
const struct ib_gid_attr *rdma_find_gid_by_filter(
737-
struct ib_device *ib_dev, const union ib_gid *gid, u8 port,
737+
struct ib_device *ib_dev, const union ib_gid *gid, u32 port,
738738
bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,
739739
void *),
740740
void *context)
@@ -818,7 +818,7 @@ static void release_gid_table(struct ib_device *device,
818818
kfree(table);
819819
}
820820

821-
static void cleanup_gid_table_port(struct ib_device *ib_dev, u8 port,
821+
static void cleanup_gid_table_port(struct ib_device *ib_dev, u32 port,
822822
struct ib_gid_table *table)
823823
{
824824
int i;
@@ -834,7 +834,7 @@ static void cleanup_gid_table_port(struct ib_device *ib_dev, u8 port,
834834
mutex_unlock(&table->lock);
835835
}
836836

837-
void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port,
837+
void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u32 port,
838838
struct net_device *ndev,
839839
unsigned long gid_type_mask,
840840
enum ib_cache_gid_default_mode mode)
@@ -867,7 +867,7 @@ void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port,
867867
}
868868
}
869869

870-
static void gid_table_reserve_default(struct ib_device *ib_dev, u8 port,
870+
static void gid_table_reserve_default(struct ib_device *ib_dev, u32 port,
871871
struct ib_gid_table *table)
872872
{
873873
unsigned int i;
@@ -884,7 +884,7 @@ static void gid_table_reserve_default(struct ib_device *ib_dev, u8 port,
884884

885885
static void gid_table_release_one(struct ib_device *ib_dev)
886886
{
887-
unsigned int p;
887+
u32 p;
888888

889889
rdma_for_each_port (ib_dev, p) {
890890
release_gid_table(ib_dev, ib_dev->port_data[p].cache.gid);
@@ -895,7 +895,7 @@ static void gid_table_release_one(struct ib_device *ib_dev)
895895
static int _gid_table_setup_one(struct ib_device *ib_dev)
896896
{
897897
struct ib_gid_table *table;
898-
unsigned int rdma_port;
898+
u32 rdma_port;
899899

900900
rdma_for_each_port (ib_dev, rdma_port) {
901901
table = alloc_gid_table(
@@ -915,7 +915,7 @@ static int _gid_table_setup_one(struct ib_device *ib_dev)
915915

916916
static void gid_table_cleanup_one(struct ib_device *ib_dev)
917917
{
918-
unsigned int p;
918+
u32 p;
919919

920920
rdma_for_each_port (ib_dev, p)
921921
cleanup_gid_table_port(ib_dev, p,
@@ -950,7 +950,7 @@ static int gid_table_setup_one(struct ib_device *ib_dev)
950950
* Returns 0 on success or appropriate error code.
951951
*
952952
*/
953-
int rdma_query_gid(struct ib_device *device, u8 port_num,
953+
int rdma_query_gid(struct ib_device *device, u32 port_num,
954954
int index, union ib_gid *gid)
955955
{
956956
struct ib_gid_table *table;
@@ -1014,7 +1014,7 @@ const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
10141014
unsigned long mask = GID_ATTR_FIND_MASK_GID |
10151015
GID_ATTR_FIND_MASK_GID_TYPE;
10161016
struct ib_gid_attr gid_attr_val = {.ndev = ndev, .gid_type = gid_type};
1017-
unsigned int p;
1017+
u32 p;
10181018

10191019
if (ndev)
10201020
mask |= GID_ATTR_FIND_MASK_NETDEV;
@@ -1043,7 +1043,7 @@ const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
10431043
EXPORT_SYMBOL(rdma_find_gid);
10441044

10451045
int ib_get_cached_pkey(struct ib_device *device,
1046-
u8 port_num,
1046+
u32 port_num,
10471047
int index,
10481048
u16 *pkey)
10491049
{
@@ -1069,9 +1069,8 @@ int ib_get_cached_pkey(struct ib_device *device,
10691069
}
10701070
EXPORT_SYMBOL(ib_get_cached_pkey);
10711071

1072-
int ib_get_cached_subnet_prefix(struct ib_device *device,
1073-
u8 port_num,
1074-
u64 *sn_pfx)
1072+
int ib_get_cached_subnet_prefix(struct ib_device *device, u32 port_num,
1073+
u64 *sn_pfx)
10751074
{
10761075
unsigned long flags;
10771076

@@ -1086,10 +1085,8 @@ int ib_get_cached_subnet_prefix(struct ib_device *device,
10861085
}
10871086
EXPORT_SYMBOL(ib_get_cached_subnet_prefix);
10881087

1089-
int ib_find_cached_pkey(struct ib_device *device,
1090-
u8 port_num,
1091-
u16 pkey,
1092-
u16 *index)
1088+
int ib_find_cached_pkey(struct ib_device *device, u32 port_num,
1089+
u16 pkey, u16 *index)
10931090
{
10941091
struct ib_pkey_cache *cache;
10951092
unsigned long flags;
@@ -1132,10 +1129,8 @@ int ib_find_cached_pkey(struct ib_device *device,
11321129
}
11331130
EXPORT_SYMBOL(ib_find_cached_pkey);
11341131

1135-
int ib_find_exact_cached_pkey(struct ib_device *device,
1136-
u8 port_num,
1137-
u16 pkey,
1138-
u16 *index)
1132+
int ib_find_exact_cached_pkey(struct ib_device *device, u32 port_num,
1133+
u16 pkey, u16 *index)
11391134
{
11401135
struct ib_pkey_cache *cache;
11411136
unsigned long flags;
@@ -1169,9 +1164,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
11691164
}
11701165
EXPORT_SYMBOL(ib_find_exact_cached_pkey);
11711166

1172-
int ib_get_cached_lmc(struct ib_device *device,
1173-
u8 port_num,
1174-
u8 *lmc)
1167+
int ib_get_cached_lmc(struct ib_device *device, u32 port_num, u8 *lmc)
11751168
{
11761169
unsigned long flags;
11771170
int ret = 0;
@@ -1187,8 +1180,7 @@ int ib_get_cached_lmc(struct ib_device *device,
11871180
}
11881181
EXPORT_SYMBOL(ib_get_cached_lmc);
11891182

1190-
int ib_get_cached_port_state(struct ib_device *device,
1191-
u8 port_num,
1183+
int ib_get_cached_port_state(struct ib_device *device, u32 port_num,
11921184
enum ib_port_state *port_state)
11931185
{
11941186
unsigned long flags;
@@ -1222,7 +1214,7 @@ EXPORT_SYMBOL(ib_get_cached_port_state);
12221214
* code.
12231215
*/
12241216
const struct ib_gid_attr *
1225-
rdma_get_gid_attr(struct ib_device *device, u8 port_num, int index)
1217+
rdma_get_gid_attr(struct ib_device *device, u32 port_num, int index)
12261218
{
12271219
const struct ib_gid_attr *attr = ERR_PTR(-ENODATA);
12281220
struct ib_gid_table *table;
@@ -1263,7 +1255,7 @@ ssize_t rdma_query_gid_table(struct ib_device *device,
12631255
const struct ib_gid_attr *gid_attr;
12641256
ssize_t num_entries = 0, ret;
12651257
struct ib_gid_table *table;
1266-
unsigned int port_num, i;
1258+
u32 port_num, i;
12671259
struct net_device *ndev;
12681260
unsigned long flags;
12691261

@@ -1361,7 +1353,7 @@ struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr)
13611353
container_of(attr, struct ib_gid_table_entry, attr);
13621354
struct ib_device *device = entry->attr.device;
13631355
struct net_device *ndev = ERR_PTR(-EINVAL);
1364-
u8 port_num = entry->attr.port_num;
1356+
u32 port_num = entry->attr.port_num;
13651357
struct ib_gid_table *table;
13661358
unsigned long flags;
13671359
bool valid;
@@ -1441,7 +1433,7 @@ int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
14411433
EXPORT_SYMBOL(rdma_read_gid_l2_fields);
14421434

14431435
static int config_non_roce_gid_cache(struct ib_device *device,
1444-
u8 port, int gid_tbl_len)
1436+
u32 port, int gid_tbl_len)
14451437
{
14461438
struct ib_gid_attr gid_attr = {};
14471439
struct ib_gid_table *table;
@@ -1472,7 +1464,7 @@ static int config_non_roce_gid_cache(struct ib_device *device,
14721464
}
14731465

14741466
static int
1475-
ib_cache_update(struct ib_device *device, u8 port, bool enforce_security)
1467+
ib_cache_update(struct ib_device *device, u32 port, bool enforce_security)
14761468
{
14771469
struct ib_port_attr *tprops = NULL;
14781470
struct ib_pkey_cache *pkey_cache = NULL, *old_pkey_cache;
@@ -1621,7 +1613,7 @@ EXPORT_SYMBOL(ib_dispatch_event);
16211613

16221614
int ib_cache_setup_one(struct ib_device *device)
16231615
{
1624-
unsigned int p;
1616+
u32 p;
16251617
int err;
16261618

16271619
rwlock_init(&device->cache_lock);
@@ -1641,7 +1633,7 @@ int ib_cache_setup_one(struct ib_device *device)
16411633

16421634
void ib_cache_release_one(struct ib_device *device)
16431635
{
1644-
unsigned int p;
1636+
u32 p;
16451637

16461638
/*
16471639
* The release function frees all the cache elements.

drivers/infiniband/core/cm.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static struct attribute *cm_counter_default_attrs[] = {
202202
struct cm_port {
203203
struct cm_device *cm_dev;
204204
struct ib_mad_agent *mad_agent;
205-
u8 port_num;
205+
u32 port_num;
206206
struct list_head cm_priv_prim_list;
207207
struct list_head cm_priv_altr_list;
208208
struct cm_counter_group counter_group[CM_COUNTER_GROUPS];
@@ -1631,7 +1631,7 @@ static bool cm_req_has_alt_path(struct cm_req_msg *req_msg)
16311631
req_msg))));
16321632
}
16331633

1634-
static void cm_path_set_rec_type(struct ib_device *ib_device, u8 port_num,
1634+
static void cm_path_set_rec_type(struct ib_device *ib_device, u32 port_num,
16351635
struct sa_path_rec *path, union ib_gid *gid)
16361636
{
16371637
if (ib_is_opa_gid(gid) && rdma_cap_opa_ah(ib_device, port_num))
@@ -1750,7 +1750,7 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
17501750
static u16 cm_get_bth_pkey(struct cm_work *work)
17511751
{
17521752
struct ib_device *ib_dev = work->port->cm_dev->ib_device;
1753-
u8 port_num = work->port->port_num;
1753+
u32 port_num = work->port->port_num;
17541754
u16 pkey_index = work->mad_recv_wc->wc->pkey_index;
17551755
u16 pkey;
17561756
int ret;
@@ -1778,7 +1778,7 @@ static void cm_opa_to_ib_sgid(struct cm_work *work,
17781778
struct sa_path_rec *path)
17791779
{
17801780
struct ib_device *dev = work->port->cm_dev->ib_device;
1781-
u8 port_num = work->port->port_num;
1781+
u32 port_num = work->port->port_num;
17821782

17831783
if (rdma_cap_opa_ah(dev, port_num) &&
17841784
(ib_is_opa_gid(&path->sgid))) {
@@ -4334,7 +4334,7 @@ static int cm_add_one(struct ib_device *ib_device)
43344334
unsigned long flags;
43354335
int ret;
43364336
int count = 0;
4337-
unsigned int i;
4337+
u32 i;
43384338

43394339
cm_dev = kzalloc(struct_size(cm_dev, port, ib_device->phys_port_cnt),
43404340
GFP_KERNEL);
@@ -4432,7 +4432,7 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data)
44324432
.clr_port_cap_mask = IB_PORT_CM_SUP
44334433
};
44344434
unsigned long flags;
4435-
unsigned int i;
4435+
u32 i;
44364436

44374437
write_lock_irqsave(&cm.device_lock, flags);
44384438
list_del(&cm_dev->list);

0 commit comments

Comments
 (0)