Lines Matching refs:action

584 	/* Check action state machine is valid */
650 /* Ignore the modify TTL action.
651 * It is always kept as last HW action.
781 struct mlx5dr_action *action;
785 action = actions[i];
786 action_type = action->action_type;
794 dest_action = action;
795 ret = dr_action_get_dest_tbl_addr(matcher, action->dest_tbl,
802 action->range->hit_tbl_action->dest_tbl,
808 action->range->miss_tbl_action->dest_tbl,
813 attr.range.definer_id = action->range->definer_id;
814 attr.range.min = action->range->min;
815 attr.range.max = action->range->max;
821 attr.ctr_id = action->ctr->ctr_id +
822 action->ctr->offset;
825 attr.flow_tag = action->flow_tag->flow_tag;
830 if (action->rewrite->ptrn && action->rewrite->arg) {
831 attr.decap_index = mlx5dr_arg_get_obj_id(action->rewrite->arg);
832 attr.decap_actions = action->rewrite->ptrn->num_of_actions;
833 attr.decap_pat_idx = action->rewrite->ptrn->index;
835 attr.decap_index = action->rewrite->index;
836 attr.decap_actions = action->rewrite->num_of_actions;
843 if (action->rewrite->single_action_opt) {
844 attr.modify_actions = action->rewrite->num_of_actions;
845 attr.single_modify_action = action->rewrite->data;
847 if (action->rewrite->ptrn && action->rewrite->arg) {
849 mlx5dr_arg_get_obj_id(action->rewrite->arg);
850 attr.modify_actions = action->rewrite->ptrn->num_of_actions;
851 attr.modify_pat_idx = action->rewrite->ptrn->index;
853 attr.modify_index = action->rewrite->index;
854 attr.modify_actions = action->rewrite->num_of_actions;
858 if (action->rewrite->modify_ttl)
869 attr.reformat.size = action->reformat->size;
870 attr.reformat.id = action->reformat->id;
873 attr.final_icm_addr = rx_rule ? action->sampler->rx_icm_addr :
874 action->sampler->tx_icm_addr;
877 if (unlikely(rx_rule && action->vport->caps->num == MLX5_VPORT_UPLINK)) {
882 attr.hit_gvmi = action->vport->caps->vhca_gvmi;
883 dest_action = action;
885 action->vport->caps->icm_address_rx :
886 action->vport->caps->icm_address_tx;
892 mlx5dr_dbg(dmn, "Device doesn't support POP VLAN action on TX\n");
902 mlx5dr_dbg(dmn, "Device doesn't support PUSH VLAN action on RX\n");
912 attr.vlans.headers[attr.vlans.count++] = action->push_vlan->vlan_hdr;
916 attr.reformat.size = action->reformat->size;
917 attr.reformat.id = action->reformat->id;
918 attr.reformat.param_0 = action->reformat->param_0;
919 attr.reformat.param_1 = action->reformat->param_1;
922 attr.aso_flow_meter.obj_id = action->aso->obj_id;
923 attr.aso_flow_meter.offset = action->aso->offset;
924 attr.aso_flow_meter.dest_reg_id = action->aso->dest_reg_id;
925 attr.aso_flow_meter.init_color = action->aso->init_color;
928 mlx5dr_err(dmn, "Unsupported action type %d\n", action_type);
932 /* Check action duplication */
939 /* Check action state machine is valid */
943 mlx5dr_err(dmn, "Invalid action (gvmi: %d, is_rx: %d) sequence provided:",
994 struct mlx5dr_action *action;
1002 action = kzalloc(sizeof(*action) + extra_size, GFP_KERNEL);
1003 if (!action)
1006 action->action_type = action_type;
1007 refcount_set(&action->refcount, 1);
1008 action->data = action + 1;
1010 return action;
1021 struct mlx5dr_action *action;
1023 action = dr_action_create_generic(DR_ACTION_TYP_FT);
1024 if (!action)
1027 action->dest_tbl->is_fw_tbl = true;
1028 action->dest_tbl->fw_tbl.dmn = dmn;
1029 action->dest_tbl->fw_tbl.id = table_num;
1030 action->dest_tbl->fw_tbl.type = FS_FT_FDB;
1033 return action;
1039 struct mlx5dr_action *action;
1043 action = dr_action_create_generic(DR_ACTION_TYP_FT);
1044 if (!action)
1047 action->dest_tbl->tbl = tbl;
1049 return action;
1077 static int dr_action_create_range_definer(struct mlx5dr_action *action)
1082 struct mlx5dr_domain *dmn = action->range->dmn;
1098 action->range->definer_id = definer_id;
1102 static void dr_action_destroy_range_definer(struct mlx5dr_action *action)
1104 mlx5dr_definer_put(action->range->dmn, action->range->definer_id);
1115 struct mlx5dr_action *action;
1129 action = dr_action_create_generic(DR_ACTION_TYP_RANGE);
1130 if (!action)
1133 action->range->hit_tbl_action =
1138 if (!action->range->hit_tbl_action)
1141 action->range->miss_tbl_action =
1146 if (!action->range->miss_tbl_action)
1149 action->range->min = min;
1150 action->range->max = max;
1151 action->range->dmn = dmn;
1153 ret = dr_action_create_range_definer(action);
1157 /* No need to increase refcount on domain for this action,
1161 return action;
1164 mlx5dr_action_destroy(action->range->miss_tbl_action);
1166 mlx5dr_action_destroy(action->range->hit_tbl_action);
1168 kfree(action);
1182 struct mlx5dr_action *action;
1249 mlx5dr_dbg(dmn, "Invalid multiple destinations action\n");
1261 action = dr_action_create_generic(DR_ACTION_TYP_FT);
1262 if (!action)
1269 &action->dest_tbl->fw_tbl.id,
1270 &action->dest_tbl->fw_tbl.group_id,
1281 action->dest_tbl->is_fw_tbl = true;
1282 action->dest_tbl->fw_tbl.dmn = dmn;
1283 action->dest_tbl->fw_tbl.type = FS_FT_FDB;
1284 action->dest_tbl->fw_tbl.ref_actions = ref_actions;
1285 action->dest_tbl->fw_tbl.num_of_ref_actions = num_of_ref;
1289 return action;
1292 kfree(action);
1304 struct mlx5dr_action *action;
1306 action = dr_action_create_generic(DR_ACTION_TYP_FT);
1307 if (!action)
1310 action->dest_tbl->is_fw_tbl = 1;
1311 action->dest_tbl->fw_tbl.type = ft->type;
1312 action->dest_tbl->fw_tbl.id = ft->id;
1313 action->dest_tbl->fw_tbl.dmn = dmn;
1317 return action;
1323 struct mlx5dr_action *action;
1325 action = dr_action_create_generic(DR_ACTION_TYP_CTR);
1326 if (!action)
1329 action->ctr->ctr_id = counter_id;
1331 return action;
1336 struct mlx5dr_action *action;
1338 action = dr_action_create_generic(DR_ACTION_TYP_TAG);
1339 if (!action)
1342 action->flow_tag->flow_tag = tag_value & 0xffffff;
1344 return action;
1350 struct mlx5dr_action *action;
1359 action = dr_action_create_generic(DR_ACTION_TYP_SAMPLER);
1360 if (!action)
1363 action->sampler->dmn = dmn;
1364 action->sampler->sampler_id = sampler_id;
1365 action->sampler->rx_icm_addr = icm_rx;
1366 action->sampler->tx_icm_addr = icm_tx;
1369 return action;
1427 struct mlx5dr_action *action)
1432 switch (action->action_type) {
1438 if (action->action_type == DR_ACTION_TYP_L2_TO_TNL_L2)
1449 action->reformat->id = reformat_id;
1450 action->reformat->size = data_sz;
1469 &action->rewrite->num_of_actions);
1471 mlx5dr_dbg(dmn, "Failed creating decap l3 action list\n");
1476 action->rewrite->data = hw_actions;
1477 action->rewrite->dmn = dmn;
1479 ret = mlx5dr_ste_alloc_modify_hdr(action);
1497 action->reformat->id = reformat_id;
1498 action->reformat->size = data_sz;
1499 action->reformat->param_0 = reformat_param_0;
1500 action->reformat->param_1 = reformat_param_1;
1503 action->reformat->id = 0;
1504 action->reformat->size = data_sz;
1505 action->reformat->param_0 = reformat_param_0;
1506 action->reformat->param_1 = reformat_param_1;
1509 mlx5dr_info(dmn, "Reformat type is not supported %d\n", action->action_type);
1527 struct mlx5dr_action *action;
1534 action = dr_action_create_generic(DR_ACTION_TYP_PUSH_VLAN);
1535 if (!action)
1538 action->push_vlan->vlan_hdr = vlan_hdr_h;
1539 return action;
1551 struct mlx5dr_action *action;
1569 action = dr_action_create_generic(action_type);
1570 if (!action)
1573 action->reformat->dmn = dmn;
1580 action);
1582 mlx5dr_dbg(dmn, "Failed creating reformat action %d\n", ret);
1586 return action;
1589 kfree(action);
1606 /* Get SW modify action data */
1610 /* Convert SW data to HW modify action format */
1613 mlx5dr_dbg(dmn, "Modify add action invalid field given\n");
1642 /* Get SW modify action data */
1648 /* Convert SW data to HW modify action format */
1651 mlx5dr_dbg(dmn, "Modify set action invalid field given\n");
1661 mlx5dr_dbg(dmn, "Modify action length + offset exceeds limit\n");
1689 /* Get SW modify action data */
1696 /* Convert SW data to HW modify action format */
1700 mlx5dr_dbg(dmn, "Modify copy action invalid field given\n");
1714 mlx5dr_dbg(dmn, "Modify action length + offset exceeds limit\n");
1739 u8 action;
1745 /* Get SW modify action type */
1746 action = MLX5_GET(set_action_in, sw_action, action_type);
1748 switch (action) {
1769 mlx5dr_info(dmn, "Unsupported action_type for modify action\n");
1777 dr_action_modify_check_set_field_limitation(struct mlx5dr_action *action,
1781 struct mlx5dr_domain *dmn = action->rewrite->dmn;
1784 action->rewrite->allow_rx = 0;
1786 mlx5dr_dbg(dmn, "Unsupported field %d for RX/FDB set action\n",
1791 action->rewrite->allow_tx = 0;
1793 mlx5dr_dbg(dmn, "Unsupported field %d for TX/FDB set action\n",
1799 if (!action->rewrite->allow_rx && !action->rewrite->allow_tx) {
1808 dr_action_modify_check_add_field_limitation(struct mlx5dr_action *action,
1812 struct mlx5dr_domain *dmn = action->rewrite->dmn;
1818 mlx5dr_dbg(dmn, "Unsupported field %d for add action\n",
1827 dr_action_modify_check_copy_field_limitation(struct mlx5dr_action *action,
1830 struct mlx5dr_domain *dmn = action->rewrite->dmn;
1839 action->rewrite->allow_rx = 0;
1841 mlx5dr_dbg(dmn, "Unsupported field %d for RX/FDB set action\n",
1846 action->rewrite->allow_tx = 0;
1848 mlx5dr_dbg(dmn, "Unsupported field %d for TX/FDB set action\n",
1855 if (!action->rewrite->allow_rx && !action->rewrite->allow_tx) {
1864 dr_action_modify_check_field_limitation(struct mlx5dr_action *action,
1867 struct mlx5dr_domain *dmn = action->rewrite->dmn;
1875 ret = dr_action_modify_check_set_field_limitation(action,
1880 ret = dr_action_modify_check_add_field_limitation(action,
1885 ret = dr_action_modify_check_copy_field_limitation(action,
1890 mlx5dr_info(dmn, "Unsupported action %d modify action\n",
1906 static int dr_actions_convert_modify_header(struct mlx5dr_action *action,
1916 struct mlx5dr_domain *dmn = action->rewrite->dmn;
1927 action->rewrite->allow_rx = 1;
1928 action->rewrite->allow_tx = 1;
1931 /* modify TTL is handled separately, as a last action */
1939 ret = dr_action_modify_check_field_limitation(action,
1951 /* Convert SW action to HW action */
1989 mlx5dr_dbg(dmn, "Modify header action number exceeds HW limit\n");
1999 /* if the resulting HW actions list is empty, add NOP action */
2011 struct mlx5dr_action *action)
2033 ret = dr_actions_convert_modify_header(action,
2043 action->rewrite->modify_ttl = modify_ttl;
2044 action->rewrite->data = (u8 *)hw_actions;
2045 action->rewrite->num_of_actions = num_hw_actions;
2049 action->rewrite->single_action_opt = true;
2051 action->rewrite->single_action_opt = false;
2052 ret = mlx5dr_ste_alloc_modify_hdr(action);
2070 struct mlx5dr_action *action;
2080 action = dr_action_create_generic(DR_ACTION_TYP_MODIFY_HDR);
2081 if (!action)
2084 action->rewrite->dmn = dmn;
2089 action);
2091 mlx5dr_dbg(dmn, "Failed creating modify header action %d\n", ret);
2095 return action;
2098 kfree(action);
2111 struct mlx5dr_action *action;
2135 action = dr_action_create_generic(DR_ACTION_TYP_VPORT);
2136 if (!action)
2139 action->vport->dmn = vport_dmn;
2140 action->vport->caps = vport_cap;
2142 return action;
2150 struct mlx5dr_action *action;
2158 action = dr_action_create_generic(DR_ACTION_TYP_ASO_FLOW_METER);
2159 if (!action)
2162 action->aso->obj_id = obj_id;
2163 action->aso->offset = meter_id;
2164 action->aso->dest_reg_id = dest_reg_id;
2165 action->aso->init_color = init_color;
2166 action->aso->dmn = dmn;
2170 return action;
2173 u32 mlx5dr_action_get_pkt_reformat_id(struct mlx5dr_action *action)
2175 return action->reformat->id;
2178 int mlx5dr_action_destroy(struct mlx5dr_action *action)
2180 if (WARN_ON_ONCE(refcount_read(&action->refcount) > 1))
2183 switch (action->action_type) {
2185 if (action->dest_tbl->is_fw_tbl)
2186 refcount_dec(&action->dest_tbl->fw_tbl.dmn->refcount);
2188 refcount_dec(&action->dest_tbl->tbl->refcount);
2190 if (action->dest_tbl->is_fw_tbl &&
2191 action->dest_tbl->fw_tbl.num_of_ref_actions) {
2195 ref_actions = action->dest_tbl->fw_tbl.ref_actions;
2196 for (i = 0; i < action->dest_tbl->fw_tbl.num_of_ref_actions; i++)
2201 mlx5dr_fw_destroy_md_tbl(action->dest_tbl->fw_tbl.dmn,
2202 action->dest_tbl->fw_tbl.id,
2203 action->dest_tbl->fw_tbl.group_id);
2208 refcount_dec(&action->reformat->dmn->refcount);
2211 mlx5dr_ste_free_modify_hdr(action);
2212 kfree(action->rewrite->data);
2213 refcount_dec(&action->rewrite->dmn->refcount);
2218 mlx5dr_cmd_destroy_reformat_ctx((action->reformat->dmn)->mdev,
2219 action->reformat->id);
2220 refcount_dec(&action->reformat->dmn->refcount);
2223 if (!action->rewrite->single_action_opt)
2224 mlx5dr_ste_free_modify_hdr(action);
2225 kfree(action->rewrite->data);
2226 refcount_dec(&action->rewrite->dmn->refcount);
2229 refcount_dec(&action->sampler->dmn->refcount);
2232 refcount_dec(&action->aso->dmn->refcount);
2235 dr_action_destroy_range_definer(action);
2236 mlx5dr_action_destroy(action->range->miss_tbl_action);
2237 mlx5dr_action_destroy(action->range->hit_tbl_action);
2243 kfree(action);