Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/iser: Unwind WR union at iser_tx_desc

After decreasing WRs array size from 7 to 3 it is more
readable to give each WR a descriptive name.

Signed-off-by: Israel Rukshin <israelr@mellanox.com>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Israel Rukshin and committed by
Jason Gunthorpe
b9294f8b b76a4399

+27 -38
+2 -1
drivers/infiniband/ulp/iser/iscsi_iser.c
··· 205 205 goto out; 206 206 } 207 207 208 - tx_desc->wr_idx = 0; 208 + tx_desc->inv_wr.next = NULL; 209 + tx_desc->reg_wr.wr.next = NULL; 209 210 tx_desc->mapped = true; 210 211 tx_desc->dma_addr = dma_addr; 211 212 tx_desc->tx_sg[0].addr = tx_desc->dma_addr;
+6 -28
drivers/infiniband/ulp/iser/iscsi_iser.h
··· 225 225 ISCSI_TX_DATAOUT 226 226 }; 227 227 228 - /* 229 - * Maximum number of work requests per task 230 - * (invalidate, registration, send) 231 - */ 232 - #define ISER_MAX_WRS 3 233 - 234 228 /** 235 229 * struct iser_tx_desc - iSER TX descriptor 236 230 * ··· 237 243 * unsolicited data-out or control 238 244 * @num_sge: number sges used on this TX task 239 245 * @mapped: Is the task header mapped 240 - * @wr_idx: Current WR index 241 - * @wrs: Array of WRs per task 246 + * reg_wr: registration WR 247 + * send_wr: send WR 248 + * inv_wr: invalidate WR 242 249 */ 243 250 struct iser_tx_desc { 244 251 struct iser_ctrl iser_header; ··· 250 255 int num_sge; 251 256 struct ib_cqe cqe; 252 257 bool mapped; 253 - u8 wr_idx; 254 - union iser_wr { 255 - struct ib_send_wr send; 256 - struct ib_reg_wr fast_reg; 257 - } wrs[ISER_MAX_WRS]; 258 + struct ib_reg_wr reg_wr; 259 + struct ib_send_wr send_wr; 260 + struct ib_send_wr inv_wr; 258 261 }; 259 262 260 263 #define ISER_RX_PAD_SIZE (256 - (ISER_RX_PAYLOAD_SIZE + \ ··· 644 651 void 645 652 iser_reg_desc_put_fmr(struct ib_conn *ib_conn, 646 653 struct iser_fr_desc *desc); 647 - 648 - static inline struct ib_send_wr * 649 - iser_tx_next_wr(struct iser_tx_desc *tx_desc) 650 - { 651 - struct ib_send_wr *cur_wr = &tx_desc->wrs[tx_desc->wr_idx].send; 652 - struct ib_send_wr *last_wr; 653 - 654 - if (tx_desc->wr_idx) { 655 - last_wr = &tx_desc->wrs[tx_desc->wr_idx - 1].send; 656 - last_wr->next = cur_wr; 657 - } 658 - tx_desc->wr_idx++; 659 - 660 - return cur_wr; 661 - } 662 654 663 655 static inline struct iser_conn * 664 656 to_iser_conn(struct ib_conn *ib_conn)
+9 -7
drivers/infiniband/ulp/iser/iser_memory.c
··· 365 365 static inline void 366 366 iser_inv_rkey(struct ib_send_wr *inv_wr, 367 367 struct ib_mr *mr, 368 - struct ib_cqe *cqe) 368 + struct ib_cqe *cqe, 369 + struct ib_send_wr *next_wr) 369 370 { 370 371 inv_wr->opcode = IB_WR_LOCAL_INV; 371 372 inv_wr->wr_cqe = cqe; 372 373 inv_wr->ex.invalidate_rkey = mr->rkey; 373 374 inv_wr->send_flags = 0; 374 375 inv_wr->num_sge = 0; 376 + inv_wr->next = next_wr; 375 377 } 376 378 377 379 static int ··· 387 385 struct ib_cqe *cqe = &iser_task->iser_conn->ib_conn.reg_cqe; 388 386 struct ib_mr *mr = rsc->sig_mr; 389 387 struct ib_sig_attrs *sig_attrs = mr->sig_attrs; 390 - struct ib_reg_wr *wr; 388 + struct ib_reg_wr *wr = &tx_desc->reg_wr; 391 389 int ret; 392 390 393 391 memset(sig_attrs, 0, sizeof(*sig_attrs)); ··· 398 396 iser_set_prot_checks(iser_task->sc, &sig_attrs->check_mask); 399 397 400 398 if (rsc->mr_valid) 401 - iser_inv_rkey(iser_tx_next_wr(tx_desc), mr, cqe); 399 + iser_inv_rkey(&tx_desc->inv_wr, mr, cqe, &wr->wr); 402 400 403 401 ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey)); 404 402 ··· 410 408 goto err; 411 409 } 412 410 413 - wr = container_of(iser_tx_next_wr(tx_desc), struct ib_reg_wr, wr); 414 411 memset(wr, 0, sizeof(*wr)); 412 + wr->wr.next = &tx_desc->send_wr; 415 413 wr->wr.opcode = IB_WR_REG_MR_INTEGRITY; 416 414 wr->wr.wr_cqe = cqe; 417 415 wr->wr.num_sge = 0; ··· 443 441 struct iser_tx_desc *tx_desc = &iser_task->desc; 444 442 struct ib_cqe *cqe = &iser_task->iser_conn->ib_conn.reg_cqe; 445 443 struct ib_mr *mr = rsc->mr; 446 - struct ib_reg_wr *wr; 444 + struct ib_reg_wr *wr = &tx_desc->reg_wr; 447 445 int n; 448 446 449 447 if (rsc->mr_valid) 450 - iser_inv_rkey(iser_tx_next_wr(tx_desc), mr, cqe); 448 + iser_inv_rkey(&tx_desc->inv_wr, mr, cqe, &wr->wr); 451 449 452 450 ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey)); 453 451 ··· 458 456 return n < 0 ? n : -EINVAL; 459 457 } 460 458 461 - wr = container_of(iser_tx_next_wr(tx_desc), struct ib_reg_wr, wr); 459 + wr->wr.next = &tx_desc->send_wr; 462 460 wr->wr.opcode = IB_WR_REG_MR; 463 461 wr->wr.wr_cqe = cqe; 464 462 wr->wr.send_flags = 0;
+10 -2
drivers/infiniband/ulp/iser/iser_verbs.c
··· 1037 1037 int iser_post_send(struct ib_conn *ib_conn, struct iser_tx_desc *tx_desc, 1038 1038 bool signal) 1039 1039 { 1040 - struct ib_send_wr *wr = iser_tx_next_wr(tx_desc); 1040 + struct ib_send_wr *wr = &tx_desc->send_wr; 1041 + struct ib_send_wr *first_wr; 1041 1042 int ib_ret; 1042 1043 1043 1044 ib_dma_sync_single_for_device(ib_conn->device->ib_device, ··· 1052 1051 wr->opcode = IB_WR_SEND; 1053 1052 wr->send_flags = signal ? IB_SEND_SIGNALED : 0; 1054 1053 1055 - ib_ret = ib_post_send(ib_conn->qp, &tx_desc->wrs[0].send, NULL); 1054 + if (tx_desc->inv_wr.next) 1055 + first_wr = &tx_desc->inv_wr; 1056 + else if (tx_desc->reg_wr.wr.next) 1057 + first_wr = &tx_desc->reg_wr.wr; 1058 + else 1059 + first_wr = wr; 1060 + 1061 + ib_ret = ib_post_send(ib_conn->qp, first_wr, NULL); 1056 1062 if (ib_ret) 1057 1063 iser_err("ib_post_send failed, ret:%d opcode:%d\n", 1058 1064 ib_ret, wr->opcode);