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

RDMA/rxe: Remove unused pkt->offset

The pkt->offset field is never used except to assign it to 0. But it adds
lots of unneeded code. This patch removes the field and related code. This
causes a measurable improvement in performance.

Link: https://lore.kernel.org/r/20210211210455.3274-1-rpearson@hpe.com
Signed-off-by: Bob Pearson <rpearson@hpe.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Bob Pearson and committed by
Jason Gunthorpe
bf139b58 fe454dc3

+90 -96
+88 -90
drivers/infiniband/sw/rxe/rxe_hdr.h
··· 22 22 u16 paylen; /* length of bth - icrc */ 23 23 u8 port_num; /* port pkt received on */ 24 24 u8 opcode; /* bth opcode of packet */ 25 - u8 offset; /* bth offset from pkt->hdr */ 26 25 }; 27 26 28 27 /* Macros should be used only for received skb */ ··· 279 280 280 281 static inline u8 bth_opcode(struct rxe_pkt_info *pkt) 281 282 { 282 - return __bth_opcode(pkt->hdr + pkt->offset); 283 + return __bth_opcode(pkt->hdr); 283 284 } 284 285 285 286 static inline void bth_set_opcode(struct rxe_pkt_info *pkt, u8 opcode) 286 287 { 287 - __bth_set_opcode(pkt->hdr + pkt->offset, opcode); 288 + __bth_set_opcode(pkt->hdr, opcode); 288 289 } 289 290 290 291 static inline u8 bth_se(struct rxe_pkt_info *pkt) 291 292 { 292 - return __bth_se(pkt->hdr + pkt->offset); 293 + return __bth_se(pkt->hdr); 293 294 } 294 295 295 296 static inline void bth_set_se(struct rxe_pkt_info *pkt, int se) 296 297 { 297 - __bth_set_se(pkt->hdr + pkt->offset, se); 298 + __bth_set_se(pkt->hdr, se); 298 299 } 299 300 300 301 static inline u8 bth_mig(struct rxe_pkt_info *pkt) 301 302 { 302 - return __bth_mig(pkt->hdr + pkt->offset); 303 + return __bth_mig(pkt->hdr); 303 304 } 304 305 305 306 static inline void bth_set_mig(struct rxe_pkt_info *pkt, u8 mig) 306 307 { 307 - __bth_set_mig(pkt->hdr + pkt->offset, mig); 308 + __bth_set_mig(pkt->hdr, mig); 308 309 } 309 310 310 311 static inline u8 bth_pad(struct rxe_pkt_info *pkt) 311 312 { 312 - return __bth_pad(pkt->hdr + pkt->offset); 313 + return __bth_pad(pkt->hdr); 313 314 } 314 315 315 316 static inline void bth_set_pad(struct rxe_pkt_info *pkt, u8 pad) 316 317 { 317 - __bth_set_pad(pkt->hdr + pkt->offset, pad); 318 + __bth_set_pad(pkt->hdr, pad); 318 319 } 319 320 320 321 static inline u8 bth_tver(struct rxe_pkt_info *pkt) 321 322 { 322 - return __bth_tver(pkt->hdr + pkt->offset); 323 + return __bth_tver(pkt->hdr); 323 324 } 324 325 325 326 static inline void bth_set_tver(struct rxe_pkt_info *pkt, u8 tver) 326 327 { 327 - __bth_set_tver(pkt->hdr + pkt->offset, tver); 328 + __bth_set_tver(pkt->hdr, tver); 328 329 } 329 330 330 331 static inline u16 bth_pkey(struct rxe_pkt_info *pkt) 331 332 { 332 - return __bth_pkey(pkt->hdr + pkt->offset); 333 + return __bth_pkey(pkt->hdr); 333 334 } 334 335 335 336 static inline void bth_set_pkey(struct rxe_pkt_info *pkt, u16 pkey) 336 337 { 337 - __bth_set_pkey(pkt->hdr + pkt->offset, pkey); 338 + __bth_set_pkey(pkt->hdr, pkey); 338 339 } 339 340 340 341 static inline u32 bth_qpn(struct rxe_pkt_info *pkt) 341 342 { 342 - return __bth_qpn(pkt->hdr + pkt->offset); 343 + return __bth_qpn(pkt->hdr); 343 344 } 344 345 345 346 static inline void bth_set_qpn(struct rxe_pkt_info *pkt, u32 qpn) 346 347 { 347 - __bth_set_qpn(pkt->hdr + pkt->offset, qpn); 348 + __bth_set_qpn(pkt->hdr, qpn); 348 349 } 349 350 350 351 static inline int bth_fecn(struct rxe_pkt_info *pkt) 351 352 { 352 - return __bth_fecn(pkt->hdr + pkt->offset); 353 + return __bth_fecn(pkt->hdr); 353 354 } 354 355 355 356 static inline void bth_set_fecn(struct rxe_pkt_info *pkt, int fecn) 356 357 { 357 - __bth_set_fecn(pkt->hdr + pkt->offset, fecn); 358 + __bth_set_fecn(pkt->hdr, fecn); 358 359 } 359 360 360 361 static inline int bth_becn(struct rxe_pkt_info *pkt) 361 362 { 362 - return __bth_becn(pkt->hdr + pkt->offset); 363 + return __bth_becn(pkt->hdr); 363 364 } 364 365 365 366 static inline void bth_set_becn(struct rxe_pkt_info *pkt, int becn) 366 367 { 367 - __bth_set_becn(pkt->hdr + pkt->offset, becn); 368 + __bth_set_becn(pkt->hdr, becn); 368 369 } 369 370 370 371 static inline u8 bth_resv6a(struct rxe_pkt_info *pkt) 371 372 { 372 - return __bth_resv6a(pkt->hdr + pkt->offset); 373 + return __bth_resv6a(pkt->hdr); 373 374 } 374 375 375 376 static inline void bth_set_resv6a(struct rxe_pkt_info *pkt) 376 377 { 377 - __bth_set_resv6a(pkt->hdr + pkt->offset); 378 + __bth_set_resv6a(pkt->hdr); 378 379 } 379 380 380 381 static inline int bth_ack(struct rxe_pkt_info *pkt) 381 382 { 382 - return __bth_ack(pkt->hdr + pkt->offset); 383 + return __bth_ack(pkt->hdr); 383 384 } 384 385 385 386 static inline void bth_set_ack(struct rxe_pkt_info *pkt, int ack) 386 387 { 387 - __bth_set_ack(pkt->hdr + pkt->offset, ack); 388 + __bth_set_ack(pkt->hdr, ack); 388 389 } 389 390 390 391 static inline void bth_set_resv7(struct rxe_pkt_info *pkt) 391 392 { 392 - __bth_set_resv7(pkt->hdr + pkt->offset); 393 + __bth_set_resv7(pkt->hdr); 393 394 } 394 395 395 396 static inline u32 bth_psn(struct rxe_pkt_info *pkt) 396 397 { 397 - return __bth_psn(pkt->hdr + pkt->offset); 398 + return __bth_psn(pkt->hdr); 398 399 } 399 400 400 401 static inline void bth_set_psn(struct rxe_pkt_info *pkt, u32 psn) 401 402 { 402 - __bth_set_psn(pkt->hdr + pkt->offset, psn); 403 + __bth_set_psn(pkt->hdr, psn); 403 404 } 404 405 405 406 static inline void bth_init(struct rxe_pkt_info *pkt, u8 opcode, int se, 406 407 int mig, int pad, u16 pkey, u32 qpn, int ack_req, 407 408 u32 psn) 408 409 { 409 - struct rxe_bth *bth = (struct rxe_bth *)(pkt->hdr + pkt->offset); 410 + struct rxe_bth *bth = (struct rxe_bth *)(pkt->hdr); 410 411 411 412 bth->opcode = opcode; 412 413 bth->flags = (pad << 4) & BTH_PAD_MASK; ··· 447 448 448 449 static inline u8 rdeth_een(struct rxe_pkt_info *pkt) 449 450 { 450 - return __rdeth_een(pkt->hdr + pkt->offset 451 - + rxe_opcode[pkt->opcode].offset[RXE_RDETH]); 451 + return __rdeth_een(pkt->hdr + 452 + rxe_opcode[pkt->opcode].offset[RXE_RDETH]); 452 453 } 453 454 454 455 static inline void rdeth_set_een(struct rxe_pkt_info *pkt, u32 een) 455 456 { 456 - __rdeth_set_een(pkt->hdr + pkt->offset 457 - + rxe_opcode[pkt->opcode].offset[RXE_RDETH], een); 457 + __rdeth_set_een(pkt->hdr + 458 + rxe_opcode[pkt->opcode].offset[RXE_RDETH], een); 458 459 } 459 460 460 461 /****************************************************************************** ··· 498 499 499 500 static inline u32 deth_qkey(struct rxe_pkt_info *pkt) 500 501 { 501 - return __deth_qkey(pkt->hdr + pkt->offset 502 - + rxe_opcode[pkt->opcode].offset[RXE_DETH]); 502 + return __deth_qkey(pkt->hdr + 503 + rxe_opcode[pkt->opcode].offset[RXE_DETH]); 503 504 } 504 505 505 506 static inline void deth_set_qkey(struct rxe_pkt_info *pkt, u32 qkey) 506 507 { 507 - __deth_set_qkey(pkt->hdr + pkt->offset 508 - + rxe_opcode[pkt->opcode].offset[RXE_DETH], qkey); 508 + __deth_set_qkey(pkt->hdr + 509 + rxe_opcode[pkt->opcode].offset[RXE_DETH], qkey); 509 510 } 510 511 511 512 static inline u32 deth_sqp(struct rxe_pkt_info *pkt) 512 513 { 513 - return __deth_sqp(pkt->hdr + pkt->offset 514 - + rxe_opcode[pkt->opcode].offset[RXE_DETH]); 514 + return __deth_sqp(pkt->hdr + 515 + rxe_opcode[pkt->opcode].offset[RXE_DETH]); 515 516 } 516 517 517 518 static inline void deth_set_sqp(struct rxe_pkt_info *pkt, u32 sqp) 518 519 { 519 - __deth_set_sqp(pkt->hdr + pkt->offset 520 - + rxe_opcode[pkt->opcode].offset[RXE_DETH], sqp); 520 + __deth_set_sqp(pkt->hdr + 521 + rxe_opcode[pkt->opcode].offset[RXE_DETH], sqp); 521 522 } 522 523 523 524 /****************************************************************************** ··· 573 574 574 575 static inline u64 reth_va(struct rxe_pkt_info *pkt) 575 576 { 576 - return __reth_va(pkt->hdr + pkt->offset 577 - + rxe_opcode[pkt->opcode].offset[RXE_RETH]); 577 + return __reth_va(pkt->hdr + 578 + rxe_opcode[pkt->opcode].offset[RXE_RETH]); 578 579 } 579 580 580 581 static inline void reth_set_va(struct rxe_pkt_info *pkt, u64 va) 581 582 { 582 - __reth_set_va(pkt->hdr + pkt->offset 583 - + rxe_opcode[pkt->opcode].offset[RXE_RETH], va); 583 + __reth_set_va(pkt->hdr + 584 + rxe_opcode[pkt->opcode].offset[RXE_RETH], va); 584 585 } 585 586 586 587 static inline u32 reth_rkey(struct rxe_pkt_info *pkt) 587 588 { 588 - return __reth_rkey(pkt->hdr + pkt->offset 589 - + rxe_opcode[pkt->opcode].offset[RXE_RETH]); 589 + return __reth_rkey(pkt->hdr + 590 + rxe_opcode[pkt->opcode].offset[RXE_RETH]); 590 591 } 591 592 592 593 static inline void reth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey) 593 594 { 594 - __reth_set_rkey(pkt->hdr + pkt->offset 595 - + rxe_opcode[pkt->opcode].offset[RXE_RETH], rkey); 595 + __reth_set_rkey(pkt->hdr + 596 + rxe_opcode[pkt->opcode].offset[RXE_RETH], rkey); 596 597 } 597 598 598 599 static inline u32 reth_len(struct rxe_pkt_info *pkt) 599 600 { 600 - return __reth_len(pkt->hdr + pkt->offset 601 - + rxe_opcode[pkt->opcode].offset[RXE_RETH]); 601 + return __reth_len(pkt->hdr + 602 + rxe_opcode[pkt->opcode].offset[RXE_RETH]); 602 603 } 603 604 604 605 static inline void reth_set_len(struct rxe_pkt_info *pkt, u32 len) 605 606 { 606 - __reth_set_len(pkt->hdr + pkt->offset 607 - + rxe_opcode[pkt->opcode].offset[RXE_RETH], len); 607 + __reth_set_len(pkt->hdr + 608 + rxe_opcode[pkt->opcode].offset[RXE_RETH], len); 608 609 } 609 610 610 611 /****************************************************************************** ··· 675 676 676 677 static inline u64 atmeth_va(struct rxe_pkt_info *pkt) 677 678 { 678 - return __atmeth_va(pkt->hdr + pkt->offset 679 - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]); 679 + return __atmeth_va(pkt->hdr + 680 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]); 680 681 } 681 682 682 683 static inline void atmeth_set_va(struct rxe_pkt_info *pkt, u64 va) 683 684 { 684 - __atmeth_set_va(pkt->hdr + pkt->offset 685 - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], va); 685 + __atmeth_set_va(pkt->hdr + 686 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], va); 686 687 } 687 688 688 689 static inline u32 atmeth_rkey(struct rxe_pkt_info *pkt) 689 690 { 690 - return __atmeth_rkey(pkt->hdr + pkt->offset 691 - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]); 691 + return __atmeth_rkey(pkt->hdr + 692 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]); 692 693 } 693 694 694 695 static inline void atmeth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey) 695 696 { 696 - __atmeth_set_rkey(pkt->hdr + pkt->offset 697 - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], rkey); 697 + __atmeth_set_rkey(pkt->hdr + 698 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], rkey); 698 699 } 699 700 700 701 static inline u64 atmeth_swap_add(struct rxe_pkt_info *pkt) 701 702 { 702 - return __atmeth_swap_add(pkt->hdr + pkt->offset 703 - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]); 703 + return __atmeth_swap_add(pkt->hdr + 704 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]); 704 705 } 705 706 706 707 static inline void atmeth_set_swap_add(struct rxe_pkt_info *pkt, u64 swap_add) 707 708 { 708 - __atmeth_set_swap_add(pkt->hdr + pkt->offset 709 - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], swap_add); 709 + __atmeth_set_swap_add(pkt->hdr + 710 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], swap_add); 710 711 } 711 712 712 713 static inline u64 atmeth_comp(struct rxe_pkt_info *pkt) 713 714 { 714 - return __atmeth_comp(pkt->hdr + pkt->offset 715 - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]); 715 + return __atmeth_comp(pkt->hdr + 716 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]); 716 717 } 717 718 718 719 static inline void atmeth_set_comp(struct rxe_pkt_info *pkt, u64 comp) 719 720 { 720 - __atmeth_set_comp(pkt->hdr + pkt->offset 721 - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], comp); 721 + __atmeth_set_comp(pkt->hdr + 722 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], comp); 722 723 } 723 724 724 725 /****************************************************************************** ··· 779 780 780 781 static inline u8 aeth_syn(struct rxe_pkt_info *pkt) 781 782 { 782 - return __aeth_syn(pkt->hdr + pkt->offset 783 - + rxe_opcode[pkt->opcode].offset[RXE_AETH]); 783 + return __aeth_syn(pkt->hdr + 784 + rxe_opcode[pkt->opcode].offset[RXE_AETH]); 784 785 } 785 786 786 787 static inline void aeth_set_syn(struct rxe_pkt_info *pkt, u8 syn) 787 788 { 788 - __aeth_set_syn(pkt->hdr + pkt->offset 789 - + rxe_opcode[pkt->opcode].offset[RXE_AETH], syn); 789 + __aeth_set_syn(pkt->hdr + 790 + rxe_opcode[pkt->opcode].offset[RXE_AETH], syn); 790 791 } 791 792 792 793 static inline u32 aeth_msn(struct rxe_pkt_info *pkt) 793 794 { 794 - return __aeth_msn(pkt->hdr + pkt->offset 795 - + rxe_opcode[pkt->opcode].offset[RXE_AETH]); 795 + return __aeth_msn(pkt->hdr + 796 + rxe_opcode[pkt->opcode].offset[RXE_AETH]); 796 797 } 797 798 798 799 static inline void aeth_set_msn(struct rxe_pkt_info *pkt, u32 msn) 799 800 { 800 - __aeth_set_msn(pkt->hdr + pkt->offset 801 - + rxe_opcode[pkt->opcode].offset[RXE_AETH], msn); 801 + __aeth_set_msn(pkt->hdr + 802 + rxe_opcode[pkt->opcode].offset[RXE_AETH], msn); 802 803 } 803 804 804 805 /****************************************************************************** ··· 824 825 825 826 static inline u64 atmack_orig(struct rxe_pkt_info *pkt) 826 827 { 827 - return __atmack_orig(pkt->hdr + pkt->offset 828 - + rxe_opcode[pkt->opcode].offset[RXE_ATMACK]); 828 + return __atmack_orig(pkt->hdr + 829 + rxe_opcode[pkt->opcode].offset[RXE_ATMACK]); 829 830 } 830 831 831 832 static inline void atmack_set_orig(struct rxe_pkt_info *pkt, u64 orig) 832 833 { 833 - __atmack_set_orig(pkt->hdr + pkt->offset 834 - + rxe_opcode[pkt->opcode].offset[RXE_ATMACK], orig); 834 + __atmack_set_orig(pkt->hdr + 835 + rxe_opcode[pkt->opcode].offset[RXE_ATMACK], orig); 835 836 } 836 837 837 838 /****************************************************************************** ··· 857 858 858 859 static inline __be32 immdt_imm(struct rxe_pkt_info *pkt) 859 860 { 860 - return __immdt_imm(pkt->hdr + pkt->offset 861 - + rxe_opcode[pkt->opcode].offset[RXE_IMMDT]); 861 + return __immdt_imm(pkt->hdr + 862 + rxe_opcode[pkt->opcode].offset[RXE_IMMDT]); 862 863 } 863 864 864 865 static inline void immdt_set_imm(struct rxe_pkt_info *pkt, __be32 imm) 865 866 { 866 - __immdt_set_imm(pkt->hdr + pkt->offset 867 - + rxe_opcode[pkt->opcode].offset[RXE_IMMDT], imm); 867 + __immdt_set_imm(pkt->hdr + 868 + rxe_opcode[pkt->opcode].offset[RXE_IMMDT], imm); 868 869 } 869 870 870 871 /****************************************************************************** ··· 890 891 891 892 static inline u32 ieth_rkey(struct rxe_pkt_info *pkt) 892 893 { 893 - return __ieth_rkey(pkt->hdr + pkt->offset 894 - + rxe_opcode[pkt->opcode].offset[RXE_IETH]); 894 + return __ieth_rkey(pkt->hdr + 895 + rxe_opcode[pkt->opcode].offset[RXE_IETH]); 895 896 } 896 897 897 898 static inline void ieth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey) 898 899 { 899 - __ieth_set_rkey(pkt->hdr + pkt->offset 900 - + rxe_opcode[pkt->opcode].offset[RXE_IETH], rkey); 900 + __ieth_set_rkey(pkt->hdr + 901 + rxe_opcode[pkt->opcode].offset[RXE_IETH], rkey); 901 902 } 902 903 903 904 enum rxe_hdr_length { ··· 914 915 915 916 static inline size_t header_size(struct rxe_pkt_info *pkt) 916 917 { 917 - return pkt->offset + rxe_opcode[pkt->opcode].length; 918 + return rxe_opcode[pkt->opcode].length; 918 919 } 919 920 920 921 static inline void *payload_addr(struct rxe_pkt_info *pkt) 921 922 { 922 - return pkt->hdr + pkt->offset 923 - + rxe_opcode[pkt->opcode].offset[RXE_PAYLOAD]; 923 + return pkt->hdr + rxe_opcode[pkt->opcode].offset[RXE_PAYLOAD]; 924 924 } 925 925 926 926 static inline size_t payload_size(struct rxe_pkt_info *pkt)
+1 -3
drivers/infiniband/sw/rxe/rxe_recv.c
··· 353 353 __be32 *icrcp; 354 354 u32 calc_icrc, pack_icrc; 355 355 356 - pkt->offset = 0; 357 - 358 - if (unlikely(skb->len < pkt->offset + RXE_BTH_BYTES)) 356 + if (unlikely(skb->len < RXE_BTH_BYTES)) 359 357 goto drop; 360 358 361 359 if (rxe_chk_dgid(rxe, skb) < 0) {
-1
drivers/infiniband/sw/rxe/rxe_req.c
··· 375 375 pkt->psn = qp->req.psn; 376 376 pkt->mask = rxe_opcode[opcode].mask; 377 377 pkt->paylen = paylen; 378 - pkt->offset = 0; 379 378 pkt->wqe = wqe; 380 379 381 380 /* init skb */
+1 -2
drivers/infiniband/sw/rxe/rxe_resp.c
··· 586 586 ack->qp = qp; 587 587 ack->opcode = opcode; 588 588 ack->mask = rxe_opcode[opcode].mask; 589 - ack->offset = pkt->offset; 590 589 ack->paylen = paylen; 591 590 592 591 /* fill in bth using the request packet headers */ 593 - memcpy(ack->hdr, pkt->hdr, pkt->offset + RXE_BTH_BYTES); 592 + memcpy(ack->hdr, pkt->hdr, RXE_BTH_BYTES); 594 593 595 594 bth_set_opcode(ack, opcode); 596 595 bth_set_qpn(ack, qp->attr.dest_qp_num);