Skip to content

Commit 76251e1

Browse files
Kamalheibjgunthorpe
authored andcommitted
RDMA/rxe: Remove pkey table
The RoCE spec requires RoCE devices to support only the default pkey. However the rxe driver maintains a 64 enties pkey table and uses only the first entry. Remove the pkey table and hard code a table of length one hard wired with the default pkey. Replace all checks of the pkey_table with a comparison to the default_pkey instead. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kamal Heib <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 928da37 commit 76251e1

File tree

6 files changed

+13
-77
lines changed

6 files changed

+13
-77
lines changed

drivers/infiniband/sw/rxe/rxe.c

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ MODULE_AUTHOR("Bob Pearson, Frank Zago, John Groves, Kamal Heib");
4040
MODULE_DESCRIPTION("Soft RDMA transport");
4141
MODULE_LICENSE("Dual BSD/GPL");
4242

43-
/* free resources for all ports on a device */
44-
static void rxe_cleanup_ports(struct rxe_dev *rxe)
45-
{
46-
kfree(rxe->port.pkey_tbl);
47-
rxe->port.pkey_tbl = NULL;
48-
49-
}
50-
5143
/* free resources for a rxe device all objects created for this device must
5244
* have been destroyed
5345
*/
@@ -66,8 +58,6 @@ void rxe_dealloc(struct ib_device *ib_dev)
6658
rxe_pool_cleanup(&rxe->mc_grp_pool);
6759
rxe_pool_cleanup(&rxe->mc_elem_pool);
6860

69-
rxe_cleanup_ports(rxe);
70-
7161
if (rxe->tfm)
7262
crypto_free_shash(rxe->tfm);
7363
}
@@ -139,25 +129,14 @@ static void rxe_init_port_param(struct rxe_port *port)
139129
/* initialize port state, note IB convention that HCA ports are always
140130
* numbered from 1
141131
*/
142-
static int rxe_init_ports(struct rxe_dev *rxe)
132+
static void rxe_init_ports(struct rxe_dev *rxe)
143133
{
144134
struct rxe_port *port = &rxe->port;
145135

146136
rxe_init_port_param(port);
147-
148-
port->pkey_tbl = kcalloc(port->attr.pkey_tbl_len,
149-
sizeof(*port->pkey_tbl), GFP_KERNEL);
150-
151-
if (!port->pkey_tbl)
152-
return -ENOMEM;
153-
154-
port->pkey_tbl[0] = 0xffff;
155137
addrconf_addr_eui48((unsigned char *)&port->port_guid,
156138
rxe->ndev->dev_addr);
157-
158139
spin_lock_init(&port->port_lock);
159-
160-
return 0;
161140
}
162141

163142
/* init pools of managed objects */
@@ -247,13 +226,11 @@ static int rxe_init(struct rxe_dev *rxe)
247226
/* init default device parameters */
248227
rxe_init_device_param(rxe);
249228

250-
err = rxe_init_ports(rxe);
251-
if (err)
252-
goto err1;
229+
rxe_init_ports(rxe);
253230

254231
err = rxe_init_pools(rxe);
255232
if (err)
256-
goto err2;
233+
return err;
257234

258235
/* init pending mmap list */
259236
spin_lock_init(&rxe->mmap_offset_lock);
@@ -263,11 +240,6 @@ static int rxe_init(struct rxe_dev *rxe)
263240
mutex_init(&rxe->usdev_lock);
264241

265242
return 0;
266-
267-
err2:
268-
rxe_cleanup_ports(rxe);
269-
err1:
270-
return err;
271243
}
272244

273245
void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu)

