net/bnxt: add conditional opcodes for mapper result table
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Mon, 6 Jul 2020 08:24:57 +0000 (13:54 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:53 +0000 (06:18 +0200)
Added support for conditional mapper result opcodes. The conditional
opcodes allows to set the action details in hardware based on the
actions configured for the flow. This allows aggregation of multiple
templates.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/ulp_mapper.c
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
drivers/net/bnxt/tf_ulp/ulp_template_struct.h

index 30180d8..86858b8 100644 (file)
@@ -840,8 +840,74 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
                        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;
        default:
+               BNXT_TF_DBG(ERR, "invalid result mapper opcode 0x%x\n",
+                           fld->result_opcode);
                return -EINVAL;
        }
        return 0;
@@ -973,6 +1039,9 @@ ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
                }
                break;
        default:
+               BNXT_TF_DBG(ERR, "invalid keymask mapper opcode 0x%x\n",
+                           opcode);
+               return -EINVAL;
                break;
        }
 
index 14c77b3..2d73ea3 100644 (file)
@@ -212,7 +212,9 @@ enum bnxt_ulp_mapper_opc {
        BNXT_ULP_MAPPER_OPC_SET_TO_ACT_BIT = 6,
        BNXT_ULP_MAPPER_OPC_SET_TO_ACT_PROP = 7,
        BNXT_ULP_MAPPER_OPC_SET_TO_ENCAP_ACT_PROP_SZ = 8,
-       BNXT_ULP_MAPPER_OPC_LAST = 9
+       BNXT_ULP_MAPPER_OPC_IF_ACT_BIT_THEN_ACT_PROP_ELSE_CONST = 9,
+       BNXT_ULP_MAPPER_OPC_IF_ACT_BIT_THEN_CONST_ELSE_CONST = 10,
+       BNXT_ULP_MAPPER_OPC_LAST = 11
 };
 
 enum bnxt_ulp_mark_db_opcode {
index ea4f253..2f2f9a2 100644 (file)
@@ -213,6 +213,8 @@ struct bnxt_ulp_mapper_result_field_info {
        enum bnxt_ulp_mapper_opc        result_opcode;
        uint16_t                        field_bit_size;
        uint8_t                         result_operand[16];
+       uint8_t                         result_operand_true[16];
+       uint8_t                         result_operand_false[16];
 };
 
 struct bnxt_ulp_mapper_ident_info {