diff mbox series

[for-next,2/3] RDMA/irdma: Fix RQ completion opcode

Message ID 20221104234749.1084-3-shiraz.saleem@intel.com (mailing list archive)
State Changes Requested
Headers show
Series irdma for-next updates 11-4-2022 | expand

Commit Message

Saleem, Shiraz Nov. 4, 2022, 11:47 p.m. UTC
From: Mustafa Ismail <mustafa.ismail@intel.com>

The opcode written by HW, in the RQ CQE, is the
RoCEv2/iWARP protocol opcode from the received
packet and not the SW opcode as currently assumed.
Fix this by returning the raw operation type and
queue type in the CQE to irdma_process_cqe and add
2 helpers set_ib_wc_op_sq set_ib_wc_op_rq to map
IRDMA HW op types to IB op types.

Note that for iWARP, only Write with Immediate is
supported so the opcode can only be IB_WC_RECV_RDMA_WITH_IMM
when there is immediate data present.

Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
 drivers/infiniband/hw/irdma/uk.c    | 16 +++----
 drivers/infiniband/hw/irdma/user.h  |  1 +
 drivers/infiniband/hw/irdma/utils.c |  2 +
 drivers/infiniband/hw/irdma/verbs.c | 94 ++++++++++++++++++++++++-------------
 4 files changed, 70 insertions(+), 43 deletions(-)

Comments

kernel test robot Nov. 5, 2022, 1:43 a.m. UTC | #1
Hi Shiraz,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.1-rc3 next-20221104]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shiraz-Saleem/irdma-for-next-updates-11-4-2022/20221105-075008
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link:    https://lore.kernel.org/r/20221104234749.1084-3-shiraz.saleem%40intel.com
patch subject: [PATCH for-next 2/3] RDMA/irdma: Fix RQ completion opcode
config: ia64-allyesconfig
compiler: ia64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/376b89f7f8be5fb9e46cdd416d0e5b8341c61fb7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Shiraz-Saleem/irdma-for-next-updates-11-4-2022/20221105-075008
        git checkout 376b89f7f8be5fb9e46cdd416d0e5b8341c61fb7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/infiniband/hw/irdma/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/infiniband/hw/irdma/verbs.c: In function 'set_ib_wc_op_sq':
>> drivers/infiniband/hw/irdma/verbs.c:3360:29: warning: variable 'qp' set but not used [-Wunused-but-set-variable]
    3360 |         struct irdma_sc_qp *qp;
         |                             ^~


vim +/qp +3360 drivers/infiniband/hw/irdma/verbs.c

  3356	
  3357	static inline void set_ib_wc_op_sq(struct irdma_cq_poll_info *cq_poll_info,
  3358					   struct ib_wc *entry)
  3359	{
> 3360		struct irdma_sc_qp *qp;
  3361	
  3362		switch (cq_poll_info->op_type) {
  3363		case IRDMA_OP_TYPE_RDMA_WRITE:
  3364		case IRDMA_OP_TYPE_RDMA_WRITE_SOL:
  3365		entry->opcode = IB_WC_RDMA_WRITE;
  3366			break;
  3367		case IRDMA_OP_TYPE_RDMA_READ_INV_STAG:
  3368		case IRDMA_OP_TYPE_RDMA_READ:
  3369			entry->opcode = IB_WC_RDMA_READ;
  3370			break;
  3371		case IRDMA_OP_TYPE_SEND_SOL:
  3372		case IRDMA_OP_TYPE_SEND_SOL_INV:
  3373		case IRDMA_OP_TYPE_SEND_INV:
  3374		case IRDMA_OP_TYPE_SEND:
  3375			entry->opcode = IB_WC_SEND;
  3376			break;
  3377		case IRDMA_OP_TYPE_FAST_REG_NSMR:
  3378			entry->opcode = IB_WC_REG_MR;
  3379			break;
  3380		case IRDMA_OP_TYPE_INV_STAG:
  3381			entry->opcode = IB_WC_LOCAL_INV;
  3382			break;
  3383		default:
  3384			qp = cq_poll_info->qp_handle;
  3385			entry->status = IB_WC_GENERAL_ERR;
  3386		}
  3387	}
  3388
kernel test robot Nov. 5, 2022, 2:03 a.m. UTC | #2
Hi Shiraz,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.1-rc3 next-20221104]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shiraz-Saleem/irdma-for-next-updates-11-4-2022/20221105-075008
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link:    https://lore.kernel.org/r/20221104234749.1084-3-shiraz.saleem%40intel.com
patch subject: [PATCH for-next 2/3] RDMA/irdma: Fix RQ completion opcode
config: i386-randconfig-a013
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/376b89f7f8be5fb9e46cdd416d0e5b8341c61fb7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Shiraz-Saleem/irdma-for-next-updates-11-4-2022/20221105-075008
        git checkout 376b89f7f8be5fb9e46cdd416d0e5b8341c61fb7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/infiniband/hw/irdma/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/infiniband/hw/irdma/uk.c:1248:8: warning: variable 'op_type' is uninitialized when used here [-Wuninitialized]
                           if (op_type == IRDMA_OP_TYPE_BIND_MW && info->minor_err == FLUSH_PROT_ERR)
                               ^~~~~~~
   drivers/infiniband/hw/irdma/uk.c:1053:12: note: initialize the variable 'op_type' to silence this warning
           u8 op_type;
                     ^
                      = '\0'
   1 warning generated.


vim +/op_type +1248 drivers/infiniband/hw/irdma/uk.c