drivers/infiniband/sw/rxe/rxe_param.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ enum rxe_device_param {
100100
RXE_MAX_SRQ_SGE = 27,
101101
RXE_MIN_SRQ_SGE = 1,
102102
RXE_MAX_FMR_PAGE_LIST_LEN = 512,
103-
RXE_MAX_PKEYS = 64,
103+
RXE_MAX_PKEYS = 1,
104104
RXE_LOCAL_CA_ACK_DELAY = 15,
105105

106106
RXE_MAX_UCONTEXT = 512,
@@ -148,7 +148,7 @@ enum rxe_port_param {
148148
RXE_PORT_INIT_TYPE_REPLY = 0,
149149
RXE_PORT_ACTIVE_WIDTH = IB_WIDTH_1X,
150150
RXE_PORT_ACTIVE_SPEED = 1,
151-
RXE_PORT_PKEY_TBL_LEN = 64,
151+
RXE_PORT_PKEY_TBL_LEN = 1,
152152
RXE_PORT_PHYS_STATE = IB_PORT_PHYS_STATE_POLLING,
153153
RXE_PORT_SUBNET_PREFIX = 0xfe80000000000000ULL,
154154
};

drivers/infiniband/sw/rxe/rxe_recv.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,36 +101,15 @@ static void set_qkey_viol_cntr(struct rxe_port *port)
101101
static int check_keys(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
102102
u32 qpn, struct rxe_qp *qp)
103103
{
104-
int i;
105-
int found_pkey = 0;
106104
struct rxe_port *port = &rxe->port;
107105
u16 pkey = bth_pkey(pkt);
108106

109107
pkt->pkey_index = 0;
110108

111-
if (qpn == 1) {
112-
for (i = 0; i < port->attr.pkey_tbl_len; i++) {
113-
if (pkey_match(pkey, port->pkey_tbl[i])) {
114-
pkt->pkey_index = i;
115-
found_pkey = 1;
116-
break;
117-
}
118-
}
119-
120-
if (!found_pkey) {
121-
pr_warn_ratelimited("bad pkey = 0x%x\n", pkey);
122-
set_bad_pkey_cntr(port);
123-
goto err1;
124-
}
125-
} else {
126-
if (unlikely(!pkey_match(pkey,
127-
port->pkey_tbl[qp->attr.pkey_index]
128-
))) {
129-
pr_warn_ratelimited("bad pkey = 0x%0x\n", pkey);
130-
set_bad_pkey_cntr(port);
131-
goto err1;
132-
}
133-
pkt->pkey_index = qp->attr.pkey_index;
109+
if (!pkey_match(pkey, IB_DEFAULT_PKEY_FULL)) {
110+
pr_warn_ratelimited("bad pkey = 0x%x\n", pkey);
111+
set_bad_pkey_cntr(port);
112+
goto err1;
134113
}
135114

136115
if ((qp_type(qp) == IB_QPT_UD || qp_type(qp) == IB_QPT_GSI) &&

drivers/infiniband/sw/rxe/rxe_req.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp,
381381
struct rxe_pkt_info *pkt)
382382
{
383383
struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
384-
struct rxe_port *port = &rxe->port;
385384
struct sk_buff *skb;
386385
struct rxe_send_wr *ibwr = &wqe->wr;
387386
struct rxe_av *av;
@@ -419,9 +418,7 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp,
419418
(pkt->mask & (RXE_WRITE_MASK | RXE_IMMDT_MASK)) ==
420419
(RXE_WRITE_MASK | RXE_IMMDT_MASK));
421420

422-
pkey = (qp_type(qp) == IB_QPT_GSI) ?
423-
port->pkey_tbl[ibwr->wr.ud.pkey_index] :
424-
port->pkey_tbl[qp->attr.pkey_index];
421+
pkey = IB_DEFAULT_PKEY_FULL;
425422

426423
qp_num = (pkt->mask & RXE_DETH_MASK) ? ibwr->wr.ud.remote_qpn :
427424
qp->attr.dest_qp_num;

drivers/infiniband/sw/rxe/rxe_verbs.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,11 @@ static int rxe_query_port(struct ib_device *dev,
8383
static int rxe_query_pkey(struct ib_device *device,
8484
u8 port_num, u16 index, u16 *pkey)
8585
{
86-
struct rxe_dev *rxe = to_rdev(device);
87-
struct rxe_port *port;
88-
89-
port = &rxe->port;
90-
91-
if (unlikely(index >= port->attr.pkey_tbl_len)) {
92-
dev_warn(device->dev.parent, "invalid index = %d\n",
93-
index);
94-
goto err1;
95-
}
86+
if (index > 0)
87+
return -EINVAL;
9688

97-
*pkey = port->pkey_tbl[index];
89+
*pkey = IB_DEFAULT_PKEY_FULL;
9890
return 0;
99-
100-
err1:
101-
return -EINVAL;
10291
}
10392

10493
static int rxe_modify_device(struct ib_device *dev,

drivers/infiniband/sw/rxe/rxe_verbs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ struct rxe_mc_elem {
371371

372372
struct rxe_port {
373373
struct ib_port_attr attr;
374-
u16 *pkey_tbl;
375374
__be64 port_guid;
376375
__be64 subnet_prefix;
377376
spinlock_t port_lock; /* guard port */

0 commit comments

Comments
 (0)