+ case BNXT_ULP_MAPPER_OPC_SET_TO_GLB_REGFILE:
+ if (!ulp_operand_read(fld->result_operand,
+ (uint8_t *)&idx,
+ sizeof(uint16_t))) {
+ BNXT_TF_DBG(ERR, "%s key operand read failed.\n", name);
+ return -EINVAL;
+ }
+ idx = tfp_be_to_cpu_16(idx);
+ if (ulp_mapper_glb_resource_read(parms->mapper_data,
+ dir,
+ idx, ®val)) {
+ BNXT_TF_DBG(ERR, "%s regfile[%d] read failed.\n",
+ name, idx);
+ return -EINVAL;
+ }
+ val = ulp_blob_push_64(blob, ®val, fld->field_bit_size);
+ if (!val) {
+ BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
+ return -EINVAL;
+ }
+ break;
+ case BNXT_ULP_MAPPER_OPC_SET_TO_COMP_FIELD:
+ if (!ulp_operand_read(fld->result_operand,
+ (uint8_t *)&idx,
+ sizeof(uint16_t))) {
+ BNXT_TF_DBG(ERR, "%s key operand read failed.\n", name);
+ return -EINVAL;
+ }
+ idx = tfp_be_to_cpu_16(idx);
+ if (idx < BNXT_ULP_CF_IDX_LAST)
+ val = ulp_blob_push_32(blob, &parms->comp_fld[idx],
+ fld->field_bit_size);
+ if (!val) {
+ BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
+ return -EINVAL;
+ }
+ break;
+ case BNXT_ULP_MAPPER_OPC_SET_TO_ZERO:
+ if (ulp_blob_pad_push(blob, fld->field_bit_size) < 0) {
+ BNXT_TF_DBG(ERR, "%s too large for blob\n", name);
+ return -EINVAL;
+ }
+
+ break;
+ case BNXT_ULP_MAPPER_OPC_IF_ACT_BIT_THEN_ACT_PROP_ELSE_CONST:
+ if (!ulp_operand_read(fld->result_operand,
+ (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)) {
+ /* Action bit is set so consider operand_true */
+ if (!ulp_operand_read(fld->result_operand_true,
+ (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_ACT_PROP_IDX_LAST) {
+ BNXT_TF_DBG(ERR, "%s act_prop[%d] oob\n",
+ name, idx);
+ return -EINVAL;
+ }
+ val = &parms->act_prop->act_details[idx];
+ field_size = ulp_mapper_act_prop_size_get(idx);
+ if (fld->field_bit_size < ULP_BYTE_2_BITS(field_size)) {
+ field_size = field_size -
+ ((fld->field_bit_size + 7) / 8);
+ val += field_size;
+ }
+ if (!ulp_blob_push(blob, val, fld->field_bit_size)) {
+ BNXT_TF_DBG(ERR, "%s push field failed\n",
+ name);
+ return -EINVAL;
+ }
+ } else {
+ /* action bit is not set, use the operand false */
+ val = fld->result_operand_false;
+ if (!ulp_blob_push(blob, val, fld->field_bit_size)) {
+ BNXT_TF_DBG(ERR, "%s failed to add field\n",
+ name);
+ return -EINVAL;
+ }
+ }
+ break;
+ case BNXT_ULP_MAPPER_OPC_IF_ACT_BIT_THEN_CONST_ELSE_CONST:
+ if (!ulp_operand_read(fld->result_operand,
+ (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)) {
+ /* Action bit is set so consider operand_true */
+ val = fld->result_operand_true;
+ } else {
+ /* action bit is not set, use the operand false */
+ val = fld->result_operand_false;
+ }
+ if (!ulp_blob_push(blob, val, fld->field_bit_size)) {
+ BNXT_TF_DBG(ERR, "%s failed to add field\n",
+ name);
+ return -EINVAL;
+ }
+ break;
+ case BNXT_ULP_MAPPER_OPC_IF_COMP_FIELD_THEN_CF_ELSE_CF:
+ if (!ulp_operand_read(fld->result_operand,
+ (uint8_t *)&idx,
+ sizeof(uint16_t))) {
+ BNXT_TF_DBG(ERR, "%s key 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))
+ val = fld->result_operand_true;
+ else
+ val = fld->result_operand_false;
+
+ /* read the appropriate computed field */
+ if (!ulp_operand_read(val, (uint8_t *)&idx, sizeof(uint16_t))) {
+ BNXT_TF_DBG(ERR, "%s val 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;
+ }
+ val = ulp_blob_push_32(blob, &parms->comp_fld[idx],
+ fld->field_bit_size);
+ if (!val) {
+ BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
+ return -EINVAL;
+ }
+ break;
+ case BNXT_ULP_MAPPER_OPC_IF_HDR_BIT_THEN_CONST_ELSE_CONST:
+ if (!ulp_operand_read(fld->result_operand,
+ (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)) {
+ /* Header bit is set so consider operand_true */
+ val = fld->result_operand_true;
+ } else {
+ /* Header bit is not set, use the operand false */
+ val = fld->result_operand_false;
+ }
+ if (!ulp_blob_push(blob, val, fld->field_bit_size)) {
+ BNXT_TF_DBG(ERR, "%s failed to add field\n",
+ name);
+ return -EINVAL;
+ }
+ break;