- uint32_t src1_sel = 0;
- enum bnxt_ulp_field_src fld_src;
- uint8_t *fld_src_oper;
- enum bnxt_ulp_field_cond_src field_cond_src;
- uint16_t const_val = 0;
- uint32_t update_flag = 0;
- uint64_t src1_val64;
- uint32_t port_id;
-
- /* process the field opcode */
- if (fld->field_opc != BNXT_ULP_FIELD_OPC_COND_OP) {
- field_cond_src = BNXT_ULP_FIELD_COND_SRC_TRUE;
- /* Read the constant from the second operand */
- memcpy(&const_val, fld->field_opr2, sizeof(uint16_t));
- const_val = tfp_be_to_cpu_16(const_val);
- } else {
- field_cond_src = fld->field_cond_src;
- }
-
- bitlen = fld->field_bit_size;
- /* Evaluate the condition */
- switch (field_cond_src) {
- case BNXT_ULP_FIELD_COND_SRC_TRUE:
- src1_sel = 1;
- break;
- case BNXT_ULP_FIELD_COND_SRC_CF:
- if (!ulp_operand_read(fld->field_cond_opr,
- (uint8_t *)&idx, sizeof(uint16_t))) {
- BNXT_TF_DBG(ERR, "%s operand read failed.\n", name);
- return -EINVAL;
- }
- idx = tfp_be_to_cpu_16(idx);
- if (idx >= BNXT_ULP_CF_IDX_LAST) {
- BNXT_TF_DBG(ERR, "%s invalid index %u\n", name, idx);
- return -EINVAL;
- }
- /* check if the computed field is set */
- if (ULP_COMP_FLD_IDX_RD(parms, idx))
- src1_sel = 1;
- break;
- case BNXT_ULP_FIELD_COND_SRC_RF:
- if (!ulp_operand_read(fld->field_cond_opr,
- (uint8_t *)&idx, sizeof(uint16_t))) {
- BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
- return -EINVAL;
- }
-
- idx = tfp_be_to_cpu_16(idx);
- /* Uninitialized regfile entries return 0 */
- if (!ulp_regfile_read(parms->regfile, idx, ®val)) {
- BNXT_TF_DBG(ERR, "%s regfile[%d] read oob\n",
- name, idx);
- return -EINVAL;
- }
- if (regval)
- src1_sel = 1;
- break;
- case BNXT_ULP_FIELD_COND_SRC_ACT_BIT:
- if (!ulp_operand_read(fld->field_cond_opr,
- (uint8_t *)&act_bit, sizeof(uint64_t))) {
- BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
- return -EINVAL;
- }
- act_bit = tfp_be_to_cpu_64(act_bit);
- if (ULP_BITMAP_ISSET(parms->act_bitmap->bits, act_bit))
- src1_sel = 1;
- break;
- case BNXT_ULP_FIELD_COND_SRC_HDR_BIT:
- if (!ulp_operand_read(fld->field_cond_opr,
- (uint8_t *)&hdr_bit, sizeof(uint64_t))) {
- BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
- return -EINVAL;
- }
- hdr_bit = tfp_be_to_cpu_64(hdr_bit);
- if (ULP_BITMAP_ISSET(parms->hdr_bitmap->bits, hdr_bit))
- src1_sel = 1;
- break;
- case BNXT_ULP_FIELD_COND_SRC_FIELD_BIT:
- if (!ulp_operand_read(fld->field_cond_opr, (uint8_t *)&idx,
- sizeof(uint16_t))) {
- BNXT_TF_DBG(ERR, "%s operand read failed.\n", name);
- return -EINVAL;
- }
- idx = tfp_be_to_cpu_16(idx);
- /* get the index from the global field list */
- if (ulp_mapper_glb_field_tbl_get(parms, idx, &bit)) {
- BNXT_TF_DBG(ERR, "invalid ulp_glb_field_tbl idx %d\n",
- idx);
- return -EINVAL;
- }
- if (bit && (ULP_INDEX_BITMAP_GET(parms->fld_bitmap->bits, bit)))
- src1_sel = 1;
- break;
- default:
- BNXT_TF_DBG(ERR, "%s invalid field opcode 0x%x at %d\n",
- name, fld->field_cond_src, write_idx);
- return -EINVAL;
- }
-
- /* pick the selected source */
- if (src1_sel) {
- fld_src = fld->field_src1;
- fld_src_oper = fld->field_opr1;
- } else {
- fld_src = fld->field_src2;
- fld_src_oper = fld->field_opr2;
- }
-