551c46edc7690c Mustafa Ismail 2021-06-02  1036  
551c46edc7690c Mustafa Ismail 2021-06-02  1037  /**
551c46edc7690c Mustafa Ismail 2021-06-02  1038   * irdma_uk_cq_poll_cmpl - get cq completion info
551c46edc7690c Mustafa Ismail 2021-06-02  1039   * @cq: hw cq
551c46edc7690c Mustafa Ismail 2021-06-02  1040   * @info: cq poll information returned
551c46edc7690c Mustafa Ismail 2021-06-02  1041   */
2c4b14ea950710 Shiraz Saleem  2022-02-17  1042  int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
2c4b14ea950710 Shiraz Saleem  2022-02-17  1043  			  struct irdma_cq_poll_info *info)
551c46edc7690c Mustafa Ismail 2021-06-02  1044  {
551c46edc7690c Mustafa Ismail 2021-06-02  1045  	u64 comp_ctx, qword0, qword2, qword3;
551c46edc7690c Mustafa Ismail 2021-06-02  1046  	__le64 *cqe;
551c46edc7690c Mustafa Ismail 2021-06-02  1047  	struct irdma_qp_uk *qp;
551c46edc7690c Mustafa Ismail 2021-06-02  1048  	struct irdma_ring *pring = NULL;
376b89f7f8be5f Mustafa Ismail 2022-11-04  1049  	u32 wqe_idx;
2c4b14ea950710 Shiraz Saleem  2022-02-17  1050  	int ret_code;
551c46edc7690c Mustafa Ismail 2021-06-02  1051  	bool move_cq_head = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1052  	u8 polarity;
dcb23bbb1de7e0 Sindhu-Devale  2022-09-06  1053  	u8 op_type;
551c46edc7690c Mustafa Ismail 2021-06-02  1054  	bool ext_valid;
551c46edc7690c Mustafa Ismail 2021-06-02  1055  	__le64 *ext_cqe;
551c46edc7690c Mustafa Ismail 2021-06-02  1056  
551c46edc7690c Mustafa Ismail 2021-06-02  1057  	if (cq->avoid_mem_cflct)
551c46edc7690c Mustafa Ismail 2021-06-02  1058  		cqe = IRDMA_GET_CURRENT_EXTENDED_CQ_ELEM(cq);
551c46edc7690c Mustafa Ismail 2021-06-02  1059  	else
551c46edc7690c Mustafa Ismail 2021-06-02  1060  		cqe = IRDMA_GET_CURRENT_CQ_ELEM(cq);
551c46edc7690c Mustafa Ismail 2021-06-02  1061  
551c46edc7690c Mustafa Ismail 2021-06-02  1062  	get_64bit_val(cqe, 24, &qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1063  	polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1064  	if (polarity != cq->polarity)
2c4b14ea950710 Shiraz Saleem  2022-02-17  1065  		return -ENOENT;
551c46edc7690c Mustafa Ismail 2021-06-02  1066  
551c46edc7690c Mustafa Ismail 2021-06-02  1067  	/* Ensure CQE contents are read after valid bit is checked */
551c46edc7690c Mustafa Ismail 2021-06-02  1068  	dma_rmb();
551c46edc7690c Mustafa Ismail 2021-06-02  1069  
551c46edc7690c Mustafa Ismail 2021-06-02  1070  	ext_valid = (bool)FIELD_GET(IRDMA_CQ_EXTCQE, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1071  	if (ext_valid) {
551c46edc7690c Mustafa Ismail 2021-06-02  1072  		u64 qword6, qword7;
551c46edc7690c Mustafa Ismail 2021-06-02  1073  		u32 peek_head;
551c46edc7690c Mustafa Ismail 2021-06-02  1074  
551c46edc7690c Mustafa Ismail 2021-06-02  1075  		if (cq->avoid_mem_cflct) {
551c46edc7690c Mustafa Ismail 2021-06-02  1076  			ext_cqe = (__le64 *)((u8 *)cqe + 32);
551c46edc7690c Mustafa Ismail 2021-06-02  1077  			get_64bit_val(ext_cqe, 24, &qword7);
e93c7d8e8c4cf8 Shiraz Saleem  2021-10-05  1078  			polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1079  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1080  			peek_head = (cq->cq_ring.head + 1) % cq->cq_ring.size;
551c46edc7690c Mustafa Ismail 2021-06-02  1081  			ext_cqe = cq->cq_base[peek_head].buf;
551c46edc7690c Mustafa Ismail 2021-06-02  1082  			get_64bit_val(ext_cqe, 24, &qword7);
e93c7d8e8c4cf8 Shiraz Saleem  2021-10-05  1083  			polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1084  			if (!peek_head)
551c46edc7690c Mustafa Ismail 2021-06-02  1085  				polarity ^= 1;
551c46edc7690c Mustafa Ismail 2021-06-02  1086  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1087  		if (polarity != cq->polarity)
2c4b14ea950710 Shiraz Saleem  2022-02-17  1088  			return -ENOENT;
551c46edc7690c Mustafa Ismail 2021-06-02  1089  
551c46edc7690c Mustafa Ismail 2021-06-02  1090  		/* Ensure ext CQE contents are read after ext valid bit is checked */
551c46edc7690c Mustafa Ismail 2021-06-02  1091  		dma_rmb();
551c46edc7690c Mustafa Ismail 2021-06-02  1092  
551c46edc7690c Mustafa Ismail 2021-06-02  1093  		info->imm_valid = (bool)FIELD_GET(IRDMA_CQ_IMMVALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1094  		if (info->imm_valid) {
551c46edc7690c Mustafa Ismail 2021-06-02  1095  			u64 qword4;
551c46edc7690c Mustafa Ismail 2021-06-02  1096  
551c46edc7690c Mustafa Ismail 2021-06-02  1097  			get_64bit_val(ext_cqe, 0, &qword4);
551c46edc7690c Mustafa Ismail 2021-06-02  1098  			info->imm_data = (u32)FIELD_GET(IRDMA_CQ_IMMDATALOW32, qword4);
551c46edc7690c Mustafa Ismail 2021-06-02  1099  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1100  		info->ud_smac_valid = (bool)FIELD_GET(IRDMA_CQ_UDSMACVALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1101  		info->ud_vlan_valid = (bool)FIELD_GET(IRDMA_CQ_UDVLANVALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1102  		if (info->ud_smac_valid || info->ud_vlan_valid) {
551c46edc7690c Mustafa Ismail 2021-06-02  1103  			get_64bit_val(ext_cqe, 16, &qword6);
551c46edc7690c Mustafa Ismail 2021-06-02  1104  			if (info->ud_vlan_valid)
551c46edc7690c Mustafa Ismail 2021-06-02  1105  				info->ud_vlan = (u16)FIELD_GET(IRDMA_CQ_UDVLAN, qword6);
551c46edc7690c Mustafa Ismail 2021-06-02  1106  			if (info->ud_smac_valid) {
551c46edc7690c Mustafa Ismail 2021-06-02  1107  				info->ud_smac[5] = qword6 & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1108  				info->ud_smac[4] = (qword6 >> 8) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1109  				info->ud_smac[3] = (qword6 >> 16) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1110  				info->ud_smac[2] = (qword6 >> 24) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1111  				info->ud_smac[1] = (qword6 >> 32) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1112  				info->ud_smac[0] = (qword6 >> 40) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1113  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1114  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1115  	} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1116  		info->imm_valid = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1117  		info->ud_smac_valid = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1118  		info->ud_vlan_valid = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1119  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1120  
376b89f7f8be5f Mustafa Ismail 2022-11-04  1121  	info->q_type = (u8)FIELD_GET(IRDMA_CQ_SQ, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1122  	info->error = (bool)FIELD_GET(IRDMA_CQ_ERROR, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1123  	info->push_dropped = (bool)FIELD_GET(IRDMACQ_PSHDROP, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1124  	info->ipv4 = (bool)FIELD_GET(IRDMACQ_IPV4, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1125  	if (info->error) {
551c46edc7690c Mustafa Ismail 2021-06-02  1126  		info->major_err = FIELD_GET(IRDMA_CQ_MAJERR, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1127  		info->minor_err = FIELD_GET(IRDMA_CQ_MINERR, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1128  		if (info->major_err == IRDMA_FLUSH_MAJOR_ERR) {
551c46edc7690c Mustafa Ismail 2021-06-02  1129  			info->comp_status = IRDMA_COMPL_STATUS_FLUSHED;
551c46edc7690c Mustafa Ismail 2021-06-02  1130  			/* Set the min error to standard flush error code for remaining cqes */
551c46edc7690c Mustafa Ismail 2021-06-02  1131  			if (info->minor_err != FLUSH_GENERAL_ERR) {
551c46edc7690c Mustafa Ismail 2021-06-02  1132  				qword3 &= ~IRDMA_CQ_MINERR;
551c46edc7690c Mustafa Ismail 2021-06-02  1133  				qword3 |= FIELD_PREP(IRDMA_CQ_MINERR, FLUSH_GENERAL_ERR);
551c46edc7690c Mustafa Ismail 2021-06-02  1134  				set_64bit_val(cqe, 24, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1135  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1136  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1137  			info->comp_status = IRDMA_COMPL_STATUS_UNKNOWN;
551c46edc7690c Mustafa Ismail 2021-06-02  1138  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1139  	} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1140  		info->comp_status = IRDMA_COMPL_STATUS_SUCCESS;
551c46edc7690c Mustafa Ismail 2021-06-02  1141  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1142  
551c46edc7690c Mustafa Ismail 2021-06-02  1143  	get_64bit_val(cqe, 0, &qword0);
551c46edc7690c Mustafa Ismail 2021-06-02  1144  	get_64bit_val(cqe, 16, &qword2);
551c46edc7690c Mustafa Ismail 2021-06-02  1145  
551c46edc7690c Mustafa Ismail 2021-06-02  1146  	info->tcp_seq_num_rtt = (u32)FIELD_GET(IRDMACQ_TCPSEQNUMRTT, qword0);
551c46edc7690c Mustafa Ismail 2021-06-02  1147  	info->qp_id = (u32)FIELD_GET(IRDMACQ_QPID, qword2);
551c46edc7690c Mustafa Ismail 2021-06-02  1148  	info->ud_src_qpn = (u32)FIELD_GET(IRDMACQ_UDSRCQPN, qword2);
551c46edc7690c Mustafa Ismail 2021-06-02  1149  
551c46edc7690c Mustafa Ismail 2021-06-02  1150  	get_64bit_val(cqe, 8, &comp_ctx);
551c46edc7690c Mustafa Ismail 2021-06-02  1151  
551c46edc7690c Mustafa Ismail 2021-06-02  1152  	info->solicited_event = (bool)FIELD_GET(IRDMACQ_SOEVENT, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1153  	qp = (struct irdma_qp_uk *)(unsigned long)comp_ctx;
551c46edc7690c Mustafa Ismail 2021-06-02  1154  	if (!qp || qp->destroy_pending) {
2c4b14ea950710 Shiraz Saleem  2022-02-17  1155  		ret_code = -EFAULT;
551c46edc7690c Mustafa Ismail 2021-06-02  1156  		goto exit;
551c46edc7690c Mustafa Ismail 2021-06-02  1157  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1158  	wqe_idx = (u32)FIELD_GET(IRDMA_CQ_WQEIDX, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1159  	info->qp_handle = (irdma_qp_handle)(unsigned long)qp;
376b89f7f8be5f Mustafa Ismail 2022-11-04  1160  	info->op_type = (u8)FIELD_GET(IRDMA_CQ_SQ, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1161  
376b89f7f8be5f Mustafa Ismail 2022-11-04  1162  	if (info->q_type == IRDMA_CQE_QTYPE_RQ) {
551c46edc7690c Mustafa Ismail 2021-06-02  1163  		u32 array_idx;
551c46edc7690c Mustafa Ismail 2021-06-02  1164  
551c46edc7690c Mustafa Ismail 2021-06-02  1165  		array_idx = wqe_idx / qp->rq_wqe_size_multiplier;
551c46edc7690c Mustafa Ismail 2021-06-02  1166  
551c46edc7690c Mustafa Ismail 2021-06-02  1167  		if (info->comp_status == IRDMA_COMPL_STATUS_FLUSHED ||
551c46edc7690c Mustafa Ismail 2021-06-02  1168  		    info->comp_status == IRDMA_COMPL_STATUS_UNKNOWN) {
551c46edc7690c Mustafa Ismail 2021-06-02  1169  			if (!IRDMA_RING_MORE_WORK(qp->rq_ring)) {
2c4b14ea950710 Shiraz Saleem  2022-02-17  1170  				ret_code = -ENOENT;
551c46edc7690c Mustafa Ismail 2021-06-02  1171  				goto exit;
551c46edc7690c Mustafa Ismail 2021-06-02  1172  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1173  
551c46edc7690c Mustafa Ismail 2021-06-02  1174  			info->wr_id = qp->rq_wrid_array[qp->rq_ring.tail];
551c46edc7690c Mustafa Ismail 2021-06-02  1175  			array_idx = qp->rq_ring.tail;
551c46edc7690c Mustafa Ismail 2021-06-02  1176  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1177  			info->wr_id = qp->rq_wrid_array[array_idx];
551c46edc7690c Mustafa Ismail 2021-06-02  1178  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1179  
551c46edc7690c Mustafa Ismail 2021-06-02  1180  		info->bytes_xfered = (u32)FIELD_GET(IRDMACQ_PAYLDLEN, qword0);
551c46edc7690c Mustafa Ismail 2021-06-02  1181  
551c46edc7690c Mustafa Ismail 2021-06-02  1182  		if (qword3 & IRDMACQ_STAG) {
551c46edc7690c Mustafa Ismail 2021-06-02  1183  			info->stag_invalid_set = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1184  			info->inv_stag = (u32)FIELD_GET(IRDMACQ_INVSTAG, qword2);
551c46edc7690c Mustafa Ismail 2021-06-02  1185  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1186  			info->stag_invalid_set = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1187  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1188  		IRDMA_RING_SET_TAIL(qp->rq_ring, array_idx + 1);
551c46edc7690c Mustafa Ismail 2021-06-02  1189  		if (info->comp_status == IRDMA_COMPL_STATUS_FLUSHED) {
551c46edc7690c Mustafa Ismail 2021-06-02  1190  			qp->rq_flush_seen = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1191  			if (!IRDMA_RING_MORE_WORK(qp->rq_ring))
551c46edc7690c Mustafa Ismail 2021-06-02  1192  				qp->rq_flush_complete = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1193  			else
551c46edc7690c Mustafa Ismail 2021-06-02  1194  				move_cq_head = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1195  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1196  		pring = &qp->rq_ring;
551c46edc7690c Mustafa Ismail 2021-06-02  1197  	} else { /* q_type is IRDMA_CQE_QTYPE_SQ */
551c46edc7690c Mustafa Ismail 2021-06-02  1198  		if (qp->first_sq_wq) {
551c46edc7690c Mustafa Ismail 2021-06-02  1199  			if (wqe_idx + 1 >= qp->conn_wqes)
551c46edc7690c Mustafa Ismail 2021-06-02  1200  				qp->first_sq_wq = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1201  
551c46edc7690c Mustafa Ismail 2021-06-02  1202  			if (wqe_idx < qp->conn_wqes && qp->sq_ring.head == qp->sq_ring.tail) {
551c46edc7690c Mustafa Ismail 2021-06-02  1203  				IRDMA_RING_MOVE_HEAD_NOCHECK(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1204  				IRDMA_RING_MOVE_TAIL(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1205  				set_64bit_val(cq->shadow_area, 0,
551c46edc7690c Mustafa Ismail 2021-06-02  1206  					      IRDMA_RING_CURRENT_HEAD(cq->cq_ring));
551c46edc7690c Mustafa Ismail 2021-06-02  1207  				memset(info, 0,
551c46edc7690c Mustafa Ismail 2021-06-02  1208  				       sizeof(struct irdma_cq_poll_info));
551c46edc7690c Mustafa Ismail 2021-06-02  1209  				return irdma_uk_cq_poll_cmpl(cq, info);
551c46edc7690c Mustafa Ismail 2021-06-02  1210  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1211  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1212  		/*cease posting push mode on push drop*/
551c46edc7690c Mustafa Ismail 2021-06-02  1213  		if (info->push_dropped) {
551c46edc7690c Mustafa Ismail 2021-06-02  1214  			qp->push_mode = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1215  			qp->push_dropped = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1216  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1217  		if (info->comp_status != IRDMA_COMPL_STATUS_FLUSHED) {
551c46edc7690c Mustafa Ismail 2021-06-02  1218  			info->wr_id = qp->sq_wrtrk_array[wqe_idx].wrid;
551c46edc7690c Mustafa Ismail 2021-06-02  1219  			if (!info->comp_status)
551c46edc7690c Mustafa Ismail 2021-06-02  1220  				info->bytes_xfered = qp->sq_wrtrk_array[wqe_idx].wr_len;
551c46edc7690c Mustafa Ismail 2021-06-02  1221  			info->op_type = (u8)FIELD_GET(IRDMACQ_OP, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1222  			IRDMA_RING_SET_TAIL(qp->sq_ring,
551c46edc7690c Mustafa Ismail 2021-06-02  1223  					    wqe_idx + qp->sq_wrtrk_array[wqe_idx].quanta);
551c46edc7690c Mustafa Ismail 2021-06-02  1224  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1225  			if (!IRDMA_RING_MORE_WORK(qp->sq_ring)) {
2c4b14ea950710 Shiraz Saleem  2022-02-17  1226  				ret_code = -ENOENT;
551c46edc7690c Mustafa Ismail 2021-06-02  1227  				goto exit;
551c46edc7690c Mustafa Ismail 2021-06-02  1228  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1229  
551c46edc7690c Mustafa Ismail 2021-06-02  1230  			do {
551c46edc7690c Mustafa Ismail 2021-06-02  1231  				__le64 *sw_wqe;
551c46edc7690c Mustafa Ismail 2021-06-02  1232  				u64 wqe_qword;
551c46edc7690c Mustafa Ismail 2021-06-02  1233  				u32 tail;
551c46edc7690c Mustafa Ismail 2021-06-02  1234  
551c46edc7690c Mustafa Ismail 2021-06-02  1235  				tail = qp->sq_ring.tail;
551c46edc7690c Mustafa Ismail 2021-06-02  1236  				sw_wqe = qp->sq_base[tail].elem;
551c46edc7690c Mustafa Ismail 2021-06-02  1237  				get_64bit_val(sw_wqe, 24,
551c46edc7690c Mustafa Ismail 2021-06-02  1238  					      &wqe_qword);
376b89f7f8be5f Mustafa Ismail 2022-11-04  1239  				info->op_type = (u8)FIELD_GET(IRDMAQPSQ_OPCODE, wqe_qword);
551c46edc7690c Mustafa Ismail 2021-06-02  1240  				IRDMA_RING_SET_TAIL(qp->sq_ring,
551c46edc7690c Mustafa Ismail 2021-06-02  1241  						    tail + qp->sq_wrtrk_array[tail].quanta);
376b89f7f8be5f Mustafa Ismail 2022-11-04  1242  				if (info->op_type != IRDMAQP_OP_NOP) {
551c46edc7690c Mustafa Ismail 2021-06-02  1243  					info->wr_id = qp->sq_wrtrk_array[tail].wrid;
551c46edc7690c Mustafa Ismail 2021-06-02  1244  					info->bytes_xfered = qp->sq_wrtrk_array[tail].wr_len;
551c46edc7690c Mustafa Ismail 2021-06-02  1245  					break;
551c46edc7690c Mustafa Ismail 2021-06-02  1246  				}
551c46edc7690c Mustafa Ismail 2021-06-02  1247  			} while (1);
dcb23bbb1de7e0 Sindhu-Devale  2022-09-06 @1248  			if (op_type == IRDMA_OP_TYPE_BIND_MW && info->minor_err == FLUSH_PROT_ERR)
dcb23bbb1de7e0 Sindhu-Devale  2022-09-06  1249  				info->minor_err = FLUSH_MW_BIND_ERR;
551c46edc7690c Mustafa Ismail 2021-06-02  1250  			qp->sq_flush_seen = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1251  			if (!IRDMA_RING_MORE_WORK(qp->sq_ring))
551c46edc7690c Mustafa Ismail 2021-06-02  1252  				qp->sq_flush_complete = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1253  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1254  		pring = &qp->sq_ring;
551c46edc7690c Mustafa Ismail 2021-06-02  1255  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1256  
551c46edc7690c Mustafa Ismail 2021-06-02  1257  	ret_code = 0;
551c46edc7690c Mustafa Ismail 2021-06-02  1258  
551c46edc7690c Mustafa Ismail 2021-06-02  1259  exit:
551c46edc7690c Mustafa Ismail 2021-06-02  1260  	if (!ret_code && info->comp_status == IRDMA_COMPL_STATUS_FLUSHED)
551c46edc7690c Mustafa Ismail 2021-06-02  1261  		if (pring && IRDMA_RING_MORE_WORK(*pring))
551c46edc7690c Mustafa Ismail 2021-06-02  1262  			move_cq_head = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1263  
551c46edc7690c Mustafa Ismail 2021-06-02  1264  	if (move_cq_head) {
551c46edc7690c Mustafa Ismail 2021-06-02  1265  		IRDMA_RING_MOVE_HEAD_NOCHECK(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1266  		if (!IRDMA_RING_CURRENT_HEAD(cq->cq_ring))
551c46edc7690c Mustafa Ismail 2021-06-02  1267  			cq->polarity ^= 1;
551c46edc7690c Mustafa Ismail 2021-06-02  1268  
551c46edc7690c Mustafa Ismail 2021-06-02  1269  		if (ext_valid && !cq->avoid_mem_cflct) {
551c46edc7690c Mustafa Ismail 2021-06-02  1270  			IRDMA_RING_MOVE_HEAD_NOCHECK(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1271  			if (!IRDMA_RING_CURRENT_HEAD(cq->cq_ring))
551c46edc7690c Mustafa Ismail 2021-06-02  1272  				cq->polarity ^= 1;
551c46edc7690c Mustafa Ismail 2021-06-02  1273  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1274  
551c46edc7690c Mustafa Ismail 2021-06-02  1275  		IRDMA_RING_MOVE_TAIL(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1276  		if (!cq->avoid_mem_cflct && ext_valid)
551c46edc7690c Mustafa Ismail 2021-06-02  1277  			IRDMA_RING_MOVE_TAIL(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1278  		set_64bit_val(cq->shadow_area, 0,
551c46edc7690c Mustafa Ismail 2021-06-02  1279  			      IRDMA_RING_CURRENT_HEAD(cq->cq_ring));
551c46edc7690c Mustafa Ismail 2021-06-02  1280  	} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1281  		qword3 &= ~IRDMA_CQ_WQEIDX;
551c46edc7690c Mustafa Ismail 2021-06-02  1282  		qword3 |= FIELD_PREP(IRDMA_CQ_WQEIDX, pring->tail);
551c46edc7690c Mustafa Ismail 2021-06-02  1283  		set_64bit_val(cqe, 24, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1284  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1285  
551c46edc7690c Mustafa Ismail 2021-06-02  1286  	return ret_code;
551c46edc7690c Mustafa Ismail 2021-06-02  1287  }
551c46edc7690c Mustafa Ismail 2021-06-02  1288
kernel test robot Nov. 10, 2022, 8:09 p.m. UTC | #3
Hi Shiraz,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.1-rc4 next-20221110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shiraz-Saleem/irdma-for-next-updates-11-4-2022/20221105-075008
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link:    https://lore.kernel.org/r/20221104234749.1084-3-shiraz.saleem%40intel.com
patch subject: [PATCH for-next 2/3] RDMA/irdma: Fix RQ completion opcode
config: s390-randconfig-r044-20221110
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 463da45892e2d2a262277b91b96f5f8c05dc25d0)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install s390 cross compiling tool for clang build
        # apt-get install binutils-s390x-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/376b89f7f8be5fb9e46cdd416d0e5b8341c61fb7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Shiraz-Saleem/irdma-for-next-updates-11-4-2022/20221105-075008
        git checkout 376b89f7f8be5fb9e46cdd416d0e5b8341c61fb7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash drivers/infiniband/hw/irdma/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from drivers/infiniband/hw/irdma/uk.c:3:
   In file included from drivers/infiniband/hw/irdma/osdep.h:6:
   In file included from include/linux/pci.h:39:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                             ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
   #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
                                                        ^
   In file included from drivers/infiniband/hw/irdma/uk.c:3:
   In file included from drivers/infiniband/hw/irdma/osdep.h:6:
   In file included from include/linux/pci.h:39:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
   #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
                                                        ^
   In file included from drivers/infiniband/hw/irdma/uk.c:3:
   In file included from drivers/infiniband/hw/irdma/osdep.h:6:
   In file included from include/linux/pci.h:39:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> drivers/infiniband/hw/irdma/uk.c:1248:8: warning: variable 'op_type' is uninitialized when used here [-Wuninitialized]
                           if (op_type == IRDMA_OP_TYPE_BIND_MW && info->minor_err == FLUSH_PROT_ERR)
                               ^~~~~~~
   drivers/infiniband/hw/irdma/uk.c:1053:12: note: initialize the variable 'op_type' to silence this warning
           u8 op_type;
                     ^
                      = '\0'
   13 warnings generated.
--
   In file included from drivers/infiniband/hw/irdma/verbs.c:3:
   In file included from drivers/infiniband/hw/irdma/main.h:6:
   In file included from include/linux/ip.h:16:
   In file included from include/linux/skbuff.h:31:
   In file included from include/linux/dma-mapping.h:10:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                             ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
   #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
                                                        ^
   In file included from drivers/infiniband/hw/irdma/verbs.c:3:
   In file included from drivers/infiniband/hw/irdma/main.h:6:
   In file included from include/linux/ip.h:16:
   In file included from include/linux/skbuff.h:31:
   In file included from include/linux/dma-mapping.h:10:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
   #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
                                                        ^
   In file included from drivers/infiniband/hw/irdma/verbs.c:3:
   In file included from drivers/infiniband/hw/irdma/main.h:6:
   In file included from include/linux/ip.h:16:
   In file included from include/linux/skbuff.h:31:
   In file included from include/linux/dma-mapping.h:10:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> drivers/infiniband/hw/irdma/verbs.c:3360:22: warning: variable 'qp' set but not used [-Wunused-but-set-variable]
           struct irdma_sc_qp *qp;
                               ^
   13 warnings generated.


vim +/op_type +1248 drivers/infiniband/hw/irdma/uk.c

551c46edc7690c Mustafa Ismail 2021-06-02  1036  
551c46edc7690c Mustafa Ismail 2021-06-02  1037  /**
551c46edc7690c Mustafa Ismail 2021-06-02  1038   * irdma_uk_cq_poll_cmpl - get cq completion info
551c46edc7690c Mustafa Ismail 2021-06-02  1039   * @cq: hw cq
551c46edc7690c Mustafa Ismail 2021-06-02  1040   * @info: cq poll information returned
551c46edc7690c Mustafa Ismail 2021-06-02  1041   */
2c4b14ea950710 Shiraz Saleem  2022-02-17  1042  int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
2c4b14ea950710 Shiraz Saleem  2022-02-17  1043  			  struct irdma_cq_poll_info *info)
551c46edc7690c Mustafa Ismail 2021-06-02  1044  {
551c46edc7690c Mustafa Ismail 2021-06-02  1045  	u64 comp_ctx, qword0, qword2, qword3;
551c46edc7690c Mustafa Ismail 2021-06-02  1046  	__le64 *cqe;
551c46edc7690c Mustafa Ismail 2021-06-02  1047  	struct irdma_qp_uk *qp;
551c46edc7690c Mustafa Ismail 2021-06-02  1048  	struct irdma_ring *pring = NULL;
376b89f7f8be5f Mustafa Ismail 2022-11-04  1049  	u32 wqe_idx;
2c4b14ea950710 Shiraz Saleem  2022-02-17  1050  	int ret_code;
551c46edc7690c Mustafa Ismail 2021-06-02  1051  	bool move_cq_head = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1052  	u8 polarity;
dcb23bbb1de7e0 Sindhu-Devale  2022-09-06  1053  	u8 op_type;
551c46edc7690c Mustafa Ismail 2021-06-02  1054  	bool ext_valid;
551c46edc7690c Mustafa Ismail 2021-06-02  1055  	__le64 *ext_cqe;
551c46edc7690c Mustafa Ismail 2021-06-02  1056  
551c46edc7690c Mustafa Ismail 2021-06-02  1057  	if (cq->avoid_mem_cflct)
551c46edc7690c Mustafa Ismail 2021-06-02  1058  		cqe = IRDMA_GET_CURRENT_EXTENDED_CQ_ELEM(cq);
551c46edc7690c Mustafa Ismail 2021-06-02  1059  	else
551c46edc7690c Mustafa Ismail 2021-06-02  1060  		cqe = IRDMA_GET_CURRENT_CQ_ELEM(cq);
551c46edc7690c Mustafa Ismail 2021-06-02  1061  
551c46edc7690c Mustafa Ismail 2021-06-02  1062  	get_64bit_val(cqe, 24, &qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1063  	polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1064  	if (polarity != cq->polarity)
2c4b14ea950710 Shiraz Saleem  2022-02-17  1065  		return -ENOENT;
551c46edc7690c Mustafa Ismail 2021-06-02  1066  
551c46edc7690c Mustafa Ismail 2021-06-02  1067  	/* Ensure CQE contents are read after valid bit is checked */
551c46edc7690c Mustafa Ismail 2021-06-02  1068  	dma_rmb();
551c46edc7690c Mustafa Ismail 2021-06-02  1069  
551c46edc7690c Mustafa Ismail 2021-06-02  1070  	ext_valid = (bool)FIELD_GET(IRDMA_CQ_EXTCQE, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1071  	if (ext_valid) {
551c46edc7690c Mustafa Ismail 2021-06-02  1072  		u64 qword6, qword7;
551c46edc7690c Mustafa Ismail 2021-06-02  1073  		u32 peek_head;
551c46edc7690c Mustafa Ismail 2021-06-02  1074  
551c46edc7690c Mustafa Ismail 2021-06-02  1075  		if (cq->avoid_mem_cflct) {
551c46edc7690c Mustafa Ismail 2021-06-02  1076  			ext_cqe = (__le64 *)((u8 *)cqe + 32);
551c46edc7690c Mustafa Ismail 2021-06-02  1077  			get_64bit_val(ext_cqe, 24, &qword7);
e93c7d8e8c4cf8 Shiraz Saleem  2021-10-05  1078  			polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1079  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1080  			peek_head = (cq->cq_ring.head + 1) % cq->cq_ring.size;
551c46edc7690c Mustafa Ismail 2021-06-02  1081  			ext_cqe = cq->cq_base[peek_head].buf;
551c46edc7690c Mustafa Ismail 2021-06-02  1082  			get_64bit_val(ext_cqe, 24, &qword7);
e93c7d8e8c4cf8 Shiraz Saleem  2021-10-05  1083  			polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1084  			if (!peek_head)
551c46edc7690c Mustafa Ismail 2021-06-02  1085  				polarity ^= 1;
551c46edc7690c Mustafa Ismail 2021-06-02  1086  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1087  		if (polarity != cq->polarity)
2c4b14ea950710 Shiraz Saleem  2022-02-17  1088  			return -ENOENT;
551c46edc7690c Mustafa Ismail 2021-06-02  1089  
551c46edc7690c Mustafa Ismail 2021-06-02  1090  		/* Ensure ext CQE contents are read after ext valid bit is checked */
551c46edc7690c Mustafa Ismail 2021-06-02  1091  		dma_rmb();
551c46edc7690c Mustafa Ismail 2021-06-02  1092  
551c46edc7690c Mustafa Ismail 2021-06-02  1093  		info->imm_valid = (bool)FIELD_GET(IRDMA_CQ_IMMVALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1094  		if (info->imm_valid) {
551c46edc7690c Mustafa Ismail 2021-06-02  1095  			u64 qword4;
551c46edc7690c Mustafa Ismail 2021-06-02  1096  
551c46edc7690c Mustafa Ismail 2021-06-02  1097  			get_64bit_val(ext_cqe, 0, &qword4);
551c46edc7690c Mustafa Ismail 2021-06-02  1098  			info->imm_data = (u32)FIELD_GET(IRDMA_CQ_IMMDATALOW32, qword4);
551c46edc7690c Mustafa Ismail 2021-06-02  1099  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1100  		info->ud_smac_valid = (bool)FIELD_GET(IRDMA_CQ_UDSMACVALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1101  		info->ud_vlan_valid = (bool)FIELD_GET(IRDMA_CQ_UDVLANVALID, qword7);
551c46edc7690c Mustafa Ismail 2021-06-02  1102  		if (info->ud_smac_valid || info->ud_vlan_valid) {
551c46edc7690c Mustafa Ismail 2021-06-02  1103  			get_64bit_val(ext_cqe, 16, &qword6);
551c46edc7690c Mustafa Ismail 2021-06-02  1104  			if (info->ud_vlan_valid)
551c46edc7690c Mustafa Ismail 2021-06-02  1105  				info->ud_vlan = (u16)FIELD_GET(IRDMA_CQ_UDVLAN, qword6);
551c46edc7690c Mustafa Ismail 2021-06-02  1106  			if (info->ud_smac_valid) {
551c46edc7690c Mustafa Ismail 2021-06-02  1107  				info->ud_smac[5] = qword6 & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1108  				info->ud_smac[4] = (qword6 >> 8) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1109  				info->ud_smac[3] = (qword6 >> 16) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1110  				info->ud_smac[2] = (qword6 >> 24) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1111  				info->ud_smac[1] = (qword6 >> 32) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1112  				info->ud_smac[0] = (qword6 >> 40) & 0xFF;
551c46edc7690c Mustafa Ismail 2021-06-02  1113  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1114  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1115  	} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1116  		info->imm_valid = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1117  		info->ud_smac_valid = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1118  		info->ud_vlan_valid = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1119  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1120  
376b89f7f8be5f Mustafa Ismail 2022-11-04  1121  	info->q_type = (u8)FIELD_GET(IRDMA_CQ_SQ, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1122  	info->error = (bool)FIELD_GET(IRDMA_CQ_ERROR, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1123  	info->push_dropped = (bool)FIELD_GET(IRDMACQ_PSHDROP, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1124  	info->ipv4 = (bool)FIELD_GET(IRDMACQ_IPV4, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1125  	if (info->error) {
551c46edc7690c Mustafa Ismail 2021-06-02  1126  		info->major_err = FIELD_GET(IRDMA_CQ_MAJERR, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1127  		info->minor_err = FIELD_GET(IRDMA_CQ_MINERR, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1128  		if (info->major_err == IRDMA_FLUSH_MAJOR_ERR) {
551c46edc7690c Mustafa Ismail 2021-06-02  1129  			info->comp_status = IRDMA_COMPL_STATUS_FLUSHED;
551c46edc7690c Mustafa Ismail 2021-06-02  1130  			/* Set the min error to standard flush error code for remaining cqes */
551c46edc7690c Mustafa Ismail 2021-06-02  1131  			if (info->minor_err != FLUSH_GENERAL_ERR) {
551c46edc7690c Mustafa Ismail 2021-06-02  1132  				qword3 &= ~IRDMA_CQ_MINERR;
551c46edc7690c Mustafa Ismail 2021-06-02  1133  				qword3 |= FIELD_PREP(IRDMA_CQ_MINERR, FLUSH_GENERAL_ERR);
551c46edc7690c Mustafa Ismail 2021-06-02  1134  				set_64bit_val(cqe, 24, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1135  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1136  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1137  			info->comp_status = IRDMA_COMPL_STATUS_UNKNOWN;
551c46edc7690c Mustafa Ismail 2021-06-02  1138  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1139  	} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1140  		info->comp_status = IRDMA_COMPL_STATUS_SUCCESS;
551c46edc7690c Mustafa Ismail 2021-06-02  1141  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1142  
551c46edc7690c Mustafa Ismail 2021-06-02  1143  	get_64bit_val(cqe, 0, &qword0);
551c46edc7690c Mustafa Ismail 2021-06-02  1144  	get_64bit_val(cqe, 16, &qword2);
551c46edc7690c Mustafa Ismail 2021-06-02  1145  
551c46edc7690c Mustafa Ismail 2021-06-02  1146  	info->tcp_seq_num_rtt = (u32)FIELD_GET(IRDMACQ_TCPSEQNUMRTT, qword0);
551c46edc7690c Mustafa Ismail 2021-06-02  1147  	info->qp_id = (u32)FIELD_GET(IRDMACQ_QPID, qword2);
551c46edc7690c Mustafa Ismail 2021-06-02  1148  	info->ud_src_qpn = (u32)FIELD_GET(IRDMACQ_UDSRCQPN, qword2);
551c46edc7690c Mustafa Ismail 2021-06-02  1149  
551c46edc7690c Mustafa Ismail 2021-06-02  1150  	get_64bit_val(cqe, 8, &comp_ctx);
551c46edc7690c Mustafa Ismail 2021-06-02  1151  
551c46edc7690c Mustafa Ismail 2021-06-02  1152  	info->solicited_event = (bool)FIELD_GET(IRDMACQ_SOEVENT, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1153  	qp = (struct irdma_qp_uk *)(unsigned long)comp_ctx;
551c46edc7690c Mustafa Ismail 2021-06-02  1154  	if (!qp || qp->destroy_pending) {
2c4b14ea950710 Shiraz Saleem  2022-02-17  1155  		ret_code = -EFAULT;
551c46edc7690c Mustafa Ismail 2021-06-02  1156  		goto exit;
551c46edc7690c Mustafa Ismail 2021-06-02  1157  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1158  	wqe_idx = (u32)FIELD_GET(IRDMA_CQ_WQEIDX, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1159  	info->qp_handle = (irdma_qp_handle)(unsigned long)qp;
376b89f7f8be5f Mustafa Ismail 2022-11-04  1160  	info->op_type = (u8)FIELD_GET(IRDMA_CQ_SQ, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1161  
376b89f7f8be5f Mustafa Ismail 2022-11-04  1162  	if (info->q_type == IRDMA_CQE_QTYPE_RQ) {
551c46edc7690c Mustafa Ismail 2021-06-02  1163  		u32 array_idx;
551c46edc7690c Mustafa Ismail 2021-06-02  1164  
551c46edc7690c Mustafa Ismail 2021-06-02  1165  		array_idx = wqe_idx / qp->rq_wqe_size_multiplier;
551c46edc7690c Mustafa Ismail 2021-06-02  1166  
551c46edc7690c Mustafa Ismail 2021-06-02  1167  		if (info->comp_status == IRDMA_COMPL_STATUS_FLUSHED ||
551c46edc7690c Mustafa Ismail 2021-06-02  1168  		    info->comp_status == IRDMA_COMPL_STATUS_UNKNOWN) {
551c46edc7690c Mustafa Ismail 2021-06-02  1169  			if (!IRDMA_RING_MORE_WORK(qp->rq_ring)) {
2c4b14ea950710 Shiraz Saleem  2022-02-17  1170  				ret_code = -ENOENT;
551c46edc7690c Mustafa Ismail 2021-06-02  1171  				goto exit;
551c46edc7690c Mustafa Ismail 2021-06-02  1172  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1173  
551c46edc7690c Mustafa Ismail 2021-06-02  1174  			info->wr_id = qp->rq_wrid_array[qp->rq_ring.tail];
551c46edc7690c Mustafa Ismail 2021-06-02  1175  			array_idx = qp->rq_ring.tail;
551c46edc7690c Mustafa Ismail 2021-06-02  1176  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1177  			info->wr_id = qp->rq_wrid_array[array_idx];
551c46edc7690c Mustafa Ismail 2021-06-02  1178  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1179  
551c46edc7690c Mustafa Ismail 2021-06-02  1180  		info->bytes_xfered = (u32)FIELD_GET(IRDMACQ_PAYLDLEN, qword0);
551c46edc7690c Mustafa Ismail 2021-06-02  1181  
551c46edc7690c Mustafa Ismail 2021-06-02  1182  		if (qword3 & IRDMACQ_STAG) {
551c46edc7690c Mustafa Ismail 2021-06-02  1183  			info->stag_invalid_set = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1184  			info->inv_stag = (u32)FIELD_GET(IRDMACQ_INVSTAG, qword2);
551c46edc7690c Mustafa Ismail 2021-06-02  1185  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1186  			info->stag_invalid_set = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1187  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1188  		IRDMA_RING_SET_TAIL(qp->rq_ring, array_idx + 1);
551c46edc7690c Mustafa Ismail 2021-06-02  1189  		if (info->comp_status == IRDMA_COMPL_STATUS_FLUSHED) {
551c46edc7690c Mustafa Ismail 2021-06-02  1190  			qp->rq_flush_seen = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1191  			if (!IRDMA_RING_MORE_WORK(qp->rq_ring))
551c46edc7690c Mustafa Ismail 2021-06-02  1192  				qp->rq_flush_complete = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1193  			else
551c46edc7690c Mustafa Ismail 2021-06-02  1194  				move_cq_head = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1195  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1196  		pring = &qp->rq_ring;
551c46edc7690c Mustafa Ismail 2021-06-02  1197  	} else { /* q_type is IRDMA_CQE_QTYPE_SQ */
551c46edc7690c Mustafa Ismail 2021-06-02  1198  		if (qp->first_sq_wq) {
551c46edc7690c Mustafa Ismail 2021-06-02  1199  			if (wqe_idx + 1 >= qp->conn_wqes)
551c46edc7690c Mustafa Ismail 2021-06-02  1200  				qp->first_sq_wq = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1201  
551c46edc7690c Mustafa Ismail 2021-06-02  1202  			if (wqe_idx < qp->conn_wqes && qp->sq_ring.head == qp->sq_ring.tail) {
551c46edc7690c Mustafa Ismail 2021-06-02  1203  				IRDMA_RING_MOVE_HEAD_NOCHECK(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1204  				IRDMA_RING_MOVE_TAIL(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1205  				set_64bit_val(cq->shadow_area, 0,
551c46edc7690c Mustafa Ismail 2021-06-02  1206  					      IRDMA_RING_CURRENT_HEAD(cq->cq_ring));
551c46edc7690c Mustafa Ismail 2021-06-02  1207  				memset(info, 0,
551c46edc7690c Mustafa Ismail 2021-06-02  1208  				       sizeof(struct irdma_cq_poll_info));
551c46edc7690c Mustafa Ismail 2021-06-02  1209  				return irdma_uk_cq_poll_cmpl(cq, info);
551c46edc7690c Mustafa Ismail 2021-06-02  1210  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1211  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1212  		/*cease posting push mode on push drop*/
551c46edc7690c Mustafa Ismail 2021-06-02  1213  		if (info->push_dropped) {
551c46edc7690c Mustafa Ismail 2021-06-02  1214  			qp->push_mode = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1215  			qp->push_dropped = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1216  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1217  		if (info->comp_status != IRDMA_COMPL_STATUS_FLUSHED) {
551c46edc7690c Mustafa Ismail 2021-06-02  1218  			info->wr_id = qp->sq_wrtrk_array[wqe_idx].wrid;
551c46edc7690c Mustafa Ismail 2021-06-02  1219  			if (!info->comp_status)
551c46edc7690c Mustafa Ismail 2021-06-02  1220  				info->bytes_xfered = qp->sq_wrtrk_array[wqe_idx].wr_len;
551c46edc7690c Mustafa Ismail 2021-06-02  1221  			info->op_type = (u8)FIELD_GET(IRDMACQ_OP, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1222  			IRDMA_RING_SET_TAIL(qp->sq_ring,
551c46edc7690c Mustafa Ismail 2021-06-02  1223  					    wqe_idx + qp->sq_wrtrk_array[wqe_idx].quanta);
551c46edc7690c Mustafa Ismail 2021-06-02  1224  		} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1225  			if (!IRDMA_RING_MORE_WORK(qp->sq_ring)) {
2c4b14ea950710 Shiraz Saleem  2022-02-17  1226  				ret_code = -ENOENT;
551c46edc7690c Mustafa Ismail 2021-06-02  1227  				goto exit;
551c46edc7690c Mustafa Ismail 2021-06-02  1228  			}
551c46edc7690c Mustafa Ismail 2021-06-02  1229  
551c46edc7690c Mustafa Ismail 2021-06-02  1230  			do {
551c46edc7690c Mustafa Ismail 2021-06-02  1231  				__le64 *sw_wqe;
551c46edc7690c Mustafa Ismail 2021-06-02  1232  				u64 wqe_qword;
551c46edc7690c Mustafa Ismail 2021-06-02  1233  				u32 tail;
551c46edc7690c Mustafa Ismail 2021-06-02  1234  
551c46edc7690c Mustafa Ismail 2021-06-02  1235  				tail = qp->sq_ring.tail;
551c46edc7690c Mustafa Ismail 2021-06-02  1236  				sw_wqe = qp->sq_base[tail].elem;
551c46edc7690c Mustafa Ismail 2021-06-02  1237  				get_64bit_val(sw_wqe, 24,
551c46edc7690c Mustafa Ismail 2021-06-02  1238  					      &wqe_qword);
376b89f7f8be5f Mustafa Ismail 2022-11-04  1239  				info->op_type = (u8)FIELD_GET(IRDMAQPSQ_OPCODE, wqe_qword);
551c46edc7690c Mustafa Ismail 2021-06-02  1240  				IRDMA_RING_SET_TAIL(qp->sq_ring,
551c46edc7690c Mustafa Ismail 2021-06-02  1241  						    tail + qp->sq_wrtrk_array[tail].quanta);
376b89f7f8be5f Mustafa Ismail 2022-11-04  1242  				if (info->op_type != IRDMAQP_OP_NOP) {
551c46edc7690c Mustafa Ismail 2021-06-02  1243  					info->wr_id = qp->sq_wrtrk_array[tail].wrid;
551c46edc7690c Mustafa Ismail 2021-06-02  1244  					info->bytes_xfered = qp->sq_wrtrk_array[tail].wr_len;
551c46edc7690c Mustafa Ismail 2021-06-02  1245  					break;
551c46edc7690c Mustafa Ismail 2021-06-02  1246  				}
551c46edc7690c Mustafa Ismail 2021-06-02  1247  			} while (1);
dcb23bbb1de7e0 Sindhu-Devale  2022-09-06 @1248  			if (op_type == IRDMA_OP_TYPE_BIND_MW && info->minor_err == FLUSH_PROT_ERR)
dcb23bbb1de7e0 Sindhu-Devale  2022-09-06  1249  				info->minor_err = FLUSH_MW_BIND_ERR;
551c46edc7690c Mustafa Ismail 2021-06-02  1250  			qp->sq_flush_seen = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1251  			if (!IRDMA_RING_MORE_WORK(qp->sq_ring))
551c46edc7690c Mustafa Ismail 2021-06-02  1252  				qp->sq_flush_complete = true;
551c46edc7690c Mustafa Ismail 2021-06-02  1253  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1254  		pring = &qp->sq_ring;
551c46edc7690c Mustafa Ismail 2021-06-02  1255  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1256  
551c46edc7690c Mustafa Ismail 2021-06-02  1257  	ret_code = 0;
551c46edc7690c Mustafa Ismail 2021-06-02  1258  
551c46edc7690c Mustafa Ismail 2021-06-02  1259  exit:
551c46edc7690c Mustafa Ismail 2021-06-02  1260  	if (!ret_code && info->comp_status == IRDMA_COMPL_STATUS_FLUSHED)
551c46edc7690c Mustafa Ismail 2021-06-02  1261  		if (pring && IRDMA_RING_MORE_WORK(*pring))
551c46edc7690c Mustafa Ismail 2021-06-02  1262  			move_cq_head = false;
551c46edc7690c Mustafa Ismail 2021-06-02  1263  
551c46edc7690c Mustafa Ismail 2021-06-02  1264  	if (move_cq_head) {
551c46edc7690c Mustafa Ismail 2021-06-02  1265  		IRDMA_RING_MOVE_HEAD_NOCHECK(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1266  		if (!IRDMA_RING_CURRENT_HEAD(cq->cq_ring))
551c46edc7690c Mustafa Ismail 2021-06-02  1267  			cq->polarity ^= 1;
551c46edc7690c Mustafa Ismail 2021-06-02  1268  
551c46edc7690c Mustafa Ismail 2021-06-02  1269  		if (ext_valid && !cq->avoid_mem_cflct) {
551c46edc7690c Mustafa Ismail 2021-06-02  1270  			IRDMA_RING_MOVE_HEAD_NOCHECK(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1271  			if (!IRDMA_RING_CURRENT_HEAD(cq->cq_ring))
551c46edc7690c Mustafa Ismail 2021-06-02  1272  				cq->polarity ^= 1;
551c46edc7690c Mustafa Ismail 2021-06-02  1273  		}
551c46edc7690c Mustafa Ismail 2021-06-02  1274  
551c46edc7690c Mustafa Ismail 2021-06-02  1275  		IRDMA_RING_MOVE_TAIL(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1276  		if (!cq->avoid_mem_cflct && ext_valid)
551c46edc7690c Mustafa Ismail 2021-06-02  1277  			IRDMA_RING_MOVE_TAIL(cq->cq_ring);
551c46edc7690c Mustafa Ismail 2021-06-02  1278  		set_64bit_val(cq->shadow_area, 0,
551c46edc7690c Mustafa Ismail 2021-06-02  1279  			      IRDMA_RING_CURRENT_HEAD(cq->cq_ring));
551c46edc7690c Mustafa Ismail 2021-06-02  1280  	} else {
551c46edc7690c Mustafa Ismail 2021-06-02  1281  		qword3 &= ~IRDMA_CQ_WQEIDX;
551c46edc7690c Mustafa Ismail 2021-06-02  1282  		qword3 |= FIELD_PREP(IRDMA_CQ_WQEIDX, pring->tail);
551c46edc7690c Mustafa Ismail 2021-06-02  1283  		set_64bit_val(cqe, 24, qword3);
551c46edc7690c Mustafa Ismail 2021-06-02  1284  	}
551c46edc7690c Mustafa Ismail 2021-06-02  1285  
551c46edc7690c Mustafa Ismail 2021-06-02  1286  	return ret_code;
551c46edc7690c Mustafa Ismail 2021-06-02  1287  }
551c46edc7690c Mustafa Ismail 2021-06-02  1288
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/irdma/uk.c b/drivers/infiniband/hw/irdma/uk.c
index 4424224..3d2c770 100644
--- a/drivers/infiniband/hw/irdma/uk.c
+++ b/drivers/infiniband/hw/irdma/uk.c
@@ -1046,7 +1046,7 @@  int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
 	__le64 *cqe;
 	struct irdma_qp_uk *qp;
 	struct irdma_ring *pring = NULL;
-	u32 wqe_idx, q_type;
+	u32 wqe_idx;
 	int ret_code;
 	bool move_cq_head = true;
 	u8 polarity;
@@ -1118,7 +1118,7 @@  int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
 		info->ud_vlan_valid = false;
 	}
 
-	q_type = (u8)FIELD_GET(IRDMA_CQ_SQ, qword3);
+	info->q_type = (u8)FIELD_GET(IRDMA_CQ_SQ, qword3);
 	info->error = (bool)FIELD_GET(IRDMA_CQ_ERROR, qword3);
 	info->push_dropped = (bool)FIELD_GET(IRDMACQ_PSHDROP, qword3);
 	info->ipv4 = (bool)FIELD_GET(IRDMACQ_IPV4, qword3);
@@ -1157,8 +1157,9 @@  int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
 	}
 	wqe_idx = (u32)FIELD_GET(IRDMA_CQ_WQEIDX, qword3);
 	info->qp_handle = (irdma_qp_handle)(unsigned long)qp;
+	info->op_type = (u8)FIELD_GET(IRDMA_CQ_SQ, qword3);
 
-	if (q_type == IRDMA_CQE_QTYPE_RQ) {
+	if (info->q_type == IRDMA_CQE_QTYPE_RQ) {
 		u32 array_idx;
 
 		array_idx = wqe_idx / qp->rq_wqe_size_multiplier;
@@ -1178,10 +1179,6 @@  int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
 
 		info->bytes_xfered = (u32)FIELD_GET(IRDMACQ_PAYLDLEN, qword0);
 
-		if (info->imm_valid)
-			info->op_type = IRDMA_OP_TYPE_REC_IMM;
-		else
-			info->op_type = IRDMA_OP_TYPE_REC;
 		if (qword3 & IRDMACQ_STAG) {
 			info->stag_invalid_set = true;
 			info->inv_stag = (u32)FIELD_GET(IRDMACQ_INVSTAG, qword2);
@@ -1239,11 +1236,10 @@  int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
 				sw_wqe = qp->sq_base[tail].elem;
 				get_64bit_val(sw_wqe, 24,
 					      &wqe_qword);
-				op_type = (u8)FIELD_GET(IRDMAQPSQ_OPCODE, wqe_qword);
-				info->op_type = op_type;
+				info->op_type = (u8)FIELD_GET(IRDMAQPSQ_OPCODE, wqe_qword);
 				IRDMA_RING_SET_TAIL(qp->sq_ring,
 						    tail + qp->sq_wrtrk_array[tail].quanta);
-				if (op_type != IRDMAQP_OP_NOP) {
+				if (info->op_type != IRDMAQP_OP_NOP) {
 					info->wr_id = qp->sq_wrtrk_array[tail].wrid;
 					info->bytes_xfered = qp->sq_wrtrk_array[tail].wr_len;
 					break;
diff --git a/drivers/infiniband/hw/irdma/user.h b/drivers/infiniband/hw/irdma/user.h
index f5d3a7c..ac397b7 100644
--- a/drivers/infiniband/hw/irdma/user.h
+++ b/drivers/infiniband/hw/irdma/user.h
@@ -245,6 +245,7 @@  struct irdma_cq_poll_info {
 	u16 ud_vlan;
 	u8 ud_smac[6];
 	u8 op_type;
+	u8 q_type;
 	bool stag_invalid_set:1; /* or L_R_Key set */
 	bool push_dropped:1;
 	bool error:1;
diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c
index 8dfc9e1..445e69e8 100644
--- a/drivers/infiniband/hw/irdma/utils.c
+++ b/drivers/infiniband/hw/irdma/utils.c
@@ -2591,6 +2591,7 @@  void irdma_generate_flush_completions(struct irdma_qp *iwqp)
 			sw_wqe = qp->sq_base[wqe_idx].elem;
 			get_64bit_val(sw_wqe, 24, &wqe_qword);
 			cmpl->cpi.op_type = (u8)FIELD_GET(IRDMAQPSQ_OPCODE, IRDMAQPSQ_OPCODE);
+			cmpl->cpi.q_type = IRDMA_CQE_QTYPE_SQ;
 			/* remove the SQ WR by moving SQ tail*/
 			IRDMA_RING_SET_TAIL(*sq_ring,
 				sq_ring->tail + qp->sq_wrtrk_array[sq_ring->tail].quanta);
@@ -2629,6 +2630,7 @@  void irdma_generate_flush_completions(struct irdma_qp *iwqp)
 
 			cmpl->cpi.wr_id = qp->rq_wrid_array[wqe_idx];
 			cmpl->cpi.op_type = IRDMA_OP_TYPE_REC;
+			cmpl->cpi.q_type = IRDMA_CQE_QTYPE_RQ;
 			/* remove the RQ WR by moving RQ tail */
 			IRDMA_RING_SET_TAIL(*rq_ring, rq_ring->tail + 1);
 			ibdev_dbg(iwqp->iwrcq->ibcq.device,
diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index b2006a0..4f28d99 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -3354,6 +3354,61 @@  static enum ib_wc_status irdma_flush_err_to_ib_wc_status(enum irdma_flush_opcode
 	}
 }
 
+static inline void set_ib_wc_op_sq(struct irdma_cq_poll_info *cq_poll_info,
+				   struct ib_wc *entry)
+{
+	struct irdma_sc_qp *qp;
+
+	switch (cq_poll_info->op_type) {
+	case IRDMA_OP_TYPE_RDMA_WRITE:
+	case IRDMA_OP_TYPE_RDMA_WRITE_SOL:
+	entry->opcode = IB_WC_RDMA_WRITE;
+		break;
+	case IRDMA_OP_TYPE_RDMA_READ_INV_STAG:
+	case IRDMA_OP_TYPE_RDMA_READ:
+		entry->opcode = IB_WC_RDMA_READ;
+		break;
+	case IRDMA_OP_TYPE_SEND_SOL:
+	case IRDMA_OP_TYPE_SEND_SOL_INV:
+	case IRDMA_OP_TYPE_SEND_INV:
+	case IRDMA_OP_TYPE_SEND:
+		entry->opcode = IB_WC_SEND;
+		break;
+	case IRDMA_OP_TYPE_FAST_REG_NSMR:
+		entry->opcode = IB_WC_REG_MR;
+		break;
+	case IRDMA_OP_TYPE_INV_STAG:
+		entry->opcode = IB_WC_LOCAL_INV;
+		break;
+	default:
+		qp = cq_poll_info->qp_handle;
+		entry->status = IB_WC_GENERAL_ERR;
+	}
+}
+
+static inline void set_ib_wc_op_rq(struct irdma_cq_poll_info *cq_poll_info,
+				   struct ib_wc *entry, bool send_imm_support)
+{
+	/**
+	 * iWARP does not support sendImm, so the presence of Imm data
+	 * must be WriteImm.
+	 */
+	if (!send_imm_support) {
+		entry->opcode = cq_poll_info->imm_valid ?
+				IB_WC_RECV_RDMA_WITH_IMM : IB_WC_RECV;
+		return;
+	}
+
+	switch (cq_poll_info->op_type) {
+	case IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE:
+	case IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE:
+		entry->opcode = IB_WC_RECV_RDMA_WITH_IMM;
+		break;
+	default:
+		entry->opcode = IB_WC_RECV;
+	}
+}
+
 /**
  * irdma_process_cqe - process cqe info
  * @entry: processed cqe
@@ -3362,7 +3417,6 @@  static enum ib_wc_status irdma_flush_err_to_ib_wc_status(enum irdma_flush_opcode
 static void irdma_process_cqe(struct ib_wc *entry,
 			      struct irdma_cq_poll_info *cq_poll_info)
 {
-	struct irdma_qp *iwqp;
 	struct irdma_sc_qp *qp;
 
 	entry->wc_flags = 0;
@@ -3370,7 +3424,6 @@  static void irdma_process_cqe(struct ib_wc *entry,
 	entry->wr_id = cq_poll_info->wr_id;
 
 	qp = cq_poll_info->qp_handle;
-	iwqp = qp->qp_uk.back_qp;
 	entry->qp = qp->qp_uk.back_qp;
 
 	if (cq_poll_info->error) {
@@ -3403,42 +3456,17 @@  static void irdma_process_cqe(struct ib_wc *entry,
 		}
 	}
 
-	switch (cq_poll_info->op_type) {
-	case IRDMA_OP_TYPE_RDMA_WRITE:
-	case IRDMA_OP_TYPE_RDMA_WRITE_SOL:
-		entry->opcode = IB_WC_RDMA_WRITE;
-		break;
-	case IRDMA_OP_TYPE_RDMA_READ_INV_STAG:
-	case IRDMA_OP_TYPE_RDMA_READ:
-		entry->opcode = IB_WC_RDMA_READ;
-		break;
-	case IRDMA_OP_TYPE_SEND_INV:
-	case IRDMA_OP_TYPE_SEND_SOL:
-	case IRDMA_OP_TYPE_SEND_SOL_INV:
-	case IRDMA_OP_TYPE_SEND:
-		entry->opcode = IB_WC_SEND;
-		break;
-	case IRDMA_OP_TYPE_FAST_REG_NSMR:
-		entry->opcode = IB_WC_REG_MR;
-		break;
-	case IRDMA_OP_TYPE_INV_STAG:
-		entry->opcode = IB_WC_LOCAL_INV;
-		break;
-	case IRDMA_OP_TYPE_REC_IMM:
-	case IRDMA_OP_TYPE_REC:
-		entry->opcode = cq_poll_info->op_type == IRDMA_OP_TYPE_REC_IMM ?
-			IB_WC_RECV_RDMA_WITH_IMM : IB_WC_RECV;
+	if (cq_poll_info->q_type == IRDMA_CQE_QTYPE_SQ) {
+		set_ib_wc_op_sq(cq_poll_info, entry);
+	} else {
+		set_ib_wc_op_rq(cq_poll_info, entry,
+				qp->qp_uk.qp_caps & IRDMA_SEND_WITH_IMM ?
+				true : false);
 		if (qp->qp_uk.qp_type != IRDMA_QP_TYPE_ROCE_UD &&
 		    cq_poll_info->stag_invalid_set) {
 			entry->ex.invalidate_rkey = cq_poll_info->inv_stag;
 			entry->wc_flags |= IB_WC_WITH_INVALIDATE;
 		}
-		break;
-	default:
-		ibdev_err(&iwqp->iwdev->ibdev,
-			  "Invalid opcode = %d in CQE\n", cq_poll_info->op_type);
-		entry->status = IB_WC_GENERAL_ERR;
-		return;
 	}
 
 	if (qp->qp_uk.qp_type == IRDMA_QP_TYPE_ROCE_UD) {